@wowok/wowok 2.3.7 → 2.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/Transaction-B_HAG_T7.mjs +1 -0
- package/dist/esm/arb-B7NNAqML.mjs +1 -0
- package/dist/esm/base-5DoRlfD_.mjs +1 -0
- package/dist/esm/call-DZtG6l2x.mjs +1 -0
- package/dist/esm/client/index.d.mts +1 -1
- package/dist/esm/client/index.mjs +1 -1
- package/dist/esm/{client-VxiBQfen.mjs → client-YYCgsO99.mjs} +1 -1
- package/dist/esm/common-CQggZ8z4.mjs +1 -0
- package/dist/esm/cryptography/index.d.mts +1 -1
- package/dist/esm/cryptography/index.mjs +1 -1
- package/dist/esm/ed25519-BrJWQ45w.mjs +1 -1
- package/dist/esm/evm-account-Dppw7HJc.d.mts +233 -0
- package/dist/esm/exception--UEPnygY.mjs +1 -0
- package/dist/esm/{falcon512-J8Pe5emy.mjs → falcon512-B4y-EH2f.mjs} +1 -1
- package/dist/esm/graphql/index.d.mts +1 -1
- package/dist/esm/graphql/index.mjs +1 -1
- package/dist/esm/{graphql-BXSiG4J0.mjs → graphql-D2Rx6H0h.mjs} +1 -1
- package/dist/esm/grpc/index.d.mts +1 -1
- package/dist/esm/grpc/index.mjs +1 -1
- package/dist/esm/{grpc-clMX5Wo0.mjs → grpc-BYkFJ8ot.mjs} +1 -1
- package/dist/esm/{index-Q3W63gcw.d.mts → index-BB7rqcJ9.d.mts} +688 -288
- package/dist/esm/index.d.mts +5 -5
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/jsonRpc/index.d.mts +1 -1
- package/dist/esm/jsonRpc/index.mjs +1 -1
- package/dist/esm/keypairs/ed25519/index.d.mts +1 -1
- package/dist/esm/keypairs/falcon512/index.d.mts +1 -1
- package/dist/esm/keypairs/falcon512/index.mjs +1 -1
- package/dist/esm/keypairs/passkey/index.d.mts +1 -1
- package/dist/esm/keypairs/passkey/index.mjs +1 -1
- package/dist/esm/keypairs/secp256k1/index.d.mts +1 -1
- package/dist/esm/keypairs/secp256k1/index.mjs +1 -1
- package/dist/esm/keypairs/secp256r1/index.d.mts +1 -1
- package/dist/esm/keypairs/secp256r1/index.mjs +1 -1
- package/dist/esm/messenger-api-DsV5ffz-.mjs +1 -0
- package/dist/esm/{messenger-Bokr4-T2.mjs → messenger-b7VI27mY.mjs} +1 -1
- package/dist/esm/multisig/index.d.mts +1 -1
- package/dist/esm/multisig/index.mjs +1 -1
- package/dist/esm/{network-DOe6BgcD.mjs → network-CeDd07Hg.mjs} +1 -1
- package/dist/esm/{networks-DhrBVvu6.d.mts → networks-CEYOA-1U.d.mts} +95 -16
- package/dist/esm/object-ZwHVe_Xm.mjs +1 -0
- package/dist/esm/passkey-D0XCtEYg.mjs +1 -0
- package/dist/esm/proof-DU8afdtW.mjs +1 -0
- package/dist/esm/publickey-BPT9QiGv.mjs +1 -1
- package/dist/esm/{publickey-S1fGFYJX.mjs → publickey-Bkjn-YAu.mjs} +1 -1
- package/dist/esm/publickey-qLbcTInT.mjs +1 -1
- package/dist/esm/publickey-zB4h0HOi.mjs +1 -1
- package/dist/esm/received-g0FdzsRW.mjs +1 -0
- package/dist/esm/{rlp-BcIAoIV4.d.mts → rlp-Do3rPWRV.d.mts} +9 -1
- package/dist/esm/rolldown-runtime-D7D4PA-g.mjs +1 -0
- package/dist/esm/secp256k1-B-8mI0dI.mjs +1 -0
- package/dist/esm/secp256r1-B3O6jSlP.mjs +1 -0
- package/dist/esm/service-BP_-4e1d.mjs +1 -0
- package/dist/esm/storage-0TLziZMp.d.mts +62 -0
- package/dist/esm/transactions/index.d.mts +1 -1
- package/dist/esm/transactions/index.mjs +1 -1
- package/dist/esm/{transactions-CDWnTSTU.mjs → transactions-rYyItYOR.mjs} +1 -1
- package/dist/esm/util-BUonvpyz.mjs +1 -0
- package/dist/esm/utils/index.mjs +1 -1
- package/dist/esm/utils-IlS3fpdQ.mjs +1 -1
- package/dist/esm/verify/index.d.mts +1 -1
- package/dist/esm/verify/index.mjs +1 -1
- package/dist/esm/w/call/allocation.d.mts +1 -1
- package/dist/esm/w/call/allocation.mjs +1 -1
- package/dist/esm/w/call/arbitration.d.mts +1 -1
- package/dist/esm/w/call/arbitration.mjs +1 -1
- package/dist/esm/w/call/base.d.mts +1 -1
- package/dist/esm/w/call/base.mjs +1 -1
- package/dist/esm/w/call/demand.d.mts +1 -1
- package/dist/esm/w/call/demand.mjs +1 -1
- package/dist/esm/w/call/guard.d.mts +1 -1
- package/dist/esm/w/call/guard.mjs +1 -1
- package/dist/esm/w/call/index.d.mts +2 -2
- package/dist/esm/w/call/index.mjs +1 -1
- package/dist/esm/w/call/machine.d.mts +1 -1
- package/dist/esm/w/call/machine.mjs +1 -1
- package/dist/esm/w/call/passport.d.mts +1 -1
- package/dist/esm/w/call/passport.mjs +1 -1
- package/dist/esm/w/call/payment.d.mts +1 -1
- package/dist/esm/w/call/payment.mjs +1 -1
- package/dist/esm/w/call/permission.d.mts +1 -1
- package/dist/esm/w/call/permission.mjs +1 -1
- package/dist/esm/w/call/progress.d.mts +1 -1
- package/dist/esm/w/call/progress.mjs +1 -1
- package/dist/esm/w/call/repository.d.mts +1 -1
- package/dist/esm/w/call/repository.mjs +1 -1
- package/dist/esm/w/call/reward.d.mts +1 -1
- package/dist/esm/w/call/reward.mjs +1 -1
- package/dist/esm/w/call/service.d.mts +1 -1
- package/dist/esm/w/call/service.mjs +1 -1
- package/dist/esm/w/call/treasury.d.mts +1 -1
- package/dist/esm/w/call/treasury.mjs +1 -1
- package/dist/esm/w/common.d.mts +1 -1
- package/dist/esm/w/common.mjs +1 -1
- package/dist/esm/w/index.d.mts +5 -5
- package/dist/esm/w/index.mjs +1 -1
- package/dist/esm/w/local/account.d.mts +1 -1
- package/dist/esm/w/local/account.mjs +1 -1
- package/dist/esm/w/local/config.mjs +1 -1
- package/dist/esm/w/local/evm/networks.d.mts +1 -1
- package/dist/esm/w/local/evm/networks.mjs +1 -1
- package/dist/esm/w/local/evm/rlp.d.mts +2 -2
- package/dist/esm/w/local/evm/rlp.mjs +1 -1
- package/dist/esm/w/local/evm-account.d.mts +3 -3
- package/dist/esm/w/local/evm-account.mjs +1 -1
- package/dist/esm/w/local/index.d.mts +5 -5
- package/dist/esm/w/local/index.mjs +1 -1
- package/dist/esm/w/local/local.mjs +1 -1
- package/dist/esm/w/local/storage.d.mts +1 -52
- package/dist/esm/w/local/storage.mjs +1 -1
- package/dist/esm/w/local/token.d.mts +1 -1
- package/dist/esm/w/local/token.mjs +1 -1
- package/dist/esm/w/local/util.mjs +1 -1
- package/dist/esm/w/local/wip.mjs +1 -1
- package/dist/esm/w/messenger/index.d.mts +1 -1
- package/dist/esm/w/messenger/index.mjs +1 -1
- package/dist/esm/w/messenger/messenger-api.d.mts +1 -1
- package/dist/esm/w/messenger/messenger-api.mjs +1 -1
- package/dist/esm/w/messenger/messenger.d.mts +1 -1
- package/dist/esm/w/messenger/messenger.mjs +1 -1
- package/dist/esm/w/messenger/pq/crypto.mjs +1 -1
- package/dist/esm/w/messenger/pq/erasure.mjs +1 -1
- package/dist/esm/w/messenger/storage.d.mts +1 -1
- package/dist/esm/w/messenger/storage.mjs +1 -1
- package/dist/esm/w/messenger/types.d.mts +1 -1
- package/dist/esm/w/messenger/types.mjs +1 -1
- package/dist/esm/w/query/index.d.mts +1 -1
- package/dist/esm/w/query/index.mjs +1 -1
- package/dist/esm/w/query/object.d.mts +1 -1
- package/dist/esm/w/query/object.mjs +1 -1
- package/dist/esm/w-DCO00HIj.mjs +1 -0
- package/package.json +1 -4
- package/dist/esm/Transaction-YosVjNZA.mjs +0 -1
- package/dist/esm/arb-NYOQp2oH.mjs +0 -1
- package/dist/esm/base-fdHKX-jS.mjs +0 -1
- package/dist/esm/bridge-AHnWGzN1.mjs +0 -1
- package/dist/esm/call-7FZbEsRl.mjs +0 -1
- package/dist/esm/common-fDv-Cuzq.mjs +0 -1
- package/dist/esm/evm-account-XzrSThfS.d.mts +0 -185
- package/dist/esm/local-c-Tbdkfa.mjs +0 -1
- package/dist/esm/messenger-api-1m7Lp85p.mjs +0 -1
- package/dist/esm/object-DzsQI-0e.mjs +0 -1
- package/dist/esm/passkey-Dh6btBAD.mjs +0 -1
- package/dist/esm/proof-DER5SXw4.mjs +0 -1
- package/dist/esm/received-D7jEPxlE.mjs +0 -1
- package/dist/esm/rolldown-runtime-DkIiUugF.mjs +0 -1
- package/dist/esm/secp256k1-BZUdTK1D.mjs +0 -1
- package/dist/esm/secp256r1-COXOSFIF.mjs +0 -1
- package/dist/esm/service-W7-dgV57.mjs +0 -1
- package/dist/esm/util-B3X9acB0.mjs +0 -1
- package/dist/esm/w/call/bridge.d.mts +0 -2
- package/dist/esm/w/call/bridge.mjs +0 -1
- package/dist/esm/w-5GiAI3sP.mjs +0 -1
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
import Database from "libsql";
|
|
2
|
-
|
|
3
|
-
//#region src/w/local/evm-account.d.ts
|
|
4
|
-
/** @deprecated 使用 EvmNetworkRegistry 代替。保留导出仅为向后兼容。 */
|
|
5
|
-
declare const ETH_MAINNET_CHAIN_ID = 1;
|
|
6
|
-
/** @deprecated 使用 EvmNetworkRegistry 代替。保留导出仅为向后兼容。 */
|
|
7
|
-
declare const DEFAULT_ETH_RPC_URL = "https://eth.llamarpc.com";
|
|
8
|
-
/** @deprecated 使用 EvmNetworkRegistry 代替。保留导出仅为向后兼容。 */
|
|
9
|
-
declare const DEFAULT_CHAIN_ID = 1;
|
|
10
|
-
interface EvmAccountData {
|
|
11
|
-
name?: string;
|
|
12
|
-
address: string;
|
|
13
|
-
pubkey?: string;
|
|
14
|
-
secret?: string;
|
|
15
|
-
suspended?: boolean;
|
|
16
|
-
createdAt?: number;
|
|
17
|
-
updatedAt?: number;
|
|
18
|
-
chainId?: number;
|
|
19
|
-
}
|
|
20
|
-
interface EvmAccountFilter {
|
|
21
|
-
name?: string;
|
|
22
|
-
address?: string;
|
|
23
|
-
suspended?: boolean;
|
|
24
|
-
createdAt?: {
|
|
25
|
-
gte?: number;
|
|
26
|
-
lte?: number;
|
|
27
|
-
};
|
|
28
|
-
updatedAt?: {
|
|
29
|
-
gte?: number;
|
|
30
|
-
lte?: number;
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/** EVM 交易请求(未签名) */
|
|
34
|
-
interface EvmTransactionRequest {
|
|
35
|
-
to: string;
|
|
36
|
-
data?: string;
|
|
37
|
-
value?: bigint;
|
|
38
|
-
/**
|
|
39
|
-
* 网络选择(优先级最高):
|
|
40
|
-
* - 数字 → 按 chainId 查 Registry
|
|
41
|
-
* - 字符串 → 按网络名查 Registry(如 "mainnet" / "arbitrum")
|
|
42
|
-
* - 不传 → 使用 Registry 默认网络
|
|
43
|
-
*/
|
|
44
|
-
network?: number | string;
|
|
45
|
-
/** 显式覆盖 chainId(通常由 network 自动填充,无需手动传) */
|
|
46
|
-
chainId?: number;
|
|
47
|
-
/** 显式覆盖 RPC URL(通常由 network 自动填充;传入则跳过 Registry) */
|
|
48
|
-
rpcUrl?: string;
|
|
49
|
-
/** gas 相关参数;不传则自动估算 */
|
|
50
|
-
gasLimit?: bigint;
|
|
51
|
-
maxFeePerGas?: bigint;
|
|
52
|
-
maxPriorityFeePerGas?: bigint;
|
|
53
|
-
gasPrice?: bigint;
|
|
54
|
-
/** nonce;不传则自动从链上查询 */
|
|
55
|
-
nonce?: number;
|
|
56
|
-
}
|
|
57
|
-
/** EVM 交易回执 */
|
|
58
|
-
interface EvmTransactionReceipt {
|
|
59
|
-
transactionHash: string;
|
|
60
|
-
blockNumber: bigint;
|
|
61
|
-
blockHash: string;
|
|
62
|
-
status: "0x1" | "0x0";
|
|
63
|
-
gasUsed: bigint;
|
|
64
|
-
effectiveGasPrice: bigint;
|
|
65
|
-
from: string;
|
|
66
|
-
to: string;
|
|
67
|
-
contractAddress?: string;
|
|
68
|
-
logs: EvmLog[];
|
|
69
|
-
}
|
|
70
|
-
interface EvmLog {
|
|
71
|
-
address: string;
|
|
72
|
-
topics: string[];
|
|
73
|
-
data: string;
|
|
74
|
-
blockNumber: bigint;
|
|
75
|
-
transactionHash: string;
|
|
76
|
-
transactionIndex: number;
|
|
77
|
-
logIndex: number;
|
|
78
|
-
removed: boolean;
|
|
79
|
-
}
|
|
80
|
-
/** EVM 账户存储接口(与 WOW IAccountStorage 形态一致但独立实例) */
|
|
81
|
-
interface IEvmAccountStorage {
|
|
82
|
-
get(): Promise<string | undefined>;
|
|
83
|
-
put(data: string): Promise<void>;
|
|
84
|
-
clear(): Promise<void>;
|
|
85
|
-
}
|
|
86
|
-
/** SQLite EVM 账户存储:使用独立表 evm_accounts,与 WOW accounts 隔离 */
|
|
87
|
-
declare class SQLiteEvmAccountStorage implements IEvmAccountStorage {
|
|
88
|
-
private _db;
|
|
89
|
-
constructor(db?: Database.Database);
|
|
90
|
-
private get db();
|
|
91
|
-
get(): Promise<string | undefined>;
|
|
92
|
-
put(data: string): Promise<void>;
|
|
93
|
-
clear(): Promise<void>;
|
|
94
|
-
}
|
|
95
|
-
declare const DEFAULT_EVM_ACCOUNT_NAME = "";
|
|
96
|
-
declare class EvmAccount {
|
|
97
|
-
static _instance: EvmAccount | undefined;
|
|
98
|
-
static storage: IEvmAccountStorage | undefined;
|
|
99
|
-
private static _lock;
|
|
100
|
-
setStorage(storage: IEvmAccountStorage): void;
|
|
101
|
-
private getStorage;
|
|
102
|
-
static Instance(): EvmAccount;
|
|
103
|
-
/** 读出后立即清空 secret,仅返回地址与元数据(与 Account 一致) */
|
|
104
|
-
private accountData;
|
|
105
|
-
private static nameMatch;
|
|
106
|
-
private name_resolve;
|
|
107
|
-
/**
|
|
108
|
-
* 解析网络配置(统一入口)
|
|
109
|
-
*
|
|
110
|
-
* 优先级:
|
|
111
|
-
* 1. 显式 rpcUrl(向后兼容,最高优先级,直接构造临时配置)
|
|
112
|
-
* 2. network(chainId | name)→ Registry 查找
|
|
113
|
-
* 3. Registry 默认网络
|
|
114
|
-
*
|
|
115
|
-
* @returns 选定的网络配置 + 实际使用的 RPC URL(已应用故障转移)
|
|
116
|
-
*/
|
|
117
|
-
private resolveNetwork;
|
|
118
|
-
/**
|
|
119
|
-
* RPC 调用(带故障转移)
|
|
120
|
-
* 主 RPC 失败时自动切换到备用 RPC,并标记原 RPC 不可用。
|
|
121
|
-
*/
|
|
122
|
-
private rpcWithFailover;
|
|
123
|
-
/**
|
|
124
|
-
* 生成新的 EVM 账户(secp256k1)
|
|
125
|
-
* @param name 账户名(可空,空则使用默认账户)
|
|
126
|
-
* @param replaceExistName 若同名存在是否替换(false 则抛错)
|
|
127
|
-
* @param chainId 默认 chainId(仅记录,签名时可覆盖)
|
|
128
|
-
*/
|
|
129
|
-
gen(name?: string | null, replaceExistName?: boolean, chainId?: number): Promise<EvmAccountData>;
|
|
130
|
-
default(): Promise<EvmAccountData | undefined>;
|
|
131
|
-
get(address_or_name: string | null | undefined, notFoundGenerate?: boolean): Promise<EvmAccountData | undefined>;
|
|
132
|
-
get_address(address_or_name: string | null | undefined): Promise<string | undefined>;
|
|
133
|
-
private get_imp;
|
|
134
|
-
list(filter?: EvmAccountFilter): Promise<EvmAccountData[]>;
|
|
135
|
-
rename(name_or_address: string | null | undefined, new_name: string): Promise<boolean>;
|
|
136
|
-
suspend(address_or_name?: string): Promise<boolean>;
|
|
137
|
-
resume(address: string, name: string | null | undefined): Promise<boolean>;
|
|
138
|
-
/** 查询 ETH 原生余额(wei) */
|
|
139
|
-
balance(address_or_name?: string, network?: number | string, rpcUrl?: string): Promise<bigint | undefined>;
|
|
140
|
-
/** 查询 ERC20 token 余额(需 ABI 调用 balanceOf) */
|
|
141
|
-
balanceOf(tokenAddress: string, address_or_name?: string, network?: number | string, rpcUrl?: string): Promise<bigint | undefined>;
|
|
142
|
-
/** 查询交易 nonce */
|
|
143
|
-
getNonce(address_or_name?: string, network?: number | string, rpcUrl?: string): Promise<number | undefined>;
|
|
144
|
-
/** 查询当前 chainId */
|
|
145
|
-
getChainId(network?: number | string, rpcUrl?: string): Promise<number>;
|
|
146
|
-
/** 查询当前区块号 */
|
|
147
|
-
getBlockNumber(network?: number | string, rpcUrl?: string): Promise<bigint>;
|
|
148
|
-
/** 估算 gas limit */
|
|
149
|
-
estimateGas(tx: EvmTransactionRequest, address_or_name?: string, network?: number | string, rpcUrl?: string): Promise<bigint>;
|
|
150
|
-
/** 查询 EIP-1559 费用参数(baseFee + maxPriorityFee) */
|
|
151
|
-
getFeeData(network?: number | string, rpcUrl?: string): Promise<{
|
|
152
|
-
maxFeePerGas: bigint;
|
|
153
|
-
maxPriorityFeePerGas: bigint;
|
|
154
|
-
gasPrice?: bigint;
|
|
155
|
-
}>;
|
|
156
|
-
/**
|
|
157
|
-
* 签名并广播 EVM 交易(一体化入口,对称于 Account.sign_and_commit)
|
|
158
|
-
*
|
|
159
|
-
* 网络选择优先级:
|
|
160
|
-
* 1. tx.network(chainId 或 name)
|
|
161
|
-
* 2. tx.rpcUrl(显式 RPC URL)
|
|
162
|
-
* 3. address_or_name 参数(已废弃,仅向后兼容)
|
|
163
|
-
* 4. EvmNetworkRegistry 默认网络
|
|
164
|
-
*
|
|
165
|
-
* @param tx 交易请求
|
|
166
|
-
* @param address_or_name 签名账户(默认使用 default 账户)
|
|
167
|
-
* @param rpcUrl RPC 节点 URL(向后兼容;推荐用 tx.network 替代)
|
|
168
|
-
* @returns 交易回执(已确认)
|
|
169
|
-
*/
|
|
170
|
-
sign_and_send(tx: EvmTransactionRequest, address_or_name?: string, rpcUrl?: string): Promise<EvmTransactionReceipt>;
|
|
171
|
-
/** 等待交易确认 */
|
|
172
|
-
waitForReceipt(txHash: string, network?: number | string, rpcUrl?: string, maxWaitMs?: number): Promise<EvmTransactionReceipt>;
|
|
173
|
-
private parseReceipt;
|
|
174
|
-
/**
|
|
175
|
-
* 对任意数据签名(非交易)
|
|
176
|
-
* 实现 EIP-191 个人签名:\x19Ethereum Signed Message:\n<len><data>
|
|
177
|
-
*/
|
|
178
|
-
signData(address_or_name: string | null | undefined, data: string | Uint8Array): Promise<{
|
|
179
|
-
signature: string;
|
|
180
|
-
publicKey: string;
|
|
181
|
-
address: string;
|
|
182
|
-
}>;
|
|
183
|
-
}
|
|
184
|
-
//#endregion
|
|
185
|
-
export { EvmAccount as a, EvmLog as c, IEvmAccountStorage as d, SQLiteEvmAccountStorage as f, ETH_MAINNET_CHAIN_ID as i, EvmTransactionReceipt as l, DEFAULT_ETH_RPC_URL as n, EvmAccountData as o, DEFAULT_EVM_ACCOUNT_NAME as r, EvmAccountFilter as s, DEFAULT_CHAIN_ID as t, EvmTransactionRequest as u };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as a30a}from'./sui-types-CuBKFvrd.mjs';import{Cache}from'./w/local/cache.mjs';import{Config}from'./w/local/config.mjs';let WErrors=function(a){return a['AccountNotFound']='account\x20not\x20found',a['AddressNotFound']='address\x20not\x20found',a['IsValidDescription']='invalid\x20description',a['IsValidName']='invalid\x20name',a['IsValidName_AllowEmpty']='invalid\x20name',a['IsValidEndpoint']='invalid\x20endpoint',a['IsValidAddress']='invalid\x20address',a['IsValidArgType']='invalid\x20argument\x20type',a['IsValidTokenType']='invalid\x20token\x20type',a['IsValidUint']='invalid\x20uint',a['IsValidInt']='invalid\x20int',a['IsValidU8']='invalid\x20u8',a['IsValidU16']='invalid\x20u16',a['IsValidU32']='invalid\x20u32',a['IsValidU64']='invalid\x20u64',a['IsValidU128']='invalid\x20u128',a['IsValidU256']='invalid\x20u256',a['IsValidRate']='invalid\x20rate[0-10000]',a['IsValidArray']='invalid\x20array',a['IsValidObjects']='invalid\x20objects',a['AllInvalid']='one\x20valid\x20at\x20least',a['InvalidParam']='invalid\x20parameter',a['IsValidPermissionIndex']='invalid\x20permission\x20index',a['IsValidKey']='invalid\x20key',a['Fail']='fail',a['IsValidIdentifier']='identifier\x20invalid',a['IsValidHttpUrl']='invalid\x20url',a['IsValidBizPermissionIndex']='invalid\x20biz-permission\x20id[1000\x20-\x2065535]',a['BcsTypeInvalid']='invalid\x20bcs\x20type',a['IsValidServiceItemName']='invalid\x20service\x20item\x20name',a['IsValidCoinType']='not\x20the\x20coin\x20type',a['IsValidGuardIdentifier']='guard\x20identifier\x20invalid',a['NoPermission']='no\x20permission',a['IsValidValue']='invalid\x20value',a['IsValidValueType']='invalid\x20value\x20type',a['IsValidLocation']='invalid\x20location',a['NetworkInvalid']='protocol\x20network\x20not\x20specified',a['WitnessTypeInvalid']='witness\x20type\x20invalid',a['AddressCountExceeded']='address\x20count\x20exceeded',a['NumberCountExceeded']='number\x20count\x20exceeded',a['NewGuardCheckFailed']='new\x20guard\x20check\x20failed',a['GuardTableItemLengthExceeded']='guard\x20table\x20item\x20length\x20exceeded',a['AccountPersistentStorageNotSet']='account\x20persistent\x20storage\x20not\x20set',a['AccountPersistentStorageNotFound']='account\x20persistent\x20storage\x20not\x20found',a['AccountNameExist']='account\x20name\x20exist',a['ConfigPersistentStorageNotSet']='config\x20persistent\x20storage\x20not\x20set',a['TokenNotFoundLocally']='token\x20not\x20found',a['LocalMarkNameExist']='local\x20mark\x20name\x20exist',a['MaxObjectsPerQuery']='max\x20objects\x20per\x20query',a['ResourceTagCountExceeded']='resource\x20tag\x20count\x20exceeded',a['ParseObjectContentFailed']='parse\x20object\x20content\x20failed',a;}({});var WException=class WException extends Error{constructor(a,b){const c=a['toString']()+(b?':'+b:'');super(c),this['code']=a,this['details']=b,Object['setPrototypeOf'](this,WException['prototype']);}['getErrorMessage'](){return this['message'];}['getErrorCode'](){return this['code'];}['getDetails'](){return this['details'];}};const W_ERROR=(a,b)=>{throw new WException(a,b);},W_SUCCESS=a=>({'success':!![],'data':a}),W_FAILURE=(a,b)=>({'success':![],'error':new WException(a,b)});function WValidate(a){return function(...b){try{return a['apply'](this,b);}catch(c){if(c instanceof WException)throw c;throw new WException('fail',c);}};}const W_SAFE=(a,b,c)=>{try{return W_SUCCESS(a());}catch(d){if(d instanceof WException)return W_FAILURE(d['code'],d['details']);return W_FAILURE(b||'fail',c||d);}},W_ENSURE=(a,b,c)=>{if(!a)W_ERROR(b,c);},W_VALIDATE_PARAM=(a,b,c,d)=>{if(!b(a))W_ERROR(c,d);},MoveErrors=[{'module':'service','code':0x1,'description':'Maximum\x20sale\x20count\x20exceeded'},{'module':'service','code':0x2,'description':'Maximum\x20repository\x20count\x20exceeded'},{'module':'service','code':0x3,'description':'Maximum\x20arbitration\x20count\x20exceeded'},{'module':'service','code':0x4,'description':'Maximum\x20WIP\x20length\x20exceeded'},{'module':'service','code':0x5,'description':'Maximum\x20WIP\x20hash\x20length\x20exceeded'},{'module':'service','code':0x6,'description':'Service\x20already\x20published'},{'module':'service','code':0x7,'description':'Service\x20not\x20published'},{'module':'service','code':0x8,'description':'Invalid\x20off-on\x20discount\x20rates'},{'module':'service','code':0x9,'description':'Maximum\x20discount\x20count\x20per\x20operation\x20exceeded'},{'module':'service','code':0xa,'description':'Discount\x20not\x20transferable'},{'module':'service','code':0xb,'description':'Discount\x20receiver\x20empty'},{'module':'service','code':0xc,'description':'Discount\x20count\x20empty'},{'module':'service','code':0xd,'description':'Maximum\x20discount\x20receiver\x20per\x20operation\x20exceeded'},{'module':'service','code':0xe,'description':'Maximum\x20total\x20discount\x20count\x20exceeded'},{'module':'service','code':0xf,'description':'Service\x20discount\x20does\x20not\x20match'},{'module':'service','code':0x10,'description':'Stock\x20not\x20enough'},{'module':'service','code':0x11,'description':'Invalid\x20quote'},{'module':'service','code':0x12,'description':'Buyer\x20guard\x20passport\x20required'},{'module':'service','code':0x13,'description':'Service\x20is\x20paused'},{'module':'service','code':0x14,'description':'Coin\x20not\x20enough'},{'module':'service','code':0x15,'description':'Maximum\x20required\x20info\x20size\x20exceeded'},{'module':'service','code':0x16,'description':'Machine\x20does\x20not\x20match'},{'module':'service','code':0x17,'description':'No\x20allocator\x20configured'},{'module':'service','code':0x18,'description':'Critical\x20setting\x20lock\x20duration\x20not\x20exceeded.\x20After\x20Service\x20is\x20published,\x20modifications\x20to\x20\x27order_allocators\x27,\x20\x27rewards\x27,\x20\x27arbitrations\x27,\x20\x27machine\x27,\x20and\x20withdrawal\x20from\x20\x27compensation_fund\x27\x20must\x20exceed\x20the\x20\x27setting_lock_duration\x27\x20lock\x20time'},{'module':'service','code':0x19,'description':'Arbitration\x20not\x20set\x20with\x20compensation\x20fund'},{'module':'service','code':0x1a,'description':'Order\x20service\x20does\x20not\x20match'},{'module':'service','code':0x1b,'description':'Compensation\x20does\x20not\x20match'},{'module':'service','code':0x1c,'description':'Maximum\x20reward\x20count\x20exceeded'},{'module':'service','code':0x1d,'description':'Invalid\x20discount\x20type'},{'module':'service','code':0x1e,'description':'Invalid\x20timestamp\x20ms\x20end'},{'module':'service','code':0x1f,'description':'WIP\x20hash\x20not\x20match'},{'module':'service','code':0x20,'description':'Sale\x20item\x20not\x20found'},{'module':'permission','code':0x1,'description':'Not\x20the\x20builder'},{'module':'permission','code':0x2,'description':'Not\x20admin'},{'module':'permission','code':0x3,'description':'Address\x20count\x20in\x20permission\x20exceeded\x20limit'},{'module':'permission','code':0x4,'description':'Permission\x20count\x20exceeded\x20limit'},{'module':'permission','code':0x5,'description':'Permission\x20denied'},{'module':'permission','code':0x6,'description':'Admin\x20count\x20exceeded\x20limit'},{'module':'permission','code':0x7,'description':'Permission\x20index\x20not\x20found'},{'module':'permission','code':0x8,'description':'Permission\x20does\x20not\x20match'},{'module':'permission','code':0x9,'description':'Not\x20user\x20address'},{'module':'passport','code':0x1,'description':'Guard\x20count\x20exceeded\x20limit'},{'module':'passport','code':0x2,'description':'Relies\x20guard\x20not\x20added'},{'module':'passport','code':0x3,'description':'Submission\x20size\x20exceeded\x20limit'},{'module':'passport','code':0x4,'description':'Already\x20verified'},{'module':'passport','code':0x5,'description':'Not\x20verified'},{'module':'passport','code':0x6,'description':'Not\x20impact\x20guard'},{'module':'passport','code':0x7,'description':'Verification\x20failed'},{'module':'passport','code':0x8,'description':'Transaction\x20does\x20not\x20match'},{'module':'passport','code':0x9,'description':'Impact\x20guard\x20not\x20found'},{'module':'passport','code':0xa,'description':'Submission\x20not\x20found'},{'module':'passport','code':0xb,'description':'Digest\x20not\x20match'},{'module':'reward','code':0x1,'description':'Guard\x20locked\x20time\x20not\x20increasing'},{'module':'reward','code':0x2,'description':'Guard\x20expired'},{'module':'reward','code':0x3,'description':'Guard\x20count\x20exceeded\x20limit'},{'module':'reward','code':0x4,'description':'Recipient\x20identifier\x20not\x20address\x20type'},{'module':'reward','code':0x5,'description':'Amount\x20not\x20u64\x20type'},{'module':'reward','code':0x6,'description':'Insufficient\x20balance'},{'module':'reward','code':0x7,'description':'Guard\x20not\x20found'},{'module':'reward','code':0x8,'description':'Record\x20count\x20exceeded\x20limit'},{'module':'reward','code':0xa,'description':'Invalid\x20guard\x20locked\x20time'},{'module':'reward','code':0xb,'description':'Guard\x20locked\x20time\x20invalid'},{'module':'reward','code':0xc,'description':'Store\x20from\x20ID\x20not\x20compatible'},{'module':'arbitration','code':0x1,'description':'Guard\x20identifier\x20not\x20number\x20type'},{'module':'arbitration','code':0x2,'description':'Voting\x20guard\x20already\x20used'},{'module':'arbitration','code':0x3,'description':'Arbitration\x20does\x20not\x20match'},{'module':'arbitration','code':0x4,'description':'Arbitration\x20is\x20paused'},{'module':'arbitration','code':0x5,'description':'Fee\x20not\x20enough'},{'module':'arbitration','code':0x6,'description':'Passport\x20required'},{'module':'arbitration','code':0x7,'description':'Guard\x20identifier\x20number\x20invalid'},{'module':'arbitration','code':0x8,'description':'Voting\x20guard\x20not\x20found'},{'module':'arbitration','code':0x9,'description':'Maximum\x20voting\x20guard\x20count\x20exceeded'},{'module':'demand','code':0x1,'description':'Maximum\x20reward\x20count\x20exceeded'},{'module':'demand','code':0x2,'description':'Maximum\x20guard\x20count\x20exceeded'},{'module':'demand','code':0x3,'description':'Passport\x20required'},{'module':'demand','code':0x4,'description':'Guard\x20not\x20found'},{'module':'progress','code':0x1,'description':'Maximum\x20context\x20repository\x20count\x20exceeded'},{'module':'progress','code':0x2,'description':'Maximum\x20named\x20operator\x20count\x20exceeded'},{'module':'progress','code':0x3,'description':'Maximum\x20named\x20operator\x20address\x20count\x20exceeded'},{'module':'progress','code':0x4,'description':'Machine\x20does\x20not\x20match'},{'module':'progress','code':0x5,'description':'Task\x20already\x20set'},{'module':'progress','code':0x6,'description':'Not\x20the\x20holder'},{'module':'progress','code':0x7,'description':'Forward\x20already\x20accomplished'},{'module':'progress','code':0x8,'description':'Permission\x20not\x20defined\x20when\x20hold'},{'module':'progress','code':0x9,'description':'Passport\x20required'},{'module':'progress','code':0xa,'description':'Order\x20does\x20not\x20match'},{'module':'guard','code':0x1,'description':'Input\x20empty'},{'module':'guard','code':0x2,'description':'Input\x20size\x20exceeded\x20limit'},{'module':'guard','code':0x3,'description':'Table\x20size\x20exceeded\x20limit'},{'module':'guard','code':0x5,'description':'Dependent\x20count\x20exceeded\x20limit'},{'module':'guard','code':0x6,'description':'Not\x20dependent\x20guard'},{'module':'guard','code':0x7,'description':'Guard\x20cannot\x20depend\x20on\x20itself'},{'module':'guard','code':0x8,'description':'Guard\x20IDs\x20parse\x20error'},{'module':'guard','code':0x9,'description':'Guard\x20IDs\x20type\x20error'},{'module':'guard','code':0xa,'description':'ID\x20value\x20count\x20not\x20equal\x20to\x20guard\x20count'},{'module':'guard','code':0xb,'description':'Submission\x20ID\x20not\x20found'},{'module':'guard','code':0xc,'description':'Submission\x20value\x20type\x20error'},{'module':'order','code':0x1,'description':'Not\x20the\x20owner'},{'module':'order','code':0x2,'description':'Maximum\x20agent\x20count\x20exceeded'},{'module':'order','code':0x3,'description':'Progress\x20not\x20specified'},{'module':'order','code':0x5,'description':'No\x20operation\x20permission'},{'module':'order','code':0x6,'description':'Maximum\x20dispute\x20count\x20exceeded'},{'module':'order','code':0x7,'description':'Order\x20already\x20claimed'},{'module':'order','code':0x8,'description':'Invalid\x20customer\x20info'},{'module':'order','code':0x9,'description':'Allocation\x20not\x20specified'},{'module':'order','code':0xa,'description':'Allocation\x20already\x20specified'},{'module':'order','code':0xb,'description':'Progress\x20already\x20specified'},{'module':'machine','code':0x1,'description':'Maximum\x20consensus\x20repositories\x20exceeded'},{'module':'machine','code':0x2,'description':'Machine\x20not\x20published'},{'module':'machine','code':0x3,'description':'Machine\x20already\x20published'},{'module':'machine','code':0x4,'description':'Maximum\x20forward\x20order\x20count\x20exceeded'},{'module':'machine','code':0x5,'description':'Maximum\x20node\x20count\x20exceeded'},{'module':'machine','code':0x6,'description':'Duplicate\x20forward\x20name'},{'module':'machine','code':0x7,'description':'Duplicate\x20node\x20previous'},{'module':'machine','code':0x8,'description':'Old\x20node\x20name\x20does\x20not\x20exist'},{'module':'machine','code':0x9,'description':'New\x20node\x20name\x20already\x20exists'},{'module':'machine','code':0xa,'description':'Node\x20not\x20found'},{'module':'machine','code':0xb,'description':'Machine\x20is\x20paused'},{'module':'machine','code':0xc,'description':'Retained\x20submission\x20error'},{'module':'machine','code':0xd,'description':'Info\x20not\x20found'},{'module':'machine','code':0xe,'description':'Permission\x20not\x20defined'},{'module':'machine','code':0xf,'description':'Maximum\x20node\x20pair\x20count\x20exceeded'},{'module':'machine','code':0x10,'description':'Maximum\x20forward\x20count\x20exceeded'},{'module':'treasury','code':0x1,'description':'Maximum\x20external\x20deposit\x20guard\x20count\x20exceeded'},{'module':'treasury','code':0x2,'description':'Maximum\x20external\x20withdraw\x20guard\x20count\x20exceeded'},{'module':'treasury','code':0x3,'description':'External\x20deposit\x20guard\x20not\x20found'},{'module':'treasury','code':0x4,'description':'External\x20withdraw\x20guard\x20not\x20found'},{'module':'treasury','code':0x5,'description':'Identifier\x20not\x20number\x20type'},{'module':'treasury','code':0x6,'description':'Deposit\x20insufficient\x20amount'},{'module':'treasury','code':0x7,'description':'Withdraw\x20insufficient\x20amount'},{'module':'treasury','code':0x8,'description':'Store\x20from\x20ID\x20not\x20compatible'},{'module':'arb','code':0x1,'description':'Maximum\x20proposition\x20count\x20exceeded'},{'module':'arb','code':0x2,'description':'Arbitration\x20order\x20does\x20not\x20match'},{'module':'arb','code':0x3,'description':'Status\x20does\x20not\x20match'},{'module':'arb','code':0x4,'description':'Voting\x20deadline\x20not\x20passed'},{'module':'arb','code':0x5,'description':'Proposition\x20not\x20found'},{'module':'arb','code':0x6,'description':'Maximum\x20voter\x20count\x20exceeded'},{'module':'arb','code':0x7,'description':'Voting\x20deadline\x20passed'},{'module':'arb','code':0x8,'description':'Withdraw\x20duration\x20time\x20not\x20passed'},{'module':'repository','code':0x1,'description':'Policy\x20description\x20length\x20exceeded'},{'module':'repository','code':0x2,'description':'Policy\x20guard\x20count\x20exceeded'},{'module':'repository','code':0x3,'description':'Policy\x20count\x20exceeded'},{'module':'repository','code':0x4,'description':'Data\x20size\x20exceeded\x20limit'},{'module':'repository','code':0x5,'description':'ID\x20count\x20exceeded\x20limit'},{'module':'repository','code':0x6,'description':'Quantities\x20not\x20equal'},{'module':'repository','code':0x7,'description':'Policy\x20not\x20found'},{'module':'repository','code':0x8,'description':'Policy\x20ID\x20from\x20none'},{'module':'repository','code':0x9,'description':'Passport\x20required'},{'module':'repository','code':0xa,'description':'Data\x20type\x20does\x20not\x20match'},{'module':'repository','code':0xb,'description':'Guard\x20specified\x20ID\x20from\x20submission'},{'module':'repository','code':0xc,'description':'Not\x20impact\x20guard\x20in\x20passport'},{'module':'repository','code':0xd,'description':'Guard\x20specified\x20not\x20in\x20policy'},{'module':'repository','code':0xe,'description':'ID\x20vector\x20not\x20enough'},{'module':'repository','code':0xf,'description':'Data\x20vector\x20not\x20enough'},{'module':'repository','code':0x10,'description':'Invalid\x20ID\x20in\x20guard\x20table'},{'module':'repository','code':0x11,'description':'Invalid\x20data\x20in\x20guard\x20table'},{'module':'repository','code':0x12,'description':'Invalid\x20ID\x20from'},{'module':'repository','code':0x13,'description':'Maximum\x20reward\x20count\x20exceeded'},{'module':'repository','code':0x14,'description':'Guard\x20not\x20specified\x20ID\x20from\x20submission'},{'module':'repository','code':0x15,'description':'Need\x20dependent\x20guard'},{'module':'common','code':0x1,'description':'Name\x20length\x20exceeded\x20limit'},{'module':'common','code':0x2,'description':'Name\x20is\x20empty'},{'module':'common','code':0x3,'description':'Description\x20length\x20exceeded\x20limit'},{'module':'common','code':0x6,'description':'Invalid\x20value\x20type'},{'module':'common','code':0x7,'description':'Address\x20type\x20does\x20not\x20match'},{'module':'common','code':0x8,'description':'Number\x20type\x20does\x20not\x20match'},{'module':'common','code':0x9,'description':'Invalid\x20data\x20value'},{'module':'common','code':0xa,'description':'Invalid\x20string\x20value'},{'module':'common','code':0xb,'description':'Long\x20name\x20length\x20exceeded\x20limit'},{'module':'common','code':0xc,'description':'Not\x20u64\x20type'},{'module':'common','code':0xd,'description':'Invalid\x20service\x20object\x20type'},{'module':'resource','code':0x1,'description':'Tags\x20count\x20exceeded\x20limit'},{'module':'allocation','code':0x1,'description':'Recipient\x20identifier\x20not\x20address\x20type'},{'module':'allocation','code':0x2,'description':'Allocator\x20count\x20exceeded'},{'module':'allocation','code':0x3,'description':'No\x20allocator'},{'module':'allocation','code':0x4,'description':'Rate\x20not\x2010000'},{'module':'allocation','code':0x5,'description':'Multiple\x20surplus'},{'module':'allocation','code':0x6,'description':'Rate\x20exceeds\x2010000'},{'module':'allocation','code':0x7,'description':'Insufficient\x20balance'},{'module':'allocation','code':0x8,'description':'Allocators\x20empty'},{'module':'allocation','code':0x9,'description':'No\x20payment\x20info'},{'module':'allocation','code':0xa,'description':'Sharing\x20count\x20exceeded'},{'module':'allocation','code':0xb,'description':'Sharing\x20mode\x20invalid'},{'module':'allocation','code':0xc,'description':'Amount\x20below\x20threshold'},{'module':'allocation','code':0xd,'description':'Amount\x20exceeds\x20max'},{'module':'proof','code':0x1,'description':'Maximum\x20proof\x20size\x20exceeded'},{'module':'proof','code':0x2,'description':'Maximum\x20server\x20pubkey\x20size\x20exceeded'},{'module':'proof','code':0x3,'description':'Maximum\x20server\x20signature\x20size\x20exceeded'},{'module':'payment','code':0x1,'description':'Recipient\x20count\x20exceeded'},{'module':'payment','code':0x2,'description':'Vector\x20count\x20not\x20equal'},{'module':'payment','code':0x3,'description':'Payment\x20not\x20match'},{'module':'payment','code':0x4,'description':'Recipient\x20empty'},{'module':'contact','code':0x1,'description':'IM\x20count\x20exceeded'},{'module':'registrar','code':0x0,'description':'Not\x20system\x20address'},{'module':'registrar','code':0x1,'description':'Record\x20count\x20exceeded'},{'module':'registrar','code':0x2,'description':'Record\x20length\x20exceeded'},{'module':'registrar','code':0x3,'description':'Record\x20type\x20empty'},{'module':'transfer','code':0x0,'description':'Shared\x20non-new\x20object'},{'module':'transfer','code':0x1,'description':'BCS\x20serialization\x20failure'},{'module':'transfer','code':0x2,'description':'Receiving\x20object\x20type\x20mismatch'},{'module':'transfer','code':0x3,'description':'Unable\x20to\x20receive\x20object'},{'module':'transfer','code':0x4,'description':'Shared\x20object\x20operation\x20not\x20supported'},{'module':'transfer','code':0x5,'description':'Operation\x20not\x20supported'},{'module':'transfer','code':0x6,'description':'Invalid\x20party\x20permissions'},{'module':'tx_context','code':0x0,'description':'Bad\x20transaction\x20hash\x20length'},{'module':'coin','code':0x0,'description':'Bad\x20witness'},{'module':'coin','code':0x1,'description':'Invalid\x20argument'},{'module':'coin','code':0x2,'description':'Not\x20enough\x20balance'},{'module':'coin','code':0x3,'description':'Global\x20pause\x20not\x20allowed'},{'module':'borrow','code':0x0,'description':'Wrong\x20borrow'},{'module':'borrow','code':0x1,'description':'Wrong\x20value'},{'module':'bcs','code':0x0,'description':'Out\x20of\x20range'},{'module':'bcs','code':0x1,'description':'Not\x20bool'},{'module':'bcs','code':0x2,'description':'Length\x20out\x20of\x20range'},{'module':'balance','code':0x0,'description':'Non-zero\x20balance'},{'module':'balance','code':0x1,'description':'Overflow'},{'module':'balance','code':0x2,'description':'Not\x20enough'},{'module':'balance','code':0x3,'description':'Not\x20system\x20address'},{'module':'balance','code':0x4,'description':'Not\x20WOW'},{'module':'parent_table','code':0x0,'description':'Parent\x20table\x20not\x20match'},{'module':'parent_table_vec','code':0x0,'description':'Index\x20out\x20of\x20bound'},{'module':'parent_linked_table','code':0x0,'description':'Table\x20is\x20empty'},{'module':'parent_linked_table','code':0x1,'description':'Table\x20not\x20match'}];function getMoveErrorDescription(a,b){const c=MoveErrors['find'](d=>d['module']===a&&d['code']===b);return c?c['description']:null;}function enrichMoveError(a){if(!a||typeof a!=='string')return a;const b='0x0000000000000000000000000000000000000000000000000000000000000002',c=/MoveAbort\([^,]+,\s*(\d+)\)/,d=/name:\s*Identifier\("([^"]+)"\)/,e=/address:\s*([0-9a-fA-Fx]+)/,f=a['match'](c),g=a['match'](d),h=a['match'](e);if(f&&g&&h){const o=parseInt(f[0x1],0xa),p=g[0x1]['toLowerCase'](),q=h[0x1]['toLowerCase']();if(q===b||q==='0x2'){const r=MoveErrors['find'](s=>s['module']['toLowerCase']()===p&&s['code']===o);if(r)return'Error\x20Description:\x20'+r['description']+'\x0a'+a;}}const i=/abort code:\s*(\d+)/,j=/'0x[0-9a-fA-F]+::([^:]+)::[^']+'/,k=/'(0x[0-9a-fA-F]+)::/,l=a['match'](i),m=a['match'](j),n=a['match'](k);if(l&&m&&n){const s=parseInt(l[0x1],0xa),t=m[0x1]['toLowerCase'](),u=n[0x1]['toLowerCase']();if(u===b||u==='0x2'){const v=MoveErrors['find'](w=>w['module']['toLowerCase']()===t&&w['code']===s);if(v)return'Error\x20Description:\x20'+v['description']+'\x0a'+a;}}return a;}const BUITIN_IDS=['0x5','0x6','0x7','0x8','0x9','0xc','0xd','0xa','@0xaaa','@0xaab','@0x403','@0xacc','@0xc'],isValidAddress=a=>{return a&&(a30a(a)||BUITIN_IDS['includes'](a));},LocalMarkNameMaxLength=0x40,LocalMarkTagMaxLength=0x40,LocalMarkTagMaxCount=0x32,LocalInfoNameMaxLength=0x40,LocalInfoContentMaxLength=0x12c,LocalInfoContentMaxCount=0x32,LocalInfoNameDefault='Address\x20of\x20delivery';var LocalMark=class LocalMark{constructor(){this['config']=Config['Instance']();}async['getCacheKey'](){return['mark',await this['config']['network_get']()];}static['Instance'](){if(!LocalMark['_instance'])LocalMark['_instance']=new LocalMark();return LocalMark['_instance'];}static['nameMatch'](a,b){if(a==null||b==null)return![];return a['toLowerCase']()===b['toLowerCase']();}['resolve_tags'](a){return a=a?.['slice'](0x0,0x32),a=a?.['filter'](b=>b!==''&&b)?.['map'](b=>{return b['slice'](0x0,0x40);}),a;}['resolve_name'](a){return a['slice'](0x0,0x40);}async['put'](a){const b=await this['getCacheKey'](),c=(await Cache['read'](b,async()=>{return{'expire':'INFINITE','data':[]};}))?.['data']||[],d=[...c],e=[];for(const f of a){f['address']=f['address']['toLowerCase']();if(!isValidAddress(f['address']))W_ERROR('invalid\x20address','LocalMark.put.mark.address:\x20'+f['address']);if(f?.['name']?.['value'])f['name']['value']=this['resolve_name'](f?.['name']?.['value']);f['tags']=this['resolve_tags'](f?.['tags']);if(f?.['name']?.['value']!=null)d['forEach'](i=>{if(LocalMark['nameMatch'](i['name'],f['name']['value'])){if(f?.['name']?.['replaceExistName'])i['name']=void 0x0;else W_ERROR('local\x20mark\x20name\x20exist','LocalMark.put.mark.name:\x20'+f['name']['value']);}});const g=Date['now'](),h={'name':f?.['name']?.['value'],'address':f['address'],'tags':f['tags'],'createdAt':g,'updatedAt':g};c['push'](h),e['push'](h);}return await Cache['read'](b,async()=>({'expire':'INFINITE','data':c}),!![]),e;}async['get'](a){if(a===void 0x0||a===null)return;const b=await this['getCacheKey']();return(await Cache['read'](b,async c=>{return{'expire':'INFINITE','data':[]};}))?.['data']?.['find'](c=>LocalMark['nameMatch'](c['name'],a)||c['address']['toLowerCase']()===a['toLowerCase']());}async['get_address'](a){if(a&&isValidAddress(a))return a['toLowerCase']();return(await this['get'](a))?.['address'];}async['get_many'](a){if(!Array['isArray'](a)||a['length']===0x0)return[];const b=await this['getCacheKey'](),c=(await Cache['read'](b,async d=>{return{'expire':'INFINITE','data':[]};}))?.['data']||[];return a['map'](d=>{return c['find'](e=>LocalMark['nameMatch'](e['name'],d)||e['address']['toLowerCase']()===d?.['toLowerCase']());});}async['get_many_address'](a){const b=new Array(a['length'])['fill'](void 0x0),c=new Map();a['forEach']((g,h)=>{if(g===null||g===void 0x0)b[h]=void 0x0;else{if(isValidAddress(g))b[h]=g['toLowerCase']();else c['set'](h,g);}});const d=Array['from'](c['values']());if(d['length']===0x0)return b;const e=await this['get_many'](d);let f=0x0;return c['forEach']((g,h)=>{b[h]=e[f]?.['address'],f++;}),b;}async['get_many_address_availables'](a){return(await this['get_many_address'](a))['filter'](b=>b!=null);}async['del'](a,b=![]){const c=await this['getCacheKey'](),d=(await Cache['read'](c,async()=>({'expire':'INFINITE','data':[]})))?.['data']||[],e=d['filter'](g=>{const h=a['map'](m=>m['toLowerCase']()),i=g['name']!==void 0x0&&g['name']!==null&&a['some'](m=>LocalMark['nameMatch'](g['name'],m)),j=h['includes'](g['address']['toLowerCase']()),k=i||j,l=g['name']===void 0x0||g['name']===null;if(b)return!k&&!l;else return!k;}),f=d['filter'](g=>!e['includes'](g));if(e['length']!==d['length'])await Cache['read'](c,async()=>({'expire':'INFINITE','data':e}),!![]);return f;}async['clear'](){const a=await this['getCacheKey']();return await Cache['read'](a,async()=>({'expire':'INFINITE','data':[]}),!![]),!![];}async['rename'](a,b){b=this['resolve_name'](b);if(a===b)return!![];const c=await this['getCacheKey'](),d=(await Cache['read'](c,async()=>({'expire':'INFINITE','data':[]})))?.['data']||[],e=d['find'](f=>LocalMark['nameMatch'](f['name'],a));if(e&&d['findIndex'](f=>LocalMark['nameMatch'](f['name'],b))===-0x1){const f=Date['now']();return e['name']=b,e['updatedAt']=f,await Cache['read'](c,async()=>({'expire':'INFINITE','data':d}),!![]),!![];}return![];}async['swap_name'](a,b){if(a===b)return!![];const c=await this['getCacheKey'](),d=(await Cache['read'](c,async()=>({'expire':'INFINITE','data':[]})))?.['data']||[],e=d['find'](g=>LocalMark['nameMatch'](g['name'],a)),f=d['find'](g=>LocalMark['nameMatch'](g['name'],b));if(e&&f){const g=Date['now']();return e['name']=b,e['updatedAt']=g,f['name']=a,f['updatedAt']=g,await Cache['read'](c,async()=>({'expire':'INFINITE','data':d}),!![]),!![];}return![];}async['set_tags'](a,b){b=this['resolve_tags'](b);const c=await this['getCacheKey'](),d=(await Cache['read'](c,async()=>({'expire':'INFINITE','data':[]})))?.['data']||[],e=d['find'](f=>LocalMark['nameMatch'](f['name'],a));if(e){const f=Date['now']();return e['tags']=b,e['updatedAt']=f,await Cache['read'](c,async()=>({'expire':'INFINITE','data':d}),!![]),!![];}return![];}async['list'](a){if(a&&a['tags'])a['tags']=a['tags']['filter'](c=>c!==''&&c);const b=await this['getCacheKey']();return((await Cache['read'](b,async()=>({'expire':'INFINITE','data':[]})))?.['data']||[])['filter'](c=>{if(a?.['address']&&c['address']['toLowerCase']()!==a['address']['toLowerCase']())return![];if(a?.['createdAt']){if(a['createdAt']['gte']!==void 0x0&&(!c['createdAt']||c['createdAt']<a['createdAt']['gte']))return![];if(a['createdAt']['lte']!==void 0x0&&(!c['createdAt']||c['createdAt']>a['createdAt']['lte']))return![];}if(a?.['updatedAt']){if(a['updatedAt']['gte']!==void 0x0&&(!c['updatedAt']||c['updatedAt']<a['updatedAt']['gte']))return![];if(a['updatedAt']['lte']!==void 0x0&&(!c['updatedAt']||c['updatedAt']>a['updatedAt']['lte']))return![];}return!![];})['map'](c=>{let d=0x0;const e=c['name']?.['toLowerCase']()||'',f=a?.['name']?.['toLowerCase']()||'';if(a?.['name']){if(e===f)d+=0x64;else{if(e['startsWith'](f))d+=0x32;else{if(e['includes'](f))d+=0x19;}}}if(a?.['tags']&&a['tags']['length']>0x0)a['tags']['forEach'](g=>{const h=g['toLowerCase']();if(c['tags'])c['tags']['forEach'](i=>{const j=i['toLowerCase']();if(j===h)d+=0x14;else{if(j['startsWith'](h))d+=0xf;else{if(j['includes'](h))d+=0xa;}}});});if((a?.['name']||a?.['tags'])&&d===0x0)d=-0x1;return{'mark':c,'score':d};})['filter'](({score:c})=>c>=0x0)['sort']((c,d)=>{if(d['score']!==c['score'])return d['score']-c['score'];const e=(c['mark']['name']||'')['length'],f=(d['mark']['name']||'')['length'];if(e!==f)return e-f;return(c['mark']['name']||'')['localeCompare'](d['mark']['name']||'');})['map'](({mark:c})=>c);}},LocalInfoAsyncLock=class{constructor(){this['_locked']=![],this['_queue']=[];}async['acquire'](){if(!this['_locked']){this['_locked']=!![];return;}return new Promise(a=>{this['_queue']['push'](a);});}['release'](){if(this['_queue']['length']>0x0)this['_queue']['shift']()();else this['_locked']=![];}async['run'](a){await this['acquire']();try{return await a();}finally{this['release']();}}},LocalInfo=class LocalInfo{constructor(){this['cacheKey']=['info'];}static{this['_lock']=new LocalInfoAsyncLock();}static['Instance'](){if(!LocalInfo['_instance'])LocalInfo['_instance']=new LocalInfo();return LocalInfo['_instance'];}static['nameMatch'](a,b){if(a==null||b==null)return![];return a['toLowerCase']()===b['toLowerCase']();}['resolve_contents'](a){return a=a['slice'](0x0,0x32),a['map'](b=>b['slice'](0x0,0x12c));}['resolve_name'](a){return a['slice'](0x0,0x40);}async['add'](a){return LocalInfo['_lock']['run'](async()=>{const b=(await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})))?.['data']||{};for(const c of a){const d=this['resolve_name'](c['name']),e=c['default']['slice'](0x0,0x12c);if(b[d]){const f=Date['now'](),g=b[d];g['default']=e;if(c['contents']!==void 0x0)g['contents']=this['resolve_contents'](c['contents']);g['updatedAt']=f;}else{const h=Date['now']();b[d]={'default':e,'contents':c['contents']?this['resolve_contents'](c['contents']):[],'createdAt':h,'updatedAt':h};}}return await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':b}),!![]),!![];});}async['get'](a=LocalInfoNameDefault){const b=((await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})))?.['data']||{})[a];return b?{'name':a,...b}:void 0x0;}async['get_default'](a=LocalInfoNameDefault){return(await this['get'](a))?.['default'];}async['get_many'](a){if(!Array['isArray'](a)||a['length']===0x0)return[];const b=(await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})))?.['data']||{};return a['map'](c=>{const d=b[c];return d?{'name':c,...d}:void 0x0;});}async['del'](a=LocalInfoNameDefault){return LocalInfo['_lock']['run'](async()=>{const b=(await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})))?.['data']||{};delete b[a],await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':b}),!![]);});}async['reset_contents'](a=LocalInfoNameDefault,b){return LocalInfo['_lock']['run'](async()=>{const c=(await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})))?.['data']||{},d=c[a];if(d){const e=Date['now']();return d['contents']=this['resolve_contents'](b),d['updatedAt']=e,await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':c}),!![]),!![];}return![];});}async['clear'](){return LocalInfo['_lock']['run'](async()=>{await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}}),!![]);});}async['list'](a){const b=(await Cache['read'](this['cacheKey'],async()=>({'expire':'INFINITE','data':{}})))?.['data']||{};return Object['entries'](b)['map'](([c,d])=>{let e=0x0;const f={'name':c,...d};if(a?.['name']){const g=c['toLowerCase'](),h=a['name']['toLowerCase']();if(g===h)e+=0x64;else{if(g['startsWith'](h))e+=0x32;else{if(g['includes'](h))e+=0x19;}}}if(a?.['default']){const i=d['default']['toLowerCase'](),j=a['default']['toLowerCase']();if(i===j)e+=0x5a;else{if(i['startsWith'](j))e+=0x2d;else{if(i['includes'](j))e+=0x16;}}}if(a?.['contents']&&a['contents']['length']>0x0)a['contents']['forEach'](k=>{const l=k['toLowerCase']();if(d['contents'])d['contents']['forEach'](m=>{const n=m['toLowerCase']();if(n===l)e+=0x14;else{if(n['startsWith'](l))e+=0xf;else{if(n['includes'](l))e+=0xa;}}});});if((a?.['name']||a?.['default']||a?.['contents'])&&e===0x0)e=-0x1;return{'info':f,'score':e};})['filter'](({score:c,info:d})=>{if(c<0x0)return![];if(a?.['createdAt']){if(a['createdAt']['gte']!==void 0x0&&(!d['createdAt']||d['createdAt']<a['createdAt']['gte']))return![];if(a['createdAt']['lte']!==void 0x0&&(!d['createdAt']||d['createdAt']>a['createdAt']['lte']))return![];}if(a?.['updatedAt']){if(a['updatedAt']['gte']!==void 0x0&&(!d['updatedAt']||d['updatedAt']<a['updatedAt']['gte']))return![];if(a['updatedAt']['lte']!==void 0x0&&(!d['updatedAt']||d['updatedAt']>a['updatedAt']['lte']))return![];}return!![];})['sort']((c,d)=>{if(d['score']!==c['score'])return d['score']-c['score'];const e=c['info']['name']['length'],f=d['info']['name']['length'];if(e!==f)return e-f;return c['info']['name']['localeCompare'](d['info']['name']);})['map'](({info:c})=>c);}};export{getMoveErrorDescription as C,enrichMoveError as S,W_ERROR as _,LocalInfoNameDefault as a,W_SUCCESS as b,LocalMarkNameMaxLength as c,isValidAddress as d,MoveErrors as f,W_ENSURE as g,WValidate as h,LocalInfoContentMaxLength as i,LocalMarkTagMaxCount as l,WException as m,LocalInfo as n,LocalInfoNameMaxLength as o,WErrors as p,LocalInfoContentMaxCount as r,LocalMark as s,BUITIN_IDS as t,LocalMarkTagMaxLength as u,W_FAILURE as v,W_VALIDATE_PARAM as x,W_SAFE as y};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{J as a32a}from'./common-fDv-Cuzq.mjs';import{_ as a32b,s as a32c}from'./local-c-Tbdkfa.mjs';import{Account}from'./w/local/account.mjs';import{GetAccountOrMark_Address,GetManyAccountOrMark_Address}from'./w/local/index.mjs';import{L as a32d}from'./object-DzsQI-0e.mjs';import{DEFAULT_MESSENGER_CONFIG,MessengerError,WTS_SCHEMA_URL}from'./w/messenger/types.mjs';import{n as a32e,t as a32f}from'./messenger-Bokr4-T2.mjs';import{MessageStorage,MessengerPersistStorage}from'./w/messenger/storage.mjs';import{hashPlaintext,verifyFalcon512Signature,verifySingleMerkleRoot}from'./w/messenger/crypto.mjs';import*as a32g from'path';import*as a32h from'fs';import{createHash}from'crypto';const MAX_ACCOUNTS=0x64,sleep=a=>new Promise(b=>setTimeout(b,a));var MessengerManager=class{constructor(a){this['accounts']=new Map(),this['messageListeners']=new Set(),this['isWatching']=![],this['accountRefreshTimer']=null,this['pollingLockedAccounts']=new Set(),this['config']={...DEFAULT_MESSENGER_CONFIG,...a?.['messengerConfig']},this['instanceId']=a?.['instanceId']||'default',this['persistStorage']=new MessengerPersistStorage();}['findAccount'](a){return this['accounts']['get'](a['toLowerCase']());}['getConfig'](){return this['config'];}['get_accounts'](){return Array['from'](this['accounts']['values']())['map'](a=>a['address']);}async['refresh_accounts'](){const {Account:a}=await import('./w/local/account.mjs'),b=await a['Instance']()['list_messenger_accounts'](),c=new Set(this['accounts']['keys']()),d=new Set(b['map'](e=>e['address']['toLowerCase']()));for(const e of c)if(!d['has'](e))this['remove_account_internal'](e);for(const f of b){const g=f['address']['toLowerCase']();if(!this['accounts']['has'](g))try{await this['add_account_internal'](f['address']);}catch(h){}}if(this['accounts']['size']>0x0&&!this['isWatching'])this['startPolling']();else{if(this['accounts']['size']===0x0&&this['isWatching'])this['stopPolling']();}await this['syncAllContactLists']();}async['start'](){await this['refresh_accounts']();for(const a of this['accounts']['values']()){if(!a['initialized']||!a['messenger'])continue;this['persistStorage']['tryAcquirePollingLock'](a['address'],this['instanceId'])&&(this['pollingLockedAccounts']['add'](a['address']['toLowerCase']()),a['messenger']['setOnMessageCallback'](b=>{for(const c of this['messageListeners'])c(b);}));}if(!this['isWatching'])this['startPolling']();if(this['accountRefreshTimer'])clearInterval(this['accountRefreshTimer']);this['accountRefreshTimer']=setInterval(()=>{this['refresh_accounts']()['catch'](b=>{});},this['config']['watch_interval_ms']);}['stop'](){this['accountRefreshTimer']&&(clearInterval(this['accountRefreshTimer']),this['accountRefreshTimer']=null);for(const a of this['pollingLockedAccounts'])this['persistStorage']['releasePollingLock'](a,this['instanceId']);this['pollingLockedAccounts']['clear'](),this['stopPolling'](),this['clear_accounts']();}async['ensureAccountReady'](a){const b=a['toLowerCase'](),c=this['accounts']['get'](b);if(c?.['initialized'])return c;if(c?.['initializing']){await c['initializing'];const d=this['accounts']['get'](b);if(d?.['initialized'])return d;throw new MessengerError('SERVER_ERROR','Account\x20'+a+'\x20initialization\x20failed');}return this['initializeAccount'](b);}async['initializeAccount'](a){const b=a['toLowerCase']();if(this['accounts']['size']>=MAX_ACCOUNTS)throw new MessengerError('INVALID_INPUT','Maximum\x20'+MAX_ACCOUNTS+'\x20accounts\x20allowed');const c=this['doInitialize'](b),d={'address':b,'messenger':null,'initialized':![],'initializing':c,'contactLists':{'friends':[],'guards':[],'lastUpdatedAt':0x0}};this['accounts']['set'](b,d);try{await c;const e=this['accounts']['get'](b);if(!e||!e['initialized'])throw new MessengerError('SERVER_ERROR','Account\x20'+a+'\x20initialization\x20failed');return e;}catch(f){this['accounts']['delete'](b);throw f;}}async['doInitialize'](a){const b=new a32f(a,this['config']);try{await b['initialize']();}catch(c){throw new MessengerError('SERVER_ERROR','Failed\x20to\x20initialize\x20account\x20'+a+':\x20'+(c instanceof Error?c['message']:String(c)));}await sleep(0x3e8),this['accounts']['set'](a,{'address':a,'messenger':b,'initialized':!![],'contactLists':{'friends':[],'guards':[],'lastUpdatedAt':0x0}}),this['isWatching']&&(this['persistStorage']['tryAcquirePollingLock'](a,this['instanceId'])&&(this['pollingLockedAccounts']['add'](a),b['setOnMessageCallback'](d=>{for(const e of this['messageListeners'])e(d);})));}async['add_account_internal'](a){await this['ensureAccountReady'](a);}['remove_account_internal'](a){const b=a['toLowerCase'](),c=this['accounts']['get'](b);if(!c)return![];if(c['initialized']&&c['messenger'])c['messenger']['disconnect']();return this['persistStorage']['releasePollingLock'](b,this['instanceId']),this['pollingLockedAccounts']['delete'](b),this['accounts']['delete'](b);}['clear_accounts'](){this['stopPolling']();for(const a of this['accounts']['values']())if(a['messenger'])a['messenger']['disconnect']();this['accounts']['clear']();}async['send'](a,b,c,d){const {Account:e}=await import('./w/local/account.mjs'),f=await e['Instance']()['get'](a,![]);if(!f)throw new MessengerError('IDENTITY_NOT_FOUND','Account\x20'+a+'\x20not\x20found');if(f['m']==null){if(d?.['new_messenger_name']==null)throw new MessengerError('ACCOUNT_MESSENGER_NOT_ENABLED','Account\x20messenger\x20name\x20not\x20set.\x20Use\x20new_messenger_name\x20parameter\x20to\x20set\x20it\x20automatically.');await e['Instance']()['set_messenger'](a,d['new_messenger_name']);}const g=await this['ensureAccountReady'](a);if(d?.['new_messenger_name']!=null){const h=await e['Instance']()['get'](a,![]);if(h&&h['m']!==d['new_messenger_name'])await e['Instance']()['set_messenger'](a,d['new_messenger_name']);}try{return await g['messenger']['sendMessage'](b,c,{'guardAddress':d?.['guardAddress'],'passportAddress':d?.['passportAddress'],'force':d?.['force']});}catch(i){if(i instanceof MessengerError&&i['code']==='IDENTITY_NOT_FOUND'){const j=i['message']||'',k=a['toLowerCase'](),l=b['toLowerCase'](),m=j['toLowerCase']()['includes'](k);if((j['toLowerCase']()['includes'](l)||j['toLowerCase']()['includes']('recipient')||j['toLowerCase']()['includes']('no\x20signed\x20prekey'))&&!m)throw new MessengerError('IDENTITY_NOT_FOUND','Recipient\x20'+b+'\x20is\x20not\x20registered\x20on\x20the\x20messenger\x20server.\x20Please\x20ask\x20them\x20to\x20enable\x20messenger\x20first.');console['log']('[MessengerManager]\x20Sender\x20'+a+'\x20not\x20found\x20on\x20server,\x20re-registering...'),await this['reinitializeAccount'](a);const n=this['accounts']['get'](a['toLowerCase']());if(n?.['initialized'])return await n['messenger']['sendMessage'](b,c,{'guardAddress':d?.['guardAddress'],'passportAddress':d?.['passportAddress'],'force':d?.['force']});}throw i;}}async['reinitializeAccount'](a){const b=a['toLowerCase'](),c=this['accounts']['get'](b);if(c){if(c['messenger'])c['messenger']['disconnect']();this['accounts']['delete'](b);}await this['initializeAccount'](b);}async['send_file'](a,b,c,d){const {Account:e}=await import('./w/local/account.mjs'),f=await e['Instance']()['get'](a,![]);if(!f)throw new MessengerError('IDENTITY_NOT_FOUND','Account\x20'+a+'\x20not\x20found');if(f['m']==null){if(d?.['new_messenger_name']==null)throw new MessengerError('ACCOUNT_MESSENGER_NOT_ENABLED','Account\x20messenger\x20name\x20not\x20set.\x20Use\x20new_messenger_name\x20parameter\x20to\x20set\x20it\x20automatically.');await e['Instance']()['set_messenger'](a,d['new_messenger_name']);}const g=await this['ensureAccountReady'](a);if(d?.['new_messenger_name']!=null){const h=await e['Instance']()['get'](a,![]);if(h&&h['m']!==d['new_messenger_name'])await e['Instance']()['set_messenger'](a,d['new_messenger_name']);}try{return await g['messenger']['sendZipFile'](b,c,{'fileName':d?.['fileName'],'contentType':d?.['contentType'],'guardAddress':d?.['guardAddress'],'passportAddress':d?.['passportAddress'],'force':d?.['force']});}catch(i){if(i instanceof MessengerError&&i['code']==='IDENTITY_NOT_FOUND'){const j=i['message']||'',k=a['toLowerCase'](),l=b['toLowerCase'](),m=j['toLowerCase']()['includes'](k);if((j['toLowerCase']()['includes'](l)||j['toLowerCase']()['includes']('recipient')||j['toLowerCase']()['includes']('no\x20signed\x20prekey'))&&!m)throw new MessengerError('IDENTITY_NOT_FOUND','Recipient\x20'+b+'\x20is\x20not\x20registered\x20on\x20the\x20messenger\x20server.\x20Please\x20ask\x20them\x20to\x20enable\x20messenger\x20first.');console['log']('[MessengerManager]\x20Sender\x20'+a+'\x20not\x20found\x20on\x20server,\x20re-registering...'),await this['reinitializeAccount'](a);const n=this['accounts']['get'](a['toLowerCase']());if(n?.['initialized'])return await n['messenger']['sendZipFile'](b,c,{'fileName':d?.['fileName'],'contentType':d?.['contentType'],'guardAddress':d?.['guardAddress'],'passportAddress':d?.['passportAddress'],'force':d?.['force']});}throw i;}}async['watch'](a){let b=[];if(a?.['account']!==void 0x0){const i=a['account']['toLowerCase'](),j=this['accounts']['get'](i);if(j?.['messenger'])await j['messenger']['pullMessages']();b=new MessageStorage(i)['getAllMessages'](i);}else for(const k of this['accounts']['values']()){if(k['messenger'])await k['messenger']['pullMessages']();const l=new MessageStorage(k['address'])['getAllMessages'](k['address']);b['push'](...l);}if(a){const m=a['peerAddress']?await GetAccountOrMark_Address(a['peerAddress']):void 0x0;b=b['filter'](n=>{if(a?.['account']!==void 0x0){const p=a['account']['toLowerCase'](),q=n['fromAddress']['toLowerCase'](),r=n['toAddress']['toLowerCase']();if(q!==p&&r!==p)return![];}if(a['direction']&&n['direction']!==a['direction'])return![];if(a['status']&&n['status']!==a['status'])return![];if(a['msgType']!==void 0x0&&n['msgType']!==a['msgType'])return![];if(a['contentType'])switch(a['contentType']){case'text':if(n['msgType']!==0x1)return![];break;case'zip':if(!n['zipMetadata'])return![];break;case'wts':if(!n['zipMetadata']||n['zipMetadata']?.['contentType']!=='wts')return![];break;case'wip':if(!n['zipMetadata']||n['zipMetadata']?.['contentType']!=='wip')return![];break;}if(a['peerAddress']&&m){const s=m['toLowerCase'](),t=n['fromAddress']['toLowerCase'](),u=n['toAddress']['toLowerCase']();if(t!==s&&u!==s)return![];}const o=a['timeField']||'createdAt';if(a['startTime']!==void 0x0||a['endTime']!==void 0x0){const v=n[o];if(v!==void 0x0){if(a['startTime']!==void 0x0&&v<a['startTime'])return![];if(a['endTime']!==void 0x0&&v>a['endTime'])return![];}}if(a['createdAtStart']!==void 0x0&&n['createdAt']<a['createdAtStart'])return![];if(a['createdAtEnd']!==void 0x0&&n['createdAt']>a['createdAtEnd'])return![];if(a['receivedAtStart']!==void 0x0){if(n['receivedAt']===void 0x0||n['receivedAt']<a['receivedAtStart'])return![];}if(a['receivedAtEnd']!==void 0x0){if(n['receivedAt']===void 0x0||n['receivedAt']>a['receivedAtEnd'])return![];}if(a['serverTimestampStart']!==void 0x0){if(n['serverTimestamp']===void 0x0||n['serverTimestamp']<a['serverTimestampStart'])return![];}if(a['serverTimestampEnd']!==void 0x0){if(n['serverTimestamp']===void 0x0||n['serverTimestamp']>a['serverTimestampEnd'])return![];}if(a['decryptedOnly']&&!n['plaintext'])return![];if(a['confirmedOnly']&&n['status']!=='confirmed')return![];if(a['arkConfirmedOnly']){if(!n['arkConfirmed'])return![];}if(a['proofedOnly']){if(!n['proof'])return![];}if(a['arkTimestampStart']!==void 0x0){if(n['arkConfirmed']===void 0x0||n['arkConfirmed']['timestamp']<a['arkTimestampStart'])return![];}if(a['arkTimestampEnd']!==void 0x0){if(n['arkConfirmed']===void 0x0||n['arkConfirmed']['timestamp']>a['arkTimestampEnd'])return![];}if(a['hasLastReceivedIndexOnly']){if(n['lastReceivedLeafIndex']===void 0x0||n['lastReceivedLeafIndex']===null)return![];}if(a['lastReceivedIndexMin']!==void 0x0){if(n['lastReceivedLeafIndex']===void 0x0||n['lastReceivedLeafIndex']<a['lastReceivedIndexMin'])return![];}if(a['lastReceivedIndexMax']!==void 0x0){if(n['lastReceivedLeafIndex']===void 0x0||n['lastReceivedLeafIndex']>a['lastReceivedIndexMax'])return![];}if(a['keyword']&&n['plaintext']){if(!n['plaintext']['toLowerCase']()['includes'](a['keyword']['toLowerCase']()))return![];}if(a['listFilterMode']&&a['listFilterMode']!=='any'){const w=this['findAccount'](n['toAddress']);if(!w)return![];const x=n['fromAddress']['toLowerCase'](),y=w['contactLists'],z=new Set(y['friends']['map'](E=>E['toLowerCase']())),A=new Set(y['guards']['map'](E=>E['guardAddress']['toLowerCase']())),B=z['has'](x),C=A['has'](x),D=!B&&!C;switch(a['listFilterMode']){case'friends':if(!B)return![];break;case'guard':if(!C)return![];break;case'stranger':if(!D)return![];break;}if(a['customListFilter']){const {includeAddresses:E,excludeAddresses:F,relation:relation='union'}=a['customListFilter'];if(F){if(new Set(F['map'](G=>G['toLowerCase']()))['has'](x))return![];}if(E&&E['length']>0x0){const G=new Set(E['map'](H=>H['toLowerCase']()))['has'](x);if(relation==='union'){const H=a['listFilterMode']==='friends'&&B||a['listFilterMode']==='guard'&&C||a['listFilterMode']==='stranger'&&D;if(!G&&!H)return![];}else{if(!G)return![];}}}}if(a['viewed']!==void 0x0){const I=n['viewedAt']!==void 0x0;if(a['viewed']!==I)return![];}if(a['viewedAtStart']!==void 0x0){if(n['viewedAt']===void 0x0||n['viewedAt']<a['viewedAtStart'])return![];}if(a['viewedAtEnd']!==void 0x0){if(n['viewedAt']===void 0x0||n['viewedAt']>a['viewedAtEnd'])return![];}return!![];});}const c=a?.['sortOrder']??'desc',d=a?.['timeField']||'createdAt';b['sort']((n,o)=>{const p=n[d]||0x0,q=o[d]||0x0;return c==='asc'?p-q:q-p;});const {MAX_QUERY_LIMIT:e}=await import('./w/messenger/types.mjs'),f=this['config']['defaultQueryLimit']??0x32,g=Math['min'](a?.['limit']??f,e),h=a?.['offset']??0x0;return b=b['slice'](h,h+g),b;}['startPolling'](){if(this['isWatching'])return;this['isWatching']=!![];}['stopPolling'](){this['isWatching']=![];}['onMessage'](a){this['messageListeners']['add'](a);}['offMessage'](a){this['messageListeners']['delete'](a);}['destroy'](){this['stop'](),this['messageListeners']['clear']();}async['syncContactLists'](a){const b=this['findAccount'](a);if(!b)return{'success':![],'friends':[],'guards':[],'error':'Account\x20not\x20found:\x20'+a};try{const [c,d]=await Promise['all']([b['messenger']['getFriendsList'](),b['messenger']['getGuardList']()]),e=d['currentGuardList']||[];return b['contactLists']={'friends':c,'guards':e,'lastUpdatedAt':Date['now']()},{'success':!![],'friends':c,'guards':e};}catch(f){return{'success':![],'friends':b['contactLists']['friends'],'guards':b['contactLists']['guards'],'error':f instanceof Error?f['message']:String(f)};}}async['syncAllContactLists'](){const a=new Map();for(const b of this['accounts']['values']()){const c=await this['syncContactLists'](b['address']);a['set'](b['address'],c);}return a;}['getContactLists'](a){return this['findAccount'](a)?.['contactLists'];}['setContactLists'](a,b){const c=this['findAccount'](a);if(!c)return![];return c['contactLists']={...c['contactLists'],...b,'lastUpdatedAt':Date['now']()},!![];}['isStranger'](a,b){const c=this['findAccount'](a);if(!c)return!![];const d=b['toLowerCase'](),e=c['contactLists'],f=e['friends']['some'](h=>h['toLowerCase']()===d),g=e['guards']['some'](h=>h['guardAddress']['toLowerCase']()===d);return!f&&!g;}['recordGuardSender'](a,b){const c=this['findAccount'](a);if(!c)return![];const d=b['toLowerCase']();return!c['contactLists']['guards']['some'](e=>e['guardAddress']['toLowerCase']()===d)&&(c['contactLists']['guards']['push']({'guardAddress':b,'passportValiditySeconds':0x15180}),c['contactLists']['lastUpdatedAt']=Date['now']()),!![];}['generateNonce'](){return Math['random']()['toString'](0x24)['substring'](0x2,0xf)+Math['random']()['toString'](0x24)['substring'](0x2,0xf);}async['watch_paginated'](a){const {MAX_QUERY_LIMIT:b}=await import('./w/messenger/types.mjs'),c=await this['watch'](a),d=c['length'],e=this['config']['defaultQueryLimit']??0x32,f=Math['min'](a?.['limit']??e,b),g=a?.['offset']??0x0;return{'messages':c['slice'](g,g+f),'total':d,'offset':g,'limit':f};}async['get_conversations'](a){const b=a?{'account':a}:void 0x0,c=await this['watch'](b),d=new Map();for(const e of c){const f=a?.['toLowerCase'](),g=e['fromAddress']['toLowerCase']()===f?e['toAddress']:e['fromAddress'];if(!d['has'](g))d['set'](g,{'peerAddress':g,'lastMessageAt':e['createdAt'],'messageCount':0x0,'unreadCount':0x0,'lastMessagePreview':e['plaintext']});const h=d['get'](g);h['messageCount']++;e['createdAt']>h['lastMessageAt']&&(h['lastMessageAt']=e['createdAt'],h['lastMessagePreview']=e['plaintext']);if(e['status']!=='read'&&e['toAddress']['toLowerCase']()===f)h['unreadCount']++;}return Array['from'](d['values']())['sort']((i,j)=>j['lastMessageAt']-i['lastMessageAt']);}async['generate_wts'](a,b,c,d,e){const f=await import('fs'),g=await import('path'),h=b['toLowerCase'](),k=c['toLowerCase']();let l=new MessageStorage(h)['getAllMessages'](h)['filter'](u=>{const v=u['fromAddress']['toLowerCase'](),w=u['toAddress']['toLowerCase']();return v===h&&w===k||v===k&&w===h;});l=l['filter'](u=>u['leafIndex']!==void 0x0&&u['serverTimestamp']!==void 0x0)['reduce']((u,v)=>{if(!u['find'](w=>w['messageId']===v['messageId']))u['push'](v);return u;},[])['sort']((u,v)=>{const w=u['serverTimestamp']-v['serverTimestamp'];if(w!==0x0)return w;return u['leafIndex']-v['leafIndex'];});if(d)switch(d['type']){case'time':{const u=Math['min'](d['start'],d['end']),v=Math['max'](d['start'],d['end']);l=l['filter'](w=>w['createdAt']>=u&&w['createdAt']<=v);break;}case'messageId':{const w=d['start'],x=d['end'];l=l['filter'](y=>y['messageId']>=w&&y['messageId']<=x);break;}case'seqIndex':{const y=Math['min'](d['start'],d['end']),z=Math['max'](d['start'],d['end']);l=l['filter'](A=>A['leafIndex']>=y&&A['leafIndex']<=z);break;}}if(l['length']===0x0)throw new MessengerError('INVALID_INPUT','No\x20messages\x20found\x20for\x20the\x20given\x20criteria');const m=l['map'](A=>A['leafIndex'])['filter'](A=>A!==void 0x0)['sort']((A,B)=>A-B),n=[];for(let A=0x1;A<m['length'];A++){const B=m[A-0x1]+0x1,C=m[A];if(C!==B){for(let D=B;D<C;D++)n['push'](D);}}if(n['length']>0x0){}if(l['length']>0x1f4)throw new MessengerError('INVALID_INPUT','Message\x20count\x20('+l['length']+')\x20exceeds\x20maximum\x20allowed\x20(500)');if(!f['existsSync'](a))f['mkdirSync'](a,{'recursive':!![]});const o=h['slice'](0x0,0x6)+'_'+k['slice'](0x0,0x6),p=[];let q=[];for(let E=0x0;E<l['length'];E++){const F=l[E];if(q['length']===0x0)q['push'](F);else{const G=q[q['length']-0x1]['leafIndex']+0x1;if(q['length']>=0x1f4||F['leafIndex']!==G)p['push'](q),q=[F];else q['push'](F);}}if(q['length']>0x0)p['push'](q);p['forEach']((H,I)=>{H['map'](J=>J['leafIndex'])['join'](',\x20');});const r=[];for(const H of p){const I=H['map'](Z=>Z['leafIndex'])['filter'](Z=>Z!==void 0x0),J=Math['min'](...I),K=Math['max'](...I),L=H[0x0]['createdAt'],M=H[H['length']-0x1]['createdAt'];for(const Z of H){if(Z['serverTimestamp']===void 0x0)throw new MessengerError('INVALID_INPUT','Message\x20'+Z['messageId']+'\x20missing\x20serverTimestamp');if(Z['leafIndex']===void 0x0)throw new MessengerError('INVALID_INPUT','Message\x20'+Z['messageId']+'\x20missing\x20leafIndex');if(!Z['prevRoot'])throw new MessengerError('INVALID_INPUT','Message\x20'+Z['messageId']+'\x20missing\x20prevRoot');if(!Z['newRoot'])throw new MessengerError('INVALID_INPUT','Message\x20'+Z['messageId']+'\x20missing\x20newRoot');if(!Z['serverSignature'])throw new MessengerError('INVALID_INPUT','Message\x20'+Z['messageId']+'\x20missing\x20serverSignature');}const N=H['map'](a0=>{const a1={'id':a0['messageId'],'from':a0['fromAddress'],'to':a0['toAddress'],'plaintextHash':a0['plaintextHash'],'clientTimestamp':a0['createdAt'],'timestamp':a0['serverTimestamp'],'leafIndex':a0['leafIndex'],'prevRoot':a0['prevRoot'],'merkleRoot':a0['newRoot'],'serverSignature':a0['serverSignature'],'serverPublicKeyIndex':0x0,'msgType':a0['msgType']};if(!e&&a0['plaintext']!==void 0x0)a1['plaintext']=a0['plaintext'];if(a0['guardAddress']!==void 0x0)a1['guardAddress']=a0['guardAddress'];if(a0['passportAddress']!==void 0x0)a1['passportAddress']=a0['passportAddress'];if(a0['arkConfirmed']!==void 0x0)a1['arkConfirmed']={'recipient':a0['arkConfirmed']['recipient'],'recipientPublicKey':a0['arkConfirmed']['recipientPublicKey'],'signature':a0['arkConfirmed']['signature'],'timestamp':a0['arkConfirmed']['timestamp']};if(a0['zipMetadata']!==void 0x0)a1['zipMetadata']=a0['zipMetadata'];if(a0['lastReceivedLeafIndex']!==void 0x0&&a0['lastReceivedLeafIndex']!==-0x1)a1['lastReceivedLeafIndex']=a0['lastReceivedLeafIndex'];return a1;}),O={'participants':[h,k]['sort']()},P=[],Q=new Map();for(const a0 of N){const a1=H['find'](a3=>a3['messageId']===a0['id'])?.['serverPublicKey']||'';if(!a1)continue;let a2=Q['get'](a1);a2===void 0x0&&(a2=P['length'],Q['set'](a1,a2),P['push']({'publicKey':a1,'validFrom':0x0})),a0['serverPublicKeyIndex']=a2;}const R={'session':O,'messages':N},{sha256:S}=await import('@noble/hashes/sha2.js'),{bytesToHex:T}=await import('@noble/hashes/utils.js'),U={'wts':WTS_SCHEMA_URL,...R},V=T(S(new TextEncoder()['encode'](a32e(U)))),W={'wts':WTS_SCHEMA_URL,'payload':R,'meta':{'type':'wts','version':'1.0','created':new Date()['toISOString'](),'hash':V,'algorithm':'sha256','startTime':L,'endTime':M,'messageCount':N['length'],'merkleRoot':N[N['length']-0x1]['merkleRoot'],'creator':h,'participant':k,'serverPublicKeys':P}},X=o+'_'+J+'-'+K+'.wts',Y=g['join'](a,X);f['writeFileSync'](Y,JSON['stringify'](W,null,0x2)),r['push'](Y);}const s=l[0x0]?.['createdAt']||0x0,t=l[l['length']-0x1]?.['createdAt']||0x0;return{'files':r,'totalMessageCount':l['length'],'timeRange':{'start':s,'end':t}};}async['addToBlacklist'](a,b){const c=this['findAccount'](a);if(!c)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return c['messenger']['addToBlacklist'](b);}async['removeFromBlacklist'](a,b){const c=this['findAccount'](a);if(!c)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return c['messenger']['removeFromBlacklist'](b);}async['clearBlacklist'](a){const b=this['findAccount'](a);if(!b)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return b['messenger']['clearBlacklist']();}async['getBlacklist'](a){const b=this['findAccount'](a);if(!b)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return b['messenger']['getBlacklist']();}async['existInBlacklist'](a,b){const c=this['findAccount'](a);if(!c)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return c['messenger']['existInBlacklist'](b);}async['addToFriendsList'](a,b){const c=this['findAccount'](a);if(!c)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return c['messenger']['addToFriendsList'](b);}async['removeFromFriendsList'](a,b){const c=this['findAccount'](a);if(!c)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return c['messenger']['removeFromFriendsList'](b);}async['clearFriendsList'](a){const b=this['findAccount'](a);if(!b)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return b['messenger']['clearFriendsList']();}async['getFriendsList'](a){const b=this['findAccount'](a);if(!b)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return b['messenger']['getFriendsList']();}async['existInFriendsList'](a,b){const c=this['findAccount'](a);if(!c)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return c['messenger']['existInFriendsList'](b);}async['addToGuardList'](a,b){const c=this['findAccount'](a);if(!c)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return c['messenger']['addToGuardList'](b);}async['removeFromGuardList'](a,b){const c=this['findAccount'](a);if(!c)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return c['messenger']['removeFromGuardList'](b);}async['getGuardList'](a){const b=this['findAccount'](a);if(!b)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return b['messenger']['getGuardList']();}async['getSettings'](a){const b=this['findAccount'](a);if(!b)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return b['messenger']['getSettings']();}async['setSettings'](a,b){const c=this['findAccount'](a);if(!c)throw new MessengerError('ACCOUNT_NOT_FOUND','Account\x20'+a+'\x20not\x20in\x20managed\x20accounts');return c['messenger']['setSettings'](b);}};function escapeHtml(a){if(!a)return'';return a['replace'](/&/g,'&')['replace'](/</g,'<')['replace'](/>/g,'>')['replace'](/"/g,'"')['replace'](/'/g,''');}function formatFileSize(a){if(a<0x400)return a+'\x20B';if(a<0x400*0x400)return(a/0x400)['toFixed'](0x1)+'\x20KB';return(a/(0x400*0x400))['toFixed'](0x1)+'\x20MB';}function isNonTextMessage(a){return!!a['zipMetadata'];}function getFileTypeLabel(a){if(a['zipMetadata']?.['contentType'])return a['zipMetadata']['contentType']['toUpperCase']();const b=a['zipMetadata']?.['fileName']||'';if(b['endsWith']('.wts'))return'WTS';if(b['endsWith']('.wip'))return'WIP';if(b['endsWith']('.zip'))return'ZIP';if(b['endsWith']('.json'))return'JSON';if(b['endsWith']('.txt'))return'TXT';if(a['zipMetadata'])return'ZIP';return'FILE';}function getThemeColors(a){return{'bgColor':a==='dark'?'#1a1a1a':'#ffffff','textColor':a==='dark'?'#e0e0e0':'#333333','borderColor':a==='dark'?'#444444':'#e0e0e0'};}function getMessageColors(a,b){if(b)return{'bgColor':a==='dark'?'#1a365d':'#e3f2fd','borderColor':a==='dark'?'#3b82f6':'#90caf9'};else return{'bgColor':a==='dark'?'#1e3a2f':'#e8f5e9','borderColor':a==='dark'?'#10b981':'#a5d6a7'};}function generateFileButton(a,b,c){if(!a['plaintext']||!a['zipMetadata']?.['fileName'])return'';const d=a['zipMetadata']['fileName'],e=a['plaintext'],f=a['zipMetadata']['fileSize']||0x0,g=getFileTypeLabel(a),h=c==='dark'?'#2a3f2a':'#e8f5e9',i=c==='dark'?'#4caf50':'#4caf50',j=c==='dark'?'#81c784':'#2e7d32',k='#4caf50';return'\x0a\x09\x09<div\x20style=\x22margin:\x2012px\x200;\x20padding:\x2016px;\x20background:\x20'+h+';\x20border:\x201px\x20solid\x20'+i+';\x20border-radius:\x208px;\x20text-align:\x20center;\x22>\x0a\x09\x09\x09<div\x20style=\x22font-size:\x2014px;\x20color:\x20'+j+';\x20margin-bottom:\x208px;\x22>\x0a\x09\x09\x09\x09📎\x20'+escapeHtml(g)+'\x20File\x0a\x09\x09\x09\x09<span\x20style=\x22font-size:\x2012px;\x20color:\x20#666;\x22>('+formatFileSize(f)+')</span>\x0a\x09\x09\x09</div>\x0a\x09\x09\x09<button\x20\x0a\x09\x09\x09\x09onclick=\x22saveFile'+b+'()\x22\x0a\x09\x09\x09\x09style=\x22padding:\x2010px\x2024px;\x20background:\x20'+k+';\x20color:\x20white;\x20border:\x20none;\x20border-radius:\x204px;\x20cursor:\x20pointer;\x20font-size:\x2014px;\x22\x0a\x09\x09\x09\x09onmouseover=\x22this.style.background=\x27#45a049\x27\x22\x0a\x09\x09\x09\x09onmouseout=\x22this.style.background=\x27'+k+'\x27\x22\x0a\x09\x09\x09>\x0a\x09\x09\x09\x09💾\x20Save\x20'+escapeHtml(d)+'\x0a\x09\x09\x09</button>\x0a\x09\x09</div>\x0a\x09\x09<script>\x0a\x09\x09\x09function\x20saveFile'+b+'()\x20{\x0a\x09\x09\x09\x09try\x20{\x0a\x09\x09\x09\x09\x09const\x20base64Data\x20=\x20\x22'+escapeHtml(e)+'\x22;\x0a\x09\x09\x09\x09\x09const\x20byteCharacters\x20=\x20atob(base64Data);\x0a\x09\x09\x09\x09\x09const\x20byteNumbers\x20=\x20new\x20Array(byteCharacters.length);\x0a\x09\x09\x09\x09\x09for\x20(let\x20i\x20=\x200;\x20i\x20<\x20byteCharacters.length;\x20i++)\x20{\x0a\x09\x09\x09\x09\x09\x09byteNumbers[i]\x20=\x20byteCharacters.charCodeAt(i);\x0a\x09\x09\x09\x09\x09}\x0a\x09\x09\x09\x09\x09const\x20byteArray\x20=\x20new\x20Uint8Array(byteNumbers);\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09let\x20mimeType\x20=\x20\x22application/octet-stream\x22;\x0a\x09\x09\x09\x09\x09const\x20fileName\x20=\x20\x22'+escapeHtml(d)+'\x22;\x0a\x09\x09\x09\x09\x09if\x20(fileName.endsWith(\x27.json\x27))\x20mimeType\x20=\x20\x22application/json\x22;\x0a\x09\x09\x09\x09\x09else\x20if\x20(fileName.endsWith(\x27.zip\x27))\x20mimeType\x20=\x20\x22application/zip\x22;\x0a\x09\x09\x09\x09\x09else\x20if\x20(fileName.endsWith(\x27.txt\x27))\x20mimeType\x20=\x20\x22text/plain\x22;\x0a\x09\x09\x09\x09\x09\x0a\x09\x09\x09\x09\x09const\x20blob\x20=\x20new\x20Blob([byteArray],\x20{\x20type:\x20mimeType\x20});\x0a\x09\x09\x09\x09\x09const\x20url\x20=\x20URL.createObjectURL(blob);\x0a\x09\x09\x09\x09\x09const\x20a\x20=\x20document.createElement(\x22a\x22);\x0a\x09\x09\x09\x09\x09a.href\x20=\x20url;\x0a\x09\x09\x09\x09\x09a.download\x20=\x20fileName;\x0a\x09\x09\x09\x09\x09document.body.appendChild(a);\x0a\x09\x09\x09\x09\x09a.click();\x0a\x09\x09\x09\x09\x09document.body.removeChild(a);\x0a\x09\x09\x09\x09\x09URL.revokeObjectURL(url);\x0a\x09\x09\x09\x09}\x20catch\x20(e)\x20{\x0a\x09\x09\x09\x09\x09alert(\x27保存文件失败:\x20\x27\x20+\x20e.message);\x0a\x09\x09\x09\x09}\x0a\x09\x09\x09}\x0a\x09\x09</script>\x0a\x09';}function generateMessageHtml(a,b,c){const {theme:d,borderColor:e,myAddress:f,maxLastReceivedLeafIndex:g}=c,h=isNonTextMessage(a),i=a['from']['toLowerCase']()===f['toLowerCase'](),j=i&&g>=0x0&&a['leafIndex']<=g,k=getMessageColors(d,i),l=d==='dark'?'#333333':'#ffffff';let m='';if(h)m=generateFileButton(a,b,d);else{if(a['plaintext'])m='<div\x20style=\x22margin:\x2012px\x200;\x20padding:\x2012px;\x20background:\x20'+l+';\x20border:\x201px\x20solid\x20'+e+';\x20border-radius:\x204px;\x20font-size:\x2014px;\x20line-height:\x201.6;\x20max-height:\x20calc(1.6em\x20*\x206);\x20overflow-y:\x20auto;\x20white-space:\x20pre-wrap;\x20word-break:\x20break-word;\x22>'+escapeHtml(a['plaintext'])+'</div>';}const n=['<div>Merkle\x20Root:\x20'+escapeHtml(a['merkleRoot'])+'</div>',a['arkConfirmed']?'<div>ARK\x20Confirmed:\x20'+escapeHtml(a['arkConfirmed']['recipient'])+'\x20at\x20'+new Date(a['arkConfirmed']['timestamp'])['toLocaleString']()+'</div>':'',a['guardAddress']?'<div>Guard:\x20'+escapeHtml(a['guardAddress'])+'</div>':'',a['passportAddress']?'<div>Passport:\x20'+escapeHtml(a['passportAddress'])+'</div>':'']['filter'](Boolean)['join']('');return'\x0a\x09\x09<div\x20style=\x22margin:\x2016px\x200;\x20padding:\x2016px;\x20border:\x201px\x20solid\x20'+k['borderColor']+';\x20border-radius:\x208px;\x20background:\x20'+k['bgColor']+';\x22>\x0a\x09\x09\x09<div\x20style=\x22display:\x20flex;\x20justify-content:\x20space-between;\x20margin-bottom:\x208px;\x20font-size:\x2012px;\x20color:\x20#666;\x22>\x0a\x09\x09\x09\x09<span>From:\x20'+escapeHtml(a['from']['slice'](0x0,0x6))+'...'+escapeHtml(a['from']['slice'](-0x3))+'\x20To:\x20'+escapeHtml(a['to']['slice'](0x0,0x6))+'...'+escapeHtml(a['to']['slice'](-0x3))+'</span>\x0a\x09\x09\x09\x09<span>'+new Date(a['timestamp'])['toLocaleString']()+'</span>\x0a\x09\x09\x09</div>\x0a\x09\x09\x09'+m+'\x0a\x09\x09\x09<div\x20style=\x22margin:\x208px\x200;\x20font-size:\x2011px;\x20color:\x20#666;\x22>\x0a\x09\x09\x09\x09'+n+'\x0a\x09\x09\x09</div>\x0a\x09\x09\x09<div\x20style=\x22font-size:\x2011px;\x20color:\x20#888;\x20margin-top:\x208px;\x20padding-top:\x208px;\x20border-top:\x201px\x20solid\x20'+e+';\x20display:\x20flex;\x20justify-content:\x20space-between;\x20align-items:\x20center;\x22>\x0a\x09\x09\x09\x09<div>Leaf\x20Index:\x20'+a['leafIndex']+'</div>\x0a\x09\x09\x09\x09'+(j?'<span\x20style=\x22color:\x20#4caf50;\x22>Delivered\x20&\x20Decrypted</span>':'')+'\x0a\x09\x09\x09</div>\x0a\x09\x09</div>\x0a\x09';}function generateSignatureHtml(a,b,c){if(!a['signatures']||a['signatures']['length']===0x0)return'';const d=b==='dark'?'#2a3f2a':'#e8f5e9',e=b==='dark'?'#81c784':'#2e7d32',f=a['signatures']['map']((g,h)=>'\x0a\x09\x09\x09<div\x20style=\x22font-size:\x2010px;\x20color:\x20'+c+';\x20margin-left:\x208px;\x22>\x0a\x09\x09\x09\x09'+(h+0x1)+'.\x20'+(g['address']?escapeHtml(g['address']['slice'](0x0,0x6))+'...'+escapeHtml(g['address']['slice'](-0x3)):'Unknown')+':\x20\x0a\x09\x09\x09\x09'+(g['valid']?'<span\x20style=\x22color:\x20#4caf50;\x22>✓\x20Valid</span>':'<span\x20style=\x22color:\x20#f44336;\x22>✗\x20Invalid</span>')+'\x0a\x09\x09\x09</div>\x0a\x09\x09')['join']('');return'\x0a\x09\x09<div\x20style=\x22margin-top:\x208px;\x20padding:\x208px;\x20background:\x20'+d+';\x20border-radius:\x204px;\x22>\x0a\x09\x09\x09<div\x20style=\x22font-size:\x2011px;\x20color:\x20'+e+';\x20margin-bottom:\x204px;\x22>\x0a\x09\x09\x09\x09✓\x20Signature\x20Verification\x20('+a['signatures']['length']+'\x20signature'+(a['signatures']['length']>0x1?'s':'')+')\x0a\x09\x09\x09</div>\x0a\x09\x09\x09'+f+'\x0a\x09\x09</div>\x0a\x09';}const MESSAGES_PER_PAGE=0x64;function generateHtmlPage(a){const {title:b,theme:c,bgColor:d,textColor:e,borderColor:f,meta:g,payload:h,verifyResult:i,maxLastReceivedLeafIndex:j}=a,k=h['messages']['length'],l=Math['ceil'](k/MESSAGES_PER_PAGE),m=[];for(let s=0x0;s<l;s++){const t=s*MESSAGES_PER_PAGE,u=Math['min'](t+MESSAGES_PER_PAGE,k),v=h['messages']['slice'](t,u)['map']((w,x)=>generateMessageHtml(w,t+x,a))['join']('');m['push']({'pageNum':s+0x1,'html':'<div\x20class=\x22page\x22\x20data-page=\x22'+(s+0x1)+'\x22\x20style=\x22display:\x20'+(s===0x0?'block':'none')+';\x22>'+v+'</div>'});}const n=l>0x1?generatePaginationHtml(l,c,e):'',o=m['map'](w=>w['html'])['join'](''),p=generateSignatureHtml(i,c,e),q=i['valid']?'<span\x20style=\x22color:\x20#4caf50;\x20margin-left:\x208px;\x22>✓\x20The\x20accuracy,\x20sequentiality,\x20and\x20integrity\x20of\x20the\x20messages\x20are\x20verified\x20without\x20tampering</span>':'<span\x20style=\x22color:\x20#ff9800;\x20margin-left:\x208px;\x22>⚠\x20'+(i['error']||'Hash\x20mismatch\x20-\x20content\x20has\x20been\x20tampered')+'</span>',r=j>=0x0?'<div>Delivered\x20&\x20Decrypted\x20Leaf\x20Index:\x20'+j+'\x20(sent\x20messages\x20are\x20only\x20confirmed\x20as\x20decrypted\x20after\x20receiving\x20a\x20reply\x20from\x20the\x20other\x20party)</div>':'';return'<!DOCTYPE\x20html>\x0a<html\x20lang=\x22en\x22>\x0a<head>\x0a\x20\x20\x20\x20<meta\x20charset=\x22UTF-8\x22>\x0a\x20\x20\x20\x20<meta\x20name=\x22viewport\x22\x20content=\x22width=device-width,\x20initial-scale=1.0\x22>\x0a\x20\x20\x20\x20<title>'+escapeHtml(b)+'</title>\x0a\x20\x20\x20\x20<style>\x0a\x20\x20\x20\x20\x20\x20\x20\x20body\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20font-family:\x20-apple-system,\x20BlinkMacSystemFont,\x20\x22Segoe\x20UI\x22,\x20Roboto,\x20sans-serif;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20max-width:\x20800px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin:\x200\x20auto;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20padding:\x2020px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20background:\x20'+d+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color:\x20'+e+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.header\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20border-bottom:\x202px\x20solid\x20'+f+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20padding-bottom:\x2016px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin-bottom:\x2024px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.meta\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20font-size:\x2012px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color:\x20#666;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin-top:\x208px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.note\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20font-size:\x2011px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color:\x20#999;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin-top:\x2012px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20padding:\x208px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20background:\x20'+(c==='dark'?'#2a2a2a':'#f5f5f5')+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20border-radius:\x204px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20font-style:\x20italic;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.pagination\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20display:\x20flex;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20justify-content:\x20center;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20align-items:\x20center;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20gap:\x208px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20margin-top:\x2024px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20padding:\x2016px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20border-top:\x201px\x20solid\x20'+f+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.pagination\x20button\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20padding:\x208px\x2016px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20border:\x201px\x20solid\x20'+f+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20background:\x20'+(c==='dark'?'#333':'#fff')+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color:\x20'+e+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cursor:\x20pointer;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20border-radius:\x204px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20font-size:\x2014px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.pagination\x20button:hover:not(:disabled)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20background:\x20'+(c==='dark'?'#444':'#f0f0f0')+';\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.pagination\x20button:disabled\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20opacity:\x200.5;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20cursor:\x20not-allowed;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.pagination\x20.page-info\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20font-size:\x2014px;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20color:\x20#666;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20.page\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20animation:\x20fadeIn\x200.3s\x20ease-in;\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20@keyframes\x20fadeIn\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20from\x20{\x20opacity:\x200;\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20to\x20{\x20opacity:\x201;\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20</style>\x0a</head>\x0a<body>\x0a\x20\x20\x20\x20<div\x20class=\x22header\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<h1>Witness\x20Timestamped\x20Sequence</h1>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22note\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20Important\x20Note:\x20This\x20page\x20is\x20for\x20message\x20browsing\x20and\x20verification\x20reference\x20only.\x20Please\x20verify\x20whether\x20the\x20message\x20sequence\x20has\x20been\x20tampered\x20with\x20through\x20the\x20\x27verify_wts\x27\x20API\x20using\x20the\x20WTS\x20file.\x0a\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<div\x20style=\x22font-size:\x2014px;\x20color:\x20#666;\x20margin-top:\x204px;\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+new Date(g['startTime'])['toLocaleDateString']()+'\x20-\x20'+new Date(g['endTime'])['toLocaleDateString']()+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+q+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<div\x20class=\x22meta\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div>Messages:\x20'+g['messageCount']+'\x20|\x20Time:\x20'+new Date(g['startTime'])['toLocaleString']()+'\x20-\x20'+new Date(g['endTime'])['toLocaleString']()+'</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20style=\x22word-break:\x20break-all;\x22>Merkle\x20Root:\x20'+escapeHtml(g['merkleRoot'])+'</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+r+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20style=\x22color:\x20'+(c==='dark'?'#3b82f6':'#1976d2')+';\x22>Creator:\x20'+escapeHtml(g['creator'])+'</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20<div\x20style=\x22color:\x20'+(c==='dark'?'#10b981':'#2e7d32')+';\x22>Participant:\x20'+escapeHtml(g['participant'])+'</div>\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'+p+'\x0a\x20\x20\x20\x20\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20<div\x20id=\x22messages-container\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20'+o+'\x0a\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20'+n+'\x0a\x20\x20\x20\x20<script>\x0a\x20\x20\x20\x20\x20\x20\x20\x20(function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20let\x20currentPage\x20=\x201;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20totalPages\x20=\x20'+l+';\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20function\x20showPage(pageNum)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20隐藏所有页面\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20document.querySelectorAll(\x27.page\x27).forEach(page\x20=>\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20page.style.display\x20=\x20\x27none\x27;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20显示目标页面\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20targetPage\x20=\x20document.querySelector(\x27.page[data-page=\x22\x27\x20+\x20pageNum\x20+\x20\x27\x22]\x27);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(targetPage)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20targetPage.style.display\x20=\x20\x27block\x27;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20currentPage\x20=\x20pageNum;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updatePaginationButtons();\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20function\x20updatePaginationButtons()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20prevBtn\x20=\x20document.getElementById(\x27prev-btn\x27);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20nextBtn\x20=\x20document.getElementById(\x27next-btn\x27);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20pageInfo\x20=\x20document.getElementById(\x27page-info\x27);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(prevBtn)\x20prevBtn.disabled\x20=\x20currentPage\x20===\x201;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(nextBtn)\x20nextBtn.disabled\x20=\x20currentPage\x20===\x20totalPages;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(pageInfo)\x20pageInfo.textContent\x20=\x20\x27Page\x20\x27\x20+\x20currentPage\x20+\x20\x27\x20of\x20\x27\x20+\x20totalPages;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20绑定按钮事件\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20prevBtn\x20=\x20document.getElementById(\x27prev-btn\x27);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20const\x20nextBtn\x20=\x20document.getElementById(\x27next-btn\x27);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(prevBtn)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20prevBtn.addEventListener(\x27click\x27,\x20function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(currentPage\x20>\x201)\x20showPage(currentPage\x20-\x201);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(nextBtn)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20nextBtn.addEventListener(\x27click\x27,\x20function()\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(currentPage\x20<\x20totalPages)\x20showPage(currentPage\x20+\x201);\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20});\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20//\x20初始化\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20updatePaginationButtons();\x0a\x20\x20\x20\x20\x20\x20\x20\x20})();\x0a\x20\x20\x20\x20</script>\x0a</body>\x0a</html>';}function generatePaginationHtml(a,b,c){return'\x0a\x20\x20\x20\x20<div\x20class=\x22pagination\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<button\x20id=\x22prev-btn\x22\x20disabled>←\x20Previous</button>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<span\x20class=\x22page-info\x22\x20id=\x22page-info\x22>Page\x201\x20of\x20'+a+'</span>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<button\x20id=\x22next-btn\x22\x20'+(a<=0x1?'disabled':'')+'>Next\x20→</button>\x0a\x20\x20\x20\x20</div>';}let managerInstance=null,isInitialized=![],startPromise=null,backgroundTimer=null;async function autoRegisterMessengerAccounts(){const a=await Account['Instance']()['list_messenger_accounts']();for(const b of a){if(!b['address']||!b['m'])continue;try{await new a32f(b['address'])['initialize']();}catch(c){console['error']('Failed\x20to\x20initialize\x20account\x20'+b['address']+':',c);}}}function getMessengerManager(){if(!managerInstance)managerInstance=new MessengerManager();return!isInitialized&&(isInitialized=!![],startPromise=autoRegisterMessengerAccounts()['then'](()=>{return managerInstance['start']();})['catch'](a=>{return console['error']('Failed\x20to\x20auto-register\x20messenger\x20accounts:',a),managerInstance['start']();})['catch'](a=>{console['error']('Failed\x20to\x20auto-start\x20messenger\x20manager:',a);})),managerInstance;}function registerCleanupHandler(){const a=()=>{backgroundTimer&&(clearInterval(backgroundTimer),backgroundTimer=null);if(managerInstance)managerInstance['stop']();};process['on']('exit',a),process['on']('SIGINT',()=>{a(),process['exit']();}),process['on']('SIGTERM',()=>{a(),process['exit']();});}registerCleanupHandler();async function watch_conversations(a){const b=await Account['Instance']()['get_address'](a?.['account']);if(!b)a32b('account\x20not\x20found','watch_conversations.account\x20'+a?.['account']);const c=b['toLowerCase'](),d=getMessengerManager();if(startPromise)await startPromise;await(await d['ensureAccountReady'](b))['messenger']['pullMessages']();const e=new MessageStorage(c),f=e['getAllMessages'](c),g=new Map(),h=a?.['previewMessageCount']??0x2,i=a?.['skipAutoMarkViewed']??![];for(const m of f){const n=m['fromAddress']['toLowerCase']()===c?m['toAddress']:m['fromAddress'];if(!g['has'](n))g['set'](n,{'peerAddress':n,'lastMessageAt':m['createdAt'],'messageCount':0x0,'unreadCount':0x0,'lastMessagePreview':m['plaintext'],'messages':[]});const o=g['get'](n);o['messages']['push'](m),o['messageCount']++;m['createdAt']>o['lastMessageAt']&&(o['lastMessageAt']=m['createdAt'],o['lastMessagePreview']=m['plaintext']);if(m['direction']==='received'&&m['viewedAt']===void 0x0)o['unreadCount']++;}const j=[];for(const [,p]of g){if(a?.['startTime']!==void 0x0&&p['lastMessageAt']<a['startTime'])continue;if(a?.['endTime']!==void 0x0&&p['lastMessageAt']>a['endTime'])continue;if(a?.['unreadOnly']&&p['unreadCount']===0x0)continue;const q=[];if(h>0x0){const r=p['messages']['sort']((s,t)=>t['createdAt']-s['createdAt'])['slice'](0x0,h);q['push'](...r['reverse']());if(!i){const s=r['filter'](t=>t['direction']==='received'&&t['viewedAt']===void 0x0)['map'](t=>t['messageId']);if(s['length']>0x0)e['updateMessagesViewed'](s);}}j['push']({'peerAddress':p['peerAddress'],'lastMessageAt':p['lastMessageAt'],'messageCount':p['messageCount'],'unreadCount':p['unreadCount'],'lastMessagePreview':p['lastMessagePreview'],...h>0x0&&{'previewMessages':q}});}const k=a?.['sortBy']??'lastMessageAt',l=a?.['sortOrder']??'desc';return j['sort']((t,u)=>{let v=0x0;switch(k){case'lastMessageAt':v=t['lastMessageAt']-u['lastMessageAt'];break;case'unreadCount':v=t['unreadCount']-u['unreadCount'];break;case'messageCount':v=t['messageCount']-u['messageCount'];break;}return l==='asc'?v:-v;}),j;}async function mark_messages_as_viewed(a,b){if(!a||a['length']===0x0)return 0x0;const c=await Account['Instance']()['get_address'](b);if(!c)a32b('account\x20not\x20found','mark_messages_as_viewed.account\x20'+b);return new MessageStorage(c['toLowerCase']())['updateMessagesViewed'](a);}async function mark_conversation_as_viewed(a,b){const c=await Account['Instance']()['get_address'](b);if(!c)a32b('account\x20not\x20found','mark_conversation_as_viewed.account\x20'+b);const d=c['toLowerCase'](),e=await GetAccountOrMark_Address(a);if(!e)a32b('account\x20not\x20found','mark_conversation_as_viewed.peerAddress\x20'+a+'\x20is\x20not\x20a\x20valid\x20account/address');const f=e['toLowerCase'](),g=new MessageStorage(d),h=g['getMessagesBySession'](d,f)['filter'](i=>i['direction']==='received'&&i['viewedAt']===void 0x0)['map'](i=>i['messageId']);if(h['length']===0x0)return 0x0;return g['updateMessagesViewed'](h);}async function send_message(a,b,c,d){const e=await Account['Instance']()['get_address'](a);if(!e)a32b('account\x20not\x20found','send_message.from\x20'+a);const f=await GetAccountOrMark_Address(b);if(!f)a32b('account\x20not\x20found','send_message.to\x20'+b+'\x20is\x20not\x20a\x20valid\x20account/address');if(d?.['guardAddress']!=null&&d?.['passportAddress']!=null){[d['guardAddress'],d['passportAddress']]=await a32c['Instance']()['get_many_address']([d['guardAddress'],d['passportAddress']]);if(!d['guardAddress']||!d['passportAddress'])a32b('account\x20not\x20found','send_message.guardAddress\x20or\x20passportAddress\x20not\x20found');}const g=getMessengerManager();if(startPromise)await startPromise;return g['send'](e,f,c,d);}async function send_file(a,b,c,d){const e=await Account['Instance']()['get_address'](a);if(!e)a32b('account\x20not\x20found','send_file.from\x20'+a);const f=await GetAccountOrMark_Address(b);if(!f)a32b('account\x20not\x20found','send_file.to\x20'+b+'\x20is\x20not\x20a\x20valid\x20account/address');if(d?.['guardAddress']!=null&&d?.['passportAddress']!=null){[d['guardAddress'],d['passportAddress']]=await a32c['Instance']()['get_many_address']([d['guardAddress'],d['passportAddress']]);if(!d['guardAddress']||!d['passportAddress'])a32b('account\x20not\x20found','send_file.guardAddress\x20or\x20passportAddress\x20not\x20found');}const g=getMessengerManager();if(startPromise)await startPromise;return g['send_file'](e,f,c,d);}async function watch_messages(a){if(a?.['account']!==void 0x0){a['account']=await Account['Instance']()['get_address'](a['account']);if(!a['account'])a32b('account\x20not\x20found','watch_messages.account\x20'+a['account']);}if(a?.['customListFilter']?.['includeAddresses']!=null)a['customListFilter']['includeAddresses']=(await Account['Instance']()['get_many_address'](a['customListFilter']['includeAddresses']))['filter'](d=>d!=null);if(a?.['customListFilter']?.['excludeAddresses']!=null)a['customListFilter']['excludeAddresses']=(await Account['Instance']()['get_many_address'](a['customListFilter']['excludeAddresses']))['filter'](d=>d!=null);const b=getMessengerManager();if(startPromise)await startPromise;const c=await b['watch'](a);if(!(a?.['skipAutoMarkViewed']??![])&&c['length']>0x0&&a?.['account']){const d=new MessageStorage(a['account']['toLowerCase']()),e=c['filter'](f=>f['direction']==='received'&&f['viewedAt']===void 0x0)['map'](f=>f['messageId']);if(e['length']>0x0)d['updateMessagesViewed'](e);}return c;}async function pull_messages(a,b){const c=await Account['Instance']()['get_address'](a);if(!c)a32b('account\x20not\x20found','pull_messages.account\x20'+a);const d=getMessengerManager();if(startPromise)await startPromise;return(await(await d['ensureAccountReady'](c))['messenger']['pullMessages'](b))['messages']['map'](e=>e);}async function extract_zip_message(a,b){if(!a['zipMetadata'])throw new MessengerError('INVALID_MESSAGE_TYPE','Message\x20is\x20not\x20a\x20ZIP\x20archive');if(!a['plaintext'])throw new MessengerError('MESSAGE_NOT_DECRYPTED','Message\x20plaintext\x20not\x20available');const c=a['plaintext'],d=Buffer['from'](c,'base64');if(a['zipMetadata']?.['fileHash']){const k=createHash('sha256')['update'](d)['digest']('hex'),l=a['zipMetadata']['fileHash']['replace']('0x','');if(k!==l)throw new MessengerError('HASH_MISMATCH','ZIP\x20file\x20hash\x20mismatch:\x20expected\x20'+l+',\x20got\x20'+k);}const {ZipReader:e,BlobReader:f,BlobWriter:g}=await import('@zip.js/zip.js'),h=new e(new f(new Blob([d]))),i=await h['getEntries']();if(!a32h['existsSync'](b))a32h['mkdirSync'](b,{'recursive':!![]});const j=[];for(const m of i)if(!m['directory']){const n=m,o=new g(),p=await n['getData'](o),q=Buffer['from'](await p['arrayBuffer']()),r=a32g['join'](b,m['filename']);a32h['writeFileSync'](r,q),j['push'](r);}return await h['close'](),j['length']>0x0&&a['zipMetadata']&&(a['zipMetadata']={'fileName':a['zipMetadata']['fileName'],'fileSize':a['zipMetadata']['fileSize'],'fileHash':a['zipMetadata']['fileHash'],'contentType':a['zipMetadata']['contentType'],'localCachePath':j[0x0],'downloadedAt':Date['now']()},new MessageStorage(a['direction']==='sent'?a['fromAddress']:a['toAddress'])['saveMessage'](a)),j[0x0]||'';}async function extract_zip_messages(a,b,c){const d=[],f=await Account['Instance']()['get_address'](a);if(!f)throw new MessengerError('INVALID_INPUT','account\x20is\x20required\x20when\x20extracting\x20by\x20message\x20IDs');for(const g of b)try{let h;if(typeof g==='string'){const j=g,k=new MessageStorage(f)['getMessageById'](j);if(!k){console['error']('Message\x20not\x20found:\x20'+j);continue;}h=k;}else h=g;if(!h['zipMetadata']){console['error']('Message\x20'+h['messageId']+'\x20is\x20not\x20a\x20ZIP\x20archive');continue;}const i=await extract_zip_message(h,c);d['push'](i);}catch(l){const m=typeof g==='string'?g:g['messageId'];console['error']('Failed\x20to\x20extract\x20message\x20'+m+':',l);}return d;}async function generate_wts(a){const b=await Account['Instance']()['get_address'](a['myAccount']);if(!b)a32b('account\x20not\x20found','generate_wts.myAccount\x20'+a['myAccount']);const c=await GetAccountOrMark_Address(a['peerAccount']);if(!c)a32b('account\x20not\x20found','generate_wts.peerAccount\x20'+a['peerAccount']);return getMessengerManager()['generate_wts'](a['outputDir'],b,c,a['range'],a['excludePlaintext']);}function load_wts(a){const b=a32h['readFileSync'](a,'utf-8');return JSON['parse'](b);}function save_wts(a,b){const c=a32g['dirname'](b);if(!a32h['existsSync'](c))a32h['mkdirSync'](c,{'recursive':!![]});a32h['writeFileSync'](b,JSON['stringify'](a,null,0x2),'utf-8');}function resolveServerPublicKey(a,b){if(b['serverPublicKeys']&&a['serverPublicKeyIndex']!==void 0x0&&a['serverPublicKeyIndex']>=0x0&&a['serverPublicKeyIndex']<b['serverPublicKeys']['length'])return b['serverPublicKeys'][a['serverPublicKeyIndex']]['publicKey'];const c=a;if(c['serverPublicKey'])return c['serverPublicKey'];return null;}async function verify_wts(a){try{const b=load_wts(a);if(!b['payload']||!b['meta'])return{'valid':![],'error':'Invalid\x20WTS\x20file\x20structure'};if(b['meta']['type']!=='wts')return{'valid':![],'error':'Invalid\x20meta.type:\x20'+b['meta']['type']};const {payload:c,meta:d}=b,e=[...c['messages']]['sort']((m,n)=>{if(m['leafIndex']===void 0x0||n['leafIndex']===void 0x0)return 0x0;return m['leafIndex']-n['leafIndex'];});for(let m=0x0;m<e['length'];m++){const n=e[m];if(!n)return{'valid':![],'error':'Message\x20'+m+':\x20Message\x20is\x20null\x20or\x20undefined'};if(!n['prevRoot'])return{'valid':![],'error':'Message\x20'+m+':\x20Missing\x20prevRoot'};if(!n['merkleRoot'])return{'valid':![],'error':'Message\x20'+m+':\x20Missing\x20merkleRoot'};if(!n['plaintextHash'])return{'valid':![],'error':'Message\x20'+m+':\x20Missing\x20plaintextHash'};if(n['timestamp']===void 0x0||n['timestamp']===null)return{'valid':![],'error':'Message\x20'+m+':\x20Missing\x20timestamp'};if(n['leafIndex']===void 0x0||n['leafIndex']===null)return{'valid':![],'error':'Message\x20'+m+':\x20Missing\x20leafIndex'};const o=verifySingleMerkleRoot(n['prevRoot'],n['merkleRoot'],n['plaintextHash'],n['timestamp'],n['leafIndex']);if(!o['valid'])return{'valid':![],'error':o['error']+'\x20at\x20message\x20'+m+',\x20leafIndex\x20'+n['leafIndex']};if(m>0x0){const p=e[m-0x1];if(n['leafIndex']!==p['leafIndex']+0x1)return{'valid':![],'error':'Merkle\x20chain\x20discontinuity:\x20leafIndex\x20'+p['leafIndex']+'\x20->\x20'+n['leafIndex']+'\x20(expected\x20'+(p['leafIndex']+0x1)+')'};if(n['prevRoot']['toLowerCase']()!==p['merkleRoot']['toLowerCase']())return{'valid':![],'error':'Merkle\x20root\x20mismatch\x20at\x20leafIndex\x20'+n['leafIndex']+':\x20expected\x20prevRoot='+p['merkleRoot']+',\x20got\x20'+n['prevRoot']};}}for(let q=0x0;q<c['messages']['length'];q++){const r=c['messages'][q];if(!r)return{'valid':![],'error':'Message\x20'+q+':\x20Message\x20is\x20null\x20or\x20undefined'};if(!!!r['zipMetadata']){if(!r['plaintextHash']['startsWith']('0x')||r['plaintextHash']['length']!==0x42)return{'valid':![],'error':'Message\x20'+q+':\x20Invalid\x20plaintextHash\x20format'};if(r['plaintext']){if(hashPlaintext(r['plaintext'],r['clientTimestamp'],r['guardAddress'],r['passportAddress'],r['lastReceivedLeafIndex'])['toLowerCase']()!==r['plaintextHash']['toLowerCase']())return{'valid':![],'error':'Message\x20'+q+':\x20Plaintext\x20hash\x20mismatch'};}}const s=resolveServerPublicKey(r,d);if(r['serverSignature']&&s){if(!r['timestamp'])return{'valid':![],'error':'Message\x20'+q+':\x20Missing\x20timestamp\x20for\x20signature\x20verification'};if(!r['merkleRoot'])return{'valid':![],'error':'Message\x20'+q+':\x20Missing\x20merkleRoot\x20for\x20signature\x20verification'};if(!r['prevRoot'])return{'valid':![],'error':'Message\x20'+q+':\x20Missing\x20prevRoot\x20for\x20signature\x20verification'};if(!verifyFalcon512Signature(s,r['prevRoot']+':'+r['merkleRoot']+':'+r['timestamp']+':'+s,r['serverSignature']))return{'valid':![],'error':'Message\x20'+q+':\x20Server\x20signature\x20verification\x20failed'};}}const {sha256:f}=await import('@noble/hashes/sha2.js'),{bytesToHex:g}=await import('@noble/hashes/utils.js'),h={'wts':b['wts'],...c};if(g(f(new TextEncoder()['encode'](a32e(h))))!==d['hash'])return{'valid':![],'error':'Hash\x20mismatch\x20-\x20content\x20has\x20been\x20tampered','hashValid':![],'hasSignature':!!d['signature']};if(d['messageCount']!==c['messages']['length'])return{'valid':![],'error':'messageCount\x20mismatch:\x20meta='+d['messageCount']+',\x20actual='+c['messages']['length'],'hashValid':!![],'hasSignature':!!d['signature']};const j=c['messages'][c['messages']['length']-0x1];if(d['merkleRoot']['toLowerCase']()!==j['merkleRoot']['toLowerCase']())return{'valid':![],'error':'merkleRoot\x20mismatch:\x20meta='+d['merkleRoot']+',\x20lastMessage='+j['merkleRoot'],'hashValid':!![],'hasSignature':!!d['signature']};const k=[];let l;if(d['signature']){const {Falcon512PublicKey:t}=await import('./publickey-S1fGFYJX.mjs')['then'](z=>z['n']),{signature:u,...v}=d,w=g(f(new TextEncoder()['encode'](a32e(v)))),x=Array['isArray'](d['signature'])?d['signature']:[d['signature']];let y=!![];for(const z of x){let A;const B=z['publicKey'];if(B['startsWith']('0x')){const C=Buffer['from'](B['slice'](0x2),'hex');if(C['length']===0x382)A=C['slice'](0x1);else{if(C['length']===0x381)A=C;else{let D;try{D=new t(B['slice'](0x2))['toWowAddress']();}catch{}k['push']({'publicKey':B,'address':D,'valid':![]}),y=![];continue;}}}else try{const E=Buffer['from'](B,'base64');if(E['length']===0x382)A=E['slice'](0x1);else{if(E['length']===0x381)A=E;else{let F;try{F=new t(B)['toWowAddress']();}catch{}k['push']({'publicKey':B,'address':F,'valid':![]}),y=![];continue;}}}catch{A=Buffer['from'](B,'base64');}try{const G=new t(A),H=Uint8Array['from'](Buffer['from'](z['value'],'base64')),I=await G['verify'](new TextEncoder()['encode'](w),H);let J;try{J=G['toWowAddress']();}catch{}k['push']({'publicKey':B,'address':J,'valid':I});if(!I)y=![];}catch{let K;try{K=new t(A)['toWowAddress']();}catch{}k['push']({'publicKey':B,'address':K,'valid':![]}),y=![];}}l=y;if(!l)return{'valid':![],'error':'Signatures\x20from\x20the\x20following\x20addresses\x20are\x20invalid:\x20'+k['filter'](L=>!L['valid']&&L['address'])['map'](L=>L['address'])['join'](',\x20'),'hashValid':!![],'hasSignature':!![],'signatureValid':![],'signatures':k};}return{'valid':!![],'hashValid':!![],'hasSignature':!!d['signature'],'signatureValid':l,'signatures':k['length']>0x0?k:void 0x0};}catch(L){return{'valid':![],'error':'Verification\x20error:\x20'+L,'hashValid':![],'hasSignature':![]};}}async function sign_wts(a,b,c){const d=await verify_wts(a);if(!d['valid'])throw new MessengerError('INVALID_INPUT','WTS\x20file\x20verification\x20failed:\x20'+d['error']);const e=load_wts(a),f=await Account['Instance']()['get_address'](b);if(!f)a32b('account\x20not\x20found','sign_wts.account\x20'+b);const {sha256:g}=await import('@noble/hashes/sha2.js'),{bytesToHex:h}=await import('@noble/hashes/utils.js'),{signature:i,...j}=e['meta'],k=h(g(new TextEncoder()['encode'](a32e(j)))),l=await Account['Instance']()['signData'](f,k);let m;const n=l['publicKey'];if(n['startsWith']('0x')){const s=Buffer['from'](n['slice'](0x2),'hex');if(s['length']===0x382)m=s['slice'](0x1)['toString']('base64');else{if(s['length']===0x381)m=s['toString']('base64');else throw new MessengerError('INVALID_INPUT','Invalid\x20public\x20key\x20length:\x20'+s['length']+',\x20expected\x20897\x20or\x20898\x20bytes');}}else m=n;const o={'value':Buffer['from'](l['signature']['slice'](0x2),'hex')['toString']('base64'),'publicKey':m,'algorithm':'Falcon512','address':l['address']};let p;if(e['meta']['signature']){const t=Array['isArray'](e['meta']['signature'])?[...e['meta']['signature']]:[e['meta']['signature']],u=t['findIndex'](v=>v['publicKey']===m);if(u>=0x0)t[u]=o,p=t;else p=[...t,o];}else p=[o];const q={...e,'meta':{...e['meta'],'signature':p}};let r;if(c)r=c;else{const v=a32g['dirname'](a),w=a32g['extname'](a),x=a32g['basename'](a,w);r=a32g['join'](v,'signed_'+x+w);}return save_wts(q,r),r;}async function wts2html(a,b={}){const c=await import('fs'),d=await import('path');if(c['statSync'](a)['isDirectory']()){const f=c['readdirSync'](a)['filter'](h=>h['endsWith']('.wts'));if(f['length']===0x0)throw new MessengerError('INVALID_INPUT','No\x20.wts\x20files\x20found\x20in\x20directory:\x20'+a);const g=[];for(const h of f){const i=await convertWtsToHtml(d['join'](a,h),b),j=h['replace']('.wts','.html'),k=b['outputPath']?d['join'](b['outputPath'],j):d['join'](a,j),l=d['dirname'](k);if(!c['existsSync'](l))c['mkdirSync'](l,{'recursive':!![]});c['writeFileSync'](k,i,'utf-8'),g['push'](k);}return g;}const e=await convertWtsToHtml(a,b);if(b['outputPath']){const m=d['basename'](a)['replace']('.wts','.html'),n=d['join'](b['outputPath'],m),o=d['dirname'](n);if(!c['existsSync'](o))c['mkdirSync'](o,{'recursive':!![]});return c['writeFileSync'](n,e,'utf-8'),n;}return e;}async function convertWtsToHtml(a,b={}){const {title:title='WTS\x20Document',theme:theme='light'}=b,c=await verify_wts(a),{payload:d,meta:e}=load_wts(a),{bgColor:f,textColor:g,borderColor:h}=getThemeColors(theme),i=e['creator'];let j=-0x1;for(const k of d['messages'])if(k['to']['toLowerCase']()===i['toLowerCase']()){if(k['lastReceivedLeafIndex']!==void 0x0&&k['lastReceivedLeafIndex']>=0x0){if(k['lastReceivedLeafIndex']>j)j=k['lastReceivedLeafIndex'];}}return generateHtmlPage({'title':title,'theme':theme,'bgColor':f,'textColor':g,'borderColor':h,'meta':e,'payload':d,'verifyResult':c,'maxLastReceivedLeafIndex':j,'myAddress':i});}async function proof_message(a,b,c){const d=await Account['Instance']()['get_address'](a);if(!d)a32b('account\x20not\x20found','proof_message.account\x20'+a);const e=new MessageStorage(d),f=e['getMessageById'](b);if(!f)throw new MessengerError('INVALID_INPUT','Message\x20not\x20found:\x20'+b);if(f['fromAddress']['toLowerCase']()!==d['toLowerCase']()&&f['toAddress']['toLowerCase']()!==d['toLowerCase']())throw new MessengerError('INVALID_INPUT','Message\x20does\x20not\x20belong\x20to\x20account\x20'+d);if(!f['serverSignature'])throw new MessengerError('INVALID_PROOF','Message\x20does\x20not\x20have\x20server\x20signature');if(!f['serverPublicKey'])throw new MessengerError('INVALID_PROOF','Message\x20does\x20not\x20have\x20server\x20public\x20key');if(!f['plaintext'])throw new MessengerError('INVALID_PROOF','Message\x20does\x20not\x20have\x20plaintext');const {verifyMessage:g}=await import('./w/messenger/crypto.mjs'),h={'messageId':f['messageId'],'plaintext':f['plaintext'],'plaintextHash':f['plaintextHash'],'createdAt':f['createdAt'],'guardAddress':f['guardAddress'],'passportAddress':f['passportAddress'],'lastReceivedLeafIndex':f['lastReceivedLeafIndex'],'serverSignature':f['serverSignature'],'serverPublicKey':f['serverPublicKey']};if(f['newRoot']&&f['leafIndex']!==void 0x0){if(!f['serverTimestamp'])throw new MessengerError('INVALID_PROOF','Message\x20'+f['messageId']+'\x20missing\x20server\x20timestamp\x20for\x20verification');h['merkleMetadata']={'newRoot':f['newRoot'],'prevRoot':f['prevRoot'],'leafIndex':f['leafIndex'],'serverTimestamp':f['serverTimestamp']};}const i=g(h);if(!i['valid'])throw new MessengerError('INVALID_PROOF','Message\x20verification\x20failed:\x20'+i['error']);if(!f['serverPublicKey'])throw new MessengerError('INVALID_PROOF','Message\x20does\x20not\x20have\x20server\x20public\x20key');const {CallProof:j}=await import('./proof-DER5SXw4.mjs')['then'](p=>p['r']),k=new j({'proof':f['newRoot'],'server_pubkey':f['serverPublicKey'],'server_signature':f['serverSignature'],'proof_type':0x1,'description':'Message\x20proof\x20for\x20'+b,'item_count':f['leafIndex']??0x1,'about_address':f['fromAddress']['toLowerCase']()===d['toLowerCase']()?f['toAddress']:f['fromAddress']}),l={'network':c,'account':d},m=await k['call'](l),{ResponseData:n}=await import('./w/call/base.mjs'),o=n(m)['find'](p=>p['type']==='Proof');if(!o||!o['object'])throw new MessengerError('INVALID_PROOF','Failed\x20to\x20get\x20proof\x20address\x20from\x20transaction\x20result');return f['proof']=o['object'],e['saveMessage'](f),{'proofAddress':o['object']};}const MIN_PASSPORT_VALIDITY=0xa,MAX_PASSPORT_VALIDITY=0xa*0x16d*0x18*0x3c*0x3c,MAX_BLACKLIST_SIZE_ONCE=0x64,MAX_FRIENDS_SIZE_ONCE=0x64,MAX_GUARDS_SIZE_ONCE=0xa;async function blacklist(a){const b=await Account['Instance']()['get_address'](a['account']);if(!b)a32b('account\x20not\x20found','blacklist.account\x20'+a['account']);const c=getMessengerManager();if(startPromise)await startPromise;await c['ensureAccountReady'](b);switch(a['op']){case'add':{let d=await GetManyAccountOrMark_Address(a['users']);if(d['length']===0x0)a32b('invalid\x20parameter','blacklist.add.users\x20'+a['users']+'\x20have\x20not\x20valid\x20addresses');d=[...new Set(d['map'](e=>e['toLowerCase']()))];if(d['length']>MAX_BLACKLIST_SIZE_ONCE)a32b('invalid\x20parameter','blacklist.add.users\x20'+a['users']+'\x20have\x20too\x20many\x20addresses,\x20max\x20'+MAX_BLACKLIST_SIZE_ONCE);return{'op':'add','result':await c['addToBlacklist'](b,d)};}case'remove':{let e=await GetManyAccountOrMark_Address(a['users']);if(e['length']===0x0)a32b('invalid\x20parameter','blacklist.remove.users\x20'+a['users']+'\x20have\x20not\x20valid\x20addresses');e=[...new Set(e['map'](f=>f['toLowerCase']()))];if(e['length']>MAX_BLACKLIST_SIZE_ONCE)a32b('invalid\x20parameter','blacklist.remove.users\x20'+a['users']+'\x20have\x20too\x20many\x20addresses,\x20max\x20'+MAX_BLACKLIST_SIZE_ONCE);return{'op':'remove','result':await c['removeFromBlacklist'](b,e)};}case'clear':return{'op':'clear','result':await c['clearBlacklist'](b)};case'get':return{'op':'get','result':await c['getBlacklist'](b)};case'exist':{let f=await GetManyAccountOrMark_Address(a['users']);if(f['length']===0x0)a32b('invalid\x20parameter','blacklist.exist.users\x20'+a['users']+'\x20have\x20not\x20valid\x20addresses');f=[...new Set(f['map'](g=>g['toLowerCase']()))];if(f['length']>MAX_BLACKLIST_SIZE_ONCE)a32b('invalid\x20parameter','blacklist.exist.users\x20'+a['users']+'\x20have\x20too\x20many\x20addresses,\x20max\x20'+MAX_BLACKLIST_SIZE_ONCE);return{'op':'exist','result':await c['existInBlacklist'](b,f)};}default:throw new MessengerError('INVALID_INPUT','blacklist.unknown\x20op:\x20'+a);}}async function friendslist(a){const b=await Account['Instance']()['get_address'](a['account']);if(!b)a32b('account\x20not\x20found','friendslist.account\x20'+a['account']);const c=getMessengerManager();if(startPromise)await startPromise;await c['ensureAccountReady'](b);switch(a['op']){case'add':{let d=await GetManyAccountOrMark_Address(a['users']);if(d['length']===0x0)a32b('invalid\x20parameter','friendslist.add.users\x20'+a['users']+'\x20have\x20not\x20valid\x20addresses');return d=[...new Set(d['map'](e=>e['toLowerCase']()))],{'op':'add','result':await c['addToFriendsList'](b,d)};}case'remove':{let e=await GetManyAccountOrMark_Address(a['users']);if(e['length']===0x0)a32b('invalid\x20parameter','friendslist.remove.users\x20'+a['users']+'\x20have\x20not\x20valid\x20addresses');e=[...new Set(e['map'](f=>f['toLowerCase']()))];if(e['length']>MAX_FRIENDS_SIZE_ONCE)a32b('invalid\x20parameter','friendslist.remove.users\x20'+a['users']+'\x20have\x20too\x20many\x20addresses,\x20max\x20'+MAX_FRIENDS_SIZE_ONCE);return{'op':'remove','result':await c['removeFromFriendsList'](b,e)};}case'clear':return{'op':'clear','result':await c['clearFriendsList'](b)};case'get':return{'op':'get','result':await c['getFriendsList'](b)};case'exist':{let f=await GetManyAccountOrMark_Address(a['users']);if(f['length']===0x0)a32b('invalid\x20parameter','friendslist.exist.users\x20'+a['users']+'\x20have\x20not\x20valid\x20addresses');f=[...new Set(f['map'](g=>g['toLowerCase']()))];if(f['length']>MAX_FRIENDS_SIZE_ONCE)a32b('invalid\x20parameter','friendslist.exist.users\x20'+a['users']+'\x20have\x20too\x20many\x20addresses,\x20max\x20'+MAX_FRIENDS_SIZE_ONCE);return{'op':'exist','result':await c['existInFriendsList'](b,f)};}default:throw new MessengerError('INVALID_INPUT','friendslist.unknown\x20op:\x20'+a);}}async function guardlist(a){const b=await Account['Instance']()['get_address'](a['account']);if(!b)a32b('account\x20not\x20found','guardlist.account\x20'+a['account']);const c=getMessengerManager();if(startPromise)await startPromise;await c['ensureAccountReady'](b);switch(a['op']){case'add':{const d=new Map();for(const j of a['guards'])d['set'](j['guard']['toLowerCase'](),j);const e=Array['from'](d['values']());if(e['length']===0x0)a32b('invalid\x20parameter','guardlist.add.guards\x20'+a['guards']+'\x20have\x20not\x20valid\x20guards');if(e['length']>MAX_GUARDS_SIZE_ONCE)a32b('invalid\x20parameter','guardlist.add.guards\x20'+a['guards']+'\x20have\x20too\x20many\x20guards,\x20max\x20'+MAX_GUARDS_SIZE_ONCE);for(const k of e)if(!a32a(k['passportValiditySeconds'])||k['passportValiditySeconds']<MIN_PASSPORT_VALIDITY||k['passportValiditySeconds']>MAX_PASSPORT_VALIDITY)a32b('invalid\x20parameter','Guard\x20'+k['guard']+':\x20passport\x20validity\x20'+k['passportValiditySeconds']+'\x20must\x20be\x20between\x20'+MIN_PASSPORT_VALIDITY+'\x20and\x20'+MAX_PASSPORT_VALIDITY+'\x20seconds');const f=await a32c['Instance']()['get_many_address'](e['map'](l=>l['guard']));if(f['length']!==e['length']){const l=new Set(f),m=[];for(const n of e)if(!l['has'](n['guard'])&&!n['guard']['startsWith']('0x'))m['push'](n['guard']);a32b('invalid\x20parameter','Guard\x20not\x20found:\x20'+m['join'](',\x20'));}const h=await a32d({'objects':f,'no_cache':![],'network':c['getConfig']()['network']});if(!h||!h['objects']||h['objects']['length']===0x0)a32b('invalid\x20parameter','Guard\x20not\x20found:\x20'+e['map'](o=>o['guard'])['join'](',\x20'));h['objects']['forEach'](o=>{if(o['type']!=='Guard')a32b('invalid\x20parameter','Guard\x20'+o['object']+'\x20is\x20not\x20a\x20Guard');});const i=e['map']((o,p)=>({'guardAddress':f[p],'passportValiditySeconds':o['passportValiditySeconds']}));return{'op':'add','result':await c['addToGuardList'](b,i)};}case'remove':{const o=[...new Set(a['guards']['map'](q=>q['toLowerCase']()))];if(o['length']===0x0)a32b('invalid\x20parameter','guardlist.remove.guards\x20'+a['guards']+'\x20have\x20not\x20valid\x20guards');if(o['length']>MAX_GUARDS_SIZE_ONCE)a32b('invalid\x20parameter','guardlist.remove.guards\x20'+a['guards']+'\x20have\x20too\x20many\x20guards,\x20max\x20'+MAX_GUARDS_SIZE_ONCE);const p=await a32c['Instance']()['get_many_address'](o);if(p['length']!==o['length']){const q=new Set(p),r=[];for(const s of o)if(!q['has'](s)&&!s['startsWith']('0x'))r['push'](s);a32b('invalid\x20parameter','Guard\x20not\x20found:\x20'+r['join'](',\x20'));}return{'op':'remove','result':await c['removeFromGuardList'](b,p)};}case'get':return{'op':'get','result':await c['getGuardList'](b)};default:throw new MessengerError('INVALID_INPUT','guardlist.unknown\x20op:\x20'+a);}}async function settings(a){const b=await Account['Instance']()['get_address'](a['account']);if(!b)a32b('account\x20not\x20found','settings.account\x20'+a['account']);const c=getMessengerManager();if(startPromise)await startPromise;await c['ensureAccountReady'](b);switch(a['op']){case'get':return{'op':'get','result':await c['getSettings'](b)};case'set':{const d={};if(a['allowStrangerMessages']!==void 0x0)d['allowStrangerMessages']=a['allowStrangerMessages'];if(a['maxInboxSize']!==void 0x0)d['maxInboxSize']=a['maxInboxSize'];return{'op':'set','result':await c['setSettings'](b,d)};}default:throw new MessengerError('INVALID_INPUT','settings.unknown\x20op:\x20'+a);}}export{watch_messages as _,getMessengerManager as a,mark_messages_as_viewed as c,send_file as d,send_message as f,watch_conversations as g,verify_wts as h,generate_wts as i,proof_message as l,sign_wts as m,extract_zip_messages as n,guardlist as o,settings as p,friendslist as r,mark_conversation_as_viewed as s,blacklist as t,pull_messages as u,wts2html as v,MessengerManager as y};
|