@discordeno/utils 19.0.0-next.fd518cb → 19.0.0-next.fda3003

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 (124) hide show
  1. package/dist/cjs/Collection.cjs +123 -0
  2. package/dist/cjs/base64.cjs +276 -0
  3. package/dist/cjs/bucket.cjs +96 -0
  4. package/dist/cjs/builders/embeds.cjs +292 -0
  5. package/dist/cjs/builders.cjs +27 -0
  6. package/dist/cjs/casing.cjs +75 -0
  7. package/dist/cjs/colors.cjs +456 -0
  8. package/dist/cjs/hash.cjs +37 -0
  9. package/dist/cjs/images.cjs +136 -0
  10. package/dist/cjs/index.cjs +35 -0
  11. package/dist/cjs/logger.cjs +157 -0
  12. package/dist/cjs/oauth2.cjs +26 -0
  13. package/dist/cjs/permissions.cjs +35 -0
  14. package/dist/cjs/reactions.cjs +21 -0
  15. package/dist/cjs/token.cjs +39 -0
  16. package/dist/cjs/typeguards.cjs +45 -0
  17. package/dist/cjs/urlToBase64.cjs +19 -0
  18. package/dist/cjs/utils.cjs +30 -0
  19. package/dist/esm/Collection.js +113 -0
  20. package/dist/esm/base64.js +262 -0
  21. package/dist/esm/bucket.js +81 -0
  22. package/dist/esm/builders/embeds.js +295 -0
  23. package/dist/esm/builders.js +5 -0
  24. package/dist/esm/casing.js +51 -0
  25. package/dist/esm/colors.js +467 -0
  26. package/dist/esm/hash.js +19 -0
  27. package/dist/esm/images.js +179 -0
  28. package/dist/esm/index.js +18 -0
  29. package/dist/esm/logger.js +130 -0
  30. package/dist/esm/oauth2.js +16 -0
  31. package/dist/esm/permissions.js +17 -0
  32. package/dist/esm/reactions.js +11 -0
  33. package/dist/esm/token.js +21 -0
  34. package/dist/esm/typeguards.js +18 -0
  35. package/dist/esm/urlToBase64.js +9 -0
  36. package/dist/esm/utils.js +15 -0
  37. package/dist/tsconfig.tsbuildinfo +1 -0
  38. package/dist/{Collection.d.ts → types/Collection.d.ts} +2 -2
  39. package/dist/types/Collection.d.ts.map +1 -0
  40. package/dist/types/base64.d.ts.map +1 -0
  41. package/dist/{bucket.d.ts → types/bucket.d.ts} +9 -1
  42. package/dist/types/bucket.d.ts.map +1 -0
  43. package/dist/types/builders/embeds.d.ts +146 -0
  44. package/dist/types/builders/embeds.d.ts.map +1 -0
  45. package/dist/types/builders.d.ts +4 -0
  46. package/dist/types/builders.d.ts.map +1 -0
  47. package/dist/types/casing.d.ts.map +1 -0
  48. package/dist/types/colors.d.ts.map +1 -0
  49. package/dist/types/hash.d.ts.map +1 -0
  50. package/dist/types/images.d.ts +202 -0
  51. package/dist/types/images.d.ts.map +1 -0
  52. package/dist/{index.d.ts → types/index.d.ts} +3 -1
  53. package/dist/types/index.d.ts.map +1 -0
  54. package/dist/types/logger.d.ts.map +1 -0
  55. package/dist/types/oauth2.d.ts +69 -0
  56. package/dist/types/oauth2.d.ts.map +1 -0
  57. package/dist/types/permissions.d.ts.map +1 -0
  58. package/dist/types/reactions.d.ts.map +1 -0
  59. package/dist/{token.d.ts → types/token.d.ts} +1 -1
  60. package/dist/types/token.d.ts.map +1 -0
  61. package/dist/{typeguards.d.ts → types/typeguards.d.ts} +2 -1
  62. package/dist/types/typeguards.d.ts.map +1 -0
  63. package/dist/types/urlToBase64.d.ts.map +1 -0
  64. package/dist/types/utils.d.ts.map +1 -0
  65. package/package.json +26 -20
  66. package/dist/Collection.d.ts.map +0 -1
  67. package/dist/Collection.js +0 -113
  68. package/dist/Collection.js.map +0 -1
  69. package/dist/base64.d.ts.map +0 -1
  70. package/dist/base64.js +0 -262
  71. package/dist/base64.js.map +0 -1
  72. package/dist/bucket.d.ts.map +0 -1
  73. package/dist/bucket.js +0 -74
  74. package/dist/bucket.js.map +0 -1
  75. package/dist/casing.d.ts.map +0 -1
  76. package/dist/casing.js +0 -51
  77. package/dist/casing.js.map +0 -1
  78. package/dist/colors.d.ts.map +0 -1
  79. package/dist/colors.js +0 -467
  80. package/dist/colors.js.map +0 -1
  81. package/dist/hash.d.ts.map +0 -1
  82. package/dist/hash.js +0 -19
  83. package/dist/hash.js.map +0 -1
  84. package/dist/images.d.ts +0 -68
  85. package/dist/images.d.ts.map +0 -1
  86. package/dist/images.js +0 -66
  87. package/dist/images.js.map +0 -1
  88. package/dist/index.d.ts.map +0 -1
  89. package/dist/index.js +0 -16
  90. package/dist/index.js.map +0 -1
  91. package/dist/interactions.d.ts +0 -3
  92. package/dist/interactions.d.ts.map +0 -1
  93. package/dist/interactions.js +0 -41
  94. package/dist/interactions.js.map +0 -1
  95. package/dist/logger.d.ts.map +0 -1
  96. package/dist/logger.js +0 -130
  97. package/dist/logger.js.map +0 -1
  98. package/dist/permissions.d.ts.map +0 -1
  99. package/dist/permissions.js +0 -17
  100. package/dist/permissions.js.map +0 -1
  101. package/dist/reactions.d.ts.map +0 -1
  102. package/dist/reactions.js +0 -11
  103. package/dist/reactions.js.map +0 -1
  104. package/dist/token.d.ts.map +0 -1
  105. package/dist/token.js +0 -16
  106. package/dist/token.js.map +0 -1
  107. package/dist/typeguards.d.ts.map +0 -1
  108. package/dist/typeguards.js +0 -15
  109. package/dist/typeguards.js.map +0 -1
  110. package/dist/urlToBase64.d.ts.map +0 -1
  111. package/dist/urlToBase64.js +0 -9
  112. package/dist/urlToBase64.js.map +0 -1
  113. package/dist/utils.d.ts.map +0 -1
  114. package/dist/utils.js +0 -15
  115. package/dist/utils.js.map +0 -1
  116. /package/dist/{base64.d.ts → types/base64.d.ts} +0 -0
  117. /package/dist/{casing.d.ts → types/casing.d.ts} +0 -0
  118. /package/dist/{colors.d.ts → types/colors.d.ts} +0 -0
  119. /package/dist/{hash.d.ts → types/hash.d.ts} +0 -0
  120. /package/dist/{logger.d.ts → types/logger.d.ts} +0 -0
  121. /package/dist/{permissions.d.ts → types/permissions.d.ts} +0 -0
  122. /package/dist/{reactions.d.ts → types/reactions.d.ts} +0 -0
  123. /package/dist/{urlToBase64.d.ts → types/urlToBase64.d.ts} +0 -0
  124. /package/dist/{utils.d.ts → types/utils.d.ts} +0 -0
@@ -0,0 +1,69 @@
1
+ import type { BigString, DiscordApplicationIntegrationType, OAuth2Scope, PermissionStrings } from '@discordeno/types';
2
+ export declare function createOAuth2Link(options: CreateOAuth2LinkOptions): string;
3
+ export interface CreateOAuth2LinkOptions {
4
+ /**
5
+ * The type of response
6
+ *
7
+ * @remarks
8
+ * Should be defined only if using either OAuth2 authorization, implicit or not, or [advanced bot authorization](https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization)
9
+ */
10
+ responseType?: 'code' | 'token';
11
+ /** The id of the application */
12
+ clientId: BigString;
13
+ /** The scopes for the application */
14
+ scope: OAuth2Scope[];
15
+ /**
16
+ * The optional state for security
17
+ *
18
+ * @see https://discord.com/developers/docs/topics/oauth2#state-and-security
19
+ */
20
+ state?: string;
21
+ /**
22
+ * The redirect uri for after the authentication
23
+ *
24
+ * @remarks
25
+ * Should be defined only if using either OAuth2 authorization, implicit or not, or [advanced bot authorization](https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization)
26
+ */
27
+ redirectUri?: string;
28
+ /**
29
+ * The type of prompt to give to the user
30
+ *
31
+ * @remarks
32
+ * If set to `none`, it will skip the authorization screen and redirect them back to your redirect URI without requesting their authorization.
33
+ * For passthrough scopes, like bot and webhook.incoming, authorization is always required.
34
+ */
35
+ prompt?: 'consent' | 'none';
36
+ /**
37
+ * The permissions of the invited bot
38
+ *
39
+ * @remarks
40
+ * Should be defined only in a [bot authorization flow](https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow) or with [advanced bot authorization](https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization)
41
+ */
42
+ permissions?: BigString | PermissionStrings[];
43
+ /**
44
+ * Pre-fills the dropdown picker with a guild for the user
45
+ *
46
+ * @remarks
47
+ * Should be defined only in a [bot authorization flow](https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow) or with [advanced bot authorization](https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization) or with the `webhook.incoming` scope
48
+ */
49
+ guildId?: BigString;
50
+ /**
51
+ * Disallows the user from changing the guild dropdown if set to true
52
+ *
53
+ * @remarks
54
+ * Should be defined only in a [bot authorization flow](https://discord.com/developers/docs/topics/oauth2#bot-authorization-flow), with [advanced bot authorization](https://discord.com/developers/docs/topics/oauth2#advanced-bot-authorization) or with the `webhook.incoming` scope
55
+ */
56
+ disableGuildSelect?: boolean;
57
+ /**
58
+ * Specifies the installation context for the authorization
59
+ *
60
+ * @remarks
61
+ * Should be defined only when {@link scope} includes {@link OAuth2Scope.ApplicationsCommands}.
62
+ *
63
+ * When set to GuildInstall (0) the application will be authorized for installation to a server, and when set to UserInstall (1) the application will be authorized for installation to a user.
64
+ *
65
+ * The application must be configured in the Developer Portal to support the provided `integrationType`.
66
+ */
67
+ integrationType?: DiscordApplicationIntegrationType;
68
+ }
69
+ //# sourceMappingURL=oauth2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth2.d.ts","sourceRoot":"","sources":["../../src/oauth2.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,iCAAiC,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAGrH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,MAAM,CAezE;AAED,MAAM,WAAW,uBAAuB;IACtC;;;;;OAKG;IACH,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IAC/B,gCAAgC;IAChC,QAAQ,EAAE,SAAS,CAAA;IACnB,qCAAqC;IACrC,KAAK,EAAE,WAAW,EAAE,CAAA;IACpB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,SAAS,GAAG,MAAM,CAAA;IAC3B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,SAAS,GAAG,iBAAiB,EAAE,CAAA;IAC7C;;;;;OAKG;IACH,OAAO,CAAC,EAAE,SAAS,CAAA;IACnB;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,iCAAiC,CAAA;CACpD"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../src/permissions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAA;AAG1D,oEAAoE;AACpE,wBAAgB,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,iBAAiB,EAAE,CAOhF;AAED,8EAA8E;AAC9E,wBAAgB,aAAa,CAAC,WAAW,EAAE,iBAAiB,EAAE,GAAG,MAAM,CAOtE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reactions.d.ts","sourceRoot":"","sources":["../../src/reactions.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAU9D"}
@@ -1,4 +1,4 @@
1
- /** Removes the Bot before the token. */
1
+ /** Removes the Bot/Bearer before the token. */
2
2
  export declare function removeTokenPrefix(token?: string, type?: 'GATEWAY' | 'REST'): string;
3
3
  /** Get the bot id from the bot token. WARNING: Discord staff has mentioned this may not be stable forever. Use at your own risk. However, note for over 5 years this has never broken. */
4
4
  export declare function getBotIdFromToken(token: string): bigint;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/token.ts"],"names":[],"mappings":"AAIA,+CAA+C;AAC/C,wBAAgB,iBAAiB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,GAAE,SAAS,GAAG,MAAe,GAAG,MAAM,CAY3F;AAED,0LAA0L;AAC1L,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD"}
@@ -1,6 +1,7 @@
1
- import type { GetMessagesAfter, GetMessagesAround, GetMessagesBefore, GetMessagesLimit, GetMessagesOptions } from '@discordeno/types';
1
+ import type { DiscordInviteCreate, DiscordInviteMetadata, GetMessagesAfter, GetMessagesAround, GetMessagesBefore, GetMessagesLimit, GetMessagesOptions } from '@discordeno/types';
2
2
  export declare function isGetMessagesAfter(options: GetMessagesOptions): options is GetMessagesAfter;
3
3
  export declare function isGetMessagesBefore(options: GetMessagesOptions): options is GetMessagesBefore;
4
4
  export declare function isGetMessagesAround(options: GetMessagesOptions): options is GetMessagesAround;
5
5
  export declare function isGetMessagesLimit(options: GetMessagesOptions): options is GetMessagesLimit;
6
+ export declare function isInviteWithMetadata(options: DiscordInviteCreate | DiscordInviteMetadata): options is DiscordInviteMetadata;
6
7
  //# sourceMappingURL=typeguards.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typeguards.d.ts","sourceRoot":"","sources":["../../src/typeguards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EAChB,kBAAkB,EACnB,MAAM,mBAAmB,CAAA;AAG1B,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,IAAI,gBAAgB,CAE3F;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,IAAI,iBAAiB,CAE7F;AAED,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,IAAI,iBAAiB,CAE7F;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,IAAI,gBAAgB,CAE3F;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,mBAAmB,GAAG,qBAAqB,GAAG,OAAO,IAAI,qBAAqB,CAE3H"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"urlToBase64.d.ts","sourceRoot":"","sources":["../../src/urlToBase64.ts"],"names":[],"mappings":"AAEA,uFAAuF;AACvF,wBAAsB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK9D"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,wBAAsB,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAQrD;AAID,6DAA6D;AAE7D,wBAAgB,WAAW,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,WAAW,GAAG,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAGxH"}
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "@discordeno/utils",
3
- "version": "19.0.0-next.fd518cb",
4
- "main": "./dist/index.js",
5
- "types": "./dist/index.d.ts",
3
+ "version": "19.0.0-next.fda3003",
4
+ "main": "./dist/esm/index.js",
5
+ "exports": {
6
+ "import": "./dist/esm/index.js",
7
+ "require": "./dist/cjs/index.cjs",
8
+ "types": "./dist/types/index.d.ts"
9
+ },
10
+ "types": "./dist/types/index.d.ts",
6
11
  "type": "module",
7
12
  "license": "Apache-2.0",
8
13
  "repository": {
@@ -10,37 +15,38 @@
10
15
  "url": "https://github.com/discordeno/discordeno.git"
11
16
  },
12
17
  "scripts": {
13
- "build": "swc --delete-dir-on-start src --out-dir dist",
14
- "build:type": "tsc --skipDefaultLibCheck --declaration --emitDeclarationOnly --declarationDir dist",
18
+ "build": "swc src --strip-leading-paths --delete-dir-on-start src --out-dir dist/esm && swc --strip-leading-paths --delete-dir-on-start src --out-dir dist/cjs -C module.type=commonjs && node ../../scripts/fixCjsExtension.js",
19
+ "build:type": "tsc --skipDefaultLibCheck --declaration --emitDeclarationOnly --declarationDir dist/types",
15
20
  "release-build": "yarn build && yarn build:type",
16
21
  "fmt": "eslint --fix \"src/**/*.ts*\"",
17
22
  "lint": "eslint \"src/**/*.ts*\"",
18
23
  "test:unit-coverage": "c8 mocha --no-warnings 'tests/**/*.spec.ts'",
19
24
  "test:unit": "c8 --r lcov mocha --no-warnings 'tests/**/*.spec.ts' && node ../../scripts/coveragePathFixing.js utils",
20
- "test:deno-unit": "swc tests --delete-dir-on-start -C jsc.minify.mangle=false --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist",
25
+ "test:deno-unit": "swc tests --strip-leading-paths --delete-dir-on-start -C jsc.minify.mangle=false --out-dir denoTestsDist && node ../../scripts/fixDenoTestExtension.js && deno test -A --import-map ../../denoImportMap.json denoTestsDist",
26
+ "test:bun-unit": "node ../../scripts/fixBunTestExtension.js && bun test bunTestsDist",
21
27
  "test:unit:watch": "mocha --no-warnings --watch --parallel 'tests/**/*.spec.ts'",
22
28
  "test:type": "tsc --noEmit",
23
29
  "test:test-type": "tsc --project tsconfig.test.json"
24
30
  },
25
31
  "dependencies": {
26
- "@discordeno/types": "19.0.0-next.fd518cb",
32
+ "@discordeno/types": "19.0.0-next.fda3003",
27
33
  "tweetnacl": "^1.0.3"
28
34
  },
29
35
  "devDependencies": {
30
- "@swc/cli": "^0.1.62",
31
- "@swc/core": "^1.3.40",
32
- "@types/chai": "^4.3.4",
33
- "@types/mocha": "^10.0.1",
34
- "@types/node": "^18.15.3",
35
- "@types/sinon": "^10.0.13",
36
- "c8": "^7.13.0",
37
- "chai": "^4.3.7",
38
- "eslint": "^8.36.0",
36
+ "@swc/cli": "^0.3.9",
37
+ "@swc/core": "^1.4.2",
38
+ "@types/chai": "^4.3.11",
39
+ "@types/mocha": "^10.0.7",
40
+ "@types/node": "^20.11.25",
41
+ "@types/sinon": "^17.0.3",
42
+ "c8": "^9.1.0",
43
+ "chai": "^5.0.3",
44
+ "eslint": "^8.57.0",
39
45
  "eslint-config-discordeno": "*",
40
- "mocha": "^10.2.0",
41
- "sinon": "^15.0.2",
42
- "ts-node": "^10.9.1",
46
+ "mocha": "^10.5.1",
47
+ "sinon": "^17.0.1",
48
+ "ts-node": "^10.9.2",
43
49
  "tsconfig": "*",
44
- "typescript": "^4.9.5"
50
+ "typescript": "5.4.5"
45
51
  }
46
52
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../src/Collection.ts"],"names":[],"mappings":";AACA,MAAM,WAAW,cAAc;CAAG;AAElC,qBAAa,UAAU,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC;IAC7C;;;OAGG;IACH,OAAO,EAAE,MAAM,GAAG,SAAS,CAAA;IAC3B,kEAAkE;IAClE,OAAO,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG;QAAE,UAAU,CAAC,EAAE,MAAM,CAAC,KAAK,CAAA;KAAE,CAAC,GAAG,SAAS,CAAA;gBAElE,OAAO,CAAC,EAAE,CAAC,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC;IAU5G,YAAY,CAAC,OAAO,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,KAAK;IAgB5D,WAAW,IAAI,IAAI;IAInB,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI;IAMhD,mBAAmB,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,cAAc,KAAK,OAAO,GAAG,IAAI;IAMxF,6EAA6E;IAC7E,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,G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,OAAO,CAAC,EAAE,iBAAiB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACjC,6DAA6D;IAC7D,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,EAAE,CAAC;IACrC,0EAA0E;IAC1E,MAAM,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAA;IACrD,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAA;IAChB,4BAA4B;IAC5B,GAAG,CAAC,EAAE,cAAc,CAAA;CACrB"}
@@ -1,113 +0,0 @@
1
- // eslint-disable-next-line @typescript-eslint/no-empty-interface
2
- export class Collection extends Map {
3
- constructor(entries, options){
4
- super(entries ?? []);
5
- this.maxSize = options?.maxSize;
6
- if (!options?.sweeper) return;
7
- this.startSweeper(options.sweeper);
8
- }
9
- startSweeper(options) {
10
- if (this.sweeper?.intervalId) clearInterval(this.sweeper.intervalId);
11
- this.sweeper = options;
12
- this.sweeper.intervalId = setInterval(()=>{
13
- this.forEach((value, key)=>{
14
- if (!this.sweeper?.filter(value, key, options.bot)) return;
15
- this.delete(key);
16
- return key;
17
- });
18
- }, options.interval);
19
- return this.sweeper.intervalId;
20
- }
21
- stopSweeper() {
22
- return clearInterval(this.sweeper?.intervalId);
23
- }
24
- changeSweeperInterval(newInterval) {
25
- if (this.sweeper == null) return;
26
- this.startSweeper({
27
- filter: this.sweeper.filter,
28
- interval: newInterval
29
- });
30
- }
31
- changeSweeperFilter(newFilter) {
32
- if (this.sweeper == null) return;
33
- this.startSweeper({
34
- filter: newFilter,
35
- interval: this.sweeper.interval
36
- });
37
- }
38
- /** Add an item to the collection. Makes sure not to go above the maxSize. */ set(key, value) {
39
- // When this collection is maxSized make sure we can add first
40
- if ((this.maxSize !== undefined || this.maxSize === 0) && this.size >= this.maxSize) {
41
- return this;
42
- }
43
- return super.set(key, value);
44
- }
45
- /** Add an item to the collection, no matter what the maxSize is. */ forceSet(key, value) {
46
- return super.set(key, value);
47
- }
48
- /** Convert the collection to an array. */ array() {
49
- return [
50
- ...this.values()
51
- ];
52
- }
53
- /** Retrieve the value of the first element in this collection. */ first() {
54
- return this.values().next().value;
55
- }
56
- /** Retrieve the value of the last element in this collection. */ last() {
57
- return [
58
- ...this.values()
59
- ][this.size - 1];
60
- }
61
- /** Retrieve the value of a random element in this collection. */ random() {
62
- const array = [
63
- ...this.values()
64
- ];
65
- return array[Math.floor(Math.random() * array.length)];
66
- }
67
- /** Find a specific element in this collection. */ find(callback) {
68
- for (const key of this.keys()){
69
- const value = this.get(key);
70
- if (callback(value, key)) return value;
71
- }
72
- // If nothing matched
73
- }
74
- /** Find all elements in this collection that match the given pattern. */ filter(callback) {
75
- const relevant = new Collection();
76
- this.forEach((value, key)=>{
77
- if (callback(value, key)) relevant.set(key, value);
78
- });
79
- return relevant;
80
- }
81
- /** Converts the collection into an array by running a callback on all items in the collection. */ map(callback) {
82
- const results = [];
83
- for (const key of this.keys()){
84
- const value = this.get(key);
85
- results.push(callback(value, key));
86
- }
87
- return results;
88
- }
89
- /** Check if one of the items in the collection matches the pattern. */ some(callback) {
90
- for (const key of this.keys()){
91
- const value = this.get(key);
92
- if (callback(value, key)) return true;
93
- }
94
- return false;
95
- }
96
- /** Check if all of the items in the collection matches the pattern. */ every(callback) {
97
- for (const key of this.keys()){
98
- const value = this.get(key);
99
- if (!callback(value, key)) return false;
100
- }
101
- return true;
102
- }
103
- /** Runs a callback on all items in the collection, merging them into a single value. */ reduce(callback, initialValue) {
104
- let accumulator = initialValue;
105
- for (const key of this.keys()){
106
- const value = this.get(key);
107
- accumulator = callback(accumulator, value, key);
108
- }
109
- return accumulator;
110
- }
111
- }
112
-
113
- //# sourceMappingURL=Collection.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/Collection.ts"],"sourcesContent":["// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface PlaceHolderBot {}\n\nexport class Collection<K, V> extends Map<K, V> {\n /**\n * The maximum amount of items allowed in this collection. To disable cache, set it 0, set to undefined to make it infinite.\n * @default undefined\n */\n maxSize: number | undefined\n /** Handler to remove items from the collection every so often. */\n sweeper: (CollectionSweeper<K, V> & { intervalId?: NodeJS.Timer }) | undefined\n\n constructor(entries?: (ReadonlyArray<readonly [K, V]> | null) | Map<K, V>, options?: CollectionOptions<K, V>) {\n super(entries ?? [])\n\n this.maxSize = options?.maxSize\n\n if (!options?.sweeper) return\n\n this.startSweeper(options.sweeper)\n }\n\n startSweeper(options: CollectionSweeper<K, V>): NodeJS.Timer {\n if (this.sweeper?.intervalId) clearInterval(this.sweeper.intervalId)\n\n this.sweeper = options\n this.sweeper.intervalId = setInterval(() => {\n this.forEach((value, key) => {\n if (!this.sweeper?.filter(value, key, options.bot)) return\n\n this.delete(key)\n return key\n })\n }, options.interval)\n\n return this.sweeper.intervalId\n }\n\n stopSweeper(): void {\n return clearInterval(this.sweeper?.intervalId)\n }\n\n changeSweeperInterval(newInterval: number): void {\n if (this.sweeper == null) return\n\n this.startSweeper({ filter: this.sweeper.filter, interval: newInterval })\n }\n\n changeSweeperFilter(newFilter: (value: V, key: K, bot: PlaceHolderBot) => boolean): void {\n if (this.sweeper == null) return\n\n this.startSweeper({ filter: newFilter, interval: this.sweeper.interval })\n }\n\n /** Add an item to the collection. Makes sure not to go above the maxSize. */\n set(key: K, value: V): this {\n // When this collection is maxSized make sure we can add first\n if ((this.maxSize !== undefined || this.maxSize === 0) && this.size >= this.maxSize) {\n return this\n }\n\n return super.set(key, value)\n }\n\n /** Add an item to the collection, no matter what the maxSize is. */\n forceSet(key: K, value: V): this {\n return super.set(key, value)\n }\n\n /** Convert the collection to an array. */\n array(): V[] {\n return [...this.values()]\n }\n\n /** Retrieve the value of the first element in this collection. */\n first(): V | undefined {\n return this.values().next().value\n }\n\n /** Retrieve the value of the last element in this collection. */\n last(): V | undefined {\n return [...this.values()][this.size - 1]\n }\n\n /** Retrieve the value of a random element in this collection. */\n random(): V | undefined {\n const array = [...this.values()]\n return array[Math.floor(Math.random() * array.length)]\n }\n\n /** Find a specific element in this collection. */\n find(callback: (value: V, key: K) => boolean): NonNullable<V> | undefined {\n for (const key of this.keys()) {\n const value = this.get(key)!\n if (callback(value, key)) return value\n }\n // If nothing matched\n }\n\n /** Find all elements in this collection that match the given pattern. */\n filter(callback: (value: V, key: K) => boolean): Collection<K, V> {\n const relevant = new Collection<K, V>()\n this.forEach((value, key) => {\n if (callback(value, key)) relevant.set(key, value)\n })\n\n return relevant\n }\n\n /** Converts the collection into an array by running a callback on all items in the collection. */\n map<T>(callback: (value: V, key: K) => T): T[] {\n const results = []\n for (const key of this.keys()) {\n const value = this.get(key)!\n results.push(callback(value, key))\n }\n return results\n }\n\n /** Check if one of the items in the collection matches the pattern. */\n some(callback: (value: V, key: K) => boolean): boolean {\n for (const key of this.keys()) {\n const value = this.get(key)!\n if (callback(value, key)) return true\n }\n\n return false\n }\n\n /** Check if all of the items in the collection matches the pattern. */\n every(callback: (value: V, key: K) => boolean): boolean {\n for (const key of this.keys()) {\n const value = this.get(key)!\n if (!callback(value, key)) return false\n }\n\n return true\n }\n\n /** Runs a callback on all items in the collection, merging them into a single value. */\n reduce<T>(callback: (accumulator: T, value: V, key: K) => T, initialValue?: T): T {\n let accumulator: T = initialValue!\n\n for (const key of this.keys()) {\n const value = this.get(key)!\n accumulator = callback(accumulator, value, key)\n }\n\n return accumulator\n }\n}\n\nexport interface CollectionOptions<K, V> {\n /** Handler to clean out the items in the collection every so often. */\n sweeper?: CollectionSweeper<K, V>\n /** The maximum number of items allowed in the collection. */\n maxSize?: number\n}\n\nexport interface CollectionSweeper<K, V> {\n /** The filter to determine whether an element should be deleted or not */\n filter: (value: V, key: K, ...args: any[]) => boolean\n /** The interval in which the sweeper should run */\n interval: number\n /** The bot object itself */\n bot?: PlaceHolderBot\n}\n"],"names":["Collection","Map","constructor","entries","options","maxSize","sweeper","startSweeper","intervalId","clearInterval","setInterval","forEach","value","key","filter","bot","delete","interval","stopSweeper","changeSweeperInterval","newInterval","changeSweeperFilter","newFilter","set","undefined","size","forceSet","array","values","first","next","last","random","Math","floor","length","find","callback","keys","get","relevant","map","results","push","some","every","reduce","initialValue","accumulator"],"mappings":"AAAA,iEAAiE;AAGjE,OAAO,MAAMA,mBAAyBC;IASpCC,YAAYC,OAA6D,EAAEC,OAAiC,CAAE;QAC5G,KAAK,CAACD,WAAW,EAAE;QAEnB,IAAI,CAACE,OAAO,GAAGD,SAASC;QAExB,IAAI,CAACD,SAASE,SAAS;QAEvB,IAAI,CAACC,YAAY,CAACH,QAAQE,OAAO;IACnC;IAEAC,aAAaH,OAAgC,EAAgB;QAC3D,IAAI,IAAI,CAACE,OAAO,EAAEE,YAAYC,cAAc,IAAI,CAACH,OAAO,CAACE,UAAU;QAEnE,IAAI,CAACF,OAAO,GAAGF;QACf,IAAI,CAACE,OAAO,CAACE,UAAU,GAAGE,YAAY,IAAM;YAC1C,IAAI,CAACC,OAAO,CAAC,CAACC,OAAOC,MAAQ;gBAC3B,IAAI,CAAC,IAAI,CAACP,OAAO,EAAEQ,OAAOF,OAAOC,KAAKT,QAAQW,GAAG,GAAG;gBAEpD,IAAI,CAACC,MAAM,CAACH;gBACZ,OAAOA;YACT;QACF,GAAGT,QAAQa,QAAQ;QAEnB,OAAO,IAAI,CAACX,OAAO,CAACE,UAAU;IAChC;IAEAU,cAAoB;QAClB,OAAOT,cAAc,IAAI,CAACH,OAAO,EAAEE;IACrC;IAEAW,sBAAsBC,WAAmB,EAAQ;QAC/C,IAAI,IAAI,CAACd,OAAO,IAAI,IAAI,EAAE;QAE1B,IAAI,CAACC,YAAY,CAAC;YAAEO,QAAQ,IAAI,CAACR,OAAO,CAACQ,MAAM;YAAEG,UAAUG;QAAY;IACzE;IAEAC,oBAAoBC,SAA6D,EAAQ;QACvF,IAAI,IAAI,CAAChB,OAAO,IAAI,IAAI,EAAE;QAE1B,IAAI,CAAC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AG,MAAM,GAAG,MAAM,CAyBzD;AAED;;;;GAIG;AACH,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAuB/C"}
package/dist/base64.js DELETED
@@ -1,262 +0,0 @@
1
- /**
2
- * CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727
3
- * Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation
4
- * @param data
5
- */ export function encode(data) {
6
- const uint8 = typeof data === 'string' ? new TextEncoder().encode(data) : data instanceof Uint8Array ? data : new Uint8Array(data);
7
- let result = '';
8
- let i;
9
- const l = uint8.length;
10
- for(i = 2; i < l; i += 3){
11
- result += base64abc[uint8[i - 2] >> 2];
12
- result += base64abc[(uint8[i - 2] & 0x03) << 4 | uint8[i - 1] >> 4];
13
- result += base64abc[(uint8[i - 1] & 0x0f) << 2 | uint8[i] >> 6];
14
- result += base64abc[uint8[i] & 0x3f];
15
- }
16
- if (i === l + 1) {
17
- // 1 octet yet to write
18
- result += base64abc[uint8[i - 2] >> 2];
19
- result += base64abc[(uint8[i - 2] & 0x03) << 4];
20
- result += '==';
21
- }
22
- if (i === l) {
23
- // 2 octets yet to write
24
- result += base64abc[uint8[i - 2] >> 2];
25
- result += base64abc[(uint8[i - 2] & 0x03) << 4 | uint8[i - 1] >> 4];
26
- result += base64abc[(uint8[i - 1] & 0x0f) << 2];
27
- result += '=';
28
- }
29
- return result;
30
- }
31
- /**
32
- * CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727
33
- * Decodes RFC4648 base64 string into an Uint8Array
34
- * @param data
35
- */ export function decode(data) {
36
- if (data.length % 4 !== 0) {
37
- throw new Error('Unable to parse base64 string.');
38
- }
39
- const index = data.indexOf('=');
40
- if (index !== -1 && index < data.length - 2) {
41
- throw new Error('Unable to parse base64 string.');
42
- }
43
- const missingOctets = data.endsWith('==') ? 2 : data.endsWith('=') ? 1 : 0;
44
- const n = data.length;
45
- const result = new Uint8Array(3 * (n / 4));
46
- let buffer;
47
- for(let i = 0, j = 0; i < n; i += 4, j += 3){
48
- buffer = getBase64Code(data.charCodeAt(i)) << 18 | getBase64Code(data.charCodeAt(i + 1)) << 12 | getBase64Code(data.charCodeAt(i + 2)) << 6 | getBase64Code(data.charCodeAt(i + 3));
49
- result[j] = buffer >> 16;
50
- result[j + 1] = buffer >> 8 & 0xff;
51
- result[j + 2] = buffer & 0xff;
52
- }
53
- return result.subarray(0, result.length - missingOctets);
54
- }
55
- /**
56
- * CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727
57
- * @param charCode
58
- */ function getBase64Code(charCode) {
59
- if (charCode >= base64codes.length) {
60
- throw new Error('Unable to parse base64 string.');
61
- }
62
- const code = base64codes[charCode];
63
- if (code === 255) {
64
- throw new Error('Unable to parse base64 string.');
65
- }
66
- return code;
67
- }
68
- // Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.
69
- const base64abc = [
70
- 'A',
71
- 'B',
72
- 'C',
73
- 'D',
74
- 'E',
75
- 'F',
76
- 'G',
77
- 'H',
78
- 'I',
79
- 'J',
80
- 'K',
81
- 'L',
82
- 'M',
83
- 'N',
84
- 'O',
85
- 'P',
86
- 'Q',
87
- 'R',
88
- 'S',
89
- 'T',
90
- 'U',
91
- 'V',
92
- 'W',
93
- 'X',
94
- 'Y',
95
- 'Z',
96
- 'a',
97
- 'b',
98
- 'c',
99
- 'd',
100
- 'e',
101
- 'f',
102
- 'g',
103
- 'h',
104
- 'i',
105
- 'j',
106
- 'k',
107
- 'l',
108
- 'm',
109
- 'n',
110
- 'o',
111
- 'p',
112
- 'q',
113
- 'r',
114
- 's',
115
- 't',
116
- 'u',
117
- 'v',
118
- 'w',
119
- 'x',
120
- 'y',
121
- 'z',
122
- '0',
123
- '1',
124
- '2',
125
- '3',
126
- '4',
127
- '5',
128
- '6',
129
- '7',
130
- '8',
131
- '9',
132
- '+',
133
- '/'
134
- ];
135
- // CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727
136
- const base64codes = [
137
- 255,
138
- 255,
139
- 255,
140
- 255,
141
- 255,
142
- 255,
143
- 255,
144
- 255,
145
- 255,
146
- 255,
147
- 255,
148
- 255,
149
- 255,
150
- 255,
151
- 255,
152
- 255,
153
- 255,
154
- 255,
155
- 255,
156
- 255,
157
- 255,
158
- 255,
159
- 255,
160
- 255,
161
- 255,
162
- 255,
163
- 255,
164
- 255,
165
- 255,
166
- 255,
167
- 255,
168
- 255,
169
- 255,
170
- 255,
171
- 255,
172
- 255,
173
- 255,
174
- 255,
175
- 255,
176
- 255,
177
- 255,
178
- 255,
179
- 255,
180
- 62,
181
- 255,
182
- 255,
183
- 255,
184
- 63,
185
- 52,
186
- 53,
187
- 54,
188
- 55,
189
- 56,
190
- 57,
191
- 58,
192
- 59,
193
- 60,
194
- 61,
195
- 255,
196
- 255,
197
- 255,
198
- 0,
199
- 255,
200
- 255,
201
- 255,
202
- 0,
203
- 1,
204
- 2,
205
- 3,
206
- 4,
207
- 5,
208
- 6,
209
- 7,
210
- 8,
211
- 9,
212
- 10,
213
- 11,
214
- 12,
215
- 13,
216
- 14,
217
- 15,
218
- 16,
219
- 17,
220
- 18,
221
- 19,
222
- 20,
223
- 21,
224
- 22,
225
- 23,
226
- 24,
227
- 25,
228
- 255,
229
- 255,
230
- 255,
231
- 255,
232
- 255,
233
- 255,
234
- 26,
235
- 27,
236
- 28,
237
- 29,
238
- 30,
239
- 31,
240
- 32,
241
- 33,
242
- 34,
243
- 35,
244
- 36,
245
- 37,
246
- 38,
247
- 39,
248
- 40,
249
- 41,
250
- 42,
251
- 43,
252
- 44,
253
- 45,
254
- 46,
255
- 47,
256
- 48,
257
- 49,
258
- 50,
259
- 51
260
- ];
261
-
262
- //# sourceMappingURL=base64.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/base64.ts"],"sourcesContent":["/**\n * CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727\n * Encodes a given Uint8Array, ArrayBuffer or string into RFC4648 base64 representation\n * @param data\n */\nexport function encode(data: ArrayBuffer | string): string {\n const uint8 = typeof data === 'string' ? new TextEncoder().encode(data) : data instanceof Uint8Array ? data : new Uint8Array(data)\n let result = ''\n let i\n const l = uint8.length\n for (i = 2; i < l; i += 3) {\n result += base64abc[uint8[i - 2] >> 2]\n result += base64abc[((uint8[i - 2] & 0x03) << 4) | (uint8[i - 1] >> 4)]\n result += base64abc[((uint8[i - 1] & 0x0f) << 2) | (uint8[i] >> 6)]\n result += base64abc[uint8[i] & 0x3f]\n }\n if (i === l + 1) {\n // 1 octet yet to write\n result += base64abc[uint8[i - 2] >> 2]\n result += base64abc[(uint8[i - 2] & 0x03) << 4]\n result += '=='\n }\n if (i === l) {\n // 2 octets yet to write\n result += base64abc[uint8[i - 2] >> 2]\n result += base64abc[((uint8[i - 2] & 0x03) << 4) | (uint8[i - 1] >> 4)]\n result += base64abc[(uint8[i - 1] & 0x0f) << 2]\n result += '='\n }\n return result\n}\n\n/**\n * CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727\n * Decodes RFC4648 base64 string into an Uint8Array\n * @param data\n */\nexport function decode(data: string): Uint8Array {\n if (data.length % 4 !== 0) {\n throw new Error('Unable to parse base64 string.')\n }\n const index = data.indexOf('=')\n if (index !== -1 && index < data.length - 2) {\n throw new Error('Unable to parse base64 string.')\n }\n const missingOctets = data.endsWith('==') ? 2 : data.endsWith('=') ? 1 : 0\n const n = data.length\n const result = new Uint8Array(3 * (n / 4))\n let buffer\n for (let i = 0, j = 0; i < n; i += 4, j += 3) {\n buffer =\n (getBase64Code(data.charCodeAt(i)) << 18) |\n (getBase64Code(data.charCodeAt(i + 1)) << 12) |\n (getBase64Code(data.charCodeAt(i + 2)) << 6) |\n getBase64Code(data.charCodeAt(i + 3))\n result[j] = buffer >> 16\n result[j + 1] = (buffer >> 8) & 0xff\n result[j + 2] = buffer & 0xff\n }\n return result.subarray(0, result.length - missingOctets)\n}\n\n/**\n * CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727\n * @param charCode\n */\nfunction getBase64Code(charCode: number): number {\n if (charCode >= base64codes.length) {\n throw new Error('Unable to parse base64 string.')\n }\n const code = base64codes[charCode]\n if (code === 255) {\n throw new Error('Unable to parse base64 string.')\n }\n return code\n}\n\n// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license.\nconst base64abc = [\n 'A',\n 'B',\n 'C',\n 'D',\n 'E',\n 'F',\n 'G',\n 'H',\n 'I',\n 'J',\n 'K',\n 'L',\n 'M',\n 'N',\n 'O',\n 'P',\n 'Q',\n 'R',\n 'S',\n 'T',\n 'U',\n 'V',\n 'W',\n 'X',\n 'Y',\n 'Z',\n 'a',\n 'b',\n 'c',\n 'd',\n 'e',\n 'f',\n 'g',\n 'h',\n 'i',\n 'j',\n 'k',\n 'l',\n 'm',\n 'n',\n 'o',\n 'p',\n 'q',\n 'r',\n 's',\n 't',\n 'u',\n 'v',\n 'w',\n 'x',\n 'y',\n 'z',\n '0',\n '1',\n '2',\n '3',\n '4',\n '5',\n '6',\n '7',\n '8',\n '9',\n '+',\n '/',\n]\n\n// CREDIT: https://gist.github.com/enepomnyaschih/72c423f727d395eeaa09697058238727\nconst base64codes = [\n 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255,\n 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 62, 255, 255, 255, 63, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 255, 255, 255,\n 0, 255, 255, 255, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 255, 255, 255, 255, 255, 255, 26,\n 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51,\n]\n"],"names":["encode","data","uint8","TextEncoder","Uint8Array","result","i","l","length","base64abc","decode","Error","index","indexOf","missingOctets","endsWith","n","buffer","j","getBase64Code","charCodeAt","subarray","charCode","base64codes","code"],"mappings":"AAAA;;;;CAIC,GACD,OAAO,SAASA,OAAOC,IAA0B,EAAU;IACzD,MAAMC,QAAQ,OAAOD,SAAS,WAAW,IAAIE,cAAcH,MAAM,CAACC,QAAQA,gBAAgBG,aAAaH,OAAO,IAAIG,WAAWH,KAAK;IAClI,IAAII,SAAS;IACb,IAAIC;IACJ,MAAMC,IAAIL,MAAMM,MAAM;IACtB,IAAKF,IAAI,GAAGA,IAAIC,GAAGD,KAAK,EAAG;QACzBD,UAAUI,SAAS,CAACP,KAAK,CAACI,IAAI,EAAE,IAAI,EAAE;QACtCD,UAAUI,SAAS,CAAC,AAAEP,CAAAA,KAAK,CAACI,IAAI,EAAE,GAAG,IAAG,KAAM,IAAMJ,KAAK,CAACI,IAAI,EAAE,IAAI,EAAG;QACvED,UAAUI,SAAS,CAAC,AAAEP,CAAAA,KAAK,CAACI,IAAI,EAAE,GAAG,IAAG,KAAM,IAAMJ,KAAK,CAACI,EAAE,IAAI,EAAG;QACnED,UAAUI,SAAS,CAACP,KAAK,CAACI,EAAE,GAAG,KAAK;IACtC;IACA,IAAIA,MAAMC,IAAI,GAAG;QACf,uBAAuB;QACvBF,UAAUI,SAAS,CAACP,KAAK,CAACI,IAAI,EAAE,IAAI,EAAE;QACtCD,UAAUI,SAAS,CAAC,AAACP,CAAAA,KAAK,CAACI,IAAI,EAAE,GAAG,IAAG,KAAM,EAAE;QAC/CD,UAAU;IACZ,CAAC;IACD,IAAIC,MAAMC,GAAG;QACX,wBAAwB;QACxBF,UAAUI,SAAS,CAACP,KAAK,CAACI,IAAI,EAAE,IAAI,EAAE;QACtCD,UAAUI,SAAS,CAAC,AAAEP,CAAAA,KAAK,CAACI,IAAI,EAAE,GAAG,IAAG,KAAM,IAAMJ,KAAK,CAACI,IAAI,EA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