@arcadiasystems/morse-sdk 0.3.0 → 0.4.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 (103) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/dist/codecs.d.ts +3 -7
  3. package/dist/codecs.d.ts.map +1 -1
  4. package/dist/codecs.js +3 -11
  5. package/dist/codecs.js.map +1 -1
  6. package/dist/config.d.ts +9 -9
  7. package/dist/config.d.ts.map +1 -1
  8. package/dist/config.js +13 -10
  9. package/dist/config.js.map +1 -1
  10. package/dist/errors.d.ts +2 -2
  11. package/dist/errors.d.ts.map +1 -1
  12. package/dist/errors.format.js +1 -2
  13. package/dist/errors.format.js.map +1 -1
  14. package/dist/errors.js +29 -27
  15. package/dist/errors.js.map +1 -1
  16. package/dist/index.d.ts +5 -5
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +4 -4
  19. package/dist/index.js.map +1 -1
  20. package/dist/ops/index.d.ts +2 -3
  21. package/dist/ops/index.d.ts.map +1 -1
  22. package/dist/ops/index.js +2 -3
  23. package/dist/ops/index.js.map +1 -1
  24. package/dist/ops/recipient-file-from-bytes.d.ts +123 -0
  25. package/dist/ops/recipient-file-from-bytes.d.ts.map +1 -0
  26. package/dist/ops/recipient-file-from-bytes.js +142 -0
  27. package/dist/ops/recipient-file-from-bytes.js.map +1 -0
  28. package/dist/ops/recipient-file.d.ts +114 -0
  29. package/dist/ops/recipient-file.d.ts.map +1 -0
  30. package/dist/ops/recipient-file.js +151 -0
  31. package/dist/ops/recipient-file.js.map +1 -0
  32. package/dist/ptb/recipient-file.d.ts +82 -0
  33. package/dist/ptb/recipient-file.d.ts.map +1 -0
  34. package/dist/ptb/recipient-file.js +148 -0
  35. package/dist/ptb/recipient-file.js.map +1 -0
  36. package/dist/read/index.d.ts +2 -2
  37. package/dist/read/index.d.ts.map +1 -1
  38. package/dist/read/index.js +2 -2
  39. package/dist/read/index.js.map +1 -1
  40. package/dist/read/recipient-file-events.d.ts +65 -0
  41. package/dist/read/recipient-file-events.d.ts.map +1 -0
  42. package/dist/read/recipient-file-events.js +172 -0
  43. package/dist/read/recipient-file-events.js.map +1 -0
  44. package/dist/read/recipient-files-reader.d.ts +27 -0
  45. package/dist/read/recipient-files-reader.d.ts.map +1 -0
  46. package/dist/read/recipient-files-reader.js +170 -0
  47. package/dist/read/recipient-files-reader.js.map +1 -0
  48. package/dist/seal/adapter.d.ts +20 -19
  49. package/dist/seal/adapter.d.ts.map +1 -1
  50. package/dist/seal/adapter.js +9 -3
  51. package/dist/seal/adapter.js.map +1 -1
  52. package/dist/seal/default-adapter.d.ts +5 -5
  53. package/dist/seal/default-adapter.d.ts.map +1 -1
  54. package/dist/seal/default-adapter.js +13 -22
  55. package/dist/seal/default-adapter.js.map +1 -1
  56. package/dist/seal/index.d.ts +2 -2
  57. package/dist/seal/index.d.ts.map +1 -1
  58. package/dist/seal/index.js +1 -1
  59. package/dist/seal/index.js.map +1 -1
  60. package/dist/seal/recipient-file-identity.d.ts +53 -0
  61. package/dist/seal/recipient-file-identity.d.ts.map +1 -0
  62. package/dist/seal/recipient-file-identity.js +87 -0
  63. package/dist/seal/recipient-file-identity.js.map +1 -0
  64. package/dist/types.d.ts +43 -59
  65. package/dist/types.d.ts.map +1 -1
  66. package/dist/types.js +1 -1
  67. package/dist/types.js.map +1 -1
  68. package/dist/wallets/keypair-adapter.d.ts.map +1 -1
  69. package/dist/wallets/keypair-adapter.js +1 -2
  70. package/dist/wallets/keypair-adapter.js.map +1 -1
  71. package/package.json +1 -1
  72. package/dist/ops/allowlist.d.ts +0 -79
  73. package/dist/ops/allowlist.d.ts.map +0 -1
  74. package/dist/ops/allowlist.js +0 -122
  75. package/dist/ops/allowlist.js.map +0 -1
  76. package/dist/ops/file-from-bytes.d.ts +0 -84
  77. package/dist/ops/file-from-bytes.d.ts.map +0 -1
  78. package/dist/ops/file-from-bytes.js +0 -133
  79. package/dist/ops/file-from-bytes.js.map +0 -1
  80. package/dist/ops/file.d.ts +0 -88
  81. package/dist/ops/file.d.ts.map +0 -1
  82. package/dist/ops/file.js +0 -142
  83. package/dist/ops/file.js.map +0 -1
  84. package/dist/ptb/allowlist.d.ts +0 -65
  85. package/dist/ptb/allowlist.d.ts.map +0 -1
  86. package/dist/ptb/allowlist.js +0 -75
  87. package/dist/ptb/allowlist.js.map +0 -1
  88. package/dist/ptb/file.d.ts +0 -58
  89. package/dist/ptb/file.d.ts.map +0 -1
  90. package/dist/ptb/file.js +0 -108
  91. package/dist/ptb/file.js.map +0 -1
  92. package/dist/read/files-events.d.ts +0 -87
  93. package/dist/read/files-events.d.ts.map +0 -1
  94. package/dist/read/files-events.js +0 -194
  95. package/dist/read/files-events.js.map +0 -1
  96. package/dist/read/files-reader.d.ts +0 -59
  97. package/dist/read/files-reader.d.ts.map +0 -1
  98. package/dist/read/files-reader.js +0 -247
  99. package/dist/read/files-reader.js.map +0 -1
  100. package/dist/seal/allowlist-identity.d.ts +0 -36
  101. package/dist/seal/allowlist-identity.d.ts.map +0 -1
  102. package/dist/seal/allowlist-identity.js +0 -81
  103. package/dist/seal/allowlist-identity.js.map +0 -1
@@ -0,0 +1,82 @@
1
+ /**
2
+ * PTB builders for the `recipient_file` module. Internal to the SDK; `ops/`
3
+ * composes these into single atomic transactions. All builders target
4
+ * `config.packageId` (the current published-at) because the
5
+ * `recipient_file` module was added in a package upgrade; calling it at
6
+ * `originalPackageId` would resolve to the v1 bytecode where the module
7
+ * does not exist.
8
+ */
9
+ import type { Transaction, TransactionArgument, TransactionObjectArgument, TransactionResult } from "@mysten/sui/transactions";
10
+ import type { BlobObjectId, PackageId, RecipientFileId, SuiAddress, WalrusBlobId } from "../types.js";
11
+ /** Walrus system `Clock` shared object. Required by `new_recipient_file*`. */
12
+ export declare const SUI_CLOCK_OBJECT_ID = "0x6";
13
+ export interface BuildNewRecipientFileArgs {
14
+ readonly packageId: PackageId;
15
+ readonly blobId: WalrusBlobId;
16
+ readonly blobObjectId?: BlobObjectId;
17
+ readonly name: string;
18
+ readonly contentType: string;
19
+ readonly size: number;
20
+ readonly recipients: readonly SuiAddress[];
21
+ }
22
+ /**
23
+ * Add a `recipient_file::new_recipient_file` call. Returns the created
24
+ * `RecipientFile` by value; the caller must consume it (typically via
25
+ * `buildShareRecipientFile` in the same PTB).
26
+ */
27
+ export declare function buildNewRecipientFile(tx: Transaction, args: BuildNewRecipientFileArgs): TransactionResult;
28
+ export interface BuildNewRecipientFileWithSealPrefixArgs extends BuildNewRecipientFileArgs {
29
+ readonly sealIdPrefix: Uint8Array;
30
+ }
31
+ /**
32
+ * Add a `recipient_file::new_recipient_file_with_seal_prefix` call. The
33
+ * supplied prefix is the bytes that Seal identities for this file's
34
+ * encrypted content must start with (followed by tag=3 and a per-encrypt
35
+ * nonce). Returns the created `RecipientFile` by value.
36
+ */
37
+ export declare function buildNewRecipientFileWithSealPrefix(tx: Transaction, args: BuildNewRecipientFileWithSealPrefixArgs): TransactionResult;
38
+ export interface BuildShareRecipientFileArgs {
39
+ readonly packageId: PackageId;
40
+ readonly file: TransactionArgument;
41
+ }
42
+ /** Add a `recipient_file::share_recipient_file` call. Consumes the file. */
43
+ export declare function buildShareRecipientFile(tx: Transaction, args: BuildShareRecipientFileArgs): TransactionResult;
44
+ export interface BuildAddRecipientArgs {
45
+ readonly packageId: PackageId;
46
+ readonly file: RecipientFileId | TransactionObjectArgument;
47
+ readonly recipient: SuiAddress;
48
+ }
49
+ /** Add a `recipient_file::add_recipient` call. */
50
+ export declare function buildAddRecipient(tx: Transaction, args: BuildAddRecipientArgs): TransactionResult;
51
+ export interface BuildRemoveRecipientArgs {
52
+ readonly packageId: PackageId;
53
+ readonly file: RecipientFileId | TransactionObjectArgument;
54
+ readonly recipient: SuiAddress;
55
+ }
56
+ /** Add a `recipient_file::remove_recipient` call. */
57
+ export declare function buildRemoveRecipient(tx: Transaction, args: BuildRemoveRecipientArgs): TransactionResult;
58
+ export interface BuildTransferRecipientFileOwnershipArgs {
59
+ readonly packageId: PackageId;
60
+ readonly file: RecipientFileId | TransactionObjectArgument;
61
+ readonly newOwner: SuiAddress;
62
+ }
63
+ /**
64
+ * Add a `recipient_file::transfer_ownership` call. Does NOT touch `members`;
65
+ * compose with `add_recipient`/`remove_recipient` for a full handover.
66
+ */
67
+ export declare function buildTransferRecipientFileOwnership(tx: Transaction, args: BuildTransferRecipientFileOwnershipArgs): TransactionResult;
68
+ export interface BuildUpdateRecipientFileMetadataArgs {
69
+ readonly packageId: PackageId;
70
+ readonly file: RecipientFileId | TransactionObjectArgument;
71
+ readonly name: string;
72
+ readonly contentType: string;
73
+ }
74
+ /** Add a `recipient_file::update_metadata` call. */
75
+ export declare function buildUpdateRecipientFileMetadata(tx: Transaction, args: BuildUpdateRecipientFileMetadataArgs): TransactionResult;
76
+ export interface BuildDeleteRecipientFileArgs {
77
+ readonly packageId: PackageId;
78
+ readonly file: RecipientFileId | TransactionObjectArgument;
79
+ }
80
+ /** Add a `recipient_file::delete_file` call. Consumes the file. */
81
+ export declare function buildDeleteRecipientFile(tx: Transaction, args: BuildDeleteRecipientFileArgs): TransactionResult;
82
+ //# sourceMappingURL=recipient-file.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipient-file.d.ts","sourceRoot":"","sources":["../../src/ptb/recipient-file.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EACX,WAAW,EACX,mBAAmB,EACnB,yBAAyB,EACzB,iBAAiB,EACjB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EACX,YAAY,EACZ,SAAS,EACT,eAAe,EACf,UAAU,EACV,YAAY,EACZ,MAAM,aAAa,CAAC;AAGrB,8EAA8E;AAC9E,eAAO,MAAM,mBAAmB,QAAQ,CAAC;AAEzC,MAAM,WAAW,yBAAyB;IACzC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,YAAY,CAAC;IAC9B,QAAQ,CAA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ED,qDAAqD;AACrD,wBAAgB,oBAAoB,CACnC,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,wBAAwB,GAC5B,iBAAiB,CAQnB;AAED,MAAM,WAAW,uCAAuC;IACvD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,yBAAyB,CAAC;IAC3D,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,mCAAmC,CAClD,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,uCAAuC,GAC3C,iBAAiB,CAQnB;AAED,MAAM,WAAW,oCAAoC;IACpD,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,yBAAyB,CAAC;IAC3D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAED,oDAAoD;AACpD,wBAAgB,gCAAgC,CAC/C,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,oCAAoC,GACxC,iBAAiB,CASnB;AAED,MAAM,WAAW,4BAA4B;IAC5C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,IAAI,EAAE,eAAe,GAAG,yBAAyB,CAAC;CAC3D;AAED,mEAAmE;AACnE,wBAAgB,wBAAwB,CACvC,EAAE,EAAE,WAAW,EACf,IAAI,EAAE,4BAA4B,GAChC,iBAAiB,CAKnB"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * PTB builders for the `recipient_file` module. Internal to the SDK; `ops/`
3
+ * composes these into single atomic transactions. All builders target
4
+ * `config.packageId` (the current published-at) because the
5
+ * `recipient_file` module was added in a package upgrade; calling it at
6
+ * `originalPackageId` would resolve to the v1 bytecode where the module
7
+ * does not exist.
8
+ */
9
+ import { ValidationError } from "../errors.js";
10
+ import { resolveObjectArg } from "./internal.js";
11
+ /** Walrus system `Clock` shared object. Required by `new_recipient_file*`. */
12
+ export const SUI_CLOCK_OBJECT_ID = "0x6";
13
+ /**
14
+ * Add a `recipient_file::new_recipient_file` call. Returns the created
15
+ * `RecipientFile` by value; the caller must consume it (typically via
16
+ * `buildShareRecipientFile` in the same PTB).
17
+ */
18
+ export function buildNewRecipientFile(tx, args) {
19
+ return tx.moveCall({
20
+ target: `${args.packageId}::recipient_file::new_recipient_file`,
21
+ arguments: [
22
+ tx.pure.vector("u8", Array.from(walrusBlobIdToBytes(args.blobId))),
23
+ optionObjectId(tx, args.blobObjectId),
24
+ tx.pure.string(args.name),
25
+ tx.pure.string(args.contentType),
26
+ tx.pure.u64(args.size),
27
+ tx.pure.vector("address", [...args.recipients]),
28
+ tx.object(SUI_CLOCK_OBJECT_ID),
29
+ ],
30
+ });
31
+ }
32
+ /**
33
+ * Add a `recipient_file::new_recipient_file_with_seal_prefix` call. The
34
+ * supplied prefix is the bytes that Seal identities for this file's
35
+ * encrypted content must start with (followed by tag=3 and a per-encrypt
36
+ * nonce). Returns the created `RecipientFile` by value.
37
+ */
38
+ export function buildNewRecipientFileWithSealPrefix(tx, args) {
39
+ return tx.moveCall({
40
+ target: `${args.packageId}::recipient_file::new_recipient_file_with_seal_prefix`,
41
+ arguments: [
42
+ tx.pure.vector("u8", Array.from(args.sealIdPrefix)),
43
+ tx.pure.vector("u8", Array.from(walrusBlobIdToBytes(args.blobId))),
44
+ optionObjectId(tx, args.blobObjectId),
45
+ tx.pure.string(args.name),
46
+ tx.pure.string(args.contentType),
47
+ tx.pure.u64(args.size),
48
+ tx.pure.vector("address", [...args.recipients]),
49
+ tx.object(SUI_CLOCK_OBJECT_ID),
50
+ ],
51
+ });
52
+ }
53
+ /** Add a `recipient_file::share_recipient_file` call. Consumes the file. */
54
+ export function buildShareRecipientFile(tx, args) {
55
+ return tx.moveCall({
56
+ target: `${args.packageId}::recipient_file::share_recipient_file`,
57
+ arguments: [args.file],
58
+ });
59
+ }
60
+ /** Add a `recipient_file::add_recipient` call. */
61
+ export function buildAddRecipient(tx, args) {
62
+ return tx.moveCall({
63
+ target: `${args.packageId}::recipient_file::add_recipient`,
64
+ arguments: [
65
+ resolveObjectArg(tx, args.file),
66
+ tx.pure.address(args.recipient),
67
+ ],
68
+ });
69
+ }
70
+ /** Add a `recipient_file::remove_recipient` call. */
71
+ export function buildRemoveRecipient(tx, args) {
72
+ return tx.moveCall({
73
+ target: `${args.packageId}::recipient_file::remove_recipient`,
74
+ arguments: [
75
+ resolveObjectArg(tx, args.file),
76
+ tx.pure.address(args.recipient),
77
+ ],
78
+ });
79
+ }
80
+ /**
81
+ * Add a `recipient_file::transfer_ownership` call. Does NOT touch `members`;
82
+ * compose with `add_recipient`/`remove_recipient` for a full handover.
83
+ */
84
+ export function buildTransferRecipientFileOwnership(tx, args) {
85
+ return tx.moveCall({
86
+ target: `${args.packageId}::recipient_file::transfer_ownership`,
87
+ arguments: [
88
+ resolveObjectArg(tx, args.file),
89
+ tx.pure.address(args.newOwner),
90
+ ],
91
+ });
92
+ }
93
+ /** Add a `recipient_file::update_metadata` call. */
94
+ export function buildUpdateRecipientFileMetadata(tx, args) {
95
+ return tx.moveCall({
96
+ target: `${args.packageId}::recipient_file::update_metadata`,
97
+ arguments: [
98
+ resolveObjectArg(tx, args.file),
99
+ tx.pure.string(args.name),
100
+ tx.pure.string(args.contentType),
101
+ ],
102
+ });
103
+ }
104
+ /** Add a `recipient_file::delete_file` call. Consumes the file. */
105
+ export function buildDeleteRecipientFile(tx, args) {
106
+ return tx.moveCall({
107
+ target: `${args.packageId}::recipient_file::delete_file`,
108
+ arguments: [resolveObjectArg(tx, args.file)],
109
+ });
110
+ }
111
+ function optionObjectId(tx, id) {
112
+ if (id === undefined) {
113
+ return tx.moveCall({
114
+ target: "0x1::option::none",
115
+ typeArguments: ["0x2::object::ID"],
116
+ });
117
+ }
118
+ return tx.moveCall({
119
+ target: "0x1::option::some",
120
+ typeArguments: ["0x2::object::ID"],
121
+ arguments: [tx.pure.id(id)],
122
+ });
123
+ }
124
+ const WALRUS_BLOB_ID_CHARS = 43;
125
+ /**
126
+ * Walrus blob ids are 43-char URL-safe base64 (32 bytes decoded). The Move
127
+ * contract expects raw bytes. Decoding here keeps PTB builders pure.
128
+ *
129
+ * Defends against a mis-branded input by asserting the length even though
130
+ * `toWalrusBlobId` already validates at the codec entry. Surfaces a
131
+ * meaningful error rather than an opaque `atob` exception if the brand
132
+ * invariant is ever violated.
133
+ */
134
+ function walrusBlobIdToBytes(blobId) {
135
+ const raw = blobId;
136
+ if (raw.length !== WALRUS_BLOB_ID_CHARS) {
137
+ throw new ValidationError(`WalrusBlobId must be ${WALRUS_BLOB_ID_CHARS} chars; got ${raw.length}`, "blobId");
138
+ }
139
+ // URL-safe base64 -> standard base64. 43 chars -> single `=` padding.
140
+ const padded = `${raw.replace(/-/g, "+").replace(/_/g, "/")}=`;
141
+ const binary = atob(padded);
142
+ const bytes = new Uint8Array(binary.length);
143
+ for (let i = 0; i < binary.length; i += 1) {
144
+ bytes[i] = binary.charCodeAt(i);
145
+ }
146
+ return bytes;
147
+ }
148
+ //# sourceMappingURL=recipient-file.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipient-file.js","sourceRoot":"","sources":["../../src/ptb/recipient-file.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAQ/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD,8EAA8E;AAC9E,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,CAAC;AAYzC;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACpC,EAAe,EACf,IAA+B;IAE/B,OAAO,EAAE,CAAC,QAAQ,CAAC;QAClB,MAAM,EAAE,GAAG,IAAI,CAAC,SAAS,sCAAsC;QAC/D,SAAS,EAAE;YACV,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EA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AE,CAAC;AAEhC;;;;;;;;GAQG;AACH,SAAS,mBAAmB,CAAC,MAAoB;IAChD,MAAM,GAAG,GAAG,MAAgB,CAAC;IAC7B,IAAI,GAAG,CAAC,MAAM,KAAK,oBAAoB,EAAE,CAAC;QACzC,MAAM,IAAI,eAAe,CACxB,wBAAwB,oBAAoB,eAAe,GAAG,CAAC,MAAM,EAAE,EACvE,QAAQ,CACR,CAAC;IACH,CAAC;IACD,sEAAsE;IACtE,MAAM,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,CAAC;IAC/D,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC5B,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC3C,KAAK,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Public barrel for the read layer.
3
3
  */
4
- export { buildFilesEventTypes, type FilesEventInput, type FilesEventTypes, reconcileFilesAccessibleBy, reconcileFilesOwnedBy, } from "./files-events.js";
5
- export { type AllowlistCapListPage, type FilesListOptions, type FilesReader, RpcFilesReader, } from "./files-reader.js";
6
4
  export { type EntryListPage, type ListEntriesOptions, type ListPublicationsOptions, type ListPublisherCapsOptions, type OwnedPublication, type PublicationListPage, type PublicationReader, type PublisherCapListPage, RpcPublicationReader, type ScanEntriesOptions, } from "./reader.js";
5
+ export { buildRecipientFileEventTypes, type RecipientFileEventInput, type RecipientFileEventTypes, reconcileRecipientFilesAccessibleBy, reconcileRecipientFilesOwnedBy, } from "./recipient-file-events.js";
6
+ export { type RecipientFilesReader, RpcRecipientFilesReader, type RpcRecipientFilesReaderConfig, } from "./recipient-files-reader.js";
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/read/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,oBAAoB,EACpB,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,0BAA0B,EAC1B,qBAAqB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAChB,cAAc,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,oBAAoB,EACpB,KAAK,kBAAkB,GACvB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/read/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,kBAAkB,EACvB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,EACtB,KAAK,oBAAoB,EACzB,oBAAoB,EACpB,KAAK,kBAAkB,GACvB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,4BAA4B,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,mCAAmC,EACnC,8BAA8B,GAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACN,KAAK,oBAAoB,EACzB,uBAAuB,EACvB,KAAK,6BAA6B,GAClC,MAAM,6BAA6B,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Public barrel for the read layer.
3
3
  */
4
- export { buildFilesEventTypes, reconcileFilesAccessibleBy, reconcileFilesOwnedBy, } from "./files-events.js";
5
- export { RpcFilesReader, } from "./files-reader.js";
6
4
  export { RpcPublicationReader, } from "./reader.js";
5
+ export { buildRecipientFileEventTypes, reconcileRecipientFilesAccessibleBy, reconcileRecipientFilesOwnedBy, } from "./recipient-file-events.js";
6
+ export { RpcRecipientFilesReader, } from "./recipient-files-reader.js";
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/read/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACN,oBAAoB,EAGpB,0BAA0B,EAC1B,qBAAqB,GACrB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAIN,cAAc,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EASN,oBAAoB,GAEpB,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/read/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EASN,oBAAoB,GAEpB,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,4BAA4B,EAG5B,mCAAmC,EACnC,8BAA8B,GAC9B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEN,uBAAuB,GAEvB,MAAM,6BAA6B,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Event-driven reads for the `recipient_file` module. Pure reconciliation
3
+ * helpers that replay a stream of event payloads into a current-state
4
+ * snapshot, plus a string builder for the fully-qualified Sui event types
5
+ * indexers subscribe to.
6
+ *
7
+ * Event identity is rooted at `recipientFileEventOriginPackageId` (the
8
+ * package address where the `recipient_file` module was FIRST defined).
9
+ * Distinct from `packageId` (current published-at; moves on every upgrade)
10
+ * and `originalPackageId` (publication-modules v1 genesis).
11
+ */
12
+ import type { PackageId, RecipientFileSummary, SuiAddress } from "../types.js";
13
+ /** Fully-qualified Move event types for the recipient-file module. */
14
+ export interface RecipientFileEventTypes {
15
+ readonly RecipientFileCreated: string;
16
+ readonly RecipientFileDeleted: string;
17
+ readonly RecipientFileMetadataUpdated: string;
18
+ readonly RecipientFileOwnershipTransferred: string;
19
+ readonly RecipientFileSealPrefixAttached: string;
20
+ readonly RecipientAdded: string;
21
+ readonly RecipientRemoved: string;
22
+ }
23
+ /**
24
+ * Build the fully-qualified event-type strings used by indexers to filter
25
+ * Sui event streams. Pass `config.recipientFileEventOriginPackageId` (NOT
26
+ * `config.packageId`, which moves on upgrades) as `originPackageId`.
27
+ */
28
+ export declare function buildRecipientFileEventTypes(originPackageId: PackageId): RecipientFileEventTypes;
29
+ /**
30
+ * Input shape for reconciliation. Indexers normalize Sui event envelopes
31
+ * into `{ type, json, timestampMs }`; the helpers below switch on `type`.
32
+ */
33
+ export interface RecipientFileEventInput {
34
+ /** Fully-qualified Sui event type. */
35
+ readonly type: string;
36
+ /** Move event payload, decoded as JSON. */
37
+ readonly json: Record<string, unknown>;
38
+ /**
39
+ * Transaction timestamp in milliseconds. Sourced from the Sui event
40
+ * envelope; used only for `createdAtMs` on summaries.
41
+ */
42
+ readonly timestampMs: number;
43
+ }
44
+ /**
45
+ * Replay `events` in order to derive every RecipientFile currently owned by
46
+ * `owner`. Pure: same inputs always produce the same output.
47
+ *
48
+ * Files are dropped from the result on `RecipientFileDeleted` and when
49
+ * `RecipientFileOwnershipTransferred` moves them off `owner`. Files
50
+ * transferred TO `owner` are NOT added because the event payload does not
51
+ * carry the file metadata; consumers needing those should re-fetch via
52
+ * `getRecipientFile` or filter `RecipientFileCreated` upstream.
53
+ */
54
+ export declare function reconcileRecipientFilesOwnedBy(events: readonly RecipientFileEventInput[], owner: SuiAddress, types: RecipientFileEventTypes): RecipientFileSummary[];
55
+ /**
56
+ * Replay `events` in order to derive every RecipientFile where `address` is
57
+ * currently a recipient (owner or member). Pure.
58
+ *
59
+ * Files are added on `RecipientFileCreated` where `address` appears in
60
+ * `members`, and on `RecipientAdded` where `recipient == address`. Files
61
+ * are dropped on `RecipientFileDeleted` and on `RecipientRemoved` where
62
+ * `recipient == address`.
63
+ */
64
+ export declare function reconcileRecipientFilesAccessibleBy(events: readonly RecipientFileEventInput[], address: SuiAddress, types: RecipientFileEventTypes): RecipientFileSummary[];
65
+ //# sourceMappingURL=recipient-file-events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipient-file-events.d.ts","sourceRoot":"","sources":["../../src/read/recipient-file-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,EACX,SAAS,EAET,oBAAoB,EACpB,UAAU,EACV,MAAM,aAAa,CAAC;AAErB,sEAAsE;AACtE,MAAM,WAAW,uBAAuB;IACvC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,4BAA4B,EAAE,MAAM,CAAC;IAC9C,QAAQ,CAAC,iCAAiC,EAAE,MAAM,CAAC;IACnD,QAAQ,CAAC,+BAA+B,EAAE,MAAM,CAAC;IACjD,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CAClC;AAED;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC3C,eAAe,EAAE,SAAS,GACxB,uBAAuB,CAWzB;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACvC,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACvC;;;OAGG;IACH,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC7B;AAYD;;;;;;;;;GASG;AACH,wBAAgB,8BAA8B,CAC7C,MAAM,EAAE,SAAS,uBAAuB,EAAE,EAC1C,KAAK,EAAE,UAAU,EACjB,KAAK,EAAE,uBAAuB,GAC5B,oBAAoB,EAAE,CAWxB;AAED;;;;;;;;GAQG;AACH,wBAAgB,mCAAmC,CAClD,MAAM,EAAE,SAAS,uBAAuB,EAAE,EAC1C,OAAO,EAAE,UAAU,EACnB,KAAK,EAAE,uBAAuB,GAC5B,oBAAoB,EAAE,CAWxB"}
@@ -0,0 +1,172 @@
1
+ /**
2
+ * Event-driven reads for the `recipient_file` module. Pure reconciliation
3
+ * helpers that replay a stream of event payloads into a current-state
4
+ * snapshot, plus a string builder for the fully-qualified Sui event types
5
+ * indexers subscribe to.
6
+ *
7
+ * Event identity is rooted at `recipientFileEventOriginPackageId` (the
8
+ * package address where the `recipient_file` module was FIRST defined).
9
+ * Distinct from `packageId` (current published-at; moves on every upgrade)
10
+ * and `originalPackageId` (publication-modules v1 genesis).
11
+ */
12
+ import { toRecipientFileId, toSuiAddress } from "../codecs.js";
13
+ import { ValidationError } from "../errors.js";
14
+ /**
15
+ * Build the fully-qualified event-type strings used by indexers to filter
16
+ * Sui event streams. Pass `config.recipientFileEventOriginPackageId` (NOT
17
+ * `config.packageId`, which moves on upgrades) as `originPackageId`.
18
+ */
19
+ export function buildRecipientFileEventTypes(originPackageId) {
20
+ const base = `${originPackageId}::recipient_file`;
21
+ return {
22
+ RecipientFileCreated: `${base}::RecipientFileCreated`,
23
+ RecipientFileDeleted: `${base}::RecipientFileDeleted`,
24
+ RecipientFileMetadataUpdated: `${base}::RecipientFileMetadataUpdated`,
25
+ RecipientFileOwnershipTransferred: `${base}::RecipientFileOwnershipTransferred`,
26
+ RecipientFileSealPrefixAttached: `${base}::RecipientFileSealPrefixAttached`,
27
+ RecipientAdded: `${base}::RecipientAdded`,
28
+ RecipientRemoved: `${base}::RecipientRemoved`,
29
+ };
30
+ }
31
+ /**
32
+ * Replay `events` in order to derive every RecipientFile currently owned by
33
+ * `owner`. Pure: same inputs always produce the same output.
34
+ *
35
+ * Files are dropped from the result on `RecipientFileDeleted` and when
36
+ * `RecipientFileOwnershipTransferred` moves them off `owner`. Files
37
+ * transferred TO `owner` are NOT added because the event payload does not
38
+ * carry the file metadata; consumers needing those should re-fetch via
39
+ * `getRecipientFile` or filter `RecipientFileCreated` upstream.
40
+ */
41
+ export function reconcileRecipientFilesOwnedBy(events, owner, types) {
42
+ const validatedOwner = toSuiAddress(owner);
43
+ const byId = new Map();
44
+ for (const event of events) {
45
+ applyEvent(event, types, byId);
46
+ }
47
+ return [...byId.values()]
48
+ .filter((s) => s.owner === validatedOwner)
49
+ .map(toSummary);
50
+ }
51
+ /**
52
+ * Replay `events` in order to derive every RecipientFile where `address` is
53
+ * currently a recipient (owner or member). Pure.
54
+ *
55
+ * Files are added on `RecipientFileCreated` where `address` appears in
56
+ * `members`, and on `RecipientAdded` where `recipient == address`. Files
57
+ * are dropped on `RecipientFileDeleted` and on `RecipientRemoved` where
58
+ * `recipient == address`.
59
+ */
60
+ export function reconcileRecipientFilesAccessibleBy(events, address, types) {
61
+ const validated = toSuiAddress(address);
62
+ const byId = new Map();
63
+ for (const event of events) {
64
+ applyEvent(event, types, byId);
65
+ }
66
+ return [...byId.values()]
67
+ .filter((s) => s.members.includes(validated))
68
+ .map(toSummary);
69
+ }
70
+ function applyEvent(event, types, byId) {
71
+ const j = event.json;
72
+ switch (event.type) {
73
+ case types.RecipientFileCreated: {
74
+ const id = readFileId(j);
75
+ const owner = toSuiAddress(readString(j, "owner"));
76
+ const members = readAddressArray(j, "members");
77
+ byId.set(id, {
78
+ id: id,
79
+ owner,
80
+ name: readString(j, "name"),
81
+ contentType: readString(j, "content_type"),
82
+ size: readSafeInteger(j, "size"),
83
+ members,
84
+ createdAtMs: event.timestampMs,
85
+ });
86
+ return;
87
+ }
88
+ case types.RecipientFileDeleted: {
89
+ byId.delete(readFileId(j));
90
+ return;
91
+ }
92
+ case types.RecipientFileMetadataUpdated: {
93
+ const summary = byId.get(readFileId(j));
94
+ if (!summary)
95
+ return;
96
+ summary.name = readString(j, "name");
97
+ summary.contentType = readString(j, "content_type");
98
+ return;
99
+ }
100
+ case types.RecipientFileOwnershipTransferred: {
101
+ const summary = byId.get(readFileId(j));
102
+ if (!summary)
103
+ return;
104
+ summary.owner = toSuiAddress(readString(j, "new_owner"));
105
+ return;
106
+ }
107
+ case types.RecipientAdded: {
108
+ const summary = byId.get(readFileId(j));
109
+ if (!summary)
110
+ return;
111
+ const recipient = toSuiAddress(readString(j, "recipient"));
112
+ if (!summary.members.includes(recipient))
113
+ summary.members.push(recipient);
114
+ return;
115
+ }
116
+ case types.RecipientRemoved: {
117
+ const summary = byId.get(readFileId(j));
118
+ if (!summary)
119
+ return;
120
+ const recipient = toSuiAddress(readString(j, "recipient"));
121
+ summary.members = summary.members.filter((m) => m !== recipient);
122
+ return;
123
+ }
124
+ default:
125
+ return;
126
+ }
127
+ }
128
+ // Normalize via `toRecipientFileId` so Map keys are canonical 64-char form
129
+ // regardless of whether the indexer surfaces short-form or padded ids.
130
+ function readFileId(json) {
131
+ return toRecipientFileId(readString(json, "file"));
132
+ }
133
+ function toSummary(s) {
134
+ return {
135
+ kind: "summary",
136
+ id: s.id,
137
+ owner: s.owner,
138
+ name: s.name,
139
+ contentType: s.contentType,
140
+ size: s.size,
141
+ members: [...s.members],
142
+ createdAtMs: s.createdAtMs,
143
+ };
144
+ }
145
+ function readString(json, key) {
146
+ const value = json[key];
147
+ if (typeof value !== "string") {
148
+ throw new ValidationError(`Event field ${key} is missing or not a string`, key);
149
+ }
150
+ return value;
151
+ }
152
+ function readSafeInteger(json, key) {
153
+ const raw = json[key];
154
+ const value = typeof raw === "string" ? Number(raw) : raw;
155
+ if (typeof value !== "number" || !Number.isSafeInteger(value) || value < 0) {
156
+ throw new ValidationError(`Event field ${key} is not a non-negative safe integer: ${JSON.stringify(raw)}`, key);
157
+ }
158
+ return value;
159
+ }
160
+ function readAddressArray(json, key) {
161
+ const value = json[key];
162
+ if (!Array.isArray(value)) {
163
+ throw new ValidationError(`Event field ${key} is not an array`, key);
164
+ }
165
+ return value.map((entry, idx) => {
166
+ if (typeof entry !== "string") {
167
+ throw new ValidationError(`Event field ${key}[${idx}] is not a string`, key);
168
+ }
169
+ return toSuiAddress(entry);
170
+ });
171
+ }
172
+ //# sourceMappingURL=recipient-file-events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipient-file-events.js","sourceRoot":"","sources":["../../src/read/recipient-file-events.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAmB/C;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC3C,eAA0B;IAE1B,MAAM,IAAI,GAAG,GAAG,eAAe,kBAAkB,CAAC;IAClD,OAAO;QACN,oBAAoB,EAAE,GAAG,IAAI,wBAAwB;QACrD,oBAAoB,EAAE,GAAG,IAAI,wBAAwB;QACrD,4BAA4B,EAAE,GAAG,IAAI,gCAAgC;QACrE,iCAAiC,EAAE,GAAG,IAAI,qCAAqC;QAC/E,+BAA+B,EAAE,GAAG,IAAI,mCAAmC;QAC3E,cAAc,EAAE,GAAG,IAAI,kBAAkB;QACzC,gBAAgB,EAAE,GAAG,IAAI,oBAAoB;KAC7C,CAAC;AACH,CAAC;AA4BD;;;;;;;;;GASG;AACH,MAAM,UAAU,8BAA8B,CAC7C,MAA0C,EAC1C,KAAiB,EACjB,KAA8B;IAE9B,MAAM,cAAc,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC;IAC3C,MAAM,IAAI,GAAG,IAAI,GAAG,EAA0B,CAAC;IAE/C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC5B,UAAU,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC;SACvB,MAAM,CAAC,CAA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,EAC/C,GAAG,CACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,eAAe,CAAC,IAA6B,EAAE,GAAW;IAClE,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,MAAM,KAAK,GAAG,OAAO,GAAG,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IAC1D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;QAC5E,MAAM,IAAI,eAAe,CACxB,eAAe,GAAG,wCAAwC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,EAAE,EAC/E,GAAG,CACH,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC;AAED,SAAS,gBAAgB,CACxB,IAA6B,EAC7B,GAAW;IAEX,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC;IACxB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,eAAe,CAAC,eAAe,GAAG,kBAAkB,EAAE,GAAG,CAAC,CAAC;IACtE,CAAC;IACD,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;QAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC/B,MAAM,IAAI,eAAe,CACxB,eAAe,GAAG,IAAI,GAAG,mBAAmB,EAC5C,GAAG,CACH,CAAC;QACH,CAAC;QACD,OAAO,YAAY,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Live object read for `RecipientFile`. Parses the shared object's JSON
3
+ * representation into the typed `RecipientFile` record.
4
+ *
5
+ * RecipientFile was introduced in the v3 contract upgrade; both the type
6
+ * filter and the move-call target paths use `config.packageId` (current
7
+ * published-at), not `originalPackageId` (publication-modules genesis).
8
+ */
9
+ import type { ObjectReader } from "../clients.js";
10
+ import type { PackageId, RecipientFile, RecipientFileId } from "../types.js";
11
+ /** Interface for reading `RecipientFile` objects. */
12
+ export interface RecipientFilesReader {
13
+ getRecipientFile(id: RecipientFileId, signal?: AbortSignal): Promise<RecipientFile>;
14
+ }
15
+ /** Configuration accepted by `RpcRecipientFilesReader.fromConfig`. */
16
+ export interface RpcRecipientFilesReaderConfig {
17
+ readonly packageId: PackageId;
18
+ }
19
+ /** RPC-backed implementation. */
20
+ export declare class RpcRecipientFilesReader implements RecipientFilesReader {
21
+ private readonly client;
22
+ private readonly packageId;
23
+ private constructor();
24
+ static fromConfig(client: ObjectReader, config: RpcRecipientFilesReaderConfig): RpcRecipientFilesReader;
25
+ getRecipientFile(id: RecipientFileId, signal?: AbortSignal): Promise<RecipientFile>;
26
+ }
27
+ //# sourceMappingURL=recipient-files-reader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipient-files-reader.d.ts","sourceRoot":"","sources":["../../src/read/recipient-files-reader.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAQlD,OAAO,KAAK,EAEX,SAAS,EACT,aAAa,EACb,eAAe,EAGf,MAAM,aAAa,CAAC;AAErB,qDAAqD;AACrD,MAAM,WAAW,oBAAoB;IACpC,gBAAgB,CACf,EAAE,EAAE,eAAe,EACnB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,aAAa,CAAC,CAAC;CAC1B;AAED,sEAAsE;AACtE,MAAM,WAAW,6BAA6B;IAC7C,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC9B;AAED,iCAAiC;AACjC,qBAAa,uBAAwB,YAAW,oBAAoB;IACnE,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAe;IACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IAEtC,OAAO;IAKP,MAAM,CAAC,UAAU,CAChB,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,6BAA6B,GACnC,uBAAuB;IAIpB,gBAAgB,CACrB,EAAE,EAAE,eAAe,EACnB,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,aAAa,CAAC;CA4BzB"}