@djvlc/runtime-web 1.1.0 → 1.1.1

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.
@@ -1,4 +1,4 @@
1
- const RUNTIME_VERSION = "1.0.6";
1
+ const RUNTIME_VERSION = "1.1.0";
2
2
  var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
3
3
  ErrorCode2["SYSTEM_INTERNAL_ERROR"] = "SYSTEM_INTERNAL_ERROR";
4
4
  ErrorCode2["SYSTEM_SERVICE_UNAVAILABLE"] = "SYSTEM_SERVICE_UNAVAILABLE";
@@ -991,42 +991,2221 @@ var ALL_BUILTIN_FUNCTIONS = [
991
991
  ...FORMAT_FUNCTIONS
992
992
  ];
993
993
  ALL_BUILTIN_FUNCTIONS.map((f2) => f2.name);
994
- var i = class extends Error {
995
- constructor(t3, s, i2, n2) {
996
- super(s || ErrorMessages[t3] || "Unknown error"), this.name = "DjvlcRuntimeError", this.code = t3, this.details = i2, this.traceId = n2, this.timestamp = Date.now();
994
+ var BaseClientError = class extends Error {
995
+ constructor(message) {
996
+ super(message);
997
+ this.name = this.constructor.name;
998
+ this.timestamp = /* @__PURE__ */ new Date();
999
+ Object.setPrototypeOf(this, new.target.prototype);
1000
+ if (Error.captureStackTrace) {
1001
+ Error.captureStackTrace(this, this.constructor);
1002
+ }
1003
+ }
1004
+ /**
1005
+ * 转换为 JSON 对象(用于日志和序列化)
1006
+ */
1007
+ toJSON() {
1008
+ return {
1009
+ name: this.name,
1010
+ type: this.type,
1011
+ message: this.message,
1012
+ retryable: this.retryable,
1013
+ timestamp: this.timestamp.toISOString(),
1014
+ stack: this.stack
1015
+ };
1016
+ }
1017
+ /**
1018
+ * 转换为字符串
1019
+ */
1020
+ toString() {
1021
+ return `${this.name}: ${this.message}`;
1022
+ }
1023
+ };
1024
+ var NetworkError = class _NetworkError extends BaseClientError {
1025
+ constructor(message, cause) {
1026
+ super(message);
1027
+ this.type = "NETWORK_ERROR";
1028
+ this.retryable = true;
1029
+ this.cause = cause;
1030
+ }
1031
+ toJSON() {
1032
+ return {
1033
+ ...super.toJSON(),
1034
+ cause: this.cause ? {
1035
+ name: this.cause.name,
1036
+ message: this.cause.message
1037
+ } : void 0
1038
+ };
1039
+ }
1040
+ /**
1041
+ * 类型守卫:判断是否为 NetworkError
1042
+ */
1043
+ static is(error) {
1044
+ return error instanceof _NetworkError;
1045
+ }
1046
+ /**
1047
+ * 从原生 fetch 错误创建 NetworkError
1048
+ */
1049
+ static fromFetchError(error) {
1050
+ const message = error.message.toLowerCase();
1051
+ if (message.includes("network") || message.includes("failed to fetch")) {
1052
+ return new _NetworkError("Network request failed", error);
1053
+ }
1054
+ if (message.includes("dns") || message.includes("getaddrinfo")) {
1055
+ return new _NetworkError("DNS resolution failed", error);
1056
+ }
1057
+ if (message.includes("connection refused") || message.includes("econnrefused")) {
1058
+ return new _NetworkError("Connection refused", error);
1059
+ }
1060
+ if (message.includes("connection reset") || message.includes("econnreset")) {
1061
+ return new _NetworkError("Connection reset", error);
1062
+ }
1063
+ if (message.includes("ssl") || message.includes("certificate")) {
1064
+ return new _NetworkError("SSL/TLS error", error);
1065
+ }
1066
+ return new _NetworkError(error.message || "Unknown network error", error);
1067
+ }
1068
+ };
1069
+ var TimeoutError = class _TimeoutError extends BaseClientError {
1070
+ constructor(timeoutMs) {
1071
+ super(`Request timeout after ${timeoutMs}ms`);
1072
+ this.type = "TIMEOUT_ERROR";
1073
+ this.retryable = true;
1074
+ this.timeoutMs = timeoutMs;
1075
+ }
1076
+ toJSON() {
1077
+ return {
1078
+ ...super.toJSON(),
1079
+ timeoutMs: this.timeoutMs
1080
+ };
1081
+ }
1082
+ /**
1083
+ * 类型守卫:判断是否为 TimeoutError
1084
+ */
1085
+ static is(error) {
1086
+ return error instanceof _TimeoutError;
1087
+ }
1088
+ };
1089
+ var BearerAuthenticator = class {
1090
+ constructor(config) {
1091
+ this.type = "bearer";
1092
+ this.getToken = config.getToken;
1093
+ this.headerName = config.headerName ?? "Authorization";
1094
+ this.prefix = config.prefix ?? "Bearer";
1095
+ }
1096
+ async authenticate(headers) {
1097
+ const token = await this.getToken();
1098
+ if (token !== null && token !== "") {
1099
+ headers[this.headerName] = `${this.prefix} ${token}`;
1100
+ }
1101
+ }
1102
+ };
1103
+ var ApiKeyAuthenticator = class {
1104
+ constructor(config) {
1105
+ this.type = "api-key";
1106
+ this.apiKey = config.apiKey;
1107
+ this.headerName = config.headerName ?? "X-API-Key";
1108
+ }
1109
+ authenticate(headers) {
1110
+ headers[this.headerName] = this.apiKey;
1111
+ }
1112
+ };
1113
+ function encodeBase64(str) {
1114
+ const utf8Bytes = new TextEncoder().encode(str);
1115
+ const binaryString = Array.from(utf8Bytes, (byte) => String.fromCharCode(byte)).join("");
1116
+ return typeof btoa !== "undefined" ? btoa(binaryString) : (() => {
1117
+ throw new Error("Base64 encoding is not supported in this environment");
1118
+ })();
1119
+ }
1120
+ var BasicAuthenticator = class {
1121
+ constructor(config) {
1122
+ this.type = "basic";
1123
+ this.encodedCredentials = encodeBase64(`${config.username}:${config.password}`);
1124
+ }
1125
+ authenticate(headers) {
1126
+ headers["Authorization"] = `Basic ${this.encodedCredentials}`;
1127
+ }
1128
+ };
1129
+ var CustomAuthenticator = class {
1130
+ constructor(config) {
1131
+ this.type = "custom";
1132
+ this.authenticateFn = config.authenticate;
1133
+ }
1134
+ async authenticate(headers) {
1135
+ await this.authenticateFn(headers);
1136
+ }
1137
+ };
1138
+ var NoAuthenticator = class {
1139
+ constructor() {
1140
+ this.type = "none";
1141
+ }
1142
+ authenticate(_headers) {
1143
+ }
1144
+ };
1145
+ var noAuthenticator = new NoAuthenticator();
1146
+ function createAuthenticatorFromConfig(config) {
1147
+ switch (config.type) {
1148
+ case "bearer":
1149
+ return new BearerAuthenticator({ getToken: config.getToken, headerName: config.headerName, prefix: config.prefix });
1150
+ case "api-key":
1151
+ return new ApiKeyAuthenticator({ apiKey: config.apiKey, headerName: config.headerName });
1152
+ case "basic":
1153
+ return new BasicAuthenticator({ username: config.username, password: config.password });
1154
+ case "custom":
1155
+ return new CustomAuthenticator({ authenticate: config.authenticate });
1156
+ case "none":
1157
+ return noAuthenticator;
1158
+ default: {
1159
+ const _exhaustiveCheck = config;
1160
+ throw new Error(`Unknown auth type: ${_exhaustiveCheck.type}`);
1161
+ }
1162
+ }
1163
+ }
1164
+ function generateRequestId() {
1165
+ const timestamp = Date.now().toString(36);
1166
+ const random = Math.random().toString(36).slice(2, 9);
1167
+ return `req_${timestamp}_${random}`;
1168
+ }
1169
+ function generateTraceId$1() {
1170
+ const timestamp = Date.now().toString(36);
1171
+ const random1 = Math.random().toString(36).slice(2, 9);
1172
+ const random2 = Math.random().toString(36).slice(2, 9);
1173
+ return `trace_${timestamp}_${random1}_${random2}`;
1174
+ }
1175
+ function sleep(ms) {
1176
+ return new Promise((resolve) => setTimeout(resolve, ms));
1177
+ }
1178
+ function generateUniqueRequestKey() {
1179
+ return `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
1180
+ }
1181
+ var REQUEST_KEY_HEADER = "X-Internal-Request-Key";
1182
+ var retryStateMap = /* @__PURE__ */ new Map();
1183
+ function getRequestKey(init) {
1184
+ const headers = init.headers;
1185
+ return (headers == null ? void 0 : headers[REQUEST_KEY_HEADER]) ?? "";
1186
+ }
1187
+ function createMiddlewares(config = {}) {
1188
+ var _a, _b, _c;
1189
+ const middlewares = [];
1190
+ middlewares.push(createRequestMiddleware(config));
1191
+ if (config.logger) {
1192
+ middlewares.push(createLoggingMiddleware(config.logger, config.debug ?? false));
1193
+ }
1194
+ if (config.enableRetry !== false && config.retry) {
1195
+ middlewares.push(createRetryMiddleware(config));
1196
+ }
1197
+ if ((_a = config.preMiddlewares) == null ? void 0 : _a.length) {
1198
+ for (const preFn of config.preMiddlewares) {
1199
+ middlewares.push({ pre: preFn });
1200
+ }
1201
+ }
1202
+ if ((_b = config.postMiddlewares) == null ? void 0 : _b.length) {
1203
+ for (const postFn of config.postMiddlewares) {
1204
+ middlewares.push({ post: postFn });
1205
+ }
1206
+ }
1207
+ if ((_c = config.errorMiddlewares) == null ? void 0 : _c.length) {
1208
+ for (const errorFn of config.errorMiddlewares) {
1209
+ middlewares.push({ onError: errorFn });
1210
+ }
1211
+ }
1212
+ return middlewares;
1213
+ }
1214
+ function createRequestMiddleware(config) {
1215
+ const authenticator = config.auth ? createAuthenticatorFromConfig(config.auth) : noAuthenticator;
1216
+ return {
1217
+ async pre(context) {
1218
+ const requestId = generateRequestId();
1219
+ const traceId = generateTraceId$1();
1220
+ const requestKey = generateUniqueRequestKey();
1221
+ retryStateMap.set(requestKey, {
1222
+ attempt: 0,
1223
+ startTime: Date.now(),
1224
+ requestId,
1225
+ traceId
1226
+ });
1227
+ const existingHeaders = context.init.headers ?? {};
1228
+ const headers = {};
1229
+ if (existingHeaders instanceof Headers) {
1230
+ existingHeaders.forEach((value, key) => {
1231
+ headers[key] = value;
1232
+ });
1233
+ } else if (Array.isArray(existingHeaders)) {
1234
+ for (const [key, value] of existingHeaders) {
1235
+ headers[key] = value;
1236
+ }
1237
+ } else {
1238
+ Object.assign(headers, existingHeaders);
1239
+ }
1240
+ headers[REQUEST_KEY_HEADER] = requestKey;
1241
+ headers["X-Request-ID"] = requestId;
1242
+ headers["X-Trace-ID"] = traceId;
1243
+ if (config.headers) {
1244
+ Object.assign(headers, config.headers);
1245
+ }
1246
+ await authenticator.authenticate(headers);
1247
+ return {
1248
+ url: context.url,
1249
+ init: {
1250
+ ...context.init,
1251
+ headers
1252
+ }
1253
+ };
1254
+ }
1255
+ };
1256
+ }
1257
+ function createLoggingMiddleware(logger, debugMode) {
1258
+ return {
1259
+ async pre(context) {
1260
+ var _a;
1261
+ if (!debugMode) return void 0;
1262
+ const method = context.init.method ?? "GET";
1263
+ const requestId = ((_a = context.init.headers) == null ? void 0 : _a["X-Request-ID"]) ?? "";
1264
+ logger.debug(`[Request] ${method} ${context.url}`, { requestId });
1265
+ return void 0;
1266
+ },
1267
+ async post(context) {
1268
+ var _a;
1269
+ const requestKey = getRequestKey(context.init);
1270
+ const state = retryStateMap.get(requestKey);
1271
+ const duration = state ? Date.now() - state.startTime : 0;
1272
+ if (requestKey) {
1273
+ retryStateMap.delete(requestKey);
1274
+ }
1275
+ if (!debugMode) return void 0;
1276
+ const method = context.init.method ?? "GET";
1277
+ const requestId = ((_a = context.init.headers) == null ? void 0 : _a["X-Request-ID"]) ?? "";
1278
+ logger.debug(`[Response] ${method} ${context.url} - ${context.response.status} (${duration}ms)`, {
1279
+ requestId,
1280
+ status: context.response.status,
1281
+ duration
1282
+ });
1283
+ return void 0;
1284
+ },
1285
+ async onError(context) {
1286
+ var _a;
1287
+ const method = context.init.method ?? "GET";
1288
+ const requestId = ((_a = context.init.headers) == null ? void 0 : _a["X-Request-ID"]) ?? "";
1289
+ const requestKey = getRequestKey(context.init);
1290
+ const state = retryStateMap.get(requestKey);
1291
+ const duration = state ? Date.now() - state.startTime : 0;
1292
+ const errorMessage = context.error instanceof Error ? context.error.message : String(context.error);
1293
+ logger.error(`[Error] ${method} ${context.url} - ${errorMessage} (${duration}ms)`, {
1294
+ requestId,
1295
+ error: errorMessage,
1296
+ duration
1297
+ });
1298
+ return void 0;
1299
+ }
1300
+ };
1301
+ }
1302
+ function createRetryMiddleware(config) {
1303
+ const retryConfig = config.retry;
1304
+ const maxRetries = retryConfig.maxRetries;
1305
+ const logger = config.logger;
1306
+ const debug = config.debug ?? false;
1307
+ return {
1308
+ async onError(context) {
1309
+ const requestKey = getRequestKey(context.init);
1310
+ const state = retryStateMap.get(requestKey);
1311
+ if (!state) {
1312
+ return void 0;
1313
+ }
1314
+ if (!shouldRetry(context.error, state.attempt, maxRetries, retryConfig)) {
1315
+ retryStateMap.delete(requestKey);
1316
+ return void 0;
1317
+ }
1318
+ state.attempt++;
1319
+ const delay = calculateRetryDelay2(state.attempt, retryConfig);
1320
+ if (retryConfig.onRetry) {
1321
+ const method = context.init.method ?? "GET";
1322
+ retryConfig.onRetry({
1323
+ attempt: state.attempt,
1324
+ maxRetries,
1325
+ delayMs: delay,
1326
+ error: context.error instanceof Error ? context.error : new Error(String(context.error)),
1327
+ url: context.url,
1328
+ method
1329
+ });
1330
+ }
1331
+ if (debug && logger) {
1332
+ const method = context.init.method ?? "GET";
1333
+ logger.debug(`[Retry] ${method} ${context.url} - attempt ${state.attempt}/${maxRetries}, delay ${delay}ms`);
1334
+ }
1335
+ await sleep(delay);
1336
+ try {
1337
+ const response = await context.fetch(context.url, context.init);
1338
+ if (!response.ok && shouldRetryStatus(response.status, state.attempt, maxRetries, retryConfig)) {
1339
+ state.attempt++;
1340
+ const nextDelay = calculateRetryDelay2(state.attempt, retryConfig);
1341
+ if (debug && logger) {
1342
+ const method = context.init.method ?? "GET";
1343
+ logger.debug(`[Retry] ${method} ${context.url} - status ${response.status}, attempt ${state.attempt}/${maxRetries}, delay ${nextDelay}ms`);
1344
+ }
1345
+ await sleep(nextDelay);
1346
+ return context.fetch(context.url, context.init);
1347
+ }
1348
+ retryStateMap.delete(requestKey);
1349
+ return response;
1350
+ } catch (retryError) {
1351
+ if (state.attempt < maxRetries) {
1352
+ throw retryError;
1353
+ }
1354
+ retryStateMap.delete(requestKey);
1355
+ throw retryError;
1356
+ }
1357
+ }
1358
+ };
1359
+ }
1360
+ function shouldRetry(error, attempt, maxRetries, retryConfig) {
1361
+ if (attempt >= maxRetries) return false;
1362
+ if (error instanceof Error && error.name === "AbortError") {
1363
+ return false;
1364
+ }
1365
+ if (error instanceof TypeError || error instanceof NetworkError) {
1366
+ return retryConfig.retryOnNetworkError !== false;
1367
+ }
1368
+ if (error instanceof TimeoutError) {
1369
+ return retryConfig.retryOnTimeout !== false;
1370
+ }
1371
+ return true;
1372
+ }
1373
+ function shouldRetryStatus(status, attempt, maxRetries, retryConfig) {
1374
+ if (attempt >= maxRetries) return false;
1375
+ const retryableCodes = retryConfig.retryableStatusCodes ?? [429, 500, 502, 503, 504];
1376
+ return retryableCodes.includes(status);
1377
+ }
1378
+ function calculateRetryDelay2(attempt, retryConfig) {
1379
+ const {
1380
+ initialDelayMs = 1e3,
1381
+ maxDelayMs = 3e4,
1382
+ backoffStrategy = "exponential",
1383
+ jitterFactor = 0.1
1384
+ } = retryConfig;
1385
+ let delay;
1386
+ switch (backoffStrategy) {
1387
+ case "fixed":
1388
+ delay = initialDelayMs;
1389
+ break;
1390
+ case "linear":
1391
+ delay = initialDelayMs * attempt;
1392
+ break;
1393
+ case "exponential":
1394
+ default:
1395
+ delay = initialDelayMs * Math.pow(2, attempt - 1);
1396
+ break;
1397
+ }
1398
+ delay = Math.min(delay, maxDelayMs);
1399
+ if (jitterFactor > 0) {
1400
+ const jitter = delay * jitterFactor * (Math.random() * 2 - 1);
1401
+ delay = Math.max(0, delay + jitter);
1402
+ }
1403
+ return Math.round(delay);
1404
+ }
1405
+ var BASE_PATH = "/api/user".replace(/\/+$/, "");
1406
+ var Configuration = class {
1407
+ constructor(configuration = {}) {
1408
+ this.configuration = configuration;
1409
+ }
1410
+ set config(configuration) {
1411
+ this.configuration = configuration;
1412
+ }
1413
+ get basePath() {
1414
+ return this.configuration.basePath != null ? this.configuration.basePath : BASE_PATH;
1415
+ }
1416
+ get fetchApi() {
1417
+ return this.configuration.fetchApi;
1418
+ }
1419
+ get middleware() {
1420
+ return this.configuration.middleware || [];
1421
+ }
1422
+ get queryParamsStringify() {
1423
+ return this.configuration.queryParamsStringify || querystring;
1424
+ }
1425
+ get username() {
1426
+ return this.configuration.username;
1427
+ }
1428
+ get password() {
1429
+ return this.configuration.password;
1430
+ }
1431
+ get apiKey() {
1432
+ const apiKey = this.configuration.apiKey;
1433
+ if (apiKey) {
1434
+ return typeof apiKey === "function" ? apiKey : () => apiKey;
1435
+ }
1436
+ return void 0;
1437
+ }
1438
+ get accessToken() {
1439
+ const accessToken = this.configuration.accessToken;
1440
+ if (accessToken) {
1441
+ return typeof accessToken === "function" ? accessToken : async () => accessToken;
1442
+ }
1443
+ return void 0;
1444
+ }
1445
+ get headers() {
1446
+ return this.configuration.headers;
1447
+ }
1448
+ get credentials() {
1449
+ return this.configuration.credentials;
1450
+ }
1451
+ };
1452
+ var DefaultConfig = new Configuration();
1453
+ var _BaseAPI = class _BaseAPI2 {
1454
+ constructor(configuration = DefaultConfig) {
1455
+ this.configuration = configuration;
1456
+ this.fetchApi = async (url, init) => {
1457
+ let fetchParams = { url, init };
1458
+ for (const middleware of this.middleware) {
1459
+ if (middleware.pre) {
1460
+ fetchParams = await middleware.pre({
1461
+ fetch: this.fetchApi,
1462
+ ...fetchParams
1463
+ }) || fetchParams;
1464
+ }
1465
+ }
1466
+ let response = void 0;
1467
+ try {
1468
+ response = await (this.configuration.fetchApi || fetch)(fetchParams.url, fetchParams.init);
1469
+ } catch (e) {
1470
+ for (const middleware of this.middleware) {
1471
+ if (middleware.onError) {
1472
+ response = await middleware.onError({
1473
+ fetch: this.fetchApi,
1474
+ url: fetchParams.url,
1475
+ init: fetchParams.init,
1476
+ error: e,
1477
+ response: response ? response.clone() : void 0
1478
+ }) || response;
1479
+ }
1480
+ }
1481
+ if (response === void 0) {
1482
+ if (e instanceof Error) {
1483
+ throw new FetchError(e, "The request failed and the interceptors did not return an alternative response");
1484
+ } else {
1485
+ throw e;
1486
+ }
1487
+ }
1488
+ }
1489
+ for (const middleware of this.middleware) {
1490
+ if (middleware.post) {
1491
+ response = await middleware.post({
1492
+ fetch: this.fetchApi,
1493
+ url: fetchParams.url,
1494
+ init: fetchParams.init,
1495
+ response: response.clone()
1496
+ }) || response;
1497
+ }
1498
+ }
1499
+ return response;
1500
+ };
1501
+ this.middleware = configuration.middleware;
1502
+ }
1503
+ withMiddleware(...middlewares) {
1504
+ const next = this.clone();
1505
+ next.middleware = next.middleware.concat(...middlewares);
1506
+ return next;
1507
+ }
1508
+ withPreMiddleware(...preMiddlewares) {
1509
+ const middlewares = preMiddlewares.map((pre) => ({ pre }));
1510
+ return this.withMiddleware(...middlewares);
1511
+ }
1512
+ withPostMiddleware(...postMiddlewares) {
1513
+ const middlewares = postMiddlewares.map((post) => ({ post }));
1514
+ return this.withMiddleware(...middlewares);
1515
+ }
1516
+ /**
1517
+ * Check if the given MIME is a JSON MIME.
1518
+ * JSON MIME examples:
1519
+ * application/json
1520
+ * application/json; charset=UTF8
1521
+ * APPLICATION/JSON
1522
+ * application/vnd.company+json
1523
+ * @param mime - MIME (Multipurpose Internet Mail Extensions)
1524
+ * @return True if the given MIME is JSON, false otherwise.
1525
+ */
1526
+ isJsonMime(mime) {
1527
+ if (!mime) {
1528
+ return false;
1529
+ }
1530
+ return _BaseAPI2.jsonRegex.test(mime);
1531
+ }
1532
+ async request(context, initOverrides) {
1533
+ const { url, init } = await this.createFetchParams(context, initOverrides);
1534
+ const response = await this.fetchApi(url, init);
1535
+ if (response && (response.status >= 200 && response.status < 300)) {
1536
+ return response;
1537
+ }
1538
+ throw new ResponseError(response, "Response returned an error code");
1539
+ }
1540
+ async createFetchParams(context, initOverrides) {
1541
+ let url = this.configuration.basePath + context.path;
1542
+ if (context.query !== void 0 && Object.keys(context.query).length !== 0) {
1543
+ url += "?" + this.configuration.queryParamsStringify(context.query);
1544
+ }
1545
+ const headers = Object.assign({}, this.configuration.headers, context.headers);
1546
+ Object.keys(headers).forEach((key) => headers[key] === void 0 ? delete headers[key] : {});
1547
+ const initOverrideFn = typeof initOverrides === "function" ? initOverrides : async () => initOverrides;
1548
+ const initParams = {
1549
+ method: context.method,
1550
+ headers,
1551
+ body: context.body,
1552
+ credentials: this.configuration.credentials
1553
+ };
1554
+ const overriddenInit = {
1555
+ ...initParams,
1556
+ ...await initOverrideFn({
1557
+ init: initParams,
1558
+ context
1559
+ })
1560
+ };
1561
+ let body;
1562
+ if (isFormData(overriddenInit.body) || overriddenInit.body instanceof URLSearchParams || isBlob(overriddenInit.body)) {
1563
+ body = overriddenInit.body;
1564
+ } else if (this.isJsonMime(headers["Content-Type"])) {
1565
+ body = JSON.stringify(overriddenInit.body);
1566
+ } else {
1567
+ body = overriddenInit.body;
1568
+ }
1569
+ const init = {
1570
+ ...overriddenInit,
1571
+ body
1572
+ };
1573
+ return { url, init };
1574
+ }
1575
+ /**
1576
+ * Create a shallow clone of `this` by constructing a new instance
1577
+ * and then shallow cloning data members.
1578
+ */
1579
+ clone() {
1580
+ const constructor = this.constructor;
1581
+ const next = new constructor(this.configuration);
1582
+ next.middleware = this.middleware.slice();
1583
+ return next;
1584
+ }
1585
+ };
1586
+ _BaseAPI.jsonRegex = new RegExp("^(:?application/json|[^;/ ]+/[^;/ ]+[+]json)[ ]*(:?;.*)?$", "i");
1587
+ var BaseAPI = _BaseAPI;
1588
+ function isBlob(value) {
1589
+ return typeof Blob !== "undefined" && value instanceof Blob;
1590
+ }
1591
+ function isFormData(value) {
1592
+ return typeof FormData !== "undefined" && value instanceof FormData;
1593
+ }
1594
+ var ResponseError = class extends Error {
1595
+ constructor(response, msg) {
1596
+ super(msg);
1597
+ this.response = response;
1598
+ this.name = "ResponseError";
1599
+ }
1600
+ };
1601
+ var FetchError = class extends Error {
1602
+ constructor(cause, msg) {
1603
+ super(msg);
1604
+ this.cause = cause;
1605
+ this.name = "FetchError";
1606
+ }
1607
+ };
1608
+ var RequiredError = class extends Error {
1609
+ constructor(field, msg) {
1610
+ super(msg);
1611
+ this.field = field;
1612
+ this.name = "RequiredError";
1613
+ }
1614
+ };
1615
+ function exists(json, key) {
1616
+ const value = json[key];
1617
+ return value !== null && value !== void 0;
1618
+ }
1619
+ function querystring(params, prefix = "") {
1620
+ return Object.keys(params).map((key) => querystringSingleKey(key, params[key], prefix)).filter((part) => part.length > 0).join("&");
1621
+ }
1622
+ function querystringSingleKey(key, value, keyPrefix = "") {
1623
+ const fullKey = keyPrefix + (keyPrefix.length ? `[${key}]` : key);
1624
+ if (value instanceof Array) {
1625
+ const multiValue = value.map((singleValue) => encodeURIComponent(String(singleValue))).join(`&${encodeURIComponent(fullKey)}=`);
1626
+ return `${encodeURIComponent(fullKey)}=${multiValue}`;
1627
+ }
1628
+ if (value instanceof Set) {
1629
+ const valueAsArray = Array.from(value);
1630
+ return querystringSingleKey(key, valueAsArray, keyPrefix);
1631
+ }
1632
+ if (value instanceof Date) {
1633
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(value.toISOString())}`;
1634
+ }
1635
+ if (value instanceof Object) {
1636
+ return querystring(value, fullKey);
1637
+ }
1638
+ return `${encodeURIComponent(fullKey)}=${encodeURIComponent(String(value))}`;
1639
+ }
1640
+ function mapValues(data, fn) {
1641
+ return Object.keys(data).reduce(
1642
+ (acc, key) => ({ ...acc, [key]: fn(data[key]) }),
1643
+ {}
1644
+ );
1645
+ }
1646
+ var JSONApiResponse = class {
1647
+ constructor(raw, transformer = (jsonValue) => jsonValue) {
1648
+ this.raw = raw;
1649
+ this.transformer = transformer;
1650
+ }
1651
+ async value() {
1652
+ return this.transformer(await this.raw.json());
1653
+ }
1654
+ };
1655
+ function ActionContextToJSON(value) {
1656
+ if (value === void 0) {
1657
+ return void 0;
1658
+ }
1659
+ if (value === null) {
1660
+ return null;
1661
+ }
1662
+ return {
1663
+ "pageVersionId": value.pageVersionId,
1664
+ "componentVersionId": value.componentVersionId,
1665
+ "componentInstanceId": value.componentInstanceId,
1666
+ "triggerEvent": value.triggerEvent,
1667
+ "deviceId": value.deviceId,
1668
+ "channel": value.channel,
1669
+ "clientTimestamp": value.clientTimestamp === void 0 ? void 0 : value.clientTimestamp.toISOString(),
1670
+ "extra": value.extra
1671
+ };
1672
+ }
1673
+ function ActionDefinitionResponseDataFromJSON(json) {
1674
+ return ActionDefinitionResponseDataFromJSONTyped(json);
1675
+ }
1676
+ function ActionDefinitionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
1677
+ if (json === void 0 || json === null) {
1678
+ return json;
1679
+ }
1680
+ return {
1681
+ "actionDefinitionVersionId": !exists(json, "actionDefinitionVersionId") ? void 0 : json["actionDefinitionVersionId"],
1682
+ "actionType": !exists(json, "actionType") ? void 0 : json["actionType"],
1683
+ "name": !exists(json, "name") ? void 0 : json["name"],
1684
+ "paramsSchema": !exists(json, "paramsSchema") ? void 0 : json["paramsSchema"],
1685
+ "resultSchema": !exists(json, "resultSchema") ? void 0 : json["resultSchema"]
1686
+ };
1687
+ }
1688
+ function ActionDefinitionResponseFromJSON(json) {
1689
+ return ActionDefinitionResponseFromJSONTyped(json);
1690
+ }
1691
+ function ActionDefinitionResponseFromJSONTyped(json, ignoreDiscriminator) {
1692
+ if (json === void 0 || json === null) {
1693
+ return json;
1694
+ }
1695
+ return {
1696
+ "data": ActionDefinitionResponseDataFromJSON(json["data"])
1697
+ };
1698
+ }
1699
+ function ActionEffectFromJSON(json) {
1700
+ return ActionEffectFromJSONTyped(json);
1701
+ }
1702
+ function ActionEffectFromJSONTyped(json, ignoreDiscriminator) {
1703
+ if (json === void 0 || json === null) {
1704
+ return json;
1705
+ }
1706
+ return {
1707
+ "type": json["type"],
1708
+ "payload": !exists(json, "payload") ? void 0 : json["payload"]
1709
+ };
1710
+ }
1711
+ function BatchQueryRequestQueriesInnerToJSON(value) {
1712
+ if (value === void 0) {
1713
+ return void 0;
1714
+ }
1715
+ if (value === null) {
1716
+ return null;
1717
+ }
1718
+ return {
1719
+ "queryVersionId": value.queryVersionId,
1720
+ "params": value.params,
1721
+ "alias": value.alias
1722
+ };
1723
+ }
1724
+ function QueryContextToJSON(value) {
1725
+ if (value === void 0) {
1726
+ return void 0;
1727
+ }
1728
+ if (value === null) {
1729
+ return null;
1730
+ }
1731
+ return {
1732
+ "pageVersionId": value.pageVersionId,
1733
+ "componentVersionId": value.componentVersionId
1734
+ };
1735
+ }
1736
+ function BatchQueryRequestToJSON(value) {
1737
+ if (value === void 0) {
1738
+ return void 0;
1739
+ }
1740
+ if (value === null) {
1741
+ return null;
1742
+ }
1743
+ return {
1744
+ "queries": value.queries.map(BatchQueryRequestQueriesInnerToJSON),
1745
+ "context": QueryContextToJSON(value.context)
1746
+ };
1747
+ }
1748
+ function BatchQueryResponseDataValueErrorFromJSON(json) {
1749
+ return BatchQueryResponseDataValueErrorFromJSONTyped(json);
1750
+ }
1751
+ function BatchQueryResponseDataValueErrorFromJSONTyped(json, ignoreDiscriminator) {
1752
+ if (json === void 0 || json === null) {
1753
+ return json;
1754
+ }
1755
+ return {
1756
+ "code": !exists(json, "code") ? void 0 : json["code"],
1757
+ "message": !exists(json, "message") ? void 0 : json["message"]
1758
+ };
1759
+ }
1760
+ function BatchQueryResponseDataValueFromJSON(json) {
1761
+ return BatchQueryResponseDataValueFromJSONTyped(json);
1762
+ }
1763
+ function BatchQueryResponseDataValueFromJSONTyped(json, ignoreDiscriminator) {
1764
+ if (json === void 0 || json === null) {
1765
+ return json;
1766
+ }
1767
+ return {
1768
+ "success": !exists(json, "success") ? void 0 : json["success"],
1769
+ "data": !exists(json, "data") ? void 0 : json["data"],
1770
+ "error": !exists(json, "error") ? void 0 : BatchQueryResponseDataValueErrorFromJSON(json["error"])
1771
+ };
1772
+ }
1773
+ function BatchQueryResponseFromJSON(json) {
1774
+ return BatchQueryResponseFromJSONTyped(json);
1775
+ }
1776
+ function BatchQueryResponseFromJSONTyped(json, ignoreDiscriminator) {
1777
+ if (json === void 0 || json === null) {
1778
+ return json;
1779
+ }
1780
+ return {
1781
+ "success": json["success"],
1782
+ "data": mapValues(json["data"], BatchQueryResponseDataValueFromJSON)
1783
+ };
1784
+ }
1785
+ function ClaimRecordInfoFromJSON(json) {
1786
+ return ClaimRecordInfoFromJSONTyped(json);
1787
+ }
1788
+ function ClaimRecordInfoFromJSONTyped(json, ignoreDiscriminator) {
1789
+ if (json === void 0 || json === null) {
1790
+ return json;
1791
+ }
1792
+ return {
1793
+ "id": json["id"],
1794
+ "activityId": !exists(json, "activityId") ? void 0 : json["activityId"],
1795
+ "rewardType": json["rewardType"],
1796
+ "rewardName": !exists(json, "rewardName") ? void 0 : json["rewardName"],
1797
+ "rewardValue": !exists(json, "rewardValue") ? void 0 : json["rewardValue"],
1798
+ "status": json["status"],
1799
+ "createdAt": new Date(json["createdAt"]),
1800
+ "claimedAt": !exists(json, "claimedAt") ? void 0 : new Date(json["claimedAt"]),
1801
+ "expiresAt": !exists(json, "expiresAt") ? void 0 : new Date(json["expiresAt"])
1802
+ };
1803
+ }
1804
+ function ExecuteActionRequestToJSON(value) {
1805
+ if (value === void 0) {
1806
+ return void 0;
1807
+ }
1808
+ if (value === null) {
1809
+ return null;
1810
+ }
1811
+ return {
1812
+ "actionType": value.actionType,
1813
+ "actionDefinitionVersionId": value.actionDefinitionVersionId,
1814
+ "params": value.params,
1815
+ "context": ActionContextToJSON(value.context),
1816
+ "idempotencyKey": value.idempotencyKey
1817
+ };
1818
+ }
1819
+ function ExecuteActionResponseAllOfDataFromJSON(json) {
1820
+ return ExecuteActionResponseAllOfDataFromJSONTyped(json);
1821
+ }
1822
+ function ExecuteActionResponseAllOfDataFromJSONTyped(json, ignoreDiscriminator) {
1823
+ if (json === void 0 || json === null) {
1824
+ return json;
1825
+ }
1826
+ return {
1827
+ "actionId": !exists(json, "actionId") ? void 0 : json["actionId"],
1828
+ "result": !exists(json, "result") ? void 0 : json["result"],
1829
+ "effects": !exists(json, "effects") ? void 0 : json["effects"].map(ActionEffectFromJSON),
1830
+ "errorCode": !exists(json, "errorCode") ? void 0 : json["errorCode"],
1831
+ "errorMessage": !exists(json, "errorMessage") ? void 0 : json["errorMessage"],
1832
+ "errorDetails": !exists(json, "errorDetails") ? void 0 : json["errorDetails"],
1833
+ "requestId": !exists(json, "requestId") ? void 0 : json["requestId"],
1834
+ "traceId": !exists(json, "traceId") ? void 0 : json["traceId"],
1835
+ "duration": !exists(json, "duration") ? void 0 : json["duration"],
1836
+ "retryable": !exists(json, "retryable") ? void 0 : json["retryable"],
1837
+ "retryAfter": !exists(json, "retryAfter") ? void 0 : json["retryAfter"]
1838
+ };
1839
+ }
1840
+ function ExecuteActionResponseFromJSON(json) {
1841
+ return ExecuteActionResponseFromJSONTyped(json);
1842
+ }
1843
+ function ExecuteActionResponseFromJSONTyped(json, ignoreDiscriminator) {
1844
+ if (json === void 0 || json === null) {
1845
+ return json;
1846
+ }
1847
+ return {
1848
+ "success": json["success"],
1849
+ "code": json["code"],
1850
+ "message": json["message"],
1851
+ "data": ExecuteActionResponseAllOfDataFromJSON(json["data"]),
1852
+ "timestamp": json["timestamp"],
1853
+ "path": json["path"],
1854
+ "requestId": !exists(json, "requestId") ? void 0 : json["requestId"]
1855
+ };
1856
+ }
1857
+ function PublicActivityInfoRewardsInnerFromJSON(json) {
1858
+ return PublicActivityInfoRewardsInnerFromJSONTyped(json);
1859
+ }
1860
+ function PublicActivityInfoRewardsInnerFromJSONTyped(json, ignoreDiscriminator) {
1861
+ if (json === void 0 || json === null) {
1862
+ return json;
1863
+ }
1864
+ return {
1865
+ "name": !exists(json, "name") ? void 0 : json["name"],
1866
+ "description": !exists(json, "description") ? void 0 : json["description"],
1867
+ "icon": !exists(json, "icon") ? void 0 : json["icon"]
1868
+ };
1869
+ }
1870
+ function PublicActivityInfoFromJSON(json) {
1871
+ return PublicActivityInfoFromJSONTyped(json);
1872
+ }
1873
+ function PublicActivityInfoFromJSONTyped(json, ignoreDiscriminator) {
1874
+ if (json === void 0 || json === null) {
1875
+ return json;
1876
+ }
1877
+ return {
1878
+ "id": json["id"],
1879
+ "name": json["name"],
1880
+ "type": json["type"],
1881
+ "status": json["status"],
1882
+ "description": !exists(json, "description") ? void 0 : json["description"],
1883
+ "startTime": !exists(json, "startTime") ? void 0 : new Date(json["startTime"]),
1884
+ "endTime": !exists(json, "endTime") ? void 0 : new Date(json["endTime"]),
1885
+ "rules": !exists(json, "rules") ? void 0 : json["rules"],
1886
+ "rewards": !exists(json, "rewards") ? void 0 : json["rewards"].map(PublicActivityInfoRewardsInnerFromJSON)
1887
+ };
1888
+ }
1889
+ function GetActivityInfo200ResponseFromJSON(json) {
1890
+ return GetActivityInfo200ResponseFromJSONTyped(json);
1891
+ }
1892
+ function GetActivityInfo200ResponseFromJSONTyped(json, ignoreDiscriminator) {
1893
+ if (json === void 0 || json === null) {
1894
+ return json;
1895
+ }
1896
+ return {
1897
+ "success": !exists(json, "success") ? void 0 : json["success"],
1898
+ "data": !exists(json, "data") ? void 0 : PublicActivityInfoFromJSON(json["data"])
1899
+ };
1900
+ }
1901
+ function UserActivityStateTypeStateOneOfAvailablePrizesInnerFromJSON(json) {
1902
+ return UserActivityStateTypeStateOneOfAvailablePrizesInnerFromJSONTyped(json);
1903
+ }
1904
+ function UserActivityStateTypeStateOneOfAvailablePrizesInnerFromJSONTyped(json, ignoreDiscriminator) {
1905
+ if (json === void 0 || json === null) {
1906
+ return json;
1907
+ }
1908
+ return {
1909
+ "prizeId": !exists(json, "prizeId") ? void 0 : json["prizeId"],
1910
+ "name": !exists(json, "name") ? void 0 : json["name"],
1911
+ "stock": !exists(json, "stock") ? void 0 : json["stock"]
1912
+ };
1913
+ }
1914
+ function UserActivityStateTypeStateOneOfFromJSONTyped(json, ignoreDiscriminator) {
1915
+ if (json === void 0 || json === null) {
1916
+ return json;
1917
+ }
1918
+ return {
1919
+ "type": json["type"],
1920
+ "claimed": json["claimed"],
1921
+ "claimedAt": !exists(json, "claimedAt") ? void 0 : new Date(json["claimedAt"]),
1922
+ "claimedPrizeId": !exists(json, "claimedPrizeId") ? void 0 : json["claimedPrizeId"],
1923
+ "availablePrizes": !exists(json, "availablePrizes") ? void 0 : json["availablePrizes"].map(UserActivityStateTypeStateOneOfAvailablePrizesInnerFromJSON)
1924
+ };
1925
+ }
1926
+ function UserActivityStateTypeStateOneOf1CycleRecordsInnerFromJSON(json) {
1927
+ return UserActivityStateTypeStateOneOf1CycleRecordsInnerFromJSONTyped(json);
1928
+ }
1929
+ function UserActivityStateTypeStateOneOf1CycleRecordsInnerFromJSONTyped(json, ignoreDiscriminator) {
1930
+ if (json === void 0 || json === null) {
1931
+ return json;
1932
+ }
1933
+ return {
1934
+ "dayKey": !exists(json, "dayKey") ? void 0 : json["dayKey"],
1935
+ "signed": !exists(json, "signed") ? void 0 : json["signed"],
1936
+ "isMakeup": !exists(json, "isMakeup") ? void 0 : json["isMakeup"]
1937
+ };
1938
+ }
1939
+ function UserActivityStateTypeStateOneOf1NextRewardFromJSON(json) {
1940
+ return UserActivityStateTypeStateOneOf1NextRewardFromJSONTyped(json);
1941
+ }
1942
+ function UserActivityStateTypeStateOneOf1NextRewardFromJSONTyped(json, ignoreDiscriminator) {
1943
+ if (json === void 0 || json === null) {
1944
+ return json;
1945
+ }
1946
+ return {
1947
+ "type": !exists(json, "type") ? void 0 : json["type"],
1948
+ "daysNeeded": !exists(json, "daysNeeded") ? void 0 : json["daysNeeded"],
1949
+ "reward": !exists(json, "reward") ? void 0 : json["reward"]
1950
+ };
1951
+ }
1952
+ function UserActivityStateTypeStateOneOf1FromJSONTyped(json, ignoreDiscriminator) {
1953
+ if (json === void 0 || json === null) {
1954
+ return json;
1955
+ }
1956
+ return {
1957
+ "type": json["type"],
1958
+ "signedToday": json["signedToday"],
1959
+ "todaySignedAt": !exists(json, "todaySignedAt") ? void 0 : new Date(json["todaySignedAt"]),
1960
+ "consecutiveDays": json["consecutiveDays"],
1961
+ "totalDays": json["totalDays"],
1962
+ "cycleRecords": json["cycleRecords"].map(UserActivityStateTypeStateOneOf1CycleRecordsInnerFromJSON),
1963
+ "makeupAvailable": json["makeupAvailable"],
1964
+ "nextReward": !exists(json, "nextReward") ? void 0 : UserActivityStateTypeStateOneOf1NextRewardFromJSON(json["nextReward"])
1965
+ };
1966
+ }
1967
+ function UserActivityStateTypeStateOneOf2PityProgressFromJSON(json) {
1968
+ return UserActivityStateTypeStateOneOf2PityProgressFromJSONTyped(json);
1969
+ }
1970
+ function UserActivityStateTypeStateOneOf2PityProgressFromJSONTyped(json, ignoreDiscriminator) {
1971
+ if (json === void 0 || json === null) {
1972
+ return json;
1973
+ }
1974
+ return {
1975
+ "current": !exists(json, "current") ? void 0 : json["current"],
1976
+ "target": !exists(json, "target") ? void 0 : json["target"]
1977
+ };
1978
+ }
1979
+ function UserActivityStateTypeStateOneOf2ResourcesInnerFromJSON(json) {
1980
+ return UserActivityStateTypeStateOneOf2ResourcesInnerFromJSONTyped(json);
1981
+ }
1982
+ function UserActivityStateTypeStateOneOf2ResourcesInnerFromJSONTyped(json, ignoreDiscriminator) {
1983
+ if (json === void 0 || json === null) {
1984
+ return json;
1985
+ }
1986
+ return {
1987
+ "type": !exists(json, "type") ? void 0 : json["type"],
1988
+ "amount": !exists(json, "amount") ? void 0 : json["amount"]
1989
+ };
1990
+ }
1991
+ function UserActivityStateTypeStateOneOf2FromJSONTyped(json, ignoreDiscriminator) {
1992
+ if (json === void 0 || json === null) {
1993
+ return json;
1994
+ }
1995
+ return {
1996
+ "type": json["type"],
1997
+ "freeDrawsRemaining": json["freeDrawsRemaining"],
1998
+ "todayDrawCount": json["todayDrawCount"],
1999
+ "totalDrawCount": json["totalDrawCount"],
2000
+ "pityProgress": !exists(json, "pityProgress") ? void 0 : UserActivityStateTypeStateOneOf2PityProgressFromJSON(json["pityProgress"]),
2001
+ "resources": !exists(json, "resources") ? void 0 : json["resources"].map(UserActivityStateTypeStateOneOf2ResourcesInnerFromJSON)
2002
+ };
2003
+ }
2004
+ function UserActivityStateTypeStateFromJSON(json) {
2005
+ return UserActivityStateTypeStateFromJSONTyped(json);
2006
+ }
2007
+ function UserActivityStateTypeStateFromJSONTyped(json, ignoreDiscriminator) {
2008
+ if (json === void 0 || json === null) {
2009
+ return json;
2010
+ }
2011
+ return { ...UserActivityStateTypeStateOneOfFromJSONTyped(json), ...UserActivityStateTypeStateOneOf1FromJSONTyped(json), ...UserActivityStateTypeStateOneOf2FromJSONTyped(json) };
2012
+ }
2013
+ function UserActivityStateFromJSON(json) {
2014
+ return UserActivityStateFromJSONTyped(json);
2015
+ }
2016
+ function UserActivityStateFromJSONTyped(json, ignoreDiscriminator) {
2017
+ if (json === void 0 || json === null) {
2018
+ return json;
2019
+ }
2020
+ return {
2021
+ "activityId": json["activityId"],
2022
+ "userId": json["userId"],
2023
+ "activityType": json["activityType"],
2024
+ "canParticipate": json["canParticipate"],
2025
+ "notParticipateReason": !exists(json, "notParticipateReason") ? void 0 : json["notParticipateReason"],
2026
+ "remainingCount": !exists(json, "remainingCount") ? void 0 : json["remainingCount"],
2027
+ "typeState": UserActivityStateTypeStateFromJSON(json["typeState"])
2028
+ };
2029
+ }
2030
+ function GetActivityState200ResponseFromJSON(json) {
2031
+ return GetActivityState200ResponseFromJSONTyped(json);
2032
+ }
2033
+ function GetActivityState200ResponseFromJSONTyped(json, ignoreDiscriminator) {
2034
+ if (json === void 0 || json === null) {
2035
+ return json;
2036
+ }
2037
+ return {
2038
+ "success": !exists(json, "success") ? void 0 : json["success"],
2039
+ "data": !exists(json, "data") ? void 0 : UserActivityStateFromJSON(json["data"])
2040
+ };
2041
+ }
2042
+ function PaginationMetaFromJSON(json) {
2043
+ return PaginationMetaFromJSONTyped(json);
2044
+ }
2045
+ function PaginationMetaFromJSONTyped(json, ignoreDiscriminator) {
2046
+ if (json === void 0 || json === null) {
2047
+ return json;
2048
+ }
2049
+ return {
2050
+ "page": json["page"],
2051
+ "limit": json["limit"],
2052
+ "total": json["total"],
2053
+ "totalPages": json["totalPages"]
2054
+ };
2055
+ }
2056
+ function GetClaimRecords200ResponseFromJSON(json) {
2057
+ return GetClaimRecords200ResponseFromJSONTyped(json);
2058
+ }
2059
+ function GetClaimRecords200ResponseFromJSONTyped(json, ignoreDiscriminator) {
2060
+ if (json === void 0 || json === null) {
2061
+ return json;
2062
+ }
2063
+ return {
2064
+ "success": !exists(json, "success") ? void 0 : json["success"],
2065
+ "data": !exists(json, "data") ? void 0 : json["data"].map(ClaimRecordInfoFromJSON),
2066
+ "meta": !exists(json, "meta") ? void 0 : PaginationMetaFromJSON(json["meta"])
2067
+ };
2068
+ }
2069
+ function LotteryRecordInfoFromJSON(json) {
2070
+ return LotteryRecordInfoFromJSONTyped(json);
2071
+ }
2072
+ function LotteryRecordInfoFromJSONTyped(json, ignoreDiscriminator) {
2073
+ if (json === void 0 || json === null) {
2074
+ return json;
2075
+ }
2076
+ return {
2077
+ "id": json["id"],
2078
+ "activityId": !exists(json, "activityId") ? void 0 : json["activityId"],
2079
+ "prizeId": json["prizeId"],
2080
+ "prizeName": !exists(json, "prizeName") ? void 0 : json["prizeName"],
2081
+ "prizeType": !exists(json, "prizeType") ? void 0 : json["prizeType"],
2082
+ "status": json["status"],
2083
+ "createdAt": new Date(json["createdAt"]),
2084
+ "claimedAt": !exists(json, "claimedAt") ? void 0 : new Date(json["claimedAt"])
2085
+ };
2086
+ }
2087
+ function GetLotteryRecords200ResponseFromJSON(json) {
2088
+ return GetLotteryRecords200ResponseFromJSONTyped(json);
2089
+ }
2090
+ function GetLotteryRecords200ResponseFromJSONTyped(json, ignoreDiscriminator) {
2091
+ if (json === void 0 || json === null) {
2092
+ return json;
2093
+ }
2094
+ return {
2095
+ "success": !exists(json, "success") ? void 0 : json["success"],
2096
+ "data": !exists(json, "data") ? void 0 : json["data"].map(LotteryRecordInfoFromJSON),
2097
+ "meta": !exists(json, "meta") ? void 0 : PaginationMetaFromJSON(json["meta"])
2098
+ };
2099
+ }
2100
+ function SigninCalendarRecordsInnerRewardFromJSON(json) {
2101
+ return SigninCalendarRecordsInnerRewardFromJSONTyped(json);
2102
+ }
2103
+ function SigninCalendarRecordsInnerRewardFromJSONTyped(json, ignoreDiscriminator) {
2104
+ if (json === void 0 || json === null) {
2105
+ return json;
2106
+ }
2107
+ return {
2108
+ "name": !exists(json, "name") ? void 0 : json["name"],
2109
+ "amount": !exists(json, "amount") ? void 0 : json["amount"]
2110
+ };
2111
+ }
2112
+ function SigninCalendarRecordsInnerFromJSON(json) {
2113
+ return SigninCalendarRecordsInnerFromJSONTyped(json);
2114
+ }
2115
+ function SigninCalendarRecordsInnerFromJSONTyped(json, ignoreDiscriminator) {
2116
+ if (json === void 0 || json === null) {
2117
+ return json;
2118
+ }
2119
+ return {
2120
+ "day": !exists(json, "day") ? void 0 : json["day"],
2121
+ "signedIn": !exists(json, "signedIn") ? void 0 : json["signedIn"],
2122
+ "reward": !exists(json, "reward") ? void 0 : SigninCalendarRecordsInnerRewardFromJSON(json["reward"])
2123
+ };
2124
+ }
2125
+ function SigninCalendarFromJSON(json) {
2126
+ return SigninCalendarFromJSONTyped(json);
2127
+ }
2128
+ function SigninCalendarFromJSONTyped(json, ignoreDiscriminator) {
2129
+ if (json === void 0 || json === null) {
2130
+ return json;
2131
+ }
2132
+ return {
2133
+ "year": json["year"],
2134
+ "month": json["month"],
2135
+ "records": json["records"].map(SigninCalendarRecordsInnerFromJSON),
2136
+ "consecutiveDays": !exists(json, "consecutiveDays") ? void 0 : json["consecutiveDays"],
2137
+ "totalDays": !exists(json, "totalDays") ? void 0 : json["totalDays"]
2138
+ };
2139
+ }
2140
+ function GetSigninCalendar200ResponseFromJSON(json) {
2141
+ return GetSigninCalendar200ResponseFromJSONTyped(json);
2142
+ }
2143
+ function GetSigninCalendar200ResponseFromJSONTyped(json, ignoreDiscriminator) {
2144
+ if (json === void 0 || json === null) {
2145
+ return json;
2146
+ }
2147
+ return {
2148
+ "success": !exists(json, "success") ? void 0 : json["success"],
2149
+ "data": !exists(json, "data") ? void 0 : SigninCalendarFromJSON(json["data"])
2150
+ };
2151
+ }
2152
+ function OpsConfigBlockedComponentsInnerFromJSON(json) {
2153
+ return OpsConfigBlockedComponentsInnerFromJSONTyped(json);
2154
+ }
2155
+ function OpsConfigBlockedComponentsInnerFromJSONTyped(json, ignoreDiscriminator) {
2156
+ if (json === void 0 || json === null) {
2157
+ return json;
2158
+ }
2159
+ return {
2160
+ "componentName": !exists(json, "componentName") ? void 0 : json["componentName"],
2161
+ "componentVersion": !exists(json, "componentVersion") ? void 0 : json["componentVersion"],
2162
+ "reason": !exists(json, "reason") ? void 0 : json["reason"]
2163
+ };
2164
+ }
2165
+ function OpsConfigFromJSON(json) {
2166
+ return OpsConfigFromJSONTyped(json);
2167
+ }
2168
+ function OpsConfigFromJSONTyped(json, ignoreDiscriminator) {
2169
+ if (json === void 0 || json === null) {
2170
+ return json;
2171
+ }
2172
+ return {
2173
+ "killSwitch": json["killSwitch"],
2174
+ "blockedComponents": json["blockedComponents"].map(OpsConfigBlockedComponentsInnerFromJSON),
2175
+ "flags": json["flags"]
2176
+ };
2177
+ }
2178
+ function QueryDataRequestCacheControlToJSON(value) {
2179
+ if (value === void 0) {
2180
+ return void 0;
2181
+ }
2182
+ if (value === null) {
2183
+ return null;
2184
+ }
2185
+ return {
2186
+ "noCache": value.noCache,
2187
+ "forceRefresh": value.forceRefresh
2188
+ };
2189
+ }
2190
+ function QueryDataRequestToJSON(value) {
2191
+ if (value === void 0) {
2192
+ return void 0;
2193
+ }
2194
+ if (value === null) {
2195
+ return null;
2196
+ }
2197
+ return {
2198
+ "queryVersionId": value.queryVersionId,
2199
+ "params": value.params,
2200
+ "cacheControl": QueryDataRequestCacheControlToJSON(value.cacheControl),
2201
+ "context": QueryContextToJSON(value.context)
2202
+ };
2203
+ }
2204
+ function QueryDataResponseFromJSON(json) {
2205
+ return QueryDataResponseFromJSONTyped(json);
2206
+ }
2207
+ function QueryDataResponseFromJSONTyped(json, ignoreDiscriminator) {
2208
+ if (json === void 0 || json === null) {
2209
+ return json;
2210
+ }
2211
+ return {
2212
+ "success": json["success"],
2213
+ "code": json["code"],
2214
+ "message": json["message"],
2215
+ "data": json["data"],
2216
+ "timestamp": json["timestamp"],
2217
+ "path": json["path"],
2218
+ "requestId": !exists(json, "requestId") ? void 0 : json["requestId"],
2219
+ "errorCode": !exists(json, "errorCode") ? void 0 : json["errorCode"],
2220
+ "errorMessage": !exists(json, "errorMessage") ? void 0 : json["errorMessage"],
2221
+ "fromCache": !exists(json, "fromCache") ? void 0 : json["fromCache"],
2222
+ "cachedAt": !exists(json, "cachedAt") ? void 0 : new Date(json["cachedAt"]),
2223
+ "age": !exists(json, "age") ? void 0 : json["age"],
2224
+ "traceId": !exists(json, "traceId") ? void 0 : json["traceId"],
2225
+ "duration": !exists(json, "duration") ? void 0 : json["duration"],
2226
+ "degraded": !exists(json, "degraded") ? void 0 : json["degraded"],
2227
+ "degradedReason": !exists(json, "degradedReason") ? void 0 : json["degradedReason"]
2228
+ };
2229
+ }
2230
+ function QueryDefinitionResponseDataFromJSON(json) {
2231
+ return QueryDefinitionResponseDataFromJSONTyped(json);
2232
+ }
2233
+ function QueryDefinitionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2234
+ if (json === void 0 || json === null) {
2235
+ return json;
2236
+ }
2237
+ return {
2238
+ "queryVersionId": !exists(json, "queryVersionId") ? void 0 : json["queryVersionId"],
2239
+ "name": !exists(json, "name") ? void 0 : json["name"],
2240
+ "paramsSchema": !exists(json, "paramsSchema") ? void 0 : json["paramsSchema"],
2241
+ "resultSchema": !exists(json, "resultSchema") ? void 0 : json["resultSchema"],
2242
+ "cacheTtl": !exists(json, "cacheTtl") ? void 0 : json["cacheTtl"]
2243
+ };
2244
+ }
2245
+ function QueryDefinitionResponseFromJSON(json) {
2246
+ return QueryDefinitionResponseFromJSONTyped(json);
2247
+ }
2248
+ function QueryDefinitionResponseFromJSONTyped(json, ignoreDiscriminator) {
2249
+ if (json === void 0 || json === null) {
2250
+ return json;
2251
+ }
2252
+ return {
2253
+ "data": QueryDefinitionResponseDataFromJSON(json["data"])
2254
+ };
2255
+ }
2256
+ function ResolvePageResponseAllOfDataRolloutMatchFromJSON(json) {
2257
+ return ResolvePageResponseAllOfDataRolloutMatchFromJSONTyped(json);
2258
+ }
2259
+ function ResolvePageResponseAllOfDataRolloutMatchFromJSONTyped(json, ignoreDiscriminator) {
2260
+ if (json === void 0 || json === null) {
2261
+ return json;
2262
+ }
2263
+ return {
2264
+ "strategyId": !exists(json, "strategyId") ? void 0 : json["strategyId"],
2265
+ "strategyName": !exists(json, "strategyName") ? void 0 : json["strategyName"],
2266
+ "isDefault": !exists(json, "isDefault") ? void 0 : json["isDefault"]
2267
+ };
2268
+ }
2269
+ function ResolvePageResponseAllOfDataSnapshotDefinitionsDigestActionsFromJSON(json) {
2270
+ return ResolvePageResponseAllOfDataSnapshotDefinitionsDigestActionsFromJSONTyped(json);
2271
+ }
2272
+ function ResolvePageResponseAllOfDataSnapshotDefinitionsDigestActionsFromJSONTyped(json, ignoreDiscriminator) {
2273
+ if (json === void 0 || json === null) {
2274
+ return json;
2275
+ }
2276
+ return {
2277
+ "id": !exists(json, "id") ? void 0 : json["id"],
2278
+ "name": !exists(json, "name") ? void 0 : json["name"],
2279
+ "versionId": !exists(json, "versionId") ? void 0 : json["versionId"],
2280
+ "hash": !exists(json, "hash") ? void 0 : json["hash"]
2281
+ };
2282
+ }
2283
+ function ResolvePageResponseAllOfDataSnapshotDefinitionsDigestFromJSON(json) {
2284
+ return ResolvePageResponseAllOfDataSnapshotDefinitionsDigestFromJSONTyped(json);
2285
+ }
2286
+ function ResolvePageResponseAllOfDataSnapshotDefinitionsDigestFromJSONTyped(json, ignoreDiscriminator) {
2287
+ if (json === void 0 || json === null) {
2288
+ return json;
2289
+ }
2290
+ return {
2291
+ "actions": !exists(json, "actions") ? void 0 : json["actions"].map(ResolvePageResponseAllOfDataSnapshotDefinitionsDigestActionsFromJSON),
2292
+ "queries": !exists(json, "queries") ? void 0 : json["queries"].map(ResolvePageResponseAllOfDataSnapshotDefinitionsDigestActionsFromJSON)
2293
+ };
2294
+ }
2295
+ function ResolvePageResponseAllOfDataSnapshotManifestEntrypointsFromJSON(json) {
2296
+ return ResolvePageResponseAllOfDataSnapshotManifestEntrypointsFromJSONTyped(json);
2297
+ }
2298
+ function ResolvePageResponseAllOfDataSnapshotManifestEntrypointsFromJSONTyped(json, ignoreDiscriminator) {
2299
+ if (json === void 0 || json === null) {
2300
+ return json;
2301
+ }
2302
+ return {
2303
+ "js": !exists(json, "js") ? void 0 : json["js"],
2304
+ "css": !exists(json, "css") ? void 0 : json["css"],
2305
+ "chunks": !exists(json, "chunks") ? void 0 : json["chunks"]
2306
+ };
2307
+ }
2308
+ function ResolvePageResponseAllOfDataSnapshotManifestComponentsFromJSON(json) {
2309
+ return ResolvePageResponseAllOfDataSnapshotManifestComponentsFromJSONTyped(json);
2310
+ }
2311
+ function ResolvePageResponseAllOfDataSnapshotManifestComponentsFromJSONTyped(json, ignoreDiscriminator) {
2312
+ if (json === void 0 || json === null) {
2313
+ return json;
2314
+ }
2315
+ return {
2316
+ "name": !exists(json, "name") ? void 0 : json["name"],
2317
+ "version": !exists(json, "version") ? void 0 : json["version"],
2318
+ "integrity": !exists(json, "integrity") ? void 0 : json["integrity"],
2319
+ "assetsUrl": !exists(json, "assetsUrl") ? void 0 : json["assetsUrl"],
2320
+ "entrypoints": !exists(json, "entrypoints") ? void 0 : ResolvePageResponseAllOfDataSnapshotManifestEntrypointsFromJSON(json["entrypoints"])
2321
+ };
2322
+ }
2323
+ function ResolvePageResponseAllOfDataSnapshotManifestRuntimeFromJSON(json) {
2324
+ return ResolvePageResponseAllOfDataSnapshotManifestRuntimeFromJSONTyped(json);
2325
+ }
2326
+ function ResolvePageResponseAllOfDataSnapshotManifestRuntimeFromJSONTyped(json, ignoreDiscriminator) {
2327
+ if (json === void 0 || json === null) {
2328
+ return json;
2329
+ }
2330
+ return {
2331
+ "version": !exists(json, "version") ? void 0 : json["version"],
2332
+ "minVersion": !exists(json, "minVersion") ? void 0 : json["minVersion"]
2333
+ };
2334
+ }
2335
+ function ResolvePageResponseAllOfDataSnapshotManifestFromJSON(json) {
2336
+ return ResolvePageResponseAllOfDataSnapshotManifestFromJSONTyped(json);
2337
+ }
2338
+ function ResolvePageResponseAllOfDataSnapshotManifestFromJSONTyped(json, ignoreDiscriminator) {
2339
+ if (json === void 0 || json === null) {
2340
+ return json;
2341
+ }
2342
+ return {
2343
+ "components": !exists(json, "components") ? void 0 : json["components"].map(ResolvePageResponseAllOfDataSnapshotManifestComponentsFromJSON),
2344
+ "runtime": !exists(json, "runtime") ? void 0 : ResolvePageResponseAllOfDataSnapshotManifestRuntimeFromJSON(json["runtime"])
2345
+ };
2346
+ }
2347
+ function ResolvePageResponseAllOfDataSnapshotMetaBindingsFromJSON(json) {
2348
+ return ResolvePageResponseAllOfDataSnapshotMetaBindingsFromJSONTyped(json);
2349
+ }
2350
+ function ResolvePageResponseAllOfDataSnapshotMetaBindingsFromJSONTyped(json, ignoreDiscriminator) {
2351
+ if (json === void 0 || json === null) {
2352
+ return json;
2353
+ }
2354
+ return {
2355
+ "componentVersions": !exists(json, "componentVersions") ? void 0 : json["componentVersions"],
2356
+ "definitionVersions": !exists(json, "definitionVersions") ? void 0 : json["definitionVersions"]
2357
+ };
2358
+ }
2359
+ function ResolvePageResponseAllOfDataSnapshotMetaFromJSON(json) {
2360
+ return ResolvePageResponseAllOfDataSnapshotMetaFromJSONTyped(json);
2361
+ }
2362
+ function ResolvePageResponseAllOfDataSnapshotMetaFromJSONTyped(json, ignoreDiscriminator) {
2363
+ if (json === void 0 || json === null) {
2364
+ return json;
2365
+ }
2366
+ return {
2367
+ "pageId": !exists(json, "pageId") ? void 0 : json["pageId"],
2368
+ "pageVersionId": !exists(json, "pageVersionId") ? void 0 : json["pageVersionId"],
2369
+ "publishId": !exists(json, "publishId") ? void 0 : json["publishId"],
2370
+ "schemaVersion": !exists(json, "schemaVersion") ? void 0 : json["schemaVersion"],
2371
+ "createdAt": !exists(json, "createdAt") ? void 0 : new Date(json["createdAt"]),
2372
+ "createdBy": !exists(json, "createdBy") ? void 0 : json["createdBy"],
2373
+ "contentHash": !exists(json, "contentHash") ? void 0 : json["contentHash"],
2374
+ "bindings": !exists(json, "bindings") ? void 0 : ResolvePageResponseAllOfDataSnapshotMetaBindingsFromJSON(json["bindings"]),
2375
+ "runtimeVersion": !exists(json, "runtimeVersion") ? void 0 : json["runtimeVersion"],
2376
+ "env": !exists(json, "env") ? void 0 : json["env"]
2377
+ };
2378
+ }
2379
+ function ResolvePageResponseAllOfDataSnapshotPageFromJSON(json) {
2380
+ return ResolvePageResponseAllOfDataSnapshotPageFromJSONTyped(json);
2381
+ }
2382
+ function ResolvePageResponseAllOfDataSnapshotPageFromJSONTyped(json, ignoreDiscriminator) {
2383
+ if (json === void 0 || json === null) {
2384
+ return json;
2385
+ }
2386
+ return {
2387
+ "schemaVersion": !exists(json, "schemaVersion") ? void 0 : json["schemaVersion"],
2388
+ "pageId": !exists(json, "pageId") ? void 0 : json["pageId"],
2389
+ "pageVersion": !exists(json, "pageVersion") ? void 0 : json["pageVersion"],
2390
+ "title": !exists(json, "title") ? void 0 : json["title"],
2391
+ "initialState": !exists(json, "initialState") ? void 0 : json["initialState"],
2392
+ "bindings": !exists(json, "bindings") ? void 0 : json["bindings"],
2393
+ "root": !exists(json, "root") ? void 0 : json["root"],
2394
+ "config": !exists(json, "config") ? void 0 : json["config"]
2395
+ };
2396
+ }
2397
+ function ResolvePageResponseAllOfDataSnapshotFromJSON(json) {
2398
+ return ResolvePageResponseAllOfDataSnapshotFromJSONTyped(json);
2399
+ }
2400
+ function ResolvePageResponseAllOfDataSnapshotFromJSONTyped(json, ignoreDiscriminator) {
2401
+ if (json === void 0 || json === null) {
2402
+ return json;
2403
+ }
2404
+ return {
2405
+ "page": !exists(json, "page") ? void 0 : ResolvePageResponseAllOfDataSnapshotPageFromJSON(json["page"]),
2406
+ "manifest": !exists(json, "manifest") ? void 0 : ResolvePageResponseAllOfDataSnapshotManifestFromJSON(json["manifest"]),
2407
+ "definitionsDigest": !exists(json, "definitionsDigest") ? void 0 : ResolvePageResponseAllOfDataSnapshotDefinitionsDigestFromJSON(json["definitionsDigest"]),
2408
+ "meta": !exists(json, "meta") ? void 0 : ResolvePageResponseAllOfDataSnapshotMetaFromJSON(json["meta"])
2409
+ };
2410
+ }
2411
+ function ResolvePageResponseAllOfDataFromJSON(json) {
2412
+ return ResolvePageResponseAllOfDataFromJSONTyped(json);
2413
+ }
2414
+ function ResolvePageResponseAllOfDataFromJSONTyped(json, ignoreDiscriminator) {
2415
+ if (json === void 0 || json === null) {
2416
+ return json;
2417
+ }
2418
+ return {
2419
+ "pageId": json["pageId"],
2420
+ "resolvedVersionId": json["resolvedVersionId"],
2421
+ "cdnBase": json["cdnBase"],
2422
+ "snapshotUrl": json["snapshotUrl"],
2423
+ "manifestUrl": json["manifestUrl"],
2424
+ "ops": OpsConfigFromJSON(json["ops"]),
2425
+ "etag": json["etag"],
2426
+ "cacheTtlSeconds": json["cacheTtlSeconds"],
2427
+ "rolloutMatch": !exists(json, "rolloutMatch") ? void 0 : ResolvePageResponseAllOfDataRolloutMatchFromJSON(json["rolloutMatch"]),
2428
+ "snapshot": !exists(json, "snapshot") ? void 0 : ResolvePageResponseAllOfDataSnapshotFromJSON(json["snapshot"])
2429
+ };
2430
+ }
2431
+ function ResolvePageResponseFromJSON(json) {
2432
+ return ResolvePageResponseFromJSONTyped(json);
2433
+ }
2434
+ function ResolvePageResponseFromJSONTyped(json, ignoreDiscriminator) {
2435
+ if (json === void 0 || json === null) {
2436
+ return json;
2437
+ }
2438
+ return {
2439
+ "success": json["success"],
2440
+ "code": json["code"],
2441
+ "message": json["message"],
2442
+ "data": ResolvePageResponseAllOfDataFromJSON(json["data"]),
2443
+ "timestamp": json["timestamp"],
2444
+ "path": json["path"],
2445
+ "requestId": !exists(json, "requestId") ? void 0 : json["requestId"]
2446
+ };
2447
+ }
2448
+ function Track202ResponseDataFromJSON(json) {
2449
+ return Track202ResponseDataFromJSONTyped(json);
2450
+ }
2451
+ function Track202ResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2452
+ if (json === void 0 || json === null) {
2453
+ return json;
2454
+ }
2455
+ return {
2456
+ "eventId": !exists(json, "eventId") ? void 0 : json["eventId"]
2457
+ };
2458
+ }
2459
+ function Track202ResponseFromJSON(json) {
2460
+ return Track202ResponseFromJSONTyped(json);
2461
+ }
2462
+ function Track202ResponseFromJSONTyped(json, ignoreDiscriminator) {
2463
+ if (json === void 0 || json === null) {
2464
+ return json;
2465
+ }
2466
+ return {
2467
+ "success": !exists(json, "success") ? void 0 : json["success"],
2468
+ "data": !exists(json, "data") ? void 0 : Track202ResponseDataFromJSON(json["data"])
2469
+ };
2470
+ }
2471
+ function TrackBatch202ResponseDataErrorsInnerFromJSON(json) {
2472
+ return TrackBatch202ResponseDataErrorsInnerFromJSONTyped(json);
2473
+ }
2474
+ function TrackBatch202ResponseDataErrorsInnerFromJSONTyped(json, ignoreDiscriminator) {
2475
+ if (json === void 0 || json === null) {
2476
+ return json;
2477
+ }
2478
+ return {
2479
+ "index": !exists(json, "index") ? void 0 : json["index"],
2480
+ "reason": !exists(json, "reason") ? void 0 : json["reason"]
2481
+ };
2482
+ }
2483
+ function TrackBatch202ResponseDataFromJSON(json) {
2484
+ return TrackBatch202ResponseDataFromJSONTyped(json);
2485
+ }
2486
+ function TrackBatch202ResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2487
+ if (json === void 0 || json === null) {
2488
+ return json;
2489
+ }
2490
+ return {
2491
+ "accepted": !exists(json, "accepted") ? void 0 : json["accepted"],
2492
+ "rejected": !exists(json, "rejected") ? void 0 : json["rejected"],
2493
+ "errors": !exists(json, "errors") ? void 0 : json["errors"].map(TrackBatch202ResponseDataErrorsInnerFromJSON)
2494
+ };
2495
+ }
2496
+ function TrackBatch202ResponseFromJSON(json) {
2497
+ return TrackBatch202ResponseFromJSONTyped(json);
2498
+ }
2499
+ function TrackBatch202ResponseFromJSONTyped(json, ignoreDiscriminator) {
2500
+ if (json === void 0 || json === null) {
2501
+ return json;
2502
+ }
2503
+ return {
2504
+ "success": !exists(json, "success") ? void 0 : json["success"],
2505
+ "data": !exists(json, "data") ? void 0 : TrackBatch202ResponseDataFromJSON(json["data"])
2506
+ };
2507
+ }
2508
+ function TrackRequestContextToJSON(value) {
2509
+ if (value === void 0) {
2510
+ return void 0;
2511
+ }
2512
+ if (value === null) {
2513
+ return null;
2514
+ }
2515
+ return {
2516
+ "pageVersionId": value.pageVersionId,
2517
+ "componentVersionId": value.componentVersionId,
2518
+ "sessionId": value.sessionId,
2519
+ "deviceType": value.deviceType,
2520
+ "traceId": value.traceId
2521
+ };
2522
+ }
2523
+ function TrackRequestToJSON(value) {
2524
+ if (value === void 0) {
2525
+ return void 0;
2526
+ }
2527
+ if (value === null) {
2528
+ return null;
2529
+ }
2530
+ return {
2531
+ "eventName": value.eventName,
2532
+ "eventType": value.eventType,
2533
+ "properties": value.properties,
2534
+ "timestamp": value.timestamp === void 0 ? void 0 : value.timestamp.toISOString(),
2535
+ "context": TrackRequestContextToJSON(value.context)
2536
+ };
2537
+ }
2538
+ function TrackBatchRequestToJSON(value) {
2539
+ if (value === void 0) {
2540
+ return void 0;
2541
+ }
2542
+ if (value === null) {
2543
+ return null;
2544
+ }
2545
+ return {
2546
+ "events": value.events.map(TrackRequestToJSON)
2547
+ };
2548
+ }
2549
+ function ValidateActionRequestToJSON(value) {
2550
+ if (value === void 0) {
2551
+ return void 0;
2552
+ }
2553
+ if (value === null) {
2554
+ return null;
2555
+ }
2556
+ return {
2557
+ "actionType": value.actionType,
2558
+ "actionDefinitionVersionId": value.actionDefinitionVersionId,
2559
+ "params": value.params
2560
+ };
2561
+ }
2562
+ function ValidateActionResponseDataErrorsInnerFromJSON(json) {
2563
+ return ValidateActionResponseDataErrorsInnerFromJSONTyped(json);
2564
+ }
2565
+ function ValidateActionResponseDataErrorsInnerFromJSONTyped(json, ignoreDiscriminator) {
2566
+ if (json === void 0 || json === null) {
2567
+ return json;
2568
+ }
2569
+ return {
2570
+ "path": !exists(json, "path") ? void 0 : json["path"],
2571
+ "message": !exists(json, "message") ? void 0 : json["message"],
2572
+ "code": !exists(json, "code") ? void 0 : json["code"]
2573
+ };
2574
+ }
2575
+ function ValidateActionResponseDataFromJSON(json) {
2576
+ return ValidateActionResponseDataFromJSONTyped(json);
2577
+ }
2578
+ function ValidateActionResponseDataFromJSONTyped(json, ignoreDiscriminator) {
2579
+ if (json === void 0 || json === null) {
2580
+ return json;
2581
+ }
2582
+ return {
2583
+ "valid": json["valid"],
2584
+ "errors": !exists(json, "errors") ? void 0 : json["errors"].map(ValidateActionResponseDataErrorsInnerFromJSON)
2585
+ };
2586
+ }
2587
+ function ValidateActionResponseFromJSON(json) {
2588
+ return ValidateActionResponseFromJSONTyped(json);
2589
+ }
2590
+ function ValidateActionResponseFromJSONTyped(json, ignoreDiscriminator) {
2591
+ if (json === void 0 || json === null) {
2592
+ return json;
2593
+ }
2594
+ return {
2595
+ "data": ValidateActionResponseDataFromJSON(json["data"])
2596
+ };
2597
+ }
2598
+ var ActionsApi = class extends BaseAPI {
2599
+ /**
2600
+ * Action Gateway 唯一入口,所有业务动作都通过此接口执行。 执行流程(Pipeline): 1. Auth(登录态/票据/签名) 2. Risk(限流、黑名单、设备指纹、验证码开关) 3. Idempotency(幂等键检查) 4. Execute(执行器:Claim/Signin/Lottery...) 5. Audit(审计落库 + outbox) 6. Normalize(统一错误码/返回) 支持的动作类型: - claim: 领取 - signin: 签到 - lottery: 抽奖 - reserve: 预约 - bind: 绑定 - task_complete: 任务完成 - vote: 投票 - share: 分享 - form_submit: 表单提交 - navigate: 页面跳转(内置) - setState: 状态更新(内置) - showToast: 提示消息(内置) - custom: 自定义动作
2601
+ * 执行动作(统一入口)
2602
+ */
2603
+ async executeActionRaw(requestParameters, initOverrides) {
2604
+ if (requestParameters.executeActionRequest === null || requestParameters.executeActionRequest === void 0) {
2605
+ throw new RequiredError("executeActionRequest", "Required parameter requestParameters.executeActionRequest was null or undefined when calling executeAction.");
2606
+ }
2607
+ const queryParameters = {};
2608
+ const headerParameters = {};
2609
+ headerParameters["Content-Type"] = "application/json";
2610
+ if (this.configuration && this.configuration.apiKey) {
2611
+ headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
2612
+ }
2613
+ if (this.configuration && this.configuration.accessToken) {
2614
+ const token = this.configuration.accessToken;
2615
+ const tokenString = await token("BearerAuth", []);
2616
+ if (tokenString) {
2617
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
2618
+ }
2619
+ }
2620
+ const response = await this.request({
2621
+ path: `/actions/execute`,
2622
+ method: "POST",
2623
+ headers: headerParameters,
2624
+ query: queryParameters,
2625
+ body: ExecuteActionRequestToJSON(requestParameters.executeActionRequest)
2626
+ }, initOverrides);
2627
+ return new JSONApiResponse(response, (jsonValue) => ExecuteActionResponseFromJSON(jsonValue));
2628
+ }
2629
+ /**
2630
+ * Action Gateway 唯一入口,所有业务动作都通过此接口执行。 执行流程(Pipeline): 1. Auth(登录态/票据/签名) 2. Risk(限流、黑名单、设备指纹、验证码开关) 3. Idempotency(幂等键检查) 4. Execute(执行器:Claim/Signin/Lottery...) 5. Audit(审计落库 + outbox) 6. Normalize(统一错误码/返回) 支持的动作类型: - claim: 领取 - signin: 签到 - lottery: 抽奖 - reserve: 预约 - bind: 绑定 - task_complete: 任务完成 - vote: 投票 - share: 分享 - form_submit: 表单提交 - navigate: 页面跳转(内置) - setState: 状态更新(内置) - showToast: 提示消息(内置) - custom: 自定义动作
2631
+ * 执行动作(统一入口)
2632
+ */
2633
+ async executeAction(requestParameters, initOverrides) {
2634
+ const response = await this.executeActionRaw(requestParameters, initOverrides);
2635
+ return await response.value();
2636
+ }
2637
+ /**
2638
+ * 获取指定动作定义版本的详细信息(用于 Runtime 渲染动作配置)
2639
+ * 获取动作定义
2640
+ */
2641
+ async getActionDefinitionRaw(requestParameters, initOverrides) {
2642
+ if (requestParameters.actionDefinitionVersionId === null || requestParameters.actionDefinitionVersionId === void 0) {
2643
+ throw new RequiredError("actionDefinitionVersionId", "Required parameter requestParameters.actionDefinitionVersionId was null or undefined when calling getActionDefinition.");
2644
+ }
2645
+ const queryParameters = {};
2646
+ if (requestParameters.actionDefinitionVersionId !== void 0) {
2647
+ queryParameters["actionDefinitionVersionId"] = requestParameters.actionDefinitionVersionId;
2648
+ }
2649
+ const headerParameters = {};
2650
+ if (this.configuration && this.configuration.apiKey) {
2651
+ headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
2652
+ }
2653
+ if (this.configuration && this.configuration.accessToken) {
2654
+ const token = this.configuration.accessToken;
2655
+ const tokenString = await token("BearerAuth", []);
2656
+ if (tokenString) {
2657
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
2658
+ }
2659
+ }
2660
+ const response = await this.request({
2661
+ path: `/actions/definitions`,
2662
+ method: "GET",
2663
+ headers: headerParameters,
2664
+ query: queryParameters
2665
+ }, initOverrides);
2666
+ return new JSONApiResponse(response, (jsonValue) => ActionDefinitionResponseFromJSON(jsonValue));
2667
+ }
2668
+ /**
2669
+ * 获取指定动作定义版本的详细信息(用于 Runtime 渲染动作配置)
2670
+ * 获取动作定义
2671
+ */
2672
+ async getActionDefinition(requestParameters, initOverrides) {
2673
+ const response = await this.getActionDefinitionRaw(requestParameters, initOverrides);
2674
+ return await response.value();
2675
+ }
2676
+ /**
2677
+ * 验证动作参数是否符合 Schema 定义(不执行动作)。 用于前端表单提交前的预校验。
2678
+ * 验证动作参数
2679
+ */
2680
+ async validateActionParamsRaw(requestParameters, initOverrides) {
2681
+ if (requestParameters.validateActionRequest === null || requestParameters.validateActionRequest === void 0) {
2682
+ throw new RequiredError("validateActionRequest", "Required parameter requestParameters.validateActionRequest was null or undefined when calling validateActionParams.");
2683
+ }
2684
+ const queryParameters = {};
2685
+ const headerParameters = {};
2686
+ headerParameters["Content-Type"] = "application/json";
2687
+ if (this.configuration && this.configuration.apiKey) {
2688
+ headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
2689
+ }
2690
+ if (this.configuration && this.configuration.accessToken) {
2691
+ const token = this.configuration.accessToken;
2692
+ const tokenString = await token("BearerAuth", []);
2693
+ if (tokenString) {
2694
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
2695
+ }
2696
+ }
2697
+ const response = await this.request({
2698
+ path: `/actions/validate`,
2699
+ method: "POST",
2700
+ headers: headerParameters,
2701
+ query: queryParameters,
2702
+ body: ValidateActionRequestToJSON(requestParameters.validateActionRequest)
2703
+ }, initOverrides);
2704
+ return new JSONApiResponse(response, (jsonValue) => ValidateActionResponseFromJSON(jsonValue));
2705
+ }
2706
+ /**
2707
+ * 验证动作参数是否符合 Schema 定义(不执行动作)。 用于前端表单提交前的预校验。
2708
+ * 验证动作参数
2709
+ */
2710
+ async validateActionParams(requestParameters, initOverrides) {
2711
+ const response = await this.validateActionParamsRaw(requestParameters, initOverrides);
2712
+ return await response.value();
2713
+ }
2714
+ };
2715
+ var ActivitiesApi = class extends BaseAPI {
2716
+ /**
2717
+ * 获取活动的公开信息,不需要登录。 返回内容包括: - 活动基本信息 - 时间范围 - 奖品列表(脱敏)
2718
+ * 获取活动信息(公开)
2719
+ */
2720
+ async getActivityInfoRaw(requestParameters, initOverrides) {
2721
+ if (requestParameters.activityId === null || requestParameters.activityId === void 0) {
2722
+ throw new RequiredError("activityId", "Required parameter requestParameters.activityId was null or undefined when calling getActivityInfo.");
2723
+ }
2724
+ const queryParameters = {};
2725
+ const headerParameters = {};
2726
+ const response = await this.request({
2727
+ path: `/activities/{activityId}`.replace(`{${"activityId"}}`, encodeURIComponent(String(requestParameters.activityId))),
2728
+ method: "GET",
2729
+ headers: headerParameters,
2730
+ query: queryParameters
2731
+ }, initOverrides);
2732
+ return new JSONApiResponse(response, (jsonValue) => GetActivityInfo200ResponseFromJSON(jsonValue));
2733
+ }
2734
+ /**
2735
+ * 获取活动的公开信息,不需要登录。 返回内容包括: - 活动基本信息 - 时间范围 - 奖品列表(脱敏)
2736
+ * 获取活动信息(公开)
2737
+ */
2738
+ async getActivityInfo(requestParameters, initOverrides) {
2739
+ const response = await this.getActivityInfoRaw(requestParameters, initOverrides);
2740
+ return await response.value();
2741
+ }
2742
+ /**
2743
+ * 查询用户在指定活动中的参与状态。 返回内容包括: - 是否可参与 - 剩余次数 - 类型特定状态(领取/签到/抽奖等)
2744
+ * 获取用户活动状态
2745
+ */
2746
+ async getActivityStateRaw(requestParameters, initOverrides) {
2747
+ if (requestParameters.activityId === null || requestParameters.activityId === void 0) {
2748
+ throw new RequiredError("activityId", "Required parameter requestParameters.activityId was null or undefined when calling getActivityState.");
2749
+ }
2750
+ const queryParameters = {};
2751
+ const headerParameters = {};
2752
+ if (this.configuration && this.configuration.accessToken) {
2753
+ const token = this.configuration.accessToken;
2754
+ const tokenString = await token("BearerAuth", []);
2755
+ if (tokenString) {
2756
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
2757
+ }
2758
+ }
2759
+ const response = await this.request({
2760
+ path: `/activities/{activityId}/state`.replace(`{${"activityId"}}`, encodeURIComponent(String(requestParameters.activityId))),
2761
+ method: "GET",
2762
+ headers: headerParameters,
2763
+ query: queryParameters
2764
+ }, initOverrides);
2765
+ return new JSONApiResponse(response, (jsonValue) => GetActivityState200ResponseFromJSON(jsonValue));
2766
+ }
2767
+ /**
2768
+ * 查询用户在指定活动中的参与状态。 返回内容包括: - 是否可参与 - 剩余次数 - 类型特定状态(领取/签到/抽奖等)
2769
+ * 获取用户活动状态
2770
+ */
2771
+ async getActivityState(requestParameters, initOverrides) {
2772
+ const response = await this.getActivityStateRaw(requestParameters, initOverrides);
2773
+ return await response.value();
2774
+ }
2775
+ /**
2776
+ * 获取用户在指定活动中的领取记录
2777
+ * 获取领取记录
2778
+ */
2779
+ async getClaimRecordsRaw(requestParameters, initOverrides) {
2780
+ if (requestParameters.activityId === null || requestParameters.activityId === void 0) {
2781
+ throw new RequiredError("activityId", "Required parameter requestParameters.activityId was null or undefined when calling getClaimRecords.");
2782
+ }
2783
+ const queryParameters = {};
2784
+ if (requestParameters.pageSize !== void 0) {
2785
+ queryParameters["pageSize"] = requestParameters.pageSize;
2786
+ }
2787
+ if (requestParameters.pageToken !== void 0) {
2788
+ queryParameters["pageToken"] = requestParameters.pageToken;
2789
+ }
2790
+ const headerParameters = {};
2791
+ if (this.configuration && this.configuration.accessToken) {
2792
+ const token = this.configuration.accessToken;
2793
+ const tokenString = await token("BearerAuth", []);
2794
+ if (tokenString) {
2795
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
2796
+ }
2797
+ }
2798
+ const response = await this.request({
2799
+ path: `/activities/{activityId}/claims`.replace(`{${"activityId"}}`, encodeURIComponent(String(requestParameters.activityId))),
2800
+ method: "GET",
2801
+ headers: headerParameters,
2802
+ query: queryParameters
2803
+ }, initOverrides);
2804
+ return new JSONApiResponse(response, (jsonValue) => GetClaimRecords200ResponseFromJSON(jsonValue));
2805
+ }
2806
+ /**
2807
+ * 获取用户在指定活动中的领取记录
2808
+ * 获取领取记录
2809
+ */
2810
+ async getClaimRecords(requestParameters, initOverrides) {
2811
+ const response = await this.getClaimRecordsRaw(requestParameters, initOverrides);
2812
+ return await response.value();
2813
+ }
2814
+ /**
2815
+ * 获取用户在指定活动中的抽奖记录
2816
+ * 获取抽奖记录
2817
+ */
2818
+ async getLotteryRecordsRaw(requestParameters, initOverrides) {
2819
+ if (requestParameters.activityId === null || requestParameters.activityId === void 0) {
2820
+ throw new RequiredError("activityId", "Required parameter requestParameters.activityId was null or undefined when calling getLotteryRecords.");
2821
+ }
2822
+ const queryParameters = {};
2823
+ if (requestParameters.pageSize !== void 0) {
2824
+ queryParameters["pageSize"] = requestParameters.pageSize;
2825
+ }
2826
+ if (requestParameters.pageToken !== void 0) {
2827
+ queryParameters["pageToken"] = requestParameters.pageToken;
2828
+ }
2829
+ const headerParameters = {};
2830
+ if (this.configuration && this.configuration.accessToken) {
2831
+ const token = this.configuration.accessToken;
2832
+ const tokenString = await token("BearerAuth", []);
2833
+ if (tokenString) {
2834
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
2835
+ }
2836
+ }
2837
+ const response = await this.request({
2838
+ path: `/activities/{activityId}/lottery`.replace(`{${"activityId"}}`, encodeURIComponent(String(requestParameters.activityId))),
2839
+ method: "GET",
2840
+ headers: headerParameters,
2841
+ query: queryParameters
2842
+ }, initOverrides);
2843
+ return new JSONApiResponse(response, (jsonValue) => GetLotteryRecords200ResponseFromJSON(jsonValue));
2844
+ }
2845
+ /**
2846
+ * 获取用户在指定活动中的抽奖记录
2847
+ * 获取抽奖记录
2848
+ */
2849
+ async getLotteryRecords(requestParameters, initOverrides) {
2850
+ const response = await this.getLotteryRecordsRaw(requestParameters, initOverrides);
2851
+ return await response.value();
2852
+ }
2853
+ /**
2854
+ * 获取用户的签到日历数据。 返回内容包括: - 当前周期的签到记录 - 连续签到天数 - 累计签到天数 - 奖励进度
2855
+ * 获取签到日历
2856
+ */
2857
+ async getSigninCalendarRaw(requestParameters, initOverrides) {
2858
+ if (requestParameters.activityId === null || requestParameters.activityId === void 0) {
2859
+ throw new RequiredError("activityId", "Required parameter requestParameters.activityId was null or undefined when calling getSigninCalendar.");
2860
+ }
2861
+ const queryParameters = {};
2862
+ if (requestParameters.month !== void 0) {
2863
+ queryParameters["month"] = requestParameters.month;
2864
+ }
2865
+ const headerParameters = {};
2866
+ if (this.configuration && this.configuration.accessToken) {
2867
+ const token = this.configuration.accessToken;
2868
+ const tokenString = await token("BearerAuth", []);
2869
+ if (tokenString) {
2870
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
2871
+ }
2872
+ }
2873
+ const response = await this.request({
2874
+ path: `/activities/{activityId}/signin/calendar`.replace(`{${"activityId"}}`, encodeURIComponent(String(requestParameters.activityId))),
2875
+ method: "GET",
2876
+ headers: headerParameters,
2877
+ query: queryParameters
2878
+ }, initOverrides);
2879
+ return new JSONApiResponse(response, (jsonValue) => GetSigninCalendar200ResponseFromJSON(jsonValue));
2880
+ }
2881
+ /**
2882
+ * 获取用户的签到日历数据。 返回内容包括: - 当前周期的签到记录 - 连续签到天数 - 累计签到天数 - 奖励进度
2883
+ * 获取签到日历
2884
+ */
2885
+ async getSigninCalendar(requestParameters, initOverrides) {
2886
+ const response = await this.getSigninCalendarRaw(requestParameters, initOverrides);
2887
+ return await response.value();
2888
+ }
2889
+ };
2890
+ var PagesApi = class extends BaseAPI {
2891
+ /**
2892
+ * Runtime 的核心接口,返回渲染所需的完整数据。 支持两种模式: 1. 稳定入口(推荐):支持灰度/回滚/ops,返回 resolvedVersionId 和 CDN 地址 2. 保底模式:当 includeSnapshot=1 时,返回完整 snapshot(CDN 失败时使用) 响应包含: - resolvedVersionId: 解析后的页面版本 ID(考虑灰度/回滚) - cdnBase: CDN 基础地址 - snapshotUrl: snapshot.json 的完整 URL - manifestUrl: manifest.json 的完整 URL - ops: 运维配置(killSwitch、blockedComponents、flags) - etag: 内容哈希(用于缓存) - cacheTtlSeconds: 缓存 TTL(建议 10~30 秒) - snapshot: 完整快照(仅当 includeSnapshot=1 时返回)
2893
+ * 解析页面(Runtime 核心接口)
2894
+ */
2895
+ async resolvePageRaw(requestParameters, initOverrides) {
2896
+ if (requestParameters.pageId === null || requestParameters.pageId === void 0) {
2897
+ throw new RequiredError("pageId", "Required parameter requestParameters.pageId was null or undefined when calling resolvePage.");
2898
+ }
2899
+ const queryParameters = {};
2900
+ if (requestParameters.pageId !== void 0) {
2901
+ queryParameters["pageId"] = requestParameters.pageId;
2902
+ }
2903
+ if (requestParameters.env !== void 0) {
2904
+ queryParameters["env"] = requestParameters.env;
2905
+ }
2906
+ if (requestParameters.uid !== void 0) {
2907
+ queryParameters["uid"] = requestParameters.uid;
2908
+ }
2909
+ if (requestParameters.deviceId !== void 0) {
2910
+ queryParameters["deviceId"] = requestParameters.deviceId;
2911
+ }
2912
+ if (requestParameters.channel !== void 0) {
2913
+ queryParameters["channel"] = requestParameters.channel;
2914
+ }
2915
+ if (requestParameters.includeSnapshot !== void 0) {
2916
+ queryParameters["includeSnapshot"] = requestParameters.includeSnapshot;
2917
+ }
2918
+ const headerParameters = {};
2919
+ if (this.configuration && this.configuration.apiKey) {
2920
+ headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
2921
+ }
2922
+ if (this.configuration && this.configuration.accessToken) {
2923
+ const token = this.configuration.accessToken;
2924
+ const tokenString = await token("BearerAuth", []);
2925
+ if (tokenString) {
2926
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
2927
+ }
2928
+ }
2929
+ const response = await this.request({
2930
+ path: `/page/resolve`,
2931
+ method: "GET",
2932
+ headers: headerParameters,
2933
+ query: queryParameters
2934
+ }, initOverrides);
2935
+ return new JSONApiResponse(response, (jsonValue) => ResolvePageResponseFromJSON(jsonValue));
2936
+ }
2937
+ /**
2938
+ * Runtime 的核心接口,返回渲染所需的完整数据。 支持两种模式: 1. 稳定入口(推荐):支持灰度/回滚/ops,返回 resolvedVersionId 和 CDN 地址 2. 保底模式:当 includeSnapshot=1 时,返回完整 snapshot(CDN 失败时使用) 响应包含: - resolvedVersionId: 解析后的页面版本 ID(考虑灰度/回滚) - cdnBase: CDN 基础地址 - snapshotUrl: snapshot.json 的完整 URL - manifestUrl: manifest.json 的完整 URL - ops: 运维配置(killSwitch、blockedComponents、flags) - etag: 内容哈希(用于缓存) - cacheTtlSeconds: 缓存 TTL(建议 10~30 秒) - snapshot: 完整快照(仅当 includeSnapshot=1 时返回)
2939
+ * 解析页面(Runtime 核心接口)
2940
+ */
2941
+ async resolvePage(requestParameters, initOverrides) {
2942
+ const response = await this.resolvePageRaw(requestParameters, initOverrides);
2943
+ return await response.value();
2944
+ }
2945
+ };
2946
+ var QueriesApi = class extends BaseAPI {
2947
+ /**
2948
+ * 批量执行多个数据查询,用于页面初始化时预取多个数据源。 所有查询并行执行,部分失败不影响其他查询返回。
2949
+ * 批量执行数据查询
2950
+ */
2951
+ async batchQueryDataRaw(requestParameters, initOverrides) {
2952
+ if (requestParameters.batchQueryRequest === null || requestParameters.batchQueryRequest === void 0) {
2953
+ throw new RequiredError("batchQueryRequest", "Required parameter requestParameters.batchQueryRequest was null or undefined when calling batchQueryData.");
2954
+ }
2955
+ const queryParameters = {};
2956
+ const headerParameters = {};
2957
+ headerParameters["Content-Type"] = "application/json";
2958
+ if (this.configuration && this.configuration.apiKey) {
2959
+ headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
2960
+ }
2961
+ if (this.configuration && this.configuration.accessToken) {
2962
+ const token = this.configuration.accessToken;
2963
+ const tokenString = await token("BearerAuth", []);
2964
+ if (tokenString) {
2965
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
2966
+ }
2967
+ }
2968
+ const response = await this.request({
2969
+ path: `/data/query/batch`,
2970
+ method: "POST",
2971
+ headers: headerParameters,
2972
+ query: queryParameters,
2973
+ body: BatchQueryRequestToJSON(requestParameters.batchQueryRequest)
2974
+ }, initOverrides);
2975
+ return new JSONApiResponse(response, (jsonValue) => BatchQueryResponseFromJSON(jsonValue));
2976
+ }
2977
+ /**
2978
+ * 批量执行多个数据查询,用于页面初始化时预取多个数据源。 所有查询并行执行,部分失败不影响其他查询返回。
2979
+ * 批量执行数据查询
2980
+ */
2981
+ async batchQueryData(requestParameters, initOverrides) {
2982
+ const response = await this.batchQueryDataRaw(requestParameters, initOverrides);
2983
+ return await response.value();
2984
+ }
2985
+ /**
2986
+ * 获取指定数据查询定义版本的详细信息
2987
+ * 获取查询定义
2988
+ */
2989
+ async getQueryDefinitionRaw(requestParameters, initOverrides) {
2990
+ if (requestParameters.queryVersionId === null || requestParameters.queryVersionId === void 0) {
2991
+ throw new RequiredError("queryVersionId", "Required parameter requestParameters.queryVersionId was null or undefined when calling getQueryDefinition.");
2992
+ }
2993
+ const queryParameters = {};
2994
+ if (requestParameters.queryVersionId !== void 0) {
2995
+ queryParameters["queryVersionId"] = requestParameters.queryVersionId;
2996
+ }
2997
+ const headerParameters = {};
2998
+ if (this.configuration && this.configuration.apiKey) {
2999
+ headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
3000
+ }
3001
+ if (this.configuration && this.configuration.accessToken) {
3002
+ const token = this.configuration.accessToken;
3003
+ const tokenString = await token("BearerAuth", []);
3004
+ if (tokenString) {
3005
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
3006
+ }
3007
+ }
3008
+ const response = await this.request({
3009
+ path: `/data/definitions`,
3010
+ method: "GET",
3011
+ headers: headerParameters,
3012
+ query: queryParameters
3013
+ }, initOverrides);
3014
+ return new JSONApiResponse(response, (jsonValue) => QueryDefinitionResponseFromJSON(jsonValue));
3015
+ }
3016
+ /**
3017
+ * 获取指定数据查询定义版本的详细信息
3018
+ * 获取查询定义
3019
+ */
3020
+ async getQueryDefinition(requestParameters, initOverrides) {
3021
+ const response = await this.getQueryDefinitionRaw(requestParameters, initOverrides);
3022
+ return await response.value();
3023
+ }
3024
+ /**
3025
+ * Data Proxy 统一入口,所有数据查询都通过此接口执行。 功能: - 白名单校验(queryVersionId 属于该 app/workspace) - 字段裁剪、脱敏 - 缓存(短 TTL) - 失败降级(兜底结构) - 审计(可选,或采样) 支持的数据源类型: - http: HTTP 接口 - graphql: GraphQL 查询 - database: 数据库查询(受限) - internal: 内部服务 - aggregation: 聚合查询
3026
+ * 执行数据查询(Data Proxy 统一入口)
3027
+ */
3028
+ async queryDataRaw(requestParameters, initOverrides) {
3029
+ if (requestParameters.queryDataRequest === null || requestParameters.queryDataRequest === void 0) {
3030
+ throw new RequiredError("queryDataRequest", "Required parameter requestParameters.queryDataRequest was null or undefined when calling queryData.");
3031
+ }
3032
+ const queryParameters = {};
3033
+ const headerParameters = {};
3034
+ headerParameters["Content-Type"] = "application/json";
3035
+ if (this.configuration && this.configuration.apiKey) {
3036
+ headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
3037
+ }
3038
+ if (this.configuration && this.configuration.accessToken) {
3039
+ const token = this.configuration.accessToken;
3040
+ const tokenString = await token("BearerAuth", []);
3041
+ if (tokenString) {
3042
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
3043
+ }
3044
+ }
3045
+ const response = await this.request({
3046
+ path: `/data/query`,
3047
+ method: "POST",
3048
+ headers: headerParameters,
3049
+ query: queryParameters,
3050
+ body: QueryDataRequestToJSON(requestParameters.queryDataRequest)
3051
+ }, initOverrides);
3052
+ return new JSONApiResponse(response, (jsonValue) => QueryDataResponseFromJSON(jsonValue));
3053
+ }
3054
+ /**
3055
+ * Data Proxy 统一入口,所有数据查询都通过此接口执行。 功能: - 白名单校验(queryVersionId 属于该 app/workspace) - 字段裁剪、脱敏 - 缓存(短 TTL) - 失败降级(兜底结构) - 审计(可选,或采样) 支持的数据源类型: - http: HTTP 接口 - graphql: GraphQL 查询 - database: 数据库查询(受限) - internal: 内部服务 - aggregation: 聚合查询
3056
+ * 执行数据查询(Data Proxy 统一入口)
3057
+ */
3058
+ async queryData(requestParameters, initOverrides) {
3059
+ const response = await this.queryDataRaw(requestParameters, initOverrides);
3060
+ return await response.value();
3061
+ }
3062
+ };
3063
+ var TrackApi = class extends BaseAPI {
3064
+ /**
3065
+ * 接收客户端埋点数据,异步写入 Outbox。 特点: - 高性能:不阻塞主链路 - 可靠:通过 Outbox 异步持久化 - 可追溯:自动关联 pageVersionId/componentVersionId/traceId
3066
+ * 埋点上报
3067
+ */
3068
+ async trackRaw(requestParameters, initOverrides) {
3069
+ if (requestParameters.trackRequest === null || requestParameters.trackRequest === void 0) {
3070
+ throw new RequiredError("trackRequest", "Required parameter requestParameters.trackRequest was null or undefined when calling track.");
3071
+ }
3072
+ const queryParameters = {};
3073
+ const headerParameters = {};
3074
+ headerParameters["Content-Type"] = "application/json";
3075
+ if (this.configuration && this.configuration.apiKey) {
3076
+ headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
3077
+ }
3078
+ if (this.configuration && this.configuration.accessToken) {
3079
+ const token = this.configuration.accessToken;
3080
+ const tokenString = await token("BearerAuth", []);
3081
+ if (tokenString) {
3082
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
3083
+ }
3084
+ }
3085
+ const response = await this.request({
3086
+ path: `/track`,
3087
+ method: "POST",
3088
+ headers: headerParameters,
3089
+ query: queryParameters,
3090
+ body: TrackRequestToJSON(requestParameters.trackRequest)
3091
+ }, initOverrides);
3092
+ return new JSONApiResponse(response, (jsonValue) => Track202ResponseFromJSON(jsonValue));
3093
+ }
3094
+ /**
3095
+ * 接收客户端埋点数据,异步写入 Outbox。 特点: - 高性能:不阻塞主链路 - 可靠:通过 Outbox 异步持久化 - 可追溯:自动关联 pageVersionId/componentVersionId/traceId
3096
+ * 埋点上报
3097
+ */
3098
+ async track(requestParameters, initOverrides) {
3099
+ const response = await this.trackRaw(requestParameters, initOverrides);
3100
+ return await response.value();
3101
+ }
3102
+ /**
3103
+ * 批量接收客户端埋点数据,提高上报效率。 限制: - 单次最多 100 条 - 单条事件不超过 10KB
3104
+ * 批量埋点上报
3105
+ */
3106
+ async trackBatchRaw(requestParameters, initOverrides) {
3107
+ if (requestParameters.trackBatchRequest === null || requestParameters.trackBatchRequest === void 0) {
3108
+ throw new RequiredError("trackBatchRequest", "Required parameter requestParameters.trackBatchRequest was null or undefined when calling trackBatch.");
3109
+ }
3110
+ const queryParameters = {};
3111
+ const headerParameters = {};
3112
+ headerParameters["Content-Type"] = "application/json";
3113
+ if (this.configuration && this.configuration.apiKey) {
3114
+ headerParameters["X-API-Key"] = this.configuration.apiKey("X-API-Key");
3115
+ }
3116
+ if (this.configuration && this.configuration.accessToken) {
3117
+ const token = this.configuration.accessToken;
3118
+ const tokenString = await token("BearerAuth", []);
3119
+ if (tokenString) {
3120
+ headerParameters["Authorization"] = `Bearer ${tokenString}`;
3121
+ }
3122
+ }
3123
+ const response = await this.request({
3124
+ path: `/track/batch`,
3125
+ method: "POST",
3126
+ headers: headerParameters,
3127
+ query: queryParameters,
3128
+ body: TrackBatchRequestToJSON(requestParameters.trackBatchRequest)
3129
+ }, initOverrides);
3130
+ return new JSONApiResponse(response, (jsonValue) => TrackBatch202ResponseFromJSON(jsonValue));
3131
+ }
3132
+ /**
3133
+ * 批量接收客户端埋点数据,提高上报效率。 限制: - 单次最多 100 条 - 单条事件不超过 10KB
3134
+ * 批量埋点上报
3135
+ */
3136
+ async trackBatch(requestParameters, initOverrides) {
3137
+ const response = await this.trackBatchRaw(requestParameters, initOverrides);
3138
+ return await response.value();
3139
+ }
3140
+ };
3141
+ var DEFAULT_BASE_URL = "/api";
3142
+ var UserClient = class {
3143
+ constructor(config = {}) {
3144
+ const baseUrl = config.baseUrl ?? DEFAULT_BASE_URL;
3145
+ const coreMiddlewares = createMiddlewares({
3146
+ auth: config.auth,
3147
+ retry: config.retry,
3148
+ enableRetry: config.enableRetry,
3149
+ logger: config.logger,
3150
+ debug: config.debug,
3151
+ timeout: config.timeout,
3152
+ headers: config.headers,
3153
+ preMiddlewares: config.preMiddlewares,
3154
+ postMiddlewares: config.postMiddlewares,
3155
+ errorMiddlewares: config.errorMiddlewares
3156
+ });
3157
+ const allMiddlewares = [...coreMiddlewares, ...config.middlewares ?? []];
3158
+ this.configuration = new Configuration({
3159
+ basePath: baseUrl,
3160
+ middleware: allMiddlewares,
3161
+ headers: config.headers
3162
+ });
3163
+ this.pages = new PagesApi(this.configuration);
3164
+ this.actions = new ActionsApi(this.configuration);
3165
+ this.activities = new ActivitiesApi(this.configuration);
3166
+ this.queries = new QueriesApi(this.configuration);
3167
+ this.track = new TrackApi(this.configuration);
3168
+ }
3169
+ };
3170
+ function createUserClient(config) {
3171
+ return new UserClient(config);
3172
+ }
3173
+ var n = class extends Error {
3174
+ constructor(t3, s, i, n2) {
3175
+ super(s || ErrorMessages[t3] || "Unknown error"), this.name = "DjvlcRuntimeError", this.code = t3, this.details = i, this.traceId = n2, this.timestamp = Date.now();
997
3176
  }
998
3177
  toJSON() {
999
3178
  return { name: this.name, code: this.code, message: this.message, details: this.details, traceId: this.traceId, timestamp: this.timestamp };
1000
3179
  }
1001
- }, n = class extends i {
1002
- constructor(t3, e, i2) {
1003
- super(ErrorCode.RESOURCE_PAGE_NOT_FOUND, t3, e, i2), this.name = "PageLoadError";
3180
+ }, r = class extends n {
3181
+ constructor(t3, e, i) {
3182
+ super(ErrorCode.RESOURCE_PAGE_NOT_FOUND, t3, e, i), this.name = "PageLoadError";
1004
3183
  }
1005
- }, r = class extends i {
1006
- constructor(t3, e, i2, n2 = ErrorCode.COMPONENT_LOAD_FAILED, r2) {
1007
- super(n2, i2, { ...r2, componentName: t3, componentVersion: e }), this.name = "ComponentLoadError", this.componentName = t3, this.componentVersion = e;
3184
+ }, o = class extends n {
3185
+ constructor(t3, e, i, n2 = ErrorCode.COMPONENT_LOAD_FAILED, r2) {
3186
+ super(n2, i, { ...r2, componentName: t3, componentVersion: e }), this.name = "ComponentLoadError", this.componentName = t3, this.componentVersion = e;
1008
3187
  }
1009
- }, o = class extends i {
1010
- constructor(t3, e, i2, n2) {
1011
- super(ErrorCode.COMPONENT_INTEGRITY_MISMATCH, `Integrity check failed for ${t3}@${e}`, { expectedHash: i2, actualHash: n2 }), this.name = "IntegrityError", this.componentName = t3, this.componentVersion = e, this.expectedHash = i2, this.actualHash = n2;
3188
+ }, a = class extends n {
3189
+ constructor(t3, e, i, n2) {
3190
+ super(ErrorCode.COMPONENT_INTEGRITY_MISMATCH, `Integrity check failed for ${t3}@${e}`, { expectedHash: i, actualHash: n2 }), this.name = "IntegrityError", this.componentName = t3, this.componentVersion = e, this.expectedHash = i, this.actualHash = n2;
1012
3191
  }
1013
- }, a = class extends i {
1014
- constructor(t3, e, i2) {
1015
- super(ErrorCode.COMPONENT_BLOCKED, `Component ${t3}@${e} is blocked`, { componentName: t3, componentVersion: e, reason: i2 }), this.name = "ComponentBlockedError", this.componentName = t3, this.componentVersion = e, this.reason = i2;
3192
+ }, c = class extends n {
3193
+ constructor(t3, e, i) {
3194
+ super(ErrorCode.COMPONENT_BLOCKED, `Component ${t3}@${e} is blocked`, { componentName: t3, componentVersion: e, reason: i }), this.name = "ComponentBlockedError", this.componentName = t3, this.componentVersion = e, this.reason = i;
1016
3195
  }
1017
- }, c = class extends i {
1018
- constructor(t3, e, i2, n2) {
1019
- super(ErrorCode.VALIDATION_EXPRESSION_ERROR, e, { ...n2, expression: t3, position: i2 }), this.name = "ExpressionError", this.expression = t3, this.position = i2;
3196
+ }, h = class extends n {
3197
+ constructor(t3, e, i, n2) {
3198
+ super(ErrorCode.VALIDATION_EXPRESSION_ERROR, e, { ...n2, expression: t3, position: i }), this.name = "ExpressionError", this.expression = t3, this.position = i;
1020
3199
  }
1021
- }, h = class extends i {
1022
- constructor(t3, e, i2 = ErrorCode.SYSTEM_INTERNAL_ERROR, n2, r2) {
1023
- super(i2, e, { ...r2, actionType: t3, actionId: n2 }), this.name = "ActionError", this.actionType = t3, this.actionId = n2;
3200
+ }, u = class extends n {
3201
+ constructor(t3, e, i = ErrorCode.SYSTEM_INTERNAL_ERROR, n2, r2) {
3202
+ super(i, e, { ...r2, actionType: t3, actionId: n2 }), this.name = "ActionError", this.actionType = t3, this.actionId = n2;
1024
3203
  }
1025
- }, l = class extends i {
1026
- constructor(t3, e, i2 = ErrorCode.SYSTEM_INTERNAL_ERROR, n2) {
1027
- super(i2, e, { ...n2, queryId: t3 }), this.name = "QueryError", this.queryId = t3;
3204
+ }, l = class extends n {
3205
+ constructor(t3, e, i = ErrorCode.SYSTEM_INTERNAL_ERROR, n2) {
3206
+ super(i, e, { ...n2, queryId: t3 }), this.name = "QueryError", this.queryId = t3;
1028
3207
  }
1029
- }, d = class {
3208
+ }, p = class {
1030
3209
  constructor(t3) {
1031
3210
  this.cache = /* @__PURE__ */ new Map(), this.options = { env: "prod", cache: { enabled: true, maxAge: 300 }, ...t3 };
1032
3211
  }
@@ -1037,51 +3216,45 @@ var i = class extends Error {
1037
3216
  const e2 = this.cache.get(s);
1038
3217
  if (e2 && this.isCacheValid(e2.timestamp)) return this.log("debug", `Page ${t3} loaded from cache`), e2.data;
1039
3218
  }
1040
- const i2 = performance.now();
3219
+ const i = performance.now();
1041
3220
  try {
1042
- const n2 = await this.callResolveApi(t3, e), r2 = await this.loadFromCdn(n2, t3);
3221
+ const n2 = await this.callResolveViaAdapter(t3, e), r2 = await this.loadFromCdn(n2, t3);
1043
3222
  ((_b = this.options.cache) == null ? void 0 : _b.enabled) && this.cache.set(s, { data: r2, timestamp: Date.now() });
1044
- const o2 = performance.now() - i2;
3223
+ const o2 = performance.now() - i;
1045
3224
  return this.log("info", `Page ${t3} resolved in ${o2.toFixed(2)}ms`), r2;
1046
3225
  } catch (e2) {
1047
- if (e2 instanceof n) throw e2;
1048
- throw new n(`Failed to resolve page: ${e2 instanceof Error ? e2.message : "Unknown error"}`, { pageId: t3 });
3226
+ if (e2 instanceof r) throw e2;
3227
+ throw new r(`Failed to resolve page: ${e2 instanceof Error ? e2.message : "Unknown error"}`, { pageId: t3 });
1049
3228
  }
1050
3229
  }
1051
- async callResolveApi(t3, e) {
1052
- const s = new URL(`${this.options.apiBaseUrl}/page/resolve`);
1053
- s.searchParams.set("pageId", t3), this.options.env && s.searchParams.set("env", this.options.env), this.options.channel && s.searchParams.set("channel", this.options.channel), this.options.previewToken && s.searchParams.set("previewToken", this.options.previewToken), (e == null ? void 0 : e.uid) && s.searchParams.set("uid", e.uid), (e == null ? void 0 : e.deviceId) && s.searchParams.set("deviceId", e.deviceId);
1054
- const i2 = { "Content-Type": "application/json", ...this.options.headers };
1055
- this.options.authToken && (i2.Authorization = `Bearer ${this.options.authToken}`), this.log("debug", "Calling resolve API:" + s.toString());
1056
- const r2 = await fetch(s.toString(), { method: "GET", headers: i2 });
1057
- if (!r2.ok) throw new n(`Failed to resolve page: ${r2.status} ${r2.statusText}`, { pageId: t3, status: r2.status });
1058
- const o2 = await r2.json();
1059
- if (!this.isValidPageResolveResponse(o2)) throw new n("Invalid page resolve response", { pageId: t3 });
1060
- return o2;
3230
+ async callResolveViaAdapter(t3, e) {
3231
+ const s = await this.options.userApiAdapter.resolvePage({ pageId: t3, uid: e == null ? void 0 : e.uid, deviceId: e == null ? void 0 : e.deviceId, env: this.options.env, channel: this.options.channel, previewToken: this.options.previewToken });
3232
+ if (!this.isValidPageResolveResponse(s)) throw new r("Invalid page resolve response", { pageId: t3 });
3233
+ return s;
1061
3234
  }
1062
3235
  async loadFromCdn(t3, e) {
1063
3236
  try {
1064
3237
  const s = await fetch(t3.snapshotUrl, { headers: this.buildHeaders() });
1065
- if (!s.ok) throw new n(`Failed to load snapshot: ${s.status}`, { pageId: e });
1066
- const i2 = await s.json();
1067
- return this.convertSnapshotToResult(i2, t3, e);
3238
+ if (!s.ok) throw new r(`Failed to load snapshot: ${s.status}`, { pageId: e });
3239
+ const i = await s.json();
3240
+ return this.convertSnapshotToResult(i, t3, e);
1068
3241
  } catch (t4) {
1069
- if (t4 instanceof n) throw t4;
1070
- throw new n(`Failed to load from CDN: ${t4 instanceof Error ? t4.message : "Unknown error"}`, { pageId: e });
3242
+ if (t4 instanceof r) throw t4;
3243
+ throw new r(`Failed to load from CDN: ${t4 instanceof Error ? t4.message : "Unknown error"}`, { pageId: e });
1071
3244
  }
1072
3245
  }
1073
3246
  convertSnapshotToResult(t3, e, s) {
1074
3247
  var _a, _b, _c, _d;
1075
- const i2 = this.convertSnapshotPageToPageSchema(t3.page), n2 = this.convertSnapshotManifestToPageManifest(t3.manifest), r2 = ((_b = (_a = t3.definitionsDigest) == null ? void 0 : _a.actions) == null ? void 0 : _b.map((t4) => t4.versionId)) || [], o2 = ((_d = (_c = t3.definitionsDigest) == null ? void 0 : _c.queries) == null ? void 0 : _d.map((t4) => t4.versionId)) || [];
1076
- return n2.actionDefinitionVersionIds = r2, n2.dataQueryVersionIds = o2, { pageId: e.pageId, pageVersionId: e.resolvedVersionId, pageJson: i2, manifest: n2, runtimeConfig: { blockedComponents: e.ops.blockedComponents.map((t4) => ({ name: t4.name, version: t4.version || "", reason: t4.reason })), killSwitches: e.ops.killSwitch.map((t4) => ({ type: t4.targetType, enabled: t4.enabled })), features: e.ops.flags }, isPreview: "preview" === this.options.env || !!this.options.previewToken };
3248
+ const i = this.convertSnapshotPageToPageSchema(t3.page), n2 = this.convertSnapshotManifestToPageManifest(t3.manifest), r2 = ((_b = (_a = t3.definitionsDigest) == null ? void 0 : _a.actions) == null ? void 0 : _b.map((t4) => t4.versionId)) || [], o2 = ((_d = (_c = t3.definitionsDigest) == null ? void 0 : _c.queries) == null ? void 0 : _d.map((t4) => t4.versionId)) || [];
3249
+ return n2.actionDefinitionVersionIds = r2, n2.dataQueryVersionIds = o2, { pageId: e.pageId, pageVersionId: e.resolvedVersionId, pageJson: i, manifest: n2, runtimeConfig: { blockedComponents: e.ops.blockedComponents.map((t4) => ({ name: t4.name, version: t4.version || "", reason: t4.reason })), killSwitches: e.ops.killSwitch.map((t4) => ({ type: t4.targetType, enabled: t4.enabled })), features: e.ops.flags }, isPreview: "preview" === this.options.env || !!this.options.previewToken };
1077
3250
  }
1078
3251
  convertSnapshotPageToPageSchema(t3) {
1079
3252
  const e = { layout: { canvasType: t3.config.canvasType, canvasSize: t3.config.canvasSize }, styles: t3.config.background || t3.config.cssVariables ? { background: t3.config.background, cssVariables: t3.config.cssVariables } : void 0 }, s = Object.keys(t3.initialState).length > 0 ? { fields: Object.keys(t3.initialState).reduce((e2, s2) => {
1080
- const i3 = t3.initialState[s2];
3253
+ const i2 = t3.initialState[s2];
1081
3254
  let n2 = "string";
1082
- return "number" == typeof i3 ? n2 = "number" : "boolean" == typeof i3 ? n2 = "boolean" : Array.isArray(i3) ? n2 = "array" : null !== i3 && "object" == typeof i3 && (n2 = "object"), e2[s2] = { type: n2, initialValue: i3 }, e2;
1083
- }, {}) } : void 0, i2 = { title: t3.title };
1084
- return { schemaVersion: t3.schemaVersion, pageId: t3.pageId, pageVersion: t3.pageVersion, runtime: { name: "djvlc-runtime", version: "1.0.0" }, meta: i2, config: e, seo: t3.seo, state: s, dataBindings: t3.bindings, root: t3.root };
3255
+ return "number" == typeof i2 ? n2 = "number" : "boolean" == typeof i2 ? n2 = "boolean" : Array.isArray(i2) ? n2 = "array" : null !== i2 && "object" == typeof i2 && (n2 = "object"), e2[s2] = { type: n2, initialValue: i2 }, e2;
3256
+ }, {}) } : void 0, i = { title: t3.title };
3257
+ return { schemaVersion: t3.schemaVersion, pageId: t3.pageId, pageVersion: t3.pageVersion, runtime: { name: "djvlc-runtime", version: "1.0.0" }, meta: i, config: e, seo: t3.seo, state: s, dataBindings: t3.bindings, root: t3.root };
1085
3258
  }
1086
3259
  convertSnapshotManifestToPageManifest(t3) {
1087
3260
  return { id: "", pageVersionId: "", manifestVersion: "1.0.0", createdAt: (/* @__PURE__ */ new Date()).toISOString(), contentHash: "", components: t3.components.map((t4) => ({ componentId: "", name: t4.name, version: t4.version, entry: `${t4.assetsUrl}/${t4.entrypoints.js}`, styleEntry: t4.entrypoints.css ? `${t4.assetsUrl}/${t4.entrypoints.css}` : void 0, integrity: t4.integrity, preload: t4.preload, priority: t4.priority })), actionDefinitionVersionIds: [], dataQueryVersionIds: [], runtimeVersion: { min: t3.runtime.minVersion, recommended: t3.runtime.version } };
@@ -1100,8 +3273,7 @@ var i = class extends Error {
1100
3273
  else this.cache.clear();
1101
3274
  }
1102
3275
  buildHeaders() {
1103
- const t3 = { "Content-Type": "application/json", ...this.options.headers };
1104
- return this.options.authToken && (t3.Authorization = `Bearer ${this.options.authToken}`), t3;
3276
+ return { "Content-Type": "application/json", ...this.options.headers };
1105
3277
  }
1106
3278
  getCacheKey(t3, e) {
1107
3279
  const s = [t3, this.options.env, this.options.channel];
@@ -1115,17 +3287,17 @@ var i = class extends Error {
1115
3287
  log(t3, e) {
1116
3288
  this.options.logger && this.options.logger[t3](e);
1117
3289
  }
1118
- }, p = class {
3290
+ }, f = { sha256: "SHA-256", sha384: "SHA-384", sha512: "SHA-512" }, m = class {
1119
3291
  constructor(t3) {
1120
3292
  this.loadedComponents = /* @__PURE__ */ new Map(), this.loadingPromises = /* @__PURE__ */ new Map(), this.options = { enableSRI: true, concurrency: 4, timeout: 3e4, blockedComponents: [], ...t3 }, this.blockedSet = new Set(this.options.blockedComponents);
1121
3293
  }
1122
3294
  async load(t3) {
1123
3295
  const e = this.getComponentKey(t3.name, t3.version);
1124
- if (this.isBlocked(t3.name, t3.version)) throw new a(t3.name, t3.version, "Component is blocked");
3296
+ if (this.isBlocked(t3.name, t3.version)) throw new c(t3.name, t3.version, "Component is blocked");
1125
3297
  const s = this.loadedComponents.get(e);
1126
3298
  if (s) return s;
1127
- const i2 = this.loadingPromises.get(e);
1128
- if (i2) return i2;
3299
+ const i = this.loadingPromises.get(e);
3300
+ if (i) return i;
1129
3301
  const n2 = this.loadComponent(t3);
1130
3302
  this.loadingPromises.set(e, n2);
1131
3303
  try {
@@ -1136,16 +3308,16 @@ var i = class extends Error {
1136
3308
  }
1137
3309
  }
1138
3310
  async loadAll(t3) {
1139
- const e = /* @__PURE__ */ new Map(), { concurrency: s = 4 } = this.options, i2 = t3.components;
1140
- for (let t4 = 0; t4 < i2.length; t4 += s) {
1141
- const n2 = i2.slice(t4, t4 + s).map(async (t5) => {
1142
- const s2 = this.getComponentKey(t5.name, t5.version), i3 = performance.now();
3311
+ const e = /* @__PURE__ */ new Map(), { concurrency: s = 4 } = this.options, i = t3.components;
3312
+ for (let t4 = 0; t4 < i.length; t4 += s) {
3313
+ const n2 = i.slice(t4, t4 + s).map(async (t5) => {
3314
+ const s2 = this.getComponentKey(t5.name, t5.version), i2 = performance.now();
1143
3315
  try {
1144
3316
  const n3 = await this.load(t5);
1145
- e.set(s2, { name: t5.name, version: t5.version, status: "loaded", component: n3.Component, loadTime: performance.now() - i3 });
3317
+ e.set(s2, { name: t5.name, version: t5.version, status: "loaded", component: n3.Component, loadTime: performance.now() - i2 });
1146
3318
  } catch (n3) {
1147
- const r2 = n3 instanceof a ? "blocked" : "failed";
1148
- if (e.set(s2, { name: t5.name, version: t5.version, status: r2, error: n3 instanceof Error ? n3.message : "Unknown error", loadTime: performance.now() - i3 }), "critical" === t5.priority) throw n3;
3319
+ const r2 = n3 instanceof c ? "blocked" : "failed";
3320
+ if (e.set(s2, { name: t5.name, version: t5.version, status: r2, error: n3 instanceof Error ? n3.message : "Unknown error", loadTime: performance.now() - i2 }), "critical" === t5.priority) throw n3;
1149
3321
  }
1150
3322
  });
1151
3323
  await Promise.all(n2);
@@ -1174,42 +3346,47 @@ var i = class extends Error {
1174
3346
  const e = performance.now(), s = this.resolveUrl(t3.entry);
1175
3347
  this.log("debug", `Loading component ${t3.name}@${t3.version}`);
1176
3348
  try {
1177
- const i2 = await this.fetchWithTimeout(s);
1178
- if (!i2.ok) throw new r(t3.name, t3.version, `Failed to fetch component: ${i2.status} ${i2.statusText}`);
1179
- const n2 = await i2.text();
3349
+ const i = await this.fetchWithTimeout(s);
3350
+ if (!i.ok) throw new o(t3.name, t3.version, `Failed to fetch component: ${i.status} ${i.statusText}`);
3351
+ const n2 = await i.text();
1180
3352
  this.options.enableSRI && t3.integrity && await this.validateIntegrity(t3, n2);
1181
- const o2 = await this.executeScript(n2, t3), a2 = performance.now() - e;
1182
- return this.log("info", `Component ${t3.name}@${t3.version} loaded in ${a2.toFixed(2)}ms`), { name: t3.name, version: t3.version, Component: o2, loadTime: a2 };
3353
+ const r2 = await this.executeScript(n2, t3), a2 = performance.now() - e;
3354
+ return this.log("info", `Component ${t3.name}@${t3.version} loaded in ${a2.toFixed(2)}ms`), { name: t3.name, version: t3.version, Component: r2, loadTime: a2 };
1183
3355
  } catch (e2) {
1184
- if (e2 instanceof r || e2 instanceof o || e2 instanceof a) throw e2;
1185
- throw new r(t3.name, t3.version, `Failed to load component: ${e2 instanceof Error ? e2.message : "Unknown error"}`);
3356
+ if (e2 instanceof o || e2 instanceof a || e2 instanceof c) throw e2;
3357
+ throw new o(t3.name, t3.version, `Failed to load component: ${e2 instanceof Error ? e2.message : "Unknown error"}`);
1186
3358
  }
1187
3359
  }
1188
3360
  async fetchWithTimeout(t3) {
1189
- const e = new AbortController(), s = setTimeout(() => e.abort(), this.options.timeout);
3361
+ const e = new AbortController(), s = setTimeout(() => e.abort(), this.options.timeout), i = { signal: e.signal, credentials: "omit", headers: this.options.headers ? { ...this.options.headers } : void 0 }, n2 = this.options.fetchComponentScript ?? fetch;
1190
3362
  try {
1191
- return await fetch(t3, { signal: e.signal, credentials: "omit" });
3363
+ return await n2(t3, i);
1192
3364
  } finally {
1193
3365
  clearTimeout(s);
1194
3366
  }
1195
3367
  }
1196
3368
  async validateIntegrity(t3, e) {
1197
3369
  if (!t3.integrity) return;
1198
- const [s, i2] = t3.integrity.split("-");
1199
- if (!s || !i2) throw new o(t3.name, t3.version, t3.integrity, "Invalid format");
1200
- const n2 = await crypto.subtle.digest(s.toUpperCase(), new TextEncoder().encode(e)), r2 = Array.from(new Uint8Array(n2)), a2 = btoa(String.fromCharCode(...r2));
1201
- if (a2 !== i2) throw new o(t3.name, t3.version, i2, a2);
3370
+ const [s, i] = t3.integrity.split("-");
3371
+ if (!s || !i) throw new a(t3.name, t3.version, t3.integrity, "Invalid format");
3372
+ const n2 = f[s.toLowerCase()];
3373
+ if (!n2) throw new a(t3.name, t3.version, t3.integrity, `Unsupported SRI algorithm: ${s}, expected sha256/sha384/sha512`);
3374
+ const r2 = await crypto.subtle.digest(n2, new TextEncoder().encode(e)), o2 = Array.from(new Uint8Array(r2)), c2 = btoa(String.fromCharCode(...o2));
3375
+ if (c2 !== i) throw new a(t3.name, t3.version, i, c2);
1202
3376
  }
1203
3377
  async executeScript(t3, e) {
1204
- const s = new Blob([t3], { type: "application/javascript" }), i2 = URL.createObjectURL(s);
3378
+ const s = new Blob([t3], { type: "application/javascript" }), i = URL.createObjectURL(s);
1205
3379
  try {
1206
- const t4 = await import(i2), s2 = t4.default || t4[e.name] || t4.Component;
1207
- if (!s2) throw new r(e.name, e.version, "Component module does not export a valid component");
3380
+ const t4 = await import(i), s2 = t4.default ?? t4[e.name] ?? t4[this.kebabToPascal(e.name)] ?? t4.Component;
3381
+ if (!s2) throw new o(e.name, e.version, "Component module does not export a valid component (expected default or Component)");
1208
3382
  return s2;
1209
3383
  } finally {
1210
- URL.revokeObjectURL(i2);
3384
+ URL.revokeObjectURL(i);
1211
3385
  }
1212
3386
  }
3387
+ kebabToPascal(t3) {
3388
+ return t3.split("-").map((t4) => t4.charAt(0).toUpperCase() + t4.slice(1).toLowerCase()).join("");
3389
+ }
1213
3390
  resolveUrl(t3) {
1214
3391
  return t3.startsWith("http://") || t3.startsWith("https://") ? t3 : `${this.options.cdnBaseUrl}/${t3.replace(/^\//, "")}`;
1215
3392
  }
@@ -1219,7 +3396,7 @@ var i = class extends Error {
1219
3396
  log(t3, e) {
1220
3397
  this.options.logger && this.options.logger[t3](e);
1221
3398
  }
1222
- }, f = class {
3399
+ }, g = class {
1223
3400
  constructor(t3) {
1224
3401
  this.preconnectedHosts = /* @__PURE__ */ new Set(), this.preloadedAssets = /* @__PURE__ */ new Set(), this.options = t3;
1225
3402
  }
@@ -1238,35 +3415,35 @@ var i = class extends Error {
1238
3415
  preloadScript(t3, e) {
1239
3416
  if (this.preloadedAssets.has(t3)) return;
1240
3417
  const s = document.createElement("link");
1241
- s.rel = "preload", s.as = "script", s.href = t3, e && (s.integrity = e, s.crossOrigin = "anonymous"), document.head.appendChild(s), this.preloadedAssets.add(t3);
3418
+ s.rel = "preload", s.setAttribute("as", "script"), s.href = t3, e && (s.setAttribute("integrity", e), s.setAttribute("crossorigin", "anonymous")), document.head.appendChild(s), this.preloadedAssets.add(t3);
1242
3419
  }
1243
3420
  preloadStyle(t3, e) {
1244
3421
  if (this.preloadedAssets.has(t3)) return;
1245
3422
  const s = document.createElement("link");
1246
- s.rel = "preload", s.as = "style", s.href = t3, e && (s.integrity = e, s.crossOrigin = "anonymous"), document.head.appendChild(s), this.preloadedAssets.add(t3);
3423
+ s.rel = "preload", s.setAttribute("as", "style"), s.href = t3, e && (s.setAttribute("integrity", e), s.setAttribute("crossorigin", "anonymous")), document.head.appendChild(s), this.preloadedAssets.add(t3);
1247
3424
  }
1248
3425
  preloadImage(t3) {
1249
3426
  if (this.preloadedAssets.has(t3)) return;
1250
3427
  const e = document.createElement("link");
1251
- e.rel = "preload", e.as = "image", e.href = t3, document.head.appendChild(e), this.preloadedAssets.add(t3);
3428
+ e.rel = "preload", e.setAttribute("as", "image"), e.href = t3, document.head.appendChild(e), this.preloadedAssets.add(t3);
1252
3429
  }
1253
3430
  prefetch(t3, e) {
1254
3431
  const s = document.createElement("link");
1255
- s.rel = "prefetch", s.href = t3, e && (s.as = e), document.head.appendChild(s);
3432
+ s.rel = "prefetch", s.href = t3, e && s.setAttribute("as", e), document.head.appendChild(s);
1256
3433
  }
1257
3434
  loadStylesheet(t3, e) {
1258
- return new Promise((s, i2) => {
3435
+ return new Promise((s, i) => {
1259
3436
  const n2 = document.createElement("link");
1260
- n2.rel = "stylesheet", n2.href = t3, e && (n2.integrity = e, n2.crossOrigin = "anonymous"), n2.onload = () => s(), n2.onerror = () => i2(new Error(`Failed to load stylesheet: ${t3}`)), document.head.appendChild(n2);
3437
+ n2.rel = "stylesheet", n2.href = t3, e && (n2.integrity = e, n2.crossOrigin = "anonymous"), n2.onload = () => s(), n2.onerror = () => i(new Error(`Failed to load stylesheet: ${t3}`)), document.head.appendChild(n2);
1261
3438
  });
1262
3439
  }
1263
3440
  loadScript(t3, e) {
1264
- return new Promise((s, i2) => {
3441
+ return new Promise((s, i) => {
1265
3442
  const n2 = document.createElement("script");
1266
- n2.src = t3, n2.async = true, e && (n2.integrity = e, n2.crossOrigin = "anonymous"), n2.onload = () => s(), n2.onerror = () => i2(new Error(`Failed to load script: ${t3}`)), document.body.appendChild(n2);
3443
+ n2.src = t3, n2.async = true, e && (n2.integrity = e, n2.crossOrigin = "anonymous"), n2.onload = () => s(), n2.onerror = () => i(new Error(`Failed to load script: ${t3}`)), document.body.appendChild(n2);
1267
3444
  });
1268
3445
  }
1269
- }, m = class {
3446
+ }, y = class {
1270
3447
  constructor() {
1271
3448
  this.listeners = /* @__PURE__ */ new Set(), this.changeCallbacks = /* @__PURE__ */ new Set(), this.state = this.createInitialState();
1272
3449
  }
@@ -1286,8 +3463,8 @@ var i = class extends Error {
1286
3463
  initializePageState(t3) {
1287
3464
  const e = {};
1288
3465
  if (t3.state && t3.state.fields) {
1289
- for (const [s, i2] of Object.entries(t3.state.fields)) if (i2 && "object" == typeof i2) {
1290
- const t4 = i2;
3466
+ for (const [s, i] of Object.entries(t3.state.fields)) if (i && "object" == typeof i) {
3467
+ const t4 = i;
1291
3468
  e[s] = t4.initialValue;
1292
3469
  }
1293
3470
  }
@@ -1312,9 +3489,9 @@ var i = class extends Error {
1312
3489
  }
1313
3490
  setVariables(t3) {
1314
3491
  const e = [];
1315
- for (const [s, i2] of Object.entries(t3)) {
3492
+ for (const [s, i] of Object.entries(t3)) {
1316
3493
  const t4 = this.getVariable(s);
1317
- e.push({ key: s, oldValue: t4, newValue: i2 });
3494
+ e.push({ key: s, oldValue: t4, newValue: i });
1318
3495
  }
1319
3496
  this.setState({ variables: { ...this.state.variables, ...t3 } }), e.forEach((t4) => this.notifyChange(t4));
1320
3497
  }
@@ -1379,26 +3556,26 @@ var i = class extends Error {
1379
3556
  }
1380
3557
  getNestedValue(t3, e) {
1381
3558
  const s = e.split(".");
1382
- let i2 = t3;
3559
+ let i = t3;
1383
3560
  for (const t4 of s) {
1384
- if (null == i2) return;
1385
- i2 = i2[t4];
3561
+ if (null == i) return;
3562
+ i = i[t4];
1386
3563
  }
1387
- return i2;
3564
+ return i;
1388
3565
  }
1389
3566
  setNestedValue(t3, e, s) {
1390
- const i2 = e.split(".");
3567
+ const i = e.split(".");
1391
3568
  let n2 = t3;
1392
- for (let t4 = 0; t4 < i2.length - 1; t4++) {
1393
- const e2 = i2[t4];
3569
+ for (let t4 = 0; t4 < i.length - 1; t4++) {
3570
+ const e2 = i[t4];
1394
3571
  void 0 !== n2[e2] && null !== n2[e2] || (n2[e2] = {}), n2 = n2[e2];
1395
3572
  }
1396
- n2[i2[i2.length - 1]] = s;
3573
+ n2[i[i.length - 1]] = s;
1397
3574
  }
1398
3575
  createInitialState() {
1399
3576
  return { phase: "idle", page: null, variables: {}, queries: {}, components: /* @__PURE__ */ new Map(), error: null, destroyed: false };
1400
3577
  }
1401
- }, g = class {
3578
+ }, b = class {
1402
3579
  constructor(t3) {
1403
3580
  this.bindings = /* @__PURE__ */ new Map(), this.dependencyGraph = /* @__PURE__ */ new Map(), this.bindingDependencies = /* @__PURE__ */ new Map(), this.options = t3;
1404
3581
  }
@@ -1413,77 +3590,77 @@ var i = class extends Error {
1413
3590
  var _a;
1414
3591
  for (const [e, s] of this.bindings) {
1415
3592
  if (e === t3.id) continue;
1416
- const i2 = s.binding;
1417
- ((_a = i2.dependencies) == null ? void 0 : _a.includes(t3.targetState)) && (this.bindingDependencies.has(t3.id) || this.bindingDependencies.set(t3.id, /* @__PURE__ */ new Set()), this.bindingDependencies.get(t3.id).add(e));
3593
+ const i = s.binding;
3594
+ ((_a = i.dependencies) == null ? void 0 : _a.includes(t3.targetState)) && (this.bindingDependencies.has(t3.id) || this.bindingDependencies.set(t3.id, /* @__PURE__ */ new Set()), this.bindingDependencies.get(t3.id).add(e));
1418
3595
  }
1419
- if (t3.dependencies) for (const e of t3.dependencies) for (const [s, i2] of this.bindings) s !== t3.id && i2.binding.targetState === e && (this.bindingDependencies.has(s) || this.bindingDependencies.set(s, /* @__PURE__ */ new Set()), this.bindingDependencies.get(s).add(t3.id));
3596
+ if (t3.dependencies) for (const e of t3.dependencies) for (const [s, i] of this.bindings) s !== t3.id && i.binding.targetState === e && (this.bindingDependencies.has(s) || this.bindingDependencies.set(s, /* @__PURE__ */ new Set()), this.bindingDependencies.get(s).add(t3.id));
1420
3597
  }
1421
3598
  async initializeBindings(t3) {
1422
3599
  var _a, _b;
1423
3600
  const e = [];
1424
3601
  for (const t4 of this.bindings.values()) "eager" === t4.binding.loadStrategy && e.push(t4.binding);
1425
- const s = this.topologicalSort(e), i2 = this.createLoadBatches(s);
1426
- for (const e2 of i2) {
1427
- const s2 = await Promise.allSettled(e2.map((e3) => this.loadBinding(e3.id, t3))), i3 = /* @__PURE__ */ new Map();
3602
+ const s = this.topologicalSort(e), i = this.createLoadBatches(s);
3603
+ for (const e2 of i) {
3604
+ const s2 = await Promise.allSettled(e2.map((e3) => this.loadBinding(e3.id, t3))), i2 = /* @__PURE__ */ new Map();
1428
3605
  s2.forEach((t4, s3) => {
1429
3606
  const n2 = e2[s3].id;
1430
- "fulfilled" === t4.status ? i3.set(n2, { success: true, data: t4.value }) : i3.set(n2, { success: false, error: t4.reason });
1431
- }), (_b = (_a = this.options).onBatchComplete) == null ? void 0 : _b.call(_a, i3);
3607
+ "fulfilled" === t4.status ? i2.set(n2, { success: true, data: t4.value }) : i2.set(n2, { success: false, error: t4.reason });
3608
+ }), (_b = (_a = this.options).onBatchComplete) == null ? void 0 : _b.call(_a, i2);
1432
3609
  }
1433
3610
  }
1434
3611
  topologicalSort(t3) {
1435
- const e = new Map(t3.map((t4) => [t4.id, t4])), s = /* @__PURE__ */ new Set(), i2 = [], n2 = (t4) => {
3612
+ const e = new Map(t3.map((t4) => [t4.id, t4])), s = /* @__PURE__ */ new Set(), i = [], n2 = (t4) => {
1436
3613
  if (!s.has(t4.id)) {
1437
- if (s.add(t4.id), t4.dependencies) for (const i3 of t4.dependencies) for (const [t5, r2] of e) r2.targetState !== i3 || s.has(t5) || n2(r2);
1438
- i2.push(t4);
3614
+ if (s.add(t4.id), t4.dependencies) for (const i2 of t4.dependencies) for (const [t5, r2] of e) r2.targetState !== i2 || s.has(t5) || n2(r2);
3615
+ i.push(t4);
1439
3616
  }
1440
3617
  };
1441
3618
  for (const e2 of t3) n2(e2);
1442
- return i2;
3619
+ return i;
1443
3620
  }
1444
3621
  createLoadBatches(t3) {
1445
3622
  const e = [], s = /* @__PURE__ */ new Set();
1446
3623
  for (; s.size < t3.length; ) {
1447
- const i2 = [];
3624
+ const i = [];
1448
3625
  for (const e2 of t3) {
1449
3626
  if (s.has(e2.id)) continue;
1450
3627
  let n2 = true;
1451
- if (e2.dependencies) for (const i3 of e2.dependencies) {
1452
- for (const e3 of t3) if (e3.targetState === i3 && !s.has(e3.id)) {
3628
+ if (e2.dependencies) for (const i2 of e2.dependencies) {
3629
+ for (const e3 of t3) if (e3.targetState === i2 && !s.has(e3.id)) {
1453
3630
  n2 = false;
1454
3631
  break;
1455
3632
  }
1456
3633
  if (!n2) break;
1457
3634
  }
1458
- n2 && i2.push(e2);
3635
+ n2 && i.push(e2);
1459
3636
  }
1460
- if (0 === i2.length) {
3637
+ if (0 === i.length) {
1461
3638
  for (const e2 of t3) if (!s.has(e2.id)) {
1462
- i2.push(e2), this.log("warn", `Possible circular dependency detected at binding: ${e2.id}`);
3639
+ i.push(e2), this.log("warn", `Possible circular dependency detected at binding: ${e2.id}`);
1463
3640
  break;
1464
3641
  }
1465
3642
  }
1466
- i2.forEach((t4) => s.add(t4.id)), i2.length > 0 && e.push(i2);
3643
+ i.forEach((t4) => s.add(t4.id)), i.length > 0 && e.push(i);
1467
3644
  }
1468
3645
  return e;
1469
3646
  }
1470
3647
  async loadBinding(t3, e, s = false) {
1471
3648
  var _a, _b, _c;
1472
- const i2 = this.bindings.get(t3);
1473
- if (!i2) throw new l(t3, `Data binding not found: ${t3}`);
1474
- const { binding: n2 } = i2;
3649
+ const i = this.bindings.get(t3);
3650
+ if (!i) throw new l(t3, `Data binding not found: ${t3}`);
3651
+ const { binding: n2 } = i;
1475
3652
  if (!n2.condition || this.evaluateCondition(n2.condition, e)) {
1476
- if (!s && this.isCacheValid(i2)) return this.log("debug", `Binding ${t3} returned from cache`), i2.cachedData;
1477
- if (i2.loading) this.log("debug", `Binding ${t3} is already loading`);
3653
+ if (!s && this.isCacheValid(i)) return this.log("debug", `Binding ${t3} returned from cache`), i.cachedData;
3654
+ if (i.loading) this.log("debug", `Binding ${t3} is already loading`);
1478
3655
  else {
1479
- i2.loading = true;
3656
+ i.loading = true;
1480
3657
  try {
1481
3658
  const s2 = this.resolveParams(n2.params || {}, e), r2 = await this.executeWithRetry(n2, s2), o2 = n2.transform ? this.applyTransform(r2, n2.transform, e) : r2;
1482
- return i2.cachedData = o2, i2.lastLoadTime = Date.now(), ((_a = n2.cache) == null ? void 0 : _a.ttl) && (i2.cacheExpireTime = Date.now() + 1e3 * n2.cache.ttl), i2.retryCount = 0, this.options.stateSetter.setVariable(n2.targetState, o2), this.setupAutoRefresh(i2, e), (_c = (_b = this.options).onDataLoaded) == null ? void 0 : _c.call(_b, t3, o2), this.log("info", `Binding ${t3} loaded successfully`), o2;
3659
+ return i.cachedData = o2, i.lastLoadTime = Date.now(), ((_a = n2.cache) == null ? void 0 : _a.ttl) && (i.cacheExpireTime = Date.now() + 1e3 * n2.cache.ttl), i.retryCount = 0, this.options.stateSetter.setVariable(n2.targetState, o2), this.setupAutoRefresh(i, e), (_c = (_b = this.options).onDataLoaded) == null ? void 0 : _c.call(_b, t3, o2), this.log("info", `Binding ${t3} loaded successfully`), o2;
1483
3660
  } catch (t4) {
1484
- throw await this.handleLoadError(i2, t4, e), t4;
3661
+ throw await this.handleLoadError(i, t4, e), t4;
1485
3662
  } finally {
1486
- i2.loading = false;
3663
+ i.loading = false;
1487
3664
  }
1488
3665
  }
1489
3666
  } else this.log("debug", `Binding ${t3} skipped by condition`);
@@ -1499,8 +3676,8 @@ var i = class extends Error {
1499
3676
  const s = this.dependencyGraph.get(t3);
1500
3677
  if (!s || 0 === s.size) return;
1501
3678
  this.log("debug", `State ${t3} changed, refreshing dependent bindings`);
1502
- const i2 = Array.from(s).map((t4) => this.loadBinding(t4, e, true));
1503
- await Promise.allSettled(i2);
3679
+ const i = Array.from(s).map((t4) => this.loadBinding(t4, e, true));
3680
+ await Promise.allSettled(i);
1504
3681
  }
1505
3682
  async triggerManualLoad(t3, e) {
1506
3683
  const s = this.bindings.get(t3);
@@ -1508,8 +3685,8 @@ var i = class extends Error {
1508
3685
  return "manual" !== s.binding.loadStrategy && this.log("warn", `Binding ${t3} is not manual strategy`), this.loadBinding(t3, e, true);
1509
3686
  }
1510
3687
  checkVisibility(t3, e, s) {
1511
- const i2 = this.bindings.get(t3);
1512
- i2 && "lazy" === i2.binding.loadStrategy && e && !i2.lastLoadTime && this.loadBinding(t3, s).catch((e2) => {
3688
+ const i = this.bindings.get(t3);
3689
+ i && "lazy" === i.binding.loadStrategy && e && !i.lastLoadTime && this.loadBinding(t3, s).catch((e2) => {
1513
3690
  this.log("error", `Lazy binding ${t3} failed to load`, e2);
1514
3691
  });
1515
3692
  }
@@ -1519,7 +3696,7 @@ var i = class extends Error {
1519
3696
  }
1520
3697
  async executeWithRetry(t3, e) {
1521
3698
  var _a, _b, _c, _d, _e, _f;
1522
- const s = ((_b = (_a = t3.onError) == null ? void 0 : _a.retry) == null ? void 0 : _b.maxRetries) ?? 0, i2 = ((_d = (_c = t3.onError) == null ? void 0 : _c.retry) == null ? void 0 : _d.backoffMs) ?? 1e3, n2 = ((_f = (_e = t3.onError) == null ? void 0 : _e.retry) == null ? void 0 : _f.backoff) ?? "fixed";
3699
+ const s = ((_b = (_a = t3.onError) == null ? void 0 : _a.retry) == null ? void 0 : _b.maxRetries) ?? 0, i = ((_d = (_c = t3.onError) == null ? void 0 : _c.retry) == null ? void 0 : _d.backoffMs) ?? 1e3, n2 = ((_f = (_e = t3.onError) == null ? void 0 : _e.retry) == null ? void 0 : _f.backoff) ?? "fixed";
1523
3700
  let r2;
1524
3701
  for (let o2 = 0; o2 <= s; o2++) try {
1525
3702
  const s2 = await this.options.requester.requestData(t3.queryVersionId, e);
@@ -1527,7 +3704,7 @@ var i = class extends Error {
1527
3704
  return s2.data;
1528
3705
  } catch (t4) {
1529
3706
  if (r2 = t4, this.log("warn", `Query attempt ${o2 + 1}/${s + 1} failed:`, t4), o2 < s) {
1530
- const t5 = "exponential" === n2 ? i2 * Math.pow(2, o2) : i2;
3707
+ const t5 = "exponential" === n2 ? i * Math.pow(2, o2) : i;
1531
3708
  await this.delay(t5);
1532
3709
  }
1533
3710
  }
@@ -1535,8 +3712,8 @@ var i = class extends Error {
1535
3712
  }
1536
3713
  async handleLoadError(t3, e, s) {
1537
3714
  var _a, _b;
1538
- const { binding: i2 } = t3, n2 = i2.onError;
1539
- t3.retryCount++, void 0 !== (n2 == null ? void 0 : n2.fallbackValue) && this.options.stateSetter.setVariable(i2.targetState, n2.fallbackValue), (n2 == null ? void 0 : n2.showError) && ((_b = (_a = this.options).onDataError) == null ? void 0 : _b.call(_a, i2.id, e)), this.log("error", `Binding ${i2.id} load failed:`, e);
3715
+ const { binding: i } = t3, n2 = i.onError;
3716
+ t3.retryCount++, void 0 !== (n2 == null ? void 0 : n2.fallbackValue) && this.options.stateSetter.setVariable(i.targetState, n2.fallbackValue), (n2 == null ? void 0 : n2.showError) && ((_b = (_a = this.options).onDataError) == null ? void 0 : _b.call(_a, i.id, e)), this.log("error", `Binding ${i.id} load failed:`, e);
1540
3717
  }
1541
3718
  setupAutoRefresh(t3, e) {
1542
3719
  t3.refreshTimer && (clearInterval(t3.refreshTimer), t3.refreshTimer = void 0);
@@ -1552,7 +3729,7 @@ var i = class extends Error {
1552
3729
  }
1553
3730
  resolveParams(t3, e) {
1554
3731
  const s = {};
1555
- for (const [i2, n2] of Object.entries(t3)) s[i2] = this.resolveValue(n2, e);
3732
+ for (const [i, n2] of Object.entries(t3)) s[i] = this.resolveValue(n2, e);
1556
3733
  return s;
1557
3734
  }
1558
3735
  resolveValue(t3, e) {
@@ -1560,19 +3737,19 @@ var i = class extends Error {
1560
3737
  if ("object" == typeof t3 && !Array.isArray(t3)) {
1561
3738
  const s = t3;
1562
3739
  if ("expression" === s.type || "binding" === s.type) return this.options.expressionEngine.evaluateWithFallback(s.expression, e, s.fallback);
1563
- const i2 = {};
1564
- for (const [t4, n2] of Object.entries(s)) i2[t4] = this.resolveValue(n2, e);
1565
- return i2;
3740
+ const i = {};
3741
+ for (const [t4, n2] of Object.entries(s)) i[t4] = this.resolveValue(n2, e);
3742
+ return i;
1566
3743
  }
1567
3744
  return "string" == typeof t3 && t3.includes("${") ? this.options.expressionEngine.evaluateTemplate(t3, e) : t3;
1568
3745
  }
1569
3746
  evaluateCondition(t3, e) {
1570
- const s = void 0 === t3.fallback || t3.fallback, i2 = this.options.expressionEngine.evaluateWithFallback(t3.value, e, s);
1571
- return Boolean(i2);
3747
+ const s = void 0 === t3.fallback || t3.fallback, i = this.options.expressionEngine.evaluateWithFallback(t3.value, e, s);
3748
+ return Boolean(i);
1572
3749
  }
1573
3750
  applyTransform(t3, e, s) {
1574
- const i2 = { ...s, local: { ...s.local || {}, $data: t3, $response: t3 } }, n2 = void 0 !== e.fallback ? e.fallback : t3;
1575
- return this.options.expressionEngine.evaluateWithFallback(e.value, i2, n2);
3751
+ const i = { ...s, local: { ...s.local || {}, $data: t3, $response: t3 } }, n2 = void 0 !== e.fallback ? e.fallback : t3;
3752
+ return this.options.expressionEngine.evaluateWithFallback(e.value, i, n2);
1576
3753
  }
1577
3754
  delay(t3) {
1578
3755
  return new Promise((e) => setTimeout(e, t3));
@@ -1580,7 +3757,7 @@ var i = class extends Error {
1580
3757
  log(t3, e, ...s) {
1581
3758
  this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
1582
3759
  }
1583
- }, y = class {
3760
+ }, w = class {
1584
3761
  constructor(t3 = {}) {
1585
3762
  this.handlers = /* @__PURE__ */ new Map(), this.options = { debug: false, maxListeners: 100, ...t3 };
1586
3763
  }
@@ -1624,7 +3801,7 @@ var i = class extends Error {
1624
3801
  log(t3, e, ...s) {
1625
3802
  this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
1626
3803
  }
1627
- }, b = class t {
3804
+ }, v = class t {
1628
3805
  constructor(t3) {
1629
3806
  this.debounceTimers = /* @__PURE__ */ new Map(), this.throttleTimers = /* @__PURE__ */ new Map(), this.options = t3;
1630
3807
  }
@@ -1632,11 +3809,11 @@ var i = class extends Error {
1632
3809
  if (t3.condition && !this.evaluateCondition(t3.condition, s, e)) return void this.log("debug", `Handler ${t3.id} skipped by condition`);
1633
3810
  if (t3.throttle && t3.throttle > 0 && !this.throttle(t3.id, t3.throttle)) return void this.log("debug", `Handler ${t3.id} throttled`);
1634
3811
  t3.debounce && t3.debounce > 0 && await this.debounce(t3.id, t3.debounce);
1635
- const i2 = { $event: e, $prevResult: void 0, $results: {} };
1636
- await this.executeActionChain(t3.actions, s, i2);
3812
+ const i = { $event: e, $prevResult: void 0, $results: {} };
3813
+ await this.executeActionChain(t3.actions, s, i);
1637
3814
  }
1638
3815
  async executeActionChain(t3, e, s) {
1639
- const i2 = [];
3816
+ const i = [];
1640
3817
  for (let n2 = 0; n2 < t3.length; n2++) {
1641
3818
  const r2 = t3[n2];
1642
3819
  if (r2.condition) {
@@ -1647,39 +3824,39 @@ var i = class extends Error {
1647
3824
  }
1648
3825
  }
1649
3826
  const o2 = this.executeSingleAction(r2, e, s);
1650
- r2.async ? i2.push(o2) : await o2;
3827
+ r2.async ? i.push(o2) : await o2;
1651
3828
  }
1652
- i2.length > 0 && await Promise.allSettled(i2);
3829
+ i.length > 0 && await Promise.allSettled(i);
1653
3830
  }
1654
3831
  async executeSingleAction(t3, e, s) {
1655
3832
  var _a, _b, _c, _d, _e, _f;
1656
- const i2 = t3.id || t3.alias || t3.builtinAction || t3.actionDefinitionVersionId || "unknown";
3833
+ const i = t3.id || t3.alias || t3.builtinAction || t3.actionDefinitionVersionId || "unknown";
1657
3834
  t3.silent || this.options.executor.showLoading();
1658
3835
  try {
1659
3836
  const n2 = this.buildActionContext(e, s), r2 = this.resolveParams(t3.params || {}, n2);
1660
3837
  (_b = (_a = this.options).onActionStart) == null ? void 0 : _b.call(_a, t3, r2);
1661
3838
  const o2 = await this.executeWithRetry(t3, r2);
1662
- s.$prevResult = o2, t3.id && (s.$results[t3.id] = o2), (_d = (_c = this.options).onActionComplete) == null ? void 0 : _d.call(_c, t3, { success: true, data: o2 }), this.log("debug", `Action ${i2} completed successfully`), t3.onSuccess && t3.onSuccess.length > 0 && await this.executeActionChain(t3.onSuccess, e, s);
3839
+ s.$prevResult = o2, t3.id && (s.$results[t3.id] = o2), (_d = (_c = this.options).onActionComplete) == null ? void 0 : _d.call(_c, t3, { success: true, data: o2 }), this.log("debug", `Action ${i} completed successfully`), t3.onSuccess && t3.onSuccess.length > 0 && await this.executeActionChain(t3.onSuccess, e, s);
1663
3840
  } catch (n2) {
1664
- this.log("error", `Action ${i2} failed:`, n2), (_f = (_e = this.options).onActionComplete) == null ? void 0 : _f.call(_e, t3, { success: false, error: n2 }), t3.onError && t3.onError.length > 0 && await this.executeActionChain(t3.onError, e, { ...s, $prevResult: { error: n2.message } });
3841
+ this.log("error", `Action ${i} failed:`, n2), (_f = (_e = this.options).onActionComplete) == null ? void 0 : _f.call(_e, t3, { success: false, error: n2 }), t3.onError && t3.onError.length > 0 && await this.executeActionChain(t3.onError, e, { ...s, $prevResult: { error: n2.message } });
1665
3842
  } finally {
1666
3843
  t3.silent || this.options.executor.hideLoading(), t3.onFinally && t3.onFinally.length > 0 && await this.executeActionChain(t3.onFinally, e, s);
1667
3844
  }
1668
3845
  }
1669
3846
  async executeWithRetry(t3, e) {
1670
3847
  var _a, _b, _c, _d, _e;
1671
- const s = ((_b = (_a = t3.policy) == null ? void 0 : _a.retry) == null ? void 0 : _b.maxAttempts) ?? 1, i2 = ((_d = (_c = t3.policy) == null ? void 0 : _c.retry) == null ? void 0 : _d.backoffMs) ?? 1e3, n2 = (_e = t3.policy) == null ? void 0 : _e.timeoutMs;
3848
+ const s = ((_b = (_a = t3.policy) == null ? void 0 : _a.retry) == null ? void 0 : _b.maxAttempts) ?? 1, i = ((_d = (_c = t3.policy) == null ? void 0 : _c.retry) == null ? void 0 : _d.backoffMs) ?? 1e3, n2 = (_e = t3.policy) == null ? void 0 : _e.timeoutMs;
1672
3849
  let r2;
1673
3850
  for (let o2 = 1; o2 <= s; o2++) try {
1674
3851
  let s2;
1675
3852
  if (t3.builtinAction) s2 = this.executeBuiltinAction(t3.builtinAction, e);
1676
3853
  else {
1677
- if (!t3.actionDefinitionVersionId) throw new h("unknown", "Action must specify builtinAction or actionDefinitionVersionId");
3854
+ if (!t3.actionDefinitionVersionId) throw new u("unknown", "Action must specify builtinAction or actionDefinitionVersionId");
1678
3855
  s2 = this.executeCustomAction(t3.actionDefinitionVersionId, e);
1679
3856
  }
1680
3857
  return n2 && (s2 = this.withTimeout(s2, n2)), await s2;
1681
3858
  } catch (t4) {
1682
- r2 = t4, this.log("warn", `Action attempt ${o2}/${s} failed:`, t4), o2 < s && await this.delay(i2 * o2);
3859
+ r2 = t4, this.log("warn", `Action attempt ${o2}/${s} failed:`, t4), o2 < s && await this.delay(i * o2);
1683
3860
  }
1684
3861
  throw r2 || new Error("Action failed after all retries");
1685
3862
  }
@@ -1704,17 +3881,17 @@ var i = class extends Error {
1704
3881
  case "track":
1705
3882
  return this.options.executor.track({ eventName: e.eventName, params: e.params }), { success: true };
1706
3883
  default:
1707
- throw new h(t3, `Unknown builtin action: ${t3}`);
3884
+ throw new u(t3, `Unknown builtin action: ${t3}`);
1708
3885
  }
1709
3886
  }
1710
3887
  async executeCustomAction(t3, e) {
1711
- const s = t3.split("@")[0], i2 = await this.options.executor.executeAction(s, { ...e, actionDefinitionVersionId: t3 });
1712
- if (!i2.success) throw new h(s, i2.errorMessage || "Action execution failed", void 0, t3, { errorCode: i2.errorCode });
1713
- return i2.data;
3888
+ const s = t3.split("@")[0], i = await this.options.executor.executeAction(s, { ...e, actionDefinitionVersionId: t3 });
3889
+ if (!i.success) throw new u(s, i.errorMessage || "Action execution failed", void 0, t3, { errorCode: i.errorCode });
3890
+ return i.data;
1714
3891
  }
1715
3892
  resolveParams(t3, e) {
1716
3893
  const s = {};
1717
- for (const [i2, n2] of Object.entries(t3)) s[i2] = this.resolveValue(n2, e);
3894
+ for (const [i, n2] of Object.entries(t3)) s[i] = this.resolveValue(n2, e);
1718
3895
  return s;
1719
3896
  }
1720
3897
  resolveValue(e, s) {
@@ -1729,40 +3906,40 @@ var i = class extends Error {
1729
3906
  if ("number" == typeof e || "boolean" == typeof e) return e;
1730
3907
  if (Array.isArray(e)) return e.map((t3) => this.resolveValue(t3, s));
1731
3908
  if ("object" == typeof e) {
1732
- const i2 = e;
1733
- if ("string" == typeof i2.type && t.EXPRESSION_TYPES.includes(i2.type) && "string" == typeof i2.value) {
1734
- const t3 = i2;
3909
+ const i = e;
3910
+ if ("string" == typeof i.type && t.EXPRESSION_TYPES.includes(i.type) && "string" == typeof i.value) {
3911
+ const t3 = i;
1735
3912
  return this.options.expressionEngine.evaluateWithFallback(t3.value, s, t3.fallback);
1736
3913
  }
1737
3914
  const n2 = {};
1738
- for (const [t3, e2] of Object.entries(i2)) n2[t3] = this.resolveValue(e2, s);
3915
+ for (const [t3, e2] of Object.entries(i)) n2[t3] = this.resolveValue(e2, s);
1739
3916
  return n2;
1740
3917
  }
1741
3918
  return e;
1742
3919
  }
1743
3920
  evaluateCondition(t3, e, s) {
1744
- const i2 = { ...e, local: { ...e.local || {}, $event: s } }, n2 = void 0 === t3.fallback || t3.fallback, r2 = this.options.expressionEngine.evaluateWithFallback(t3.value, i2, n2);
3921
+ const i = { ...e, local: { ...e.local || {}, $event: s } }, n2 = void 0 === t3.fallback || t3.fallback, r2 = this.options.expressionEngine.evaluateWithFallback(t3.value, i, n2);
1745
3922
  return Boolean(r2);
1746
3923
  }
1747
3924
  buildActionContext(t3, e) {
1748
3925
  return { ...t3, local: { ...t3.local || {}, $event: e.$event, $prevResult: e.$prevResult, $results: e.$results } };
1749
3926
  }
1750
3927
  withTimeout(t3, e) {
1751
- return new Promise((s, i2) => {
3928
+ return new Promise((s, i) => {
1752
3929
  const n2 = setTimeout(() => {
1753
- i2(new Error(`Action timed out after ${e}ms`));
3930
+ i(new Error(`Action timed out after ${e}ms`));
1754
3931
  }, e);
1755
3932
  t3.then((t4) => {
1756
3933
  clearTimeout(n2), s(t4);
1757
3934
  }).catch((t4) => {
1758
- clearTimeout(n2), i2(t4);
3935
+ clearTimeout(n2), i(t4);
1759
3936
  });
1760
3937
  });
1761
3938
  }
1762
3939
  debounce(t3, e) {
1763
3940
  return new Promise((s) => {
1764
- const i2 = this.debounceTimers.get(t3);
1765
- i2 && clearTimeout(i2);
3941
+ const i = this.debounceTimers.get(t3);
3942
+ i && clearTimeout(i);
1766
3943
  const n2 = setTimeout(() => {
1767
3944
  this.debounceTimers.delete(t3), s();
1768
3945
  }, e);
@@ -1783,8 +3960,8 @@ var i = class extends Error {
1783
3960
  this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
1784
3961
  }
1785
3962
  };
1786
- b.EXPRESSION_TYPES = ["state", "binding", "local", "template", "computed"];
1787
- var w = b, v = class {
3963
+ v.EXPRESSION_TYPES = ["state", "binding", "local", "template", "computed"];
3964
+ var $ = v, S = class {
1788
3965
  constructor(t3) {
1789
3966
  this.pos = 0, this.tokens = [], this.input = t3;
1790
3967
  }
@@ -1890,14 +4067,14 @@ var w = b, v = class {
1890
4067
  peek(t3 = 1) {
1891
4068
  return this.input[this.pos + t3] || "";
1892
4069
  }
1893
- }, $ = { len: (t3) => "string" == typeof t3 || Array.isArray(t3) ? t3.length : 0, trim: (t3) => String(t3 ?? "").trim(), upper: (t3) => String(t3 ?? "").toUpperCase(), lower: (t3) => String(t3 ?? "").toLowerCase(), substr: (t3, e, s) => {
1894
- const i2 = String(t3 ?? ""), n2 = Number(e) || 0, r2 = void 0 !== s ? Number(s) : void 0;
1895
- return i2.substring(n2, void 0 !== r2 ? n2 + r2 : void 0);
4070
+ }, x = { len: (t3) => "string" == typeof t3 || Array.isArray(t3) ? t3.length : 0, trim: (t3) => String(t3 ?? "").trim(), upper: (t3) => String(t3 ?? "").toUpperCase(), lower: (t3) => String(t3 ?? "").toLowerCase(), substr: (t3, e, s) => {
4071
+ const i = String(t3 ?? ""), n2 = Number(e) || 0, r2 = void 0 !== s ? Number(s) : void 0;
4072
+ return i.substring(n2, void 0 !== r2 ? n2 + r2 : void 0);
1896
4073
  }, concat: (...t3) => t3.map((t4) => String(t4 ?? "")).join(""), replace: (t3, e, s) => String(t3 ?? "").split(String(e)).join(String(s)), split: (t3, e) => String(t3 ?? "").split(String(e)), join: (t3, e) => Array.isArray(t3) ? t3.join(void 0 !== e ? String(e) : ",") : "", startsWith: (t3, e) => String(t3 ?? "").startsWith(String(e)), endsWith: (t3, e) => String(t3 ?? "").endsWith(String(e)), contains: (t3, e) => String(t3 ?? "").includes(String(e)), toNumber: (t3) => {
1897
4074
  const e = Number(t3);
1898
4075
  return isNaN(e) ? 0 : e;
1899
4076
  }, toString: (t3) => String(t3 ?? ""), toInt: (t3) => Math.trunc(Number(t3) || 0), toFloat: (t3) => parseFloat(String(t3)) || 0, round: (t3, e) => {
1900
- const s = Number(t3) || 0, i2 = Number(e) || 0, n2 = Math.pow(10, i2);
4077
+ const s = Number(t3) || 0, i = Number(e) || 0, n2 = Math.pow(10, i);
1901
4078
  return Math.round(s * n2) / n2;
1902
4079
  }, floor: (t3) => Math.floor(Number(t3) || 0), ceil: (t3) => Math.ceil(Number(t3) || 0), abs: (t3) => Math.abs(Number(t3) || 0), min: (...t3) => {
1903
4080
  const e = t3.map((t4) => Number(t4)).filter((t4) => !isNaN(t4));
@@ -1906,16 +4083,16 @@ var w = b, v = class {
1906
4083
  const e = t3.map((t4) => Number(t4)).filter((t4) => !isNaN(t4));
1907
4084
  return e.length > 0 ? Math.max(...e) : 0;
1908
4085
  }, sum: (t3) => Array.isArray(t3) ? t3.reduce((t4, e) => t4 + (Number(e) || 0), 0) : 0, avg: (t3) => Array.isArray(t3) && 0 !== t3.length ? t3.reduce((t4, e) => t4 + (Number(e) || 0), 0) / t3.length : 0, random: () => Math.random(), randomInt: (t3, e) => {
1909
- const s = Math.ceil(Number(t3) || 0), i2 = Math.floor(Number(e) || 100);
1910
- return Math.floor(Math.random() * (i2 - s + 1)) + s;
4086
+ const s = Math.ceil(Number(t3) || 0), i = Math.floor(Number(e) || 100);
4087
+ return Math.floor(Math.random() * (i - s + 1)) + s;
1911
4088
  }, now: () => Date.now(), today: () => (/* @__PURE__ */ new Date()).toISOString().split("T")[0], dateFormat: (t3, e) => {
1912
- const s = new Date(Number(t3) || Date.now()), i2 = (t4) => t4.toString().padStart(2, "0");
1913
- return String(e || "YYYY-MM-DD").replace("YYYY", s.getFullYear().toString()).replace("MM", i2(s.getMonth() + 1)).replace("DD", i2(s.getDate())).replace("HH", i2(s.getHours())).replace("mm", i2(s.getMinutes())).replace("ss", i2(s.getSeconds()));
4089
+ const s = new Date(Number(t3) || Date.now()), i = (t4) => t4.toString().padStart(2, "0");
4090
+ return String(e || "YYYY-MM-DD").replace("YYYY", s.getFullYear().toString()).replace("MM", i(s.getMonth() + 1)).replace("DD", i(s.getDate())).replace("HH", i(s.getHours())).replace("mm", i(s.getMinutes())).replace("ss", i(s.getSeconds()));
1914
4091
  }, dateParse: (t3) => new Date(String(t3)).getTime(), year: (t3) => new Date(Number(t3) || Date.now()).getFullYear(), month: (t3) => new Date(Number(t3) || Date.now()).getMonth() + 1, day: (t3) => new Date(Number(t3) || Date.now()).getDate(), addDays: (t3, e) => {
1915
4092
  const s = new Date(Number(t3) || Date.now());
1916
4093
  return s.setDate(s.getDate() + (Number(e) || 0)), s.getTime();
1917
4094
  }, diffDays: (t3, e) => {
1918
- const s = new Date(Number(t3) || Date.now()), i2 = new Date(Number(e) || Date.now()), n2 = Math.abs(i2.getTime() - s.getTime());
4095
+ const s = new Date(Number(t3) || Date.now()), i = new Date(Number(e) || Date.now()), n2 = Math.abs(i.getTime() - s.getTime());
1919
4096
  return Math.floor(n2 / 864e5);
1920
4097
  }, isNull: (t3) => null == t3, isUndefined: (t3) => void 0 === t3, isEmpty: (t3) => null == t3 || ("string" == typeof t3 || Array.isArray(t3) ? 0 === t3.length : "object" == typeof t3 && 0 === Object.keys(t3).length), isArray: (t3) => Array.isArray(t3), isObject: (t3) => null !== t3 && "object" == typeof t3 && !Array.isArray(t3), isString: (t3) => "string" == typeof t3, isNumber: (t3) => "number" == typeof t3 && !isNaN(t3), isBoolean: (t3) => "boolean" == typeof t3, typeOf: (t3) => null === t3 ? "null" : Array.isArray(t3) ? "array" : typeof t3, default: (t3, e) => t3 ?? e, coalesce: (...t3) => {
1921
4098
  for (const e of t3) if (null != e) return e;
@@ -1928,9 +4105,9 @@ var w = b, v = class {
1928
4105
  if (Array.isArray(t3)) return t3[Number(e) || 0];
1929
4106
  }, slice: (t3, e, s) => Array.isArray(t3) ? t3.slice(Number(e) || 0, void 0 !== s ? Number(s) : void 0) : [], includes: (t3, e) => !!Array.isArray(t3) && t3.includes(e), indexOf: (t3, e) => Array.isArray(t3) ? t3.indexOf(e) : -1, reverse: (t3) => Array.isArray(t3) ? [...t3].reverse() : [], sort: (t3) => Array.isArray(t3) ? [...t3].sort() : [], unique: (t3) => Array.isArray(t3) ? [...new Set(t3)] : [], flatten: (t3) => Array.isArray(t3) ? t3.flat() : [], count: (t3) => Array.isArray(t3) ? t3.length : 0, get: (t3, e, s) => {
1930
4107
  if (null == t3) return s;
1931
- const i2 = String(e).split(".");
4108
+ const i = String(e).split(".");
1932
4109
  let n2 = t3;
1933
- for (const t4 of i2) {
4110
+ for (const t4 of i) {
1934
4111
  if (null == n2) return s;
1935
4112
  n2 = n2[t4];
1936
4113
  }
@@ -1940,31 +4117,31 @@ var w = b, v = class {
1940
4117
  for (const s of t3) "object" == typeof s && null !== s && Object.assign(e, s);
1941
4118
  return e;
1942
4119
  }, and: (...t3) => t3.every((t4) => Boolean(t4)), or: (...t3) => t3.some((t4) => Boolean(t4)), not: (t3) => !t3, eq: (t3, e) => t3 === e, ne: (t3, e) => t3 !== e, gt: (t3, e) => Number(t3) > Number(e), gte: (t3, e) => Number(t3) >= Number(e), lt: (t3, e) => Number(t3) < Number(e), lte: (t3, e) => Number(t3) <= Number(e), between: (t3, e, s) => {
1943
- const i2 = Number(t3);
1944
- return i2 >= Number(e) && i2 <= Number(s);
4120
+ const i = Number(t3);
4121
+ return i >= Number(e) && i <= Number(s);
1945
4122
  }, formatNumber: (t3, e) => {
1946
- const s = Number(t3) || 0, i2 = Number(e) ?? 0;
1947
- return s.toLocaleString(void 0, { minimumFractionDigits: i2, maximumFractionDigits: i2 });
4123
+ const s = Number(t3) || 0, i = Number(e) ?? 0;
4124
+ return s.toLocaleString(void 0, { minimumFractionDigits: i, maximumFractionDigits: i });
1948
4125
  }, formatCurrency: (t3, e) => {
1949
- const s = Number(t3) || 0, i2 = String(e || "CNY");
1950
- return s.toLocaleString("zh-CN", { style: "currency", currency: i2 });
4126
+ const s = Number(t3) || 0, i = String(e || "CNY");
4127
+ return s.toLocaleString("zh-CN", { style: "currency", currency: i });
1951
4128
  }, formatPercent: (t3, e) => {
1952
- const s = Number(t3) || 0, i2 = Number(e) ?? 0;
1953
- return (100 * s).toFixed(i2) + "%";
4129
+ const s = Number(t3) || 0, i = Number(e) ?? 0;
4130
+ return (100 * s).toFixed(i) + "%";
1954
4131
  }, currency: (t3, e, s) => {
1955
- const i2 = Number(t3) || 0, n2 = String(e ?? "¥"), r2 = Number(s) ?? 2;
1956
- return `${n2}${i2.toLocaleString(void 0, { minimumFractionDigits: r2, maximumFractionDigits: r2 })}`;
4132
+ const i = Number(t3) || 0, n2 = String(e ?? "¥"), r2 = Number(s) ?? 2;
4133
+ return `${n2}${i.toLocaleString(void 0, { minimumFractionDigits: r2, maximumFractionDigits: r2 })}`;
1957
4134
  }, percent: (t3, e) => {
1958
- const s = Number(t3) || 0, i2 = Number(e) ?? 0;
1959
- return (100 * s).toFixed(i2) + "%";
4135
+ const s = Number(t3) || 0, i = Number(e) ?? 0;
4136
+ return (100 * s).toFixed(i) + "%";
1960
4137
  }, number: (t3, e) => {
1961
- const s = Number(t3) || 0, i2 = Number(e) ?? 0;
1962
- return s.toLocaleString(void 0, { minimumFractionDigits: i2, maximumFractionDigits: i2 });
4138
+ const s = Number(t3) || 0, i = Number(e) ?? 0;
4139
+ return s.toLocaleString(void 0, { minimumFractionDigits: i, maximumFractionDigits: i });
1963
4140
  }, pluralize: (t3, e, s) => {
1964
- const i2 = Number(t3) || 0;
1965
- return `${i2} ${String(1 === i2 ? e : s)}`;
1966
- }, mask: (t3, e, s, i2) => {
1967
- const n2 = String(t3 ?? ""), r2 = Number(e) || 3, o2 = Number(s) || 4, a2 = String(i2 ?? "*");
4141
+ const i = Number(t3) || 0;
4142
+ return `${i} ${String(1 === i ? e : s)}`;
4143
+ }, mask: (t3, e, s, i) => {
4144
+ const n2 = String(t3 ?? ""), r2 = Number(e) || 3, o2 = Number(s) || 4, a2 = String(i ?? "*");
1968
4145
  if (n2.length <= r2 + o2) return n2;
1969
4146
  const c2 = n2.slice(0, r2), h2 = n2.slice(-o2);
1970
4147
  return c2 + a2.repeat(n2.length - r2 - o2) + h2;
@@ -1981,39 +4158,39 @@ var w = b, v = class {
1981
4158
  return null;
1982
4159
  }
1983
4160
  }, clamp: (t3, e, s) => {
1984
- const i2 = Number(t3) || 0, n2 = Number(e) || 0, r2 = Number(s) || 100;
1985
- return Math.min(Math.max(i2, n2), r2);
4161
+ const i = Number(t3) || 0, n2 = Number(e) || 0, r2 = Number(s) || 100;
4162
+ return Math.min(Math.max(i, n2), r2);
1986
4163
  }, length: (t3) => Array.isArray(t3) || "string" == typeof t3 ? t3.length : 0, average: (t3) => Array.isArray(t3) && 0 !== t3.length ? t3.reduce((t4, e) => t4 + (Number(e) || 0), 0) / t3.length : 0, dateAdd: (t3, e, s) => {
1987
- const i2 = new Date(Number(t3) || Date.now()), n2 = Number(e) || 0;
4164
+ const i = new Date(Number(t3) || Date.now()), n2 = Number(e) || 0;
1988
4165
  switch (String(s ?? "day").toLowerCase()) {
1989
4166
  case "year":
1990
4167
  case "years":
1991
- i2.setFullYear(i2.getFullYear() + n2);
4168
+ i.setFullYear(i.getFullYear() + n2);
1992
4169
  break;
1993
4170
  case "month":
1994
4171
  case "months":
1995
- i2.setMonth(i2.getMonth() + n2);
4172
+ i.setMonth(i.getMonth() + n2);
1996
4173
  break;
1997
4174
  case "week":
1998
4175
  case "weeks":
1999
- i2.setDate(i2.getDate() + 7 * n2);
4176
+ i.setDate(i.getDate() + 7 * n2);
2000
4177
  break;
2001
4178
  case "day":
2002
4179
  case "days":
2003
4180
  default:
2004
- i2.setDate(i2.getDate() + n2);
4181
+ i.setDate(i.getDate() + n2);
2005
4182
  break;
2006
4183
  case "hour":
2007
4184
  case "hours":
2008
- i2.setHours(i2.getHours() + n2);
4185
+ i.setHours(i.getHours() + n2);
2009
4186
  break;
2010
4187
  case "minute":
2011
4188
  case "minutes":
2012
- i2.setMinutes(i2.getMinutes() + n2);
4189
+ i.setMinutes(i.getMinutes() + n2);
2013
4190
  }
2014
- return i2.getTime();
4191
+ return i.getTime();
2015
4192
  }, dateDiff: (t3, e, s) => {
2016
- const i2 = new Date(Number(t3) || Date.now()), n2 = new Date(Number(e) || Date.now()).getTime() - i2.getTime();
4193
+ const i = new Date(Number(t3) || Date.now()), n2 = new Date(Number(e) || Date.now()).getTime() - i.getTime();
2017
4194
  switch (String(s ?? "day").toLowerCase()) {
2018
4195
  case "year":
2019
4196
  case "years":
@@ -2036,18 +4213,18 @@ var w = b, v = class {
2036
4213
  return Math.floor(n2 / 6e4);
2037
4214
  }
2038
4215
  }, $if: (t3, e, s) => t3 ? e : s, toBoolean: (t3) => "string" == typeof t3 ? "false" !== t3.toLowerCase() && "0" !== t3 && "" !== t3 : Boolean(t3), substring: (t3, e, s) => {
2039
- const i2 = String(t3 ?? ""), n2 = Number(e) || 0, r2 = void 0 !== s ? Number(s) : void 0;
2040
- return i2.substring(n2, r2);
4216
+ const i = String(t3 ?? ""), n2 = Number(e) || 0, r2 = void 0 !== s ? Number(s) : void 0;
4217
+ return i.substring(n2, r2);
2041
4218
  }, padStart: (t3, e, s) => {
2042
- const i2 = String(t3 ?? ""), n2 = Number(e) || 0, r2 = String(s ?? " ");
2043
- return i2.padStart(n2, r2);
4219
+ const i = String(t3 ?? ""), n2 = Number(e) || 0, r2 = String(s ?? " ");
4220
+ return i.padStart(n2, r2);
2044
4221
  }, padEnd: (t3, e, s) => {
2045
- const i2 = String(t3 ?? ""), n2 = Number(e) || 0, r2 = String(s ?? " ");
2046
- return i2.padEnd(n2, r2);
4222
+ const i = String(t3 ?? ""), n2 = Number(e) || 0, r2 = String(s ?? " ");
4223
+ return i.padEnd(n2, r2);
2047
4224
  }, repeat: (t3, e) => {
2048
- const s = String(t3 ?? ""), i2 = Math.max(0, Math.floor(Number(e) || 0));
2049
- return s.repeat(i2);
2050
- } }, S = { "||": 1, "??": 1, "&&": 2, "==": 3, "!=": 3, "<": 4, ">": 4, "<=": 4, ">=": 4, "+": 5, "-": 5, "*": 6, "/": 6, "%": 6 }, x = class {
4225
+ const s = String(t3 ?? ""), i = Math.max(0, Math.floor(Number(e) || 0));
4226
+ return s.repeat(i);
4227
+ } }, k = { "||": 1, "??": 1, "&&": 2, "==": 3, "!=": 3, "<": 4, ">": 4, "<=": 4, ">=": 4, "+": 5, "-": 5, "*": 6, "/": 6, "%": 6 }, I = class {
2051
4228
  constructor(t3) {
2052
4229
  this.pos = 0, this.tokens = t3;
2053
4230
  }
@@ -2073,10 +4250,10 @@ var w = b, v = class {
2073
4250
  for (; ; ) {
2074
4251
  const s = this.current();
2075
4252
  if ("OPERATOR" !== s.type) break;
2076
- const i2 = S[s.value];
2077
- if (void 0 === i2 || i2 < t3) break;
4253
+ const i = k[s.value];
4254
+ if (void 0 === i || i < t3) break;
2078
4255
  this.advance();
2079
- const n2 = this.parseBinary(i2 + 1);
4256
+ const n2 = this.parseBinary(i + 1);
2080
4257
  e = { type: "binary", operator: s.value, left: e, right: n2, raw: void 0 };
2081
4258
  }
2082
4259
  return e;
@@ -2103,10 +4280,10 @@ var w = b, v = class {
2103
4280
  if ("LPAREN" !== e.type || "identifier" !== t3.type) break;
2104
4281
  {
2105
4282
  const s = t3.name;
2106
- if (!(s in $)) throw new Error(`Unknown function '${s}' at position ${e.start}`);
4283
+ if (!(s in x)) throw new Error(`Unknown function '${s}' at position ${e.start}`);
2107
4284
  this.advance();
2108
- const i2 = this.parseArguments();
2109
- this.expect("RPAREN"), t3 = { type: "call", callee: s, arguments: i2, raw: void 0 };
4285
+ const i = this.parseArguments();
4286
+ this.expect("RPAREN"), t3 = { type: "call", callee: s, arguments: i, raw: void 0 };
2110
4287
  }
2111
4288
  }
2112
4289
  }
@@ -2148,7 +4325,7 @@ var w = b, v = class {
2148
4325
  if (e.type !== t3) throw new Error(`Expected '${t3}' but got '${e.type}' at position ${e.start}`);
2149
4326
  return this.advance();
2150
4327
  }
2151
- }, k = class {
4328
+ }, E = class {
2152
4329
  constructor(t3 = {}) {
2153
4330
  this.depth = 0, this.startTime = 0, this.options = { maxDepth: 100, timeout: 1e3, debug: false, ...t3 };
2154
4331
  }
@@ -2179,7 +4356,7 @@ var w = b, v = class {
2179
4356
  case "array":
2180
4357
  return this.evaluateArray(t3, e);
2181
4358
  default:
2182
- throw new c("", `Unknown node type: ${t3.type}`);
4359
+ throw new h("", `Unknown node type: ${t3.type}`);
2183
4360
  }
2184
4361
  }
2185
4362
  evaluateLiteral(t3) {
@@ -2206,18 +4383,18 @@ var w = b, v = class {
2206
4383
  return (_b = e.local) == null ? void 0 : _b.index;
2207
4384
  default:
2208
4385
  if (e.local && s in e.local) return e.local[s];
2209
- throw new c("", `Unknown variable '${s}'. Available: state, binding, local, props, event`);
4386
+ throw new h("", `Unknown variable '${s}'. Available: state, binding, local, props, event`);
2210
4387
  }
2211
4388
  }
2212
4389
  evaluateMember(t3, e) {
2213
4390
  const s = this.evaluateNode(t3.object, e);
2214
4391
  if (null == s) return;
2215
- let i2;
2216
- return i2 = t3.computed ? this.evaluateNode(t3.property, e) : t3.property, "object" == typeof s && null !== s ? s[i2] : void 0;
4392
+ let i;
4393
+ return i = t3.computed ? this.evaluateNode(t3.property, e) : t3.property, "object" == typeof s && null !== s ? s[i] : void 0;
2217
4394
  }
2218
4395
  evaluateCall(t3, e) {
2219
- const s = $[t3.callee];
2220
- if (!s) throw new c("", `Unknown function '${t3.callee}'`);
4396
+ const s = x[t3.callee];
4397
+ if (!s) throw new h("", `Unknown function '${t3.callee}'`);
2221
4398
  return s(...t3.arguments.map((t4) => this.evaluateNode(t4, e)));
2222
4399
  }
2223
4400
  evaluateBinary(t3, e) {
@@ -2233,32 +4410,32 @@ var w = b, v = class {
2233
4410
  const s2 = this.evaluateNode(t3.left, e);
2234
4411
  return null != s2 ? s2 : this.evaluateNode(t3.right, e);
2235
4412
  }
2236
- const i2 = this.evaluateNode(t3.left, e), n2 = this.evaluateNode(t3.right, e);
4413
+ const i = this.evaluateNode(t3.left, e), n2 = this.evaluateNode(t3.right, e);
2237
4414
  switch (s) {
2238
4415
  case "+":
2239
- return "string" == typeof i2 || "string" == typeof n2 ? String(i2) + String(n2) : i2 + n2;
4416
+ return "string" == typeof i || "string" == typeof n2 ? String(i) + String(n2) : i + n2;
2240
4417
  case "-":
2241
- return i2 - n2;
4418
+ return i - n2;
2242
4419
  case "*":
2243
- return i2 * n2;
4420
+ return i * n2;
2244
4421
  case "/":
2245
- return i2 / n2;
4422
+ return i / n2;
2246
4423
  case "%":
2247
- return i2 % n2;
4424
+ return i % n2;
2248
4425
  case "==":
2249
- return i2 === n2;
4426
+ return i === n2;
2250
4427
  case "!=":
2251
- return i2 !== n2;
4428
+ return i !== n2;
2252
4429
  case "<":
2253
- return i2 < n2;
4430
+ return i < n2;
2254
4431
  case ">":
2255
- return i2 > n2;
4432
+ return i > n2;
2256
4433
  case "<=":
2257
- return i2 <= n2;
4434
+ return i <= n2;
2258
4435
  case ">=":
2259
- return i2 >= n2;
4436
+ return i >= n2;
2260
4437
  default:
2261
- throw new c("", `Unknown operator '${s}'`);
4438
+ throw new h("", `Unknown operator '${s}'`);
2262
4439
  }
2263
4440
  }
2264
4441
  evaluateUnary(t3, e) {
@@ -2269,7 +4446,7 @@ var w = b, v = class {
2269
4446
  case "-":
2270
4447
  return -s;
2271
4448
  default:
2272
- throw new c("", `Unknown unary operator '${t3.operator}'`);
4449
+ throw new h("", `Unknown unary operator '${t3.operator}'`);
2273
4450
  }
2274
4451
  }
2275
4452
  evaluateConditional(t3, e) {
@@ -2279,12 +4456,12 @@ var w = b, v = class {
2279
4456
  return t3.elements.map((t4) => this.evaluateNode(t4, e));
2280
4457
  }
2281
4458
  checkLimits() {
2282
- if (this.depth++, this.depth > (this.options.maxDepth ?? 100)) throw new c("", "Maximum recursion depth exceeded");
2283
- if (Date.now() - this.startTime > (this.options.timeout ?? 1e3)) throw new c("", "Expression evaluation timeout");
4459
+ if (this.depth++, this.depth > (this.options.maxDepth ?? 100)) throw new h("", "Maximum recursion depth exceeded");
4460
+ if (Date.now() - this.startTime > (this.options.timeout ?? 1e3)) throw new h("", "Expression evaluation timeout");
2284
4461
  }
2285
- }, E = class {
4462
+ }, N = class {
2286
4463
  constructor(t3 = {}) {
2287
- this.astCache = /* @__PURE__ */ new Map(), this.options = { cacheAST: true, maxCacheSize: 1e3, ...t3 }, this.evaluator = new k(t3);
4464
+ this.astCache = /* @__PURE__ */ new Map(), this.options = { cacheAST: true, maxCacheSize: 1e3, ...t3 }, this.evaluator = new E(t3);
2288
4465
  }
2289
4466
  evaluate(t3, e) {
2290
4467
  try {
@@ -2295,13 +4472,13 @@ var w = b, v = class {
2295
4472
  }
2296
4473
  }
2297
4474
  evaluateWithFallback(t3, e, s) {
2298
- const i2 = "string" == typeof t3 ? t3 : t3.value, n2 = "object" == typeof t3 && void 0 !== t3.fallback ? t3.fallback : s, r2 = this.evaluate(i2, e);
2299
- return r2.error ? (this.log("warn", `Expression evaluation failed: ${r2.error.message}`, i2), n2) : r2.value;
4475
+ const i = "string" == typeof t3 ? t3 : t3.value, n2 = "object" == typeof t3 && void 0 !== t3.fallback ? t3.fallback : s, r2 = this.evaluate(i, e);
4476
+ return r2.error ? (this.log("warn", `Expression evaluation failed: ${r2.error.message}`, i), n2) : r2.value;
2300
4477
  }
2301
4478
  evaluateTemplate(t3, e) {
2302
4479
  return t3.replace(/\$\{([^}]+)\}/g, (t4, s) => {
2303
- const i2 = this.evaluate(s.trim(), e);
2304
- return i2.error ? (this.log("warn", `Template expression failed: ${i2.error.message}`, s), "") : String(i2.value ?? "");
4480
+ const i = this.evaluate(s.trim(), e);
4481
+ return i.error ? (this.log("warn", `Template expression failed: ${i.error.message}`, s), "") : String(i.value ?? "");
2305
4482
  });
2306
4483
  }
2307
4484
  parse(t3) {
@@ -2310,19 +4487,19 @@ var w = b, v = class {
2310
4487
  if (e) return e;
2311
4488
  }
2312
4489
  try {
2313
- const e = new v(t3).tokenize(), s = new x(e).parse();
4490
+ const e = new S(t3).tokenize(), s = new I(e).parse();
2314
4491
  return this.options.cacheAST && (this.astCache.size >= (this.options.maxCacheSize ?? 1e3) && Array.from(this.astCache.keys()).slice(0, Math.floor(this.astCache.size / 2)).forEach((t4) => this.astCache.delete(t4)), this.astCache.set(t3, s)), s;
2315
4492
  } catch (e) {
2316
- throw new c(t3, e instanceof Error ? e.message : "Parse error");
4493
+ throw new h(t3, e instanceof Error ? e.message : "Parse error");
2317
4494
  }
2318
4495
  }
2319
4496
  validate(t3) {
2320
- const e = [], s = [], i2 = [], n2 = [];
4497
+ const e = [], s = [], i = [], n2 = [];
2321
4498
  try {
2322
4499
  const e2 = this.parse(t3);
2323
- return this.collectReferences(e2, i2, n2), { valid: true, errors: [], warnings: s, referencedPaths: i2, usedFunctions: n2 };
4500
+ return this.collectReferences(e2, i, n2), { valid: true, errors: [], warnings: s, referencedPaths: i, usedFunctions: n2 };
2324
4501
  } catch (t4) {
2325
- return e.push({ type: "invalid_syntax", message: t4 instanceof Error ? t4.message : "Parse error" }), { valid: false, errors: e, warnings: s, referencedPaths: i2, usedFunctions: n2 };
4502
+ return e.push({ type: "invalid_syntax", message: t4 instanceof Error ? t4.message : "Parse error" }), { valid: false, errors: e, warnings: s, referencedPaths: i, usedFunctions: n2 };
2326
4503
  }
2327
4504
  }
2328
4505
  clearCache() {
@@ -2365,7 +4542,7 @@ var w = b, v = class {
2365
4542
  log(t3, e, ...s) {
2366
4543
  this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
2367
4544
  }
2368
- }, N = class {
4545
+ }, C = class {
2369
4546
  constructor(t3) {
2370
4547
  this.loadingCount = 0, this.loadingElement = null, this.clipboard = { write: async (t4) => {
2371
4548
  try {
@@ -2389,8 +4566,8 @@ var w = b, v = class {
2389
4566
  return null;
2390
4567
  }
2391
4568
  }, set: (t4, e, s) => {
2392
- const i2 = `${this.storageNamespace}:${t4}`, n2 = { value: e, expires: (s == null ? void 0 : s.ttlSeconds) ? Date.now() + 1e3 * s.ttlSeconds : void 0 };
2393
- ("session" === (s == null ? void 0 : s.level) ? sessionStorage : localStorage).setItem(i2, JSON.stringify(n2));
4569
+ const i = `${this.storageNamespace}:${t4}`, n2 = { value: e, expires: (s == null ? void 0 : s.ttlSeconds) ? Date.now() + 1e3 * s.ttlSeconds : void 0 };
4570
+ ("session" === (s == null ? void 0 : s.level) ? sessionStorage : localStorage).setItem(i, JSON.stringify(n2));
2394
4571
  }, remove: (t4) => {
2395
4572
  const e = `${this.storageNamespace}:${t4}`;
2396
4573
  localStorage.removeItem(e), sessionStorage.removeItem(e);
@@ -2427,42 +4604,30 @@ var w = b, v = class {
2427
4604
  track(t3) {
2428
4605
  this.log("debug", "Track event:", t3);
2429
4606
  const e = this.options.context;
2430
- fetch(`${this.options.apiBaseUrl}/track`, { method: "POST", headers: this.buildHeaders(), body: JSON.stringify({ eventName: t3.eventName, params: t3.params, type: t3.type || "custom", timestamp: Date.now(), context: { pageVersionId: e.pageVersionId, runtimeVersion: e.runtimeVersion, userId: e.userId, deviceId: e.deviceId, channel: e.channel, appId: e.appId, env: e.env } }), keepalive: true }).catch((t4) => {
2431
- this.log("warn", "Track failed:", t4);
2432
- });
4607
+ this.options.userApiAdapter.track({ eventName: t3.eventName, params: t3.params, type: t3.type || "custom", timestamp: Date.now(), context: { pageVersionId: e.pageVersionId, runtimeVersion: e.runtimeVersion, userId: e.userId, deviceId: e.deviceId, channel: e.channel, appId: e.appId, env: e.env } });
2433
4608
  }
2434
4609
  async requestData(t3, e) {
2435
4610
  this.log("debug", `Requesting data: ${t3}`, e);
2436
- const s = performance.now(), i2 = this.options.context;
4611
+ const s = performance.now(), i = this.options.context;
2437
4612
  try {
2438
- const n2 = await fetch(`${this.options.apiBaseUrl}/data/query`, { method: "POST", headers: this.buildHeaders(), body: JSON.stringify({ queryVersionId: t3, params: e || {}, context: { pageVersionId: i2.pageVersionId, uid: i2.userId, deviceId: i2.deviceId } }) });
2439
- if (!n2.ok) {
2440
- const t4 = await n2.text();
2441
- throw new Error(`HTTP ${n2.status}: ${t4 || n2.statusText}`);
2442
- }
2443
- const r2 = await n2.json(), o2 = performance.now() - s;
2444
- if (this.log("debug", `Data query completed in ${o2.toFixed(2)}ms`), !r2.success) throw new Error(r2.message || r2.errorMessage || "Query failed");
2445
- return this.options.stateManager.setQuery(t3, r2.data), r2.data;
4613
+ const n2 = await this.options.userApiAdapter.executeQuery({ queryVersionId: t3, params: e ?? {}, context: { pageVersionId: i.pageVersionId, uid: i.userId, deviceId: i.deviceId } }), r2 = performance.now() - s;
4614
+ if (this.log("debug", `Data query completed in ${r2.toFixed(2)}ms`), !n2.success) throw new Error(n2.message || n2.errorMessage || "Query failed");
4615
+ return this.options.stateManager.setQuery(t3, n2.data), n2.data;
2446
4616
  } catch (e2) {
2447
- const i3 = performance.now() - s;
2448
- throw this.log("error", `Data query failed: ${t3} (${i3.toFixed(2)}ms)`, e2), e2;
4617
+ const i2 = performance.now() - s;
4618
+ throw this.log("error", `Data query failed: ${t3} (${i2.toFixed(2)}ms)`, e2), e2;
2449
4619
  }
2450
4620
  }
2451
4621
  async executeAction(t3, e = {}) {
2452
4622
  this.log("debug", `Executing action: ${t3}`, e);
2453
- const s = performance.now(), i2 = this.options.context, n2 = this.generateIdempotencyKey(t3, e);
4623
+ const s = performance.now(), i = this.options.context, n2 = this.generateIdempotencyKey(t3, e);
2454
4624
  this.track({ eventName: "djvlc_action_start", params: { actionType: t3, idempotencyKey: n2 }, type: "custom" });
2455
4625
  try {
2456
- const r2 = await fetch(`${this.options.apiBaseUrl}/actions/execute`, { method: "POST", headers: this.buildHeaders(), body: JSON.stringify({ actionType: t3, params: e || {}, context: { pageVersionId: i2.pageVersionId, uid: i2.userId, deviceId: i2.deviceId, channel: i2.channel, appId: i2.appId }, idempotencyKey: n2 }) });
2457
- if (!r2.ok) {
2458
- const e2 = await r2.text(), i3 = performance.now() - s;
2459
- return this.log("error", `Action HTTP error: ${t3} (${i3.toFixed(2)}ms)`, e2), { success: false, errorCode: `HTTP_${r2.status}`, errorMessage: e2 || r2.statusText };
2460
- }
2461
- const o2 = await r2.json(), a2 = performance.now() - s;
2462
- return this.log("debug", `Action completed in ${a2.toFixed(2)}ms`, { success: o2.success }), this.track({ eventName: o2.success ? "djvlc_action_success" : "djvlc_action_fail", params: { actionType: t3, idempotencyKey: n2, duration: Math.round(a2), errorCode: o2.errorCode }, type: "custom" }), { success: o2.success, data: o2.data, errorCode: o2.errorCode, errorMessage: o2.errorMessage };
4626
+ const r2 = await this.options.userApiAdapter.executeAction({ actionType: t3, params: e || {}, context: { pageVersionId: i.pageVersionId, uid: i.userId, deviceId: i.deviceId, channel: i.channel, appId: i.appId }, idempotencyKey: n2 }), o2 = performance.now() - s;
4627
+ return this.log("debug", `Action completed in ${o2.toFixed(2)}ms`, { success: r2.success }), this.track({ eventName: r2.success ? "djvlc_action_success" : "djvlc_action_fail", params: { actionType: t3, idempotencyKey: n2, duration: Math.round(o2), errorCode: r2.errorCode }, type: "custom" }), r2;
2463
4628
  } catch (e2) {
2464
- const i3 = performance.now() - s;
2465
- return this.log("error", `Action failed: ${t3} (${i3.toFixed(2)}ms)`, e2), this.track({ eventName: "djvlc_action_error", params: { actionType: t3, idempotencyKey: n2, duration: Math.round(i3), errorMessage: e2 instanceof Error ? e2.message : "Unknown error" }, type: "custom" }), { success: false, errorCode: "NETWORK_ERROR", errorMessage: e2 instanceof Error ? e2.message : "Action failed" };
4629
+ const i2 = performance.now() - s;
4630
+ return this.log("error", `Action failed: ${t3} (${i2.toFixed(2)}ms)`, e2), this.track({ eventName: "djvlc_action_error", params: { actionType: t3, idempotencyKey: n2, duration: Math.round(i2), errorMessage: e2 instanceof Error ? e2.message : "Unknown error" }, type: "custom" }), { success: false, errorCode: "NETWORK_ERROR", errorMessage: e2 instanceof Error ? e2.message : "Action failed" };
2466
4631
  }
2467
4632
  }
2468
4633
  async openDialog(t3) {
@@ -2551,13 +4716,9 @@ var w = b, v = class {
2551
4716
  const t3 = this.options.context;
2552
4717
  return { pageVersionId: t3.pageVersionId, componentVersionId: "", instanceId: "", userId: t3.userId, deviceId: t3.deviceId, channel: t3.channel, appId: t3.appId, env: t3.env };
2553
4718
  }
2554
- buildHeaders() {
2555
- const t3 = { "Content-Type": "application/json", ...this.options.headers };
2556
- return this.options.authToken && (t3.Authorization = `Bearer ${this.options.authToken}`), t3;
2557
- }
2558
4719
  generateIdempotencyKey(t3, e) {
2559
- const s = Date.now(), i2 = JSON.stringify(e || {});
2560
- return `${t3}:${s}:${this.simpleHash(i2)}`;
4720
+ const s = Date.now(), i = JSON.stringify(e || {});
4721
+ return `${t3}:${s}:${this.simpleHash(i)}`;
2561
4722
  }
2562
4723
  simpleHash(t3) {
2563
4724
  let e = 0;
@@ -2578,7 +4739,7 @@ var w = b, v = class {
2578
4739
  log(t3, e, ...s) {
2579
4740
  this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
2580
4741
  }
2581
- }, C = class {
4742
+ }, A = class {
2582
4743
  constructor(t3 = {}) {
2583
4744
  var _a;
2584
4745
  this.blockedComponentsMap = /* @__PURE__ */ new Map(), this.blockedActionsSet = /* @__PURE__ */ new Set(), this.allowedCapabilitiesSet = null, this.options = { enableSRI: true, cdnDomains: [], apiDomains: [], blockedComponents: [], blockedActions: [], applyCSPOnInit: false, ...t3 }, this.updateBlockedList(((_a = t3.blockedComponents) == null ? void 0 : _a.map((t4) => `${t4.name}@${t4.version}`)) || [], t3.blockedActions || []), t3.allowedCapabilities && (this.allowedCapabilitiesSet = new Set(t3.allowedCapabilities)), t3.applyCSPOnInit && this.applyCSP();
@@ -2614,15 +4775,15 @@ var w = b, v = class {
2614
4775
  }
2615
4776
  validateCapabilities(t3, e, s) {
2616
4777
  if (!this.allowedCapabilitiesSet) return { valid: true, disallowed: [] };
2617
- const i2 = s.filter((t4) => !this.allowedCapabilitiesSet.has(t4));
2618
- return i2.length > 0 && this.log("warn", `Component ${t3}@${e} uses disallowed capabilities: ${i2.join(", ")}`), { valid: 0 === i2.length, disallowed: i2 };
4778
+ const i = s.filter((t4) => !this.allowedCapabilitiesSet.has(t4));
4779
+ return i.length > 0 && this.log("warn", `Component ${t3}@${e} uses disallowed capabilities: ${i.join(", ")}`), { valid: 0 === i.length, disallowed: i };
2619
4780
  }
2620
- async validateIntegrity(t3, e, s, i2) {
4781
+ async validateIntegrity(t3, e, s, i) {
2621
4782
  if (!this.options.enableSRI) return;
2622
- const [n2, r2] = i2.split("-");
2623
- if (!n2 || !r2) throw new o(t3, e, i2, "Invalid integrity format");
2624
- const a2 = await this.computeHash(s, n2);
2625
- if (a2 !== r2) throw this.log("error", `Integrity check failed for ${t3}@${e}`), new o(t3, e, r2, a2);
4783
+ const [n2, r2] = i.split("-");
4784
+ if (!n2 || !r2) throw new a(t3, e, i, "Invalid integrity format");
4785
+ const o2 = await this.computeHash(s, n2);
4786
+ if (o2 !== r2) throw this.log("error", `Integrity check failed for ${t3}@${e}`), new a(t3, e, r2, o2);
2626
4787
  this.log("debug", `Integrity check passed for ${t3}@${e}`);
2627
4788
  }
2628
4789
  async generateIntegrity(t3, e = "sha384") {
@@ -2655,8 +4816,8 @@ var w = b, v = class {
2655
4816
  }
2656
4817
  }
2657
4818
  generateCSPPolicy() {
2658
- const t3 = this.options.cdnDomains || [], e = this.options.apiDomains || [], s = ["'self'", ...t3].join(" "), i2 = ["'self'", ...e, ...t3].join(" ");
2659
- return ["default-src 'self'", `script-src ${s}`, `style-src ${["'self'", "'unsafe-inline'", ...t3].join(" ")}`, `img-src ${["'self'", "data:", "blob:", ...t3].join(" ")}`, `font-src ${["'self'", "data:", ...t3].join(" ")}`, `connect-src ${i2}`, "frame-ancestors 'self'", "base-uri 'self'", "form-action 'self'", "upgrade-insecure-requests"].join("; ");
4819
+ const t3 = this.options.cdnDomains || [], e = this.options.apiDomains || [], s = ["'self'", ...t3].join(" "), i = ["'self'", ...e, ...t3].join(" ");
4820
+ return ["default-src 'self'", `script-src ${s}`, `style-src ${["'self'", "'unsafe-inline'", ...t3].join(" ")}`, `img-src ${["'self'", "data:", "blob:", ...t3].join(" ")}`, `font-src ${["'self'", "data:", ...t3].join(" ")}`, `connect-src ${i}`, "frame-ancestors 'self'", "base-uri 'self'", "form-action 'self'", "upgrade-insecure-requests"].join("; ");
2660
4821
  }
2661
4822
  applyCSP() {
2662
4823
  if (document.querySelector('meta[http-equiv="Content-Security-Policy"]')) return void this.log("debug", "CSP meta tag already exists, skipping");
@@ -2665,22 +4826,22 @@ var w = b, v = class {
2665
4826
  }
2666
4827
  assertNotBlocked(t3, e) {
2667
4828
  const s = this.getBlockedInfo(t3, e);
2668
- if (s) throw new a(t3, e, s.reason);
4829
+ if (s) throw new c(t3, e, s.reason);
2669
4830
  }
2670
4831
  createSafeEvaluator() {
2671
4832
  return (t3, e) => {
2672
- const s = Object.keys(e), i2 = Object.values(e);
2673
- return new Function(...s, `"use strict"; return (${t3});`)(...i2);
4833
+ const s = Object.keys(e), i = Object.values(e);
4834
+ return new Function(...s, `"use strict"; return (${t3});`)(...i);
2674
4835
  };
2675
4836
  }
2676
4837
  async computeHash(t3, e) {
2677
- const s = new TextEncoder().encode(t3), i2 = await crypto.subtle.digest(e.toUpperCase(), s), n2 = Array.from(new Uint8Array(i2));
4838
+ const s = new TextEncoder().encode(t3), i = await crypto.subtle.digest(e.toUpperCase(), s), n2 = Array.from(new Uint8Array(i));
2678
4839
  return btoa(String.fromCharCode(...n2));
2679
4840
  }
2680
4841
  log(t3, e, ...s) {
2681
4842
  this.options.logger && this.options.logger[t3](e, ...s);
2682
4843
  }
2683
- }, I = class {
4844
+ }, T = class {
2684
4845
  constructor(t3) {
2685
4846
  this.spans = /* @__PURE__ */ new Map(), this.metrics = [], this.errors = [], this.options = { enabled: true, sampleRate: 1, batchSize: 50, flushInterval: 3e4, ...t3 }, this.traceId = this.generateTraceId(), this.shouldSample = Math.random() < (this.options.sampleRate ?? 1), this.options.enabled && this.options.endpoint && this.startAutoFlush(), "undefined" != typeof window && (window.addEventListener("beforeunload", () => this.flush()), window.addEventListener("visibilitychange", () => {
2686
4847
  "hidden" === document.visibilityState && this.flush();
@@ -2696,35 +4857,35 @@ var w = b, v = class {
2696
4857
  parseTraceparent(t3) {
2697
4858
  const e = t3.split("-");
2698
4859
  if (4 !== e.length) return null;
2699
- const [, s, i2, n2] = e;
2700
- return { traceId: s, parentSpanId: i2, sampled: "01" === n2 };
4860
+ const [, s, i, n2] = e;
4861
+ return { traceId: s, parentSpanId: i, sampled: "01" === n2 };
2701
4862
  }
2702
4863
  startSpan(t3, e, s) {
2703
- const i2 = { spanId: this.generateSpanId(), traceId: this.traceId, parentSpanId: e, name: t3, startTime: performance.now(), attributes: { pageVersionId: this.options.pageVersionId, ...s } };
2704
- return this.spans.set(i2.spanId, i2), this.log("debug", `Span started: ${t3} (${i2.spanId})`), i2;
4864
+ const i = { spanId: this.generateSpanId(), traceId: this.traceId, parentSpanId: e, name: t3, startTime: performance.now(), attributes: { pageVersionId: this.options.pageVersionId, ...s } };
4865
+ return this.spans.set(i.spanId, i), this.log("debug", `Span started: ${t3} (${i.spanId})`), i;
2705
4866
  }
2706
4867
  endSpan(t3, e = "ok", s) {
2707
- const i2 = this.spans.get(t3);
2708
- if (i2) {
2709
- i2.endTime = performance.now(), i2.status = e, s && (i2.attributes = { ...i2.attributes, ...s });
2710
- const n2 = i2.endTime - i2.startTime;
2711
- this.log("debug", `Span ended: ${i2.name} (${t3}) - ${n2.toFixed(2)}ms [${e}]`);
4868
+ const i = this.spans.get(t3);
4869
+ if (i) {
4870
+ i.endTime = performance.now(), i.status = e, s && (i.attributes = { ...i.attributes, ...s });
4871
+ const n2 = i.endTime - i.startTime;
4872
+ this.log("debug", `Span ended: ${i.name} (${t3}) - ${n2.toFixed(2)}ms [${e}]`);
2712
4873
  }
2713
4874
  }
2714
4875
  recordPageLoad(t3) {
2715
4876
  this.recordMetricInternal({ type: "pageLoadTime", value: t3, pageVersionId: this.options.pageVersionId, timestamp: Date.now() });
2716
4877
  }
2717
- recordComponentLoad(t3, e, s, i2) {
2718
- this.recordMetricInternal({ type: "componentLoadTime", value: s, pageVersionId: this.options.pageVersionId, componentName: t3, componentVersion: e, timestamp: Date.now() }), i2 || this.recordError(new Error(`Component load failed: ${t3}@${e}`), { componentVersion: `${t3}@${e}` });
4878
+ recordComponentLoad(t3, e, s, i) {
4879
+ this.recordMetricInternal({ type: "componentLoadTime", value: s, pageVersionId: this.options.pageVersionId, componentName: t3, componentVersion: e, timestamp: Date.now() }), i || this.recordError(new Error(`Component load failed: ${t3}@${e}`), { componentVersion: `${t3}@${e}` });
2719
4880
  }
2720
4881
  recordFirstRender(t3) {
2721
4882
  this.recordMetricInternal({ type: "firstRenderTime", value: t3, pageVersionId: this.options.pageVersionId, timestamp: Date.now() });
2722
4883
  }
2723
- recordActionExecute(t3, e, s, i2) {
2724
- this.recordMetricInternal({ type: "actionExecuteTime", value: s, pageVersionId: this.options.pageVersionId, actionType: t3, timestamp: Date.now() }), i2 || this.recordError(new Error(`Action failed: ${t3}`), { actionId: e });
4884
+ recordActionExecute(t3, e, s, i) {
4885
+ this.recordMetricInternal({ type: "actionExecuteTime", value: s, pageVersionId: this.options.pageVersionId, actionType: t3, timestamp: Date.now() }), i || this.recordError(new Error(`Action failed: ${t3}`), { actionId: e });
2725
4886
  }
2726
- recordQueryExecute(t3, e, s, i2 = false) {
2727
- this.recordMetricInternal({ type: "queryFetchTime", value: e, pageVersionId: this.options.pageVersionId, queryId: t3, timestamp: Date.now() }), this.log("debug", `Query ${t3}: ${e.toFixed(2)}ms, cache: ${i2}, success: ${s}`);
4887
+ recordQueryExecute(t3, e, s, i = false) {
4888
+ this.recordMetricInternal({ type: "queryFetchTime", value: e, pageVersionId: this.options.pageVersionId, queryId: t3, timestamp: Date.now() }), this.log("debug", `Query ${t3}: ${e.toFixed(2)}ms, cache: ${i}, success: ${s}`);
2728
4889
  }
2729
4890
  recordExpressionEval(t3, e, s) {
2730
4891
  e > 1 && this.recordMetricInternal({ type: "expressionEvalTime", value: e, pageVersionId: this.options.pageVersionId, timestamp: Date.now() });
@@ -2783,7 +4944,7 @@ var w = b, v = class {
2783
4944
  log(t3, e, ...s) {
2784
4945
  this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
2785
4946
  }
2786
- }, A = class t2 {
4947
+ }, j = class t2 {
2787
4948
  constructor(t3) {
2788
4949
  this.container = null, this.renderedElements = /* @__PURE__ */ new Map(), this.componentEventListeners = /* @__PURE__ */ new Map(), this.expressionContext = { state: {}, binding: {}, local: {} }, this.loopContextStack = [], this.styleElement = null, this.options = t3;
2789
4950
  }
@@ -2819,13 +4980,13 @@ var w = b, v = class {
2819
4980
  }), this.renderedElements.clear(), this.styleElement && (this.styleElement.remove(), this.styleElement = null), this.loopContextStack = [];
2820
4981
  }
2821
4982
  renderNode(t3) {
2822
- const { id: e, componentType: s, componentVersion: i2 } = t3;
4983
+ const { id: e, componentType: s, componentVersion: i } = t3;
2823
4984
  try {
2824
4985
  if (t3.condition && !this.evaluateCondition(t3.condition)) return this.log("debug", `Component ${e} hidden by condition`), null;
2825
4986
  if (t3.loop) return this.renderLoop(t3);
2826
4987
  const n2 = this.createElement(t3);
2827
4988
  if (!n2) return null;
2828
- n2.setAttribute("data-component-id", e), n2.setAttribute("data-component-type", s), i2 && n2.setAttribute("data-component-version", i2);
4989
+ n2.setAttribute("data-component-id", e), n2.setAttribute("data-component-type", s), i && n2.setAttribute("data-component-version", i);
2829
4990
  const r2 = this.resolveProps(t3.props);
2830
4991
  if (this.applyProps(n2, r2), t3.style && this.applyStyles(n2, t3.style), t3.layout && this.applyLayout(n2, t3.layout), this.options.injectHostApi(n2, e), t3.eventHandlers && t3.eventHandlers.length > 0 && this.bindEventHandlers(n2, e, t3.eventHandlers), this.renderChildren(n2, t3), t3.ref) {
2831
4992
  const e2 = this.expressionContext.local, s2 = e2.$refs || {};
@@ -2840,8 +5001,8 @@ var w = b, v = class {
2840
5001
  var _a;
2841
5002
  const { componentType: e } = t3, s = this.options.components.get(e);
2842
5003
  if (s && customElements.get(e)) return document.createElement(e);
2843
- const i2 = `${e}-${(_a = t3.componentVersion) == null ? void 0 : _a.replace(/\./g, "-")}`;
2844
- if (customElements.get(i2)) return document.createElement(i2);
5004
+ const i = `${e}-${(_a = t3.componentVersion) == null ? void 0 : _a.replace(/\./g, "-")}`;
5005
+ if (customElements.get(i)) return document.createElement(i);
2845
5006
  const n2 = document.createElement("div");
2846
5007
  return n2.className = `djvlc-component djvlc-${e}`, s || (this.log("warn", `Component not loaded: ${e}`), n2.classList.add("djvlc-component-fallback")), n2;
2847
5008
  }
@@ -2850,7 +5011,7 @@ var w = b, v = class {
2850
5011
  if (!e) return null;
2851
5012
  const s = this.evaluateExpression(e.items);
2852
5013
  if (!Array.isArray(s)) return this.log("warn", `Loop items is not an array for ${t3.id}`), null;
2853
- const i2 = document.createDocumentFragment();
5014
+ const i = document.createDocumentFragment();
2854
5015
  s.forEach((s2, n3) => {
2855
5016
  this.loopContextStack.push({ item: s2, index: n3, loopConfig: e });
2856
5017
  const r2 = { ...this.expressionContext }, o2 = { ...this.expressionContext.local, [e.itemName]: s2, item: s2, index: n3 };
@@ -2858,17 +5019,17 @@ var w = b, v = class {
2858
5019
  const a2 = { ...t3, id: `${t3.id}_${n3}`, loop: void 0 }, c2 = this.renderNode(a2);
2859
5020
  if (c2) {
2860
5021
  const t4 = this.evaluateExpression(e.key);
2861
- c2.setAttribute("data-loop-key", String(t4 ?? n3)), i2.appendChild(c2);
5022
+ c2.setAttribute("data-loop-key", String(t4 ?? n3)), i.appendChild(c2);
2862
5023
  }
2863
5024
  this.expressionContext = r2, this.loopContextStack.pop();
2864
5025
  });
2865
5026
  const n2 = document.createElement("div");
2866
- return n2.className = "djvlc-loop-container", n2.setAttribute("data-loop-id", t3.id), n2.appendChild(i2), n2;
5027
+ return n2.className = "djvlc-loop-container", n2.setAttribute("data-loop-id", t3.id), n2.appendChild(i), n2;
2867
5028
  }
2868
5029
  renderChildren(t3, e) {
2869
- if (e.slots && Object.keys(e.slots).length > 0) for (const [s, i2] of Object.entries(e.slots)) {
5030
+ if (e.slots && Object.keys(e.slots).length > 0) for (const [s, i] of Object.entries(e.slots)) {
2870
5031
  const e2 = this.createSlotContainer(s);
2871
- for (const t4 of i2) {
5032
+ for (const t4 of i) {
2872
5033
  const s2 = this.renderNode(t4);
2873
5034
  s2 && e2.appendChild(s2);
2874
5035
  }
@@ -2880,31 +5041,31 @@ var w = b, v = class {
2880
5041
  return e.className = `djvlc-slot djvlc-slot-${t3}`, e.setAttribute("data-slot", t3), e;
2881
5042
  }
2882
5043
  bindEventHandlers(t3, e, s) {
2883
- const i2 = [];
5044
+ const i = [];
2884
5045
  for (const n2 of s) {
2885
5046
  const { eventName: s2, preventDefault: r2, stopPropagation: o2, throttle: a2, debounce: c2, condition: h2 } = n2;
2886
- let l2 = (t4) => {
5047
+ let u2 = (t4) => {
2887
5048
  if (h2 && !this.evaluateCondition(h2)) return;
2888
5049
  r2 && t4.preventDefault(), o2 && t4.stopPropagation();
2889
- const i3 = t4.detail || {};
2890
- this.options.onComponentEvent && this.options.onComponentEvent(e, s2, [n2], i3);
5050
+ const i2 = t4.detail || {};
5051
+ this.options.onComponentEvent && this.options.onComponentEvent(e, s2, [n2], i2);
2891
5052
  };
2892
- a2 && a2 > 0 && (l2 = this.createThrottledHandler(l2, a2)), c2 && c2 > 0 && (l2 = this.createDebouncedHandler(l2, c2)), t3.addEventListener(s2, l2), i2.push({ event: s2, handler: l2 });
5053
+ a2 && a2 > 0 && (u2 = this.createThrottledHandler(u2, a2)), c2 && c2 > 0 && (u2 = this.createDebouncedHandler(u2, c2)), t3.addEventListener(s2, u2), i.push({ event: s2, handler: u2 });
2893
5054
  }
2894
- this.componentEventListeners.set(e, i2);
5055
+ this.componentEventListeners.set(e, i);
2895
5056
  }
2896
5057
  createThrottledHandler(t3, e) {
2897
5058
  let s = 0;
2898
- return (i2) => {
5059
+ return (i) => {
2899
5060
  const n2 = Date.now();
2900
- n2 - s >= e && (s = n2, t3(i2));
5061
+ n2 - s >= e && (s = n2, t3(i));
2901
5062
  };
2902
5063
  }
2903
5064
  createDebouncedHandler(t3, e) {
2904
5065
  let s = null;
2905
- return (i2) => {
5066
+ return (i) => {
2906
5067
  s && clearTimeout(s), s = setTimeout(() => {
2907
- t3(i2), s = null;
5068
+ t3(i), s = null;
2908
5069
  }, e);
2909
5070
  };
2910
5071
  }
@@ -2931,7 +5092,7 @@ var w = b, v = class {
2931
5092
  }
2932
5093
  resolveProps(t3) {
2933
5094
  const e = {};
2934
- for (const [s, i2] of Object.entries(t3)) e[s] = this.resolveValue(i2);
5095
+ for (const [s, i] of Object.entries(t3)) e[s] = this.resolveValue(i);
2935
5096
  return e;
2936
5097
  }
2937
5098
  resolveValue(e) {
@@ -2945,19 +5106,19 @@ var w = b, v = class {
2945
5106
  const t3 = s;
2946
5107
  return this.options.expressionEngine.evaluateWithFallback(t3.value, this.buildExpressionContext(), t3.fallback);
2947
5108
  }
2948
- const i2 = {};
2949
- for (const [t3, e2] of Object.entries(s)) i2[t3] = this.resolveValue(e2);
2950
- return i2;
5109
+ const i = {};
5110
+ for (const [t3, e2] of Object.entries(s)) i[t3] = this.resolveValue(e2);
5111
+ return i;
2951
5112
  }
2952
5113
  return e;
2953
5114
  }
2954
5115
  applyProps(t3, e) {
2955
- for (const [s, i2] of Object.entries(e)) null != i2 && (t3.tagName.includes("-") ? t3[s] = i2 : "boolean" == typeof i2 ? i2 ? t3.setAttribute(s, "") : t3.removeAttribute(s) : "object" == typeof i2 ? t3.setAttribute(s, JSON.stringify(i2)) : t3.setAttribute(s, String(i2)));
5116
+ for (const [s, i] of Object.entries(e)) null != i && (t3.tagName.includes("-") ? t3[s] = i : "boolean" == typeof i ? i ? t3.setAttribute(s, "") : t3.removeAttribute(s) : "object" == typeof i ? t3.setAttribute(s, JSON.stringify(i)) : t3.setAttribute(s, String(i)));
2956
5117
  }
2957
5118
  applyStyles(t3, e) {
2958
- if (e.inline) for (const [s, i2] of Object.entries(e.inline)) {
2959
- if (null == i2) continue;
2960
- const e2 = this.resolveValue(i2);
5119
+ if (e.inline) for (const [s, i] of Object.entries(e.inline)) {
5120
+ if (null == i) continue;
5121
+ const e2 = this.resolveValue(i);
2961
5122
  let n2;
2962
5123
  n2 = "number" == typeof e2 ? ["zIndex", "opacity", "flex", "fontWeight", "lineHeight"].includes(s) ? String(e2) : `${e2}px` : String(e2);
2963
5124
  const r2 = s.replace(/([A-Z])/g, "-$1").toLowerCase();
@@ -2966,34 +5127,34 @@ var w = b, v = class {
2966
5127
  e.className && t3.classList.add(...String(e.className).split(" ").filter(Boolean));
2967
5128
  }
2968
5129
  applyLayout(t3, e) {
2969
- const { x: s, y: i2, width: n2, height: r2, rotation: o2, zIndex: a2, responsive: c2 } = e;
2970
- t3.style.position = "absolute", void 0 !== s && (t3.style.left = `${s}px`), void 0 !== i2 && (t3.style.top = `${i2}px`), void 0 !== n2 && (t3.style.width = `${n2}px`), void 0 !== r2 && (t3.style.height = `${r2}px`), void 0 !== o2 && (t3.style.transform = `rotate(${o2}deg)`), void 0 !== a2 && (t3.style.zIndex = String(a2)), c2 && this.applyResponsiveLayout(t3, c2);
5130
+ const { x: s, y: i, width: n2, height: r2, rotation: o2, zIndex: a2, responsive: c2 } = e;
5131
+ t3.style.position = "absolute", void 0 !== s && (t3.style.left = `${s}px`), void 0 !== i && (t3.style.top = `${i}px`), void 0 !== n2 && (t3.style.width = `${n2}px`), void 0 !== r2 && (t3.style.height = `${r2}px`), void 0 !== o2 && (t3.style.transform = `rotate(${o2}deg)`), void 0 !== a2 && (t3.style.zIndex = String(a2)), c2 && this.applyResponsiveLayout(t3, c2);
2971
5132
  }
2972
5133
  applyResponsiveLayout(t3, e) {
2973
5134
  const s = t3.getAttribute("data-component-id");
2974
5135
  if (!s) return;
2975
- let i2 = "";
2976
- if (e.mobile && (i2 += `
5136
+ let i = "";
5137
+ if (e.mobile && (i += `
2977
5138
  @media (max-width: 767px) {
2978
5139
  [data-component-id="${s}"] {
2979
5140
  ${this.layoutToCSS(e.mobile)}
2980
5141
  }
2981
5142
  }
2982
- `), e.tablet && (i2 += `
5143
+ `), e.tablet && (i += `
2983
5144
  @media (min-width: 768px) and (max-width: 1023px) {
2984
5145
  [data-component-id="${s}"] {
2985
5146
  ${this.layoutToCSS(e.tablet)}
2986
5147
  }
2987
5148
  }
2988
- `), e.desktop && (i2 += `
5149
+ `), e.desktop && (i += `
2989
5150
  @media (min-width: 1440px) {
2990
5151
  [data-component-id="${s}"] {
2991
5152
  ${this.layoutToCSS(e.desktop)}
2992
5153
  }
2993
5154
  }
2994
- `), i2) {
5155
+ `), i) {
2995
5156
  const t4 = document.createElement("style");
2996
- t4.setAttribute("data-djvlc-responsive", s), t4.textContent = i2, document.head.appendChild(t4);
5157
+ t4.setAttribute("data-djvlc-responsive", s), t4.textContent = i, document.head.appendChild(t4);
2997
5158
  }
2998
5159
  }
2999
5160
  layoutToCSS(t3) {
@@ -3013,9 +5174,9 @@ var w = b, v = class {
3013
5174
  t3.setAttribute("lang", s), t3.setAttribute("data-locale", s), t3.setAttribute("data-default-locale", e.defaultLocale), t3.setAttribute("data-supported-locales", e.supportedLocales.join(",")), e.translationBundleId && t3.setAttribute("data-translation-bundle", e.translationBundleId), t3.style.setProperty("--djvlc-locale", s), t3.style.setProperty("--djvlc-dir", this.getTextDirection(s)), "rtl" === this.getTextDirection(s) ? (t3.setAttribute("dir", "rtl"), t3.classList.add("djvlc-rtl")) : t3.setAttribute("dir", "ltr"), this.expressionContext = { ...this.expressionContext, local: { ...this.expressionContext.local, $locale: s, $defaultLocale: e.defaultLocale, $supportedLocales: e.supportedLocales } }, this.log("debug", `I18n configured: locale=${s}, default=${e.defaultLocale}`);
3014
5175
  }
3015
5176
  detectLocale(t3) {
3016
- const { defaultLocale: e, supportedLocales: s, detection: i2 = "browser" } = t3;
5177
+ const { defaultLocale: e, supportedLocales: s, detection: i = "browser" } = t3;
3017
5178
  let n2 = null;
3018
- switch (i2) {
5179
+ switch (i) {
3019
5180
  case "browser":
3020
5181
  case "header":
3021
5182
  n2 = this.detectBrowserLocale(s);
@@ -3042,8 +5203,8 @@ var w = b, v = class {
3042
5203
  const e = navigator.languages || [navigator.language];
3043
5204
  for (const s of e) {
3044
5205
  if (t3.includes(s)) return s;
3045
- const e2 = s.split("-")[0], i2 = t3.find((t4) => t4 === e2 || t4.startsWith(`${e2}-`));
3046
- if (i2) return i2;
5206
+ const e2 = s.split("-")[0], i = t3.find((t4) => t4 === e2 || t4.startsWith(`${e2}-`));
5207
+ if (i) return i;
3047
5208
  }
3048
5209
  return null;
3049
5210
  }
@@ -3065,9 +5226,9 @@ var w = b, v = class {
3065
5226
  if ("undefined" == typeof document) return null;
3066
5227
  const e = document.cookie.split(";");
3067
5228
  for (const s of e) {
3068
- const [e2, i2] = s.trim().split("=");
5229
+ const [e2, i] = s.trim().split("=");
3069
5230
  if ("lang" === e2 || "locale" === e2 || "language" === e2) {
3070
- const e3 = decodeURIComponent(i2);
5231
+ const e3 = decodeURIComponent(i);
3071
5232
  if (t3.includes(e3)) return e3;
3072
5233
  }
3073
5234
  }
@@ -3079,15 +5240,15 @@ var w = b, v = class {
3079
5240
  }
3080
5241
  applyLayoutConfig(t3, e) {
3081
5242
  if (t3.setAttribute("data-canvas-type", e.canvasType), e.canvasSize && "responsive" !== e.canvasType && (t3.style.width = `${e.canvasSize.width}px`, t3.style.minHeight = `${e.canvasSize.height}px`), e.maxWidth && (t3.style.maxWidth = `${e.maxWidth}px`, t3.style.marginLeft = "auto", t3.style.marginRight = "auto"), e.padding) {
3082
- const { top: s = 0, right: i2 = 0, bottom: n2 = 0, left: r2 = 0 } = e.padding;
3083
- t3.style.padding = `${s}px ${i2}px ${n2}px ${r2}px`;
5243
+ const { top: s = 0, right: i = 0, bottom: n2 = 0, left: r2 = 0 } = e.padding;
5244
+ t3.style.padding = `${s}px ${i}px ${n2}px ${r2}px`;
3084
5245
  }
3085
5246
  e.viewport && (e.viewport.mobile && t3.style.setProperty("--djvlc-breakpoint-mobile", `${e.viewport.mobile}px`), e.viewport.tablet && t3.style.setProperty("--djvlc-breakpoint-tablet", `${e.viewport.tablet}px`), e.viewport.desktop && t3.style.setProperty("--djvlc-breakpoint-desktop", `${e.viewport.desktop}px`));
3086
5247
  }
3087
5248
  applyStylesConfig(t3, e) {
3088
- if (e.theme && this.applyThemeConfig(t3, e.theme), e.background && this.applyBackgroundConfig(t3, e.background), e.cssVariables) for (const [s, i2] of Object.entries(e.cssVariables)) {
5249
+ if (e.theme && this.applyThemeConfig(t3, e.theme), e.background && this.applyBackgroundConfig(t3, e.background), e.cssVariables) for (const [s, i] of Object.entries(e.cssVariables)) {
3089
5250
  const e2 = s.startsWith("--") ? s : `--${s}`;
3090
- t3.style.setProperty(e2, i2);
5251
+ t3.style.setProperty(e2, i);
3091
5252
  }
3092
5253
  e.customCSS && this.injectCustomCSS(e.customCSS);
3093
5254
  }
@@ -3096,9 +5257,9 @@ var w = b, v = class {
3096
5257
  const e2 = window.matchMedia("(prefers-color-scheme: dark)").matches;
3097
5258
  t3.setAttribute("data-theme-resolved", e2 ? "dark" : "light");
3098
5259
  }
3099
- if (e.variables) for (const [s, i2] of Object.entries(e.variables)) {
5260
+ if (e.variables) for (const [s, i] of Object.entries(e.variables)) {
3100
5261
  const e2 = s.startsWith("--") ? s : `--theme-${s}`;
3101
- t3.style.setProperty(e2, i2);
5262
+ t3.style.setProperty(e2, i);
3102
5263
  }
3103
5264
  e.transition && t3.style.setProperty("--djvlc-theme-transition", "all 0.3s ease");
3104
5265
  }
@@ -3120,27 +5281,27 @@ var w = b, v = class {
3120
5281
  initializePageState(t3) {
3121
5282
  if (t3.state && t3.state.fields) {
3122
5283
  const e = {};
3123
- for (const [s, i2] of Object.entries(t3.state.fields)) i2 && "object" == typeof i2 && (e[s] = i2.initialValue);
5284
+ for (const [s, i] of Object.entries(t3.state.fields)) i && "object" == typeof i && (e[s] = i.initialValue);
3124
5285
  this.expressionContext = { ...this.expressionContext, state: e };
3125
5286
  }
3126
5287
  }
3127
5288
  createErrorFallback(t3, e, s) {
3128
- const i2 = document.createElement("div");
3129
- return i2.className = "djvlc-error-boundary", i2.setAttribute("data-component-id", t3), i2.setAttribute("data-error", "true"), i2.innerHTML = `
5289
+ const i = document.createElement("div");
5290
+ return i.className = "djvlc-error-boundary", i.setAttribute("data-component-id", t3), i.setAttribute("data-error", "true"), i.innerHTML = `
3130
5291
  <div class="djvlc-error-content">
3131
5292
  <span class="djvlc-error-icon">⚠️</span>
3132
5293
  <span class="djvlc-error-message">组件渲染失败: ${e}</span>
3133
5294
  ${this.options.debug ? `<pre class="djvlc-error-detail">${s.message}</pre>` : ""}
3134
5295
  </div>
3135
- `, i2;
5296
+ `, i;
3136
5297
  }
3137
5298
  log(t3, e, ...s) {
3138
5299
  this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
3139
5300
  }
3140
5301
  };
3141
- A.EXPRESSION_TYPES = ["state", "binding", "local", "template", "computed"];
3142
- var T = A;
3143
- function j() {
5302
+ j.EXPRESSION_TYPES = ["state", "binding", "local", "template", "computed"];
5303
+ var D = j;
5304
+ function R() {
3144
5305
  customElements.get("djvlc-fallback") || customElements.define("djvlc-fallback", class extends HTMLElement {
3145
5306
  constructor() {
3146
5307
  super(), this.attachShadow({ mode: "open" }).innerHTML = '\n <style>\n :host {\n display: block;\n padding: 16px;\n background: #fff2f0;\n border: 1px solid #ffccc7;\n border-radius: 4px;\n color: #ff4d4f;\n font-size: 14px;\n }\n .title {\n font-weight: 600;\n margin-bottom: 8px;\n }\n .message {\n color: #666;\n }\n </style>\n <div class="title">组件加载失败</div>\n <div class="message"><slot>请刷新页面重试</slot></div>\n ';
@@ -3168,11 +5329,11 @@ function j() {
3168
5329
  }
3169
5330
  });
3170
5331
  }
3171
- function D(t3, e, s) {
3172
- const i2 = `djvlc-${"error-boundary"}`, n2 = document.createElement(i2);
5332
+ function M(t3, e, s) {
5333
+ const i = `djvlc-${"error-boundary"}`, n2 = document.createElement(i);
3173
5334
  return e && n2.setAttribute("message", e), n2;
3174
5335
  }
3175
- var R = class {
5336
+ var L = class {
3176
5337
  constructor(t3) {
3177
5338
  this.lifecycle = null, this.mounted = false, this.destroyed = false, this.cleanupFns = [], this.options = t3;
3178
5339
  }
@@ -3224,8 +5385,8 @@ var R = class {
3224
5385
  if (e && 0 !== e.length) {
3225
5386
  this.log("debug", `Executing ${e.length} actions for ${t3}`);
3226
5387
  try {
3227
- const i2 = { id: `lifecycle_${t3}`, eventName: t3, actions: e };
3228
- await this.options.actionBridge.handleEvent(i2, { lifecycle: t3 }, s), this.log("debug", `Lifecycle ${t3} actions completed`);
5388
+ const i = { id: `lifecycle_${t3}`, eventName: t3, actions: e };
5389
+ await this.options.actionBridge.handleEvent(i, { lifecycle: t3 }, s), this.log("debug", `Lifecycle ${t3} actions completed`);
3229
5390
  } catch (e2) {
3230
5391
  this.log("error", `Failed to execute lifecycle ${t3} actions`, e2);
3231
5392
  }
@@ -3234,20 +5395,41 @@ var R = class {
3234
5395
  log(t3, e, ...s) {
3235
5396
  this.options.logger ? this.options.logger[t3](e, ...s) : this.options.debug;
3236
5397
  }
3237
- }, M = CURRENT_SCHEMA_VERSION, O = "1.0.0";
3238
- function L(t3) {
3239
- return new P(t3);
5398
+ }, O = class {
5399
+ constructor(t3 = {}) {
5400
+ this.client = createUserClient({ baseUrl: t3.baseUrl ?? "/api", timeout: t3.timeout ?? 3e4, auth: t3.auth, headers: t3.headers, retry: t3.retry, enableRetry: t3.enableRetry, logger: t3.logger, debug: t3.debug });
5401
+ }
5402
+ async resolvePage(t3) {
5403
+ return (await this.client.pages.resolvePage({ pageId: t3.pageId, env: t3.env, uid: t3.uid, deviceId: t3.deviceId, channel: t3.channel })).data;
5404
+ }
5405
+ async executeAction(t3) {
5406
+ const e = await this.client.actions.executeAction({ executeActionRequest: { actionType: t3.actionType, params: t3.params, context: { pageVersionId: t3.context.pageVersionId, deviceId: t3.context.deviceId, channel: t3.context.channel, extra: { uid: t3.context.uid, appId: t3.context.appId } }, idempotencyKey: t3.idempotencyKey } }), s = e.data;
5407
+ return { success: e.success, data: s == null ? void 0 : s.result, errorCode: s == null ? void 0 : s.errorCode, errorMessage: s == null ? void 0 : s.errorMessage };
5408
+ }
5409
+ async executeQuery(t3) {
5410
+ const e = await this.client.queries.queryData({ queryDataRequest: { queryVersionId: t3.queryVersionId, params: t3.params ?? {}, context: { pageVersionId: t3.context.pageVersionId } } });
5411
+ return { success: e.success, data: e.data ?? void 0, message: e.message, errorMessage: e.errorMessage };
5412
+ }
5413
+ track(t3) {
5414
+ this.client.track.track({ trackRequest: { eventName: t3.eventName, eventType: t3.type ?? "custom", properties: t3.params, timestamp: null != t3.timestamp ? new Date(t3.timestamp) : void 0, context: { pageVersionId: t3.context.pageVersionId, sessionId: t3.context.userId } } }).catch(() => {
5415
+ });
5416
+ }
5417
+ }, V = CURRENT_SCHEMA_VERSION, B = "1.0.0";
5418
+ function U(t3) {
5419
+ return new F(t3);
3240
5420
  }
3241
- var P = class {
5421
+ var F = class {
3242
5422
  constructor(t3) {
3243
5423
  if (this.container = null, !t3.pageId) throw new Error("pageId is required");
3244
- this.options = { channel: "prod", debug: false, enableSRI: true, env: "production", ...t3 }, this.logger = this.createLogger(), this.stateManager = new m(), this.eventBus = new y({ debug: t3.debug, logger: this.logger }), this.expressionEngine = new E({ debug: t3.debug, logger: this.logger }), this.pageLoader = new d({ apiBaseUrl: t3.apiBaseUrl, channel: t3.channel, authToken: t3.authToken, previewToken: t3.previewToken, headers: t3.headers, logger: this.logger }), this.componentLoader = new p({ cdnBaseUrl: t3.cdnBaseUrl, enableSRI: t3.enableSRI, logger: this.logger }), this.assetLoader = new f({ cdnHosts: [new URL(t3.cdnBaseUrl).host], apiHosts: [new URL(t3.apiBaseUrl).host] }), this.securityManager = new C({ enableSRI: t3.enableSRI, cdnDomains: [new URL(t3.cdnBaseUrl).host], apiDomains: [new URL(t3.apiBaseUrl).host], logger: this.logger }), this.log("info", "Runtime created", { version: O });
5424
+ this.options = { channel: "prod", debug: false, enableSRI: true, env: "production", ...t3 }, this.logger = this.createLogger(), this.stateManager = new y(), this.eventBus = new w({ debug: t3.debug, logger: this.logger }), this.expressionEngine = new N({ debug: t3.debug, logger: this.logger });
5425
+ const e = t3;
5426
+ this.userApiAdapter = e.userApiAdapter ?? new O({ baseUrl: t3.apiBaseUrl, headers: t3.headers, ...null != t3.authToken && "" !== t3.authToken ? { auth: { type: "bearer", getToken: () => Promise.resolve(t3.authToken) } } : {} }), this.pageLoader = new p({ apiBaseUrl: t3.apiBaseUrl, userApiAdapter: this.userApiAdapter, channel: t3.channel, previewToken: t3.previewToken, headers: t3.headers, logger: this.logger }), this.componentLoader = new m({ cdnBaseUrl: t3.cdnBaseUrl, enableSRI: t3.enableSRI, headers: t3.headers, logger: this.logger }), this.assetLoader = new g({ cdnHosts: [new URL(t3.cdnBaseUrl).host], apiHosts: [new URL(t3.apiBaseUrl).host] }), this.securityManager = new A({ enableSRI: t3.enableSRI, cdnDomains: [new URL(t3.cdnBaseUrl).host], apiDomains: [new URL(t3.apiBaseUrl).host], logger: this.logger }), this.log("info", "Runtime created", { version: B });
3245
5427
  }
3246
5428
  async init() {
3247
5429
  this.log("info", "Initializing runtime");
3248
5430
  const t3 = performance.now();
3249
5431
  try {
3250
- this.container = this.resolveContainer(), this.assetLoader.preconnectAll(), this.pageLoader.preconnect(), j(), this.stateManager.setPhase("resolving");
5432
+ this.container = this.resolveContainer(), this.assetLoader.preconnectAll(), this.pageLoader.preconnect(), R(), this.stateManager.setPhase("resolving");
3251
5433
  const e = performance.now() - t3;
3252
5434
  this.log("info", `Runtime initialized in ${e.toFixed(2)}ms`);
3253
5435
  } catch (t4) {
@@ -3261,7 +5443,7 @@ var P = class {
3261
5443
  try {
3262
5444
  this.stateManager.setPhase("resolving");
3263
5445
  const e = await this.pageLoader.resolve(this.options.pageId, { uid: this.options.userId, deviceId: this.options.deviceId });
3264
- if (this.validateSchemaVersion(e.pageJson), this.stateManager.setPage(e), this.telemetryManager = new I({ pageVersionId: e.pageVersionId, appId: this.options.appId, debug: this.options.debug, logger: this.logger, onMetric: this.options.onMetric }), e.runtimeConfig) {
5446
+ if (this.validateSchemaVersion(e.pageJson), this.stateManager.setPage(e), this.telemetryManager = new T({ pageVersionId: e.pageVersionId, appId: this.options.appId, debug: this.options.debug, logger: this.logger, onMetric: this.options.onMetric }), e.runtimeConfig) {
3265
5447
  const t4 = ((_a = e.runtimeConfig.blockedComponents) == null ? void 0 : _a.map((t5) => `${t5.name}@${t5.version}`)) || [];
3266
5448
  this.securityManager.updateBlockedList(t4, []), this.componentLoader.updateBlockedList(t4);
3267
5449
  }
@@ -3276,7 +5458,7 @@ var P = class {
3276
5458
  }
3277
5459
  async render() {
3278
5460
  const t3 = this.stateManager.getState();
3279
- if (!t3.page || !this.container) throw new n("Page not loaded");
5461
+ if (!t3.page || !this.container) throw new r("Page not loaded");
3280
5462
  this.log("info", "Rendering page");
3281
5463
  const e = performance.now();
3282
5464
  try {
@@ -3319,7 +5501,7 @@ var P = class {
3319
5501
  this.log("info", "Destroying runtime"), await ((_a = this.lifecycleManager) == null ? void 0 : _a.destroy()), (_b = this.telemetryManager) == null ? void 0 : _b.flush(), (_c = this.dataBindingManager) == null ? void 0 : _c.destroy(), (_d = this.actionBridge) == null ? void 0 : _d.destroy(), (_e = this.renderer) == null ? void 0 : _e.destroy(), this.eventBus.clear(), this.stateManager.setDestroyed(), this.container && (this.container.innerHTML = ""), this.emitEvent("page:destroyed", {}), this.log("info", "Runtime destroyed");
3320
5502
  }
3321
5503
  validateSchemaVersion(t3) {
3322
- if (t3.schemaVersion !== M) throw new n(`Unsupported schema version: ${t3.schemaVersion}. Only ${M} is supported.`, { schemaVersion: t3.schemaVersion, supportedVersion: M });
5504
+ if (t3.schemaVersion !== V) throw new r(`Unsupported schema version: ${t3.schemaVersion}. Only ${V} is supported.`, { schemaVersion: t3.schemaVersion, supportedVersion: V });
3323
5505
  }
3324
5506
  resolveContainer() {
3325
5507
  const { container: t3 } = this.options;
@@ -3331,10 +5513,10 @@ var P = class {
3331
5513
  return t3;
3332
5514
  }
3333
5515
  initHostApi(t3) {
3334
- this.hostApi = new N({ apiBaseUrl: this.options.apiBaseUrl, authToken: this.options.authToken, headers: this.options.headers, stateManager: this.stateManager, eventBus: this.eventBus, expressionEngine: this.expressionEngine, context: { pageId: t3.pageId, pageVersionId: t3.pageVersionId, runtimeVersion: O, userId: this.options.userId, deviceId: this.options.deviceId, channel: this.options.channel, appId: this.options.appId || "", env: this.options.env || "production", isEditMode: false, isPreviewMode: t3.isPreview || false }, debug: this.options.debug, logger: this.logger });
5516
+ this.hostApi = new C({ userApiAdapter: this.userApiAdapter, stateManager: this.stateManager, eventBus: this.eventBus, expressionEngine: this.expressionEngine, context: { pageId: t3.pageId, pageVersionId: t3.pageVersionId, runtimeVersion: B, userId: this.options.userId, deviceId: this.options.deviceId, channel: this.options.channel, appId: this.options.appId || "", env: this.options.env || "production", isEditMode: false, isPreviewMode: t3.isPreview || false }, debug: this.options.debug, logger: this.logger });
3335
5517
  }
3336
5518
  initActionBridge() {
3337
- this.actionBridge = new w({ executor: { executeAction: (t3, e) => this.hostApi.executeAction(t3, e), requestData: (t3, e) => this.hostApi.requestData(t3, e), navigate: (t3) => this.hostApi.navigate(t3), openDialog: (t3) => this.hostApi.openDialog(t3), closeDialog: () => this.hostApi.closeDialog(), showToast: (t3) => this.hostApi.showToast(t3), showLoading: (t3) => this.hostApi.showLoading(t3), hideLoading: () => this.hostApi.hideLoading(), track: (t3) => this.hostApi.track(t3), setState: (t3, e) => this.stateManager.setVariable(t3, e), getState: (t3) => this.stateManager.getVariable(t3), refreshData: (t3) => this.refreshData(t3) }, expressionEngine: this.expressionEngine, debug: this.options.debug, logger: this.logger, onActionStart: (t3, e) => {
5519
+ this.actionBridge = new $({ executor: { executeAction: (t3, e) => this.hostApi.executeAction(t3, e), requestData: (t3, e) => this.hostApi.requestData(t3, e), navigate: (t3) => this.hostApi.navigate(t3), openDialog: (t3) => this.hostApi.openDialog(t3), closeDialog: () => this.hostApi.closeDialog(), showToast: (t3) => this.hostApi.showToast(t3), showLoading: (t3) => this.hostApi.showLoading(t3), hideLoading: () => this.hostApi.hideLoading(), track: (t3) => this.hostApi.track(t3), setState: (t3, e) => this.stateManager.setVariable(t3, e), getState: (t3) => this.stateManager.getVariable(t3), refreshData: (t3) => this.refreshData(t3) }, expressionEngine: this.expressionEngine, debug: this.options.debug, logger: this.logger, onActionStart: (t3, e) => {
3338
5520
  this.emitEvent("action:executing", { action: t3, params: e });
3339
5521
  }, onActionComplete: (t3, e) => {
3340
5522
  var _a;
@@ -3342,7 +5524,7 @@ var P = class {
3342
5524
  } });
3343
5525
  }
3344
5526
  initDataBindingManager(t3) {
3345
- this.dataBindingManager = new g({ requester: { requestData: (t4, e) => this.hostApi.requestData(t4, e) }, stateSetter: { setVariable: (t4, e) => this.stateManager.setVariable(t4, e), getVariable: (t4) => this.stateManager.getVariable(t4) }, expressionEngine: this.expressionEngine, debug: this.options.debug, logger: this.logger, onDataLoaded: (t4, e) => {
5527
+ this.dataBindingManager = new b({ requester: { requestData: (t4, e) => this.hostApi.requestData(t4, e) }, stateSetter: { setVariable: (t4, e) => this.stateManager.setVariable(t4, e), getVariable: (t4) => this.stateManager.getVariable(t4) }, expressionEngine: this.expressionEngine, debug: this.options.debug, logger: this.logger, onDataLoaded: (t4, e) => {
3346
5528
  var _a;
3347
5529
  this.emitEvent("query:fetched", { bindingId: t4, data: e }), (_a = this.renderer) == null ? void 0 : _a.updateContext(this.stateManager.getExpressionContext());
3348
5530
  }, onDataError: (t4, e) => {
@@ -3352,7 +5534,7 @@ var P = class {
3352
5534
  });
3353
5535
  }
3354
5536
  initLifecycleManager(t3) {
3355
- this.lifecycleManager = new R({ actionBridge: this.actionBridge, getContext: () => this.stateManager.getExpressionContext(), debug: this.options.debug, logger: this.logger, onLifecycleEvent: (t4, e) => {
5537
+ this.lifecycleManager = new L({ actionBridge: this.actionBridge, getContext: () => this.stateManager.getExpressionContext(), debug: this.options.debug, logger: this.logger, onLifecycleEvent: (t4, e) => {
3356
5538
  this.emitEvent(`page:lifecycle:${t4}`, e ?? {});
3357
5539
  } }), this.lifecycleManager.register(t3.lifecycle);
3358
5540
  }
@@ -3360,27 +5542,27 @@ var P = class {
3360
5542
  const t3 = /* @__PURE__ */ new Map();
3361
5543
  this.stateManager.getState().components.forEach((e, s) => {
3362
5544
  if ("loaded" === e.status && e.component) {
3363
- const [i2, n2] = s.split("@");
3364
- t3.set(i2, { name: i2, version: n2, Component: e.component, loadTime: e.loadTime || 0 });
5545
+ const [i, n2] = s.split("@");
5546
+ t3.set(i, { name: i, version: n2, Component: e.component, loadTime: e.loadTime || 0 });
3365
5547
  }
3366
- }), this.renderer = new T({ expressionEngine: this.expressionEngine, components: t3, injectHostApi: (t4, e) => {
5548
+ }), this.renderer = new D({ expressionEngine: this.expressionEngine, components: t3, injectHostApi: (t4, e) => {
3367
5549
  t4.hostApi = this.hostApi, t4.componentId = e;
3368
- }, onComponentEvent: (t4, e, s, i2) => {
3369
- this.handleComponentEvent(t4, e, s, i2);
3370
- }, debug: this.options.debug, logger: this.logger, onRenderError: (t4, e) => (this.log("error", `Render error in ${t4}:`, e), this.emitEvent("component:error", { componentId: t4, error: e.message }), D("error", e.message)) }), this.renderer.init();
5550
+ }, onComponentEvent: (t4, e, s, i) => {
5551
+ this.handleComponentEvent(t4, e, s, i);
5552
+ }, debug: this.options.debug, logger: this.logger, onRenderError: (t4, e) => (this.log("error", `Render error in ${t4}:`, e), this.emitEvent("component:error", { componentId: t4, error: e.message }), M("error", e.message)) }), this.renderer.init();
3371
5553
  }
3372
- handleComponentEvent(t3, e, s, i2) {
3373
- this.log("debug", `Component event: ${t3}.${e}`, i2);
3374
- for (const t4 of s) this.actionBridge.handleEvent(t4, i2, this.stateManager.getExpressionContext());
5554
+ handleComponentEvent(t3, e, s, i) {
5555
+ this.log("debug", `Component event: ${t3}.${e}`, i);
5556
+ for (const t4 of s) this.actionBridge.handleEvent(t4, i, this.stateManager.getExpressionContext());
3375
5557
  }
3376
5558
  handleError(t3) {
3377
5559
  var _a;
3378
- const e = t3 instanceof i ? { type: "LOAD_ERROR", message: t3.message, code: t3.code, details: t3.details, traceId: t3.traceId, timestamp: t3.timestamp } : { type: "UNKNOWN_ERROR", message: t3.message, cause: t3, timestamp: Date.now() };
5560
+ const e = t3 instanceof n ? { type: "LOAD_ERROR", message: t3.message, code: t3.code, details: t3.details, traceId: t3.traceId, timestamp: t3.timestamp } : { type: "UNKNOWN_ERROR", message: t3.message, cause: t3, timestamp: Date.now() };
3379
5561
  this.stateManager.setError(e), (_a = this.telemetryManager) == null ? void 0 : _a.recordError(t3), this.emitEvent("page:error", { error: t3.message }), this.options.onError && this.options.onError(e);
3380
5562
  }
3381
5563
  emitEvent(t3, e) {
3382
5564
  var _a;
3383
- const s = y.createEvent(t3, e, (_a = this.telemetryManager) == null ? void 0 : _a.getTraceId());
5565
+ const s = w.createEvent(t3, e, (_a = this.telemetryManager) == null ? void 0 : _a.getTraceId());
3384
5566
  this.eventBus.emit(s), this.options.onEvent && this.options.onEvent(s);
3385
5567
  }
3386
5568
  createLogger() {
@@ -3710,7 +5892,7 @@ async function mount(container, options) {
3710
5892
  }
3711
5893
  }
3712
5894
  };
3713
- const runtime = L(runtimeOptions);
5895
+ const runtime = U(runtimeOptions);
3714
5896
  const withTimeout = (promise, ms) => {
3715
5897
  return Promise.race([
3716
5898
  promise,
@@ -3843,8 +6025,8 @@ async function batchMount(mounts, options) {
3843
6025
  const startTime = performance.now();
3844
6026
  const results = /* @__PURE__ */ new Map();
3845
6027
  const errors = /* @__PURE__ */ new Map();
3846
- for (let i2 = 0; i2 < mounts.length; i2 += concurrency) {
3847
- const batch = mounts.slice(i2, i2 + concurrency);
6028
+ for (let i = 0; i < mounts.length; i += concurrency) {
6029
+ const batch = mounts.slice(i, i + concurrency);
3848
6030
  const batchPromises = batch.map(async ({ id, container, options: mountOptions }) => {
3849
6031
  try {
3850
6032
  const result = await mount(container, mountOptions);
@@ -4155,8 +6337,8 @@ class StorageHelper {
4155
6337
  */
4156
6338
  clear() {
4157
6339
  const keysToRemove = [];
4158
- for (let i2 = 0; i2 < this.storage.length; i2++) {
4159
- const key = this.storage.key(i2);
6340
+ for (let i = 0; i < this.storage.length; i++) {
6341
+ const key = this.storage.key(i);
4160
6342
  if (key == null ? void 0 : key.startsWith(`${this.namespace}:`)) {
4161
6343
  keysToRemove.push(key);
4162
6344
  }
@@ -4199,7 +6381,7 @@ const index = {
4199
6381
  isWeChat,
4200
6382
  supportsWebP,
4201
6383
  // 核心
4202
- createRuntime: L
6384
+ createRuntime: U
4203
6385
  };
4204
6386
  export {
4205
6387
  ErrorReporter,
@@ -4211,7 +6393,7 @@ export {
4211
6393
  collectWebVitalsMetrics,
4212
6394
  createErrorReporter,
4213
6395
  createPerformanceMonitor,
4214
- L as createRuntime,
6396
+ U as createRuntime,
4215
6397
  createStorageHelper,
4216
6398
  createTrackingManager,
4217
6399
  index as default,