@alipay/ams-checkout 0.0.1787898127-dev.2 → 0.0.1787898127-dev.21

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,12 +1,16 @@
1
1
  var _excluded = ["onStatusChange"],
2
2
  _excluded2 = ["onBeforeConfirm"];
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
5
4
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
6
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
7
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
8
5
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
9
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
8
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
10
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
11
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
13
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
10
14
  function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
11
15
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
12
16
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
@@ -29,22 +33,31 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
29
33
  function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
30
34
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
31
35
  function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
32
- import { openModal, showToast, sdkQuery, getLocaleFromRenderData, getDevReqConfig, getMetaData, buildPageUrl, debugError, debug, MessageType, request, parseHostSign, SDKBridge, parseTrackerId, oneAccountQuery, OpenSDKError, awaitWrap, themeColorMap, ApplePayHostService, buildRecurringPaymentRequest, checkSessionData, sdkTracker, ModalPort } from "../../../../modern/tools";
36
+ import { ERRORMESSAGE, PROMISE_CALLBACK_CODE } from "../../../../constant";
37
+ import { BusManager, BusMessage } from "../../../bus";
38
+ import { ApplePayActionEnum } from "../../../bus/interface";
33
39
  import { shouldQueryOneAccount } from "../../../utils/connectConfig";
40
+ import { ApplePayHostService, awaitWrap, buildPageUrl, buildRecurringPaymentRequest, checkSessionData, debug, debugError, getDevReqConfig, getLocaleFromRenderData, getMetaData, getModalMessageTrackData, installModalMessageMonitor, MessageType, ModalPort, oneAccountQuery, openModal, OpenSDKError, parseHostSign, parseTrackerId, request, SDKBridge, sdkQuery, sdkTracker, showToast, themeColorMap } from "../../../../modern/tools";
41
+ import { getApplePayPaymentSession } from "../../../../service";
34
42
  import { device } from "../../../../util";
43
+ import { BEFORE_CONFIRM_TIMEOUT_MS, executeWithTimeout, MERCHANT_CONFIRM_ABORT_CODE, MERCHANT_CONFIRM_TIMEOUT_CODE } from "../../../../util/beforeConfirm";
44
+ import CallApp from "../../../../util/intl-callapp/es/main";
45
+ import { LogConfig, Logger } from "../../../../util/logger";
46
+ import { getIdengineTimezone } from "../../../../util/timezone";
47
+ import { v4 as uuid } from 'uuid';
35
48
  import { EventCallbackCode } from "../type";
36
- import { adaptSubmitResult, adaptAppearance } from "./adapter";
37
49
  import { safeParse } from "../util";
38
- import { v4 as uuid } from 'uuid';
50
+ import { adaptAppearance, adaptSubmitResult } from "./adapter";
39
51
 
40
52
  // ============================================================
41
53
  // 埋点 helper(不改 opensdk 源码,复用 sdkTracker 单例,trackId 已自动注入)
42
- // code 规约:7982 + 阶段后缀,与 opensdk internalTracker 对齐
43
- // 7982mount / 7982handshake / 7982element / 7982(异常无后缀)
54
+ // code 规约:7882 + 阶段后缀
55
+ // 7882mount / 7882handshake / 7882element / 7882(异常无后缀)
44
56
  // 只插入调用,不影响任何运行逻辑
45
57
  // ============================================================
46
58
 
47
- var TRACK_CODE_PREFIX = '7982';
59
+ var TRACK_CODE_PREFIX = '7882';
60
+ var MODERN_CONTROLLER_ELEMENT_TYPE = 'payment_v1';
48
61
 
49
62
  /**
50
63
  * 优先取 sessionData 解析出的 clientId;
@@ -68,14 +81,17 @@ var resolveMerchantId = function resolveMerchantId(parseData) {
68
81
  };
69
82
  // reportApiEnd 留为模块级,merchant_id 改为显式参数(由 runApi 从实例传入),
70
83
  // 避免原模块级 _merchantId 的多实例共享竞争。track/trackXxx 已改为实例方法读 this.merchantId。
71
- var reportApiEnd = function reportApiEnd(api, durationMs, merchantId) {
72
- var extra = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
84
+ var reportApiEnd = function reportApiEnd(api, durationMs, merchantId, productScene) {
85
+ var extra = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
73
86
  try {
74
87
  sdkTracker.log(_objectSpread({
75
88
  code: "".concat(TRACK_CODE_PREFIX, "api"),
76
89
  msg: api,
77
90
  m1: durationMs,
78
- merchant_id: merchantId
91
+ merchant_id: merchantId,
92
+ product_scene: productScene,
93
+ element_type: MODERN_CONTROLLER_ELEMENT_TYPE,
94
+ idengine_timezone: getIdengineTimezone()
79
95
  }, extra));
80
96
  } catch (_unused2) {
81
97
  /* 埋点失败绝不影响主流程 */
@@ -133,7 +149,7 @@ var normalizeApiInput = function normalizeApiInput(api, params) {
133
149
  // 统一包裹:捕获终态(resolve/reject)后上报,原值/原异常原样透传,不影响任何已有逻辑。
134
150
  // extraBuilder 供调用方注入实例上下文字段(如 paymentMethodType),其值覆盖 normalizeApiResult 结果。
135
151
  var runApi = /*#__PURE__*/function () {
136
- var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, fn, extraBuilder, inputExtra, merchantId) {
152
+ var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(api, fn, extraBuilder, inputExtra, merchantId, productScene) {
137
153
  var startedAt, result;
138
154
  return _regeneratorRuntime().wrap(function _callee$(_context) {
139
155
  while (1) switch (_context.prev = _context.next) {
@@ -144,12 +160,12 @@ var runApi = /*#__PURE__*/function () {
144
160
  return fn();
145
161
  case 4:
146
162
  result = _context.sent;
147
- reportApiEnd(api, Date.now() - startedAt, merchantId, _objectSpread(_objectSpread(_objectSpread({}, inputExtra), normalizeApiResult(api, result)), extraBuilder === null || extraBuilder === void 0 ? void 0 : extraBuilder(false)));
163
+ reportApiEnd(api, Date.now() - startedAt, merchantId, productScene, _objectSpread(_objectSpread(_objectSpread({}, inputExtra), normalizeApiResult(api, result)), extraBuilder === null || extraBuilder === void 0 ? void 0 : extraBuilder(false)));
148
164
  return _context.abrupt("return", result);
149
165
  case 9:
150
166
  _context.prev = 9;
151
167
  _context.t0 = _context["catch"](1);
152
- reportApiEnd(api, Date.now() - startedAt, merchantId, _objectSpread(_objectSpread({}, inputExtra), {}, {
168
+ reportApiEnd(api, Date.now() - startedAt, merchantId, productScene, _objectSpread(_objectSpread({}, inputExtra), {}, {
153
169
  d1: 'error',
154
170
  d2: (_context.t0 === null || _context.t0 === void 0 ? void 0 : _context.t0.code) || 'UNKNOWN'
155
171
  }, extraBuilder === null || extraBuilder === void 0 ? void 0 : extraBuilder(true)));
@@ -160,17 +176,10 @@ var runApi = /*#__PURE__*/function () {
160
176
  }
161
177
  }, _callee, null, [[1, 9]]);
162
178
  }));
163
- return function runApi(_x, _x2, _x3, _x4, _x5) {
179
+ return function runApi(_x, _x2, _x3, _x4, _x5, _x6) {
164
180
  return _ref.apply(this, arguments);
165
181
  };
166
182
  }();
167
- import CallApp from "../../../../util/intl-callapp/es/main";
168
- import { getApplePayPaymentSession } from "../../../../service";
169
- import { BusManager, BusMessage } from "../../../bus";
170
- import { ApplePayActionEnum } from "../../../bus/interface";
171
- import { ERRORMESSAGE, PROMISE_CALLBACK_CODE } from "../../../../constant";
172
- import { LogConfig, Logger } from "../../../../util/logger";
173
- import { executeWithTimeout, BEFORE_CONFIRM_TIMEOUT_MS } from "../../../../util/beforeConfirm";
174
183
  var recoverSdkQueryBusinessResponse = function recoverSdkQueryBusinessResponse(error) {
175
184
  var response = error === null || error === void 0 ? void 0 : error.response;
176
185
  if ((response === null || response === void 0 ? void 0 : response.success) === false) {
@@ -269,6 +278,7 @@ var AMSMessageType = {
269
278
  */
270
279
  export var ModernElementController = /*#__PURE__*/function () {
271
280
  function ModernElementController(_ref2) {
281
+ var _this = this;
272
282
  var onStatusChange = _ref2.onStatusChange,
273
283
  options = _objectWithoutProperties(_ref2, _excluded);
274
284
  _classCallCheck(this, ModernElementController);
@@ -293,6 +303,8 @@ export var ModernElementController = /*#__PURE__*/function () {
293
303
  _defineProperty(this, "_merchantCurrency", null);
294
304
  /** 当前选中的支付方式类型(如 'APPLEPAY', 'CARD'),通过 paymentMethodChanged 事件更新 */
295
305
  _defineProperty(this, "currentPaymentMethodType", '');
306
+ /** Removes the passive host-window modal monitor for this controller. */
307
+ _defineProperty(this, "stopModalMessageMonitor", void 0);
296
308
  /** 提交进行中标志:submitPayment 执行期间为 true,用于拒绝并发重入,避免旧闭包串扰/重复拉起钱包 */
297
309
  _defineProperty(this, "isSubmitting", false);
298
310
  /**
@@ -300,6 +312,8 @@ export var ModernElementController = /*#__PURE__*/function () {
300
312
  * 实例隔离:多实例并发 mount 时各自持有,避免原模块级 _merchantId 的共享竞争。
301
313
  */
302
314
  _defineProperty(this, "merchantId", '');
315
+ /** session 中的真实业务场景,仅作为埋点公共维度,不参与业务判断。 */
316
+ _defineProperty(this, "productScene", '');
303
317
  this.options = options;
304
318
  this.onStatusChange = onStatusChange;
305
319
  if (options.sessionData) {
@@ -320,6 +334,12 @@ export var ModernElementController = /*#__PURE__*/function () {
320
334
  debug('INFO', direction === 'OUT' ? 'SDK_INTERNAL' : 'APP_RUNTIME', msg.type, msg.payload);
321
335
  }
322
336
  });
337
+ this.stopModalMessageMonitor = installModalMessageMonitor(function (data) {
338
+ return _this.trackElement('modal_lifecycle_monitor', getModalMessageTrackData(data));
339
+ }, function (event) {
340
+ var _this$iframe;
341
+ return event.source === ((_this$iframe = _this.iframe) === null || _this$iframe === void 0 ? void 0 : _this$iframe.contentWindow);
342
+ });
323
343
  }
324
344
  _createClass(ModernElementController, [{
325
345
  key: "track",
@@ -332,7 +352,10 @@ export var ModernElementController = /*#__PURE__*/function () {
332
352
  sdkTracker.log(_objectSpread({
333
353
  code: code,
334
354
  msg: msg,
335
- merchant_id: this.merchantId
355
+ merchant_id: this.merchantId,
356
+ product_scene: this.productScene,
357
+ element_type: MODERN_CONTROLLER_ELEMENT_TYPE,
358
+ idengine_timezone: getIdengineTimezone()
336
359
  }, extra));
337
360
  } catch (_unused3) {
338
361
  /* 埋点失败绝不影响主流程 */
@@ -362,11 +385,44 @@ export var ModernElementController = /*#__PURE__*/function () {
362
385
  var extra = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
363
386
  this.track('error', msg, extra);
364
387
  }
388
+ }, {
389
+ key: "createRequestTracker",
390
+ value: function createRequestTracker() {
391
+ var _this2 = this;
392
+ try {
393
+ var requestTracker = Object.create(sdkTracker);
394
+ requestTracker.log = function () {
395
+ try {
396
+ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
397
+ args[_key2] = arguments[_key2];
398
+ }
399
+ var event = args[0],
400
+ rest = args.slice(1);
401
+ if (event && _typeof(event) === 'object') {
402
+ sdkTracker.log.apply(sdkTracker, [_objectSpread(_objectSpread({}, event), {}, {
403
+ merchant_id: _this2.merchantId,
404
+ product_scene: _this2.productScene,
405
+ element_type: MODERN_CONTROLLER_ELEMENT_TYPE,
406
+ idengine_timezone: getIdengineTimezone()
407
+ })].concat(_toConsumableArray(rest)));
408
+ return;
409
+ }
410
+ sdkTracker.log.apply(sdkTracker, args);
411
+ } catch (_unused4) {
412
+ /* 埋点失败绝不影响请求 */
413
+ }
414
+ };
415
+ return requestTracker;
416
+ } catch (_unused5) {
417
+ return sdkTracker;
418
+ }
419
+ }
365
420
  }, {
366
421
  key: "mount",
367
422
  value: function () {
368
423
  var _mount = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(renderOptions, sdkSelector) {
369
- var _this = this;
424
+ var _this3 = this;
425
+ var _metaData$paymentSess, metaData;
370
426
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
371
427
  while (1) switch (_context2.prev = _context2.next) {
372
428
  case 0:
@@ -375,23 +431,25 @@ export var ModernElementController = /*#__PURE__*/function () {
375
431
  // 缺失/无效时会 throw,这里容错吞掉——失败的校验仍由后续 setup() 内的 checkSessionData
376
432
  // 抛出、走 mount_error 统一上报,不改变错误时序。
377
433
  try {
378
- this.merchantId = resolveMerchantId(checkSessionData(this.options.sessionData, 'ELEMENT_PAYMENT'));
379
- } catch (_unused4) {
434
+ metaData = checkSessionData(this.options.sessionData, 'ELEMENT_PAYMENT');
435
+ this.merchantId = resolveMerchantId(metaData);
436
+ this.productScene = (metaData === null || metaData === void 0 || (_metaData$paymentSess = metaData.paymentSessionConfig) === null || _metaData$paymentSess === void 0 ? void 0 : _metaData$paymentSess.productScene) || '';
437
+ } catch (_unused6) {
380
438
  /* setup 校验异常会统一上报 */
381
439
  }
382
440
  return _context2.abrupt("return", runApi('mount', function () {
383
- return _this.doMount(renderOptions, sdkSelector);
441
+ return _this3.doMount(renderOptions, sdkSelector);
384
442
  }, undefined, normalizeApiInput('mount', {
385
443
  renderOptions: renderOptions,
386
444
  sdkSelector: sdkSelector
387
- }), this.merchantId));
445
+ }), this.merchantId, this.productScene));
388
446
  case 2:
389
447
  case "end":
390
448
  return _context2.stop();
391
449
  }
392
450
  }, _callee2, this);
393
451
  }));
394
- function mount(_x6, _x7) {
452
+ function mount(_x7, _x8) {
395
453
  return _mount.apply(this, arguments);
396
454
  }
397
455
  return mount;
@@ -445,7 +503,7 @@ export var ModernElementController = /*#__PURE__*/function () {
445
503
  if (iframeOrigin && iframeOrigin !== 'null') {
446
504
  this.bridge.setOrigin(iframeOrigin);
447
505
  }
448
- } catch (_unused5) {
506
+ } catch (_unused7) {
449
507
  // URL 解析失败时保持默认 origin
450
508
  }
451
509
  } else {
@@ -538,7 +596,7 @@ export var ModernElementController = /*#__PURE__*/function () {
538
596
  }
539
597
  }, _callee3, this, [[8, 44]]);
540
598
  }));
541
- function doMount(_x8, _x9) {
599
+ function doMount(_x9, _x10) {
542
600
  return _doMount.apply(this, arguments);
543
601
  }
544
602
  return doMount;
@@ -557,8 +615,9 @@ export var ModernElementController = /*#__PURE__*/function () {
557
615
  key: "setup",
558
616
  value: (function () {
559
617
  var _setup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(renderOptions) {
560
- var _parseData$connectFac,
561
- _this2 = this,
618
+ var _parseData$paymentSes,
619
+ _parseData$connectFac,
620
+ _this4 = this,
562
621
  _parseData$paymentMet,
563
622
  _sdkQueryResult$data;
564
623
  var sessionData, parseData, lastEnv, isConnect, shouldQueryOneAccountFlag, paymentSessionConfig, genSdkQueryPromise, genOneAccountQueryPromise, promises, cancelDestroyCallback, destroyPromise, queryPromise, _yield$Promise$race$f, _yield$Promise$race$f2, sdkQueryResult, oneAccountQueryResult, _sdkQueryResult$error, _sdkQueryResult$error2, _oneAccountQueryResul, _oneAccountQueryResul2, preferredLocale, locale, renderDataError;
@@ -572,18 +631,20 @@ export var ModernElementController = /*#__PURE__*/function () {
572
631
  sessionData = this.options.sessionData; // checkSessionData 失败会 throw AntomSDKError(SESSION_DATA_INVALID),
573
632
  // 冒泡到 mount 的 catch 由 mount_error 统一上报,此处无需额外处理
574
633
  parseData = checkSessionData(sessionData, 'ELEMENT_PAYMENT');
634
+ this.merchantId || (this.merchantId = resolveMerchantId(parseData));
635
+ this.productScene = (parseData === null || parseData === void 0 || (_parseData$paymentSes = parseData.paymentSessionConfig) === null || _parseData$paymentSes === void 0 ? void 0 : _parseData$paymentSes.productScene) || '';
575
636
  lastEnv = this.options.environment === 'sandbox' ? 'sandbox' : 'prod';
576
637
  this.options.environment;
577
638
 
578
639
  // 初始化 request 全局配置,使 sdkQuery 能正确发起请求
579
- // tracker: sdkTracker —— 接入 HTTP 层自动埋点(B 套),上报每个请求的成败/RTT/错误码
580
- // 与 antom.ts 入口对齐;不传则 sdkQuery/submitPay/inquiry 等网络细节不可观测
640
+ // 实例级 tracker wrapper 接入 HTTP 自动埋点,并仅在日志中补齐 controller 公共维度。
641
+ // 不传 tracker 则 sdkQuery/submitPay/inquiry 等网络细节不可观测。
581
642
  request.setGlobalOptions(_objectSpread(_objectSpread({
582
643
  hostSign: parseHostSign(sessionData),
583
644
  env: lastEnv
584
645
  }, getDevReqConfig()), {}, {
585
- sdkVersion: "0.0.1787898127-dev.2" || '',
586
- tracker: sdkTracker
646
+ sdkVersion: "0.0.1787898127-dev.21" || '',
647
+ tracker: this.createRequestTracker()
587
648
  }));
588
649
  isConnect = !!(parseData !== null && parseData !== void 0 && (_parseData$connectFac = parseData.connectFactor) !== null && _parseData$connectFac !== void 0 && _parseData$connectFac.enableConnect);
589
650
  shouldQueryOneAccountFlag = shouldQueryOneAccount(isConnect, parseData === null || parseData === void 0 ? void 0 : parseData.extendInfo);
@@ -595,14 +656,14 @@ export var ModernElementController = /*#__PURE__*/function () {
595
656
  isUserPreferredLocale: true
596
657
  },
597
658
  merchantAppointParam: (_renderOptions$mercha = renderOptions.merchantAppointParam) !== null && _renderOptions$mercha !== void 0 && _renderOptions$mercha.storedCard ? renderOptions.merchantAppointParam : undefined,
598
- notRedirectAfterComplete: _this2.notRedirectAfterComplete,
659
+ notRedirectAfterComplete: _this4.notRedirectAfterComplete,
599
660
  // sdk需要传入该字段
600
661
  paymentSessionConfig: parseData === null || parseData === void 0 ? void 0 : parseData.paymentSessionConfig,
601
662
  paymentSessionData: sessionData
602
663
  }, {
603
664
  // 传商户初始化的 locale,服务端据此返回对应语言(缺失则回落用户偏好/en_US)
604
665
  envInfo: {
605
- locale: _this2.options.locale
666
+ locale: _this4.options.locale
606
667
  }
607
668
  }).catch(recoverSdkQueryBusinessResponse));
608
669
  };
@@ -618,14 +679,14 @@ export var ModernElementController = /*#__PURE__*/function () {
618
679
  promises = shouldQueryOneAccountFlag ? [genSdkQueryPromise(), genOneAccountQueryPromise()] : [genSdkQueryPromise(), undefined];
619
680
  cancelDestroyCallback = function cancelDestroyCallback() {};
620
681
  destroyPromise = new Promise(function (_, reject) {
621
- cancelDestroyCallback = _this2.onDestroy(function () {
682
+ cancelDestroyCallback = _this4.onDestroy(function () {
622
683
  return reject(getDestroyedError());
623
684
  });
624
685
  });
625
686
  queryPromise = Promise.all(promises);
626
- _context4.next = 19;
687
+ _context4.next = 21;
627
688
  return Promise.race([queryPromise, destroyPromise]).finally(cancelDestroyCallback);
628
- case 19:
689
+ case 21:
629
690
  _yield$Promise$race$f = _context4.sent;
630
691
  _yield$Promise$race$f2 = _slicedToArray(_yield$Promise$race$f, 2);
631
692
  sdkQueryResult = _yield$Promise$race$f2[0];
@@ -680,7 +741,7 @@ export var ModernElementController = /*#__PURE__*/function () {
680
741
  // 新sdk字段
681
742
  locale: locale,
682
743
  // 新sdk字段
683
- sdkVersion: "0.0.1787898127-dev.2" || '',
744
+ sdkVersion: "0.0.1787898127-dev.21" || '',
684
745
  // 新sdk字段
685
746
  merchantId: (sdkQueryResult === null || sdkQueryResult === void 0 || (_sdkQueryResult$data = sdkQueryResult.data) === null || _sdkQueryResult$data === void 0 ? void 0 : _sdkQueryResult$data.merchantId) || '',
686
747
  // 新sdk字段
@@ -690,13 +751,13 @@ export var ModernElementController = /*#__PURE__*/function () {
690
751
  env: lastEnv
691
752
  }, getDevReqConfig())
692
753
  });
693
- case 29:
754
+ case 31:
694
755
  case "end":
695
756
  return _context4.stop();
696
757
  }
697
758
  }, _callee4, this);
698
759
  }));
699
- function setup(_x10) {
760
+ function setup(_x11) {
700
761
  return _setup.apply(this, arguments);
701
762
  }
702
763
  return setup;
@@ -793,20 +854,20 @@ export var ModernElementController = /*#__PURE__*/function () {
793
854
  }, {
794
855
  key: "bindBridgeEvents",
795
856
  value: function bindBridgeEvents() {
796
- var _this3 = this;
857
+ var _this5 = this;
797
858
  this.bridge.on(MessageType.HEIGHT_UPDATE, function (height) {
798
- if (_this3.iframe) _this3.iframe.style.height = "".concat(height, "px");
859
+ if (_this5.iframe) _this5.iframe.style.height = "".concat(height, "px");
799
860
  });
800
861
  this.bridge.on(AMSMessageType.SHOWTOAST, function (payload, _ports, meta) {
801
- var _this3$iframe, _this3$modalIframe;
802
- if (meta && meta.source !== ((_this3$iframe = _this3.iframe) === null || _this3$iframe === void 0 ? void 0 : _this3$iframe.contentWindow) && meta.source !== ((_this3$modalIframe = _this3.modalIframe) === null || _this3$modalIframe === void 0 ? void 0 : _this3$modalIframe.contentWindow)) {
862
+ var _this5$iframe, _this5$modalIframe;
863
+ if (meta && meta.source !== ((_this5$iframe = _this5.iframe) === null || _this5$iframe === void 0 ? void 0 : _this5$iframe.contentWindow) && meta.source !== ((_this5$modalIframe = _this5.modalIframe) === null || _this5$modalIframe === void 0 ? void 0 : _this5$modalIframe.contentWindow)) {
803
864
  return;
804
865
  }
805
866
  showToast(payload);
806
867
  });
807
868
  this.bridge.on(MessageType.REDIRECT, function (payload, _ports, meta) {
808
- var _this3$iframe2, _this3$modalIframe2;
809
- if (meta && meta.source !== ((_this3$iframe2 = _this3.iframe) === null || _this3$iframe2 === void 0 ? void 0 : _this3$iframe2.contentWindow) && meta.source !== ((_this3$modalIframe2 = _this3.modalIframe) === null || _this3$modalIframe2 === void 0 ? void 0 : _this3$modalIframe2.contentWindow)) {
869
+ var _this5$iframe2, _this5$modalIframe2;
870
+ if (meta && meta.source !== ((_this5$iframe2 = _this5.iframe) === null || _this5$iframe2 === void 0 ? void 0 : _this5$iframe2.contentWindow) && meta.source !== ((_this5$modalIframe2 = _this5.modalIframe) === null || _this5$modalIframe2 === void 0 ? void 0 : _this5$modalIframe2.contentWindow)) {
810
871
  return;
811
872
  }
812
873
  var url = payload.url,
@@ -815,7 +876,7 @@ export var ModernElementController = /*#__PURE__*/function () {
815
876
  schemaUrl = payload.schemaUrl,
816
877
  destroy = payload.destroy;
817
878
  // d1=mode(redirect/replace) d2=跳转类型 d3=兜底url d4=appLinkUrl d5=schemaUrl d6=是否销毁
818
- _this3.trackElement('redirect', {
879
+ _this5.trackElement('redirect', {
819
880
  d1: mode || 'redirect',
820
881
  d2: appLinkUrl ? 'app_link' : schemaUrl ? 'schema' : 'url',
821
882
  d3: url || '',
@@ -824,7 +885,7 @@ export var ModernElementController = /*#__PURE__*/function () {
824
885
  d6: destroy ? '1' : '0'
825
886
  });
826
887
  if (destroy) {
827
- _this3.destroy();
888
+ _this5.destroy();
828
889
  }
829
890
  function fallbackJump() {
830
891
  if (mode === 'replace') {
@@ -838,7 +899,7 @@ export var ModernElementController = /*#__PURE__*/function () {
838
899
  var app = new CallApp({
839
900
  resultJudgmentTime: 2000,
840
901
  fallback: function fallback() {
841
- _this3.trackElement('redirect_fallback', {
902
+ _this5.trackElement('redirect_fallback', {
842
903
  d1: 'callapp_failed',
843
904
  d2: url || ''
844
905
  });
@@ -853,7 +914,7 @@ export var ModernElementController = /*#__PURE__*/function () {
853
914
  fallbackJump();
854
915
  }
855
916
  } catch (error) {
856
- _this3.trackError('redirect_error', {
917
+ _this5.trackError('redirect_error', {
857
918
  d1: 'callapp_exception',
858
919
  d2: (error === null || error === void 0 ? void 0 : error.message) || '',
859
920
  d3: url || ''
@@ -862,34 +923,34 @@ export var ModernElementController = /*#__PURE__*/function () {
862
923
  }
863
924
  });
864
925
  this.bridge.on(MessageType.OPEN_MODAL, function (payload, _ports, meta) {
865
- var _this3$iframe3;
866
- if (meta && meta.source !== ((_this3$iframe3 = _this3.iframe) === null || _this3$iframe3 === void 0 ? void 0 : _this3$iframe3.contentWindow)) {
926
+ var _this5$iframe3;
927
+ if (meta && meta.source !== ((_this5$iframe3 = _this5.iframe) === null || _this5$iframe3 === void 0 ? void 0 : _this5$iframe3.contentWindow)) {
867
928
  return;
868
929
  }
869
- _this3.handleOpenModal(payload);
870
- _this3.bridge.once(MessageType.CLOSE_MODAL, function () {
871
- _this3.handleCloseModal();
930
+ _this5.handleOpenModal(payload);
931
+ _this5.bridge.once(MessageType.CLOSE_MODAL, function () {
932
+ _this5.handleCloseModal();
872
933
  });
873
934
  });
874
935
  this.bridge.on(MessageType.DESTROY_ELEMENT, function (_payload, _ports, meta) {
875
- var _this3$iframe4;
876
- if (meta && meta.source !== ((_this3$iframe4 = _this3.iframe) === null || _this3$iframe4 === void 0 ? void 0 : _this3$iframe4.contentWindow)) {
936
+ var _this5$iframe4;
937
+ if (meta && meta.source !== ((_this5$iframe4 = _this5.iframe) === null || _this5$iframe4 === void 0 ? void 0 : _this5$iframe4.contentWindow)) {
877
938
  return;
878
939
  }
879
- _this3.destroy();
940
+ _this5.destroy();
880
941
  });
881
942
 
882
943
  // skipRenderPaymentMethod 场景:webapp 委托 SDK 全权拉起 ApplePay,fire-and-forget
883
944
  // 走 plugin/applepay 标准链路(onEventCallback 自动通知商户)
884
945
  this.bridge.on(AMSMessageType.HANDLE_PAYMENT, function () {
885
- _this3.handleHandlePayment();
946
+ _this5.handleHandlePayment();
886
947
  });
887
948
 
888
949
  // Apple Pay beforeConfirm:在 submitPayment 内通过 bridge.once 监听,此处不再注册
889
950
 
890
951
  // 支付方式变化:iframe 通知 SDK 当前选中的支付方式类型
891
952
  this.bridge.on(AMSMessageType.PAYMENT_METHOD_CHANGED, function (payload) {
892
- _this3.currentPaymentMethodType = (payload === null || payload === void 0 ? void 0 : payload.type) || '';
953
+ _this5.currentPaymentMethodType = (payload === null || payload === void 0 ? void 0 : payload.type) || '';
893
954
  });
894
955
  }
895
956
 
@@ -903,7 +964,7 @@ export var ModernElementController = /*#__PURE__*/function () {
903
964
  value: (function () {
904
965
  var _handleGetApplePayToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(payload, onBeforeConfirm) {
905
966
  var _paymentMethod,
906
- _this4 = this;
967
+ _this6 = this;
907
968
  var sessionData, applePayProps, paymentRequest, merchantCapabilities, merchantInfo, paymentAmount, supportedNetworks, version, requiredBillingContactFields, requiredShippingContactFields, finalAmount, finalCurrency, capturedResult, recurringRequest, service, _capturedResult, errCode;
908
969
  return _regeneratorRuntime().wrap(function _callee7$(_context7) {
909
970
  while (1) switch (_context7.prev = _context7.next) {
@@ -975,7 +1036,7 @@ export var ModernElementController = /*#__PURE__*/function () {
975
1036
  return _regeneratorRuntime().wrap(function _callee5$(_context5) {
976
1037
  while (1) switch (_context5.prev = _context5.next) {
977
1038
  case 0:
978
- _this4.trackElement('applepay_validate_start', {
1039
+ _this6.trackElement('applepay_validate_start', {
979
1040
  d1: 'merchant_validate'
980
1041
  });
981
1042
  _context5.next = 3;
@@ -984,7 +1045,7 @@ export var ModernElementController = /*#__PURE__*/function () {
984
1045
  paymentSessionData: sessionData,
985
1046
  merchantDomain: window.location.hostname
986
1047
  }, {
987
- env: _this4.options.environment,
1048
+ env: _this6.options.environment,
988
1049
  envInfo: {
989
1050
  deviceId: ''
990
1051
  }
@@ -995,12 +1056,12 @@ export var ModernElementController = /*#__PURE__*/function () {
995
1056
  _context5.next = 7;
996
1057
  break;
997
1058
  }
998
- _this4.trackElement('applepay_validate_success', {
1059
+ _this6.trackElement('applepay_validate_success', {
999
1060
  d1: 'got_session'
1000
1061
  });
1001
1062
  return _context5.abrupt("return", typeof res.merchantSessionObject === 'string' ? JSON.parse(res.merchantSessionObject) : res.merchantSessionObject);
1002
1063
  case 7:
1003
- _this4.trackError('applepay_merchant_validate_failed', {
1064
+ _this6.trackError('applepay_merchant_validate_failed', {
1004
1065
  d1: 'VALIDATION_FAILED',
1005
1066
  d2: (res === null || res === void 0 ? void 0 : res.errorMessage) || 'Merchant validation failed'
1006
1067
  });
@@ -1013,20 +1074,20 @@ export var ModernElementController = /*#__PURE__*/function () {
1013
1074
  }
1014
1075
  }, _callee5);
1015
1076
  }));
1016
- function validateMerchant(_x13) {
1077
+ function validateMerchant(_x14) {
1017
1078
  return _validateMerchant.apply(this, arguments);
1018
1079
  }
1019
1080
  return validateMerchant;
1020
1081
  }(),
1021
1082
  onAuthorized: function () {
1022
1083
  var _onAuthorized = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(_ref4) {
1023
- var token, billingContact, shippingContact, startTime, _yield$executeWithTim, rawResult, timedOut, shouldContinue;
1084
+ var token, billingContact, shippingContact, startTime, _yield$executeWithTim, rawResult, timedOut, isTimeout, shouldContinue;
1024
1085
  return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1025
1086
  while (1) switch (_context6.prev = _context6.next) {
1026
1087
  case 0:
1027
1088
  token = _ref4.token, billingContact = _ref4.billingContact, shippingContact = _ref4.shippingContact;
1028
1089
  if (!onBeforeConfirm) {
1029
- _context6.next = 18;
1090
+ _context6.next = 19;
1030
1091
  break;
1031
1092
  }
1032
1093
  _context6.prev = 2;
@@ -1040,50 +1101,51 @@ export var ModernElementController = /*#__PURE__*/function () {
1040
1101
  rawResult = _yield$executeWithTim.result;
1041
1102
  timedOut = _yield$executeWithTim.timedOut;
1042
1103
  // 双重校验:timedOut(Promise race)+ startTime(实际时间差),与老 ElementController 对齐
1043
- shouldContinue = !timedOut && !!rawResult && Date.now() - startTime < BEFORE_CONFIRM_TIMEOUT_MS;
1044
- if (timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS) {
1045
- _this4.trackError('sdk_before_confirm_timeout', {
1104
+ isTimeout = timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS;
1105
+ shouldContinue = !isTimeout && !!rawResult;
1106
+ if (isTimeout) {
1107
+ _this6.trackError('sdk_before_confirm_timeout', {
1046
1108
  d1: 'applePay_chrome_modern'
1047
1109
  });
1048
1110
  }
1049
1111
  if (shouldContinue) {
1050
- _context6.next = 13;
1112
+ _context6.next = 14;
1051
1113
  break;
1052
1114
  }
1053
1115
  return _context6.abrupt("return", {
1054
1116
  success: false,
1055
- errorCode: 'MERCHANT_CONFIRM_ABORT'
1117
+ errorCode: isTimeout ? MERCHANT_CONFIRM_TIMEOUT_CODE : MERCHANT_CONFIRM_ABORT_CODE
1056
1118
  });
1057
- case 13:
1058
- _context6.next = 18;
1119
+ case 14:
1120
+ _context6.next = 19;
1059
1121
  break;
1060
- case 15:
1061
- _context6.prev = 15;
1122
+ case 16:
1123
+ _context6.prev = 16;
1062
1124
  _context6.t0 = _context6["catch"](2);
1063
1125
  return _context6.abrupt("return", {
1064
1126
  success: false,
1065
- errorCode: 'MERCHANT_CONFIRM_ABORT'
1127
+ errorCode: MERCHANT_CONFIRM_ABORT_CODE
1066
1128
  });
1067
- case 18:
1129
+ case 19:
1068
1130
  capturedResult = {
1069
1131
  token: token,
1070
1132
  billingContact: billingContact,
1071
1133
  shippingContact: shippingContact
1072
1134
  };
1073
- _this4.trackElement('applepay_authorized', {
1135
+ _this6.trackElement('applepay_authorized', {
1074
1136
  d1: token ? 'has_token' : 'no_token'
1075
1137
  });
1076
1138
  return _context6.abrupt("return", {
1077
1139
  success: true,
1078
1140
  result: capturedResult
1079
1141
  });
1080
- case 21:
1142
+ case 22:
1081
1143
  case "end":
1082
1144
  return _context6.stop();
1083
1145
  }
1084
- }, _callee6, null, [[2, 15]]);
1146
+ }, _callee6, null, [[2, 16]]);
1085
1147
  }));
1086
- function onAuthorized(_x14) {
1148
+ function onAuthorized(_x15) {
1087
1149
  return _onAuthorized.apply(this, arguments);
1088
1150
  }
1089
1151
  return onAuthorized;
@@ -1132,7 +1194,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1132
1194
  }
1133
1195
  }, _callee7, this, [[15, 22]]);
1134
1196
  }));
1135
- function handleGetApplePayToken(_x11, _x12) {
1197
+ function handleGetApplePayToken(_x12, _x13) {
1136
1198
  return _handleGetApplePayToken.apply(this, arguments);
1137
1199
  }
1138
1200
  return handleGetApplePayToken;
@@ -1157,7 +1219,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1157
1219
  key: "handleGetGooglePayToken",
1158
1220
  value: function handleGetGooglePayToken(payload) {
1159
1221
  var _data$paymentMethodDe,
1160
- _this5 = this,
1222
+ _this7 = this,
1161
1223
  _google;
1162
1224
  var data = payload === null || payload === void 0 ? void 0 : payload.data;
1163
1225
  var googlePayProps = data === null || data === void 0 || (_data$paymentMethodDe = data.paymentMethodDetail) === null || _data$paymentMethodDe === void 0 ? void 0 : _data$paymentMethodDe.googlePayProps;
@@ -1201,10 +1263,10 @@ export var ModernElementController = /*#__PURE__*/function () {
1201
1263
  };
1202
1264
  }).then(function (paymentData) {
1203
1265
  if (paymentData) {
1204
- _this5.trackElement('googlepay_token_success', {
1266
+ _this7.trackElement('googlepay_token_success', {
1205
1267
  d1: 'has_token'
1206
1268
  });
1207
- _this5.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1269
+ _this7.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1208
1270
  success: true,
1209
1271
  result: paymentData
1210
1272
  });
@@ -1212,16 +1274,16 @@ export var ModernElementController = /*#__PURE__*/function () {
1212
1274
  }).catch(function (err) {
1213
1275
  var statusCode = (err === null || err === void 0 ? void 0 : err.statusCode) || 'GOOGLE_PAY_PAYMENT_FAILED';
1214
1276
  if (statusCode === 'CANCELED') {
1215
- _this5.trackElement('googlepay_cancel', {
1277
+ _this7.trackElement('googlepay_cancel', {
1216
1278
  d1: 'user_cancel'
1217
1279
  });
1218
1280
  } else {
1219
- _this5.trackError('googlepay_token_failed', {
1281
+ _this7.trackError('googlepay_token_failed', {
1220
1282
  d1: statusCode,
1221
1283
  d2: (err === null || err === void 0 ? void 0 : err.statusMessage) || ''
1222
1284
  });
1223
1285
  }
1224
- _this5.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1286
+ _this7.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1225
1287
  success: false,
1226
1288
  err: _objectSpread({
1227
1289
  statusCode: statusCode
@@ -1253,10 +1315,10 @@ export var ModernElementController = /*#__PURE__*/function () {
1253
1315
  loadAndPay();
1254
1316
  };
1255
1317
  script.onerror = function () {
1256
- _this5.trackError('googlepay_script_load_failed', {
1318
+ _this7.trackError('googlepay_script_load_failed', {
1257
1319
  d1: 'script_error'
1258
1320
  });
1259
- _this5.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1321
+ _this7.bridge.send(AMSMessageType.GET_GOOGLE_PAY_TOKEN_REPLY, {
1260
1322
  success: false,
1261
1323
  err: {
1262
1324
  statusCode: 'GOOGLE_PAY_NOT_SUPPORTED'
@@ -1305,7 +1367,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1305
1367
  }, {
1306
1368
  key: "handleBeforeConfirmInternal",
1307
1369
  value: function handleBeforeConfirmInternal(onBeforeConfirm) {
1308
- var _this6 = this;
1370
+ var _this8 = this;
1309
1371
  if (!onBeforeConfirm) {
1310
1372
  logger.logInfo({
1311
1373
  title: 'sdk_before_confirm_skip'
@@ -1330,8 +1392,9 @@ export var ModernElementController = /*#__PURE__*/function () {
1330
1392
  var rawResult = _ref5.result,
1331
1393
  timedOut = _ref5.timedOut;
1332
1394
  // 双重校验:timedOut(Promise race)+ startTime(实际时间差),与老 ElementController 对齐
1333
- var shouldContinue = !timedOut && !!rawResult && Date.now() - startTime < BEFORE_CONFIRM_TIMEOUT_MS;
1334
- if (timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS) {
1395
+ var isTimeout = timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS;
1396
+ var shouldContinue = !isTimeout && !!rawResult;
1397
+ if (isTimeout) {
1335
1398
  logger.logError({
1336
1399
  title: 'sdk_before_confirm_timeout'
1337
1400
  });
@@ -1341,10 +1404,12 @@ export var ModernElementController = /*#__PURE__*/function () {
1341
1404
  }, {
1342
1405
  shouldContinue: shouldContinue
1343
1406
  });
1344
- _this6.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, {
1407
+ _this8.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, _objectSpread({
1345
1408
  success: true,
1346
1409
  result: !!shouldContinue
1347
- });
1410
+ }, isTimeout ? {
1411
+ isTimeout: true
1412
+ } : {}));
1348
1413
  }).catch(function (error) {
1349
1414
  logger.logError({
1350
1415
  title: 'sdk_before_confirm_error'
@@ -1352,7 +1417,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1352
1417
  errorMessage: String((error === null || error === void 0 ? void 0 : error.message) || error).slice(0, 200),
1353
1418
  path: 'modernController_bridge'
1354
1419
  });
1355
- _this6.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, {
1420
+ _this8.bridge.send(AMSMessageType.BEFORE_CONFIRM_REPLY, {
1356
1421
  success: false,
1357
1422
  result: false
1358
1423
  });
@@ -1366,12 +1431,12 @@ export var ModernElementController = /*#__PURE__*/function () {
1366
1431
  }, {
1367
1432
  key: "waitForReadyHandshake",
1368
1433
  value: function waitForReadyHandshake() {
1369
- var _this7 = this;
1434
+ var _this9 = this;
1370
1435
  return new Promise(function (resolve, reject) {
1371
1436
  var cancelDestroyCallback = function cancelDestroyCallback() {};
1372
1437
  var timer = setTimeout(function () {
1373
1438
  cancelDestroyCallback();
1374
- _this7.trackError('ready_handshake_timeout', {
1439
+ _this9.trackError('ready_handshake_timeout', {
1375
1440
  d1: String(MOUNT_TIMEOUT)
1376
1441
  });
1377
1442
  reject({
@@ -1379,16 +1444,16 @@ export var ModernElementController = /*#__PURE__*/function () {
1379
1444
  message: 'An error occurred; the transaction cannot be initiated.'
1380
1445
  });
1381
1446
  }, MOUNT_TIMEOUT);
1382
- cancelDestroyCallback = _this7.onDestroy(function () {
1447
+ cancelDestroyCallback = _this9.onDestroy(function () {
1383
1448
  clearTimeout(timer);
1384
1449
  reject(getDestroyedError());
1385
1450
  });
1386
- _this7.bridge.once(MessageType.READY_HANDSHAKE, function () {
1387
- var _this7$iframe;
1451
+ _this9.bridge.once(MessageType.READY_HANDSHAKE, function () {
1452
+ var _this9$iframe;
1388
1453
  clearTimeout(timer);
1389
1454
  cancelDestroyCallback();
1390
- if (!((_this7$iframe = _this7.iframe) !== null && _this7$iframe !== void 0 && _this7$iframe.contentWindow)) {
1391
- _this7.trackError('iframe_contentwindow_unavailable', {
1455
+ if (!((_this9$iframe = _this9.iframe) !== null && _this9$iframe !== void 0 && _this9$iframe.contentWindow)) {
1456
+ _this9.trackError('iframe_contentwindow_unavailable', {
1392
1457
  d1: 'after_ready_handshake'
1393
1458
  });
1394
1459
  reject({
@@ -1397,9 +1462,9 @@ export var ModernElementController = /*#__PURE__*/function () {
1397
1462
  });
1398
1463
  return;
1399
1464
  }
1400
- _this7.bridge.setTarget(_this7.iframe.contentWindow);
1401
- _this7.trackHandshake('ready_handshake_received', {
1402
- m1: _this7._mountStartTime ? Date.now() - _this7._mountStartTime : 0
1465
+ _this9.bridge.setTarget(_this9.iframe.contentWindow);
1466
+ _this9.trackHandshake('ready_handshake_received', {
1467
+ m1: _this9._mountStartTime ? Date.now() - _this9._mountStartTime : 0
1403
1468
  });
1404
1469
  resolve();
1405
1470
  });
@@ -1424,12 +1489,12 @@ export var ModernElementController = /*#__PURE__*/function () {
1424
1489
  }, {
1425
1490
  key: "waitForHandshakeAck",
1426
1491
  value: function waitForHandshakeAck() {
1427
- var _this8 = this;
1492
+ var _this10 = this;
1428
1493
  return new Promise(function (resolve, reject) {
1429
1494
  var cancelDestroyCallback = function cancelDestroyCallback() {};
1430
1495
  var timer = setTimeout(function () {
1431
1496
  cancelDestroyCallback();
1432
- _this8.trackError('handshake_ack_timeout', {
1497
+ _this10.trackError('handshake_ack_timeout', {
1433
1498
  d1: String(MOUNT_TIMEOUT)
1434
1499
  });
1435
1500
  reject({
@@ -1437,15 +1502,15 @@ export var ModernElementController = /*#__PURE__*/function () {
1437
1502
  message: 'An error occurred; the transaction cannot be initiated.'
1438
1503
  });
1439
1504
  }, MOUNT_TIMEOUT);
1440
- cancelDestroyCallback = _this8.onDestroy(function () {
1505
+ cancelDestroyCallback = _this10.onDestroy(function () {
1441
1506
  clearTimeout(timer);
1442
1507
  reject(getDestroyedError());
1443
1508
  });
1444
- _this8.bridge.once(MessageType.HANDSHAKE_ACK, function () {
1509
+ _this10.bridge.once(MessageType.HANDSHAKE_ACK, function () {
1445
1510
  clearTimeout(timer);
1446
1511
  cancelDestroyCallback();
1447
- _this8.trackHandshake('handshake_ack_received', {
1448
- m1: _this8._mountStartTime ? Date.now() - _this8._mountStartTime : 0
1512
+ _this10.trackHandshake('handshake_ack_received', {
1513
+ m1: _this10._mountStartTime ? Date.now() - _this10._mountStartTime : 0
1449
1514
  });
1450
1515
  resolve();
1451
1516
  });
@@ -1455,24 +1520,24 @@ export var ModernElementController = /*#__PURE__*/function () {
1455
1520
  key: "submitPayment",
1456
1521
  value: function () {
1457
1522
  var _submitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8(params) {
1458
- var _this9 = this;
1523
+ var _this11 = this;
1459
1524
  return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1460
1525
  while (1) switch (_context8.prev = _context8.next) {
1461
1526
  case 0:
1462
1527
  return _context8.abrupt("return", runApi('submitPayment', function () {
1463
- return _this9.doSubmitPayment(params);
1528
+ return _this11.doSubmitPayment(params);
1464
1529
  }, function () {
1465
- return _this9.currentPaymentMethodType ? {
1466
- d4: _this9.currentPaymentMethodType
1530
+ return _this11.currentPaymentMethodType ? {
1531
+ d4: _this11.currentPaymentMethodType
1467
1532
  } : {};
1468
- }, normalizeApiInput('submitPayment', params), this.merchantId));
1533
+ }, normalizeApiInput('submitPayment', params), this.merchantId, this.productScene));
1469
1534
  case 1:
1470
1535
  case "end":
1471
1536
  return _context8.stop();
1472
1537
  }
1473
1538
  }, _callee8, this);
1474
1539
  }));
1475
- function submitPayment(_x15) {
1540
+ function submitPayment(_x16) {
1476
1541
  return _submitPayment.apply(this, arguments);
1477
1542
  }
1478
1543
  return submitPayment;
@@ -1481,8 +1546,8 @@ export var ModernElementController = /*#__PURE__*/function () {
1481
1546
  key: "doSubmitPayment",
1482
1547
  value: function () {
1483
1548
  var _doSubmitPayment = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee9(params) {
1484
- var _this10 = this;
1485
- var _this$options$loading7, _this$options$loading8, isApplePay, _ref6, onBeforeConfirm, serializableParams, startTime, _yield$executeWithTim2, shouldContinue, timedOut, hasBeforeConfirmForApplePay, hasAmount, hasCurrency, cleanups, _result$error5, resultPromise, result, _this$options$loading9, _this$options$loading10;
1549
+ var _this12 = this;
1550
+ var _this$options$loading7, _this$options$loading8, isApplePay, _ref6, onBeforeConfirm, serializableParams, startTime, _yield$executeWithTim2, shouldContinue, timedOut, isTimeout, hasBeforeConfirmForApplePay, hasAmount, hasCurrency, cleanups, _result$error5, resultPromise, result, _this$options$loading9, _this$options$loading10;
1486
1551
  return _regeneratorRuntime().wrap(function _callee9$(_context9) {
1487
1552
  while (1) switch (_context9.prev = _context9.next) {
1488
1553
  case 0:
@@ -1519,7 +1584,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1519
1584
  isApplePay = this.currentPaymentMethodType === 'APPLEPAY'; // 剥除 onBeforeConfirm 函数,避免 postMessage 序列化报错
1520
1585
  _ref6 = params || {}, onBeforeConfirm = _ref6.onBeforeConfirm, serializableParams = _objectWithoutProperties(_ref6, _excluded2); // ── 非 Apple Pay:同步执行 onBeforeConfirm(submit 前拦截,对齐老 ElementController) ──
1521
1586
  if (!(onBeforeConfirm && !isApplePay)) {
1522
- _context9.next = 31;
1587
+ _context9.next = 32;
1523
1588
  break;
1524
1589
  }
1525
1590
  logger.logInfo({
@@ -1538,11 +1603,13 @@ export var ModernElementController = /*#__PURE__*/function () {
1538
1603
  _yield$executeWithTim2 = _context9.sent;
1539
1604
  shouldContinue = _yield$executeWithTim2.result;
1540
1605
  timedOut = _yield$executeWithTim2.timedOut;
1541
- if (!(timedOut || !shouldContinue || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS)) {
1542
- _context9.next = 22;
1606
+ // 双重校验:timedOut(Promise race)+ startTime(实际时间差),防止竞态误判
1607
+ isTimeout = timedOut || Date.now() - startTime >= BEFORE_CONFIRM_TIMEOUT_MS;
1608
+ if (!(isTimeout || !shouldContinue)) {
1609
+ _context9.next = 23;
1543
1610
  break;
1544
1611
  }
1545
- if (timedOut) {
1612
+ if (isTimeout) {
1546
1613
  logger.logError({
1547
1614
  title: 'sdk_before_confirm_timeout'
1548
1615
  }, {
@@ -1560,21 +1627,22 @@ export var ModernElementController = /*#__PURE__*/function () {
1560
1627
  return _context9.abrupt("return", {
1561
1628
  status: 'FAIL',
1562
1629
  error: {
1563
- code: 'MERCHANT_CONFIRM_ABORT',
1564
- message: 'Merchant canceled payment.'
1630
+ code: isTimeout ? MERCHANT_CONFIRM_TIMEOUT_CODE : MERCHANT_CONFIRM_ABORT_CODE,
1631
+ message: isTimeout ? 'Merchant confirmation timed out.' : 'Merchant canceled payment.',
1632
+ needChangeSessionForRetry: false
1565
1633
  }
1566
1634
  });
1567
- case 22:
1635
+ case 23:
1568
1636
  logger.logInfo({
1569
1637
  title: 'sdk_before_confirm_success'
1570
1638
  }, {
1571
1639
  paymentMethodType: this.currentPaymentMethodType || 'UNKNOWN',
1572
1640
  path: 'nonApplePay_sync'
1573
1641
  });
1574
- _context9.next = 29;
1642
+ _context9.next = 30;
1575
1643
  break;
1576
- case 25:
1577
- _context9.prev = 25;
1644
+ case 26:
1645
+ _context9.prev = 26;
1578
1646
  _context9.t0 = _context9["catch"](12);
1579
1647
  logger.logError({
1580
1648
  title: 'sdk_before_confirm_error'
@@ -1586,14 +1654,15 @@ export var ModernElementController = /*#__PURE__*/function () {
1586
1654
  return _context9.abrupt("return", {
1587
1655
  status: 'FAIL',
1588
1656
  error: {
1589
- code: 'MERCHANT_CONFIRM_ABORT',
1590
- message: 'Merchant canceled payment.'
1657
+ code: MERCHANT_CONFIRM_ABORT_CODE,
1658
+ message: 'Merchant canceled payment.',
1659
+ needChangeSessionForRetry: false
1591
1660
  }
1592
1661
  });
1593
- case 29:
1594
- _context9.next = 32;
1662
+ case 30:
1663
+ _context9.next = 33;
1595
1664
  break;
1596
- case 31:
1665
+ case 32:
1597
1666
  if (!onBeforeConfirm) {
1598
1667
  logger.logInfo({
1599
1668
  title: 'sdk_before_confirm_skip'
@@ -1602,7 +1671,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1602
1671
  path: isApplePay ? 'applePay_eventBridge' : 'nonApplePay_sync'
1603
1672
  });
1604
1673
  }
1605
- case 32:
1674
+ case 33:
1606
1675
  // Apple Pay: 标记是否有 beforeConfirm,供 SUBMIT 消息的 hasBeforeConfirm 字段使用
1607
1676
  hasBeforeConfirmForApplePay = isApplePay && !!onBeforeConfirm; // ── amount/currency 校验 + 缓存(对齐老 ElementController 逻辑) ──
1608
1677
  hasAmount = !!(serializableParams !== null && serializableParams !== void 0 && serializableParams.amount);
@@ -1626,24 +1695,24 @@ export var ModernElementController = /*#__PURE__*/function () {
1626
1695
  // 未命中的 once wrapper 绑着旧闭包(旧 onBeforeConfirm / 旧 resolve)会残留并串扰后续提交,
1627
1696
  // 在 submit 终态统一释放(二次 off 幂等,已命中的 once 已自行 off)。
1628
1697
  cleanups = [];
1629
- _context9.prev = 41;
1698
+ _context9.prev = 42;
1630
1699
  resultPromise = new Promise(function (resolve) {
1631
1700
  // 先注册事件监听,再发送 SUBMIT,避免 webapp 快速响应导致消息丢失
1632
1701
  // PC 非 Safari:webapp 委托 SDK 拉起 Apple Pay 拿 token
1633
- cleanups.push(_this10.bridge.once(AMSMessageType.GET_APPLE_PAY_TOKEN, function (payload) {
1634
- _this10.handleGetApplePayToken(payload, onBeforeConfirm).then(function () {
1702
+ cleanups.push(_this12.bridge.once(AMSMessageType.GET_APPLE_PAY_TOKEN, function (payload) {
1703
+ _this12.handleGetApplePayToken(payload, onBeforeConfirm).then(function () {
1635
1704
  // token 已回传 webapp,继续等 SUBMIT_REPLY
1636
1705
  });
1637
1706
  }));
1638
1707
  // Web element GP:webapp 委托 SDK/父 frame 调 loadPaymentData 拿 token
1639
- cleanups.push(_this10.bridge.once(AMSMessageType.GET_GOOGLE_PAY_TOKEN, function (payload) {
1640
- _this10.handleGetGooglePayToken(payload);
1708
+ cleanups.push(_this12.bridge.once(AMSMessageType.GET_GOOGLE_PAY_TOKEN, function (payload) {
1709
+ _this12.handleGetGooglePayToken(payload);
1641
1710
  }));
1642
1711
  // Safari:webapp 请求执行商户 onBeforeConfirm 回调
1643
- cleanups.push(_this10.bridge.once(AMSMessageType.BEFORE_CONFIRM, function () {
1644
- _this10.handleBeforeConfirmInternal(onBeforeConfirm || null);
1712
+ cleanups.push(_this12.bridge.once(AMSMessageType.BEFORE_CONFIRM, function () {
1713
+ _this12.handleBeforeConfirmInternal(onBeforeConfirm || null);
1645
1714
  }));
1646
- cleanups.push(_this10.bridge.once(MessageType.SUBMIT_REPLY, resolve));
1715
+ cleanups.push(_this12.bridge.once(MessageType.SUBMIT_REPLY, resolve));
1647
1716
  }); // 监听注册完成后再发送 SUBMIT,确保不会遗漏快速响应
1648
1717
  this.send(MessageType.SUBMIT, _objectSpread(_objectSpread({}, serializableParams), {}, {
1649
1718
  redirect: this.notRedirectAfterComplete ? 'if_required' : 'always',
@@ -1652,45 +1721,45 @@ export var ModernElementController = /*#__PURE__*/function () {
1652
1721
  amount: serializableParams.amount,
1653
1722
  currency: serializableParams.currency
1654
1723
  } : {}));
1655
- _context9.next = 46;
1724
+ _context9.next = 47;
1656
1725
  return resultPromise;
1657
- case 46:
1726
+ case 47:
1658
1727
  result = _context9.sent;
1659
1728
  this.trackElement('submit_reply', {
1660
1729
  d1: (result === null || result === void 0 ? void 0 : result.status) || '',
1661
1730
  d2: (result === null || result === void 0 || (_result$error5 = result.error) === null || _result$error5 === void 0 ? void 0 : _result$error5.code) || ''
1662
1731
  });
1663
1732
  return _context9.abrupt("return", adaptSubmitResult(result));
1664
- case 51:
1665
- _context9.prev = 51;
1666
- _context9.t1 = _context9["catch"](41);
1733
+ case 52:
1734
+ _context9.prev = 52;
1735
+ _context9.t1 = _context9["catch"](42);
1667
1736
  this.trackError('submit_error', {
1668
1737
  d1: (_context9.t1 === null || _context9.t1 === void 0 ? void 0 : _context9.t1.code) || 'UNKNOWN',
1669
1738
  d2: (_context9.t1 === null || _context9.t1 === void 0 ? void 0 : _context9.t1.message) || ''
1670
1739
  });
1671
1740
  throw _context9.t1;
1672
- case 55:
1673
- _context9.prev = 55;
1741
+ case 56:
1742
+ _context9.prev = 56;
1674
1743
  cleanups.forEach(function (fn) {
1675
1744
  try {
1676
1745
  fn();
1677
- } catch (_unused7) {
1746
+ } catch (_unused9) {
1678
1747
  /* ignore cleanup error */
1679
1748
  }
1680
1749
  });
1681
1750
  (_this$options$loading9 = this.options.loading) === null || _this$options$loading9 === void 0 || (_this$options$loading10 = _this$options$loading9.onEndLoading) === null || _this$options$loading10 === void 0 || _this$options$loading10.call(_this$options$loading9);
1682
- return _context9.finish(55);
1683
- case 59:
1684
- _context9.prev = 59;
1751
+ return _context9.finish(56);
1752
+ case 60:
1753
+ _context9.prev = 60;
1685
1754
  this.isSubmitting = false;
1686
- return _context9.finish(59);
1687
- case 62:
1755
+ return _context9.finish(60);
1756
+ case 63:
1688
1757
  case "end":
1689
1758
  return _context9.stop();
1690
1759
  }
1691
- }, _callee9, this, [[7,, 59, 62], [12, 25], [41, 51, 55, 59]]);
1760
+ }, _callee9, this, [[7,, 60, 63], [12, 26], [42, 52, 56, 60]]);
1692
1761
  }));
1693
- function doSubmitPayment(_x16) {
1762
+ function doSubmitPayment(_x17) {
1694
1763
  return _doSubmitPayment.apply(this, arguments);
1695
1764
  }
1696
1765
  return doSubmitPayment;
@@ -1699,13 +1768,13 @@ export var ModernElementController = /*#__PURE__*/function () {
1699
1768
  key: "validateFields",
1700
1769
  value: function () {
1701
1770
  var _validateFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee10() {
1702
- var _this11 = this;
1771
+ var _this13 = this;
1703
1772
  return _regeneratorRuntime().wrap(function _callee10$(_context10) {
1704
1773
  while (1) switch (_context10.prev = _context10.next) {
1705
1774
  case 0:
1706
1775
  return _context10.abrupt("return", runApi('validateFields', function () {
1707
- return _this11.doValidateFields();
1708
- }, undefined, undefined, this.merchantId));
1776
+ return _this13.doValidateFields();
1777
+ }, undefined, undefined, this.merchantId, this.productScene));
1709
1778
  case 1:
1710
1779
  case "end":
1711
1780
  return _context10.stop();
@@ -1721,7 +1790,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1721
1790
  key: "doValidateFields",
1722
1791
  value: function () {
1723
1792
  var _doValidateFields = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee11() {
1724
- var _this12 = this;
1793
+ var _this14 = this;
1725
1794
  return _regeneratorRuntime().wrap(function _callee11$(_context11) {
1726
1795
  while (1) switch (_context11.prev = _context11.next) {
1727
1796
  case 0:
@@ -1739,17 +1808,17 @@ export var ModernElementController = /*#__PURE__*/function () {
1739
1808
  this.send(AMSMessageType.VALIDATE);
1740
1809
  return _context11.abrupt("return", new Promise(function (resolve) {
1741
1810
  var timer = setTimeout(function () {
1742
- _this12.trackError('validate_fields_timeout', {
1811
+ _this14.trackError('validate_fields_timeout', {
1743
1812
  d1: '15000'
1744
1813
  });
1745
1814
  resolve({
1746
1815
  isValid: false
1747
1816
  });
1748
1817
  }, 15000);
1749
- _this12.bridge.once(AMSMessageType.VALIDATE_REPLY, function (payload) {
1818
+ _this14.bridge.once(AMSMessageType.VALIDATE_REPLY, function (payload) {
1750
1819
  clearTimeout(timer);
1751
1820
  var isValid = !!(payload !== null && payload !== void 0 && payload.isValid);
1752
- _this12.trackElement('validate_result', {
1821
+ _this14.trackElement('validate_result', {
1753
1822
  d1: isValid ? 'valid' : 'invalid'
1754
1823
  });
1755
1824
  resolve(payload || {
@@ -1782,7 +1851,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1782
1851
  }
1783
1852
  }, _callee12);
1784
1853
  }));
1785
- function updatePayment(_x17) {
1854
+ function updatePayment(_x18) {
1786
1855
  return _updatePayment.apply(this, arguments);
1787
1856
  }
1788
1857
  return updatePayment;
@@ -1795,16 +1864,17 @@ export var ModernElementController = /*#__PURE__*/function () {
1795
1864
  }, {
1796
1865
  key: "destroy",
1797
1866
  value: function destroy() {
1798
- var _this$iframe;
1867
+ var _this$iframe2;
1799
1868
  this.trackElement('destroy', {
1800
1869
  d1: this.status
1801
1870
  });
1802
1871
  if (this.status === 'initialized' || this.status === 'destroyed') {
1803
1872
  return;
1804
1873
  }
1874
+ this.stopModalMessageMonitor();
1805
1875
  this.handleCloseModal();
1806
1876
  this.bridge.destroy();
1807
- if ((_this$iframe = this.iframe) !== null && _this$iframe !== void 0 && _this$iframe.parentNode) this.iframe.parentNode.removeChild(this.iframe);
1877
+ if ((_this$iframe2 = this.iframe) !== null && _this$iframe2 !== void 0 && _this$iframe2.parentNode) this.iframe.parentNode.removeChild(this.iframe);
1808
1878
  this.iframe = null;
1809
1879
  this.setStatus('destroyed');
1810
1880
  this.runDestroyCallbacks();
@@ -1813,8 +1883,8 @@ export var ModernElementController = /*#__PURE__*/function () {
1813
1883
  }, {
1814
1884
  key: "cleanup",
1815
1885
  value: function cleanup() {
1816
- var _this$iframe2;
1817
- if ((_this$iframe2 = this.iframe) !== null && _this$iframe2 !== void 0 && _this$iframe2.parentNode) this.iframe.parentNode.removeChild(this.iframe);
1886
+ var _this$iframe3;
1887
+ if ((_this$iframe3 = this.iframe) !== null && _this$iframe3 !== void 0 && _this$iframe3.parentNode) this.iframe.parentNode.removeChild(this.iframe);
1818
1888
  this.iframe = null;
1819
1889
  this.setStatus('initialized');
1820
1890
  this.cachedSend = [];
@@ -1832,7 +1902,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1832
1902
  }, {
1833
1903
  key: "onDestroy",
1834
1904
  value: function onDestroy(callback) {
1835
- var _this13 = this;
1905
+ var _this15 = this;
1836
1906
  if (this.status === 'destroyed') {
1837
1907
  callback();
1838
1908
  return function () {
@@ -1841,7 +1911,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1841
1911
  }
1842
1912
  this.destroyCallbacks.push(callback);
1843
1913
  return function () {
1844
- _this13.destroyCallbacks = _this13.destroyCallbacks.filter(function (item) {
1914
+ _this15.destroyCallbacks = _this15.destroyCallbacks.filter(function (item) {
1845
1915
  return item !== callback;
1846
1916
  });
1847
1917
  };
@@ -1881,12 +1951,12 @@ export var ModernElementController = /*#__PURE__*/function () {
1881
1951
  }, {
1882
1952
  key: "flushCachedMessages",
1883
1953
  value: function flushCachedMessages() {
1884
- var _this14 = this;
1954
+ var _this16 = this;
1885
1955
  if (this.cachedSend.length > 0) {
1886
1956
  this.cachedSend.forEach(function (_ref7) {
1887
1957
  var type = _ref7.type,
1888
1958
  payload = _ref7.payload;
1889
- _this14.bridge.send(type, payload);
1959
+ _this16.bridge.send(type, payload);
1890
1960
  });
1891
1961
  this.cachedSend = [];
1892
1962
  }
@@ -1909,7 +1979,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1909
1979
  var _payload$appearance,
1910
1980
  _themeColorMap$appear,
1911
1981
  _payload$appearance2,
1912
- _this15 = this;
1982
+ _this17 = this;
1913
1983
  // 清理已存在的 modal
1914
1984
  this.handleCloseModal();
1915
1985
  var mode = device.isMobile ? 'mobile' : 'desktop';
@@ -1943,9 +2013,10 @@ export var ModernElementController = /*#__PURE__*/function () {
1943
2013
  // 从 appearance 提取主题信息,组装 loadingConfig(对齐 antom.ts openModal 的处理逻辑)
1944
2014
  var appearanceTheme = (payload === null || payload === void 0 || (_payload$appearance = payload.appearance) === null || _payload$appearance === void 0 ? void 0 : _payload$appearance.theme) || 'default';
1945
2015
  var themeConfig = (_themeColorMap$appear = themeColorMap[appearanceTheme]) !== null && _themeColorMap$appear !== void 0 ? _themeColorMap$appear : themeColorMap.default;
2016
+ var appearanceVariables = payload === null || payload === void 0 || (_payload$appearance2 = payload.appearance) === null || _payload$appearance2 === void 0 ? void 0 : _payload$appearance2.variables;
1946
2017
  var loadingConfig = {
1947
2018
  theme: themeConfig.theme,
1948
- backgroundColor: (payload === null || payload === void 0 || (_payload$appearance2 = payload.appearance) === null || _payload$appearance2 === void 0 || (_payload$appearance2 = _payload$appearance2.variables) === null || _payload$appearance2 === void 0 ? void 0 : _payload$appearance2['background-primary']) || themeConfig.backgroundColor
2019
+ backgroundColor: (appearanceVariables === null || appearanceVariables === void 0 ? void 0 : appearanceVariables['color-background-primary']) || (appearanceVariables === null || appearanceVariables === void 0 ? void 0 : appearanceVariables['background-primary']) || themeConfig.backgroundColor
1949
2020
  };
1950
2021
 
1951
2022
  // 调用 openModal 工具函数创建 DOM(overlay + modal + iframe + 动画 + close icon + loading)
@@ -1964,7 +2035,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1964
2035
  destroy = _openModal.destroy;
1965
2036
  var offReady = modalBridge.once(MessageType.MODAL_TRANSFER_READY, function (_payload, _ports, meta) {
1966
2037
  if (meta && meta.source !== iframe.contentWindow) return;
1967
- _this15.trackElement('modal_loaded', {
2038
+ _this17.trackElement('modal_loaded', {
1968
2039
  d1: payload.url
1969
2040
  });
1970
2041
  // 确保 target 已设置(如果 load 事件尚未触发,在此设置)
@@ -1975,7 +2046,7 @@ export var ModernElementController = /*#__PURE__*/function () {
1975
2046
  if (iframeOrigin && iframeOrigin !== 'null') {
1976
2047
  modalBridge.setOrigin(iframeOrigin);
1977
2048
  }
1978
- } catch (_unused8) {
2049
+ } catch (_unused10) {
1979
2050
  // URL 解析失败时保持默认 origin
1980
2051
  }
1981
2052
  // 如果 payload 有 appearance,通过 TRANSFER_MODAL_APPEARANCE 消息发送给 modal
@@ -1993,13 +2064,13 @@ export var ModernElementController = /*#__PURE__*/function () {
1993
2064
  this.modalIframe = iframe;
1994
2065
  this.modalDestroy = function () {
1995
2066
  if (payload.closeConfirm) {
1996
- _this15.trackElement('modal_close_confirm', {
2067
+ _this17.trackElement('modal_close_confirm', {
1997
2068
  d1: 'confirm_resolved'
1998
2069
  });
1999
2070
  }
2000
2071
  destroy();
2001
2072
  offReady();
2002
- _this15.modalIframe = null;
2073
+ _this17.modalIframe = null;
2003
2074
  };
2004
2075
  }
2005
2076