kacky-gbx-parser 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/Classes/Game/CGameCtnBlock.d.ts +16 -0
  2. package/dist/Classes/Game/CGameCtnBlock.d.ts.map +1 -0
  3. package/dist/Classes/Game/CGameCtnBlockSkin.d.ts +28 -0
  4. package/dist/Classes/Game/CGameCtnBlockSkin.d.ts.map +1 -0
  5. package/dist/Classes/Game/CGameCtnChallenge.d.ts +329 -0
  6. package/dist/Classes/Game/CGameCtnChallenge.d.ts.map +1 -0
  7. package/dist/Classes/Game/CGameCtnChallengeParameters.d.ts +72 -0
  8. package/dist/Classes/Game/CGameCtnChallengeParameters.d.ts.map +1 -0
  9. package/dist/Classes/Game/CGameCtnCollectorList.d.ts +16 -0
  10. package/dist/Classes/Game/CGameCtnCollectorList.d.ts.map +1 -0
  11. package/dist/Classes/Game/CGameCtnGhost.d.ts +170 -0
  12. package/dist/Classes/Game/CGameCtnGhost.d.ts.map +1 -0
  13. package/dist/Classes/Game/CGameCtnMediaBlock.d.ts +7 -0
  14. package/dist/Classes/Game/CGameCtnMediaBlock.d.ts.map +1 -0
  15. package/dist/Classes/Game/CGameCtnMediaBlockTriangles.d.ts +7 -0
  16. package/dist/Classes/Game/CGameCtnMediaBlockTriangles.d.ts.map +1 -0
  17. package/dist/Classes/Game/CGameCtnMediaClip.d.ts +13 -0
  18. package/dist/Classes/Game/CGameCtnMediaClip.d.ts.map +1 -0
  19. package/dist/Classes/Game/CGameCtnMediaTrack.d.ts +11 -0
  20. package/dist/Classes/Game/CGameCtnMediaTrack.d.ts.map +1 -0
  21. package/dist/Classes/Game/CGameCtnReplayRecord.d.ts +127 -0
  22. package/dist/Classes/Game/CGameCtnReplayRecord.d.ts.map +1 -0
  23. package/dist/Classes/Game/CGameGhost.d.ts +71 -0
  24. package/dist/Classes/Game/CGameGhost.d.ts.map +1 -0
  25. package/dist/Classes/Game/CGameWaypointSpecialProperty.d.ts +11 -0
  26. package/dist/Classes/Game/CGameWaypointSpecialProperty.d.ts.map +1 -0
  27. package/dist/Classes/Game/index.d.ts +15 -0
  28. package/dist/Classes/Game/index.d.ts.map +1 -0
  29. package/dist/Classes/Node.d.ts +9 -0
  30. package/dist/Classes/Node.d.ts.map +1 -0
  31. package/dist/Classes/Plug/CPlugEntRecordData.d.ts +15 -0
  32. package/dist/Classes/Plug/CPlugEntRecordData.d.ts.map +1 -0
  33. package/dist/Classes/Plug/index.d.ts +3 -0
  34. package/dist/Classes/Plug/index.d.ts.map +1 -0
  35. package/dist/Classes/Utilities/GameVersion.d.ts +30 -0
  36. package/dist/Classes/Utilities/GameVersion.d.ts.map +1 -0
  37. package/dist/Data/ClassWrap.d.ts +4 -0
  38. package/dist/Data/ClassWrap.d.ts.map +1 -0
  39. package/dist/Data/CollectionIDs.d.ts +5 -0
  40. package/dist/Data/CollectionIDs.d.ts.map +1 -0
  41. package/dist/Data/NodeTypes.d.ts +6 -0
  42. package/dist/Data/NodeTypes.d.ts.map +1 -0
  43. package/dist/Functions/Utils.d.ts +35 -0
  44. package/dist/Functions/Utils.d.ts.map +1 -0
  45. package/dist/GBX.d.ts +16 -0
  46. package/dist/GBX.d.ts.map +1 -0
  47. package/dist/GBXReader.d.ts +32 -0
  48. package/dist/GBXReader.d.ts.map +1 -0
  49. package/dist/Handlers/DataStream.d.ts +153 -0
  50. package/dist/Handlers/DataStream.d.ts.map +1 -0
  51. package/dist/Handlers/Hex.d.ts +12 -0
  52. package/dist/Handlers/Hex.d.ts.map +1 -0
  53. package/dist/Handlers/LZOHandler.d.ts +15 -0
  54. package/dist/Handlers/LZOHandler.d.ts.map +1 -0
  55. package/dist/Handlers/Logger.d.ts +42 -0
  56. package/dist/Handlers/Logger.d.ts.map +1 -0
  57. package/dist/Handlers/Merger.d.ts +27 -0
  58. package/dist/Handlers/Merger.d.ts.map +1 -0
  59. package/dist/Handlers/ZLibHandler.d.ts +15 -0
  60. package/dist/Handlers/ZLibHandler.d.ts.map +1 -0
  61. package/dist/Handlers/index.d.ts +8 -0
  62. package/dist/Handlers/index.d.ts.map +1 -0
  63. package/dist/gbx.js +1 -0
  64. package/dist/index.cjs +1 -0
  65. package/dist/index.d.ts +8 -0
  66. package/dist/index.d.ts.map +1 -0
  67. package/dist/index.js +1 -0
  68. package/dist/index.mjs +1 -0
  69. package/dist/types.d.ts +93 -0
  70. package/dist/types.d.ts.map +1 -0
  71. package/package.json +63 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataStream.d.ts","sourceRoot":"","sources":["../../src/Handlers/DataStream.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAU;IAC9B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,QAAQ,CAAa;gBAEjB,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC;IAI1C;;OAEG;IACH,IAAW,cAAc,IAAI,MAAM,CAElC;IAED;;;;;OAKG;IACI,WAAW,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,CAAC,GAAG,CAAC,EAAE;IAI1E;;;OAGG;IACI,QAAQ,CAAC,MAAM,SAAI,GAAG,MAAM;IAKnC;;;OAGG;IACI,QAAQ,IAAI,MAAM;IAMzB;;;;OAIG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAIzC;;;;OAIG;IACI,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAIzC;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAIrB;;;;OAIG;IACI,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIzC;;;;OAIG;IACI,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM;IAIzC;;;OAGG;IACI,SAAS,IAAI,MAAM;IAY1B;;;OAGG;IACI,UAAU,IAAI,MAAM;IAI3B;;;OAGG;IACI,UAAU,IAAI,MAAM;IAI3B;;;OAGG;IACI,UAAU,IAAI,MAAM;IAI3B;;;OAGG;IACI,UAAU,IAAI,MAAM;IAI3B;;;OAGG;IACI,WAAW,IAAI,OAAO;IAI7B;;;;OAIG;IACI,UAAU,CAAC,KAAK,SAAI,GAAG,MAAM;IAMpC;;;OAGG;IACI,QAAQ,IAAI,MAAM;IAIzB;;;OAGG;IACI,QAAQ,IAAI,IAAI;IAIvB;;;OAGG;IACI,QAAQ,IAAI,IAAI;IAIvB;;;OAGG;IACI,WAAW,IAAI,OAAO;IAI7B;;;OAGG;IACI,WAAW,IAAI,OAAO;IAI7B;;;OAGG;IACI,SAAS,IAAI,KAAK;IAIzB;;;OAGG;IACI,QAAQ,IAAI,KAAK;IAQxB;;;OAGG;IACI,iBAAiB,IAAI,MAAM;IAYlC,OAAO,CAAC,QAAQ,CAAa;IAE7B;;OAEG;IACI,iBAAiB,CAAC,QAAQ,KAAK,QAAQ,GAAG,SAAS;IA0B1D,OAAO,CAAC,eAAe,CAAC,CAAS;IACjC,OAAO,CAAC,eAAe,CAAgB;IAEvC;;;OAGG;IACI,kBAAkB,IAAI,MAAM;IAkCnC;;;OAGG;IACI,cAAc,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;CAsBhD"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Handles hexadecimal numbers.
3
+ */
4
+ export default class Hex {
5
+ /**
6
+ * Converts a decimal number to a hexadecimal string.
7
+ * @param decimal The decimal number to convert.
8
+ * @returns A hexadecimal string.
9
+ */
10
+ static fromDecimal(decimal: number): string;
11
+ }
12
+ //# sourceMappingURL=Hex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Hex.d.ts","sourceRoot":"","sources":["../../src/Handlers/Hex.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,GAAG;IACvB;;;;OAIG;WACW,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAGlD"}
@@ -0,0 +1,15 @@
1
+ export default class LZOHandler {
2
+ /**
3
+ * Compresses data using LZO.
4
+ * @param data The data to compress.
5
+ * @returns The compressed data as Buffer.
6
+ */
7
+ static compress(data: Array<number>): Promise<number[]>;
8
+ /**
9
+ * Decompresses data using LZO.
10
+ * @param data The data to decompress.
11
+ * @returns The decompressed data as Buffer.
12
+ */
13
+ static decompress(data: Array<number>): Promise<number[]>;
14
+ }
15
+ //# sourceMappingURL=LZOHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LZOHandler.d.ts","sourceRoot":"","sources":["../../src/Handlers/LZOHandler.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,OAAO,OAAO,UAAU;IAC9B;;;;OAIG;WACU,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAU7D;;;;OAIG;WACU,UAAU,CAAC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;CAS/D"}
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Handles logging.
3
+ */
4
+ export default class Logger {
5
+ static showLogs: boolean;
6
+ static showDebug: boolean;
7
+ static showWarns: boolean;
8
+ static reset: string;
9
+ /**
10
+ * Highlights the given text with the specified color.
11
+ * @param text The text to highlight.
12
+ * @param colorCode The color code to use.
13
+ * @returns The highlighted text.
14
+ */
15
+ private static highlight;
16
+ /**
17
+ * Logs the given arguments to the console with the info prefix.
18
+ * @param args The arguments to log.
19
+ */
20
+ static log(...args: any[]): void;
21
+ /**
22
+ * Logs the given arguments to the console with the debug prefix.
23
+ * @param args The arguments to log.
24
+ */
25
+ static debug(...args: any[]): void;
26
+ /**
27
+ * Logs the given arguments to the console with the warn prefix.
28
+ * @param args The arguments to log.
29
+ */
30
+ static warn(...args: any[]): void;
31
+ /**
32
+ * Logs the given arguments to the console with the error prefix.
33
+ * @param args The arguments to log.
34
+ */
35
+ static error(...args: any[]): void;
36
+ /**
37
+ * Logs the given arguments to the console in a visible way.
38
+ * @param args The arguments to log.
39
+ */
40
+ static outline(...args: any[]): void;
41
+ }
42
+ //# sourceMappingURL=Logger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/Handlers/Logger.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAM;IAC1B,MAAM,CAAC,QAAQ,EAAE,OAAO,CAAS;IACjC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAS;IAClC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAS;IAElC,MAAM,CAAC,KAAK,SAAa;IAEzB;;;;;OAKG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAKxB;;;OAGG;WACW,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAKvC;;;OAGG;WACW,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAKzC;;;OAGG;WACW,IAAI,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAKxC;;;OAGG;WACW,KAAK,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;IAIzC;;;OAGG;WACW,OAAO,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI;CAG3C"}
@@ -0,0 +1,27 @@
1
+ interface ChunkList {
2
+ [key: number]: {
3
+ unknowns: any[];
4
+ version: any;
5
+ } | null;
6
+ }
7
+ export default class Merger {
8
+ /**
9
+ * Merge unknowns and versions into an object of chunks.
10
+ * @param chunks A list of chunks.
11
+ * @param unknowns An object of unknowns.
12
+ * @param versions An object of versions.
13
+ * @returns combined chunks.
14
+ */
15
+ static mergeChunks(chunks: {
16
+ [x: number]: boolean;
17
+ }, unknowns: Unknowns, versions: Versions): ChunkList;
18
+ /**
19
+ * Destructively merge two instances of the same class.
20
+ * @param target Instance to merge into.
21
+ * @param source Instance to merge from.
22
+ * @returns Merged instance.
23
+ */
24
+ static mergeInstances<NodeType>(target: NodeType, source: NodeType): NodeType;
25
+ }
26
+ export {};
27
+ //# sourceMappingURL=Merger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Merger.d.ts","sourceRoot":"","sources":["../../src/Handlers/Merger.ts"],"names":[],"mappings":"AAAA,UAAU,SAAS;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG;QACd,QAAQ,EAAE,GAAG,EAAE,CAAC;QAChB,OAAO,EAAE,GAAG,CAAC;KACb,GAAG,IAAI,CAAC;CACT;AAED,MAAM,CAAC,OAAO,OAAO,MAAM;IAC1B;;;;;;OAMG;IACH,MAAM,CAAC,WAAW,CACjB,MAAM,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,EAChC,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,QAAQ,GAChB,SAAS;IAoBZ;;;;;OAKG;IACH,MAAM,CAAC,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,GAAG,QAAQ;CAU7E"}
@@ -0,0 +1,15 @@
1
+ export default class ZLibHandler {
2
+ /**
3
+ * Compresses data using ZLib (deflate).
4
+ * @param data The data to compress.
5
+ * @returns The compressed data.
6
+ */
7
+ static compress(data: Uint8Array | number[]): Promise<Uint8Array>;
8
+ /**
9
+ * Decompresses data using ZLib (inflate).
10
+ * @param data The data to decompress.
11
+ * @returns The decompressed data.
12
+ */
13
+ static decompress(data: Uint8Array | number[]): Promise<Uint8Array>;
14
+ }
15
+ //# sourceMappingURL=ZLibHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZLibHandler.d.ts","sourceRoot":"","sources":["../../src/Handlers/ZLibHandler.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,OAAO,OAAO,WAAW;IAC/B;;;;OAIG;WACU,QAAQ,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;IAUvE;;;;OAIG;WACU,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,GAAG,OAAO,CAAC,UAAU,CAAC;CASzE"}
@@ -0,0 +1,8 @@
1
+ import DataStream from './DataStream';
2
+ import Hex from './Hex';
3
+ import Logger from './Logger';
4
+ import LZOHandler from './LZOHandler';
5
+ import ZLibHandler from './ZLibHandler';
6
+ import Merger from './Merger';
7
+ export { DataStream, Hex, Logger, LZOHandler, ZLibHandler, Merger };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Handlers/index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,GAAG,MAAM,OAAO,CAAC;AACxB,OAAO,MAAM,MAAM,UAAU,CAAC;AAC9B,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,WAAW,MAAM,eAAe,CAAC;AACxC,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC"}
package/dist/gbx.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var gbx=(()=>{var ne=Object.create;var z=Object.defineProperty;var ie=Object.getOwnPropertyDescriptor;var se=Object.getOwnPropertyNames;var oe=Object.getPrototypeOf,re=Object.prototype.hasOwnProperty;var o=(r,e)=>z(r,"name",{value:e,configurable:!0}),Y=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(e,t)=>(typeof require<"u"?require:e)[t]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var ae=(r,e)=>{for(var t in e)z(r,t,{get:e[t],enumerable:!0})},_=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of se(e))!re.call(r,s)&&s!==t&&z(r,s,{get:()=>e[s],enumerable:!(n=ie(e,s))||n.enumerable});return r};var J=(r,e,t)=>(t=r!=null?ne(oe(r)):{},_(e||!r||!r.__esModule?z(t,"default",{value:r,enumerable:!0}):t,r)),ce=r=>_(z({},"__esModule",{value:!0}),r);var de={};ae(de,{CGameCtnBlock:()=>R,CGameCtnBlockSkin:()=>G,CGameCtnChallenge:()=>v,CGameCtnChallengeParameters:()=>T,CGameCtnCollectorList:()=>S,CGameCtnGhost:()=>g,CGameCtnMediaBlock:()=>I,CGameCtnMediaClip:()=>P,CGameCtnMediaTrack:()=>N,CGameCtnReplayRecord:()=>L,CGameGhost:()=>F,CGameWaypointSpecialProperty:()=>M,CPlugEntRecordData:()=>A,GBX:()=>B,Utils:()=>K,ZLibHandler:()=>D});var O={554172416:50606080,554225664:50933760,603992064:50606080,604028928:50704384,604090368:50929664,604217344:50696192,604225536:50442240,604237824:50933760,604377088:50823168,604381184:50823168,604463104:50827264,604495872:50933760,50638848:50499584};var R=class{static{o(this,"CGameCtnBlock")}author;blockName;direction;flags;position;skin;waypointSpecialProperty};var d=class{static{o(this,"Node")}chunks={}};var G=class extends d{static{o(this,"CGameCtnBlockSkin")}foregroundPackDesc;packDesc;parentPackDesc;text;50696192=({r:e},t)=>{this.text=e.n(),t.t(e.n())};50696193=({r:e})=>{this.text=e.n(),this.packDesc=e.d()};50696194=({r:e})=>{this.text=e.n(),this.packDesc=e.d(),this.parentPackDesc=e.d()};50696195=({r:e},t)=>{t.i(e.e()),this.foregroundPackDesc=e.d()}};var y=class extends d{static{o(this,"GameVersion")}f(e){return Object.keys(e).map(t=>parseInt(t,10))}isTM2020(){let e=this.f(this.chunks),t=e.some(i=>i>50606169&&i<=50610175),n=e.some(i=>i>50929704&&i<=50933759),s=e.some(i=>i>50933798&&i<=50937855);return t||n||s}isManiaPlanet(){let e=this.f(this.chunks),t=e.some(i=>i>50606122&&i<=50610175),n=e.some(i=>i>50929689&&i<=50933759),s=e.some(i=>i>50933781&&i<=50937855);return t||n||s}isTurbo(){let e=this.f(this.chunks),t=this.chunks[50606144]?.version>2&&!e.some(i=>i>50606165&&i<=50610175),n=e.some(i=>i==50929664)&&!e.some(i=>i>50929703&&i<=50933759),s=e.some(i=>i>50933793)&&!e.some(i=>i>50933795&&i<=50937855);return t||n||s}isTMF(){let e=this.f(this.chunks),t=e.some(i=>i>=50606080)&&!e.some(i=>i>50606122&&i<=50610175),n=e.some(i=>i>=50929664)&&!e.some(i=>i>50929689),s=e.some(i=>i>=50933760)&&!e.some(i=>i>50933781);return t||n||s}};var v=class extends y{static{o(this,"CGameCtnChallenge")}authorExtraInfo;authorLogin;authorNickname;authorScore;authorTime;authorVersion;authorZone;blocks;blockStock;bronzeTime;buildVersion;challengeParameters;checkpoints;comments;cost;crc32;createdWithSimpleEditor;customMusicPackDesc;dayDuration;dayTime;decoBaseHeightOffset;decoration;dynamicDaylight;editorMode;goldTime;hasCustomCamThumbnail;hashedPassword;headerVersion;isLapRace;isMultilap;lightmapCacheUid;lightmapVersion;mapCoordOrigin;mapCoordTarget;mapInfo;mapKind;mapName;mapStyle;mapType;modPackDesc;nbCheckpoints;nbLaps;needUnlock;objectiveTextAuthor;objectiveTextBronze;objectiveTextGold;objectiveTextSilver;offzones;offzoneTriggerSize;packMask;password;playerModel;playMode;silverTime;size;thumbnailData;thumbnailFarClipPlane;thumbnailFov;thumbnailNearClipPlane;thumbnailPitchYawRoll;thumbnailPosition;thumbnailSize;titleId;unlimiter;worldDistortion;xml;50606082=({r:e},t)=>{let n=t.i(e.s());n<=2&&(this.mapInfo=e.u(),this.mapName=e.n()),t.t(e.a()),n>=1&&(this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e()),n==2&&t.t(e.s()),n>=4&&(this.cost=e.e()),n>=5&&(this.isLapRace=e.a()),n==6&&(this.isMultilap=e.a()),n>=7&&(this.playMode=e.e()),n>=9&&t.t(e.e()),n>=10&&(this.authorScore=e.e()),n>=11&&(this.editorMode=e.e()),n>=12&&t.t(e.e()),n>=13&&(this.nbCheckpoints=e.e(),this.nbLaps=e.e())};50606083=({r:e},t)=>{let n=t.i(e.s());this.mapInfo=e.u(),this.mapName=e.n(),this.mapKind=e.s(),n>=1&&(t.t(e.e()),this.password=e.n()),n>=2&&(this.decoration=e.u()),n>=3&&(this.mapCoordOrigin=e.k()),n>=4&&(this.mapCoordTarget=e.k()),n>=5&&(this.packMask=e.h(16)),n>=6&&(this.mapType=e.n(),this.mapStyle=e.n()),n>=8&&(this.lightmapCacheUid=e.h(8)),n>=9&&(this.lightmapVersion=e.s()),n>=11&&(this.titleId=e.c())};50606084=({r:e})=>{this.headerVersion=e.e()};50606085=({r:e})=>{this.xml=e.n()};50606087=({r:e},t)=>{t.i(e.e()),this.thumbnailSize=e.e(),e.n(15),this.thumbnailData=e.p(this.thumbnailSize),e.n(16),e.n(10),this.comments=e.n(),e.n(11)};50606088=({r:e},t)=>{t.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50606093=({r:e})=>{this.playerModel=e.u()};50606095=({r:e})=>{this.mapInfo=e.u(),this.size=e.b(),this.blocks=e.createArray(e.e(),()=>e.l()),this.needUnlock=e.a(),this.decoration=e.u()};50606097=({r:e})=>{this.blockStock=e.l(),this.challengeParameters=e.l(),this.mapKind=e.e()};50606099=({r:e},t)=>{this.mapInfo=e.u(),this.mapName=e.n(),this.decoration=e.u(),this.size=e.b(),t.t(e.a()),this.blocks=e.createArray(e.e(),()=>{let n=e.c(),s=e.s(),i=e.G(),a=e.C();return{blockName:n,direction:s,position:i,flags:a}})};50606100=({r:e},t)=>{t.t(e.a()),this.password=e.n()};50606102=({r:e},t)=>{t.t(e.e())};50606103=({r:e})=>{this.checkpoints=e.createArray(e.e(),()=>e.b())};50606104=({r:e})=>{this.isLapRace=e.a(),this.nbLaps=e.e()};50606105=({r:e})=>{this.modPackDesc=e.d()};50606106=({r:e},t)=>{t.t(e.l())};50606107=({r:e},t)=>{if(t.t(e.e())!=0)throw new Error("Unexpected value SOldIgs > 0 in chunk 0x0304301b")};50606108=({r:e})=>{this.playMode=e.e()};50606109=({r:e},t)=>{t.t(e.e())};50606111=({r:e},t)=>{this.blocks=[],this.mapInfo=e.u(),this.mapName=e.n(),this.decoration=e.u(),this.size=e.b(),this.needUnlock=e.a();let n=t.i(e.e()),s=e.e(),i=o(()=>{let a=e.c(),c=e.s(),u=e.G(),l=0;n>0?l=e.e():l=e.C();let b,C,k;if(l&32768&&(b=e.c(),C=e.l()),n<=1)return!1;if(n>=6&&(u.x-=1,u.z-=1),l&1<<19)throw new Error("Parsin not possible.");if(l&1<<20&&(k=e.l()),l&1<<18){let X=e.e(),q=[];for(let Z=0;Z<X;Z++){var W=q[Z];e.h(4),e.h(4);let te=e.e();for(let j=0;j<te;j++)W[j]=(e.c(),e.c(),e.c())}}if(l&1<<17){let X=e.c(),q=e.h(4),Z=e.h(4)}return this.blocks?.push({blockName:a,direction:c,position:u,flags:l,author:b,skin:C,waypointSpecialProperty:k}),!0},"readBlock");for(let a=0;a<s;a++)i();for(;(e.peekUInt32()&3221225472)>0;)i()};50606112=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606113=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606114=({r:e},t)=>{t.t(e.e())};50606115=({r:e})=>{this.mapCoordOrigin=e.k(),this.mapCoordTarget=this.mapCoordOrigin};50606116=({r:e})=>{this.customMusicPackDesc=e.d()};50606117=({r:e})=>{this.mapCoordOrigin=e.k(),this.mapCoordTarget=e.k()};50606118=({r:e},t)=>{t.t(e.l())};50606119=({r:e},t)=>{this.hasCustomCamThumbnail=e.a(),this.hasCustomCamThumbnail&&(t.t(e.s()),t.t(e.m()),t.t(e.m()),t.t(e.m()),this.thumbnailPosition=e.m(),this.thumbnailFov=e.o(),this.thumbnailNearClipPlane=e.o(),this.thumbnailFarClipPlane=e.o())};50606120=(e,t)=>{this[50606119](e,t);let{r:n}=e;this.comments=n.n()};50606121=({r:e})=>{this.hashedPassword=e.p(16),this.crc32=e.e()};50606122=({r:e})=>{this.createdWithSimpleEditor=e.a()};50606125=({r:e},t)=>{this.thumbnailPosition=e.m(),this.thumbnailPitchYawRoll=e.m(),this.thumbnailFov=e.o(),t.t(e.o()),t.t(e.o()),this.thumbnailNearClipPlane=e.o(),this.thumbnailFarClipPlane=e.o(),this.comments=e.n()};50606132=({r:e})=>{let t=e.e();e.p(t)};50606134=(e,t)=>{this[50606125](e,t)};50606144=({r:e,length:t},n)=>{n.i(e.e()),e.p(t-4)};50606146=({r:e},t)=>{t.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50606151=({r:e},t)=>{let n=t.i(e.e());if(t.t(e.n()),n>=1)throw new Error("Unexpected version >= 1 in chunk 0x03043047")};50606153=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606155=({r:e})=>{this.objectiveTextAuthor=e.n(),this.objectiveTextGold=e.n(),this.objectiveTextSilver=e.n(),this.objectiveTextBronze=e.n()};50606160=({r:e},t)=>{t.i(e.e()),this.offzoneTriggerSize=[e.e(),e.e(),e.e()],this.offzones=e.createArray(e.e(),()=>({1:e.b(),2:e.b()}))};50606161=({r:e},t)=>{t.i(e.e()),this.titleId=e.c(),this.buildVersion=e.n()};50606162=({r:e},t)=>{t.i(e.e()),this.decoBaseHeightOffset=e.e()};50606166=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.dayTime=e.e(),t.t(e.e()),this.dynamicDaylight=e.a(),this.dayDuration=e.e()};50606168=({r:e},t)=>{if(t.i(e.e()),t.t(e.e())>0)throw new Error("Unexpected value > 0 in chunk 0x03043058")};50606169=({r:e},t)=>{let n=t.i(e.e());if(this.worldDistortion=e.m(),n==0)throw new Error("Unexpected version 0 in chunk 0x03043059");if(n>=1&&t.t(e.a()))throw new Error("Unexpected value true in chunk 0x03043059");n>=3&&(t.t(e.e()),t.t(e.e()))};50606170=({r:e},t)=>{t.t(e.e()),t.t(e.e())};50606187=({r:e},t)=>{t.t(e.e()),this.dayTime=e.e(),t.t(e.e()),this.dynamicDaylight=e.a(),this.dayDuration=e.e()};50606165=({r:e},t)=>{let n=t.t(e.s());switch(this.unlimiter=-1,n){case 1:this.unlimiter=1.1;break;case 2:this.unlimiter=1.2;break}e.forceChunkSkip(50606165)};1056968704=({r:e},t)=>{this.unlimiter=1.3,e.forceChunkSkip(1056968704)};1056968705=({r:e},t)=>{let n=t.t(e.s());switch(this.unlimiter=-1,n){case 0:this.unlimiter=-1;break;case 1:this.unlimiter=.4;break;case 2:this.unlimiter=.6;break;case 3:this.unlimiter=.7;break;case 4:this.unlimiter=1.1;break;case 5:this.unlimiter=1.2;break;case 6:this.unlimiter=1.3;break;case 7:this.unlimiter=2;break}e.forceChunkSkip(1056968705)};1056968706=({r:e},t)=>{this.unlimiter=2,e.forceChunkSkip(1056968706)};1056968707=({r:e},t)=>{this.unlimiter=2,e.forceChunkSkip(1056968707)}};var T=class extends d{static{o(this,"CGameCtnChallengeParameters")}authorScore;authorTime;bronzeTime;goldTime;isValidatedForScriptModes;mapStyle;mapType;raceValidationGhost;silverTime;timeLimit;tip;tip1;tip2;tip3;tip4;50704384=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704385=({r:e})=>{this.tip1=e.n(),this.tip2=e.n(),this.tip3=e.n(),this.tip4=e.n()};50704386=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.o()),t.t(e.o()),t.t(e.o()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704387=({r:e},t)=>{t.t(e.e()),t.t(e.o()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704388=({r:e},t)=>{this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e(),t.t(e.e())};50704389=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e())};50704390=({r:e},t)=>{t.t(e.createArray(e.e(),()=>e.e()))};50704391=({r:e},t)=>{t.t(e.e())};50704392=({r:e})=>{this.timeLimit=e.e(),this.authorScore=e.e()};50704394=({r:e})=>{this.tip=e.n(),this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e(),this.timeLimit=e.e(),this.authorScore=e.e()};50704397=({r:e})=>{this.raceValidationGhost=e.l()};50704398=({r:e})=>{this.mapType=e.n(),this.mapStyle=e.n(),this.isValidatedForScriptModes=e.a()}};var S=class extends d{static{o(this,"CGameCtnCollectorList")}blockSet;50442240=({r:e})=>{this.blockSet=e.createArray(e.e(),()=>{let t=e.u(),n=e.e();return{blockModel:t,count:n}})}};var F=class extends y{static{o(this,"CGameGhost")}isReplaying;sampleData;sampleDataUncompressedSize;sampleRecords;sampleOffsets;sampleTimes;isFixedTimeStep;samplePeriod;sampleVersion;async decompressSampleData(){if(!this.sampleData||this.sampleData.length===0)return[];let e=await D.decompress(this.sampleData),t=new f(Array.from(e)),n=[];for(;t.bytesAvailable>=20;)try{let s={x:t.o(),y:t.o(),z:t.o()},i=t.C(),a=t.s(),c=t.s(),u=t.C(),l=t.s(),b=t.s();n.push({position:s,angle:i,axisHeading:a,axisPitch:c,speed:u,velHeading:l,velPitch:b})}catch{break}return this.sampleRecords=n,n}static speedToDisplaySpeed(e){return e===0?0:Math.exp(e/1e3)*1e3}50589699=({r:e})=>{let t=e.e();this.sampleData=e.p(t),this.sampleOffsets=e.createArray(e.e(),()=>e.e()),this.sampleTimes=e.createArray(e.e(),()=>e.e()),this.isFixedTimeStep=e.a(),this.samplePeriod=e.e(),this.sampleVersion=e.e()};50589700=({r:e},t)=>{t.t(e.e())};50589701=({r:e})=>{this.sampleDataUncompressedSize=e.e();let t=e.e();this.sampleData=e.p(t)};50589702=e=>{let{r:t}=e;this.isReplaying=t.a(),this[50589701](e)}};var g=class extends F{static{o(this,"CGameCtnGhost")}appearanceVersion;apperanceVersion;badge;checkpoints;controlEntries;controlNames;eventsDuration;ghostAvatarName;ghostClubTag;ghostLogin;ghostNickname;ghostTrigram;ghostUid;ghostZone;hasBadges;lightTrailColor;playerModel;raceTime;recordData;recordingContext;respawns;skinFile;skinPackDescs;steeringWheelSensitivity;stuntScore;validationChallengeUid;validationCpuKind;validationExeChecksum;validationExeVersion;validationOsKind;validationRaceSettings;validationTitleId;50929664=({r:e},t)=>{let n=e.e();n>=9&&(this.appearanceVersion=e.e()),this.playerModel=e.u(),this.lightTrailColor=e.m(),this.skinPackDescs=e.createArray(e.e(),()=>e.d()),this.hasBadges=e.a(),this.hasBadges&&(this.badge={},this.badge.version=e.e(),this.badge.color=[e.e(),e.e(),e.e()],this.badge.version==0&&(t.t(e.e()),t.t(e.n())),this.badge.stickers=e.createArray(e.e(),()=>{let s=e.n(),i=e.n();return{item1:s,item2:i}}),this.badge.layers=e.createArray(e.e(),()=>e.n())),(this.apperanceVersion??!1)&&t.t(e.n()),this.ghostNickname=e.n(),this.ghostAvatarName=e.n(),n>=2&&(this.recordingContext=e.n()),n>=4&&t.t(e.a()),n>=5&&(this.recordData=e.l(),t.t(e.createArray(e.e(),()=>e.e()))),n>=6&&(this.ghostTrigram=e.n()),n>=7&&(this.ghostZone=e.n()),n>=8&&(this.ghostClubTag=e.n())};50929667=({r:e})=>{this.playerModel=e.u(),this.skinFile=e.n(),this.ghostNickname=e.n()};50929668=({r:e})=>{let t=e.e();this.checkpoints=e.createArray(t,()=>{let n=e.e(),s=e.o();return{time:n,speed:s}})};50929669=({r:e})=>{this.raceTime=e.e()};50929670=({r:e},t)=>{this.playerModel=e.u(),this.skinFile=e.n(),t.t(e.e()),this.ghostNickname=e.n()};50929671=({r:e})=>{this.lightTrailColor=e.m()};50929672=({r:e})=>{this.respawns=e.e()};50929673=({r:e})=>{this.lightTrailColor=[e.e(),e.e(),e.e()]};50929674=({r:e})=>{this.stuntScore=e.e()};50929675=({r:e})=>{let t=e.e();this.checkpoints=e.createArray(t,()=>{let n=e.e(),s=e.e();return{time:n,stuntScore:s}})};50929676=({r:e},t)=>{t.t(e.e())};50929677=({r:e},t)=>{this.playerModel=e.u(),this.skinFile=e.n(),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),this.ghostNickname=e.n()};50929678=({r:e})=>{this.ghostUid=e.c()};50929679=({r:e})=>{this.ghostLogin=e.n()};50929680=({r:e})=>{this.validationChallengeUid=e.c()};50929681=({r:e},t)=>{if(this.eventsDuration=e.e(),this.eventsDuration==0)return;t.t(e.e()),this.controlNames=e.createArray(e.e(),()=>e.c());let n=e.e();t.t(e.e()),this.controlEntries=e.createArray(n,()=>{let s=e.e()-1e5,i=e.s(),a=e.e(),c=this.controlNames[i],u=["Steer","Gas","AccelerateReal","BrakeReal"].includes(c);return{name:c,time:s,value:a,analog:u}}),this.validationExeVersion=e.n(),this.validationExeChecksum=e.e(),this.validationOsKind=e.e(),this.validationCpuKind=e.e(),this.validationRaceSettings=e.n()};50929682=({r:e},t)=>{t.t(e.e()),t.t(e.h(16))};50929683=({r:e},t)=>{t.t(e.e()),t.t(e.e())};50929684=({r:e},t)=>{t.t(e.e())};50929685=({r:e})=>{this.ghostNickname=e.c()};50929687=({r:e})=>{this.skinPackDescs=e.createArray(e.e(),()=>e.d()),this.ghostNickname=e.n(),this.ghostAvatarName=e.n()};50929688=({r:e})=>{this.playerModel=e.u()};50929689=(e,t)=>{this[50929681](e,t);let{r:n}=e;this.eventsDuration!=0&&t.t(n.e())};50929690=({r:e},t)=>{t.t(e.e())};50929692=({r:e},t)=>{t.t(e.h(32))};50929699=({r:e},t)=>{let n=t.i(e.e());t.t(e.n()),t.t(e.e()),t.t(e.n()),t.t(e.e()),t.t(e.e()),t.t(e.n()),t.t(e.e()),t.t(e.n()),n>=2&&(t.t(e.s()),t.t(e.e()),t.t(e.e())),n>=3&&(t.t(e.s()),t.t(e.s()))};50929702=({r:e},t)=>{t.t(e.h(16))};50929704=({r:e},t)=>{(this.eventsDuration??!0)||(this.validationTitleId=e.n(),t.t(e.h(32)))}};var P=class{static{o(this,"CGameCtnMediaClip")}tracks;name;stopWhenLeave;stopWhenRespawn;localPlayerClipEntIndex;50827277=({r:e})=>{this.tracks=[];let t=e.e(),n=e.e();for(let a=0;a<n;a++){let c=e.l();this.tracks.push(c)}this.name=e.n(),this.stopWhenLeave=e.a();let s=e.e();this.stopWhenRespawn=e.a();let i=e.e();this.localPlayerClipEntIndex=e.e()}};var I=class extends d{static{o(this,"CGameCtnMediaBlock")}};var V=class{static{o(this,"CGameCtnMediaBlockTriangles")}50499585=({r:e})=>{let t=e.e(),n=[];for(let a=0;a<t;a++)n.push(e.o());t=e.e();let s=e.e();for(let a=0;a<t;a++)for(let c=0;c<s;c++){let u=e.m()}s=e.e();for(let a=0;a<s;a++){let c=e.m(),u=e.o()}let i=e.e();for(let a=0;a<i;a++){let c=e.e(),u=e.e(),l=e.e()}e.e(),e.e(),e.e(),e.o(),e.e(),e.h(8)}};var N=class{static{o(this,"CGameCtnMediaTrack")}name;blocks;keepPlaying;50823169=({r:e})=>{this.blocks=[];let t=e.n();e.e();let n=e.e();for(let i=0;i<n;i++){let a=e.l();this.blocks.push(a)}let s=e.e()};50823172=({r:e})=>{this.keepPlaying=e.a(),e.e()}};var L=class extends y{static{o(this,"CGameCtnReplayRecord")}authorExtraInfo;authorLogin;authorNickname;authorVersion;authorZone;challengeData;controlEntries;controlNames;eventsDuration;extras;game;ghosts;mapInfo;playerLogin;playerNickname;playgroundScript;recordData;time;titleId;xml;50933760=({r:e},t)=>{let n=t.i(e.e());n>=2&&(this.mapInfo=e.u(),this.time=e.e(),this.playerNickname=e.n()),n>=6&&(this.playerLogin=e.n()),n>=8&&(t.t(e.s()),this.titleId=e.c())};50933761=({r:e})=>{this.xml=e.n()};50933762=({r:e,isHeaderChunk:t},n)=>{if(t){n.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n();return}let s=e.e();this.challengeData=new B(e.p(s))};50933764=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.ghosts=e.createArray(e.e(),()=>e.l()),t.t(e.e()),t.t(e.e())};50933765=({r:e},t)=>{t.t(e.e())};50933767=({r:e},t)=>{t.t(e.e())};50933768=({r:e},t)=>{this.game=e.n(),t.t(e.e())};50933772=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933773=({r:e},t)=>{if(this.eventsDuration=e.e(),this.eventsDuration==0)return;t.t(e.e()),this.controlNames=e.createArray(e.e(),()=>e.c());let n=e.e();t.t(e.e()),this.controlEntries=e.createArray(n,()=>{let s=e.e()+1e5,i=e.s(),a=e.e(),c=this.controlNames[i],u=["Steer","Gas","AccelerateReal","BrakeReal"].includes(c);return{name:c,time:s,value:a,analog:u}})};50933774=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933775=({r:e},t)=>{this.game=e.n(),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.n())};50933776=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933780=({r:e},t)=>{t.i(e.e()),this.ghosts=e.createArray(e.e(),()=>e.l()),t.t(e.e()),this.extras=e.createArray(e.e(),()=>{let n=e.e(),s=e.e();return{extra1:n,extra2:s}})};50933781=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933784=({r:e})=>{this.titleId=e.c(),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50933787=({r:e},t)=>{t.i(e.e()),t.t(e.createArray(e.e(),()=>({1:e.e(),2:e.e()})))};50933788=({r:e},t)=>{t.i(e.e()),this.playgroundScript=e.n()};50933793=({r:e},t)=>{t.i(e.e()),t.t(e.a())};50933796=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.recordData=e.l()};50933797=({r:e},t)=>{t.i(e.e()),t.t(e.e()),t.t(e.e())}};var M=class extends d{static{o(this,"CGameWaypointSpecialProperty")}order;spawn;tag;771788800=({r:e},t)=>{let n=t.i(e.e());n==1?(this.spawn=e.e(),this.order=e.e()):n==2&&(this.tag=e.n(),this.order=e.e())}};var A=class extends d{static{o(this,"CPlugEntRecordData")}compressedData;compressedSize;uncompressedSize;152170496=({r:e},t)=>{t.i(e.e())>=5&&(this.uncompressedSize=e.e(),this.compressedSize=e.e(),this.compressedData=e.p(this.compressedSize))}};function H(r){return{50442240:S,50606080:v,50696192:G,50704384:T,50819072:I,50499584:V,50823168:N,50827264:P,50929664:g,50933760:L,152170496:A,771788800:M}[r]}o(H,"getNodeType");var E=class{constructor(e){this.options=e;Object.assign(this,e)}static{o(this,"GBXReader")}current;fullChunkId=0;versions={};unknowns={};i(e){return this.versions[this.fullChunkId]=e,e}t(e){return this.unknowns[this.fullChunkId]===void 0&&(this.unknowns[this.fullChunkId]=[]),this.unknowns[this.fullChunkId].push(e),e}v(){let e=this.options.stream,t={};for(;;){let n=e.e();if(n==4207599105)break;if(t[n]=!0,e.peekUInt32()==1397442896){let i=e.e(),a=e.e();if(!this.w(n,!1,a)){m.warn(`Skipped chunk: 0x${x.fromDecimal(n)}`);let u=e.p(a);t[n]=!1}continue}if(!this.w(n))throw new Error(`Failed processing unskippable chunk 0x${x.fromDecimal(n)}.`)}return this.current.chunks=w.mergeChunks(t,this.unknowns,this.versions),this.current}w(e,t=!1,n=0){let s=this.options.stream;this.fullChunkId=e;let i=this.options.classId,a=e&4294963200;i=O[i]??i,a=O[a]??a;let c=H(i),u=a+(e&4095);return c===void 0||(this.current===void 0&&(this.current=new c),this.current[u]===void 0)?!1:(m.debug(`Processing ${t?"header chunk":"chunk"}: 0x${x.fromDecimal(u)}`),this.current[u]({r:s,length:n,fullChunkId:e,isHeaderChunk:t},{i:this.i.bind(this),t:this.t.bind(this)}),!0)}T(e){let t=this.options.headerChunks,n={};for(let s=0;s<t.length;s++){let i=t[s],a=e+i.chunkId;this.options.stream=new f(i.chunkData),this.w(a,!0)||(m.warn(`Skipped chunk: 0x${x.fromDecimal(a)}`),n[a]=!1),n[a]=!0}return this.current.chunks=w.mergeChunks(n,this.unknowns,this.versions),this.current}};var $={0:"Desert",1:"Snow",2:"Rally",3:"Island",4:"Bay",5:"Coast",6:"Stadium",7:"Basic",8:"Plain",9:"Moon",10:"Toy",11:"Valley",12:"Canyon",13:"Lagoon",14:"Deprecated_Arena",17:"TMCommon",18:"Canyon4",19:"Canyon256",20:"Valley4",21:"Valley256",22:"Lagoon4",23:"Lagoon256",24:"Stadium4",25:"Stadium256",26:"Trackmania",100:"History",101:"Society",102:"Galaxy",200:"Gothic",201:"Paris",202:"Storm",203:"Cryo",204:"Meteor",205:"Meteor4",206:"Meteor256",299:"SMCommon",1e4:"Vehicles",10001:"Orbital",10002:"Actors",10003:"Common",4294967295:"Unassigned"};var pe=new TextDecoder,f=class{static{o(this,"DataStream")}stream;position=0;constructor(e){this.stream=e}get bytesAvailable(){return this.stream.length-this.position}createArray(e,t){return Array.from({length:e},(n,s)=>t(s))}peekByte(e=0){return this.stream[this.position+e]}s(){let e=this.peekByte();if(e===void 0)throw new Error("Attempted to read an undefined byte.");return this.position++,e}peekBytes(e){return this.createArray(e,t=>this.peekByte(t))}p(e){return this.createArray(e,()=>this.s())}bytesToNumber(e){return e.reduce((t,n,s)=>t|n<<s*8,0)}peekNumbers(e){return this.bytesToNumber(this.peekBytes(e))>>>0}h(e){return this.bytesToNumber(this.p(e))>>>0}o(){let e=this.bytesToNumber(this.p(4));if(e==0)return 0;let t=e>>>31?-1:1,n=(e>>>23&255)-127,s=e&8388607|8388608;return t*s*Math.pow(2,n-23)}peekUInt16(){return this.peekNumbers(2)}C(){return this.h(2)}peekUInt32(){return this.peekNumbers(4)}e(){return this.h(4)}a(){return!!this.h(4)}n(e=0){return e==0&&(e=this.h(4)),pe.decode(new Uint8Array(this.p(e)))}g(){return this.n(1)}S(){return{x:this.e(),y:this.e()}}b(){return{x:this.e(),y:this.e(),z:this.e()}}k(){return{x:this.o(),y:this.o()}}m(){return{x:this.o(),y:this.o(),z:this.o()}}G(){return{x:this.s(),y:this.s(),z:this.s()}}u(){return{id:this.c(),collection:this.c(),author:this.c()}}d(){let e=this.s();e>=3&&this.p(32);let t=this.n();return(t.length>0&&e>=1||e>=3)&&this.n(),t}nodeList=[];l(){let e=this.h(4)<<1>>1;if(e==-1)return;let t=this.nodeList[e]!==void 0;if(e>=0&&!t){let n=this.e(),s=new E({stream:this,classId:n}).v();return this.nodeList[e]=s,s}if(t)return this.nodeList[e];throw new Error("Invalid node reference")}lookbackVersion;lookbackStrings=[];c(){this.lookbackVersion===void 0&&(this.lookbackVersion=this.e());let e=new Uint32Array([this.e()])[0];if(e==4294967295)return"";if((e&16383)==0&&(e>>30==1||e>>30==-2)){let t=this.n();return this.lookbackStrings.push(t),t}if((e&16383)==16383)switch(e>>30){case 2:return"Unassigned";case 3:return"";default:throw new Error("Invalid lookback string, the file provided may be corrupt")}return e>>30==0?$[e]===void 0?"Unknown collection":$[e]:this.lookbackStrings.length>(e&16383)-1?this.lookbackStrings[(e&16383)-1]:""}forceChunkSkip(e){for(;;){let t=this.peekUInt32();if((t&4294967040)==(e&4294967040)){m.warn(`Force skipped chunk: 0x${x.fromDecimal(e)}`);break}if(t==4207599105&&this.peekByte(4)===void 0){m.warn(`Force skipped chunk: 0x${x.fromDecimal(e)}`),m.warn("Reached end of file early");break}let n=this.s()}}};var x=class{static{o(this,"Hex")}static fromDecimal(e){return e.toString(16)}};var m=class{static{o(this,"Logger")}static showLogs=!1;static showDebug=!1;static showWarns=!1;static reset="\x1B[0m";static highlight(e,t=35){return`${`\x1B[${t}m`}${e}${this.reset}`}static log(...e){this.showLogs&&console.log(this.highlight("[INFO]",34),...e)}static debug(...e){this.showDebug&&console.log(this.highlight("[DEBUG]",35),...e)}static warn(...e){this.showWarns&&console.warn(this.highlight("[WARN]",33),...e)}static error(...e){console.error(this.highlight("[ERROR]",31),...e)}static outline(...e){console.log(this.highlight("[DEVEL]",41),this.highlight(e[0],35),...e.slice(1))}};var le=typeof globalThis.LZO<"u";async function Q(){if(le)return globalThis.LZO;let{LZO:r}=await import("lzo-ts");return r}o(Q,"getLZO");var U=class{static{o(this,"LZOHandler")}static async compress(e){try{return(await Q()).compress(e)}catch(t){throw console.error("LZO compress error:",t),new Error("Failed to compress data, is the lzo-ts package installed?")}}static async decompress(e){try{return(await Q()).decompress(e)}catch(t){throw console.error("LZO decompress error:",t),new Error("Failed to decompress data, is the lzo-ts package installed?")}}};var me=typeof globalThis.ZLib<"u";async function ee(){return me?globalThis.ZLib:await import("pako")}o(ee,"getZLib");var D=class{static{o(this,"ZLibHandler")}static async compress(e){try{return(await ee()).deflate(new Uint8Array(e))}catch(t){throw console.error("ZLib compress error:",t),new Error("Failed to compress data, is the pako package installed?")}}static async decompress(e){try{return(await ee()).inflate(new Uint8Array(e))}catch(t){throw console.error("ZLib decompress error:",t),new Error("Failed to decompress data, is the pako package installed?")}}};var w=class{static{o(this,"Merger")}static mergeChunks(e,t,n){let s={};for(let i in e){if(e[i]===!1){s[i]=null;continue}s[i]={unknowns:t[i],version:n[i]}}return s}static mergeInstances(e,t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==void 0&&(e[n]=t[n]);return e}};var B=class{static{o(this,"GBX")}stream;classId;wrappedClassId;bodyCompression="C";constructor(e,t=2){t>=1&&(m.showWarns=!0),t>=2&&(m.showLogs=!0),t>=3&&(m.showDebug=!0),this.stream=new f(e)}async parseHeaders(){if(this.stream.n(3)!="GBX")return Promise.reject(new Error("Not a GBX file"));m.debug("Found GBX magic");let e=this.stream.C();if(e<3)return Promise.reject(new Error("Unsupported GBX version"));m.debug(`Reading GBX version ${e}`);let t=this.stream.g(),n=this.stream.g();this.bodyCompression=this.stream.g(),e>=4&&this.stream.g(),this.classId=this.stream.e(),this.wrappedClassId=O[this.classId],e>=6&&this.stream.e();let s=this.stream.e();if(s==0)return Promise.reject(new Error("No header chunks"));let i=[];for(let l=0;l<s;l++){let b=this.stream.e()&4095,C=this.stream.e()&2147483647,k=(C&2147483648)!=0;i.push({chunkId:b,chunkSize:C,isHeavy:k})}for(let l=0;l<s;l++)i[l].chunkData=this.stream.p(i[l].chunkSize);m.debug("Reading header data");let a=new E({headerChunks:i,classId:this.classId}).T(this.classId),c=this.stream.e();return this.stream.e()>0?Promise.reject(new Error("[Unimplemented] External nodes are not supported")):Promise.resolve(a)}async parse(){let e=await this.parseHeaders(),t;if(this.bodyCompression==="C"){let s=this.stream.e(),i=this.stream.e(),a=this.stream.p(i);m.debug(`Decompressing body: ${i} -> ${s} bytes`),t=new f(await U.decompress(a))}else{m.debug("Reading uncompressed body");let s=this.stream.p(this.stream.bytesAvailable);t=new f(s)}m.debug("Reading body data");let n=new E({stream:t,classId:this.classId}).v();return Promise.resolve(w.mergeInstances(e,n))}};var K;(a=>{function r(c){if(c instanceof g)return c.checkpoints?.length||void 0;let u=c.chunks?.[50606111]?.version,l=new Set,b=0;if(u>=6)c.blocks?.forEach(C=>{let k=C.waypointSpecialProperty;if(k?.order!==void 0&&(k?.tag=="Checkpoint"&&b++,k?.tag=="LinkedCheckpoint")){if(l.has(k.order))return;b++,l.add(k.order)}});else return c.checkpoints?.length||void 0;if(c.blocks!==void 0)return c.nbCheckpoints&&b<c.nbCheckpoints?(m.warn("The amount of checkpoints doesn't match the amount of checkpoints in the header. Returning amount of header."),c.nbCheckpoints):b}a.getCheckpointCount=r,o(r,"getCheckpointCount");function e(c){return c.controlEntries?.filter(u=>u?.name=="Respawn"&&u?.value==1)}o(e,"getRespawns");function t(c){return e(c)?.length}a.getRespawnsCount=t,o(t,"getRespawnsCount");function n(c){return c.checkpoints?.map(u=>u.time)}a.getCheckpointTimes=n,o(n,"getCheckpointTimes");function s(c){let u=n(c),l=e(c);if(u===void 0||l===void 0)return;let b=u.map(()=>0),C=0;for(let k of l){let W=u[C];k.time>=W&&C++,b[C]++}return b}a.getRespawnsByCheckpoint=s,o(s,"getRespawnsByCheckpoint");function i(c){let u=n(c);if(u!==void 0)return u.map((l,b,C)=>{let k=C[b-1]||0;return l-k})}a.getSectorTimes=i,o(i,"getSectorTimes")})(K||={});return ce(de);})();
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";var te=Object.create;var z=Object.defineProperty;var ne=Object.getOwnPropertyDescriptor;var ie=Object.getOwnPropertyNames;var se=Object.getPrototypeOf,oe=Object.prototype.hasOwnProperty;var o=(a,e)=>z(a,"name",{value:e,configurable:!0});var re=(a,e)=>{for(var t in e)z(a,t,{get:e[t],enumerable:!0})},Y=(a,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of ie(e))!oe.call(a,s)&&s!==t&&z(a,s,{get:()=>e[s],enumerable:!(n=ne(e,s))||n.enumerable});return a};var _=(a,e,t)=>(t=a!=null?te(se(a)):{},Y(e||!a||!a.__esModule?z(t,"default",{value:a,enumerable:!0}):t,a)),ae=a=>Y(z({},"__esModule",{value:!0}),a);var me={};re(me,{CGameCtnBlock:()=>R,CGameCtnBlockSkin:()=>G,CGameCtnChallenge:()=>v,CGameCtnChallengeParameters:()=>S,CGameCtnCollectorList:()=>T,CGameCtnGhost:()=>g,CGameCtnMediaBlock:()=>I,CGameCtnMediaClip:()=>D,CGameCtnMediaTrack:()=>N,CGameCtnReplayRecord:()=>L,CGameGhost:()=>F,CGameWaypointSpecialProperty:()=>M,CPlugEntRecordData:()=>A,GBX:()=>E,Utils:()=>K,ZLibHandler:()=>P});module.exports=ae(me);var O={554172416:50606080,554225664:50933760,603992064:50606080,604028928:50704384,604090368:50929664,604217344:50696192,604225536:50442240,604237824:50933760,604377088:50823168,604381184:50823168,604463104:50827264,604495872:50933760,50638848:50499584};var R=class{static{o(this,"CGameCtnBlock")}author;blockName;direction;flags;position;skin;waypointSpecialProperty};var d=class{static{o(this,"Node")}chunks={}};var G=class extends d{static{o(this,"CGameCtnBlockSkin")}foregroundPackDesc;packDesc;parentPackDesc;text;50696192=({r:e},t)=>{this.text=e.n(),t.t(e.n())};50696193=({r:e})=>{this.text=e.n(),this.packDesc=e.d()};50696194=({r:e})=>{this.text=e.n(),this.packDesc=e.d(),this.parentPackDesc=e.d()};50696195=({r:e},t)=>{t.i(e.e()),this.foregroundPackDesc=e.d()}};var y=class extends d{static{o(this,"GameVersion")}f(e){return Object.keys(e).map(t=>parseInt(t,10))}isTM2020(){let e=this.f(this.chunks),t=e.some(i=>i>50606169&&i<=50610175),n=e.some(i=>i>50929704&&i<=50933759),s=e.some(i=>i>50933798&&i<=50937855);return t||n||s}isManiaPlanet(){let e=this.f(this.chunks),t=e.some(i=>i>50606122&&i<=50610175),n=e.some(i=>i>50929689&&i<=50933759),s=e.some(i=>i>50933781&&i<=50937855);return t||n||s}isTurbo(){let e=this.f(this.chunks),t=this.chunks[50606144]?.version>2&&!e.some(i=>i>50606165&&i<=50610175),n=e.some(i=>i==50929664)&&!e.some(i=>i>50929703&&i<=50933759),s=e.some(i=>i>50933793)&&!e.some(i=>i>50933795&&i<=50937855);return t||n||s}isTMF(){let e=this.f(this.chunks),t=e.some(i=>i>=50606080)&&!e.some(i=>i>50606122&&i<=50610175),n=e.some(i=>i>=50929664)&&!e.some(i=>i>50929689),s=e.some(i=>i>=50933760)&&!e.some(i=>i>50933781);return t||n||s}};var v=class extends y{static{o(this,"CGameCtnChallenge")}authorExtraInfo;authorLogin;authorNickname;authorScore;authorTime;authorVersion;authorZone;blocks;blockStock;bronzeTime;buildVersion;challengeParameters;checkpoints;comments;cost;crc32;createdWithSimpleEditor;customMusicPackDesc;dayDuration;dayTime;decoBaseHeightOffset;decoration;dynamicDaylight;editorMode;goldTime;hasCustomCamThumbnail;hashedPassword;headerVersion;isLapRace;isMultilap;lightmapCacheUid;lightmapVersion;mapCoordOrigin;mapCoordTarget;mapInfo;mapKind;mapName;mapStyle;mapType;modPackDesc;nbCheckpoints;nbLaps;needUnlock;objectiveTextAuthor;objectiveTextBronze;objectiveTextGold;objectiveTextSilver;offzones;offzoneTriggerSize;packMask;password;playerModel;playMode;silverTime;size;thumbnailData;thumbnailFarClipPlane;thumbnailFov;thumbnailNearClipPlane;thumbnailPitchYawRoll;thumbnailPosition;thumbnailSize;titleId;unlimiter;worldDistortion;xml;50606082=({r:e},t)=>{let n=t.i(e.s());n<=2&&(this.mapInfo=e.u(),this.mapName=e.n()),t.t(e.a()),n>=1&&(this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e()),n==2&&t.t(e.s()),n>=4&&(this.cost=e.e()),n>=5&&(this.isLapRace=e.a()),n==6&&(this.isMultilap=e.a()),n>=7&&(this.playMode=e.e()),n>=9&&t.t(e.e()),n>=10&&(this.authorScore=e.e()),n>=11&&(this.editorMode=e.e()),n>=12&&t.t(e.e()),n>=13&&(this.nbCheckpoints=e.e(),this.nbLaps=e.e())};50606083=({r:e},t)=>{let n=t.i(e.s());this.mapInfo=e.u(),this.mapName=e.n(),this.mapKind=e.s(),n>=1&&(t.t(e.e()),this.password=e.n()),n>=2&&(this.decoration=e.u()),n>=3&&(this.mapCoordOrigin=e.k()),n>=4&&(this.mapCoordTarget=e.k()),n>=5&&(this.packMask=e.h(16)),n>=6&&(this.mapType=e.n(),this.mapStyle=e.n()),n>=8&&(this.lightmapCacheUid=e.h(8)),n>=9&&(this.lightmapVersion=e.s()),n>=11&&(this.titleId=e.c())};50606084=({r:e})=>{this.headerVersion=e.e()};50606085=({r:e})=>{this.xml=e.n()};50606087=({r:e},t)=>{t.i(e.e()),this.thumbnailSize=e.e(),e.n(15),this.thumbnailData=e.p(this.thumbnailSize),e.n(16),e.n(10),this.comments=e.n(),e.n(11)};50606088=({r:e},t)=>{t.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50606093=({r:e})=>{this.playerModel=e.u()};50606095=({r:e})=>{this.mapInfo=e.u(),this.size=e.b(),this.blocks=e.createArray(e.e(),()=>e.l()),this.needUnlock=e.a(),this.decoration=e.u()};50606097=({r:e})=>{this.blockStock=e.l(),this.challengeParameters=e.l(),this.mapKind=e.e()};50606099=({r:e},t)=>{this.mapInfo=e.u(),this.mapName=e.n(),this.decoration=e.u(),this.size=e.b(),t.t(e.a()),this.blocks=e.createArray(e.e(),()=>{let n=e.c(),s=e.s(),i=e.G(),r=e.C();return{blockName:n,direction:s,position:i,flags:r}})};50606100=({r:e},t)=>{t.t(e.a()),this.password=e.n()};50606102=({r:e},t)=>{t.t(e.e())};50606103=({r:e})=>{this.checkpoints=e.createArray(e.e(),()=>e.b())};50606104=({r:e})=>{this.isLapRace=e.a(),this.nbLaps=e.e()};50606105=({r:e})=>{this.modPackDesc=e.d()};50606106=({r:e},t)=>{t.t(e.l())};50606107=({r:e},t)=>{if(t.t(e.e())!=0)throw new Error("Unexpected value SOldIgs > 0 in chunk 0x0304301b")};50606108=({r:e})=>{this.playMode=e.e()};50606109=({r:e},t)=>{t.t(e.e())};50606111=({r:e},t)=>{this.blocks=[],this.mapInfo=e.u(),this.mapName=e.n(),this.decoration=e.u(),this.size=e.b(),this.needUnlock=e.a();let n=t.i(e.e()),s=e.e(),i=o(()=>{let r=e.c(),c=e.s(),u=e.G(),l=0;n>0?l=e.e():l=e.C();let b,C,k;if(l&32768&&(b=e.c(),C=e.l()),n<=1)return!1;if(n>=6&&(u.x-=1,u.z-=1),l&1<<19)throw new Error("Parsin not possible.");if(l&1<<20&&(k=e.l()),l&1<<18){let X=e.e(),q=[];for(let Z=0;Z<X;Z++){var W=q[Z];e.h(4),e.h(4);let ee=e.e();for(let j=0;j<ee;j++)W[j]=(e.c(),e.c(),e.c())}}if(l&1<<17){let X=e.c(),q=e.h(4),Z=e.h(4)}return this.blocks?.push({blockName:r,direction:c,position:u,flags:l,author:b,skin:C,waypointSpecialProperty:k}),!0},"readBlock");for(let r=0;r<s;r++)i();for(;(e.peekUInt32()&3221225472)>0;)i()};50606112=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606113=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606114=({r:e},t)=>{t.t(e.e())};50606115=({r:e})=>{this.mapCoordOrigin=e.k(),this.mapCoordTarget=this.mapCoordOrigin};50606116=({r:e})=>{this.customMusicPackDesc=e.d()};50606117=({r:e})=>{this.mapCoordOrigin=e.k(),this.mapCoordTarget=e.k()};50606118=({r:e},t)=>{t.t(e.l())};50606119=({r:e},t)=>{this.hasCustomCamThumbnail=e.a(),this.hasCustomCamThumbnail&&(t.t(e.s()),t.t(e.m()),t.t(e.m()),t.t(e.m()),this.thumbnailPosition=e.m(),this.thumbnailFov=e.o(),this.thumbnailNearClipPlane=e.o(),this.thumbnailFarClipPlane=e.o())};50606120=(e,t)=>{this[50606119](e,t);let{r:n}=e;this.comments=n.n()};50606121=({r:e})=>{this.hashedPassword=e.p(16),this.crc32=e.e()};50606122=({r:e})=>{this.createdWithSimpleEditor=e.a()};50606125=({r:e},t)=>{this.thumbnailPosition=e.m(),this.thumbnailPitchYawRoll=e.m(),this.thumbnailFov=e.o(),t.t(e.o()),t.t(e.o()),this.thumbnailNearClipPlane=e.o(),this.thumbnailFarClipPlane=e.o(),this.comments=e.n()};50606132=({r:e})=>{let t=e.e();e.p(t)};50606134=(e,t)=>{this[50606125](e,t)};50606144=({r:e,length:t},n)=>{n.i(e.e()),e.p(t-4)};50606146=({r:e},t)=>{t.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50606151=({r:e},t)=>{let n=t.i(e.e());if(t.t(e.n()),n>=1)throw new Error("Unexpected version >= 1 in chunk 0x03043047")};50606153=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606155=({r:e})=>{this.objectiveTextAuthor=e.n(),this.objectiveTextGold=e.n(),this.objectiveTextSilver=e.n(),this.objectiveTextBronze=e.n()};50606160=({r:e},t)=>{t.i(e.e()),this.offzoneTriggerSize=[e.e(),e.e(),e.e()],this.offzones=e.createArray(e.e(),()=>({1:e.b(),2:e.b()}))};50606161=({r:e},t)=>{t.i(e.e()),this.titleId=e.c(),this.buildVersion=e.n()};50606162=({r:e},t)=>{t.i(e.e()),this.decoBaseHeightOffset=e.e()};50606166=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.dayTime=e.e(),t.t(e.e()),this.dynamicDaylight=e.a(),this.dayDuration=e.e()};50606168=({r:e},t)=>{if(t.i(e.e()),t.t(e.e())>0)throw new Error("Unexpected value > 0 in chunk 0x03043058")};50606169=({r:e},t)=>{let n=t.i(e.e());if(this.worldDistortion=e.m(),n==0)throw new Error("Unexpected version 0 in chunk 0x03043059");if(n>=1&&t.t(e.a()))throw new Error("Unexpected value true in chunk 0x03043059");n>=3&&(t.t(e.e()),t.t(e.e()))};50606170=({r:e},t)=>{t.t(e.e()),t.t(e.e())};50606187=({r:e},t)=>{t.t(e.e()),this.dayTime=e.e(),t.t(e.e()),this.dynamicDaylight=e.a(),this.dayDuration=e.e()};50606165=({r:e},t)=>{let n=t.t(e.s());switch(this.unlimiter=-1,n){case 1:this.unlimiter=1.1;break;case 2:this.unlimiter=1.2;break}e.forceChunkSkip(50606165)};1056968704=({r:e},t)=>{this.unlimiter=1.3,e.forceChunkSkip(1056968704)};1056968705=({r:e},t)=>{let n=t.t(e.s());switch(this.unlimiter=-1,n){case 0:this.unlimiter=-1;break;case 1:this.unlimiter=.4;break;case 2:this.unlimiter=.6;break;case 3:this.unlimiter=.7;break;case 4:this.unlimiter=1.1;break;case 5:this.unlimiter=1.2;break;case 6:this.unlimiter=1.3;break;case 7:this.unlimiter=2;break}e.forceChunkSkip(1056968705)};1056968706=({r:e},t)=>{this.unlimiter=2,e.forceChunkSkip(1056968706)};1056968707=({r:e},t)=>{this.unlimiter=2,e.forceChunkSkip(1056968707)}};var S=class extends d{static{o(this,"CGameCtnChallengeParameters")}authorScore;authorTime;bronzeTime;goldTime;isValidatedForScriptModes;mapStyle;mapType;raceValidationGhost;silverTime;timeLimit;tip;tip1;tip2;tip3;tip4;50704384=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704385=({r:e})=>{this.tip1=e.n(),this.tip2=e.n(),this.tip3=e.n(),this.tip4=e.n()};50704386=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.o()),t.t(e.o()),t.t(e.o()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704387=({r:e},t)=>{t.t(e.e()),t.t(e.o()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704388=({r:e},t)=>{this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e(),t.t(e.e())};50704389=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e())};50704390=({r:e},t)=>{t.t(e.createArray(e.e(),()=>e.e()))};50704391=({r:e},t)=>{t.t(e.e())};50704392=({r:e})=>{this.timeLimit=e.e(),this.authorScore=e.e()};50704394=({r:e})=>{this.tip=e.n(),this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e(),this.timeLimit=e.e(),this.authorScore=e.e()};50704397=({r:e})=>{this.raceValidationGhost=e.l()};50704398=({r:e})=>{this.mapType=e.n(),this.mapStyle=e.n(),this.isValidatedForScriptModes=e.a()}};var T=class extends d{static{o(this,"CGameCtnCollectorList")}blockSet;50442240=({r:e})=>{this.blockSet=e.createArray(e.e(),()=>{let t=e.u(),n=e.e();return{blockModel:t,count:n}})}};var F=class extends y{static{o(this,"CGameGhost")}isReplaying;sampleData;sampleDataUncompressedSize;sampleRecords;sampleOffsets;sampleTimes;isFixedTimeStep;samplePeriod;sampleVersion;async decompressSampleData(){if(!this.sampleData||this.sampleData.length===0)return[];let e=await P.decompress(this.sampleData),t=new f(Array.from(e)),n=[];for(;t.bytesAvailable>=20;)try{let s={x:t.o(),y:t.o(),z:t.o()},i=t.C(),r=t.s(),c=t.s(),u=t.C(),l=t.s(),b=t.s();n.push({position:s,angle:i,axisHeading:r,axisPitch:c,speed:u,velHeading:l,velPitch:b})}catch{break}return this.sampleRecords=n,n}static speedToDisplaySpeed(e){return e===0?0:Math.exp(e/1e3)*1e3}50589699=({r:e})=>{let t=e.e();this.sampleData=e.p(t),this.sampleOffsets=e.createArray(e.e(),()=>e.e()),this.sampleTimes=e.createArray(e.e(),()=>e.e()),this.isFixedTimeStep=e.a(),this.samplePeriod=e.e(),this.sampleVersion=e.e()};50589700=({r:e},t)=>{t.t(e.e())};50589701=({r:e})=>{this.sampleDataUncompressedSize=e.e();let t=e.e();this.sampleData=e.p(t)};50589702=e=>{let{r:t}=e;this.isReplaying=t.a(),this[50589701](e)}};var g=class extends F{static{o(this,"CGameCtnGhost")}appearanceVersion;apperanceVersion;badge;checkpoints;controlEntries;controlNames;eventsDuration;ghostAvatarName;ghostClubTag;ghostLogin;ghostNickname;ghostTrigram;ghostUid;ghostZone;hasBadges;lightTrailColor;playerModel;raceTime;recordData;recordingContext;respawns;skinFile;skinPackDescs;steeringWheelSensitivity;stuntScore;validationChallengeUid;validationCpuKind;validationExeChecksum;validationExeVersion;validationOsKind;validationRaceSettings;validationTitleId;50929664=({r:e},t)=>{let n=e.e();n>=9&&(this.appearanceVersion=e.e()),this.playerModel=e.u(),this.lightTrailColor=e.m(),this.skinPackDescs=e.createArray(e.e(),()=>e.d()),this.hasBadges=e.a(),this.hasBadges&&(this.badge={},this.badge.version=e.e(),this.badge.color=[e.e(),e.e(),e.e()],this.badge.version==0&&(t.t(e.e()),t.t(e.n())),this.badge.stickers=e.createArray(e.e(),()=>{let s=e.n(),i=e.n();return{item1:s,item2:i}}),this.badge.layers=e.createArray(e.e(),()=>e.n())),(this.apperanceVersion??!1)&&t.t(e.n()),this.ghostNickname=e.n(),this.ghostAvatarName=e.n(),n>=2&&(this.recordingContext=e.n()),n>=4&&t.t(e.a()),n>=5&&(this.recordData=e.l(),t.t(e.createArray(e.e(),()=>e.e()))),n>=6&&(this.ghostTrigram=e.n()),n>=7&&(this.ghostZone=e.n()),n>=8&&(this.ghostClubTag=e.n())};50929667=({r:e})=>{this.playerModel=e.u(),this.skinFile=e.n(),this.ghostNickname=e.n()};50929668=({r:e})=>{let t=e.e();this.checkpoints=e.createArray(t,()=>{let n=e.e(),s=e.o();return{time:n,speed:s}})};50929669=({r:e})=>{this.raceTime=e.e()};50929670=({r:e},t)=>{this.playerModel=e.u(),this.skinFile=e.n(),t.t(e.e()),this.ghostNickname=e.n()};50929671=({r:e})=>{this.lightTrailColor=e.m()};50929672=({r:e})=>{this.respawns=e.e()};50929673=({r:e})=>{this.lightTrailColor=[e.e(),e.e(),e.e()]};50929674=({r:e})=>{this.stuntScore=e.e()};50929675=({r:e})=>{let t=e.e();this.checkpoints=e.createArray(t,()=>{let n=e.e(),s=e.e();return{time:n,stuntScore:s}})};50929676=({r:e},t)=>{t.t(e.e())};50929677=({r:e},t)=>{this.playerModel=e.u(),this.skinFile=e.n(),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),this.ghostNickname=e.n()};50929678=({r:e})=>{this.ghostUid=e.c()};50929679=({r:e})=>{this.ghostLogin=e.n()};50929680=({r:e})=>{this.validationChallengeUid=e.c()};50929681=({r:e},t)=>{if(this.eventsDuration=e.e(),this.eventsDuration==0)return;t.t(e.e()),this.controlNames=e.createArray(e.e(),()=>e.c());let n=e.e();t.t(e.e()),this.controlEntries=e.createArray(n,()=>{let s=e.e()-1e5,i=e.s(),r=e.e(),c=this.controlNames[i],u=["Steer","Gas","AccelerateReal","BrakeReal"].includes(c);return{name:c,time:s,value:r,analog:u}}),this.validationExeVersion=e.n(),this.validationExeChecksum=e.e(),this.validationOsKind=e.e(),this.validationCpuKind=e.e(),this.validationRaceSettings=e.n()};50929682=({r:e},t)=>{t.t(e.e()),t.t(e.h(16))};50929683=({r:e},t)=>{t.t(e.e()),t.t(e.e())};50929684=({r:e},t)=>{t.t(e.e())};50929685=({r:e})=>{this.ghostNickname=e.c()};50929687=({r:e})=>{this.skinPackDescs=e.createArray(e.e(),()=>e.d()),this.ghostNickname=e.n(),this.ghostAvatarName=e.n()};50929688=({r:e})=>{this.playerModel=e.u()};50929689=(e,t)=>{this[50929681](e,t);let{r:n}=e;this.eventsDuration!=0&&t.t(n.e())};50929690=({r:e},t)=>{t.t(e.e())};50929692=({r:e},t)=>{t.t(e.h(32))};50929699=({r:e},t)=>{let n=t.i(e.e());t.t(e.n()),t.t(e.e()),t.t(e.n()),t.t(e.e()),t.t(e.e()),t.t(e.n()),t.t(e.e()),t.t(e.n()),n>=2&&(t.t(e.s()),t.t(e.e()),t.t(e.e())),n>=3&&(t.t(e.s()),t.t(e.s()))};50929702=({r:e},t)=>{t.t(e.h(16))};50929704=({r:e},t)=>{(this.eventsDuration??!0)||(this.validationTitleId=e.n(),t.t(e.h(32)))}};var D=class{static{o(this,"CGameCtnMediaClip")}tracks;name;stopWhenLeave;stopWhenRespawn;localPlayerClipEntIndex;50827277=({r:e})=>{this.tracks=[];let t=e.e(),n=e.e();for(let r=0;r<n;r++){let c=e.l();this.tracks.push(c)}this.name=e.n(),this.stopWhenLeave=e.a();let s=e.e();this.stopWhenRespawn=e.a();let i=e.e();this.localPlayerClipEntIndex=e.e()}};var I=class extends d{static{o(this,"CGameCtnMediaBlock")}};var V=class{static{o(this,"CGameCtnMediaBlockTriangles")}50499585=({r:e})=>{let t=e.e(),n=[];for(let r=0;r<t;r++)n.push(e.o());t=e.e();let s=e.e();for(let r=0;r<t;r++)for(let c=0;c<s;c++){let u=e.m()}s=e.e();for(let r=0;r<s;r++){let c=e.m(),u=e.o()}let i=e.e();for(let r=0;r<i;r++){let c=e.e(),u=e.e(),l=e.e()}e.e(),e.e(),e.e(),e.o(),e.e(),e.h(8)}};var N=class{static{o(this,"CGameCtnMediaTrack")}name;blocks;keepPlaying;50823169=({r:e})=>{this.blocks=[];let t=e.n();e.e();let n=e.e();for(let i=0;i<n;i++){let r=e.l();this.blocks.push(r)}let s=e.e()};50823172=({r:e})=>{this.keepPlaying=e.a(),e.e()}};var L=class extends y{static{o(this,"CGameCtnReplayRecord")}authorExtraInfo;authorLogin;authorNickname;authorVersion;authorZone;challengeData;controlEntries;controlNames;eventsDuration;extras;game;ghosts;mapInfo;playerLogin;playerNickname;playgroundScript;recordData;time;titleId;xml;50933760=({r:e},t)=>{let n=t.i(e.e());n>=2&&(this.mapInfo=e.u(),this.time=e.e(),this.playerNickname=e.n()),n>=6&&(this.playerLogin=e.n()),n>=8&&(t.t(e.s()),this.titleId=e.c())};50933761=({r:e})=>{this.xml=e.n()};50933762=({r:e,isHeaderChunk:t},n)=>{if(t){n.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n();return}let s=e.e();this.challengeData=new E(e.p(s))};50933764=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.ghosts=e.createArray(e.e(),()=>e.l()),t.t(e.e()),t.t(e.e())};50933765=({r:e},t)=>{t.t(e.e())};50933767=({r:e},t)=>{t.t(e.e())};50933768=({r:e},t)=>{this.game=e.n(),t.t(e.e())};50933772=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933773=({r:e},t)=>{if(this.eventsDuration=e.e(),this.eventsDuration==0)return;t.t(e.e()),this.controlNames=e.createArray(e.e(),()=>e.c());let n=e.e();t.t(e.e()),this.controlEntries=e.createArray(n,()=>{let s=e.e()+1e5,i=e.s(),r=e.e(),c=this.controlNames[i],u=["Steer","Gas","AccelerateReal","BrakeReal"].includes(c);return{name:c,time:s,value:r,analog:u}})};50933774=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933775=({r:e},t)=>{this.game=e.n(),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.n())};50933776=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933780=({r:e},t)=>{t.i(e.e()),this.ghosts=e.createArray(e.e(),()=>e.l()),t.t(e.e()),this.extras=e.createArray(e.e(),()=>{let n=e.e(),s=e.e();return{extra1:n,extra2:s}})};50933781=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933784=({r:e})=>{this.titleId=e.c(),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50933787=({r:e},t)=>{t.i(e.e()),t.t(e.createArray(e.e(),()=>({1:e.e(),2:e.e()})))};50933788=({r:e},t)=>{t.i(e.e()),this.playgroundScript=e.n()};50933793=({r:e},t)=>{t.i(e.e()),t.t(e.a())};50933796=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.recordData=e.l()};50933797=({r:e},t)=>{t.i(e.e()),t.t(e.e()),t.t(e.e())}};var M=class extends d{static{o(this,"CGameWaypointSpecialProperty")}order;spawn;tag;771788800=({r:e},t)=>{let n=t.i(e.e());n==1?(this.spawn=e.e(),this.order=e.e()):n==2&&(this.tag=e.n(),this.order=e.e())}};var A=class extends d{static{o(this,"CPlugEntRecordData")}compressedData;compressedSize;uncompressedSize;152170496=({r:e},t)=>{t.i(e.e())>=5&&(this.uncompressedSize=e.e(),this.compressedSize=e.e(),this.compressedData=e.p(this.compressedSize))}};function H(a){return{50442240:T,50606080:v,50696192:G,50704384:S,50819072:I,50499584:V,50823168:N,50827264:D,50929664:g,50933760:L,152170496:A,771788800:M}[a]}o(H,"getNodeType");var B=class{constructor(e){this.options=e;Object.assign(this,e)}static{o(this,"GBXReader")}current;fullChunkId=0;versions={};unknowns={};i(e){return this.versions[this.fullChunkId]=e,e}t(e){return this.unknowns[this.fullChunkId]===void 0&&(this.unknowns[this.fullChunkId]=[]),this.unknowns[this.fullChunkId].push(e),e}v(){let e=this.options.stream,t={};for(;;){let n=e.e();if(n==4207599105)break;if(t[n]=!0,e.peekUInt32()==1397442896){let i=e.e(),r=e.e();if(!this.w(n,!1,r)){m.warn(`Skipped chunk: 0x${x.fromDecimal(n)}`);let u=e.p(r);t[n]=!1}continue}if(!this.w(n))throw new Error(`Failed processing unskippable chunk 0x${x.fromDecimal(n)}.`)}return this.current.chunks=w.mergeChunks(t,this.unknowns,this.versions),this.current}w(e,t=!1,n=0){let s=this.options.stream;this.fullChunkId=e;let i=this.options.classId,r=e&4294963200;i=O[i]??i,r=O[r]??r;let c=H(i),u=r+(e&4095);return c===void 0||(this.current===void 0&&(this.current=new c),this.current[u]===void 0)?!1:(m.debug(`Processing ${t?"header chunk":"chunk"}: 0x${x.fromDecimal(u)}`),this.current[u]({r:s,length:n,fullChunkId:e,isHeaderChunk:t},{i:this.i.bind(this),t:this.t.bind(this)}),!0)}S(e){let t=this.options.headerChunks,n={};for(let s=0;s<t.length;s++){let i=t[s],r=e+i.chunkId;this.options.stream=new f(i.chunkData),this.w(r,!0)||(m.warn(`Skipped chunk: 0x${x.fromDecimal(r)}`),n[r]=!1),n[r]=!0}return this.current.chunks=w.mergeChunks(n,this.unknowns,this.versions),this.current}};var $={0:"Desert",1:"Snow",2:"Rally",3:"Island",4:"Bay",5:"Coast",6:"Stadium",7:"Basic",8:"Plain",9:"Moon",10:"Toy",11:"Valley",12:"Canyon",13:"Lagoon",14:"Deprecated_Arena",17:"TMCommon",18:"Canyon4",19:"Canyon256",20:"Valley4",21:"Valley256",22:"Lagoon4",23:"Lagoon256",24:"Stadium4",25:"Stadium256",26:"Trackmania",100:"History",101:"Society",102:"Galaxy",200:"Gothic",201:"Paris",202:"Storm",203:"Cryo",204:"Meteor",205:"Meteor4",206:"Meteor256",299:"SMCommon",1e4:"Vehicles",10001:"Orbital",10002:"Actors",10003:"Common",4294967295:"Unassigned"};var he=new TextDecoder,f=class{static{o(this,"DataStream")}stream;position=0;constructor(e){this.stream=e}get bytesAvailable(){return this.stream.length-this.position}createArray(e,t){return Array.from({length:e},(n,s)=>t(s))}peekByte(e=0){return this.stream[this.position+e]}s(){let e=this.peekByte();if(e===void 0)throw new Error("Attempted to read an undefined byte.");return this.position++,e}peekBytes(e){return this.createArray(e,t=>this.peekByte(t))}p(e){return this.createArray(e,()=>this.s())}bytesToNumber(e){return e.reduce((t,n,s)=>t|n<<s*8,0)}peekNumbers(e){return this.bytesToNumber(this.peekBytes(e))>>>0}h(e){return this.bytesToNumber(this.p(e))>>>0}o(){let e=this.bytesToNumber(this.p(4));if(e==0)return 0;let t=e>>>31?-1:1,n=(e>>>23&255)-127,s=e&8388607|8388608;return t*s*Math.pow(2,n-23)}peekUInt16(){return this.peekNumbers(2)}C(){return this.h(2)}peekUInt32(){return this.peekNumbers(4)}e(){return this.h(4)}a(){return!!this.h(4)}n(e=0){return e==0&&(e=this.h(4)),he.decode(new Uint8Array(this.p(e)))}g(){return this.n(1)}T(){return{x:this.e(),y:this.e()}}b(){return{x:this.e(),y:this.e(),z:this.e()}}k(){return{x:this.o(),y:this.o()}}m(){return{x:this.o(),y:this.o(),z:this.o()}}G(){return{x:this.s(),y:this.s(),z:this.s()}}u(){return{id:this.c(),collection:this.c(),author:this.c()}}d(){let e=this.s();e>=3&&this.p(32);let t=this.n();return(t.length>0&&e>=1||e>=3)&&this.n(),t}nodeList=[];l(){let e=this.h(4)<<1>>1;if(e==-1)return;let t=this.nodeList[e]!==void 0;if(e>=0&&!t){let n=this.e(),s=new B({stream:this,classId:n}).v();return this.nodeList[e]=s,s}if(t)return this.nodeList[e];throw new Error("Invalid node reference")}lookbackVersion;lookbackStrings=[];c(){this.lookbackVersion===void 0&&(this.lookbackVersion=this.e());let e=new Uint32Array([this.e()])[0];if(e==4294967295)return"";if((e&16383)==0&&(e>>30==1||e>>30==-2)){let t=this.n();return this.lookbackStrings.push(t),t}if((e&16383)==16383)switch(e>>30){case 2:return"Unassigned";case 3:return"";default:throw new Error("Invalid lookback string, the file provided may be corrupt")}return e>>30==0?$[e]===void 0?"Unknown collection":$[e]:this.lookbackStrings.length>(e&16383)-1?this.lookbackStrings[(e&16383)-1]:""}forceChunkSkip(e){for(;;){let t=this.peekUInt32();if((t&4294967040)==(e&4294967040)){m.warn(`Force skipped chunk: 0x${x.fromDecimal(e)}`);break}if(t==4207599105&&this.peekByte(4)===void 0){m.warn(`Force skipped chunk: 0x${x.fromDecimal(e)}`),m.warn("Reached end of file early");break}let n=this.s()}}};var x=class{static{o(this,"Hex")}static fromDecimal(e){return e.toString(16)}};var m=class{static{o(this,"Logger")}static showLogs=!1;static showDebug=!1;static showWarns=!1;static reset="\x1B[0m";static highlight(e,t=35){return`${`\x1B[${t}m`}${e}${this.reset}`}static log(...e){this.showLogs&&console.log(this.highlight("[INFO]",34),...e)}static debug(...e){this.showDebug&&console.log(this.highlight("[DEBUG]",35),...e)}static warn(...e){this.showWarns&&console.warn(this.highlight("[WARN]",33),...e)}static error(...e){console.error(this.highlight("[ERROR]",31),...e)}static outline(...e){console.log(this.highlight("[DEVEL]",41),this.highlight(e[0],35),...e.slice(1))}};var pe=typeof globalThis.LZO<"u";async function J(){if(pe)return globalThis.LZO;let{LZO:a}=await import("lzo-ts");return a}o(J,"getLZO");var U=class{static{o(this,"LZOHandler")}static async compress(e){try{return(await J()).compress(e)}catch(t){throw console.error("LZO compress error:",t),new Error("Failed to compress data, is the lzo-ts package installed?")}}static async decompress(e){try{return(await J()).decompress(e)}catch(t){throw console.error("LZO decompress error:",t),new Error("Failed to decompress data, is the lzo-ts package installed?")}}};var le=typeof globalThis.ZLib<"u";async function Q(){return le?globalThis.ZLib:await import("pako")}o(Q,"getZLib");var P=class{static{o(this,"ZLibHandler")}static async compress(e){try{return(await Q()).deflate(new Uint8Array(e))}catch(t){throw console.error("ZLib compress error:",t),new Error("Failed to compress data, is the pako package installed?")}}static async decompress(e){try{return(await Q()).inflate(new Uint8Array(e))}catch(t){throw console.error("ZLib decompress error:",t),new Error("Failed to decompress data, is the pako package installed?")}}};var w=class{static{o(this,"Merger")}static mergeChunks(e,t,n){let s={};for(let i in e){if(e[i]===!1){s[i]=null;continue}s[i]={unknowns:t[i],version:n[i]}}return s}static mergeInstances(e,t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==void 0&&(e[n]=t[n]);return e}};var E=class{static{o(this,"GBX")}stream;classId;wrappedClassId;bodyCompression="C";constructor(e,t=2){t>=1&&(m.showWarns=!0),t>=2&&(m.showLogs=!0),t>=3&&(m.showDebug=!0),this.stream=new f(e)}async parseHeaders(){if(this.stream.n(3)!="GBX")return Promise.reject(new Error("Not a GBX file"));m.debug("Found GBX magic");let e=this.stream.C();if(e<3)return Promise.reject(new Error("Unsupported GBX version"));m.debug(`Reading GBX version ${e}`);let t=this.stream.g(),n=this.stream.g();this.bodyCompression=this.stream.g(),e>=4&&this.stream.g(),this.classId=this.stream.e(),this.wrappedClassId=O[this.classId],e>=6&&this.stream.e();let s=this.stream.e();if(s==0)return Promise.reject(new Error("No header chunks"));let i=[];for(let l=0;l<s;l++){let b=this.stream.e()&4095,C=this.stream.e()&2147483647,k=(C&2147483648)!=0;i.push({chunkId:b,chunkSize:C,isHeavy:k})}for(let l=0;l<s;l++)i[l].chunkData=this.stream.p(i[l].chunkSize);m.debug("Reading header data");let r=new B({headerChunks:i,classId:this.classId}).S(this.classId),c=this.stream.e();return this.stream.e()>0?Promise.reject(new Error("[Unimplemented] External nodes are not supported")):Promise.resolve(r)}async parse(){let e=await this.parseHeaders(),t;if(this.bodyCompression==="C"){let s=this.stream.e(),i=this.stream.e(),r=this.stream.p(i);m.debug(`Decompressing body: ${i} -> ${s} bytes`),t=new f(await U.decompress(r))}else{m.debug("Reading uncompressed body");let s=this.stream.p(this.stream.bytesAvailable);t=new f(s)}m.debug("Reading body data");let n=new B({stream:t,classId:this.classId}).v();return Promise.resolve(w.mergeInstances(e,n))}};var K;(r=>{function a(c){if(c instanceof g)return c.checkpoints?.length||void 0;let u=c.chunks?.[50606111]?.version,l=new Set,b=0;if(u>=6)c.blocks?.forEach(C=>{let k=C.waypointSpecialProperty;if(k?.order!==void 0&&(k?.tag=="Checkpoint"&&b++,k?.tag=="LinkedCheckpoint")){if(l.has(k.order))return;b++,l.add(k.order)}});else return c.checkpoints?.length||void 0;if(c.blocks!==void 0)return c.nbCheckpoints&&b<c.nbCheckpoints?(m.warn("The amount of checkpoints doesn't match the amount of checkpoints in the header. Returning amount of header."),c.nbCheckpoints):b}r.getCheckpointCount=a,o(a,"getCheckpointCount");function e(c){return c.controlEntries?.filter(u=>u?.name=="Respawn"&&u?.value==1)}o(e,"getRespawns");function t(c){return e(c)?.length}r.getRespawnsCount=t,o(t,"getRespawnsCount");function n(c){return c.checkpoints?.map(u=>u.time)}r.getCheckpointTimes=n,o(n,"getCheckpointTimes");function s(c){let u=n(c),l=e(c);if(u===void 0||l===void 0)return;let b=u.map(()=>0),C=0;for(let k of l){let W=u[C];k.time>=W&&C++,b[C]++}return b}r.getRespawnsByCheckpoint=s,o(s,"getRespawnsByCheckpoint");function i(c){let u=n(c);if(u!==void 0)return u.map((l,b,C)=>{let k=C[b-1]||0;return l-k})}r.getSectorTimes=i,o(i,"getSectorTimes")})(K||={});0&&(module.exports={CGameCtnBlock,CGameCtnBlockSkin,CGameCtnChallenge,CGameCtnChallengeParameters,CGameCtnCollectorList,CGameCtnGhost,CGameCtnMediaBlock,CGameCtnMediaClip,CGameCtnMediaTrack,CGameCtnReplayRecord,CGameGhost,CGameWaypointSpecialProperty,CPlugEntRecordData,GBX,Utils,ZLibHandler});
@@ -0,0 +1,8 @@
1
+ import GBX from './GBX';
2
+ export { GBX };
3
+ export { CGameCtnBlock, CGameCtnBlockSkin, CGameCtnChallenge, CGameCtnChallengeParameters, CGameCtnCollectorList, CGameCtnGhost, CGameCtnMediaClip, CGameCtnMediaTrack, CGameCtnMediaBlock, CGameCtnReplayRecord, CGameGhost, CGameWaypointSpecialProperty, } from './Classes/Game';
4
+ export type { GhostSampleRecord } from './Classes/Game/CGameGhost';
5
+ export { CPlugEntRecordData } from './Classes/Plug';
6
+ export { Utils } from './Functions/Utils';
7
+ export { ZLibHandler } from './Handlers';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,OAAO,CAAC;AAExB,OAAO,EAAE,GAAG,EAAE,CAAC;AAEf,OAAO,EACN,aAAa,EACb,iBAAiB,EACjB,iBAAiB,EACjB,2BAA2B,EAC3B,qBAAqB,EACrB,aAAa,EACb,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,EAClB,oBAAoB,EACpB,UAAU,EACV,4BAA4B,GAC5B,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEnE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";var Q=Object.create;var z=Object.defineProperty;var ee=Object.getOwnPropertyDescriptor;var te=Object.getOwnPropertyNames;var ne=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty;var o=(r,e)=>z(r,"name",{value:e,configurable:!0});var se=(r,e)=>{for(var t in e)z(r,t,{get:e[t],enumerable:!0})},_=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of te(e))!ie.call(r,s)&&s!==t&&z(r,s,{get:()=>e[s],enumerable:!(n=ee(e,s))||n.enumerable});return r};var H=(r,e,t)=>(t=r!=null?Q(ne(r)):{},_(e||!r||!r.__esModule?z(t,"default",{value:r,enumerable:!0}):t,r)),oe=r=>_(z({},"__esModule",{value:!0}),r);var ue={};se(ue,{CGameCtnBlock:()=>R,CGameCtnBlockSkin:()=>v,CGameCtnChallenge:()=>S,CGameCtnChallengeParameters:()=>w,CGameCtnCollectorList:()=>T,CGameCtnGhost:()=>g,CGameCtnMediaBlock:()=>I,CGameCtnMediaClip:()=>D,CGameCtnMediaTrack:()=>N,CGameCtnReplayRecord:()=>M,CGameGhost:()=>F,CGameWaypointSpecialProperty:()=>E,CPlugEntRecordData:()=>A,GBX:()=>B,Utils:()=>X,ZLibHandler:()=>P});module.exports=oe(ue);var u={compress:o(async r=>{let{LZO:e}=await import("lzo-ts");return e.compress(r)},"compress"),decompress:o(async r=>{let{LZO:e}=await import("lzo-ts");return e.decompress(r)},"decompress")},h={inflate:o(async r=>(await import("pako")).inflate(new Uint8Array(r)),"inflate"),deflate:o(async r=>(await import("pako")).deflate(new Uint8Array(r)),"deflate")};var O={554172416:50606080,554225664:50933760,603992064:50606080,604028928:50704384,604090368:50929664,604217344:50696192,604225536:50442240,604237824:50933760,604377088:50823168,604381184:50823168,604463104:50827264,604495872:50933760,50638848:50499584};var R=class{static{o(this,"CGameCtnBlock")}author;blockName;direction;flags;position;skin;waypointSpecialProperty};var d=class{static{o(this,"Node")}chunks={}};var v=class extends d{static{o(this,"CGameCtnBlockSkin")}foregroundPackDesc;packDesc;parentPackDesc;text;50696192=({r:e},t)=>{this.text=e.n(),t.t(e.n())};50696193=({r:e})=>{this.text=e.n(),this.packDesc=e.d()};50696194=({r:e})=>{this.text=e.n(),this.packDesc=e.d(),this.parentPackDesc=e.d()};50696195=({r:e},t)=>{t.i(e.e()),this.foregroundPackDesc=e.d()}};var y=class extends d{static{o(this,"GameVersion")}f(e){return Object.keys(e).map(t=>parseInt(t,10))}isTM2020(){let e=this.f(this.chunks),t=e.some(i=>i>50606169&&i<=50610175),n=e.some(i=>i>50929704&&i<=50933759),s=e.some(i=>i>50933798&&i<=50937855);return t||n||s}isManiaPlanet(){let e=this.f(this.chunks),t=e.some(i=>i>50606122&&i<=50610175),n=e.some(i=>i>50929689&&i<=50933759),s=e.some(i=>i>50933781&&i<=50937855);return t||n||s}isTurbo(){let e=this.f(this.chunks),t=this.chunks[50606144]?.version>2&&!e.some(i=>i>50606165&&i<=50610175),n=e.some(i=>i==50929664)&&!e.some(i=>i>50929703&&i<=50933759),s=e.some(i=>i>50933793)&&!e.some(i=>i>50933795&&i<=50937855);return t||n||s}isTMF(){let e=this.f(this.chunks),t=e.some(i=>i>=50606080)&&!e.some(i=>i>50606122&&i<=50610175),n=e.some(i=>i>=50929664)&&!e.some(i=>i>50929689),s=e.some(i=>i>=50933760)&&!e.some(i=>i>50933781);return t||n||s}};var S=class extends y{static{o(this,"CGameCtnChallenge")}authorExtraInfo;authorLogin;authorNickname;authorScore;authorTime;authorVersion;authorZone;blocks;blockStock;bronzeTime;buildVersion;challengeParameters;checkpoints;comments;cost;crc32;createdWithSimpleEditor;customMusicPackDesc;dayDuration;dayTime;decoBaseHeightOffset;decoration;dynamicDaylight;editorMode;goldTime;hasCustomCamThumbnail;hashedPassword;headerVersion;isLapRace;isMultilap;lightmapCacheUid;lightmapVersion;mapCoordOrigin;mapCoordTarget;mapInfo;mapKind;mapName;mapStyle;mapType;modPackDesc;nbCheckpoints;nbLaps;needUnlock;objectiveTextAuthor;objectiveTextBronze;objectiveTextGold;objectiveTextSilver;offzones;offzoneTriggerSize;packMask;password;playerModel;playMode;silverTime;size;thumbnailData;thumbnailFarClipPlane;thumbnailFov;thumbnailNearClipPlane;thumbnailPitchYawRoll;thumbnailPosition;thumbnailSize;titleId;unlimiter;worldDistortion;xml;50606082=({r:e},t)=>{let n=t.i(e.s());n<=2&&(this.mapInfo=e.u(),this.mapName=e.n()),t.t(e.a()),n>=1&&(this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e()),n==2&&t.t(e.s()),n>=4&&(this.cost=e.e()),n>=5&&(this.isLapRace=e.a()),n==6&&(this.isMultilap=e.a()),n>=7&&(this.playMode=e.e()),n>=9&&t.t(e.e()),n>=10&&(this.authorScore=e.e()),n>=11&&(this.editorMode=e.e()),n>=12&&t.t(e.e()),n>=13&&(this.nbCheckpoints=e.e(),this.nbLaps=e.e())};50606083=({r:e},t)=>{let n=t.i(e.s());this.mapInfo=e.u(),this.mapName=e.n(),this.mapKind=e.s(),n>=1&&(t.t(e.e()),this.password=e.n()),n>=2&&(this.decoration=e.u()),n>=3&&(this.mapCoordOrigin=e.k()),n>=4&&(this.mapCoordTarget=e.k()),n>=5&&(this.packMask=e.h(16)),n>=6&&(this.mapType=e.n(),this.mapStyle=e.n()),n>=8&&(this.lightmapCacheUid=e.h(8)),n>=9&&(this.lightmapVersion=e.s()),n>=11&&(this.titleId=e.c())};50606084=({r:e})=>{this.headerVersion=e.e()};50606085=({r:e})=>{this.xml=e.n()};50606087=({r:e},t)=>{t.i(e.e()),this.thumbnailSize=e.e(),e.n(15),this.thumbnailData=e.p(this.thumbnailSize),e.n(16),e.n(10),this.comments=e.n(),e.n(11)};50606088=({r:e},t)=>{t.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50606093=({r:e})=>{this.playerModel=e.u()};50606095=({r:e})=>{this.mapInfo=e.u(),this.size=e.b(),this.blocks=e.createArray(e.e(),()=>e.l()),this.needUnlock=e.a(),this.decoration=e.u()};50606097=({r:e})=>{this.blockStock=e.l(),this.challengeParameters=e.l(),this.mapKind=e.e()};50606099=({r:e},t)=>{this.mapInfo=e.u(),this.mapName=e.n(),this.decoration=e.u(),this.size=e.b(),t.t(e.a()),this.blocks=e.createArray(e.e(),()=>{let n=e.c(),s=e.s(),i=e.v(),a=e.C();return{blockName:n,direction:s,position:i,flags:a}})};50606100=({r:e},t)=>{t.t(e.a()),this.password=e.n()};50606102=({r:e},t)=>{t.t(e.e())};50606103=({r:e})=>{this.checkpoints=e.createArray(e.e(),()=>e.b())};50606104=({r:e})=>{this.isLapRace=e.a(),this.nbLaps=e.e()};50606105=({r:e})=>{this.modPackDesc=e.d()};50606106=({r:e},t)=>{t.t(e.l())};50606107=({r:e},t)=>{if(t.t(e.e())!=0)throw new Error("Unexpected value SOldIgs > 0 in chunk 0x0304301b")};50606108=({r:e})=>{this.playMode=e.e()};50606109=({r:e},t)=>{t.t(e.e())};50606111=({r:e},t)=>{this.blocks=[],this.mapInfo=e.u(),this.mapName=e.n(),this.decoration=e.u(),this.size=e.b(),this.needUnlock=e.a();let n=t.i(e.e()),s=e.e(),i=o(()=>{let a=e.c(),c=e.s(),p=e.v(),l=0;n>0?l=e.e():l=e.C();let b,C,k;if(l&32768&&(b=e.c(),C=e.l()),n<=1)return!1;if(n>=6&&(p.x-=1,p.z-=1),l&1<<19)throw new Error("Parsin not possible.");if(l&1<<20&&(k=e.l()),l&1<<18){let q=e.e(),Y=[];for(let W=0;W<q;W++){var j=Y[W];e.h(4),e.h(4);let J=e.e();for(let Z=0;Z<J;Z++)j[Z]=(e.c(),e.c(),e.c())}}if(l&1<<17){let q=e.c(),Y=e.h(4),W=e.h(4)}return this.blocks?.push({blockName:a,direction:c,position:p,flags:l,author:b,skin:C,waypointSpecialProperty:k}),!0},"readBlock");for(let a=0;a<s;a++)i();for(;(e.peekUInt32()&3221225472)>0;)i()};50606112=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606113=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606114=({r:e},t)=>{t.t(e.e())};50606115=({r:e})=>{this.mapCoordOrigin=e.k(),this.mapCoordTarget=this.mapCoordOrigin};50606116=({r:e})=>{this.customMusicPackDesc=e.d()};50606117=({r:e})=>{this.mapCoordOrigin=e.k(),this.mapCoordTarget=e.k()};50606118=({r:e},t)=>{t.t(e.l())};50606119=({r:e},t)=>{this.hasCustomCamThumbnail=e.a(),this.hasCustomCamThumbnail&&(t.t(e.s()),t.t(e.m()),t.t(e.m()),t.t(e.m()),this.thumbnailPosition=e.m(),this.thumbnailFov=e.o(),this.thumbnailNearClipPlane=e.o(),this.thumbnailFarClipPlane=e.o())};50606120=(e,t)=>{this[50606119](e,t);let{r:n}=e;this.comments=n.n()};50606121=({r:e})=>{this.hashedPassword=e.p(16),this.crc32=e.e()};50606122=({r:e})=>{this.createdWithSimpleEditor=e.a()};50606125=({r:e},t)=>{this.thumbnailPosition=e.m(),this.thumbnailPitchYawRoll=e.m(),this.thumbnailFov=e.o(),t.t(e.o()),t.t(e.o()),this.thumbnailNearClipPlane=e.o(),this.thumbnailFarClipPlane=e.o(),this.comments=e.n()};50606132=({r:e})=>{let t=e.e();e.p(t)};50606134=(e,t)=>{this[50606125](e,t)};50606144=({r:e,length:t},n)=>{n.i(e.e()),e.p(t-4)};50606146=({r:e},t)=>{t.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50606151=({r:e},t)=>{let n=t.i(e.e());if(t.t(e.n()),n>=1)throw new Error("Unexpected version >= 1 in chunk 0x03043047")};50606153=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606155=({r:e})=>{this.objectiveTextAuthor=e.n(),this.objectiveTextGold=e.n(),this.objectiveTextSilver=e.n(),this.objectiveTextBronze=e.n()};50606160=({r:e},t)=>{t.i(e.e()),this.offzoneTriggerSize=[e.e(),e.e(),e.e()],this.offzones=e.createArray(e.e(),()=>({1:e.b(),2:e.b()}))};50606161=({r:e},t)=>{t.i(e.e()),this.titleId=e.c(),this.buildVersion=e.n()};50606162=({r:e},t)=>{t.i(e.e()),this.decoBaseHeightOffset=e.e()};50606166=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.dayTime=e.e(),t.t(e.e()),this.dynamicDaylight=e.a(),this.dayDuration=e.e()};50606168=({r:e},t)=>{if(t.i(e.e()),t.t(e.e())>0)throw new Error("Unexpected value > 0 in chunk 0x03043058")};50606169=({r:e},t)=>{let n=t.i(e.e());if(this.worldDistortion=e.m(),n==0)throw new Error("Unexpected version 0 in chunk 0x03043059");if(n>=1&&t.t(e.a()))throw new Error("Unexpected value true in chunk 0x03043059");n>=3&&(t.t(e.e()),t.t(e.e()))};50606170=({r:e},t)=>{t.t(e.e()),t.t(e.e())};50606187=({r:e},t)=>{t.t(e.e()),this.dayTime=e.e(),t.t(e.e()),this.dynamicDaylight=e.a(),this.dayDuration=e.e()};50606165=({r:e},t)=>{let n=t.t(e.s());switch(this.unlimiter=-1,n){case 1:this.unlimiter=1.1;break;case 2:this.unlimiter=1.2;break}e.forceChunkSkip(50606165)};1056968704=({r:e},t)=>{this.unlimiter=1.3,e.forceChunkSkip(1056968704)};1056968705=({r:e},t)=>{let n=t.t(e.s());switch(this.unlimiter=-1,n){case 0:this.unlimiter=-1;break;case 1:this.unlimiter=.4;break;case 2:this.unlimiter=.6;break;case 3:this.unlimiter=.7;break;case 4:this.unlimiter=1.1;break;case 5:this.unlimiter=1.2;break;case 6:this.unlimiter=1.3;break;case 7:this.unlimiter=2;break}e.forceChunkSkip(1056968705)};1056968706=({r:e},t)=>{this.unlimiter=2,e.forceChunkSkip(1056968706)};1056968707=({r:e},t)=>{this.unlimiter=2,e.forceChunkSkip(1056968707)}};var w=class extends d{static{o(this,"CGameCtnChallengeParameters")}authorScore;authorTime;bronzeTime;goldTime;isValidatedForScriptModes;mapStyle;mapType;raceValidationGhost;silverTime;timeLimit;tip;tip1;tip2;tip3;tip4;50704384=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704385=({r:e})=>{this.tip1=e.n(),this.tip2=e.n(),this.tip3=e.n(),this.tip4=e.n()};50704386=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.o()),t.t(e.o()),t.t(e.o()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704387=({r:e},t)=>{t.t(e.e()),t.t(e.o()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704388=({r:e},t)=>{this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e(),t.t(e.e())};50704389=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e())};50704390=({r:e},t)=>{t.t(e.createArray(e.e(),()=>e.e()))};50704391=({r:e},t)=>{t.t(e.e())};50704392=({r:e})=>{this.timeLimit=e.e(),this.authorScore=e.e()};50704394=({r:e})=>{this.tip=e.n(),this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e(),this.timeLimit=e.e(),this.authorScore=e.e()};50704397=({r:e})=>{this.raceValidationGhost=e.l()};50704398=({r:e})=>{this.mapType=e.n(),this.mapStyle=e.n(),this.isValidatedForScriptModes=e.a()}};var T=class extends d{static{o(this,"CGameCtnCollectorList")}blockSet;50442240=({r:e})=>{this.blockSet=e.createArray(e.e(),()=>{let t=e.u(),n=e.e();return{blockModel:t,count:n}})}};var F=class extends y{static{o(this,"CGameGhost")}isReplaying;sampleData;sampleDataUncompressedSize;sampleRecords;sampleOffsets;sampleTimes;isFixedTimeStep;samplePeriod;sampleVersion;async decompressSampleData(){if(!this.sampleData||this.sampleData.length===0)return[];let e=await P.decompress(this.sampleData),t=new f(Array.from(e)),n=[];for(;t.bytesAvailable>=20;)try{let s={x:t.o(),y:t.o(),z:t.o()},i=t.C(),a=t.s(),c=t.s(),p=t.C(),l=t.s(),b=t.s();n.push({position:s,angle:i,axisHeading:a,axisPitch:c,speed:p,velHeading:l,velPitch:b})}catch{break}return this.sampleRecords=n,n}static speedToDisplaySpeed(e){return e===0?0:Math.exp(e/1e3)*1e3}50589699=({r:e})=>{let t=e.e();this.sampleData=e.p(t),this.sampleOffsets=e.createArray(e.e(),()=>e.e()),this.sampleTimes=e.createArray(e.e(),()=>e.e()),this.isFixedTimeStep=e.a(),this.samplePeriod=e.e(),this.sampleVersion=e.e()};50589700=({r:e},t)=>{t.t(e.e())};50589701=({r:e})=>{this.sampleDataUncompressedSize=e.e();let t=e.e();this.sampleData=e.p(t)};50589702=e=>{let{r:t}=e;this.isReplaying=t.a(),this[50589701](e)}};var g=class extends F{static{o(this,"CGameCtnGhost")}appearanceVersion;apperanceVersion;badge;checkpoints;controlEntries;controlNames;eventsDuration;ghostAvatarName;ghostClubTag;ghostLogin;ghostNickname;ghostTrigram;ghostUid;ghostZone;hasBadges;lightTrailColor;playerModel;raceTime;recordData;recordingContext;respawns;skinFile;skinPackDescs;steeringWheelSensitivity;stuntScore;validationChallengeUid;validationCpuKind;validationExeChecksum;validationExeVersion;validationOsKind;validationRaceSettings;validationTitleId;50929664=({r:e},t)=>{let n=e.e();n>=9&&(this.appearanceVersion=e.e()),this.playerModel=e.u(),this.lightTrailColor=e.m(),this.skinPackDescs=e.createArray(e.e(),()=>e.d()),this.hasBadges=e.a(),this.hasBadges&&(this.badge={},this.badge.version=e.e(),this.badge.color=[e.e(),e.e(),e.e()],this.badge.version==0&&(t.t(e.e()),t.t(e.n())),this.badge.stickers=e.createArray(e.e(),()=>{let s=e.n(),i=e.n();return{item1:s,item2:i}}),this.badge.layers=e.createArray(e.e(),()=>e.n())),(this.apperanceVersion??!1)&&t.t(e.n()),this.ghostNickname=e.n(),this.ghostAvatarName=e.n(),n>=2&&(this.recordingContext=e.n()),n>=4&&t.t(e.a()),n>=5&&(this.recordData=e.l(),t.t(e.createArray(e.e(),()=>e.e()))),n>=6&&(this.ghostTrigram=e.n()),n>=7&&(this.ghostZone=e.n()),n>=8&&(this.ghostClubTag=e.n())};50929667=({r:e})=>{this.playerModel=e.u(),this.skinFile=e.n(),this.ghostNickname=e.n()};50929668=({r:e})=>{let t=e.e();this.checkpoints=e.createArray(t,()=>{let n=e.e(),s=e.o();return{time:n,speed:s}})};50929669=({r:e})=>{this.raceTime=e.e()};50929670=({r:e},t)=>{this.playerModel=e.u(),this.skinFile=e.n(),t.t(e.e()),this.ghostNickname=e.n()};50929671=({r:e})=>{this.lightTrailColor=e.m()};50929672=({r:e})=>{this.respawns=e.e()};50929673=({r:e})=>{this.lightTrailColor=[e.e(),e.e(),e.e()]};50929674=({r:e})=>{this.stuntScore=e.e()};50929675=({r:e})=>{let t=e.e();this.checkpoints=e.createArray(t,()=>{let n=e.e(),s=e.e();return{time:n,stuntScore:s}})};50929676=({r:e},t)=>{t.t(e.e())};50929677=({r:e},t)=>{this.playerModel=e.u(),this.skinFile=e.n(),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),this.ghostNickname=e.n()};50929678=({r:e})=>{this.ghostUid=e.c()};50929679=({r:e})=>{this.ghostLogin=e.n()};50929680=({r:e})=>{this.validationChallengeUid=e.c()};50929681=({r:e},t)=>{if(this.eventsDuration=e.e(),this.eventsDuration==0)return;t.t(e.e()),this.controlNames=e.createArray(e.e(),()=>e.c());let n=e.e();t.t(e.e()),this.controlEntries=e.createArray(n,()=>{let s=e.e()-1e5,i=e.s(),a=e.e(),c=this.controlNames[i],p=["Steer","Gas","AccelerateReal","BrakeReal"].includes(c);return{name:c,time:s,value:a,analog:p}}),this.validationExeVersion=e.n(),this.validationExeChecksum=e.e(),this.validationOsKind=e.e(),this.validationCpuKind=e.e(),this.validationRaceSettings=e.n()};50929682=({r:e},t)=>{t.t(e.e()),t.t(e.h(16))};50929683=({r:e},t)=>{t.t(e.e()),t.t(e.e())};50929684=({r:e},t)=>{t.t(e.e())};50929685=({r:e})=>{this.ghostNickname=e.c()};50929687=({r:e})=>{this.skinPackDescs=e.createArray(e.e(),()=>e.d()),this.ghostNickname=e.n(),this.ghostAvatarName=e.n()};50929688=({r:e})=>{this.playerModel=e.u()};50929689=(e,t)=>{this[50929681](e,t);let{r:n}=e;this.eventsDuration!=0&&t.t(n.e())};50929690=({r:e},t)=>{t.t(e.e())};50929692=({r:e},t)=>{t.t(e.h(32))};50929699=({r:e},t)=>{let n=t.i(e.e());t.t(e.n()),t.t(e.e()),t.t(e.n()),t.t(e.e()),t.t(e.e()),t.t(e.n()),t.t(e.e()),t.t(e.n()),n>=2&&(t.t(e.s()),t.t(e.e()),t.t(e.e())),n>=3&&(t.t(e.s()),t.t(e.s()))};50929702=({r:e},t)=>{t.t(e.h(16))};50929704=({r:e},t)=>{(this.eventsDuration??!0)||(this.validationTitleId=e.n(),t.t(e.h(32)))}};var D=class{static{o(this,"CGameCtnMediaClip")}tracks;name;stopWhenLeave;stopWhenRespawn;localPlayerClipEntIndex;50827277=({r:e})=>{this.tracks=[];let t=e.e(),n=e.e();for(let a=0;a<n;a++){let c=e.l();this.tracks.push(c)}this.name=e.n(),this.stopWhenLeave=e.a();let s=e.e();this.stopWhenRespawn=e.a();let i=e.e();this.localPlayerClipEntIndex=e.e()}};var I=class extends d{static{o(this,"CGameCtnMediaBlock")}};var V=class{static{o(this,"CGameCtnMediaBlockTriangles")}50499585=({r:e})=>{let t=e.e(),n=[];for(let a=0;a<t;a++)n.push(e.o());t=e.e();let s=e.e();for(let a=0;a<t;a++)for(let c=0;c<s;c++){let p=e.m()}s=e.e();for(let a=0;a<s;a++){let c=e.m(),p=e.o()}let i=e.e();for(let a=0;a<i;a++){let c=e.e(),p=e.e(),l=e.e()}e.e(),e.e(),e.e(),e.o(),e.e(),e.h(8)}};var N=class{static{o(this,"CGameCtnMediaTrack")}name;blocks;keepPlaying;50823169=({r:e})=>{this.blocks=[];let t=e.n();e.e();let n=e.e();for(let i=0;i<n;i++){let a=e.l();this.blocks.push(a)}let s=e.e()};50823172=({r:e})=>{this.keepPlaying=e.a(),e.e()}};var M=class extends y{static{o(this,"CGameCtnReplayRecord")}authorExtraInfo;authorLogin;authorNickname;authorVersion;authorZone;challengeData;controlEntries;controlNames;eventsDuration;extras;game;ghosts;mapInfo;playerLogin;playerNickname;playgroundScript;recordData;time;titleId;xml;50933760=({r:e},t)=>{let n=t.i(e.e());n>=2&&(this.mapInfo=e.u(),this.time=e.e(),this.playerNickname=e.n()),n>=6&&(this.playerLogin=e.n()),n>=8&&(t.t(e.s()),this.titleId=e.c())};50933761=({r:e})=>{this.xml=e.n()};50933762=({r:e,isHeaderChunk:t},n)=>{if(t){n.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n();return}let s=e.e();this.challengeData=new B(e.p(s))};50933764=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.ghosts=e.createArray(e.e(),()=>e.l()),t.t(e.e()),t.t(e.e())};50933765=({r:e},t)=>{t.t(e.e())};50933767=({r:e},t)=>{t.t(e.e())};50933768=({r:e},t)=>{this.game=e.n(),t.t(e.e())};50933772=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933773=({r:e},t)=>{if(this.eventsDuration=e.e(),this.eventsDuration==0)return;t.t(e.e()),this.controlNames=e.createArray(e.e(),()=>e.c());let n=e.e();t.t(e.e()),this.controlEntries=e.createArray(n,()=>{let s=e.e()+1e5,i=e.s(),a=e.e(),c=this.controlNames[i],p=["Steer","Gas","AccelerateReal","BrakeReal"].includes(c);return{name:c,time:s,value:a,analog:p}})};50933774=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933775=({r:e},t)=>{this.game=e.n(),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.n())};50933776=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933780=({r:e},t)=>{t.i(e.e()),this.ghosts=e.createArray(e.e(),()=>e.l()),t.t(e.e()),this.extras=e.createArray(e.e(),()=>{let n=e.e(),s=e.e();return{extra1:n,extra2:s}})};50933781=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933784=({r:e})=>{this.titleId=e.c(),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50933787=({r:e},t)=>{t.i(e.e()),t.t(e.createArray(e.e(),()=>({1:e.e(),2:e.e()})))};50933788=({r:e},t)=>{t.i(e.e()),this.playgroundScript=e.n()};50933793=({r:e},t)=>{t.i(e.e()),t.t(e.a())};50933796=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.recordData=e.l()};50933797=({r:e},t)=>{t.i(e.e()),t.t(e.e()),t.t(e.e())}};var E=class extends d{static{o(this,"CGameWaypointSpecialProperty")}order;spawn;tag;771788800=({r:e},t)=>{let n=t.i(e.e());n==1?(this.spawn=e.e(),this.order=e.e()):n==2&&(this.tag=e.n(),this.order=e.e())}};var A=class extends d{static{o(this,"CPlugEntRecordData")}compressedData;compressedSize;uncompressedSize;152170496=({r:e},t)=>{t.i(e.e())>=5&&(this.uncompressedSize=e.e(),this.compressedSize=e.e(),this.compressedData=e.p(this.compressedSize))}};function $(r){return{50442240:T,50606080:S,50696192:v,50704384:w,50819072:I,50499584:V,50823168:N,50827264:D,50929664:g,50933760:M,152170496:A,771788800:E}[r]}o($,"getNodeType");var L=class{constructor(e){this.options=e;Object.assign(this,e)}static{o(this,"GBXReader")}current;fullChunkId=0;versions={};unknowns={};i(e){return this.versions[this.fullChunkId]=e,e}t(e){return this.unknowns[this.fullChunkId]===void 0&&(this.unknowns[this.fullChunkId]=[]),this.unknowns[this.fullChunkId].push(e),e}S(){let e=this.options.stream,t={};for(;;){let n=e.e();if(n==4207599105)break;if(t[n]=!0,e.peekUInt32()==1397442896){let i=e.e(),a=e.e();if(!this.G(n,!1,a)){m.warn(`Skipped chunk: 0x${x.fromDecimal(n)}`);let p=e.p(a);t[n]=!1}continue}if(!this.G(n))throw new Error(`Failed processing unskippable chunk 0x${x.fromDecimal(n)}.`)}return this.current.chunks=G.mergeChunks(t,this.unknowns,this.versions),this.current}G(e,t=!1,n=0){let s=this.options.stream;this.fullChunkId=e;let i=this.options.classId,a=e&4294963200;i=O[i]??i,a=O[a]??a;let c=$(i),p=a+(e&4095);return c===void 0||(this.current===void 0&&(this.current=new c),this.current[p]===void 0)?!1:(m.debug(`Processing ${t?"header chunk":"chunk"}: 0x${x.fromDecimal(p)}`),this.current[p]({r:s,length:n,fullChunkId:e,isHeaderChunk:t},{i:this.i.bind(this),t:this.t.bind(this)}),!0)}w(e){let t=this.options.headerChunks,n={};for(let s=0;s<t.length;s++){let i=t[s],a=e+i.chunkId;this.options.stream=new f(i.chunkData),this.G(a,!0)||(m.warn(`Skipped chunk: 0x${x.fromDecimal(a)}`),n[a]=!1),n[a]=!0}return this.current.chunks=G.mergeChunks(n,this.unknowns,this.versions),this.current}};var K={0:"Desert",1:"Snow",2:"Rally",3:"Island",4:"Bay",5:"Coast",6:"Stadium",7:"Basic",8:"Plain",9:"Moon",10:"Toy",11:"Valley",12:"Canyon",13:"Lagoon",14:"Deprecated_Arena",17:"TMCommon",18:"Canyon4",19:"Canyon256",20:"Valley4",21:"Valley256",22:"Lagoon4",23:"Lagoon256",24:"Stadium4",25:"Stadium256",26:"Trackmania",100:"History",101:"Society",102:"Galaxy",200:"Gothic",201:"Paris",202:"Storm",203:"Cryo",204:"Meteor",205:"Meteor4",206:"Meteor256",299:"SMCommon",1e4:"Vehicles",10001:"Orbital",10002:"Actors",10003:"Common",4294967295:"Unassigned"};var ce=new TextDecoder,f=class{static{o(this,"DataStream")}stream;position=0;constructor(e){this.stream=e}get bytesAvailable(){return this.stream.length-this.position}createArray(e,t){return Array.from({length:e},(n,s)=>t(s))}peekByte(e=0){return this.stream[this.position+e]}s(){let e=this.peekByte();if(e===void 0)throw new Error("Attempted to read an undefined byte.");return this.position++,e}peekBytes(e){return this.createArray(e,t=>this.peekByte(t))}p(e){return this.createArray(e,()=>this.s())}bytesToNumber(e){return e.reduce((t,n,s)=>t|n<<s*8,0)}peekNumbers(e){return this.bytesToNumber(this.peekBytes(e))>>>0}h(e){return this.bytesToNumber(this.p(e))>>>0}o(){let e=this.bytesToNumber(this.p(4));if(e==0)return 0;let t=e>>>31?-1:1,n=(e>>>23&255)-127,s=e&8388607|8388608;return t*s*Math.pow(2,n-23)}peekUInt16(){return this.peekNumbers(2)}C(){return this.h(2)}peekUInt32(){return this.peekNumbers(4)}e(){return this.h(4)}a(){return!!this.h(4)}n(e=0){return e==0&&(e=this.h(4)),ce.decode(new Uint8Array(this.p(e)))}g(){return this.n(1)}T(){return{x:this.e(),y:this.e()}}b(){return{x:this.e(),y:this.e(),z:this.e()}}k(){return{x:this.o(),y:this.o()}}m(){return{x:this.o(),y:this.o(),z:this.o()}}v(){return{x:this.s(),y:this.s(),z:this.s()}}u(){return{id:this.c(),collection:this.c(),author:this.c()}}d(){let e=this.s();e>=3&&this.p(32);let t=this.n();return(t.length>0&&e>=1||e>=3)&&this.n(),t}nodeList=[];l(){let e=this.h(4)<<1>>1;if(e==-1)return;let t=this.nodeList[e]!==void 0;if(e>=0&&!t){let n=this.e(),s=new L({stream:this,classId:n}).S();return this.nodeList[e]=s,s}if(t)return this.nodeList[e];throw new Error("Invalid node reference")}lookbackVersion;lookbackStrings=[];c(){this.lookbackVersion===void 0&&(this.lookbackVersion=this.e());let e=new Uint32Array([this.e()])[0];if(e==4294967295)return"";if((e&16383)==0&&(e>>30==1||e>>30==-2)){let t=this.n();return this.lookbackStrings.push(t),t}if((e&16383)==16383)switch(e>>30){case 2:return"Unassigned";case 3:return"";default:throw new Error("Invalid lookback string, the file provided may be corrupt")}return e>>30==0?K[e]===void 0?"Unknown collection":K[e]:this.lookbackStrings.length>(e&16383)-1?this.lookbackStrings[(e&16383)-1]:""}forceChunkSkip(e){for(;;){let t=this.peekUInt32();if((t&4294967040)==(e&4294967040)){m.warn(`Force skipped chunk: 0x${x.fromDecimal(e)}`);break}if(t==4207599105&&this.peekByte(4)===void 0){m.warn(`Force skipped chunk: 0x${x.fromDecimal(e)}`),m.warn("Reached end of file early");break}let n=this.s()}}};var x=class{static{o(this,"Hex")}static fromDecimal(e){return e.toString(16)}};var m=class{static{o(this,"Logger")}static showLogs=!1;static showDebug=!1;static showWarns=!1;static reset="\x1B[0m";static highlight(e,t=35){return`${`\x1B[${t}m`}${e}${this.reset}`}static log(...e){this.showLogs&&console.log(this.highlight("[INFO]",34),...e)}static debug(...e){this.showDebug&&console.log(this.highlight("[DEBUG]",35),...e)}static warn(...e){this.showWarns&&console.warn(this.highlight("[WARN]",33),...e)}static error(...e){console.error(this.highlight("[ERROR]",31),...e)}static outline(...e){console.log(this.highlight("[DEVEL]",41),this.highlight(e[0],35),...e.slice(1))}};var U=class{static{o(this,"LZOHandler")}static async compress(e){try{return u.compress(e)}catch(t){throw console.error(t),new Error("Failed to compress data, is the lzo-ts package installed?")}}static async decompress(e){try{return u.decompress(e)}catch(t){throw console.error(t),new Error("Failed to decompress data, is the lzo-ts package installed?")}}};var P=class{static{o(this,"ZLibHandler")}static async compress(e){try{return h.deflate(e)}catch(t){throw console.error(t),new Error("Failed to compress data, is the pako package installed?")}}static async decompress(e){try{return h.inflate(e)}catch(t){throw console.error(t),new Error("Failed to decompress data, is the pako package installed?")}}};var G=class{static{o(this,"Merger")}static mergeChunks(e,t,n){let s={};for(let i in e){if(e[i]===!1){s[i]=null;continue}s[i]={unknowns:t[i],version:n[i]}}return s}static mergeInstances(e,t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==void 0&&(e[n]=t[n]);return e}};var B=class{static{o(this,"GBX")}stream;classId;wrappedClassId;bodyCompression="C";constructor(e,t=2){t>=1&&(m.showWarns=!0),t>=2&&(m.showLogs=!0),t>=3&&(m.showDebug=!0),this.stream=new f(e)}async parseHeaders(){if(this.stream.n(3)!="GBX")return Promise.reject(new Error("Not a GBX file"));m.debug("Found GBX magic");let e=this.stream.C();if(e<3)return Promise.reject(new Error("Unsupported GBX version"));m.debug(`Reading GBX version ${e}`);let t=this.stream.g(),n=this.stream.g();this.bodyCompression=this.stream.g(),e>=4&&this.stream.g(),this.classId=this.stream.e(),this.wrappedClassId=O[this.classId],e>=6&&this.stream.e();let s=this.stream.e();if(s==0)return Promise.reject(new Error("No header chunks"));let i=[];for(let l=0;l<s;l++){let b=this.stream.e()&4095,C=this.stream.e()&2147483647,k=(C&2147483648)!=0;i.push({chunkId:b,chunkSize:C,isHeavy:k})}for(let l=0;l<s;l++)i[l].chunkData=this.stream.p(i[l].chunkSize);m.debug("Reading header data");let a=new L({headerChunks:i,classId:this.classId}).w(this.classId),c=this.stream.e();return this.stream.e()>0?Promise.reject(new Error("[Unimplemented] External nodes are not supported")):Promise.resolve(a)}async parse(){let e=await this.parseHeaders(),t;if(this.bodyCompression==="C"){let s=this.stream.e(),i=this.stream.e(),a=this.stream.p(i);m.debug(`Decompressing body: ${i} -> ${s} bytes`),t=new f(await U.decompress(a))}else{m.debug("Reading uncompressed body");let s=this.stream.p(this.stream.bytesAvailable);t=new f(s)}m.debug("Reading body data");let n=new L({stream:t,classId:this.classId}).S();return Promise.resolve(G.mergeInstances(e,n))}};var X;(a=>{function r(c){if(c instanceof g)return c.checkpoints?.length||void 0;let p=c.chunks?.[50606111]?.version,l=new Set,b=0;if(p>=6)c.blocks?.forEach(C=>{let k=C.waypointSpecialProperty;if(k?.order!==void 0&&(k?.tag=="Checkpoint"&&b++,k?.tag=="LinkedCheckpoint")){if(l.has(k.order))return;b++,l.add(k.order)}});else return c.checkpoints?.length||void 0;if(c.blocks!==void 0)return c.nbCheckpoints&&b<c.nbCheckpoints?(m.warn("The amount of checkpoints doesn't match the amount of checkpoints in the header. Returning amount of header."),c.nbCheckpoints):b}a.getCheckpointCount=r,o(r,"getCheckpointCount");function e(c){return c.controlEntries?.filter(p=>p?.name=="Respawn"&&p?.value==1)}o(e,"getRespawns");function t(c){return e(c)?.length}a.getRespawnsCount=t,o(t,"getRespawnsCount");function n(c){return c.checkpoints?.map(p=>p.time)}a.getCheckpointTimes=n,o(n,"getCheckpointTimes");function s(c){let p=n(c),l=e(c);if(p===void 0||l===void 0)return;let b=p.map(()=>0),C=0;for(let k of l){let j=p[C];k.time>=j&&C++,b[C]++}return b}a.getRespawnsByCheckpoint=s,o(s,"getRespawnsByCheckpoint");function i(c){let p=n(c);if(p!==void 0)return p.map((l,b,C)=>{let k=C[b-1]||0;return l-k})}a.getSectorTimes=i,o(i,"getSectorTimes")})(X||={});0&&(module.exports={CGameCtnBlock,CGameCtnBlockSkin,CGameCtnChallenge,CGameCtnChallengeParameters,CGameCtnCollectorList,CGameCtnGhost,CGameCtnMediaBlock,CGameCtnMediaClip,CGameCtnMediaTrack,CGameCtnReplayRecord,CGameGhost,CGameWaypointSpecialProperty,CPlugEntRecordData,GBX,Utils,ZLibHandler});
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ var J=Object.defineProperty;var o=(p,e)=>J(p,"name",{value:e,configurable:!0});var U={554172416:50606080,554225664:50933760,603992064:50606080,604028928:50704384,604090368:50929664,604217344:50696192,604225536:50442240,604237824:50933760,604377088:50823168,604381184:50823168,604463104:50827264,604495872:50933760,50638848:50499584};var z=class{static{o(this,"CGameCtnBlock")}author;blockName;direction;flags;position;skin;waypointSpecialProperty};var d=class{static{o(this,"Node")}chunks={}};var G=class extends d{static{o(this,"CGameCtnBlockSkin")}foregroundPackDesc;packDesc;parentPackDesc;text;50696192=({r:e},t)=>{this.text=e.n(),t.t(e.n())};50696193=({r:e})=>{this.text=e.n(),this.packDesc=e.d()};50696194=({r:e})=>{this.text=e.n(),this.packDesc=e.d(),this.parentPackDesc=e.d()};50696195=({r:e},t)=>{t.i(e.e()),this.foregroundPackDesc=e.d()}};var g=class extends d{static{o(this,"GameVersion")}f(e){return Object.keys(e).map(t=>parseInt(t,10))}isTM2020(){let e=this.f(this.chunks),t=e.some(i=>i>50606169&&i<=50610175),n=e.some(i=>i>50929704&&i<=50933759),s=e.some(i=>i>50933798&&i<=50937855);return t||n||s}isManiaPlanet(){let e=this.f(this.chunks),t=e.some(i=>i>50606122&&i<=50610175),n=e.some(i=>i>50929689&&i<=50933759),s=e.some(i=>i>50933781&&i<=50937855);return t||n||s}isTurbo(){let e=this.f(this.chunks),t=this.chunks[50606144]?.version>2&&!e.some(i=>i>50606165&&i<=50610175),n=e.some(i=>i==50929664)&&!e.some(i=>i>50929703&&i<=50933759),s=e.some(i=>i>50933793)&&!e.some(i=>i>50933795&&i<=50937855);return t||n||s}isTMF(){let e=this.f(this.chunks),t=e.some(i=>i>=50606080)&&!e.some(i=>i>50606122&&i<=50610175),n=e.some(i=>i>=50929664)&&!e.some(i=>i>50929689),s=e.some(i=>i>=50933760)&&!e.some(i=>i>50933781);return t||n||s}};var v=class extends g{static{o(this,"CGameCtnChallenge")}authorExtraInfo;authorLogin;authorNickname;authorScore;authorTime;authorVersion;authorZone;blocks;blockStock;bronzeTime;buildVersion;challengeParameters;checkpoints;comments;cost;crc32;createdWithSimpleEditor;customMusicPackDesc;dayDuration;dayTime;decoBaseHeightOffset;decoration;dynamicDaylight;editorMode;goldTime;hasCustomCamThumbnail;hashedPassword;headerVersion;isLapRace;isMultilap;lightmapCacheUid;lightmapVersion;mapCoordOrigin;mapCoordTarget;mapInfo;mapKind;mapName;mapStyle;mapType;modPackDesc;nbCheckpoints;nbLaps;needUnlock;objectiveTextAuthor;objectiveTextBronze;objectiveTextGold;objectiveTextSilver;offzones;offzoneTriggerSize;packMask;password;playerModel;playMode;silverTime;size;thumbnailData;thumbnailFarClipPlane;thumbnailFov;thumbnailNearClipPlane;thumbnailPitchYawRoll;thumbnailPosition;thumbnailSize;titleId;unlimiter;worldDistortion;xml;50606082=({r:e},t)=>{let n=t.i(e.s());n<=2&&(this.mapInfo=e.u(),this.mapName=e.n()),t.t(e.a()),n>=1&&(this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e()),n==2&&t.t(e.s()),n>=4&&(this.cost=e.e()),n>=5&&(this.isLapRace=e.a()),n==6&&(this.isMultilap=e.a()),n>=7&&(this.playMode=e.e()),n>=9&&t.t(e.e()),n>=10&&(this.authorScore=e.e()),n>=11&&(this.editorMode=e.e()),n>=12&&t.t(e.e()),n>=13&&(this.nbCheckpoints=e.e(),this.nbLaps=e.e())};50606083=({r:e},t)=>{let n=t.i(e.s());this.mapInfo=e.u(),this.mapName=e.n(),this.mapKind=e.s(),n>=1&&(t.t(e.e()),this.password=e.n()),n>=2&&(this.decoration=e.u()),n>=3&&(this.mapCoordOrigin=e.k()),n>=4&&(this.mapCoordTarget=e.k()),n>=5&&(this.packMask=e.h(16)),n>=6&&(this.mapType=e.n(),this.mapStyle=e.n()),n>=8&&(this.lightmapCacheUid=e.h(8)),n>=9&&(this.lightmapVersion=e.s()),n>=11&&(this.titleId=e.c())};50606084=({r:e})=>{this.headerVersion=e.e()};50606085=({r:e})=>{this.xml=e.n()};50606087=({r:e},t)=>{t.i(e.e()),this.thumbnailSize=e.e(),e.n(15),this.thumbnailData=e.p(this.thumbnailSize),e.n(16),e.n(10),this.comments=e.n(),e.n(11)};50606088=({r:e},t)=>{t.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50606093=({r:e})=>{this.playerModel=e.u()};50606095=({r:e})=>{this.mapInfo=e.u(),this.size=e.b(),this.blocks=e.createArray(e.e(),()=>e.l()),this.needUnlock=e.a(),this.decoration=e.u()};50606097=({r:e})=>{this.blockStock=e.l(),this.challengeParameters=e.l(),this.mapKind=e.e()};50606099=({r:e},t)=>{this.mapInfo=e.u(),this.mapName=e.n(),this.decoration=e.u(),this.size=e.b(),t.t(e.a()),this.blocks=e.createArray(e.e(),()=>{let n=e.c(),s=e.s(),i=e.G(),r=e.C();return{blockName:n,direction:s,position:i,flags:r}})};50606100=({r:e},t)=>{t.t(e.a()),this.password=e.n()};50606102=({r:e},t)=>{t.t(e.e())};50606103=({r:e})=>{this.checkpoints=e.createArray(e.e(),()=>e.b())};50606104=({r:e})=>{this.isLapRace=e.a(),this.nbLaps=e.e()};50606105=({r:e})=>{this.modPackDesc=e.d()};50606106=({r:e},t)=>{t.t(e.l())};50606107=({r:e},t)=>{if(t.t(e.e())!=0)throw new Error("Unexpected value SOldIgs > 0 in chunk 0x0304301b")};50606108=({r:e})=>{this.playMode=e.e()};50606109=({r:e},t)=>{t.t(e.e())};50606111=({r:e},t)=>{this.blocks=[],this.mapInfo=e.u(),this.mapName=e.n(),this.decoration=e.u(),this.size=e.b(),this.needUnlock=e.a();let n=t.i(e.e()),s=e.e(),i=o(()=>{let r=e.c(),a=e.s(),c=e.G(),l=0;n>0?l=e.e():l=e.C();let b,C,k;if(l&32768&&(b=e.c(),C=e.l()),n<=1)return!1;if(n>=6&&(c.x-=1,c.z-=1),l&1<<19)throw new Error("Parsin not possible.");if(l&1<<20&&(k=e.l()),l&1<<18){let $=e.e(),K=[];for(let O=0;O<$;O++){var Z=K[O];e.h(4),e.h(4);let _=e.e();for(let W=0;W<_;W++)Z[W]=(e.c(),e.c(),e.c())}}if(l&1<<17){let $=e.c(),K=e.h(4),O=e.h(4)}return this.blocks?.push({blockName:r,direction:a,position:c,flags:l,author:b,skin:C,waypointSpecialProperty:k}),!0},"readBlock");for(let r=0;r<s;r++)i();for(;(e.peekUInt32()&3221225472)>0;)i()};50606112=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606113=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606114=({r:e},t)=>{t.t(e.e())};50606115=({r:e})=>{this.mapCoordOrigin=e.k(),this.mapCoordTarget=this.mapCoordOrigin};50606116=({r:e})=>{this.customMusicPackDesc=e.d()};50606117=({r:e})=>{this.mapCoordOrigin=e.k(),this.mapCoordTarget=e.k()};50606118=({r:e},t)=>{t.t(e.l())};50606119=({r:e},t)=>{this.hasCustomCamThumbnail=e.a(),this.hasCustomCamThumbnail&&(t.t(e.s()),t.t(e.m()),t.t(e.m()),t.t(e.m()),this.thumbnailPosition=e.m(),this.thumbnailFov=e.o(),this.thumbnailNearClipPlane=e.o(),this.thumbnailFarClipPlane=e.o())};50606120=(e,t)=>{this[50606119](e,t);let{r:n}=e;this.comments=n.n()};50606121=({r:e})=>{this.hashedPassword=e.p(16),this.crc32=e.e()};50606122=({r:e})=>{this.createdWithSimpleEditor=e.a()};50606125=({r:e},t)=>{this.thumbnailPosition=e.m(),this.thumbnailPitchYawRoll=e.m(),this.thumbnailFov=e.o(),t.t(e.o()),t.t(e.o()),this.thumbnailNearClipPlane=e.o(),this.thumbnailFarClipPlane=e.o(),this.comments=e.n()};50606132=({r:e})=>{let t=e.e();e.p(t)};50606134=(e,t)=>{this[50606125](e,t)};50606144=({r:e,length:t},n)=>{n.i(e.e()),e.p(t-4)};50606146=({r:e},t)=>{t.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50606151=({r:e},t)=>{let n=t.i(e.e());if(t.t(e.n()),n>=1)throw new Error("Unexpected version >= 1 in chunk 0x03043047")};50606153=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50606155=({r:e})=>{this.objectiveTextAuthor=e.n(),this.objectiveTextGold=e.n(),this.objectiveTextSilver=e.n(),this.objectiveTextBronze=e.n()};50606160=({r:e},t)=>{t.i(e.e()),this.offzoneTriggerSize=[e.e(),e.e(),e.e()],this.offzones=e.createArray(e.e(),()=>({1:e.b(),2:e.b()}))};50606161=({r:e},t)=>{t.i(e.e()),this.titleId=e.c(),this.buildVersion=e.n()};50606162=({r:e},t)=>{t.i(e.e()),this.decoBaseHeightOffset=e.e()};50606166=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.dayTime=e.e(),t.t(e.e()),this.dynamicDaylight=e.a(),this.dayDuration=e.e()};50606168=({r:e},t)=>{if(t.i(e.e()),t.t(e.e())>0)throw new Error("Unexpected value > 0 in chunk 0x03043058")};50606169=({r:e},t)=>{let n=t.i(e.e());if(this.worldDistortion=e.m(),n==0)throw new Error("Unexpected version 0 in chunk 0x03043059");if(n>=1&&t.t(e.a()))throw new Error("Unexpected value true in chunk 0x03043059");n>=3&&(t.t(e.e()),t.t(e.e()))};50606170=({r:e},t)=>{t.t(e.e()),t.t(e.e())};50606187=({r:e},t)=>{t.t(e.e()),this.dayTime=e.e(),t.t(e.e()),this.dynamicDaylight=e.a(),this.dayDuration=e.e()};50606165=({r:e},t)=>{let n=t.t(e.s());switch(this.unlimiter=-1,n){case 1:this.unlimiter=1.1;break;case 2:this.unlimiter=1.2;break}e.forceChunkSkip(50606165)};1056968704=({r:e},t)=>{this.unlimiter=1.3,e.forceChunkSkip(1056968704)};1056968705=({r:e},t)=>{let n=t.t(e.s());switch(this.unlimiter=-1,n){case 0:this.unlimiter=-1;break;case 1:this.unlimiter=.4;break;case 2:this.unlimiter=.6;break;case 3:this.unlimiter=.7;break;case 4:this.unlimiter=1.1;break;case 5:this.unlimiter=1.2;break;case 6:this.unlimiter=1.3;break;case 7:this.unlimiter=2;break}e.forceChunkSkip(1056968705)};1056968706=({r:e},t)=>{this.unlimiter=2,e.forceChunkSkip(1056968706)};1056968707=({r:e},t)=>{this.unlimiter=2,e.forceChunkSkip(1056968707)}};var S=class extends d{static{o(this,"CGameCtnChallengeParameters")}authorScore;authorTime;bronzeTime;goldTime;isValidatedForScriptModes;mapStyle;mapType;raceValidationGhost;silverTime;timeLimit;tip;tip1;tip2;tip3;tip4;50704384=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704385=({r:e})=>{this.tip1=e.n(),this.tip2=e.n(),this.tip3=e.n(),this.tip4=e.n()};50704386=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.o()),t.t(e.o()),t.t(e.o()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704387=({r:e},t)=>{t.t(e.e()),t.t(e.o()),t.t(e.e()),t.t(e.e()),t.t(e.e())};50704388=({r:e},t)=>{this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e(),t.t(e.e())};50704389=({r:e},t)=>{t.t(e.e()),t.t(e.e()),t.t(e.e())};50704390=({r:e},t)=>{t.t(e.createArray(e.e(),()=>e.e()))};50704391=({r:e},t)=>{t.t(e.e())};50704392=({r:e})=>{this.timeLimit=e.e(),this.authorScore=e.e()};50704394=({r:e})=>{this.tip=e.n(),this.bronzeTime=e.e(),this.silverTime=e.e(),this.goldTime=e.e(),this.authorTime=e.e(),this.timeLimit=e.e(),this.authorScore=e.e()};50704397=({r:e})=>{this.raceValidationGhost=e.l()};50704398=({r:e})=>{this.mapType=e.n(),this.mapStyle=e.n(),this.isValidatedForScriptModes=e.a()}};var T=class extends d{static{o(this,"CGameCtnCollectorList")}blockSet;50442240=({r:e})=>{this.blockSet=e.createArray(e.e(),()=>{let t=e.u(),n=e.e();return{blockModel:t,count:n}})}};var F=class extends g{static{o(this,"CGameGhost")}isReplaying;sampleData;sampleDataUncompressedSize;sampleRecords;sampleOffsets;sampleTimes;isFixedTimeStep;samplePeriod;sampleVersion;async decompressSampleData(){if(!this.sampleData||this.sampleData.length===0)return[];let e=await P.decompress(this.sampleData),t=new f(Array.from(e)),n=[];for(;t.bytesAvailable>=20;)try{let s={x:t.o(),y:t.o(),z:t.o()},i=t.C(),r=t.s(),a=t.s(),c=t.C(),l=t.s(),b=t.s();n.push({position:s,angle:i,axisHeading:r,axisPitch:a,speed:c,velHeading:l,velPitch:b})}catch{break}return this.sampleRecords=n,n}static speedToDisplaySpeed(e){return e===0?0:Math.exp(e/1e3)*1e3}50589699=({r:e})=>{let t=e.e();this.sampleData=e.p(t),this.sampleOffsets=e.createArray(e.e(),()=>e.e()),this.sampleTimes=e.createArray(e.e(),()=>e.e()),this.isFixedTimeStep=e.a(),this.samplePeriod=e.e(),this.sampleVersion=e.e()};50589700=({r:e},t)=>{t.t(e.e())};50589701=({r:e})=>{this.sampleDataUncompressedSize=e.e();let t=e.e();this.sampleData=e.p(t)};50589702=e=>{let{r:t}=e;this.isReplaying=t.a(),this[50589701](e)}};var y=class extends F{static{o(this,"CGameCtnGhost")}appearanceVersion;apperanceVersion;badge;checkpoints;controlEntries;controlNames;eventsDuration;ghostAvatarName;ghostClubTag;ghostLogin;ghostNickname;ghostTrigram;ghostUid;ghostZone;hasBadges;lightTrailColor;playerModel;raceTime;recordData;recordingContext;respawns;skinFile;skinPackDescs;steeringWheelSensitivity;stuntScore;validationChallengeUid;validationCpuKind;validationExeChecksum;validationExeVersion;validationOsKind;validationRaceSettings;validationTitleId;50929664=({r:e},t)=>{let n=e.e();n>=9&&(this.appearanceVersion=e.e()),this.playerModel=e.u(),this.lightTrailColor=e.m(),this.skinPackDescs=e.createArray(e.e(),()=>e.d()),this.hasBadges=e.a(),this.hasBadges&&(this.badge={},this.badge.version=e.e(),this.badge.color=[e.e(),e.e(),e.e()],this.badge.version==0&&(t.t(e.e()),t.t(e.n())),this.badge.stickers=e.createArray(e.e(),()=>{let s=e.n(),i=e.n();return{item1:s,item2:i}}),this.badge.layers=e.createArray(e.e(),()=>e.n())),(this.apperanceVersion??!1)&&t.t(e.n()),this.ghostNickname=e.n(),this.ghostAvatarName=e.n(),n>=2&&(this.recordingContext=e.n()),n>=4&&t.t(e.a()),n>=5&&(this.recordData=e.l(),t.t(e.createArray(e.e(),()=>e.e()))),n>=6&&(this.ghostTrigram=e.n()),n>=7&&(this.ghostZone=e.n()),n>=8&&(this.ghostClubTag=e.n())};50929667=({r:e})=>{this.playerModel=e.u(),this.skinFile=e.n(),this.ghostNickname=e.n()};50929668=({r:e})=>{let t=e.e();this.checkpoints=e.createArray(t,()=>{let n=e.e(),s=e.o();return{time:n,speed:s}})};50929669=({r:e})=>{this.raceTime=e.e()};50929670=({r:e},t)=>{this.playerModel=e.u(),this.skinFile=e.n(),t.t(e.e()),this.ghostNickname=e.n()};50929671=({r:e})=>{this.lightTrailColor=e.m()};50929672=({r:e})=>{this.respawns=e.e()};50929673=({r:e})=>{this.lightTrailColor=[e.e(),e.e(),e.e()]};50929674=({r:e})=>{this.stuntScore=e.e()};50929675=({r:e})=>{let t=e.e();this.checkpoints=e.createArray(t,()=>{let n=e.e(),s=e.e();return{time:n,stuntScore:s}})};50929676=({r:e},t)=>{t.t(e.e())};50929677=({r:e},t)=>{this.playerModel=e.u(),this.skinFile=e.n(),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.e()),this.ghostNickname=e.n()};50929678=({r:e})=>{this.ghostUid=e.c()};50929679=({r:e})=>{this.ghostLogin=e.n()};50929680=({r:e})=>{this.validationChallengeUid=e.c()};50929681=({r:e},t)=>{if(this.eventsDuration=e.e(),this.eventsDuration==0)return;t.t(e.e()),this.controlNames=e.createArray(e.e(),()=>e.c());let n=e.e();t.t(e.e()),this.controlEntries=e.createArray(n,()=>{let s=e.e()-1e5,i=e.s(),r=e.e(),a=this.controlNames[i],c=["Steer","Gas","AccelerateReal","BrakeReal"].includes(a);return{name:a,time:s,value:r,analog:c}}),this.validationExeVersion=e.n(),this.validationExeChecksum=e.e(),this.validationOsKind=e.e(),this.validationCpuKind=e.e(),this.validationRaceSettings=e.n()};50929682=({r:e},t)=>{t.t(e.e()),t.t(e.h(16))};50929683=({r:e},t)=>{t.t(e.e()),t.t(e.e())};50929684=({r:e},t)=>{t.t(e.e())};50929685=({r:e})=>{this.ghostNickname=e.c()};50929687=({r:e})=>{this.skinPackDescs=e.createArray(e.e(),()=>e.d()),this.ghostNickname=e.n(),this.ghostAvatarName=e.n()};50929688=({r:e})=>{this.playerModel=e.u()};50929689=(e,t)=>{this[50929681](e,t);let{r:n}=e;this.eventsDuration!=0&&t.t(n.e())};50929690=({r:e},t)=>{t.t(e.e())};50929692=({r:e},t)=>{t.t(e.h(32))};50929699=({r:e},t)=>{let n=t.i(e.e());t.t(e.n()),t.t(e.e()),t.t(e.n()),t.t(e.e()),t.t(e.e()),t.t(e.n()),t.t(e.e()),t.t(e.n()),n>=2&&(t.t(e.s()),t.t(e.e()),t.t(e.e())),n>=3&&(t.t(e.s()),t.t(e.s()))};50929702=({r:e},t)=>{t.t(e.h(16))};50929704=({r:e},t)=>{(this.eventsDuration??!0)||(this.validationTitleId=e.n(),t.t(e.h(32)))}};var D=class{static{o(this,"CGameCtnMediaClip")}tracks;name;stopWhenLeave;stopWhenRespawn;localPlayerClipEntIndex;50827277=({r:e})=>{this.tracks=[];let t=e.e(),n=e.e();for(let r=0;r<n;r++){let a=e.l();this.tracks.push(a)}this.name=e.n(),this.stopWhenLeave=e.a();let s=e.e();this.stopWhenRespawn=e.a();let i=e.e();this.localPlayerClipEntIndex=e.e()}};var I=class extends d{static{o(this,"CGameCtnMediaBlock")}};var B=class{static{o(this,"CGameCtnMediaBlockTriangles")}50499585=({r:e})=>{let t=e.e(),n=[];for(let r=0;r<t;r++)n.push(e.o());t=e.e();let s=e.e();for(let r=0;r<t;r++)for(let a=0;a<s;a++){let c=e.m()}s=e.e();for(let r=0;r<s;r++){let a=e.m(),c=e.o()}let i=e.e();for(let r=0;r<i;r++){let a=e.e(),c=e.e(),l=e.e()}e.e(),e.e(),e.e(),e.o(),e.e(),e.h(8)}};var N=class{static{o(this,"CGameCtnMediaTrack")}name;blocks;keepPlaying;50823169=({r:e})=>{this.blocks=[];let t=e.n();e.e();let n=e.e();for(let i=0;i<n;i++){let r=e.l();this.blocks.push(r)}let s=e.e()};50823172=({r:e})=>{this.keepPlaying=e.a(),e.e()}};var L=class extends g{static{o(this,"CGameCtnReplayRecord")}authorExtraInfo;authorLogin;authorNickname;authorVersion;authorZone;challengeData;controlEntries;controlNames;eventsDuration;extras;game;ghosts;mapInfo;playerLogin;playerNickname;playgroundScript;recordData;time;titleId;xml;50933760=({r:e},t)=>{let n=t.i(e.e());n>=2&&(this.mapInfo=e.u(),this.time=e.e(),this.playerNickname=e.n()),n>=6&&(this.playerLogin=e.n()),n>=8&&(t.t(e.s()),this.titleId=e.c())};50933761=({r:e})=>{this.xml=e.n()};50933762=({r:e,isHeaderChunk:t},n)=>{if(t){n.i(e.e()),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n();return}let s=e.e();this.challengeData=new R(e.p(s))};50933764=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.ghosts=e.createArray(e.e(),()=>e.l()),t.t(e.e()),t.t(e.e())};50933765=({r:e},t)=>{t.t(e.e())};50933767=({r:e},t)=>{t.t(e.e())};50933768=({r:e},t)=>{this.game=e.n(),t.t(e.e())};50933772=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933773=({r:e},t)=>{if(this.eventsDuration=e.e(),this.eventsDuration==0)return;t.t(e.e()),this.controlNames=e.createArray(e.e(),()=>e.c());let n=e.e();t.t(e.e()),this.controlEntries=e.createArray(n,()=>{let s=e.e()+1e5,i=e.s(),r=e.e(),a=this.controlNames[i],c=["Steer","Gas","AccelerateReal","BrakeReal"].includes(a);return{name:a,time:s,value:r,analog:c}})};50933774=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933775=({r:e},t)=>{this.game=e.n(),t.t(e.e()),t.t(e.e()),t.t(e.e()),t.t(e.n())};50933776=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933780=({r:e},t)=>{t.i(e.e()),this.ghosts=e.createArray(e.e(),()=>e.l()),t.t(e.e()),this.extras=e.createArray(e.e(),()=>{let n=e.e(),s=e.e();return{extra1:n,extra2:s}})};50933781=({r:e,fullChunkId:t})=>{e.forceChunkSkip(t)};50933784=({r:e})=>{this.titleId=e.c(),this.authorVersion=e.e(),this.authorLogin=e.n(),this.authorNickname=e.n(),this.authorZone=e.n(),this.authorExtraInfo=e.n()};50933787=({r:e},t)=>{t.i(e.e()),t.t(e.createArray(e.e(),()=>({1:e.e(),2:e.e()})))};50933788=({r:e},t)=>{t.i(e.e()),this.playgroundScript=e.n()};50933793=({r:e},t)=>{t.i(e.e()),t.t(e.a())};50933796=({r:e},t)=>{t.i(e.e()),t.t(e.e()),this.recordData=e.l()};50933797=({r:e},t)=>{t.i(e.e()),t.t(e.e()),t.t(e.e())}};var M=class extends d{static{o(this,"CGameWaypointSpecialProperty")}order;spawn;tag;771788800=({r:e},t)=>{let n=t.i(e.e());n==1?(this.spawn=e.e(),this.order=e.e()):n==2&&(this.tag=e.n(),this.order=e.e())}};var A=class extends d{static{o(this,"CPlugEntRecordData")}compressedData;compressedSize;uncompressedSize;152170496=({r:e},t)=>{t.i(e.e())>=5&&(this.uncompressedSize=e.e(),this.compressedSize=e.e(),this.compressedData=e.p(this.compressedSize))}};function j(p){return{50442240:T,50606080:v,50696192:G,50704384:S,50819072:I,50499584:B,50823168:N,50827264:D,50929664:y,50933760:L,152170496:A,771788800:M}[p]}o(j,"getNodeType");var E=class{constructor(e){this.options=e;Object.assign(this,e)}static{o(this,"GBXReader")}current;fullChunkId=0;versions={};unknowns={};i(e){return this.versions[this.fullChunkId]=e,e}t(e){return this.unknowns[this.fullChunkId]===void 0&&(this.unknowns[this.fullChunkId]=[]),this.unknowns[this.fullChunkId].push(e),e}v(){let e=this.options.stream,t={};for(;;){let n=e.e();if(n==4207599105)break;if(t[n]=!0,e.peekUInt32()==1397442896){let i=e.e(),r=e.e();if(!this.w(n,!1,r)){m.warn(`Skipped chunk: 0x${x.fromDecimal(n)}`);let c=e.p(r);t[n]=!1}continue}if(!this.w(n))throw new Error(`Failed processing unskippable chunk 0x${x.fromDecimal(n)}.`)}return this.current.chunks=w.mergeChunks(t,this.unknowns,this.versions),this.current}w(e,t=!1,n=0){let s=this.options.stream;this.fullChunkId=e;let i=this.options.classId,r=e&4294963200;i=U[i]??i,r=U[r]??r;let a=j(i),c=r+(e&4095);return a===void 0||(this.current===void 0&&(this.current=new a),this.current[c]===void 0)?!1:(m.debug(`Processing ${t?"header chunk":"chunk"}: 0x${x.fromDecimal(c)}`),this.current[c]({r:s,length:n,fullChunkId:e,isHeaderChunk:t},{i:this.i.bind(this),t:this.t.bind(this)}),!0)}S(e){let t=this.options.headerChunks,n={};for(let s=0;s<t.length;s++){let i=t[s],r=e+i.chunkId;this.options.stream=new f(i.chunkData),this.w(r,!0)||(m.warn(`Skipped chunk: 0x${x.fromDecimal(r)}`),n[r]=!1),n[r]=!0}return this.current.chunks=w.mergeChunks(n,this.unknowns,this.versions),this.current}};var H={0:"Desert",1:"Snow",2:"Rally",3:"Island",4:"Bay",5:"Coast",6:"Stadium",7:"Basic",8:"Plain",9:"Moon",10:"Toy",11:"Valley",12:"Canyon",13:"Lagoon",14:"Deprecated_Arena",17:"TMCommon",18:"Canyon4",19:"Canyon256",20:"Valley4",21:"Valley256",22:"Lagoon4",23:"Lagoon256",24:"Stadium4",25:"Stadium256",26:"Trackmania",100:"History",101:"Society",102:"Galaxy",200:"Gothic",201:"Paris",202:"Storm",203:"Cryo",204:"Meteor",205:"Meteor4",206:"Meteor256",299:"SMCommon",1e4:"Vehicles",10001:"Orbital",10002:"Actors",10003:"Common",4294967295:"Unassigned"};var te=new TextDecoder,f=class{static{o(this,"DataStream")}stream;position=0;constructor(e){this.stream=e}get bytesAvailable(){return this.stream.length-this.position}createArray(e,t){return Array.from({length:e},(n,s)=>t(s))}peekByte(e=0){return this.stream[this.position+e]}s(){let e=this.peekByte();if(e===void 0)throw new Error("Attempted to read an undefined byte.");return this.position++,e}peekBytes(e){return this.createArray(e,t=>this.peekByte(t))}p(e){return this.createArray(e,()=>this.s())}bytesToNumber(e){return e.reduce((t,n,s)=>t|n<<s*8,0)}peekNumbers(e){return this.bytesToNumber(this.peekBytes(e))>>>0}h(e){return this.bytesToNumber(this.p(e))>>>0}o(){let e=this.bytesToNumber(this.p(4));if(e==0)return 0;let t=e>>>31?-1:1,n=(e>>>23&255)-127,s=e&8388607|8388608;return t*s*Math.pow(2,n-23)}peekUInt16(){return this.peekNumbers(2)}C(){return this.h(2)}peekUInt32(){return this.peekNumbers(4)}e(){return this.h(4)}a(){return!!this.h(4)}n(e=0){return e==0&&(e=this.h(4)),te.decode(new Uint8Array(this.p(e)))}g(){return this.n(1)}T(){return{x:this.e(),y:this.e()}}b(){return{x:this.e(),y:this.e(),z:this.e()}}k(){return{x:this.o(),y:this.o()}}m(){return{x:this.o(),y:this.o(),z:this.o()}}G(){return{x:this.s(),y:this.s(),z:this.s()}}u(){return{id:this.c(),collection:this.c(),author:this.c()}}d(){let e=this.s();e>=3&&this.p(32);let t=this.n();return(t.length>0&&e>=1||e>=3)&&this.n(),t}nodeList=[];l(){let e=this.h(4)<<1>>1;if(e==-1)return;let t=this.nodeList[e]!==void 0;if(e>=0&&!t){let n=this.e(),s=new E({stream:this,classId:n}).v();return this.nodeList[e]=s,s}if(t)return this.nodeList[e];throw new Error("Invalid node reference")}lookbackVersion;lookbackStrings=[];c(){this.lookbackVersion===void 0&&(this.lookbackVersion=this.e());let e=new Uint32Array([this.e()])[0];if(e==4294967295)return"";if((e&16383)==0&&(e>>30==1||e>>30==-2)){let t=this.n();return this.lookbackStrings.push(t),t}if((e&16383)==16383)switch(e>>30){case 2:return"Unassigned";case 3:return"";default:throw new Error("Invalid lookback string, the file provided may be corrupt")}return e>>30==0?H[e]===void 0?"Unknown collection":H[e]:this.lookbackStrings.length>(e&16383)-1?this.lookbackStrings[(e&16383)-1]:""}forceChunkSkip(e){for(;;){let t=this.peekUInt32();if((t&4294967040)==(e&4294967040)){m.warn(`Force skipped chunk: 0x${x.fromDecimal(e)}`);break}if(t==4207599105&&this.peekByte(4)===void 0){m.warn(`Force skipped chunk: 0x${x.fromDecimal(e)}`),m.warn("Reached end of file early");break}let n=this.s()}}};var x=class{static{o(this,"Hex")}static fromDecimal(e){return e.toString(16)}};var m=class{static{o(this,"Logger")}static showLogs=!1;static showDebug=!1;static showWarns=!1;static reset="\x1B[0m";static highlight(e,t=35){return`${`\x1B[${t}m`}${e}${this.reset}`}static log(...e){this.showLogs&&console.log(this.highlight("[INFO]",34),...e)}static debug(...e){this.showDebug&&console.log(this.highlight("[DEBUG]",35),...e)}static warn(...e){this.showWarns&&console.warn(this.highlight("[WARN]",33),...e)}static error(...e){console.error(this.highlight("[ERROR]",31),...e)}static outline(...e){console.log(this.highlight("[DEVEL]",41),this.highlight(e[0],35),...e.slice(1))}};var ne=typeof globalThis.LZO<"u";async function X(){if(ne)return globalThis.LZO;let{LZO:p}=await import("lzo-ts");return p}o(X,"getLZO");var V=class{static{o(this,"LZOHandler")}static async compress(e){try{return(await X()).compress(e)}catch(t){throw console.error("LZO compress error:",t),new Error("Failed to compress data, is the lzo-ts package installed?")}}static async decompress(e){try{return(await X()).decompress(e)}catch(t){throw console.error("LZO decompress error:",t),new Error("Failed to decompress data, is the lzo-ts package installed?")}}};var ie=typeof globalThis.ZLib<"u";async function q(){return ie?globalThis.ZLib:await import("pako")}o(q,"getZLib");var P=class{static{o(this,"ZLibHandler")}static async compress(e){try{return(await q()).deflate(new Uint8Array(e))}catch(t){throw console.error("ZLib compress error:",t),new Error("Failed to compress data, is the pako package installed?")}}static async decompress(e){try{return(await q()).inflate(new Uint8Array(e))}catch(t){throw console.error("ZLib decompress error:",t),new Error("Failed to decompress data, is the pako package installed?")}}};var w=class{static{o(this,"Merger")}static mergeChunks(e,t,n){let s={};for(let i in e){if(e[i]===!1){s[i]=null;continue}s[i]={unknowns:t[i],version:n[i]}}return s}static mergeInstances(e,t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&t[n]!==void 0&&(e[n]=t[n]);return e}};var R=class{static{o(this,"GBX")}stream;classId;wrappedClassId;bodyCompression="C";constructor(e,t=2){t>=1&&(m.showWarns=!0),t>=2&&(m.showLogs=!0),t>=3&&(m.showDebug=!0),this.stream=new f(e)}async parseHeaders(){if(this.stream.n(3)!="GBX")return Promise.reject(new Error("Not a GBX file"));m.debug("Found GBX magic");let e=this.stream.C();if(e<3)return Promise.reject(new Error("Unsupported GBX version"));m.debug(`Reading GBX version ${e}`);let t=this.stream.g(),n=this.stream.g();this.bodyCompression=this.stream.g(),e>=4&&this.stream.g(),this.classId=this.stream.e(),this.wrappedClassId=U[this.classId],e>=6&&this.stream.e();let s=this.stream.e();if(s==0)return Promise.reject(new Error("No header chunks"));let i=[];for(let l=0;l<s;l++){let b=this.stream.e()&4095,C=this.stream.e()&2147483647,k=(C&2147483648)!=0;i.push({chunkId:b,chunkSize:C,isHeavy:k})}for(let l=0;l<s;l++)i[l].chunkData=this.stream.p(i[l].chunkSize);m.debug("Reading header data");let r=new E({headerChunks:i,classId:this.classId}).S(this.classId),a=this.stream.e();return this.stream.e()>0?Promise.reject(new Error("[Unimplemented] External nodes are not supported")):Promise.resolve(r)}async parse(){let e=await this.parseHeaders(),t;if(this.bodyCompression==="C"){let s=this.stream.e(),i=this.stream.e(),r=this.stream.p(i);m.debug(`Decompressing body: ${i} -> ${s} bytes`),t=new f(await V.decompress(r))}else{m.debug("Reading uncompressed body");let s=this.stream.p(this.stream.bytesAvailable);t=new f(s)}m.debug("Reading body data");let n=new E({stream:t,classId:this.classId}).v();return Promise.resolve(w.mergeInstances(e,n))}};var Y;(r=>{function p(a){if(a instanceof y)return a.checkpoints?.length||void 0;let c=a.chunks?.[50606111]?.version,l=new Set,b=0;if(c>=6)a.blocks?.forEach(C=>{let k=C.waypointSpecialProperty;if(k?.order!==void 0&&(k?.tag=="Checkpoint"&&b++,k?.tag=="LinkedCheckpoint")){if(l.has(k.order))return;b++,l.add(k.order)}});else return a.checkpoints?.length||void 0;if(a.blocks!==void 0)return a.nbCheckpoints&&b<a.nbCheckpoints?(m.warn("The amount of checkpoints doesn't match the amount of checkpoints in the header. Returning amount of header."),a.nbCheckpoints):b}r.getCheckpointCount=p,o(p,"getCheckpointCount");function e(a){return a.controlEntries?.filter(c=>c?.name=="Respawn"&&c?.value==1)}o(e,"getRespawns");function t(a){return e(a)?.length}r.getRespawnsCount=t,o(t,"getRespawnsCount");function n(a){return a.checkpoints?.map(c=>c.time)}r.getCheckpointTimes=n,o(n,"getCheckpointTimes");function s(a){let c=n(a),l=e(a);if(c===void 0||l===void 0)return;let b=c.map(()=>0),C=0;for(let k of l){let Z=c[C];k.time>=Z&&C++,b[C]++}return b}r.getRespawnsByCheckpoint=s,o(s,"getRespawnsByCheckpoint");function i(a){let c=n(a);if(c!==void 0)return c.map((l,b,C)=>{let k=C[b-1]||0;return l-k})}r.getSectorTimes=i,o(i,"getSectorTimes")})(Y||={});export{z as CGameCtnBlock,G as CGameCtnBlockSkin,v as CGameCtnChallenge,S as CGameCtnChallengeParameters,T as CGameCtnCollectorList,y as CGameCtnGhost,I as CGameCtnMediaBlock,D as CGameCtnMediaClip,N as CGameCtnMediaTrack,L as CGameCtnReplayRecord,F as CGameGhost,M as CGameWaypointSpecialProperty,A as CPlugEntRecordData,R as GBX,Y as Utils,P as ZLibHandler};
@@ -0,0 +1,93 @@
1
+ interface IHeaderChunks {
2
+ chunkId: number;
3
+ chunkSize: number;
4
+ chunkData?: number[];
5
+ isHeavy: boolean;
6
+ }
7
+ interface ICollectionList {
8
+ [key: number]: string;
9
+ }
10
+ interface IMeta {
11
+ id: string;
12
+ collection: string;
13
+ author: string;
14
+ }
15
+ interface Chunk {
16
+ r: import('./Handlers').DataStream;
17
+ fullChunkId: number;
18
+ isHeaderChunk: boolean;
19
+ length: number;
20
+ }
21
+ interface ChunkFunctions {
22
+ readVersion<T>(version: T): T;
23
+ readUnknown<T>(unknown: T): T;
24
+ }
25
+ type Chunks = {
26
+ [x: number]: boolean;
27
+ };
28
+ type Unknowns = {
29
+ [x: number]: any[];
30
+ };
31
+ type Versions = {
32
+ [x: number]: number;
33
+ };
34
+ interface Int2 {
35
+ x: number;
36
+ y: number;
37
+ }
38
+ interface Int3 {
39
+ x: number;
40
+ y: number;
41
+ z: number;
42
+ }
43
+ interface Vector2 {
44
+ x: number;
45
+ y: number;
46
+ }
47
+ interface Vector3 {
48
+ x: number;
49
+ y: number;
50
+ z: number;
51
+ }
52
+ interface Byte3 {
53
+ x: number;
54
+ y: number;
55
+ z: number;
56
+ }
57
+ declare enum MapKind {
58
+ EndMarker,
59
+ Campaign,
60
+ Puzzle,
61
+ Retro,
62
+ TimeAttack,
63
+ Rounds,
64
+ InProgress,
65
+ Campaign_7,
66
+ Multi,
67
+ Solo,
68
+ Site,
69
+ SoloNadeo,
70
+ MultiNadeo
71
+ }
72
+ declare enum PlayMode {
73
+ Race,
74
+ Platform,
75
+ Puzzle,
76
+ Crazy,
77
+ Shortcut,
78
+ Stunts,
79
+ Script
80
+ }
81
+ declare enum EditorMode {
82
+ Advanced,
83
+ Simple,
84
+ HasGhostBlocks,
85
+ Gamepad = 4
86
+ }
87
+ declare enum Direction {
88
+ North,// +X
89
+ East,// -X
90
+ South,// -Z
91
+ West
92
+ }
93
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,UAAU,aAAa;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,UAAU,eAAe;IACxB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB;AAED,UAAU,KAAK;IACd,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,UAAU,KAAK;IACd,CAAC,EAAE,OAAO,YAAY,EAAE,UAAU,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,OAAO,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;CACf;AAED,UAAU,cAAc;IACvB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;IAC9B,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC;CAC9B;AAED,KAAK,MAAM,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;CAAE,CAAC;AACvC,KAAK,QAAQ,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,EAAE,CAAA;CAAE,CAAC;AACvC,KAAK,QAAQ,GAAG;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,CAAC;AAExC,UAAU,IAAI;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,UAAU,IAAI;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,UAAU,OAAO;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,UAAU,OAAO;IAChB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,UAAU,KAAK;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACV;AAED,OAAO,MAAM,OAAO;IACnB,SAAS;IACT,QAAQ;IACR,MAAM;IACN,KAAK;IACL,UAAU;IACV,MAAM;IACN,UAAU;IACV,UAAU;IACV,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,SAAS;IACT,UAAU;CACV;AAED,OAAO,MAAM,QAAQ;IACpB,IAAI;IACJ,QAAQ;IACR,MAAM;IACN,KAAK;IACL,QAAQ;IACR,MAAM;IACN,MAAM;CACN;AAED,OAAO,MAAM,UAAU;IACtB,QAAQ;IACR,MAAM;IACN,cAAc;IACd,OAAO,IAAI;CACX;AAED,OAAO,MAAM,SAAS;IACrB,KAAK,CAAE,KAAK;IACZ,IAAI,CAAE,KAAK;IACX,KAAK,CAAE,KAAK;IACZ,IAAI;CACJ"}