@alipay/ams-checkout 0.0.1730107332-dev.4 → 0.0.1730706734-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. package/dist/umd/ams-checkout.min.js +1 -1
  2. package/esm/config/index.d.ts +7 -7
  3. package/esm/config/index.js +7 -7
  4. package/esm/constant/index.d.ts +6 -1
  5. package/esm/constant/index.js +80 -3
  6. package/esm/core/bus/ability/callback.d.ts +9 -0
  7. package/esm/{foundation/service/api-bus → core/bus}/ability/callback.js +1 -1
  8. package/esm/core/bus/ability/globalData.d.ts +10 -0
  9. package/esm/{foundation/service/api-bus → core/bus}/ability/globalData.js +2 -2
  10. package/esm/{foundation/service/api-bus → core/bus}/ability/request.d.ts +1 -1
  11. package/esm/{foundation/service/api-bus → core/bus}/ability/request.js +2 -2
  12. package/esm/core/bus/ability/security.d.ts +10 -0
  13. package/esm/core/bus/ability/security.js +104 -0
  14. package/esm/core/bus/ability/tracker.d.ts +9 -0
  15. package/esm/core/bus/ability/tracker.js +77 -0
  16. package/esm/core/bus/index.d.ts +125 -0
  17. package/esm/core/bus/index.js +366 -0
  18. package/esm/core/component/address.d.ts +8 -0
  19. package/esm/core/component/address.js +72 -0
  20. package/esm/core/component/appPreloadProcessing.d.ts +1 -0
  21. package/esm/core/component/appPreloadProcessing.js +91 -0
  22. package/esm/core/component/ckp/index.d.ts +27 -0
  23. package/esm/core/component/ckp/index.js +166 -0
  24. package/esm/core/component/element/components/address.d.ts +19 -0
  25. package/esm/core/component/element/components/address.js +68 -0
  26. package/esm/core/component/element/components/auth.d.ts +17 -0
  27. package/esm/core/component/element/components/auth.js +59 -0
  28. package/esm/core/component/element/components/payment.d.ts +19 -0
  29. package/esm/core/component/element/components/payment.js +74 -0
  30. package/esm/core/component/element/element-mock.d.ts +2 -0
  31. package/esm/core/component/element/element-mock.js +263 -0
  32. package/esm/core/component/element/index.d.ts +47 -0
  33. package/esm/core/component/element/index.js +776 -0
  34. package/esm/core/component/element/mock.d.ts +3 -0
  35. package/esm/core/component/element/mock.js +1156 -0
  36. package/esm/core/component/element/type.d.ts +176 -0
  37. package/esm/core/component/element/type.js +34 -0
  38. package/esm/core/component/element/utils.d.ts +13 -0
  39. package/esm/core/component/element/utils.js +6 -0
  40. package/esm/core/component/index.d.ts +51 -0
  41. package/esm/core/component/index.js +535 -0
  42. package/esm/core/drop-in/index.d.ts +22 -0
  43. package/esm/core/drop-in/index.js +104 -0
  44. package/esm/core/instance/index.d.ts +89 -0
  45. package/esm/core/instance/index.js +500 -0
  46. package/esm/foundation/core/index.d.ts +3 -3
  47. package/esm/foundation/core/index.js +51 -114
  48. package/esm/foundation/index.d.ts +3 -5
  49. package/esm/foundation/product-processor/easysafepay/deps.d.ts +4 -7
  50. package/esm/foundation/product-processor/easysafepay/deps.js +2 -5
  51. package/esm/foundation/product-processor/easysafepay/index.d.ts +4 -5
  52. package/esm/foundation/product-processor/easysafepay/index.js +114 -174
  53. package/esm/foundation/service/container/index.js +5 -5
  54. package/esm/foundation/service/container/popup.js +1 -1
  55. package/esm/foundation/service/event-bus/ability/callback.js +55 -0
  56. package/esm/foundation/service/{api-bus → event-bus}/ability/globalData.d.ts +1 -1
  57. package/esm/foundation/service/event-bus/ability/globalData.js +89 -0
  58. package/esm/foundation/service/event-bus/ability/request.d.ts +10 -0
  59. package/esm/foundation/service/event-bus/ability/request.js +151 -0
  60. package/esm/foundation/service/{api-bus → event-bus}/ability/security.js +19 -29
  61. package/esm/foundation/service/{api-bus → event-bus}/ability/tracker.js +1 -1
  62. package/esm/foundation/service/{api-bus → event-bus}/busManager.js +1 -1
  63. package/esm/foundation/service/event-center.d.ts +5 -4
  64. package/esm/foundation/service/event-center.js +39 -8
  65. package/esm/foundation/service/global-data/index.js +5 -4
  66. package/esm/foundation/service/index.js +1 -1
  67. package/esm/foundation/service/requester/requester.js +11 -14
  68. package/esm/foundation/service/security/index.d.ts +7 -9
  69. package/esm/foundation/service/security/index.js +44 -113
  70. package/esm/foundation/utils/redirect_utils.js +8 -24
  71. package/esm/foundation/utils/web_app_url_utils.d.ts +2 -11
  72. package/esm/foundation/utils/web_app_url_utils.js +2 -17
  73. package/esm/index.d.ts +30 -1
  74. package/esm/index.js +147 -7
  75. package/esm/plugin/applepay/component.d.ts +50 -0
  76. package/esm/plugin/applepay/component.js +339 -0
  77. package/esm/plugin/applepay/index.d.ts +17 -0
  78. package/esm/plugin/applepay/index.js +117 -0
  79. package/esm/plugin/applepay/interface.d.ts +161 -0
  80. package/esm/plugin/applepay/interface.js +69 -0
  81. package/esm/plugin/applepay/service.d.ts +54 -0
  82. package/esm/plugin/applepay/service.js +289 -0
  83. package/esm/plugin/component/cashierApp.d.ts +36 -0
  84. package/esm/plugin/component/cashierApp.js +245 -0
  85. package/esm/{component → plugin/component}/channel.d.ts +2 -1
  86. package/esm/{component → plugin/component}/channel.js +37 -1
  87. package/esm/{component → plugin/component}/component.inline.style.d.ts +2 -2
  88. package/esm/{component → plugin/component}/component.inline.style.js +7 -6
  89. package/esm/{component → plugin/component}/component.popup.style.d.ts +1 -1
  90. package/esm/{component → plugin/component}/component.popup.style.js +4 -4
  91. package/esm/plugin/component/index.d.ts +126 -0
  92. package/esm/plugin/component/index.js +1862 -0
  93. package/esm/{component → plugin/component}/popupWindow.style.js +2 -2
  94. package/esm/plugin/const.d.ts +2 -0
  95. package/esm/plugin/const.js +33 -0
  96. package/esm/plugin/drop-in/index.d.ts +71 -0
  97. package/esm/plugin/drop-in/index.js +324 -0
  98. package/esm/plugin/payment-element/utils.d.ts +2 -0
  99. package/esm/plugin/payment-element/utils.js +7 -0
  100. package/esm/plugin/paypal/index.d.ts +20 -0
  101. package/esm/plugin/paypal/index.js +390 -0
  102. package/esm/plugin/type.d.ts +34 -0
  103. package/esm/plugin/type.js +1 -0
  104. package/esm/plugin/utils.d.ts +6 -0
  105. package/esm/plugin/utils.js +21 -0
  106. package/esm/service/element.d.ts +4 -0
  107. package/esm/service/element.js +51 -0
  108. package/esm/service/index.d.ts +1 -0
  109. package/esm/service/index.js +2 -0
  110. package/esm/types/index.d.ts +218 -22
  111. package/esm/types/index.js +47 -4
  112. package/esm/util/createIframeNode.d.ts +6 -0
  113. package/esm/util/createIframeNode.js +48 -0
  114. package/esm/util/getBackScheme.d.ts +2 -2
  115. package/esm/util/getBackScheme.js +2 -94
  116. package/esm/util/index.d.ts +11 -1
  117. package/esm/util/index.js +84 -4
  118. package/esm/util/intl-callapp/es/index.js +0 -1
  119. package/esm/util/ua/index.d.ts +2 -0
  120. package/esm/util/ua/index.js +2 -0
  121. package/esm/util/ua/isAndroid.d.ts +4 -0
  122. package/esm/util/ua/isAndroid.js +7 -0
  123. package/esm/util/ua/isIOS.d.ts +4 -0
  124. package/esm/util/ua/isIOS.js +7 -0
  125. package/package.json +2 -1
  126. package/esm/foundation/utils/payment_product_utils.d.ts +0 -13
  127. package/esm/foundation/utils/payment_product_utils.js +0 -38
  128. /package/esm/{foundation/service/api-bus → core/bus}/interface.d.ts +0 -0
  129. /package/esm/{foundation/service/api-bus → core/bus}/interface.js +0 -0
  130. /package/esm/foundation/service/{api-bus → event-bus}/ability/callback.d.ts +0 -0
  131. /package/esm/foundation/service/{api-bus → event-bus}/ability/security.d.ts +0 -0
  132. /package/esm/foundation/service/{api-bus → event-bus}/ability/tracker.d.ts +0 -0
  133. /package/esm/foundation/service/{api-bus → event-bus}/busManager.d.ts +0 -0
  134. /package/esm/foundation/service/{api-bus → event-bus}/index.d.ts +0 -0
  135. /package/esm/foundation/service/{api-bus → event-bus}/index.js +0 -0
  136. /package/esm/{component → plugin/component}/popupWindow.style.d.ts +0 -0
@@ -0,0 +1,1862 @@
1
+ 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); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
5
+ function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
6
+ function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
7
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
8
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
9
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
10
+ 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; }
11
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
12
+ 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); }
13
+ /**
14
+ * Copyright (c) 2022 International Business Group, Ant Group. All rights reserved.
15
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), the rights to use, copy, modify, merge, and/or distribute the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
16
+ * 1. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE; and
17
+ * 2. If applicable, the use of the Software is also subject to the terms and conditions of any non-disclosure agreement signed by you and the relevant Ant Group entity.
18
+ */
19
+ /* eslint-disable @typescript-eslint/no-explicit-any */
20
+ import { v4 as uuid } from 'uuid';
21
+ import { sdkVersion } from "../../config";
22
+ import { COMPONENTPLUGINID, COMPONENT_CLOSE_BLOCK_ID, COMPONENT_CONTAINER_ID, COMPONENT_RETENTION_ID, COMPONENT_SECTION_ID, ERRORMESSAGE, EVENT, LISTENER_PREFIX, LOADING_ID, LOADTIME_LIMIT, MOCKUP_ID, POPUP_LOADTIME_LOG_LIMIT, TIMEOUT_WEB_APP_HEART_BEAT, TIME_DELAY_SEND_HEART_BEAT } from "../../constant";
23
+ import { queryPaymentInfo, submitPayInfo } from "../../service";
24
+ import { ComponentSignEnum, DisplayTypeEnum, eventCodeEnum, MessageName, PlatformEnum, ProductSceneEnum, RedirectType, TargetEnum } from "../../types";
25
+ import { getType, isJsonString, isPC } from "../../util";
26
+ import { isLocalMock } from "../../util/mock";
27
+ import { matchVersion } from "../../util/versionCompare";
28
+ import { getBackScheme } from "../../util/getBackScheme";
29
+ import { handlePaymentSessionConfig } from "../payment-element/utils";
30
+ import { createIframe, createPreloadIframe, getAppDomain, getIframeUrl } from "./cashierApp";
31
+ import { getChannelBehavior, handleGooglePay } from "./channel";
32
+ import { addInlineLoading, createInlineBaseElement } from "./component.inline.style";
33
+ import { addPopupLoading, createBaseElement, createMockup, createRetentionPopup, handleDeclareInfo as _handleDeclareInfo, hideRetentionPopup, removeRetentionPopup as _removeRetentionPopup, slideInAndOutKeyframes } from "./component.popup.style";
34
+ import { createModal, destroyModal, insertStyleSheet, removePopupLoading } from "./popupWindow.style";
35
+ window.changingPageHeight = window.innerHeight;
36
+ var ComponentApp = /*#__PURE__*/function () {
37
+ function ComponentApp(componentOption) {
38
+ _classCallCheck(this, ComponentApp);
39
+ _defineProperty(this, "app", void 0);
40
+ _defineProperty(this, "AMSSDK", void 0);
41
+ _defineProperty(this, "platform", void 0);
42
+ _defineProperty(this, "_performanceData", []);
43
+ _defineProperty(this, "_loadAppPromiseResolve", null);
44
+ _defineProperty(this, "_isInitComponent", void 0);
45
+ _defineProperty(this, "_globalData", void 0);
46
+ _defineProperty(this, "popupApp", void 0);
47
+ _defineProperty(this, "appDomain", void 0);
48
+ _defineProperty(this, "createIframeNode", void 0);
49
+ _defineProperty(this, "createPreloadIframeNode", void 0);
50
+ _defineProperty(this, "_selector", void 0);
51
+ _defineProperty(this, "_appVersion", void 0);
52
+ _defineProperty(this, "_isRetention", void 0);
53
+ _defineProperty(this, "_allowSubmitPayCallAhead", void 0);
54
+ _defineProperty(this, "_actionQueryPromise", null);
55
+ _defineProperty(this, "_actionSubmitPromise", null);
56
+ _defineProperty(this, "_renderParams", null);
57
+ _defineProperty(this, "_componentSign", ComponentSignEnum.NONE);
58
+ _defineProperty(this, "_appLocationSearch", void 0);
59
+ _defineProperty(this, "_renderDisplayType", DisplayTypeEnum.popup);
60
+ _defineProperty(this, "_multipleCallbackEvents", void 0);
61
+ _defineProperty(this, "_isAppWebview", void 0);
62
+ _defineProperty(this, "_merchantAppointParam", void 0);
63
+ _defineProperty(this, "_webAppHeartBeatTimeoutFn", void 0);
64
+ this._appVersion = componentOption.appVersion;
65
+ this._isInitComponent = false;
66
+ this._selector = "#".concat(COMPONENT_SECTION_ID);
67
+ this.createIframeNode = function () {
68
+ return Promise.resolve();
69
+ };
70
+ this.createPreloadIframeNode = function () {
71
+ return Promise.resolve();
72
+ };
73
+ this.platform = isPC() ? PlatformEnum.desktop : PlatformEnum.mobile;
74
+ this._isRetention = true;
75
+ this._appLocationSearch = '';
76
+ this._performanceData.push({
77
+ key: 'sdk_init',
78
+ value: Date.now()
79
+ });
80
+ this._globalData = new Map();
81
+ }
82
+
83
+ /**
84
+ * @description Cancel listening and destroy the dom
85
+ */
86
+ _createClass(ComponentApp, [{
87
+ key: "logoutPlugin",
88
+ value: function logoutPlugin() {
89
+ this.cleanContainer(true);
90
+ }
91
+
92
+ /**
93
+ * @description When SDK registers plug-ins, it is a required function to receive SDK instances
94
+ */
95
+ }, {
96
+ key: "applyPlugin",
97
+ value: function applyPlugin(AMSSDK) {
98
+ this.AMSSDK = AMSSDK;
99
+ this.subscribeFromSDK();
100
+ }
101
+ }, {
102
+ key: "initLoggerMeta",
103
+ value: function initLoggerMeta() {
104
+ var _this$_renderParams, _paymentSessionMetaDa, _this$_renderParams2, _this$_renderParams3;
105
+ var paymentSessionMetaData = (_this$_renderParams = this._renderParams) === null || _this$_renderParams === void 0 ? void 0 : _this$_renderParams.paymentSessionMetaData;
106
+ var paymentSessionConfig = paymentSessionMetaData.paymentSessionConfig;
107
+ this.AMSSDK.logger.setMedta({
108
+ platform: this.platform === PlatformEnum.desktop ? 'PC' : 'WAP',
109
+ // PC/WAP,
110
+ sdkVersion: sdkVersion,
111
+ webAppVersion: this._appVersion,
112
+ instanceId: this.AMSSDK._instanceId,
113
+ storageId: this.AMSSDK._storageId,
114
+ // the better way to use md5 paymentSesionID
115
+ renderDisplayType: paymentSessionMetaData === null || paymentSessionMetaData === void 0 ? void 0 : paymentSessionMetaData.renderDisplayType,
116
+ merchantId: paymentSessionMetaData === null || paymentSessionMetaData === void 0 ? void 0 : paymentSessionMetaData.clientId,
117
+ productScene: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productScene,
118
+ productSceneVersion: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.productSceneVersion,
119
+ paymentMethodType: paymentSessionMetaData === null || paymentSessionMetaData === void 0 || (_paymentSessionMetaDa = paymentSessionMetaData.paymentMethodInfoView) === null || _paymentSessionMetaDa === void 0 ? void 0 : _paymentSessionMetaDa.paymentMethodType,
120
+ paymentMethodCategoryType: paymentSessionConfig === null || paymentSessionConfig === void 0 ? void 0 : paymentSessionConfig.paymentMethodCategoryType,
121
+ requestSeq: (_this$_renderParams2 = this._renderParams) === null || _this$_renderParams2 === void 0 ? void 0 : _this$_renderParams2.sessionData,
122
+ trackId: (_this$_renderParams3 = this._renderParams) === null || _this$_renderParams3 === void 0 ? void 0 : _this$_renderParams3.sessionData
123
+ });
124
+ }
125
+
126
+ /**
127
+ * @description Set the rendering capability of the cashier plug-in. Different technology stacks have some differences in the packaging and use of rendering functions
128
+ */
129
+ }, {
130
+ key: "setRender",
131
+ value: function setRender(renderFunc) {
132
+ this.createIframeNode = renderFunc;
133
+ }
134
+ }, {
135
+ key: "setPreloadRender",
136
+ value: function setPreloadRender(renderFunc) {
137
+ this.createPreloadIframeNode = renderFunc;
138
+ }
139
+ }, {
140
+ key: "initSecurity",
141
+ value: function initSecurity() {
142
+ var _this$_renderParams4,
143
+ _this = this;
144
+ var product = (_this$_renderParams4 = this._renderParams) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionMetaData) === null || _this$_renderParams4 === void 0 || (_this$_renderParams4 = _this$_renderParams4.paymentSessionConfig) === null || _this$_renderParams4 === void 0 ? void 0 : _this$_renderParams4.productScene;
145
+ if (ComponentSignEnum.CASHIER_PAYMENT_APM === this._componentSign) return;
146
+ if (ComponentSignEnum.CASHIER_PAYMENT_BANK === this._componentSign) {
147
+ this.AMSSDK.logger.logInfo({
148
+ title: 'sdk_event_security_unneeded_scenarios'
149
+ }, {
150
+ product: product
151
+ });
152
+ }
153
+ var securitySDK = this.AMSSDK._getSecuritySDKByProductScene({
154
+ product: product
155
+ });
156
+ if (!securitySDK) {
157
+ this.AMSSDK.logger.logInfo({
158
+ title: 'sdk_event_securitySdkInit'
159
+ });
160
+ this.AMSSDK._newSecuritySDKByScene({
161
+ product: product
162
+ }, function () {
163
+ _this.AMSSDK.logger.logInfo({
164
+ title: 'sdk_event_securitySdkInitSuccess'
165
+ });
166
+ }, function () {
167
+ _this.AMSSDK.logger.logError({
168
+ title: 'sdk_error_securitySdkInitFailed'
169
+ }, {
170
+ sign: 'SDK internal initialization'
171
+ });
172
+ });
173
+ }
174
+ }
175
+ }, {
176
+ key: "logDeviceId",
177
+ value: function logDeviceId(deviceId, getDeviceIdStartTime) {
178
+ var time = "".concat(Date.now() - getDeviceIdStartTime);
179
+ if (deviceId) {
180
+ this.AMSSDK.logger.logInfo({
181
+ title: 'sdk_event_securitySdkGetTokenSuccess'
182
+ }, {
183
+ deviceId: deviceId,
184
+ time: time
185
+ }).send();
186
+ } else {
187
+ this.AMSSDK.logger.logInfo({
188
+ title: 'sdk_error_securitySdkGetTokenFailed'
189
+ }, {
190
+ deviceId: deviceId,
191
+ time: time
192
+ }).send();
193
+ }
194
+ }
195
+ }, {
196
+ key: "getDeviceIdAndLog",
197
+ value: function getDeviceIdAndLog() {
198
+ var _this2 = this;
199
+ var deviceIdParameter = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
200
+ var isPolling = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
201
+ return new Promise(function (resolve) {
202
+ // To avoid rendering being blocked, move the logic to the next event loop for processing
203
+ setTimeout( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
204
+ var _this2$_renderParams;
205
+ var productScene, getDeviceIdStartTime, securitySDK, deviceId;
206
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
207
+ while (1) switch (_context.prev = _context.next) {
208
+ case 0:
209
+ productScene = (_this2$_renderParams = _this2._renderParams) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionMetaData) === null || _this2$_renderParams === void 0 || (_this2$_renderParams = _this2$_renderParams.paymentSessionConfig) === null || _this2$_renderParams === void 0 ? void 0 : _this2$_renderParams.productScene;
210
+ getDeviceIdStartTime = Date.now();
211
+ securitySDK = _this2.AMSSDK._getSecuritySDKByProductScene({
212
+ product: (deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.productScene) || productScene
213
+ });
214
+ deviceId = '';
215
+ if (!securitySDK) {
216
+ _context.next = 16;
217
+ break;
218
+ }
219
+ if (!(isPolling && parseInt(deviceIdParameter === null || deviceIdParameter === void 0 ? void 0 : deviceIdParameter.tokenCollectTime) > 0)) {
220
+ _context.next = 11;
221
+ break;
222
+ }
223
+ _context.next = 8;
224
+ return securitySDK.pollingGetApdidToken(deviceIdParameter);
225
+ case 8:
226
+ _context.t0 = _context.sent;
227
+ _context.next = 14;
228
+ break;
229
+ case 11:
230
+ _context.next = 13;
231
+ return securitySDK.getApdidToken();
232
+ case 13:
233
+ _context.t0 = _context.sent;
234
+ case 14:
235
+ deviceId = _context.t0;
236
+ _this2.logDeviceId(deviceId, getDeviceIdStartTime);
237
+ case 16:
238
+ resolve(deviceId);
239
+ case 17:
240
+ case "end":
241
+ return _context.stop();
242
+ }
243
+ }, _callee);
244
+ })), 0);
245
+ });
246
+ }
247
+
248
+ /**
249
+ * @description render iframe content
250
+ */
251
+ }, {
252
+ key: "appendIframeNodes",
253
+ value: function appendIframeNodes(componentSign, renderParams) {
254
+ var _renderParams,
255
+ _this$_renderParams5,
256
+ _this$_renderParams6,
257
+ _this$_renderParams7,
258
+ _this$_renderParams8,
259
+ _this3 = this;
260
+ if (this._isInitComponent) {
261
+ this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
262
+ return Promise.reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.SINGLETON_COMPONENT_ERROR);
263
+ }
264
+ renderParams = this.setParameterDefaultValues(componentSign, renderParams);
265
+ this._merchantAppointParam = renderParams.merchantAppointParam;
266
+ this._isInitComponent = true;
267
+ this._renderParams = renderParams;
268
+ this._componentSign = componentSign;
269
+ if ((_renderParams = renderParams) !== null && _renderParams !== void 0 && _renderParams.selector) this._selector = renderParams.selector;
270
+ this._renderDisplayType = renderParams.renderDisplayType;
271
+ // connect element模式会存在加载多个sdk,appendAliasContainerId为true来判断,给容器inlineId添加标识,id中不能存在#需在这里提前过滤一下
272
+ var _selector = this._selector.indexOf('#') === -1 ? this._selector : this._selector.slice(1);
273
+ // 修改需当前文件搜索,这段注释appendAliasContainerId
274
+ var appendAliasContainerId = renderParams.appendAliasContainerId ? "-".concat(_selector) : '';
275
+ var inlineId = "".concat(COMPONENT_CONTAINER_ID).concat(appendAliasContainerId);
276
+ var insertedNode = this._renderDisplayType === DisplayTypeEnum.inline ? "#".concat(inlineId) : this._selector;
277
+ this._isAppWebview = renderParams.isAppWebview;
278
+ this.initLoggerMeta();
279
+ this.initSecurity();
280
+ this._performanceData.push({
281
+ key: 'sdk_create_component',
282
+ value: Date.now()
283
+ });
284
+ var params = {
285
+ paymentSessionData: this._renderParams && ((_this$_renderParams5 = this._renderParams) === null || _this$_renderParams5 === void 0 ? void 0 : _this$_renderParams5.sessionData) || '',
286
+ paymentSessionConfig: (_this$_renderParams6 = this._renderParams) === null || _this$_renderParams6 === void 0 || (_this$_renderParams6 = _this$_renderParams6.paymentSessionMetaData) === null || _this$_renderParams6 === void 0 ? void 0 : _this$_renderParams6.paymentSessionConfig
287
+ };
288
+ var _ref2 = params.paymentSessionConfig || {},
289
+ _ref2$productSceneVer = _ref2.productSceneVersion,
290
+ productSceneVersion = _ref2$productSceneVer === void 0 ? '' : _ref2$productSceneVer,
291
+ _ref2$productScene = _ref2.productScene,
292
+ productScene = _ref2$productScene === void 0 ? '' : _ref2$productScene;
293
+ var _ref3 = ((_this$_renderParams7 = this._renderParams) === null || _this$_renderParams7 === void 0 ? void 0 : _this$_renderParams7.paymentSessionMetaData) || {},
294
+ _ref3$action = _ref3.action,
295
+ _ref3$action2 = _ref3$action === void 0 ? {} : _ref3$action,
296
+ _ref3$action2$autoDeb = _ref3$action2.autoDebitWithToken,
297
+ autoDebitWithToken = _ref3$action2$autoDeb === void 0 ? false : _ref3$action2$autoDeb,
298
+ _ref3$action2$require = _ref3$action2.requireFastSdk,
299
+ requireFastSdk = _ref3$action2$require === void 0 ? false : _ref3$action2$require;
300
+ var _ref4 = ((_this$_renderParams8 = this._renderParams) === null || _this$_renderParams8 === void 0 ? void 0 : _this$_renderParams8.paymentSessionMetaData) || {},
301
+ _ref4$authUrlInfo = _ref4.authUrlInfo,
302
+ authUrlInfo = _ref4$authUrlInfo === void 0 ? {} : _ref4$authUrlInfo;
303
+ this.AMSSDK.logger.logInfo({
304
+ title: 'sdk_event_createComponent'
305
+ }, {
306
+ version: productSceneVersion,
307
+ product: this.AMSSDK.options.product
308
+ }).send();
309
+ if (ComponentSignEnum.EASY_PAY_WALLET === this._componentSign) {
310
+ if (productScene === ProductSceneEnum.EASY_PAY && productSceneVersion === '1.0' && !autoDebitWithToken && requireFastSdk) {
311
+ // EASY_PAY 1.0首次支付,requireFastSdk为true,不需要接口请求
312
+ this.handleAuthUrlInfo(authUrlInfo);
313
+ return;
314
+ }
315
+ }
316
+ if (ComponentSignEnum.AUTO_DEBIT_WALLET === this._componentSign) {
317
+ var _this$_renderParams9, _action$web, _action$wap;
318
+ var action = ((_this$_renderParams9 = this._renderParams) === null || _this$_renderParams9 === void 0 || (_this$_renderParams9 = _this$_renderParams9.paymentSessionMetaData) === null || _this$_renderParams9 === void 0 ? void 0 : _this$_renderParams9.action) || {};
319
+ var signType = isPC() ? action === null || action === void 0 || (_action$web = action.web) === null || _action$web === void 0 ? void 0 : _action$web.signType : action === null || action === void 0 || (_action$wap = action.wap) === null || _action$wap === void 0 ? void 0 : _action$wap.signType;
320
+ var _requireFastSdk = (action === null || action === void 0 ? void 0 : action.requireFastSdk) || false;
321
+ if (signType === 'REDIRECT' && _requireFastSdk === true) {
322
+ // REDIRECT,requireFastSdk为true,不需要接口请求
323
+ this.handleAuthUrlInfo(authUrlInfo);
324
+ return;
325
+ }
326
+ }
327
+ if (ComponentSignEnum.AUTO_DEBIT_PAY_WALLET === this._componentSign) {
328
+ if (requireFastSdk === true && productSceneVersion === '1.0') {
329
+ // REDIRECT,requireFastSdk为true,不需要接口请求
330
+ this.handleAuthUrlInfo(authUrlInfo);
331
+ return;
332
+ } else {
333
+ return Promise.reject({
334
+ code: ERRORMESSAGE.CREATEPAYMENT_PARAMETER_ERROR.code,
335
+ message: "Abnormal response data, interface failure, or unsupported payment method."
336
+ });
337
+ }
338
+ }
339
+ this.dispatchToSDK(EVENT.eventCallback.name, {
340
+ code: eventCodeEnum.SDK_START_OF_LOADING
341
+ });
342
+ if (this._renderDisplayType === DisplayTypeEnum.inline) {
343
+ var container = createInlineBaseElement(this._selector, COMPONENT_CONTAINER_ID, inlineId);
344
+ if (container) this.renderInlineLoading(renderParams, container);
345
+ insertStyleSheet();
346
+ }
347
+ if (this._renderDisplayType === DisplayTypeEnum.popup) {
348
+ var _this$_renderParams10;
349
+ createBaseElement(this.platform, this.closeBtnFunc.bind(this));
350
+ createRetentionPopup(this.platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
351
+ var channelBehavior = getChannelBehavior((_this$_renderParams10 = this._renderParams) === null || _this$_renderParams10 === void 0 ? void 0 : _this$_renderParams10.paymentSessionMetaData);
352
+ var onClickOutside = function onClickOutside() {};
353
+ if (channelBehavior !== null && channelBehavior !== void 0 && channelBehavior.allowClickOutsideClose) {
354
+ onClickOutside = this.closeBtnFunc.bind(this);
355
+ }
356
+ createMockup({
357
+ platform: this.platform,
358
+ onClickOutside: onClickOutside
359
+ });
360
+ this.renderPopupLoading(renderParams);
361
+ }
362
+ this.createApp(renderParams);
363
+ return Promise.all([this.createActionQueryPromise(), this.createSubmitPromise(), this.createIframeNode(this, insertedNode, this._renderDisplayType), this._createLoadAppPromise()]).then(function () {
364
+ return Promise.resolve();
365
+ }).catch(function (error) {
366
+ _this3.AMSSDK.logger.logError({
367
+ title: 'sdk_error_created_app_process_failed'
368
+ }).send();
369
+ _this3._isInitComponent = false;
370
+ _this3.cleanContainer();
371
+ return Promise.reject(error);
372
+ });
373
+ }
374
+ }, {
375
+ key: "appendPreloadIframeNodes",
376
+ value: function appendPreloadIframeNodes(componentSign, productSceneVersion) {
377
+ var virtualPreloadIframe = this.createPreloadApp(componentSign, productSceneVersion);
378
+ this.createPreloadIframeNode(virtualPreloadIframe);
379
+ this.AMSSDK.logger.logInfo({
380
+ title: 'performance_optimization_preload'
381
+ }, {
382
+ componentSign: componentSign,
383
+ productSceneVersion: productSceneVersion
384
+ });
385
+ }
386
+ }, {
387
+ key: "setParameterDefaultValues",
388
+ value: function setParameterDefaultValues(componentSign, renderParams) {
389
+ var newParams = Object.assign({}, renderParams);
390
+ if (componentSign === ComponentSignEnum.VAULTING_CARD) {
391
+ var _newParams$notRedirec;
392
+ newParams.notRedirectAfterComplete = (_newParams$notRedirec = newParams === null || newParams === void 0 ? void 0 : newParams.notRedirectAfterComplete) !== null && _newParams$notRedirec !== void 0 ? _newParams$notRedirec : true;
393
+ }
394
+ return newParams;
395
+ }
396
+ }, {
397
+ key: "renderInlineLoading",
398
+ value: function renderInlineLoading(renderParams, selector) {
399
+ var _renderParams$appeara, _this$_renderParams11;
400
+ var showLoading = renderParams === null || renderParams === void 0 || (_renderParams$appeara = renderParams.appearance) === null || _renderParams$appeara === void 0 ? void 0 : _renderParams$appeara.showLoading;
401
+ showLoading = typeof showLoading === 'boolean' ? showLoading : true;
402
+ var extendInfo = renderParams.paymentSessionMetaData.extendInfo;
403
+ var isExpressCheckout = false;
404
+ try {
405
+ // expressCheckout可能出现string(false) JSON.parse再转一次
406
+ isExpressCheckout = JSON.parse(JSON.parse(extendInfo).expressCheckout);
407
+ } catch (error) {
408
+ // 遇到JSON解析错误,默认false
409
+ }
410
+ if (showLoading) addInlineLoading(selector, this.platform, {
411
+ componentSign: this._componentSign,
412
+ type: (_this$_renderParams11 = this._renderParams) === null || _this$_renderParams11 === void 0 || (_this$_renderParams11 = _this$_renderParams11.appearance) === null || _this$_renderParams11 === void 0 || (_this$_renderParams11 = _this$_renderParams11.layout) === null || _this$_renderParams11 === void 0 ? void 0 : _this$_renderParams11.type,
413
+ isExpressCheckout: isExpressCheckout
414
+ });
415
+ }
416
+ }, {
417
+ key: "renderPopupLoading",
418
+ value: function renderPopupLoading(renderParams) {
419
+ var _renderParams$appeara2;
420
+ var showLoading = renderParams === null || renderParams === void 0 || (_renderParams$appeara2 = renderParams.appearance) === null || _renderParams$appeara2 === void 0 ? void 0 : _renderParams$appeara2.showLoading;
421
+ showLoading = typeof showLoading === 'boolean' ? showLoading : true;
422
+ if (!showLoading) return;
423
+ var mockup = document.getElementById(MOCKUP_ID);
424
+ if (mockup) mockup.style.display = 'block';
425
+ addPopupLoading();
426
+ }
427
+ }, {
428
+ key: "_createLoadAppPromise",
429
+ value: function _createLoadAppPromise(loadTimeLimit) {
430
+ var _this4 = this;
431
+ return new Promise(function (resolve, reject) {
432
+ _this4._loadAppPromiseResolve = resolve;
433
+ setTimeout(function () {
434
+ reject(ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
435
+ }, loadTimeLimit !== null && loadTimeLimit !== void 0 ? loadTimeLimit : LOADTIME_LIMIT);
436
+ }).catch(function (error) {
437
+ _this4.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
438
+ _this4.AMSSDK.logger.logError({
439
+ title: 'sdk_error_web_app_timeout'
440
+ }).send();
441
+ return Promise.reject(error);
442
+ });
443
+ }
444
+
445
+ /**
446
+ * @description Interface request
447
+ */
448
+ }, {
449
+ key: "createActionQueryPromise",
450
+ value: function createActionQueryPromise() {
451
+ var _this5 = this;
452
+ this._performanceData.push({
453
+ key: 'sdk_action_query_start',
454
+ value: Date.now()
455
+ });
456
+ // eslint-disable-next-line no-async-promise-executor
457
+ this._actionQueryPromise = new Promise( /*#__PURE__*/function () {
458
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(resolve, reject) {
459
+ var _this5$_renderParams, _this5$_renderParams2, _this5$_renderParams3, _this5$_renderParams4, _this5$_renderParams5, _this5$_renderParams6, _this5$_renderParams7;
460
+ var envInfo, params, _ref6, _ref6$extendInfo, extendInfo, actionData, enableVaultingApiOptimize, enableEasypayApiOptimize, _ref7, skipSdkQuery, skipSdkQueryForm, extendInfoData, ifSkip, channelBehavior, _this5$_renderParams8, _this5$_renderParams9, _ref8, _ref8$productSceneVer, productSceneVersion, _ref8$productScene, productScene, _ref9, _ref9$action, _ref9$action2, _ref9$action2$autoDeb, autoDebitWithToken, _this5$_renderParams10, _action$web2, _action$wap2, action, signType;
461
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
462
+ while (1) switch (_context2.prev = _context2.next) {
463
+ case 0:
464
+ envInfo = {
465
+ locale: _this5.AMSSDK.options.locale
466
+ };
467
+ params = {
468
+ paymentSessionData: _this5._renderParams && ((_this5$_renderParams = _this5._renderParams) === null || _this5$_renderParams === void 0 ? void 0 : _this5$_renderParams.sessionData) || '',
469
+ paymentSessionConfig: (_this5$_renderParams2 = _this5._renderParams) === null || _this5$_renderParams2 === void 0 || (_this5$_renderParams2 = _this5$_renderParams2.paymentSessionMetaData) === null || _this5$_renderParams2 === void 0 ? void 0 : _this5$_renderParams2.paymentSessionConfig,
470
+ notRedirectAfterComplete: ((_this5$_renderParams3 = _this5._renderParams) === null || _this5$_renderParams3 === void 0 ? void 0 : _this5$_renderParams3.notRedirectAfterComplete) === true,
471
+ merchantAppointParam: _this5._merchantAppointParam
472
+ };
473
+ /**
474
+ * @description Simulated or unnecessary scenarios
475
+ */
476
+ _ref6 = ((_this5$_renderParams4 = _this5._renderParams) === null || _this5$_renderParams4 === void 0 ? void 0 : _this5$_renderParams4.paymentSessionMetaData) || {}, _ref6$extendInfo = _ref6.extendInfo, extendInfo = _ref6$extendInfo === void 0 ? '' : _ref6$extendInfo, actionData = _ref6.action;
477
+ enableVaultingApiOptimize = false;
478
+ enableEasypayApiOptimize = false;
479
+ _ref7 = ((_this5$_renderParams5 = _this5._renderParams) === null || _this5$_renderParams5 === void 0 || (_this5$_renderParams5 = _this5$_renderParams5.paymentSessionMetaData) === null || _this5$_renderParams5 === void 0 ? void 0 : _this5$_renderParams5.action) || {}, skipSdkQuery = _ref7.skipSdkQuery, skipSdkQueryForm = _ref7.skipSdkQueryForm;
480
+ try {
481
+ extendInfoData = JSON.parse(extendInfo);
482
+ enableVaultingApiOptimize = extendInfoData.enableVaultingApiOptimize || false;
483
+ enableEasypayApiOptimize = extendInfoData.enableEasypayApiOptimize || false;
484
+ } catch (error) {
485
+ console.log(error);
486
+ }
487
+ if (!isLocalMock()) {
488
+ _context2.next = 9;
489
+ break;
490
+ }
491
+ return _context2.abrupt("return", resolve({
492
+ message: 'sdk no need to make query request',
493
+ success: true
494
+ }));
495
+ case 9:
496
+ if (ComponentSignEnum.ELEMENT_PAYMENT === _this5._componentSign) {
497
+ params.paymentSessionConfig = handlePaymentSessionConfig(params.paymentSessionConfig);
498
+ }
499
+ if (!(ComponentSignEnum.ELEMENT_PAYMENT === _this5._componentSign && _this5 !== null && _this5 !== void 0 && (_this5$_renderParams6 = _this5._renderParams) !== null && _this5$_renderParams6 !== void 0 && (_this5$_renderParams6 = _this5$_renderParams6.paymentSessionMetaData) !== null && _this5$_renderParams6 !== void 0 && (_this5$_renderParams6 = _this5$_renderParams6.connectFactor) !== null && _this5$_renderParams6 !== void 0 && _this5$_renderParams6.enableConnect)) {
500
+ _context2.next = 12;
501
+ break;
502
+ }
503
+ return _context2.abrupt("return", resolve({
504
+ message: 'sdk no need to make query request',
505
+ success: true
506
+ }));
507
+ case 12:
508
+ if (!(ComponentSignEnum.ELEMENT_ADDRESS === _this5._componentSign)) {
509
+ _context2.next = 14;
510
+ break;
511
+ }
512
+ return _context2.abrupt("return", resolve({
513
+ message: 'sdk no need to make query request',
514
+ success: true
515
+ }));
516
+ case 14:
517
+ if (!(ComponentSignEnum.VAULTING_CARD === _this5._componentSign)) {
518
+ _context2.next = 26;
519
+ break;
520
+ }
521
+ if (!enableVaultingApiOptimize) {
522
+ _context2.next = 26;
523
+ break;
524
+ }
525
+ if (!skipSdkQueryForm) {
526
+ _context2.next = 23;
527
+ break;
528
+ }
529
+ // 优先判断 skipSdkQueryForm
530
+ ifSkip = matchVersion(skipSdkQueryForm, _this5._appVersion);
531
+ if (!ifSkip) {
532
+ _context2.next = 21;
533
+ break;
534
+ }
535
+ resolve({
536
+ message: 'sdk no need to make query request',
537
+ success: true
538
+ });
539
+ return _context2.abrupt("return");
540
+ case 21:
541
+ _context2.next = 26;
542
+ break;
543
+ case 23:
544
+ if (!skipSdkQuery) {
545
+ _context2.next = 26;
546
+ break;
547
+ }
548
+ resolve({
549
+ message: 'sdk no need to make query request',
550
+ success: true
551
+ });
552
+ return _context2.abrupt("return");
553
+ case 26:
554
+ channelBehavior = getChannelBehavior((_this5$_renderParams7 = _this5._renderParams) === null || _this5$_renderParams7 === void 0 ? void 0 : _this5$_renderParams7.paymentSessionMetaData); // Easypay TOSS 渠道无需actionQuery
555
+ if (!(channelBehavior !== null && channelBehavior !== void 0 && channelBehavior.usePaymentSessionAsQueryResult)) {
556
+ _context2.next = 29;
557
+ break;
558
+ }
559
+ return _context2.abrupt("return", resolve({
560
+ autoDebitWithToken: actionData === null || actionData === void 0 ? void 0 : actionData.autoDebitWithToken,
561
+ amountConfirmRequired: actionData === null || actionData === void 0 ? void 0 : actionData.amountConfirmRequired,
562
+ success: true
563
+ }));
564
+ case 29:
565
+ if (!(ComponentSignEnum.CASHIER_PAYMENT_CARD === _this5._componentSign || ComponentSignEnum.VAULTING_CARD === _this5._componentSign)) {
566
+ _context2.next = 35;
567
+ break;
568
+ }
569
+ params.paymentMethodType = 'CARD';
570
+ _context2.next = 33;
571
+ return _this5.getDeviceIdAndLog();
572
+ case 33:
573
+ envInfo.deviceId = _context2.sent;
574
+ if (window.navigator.userAgent.indexOf('miniProgram') > -1) {
575
+ envInfo.extendInfo = {
576
+ WAP_SUB_TYPE: 'WECHAT_MINI_PROGRAM'
577
+ };
578
+ }
579
+ case 35:
580
+ if (!(ComponentSignEnum.EASY_PAY_WALLET === _this5._componentSign)) {
581
+ _context2.next = 45;
582
+ break;
583
+ }
584
+ _ref8 = params.paymentSessionConfig || {}, _ref8$productSceneVer = _ref8.productSceneVersion, productSceneVersion = _ref8$productSceneVer === void 0 ? '' : _ref8$productSceneVer, _ref8$productScene = _ref8.productScene, productScene = _ref8$productScene === void 0 ? '' : _ref8$productScene;
585
+ _ref9 = ((_this5$_renderParams8 = _this5._renderParams) === null || _this5$_renderParams8 === void 0 ? void 0 : _this5$_renderParams8.paymentSessionMetaData) || {}, _ref9$action = _ref9.action, _ref9$action2 = _ref9$action === void 0 ? {} : _ref9$action, _ref9$action2$autoDeb = _ref9$action2.autoDebitWithToken, autoDebitWithToken = _ref9$action2$autoDeb === void 0 ? false : _ref9$action2$autoDeb;
586
+ if (!((_this5$_renderParams9 = _this5._renderParams) !== null && _this5$_renderParams9 !== void 0 && (_this5$_renderParams9 = _this5$_renderParams9.paymentSessionMetaData) !== null && _this5$_renderParams9 !== void 0 && (_this5$_renderParams9 = _this5$_renderParams9.action) !== null && _this5$_renderParams9 !== void 0 && _this5$_renderParams9.skipSdkQuery && enableEasypayApiOptimize)) {
587
+ _context2.next = 40;
588
+ break;
589
+ }
590
+ return _context2.abrupt("return", resolve({
591
+ message: 'sdk no need to make query request',
592
+ success: true
593
+ }));
594
+ case 40:
595
+ if (!(productScene === ProductSceneEnum.EASY_PAY && productSceneVersion === '2.0')) {
596
+ _context2.next = 42;
597
+ break;
598
+ }
599
+ return _context2.abrupt("return", resolve({
600
+ message: 'sdk no need to make query request',
601
+ success: true
602
+ }));
603
+ case 42:
604
+ _context2.next = 44;
605
+ return _this5.getDeviceIdAndLog();
606
+ case 44:
607
+ envInfo.deviceId = _context2.sent;
608
+ case 45:
609
+ if (!(ComponentSignEnum.AUTO_DEBIT_WALLET === _this5._componentSign)) {
610
+ _context2.next = 55;
611
+ break;
612
+ }
613
+ action = ((_this5$_renderParams10 = _this5._renderParams) === null || _this5$_renderParams10 === void 0 || (_this5$_renderParams10 = _this5$_renderParams10.paymentSessionMetaData) === null || _this5$_renderParams10 === void 0 ? void 0 : _this5$_renderParams10.action) || {};
614
+ signType = isPC() ? action === null || action === void 0 || (_action$web2 = action.web) === null || _action$web2 === void 0 ? void 0 : _action$web2.signType : action === null || action === void 0 || (_action$wap2 = action.wap) === null || _action$wap2 === void 0 ? void 0 : _action$wap2.signType;
615
+ if (!(signType === 'SMS')) {
616
+ _context2.next = 50;
617
+ break;
618
+ }
619
+ return _context2.abrupt("return", resolve({
620
+ message: 'sdk no need to make query request',
621
+ success: true
622
+ }));
623
+ case 50:
624
+ if (!(!signType || signType !== 'REDIRECT')) {
625
+ _context2.next = 52;
626
+ break;
627
+ }
628
+ return _context2.abrupt("return", resolve({
629
+ success: false
630
+ }));
631
+ case 52:
632
+ _context2.next = 54;
633
+ return _this5.getDeviceIdAndLog();
634
+ case 54:
635
+ envInfo.deviceId = _context2.sent;
636
+ case 55:
637
+ _this5.AMSSDK.logger.logInfo({
638
+ title: 'sdk_event_sdkQuery'
639
+ }, {
640
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
641
+ requestBody: params
642
+ }).send();
643
+ queryPaymentInfo(params, {
644
+ env: _this5.AMSSDK.options.env.environment,
645
+ envInfo: envInfo
646
+ }, _this5.AMSSDK.logger).then(function (res) {
647
+ _this5._performanceData.push({
648
+ key: 'sdk_action_query_end',
649
+ value: Date.now()
650
+ });
651
+ resolve(res);
652
+ _this5.AMSSDK.logger.logInfo({
653
+ title: 'sdk_event_sdkQueryEnd'
654
+ }, {
655
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
656
+ responseBody: res
657
+ }).send();
658
+ }).catch(function (err) {
659
+ if ([ComponentSignEnum.CASHIER_PAYMENT_CARD, ComponentSignEnum.VAULTING_CARD, ComponentSignEnum.CASHIER_PAYMENT_APM].includes(_this5._componentSign)) {
660
+ return resolve({
661
+ success: false
662
+ });
663
+ }
664
+ _this5.dispatchToSDK(EVENT.error.name, {
665
+ code: ERRORMESSAGE.CREATECOMPONENT_ERROR.code
666
+ });
667
+ _this5.AMSSDK.logger.logError({
668
+ title: 'sdk_event_sdkQuery_failed'
669
+ }, {
670
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
671
+ errorReason: err
672
+ }).send();
673
+ reject(err);
674
+ });
675
+ case 57:
676
+ case "end":
677
+ return _context2.stop();
678
+ }
679
+ }, _callee2);
680
+ }));
681
+ return function (_x, _x2) {
682
+ return _ref5.apply(this, arguments);
683
+ };
684
+ }());
685
+ return this._actionQueryPromise;
686
+ }
687
+
688
+ // private create
689
+ }, {
690
+ key: "createSubmitPromise",
691
+ value: function createSubmitPromise() {
692
+ var _this$_renderParams12,
693
+ _this$_renderParams13,
694
+ _this$_renderParams14,
695
+ _this6 = this;
696
+ this._performanceData.push({
697
+ key: 'sdk_submit_start',
698
+ value: Date.now()
699
+ });
700
+ var params = {
701
+ paymentSessionData: this._renderParams && ((_this$_renderParams12 = this._renderParams) === null || _this$_renderParams12 === void 0 ? void 0 : _this$_renderParams12.sessionData) || '',
702
+ paymentSessionConfig: (_this$_renderParams13 = this._renderParams) === null || _this$_renderParams13 === void 0 || (_this$_renderParams13 = _this$_renderParams13.paymentSessionMetaData) === null || _this$_renderParams13 === void 0 ? void 0 : _this$_renderParams13.paymentSessionConfig
703
+ };
704
+ var channelBehavior = getChannelBehavior((_this$_renderParams14 = this._renderParams) === null || _this$_renderParams14 === void 0 ? void 0 : _this$_renderParams14.paymentSessionMetaData);
705
+ // eslint-disable-next-line no-async-promise-executor
706
+ this._actionSubmitPromise = new Promise( /*#__PURE__*/function () {
707
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(resolve) {
708
+ var _channelBehavior$buil, _this6$_renderParams$;
709
+ var shouldSkipSubmitPayInSDK, _this6$_renderParams, _this6$_renderParams2, _this6$_renderParams3, _ref11, _ref11$productSceneVe, productSceneVersion, _ref11$productScene, productScene, _ref12, _ref12$action, _ref12$action2, _ref12$action2$enable, enableSignAgreement, _ref12$action2$autoDe, autoDebitWithToken, _ref13, _ref13$paymentMethodI, _ref13$paymentMethodI2, _ref13$paymentMethodI3, paymentMethodType, isAppWebview, backScheme, extParams;
710
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
711
+ while (1) switch (_context3.prev = _context3.next) {
712
+ case 0:
713
+ if (!(_this6.AMSSDK.options.product === ProductSceneEnum.ELEMENT_ADDRESS)) {
714
+ _context3.next = 2;
715
+ break;
716
+ }
717
+ return _context3.abrupt("return", resolve({
718
+ message: 'sdk no need to make submitPay request',
719
+ success: true
720
+ }));
721
+ case 2:
722
+ shouldSkipSubmitPayInSDK = false;
723
+ if (channelBehavior) {
724
+ // 新逻辑走 channelBehavior判断
725
+ shouldSkipSubmitPayInSDK = !channelBehavior.submitPayInSdk;
726
+ } else {
727
+ shouldSkipSubmitPayInSDK = !((_this6$_renderParams = _this6._renderParams) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.paymentSessionMetaData) !== null && _this6$_renderParams !== void 0 && (_this6$_renderParams = _this6$_renderParams.action) !== null && _this6$_renderParams !== void 0 && _this6$_renderParams.skipSdkQuery) || ComponentSignEnum.EASY_PAY_WALLET !== _this6._componentSign;
728
+ }
729
+ if (ComponentSignEnum.EASY_PAY_WALLET === _this6._componentSign) {
730
+ _ref11 = params.paymentSessionConfig || {}, _ref11$productSceneVe = _ref11.productSceneVersion, productSceneVersion = _ref11$productSceneVe === void 0 ? '' : _ref11$productSceneVe, _ref11$productScene = _ref11.productScene, productScene = _ref11$productScene === void 0 ? '' : _ref11$productScene;
731
+ _ref12 = ((_this6$_renderParams2 = _this6._renderParams) === null || _this6$_renderParams2 === void 0 ? void 0 : _this6$_renderParams2.paymentSessionMetaData) || {}, _ref12$action = _ref12.action, _ref12$action2 = _ref12$action === void 0 ? {} : _ref12$action, _ref12$action2$enable = _ref12$action2.enableSignAgreement, enableSignAgreement = _ref12$action2$enable === void 0 ? false : _ref12$action2$enable, _ref12$action2$autoDe = _ref12$action2.autoDebitWithToken, autoDebitWithToken = _ref12$action2$autoDe === void 0 ? false : _ref12$action2$autoDe;
732
+ _ref13 = ((_this6$_renderParams3 = _this6._renderParams) === null || _this6$_renderParams3 === void 0 ? void 0 : _this6$_renderParams3.paymentSessionMetaData) || {}, _ref13$paymentMethodI = _ref13.paymentMethodInfoView, _ref13$paymentMethodI2 = _ref13$paymentMethodI === void 0 ? {} : _ref13$paymentMethodI, _ref13$paymentMethodI3 = _ref13$paymentMethodI2.paymentMethodType, paymentMethodType = _ref13$paymentMethodI3 === void 0 ? '' : _ref13$paymentMethodI3;
733
+ if (productScene === ProductSceneEnum.EASY_PAY && productSceneVersion === '2.0' && !autoDebitWithToken) {
734
+ isAppWebview = _this6._isAppWebview || false; ///EasyPay 2.0 首次传signAgreement字段
735
+ params['signAgreement'] = enableSignAgreement;
736
+ if (paymentMethodType == 'ALIPAY_CN' && !isAppWebview) {
737
+ backScheme = getBackScheme(undefined, _this6.AMSSDK.logger);
738
+ if (backScheme && backScheme !== 'https') {
739
+ params['h5FromApp'] = encodeURIComponent(backScheme);
740
+ }
741
+ }
742
+ }
743
+ }
744
+ // 带上标记告知WebCheckOut SDK已发送submitpay请求
745
+ _this6._allowSubmitPayCallAhead = !shouldSkipSubmitPayInSDK;
746
+ if (!shouldSkipSubmitPayInSDK) {
747
+ _context3.next = 8;
748
+ break;
749
+ }
750
+ return _context3.abrupt("return", resolve({
751
+ message: 'sdk no need to make submitPay request',
752
+ success: true
753
+ }));
754
+ case 8:
755
+ _this6.AMSSDK.logger.logInfo({
756
+ title: 'sdk_event_submitPay'
757
+ }, {
758
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
759
+ requestBody: params
760
+ }).send();
761
+ extParams = (channelBehavior === null || channelBehavior === void 0 || (_channelBehavior$buil = channelBehavior.buildSubmitPayExtParams) === null || _channelBehavior$buil === void 0 ? void 0 : _channelBehavior$buil.call(channelBehavior, {
762
+ instanceId: _this6.AMSSDK._instanceId,
763
+ locale: _this6.AMSSDK.options.locale,
764
+ paymentMethodType: (_this6$_renderParams$ = _this6._renderParams.paymentSessionMetaData) === null || _this6$_renderParams$ === void 0 || (_this6$_renderParams$ = _this6$_renderParams$.paymentMethodInfoView) === null || _this6$_renderParams$ === void 0 ? void 0 : _this6$_renderParams$.paymentMethodType,
765
+ paymentSessionData: _this6._renderParams.sessionData,
766
+ env: _this6.AMSSDK.options.env.environment,
767
+ sdkVersion: _this6._appVersion
768
+ })) || {};
769
+ params.extParams = extParams;
770
+ _context3.t0 = submitPayInfo;
771
+ _context3.t1 = params;
772
+ _context3.t2 = _this6.AMSSDK.options.env.environment;
773
+ _context3.next = 16;
774
+ return _this6.getDeviceIdAndLog();
775
+ case 16:
776
+ _context3.t3 = _context3.sent;
777
+ _context3.t4 = {
778
+ deviceId: _context3.t3
779
+ };
780
+ _context3.t5 = {
781
+ env: _context3.t2,
782
+ timeout: 15000,
783
+ envInfo: _context3.t4
784
+ };
785
+ _context3.t6 = _this6.AMSSDK.logger;
786
+ (0, _context3.t0)(_context3.t1, _context3.t5, _context3.t6).then(function (res) {
787
+ _this6._performanceData.push({
788
+ key: 'sdk_submit_end',
789
+ value: Date.now()
790
+ });
791
+ _this6.AMSSDK.logger.logInfo({
792
+ title: 'sdk_event_submitPayEnd'
793
+ }, {
794
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
795
+ responseBody: res
796
+ }).send();
797
+ resolve(res);
798
+ }).catch(function (err) {
799
+ _this6.AMSSDK.logger.logError({
800
+ title: 'sdk_event_submitPay_failed'
801
+ }, {
802
+ paymentSessionConfig: JSON.stringify(params.paymentSessionConfig),
803
+ responseBody: err
804
+ }).send();
805
+ resolve({
806
+ success: false
807
+ });
808
+ });
809
+ case 21:
810
+ case "end":
811
+ return _context3.stop();
812
+ }
813
+ }, _callee3);
814
+ }));
815
+ return function (_x3) {
816
+ return _ref10.apply(this, arguments);
817
+ };
818
+ }());
819
+ }
820
+ }, {
821
+ key: "cleanElement",
822
+ value: function cleanElement() {
823
+ try {
824
+ var _document$getElementB;
825
+ // selector and container
826
+ if (getType(this._selector) === 'string') {
827
+ var selectorDom = document.querySelector(this._selector);
828
+ if (selectorDom) selectorDom.innerHTML = '';
829
+ }
830
+ var container = document.getElementById(COMPONENT_CONTAINER_ID);
831
+ if (container) container === null || container === void 0 || container.remove();
832
+
833
+ // animation
834
+ (_document$getElementB = document.getElementById("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style"))) === null || _document$getElementB === void 0 || _document$getElementB.remove();
835
+
836
+ // mockup
837
+ var body = document.getElementsByTagName('body')[0];
838
+ body.style.overflow = 'auto';
839
+ var mockup = document.getElementById(MOCKUP_ID);
840
+ mockup === null || mockup === void 0 || mockup.remove();
841
+
842
+ // retentionPopup
843
+ this.removeRetentionPopup(this.platform);
844
+
845
+ // listener
846
+ this.removeEventListener();
847
+ } catch (error) {
848
+ console.error(error);
849
+ }
850
+ }
851
+ // 预加载iframe创建
852
+ }, {
853
+ key: "createPreloadApp",
854
+ value: function createPreloadApp(componentSign) {
855
+ var productSceneVersion = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1.0';
856
+ var preloadIframe = createPreloadIframe(componentSign, productSceneVersion);
857
+ var productScene = componentSign.split(/_(?=[^_]*$)/)[0];
858
+ var _getIframeUrl = getIframeUrl({
859
+ renderDisplayType: DisplayTypeEnum.popup,
860
+ componentSign: componentSign,
861
+ analytics: {
862
+ enabled: false
863
+ },
864
+ productScene: productScene,
865
+ productSceneVersion: productSceneVersion,
866
+ environment: this.AMSSDK.options.env.environment,
867
+ appVersion: this._appVersion,
868
+ instanceId: '',
869
+ isPreload: 'true',
870
+ mid: ''
871
+ }),
872
+ path = _getIframeUrl.path,
873
+ locationSearch = _getIframeUrl.locationSearch;
874
+ preloadIframe.src = "".concat(path, "?").concat(locationSearch);
875
+ if (!path) {
876
+ this.AMSSDK.logger.logError({
877
+ title: 'performance_optimization_preload_path_error'
878
+ }, {
879
+ path: path,
880
+ locationSearch: locationSearch
881
+ });
882
+ }
883
+ return preloadIframe;
884
+ }
885
+ /**
886
+ * @description Create app
887
+ */
888
+ }, {
889
+ key: "createApp",
890
+ value: function createApp(renderParams) {
891
+ if (!!window.postMessage !== true) {
892
+ this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.SDK_COMPATIBILITY_ISSUES.BROWSER_NOT_SUPPORT_POSTMESSAGE);
893
+ return;
894
+ }
895
+ this._performanceData.push({
896
+ key: 'sdk_popup_start',
897
+ value: Date.now()
898
+ });
899
+ try {
900
+ var _renderParams$payment, _renderParams$payment2, _renderParams$payment3, _renderParams$payment4, _renderParams$debugPr, _renderParams$debugPr2;
901
+ var productSceneVersion = (renderParams === null || renderParams === void 0 || (_renderParams$payment = renderParams.paymentSessionMetaData) === null || _renderParams$payment === void 0 || (_renderParams$payment = _renderParams$payment.paymentSessionConfig) === null || _renderParams$payment === void 0 ? void 0 : _renderParams$payment.productSceneVersion) || '';
902
+ var productScene = (renderParams === null || renderParams === void 0 || (_renderParams$payment2 = renderParams.paymentSessionMetaData) === null || _renderParams$payment2 === void 0 || (_renderParams$payment2 = _renderParams$payment2.paymentSessionConfig) === null || _renderParams$payment2 === void 0 ? void 0 : _renderParams$payment2.productScene) || '';
903
+ var extendInfo = (renderParams === null || renderParams === void 0 || (_renderParams$payment3 = renderParams.paymentSessionMetaData) === null || _renderParams$payment3 === void 0 ? void 0 : _renderParams$payment3.extendInfo) || '';
904
+ var mid = renderParams === null || renderParams === void 0 || (_renderParams$payment4 = renderParams.paymentSessionMetaData) === null || _renderParams$payment4 === void 0 ? void 0 : _renderParams$payment4.clientId;
905
+ var environment = this.AMSSDK.options.env.environment;
906
+ this.appDomain = getAppDomain({
907
+ environment: environment,
908
+ appVersion: this._appVersion,
909
+ componentSign: this._componentSign,
910
+ productScene: productScene,
911
+ productSceneVersion: productSceneVersion,
912
+ extendInfo: extendInfo,
913
+ mid: mid,
914
+ localLink: renderParams === null || renderParams === void 0 || (_renderParams$debugPr = renderParams.debugProps) === null || _renderParams$debugPr === void 0 ? void 0 : _renderParams$debugPr.localLink // TODO Connect本地调试link
915
+ });
916
+ this.app = createIframe(this.AMSSDK.options.mode, this.platform);
917
+ var hostSign = ((renderParams === null || renderParams === void 0 ? void 0 : renderParams.sessionData) || '').split('&&')[1] || '';
918
+ var _getIframeUrl2 = getIframeUrl({
919
+ renderDisplayType: renderParams.renderDisplayType,
920
+ componentSign: this._componentSign,
921
+ analytics: this.AMSSDK.options.analytics,
922
+ productScene: productScene,
923
+ productSceneVersion: productSceneVersion,
924
+ environment: environment,
925
+ appVersion: this._appVersion,
926
+ extendInfo: extendInfo,
927
+ locale: this.AMSSDK.options.locale,
928
+ instanceId: this.AMSSDK._instanceId,
929
+ hostSign: hostSign,
930
+ mid: mid,
931
+ localLink: renderParams === null || renderParams === void 0 || (_renderParams$debugPr2 = renderParams.debugProps) === null || _renderParams$debugPr2 === void 0 ? void 0 : _renderParams$debugPr2.localLink // TODO Connect本地调试link
932
+ }),
933
+ path = _getIframeUrl2.path,
934
+ locationSearch = _getIframeUrl2.locationSearch;
935
+ this._appLocationSearch = locationSearch;
936
+ // locationSearch 是一个序列化好的字符串
937
+ // 先判断path 是否有QueryParams,如果有需要扩展,否则直接拼?xx=xx
938
+ if (path.indexOf('?') !== -1) {
939
+ this.app.src = "".concat(path, "&").concat(locationSearch);
940
+ } else {
941
+ this.app.src = "".concat(path, "?").concat(locationSearch);
942
+ }
943
+ // Subscribe to messages from iframe
944
+ this.addEventListener();
945
+ } catch (error) {
946
+ this.AMSSDK.logger.logError({
947
+ title: 'sdk_error_created_app_failed'
948
+ }).send();
949
+ this.dispatchToSDK(EVENT.error.name, Object.assign({}, ERRORMESSAGE.SDK_COMPATIBILITY_ISSUES.FAILED_TO_CREATE_IFRAME, {
950
+ stack: error
951
+ }));
952
+ }
953
+ }
954
+ }, {
955
+ key: "listener",
956
+ value: function listener(e) {
957
+ var _e$data;
958
+ if (e.origin !== this.appDomain) return;
959
+ if (((_e$data = e.data) === null || _e$data === void 0 ? void 0 : _e$data.source) === 'react-devtools-content-script') {
960
+ // 防止 react 开发工具发的消息,非常频繁影响查看日志
961
+ return;
962
+ }
963
+ var isJson = isJsonString(e.data);
964
+ if (isJson) {
965
+ var data = JSON.parse(e.data);
966
+ if (data.name !== MessageName.APP_TO_SDK && data.name !== MessageName.APP_TO_APP || data.instanceId !== this.AMSSDK._instanceId) return;
967
+ this._handleAppMessage(data);
968
+ } else {
969
+ console.warn(ERRORMESSAGE.NOT_JSON_FORMAT);
970
+ this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.NOT_JSON_FORMAT);
971
+ }
972
+ }
973
+ }, {
974
+ key: "resizeListener",
975
+ value: function resizeListener(e) {
976
+ var _e$target, _e$target2;
977
+ var cashier = document.getElementById(COMPONENT_CONTAINER_ID);
978
+ cashier.style.transition = 'none';
979
+ this.dispatchToApp({
980
+ context: {
981
+ event: 'renderResize',
982
+ data: {
983
+ heightOfVisible: (e === null || e === void 0 || (_e$target = e.target) === null || _e$target === void 0 ? void 0 : _e$target.innerHeight) || window.innerHeight,
984
+ widthOfVisible: (e === null || e === void 0 || (_e$target2 = e.target) === null || _e$target2 === void 0 ? void 0 : _e$target2.innerWidth) || window.innerWidth
985
+ }
986
+ }
987
+ });
988
+ }
989
+ }, {
990
+ key: "createDialog",
991
+ value: function () {
992
+ var _createDialog = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(data) {
993
+ var pageUrl, _data$device, isLoad, timeout, logTimeout;
994
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
995
+ while (1) switch (_context4.prev = _context4.next) {
996
+ case 0:
997
+ pageUrl = data.url.includes('?') ? "".concat(data.url, "&").concat(this._appLocationSearch) : "".concat(data.url, "?").concat(this._appLocationSearch);
998
+ _context4.prev = 1;
999
+ isLoad = false;
1000
+ _context4.next = 5;
1001
+ return createModal({
1002
+ widthPadding: data === null || data === void 0 ? void 0 : data.widthPadding,
1003
+ device: (_data$device = data === null || data === void 0 ? void 0 : data.device) !== null && _data$device !== void 0 ? _data$device : this.platform,
1004
+ loadingConfig: data === null || data === void 0 ? void 0 : data.loadingConfig,
1005
+ url: pageUrl
1006
+ });
1007
+ case 5:
1008
+ this.popupApp = _context4.sent;
1009
+ timeout = setTimeout(function () {
1010
+ if (isLoad) return;
1011
+ throw {
1012
+ title: 'sdk_error_create_pop_up'
1013
+ };
1014
+ }, LOADTIME_LIMIT);
1015
+ logTimeout = setTimeout(function () {
1016
+ if (isLoad) return;
1017
+ throw {
1018
+ title: 'sdk_error_pop_up_time_out'
1019
+ };
1020
+ }, POPUP_LOADTIME_LOG_LIMIT);
1021
+ this.popupApp.onload = function () {
1022
+ isLoad = true;
1023
+ removePopupLoading();
1024
+ clearTimeout(timeout);
1025
+ clearTimeout(logTimeout);
1026
+ };
1027
+ _context4.next = 15;
1028
+ break;
1029
+ case 11:
1030
+ _context4.prev = 11;
1031
+ _context4.t0 = _context4["catch"](1);
1032
+ this.AMSSDK.logger.logError({
1033
+ title: (_context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.title) || 'sdk_error_create_pop_up'
1034
+ }, {
1035
+ message: _context4.t0 === null || _context4.t0 === void 0 ? void 0 : _context4.t0.message,
1036
+ url: pageUrl
1037
+ });
1038
+ this.dispatchToSDK(EVENT.error.name, ERRORMESSAGE.CREATECOMPONENT_ERROR.LOAD_APP_TIMEOUT);
1039
+ case 15:
1040
+ case "end":
1041
+ return _context4.stop();
1042
+ }
1043
+ }, _callee4, this, [[1, 11]]);
1044
+ }));
1045
+ function createDialog(_x4) {
1046
+ return _createDialog.apply(this, arguments);
1047
+ }
1048
+ return createDialog;
1049
+ }()
1050
+ }, {
1051
+ key: "getDeviceIdAndCallback",
1052
+ value: function () {
1053
+ var _getDeviceIdAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(eventContext) {
1054
+ var deviceId;
1055
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
1056
+ while (1) switch (_context5.prev = _context5.next) {
1057
+ case 0:
1058
+ if (!(eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId)) {
1059
+ _context5.next = 5;
1060
+ break;
1061
+ }
1062
+ _context5.next = 3;
1063
+ return this.getDeviceIdAndLog(eventContext === null || eventContext === void 0 ? void 0 : eventContext.data, true);
1064
+ case 3:
1065
+ deviceId = _context5.sent;
1066
+ this.dispatchToApp({
1067
+ context: {
1068
+ event: 'appEventCallback',
1069
+ eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
1070
+ data: {
1071
+ deviceId: deviceId
1072
+ }
1073
+ }
1074
+ });
1075
+ case 5:
1076
+ case "end":
1077
+ return _context5.stop();
1078
+ }
1079
+ }, _callee5, this);
1080
+ }));
1081
+ function getDeviceIdAndCallback(_x5) {
1082
+ return _getDeviceIdAndCallback.apply(this, arguments);
1083
+ }
1084
+ return getDeviceIdAndCallback;
1085
+ }()
1086
+ }, {
1087
+ key: "getUserAgentAndCallback",
1088
+ value: function () {
1089
+ var _getUserAgentAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee6(eventContext) {
1090
+ return _regeneratorRuntime().wrap(function _callee6$(_context6) {
1091
+ while (1) switch (_context6.prev = _context6.next) {
1092
+ case 0:
1093
+ if (eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId) {
1094
+ try {
1095
+ this.dispatchToApp({
1096
+ context: {
1097
+ event: 'appEventCallback',
1098
+ eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
1099
+ data: {
1100
+ userAgent: window.navigator.userAgent
1101
+ }
1102
+ }
1103
+ });
1104
+ } catch (error) {
1105
+ /* empty */
1106
+ }
1107
+ }
1108
+ case 1:
1109
+ case "end":
1110
+ return _context6.stop();
1111
+ }
1112
+ }, _callee6, this);
1113
+ }));
1114
+ function getUserAgentAndCallback(_x6) {
1115
+ return _getUserAgentAndCallback.apply(this, arguments);
1116
+ }
1117
+ return getUserAgentAndCallback;
1118
+ }()
1119
+ }, {
1120
+ key: "returnDataAndCallback",
1121
+ value: function () {
1122
+ var _returnDataAndCallback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee7(eventContext) {
1123
+ var _eventContext$data, targetData;
1124
+ return _regeneratorRuntime().wrap(function _callee7$(_context7) {
1125
+ while (1) switch (_context7.prev = _context7.next) {
1126
+ case 0:
1127
+ if (eventContext !== null && eventContext !== void 0 && eventContext.eventCallbackId) {
1128
+ targetData = this._globalData.get((_eventContext$data = eventContext.data) === null || _eventContext$data === void 0 ? void 0 : _eventContext$data.dataKey);
1129
+ this.dispatchToApp({
1130
+ context: {
1131
+ event: 'appEventCallback',
1132
+ eventCallbackId: eventContext === null || eventContext === void 0 ? void 0 : eventContext.eventCallbackId,
1133
+ data: targetData
1134
+ }
1135
+ });
1136
+ }
1137
+ case 1:
1138
+ case "end":
1139
+ return _context7.stop();
1140
+ }
1141
+ }, _callee7, this);
1142
+ }));
1143
+ function returnDataAndCallback(_x7) {
1144
+ return _returnDataAndCallback.apply(this, arguments);
1145
+ }
1146
+ return returnDataAndCallback;
1147
+ }()
1148
+ /**
1149
+ * @description Initialize subscription iframe message
1150
+ */
1151
+ }, {
1152
+ key: "addEventListener",
1153
+ value: function addEventListener() {
1154
+ this.removeEventListener();
1155
+ window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)] = this.listener.bind(this);
1156
+ window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")] = this.resizeListener.bind(this);
1157
+ window.addEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
1158
+ window.addEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
1159
+ }
1160
+ }, {
1161
+ key: "removeEventListener",
1162
+ value: function removeEventListener() {
1163
+ window.removeEventListener('message', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId)]);
1164
+ window.removeEventListener('resize', window["".concat(LISTENER_PREFIX, "_").concat(this.AMSSDK._instanceId, "_resize")]);
1165
+ }
1166
+
1167
+ /**
1168
+ * @description Processing messages from iframe
1169
+ */
1170
+ }, {
1171
+ key: "_handleAppMessage",
1172
+ value: function _handleAppMessage(data) {
1173
+ var _data$context2,
1174
+ _this7 = this;
1175
+ var eventKeyMap = Object.keys(EVENT).map(function (key) {
1176
+ return EVENT[key].name;
1177
+ });
1178
+ if (!eventKeyMap.includes(data.context.event)) {
1179
+ return;
1180
+ }
1181
+ if (data.context.event === EVENT.getDeviceId.name) {
1182
+ this.getDeviceIdAndCallback(data.context);
1183
+ return;
1184
+ }
1185
+ if (data.context.event === EVENT.getUserAgentFromSdk.name) {
1186
+ this.getUserAgentAndCallback(data.context);
1187
+ return;
1188
+ }
1189
+ if (data.context.event === EVENT.popWindow.name) {
1190
+ destroyModal();
1191
+ return;
1192
+ }
1193
+ if (data.context.event === EVENT.getGlobalData.name) {
1194
+ this.returnDataAndCallback(data.context);
1195
+ return;
1196
+ }
1197
+ if (data.context.event === EVENT.setGlobalData.name) {
1198
+ var _data$context$data, _data$context$data2;
1199
+ this._globalData.set((_data$context$data = data.context.data) === null || _data$context$data === void 0 ? void 0 : _data$context$data.dataKey, (_data$context$data2 = data.context.data) === null || _data$context$data2 === void 0 ? void 0 : _data$context$data2.data);
1200
+ return;
1201
+ }
1202
+ if (data.context.event === EVENT.popupWindow.name) {
1203
+ var _data$context;
1204
+ this.createDialog((_data$context = data.context) === null || _data$context === void 0 ? void 0 : _data$context.data);
1205
+ return;
1206
+ }
1207
+ if (data.context.event === EVENT.sendMuitiAppEventToSdk.name) {
1208
+ this.dispatchToApp({
1209
+ context: {
1210
+ event: 'receiveMuitiAppFromSdk',
1211
+ data: data.context.data
1212
+ }
1213
+ });
1214
+ return;
1215
+ }
1216
+ if (data.context.event === EVENT.dismissLoading.name) {
1217
+ var _data$context$data3;
1218
+ this.dismissLoadingFunc(false);
1219
+ this.dispatchToSDK(EVENT.eventCallback.name, {
1220
+ code: 'SDK_END_OF_LOADING',
1221
+ message: ((_data$context$data3 = data.context.data) === null || _data$context$data3 === void 0 ? void 0 : _data$context$data3.message) || ''
1222
+ });
1223
+ return;
1224
+ }
1225
+ if (data.context.event === EVENT.launch.name) {
1226
+ this._performanceData.push({
1227
+ key: 'sdk_onLaunch',
1228
+ value: Date.now()
1229
+ });
1230
+ this.AMSSDK.logger.logInfo({
1231
+ title: 'sdk_event_webAppOnLaunch'
1232
+ }).send();
1233
+ this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
1234
+ this.sendRenderEvent();
1235
+ return;
1236
+ }
1237
+ if (data.context.event === EVENT.sizeChanged.name) {
1238
+ this.handleSizeChanged(data);
1239
+ }
1240
+ if (data.context.event === EVENT.close.name) {
1241
+ return this.closeBtnFunc();
1242
+ }
1243
+ if (data.context.event === EVENT.redirect.name) {
1244
+ return this.handleRedirect(data.context.data);
1245
+ }
1246
+ if (data.context.event === EVENT.submitForm.name) {
1247
+ this.submitForm(data.context.data);
1248
+ return;
1249
+ }
1250
+ if (data.context.event === EVENT.hideCloseButton.name) {
1251
+ this.handleCloseBtnShow(false);
1252
+ return;
1253
+ }
1254
+ if (data.context.event === EVENT.showCloseButton.name) {
1255
+ this.handleCloseBtnShow(true);
1256
+ return;
1257
+ }
1258
+ if (data.context.event === EVENT.setAllowRetention.name) {
1259
+ if (data.context.data === true) this._isRetention = true;
1260
+ if (data.context.data === false) this._isRetention = false;
1261
+ return;
1262
+ }
1263
+ if (data.context.event === EVENT.declareCheckoutInfo.name) {
1264
+ this.handleDeclareInfo(data.context.data);
1265
+ return;
1266
+ }
1267
+ if (data.context.event === EVENT.declareEventCallbackInfo.name) {
1268
+ this._multipleCallbackEvents = data.context.data;
1269
+ return;
1270
+ }
1271
+ if (data.context.event === EVENT.appHeartBeat.name) {
1272
+ this.handleAppHeartBeat();
1273
+ return;
1274
+ }
1275
+ if (data.context.event === EVENT.beforeSubmit.name) {
1276
+ var _this$AMSSDK$_eventCe;
1277
+ if ((_this$AMSSDK$_eventCe = this.AMSSDK._eventCenter) !== null && _this$AMSSDK$_eventCe !== void 0 && _this$AMSSDK$_eventCe.isExist(EVENT.beforeSubmit.name)) {
1278
+ this.AMSSDK._eventCenter.emit(EVENT.beforeSubmit.name, data.context.data);
1279
+ return;
1280
+ }
1281
+ // 不存在事件,默认通过
1282
+ var eventCallbackId = uuid();
1283
+ this.dispatchToApp({
1284
+ context: {
1285
+ event: EVENT.beforeSubmitDone.name,
1286
+ eventCallbackId: eventCallbackId,
1287
+ data: {
1288
+ result: 'IGNORE'
1289
+ }
1290
+ }
1291
+ });
1292
+ return;
1293
+ }
1294
+ if (data.context.event === EVENT.eventCallback.name) {
1295
+ this.AMSSDK.logger.logInfo({
1296
+ title: 'sdk_event_event_callback'
1297
+ }).send();
1298
+ }
1299
+ if ((data === null || data === void 0 || (_data$context2 = data.context) === null || _data$context2 === void 0 ? void 0 : _data$context2.event) === EVENT.getGooglePayToken.name) {
1300
+ handleGooglePay(data).then(function (res) {
1301
+ _this7.dispatchToApp({
1302
+ context: {
1303
+ event: 'getGooglePayToken',
1304
+ data: _objectSpread({}, res)
1305
+ }
1306
+ });
1307
+ }).catch(function (err) {
1308
+ _this7.dispatchToApp({
1309
+ context: {
1310
+ event: 'getGooglePayToken',
1311
+ data: {
1312
+ err: err
1313
+ }
1314
+ }
1315
+ });
1316
+ });
1317
+ return;
1318
+ }
1319
+
1320
+ // The plug-in communicates with the sdk after processing
1321
+ this.dispatchToSDK(data.context.event, data.context.data, data.context.eventCallbackId);
1322
+ }
1323
+ }, {
1324
+ key: "dismissLoadingFunc",
1325
+ value: function dismissLoadingFunc() {
1326
+ var _document$getElementB2;
1327
+ var isShowMockup = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
1328
+ var mockup = document.getElementById(MOCKUP_ID);
1329
+ if (mockup) {
1330
+ mockup.style.background = 'rgb(0, 0, 0, 0.6)';
1331
+ mockup.style.display = isShowMockup ? 'block' : 'none';
1332
+ }
1333
+ (_document$getElementB2 = document.getElementById(LOADING_ID)) === null || _document$getElementB2 === void 0 || _document$getElementB2.remove();
1334
+ }
1335
+ }, {
1336
+ key: "handleSizeChanged",
1337
+ value: function handleSizeChanged(data) {
1338
+ var _data$context$data4, _cashier$style;
1339
+ var _selector = this._renderParams.selector.indexOf('#') === -1 ? this._renderParams.selector : this._renderParams.selector.slice(1);
1340
+ // 修改需当前文件搜索,这段注释appendAliasContainerId
1341
+ var appendAliasContainerId = this._renderParams.appendAliasContainerId;
1342
+ var selectorId = appendAliasContainerId ? "".concat(COMPONENT_CONTAINER_ID, "-").concat(_selector) : COMPONENT_CONTAINER_ID;
1343
+ var cashier = document.getElementById(selectorId);
1344
+ if (((_data$context$data4 = data.context.data) === null || _data$context$data4 === void 0 ? void 0 : _data$context$data4.height) <= 1 || data.context.data.height === parseInt(cashier === null || cashier === void 0 || (_cashier$style = cashier.style) === null || _cashier$style === void 0 ? void 0 : _cashier$style.height)) return;
1345
+ cashier.style.height = "".concat(data.context.data.height, "px");
1346
+ this.app.style.opacity = '1';
1347
+ if (this._renderDisplayType === DisplayTypeEnum.popup) {
1348
+ if (this.platform === 'desktop') {
1349
+ if (data.context.data.width) cashier.style.width = "".concat(data.context.data.width, "px");
1350
+ cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
1351
+ this.app.style.height = "".concat(data.context.data.height, "px");
1352
+ }
1353
+ if (this.platform === 'mobile') {
1354
+ cashier.classList.add("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
1355
+ var animationStyleId = "".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation-style");
1356
+ var animationStyle = document.getElementById(animationStyleId);
1357
+ if (animationStyle) animationStyle === null || animationStyle === void 0 || animationStyle.remove();
1358
+
1359
+ // 此style用于弹窗出现和高度变化时动画,动画不同,属性不同
1360
+ this.app.style.height = parseInt(this.app.style.height) > 0 ? '100%' : "".concat(data.context.data.height, "px");
1361
+ // 弹出和弹入动画
1362
+ var runkeyframes = slideInAndOutKeyframes(COMPONENT_CONTAINER_ID, data.context.data.height);
1363
+ // 创建style标签
1364
+ var style = document.createElement('style');
1365
+ style.id = animationStyleId;
1366
+ // 设置style属性
1367
+ style.type = 'text/css';
1368
+ // 将 keyframes样式写入style内
1369
+ style.innerHTML = runkeyframes;
1370
+ // 将style样式存放到head标签
1371
+ document.getElementsByTagName('head')[0].appendChild(style);
1372
+
1373
+ // size变动时动画
1374
+ setTimeout(function () {
1375
+ cashier.style.transition = 'height 0.28s ease-in-out';
1376
+ }, 500);
1377
+ }
1378
+ // 关闭loading,保留蒙层
1379
+ this.dismissLoadingFunc();
1380
+ }
1381
+ if (this._renderDisplayType === DisplayTypeEnum.inline) {
1382
+ var _document$getElementB3;
1383
+ (_document$getElementB3 = document.getElementById(LOADING_ID)) === null || _document$getElementB3 === void 0 || _document$getElementB3.remove();
1384
+ this.app.style.height = "".concat(data.context.data.height, "px");
1385
+ }
1386
+ }
1387
+ }, {
1388
+ key: "handleAuthUrlInfo",
1389
+ value: function handleAuthUrlInfo(authUrlInfo) {
1390
+ var data = {};
1391
+ if (!(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.normalUrl) && !(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.schemeUrl) && !(authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.applinkUrl) && authUrlInfo !== null && authUrlInfo !== void 0 && authUrlInfo.authUrl) {
1392
+ data = {
1393
+ normalUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
1394
+ schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl,
1395
+ applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.authUrl
1396
+ };
1397
+ } else {
1398
+ data = {
1399
+ normalUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.normalUrl,
1400
+ schemeUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.schemeUrl,
1401
+ applinkUrl: authUrlInfo === null || authUrlInfo === void 0 ? void 0 : authUrlInfo.applinkUrl
1402
+ };
1403
+ }
1404
+ this.handleRedirect(data, true);
1405
+ }
1406
+ }, {
1407
+ key: "handleRedirect",
1408
+ value: function handleRedirect(data) {
1409
+ var _data$isDestroy,
1410
+ _data$isCallApp,
1411
+ _data$callAppDetectSu,
1412
+ _this8 = this;
1413
+ var fromFastSdk = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
1414
+ var _data = typeof data === 'string' ? {
1415
+ normalUrl: data
1416
+ } : _objectSpread(_objectSpread({}, data), {}, {
1417
+ applinkUrl: (data === null || data === void 0 ? void 0 : data.applinkUrl) || '',
1418
+ schemeUrl: (data === null || data === void 0 ? void 0 : data.schemeUrl) || '',
1419
+ normalUrl: (data === null || data === void 0 ? void 0 : data.normalUrl) || '',
1420
+ target: data === null || data === void 0 ? void 0 : data.target,
1421
+ isDestroy: (_data$isDestroy = data === null || data === void 0 ? void 0 : data.isDestroy) !== null && _data$isDestroy !== void 0 ? _data$isDestroy : true,
1422
+ isCallApp: (_data$isCallApp = data === null || data === void 0 ? void 0 : data.isCallApp) !== null && _data$isCallApp !== void 0 ? _data$isCallApp : false,
1423
+ callAppDetectSuccessDelay: (_data$callAppDetectSu = data === null || data === void 0 ? void 0 : data.callAppDetectSuccessDelay) !== null && _data$callAppDetectSu !== void 0 ? _data$callAppDetectSu : 2000
1424
+ });
1425
+ this.AMSSDK.logger.logInfo({
1426
+ title: 'sdk_event_call_url_start'
1427
+ }, _objectSpread({}, data)).send();
1428
+ var successCallback = function successCallback(type, url, durationInSeconds) {
1429
+ _this8.dispatchToSDK(EVENT.eventCallback.name, {
1430
+ code: eventCodeEnum.SDK_CALL_URL_SUCCESS,
1431
+ message: "Successfully opened the app,".concat(type, ": ").concat(url)
1432
+ });
1433
+ var extra = {
1434
+ redirectInfo: JSON.stringify(_data),
1435
+ openType: type,
1436
+ url: url,
1437
+ fromFastSdk: fromFastSdk
1438
+ };
1439
+ if (durationInSeconds) {
1440
+ extra['durationInSeconds'] = durationInSeconds;
1441
+ }
1442
+ _this8.AMSSDK.logger.logInfo({
1443
+ title: 'sdk_event_call_url_success'
1444
+ }, extra).send();
1445
+ };
1446
+ var failCallback = function failCallback(type, url, durationInSeconds) {
1447
+ _this8.dispatchToSDK(EVENT.eventCallback.name, {
1448
+ code: eventCodeEnum.SDK_CALL_URL_ERROR,
1449
+ message: "Failed to open app,applinkUrl: ".concat(_data === null || _data === void 0 ? void 0 : _data.applinkUrl, " schemeUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.schemeUrl, " normalUrl: ").concat(_data === null || _data === void 0 ? void 0 : _data.normalUrl)
1450
+ });
1451
+ var extra = {
1452
+ redirectInfo: JSON.stringify(_data),
1453
+ openType: type,
1454
+ url: url,
1455
+ fromFastSdk: fromFastSdk
1456
+ };
1457
+ if (durationInSeconds) {
1458
+ extra['durationInSeconds'] = durationInSeconds;
1459
+ }
1460
+ _this8.AMSSDK.logger.logInfo({
1461
+ title: 'sdk_error_call_url_failed'
1462
+ }, extra).send();
1463
+ };
1464
+
1465
+ // 支持 target: _blank,新开tab页打开
1466
+ if (_data.target === TargetEnum.BLANK) {
1467
+ if (!_data.normalUrl) return failCallback(RedirectType.NormalUrl, '');
1468
+ successCallback(RedirectType.NormalUrl, _data.normalUrl);
1469
+ window.open(_data.normalUrl);
1470
+ return;
1471
+ }
1472
+ if (_data.target === TargetEnum.REPLACE && !(_data !== null && _data !== void 0 && _data.applinkUrl) && !(_data !== null && _data !== void 0 && _data.schemeUrl)) {
1473
+ if (!_data.normalUrl) return failCallback(RedirectType.NormalUrl, '');
1474
+ successCallback(RedirectType.NormalUrl, _data.normalUrl);
1475
+ window.location.replace(_data.normalUrl);
1476
+ return;
1477
+ }
1478
+ // 销毁iframe和全局loading
1479
+ if (_data !== null && _data !== void 0 && _data.isDestroy) this.cleanContainer();
1480
+ // 唤端
1481
+ if (_data !== null && _data !== void 0 && _data.isCallApp && _data !== null && _data !== void 0 && _data.schemeUrl) {
1482
+ var startCallAppTime = new Date();
1483
+ var detectSuccessDelay = typeof (data === null || data === void 0 ? void 0 : data.callAppDetectSuccessDelay) === 'number' ? data.callAppDetectSuccessDelay : 5000;
1484
+ this.AMSSDK._redirect({
1485
+ schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl,
1486
+ callAppJudgeTime: detectSuccessDelay
1487
+ }).then(function () {
1488
+ var endCallAppTime = new Date();
1489
+ var durationInMilliseconds = endCallAppTime.getTime() - startCallAppTime.getTime();
1490
+ var durationInSeconds = durationInMilliseconds / 1000;
1491
+ successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl, durationInSeconds);
1492
+ }).catch(function () {
1493
+ var endCallAppTime = new Date();
1494
+ var durationInMilliseconds = endCallAppTime.getTime() - startCallAppTime.getTime();
1495
+ var durationInSeconds = durationInMilliseconds / 1000;
1496
+ failCallback(RedirectType.SchemeUrl, _data.schemeUrl, durationInSeconds);
1497
+ });
1498
+ return;
1499
+ }
1500
+ this.AMSSDK._redirect({
1501
+ applinkUrl: _data === null || _data === void 0 ? void 0 : _data.applinkUrl
1502
+ }).then(function () {
1503
+ successCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
1504
+ }).catch(function () {
1505
+ if (_data !== null && _data !== void 0 && _data.applinkUrl) failCallback(RedirectType.ApplinkUrl, _data === null || _data === void 0 ? void 0 : _data.applinkUrl);
1506
+ return _this8.AMSSDK._redirect({
1507
+ schemeUrl: _data === null || _data === void 0 ? void 0 : _data.schemeUrl
1508
+ });
1509
+ }).then(function () {
1510
+ successCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
1511
+ }).catch(function () {
1512
+ if (_data !== null && _data !== void 0 && _data.schemeUrl) failCallback(RedirectType.SchemeUrl, _data === null || _data === void 0 ? void 0 : _data.schemeUrl);
1513
+ return _this8.AMSSDK._redirect({
1514
+ normalUrl: _data === null || _data === void 0 ? void 0 : _data.normalUrl
1515
+ });
1516
+ }).then(function () {
1517
+ successCallback(RedirectType.NormalUrl, _data === null || _data === void 0 ? void 0 : _data.normalUrl);
1518
+ }).catch(function () {
1519
+ failCallback(RedirectType.NormalUrl, _data === null || _data === void 0 ? void 0 : _data.normalUrl);
1520
+ });
1521
+ }
1522
+ }, {
1523
+ key: "handleDeclareInfo",
1524
+ value: function handleDeclareInfo(_ref14) {
1525
+ var _ref14$closeDialogDat = _ref14.closeDialogData,
1526
+ closeDialogData = _ref14$closeDialogDat === void 0 ? {} : _ref14$closeDialogDat;
1527
+ _handleDeclareInfo({
1528
+ closeDialogData: closeDialogData
1529
+ });
1530
+ }
1531
+ }, {
1532
+ key: "handleDeclarePopWindowCallback",
1533
+ value: function handleDeclarePopWindowCallback() {
1534
+ var eventInfoName = 'popWindowEventInfo';
1535
+ if (this._multipleCallbackEvents && eventInfoName in this._multipleCallbackEvents) {
1536
+ var eventInfo = this._multipleCallbackEvents[eventInfoName];
1537
+ if (eventInfo.enableCallback) {
1538
+ this.dispatchToSDK(EVENT.eventCallback.name, {
1539
+ code: eventInfo.eventName,
1540
+ result: {
1541
+ result: eventInfo.eventResult || {}
1542
+ }
1543
+ });
1544
+ }
1545
+ } else {
1546
+ console.log("not valid ".concat(eventInfoName, " in "), this._multipleCallbackEvents);
1547
+ }
1548
+ }
1549
+ }, {
1550
+ key: "handleAppHeartBeat",
1551
+ value: function handleAppHeartBeat() {
1552
+ var _this9 = this;
1553
+ try {
1554
+ if (!this._webAppHeartBeatTimeoutFn) {
1555
+ this._webAppHeartBeatTimeoutFn = function () {
1556
+ if (_this9.isAppAttached()) {
1557
+ _this9.AMSSDK.logger.logError({
1558
+ title: 'sdk_error_appHeartBeatTimeout'
1559
+ });
1560
+ }
1561
+ };
1562
+ }
1563
+ if (window._webAppHeartBeatTimeoutId) {
1564
+ clearTimeout(window._webAppHeartBeatTimeoutId);
1565
+ window._webAppHeartBeatTimeoutId = null;
1566
+ }
1567
+ if (this._webAppHeartBeatTimeoutFn) {
1568
+ window._webAppHeartBeatTimeoutId = setTimeout(this._webAppHeartBeatTimeoutFn, TIMEOUT_WEB_APP_HEART_BEAT);
1569
+ }
1570
+ setTimeout(function () {
1571
+ if (_this9.isAppAttached()) {
1572
+ _this9.dispatchToApp({
1573
+ context: {
1574
+ event: 'sdkHeartBeat',
1575
+ data: {}
1576
+ }
1577
+ });
1578
+ }
1579
+ }, TIME_DELAY_SEND_HEART_BEAT);
1580
+ } catch (error) {
1581
+ this.AMSSDK.logger.logError({
1582
+ title: 'sdk_error_handleAppHeartBeat'
1583
+ }, {
1584
+ errorMessage: error.message
1585
+ });
1586
+ }
1587
+ }
1588
+ }, {
1589
+ key: "isAppAttached",
1590
+ value: function isAppAttached() {
1591
+ return this.app || this.popupApp;
1592
+ }
1593
+ }, {
1594
+ key: "isWindowVisible",
1595
+ value: function isWindowVisible() {
1596
+ var _document;
1597
+ return ((_document = document) === null || _document === void 0 ? void 0 : _document.visibilityState) === 'visible';
1598
+ }
1599
+ }, {
1600
+ key: "handleCloseBtnShow",
1601
+ value: function handleCloseBtnShow(showClose) {
1602
+ var closeBlock = document.getElementById(COMPONENT_CLOSE_BLOCK_ID);
1603
+ if (showClose) {
1604
+ closeBlock === null || closeBlock === void 0 || closeBlock.classList.remove("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
1605
+ } else if (showClose === false) {
1606
+ closeBlock === null || closeBlock === void 0 || closeBlock.classList.add("".concat(COMPONENT_CLOSE_BLOCK_ID, "-hidden"));
1607
+ }
1608
+ }
1609
+
1610
+ /**
1611
+ * @description Send message to SDK
1612
+ */
1613
+ }, {
1614
+ key: "dispatchToSDK",
1615
+ value: function dispatchToSDK(event, data, eventCallbackId) {
1616
+ this.AMSSDK._eventCenter.emit(event, data);
1617
+ if (eventCallbackId) this.AMSSDK._eventCenter.emit(eventCallbackId, data);
1618
+ }
1619
+
1620
+ /**
1621
+ * @description Send message to iframe
1622
+ */
1623
+ }, {
1624
+ key: "dispatchToApp",
1625
+ value: function dispatchToApp(payload) {
1626
+ var targetElement = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
1627
+ var data = Object.assign({}, payload, {
1628
+ name: MessageName.SDK_TO_APP,
1629
+ mode: this.AMSSDK.options.mode,
1630
+ appId: COMPONENTPLUGINID,
1631
+ instanceId: this.AMSSDK._instanceId
1632
+ });
1633
+ if (targetElement && targetElement.contentWindow) {
1634
+ return targetElement.contentWindow.postMessage(JSON.stringify(data), '*');
1635
+ }
1636
+ if (this.app || this.popupApp) {
1637
+ var _this$app, _this$app2, _this$popupApp, _this$popupApp2;
1638
+ (this === null || this === void 0 || (_this$app = this.app) === null || _this$app === void 0 ? void 0 : _this$app.contentWindow) && (this === null || this === void 0 || (_this$app2 = this.app) === null || _this$app2 === void 0 ? void 0 : _this$app2.contentWindow.postMessage(JSON.stringify(data), this.appDomain));
1639
+ (this === null || this === void 0 || (_this$popupApp = this.popupApp) === null || _this$popupApp === void 0 ? void 0 : _this$popupApp.contentWindow) && (this === null || this === void 0 || (_this$popupApp2 = this.popupApp) === null || _this$popupApp2 === void 0 ? void 0 : _this$popupApp2.contentWindow.postMessage(JSON.stringify(data), '*'));
1640
+ return;
1641
+ }
1642
+ throw new Error(ERRORMESSAGE.SDK_SUBMIT_ERROR.message);
1643
+ }
1644
+
1645
+ /**
1646
+ * @description Subscribe to messages from SDK
1647
+ */
1648
+ }, {
1649
+ key: "subscribeFromSDK",
1650
+ value: function subscribeFromSDK() {
1651
+ var eventKeyMap = {};
1652
+ for (var key in eventKeyMap) {
1653
+ // eslint-disable-next-line no-prototype-builtins
1654
+ if (eventKeyMap.hasOwnProperty(key)) {
1655
+ this.AMSSDK._eventCenter.on("".concat(COMPONENTPLUGINID, "-").concat(key), eventKeyMap[key].bind(this));
1656
+ }
1657
+ }
1658
+ }
1659
+
1660
+ /**
1661
+ * @description Send rendering events to iframe
1662
+ */
1663
+ }, {
1664
+ key: "sendRenderEvent",
1665
+ value: (function () {
1666
+ var _sendRenderEvent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee8() {
1667
+ var _this$_renderParams15, _this$_renderParams16, _this$_renderParams17, _this$_renderParams18, _this$_renderParams19, _this$_renderParams20, _this$_renderParams21, _this$_renderParams22, _this$_renderParams23, _this$AMSSDK$logger, _this$_renderParams24, _this$_renderParams25, _this$_renderParams26, _this$AMSSDK, _this$_renderParams27, isAddressElement, res, submitRes;
1668
+ return _regeneratorRuntime().wrap(function _callee8$(_context8) {
1669
+ while (1) switch (_context8.prev = _context8.next) {
1670
+ case 0:
1671
+ _context8.prev = 0;
1672
+ isAddressElement = this.AMSSDK.options.product === ProductSceneEnum.ELEMENT_ADDRESS;
1673
+ if (!((!this._actionQueryPromise || !this._actionSubmitPromise) && !isAddressElement)) {
1674
+ _context8.next = 4;
1675
+ break;
1676
+ }
1677
+ return _context8.abrupt("return");
1678
+ case 4:
1679
+ _context8.next = 6;
1680
+ return this._actionQueryPromise;
1681
+ case 6:
1682
+ res = _context8.sent;
1683
+ _context8.next = 9;
1684
+ return this._actionSubmitPromise;
1685
+ case 9:
1686
+ submitRes = _context8.sent;
1687
+ this._performanceData.push({
1688
+ key: 'sdk_render_component',
1689
+ value: Date.now()
1690
+ });
1691
+ this.dispatchToApp({
1692
+ context: {
1693
+ event: 'renderComponent',
1694
+ data: {
1695
+ queryResult: res,
1696
+ submitResult: submitRes,
1697
+ sessionResult: (_this$_renderParams15 = this._renderParams) === null || _this$_renderParams15 === void 0 ? void 0 : _this$_renderParams15.paymentSessionMetaData,
1698
+ paymentSessionData: (_this$_renderParams16 = this._renderParams) === null || _this$_renderParams16 === void 0 ? void 0 : _this$_renderParams16.sessionData,
1699
+ heightOfVisible: Math.max(window.changingPageHeight, window.innerHeight),
1700
+ renderDisplayType: (_this$_renderParams17 = this._renderParams) === null || _this$_renderParams17 === void 0 ? void 0 : _this$_renderParams17.renderDisplayType,
1701
+ appearance: (_this$_renderParams18 = this._renderParams) === null || _this$_renderParams18 === void 0 ? void 0 : _this$_renderParams18.appearance,
1702
+ notRedirectAfterComplete: ((_this$_renderParams19 = this._renderParams) === null || _this$_renderParams19 === void 0 ? void 0 : _this$_renderParams19.notRedirectAfterComplete) === true,
1703
+ isAppWebview: this._isAppWebview,
1704
+ merchantAppointParam: this._merchantAppointParam,
1705
+ allowSubmitPayCallAhead: this._allowSubmitPayCallAhead,
1706
+ /** 地址组件集成的参数 */
1707
+ configParams: (_this$_renderParams20 = this._renderParams) === null || _this$_renderParams20 === void 0 ? void 0 : _this$_renderParams20.configParams,
1708
+ prefillValue: (_this$_renderParams21 = this._renderParams) === null || _this$_renderParams21 === void 0 ? void 0 : _this$_renderParams21.prefillValue,
1709
+ componentSession: (_this$_renderParams22 = this._renderParams) === null || _this$_renderParams22 === void 0 ? void 0 : _this$_renderParams22.componentSession,
1710
+ envInfo: {
1711
+ screenHeight: screen.height,
1712
+ screenWidth: screen.width
1713
+ },
1714
+ logMetaData: _objectSpread(_objectSpread({
1715
+ trackId: (_this$_renderParams23 = this._renderParams) === null || _this$_renderParams23 === void 0 ? void 0 : _this$_renderParams23.sessionData,
1716
+ platform: this.platform,
1717
+ firstLogTime: (_this$AMSSDK$logger = this.AMSSDK.logger) === null || _this$AMSSDK$logger === void 0 ? void 0 : _this$AMSSDK$logger.getComponentStartTime()
1718
+ }, ((_this$_renderParams24 = this._renderParams) === null || _this$_renderParams24 === void 0 || (_this$_renderParams24 = _this$_renderParams24.paymentSessionMetaData) === null || _this$_renderParams24 === void 0 ? void 0 : _this$_renderParams24.paymentSessionConfig) || {}), {}, {
1719
+ renderDisplayType: (_this$_renderParams25 = this._renderParams) === null || _this$_renderParams25 === void 0 ? void 0 : _this$_renderParams25.renderDisplayType,
1720
+ sdkVersion: this._appVersion,
1721
+ merchantId: (_this$_renderParams26 = this._renderParams) === null || _this$_renderParams26 === void 0 || (_this$_renderParams26 = _this$_renderParams26.paymentSessionMetaData) === null || _this$_renderParams26 === void 0 ? void 0 : _this$_renderParams26.clientId,
1722
+ instanceId: (_this$AMSSDK = this.AMSSDK) === null || _this$AMSSDK === void 0 ? void 0 : _this$AMSSDK._instanceId,
1723
+ performanceData: this._performanceData,
1724
+ paymentMethodType: (_this$_renderParams27 = this._renderParams) === null || _this$_renderParams27 === void 0 || (_this$_renderParams27 = _this$_renderParams27.paymentSessionMetaData) === null || _this$_renderParams27 === void 0 || (_this$_renderParams27 = _this$_renderParams27.paymentMethodInfoView) === null || _this$_renderParams27 === void 0 ? void 0 : _this$_renderParams27.paymentMethodType
1725
+ })
1726
+ }
1727
+ }
1728
+ }, null);
1729
+ this.AMSSDK.logger.logInfo({
1730
+ title: 'sdk_event_renderComponent'
1731
+ });
1732
+ this.dispatchToApp({
1733
+ context: {
1734
+ event: 'web-sdk-performance',
1735
+ data: {
1736
+ performanceData: this._performanceData
1737
+ }
1738
+ }
1739
+ });
1740
+ // eslint-disable-next-line no-empty
1741
+ _context8.next = 18;
1742
+ break;
1743
+ case 16:
1744
+ _context8.prev = 16;
1745
+ _context8.t0 = _context8["catch"](0);
1746
+ case 18:
1747
+ case "end":
1748
+ return _context8.stop();
1749
+ }
1750
+ }, _callee8, this, [[0, 16]]);
1751
+ }));
1752
+ function sendRenderEvent() {
1753
+ return _sendRenderEvent.apply(this, arguments);
1754
+ }
1755
+ return sendRenderEvent;
1756
+ }()
1757
+ /**
1758
+ * @description close cashier
1759
+ */
1760
+ )
1761
+ }, {
1762
+ key: "cleanContainer",
1763
+ value: function cleanContainer() {
1764
+ var _document$getElementB4,
1765
+ _this10 = this;
1766
+ var immediately = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1767
+ (_document$getElementB4 = document.getElementById(LOADING_ID)) === null || _document$getElementB4 === void 0 || _document$getElementB4.remove();
1768
+ this.hideComponentAnimation();
1769
+ var mockup = document.getElementById(MOCKUP_ID);
1770
+ mockup === null || mockup === void 0 || mockup.classList.add("".concat(MOCKUP_ID, "-hidden"));
1771
+ this._loadAppPromiseResolve && this._loadAppPromiseResolve(true);
1772
+ this._performanceData = [];
1773
+ this._isInitComponent = false;
1774
+ this.app = null;
1775
+ if (immediately) this.cleanElement();else {
1776
+ setTimeout(function () {
1777
+ _this10.cleanElement();
1778
+ }, 300);
1779
+ }
1780
+ }
1781
+ }, {
1782
+ key: "hideComponentAnimation",
1783
+ value: function hideComponentAnimation() {
1784
+ var _container$style;
1785
+ var container = document.getElementById(COMPONENT_CONTAINER_ID);
1786
+ if (this.app) this.app.style.height = container === null || container === void 0 || (_container$style = container.style) === null || _container$style === void 0 ? void 0 : _container$style.height;
1787
+ if (container) {
1788
+ // size变化动画取消
1789
+ container.style.transition = '';
1790
+ container === null || container === void 0 || container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform));
1791
+ container === null || container === void 0 || container.classList.remove("".concat(COMPONENT_CONTAINER_ID, "-").concat(this.platform, "-animation"));
1792
+ container === null || container === void 0 || container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-hidden-").concat(this.platform));
1793
+ }
1794
+ }
1795
+ }, {
1796
+ key: "closeBtnFunc",
1797
+ value: function closeBtnFunc() {
1798
+ // element && element.removeEventListener()
1799
+ if (this._isRetention) this.showRetentionPopup();else {
1800
+ this.cleanContainer();
1801
+ this.dispatchToSDK(EVENT.close.name, {});
1802
+ this.handleDeclarePopWindowCallback();
1803
+ }
1804
+ }
1805
+ }, {
1806
+ key: "retentionPopupLeaveFunc",
1807
+ value: function retentionPopupLeaveFunc() {
1808
+ this.dispatchToSDK(EVENT.close.name, {});
1809
+ this.hideRetentionPopupFunc();
1810
+ this.cleanContainer();
1811
+ this.handleDeclarePopWindowCallback();
1812
+ }
1813
+ }, {
1814
+ key: "removeRetentionPopup",
1815
+ value: function removeRetentionPopup(platform) {
1816
+ _removeRetentionPopup();
1817
+ // TODO check
1818
+ // removeRetentionPopup(platform, this.hideRetentionPopupFunc.bind(this), this.retentionPopupLeaveFunc.bind(this));
1819
+ }
1820
+ }, {
1821
+ key: "showRetentionPopup",
1822
+ value: function showRetentionPopup() {
1823
+ var retentionPopup = document.getElementById(COMPONENT_RETENTION_ID);
1824
+ var container = document.getElementById(COMPONENT_CONTAINER_ID);
1825
+ if (retentionPopup) {
1826
+ container === null || container === void 0 || container.classList.add("".concat(COMPONENT_CONTAINER_ID, "-opacity"));
1827
+ retentionPopup.classList.remove("".concat(COMPONENT_RETENTION_ID, "-hidden"));
1828
+ retentionPopup.classList.add("".concat(COMPONENT_RETENTION_ID, "-show"));
1829
+ }
1830
+ }
1831
+ }, {
1832
+ key: "hideRetentionPopupFunc",
1833
+ value: function hideRetentionPopupFunc() {
1834
+ hideRetentionPopup();
1835
+ }
1836
+ }, {
1837
+ key: "submitForm",
1838
+ value: function submitForm(data) {
1839
+ var attributes = data.attributes;
1840
+ var _document2 = document,
1841
+ body = _document2.body;
1842
+ var form = document.createElement('form');
1843
+ form.setAttribute('height', '1');
1844
+ form.setAttribute('width', '1');
1845
+ Object.keys(attributes.data).forEach(function (key) {
1846
+ var input = document.createElement('input');
1847
+ input.setAttribute('type', 'hidden');
1848
+ input.setAttribute('name', key);
1849
+ input.setAttribute('value', attributes.data[key]);
1850
+ form.appendChild(input);
1851
+ });
1852
+ form.setAttribute('action', attributes.action);
1853
+ form.setAttribute('method', 'post');
1854
+ body.appendChild(form);
1855
+ setTimeout(function () {
1856
+ form.submit();
1857
+ }, 0);
1858
+ }
1859
+ }]);
1860
+ return ComponentApp;
1861
+ }();
1862
+ export { ComponentApp as default };