@dintero/checkout-web-sdk 0.12.15 → 0.12.17

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.
@@ -2,7 +2,7 @@ import 'native-promise-only';
2
2
 
3
3
  var pkg = {
4
4
  name: "@dintero/checkout-web-sdk",
5
- version: "0.12.15",
5
+ version: "0.12.17",
6
6
  description: "Dintero Checkout SDK for web frontends",
7
7
  main: "dist/dintero-checkout-web-sdk.cjs.js",
8
8
  module: "dist/dintero-checkout-web-sdk.esm.js",
@@ -36,16 +36,16 @@ var pkg = {
36
36
  devDependencies: {
37
37
  "@babel/core": "7.29.7",
38
38
  "@babel/preset-typescript": "7.29.7",
39
- "@biomejs/biome": "2.4.15",
39
+ "@biomejs/biome": "2.5.0",
40
40
  "@preconstruct/cli": "2.8.13",
41
41
  "@semantic-release/exec": "7.1.0",
42
42
  "@semantic-release/git": "10.0.1",
43
- "@vitest/browser": "4.1.7",
43
+ "@vitest/browser": "4.1.9",
44
44
  "@vitest/browser-webdriverio": "^4.0.4",
45
- "semantic-release": "25.0.3",
45
+ "semantic-release": "25.0.5",
46
46
  typescript: "6.0.3",
47
- vitest: "4.1.7",
48
- webdriverio: "9.27.2"
47
+ vitest: "4.1.9",
48
+ webdriverio: "9.29.0"
49
49
  },
50
50
  dependencies: {
51
51
  "native-promise-only": "0.8.1"
@@ -220,6 +220,19 @@ const getPopOutUrl = ({
220
220
  }
221
221
  return `${padTrailingSlash(endpoint)}?${params.toString()}`;
222
222
  };
223
+
224
+ /**
225
+ * Get the target origin for postMessage calls derived from the endpoint.
226
+ * Falls back to the default checkout endpoint when none is configured.
227
+ */
228
+ const getTargetOrigin = endpoint => {
229
+ const resolvedEndpoint = endpoint || "https://checkout.dintero.com";
230
+ try {
231
+ return new URL(resolvedEndpoint).origin;
232
+ } catch {
233
+ throw new Error("Invalid endpoint");
234
+ }
235
+ };
223
236
  const getHostname = () => {
224
237
  try {
225
238
  const {
@@ -245,6 +258,7 @@ const hostnameIsTop = () => {
245
258
  const url = {
246
259
  getPopOutUrl,
247
260
  getSessionUrl,
261
+ getTargetOrigin,
248
262
  windowLocationAssign
249
263
  };
250
264
 
@@ -348,38 +362,38 @@ const openPopOut = async options => {
348
362
  popOutWindow
349
363
  };
350
364
  };
351
- const postPopOutSessionLock = (popOutWindow, sid) => {
365
+ const postPopOutSessionLock = (popOutWindow, sid, targetOrigin) => {
352
366
  try {
353
367
  if (popOutWindow) {
354
368
  popOutWindow.postMessage({
355
369
  type: "LockSession",
356
370
  sid
357
- }, "*");
371
+ }, targetOrigin);
358
372
  }
359
373
  } catch (e) {
360
374
  console.error(e);
361
375
  }
362
376
  };
363
- const postPopOutSessionRefresh = (popOutWindow, sid) => {
377
+ const postPopOutSessionRefresh = (popOutWindow, sid, targetOrigin) => {
364
378
  try {
365
379
  if (popOutWindow) {
366
380
  popOutWindow.postMessage({
367
381
  type: "RefreshSession",
368
382
  sid
369
- }, "*");
383
+ }, targetOrigin);
370
384
  }
371
385
  } catch (e) {
372
386
  console.error(e);
373
387
  }
374
388
  };
375
- const postPopOutActivePaymentProductType = (popOutWindow, sid, paymentProductType) => {
389
+ const postPopOutActivePaymentProductType = (popOutWindow, sid, targetOrigin, paymentProductType) => {
376
390
  try {
377
391
  if (popOutWindow) {
378
392
  popOutWindow.postMessage({
379
393
  type: "SetActivePaymentProductType",
380
394
  sid,
381
395
  payment_product_type: paymentProductType
382
- }, "*");
396
+ }, targetOrigin);
383
397
  }
384
398
  } catch (e) {
385
399
  console.error(e);
@@ -836,135 +850,135 @@ const removePopOutButton = () => {
836
850
  /**
837
851
  * Post a message acknowledgement to the checkout iframe.
838
852
  */
839
- const postAck = (source, event) => {
853
+ const postAck = (source, event, targetOrigin) => {
840
854
  if (event.data.mid && source) {
841
855
  source.postMessage({
842
856
  ack: event.data.mid
843
- }, event.origin || "*");
857
+ }, targetOrigin);
844
858
  }
845
859
  };
846
860
 
847
861
  /**
848
862
  * Post a SessionLock-event to the checkout iframe.
849
863
  */
850
- const postSessionLock = (iframe, sid) => {
864
+ const postSessionLock = (iframe, sid, targetOrigin) => {
851
865
  if (iframe.contentWindow) {
852
866
  iframe.contentWindow.postMessage({
853
867
  type: "LockSession",
854
868
  sid
855
- }, "*");
869
+ }, targetOrigin);
856
870
  }
857
871
  };
858
872
 
859
873
  /**
860
874
  * Post the validation result to the checkout iframe
861
875
  */
862
- const postValidationResult = (iframe, sid, result) => {
876
+ const postValidationResult = (iframe, sid, result, targetOrigin) => {
863
877
  if (iframe.contentWindow) {
864
878
  iframe.contentWindow.postMessage({
865
879
  type: "ValidationResult",
866
880
  sid,
867
881
  ...result
868
- }, "*");
882
+ }, targetOrigin);
869
883
  }
870
884
  };
871
885
 
872
886
  /**
873
887
  * Post the address call back result to the checkout iframe
874
888
  */
875
- const postAddressCallbackResult = (iframe, sid, result) => {
889
+ const postAddressCallbackResult = (iframe, sid, result, targetOrigin) => {
876
890
  if (iframe.contentWindow) {
877
891
  iframe.contentWindow.postMessage({
878
892
  type: "AddressCallbackResult",
879
893
  sid,
880
894
  ...result
881
- }, "*");
895
+ }, targetOrigin);
882
896
  }
883
897
  };
884
898
 
885
899
  /**
886
900
  * Post RefreshSession-event to the checkout iframe.
887
901
  */
888
- const postSessionRefresh = (iframe, sid) => {
902
+ const postSessionRefresh = (iframe, sid, targetOrigin) => {
889
903
  if (iframe.contentWindow) {
890
904
  iframe.contentWindow.postMessage({
891
905
  type: "RefreshSession",
892
906
  sid
893
- }, "*");
907
+ }, targetOrigin);
894
908
  }
895
909
  };
896
910
 
897
911
  /**
898
912
  * Post SetActivePaymentProductType-event to the checkout iframe.
899
913
  */
900
- const postActivePaymentProductType = (iframe, sid, paymentProductType) => {
914
+ const postActivePaymentProductType = (iframe, sid, targetOrigin, paymentProductType) => {
901
915
  if (iframe.contentWindow) {
902
916
  iframe.contentWindow.postMessage({
903
917
  type: "SetActivePaymentProductType",
904
918
  sid,
905
919
  payment_product_type: paymentProductType
906
- }, "*");
920
+ }, targetOrigin);
907
921
  }
908
922
  };
909
923
 
910
924
  /**
911
925
  * Post ClosePopOut-event to the checkout iframe.
912
926
  */
913
- const postValidatePopOutEvent = (iframe, sid) => {
927
+ const postValidatePopOutEvent = (iframe, sid, targetOrigin) => {
914
928
  if (iframe.contentWindow) {
915
929
  iframe.contentWindow.postMessage({
916
930
  type: "ValidatingPopOut",
917
931
  sid
918
- }, "*");
932
+ }, targetOrigin);
919
933
  }
920
934
  };
921
935
 
922
936
  /**
923
937
  * Post OpenPopOutFailed-event to the checkout iframe.
924
938
  */
925
- const postOpenPopOutFailedEvent = (iframe, sid) => {
939
+ const postOpenPopOutFailedEvent = (iframe, sid, targetOrigin) => {
926
940
  if (iframe.contentWindow) {
927
941
  iframe.contentWindow.postMessage({
928
942
  type: "OpenPopOutFailed",
929
943
  sid
930
- }, "*");
944
+ }, targetOrigin);
931
945
  }
932
946
  };
933
947
 
934
948
  /**
935
949
  * Post OpenedPopOut-event to the checkout iframe.
936
950
  */
937
- const postOpenPopOutEvent = (iframe, sid) => {
951
+ const postOpenPopOutEvent = (iframe, sid, targetOrigin) => {
938
952
  if (iframe.contentWindow) {
939
953
  iframe.contentWindow.postMessage({
940
954
  type: "OpenedPopOut",
941
955
  sid
942
- }, "*");
956
+ }, targetOrigin);
943
957
  }
944
958
  };
945
959
 
946
960
  /**
947
961
  * Post ClosePopOut-event to the checkout iframe.
948
962
  */
949
- const postClosePopOutEvent = (iframe, sid) => {
963
+ const postClosePopOutEvent = (iframe, sid, targetOrigin) => {
950
964
  if (iframe.contentWindow) {
951
965
  iframe.contentWindow.postMessage({
952
966
  type: "ClosedPopOut",
953
967
  sid
954
- }, "*");
968
+ }, targetOrigin);
955
969
  }
956
970
  };
957
971
 
958
972
  /**
959
973
  * Post SetLanguage-event to the checkout iframe.
960
974
  */
961
- const postSetLanguage = (iframe, sid, language) => {
975
+ const postSetLanguage = (iframe, sid, language, targetOrigin) => {
962
976
  if (iframe.contentWindow) {
963
977
  iframe.contentWindow.postMessage({
964
978
  type: "SetLanguage",
965
979
  sid,
966
980
  language
967
- }, "*");
981
+ }, targetOrigin);
968
982
  }
969
983
  };
970
984
 
@@ -990,7 +1004,7 @@ const subscribe = options => {
990
1004
  const correctSid = event.data && event.data.sid === sid;
991
1005
  const correctMessageType = eventTypes.indexOf(event.data?.type) !== -1;
992
1006
  if (correctOrigin && correctWindow && correctSid && correctMessageType) {
993
- postAck(checkout.iframe.contentWindow, event);
1007
+ postAck(checkout.iframe.contentWindow, event, endpointUrl.origin);
994
1008
  handler(event.data, checkout);
995
1009
  }
996
1010
  };
@@ -1052,6 +1066,7 @@ const setLanguage = (event, checkout) => {
1052
1066
  checkout.language = event.language;
1053
1067
  }
1054
1068
  };
1069
+ const paymentCompletedEvents = [CheckoutEvents.SessionCancel, CheckoutEvents.SessionPaymentOnHold, CheckoutEvents.SessionPaymentAuthorized, CheckoutEvents.SessionPaymentError];
1055
1070
 
1056
1071
  /**
1057
1072
  * Wrap function with try catch so an error in a single function won't short circuit other code in the current context.
@@ -1075,12 +1090,11 @@ const createPopOutMessageHandler = (source, checkout) => {
1075
1090
  // biome-ignore lint/suspicious/noExplicitAny: internal LanguageChanged event, not part of SessionEvent
1076
1091
  handler: (eventData, checkout) => {
1077
1092
  // Tell the embedded checkout to change language.
1078
- postSetLanguage(checkout.iframe, checkout.options.sid, eventData.language);
1093
+ postSetLanguage(checkout.iframe, checkout.options.sid, eventData.language, url.getTargetOrigin(checkout.options.endpoint));
1079
1094
  }
1080
1095
  };
1081
1096
 
1082
1097
  // Close pop out, and remove SDK rendered button when payment is completed.
1083
- const paymentCompletedEvents = [CheckoutEvents.SessionCancel, CheckoutEvents.SessionPaymentOnHold, CheckoutEvents.SessionPaymentAuthorized, CheckoutEvents.SessionPaymentError];
1084
1098
  const popOutCompletedHandler = {
1085
1099
  internalPopOutHandler: true,
1086
1100
  eventTypes: paymentCompletedEvents,
@@ -1147,7 +1161,7 @@ const showPopOut = async (event, checkout) => {
1147
1161
  onOpen: popOutWindow => createPopOutMessageHandler(popOutWindow, checkout),
1148
1162
  onClose: () => {
1149
1163
  removeBackdrop();
1150
- postClosePopOutEvent(checkout.iframe, checkout.options.sid);
1164
+ postClosePopOutEvent(checkout.iframe, checkout.options.sid, url.getTargetOrigin(checkout.options.endpoint));
1151
1165
  setPopOutButtonDisabled(false);
1152
1166
  checkout.popOutWindow = undefined;
1153
1167
  }
@@ -1158,7 +1172,7 @@ const showPopOut = async (event, checkout) => {
1158
1172
  popOutWindow
1159
1173
  } = openPopOutResult;
1160
1174
  if (popOutWindow) {
1161
- postOpenPopOutEvent(checkout.iframe, checkout.options.sid);
1175
+ postOpenPopOutEvent(checkout.iframe, checkout.options.sid, url.getTargetOrigin(checkout.options.endpoint));
1162
1176
  // Add pop out window to checkout instance
1163
1177
  checkout.popOutWindow = popOutWindow;
1164
1178
  createBackdrop({
@@ -1168,7 +1182,7 @@ const showPopOut = async (event, checkout) => {
1168
1182
  });
1169
1183
  return true;
1170
1184
  } else {
1171
- postOpenPopOutFailedEvent(checkout.iframe, checkout.options.sid);
1185
+ postOpenPopOutFailedEvent(checkout.iframe, checkout.options.sid, url.getTargetOrigin(checkout.options.endpoint));
1172
1186
  return false;
1173
1187
  }
1174
1188
  };
@@ -1182,7 +1196,7 @@ const createPopOutValidationCallback = (event, checkout) => {
1182
1196
  return result => {
1183
1197
  // Tell the embedded iframe about the validation result so it can show an error message if
1184
1198
  // the validation failed.
1185
- postValidationResult(checkout.iframe, checkout.options.sid, result);
1199
+ postValidationResult(checkout.iframe, checkout.options.sid, result, url.getTargetOrigin(checkout.options.endpoint));
1186
1200
  if (result.success && checkout.popOutWindow) {
1187
1201
  // Redirect user to session in pop out window
1188
1202
  checkout.popOutWindow.location.href = url.getPopOutUrl({
@@ -1213,7 +1227,7 @@ const handlePopOutButtonClick = async (event, checkout) => {
1213
1227
  // Let the host application validate the payment session before opening checkout.
1214
1228
 
1215
1229
  // Tell the embedded iframe that we are validating the session
1216
- postValidatePopOutEvent(checkout.iframe, checkout.options.sid);
1230
+ postValidatePopOutEvent(checkout.iframe, checkout.options.sid, url.getTargetOrigin(checkout.options.endpoint));
1217
1231
 
1218
1232
  // Create callback function added to the SDK event and onValidateSession attributes
1219
1233
  const callback = createPopOutValidationCallback(event, checkout);
@@ -1232,7 +1246,7 @@ const handlePopOutButtonClick = async (event, checkout) => {
1232
1246
  postValidationResult(checkout.iframe, checkout.options.sid, {
1233
1247
  success: false,
1234
1248
  clientValidationError: "Validation runtime error"
1235
- });
1249
+ }, url.getTargetOrigin(checkout.options.endpoint));
1236
1250
  }
1237
1251
  }
1238
1252
  };
@@ -1248,6 +1262,9 @@ const isShowPopOutButton = event => {
1248
1262
  * Display the SDK rendered pop out button on top of the embedded iframe
1249
1263
  */
1250
1264
  const handleShowButton = (event, checkout) => {
1265
+ if (checkout.paymentCompleted) {
1266
+ return;
1267
+ }
1251
1268
  if (isShowPopOutButton(event)) {
1252
1269
  if (event.session) {
1253
1270
  // Update checkout instance session
@@ -1277,6 +1294,15 @@ const handleRemoveButton = (event, _checkout) => {
1277
1294
  removePopOutButton();
1278
1295
  }
1279
1296
  };
1297
+
1298
+ /**
1299
+ * Mark the payment as completed and remove the pop out button. Once completed,
1300
+ * handleShowButton ignores any further ShowPopOutButton messages.
1301
+ */
1302
+ const handlePaymentCompleted = (_event, checkout) => {
1303
+ checkout.paymentCompleted = true;
1304
+ removePopOutButton();
1305
+ };
1280
1306
  const cleanUpPopOut = checkout => {
1281
1307
  // Ensures that the pop out is no longer open when the payment is completed or the checkout is destroyed.
1282
1308
  removePopOutButton();
@@ -1327,6 +1353,10 @@ const embed = async options => {
1327
1353
  onAddressCallback,
1328
1354
  popOut
1329
1355
  } = internalOptions;
1356
+
1357
+ // Origin of the checkout endpoint, used as the target origin for all
1358
+ // postMessage calls so messages are only ever delivered to the trusted origin.
1359
+ const targetOrigin = url.getTargetOrigin(endpoint);
1330
1360
  let checkout;
1331
1361
  const subscriptions = [];
1332
1362
  let has_delivered_final_event = false;
@@ -1416,30 +1446,30 @@ const embed = async options => {
1416
1446
  };
1417
1447
  const lockSession = () => {
1418
1448
  return promisifyAction(() => {
1419
- postSessionLock(iframe, sid);
1420
- popOutModule.postPopOutSessionLock(checkout?.popOutWindow, sid);
1449
+ postSessionLock(iframe, sid, targetOrigin);
1450
+ popOutModule.postPopOutSessionLock(checkout?.popOutWindow, sid, targetOrigin);
1421
1451
  }, CheckoutEvents.SessionLocked, CheckoutEvents.SessionLockFailed);
1422
1452
  };
1423
1453
  const refreshSession = () => {
1424
1454
  return promisifyAction(() => {
1425
- postSessionRefresh(iframe, sid);
1426
- popOutModule.postPopOutSessionRefresh(checkout?.popOutWindow, sid);
1455
+ postSessionRefresh(iframe, sid, targetOrigin);
1456
+ popOutModule.postPopOutSessionRefresh(checkout?.popOutWindow, sid, targetOrigin);
1427
1457
  }, CheckoutEvents.SessionUpdated, CheckoutEvents.SessionNotFound);
1428
1458
  };
1429
1459
  const setActivePaymentProductType = paymentProductType => {
1430
1460
  // Send to either embed or pop out
1431
1461
  if (options.popOut) {
1432
- popOutModule.postPopOutActivePaymentProductType(checkout?.popOutWindow, sid, paymentProductType);
1462
+ popOutModule.postPopOutActivePaymentProductType(checkout?.popOutWindow, sid, targetOrigin, paymentProductType);
1433
1463
  } else {
1434
- postActivePaymentProductType(iframe, sid, paymentProductType);
1464
+ postActivePaymentProductType(iframe, sid, targetOrigin, paymentProductType);
1435
1465
  }
1436
1466
  };
1437
1467
  const submitValidationResult = result => {
1438
- postValidationResult(iframe, sid, result);
1468
+ postValidationResult(iframe, sid, result, targetOrigin);
1439
1469
  // For pop out we do validation when opening the pop out
1440
1470
  };
1441
1471
  const submitAddressCallbackResult = result => {
1442
- postAddressCallbackResult(iframe, sid, result);
1472
+ postAddressCallbackResult(iframe, sid, result, targetOrigin);
1443
1473
  // For pop out we do validation when opening the pop out
1444
1474
  };
1445
1475
 
@@ -1560,6 +1590,9 @@ const embed = async options => {
1560
1590
  }, {
1561
1591
  handler: wrappedOnAddressCallback,
1562
1592
  eventTypes: [CheckoutEvents.AddressCallback]
1593
+ }, {
1594
+ handler: handlePaymentCompleted,
1595
+ eventTypes: paymentCompletedEvents
1563
1596
  }, {
1564
1597
  handler: handleShowButton,
1565
1598
  eventTypes: [InternalCheckoutEvents.ShowPopOutButton]
@@ -1580,7 +1613,8 @@ const embed = async options => {
1580
1613
  options: internalOptions,
1581
1614
  handlers,
1582
1615
  session: undefined,
1583
- popOutWindow: undefined
1616
+ popOutWindow: undefined,
1617
+ paymentCompleted: false
1584
1618
  };
1585
1619
  const checkoutInstance = checkout;
1586
1620
  for (const {
@@ -3,5 +3,5 @@
3
3
  v0.8.1 (c) Kyle Simpson
4
4
  MIT License: http://getify.mit-license.org
5
5
  */
6
- var n,o,i;i=function(){var e,t,n,o=Object.prototype.toString,i="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,t,n,o){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:!1!==o})}}catch(t){e=function(e,t,n){return e[t]=n,e}}function r(e,o){n.add(e,o),t||(t=i(n.drain))}function s(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t&&t}function a(){for(var e=0;e<this.chain.length;e++)d(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function d(e,t,n){var o,i;try{!1===t?n.reject(e.msg):(o=!0===t?e.msg:t.call(void 0,e.msg))===n.promise?n.reject(TypeError("Promise-chain cycle")):(i=s(o))?i.call(o,n.resolve,n.reject):n.resolve(o)}catch(e){n.reject(e)}}function c(e){var t,n=this;if(!n.triggered){n.triggered=!0,n.def&&(n=n.def);try{(t=s(e))?r(function(){var o=new u(n);try{t.call(e,function(){c.apply(o,arguments)},function(){l.apply(o,arguments)})}catch(e){l.call(o,e)}}):(n.msg=e,n.state=1,n.chain.length>0&&r(a,n))}catch(e){l.call(new u(n),e)}}}function l(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&r(a,t))}function p(e,t,n,o){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){n(i,e)},o)})(i)}function u(e){this.def=e,this.triggered=!1}function f(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function h(e){if("function"!=typeof e)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var t=new f(this);this.then=function(e,n){var o={success:"function"!=typeof e||e,failure:"function"==typeof n&&n};return o.promise=new this.constructor(function(e,t){if("function"!=typeof e||"function"!=typeof t)throw TypeError("Not a function");o.resolve=e,o.reject=t}),t.chain.push(o),0!==t.state&&r(a,t),o.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){c.call(t,e)},function(e){l.call(t,e)})}catch(e){l.call(t,e)}}n=function(){var e,n,o;function i(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(t,r){o=new i(t,r),n?n.next=o:e=o,n=o,o=void 0},drain:function(){var o=e;for(e=n=t=void 0;o;)o.fn.call(o.self),o=o.next}}}();var m=e({},"constructor",h,!1);return h.prototype=m,e(m,"__NPO__",0,!1),e(h,"resolve",function(e){return e&&"object"==typeof e&&1===e.__NPO__?e:new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");t(e)})}),e(h,"reject",function(e){return new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");n(e)})}),e(h,"all",function(e){var t=this;return"[object Array]"!=o.call(e)?t.reject(TypeError("Not an array")):0===e.length?t.resolve([]):new t(function(n,o){if("function"!=typeof n||"function"!=typeof o)throw TypeError("Not a function");var i=e.length,r=Array(i),s=0;p(t,e,function(e,t){r[e]=t,++s===i&&n(r)},o)})}),e(h,"race",function(e){var t=this;return"[object Array]"!=o.call(e)?t.reject(TypeError("Not an array")):new t(function(n,o){if("function"!=typeof n||"function"!=typeof o)throw TypeError("Not a function");p(t,e,function(e,t){n(t)},o)})}),h},(o=t)[n="Promise"]=o[n]||i(),e.exports&&(e.exports=o[n])});var n="0.12.15";let o=function(e){return e.SessionNotFound="SessionNotFound",e.SessionLoaded="SessionLoaded",e.SessionUpdated="SessionUpdated",e.SessionCancel="SessionCancel",e.SessionPaymentOnHold="SessionPaymentOnHold",e.SessionPaymentAuthorized="SessionPaymentAuthorized",e.SessionPaymentError="SessionPaymentError",e.SessionLocked="SessionLocked",e.SessionLockFailed="SessionLockFailed",e.ActivePaymentProductType="ActivePaymentProductType",e.ValidateSession="ValidateSession",e.AddressCallback="AddressCallback",e}({}),i=function(e){return e.HeightChanged="HeightChanged",e.LanguageChanged="LanguageChanged",e.ScrollToTop="ScrollToTop",e.ShowPopOutButton="ShowPopOutButton",e.HidePopOutButton="HidePopOutButton",e.TopLevelNavigation="TopLevelNavigation",e}({});const r=e=>e.endsWith("/")?e:`${e}/`,s=()=>{try{const{hostname:e}=window.location;return e}catch(e){return}},a=()=>{try{if(window.self===window.top)return!0;const e=s(),t=window.top?.location.hostname;return Boolean(t&&e&&e===t)}catch(e){return!1}},d=({sid:e,endpoint:t,language:o,shouldCallValidateSession:i})=>{const a=new URLSearchParams;a.append("ui","fullscreen"),a.append("role","pop_out_payment"),a.append("sid",e),a.append("sdk",n),o&&a.append("language",o),i&&a.append("loader","true");const d=s();return d&&a.append("sdk_hostname",d),`${r(t)}?${a.toString()}`},c=e=>{const{sid:t,endpoint:o,language:i,ui:d,shouldCallValidateSession:c,shouldCallAddressCallback:l,popOut:p,redirect:u}=e;if(!o)throw new Error("Invalid endpoint");const f=new URLSearchParams;f.append("sdk",n),d&&f.append("ui",d),i&&f.append("language",i),c&&f.append("client_side_validation","true"),l&&f.append("client_side_address_callback","true"),p&&f.append("role","pop_out_launcher"),e.hasOwnProperty("hideTestMessage")&&void 0!==e.hideTestMessage&&!0===e.hideTestMessage&&f.append("hide_test_message","true");const h=s();return h&&f.append("sdk_hostname",h),u||a()||f.append("sdk_not_top_level","true"),"https://checkout.dintero.com"===o?`${o}/v1/view/${t}?${f.toString()}`:(f.append("sid",t),`${r(o)}?${f.toString()}`)},l=e=>{window.location.assign(e)},p=async e=>{let t,n,o=-1;if(n&&!n.closed)return{close:()=>{},focus:()=>{},popOutWindow:void 0};const i=d(e);n=await((e,t,n,o)=>new Promise(i=>{try{const r=window.screenX+(window.outerWidth-n)/2,s=window.screenY+(window.outerHeight-o)/2,a=`width=${n},height=${o},left=${r},top=${s},location=no,menubar=no,toolbar=no,status=no`;let d,c=-1;const l=n=>{const o=n.source===d,r=n.origin===new URL(t).origin,s=n.data&&"AppLoaded"===n.data.type,a="popOut"===n.data.context,p=n.data.sid===e;o&&r&&s&&a&&p&&(clearTimeout(c),i(d),window.removeEventListener("message",l))};if(window.addEventListener("message",l),d=window.open(t,"dintero-checkout",a)??void 0,!d)return console.log("createPopOutWindow no popOut"),void i(void 0);c=window.setTimeout(()=>{console.log("createPopOutWindow timeout"),i(void 0)},1e4)}catch(e){i(void 0)}}))(e.sid,i,Math.min(480,window.screen.width),Math.min(840,window.screen.height));const r=()=>{window.clearInterval(o),o=-1,window.removeEventListener("beforeunload",s),n=void 0,e.onClose(),t&&t()},s=()=>{n&&n.close(),r()};return window.addEventListener("beforeunload",s),o=window.setInterval(()=>{n?.closed&&r()},200),n&&(t=e.onOpen(n)),{close:s,focus:()=>{n&&n.focus()},popOutWindow:n}},u=(e,t)=>{try{e&&e.postMessage({type:"LockSession",sid:t},"*")}catch(e){console.error(e)}},f=(e,t)=>{try{e&&e.postMessage({type:"RefreshSession",sid:t},"*")}catch(e){console.error(e)}},h=(e,t,n)=>{try{e&&e.postMessage({type:"SetActivePaymentProductType",sid:t,payment_product_type:n},"*")}catch(e){console.error(e)}},m="dintero-checkout-sdk-style",g="dintero-checkout-sdk-backdrop",y="dintero-checkout-sdk-backdrop-description",w="dintero-checkout-sdk-backdrop-focus",b="dintero-checkout-sdk-backdrop-close",v=e=>t=>(t.preventDefault(),t.stopPropagation(),e(),!1),L=()=>{const e=document.createElement("div");return e.setAttribute("id",g),e.setAttribute("role","dialog"),e.style.zIndex=(()=>{const e=document.getElementsByTagName("*"),t=Array.from(e).reduce((e,t)=>{try{const n=document.defaultView?.getComputedStyle(t,null).getPropertyValue("z-index"),o=Number.parseInt(n||"0",10);if(!Number.isNaN(o)&&o>e)return o}catch(e){console.error(e)}return e},0);return t<9999?"9999":(t+1).toString()})(),e},C=e=>{const t=document.getElementById(w),n=document.getElementById(b);"Tab"!==e.key&&"Tab"!==e.code||(document.activeElement===t?(n?.focus(),e.preventDefault()):(t?.focus(),e.preventDefault()))},S=e=>{(()=>{if(document.getElementById(m))return;const e=document.createElement("style");e.setAttribute("id",m),e.innerHTML=`\n @keyframes ${g}-fade-in {\n from {opacity: 0;}\n to {opacity: 1;}\n }\n\n #${g} {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n height: 100vh;\n width: 100vw;\n background-color: rgba(0,0,0,0.9);\n background: radial-gradient(rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.8) 100%);\n cursor: pointer;\n animation: 20ms ease-out ${g}-fade-in;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 20px;\n color: #ffffff;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';\n font-size: 18px;\n font-weight: 400;\n line-height: normal;\n text-rendering: geometricPrecision;\n margin: 0;\n padding: 0;\n border: 0;\n vertical-align: baseline;\n line-height: normal;\n }\n\n #${g} p {\n padding: 0;\n margin: 0;\n border: 0;\n user-select: none;\n }\n\n #${w} {\n background-color: #efefef !important;\n color: #000000 !important;\n font-size: 16px !important;\n font-weight: 600 !important;\n border-radius: 200px !important;\n margin: 0 !important;\n line-height: normal !important;\n border: none !important;\n padding: 10px 20px !important;\n user-select: none !important;\n cursor: pointer !important;\n }\n #${w}:hover,\n #${w}:focus {\n outline: none !important;\n background-color: #ffffff !important;\n border: none !important;\n color: #000000 !important;\n padding: 10px 20px !important;\n margin: 0 !important;\n }\n #${w}:focus{\n outline-offset: 2px;\n outline: 1px #ffffff solid !important;\n }\n\n #${b} {\n background: transparent !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n border-radius: 4px !important;\n height: 24px !important;\n width: 24px !important;\n color: #efefef !important;\n position: absolute !important;\n top: 16px !important;\n right: 24px !important;\n transition: all 200ms ease-out !important;\n cursor: pointer !important;\n }\n\n #${b}:hover,\n #${b}:focus {\n outline: none !important;\n color: #ffffff !important;\n border: none !important;\n background: transparent !important;\n padding: 0 !important;\n margin: 0 !important;\n position: absolute;\n top: 16px;\n right: 24px;\n }\n #${b}:focus{\n outline: 1px #ffffff solid !important;\n }\n\n #${g}:before,\n #${g}:after,\n #${g} > *:before,\n #${g} > *:after {\n content: '';\n content: none;\n }\n `,document.head.appendChild(e)})();const t=L(),n=(e=>{const t=document.createElement("button");return t.setAttribute("id",b),t.setAttribute("type","button"),t.setAttribute("aria-label",e),t.innerHTML='\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n stroke="currentColor"\n stroke-width="2"\n stroke-linecap="round"\n stroke-linejoin="round"\n alt="close icon"\n >\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>',t})(e.event.closeLabel),o=(()=>{const e=document.createElement("div");return e.innerHTML='\n <svg width="120px" height="22px" viewBox="0 0 630 111" version="1.1" >\n <g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">\n <g id="Dintero" fill="#ffffff" fillRule="nonzero">\n <path d="M376.23,60.48 L376.23,73.54 L454.13,73.54 C456.31,41.55 435.85,23.71 410.61,23.71 C385.37,23.71 367.09,41.77 367.09,66.79 C367.09,92.03 386.02,110.31 411.91,110.31 C433.02,110.31 448.9,97.25 453.25,82.24 L436.5,82.24 C432.37,89.42 423.88,95.51 411.91,95.51 C395.16,95.51 382.75,83.11 382.75,66.79 C382.75,50.69 394.72,38.5 410.6,38.5 C426.48,38.5 438.45,50.68 438.45,66.79 L444.54,60.48 L376.23,60.48 Z M154.29,17.83 L171.7,17.83 L171.7,0.42 L154.29,0.42 L154.29,17.83 Z M120.34,108.13 L191.27,108.13 L191.27,93.77 L120.34,93.77 L120.34,108.13 Z M156.46,40.24 L156.46,108.13 L171.69,108.13 L171.69,45.47 C171.69,32.85 165.82,25.89 151.89,25.89 L120.34,25.89 L120.34,40.25 L156.46,40.25 L156.46,40.24 Z M499.17,25.88 L464.36,25.88 L464.36,40.24 L483.94,40.24 L484.16,108.13 L499.39,108.13 L499.17,62.44 C499.17,48.51 508.53,40.25 521.58,40.25 L535.29,40.25 L535.29,25.89 L524.41,25.89 C509.18,25.89 501.78,31.33 497.65,41.56 L495.47,47 L499.17,47.65 L499.17,25.88 Z M288.76,25.88 L310.52,25.88 L310.52,6.3 L325.75,6.3 L325.75,25.88 L359.69,25.88 L359.69,40.24 L325.75,40.24 L325.75,93.77 L359.69,93.77 L359.69,108.13 L332.49,108.13 C318.56,108.13 310.51,98.99 310.51,86.37 L310.51,40.24 L288.75,40.24 L288.75,25.88 L288.76,25.88 Z M464.35,108.13 L535.28,108.13 L535.28,93.77 L464.35,93.77 L464.35,108.13 Z M108.6,54.17 C108.6,23.06 85.54,0.43 53.77,0.43 L0.9,0.43 L0.9,108.14 L53.77,108.14 C85.53,108.13 108.6,85.5 108.6,54.17 M248.07,23.71 C234.58,23.71 223.92,31.98 220,41.55 L220,25.88 L204.77,25.88 L204.77,108.13 L220,108.13 L220,66.35 C220,53.08 224.79,38.93 243.72,38.93 C259.39,38.93 267.44,48.07 267.44,67.43 L267.44,108.12 L282.67,108.12 L282.67,64.6 C282.67,35.02 265.91,23.71 248.07,23.71 M586.2,110.31 C611.22,110.31 629.72,92.03 629.72,67.01 C629.72,41.99 611.23,23.71 586.2,23.71 C560.96,23.71 542.68,41.99 542.68,67.01 C542.68,92.03 560.96,110.31 586.2,110.31 M586.2,95.51 C570.32,95.51 558.35,83.33 558.35,67.01 C558.35,50.69 570.32,38.51 586.2,38.51 C602.08,38.51 614.05,50.69 614.05,67.01 C614.05,83.33 602.08,95.51 586.2,95.51 M16.99,92.9 L16.99,15.66 L51.8,15.66 C75.3,15.66 92.05,31.98 92.05,54.61 C92.05,76.8 75.3,92.91 51.8,92.91 L16.99,92.91 L16.99,92.9 Z" id="Shape"></path>\n </g>\n </g>\n </svg>',e})(),i=(e=>{const t=document.createElement("p");return t.setAttribute("id",y),t.innerText=e,t})(e.event.descriptionLabel),r=(e=>{const t=document.createElement("button");return t.setAttribute("id",w),t.setAttribute("type","button"),t.innerText=e,t})(e.event.focusLabel);return t.onclick=v(e.focus),r.onclick=v(e.focus),n.onclick=v(e.close),document.addEventListener("keydown",C),t.appendChild(n),t.appendChild(o),t.appendChild(i),t.appendChild(r),document.body.appendChild(t),t.focus(),t},k=()=>{try{const e=document.getElementById(g);e&&document.body.removeChild(e),document.removeEventListener("keydown",C)}catch(e){console.error(e)}},T="dintero-checkout-sdk-launch-pop-out",x=(e,t)=>{if(!e&&!t)return;const n=`${T}-styles`;if(document.getElementById(n))return;const o=document.createElement("style");o.setAttribute("id",n);const i=[];e&&i.push(P(`#${T}:hover:not(:disabled)`,e)),t&&i.push(P(`#${T}:focus-visible`,t)),o.textContent=i.join("\n"),document.head.appendChild(o)},P=(e,t)=>[`${e} {`,E(t),"}"].join("\n"),E=e=>Object.entries(e).map(([e,t])=>` ${O(e)}: ${t} !important;`).join("\n"),O=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),A=e=>{const{container:t}=e,n=document.getElementById(T),o=n||document.createElement("button");((e,{label:t,disabled:n,top:o,left:i,right:r,styles:s,onClick:a,stylesHover:d,stylesFocusVisible:c})=>{e.setAttribute("id",T),e.setAttribute("type","button"),"true"===n?e.setAttribute("disabled",n):e.removeAttribute("disabled"),e.onclick=t=>{t.preventDefault(),t.stopPropagation(),e.style.boxShadow="inset 0 0 10px rgba(34, 84, 65, 0.9)",a(),window.setTimeout(()=>{e.style.boxShadow="none"},200)},e.innerText=t,e.style.position="absolute",e.style.top=`${o}px`,e.style.left=`${i}px`,e.style.right=`${r}px`;const{...l}=s;for(const[t,n]of Object.entries(l))e.style[t]=n;try{x(d,c)}catch(e){console.error(e)}})(o,e),n||t.appendChild(o)},$=()=>{try{const e=document.getElementById(T);e&&e.remove()}catch(e){console.error(e)}},W=(e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"ValidationResult",sid:t,...n},"*")},_=e=>{const{sid:t,endpoint:n,handler:o,eventTypes:i,checkout:r}=e,s=new URL(n),a=e=>{const n=e.origin===s.origin,a=e.source===r.iframe.contentWindow,d=e.data&&e.data.sid===t,c=-1!==i.indexOf(e.data?.type);n&&a&&d&&c&&(((e,t)=>{t.data.mid&&e&&e.postMessage({ack:t.data.mid},t.origin||"*")})(r.iframe.contentWindow,e),o(e.data,r))};window.addEventListener("message",a,!1);return{unsubscribe:()=>{window.removeEventListener("message",a,!1)}}},M=(e,t)=>{z(t),e.href&&l(e.href)},j=(e,t)=>{(e.height||0===e.height)&&t.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},V=(e,t)=>{try{t.iframe.scrollIntoView({block:"start",behavior:"smooth"})}catch(e){console.error(e)}},B=(e,t)=>{e.language&&(t.language=e.language)},N=e=>{try{e()}catch(e){console.error(e)}},I=async(e,t)=>{const n=await p({sid:t.options.sid,endpoint:t.options.endpoint??"https://checkout.dintero.com",shouldCallValidateSession:Boolean(t.options.onValidateSession),shouldCallAddressCallback:!1,language:e.language,onOpen:e=>((e,t)=>{const n={internalPopOutHandler:!0,eventTypes:[i.LanguageChanged],handler:(e,t)=>{var n,o,i;n=t.iframe,o=t.options.sid,i=e.language,n.contentWindow&&n.contentWindow.postMessage({type:"SetLanguage",sid:o,language:i},"*")}},r={internalPopOutHandler:!0,eventTypes:[o.SessionCancel,o.SessionPaymentOnHold,o.SessionPaymentAuthorized,o.SessionPaymentError],handler:(t,n)=>{if(t.href){$();try{e.close()}catch(e){console.error(e)}}else console.error("Payment Complete event missing href property")}},s=o=>{if(o.source===e&&"popOut"===o.data.context&&o.data.sid===t.options.sid)for(const e of[n,r,...t.handlers])if(e.eventTypes.includes(o.data.type)&&e.handler){const{handler:n}=e;N(()=>{n(o.data,t)})}};return window.addEventListener("message",s),()=>{window.removeEventListener("message",s)}})(e,t),onClose:()=>{var e,n;k(),e=t.iframe,n=t.options.sid,e.contentWindow&&e.contentWindow.postMessage({type:"ClosedPopOut",sid:n},"*"),(e=>{try{const t=document.getElementById(T);t&&(e?t.setAttribute("disabled",e.toString()):t.removeAttribute("disabled"))}catch(e){console.error(e)}})(!1),t.popOutWindow=void 0}}),{close:r,focus:s,popOutWindow:a}=n;return a?(d=t.iframe,c=t.options.sid,d.contentWindow&&d.contentWindow.postMessage({type:"OpenedPopOut",sid:c},"*"),t.popOutWindow=a,(e=>{try{if(document.getElementById(g))return;return S(e)}catch(e){console.error(e)}})({focus:s,close:r,event:e}),!0):(((e,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"OpenPopOutFailed",sid:t},"*")})(t.iframe,t.options.sid),!1);var d,c},H=async(e,t)=>{if(await I(e,t)&&t.options.onValidateSession){n=t.iframe,i=t.options.sid,n.contentWindow&&n.contentWindow.postMessage({type:"ValidatingPopOut",sid:i},"*");const r=((e,t)=>n=>{W(t.iframe,t.options.sid,n),n.success&&t.popOutWindow?t.popOutWindow.location.href=d({sid:t.options.sid,endpoint:t.options.endpoint??"https://checkout.dintero.com",shouldCallValidateSession:!1,shouldCallAddressCallback:!1,language:e.language}):(t.popOutWindow&&t.popOutWindow.close(),console.error(n.clientValidationError))})(e,t);try{t.options.onValidateSession({type:o.ValidateSession,session:t.session,callback:r},t,r)}catch(e){console.error(e),W(t.iframe,t.options.sid,{success:!1,clientValidationError:"Validation runtime error"})}}var n,i},F=(e,t)=>{(e=>"object"==typeof e&&null!==e&&e.type===i.ShowPopOutButton)(e)&&(e.session&&(t.session=e.session),A({container:t.options.innerContainer,label:e.openLabel,top:e.top,left:e.left,right:e.right,styles:e.styles,stylesHover:e.stylesHover,stylesFocusVisible:e.stylesFocusVisible,disabled:e.disabled,onClick:()=>H(e,t)}),(e=>{const t=document.getElementById(w);t&&(t.innerText=e.focusLabel);const n=document.getElementById(y);n&&(n.innerText=e.descriptionLabel);const o=document.getElementById(b);o&&o.setAttribute("aria-label",e.descriptionLabel)})(e))},R=(e,t)=>{e.type===i.HidePopOutButton&&$()},z=e=>{if($(),k(),e.popOutWindow)try{e.popOutWindow.close()}catch(e){console.error(e)}};e.embed=async e=>{const t=document.createElement("div");t.style.position="relative",t.style.boxSizing="border-box";const r={endpoint:"https://checkout.dintero.com",innerContainer:t,...e},{container:s,sid:a,language:d,endpoint:l,onSession:p,onSessionCancel:m,onPayment:g,onPaymentAuthorized:y,onPaymentError:w,onSessionNotFound:b,onSessionLocked:v,onSessionLockFailed:L,onActivePaymentType:C,onValidateSession:S,onAddressCallback:T,popOut:x}=r;let P;const E=[];let O=!1;s.appendChild(t);const{iframe:A,initiate:$}=((e,t)=>{if(!e?.appendChild)throw new Error("Invalid container");const n=document.createElement("iframe");return n.setAttribute("frameborder","0"),n.setAttribute("allowTransparency","true"),n.setAttribute("style","width:100%; height:0;"),n.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-top-navigation"),n.setAttribute("allow","payment; clipboard-write *"),n.setAttribute("importance","high"),n.setAttribute("src",t),{iframe:n,initiate:async()=>new Promise((t,o)=>{n.onload=()=>t(),n.onerror=()=>o(),e.appendChild(n)})}})(t,c({sid:a,endpoint:l,language:d,ui:e.ui||"inline",shouldCallValidateSession:void 0!==S,shouldCallAddressCallback:void 0!==T,popOut:x,...e.hasOwnProperty("hideTestMessage")&&{hideTestMessage:e.hideTestMessage}})),N=(e,t,n)=>{if(!P)throw new Error("Unable to create action promise: checkout is undefined");const o=P;return new Promise((i,r)=>{const s=[];s.push(_({sid:a,endpoint:l,handler:e=>{for(const e of s)e.unsubscribe();i(e)},eventTypes:[t],checkout:o,source:o.iframe.contentWindow})),s.push(_({sid:a,endpoint:l,handler:()=>{for(const e of s)e.unsubscribe();r(`Received unexpected event: ${n}`)},eventTypes:[n],checkout:o,source:o.iframe.contentWindow})),e()})},I=()=>N(()=>{((e,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:t},"*")})(A,a),f(P?.popOutWindow,a)},o.SessionUpdated,o.SessionNotFound),H=e=>{W(A,a,e)},U=e=>{((e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"AddressCallbackResult",sid:t,...n},"*")})(A,a,e)},Z=(e,t,i)=>(e,r)=>{if(!O){O=!0,z(r);const s=["sid","merchant_reference","transaction_id","error"].map(t=>[t,e[t]]);e.type!==o.SessionCancel||e.error||s.push(["error","cancelled"]),s.push(["language",r.language]),s.push(["sdk",n]);const a=s.filter(([e,t])=>t).map(([e,t])=>`${e}=${t}`).join("&");r.iframe.setAttribute("src",((e,t,n)=>{const o=e.endsWith("/")?"":"/";return`${e}${o}${t}?${n}`})(t,"embedResult/",a)),i(e,r)}},D=[{handler:B,eventTypes:[i.LanguageChanged]},{handler:j,eventTypes:[i.HeightChanged]},{handler:V,eventTypes:[i.ScrollToTop]},{handler:M,eventTypes:[i.TopLevelNavigation]},{handler:(e,t)=>{t.session=e.session,p&&p(e,t)},eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:Z(0,l,g??M)},{eventTypes:[o.SessionPaymentAuthorized],handler:Z(0,l,y??g??M)},{handler:Z(0,l,m??M),eventTypes:[o.SessionCancel]},{handler:Z(0,l,w??M),eventTypes:[o.SessionPaymentError]},{handler:b,eventTypes:[o.SessionNotFound]},{handler:(e,t)=>{v&&v(e,t,I)},eventTypes:[o.SessionLocked]},{handler:L,eventTypes:[o.SessionLockFailed]},{handler:C,eventTypes:[o.ActivePaymentProductType]},{handler:(e,t)=>{if(S)try{S({...e,callback:H},t,H)}catch(e){console.error(e),H({success:!1,clientValidationError:"Validation runtime error"})}},eventTypes:[o.ValidateSession]},{handler:(e,t)=>{if(T)try{T({...e,callback:U},t,U)}catch(e){console.error(e),U({success:!1,error:"Address callback runtime error"})}},eventTypes:[o.AddressCallback]},{handler:F,eventTypes:[i.ShowPopOutButton]},{handler:R,eventTypes:[i.HidePopOutButton]}];P={destroy:()=>{if(P&&z(P),A){r.popOut&&k();for(const e of E)e.unsubscribe();A.parentElement&&t.removeChild(A)}t.parentElement&&s.removeChild(t)},iframe:A,language:d??"",lockSession:()=>N(()=>{((e,t)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:t},"*")})(A,a),u(P?.popOutWindow,a)},o.SessionLocked,o.SessionLockFailed),refreshSession:I,setActivePaymentProductType:t=>{e.popOut?h(P?.popOutWindow,a,t):((e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:t,payment_product_type:n},"*")})(A,a,t)},submitValidationResult:H,submitAddressCallbackResult:U,options:r,handlers:D,session:void 0,popOutWindow:void 0};const q=P;for(const{handler:e,eventTypes:t}of D)e&&E.push(_({sid:a,endpoint:l,handler:e,eventTypes:t,checkout:q,source:q.iframe.contentWindow}));return await $(),q},e.redirect=e=>{const{sid:t,language:n,endpoint:o="https://checkout.dintero.com"}=e;l(c({sid:t,endpoint:o,language:n,shouldCallValidateSession:!1,shouldCallAddressCallback:!1,redirect:!0}))},Object.defineProperty(e,"__esModule",{value:!0})});
6
+ var n,o,i;i=function(){var e,t,n,o=Object.prototype.toString,i="undefined"!=typeof setImmediate?function(e){return setImmediate(e)}:setTimeout;try{Object.defineProperty({},"x",{}),e=function(e,t,n,o){return Object.defineProperty(e,t,{value:n,writable:!0,configurable:!1!==o})}}catch(t){e=function(e,t,n){return e[t]=n,e}}function r(e,o){n.add(e,o),t||(t=i(n.drain))}function s(e){var t,n=typeof e;return null==e||"object"!=n&&"function"!=n||(t=e.then),"function"==typeof t&&t}function a(){for(var e=0;e<this.chain.length;e++)d(this,1===this.state?this.chain[e].success:this.chain[e].failure,this.chain[e]);this.chain.length=0}function d(e,t,n){var o,i;try{!1===t?n.reject(e.msg):(o=!0===t?e.msg:t.call(void 0,e.msg))===n.promise?n.reject(TypeError("Promise-chain cycle")):(i=s(o))?i.call(o,n.resolve,n.reject):n.resolve(o)}catch(e){n.reject(e)}}function c(e){var t,n=this;if(!n.triggered){n.triggered=!0,n.def&&(n=n.def);try{(t=s(e))?r(function(){var o=new u(n);try{t.call(e,function(){c.apply(o,arguments)},function(){l.apply(o,arguments)})}catch(e){l.call(o,e)}}):(n.msg=e,n.state=1,n.chain.length>0&&r(a,n))}catch(e){l.call(new u(n),e)}}}function l(e){var t=this;t.triggered||(t.triggered=!0,t.def&&(t=t.def),t.msg=e,t.state=2,t.chain.length>0&&r(a,t))}function p(e,t,n,o){for(var i=0;i<t.length;i++)(function(i){e.resolve(t[i]).then(function(e){n(i,e)},o)})(i)}function u(e){this.def=e,this.triggered=!1}function f(e){this.promise=e,this.state=0,this.triggered=!1,this.chain=[],this.msg=void 0}function h(e){if("function"!=typeof e)throw TypeError("Not a function");if(0!==this.__NPO__)throw TypeError("Not a promise");this.__NPO__=1;var t=new f(this);this.then=function(e,n){var o={success:"function"!=typeof e||e,failure:"function"==typeof n&&n};return o.promise=new this.constructor(function(e,t){if("function"!=typeof e||"function"!=typeof t)throw TypeError("Not a function");o.resolve=e,o.reject=t}),t.chain.push(o),0!==t.state&&r(a,t),o.promise},this.catch=function(e){return this.then(void 0,e)};try{e.call(void 0,function(e){c.call(t,e)},function(e){l.call(t,e)})}catch(e){l.call(t,e)}}n=function(){var e,n,o;function i(e,t){this.fn=e,this.self=t,this.next=void 0}return{add:function(t,r){o=new i(t,r),n?n.next=o:e=o,n=o,o=void 0},drain:function(){var o=e;for(e=n=t=void 0;o;)o.fn.call(o.self),o=o.next}}}();var m=e({},"constructor",h,!1);return h.prototype=m,e(m,"__NPO__",0,!1),e(h,"resolve",function(e){return e&&"object"==typeof e&&1===e.__NPO__?e:new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");t(e)})}),e(h,"reject",function(e){return new this(function(t,n){if("function"!=typeof t||"function"!=typeof n)throw TypeError("Not a function");n(e)})}),e(h,"all",function(e){var t=this;return"[object Array]"!=o.call(e)?t.reject(TypeError("Not an array")):0===e.length?t.resolve([]):new t(function(n,o){if("function"!=typeof n||"function"!=typeof o)throw TypeError("Not a function");var i=e.length,r=Array(i),s=0;p(t,e,function(e,t){r[e]=t,++s===i&&n(r)},o)})}),e(h,"race",function(e){var t=this;return"[object Array]"!=o.call(e)?t.reject(TypeError("Not an array")):new t(function(n,o){if("function"!=typeof n||"function"!=typeof o)throw TypeError("Not a function");p(t,e,function(e,t){n(t)},o)})}),h},(o=t)[n="Promise"]=o[n]||i(),e.exports&&(e.exports=o[n])});var n="0.12.17";let o=function(e){return e.SessionNotFound="SessionNotFound",e.SessionLoaded="SessionLoaded",e.SessionUpdated="SessionUpdated",e.SessionCancel="SessionCancel",e.SessionPaymentOnHold="SessionPaymentOnHold",e.SessionPaymentAuthorized="SessionPaymentAuthorized",e.SessionPaymentError="SessionPaymentError",e.SessionLocked="SessionLocked",e.SessionLockFailed="SessionLockFailed",e.ActivePaymentProductType="ActivePaymentProductType",e.ValidateSession="ValidateSession",e.AddressCallback="AddressCallback",e}({}),i=function(e){return e.HeightChanged="HeightChanged",e.LanguageChanged="LanguageChanged",e.ScrollToTop="ScrollToTop",e.ShowPopOutButton="ShowPopOutButton",e.HidePopOutButton="HidePopOutButton",e.TopLevelNavigation="TopLevelNavigation",e}({});const r=e=>e.endsWith("/")?e:`${e}/`,s=()=>{try{const{hostname:e}=window.location;return e}catch(e){return}},a=()=>{try{if(window.self===window.top)return!0;const e=s(),t=window.top?.location.hostname;return Boolean(t&&e&&e===t)}catch(e){return!1}},d=({sid:e,endpoint:t,language:o,shouldCallValidateSession:i})=>{const a=new URLSearchParams;a.append("ui","fullscreen"),a.append("role","pop_out_payment"),a.append("sid",e),a.append("sdk",n),o&&a.append("language",o),i&&a.append("loader","true");const d=s();return d&&a.append("sdk_hostname",d),`${r(t)}?${a.toString()}`},c=e=>{const{sid:t,endpoint:o,language:i,ui:d,shouldCallValidateSession:c,shouldCallAddressCallback:l,popOut:p,redirect:u}=e;if(!o)throw new Error("Invalid endpoint");const f=new URLSearchParams;f.append("sdk",n),d&&f.append("ui",d),i&&f.append("language",i),c&&f.append("client_side_validation","true"),l&&f.append("client_side_address_callback","true"),p&&f.append("role","pop_out_launcher"),e.hasOwnProperty("hideTestMessage")&&void 0!==e.hideTestMessage&&!0===e.hideTestMessage&&f.append("hide_test_message","true");const h=s();return h&&f.append("sdk_hostname",h),u||a()||f.append("sdk_not_top_level","true"),"https://checkout.dintero.com"===o?`${o}/v1/view/${t}?${f.toString()}`:(f.append("sid",t),`${r(o)}?${f.toString()}`)},l=e=>{const t=e||"https://checkout.dintero.com";try{return new URL(t).origin}catch{throw new Error("Invalid endpoint")}},p=e=>{window.location.assign(e)},u=async e=>{let t,n,o=-1;if(n&&!n.closed)return{close:()=>{},focus:()=>{},popOutWindow:void 0};const i=d(e);n=await((e,t,n,o)=>new Promise(i=>{try{const r=window.screenX+(window.outerWidth-n)/2,s=window.screenY+(window.outerHeight-o)/2,a=`width=${n},height=${o},left=${r},top=${s},location=no,menubar=no,toolbar=no,status=no`;let d,c=-1;const l=n=>{const o=n.source===d,r=n.origin===new URL(t).origin,s=n.data&&"AppLoaded"===n.data.type,a="popOut"===n.data.context,p=n.data.sid===e;o&&r&&s&&a&&p&&(clearTimeout(c),i(d),window.removeEventListener("message",l))};if(window.addEventListener("message",l),d=window.open(t,"dintero-checkout",a)??void 0,!d)return console.log("createPopOutWindow no popOut"),void i(void 0);c=window.setTimeout(()=>{console.log("createPopOutWindow timeout"),i(void 0)},1e4)}catch(e){i(void 0)}}))(e.sid,i,Math.min(480,window.screen.width),Math.min(840,window.screen.height));const r=()=>{window.clearInterval(o),o=-1,window.removeEventListener("beforeunload",s),n=void 0,e.onClose(),t&&t()},s=()=>{n&&n.close(),r()};return window.addEventListener("beforeunload",s),o=window.setInterval(()=>{n?.closed&&r()},200),n&&(t=e.onOpen(n)),{close:s,focus:()=>{n&&n.focus()},popOutWindow:n}},f=(e,t,n)=>{try{e&&e.postMessage({type:"LockSession",sid:t},n)}catch(e){console.error(e)}},h=(e,t,n)=>{try{e&&e.postMessage({type:"RefreshSession",sid:t},n)}catch(e){console.error(e)}},m=(e,t,n,o)=>{try{e&&e.postMessage({type:"SetActivePaymentProductType",sid:t,payment_product_type:o},n)}catch(e){console.error(e)}},y="dintero-checkout-sdk-style",g="dintero-checkout-sdk-backdrop",w="dintero-checkout-sdk-backdrop-description",v="dintero-checkout-sdk-backdrop-focus",b="dintero-checkout-sdk-backdrop-close",L=e=>t=>(t.preventDefault(),t.stopPropagation(),e(),!1),C=()=>{const e=document.createElement("div");return e.setAttribute("id",g),e.setAttribute("role","dialog"),e.style.zIndex=(()=>{const e=document.getElementsByTagName("*"),t=Array.from(e).reduce((e,t)=>{try{const n=document.defaultView?.getComputedStyle(t,null).getPropertyValue("z-index"),o=Number.parseInt(n||"0",10);if(!Number.isNaN(o)&&o>e)return o}catch(e){console.error(e)}return e},0);return t<9999?"9999":(t+1).toString()})(),e},S=e=>{const t=document.getElementById(v),n=document.getElementById(b);"Tab"!==e.key&&"Tab"!==e.code||(document.activeElement===t?(n?.focus(),e.preventDefault()):(t?.focus(),e.preventDefault()))},k=e=>{(()=>{if(document.getElementById(y))return;const e=document.createElement("style");e.setAttribute("id",y),e.innerHTML=`\n @keyframes ${g}-fade-in {\n from {opacity: 0;}\n to {opacity: 1;}\n }\n\n #${g} {\n position: fixed;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n height: 100vh;\n width: 100vw;\n background-color: rgba(0,0,0,0.9);\n background: radial-gradient(rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.8) 100%);\n cursor: pointer;\n animation: 20ms ease-out ${g}-fade-in;\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n gap: 20px;\n color: #ffffff;\n font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';\n font-size: 18px;\n font-weight: 400;\n line-height: normal;\n text-rendering: geometricPrecision;\n margin: 0;\n padding: 0;\n border: 0;\n vertical-align: baseline;\n line-height: normal;\n }\n\n #${g} p {\n padding: 0;\n margin: 0;\n border: 0;\n user-select: none;\n }\n\n #${v} {\n background-color: #efefef !important;\n color: #000000 !important;\n font-size: 16px !important;\n font-weight: 600 !important;\n border-radius: 200px !important;\n margin: 0 !important;\n line-height: normal !important;\n border: none !important;\n padding: 10px 20px !important;\n user-select: none !important;\n cursor: pointer !important;\n }\n #${v}:hover,\n #${v}:focus {\n outline: none !important;\n background-color: #ffffff !important;\n border: none !important;\n color: #000000 !important;\n padding: 10px 20px !important;\n margin: 0 !important;\n }\n #${v}:focus{\n outline-offset: 2px;\n outline: 1px #ffffff solid !important;\n }\n\n #${b} {\n background: transparent !important;\n padding: 0 !important;\n margin: 0 !important;\n border: none !important;\n border-radius: 4px !important;\n height: 24px !important;\n width: 24px !important;\n color: #efefef !important;\n position: absolute !important;\n top: 16px !important;\n right: 24px !important;\n transition: all 200ms ease-out !important;\n cursor: pointer !important;\n }\n\n #${b}:hover,\n #${b}:focus {\n outline: none !important;\n color: #ffffff !important;\n border: none !important;\n background: transparent !important;\n padding: 0 !important;\n margin: 0 !important;\n position: absolute;\n top: 16px;\n right: 24px;\n }\n #${b}:focus{\n outline: 1px #ffffff solid !important;\n }\n\n #${g}:before,\n #${g}:after,\n #${g} > *:before,\n #${g} > *:after {\n content: '';\n content: none;\n }\n `,document.head.appendChild(e)})();const t=C(),n=(e=>{const t=document.createElement("button");return t.setAttribute("id",b),t.setAttribute("type","button"),t.setAttribute("aria-label",e),t.innerHTML='\n <svg\n xmlns="http://www.w3.org/2000/svg"\n width="24"\n height="24"\n viewBox="0 0 24 24"\n fill="none"\n stroke="currentColor"\n stroke-width="2"\n stroke-linecap="round"\n stroke-linejoin="round"\n alt="close icon"\n >\n <line x1="18" y1="6" x2="6" y2="18"></line>\n <line x1="6" y1="6" x2="18" y2="18"></line>\n </svg>',t})(e.event.closeLabel),o=(()=>{const e=document.createElement("div");return e.innerHTML='\n <svg width="120px" height="22px" viewBox="0 0 630 111" version="1.1" >\n <g id="Page-1" stroke="none" strokeWidth="1" fill="none" fillRule="evenodd">\n <g id="Dintero" fill="#ffffff" fillRule="nonzero">\n <path d="M376.23,60.48 L376.23,73.54 L454.13,73.54 C456.31,41.55 435.85,23.71 410.61,23.71 C385.37,23.71 367.09,41.77 367.09,66.79 C367.09,92.03 386.02,110.31 411.91,110.31 C433.02,110.31 448.9,97.25 453.25,82.24 L436.5,82.24 C432.37,89.42 423.88,95.51 411.91,95.51 C395.16,95.51 382.75,83.11 382.75,66.79 C382.75,50.69 394.72,38.5 410.6,38.5 C426.48,38.5 438.45,50.68 438.45,66.79 L444.54,60.48 L376.23,60.48 Z M154.29,17.83 L171.7,17.83 L171.7,0.42 L154.29,0.42 L154.29,17.83 Z M120.34,108.13 L191.27,108.13 L191.27,93.77 L120.34,93.77 L120.34,108.13 Z M156.46,40.24 L156.46,108.13 L171.69,108.13 L171.69,45.47 C171.69,32.85 165.82,25.89 151.89,25.89 L120.34,25.89 L120.34,40.25 L156.46,40.25 L156.46,40.24 Z M499.17,25.88 L464.36,25.88 L464.36,40.24 L483.94,40.24 L484.16,108.13 L499.39,108.13 L499.17,62.44 C499.17,48.51 508.53,40.25 521.58,40.25 L535.29,40.25 L535.29,25.89 L524.41,25.89 C509.18,25.89 501.78,31.33 497.65,41.56 L495.47,47 L499.17,47.65 L499.17,25.88 Z M288.76,25.88 L310.52,25.88 L310.52,6.3 L325.75,6.3 L325.75,25.88 L359.69,25.88 L359.69,40.24 L325.75,40.24 L325.75,93.77 L359.69,93.77 L359.69,108.13 L332.49,108.13 C318.56,108.13 310.51,98.99 310.51,86.37 L310.51,40.24 L288.75,40.24 L288.75,25.88 L288.76,25.88 Z M464.35,108.13 L535.28,108.13 L535.28,93.77 L464.35,93.77 L464.35,108.13 Z M108.6,54.17 C108.6,23.06 85.54,0.43 53.77,0.43 L0.9,0.43 L0.9,108.14 L53.77,108.14 C85.53,108.13 108.6,85.5 108.6,54.17 M248.07,23.71 C234.58,23.71 223.92,31.98 220,41.55 L220,25.88 L204.77,25.88 L204.77,108.13 L220,108.13 L220,66.35 C220,53.08 224.79,38.93 243.72,38.93 C259.39,38.93 267.44,48.07 267.44,67.43 L267.44,108.12 L282.67,108.12 L282.67,64.6 C282.67,35.02 265.91,23.71 248.07,23.71 M586.2,110.31 C611.22,110.31 629.72,92.03 629.72,67.01 C629.72,41.99 611.23,23.71 586.2,23.71 C560.96,23.71 542.68,41.99 542.68,67.01 C542.68,92.03 560.96,110.31 586.2,110.31 M586.2,95.51 C570.32,95.51 558.35,83.33 558.35,67.01 C558.35,50.69 570.32,38.51 586.2,38.51 C602.08,38.51 614.05,50.69 614.05,67.01 C614.05,83.33 602.08,95.51 586.2,95.51 M16.99,92.9 L16.99,15.66 L51.8,15.66 C75.3,15.66 92.05,31.98 92.05,54.61 C92.05,76.8 75.3,92.91 51.8,92.91 L16.99,92.91 L16.99,92.9 Z" id="Shape"></path>\n </g>\n </g>\n </svg>',e})(),i=(e=>{const t=document.createElement("p");return t.setAttribute("id",w),t.innerText=e,t})(e.event.descriptionLabel),r=(e=>{const t=document.createElement("button");return t.setAttribute("id",v),t.setAttribute("type","button"),t.innerText=e,t})(e.event.focusLabel);return t.onclick=L(e.focus),r.onclick=L(e.focus),n.onclick=L(e.close),document.addEventListener("keydown",S),t.appendChild(n),t.appendChild(o),t.appendChild(i),t.appendChild(r),document.body.appendChild(t),t.focus(),t},T=()=>{try{const e=document.getElementById(g);e&&document.body.removeChild(e),document.removeEventListener("keydown",S)}catch(e){console.error(e)}},x="dintero-checkout-sdk-launch-pop-out",P=(e,t)=>{if(!e&&!t)return;const n=`${x}-styles`;if(document.getElementById(n))return;const o=document.createElement("style");o.setAttribute("id",n);const i=[];e&&i.push(E(`#${x}:hover:not(:disabled)`,e)),t&&i.push(E(`#${x}:focus-visible`,t)),o.textContent=i.join("\n"),document.head.appendChild(o)},E=(e,t)=>[`${e} {`,O(t),"}"].join("\n"),O=e=>Object.entries(e).map(([e,t])=>` ${A(e)}: ${t} !important;`).join("\n"),A=e=>e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase(),$=e=>{const{container:t}=e,n=document.getElementById(x),o=n||document.createElement("button");((e,{label:t,disabled:n,top:o,left:i,right:r,styles:s,onClick:a,stylesHover:d,stylesFocusVisible:c})=>{e.setAttribute("id",x),e.setAttribute("type","button"),"true"===n?e.setAttribute("disabled",n):e.removeAttribute("disabled"),e.onclick=t=>{t.preventDefault(),t.stopPropagation(),e.style.boxShadow="inset 0 0 10px rgba(34, 84, 65, 0.9)",a(),window.setTimeout(()=>{e.style.boxShadow="none"},200)},e.innerText=t,e.style.position="absolute",e.style.top=`${o}px`,e.style.left=`${i}px`,e.style.right=`${r}px`;const{...l}=s;for(const[t,n]of Object.entries(l))e.style[t]=n;try{P(d,c)}catch(e){console.error(e)}})(o,e),n||t.appendChild(o)},W=()=>{try{const e=document.getElementById(x);e&&e.remove()}catch(e){console.error(e)}},_=(e,t,n,o)=>{e.contentWindow&&e.contentWindow.postMessage({type:"ValidationResult",sid:t,...n},o)},M=e=>{const{sid:t,endpoint:n,handler:o,eventTypes:i,checkout:r}=e,s=new URL(n),a=e=>{const n=e.origin===s.origin,a=e.source===r.iframe.contentWindow,d=e.data&&e.data.sid===t,c=-1!==i.indexOf(e.data?.type);n&&a&&d&&c&&(((e,t,n)=>{t.data.mid&&e&&e.postMessage({ack:t.data.mid},n)})(r.iframe.contentWindow,e,s.origin),o(e.data,r))};window.addEventListener("message",a,!1);return{unsubscribe:()=>{window.removeEventListener("message",a,!1)}}},j=(e,t)=>{D(t),e.href&&p(e.href)},V=(e,t)=>{(e.height||0===e.height)&&t.iframe.setAttribute("style",`width:100%; height:${e.height}px;`)},B=(e,t)=>{try{t.iframe.scrollIntoView({block:"start",behavior:"smooth"})}catch(e){console.error(e)}},N=(e,t)=>{e.language&&(t.language=e.language)},I=[o.SessionCancel,o.SessionPaymentOnHold,o.SessionPaymentAuthorized,o.SessionPaymentError],H=e=>{try{e()}catch(e){console.error(e)}},R=async(e,t)=>{const n=await u({sid:t.options.sid,endpoint:t.options.endpoint??"https://checkout.dintero.com",shouldCallValidateSession:Boolean(t.options.onValidateSession),shouldCallAddressCallback:!1,language:e.language,onOpen:e=>((e,t)=>{const n={internalPopOutHandler:!0,eventTypes:[i.LanguageChanged],handler:(e,t)=>{var n,o,i,r;n=t.iframe,o=t.options.sid,i=e.language,r=l(t.options.endpoint),n.contentWindow&&n.contentWindow.postMessage({type:"SetLanguage",sid:o,language:i},r)}},o={internalPopOutHandler:!0,eventTypes:I,handler:(t,n)=>{if(t.href){W();try{e.close()}catch(e){console.error(e)}}else console.error("Payment Complete event missing href property")}},r=i=>{if(i.source===e&&"popOut"===i.data.context&&i.data.sid===t.options.sid)for(const e of[n,o,...t.handlers])if(e.eventTypes.includes(i.data.type)&&e.handler){const{handler:n}=e;H(()=>{n(i.data,t)})}};return window.addEventListener("message",r),()=>{window.removeEventListener("message",r)}})(e,t),onClose:()=>{var e,n,o;T(),e=t.iframe,n=t.options.sid,o=l(t.options.endpoint),e.contentWindow&&e.contentWindow.postMessage({type:"ClosedPopOut",sid:n},o),(e=>{try{const t=document.getElementById(x);t&&(e?t.setAttribute("disabled",e.toString()):t.removeAttribute("disabled"))}catch(e){console.error(e)}})(!1),t.popOutWindow=void 0}}),{close:o,focus:r,popOutWindow:s}=n;return s?(a=t.iframe,d=t.options.sid,c=l(t.options.endpoint),a.contentWindow&&a.contentWindow.postMessage({type:"OpenedPopOut",sid:d},c),t.popOutWindow=s,(e=>{try{if(document.getElementById(g))return;return k(e)}catch(e){console.error(e)}})({focus:r,close:o,event:e}),!0):(((e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"OpenPopOutFailed",sid:t},n)})(t.iframe,t.options.sid,l(t.options.endpoint)),!1);var a,d,c},F=async(e,t)=>{if(await R(e,t)&&t.options.onValidateSession){n=t.iframe,i=t.options.sid,r=l(t.options.endpoint),n.contentWindow&&n.contentWindow.postMessage({type:"ValidatingPopOut",sid:i},r);const s=((e,t)=>n=>{_(t.iframe,t.options.sid,n,l(t.options.endpoint)),n.success&&t.popOutWindow?t.popOutWindow.location.href=d({sid:t.options.sid,endpoint:t.options.endpoint??"https://checkout.dintero.com",shouldCallValidateSession:!1,shouldCallAddressCallback:!1,language:e.language}):(t.popOutWindow&&t.popOutWindow.close(),console.error(n.clientValidationError))})(e,t);try{t.options.onValidateSession({type:o.ValidateSession,session:t.session,callback:s},t,s)}catch(e){console.error(e),_(t.iframe,t.options.sid,{success:!1,clientValidationError:"Validation runtime error"},l(t.options.endpoint))}}var n,i,r},U=(e,t)=>{t.paymentCompleted||(e=>"object"==typeof e&&null!==e&&e.type===i.ShowPopOutButton)(e)&&(e.session&&(t.session=e.session),$({container:t.options.innerContainer,label:e.openLabel,top:e.top,left:e.left,right:e.right,styles:e.styles,stylesHover:e.stylesHover,stylesFocusVisible:e.stylesFocusVisible,disabled:e.disabled,onClick:()=>F(e,t)}),(e=>{const t=document.getElementById(v);t&&(t.innerText=e.focusLabel);const n=document.getElementById(w);n&&(n.innerText=e.descriptionLabel);const o=document.getElementById(b);o&&o.setAttribute("aria-label",e.descriptionLabel)})(e))},z=(e,t)=>{e.type===i.HidePopOutButton&&W()},Z=(e,t)=>{t.paymentCompleted=!0,W()},D=e=>{if(W(),T(),e.popOutWindow)try{e.popOutWindow.close()}catch(e){console.error(e)}};e.embed=async e=>{const t=document.createElement("div");t.style.position="relative",t.style.boxSizing="border-box";const r={endpoint:"https://checkout.dintero.com",innerContainer:t,...e},{container:s,sid:a,language:d,endpoint:p,onSession:u,onSessionCancel:y,onPayment:g,onPaymentAuthorized:w,onPaymentError:v,onSessionNotFound:b,onSessionLocked:L,onSessionLockFailed:C,onActivePaymentType:S,onValidateSession:k,onAddressCallback:x,popOut:P}=r,E=l(p);let O;const A=[];let $=!1;s.appendChild(t);const{iframe:W,initiate:H}=((e,t)=>{if(!e?.appendChild)throw new Error("Invalid container");const n=document.createElement("iframe");return n.setAttribute("frameborder","0"),n.setAttribute("allowTransparency","true"),n.setAttribute("style","width:100%; height:0;"),n.setAttribute("sandbox","allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-top-navigation"),n.setAttribute("allow","payment; clipboard-write *"),n.setAttribute("importance","high"),n.setAttribute("src",t),{iframe:n,initiate:async()=>new Promise((t,o)=>{n.onload=()=>t(),n.onerror=()=>o(),e.appendChild(n)})}})(t,c({sid:a,endpoint:p,language:d,ui:e.ui||"inline",shouldCallValidateSession:void 0!==k,shouldCallAddressCallback:void 0!==x,popOut:P,...e.hasOwnProperty("hideTestMessage")&&{hideTestMessage:e.hideTestMessage}})),R=(e,t,n)=>{if(!O)throw new Error("Unable to create action promise: checkout is undefined");const o=O;return new Promise((i,r)=>{const s=[];s.push(M({sid:a,endpoint:p,handler:e=>{for(const e of s)e.unsubscribe();i(e)},eventTypes:[t],checkout:o,source:o.iframe.contentWindow})),s.push(M({sid:a,endpoint:p,handler:()=>{for(const e of s)e.unsubscribe();r(`Received unexpected event: ${n}`)},eventTypes:[n],checkout:o,source:o.iframe.contentWindow})),e()})},F=()=>R(()=>{((e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"RefreshSession",sid:t},n)})(W,a,E),h(O?.popOutWindow,a,E)},o.SessionUpdated,o.SessionNotFound),q=e=>{_(W,a,e,E)},X=e=>{((e,t,n,o)=>{e.contentWindow&&e.contentWindow.postMessage({type:"AddressCallbackResult",sid:t,...n},o)})(W,a,e,E)},Y=(e,t,i)=>(e,r)=>{if(!$){$=!0,D(r);const s=["sid","merchant_reference","transaction_id","error"].map(t=>[t,e[t]]);e.type!==o.SessionCancel||e.error||s.push(["error","cancelled"]),s.push(["language",r.language]),s.push(["sdk",n]);const a=s.filter(([e,t])=>t).map(([e,t])=>`${e}=${t}`).join("&");r.iframe.setAttribute("src",((e,t,n)=>{const o=e.endsWith("/")?"":"/";return`${e}${o}${t}?${n}`})(t,"embedResult/",a)),i(e,r)}},G=[{handler:N,eventTypes:[i.LanguageChanged]},{handler:V,eventTypes:[i.HeightChanged]},{handler:B,eventTypes:[i.ScrollToTop]},{handler:j,eventTypes:[i.TopLevelNavigation]},{handler:(e,t)=>{t.session=e.session,u&&u(e,t)},eventTypes:[o.SessionLoaded,o.SessionUpdated]},{eventTypes:[o.SessionPaymentOnHold],handler:Y(0,p,g??j)},{eventTypes:[o.SessionPaymentAuthorized],handler:Y(0,p,w??g??j)},{handler:Y(0,p,y??j),eventTypes:[o.SessionCancel]},{handler:Y(0,p,v??j),eventTypes:[o.SessionPaymentError]},{handler:b,eventTypes:[o.SessionNotFound]},{handler:(e,t)=>{L&&L(e,t,F)},eventTypes:[o.SessionLocked]},{handler:C,eventTypes:[o.SessionLockFailed]},{handler:S,eventTypes:[o.ActivePaymentProductType]},{handler:(e,t)=>{if(k)try{k({...e,callback:q},t,q)}catch(e){console.error(e),q({success:!1,clientValidationError:"Validation runtime error"})}},eventTypes:[o.ValidateSession]},{handler:(e,t)=>{if(x)try{x({...e,callback:X},t,X)}catch(e){console.error(e),X({success:!1,error:"Address callback runtime error"})}},eventTypes:[o.AddressCallback]},{handler:Z,eventTypes:I},{handler:U,eventTypes:[i.ShowPopOutButton]},{handler:z,eventTypes:[i.HidePopOutButton]}];O={destroy:()=>{if(O&&D(O),W){r.popOut&&T();for(const e of A)e.unsubscribe();W.parentElement&&t.removeChild(W)}t.parentElement&&s.removeChild(t)},iframe:W,language:d??"",lockSession:()=>R(()=>{((e,t,n)=>{e.contentWindow&&e.contentWindow.postMessage({type:"LockSession",sid:t},n)})(W,a,E),f(O?.popOutWindow,a,E)},o.SessionLocked,o.SessionLockFailed),refreshSession:F,setActivePaymentProductType:t=>{e.popOut?m(O?.popOutWindow,a,E,t):((e,t,n,o)=>{e.contentWindow&&e.contentWindow.postMessage({type:"SetActivePaymentProductType",sid:t,payment_product_type:o},n)})(W,a,E,t)},submitValidationResult:q,submitAddressCallbackResult:X,options:r,handlers:G,session:void 0,popOutWindow:void 0,paymentCompleted:!1};const J=O;for(const{handler:e,eventTypes:t}of G)e&&A.push(M({sid:a,endpoint:p,handler:e,eventTypes:t,checkout:J,source:J.iframe.contentWindow}));return await H(),J},e.redirect=e=>{const{sid:t,language:n,endpoint:o="https://checkout.dintero.com"}=e;p(c({sid:t,endpoint:o,language:n,shouldCallValidateSession:!1,shouldCallAddressCallback:!1,redirect:!0}))},Object.defineProperty(e,"__esModule",{value:!0})});
7
7
  //# sourceMappingURL=dintero-checkout-web-sdk.umd.min.js.map