@usethrottle/checkout-react 2.1.0 → 2.2.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.
package/dist/index.js CHANGED
@@ -1,3 +1,1000 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // ../../node_modules/.pnpm/@gr4vy+secure-fields@2.11.1/node_modules/@gr4vy/secure-fields/lib/index.js
28
+ var require_lib = __commonJS({
29
+ "../../node_modules/.pnpm/@gr4vy+secure-fields@2.11.1/node_modules/@gr4vy/secure-fields/lib/index.js"(exports, module) {
30
+ "use strict";
31
+ !(function(e, t) {
32
+ if ("object" == typeof exports && "object" == typeof module) module.exports = t();
33
+ else if ("function" == typeof define && define.amd) define([], t);
34
+ else {
35
+ var r = t();
36
+ for (var n in r) ("object" == typeof exports ? exports : e)[n] = r[n];
37
+ }
38
+ })(exports, () => (() => {
39
+ "use strict";
40
+ const e = { d: (t2, r2) => {
41
+ for (var n2 in r2) e.o(r2, n2) && !e.o(t2, n2) && Object.defineProperty(t2, n2, { enumerable: true, get: r2[n2] });
42
+ }, o: (e2, t2) => Object.prototype.hasOwnProperty.call(e2, t2), r: (e2) => {
43
+ Object.defineProperty(e2, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e2, "__esModule", { value: true });
44
+ } };
45
+ let t = {};
46
+ e.r(t), e.d(t, { Events: () => o, SecureFields: () => te, SecureInput: () => W });
47
+ var r = function(e2) {
48
+ var t2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "production";
49
+ return "https://".concat(arguments.length > 2 ? arguments[2] : void 0, ".").concat("sandbox" === t2 ? "sandbox." : "").concat(e2, ".gr4vy.app");
50
+ }, n = (e2, t2) => "".concat(e2, "?").concat(new URLSearchParams(t2).toString()), i = "@gr4vy-secure-fields-debug", o = (function(e2) {
51
+ return e2.CARD_VAULT_SUCCESS = "card-vault-success", e2.CARD_VAULT_FAILURE = "card-vault-failure", e2.FORM_CHANGE = "form-change", e2.METHOD_CHANGE = "method-change", e2.READY = "ready", e2.RESIZE = "resize", e2.CLICK_TO_PAY_INITIALIZED = "click-to-pay-initialized", e2.CLICK_TO_PAY_READY = "click-to-pay-ready", e2.CLICK_TO_PAY_SIGN_OUT = "click-to-pay-sign-out", e2.CLICK_TO_PAY_ERROR = "click-to-pay-error", e2.CLICK_TO_PAY_CANCEL = "click-to-pay-cancel", e2.CLICK_TO_PAY_CHECKOUT_WITH_NEW_CARD = "click-to-pay-checkout-with-new-card", e2.CLICK_TO_PAY_UNABLE_TO_LOAD_DPA = "click-to-pay-unable-to-load-dpa", e2.CLICK_TO_PAY_VISIBILITY_CHANGE = "click-to-pay:visibility-change", e2.CLICK_TO_PAY_CARD_FORM_VISIBILITY_CHANGE = "click-to-pay-card-form:visibility-change", e2.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE = "click-to-pay-sign-in:visibility-change", e2.CLICK_TO_PAY_PROCESSING = "click-to-pay-processing", e2.CLICK_TO_PAY_AUTHENTICATE = "click-to-pay-authenticate", e2.CLICK_TO_PAY_AUTHENTICATE_FAILURE = "click-to-pay-authenticate-failure", e2.THREE_DS_START = "three-ds-start", e2.THREE_DS_FINISH = "three-ds-finish", e2;
52
+ })({}), a = (function(e2) {
53
+ return e2.REQUEST_PORT = "request-port", e2.TRANSFER_PORT = "transfer-port", e2.REQUEST_RECOGNITION_TOKEN = "request-recognition-token", e2.REQUEST_RECOGNITION_TOKEN_FAILED = "request-recognition-token-failed", e2.RECOGNITION_TOKEN = "recognition-token", e2;
54
+ })({}), s = (function(e2) {
55
+ return e2.FOCUSED = "data-secure-fields-focused", e2.INVALID = "data-secure-fields-invalid", e2.AUTOFILLED = "data-secure-fields-autofilled", e2;
56
+ })({}), c = (function(e2) {
57
+ return e2.PAYMENT_METHOD_ID_IN_USE = "You're passing a paymentMethodId to use a stored payment method, which means Secure Fields methods `addCardNumber`, `addExpiryDate` and `addClickToPay` are automatically disabled and won't render the related fields", e2.PAYMENT_METHOD_ID_DEPRECATED = "The 'paymentMethodId' prop is deprecated and will be removed in a future version. Please use the 'paymentMethod' prop instead: { paymentMethod: { id: 'your-id', scheme: 'visa' } }", e2.FIELD_PATTERN_IN_USE = "The `pattern` option can't be used on card fields, so it won't be applied here.", e2.AUTO_ADVANCE_ENABLED = "autoAdvance is enabled. Auto-advancing focus on field completion can degrade checkout UX (see WCAG 3.2.2). Use with caution.", e2.NO_RECOGNITION_TOKEN = "The recognition token couldn't be obtained or the request took too much time. It is possible that a Click to Pay user was therefore not recognised.", e2;
58
+ })({}), l = "secure-fields", d = { number: "addCardNumberField", expiryDate: "addExpiryDateField", securityCode: "addSecurityCodeField" }, h = ["01", "02", "03", "04", "05"];
59
+ function u(e2, t2) {
60
+ (null == t2 || t2 > e2.length) && (t2 = e2.length);
61
+ for (var r2 = 0, n2 = new Array(t2); r2 < t2; r2++) n2[r2] = e2[r2];
62
+ return n2;
63
+ }
64
+ function p(e2, t2) {
65
+ return (function(e3) {
66
+ if (Array.isArray(e3)) return e3;
67
+ })(e2) || (function(e3, t3) {
68
+ var r2 = null == e3 ? null : "undefined" != typeof Symbol && e3[Symbol.iterator] || e3["@@iterator"];
69
+ if (null != r2) {
70
+ var n2, i2, o2 = [], a2 = true, s2 = false;
71
+ try {
72
+ for (r2 = r2.call(e3); !(a2 = (n2 = r2.next()).done) && (o2.push(n2.value), !t3 || o2.length !== t3); a2 = true) ;
73
+ } catch (e4) {
74
+ s2 = true, i2 = e4;
75
+ } finally {
76
+ try {
77
+ a2 || null == r2.return || r2.return();
78
+ } finally {
79
+ if (s2) throw i2;
80
+ }
81
+ }
82
+ return o2;
83
+ }
84
+ })(e2, t2) || (function(e3, t3) {
85
+ if (e3) {
86
+ if ("string" == typeof e3) return u(e3, t3);
87
+ var r2 = Object.prototype.toString.call(e3).slice(8, -1);
88
+ return "Object" === r2 && e3.constructor && (r2 = e3.constructor.name), "Map" === r2 || "Set" === r2 ? Array.from(r2) : "Arguments" === r2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r2) ? u(e3, t3) : void 0;
89
+ }
90
+ })(e2, t2) || (function() {
91
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
92
+ })();
93
+ }
94
+ var y = new class {
95
+ subscribe(e2, t2) {
96
+ this.subscribers.push([e2, t2]);
97
+ }
98
+ unsubscribe(e2, t2) {
99
+ this.subscribers = this.subscribers.filter((r2) => {
100
+ var n2 = p(r2, 2), i2 = n2[0], o2 = n2[1];
101
+ return i2 !== e2 || o2.toString() !== t2.toString();
102
+ });
103
+ }
104
+ unsubscribeAll() {
105
+ this.subscribers = [];
106
+ }
107
+ publish(e2, t2) {
108
+ this.subscribers.forEach((r2) => {
109
+ var n2 = p(r2, 2), i2 = n2[0], o2 = n2[1];
110
+ return setTimeout(() => i2 === e2 ? o2(t2) : null, 0);
111
+ });
112
+ }
113
+ constructor() {
114
+ var e2, t2;
115
+ t2 = void 0, (e2 = "subscribers") in this ? Object.defineProperty(this, e2, { value: t2, enumerable: true, configurable: true, writable: true }) : this[e2] = t2, this.subscribers = [];
116
+ }
117
+ }();
118
+ function m(e2, t2) {
119
+ (null == t2 || t2 > e2.length) && (t2 = e2.length);
120
+ for (var r2 = 0, n2 = new Array(t2); r2 < t2; r2++) n2[r2] = e2[r2];
121
+ return n2;
122
+ }
123
+ function f(e2, t2) {
124
+ return (function(e3) {
125
+ if (Array.isArray(e3)) return e3;
126
+ })(e2) || (function(e3, t3) {
127
+ var r2 = null == e3 ? null : "undefined" != typeof Symbol && e3[Symbol.iterator] || e3["@@iterator"];
128
+ if (null != r2) {
129
+ var n2, i2, o2 = [], a2 = true, s2 = false;
130
+ try {
131
+ for (r2 = r2.call(e3); !(a2 = (n2 = r2.next()).done) && (o2.push(n2.value), !t3 || o2.length !== t3); a2 = true) ;
132
+ } catch (e4) {
133
+ s2 = true, i2 = e4;
134
+ } finally {
135
+ try {
136
+ a2 || null == r2.return || r2.return();
137
+ } finally {
138
+ if (s2) throw i2;
139
+ }
140
+ }
141
+ return o2;
142
+ }
143
+ })(e2, t2) || (function(e3, t3) {
144
+ if (e3) {
145
+ if ("string" == typeof e3) return m(e3, t3);
146
+ var r2 = Object.prototype.toString.call(e3).slice(8, -1);
147
+ return "Object" === r2 && e3.constructor && (r2 = e3.constructor.name), "Map" === r2 || "Set" === r2 ? Array.from(r2) : "Arguments" === r2 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r2) ? m(e3, t3) : void 0;
148
+ }
149
+ })(e2, t2) || (function() {
150
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
151
+ })();
152
+ }
153
+ var v = new class {
154
+ add(e2, t2, r2) {
155
+ window.addEventListener(e2, t2), this.listeners.push([e2, t2, r2]);
156
+ }
157
+ remove(e2, t2, r2) {
158
+ var n2 = this.listeners.findIndex((n3) => {
159
+ var i3 = f(n3, 3), o3 = i3[0], a3 = i3[1], s3 = i3[2];
160
+ return o3 === e2 && a3.toString() === t2.toString() && s3 === r2;
161
+ });
162
+ if (-1 !== n2) {
163
+ var i2 = f(this.listeners.splice(n2, 1), 1), o2 = f(i2[0], 2), a2 = o2[0], s2 = o2[1];
164
+ window.removeEventListener(a2, s2);
165
+ }
166
+ }
167
+ removeAll() {
168
+ this.listeners.forEach((e2) => {
169
+ var t2 = f(e2, 2), r2 = t2[0], n2 = t2[1];
170
+ window.removeEventListener(r2, n2);
171
+ }), this.listeners = [];
172
+ }
173
+ constructor() {
174
+ var e2, t2;
175
+ t2 = [], (e2 = "listeners") in this ? Object.defineProperty(this, e2, { value: t2, enumerable: true, configurable: true, writable: true }) : this[e2] = t2;
176
+ }
177
+ }();
178
+ function b(e2, t2, r2) {
179
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
180
+ }
181
+ function _(e2) {
182
+ for (var t2 = 1; t2 < arguments.length; t2++) {
183
+ var r2 = null != arguments[t2] ? arguments[t2] : {}, n2 = Object.keys(r2);
184
+ "function" == typeof Object.getOwnPropertySymbols && (n2 = n2.concat(Object.getOwnPropertySymbols(r2).filter(function(e3) {
185
+ return Object.getOwnPropertyDescriptor(r2, e3).enumerable;
186
+ }))), n2.forEach(function(t3) {
187
+ b(e2, t3, r2[t3]);
188
+ });
189
+ }
190
+ return e2;
191
+ }
192
+ var I = { debug: false, level: "log" }, g = (e2, t2, r2) => {
193
+ var n2 = _({}, I, r2), o2 = n2.debug, a2 = n2.level;
194
+ (o2 || "true" === localStorage.getItem(i)) && console[a2]("Gr4vy - Secure Fields - ".concat(e2), t2 || {});
195
+ }, O = (e2, t2, r2) => {
196
+ var n2, i2;
197
+ g(e2, t2, (n2 = _({}, r2), i2 = null != (i2 = { level: "warn" }) ? i2 : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(n2, Object.getOwnPropertyDescriptors(i2)) : (function(e3) {
198
+ var t3 = Object.keys(e3);
199
+ if (Object.getOwnPropertySymbols) {
200
+ var r3 = Object.getOwnPropertySymbols(e3);
201
+ t3.push.apply(t3, r3);
202
+ }
203
+ return t3;
204
+ })(Object(i2)).forEach(function(e3) {
205
+ Object.defineProperty(n2, e3, Object.getOwnPropertyDescriptor(i2, e3));
206
+ }), n2));
207
+ };
208
+ function C(e2, t2, r2, n2, i2, o2, a2) {
209
+ try {
210
+ var s2 = e2[o2](a2), c2 = s2.value;
211
+ } catch (e3) {
212
+ return void r2(e3);
213
+ }
214
+ s2.done ? t2(c2) : Promise.resolve(c2).then(n2, i2);
215
+ }
216
+ function E(e2, t2, r2) {
217
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
218
+ }
219
+ function T(e2) {
220
+ for (var t2 = 1; t2 < arguments.length; t2++) {
221
+ var r2 = null != arguments[t2] ? arguments[t2] : {}, n2 = Object.keys(r2);
222
+ "function" == typeof Object.getOwnPropertySymbols && (n2 = n2.concat(Object.getOwnPropertySymbols(r2).filter(function(e3) {
223
+ return Object.getOwnPropertyDescriptor(r2, e3).enumerable;
224
+ }))), n2.forEach(function(t3) {
225
+ E(e2, t3, r2[t3]);
226
+ });
227
+ }
228
+ return e2;
229
+ }
230
+ function A(e2, t2) {
231
+ return t2 = null != t2 ? t2 : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : (function(e3) {
232
+ var t3 = Object.keys(e3);
233
+ if (Object.getOwnPropertySymbols) {
234
+ var r2 = Object.getOwnPropertySymbols(e3);
235
+ t3.push.apply(t3, r2);
236
+ }
237
+ return t3;
238
+ })(Object(t2)).forEach(function(r2) {
239
+ Object.defineProperty(e2, r2, Object.getOwnPropertyDescriptor(t2, r2));
240
+ }), e2;
241
+ }
242
+ class S {
243
+ init(e2, t2) {
244
+ var r2;
245
+ this.challengeWindowSize = h.includes(null == t2 ? void 0 : t2.challengeWindowSize) ? t2.challengeWindowSize : "05", this.element = "string" == typeof e2 ? document.querySelector(e2) : e2;
246
+ var i2 = "gr4vy-threeds-flow-controller";
247
+ null === (r2 = document.body.querySelector("iframe#".concat(i2))) || void 0 === r2 || r2.remove();
248
+ var o2 = document.createElement("iframe");
249
+ o2.id = i2, o2.title = "ThreeDSecure", o2.style.display = "block", o2.style.border = "0px", o2.style.padding = "0px", o2.style.margin = "0px", o2.style.width = "100%", o2.style.height = "100%", o2.src = n(this.secureFields.frameUrl + "/threeds.html", { sessionId: this.secureFields.config.sessionId, parentOrigin: this.secureFields.parentOrigin, gr4vyId: this.secureFields.config.gr4vyId, environment: this.secureFields.config.environment }), this.element.appendChild(o2), this.controller = o2;
250
+ var a2 = { type: "three-ds-init", channel: l, data: { challengeWindowSize: this.challengeWindowSize } };
251
+ return o2.addEventListener("load", () => {
252
+ var e3;
253
+ null === (e3 = o2.contentWindow) || void 0 === e3 || e3.postMessage(a2, this.secureFields.frameUrl), this.resolveReady();
254
+ }, { once: true }), this.destroy(), v.add("message", this.boundListener, "three-ds"), this;
255
+ }
256
+ destroy() {
257
+ v.remove("message", this.boundListener, "three-ds");
258
+ }
259
+ listener(e2) {
260
+ return (t2 = function* () {
261
+ if (e2.origin === this.secureFields.frameUrl) {
262
+ var t3 = e2.data, r2 = t3.type, n2 = t3.data;
263
+ switch (r2) {
264
+ case o.THREE_DS_START:
265
+ y.publish(o.THREE_DS_START, A(T({}, n2), { element: this.element })), g("3DS start", e2.data.data);
266
+ break;
267
+ case o.THREE_DS_FINISH:
268
+ y.publish(o.THREE_DS_FINISH, A(T({}, n2), { element: this.element })), g("3DS finish", e2.data.data);
269
+ }
270
+ }
271
+ }, function() {
272
+ var e3 = this, r2 = arguments;
273
+ return new Promise(function(n2, i2) {
274
+ var o2 = t2.apply(e3, r2);
275
+ function a2(e4) {
276
+ C(o2, n2, i2, a2, s2, "next", e4);
277
+ }
278
+ function s2(e4) {
279
+ C(o2, n2, i2, a2, s2, "throw", e4);
280
+ }
281
+ a2(void 0);
282
+ });
283
+ }).call(this);
284
+ var t2;
285
+ }
286
+ constructor(e2) {
287
+ E(this, "secureFields", void 0), E(this, "controller", void 0), E(this, "ready", void 0), E(this, "challengeWindowSize", void 0), E(this, "element", void 0), E(this, "resolveReady", void 0), E(this, "boundListener", void 0), this.secureFields = e2, this.boundListener = this.listener.bind(this), this.ready = new Promise((e3) => {
288
+ this.resolveReady = e3;
289
+ });
290
+ }
291
+ }
292
+ function P(e2, t2, r2, n2, i2, o2, a2) {
293
+ try {
294
+ var s2 = e2[o2](a2), c2 = s2.value;
295
+ } catch (e3) {
296
+ return void r2(e3);
297
+ }
298
+ s2.done ? t2(c2) : Promise.resolve(c2).then(n2, i2);
299
+ }
300
+ class w extends Error {
301
+ constructor(e2) {
302
+ super(e2), this.name = "UnableToLoadDpaError";
303
+ }
304
+ }
305
+ var k = (e2, t2) => e2 && (e2.style.display = t2 ? "block" : "none"), N = (e2) => {
306
+ var t2, r2;
307
+ if (null === (t2 = document) || void 0 === t2 ? void 0 : t2.cookie) return null === (r2 = "; ".concat(document.cookie).match(";\\s*".concat(e2, "=([^;]+)"))) || void 0 === r2 ? void 0 : r2[1];
308
+ };
309
+ function D(e2, t2, r2, n2, i2, o2, a2) {
310
+ try {
311
+ var s2 = e2[o2](a2), c2 = s2.value;
312
+ } catch (e3) {
313
+ return void r2(e3);
314
+ }
315
+ s2.done ? t2(c2) : Promise.resolve(c2).then(n2, i2);
316
+ }
317
+ function L(e2) {
318
+ return function() {
319
+ var t2 = this, r2 = arguments;
320
+ return new Promise(function(n2, i2) {
321
+ var o2 = e2.apply(t2, r2);
322
+ function a2(e3) {
323
+ D(o2, n2, i2, a2, s2, "next", e3);
324
+ }
325
+ function s2(e3) {
326
+ D(o2, n2, i2, a2, s2, "throw", e3);
327
+ }
328
+ a2(void 0);
329
+ });
330
+ };
331
+ }
332
+ function R(e2, t2, r2) {
333
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
334
+ }
335
+ function U() {
336
+ return U = Object.assign || function(e2) {
337
+ for (var t2 = 1; t2 < arguments.length; t2++) {
338
+ var r2 = arguments[t2];
339
+ for (var n2 in r2) Object.prototype.hasOwnProperty.call(r2, n2) && (e2[n2] = r2[n2]);
340
+ }
341
+ return e2;
342
+ }, U.apply(this, arguments);
343
+ }
344
+ function j(e2) {
345
+ for (var t2 = 1; t2 < arguments.length; t2++) {
346
+ var r2 = null != arguments[t2] ? arguments[t2] : {}, n2 = Object.keys(r2);
347
+ "function" == typeof Object.getOwnPropertySymbols && (n2 = n2.concat(Object.getOwnPropertySymbols(r2).filter(function(e3) {
348
+ return Object.getOwnPropertyDescriptor(r2, e3).enumerable;
349
+ }))), n2.forEach(function(t3) {
350
+ R(e2, t3, r2[t3]);
351
+ });
352
+ }
353
+ return e2;
354
+ }
355
+ class M {
356
+ _addIframe(e2, t2, r2, i2) {
357
+ var o2 = document.createElement("iframe");
358
+ return o2.id = e2, o2.title = t2, o2.setAttribute("width", "100%"), o2.setAttribute("frameborder", "0"), o2.setAttribute("style", "height:0px"), o2.src = n(r2, i2), o2;
359
+ }
360
+ _attachListeners() {
361
+ var e2 = new MessageChannel(), t2 = true, r2 = (r3) => {
362
+ var n2 = r3.origin, i2 = r3.data, s2 = i2.type, d2 = i2.data;
363
+ switch (n2) {
364
+ case this.origin:
365
+ switch (s2) {
366
+ case o.RESIZE:
367
+ this.controller.style.height = "".concat(d2.height > 0 ? d2.height + 48 : 0, "px");
368
+ break;
369
+ case o.METHOD_CHANGE:
370
+ var h2 = d2.method || "card";
371
+ (this.secureFields.method !== h2 || t2) && (t2 = false, this.secureFields.updateMethod(h2, { data: d2 }), k(this.cardForm, "card" === h2), y.publish(o.CLICK_TO_PAY_CARD_FORM_VISIBILITY_CHANGE, "card" === h2));
372
+ break;
373
+ case o.CLICK_TO_PAY_INITIALIZED:
374
+ y.publish(o.CLICK_TO_PAY_INITIALIZED, this.clickToPay), g("Click to Pay initialized", this.clickToPay), k(this.signIn, false), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, false), k(this.clickToPay.element, true), y.publish(o.CLICK_TO_PAY_VISIBILITY_CHANGE, true);
375
+ break;
376
+ case o.CLICK_TO_PAY_READY:
377
+ this._buyerExists = d2.buyerExists, y.publish(o.CLICK_TO_PAY_READY, d2), g("Click to Pay ready"), k(this.signIn, !d2.buyerExists), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, !d2.buyerExists), k(this.clickToPay.element, true), y.publish(o.CLICK_TO_PAY_VISIBILITY_CHANGE, true);
378
+ break;
379
+ case o.CLICK_TO_PAY_SIGN_OUT:
380
+ this.clickToPay.signOut();
381
+ break;
382
+ case o.CLICK_TO_PAY_ERROR:
383
+ y.publish(o.CLICK_TO_PAY_ERROR, d2), g("Click to Pay error:", d2), k(this.signIn, !["UNKNOWN", "INVALID_CARD", "CODE_INVALID"].includes(d2.error)), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, !["UNKNOWN", "INVALID_CARD", "CODE_INVALID"].includes(d2.error)), k(this.clickToPay.element, "UNKNOWN" !== d2.error), y.publish(o.CLICK_TO_PAY_VISIBILITY_CHANGE, "UNKNOWN" !== d2.error);
384
+ break;
385
+ case o.CLICK_TO_PAY_CANCEL:
386
+ y.publish(o.CLICK_TO_PAY_CANCEL, d2), g("Click to Pay cancelled"), this._buyerExists || (k(this.signIn, true), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, true));
387
+ break;
388
+ case o.CLICK_TO_PAY_CHECKOUT_WITH_NEW_CARD:
389
+ y.publish(o.CLICK_TO_PAY_CHECKOUT_WITH_NEW_CARD, d2), k(this.signIn, false), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, false), g("Click to Pay checkout with new card initiated");
390
+ break;
391
+ case o.CLICK_TO_PAY_PROCESSING:
392
+ k(this.cardForm, !d2), y.publish(o.CLICK_TO_PAY_CARD_FORM_VISIBILITY_CHANGE, d2), g("Click to Pay processing", d2);
393
+ break;
394
+ case o.CLICK_TO_PAY_AUTHENTICATE:
395
+ !(function(e3, t3) {
396
+ for (var r4 = arguments.length, n3 = new Array(r4 > 2 ? r4 - 2 : 0), i3 = 2; i3 < r4; i3++) n3[i3 - 2] = arguments[i3];
397
+ document.cookie = "".concat(e3, "=").concat(t3, "; path=/; ").concat(n3.join("; "));
398
+ })("recognitionToken", d2.recognitionToken, "Secure", "SameSite=Strict", "MaxAge=15552000");
399
+ break;
400
+ case o.CLICK_TO_PAY_AUTHENTICATE_FAILURE:
401
+ y.publish(o.CLICK_TO_PAY_AUTHENTICATE_FAILURE, d2), g("Click to Pay authenticate failure:", d2);
402
+ break;
403
+ case a.REQUEST_RECOGNITION_TOKEN:
404
+ this.controller.contentWindow.postMessage({ channel: l, type: a.RECOGNITION_TOKEN, data: { recognitionToken: N("recognitionToken") } }, this.origin);
405
+ break;
406
+ case a.REQUEST_RECOGNITION_TOKEN_FAILED:
407
+ O(c.NO_RECOGNITION_TOKEN);
408
+ break;
409
+ case a.REQUEST_PORT:
410
+ this.controller.contentWindow.postMessage({ channel: l, type: a.TRANSFER_PORT }, this.origin, [e2.port1]);
411
+ }
412
+ break;
413
+ case this.secureFields.frameUrl:
414
+ s2 === a.REQUEST_PORT && this.encrypt.contentWindow.postMessage({ channel: l, type: a.TRANSFER_PORT }, this.secureFields.frameUrl, [e2.port2]);
415
+ }
416
+ };
417
+ v.remove("message", r2, "click-to-pay"), v.add("message", r2, "click-to-pay");
418
+ }
419
+ _fetchDPA(e2, t2) {
420
+ return L(function* (e3, t3) {
421
+ var n2 = t3.gr4vyId, i2 = t3.environment, a2 = t3.sessionId;
422
+ try {
423
+ var s2 = e3 || (function(e4) {
424
+ return r(e4, arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "production", "api");
425
+ })(n2, i2);
426
+ return yield (function(e4) {
427
+ return (t4 = function* (e5) {
428
+ var t5 = e5.apiBaseUrl, r2 = e5.checkoutSessionId;
429
+ try {
430
+ var n3 = "".concat(t5, "/digital-wallets/click-to-pay/session"), i3 = yield fetch(n3, { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ checkout_session_id: r2 }) });
431
+ if (i3.ok) {
432
+ var o2 = yield i3.json();
433
+ return { srcDpaId: o2.digital_payment_application_id, dpaName: o2.digital_payment_application_name };
434
+ }
435
+ throw new w("Unable to load DPA");
436
+ } catch (e6) {
437
+ throw new w("Unable to load DPA");
438
+ }
439
+ }, function() {
440
+ var e5 = this, r2 = arguments;
441
+ return new Promise(function(n3, i3) {
442
+ var o2 = t4.apply(e5, r2);
443
+ function a3(e6) {
444
+ P(o2, n3, i3, a3, s3, "next", e6);
445
+ }
446
+ function s3(e6) {
447
+ P(o2, n3, i3, a3, s3, "throw", e6);
448
+ }
449
+ a3(void 0);
450
+ });
451
+ }).apply(this, arguments);
452
+ var t4;
453
+ })({ apiBaseUrl: s2, checkoutSessionId: a2 });
454
+ } catch (e4) {
455
+ return g(e4.message), y.publish(o.CLICK_TO_PAY_UNABLE_TO_LOAD_DPA), k(this.cardForm, true), y.publish(o.CLICK_TO_PAY_CARD_FORM_VISIBILITY_CHANGE, true), k(this.clickToPay.element, false), void y.publish(o.CLICK_TO_PAY_VISIBILITY_CHANGE, false);
456
+ }
457
+ }).apply(this, arguments);
458
+ }
459
+ _initConsentCheckbox(e2) {
460
+ var t2 = e2.checked ? "click-to-pay" : "card";
461
+ this.secureFields.updateMethod(t2, { data: { method: t2 } }), e2.addEventListener("change", (e3) => {
462
+ var t3 = e3.target;
463
+ this.consent = t3.checked;
464
+ }), v.add("message", (t3) => {
465
+ switch (t3.data.type) {
466
+ case o.CLICK_TO_PAY_ERROR:
467
+ "UNKNOWN" === t3.data.data.error && (this.consent = false, e2.checked = false);
468
+ break;
469
+ case o.METHOD_CHANGE:
470
+ var r2 = this._buyerExists && "card" === t3.data.data.method;
471
+ this.consent = r2, e2.checked = r2;
472
+ }
473
+ }, "click-to-pay-consent-checkbox");
474
+ }
475
+ _setNewCardRememberMe(e2) {
476
+ this.controller.contentWindow.postMessage({ type: "remember-me-new-card-changed", channel: l, data: { value: e2 } }, this.origin);
477
+ }
478
+ _initNewCardRememberMeCheckbox(e2) {
479
+ e2.addEventListener("change", (e3) => {
480
+ var t2 = e3.target;
481
+ this._setNewCardRememberMe(t2.checked);
482
+ }), v.add("message", (t2) => {
483
+ switch (t2.data.type) {
484
+ case o.CLICK_TO_PAY_INITIALIZED:
485
+ this._setNewCardRememberMe(e2.checked);
486
+ break;
487
+ case o.CLICK_TO_PAY_ERROR:
488
+ "UNKNOWN" === t2.data.data.error && (this._setNewCardRememberMe(false), e2.checked = false);
489
+ }
490
+ }, "click-to-pay-new-card-remember-me-checkbox");
491
+ }
492
+ _initLearnMore(e2) {
493
+ e2.style.visibility = "hidden", v.add("message", (t2) => {
494
+ t2.data.type === o.CLICK_TO_PAY_INITIALIZED && (e2.style.visibility = "visible", e2.addEventListener("click", () => {
495
+ this.controller.contentWindow.postMessage({ type: "show-learn-more", channel: l }, this.origin);
496
+ }));
497
+ }, "click-to-pay-learn-more");
498
+ }
499
+ init(e2, t2) {
500
+ return L(function* () {
501
+ this.cardForm = "string" == typeof (null == t2 ? void 0 : t2.cardForm) ? document.querySelector(null == t2 ? void 0 : t2.cardForm) : null == t2 ? void 0 : t2.cardForm, this.signIn = "string" == typeof (null == t2 ? void 0 : t2.signIn) ? document.querySelector(null == t2 ? void 0 : t2.signIn) : null == t2 ? void 0 : t2.signIn, k(this.signIn, false);
502
+ var r2 = this.secureFields, n2 = r2.apiUrl, i2 = r2.config, a2 = i2.gr4vyId, s2 = i2.environment, c2 = i2.sessionId, l2 = r2.environmentPath;
503
+ if (this.clickToPay = { element: null, options: t2, signIn: (e3) => {
504
+ var t3 = e3.email, r3 = e3.mobileNumber;
505
+ return L(function* () {
506
+ var e4 = this.clickToPay, n3 = e4.element, i3 = e4.options;
507
+ delete i3.email, delete i3.mobileNumber, n3.innerHTML = "", k(this.signIn, false), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, false), k(this.cardForm, false), y.publish(o.CLICK_TO_PAY_CARD_FORM_VISIBILITY_CHANGE, false), this.secureFields.update("clickToPay", yield this.init(n3, j({}, i3, t3 ? { email: t3 } : {}, r3 ? { mobileNumber: r3 } : {})));
508
+ }).call(this);
509
+ }, signOut: () => (this._buyerExists = false, y.publish(o.CLICK_TO_PAY_SIGN_OUT), g("Click to pay signed out"), k(this.signIn, true), y.publish(o.CLICK_TO_PAY_SIGN_IN_VISIBILITY_CHANGE, true), document.cookie = "".concat("recognitionToken", "=; path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC;"), this.clickToPay.signIn({ email: null, mobileNumber: null })), updateCheckoutOptions: (e3) => {
510
+ this.checkoutOptions = j({}, this.checkoutOptions, e3);
511
+ } }, !(null == t2 ? void 0 : t2.srcDpaId) || !(null == t2 ? void 0 : t2.dpaName)) {
512
+ var d2 = yield this._fetchDPA(n2, { gr4vyId: a2, environment: s2, sessionId: c2 });
513
+ if (!(null == d2 ? void 0 : d2.srcDpaId) && !(null == d2 ? void 0 : d2.dpaName)) return;
514
+ t2.srcDpaId = d2.srcDpaId, t2.dpaName = d2.dpaName;
515
+ }
516
+ this.url = window.CLICK_TO_PAY_FRAME_URL || "https://click-to-pay.".concat(l2).concat(a2, ".gr4vy.app"), this.origin = new URL(this.url).origin;
517
+ var h2 = window.location.origin, u2 = ((function(e3) {
518
+ if (null == e3) throw new TypeError("Cannot destructure " + e3);
519
+ })(t2), j({ gr4vyId: a2, environment: s2, sessionId: c2 }, U({}, t2)));
520
+ if (this.controller = this._addIframe("click-to-pay-controller", "Click To Pay", "".concat(this.url, "/click-to-pay.html"), { parentOrigin: h2, environment: s2, config: encodeURIComponent(JSON.stringify(u2)) }), this.encrypt = this._addIframe("click-to-pay-encrypt", "Click To Pay Encrypt", "".concat(this.secureFields.frameUrl, "/click-to-pay-encrypt.html"), { parentOrigin: h2, environment: s2, config: encodeURIComponent(JSON.stringify(u2)) }), this._attachListeners(), null == t2 ? void 0 : t2.consentCheckbox) {
521
+ var p2 = "string" == typeof (null == t2 ? void 0 : t2.consentCheckbox) ? document.querySelector(null == t2 ? void 0 : t2.consentCheckbox) : null == t2 ? void 0 : t2.consentCheckbox;
522
+ p2 && this._initConsentCheckbox(p2);
523
+ }
524
+ if (null == t2 ? void 0 : t2.rememberMeCheckbox) {
525
+ var m2 = "string" == typeof (null == t2 ? void 0 : t2.rememberMeCheckbox) ? document.querySelector(t2.rememberMeCheckbox) : null == t2 ? void 0 : t2.rememberMeCheckbox;
526
+ m2 && this._initNewCardRememberMeCheckbox(m2);
527
+ }
528
+ if (null == t2 ? void 0 : t2.learnMoreLink) {
529
+ var f2 = "string" == typeof (null == t2 ? void 0 : t2.learnMoreLink) ? document.querySelector(null == t2 ? void 0 : t2.learnMoreLink) : null == t2 ? void 0 : t2.learnMoreLink;
530
+ f2 && this._initLearnMore(f2);
531
+ }
532
+ return (e2 = "string" == typeof e2 ? document.querySelector(e2) : e2).appendChild(this.controller), e2.appendChild(this.encrypt), this.clickToPay.element = e2, this.clickToPay;
533
+ }).call(this);
534
+ }
535
+ constructor(e2) {
536
+ R(this, "secureFields", void 0), R(this, "_buyerExists", void 0), R(this, "consent", void 0), R(this, "controller", void 0), R(this, "encrypt", void 0), R(this, "origin", void 0), R(this, "url", void 0), R(this, "cardForm", void 0), R(this, "signIn", void 0), R(this, "checkoutOptions", void 0), R(this, "clickToPay", void 0), this.secureFields = e2, this._buyerExists = false, this.consent = false, this.checkoutOptions = {};
537
+ }
538
+ }
539
+ var F = (e2) => (e2 != e2.toLowerCase() && (e2 = e2.replace(/[A-Z]/g, (e3) => "-" + e3.toLowerCase())), e2);
540
+ function x(e2, t2) {
541
+ (null == t2 || t2 > e2.length) && (t2 = e2.length);
542
+ for (var r2 = 0, n2 = new Array(t2); r2 < t2; r2++) n2[r2] = e2[r2];
543
+ return n2;
544
+ }
545
+ var Y = function() {
546
+ var e2 = function(t2) {
547
+ var r2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "";
548
+ return Object.entries(t2).reduce((n2, i2) => {
549
+ var o2, a2, s2 = (a2 = 2, (function(e3) {
550
+ if (Array.isArray(e3)) return e3;
551
+ })(o2 = i2) || (function(e3, t3) {
552
+ var r3 = null == e3 ? null : "undefined" != typeof Symbol && e3[Symbol.iterator] || e3["@@iterator"];
553
+ if (null != r3) {
554
+ var n3, i3, o3 = [], a3 = true, s3 = false;
555
+ try {
556
+ for (r3 = r3.call(e3); !(a3 = (n3 = r3.next()).done) && (o3.push(n3.value), !t3 || o3.length !== t3); a3 = true) ;
557
+ } catch (e4) {
558
+ s3 = true, i3 = e4;
559
+ } finally {
560
+ try {
561
+ a3 || null == r3.return || r3.return();
562
+ } finally {
563
+ if (s3) throw i3;
564
+ }
565
+ }
566
+ return o3;
567
+ }
568
+ })(o2, a2) || (function(e3, t3) {
569
+ if (e3) {
570
+ if ("string" == typeof e3) return x(e3, t3);
571
+ var r3 = Object.prototype.toString.call(e3).slice(8, -1);
572
+ return "Object" === r3 && e3.constructor && (r3 = e3.constructor.name), "Map" === r3 || "Set" === r3 ? Array.from(r3) : "Arguments" === r3 || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r3) ? x(e3, t3) : void 0;
573
+ }
574
+ })(o2, a2) || (function() {
575
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
576
+ })()), c2 = s2[0], l2 = s2[1];
577
+ return ((e3) => "[object Object]" === Object.prototype.toString.call(e3))(l2) ? n2.push(...e2(t2[c2], "".concat((r2 + c2).match(/[a-zA-Z0-9]+/g).join("-"), "-"))) : (c2 = F(c2).replace(/^-/, ""), n2.push(["--".concat(r2).concat(c2), l2])), n2;
578
+ }, []);
579
+ };
580
+ return e2(arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {});
581
+ };
582
+ function K(e2, t2, r2, n2, i2, o2, a2) {
583
+ try {
584
+ var s2 = e2[o2](a2), c2 = s2.value;
585
+ } catch (e3) {
586
+ return void r2(e3);
587
+ }
588
+ s2.done ? t2(c2) : Promise.resolve(c2).then(n2, i2);
589
+ }
590
+ function H(e2, t2, r2) {
591
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
592
+ }
593
+ function G(e2) {
594
+ for (var t2 = 1; t2 < arguments.length; t2++) {
595
+ var r2 = null != arguments[t2] ? arguments[t2] : {}, n2 = Object.keys(r2);
596
+ "function" == typeof Object.getOwnPropertySymbols && (n2 = n2.concat(Object.getOwnPropertySymbols(r2).filter(function(e3) {
597
+ return Object.getOwnPropertyDescriptor(r2, e3).enumerable;
598
+ }))), n2.forEach(function(t3) {
599
+ H(e2, t3, r2[t3]);
600
+ });
601
+ }
602
+ return e2;
603
+ }
604
+ function V(e2, t2) {
605
+ return t2 = null != t2 ? t2 : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : (function(e3) {
606
+ var t3 = Object.keys(e3);
607
+ if (Object.getOwnPropertySymbols) {
608
+ var r2 = Object.getOwnPropertySymbols(e3);
609
+ t3.push.apply(t3, r2);
610
+ }
611
+ return t3;
612
+ })(Object(t2)).forEach(function(r2) {
613
+ Object.defineProperty(e2, r2, Object.getOwnPropertyDescriptor(t2, r2));
614
+ }), e2;
615
+ }
616
+ class W {
617
+ _postMessage(e2) {
618
+ return (t2 = function* () {
619
+ yield this.ready, this.frame.contentWindow.postMessage(G({ channel: l }, e2), this.frameUrl);
620
+ }, function() {
621
+ var e3 = this, r2 = arguments;
622
+ return new Promise(function(n2, i2) {
623
+ var o2 = t2.apply(e3, r2);
624
+ function a2(e4) {
625
+ K(o2, n2, i2, a2, s2, "next", e4);
626
+ }
627
+ function s2(e4) {
628
+ K(o2, n2, i2, a2, s2, "throw", e4);
629
+ }
630
+ a2(void 0);
631
+ });
632
+ }).call(this);
633
+ var t2;
634
+ }
635
+ update(e2) {
636
+ if (this.frameUrl) {
637
+ this.options = G({}, this.options, e2);
638
+ var t2 = Y(G({}, this.options.styles, e2.styles)), r2 = V(G({}, this.options, e2), { styles: t2 });
639
+ this._postMessage({ type: "update", data: V(G({}, r2), { styles: t2 }) }), g("Updated field", this.options);
640
+ }
641
+ }
642
+ setPlaceholder(e2) {
643
+ this.update({ placeholder: e2 });
644
+ }
645
+ setStyles(e2) {
646
+ this.update({ styles: e2 });
647
+ }
648
+ clear() {
649
+ if (this.frameUrl) {
650
+ var e2 = this.type;
651
+ this._postMessage({ type: "reset", data: { type: e2 } }), g("Cleared field", { type: e2 });
652
+ }
653
+ }
654
+ focus() {
655
+ if (this.frameUrl) {
656
+ var e2 = this.type;
657
+ this._postMessage({ type: "focus", data: { type: e2 } }), g("Focus field", { type: e2 });
658
+ }
659
+ }
660
+ redactValue() {
661
+ if (this.frameUrl) {
662
+ var e2 = this.type;
663
+ this._postMessage({ type: "redact-value", data: { type: e2 } }), g("Redact field", { type: e2 });
664
+ }
665
+ }
666
+ unredactValue() {
667
+ if (this.frameUrl) {
668
+ var e2 = this.type;
669
+ this._postMessage({ type: "unredact-value", data: { type: e2 } }), g("Unredact field", { type: e2 });
670
+ }
671
+ }
672
+ setEnterKeyHint(e2) {
673
+ if (this.frameUrl) {
674
+ var t2 = this.type;
675
+ this._postMessage({ type: "set-enter-key-hint", data: { type: t2, value: e2 } }), g("Updated enter key hint", { type: t2, value: e2 });
676
+ }
677
+ }
678
+ constructor(e2) {
679
+ if (H(this, "frameUrl", void 0), H(this, "parentOrigin", void 0), H(this, "frame", void 0), H(this, "type", void 0), H(this, "options", void 0), H(this, "addEventListener", void 0), H(this, "removeEventListener", void 0), H(this, "ready", void 0), H(this, "_resolveReady", void 0), H(this, "complete", void 0), e2) {
680
+ this.ready = new Promise((e3) => {
681
+ this._resolveReady = e3;
682
+ });
683
+ var t2 = e2.frameUrl, r2 = e2.parentOrigin, i2 = e2.font, o2 = e2.sessionId, a2 = e2.gr4vyId, s2 = e2.environment, c2 = e2.options, l2 = c2.type, d2 = c2.autoFocus, h2 = (function(e3, t3) {
684
+ if (null == e3) return {};
685
+ var r3, n2, i3, o3 = {};
686
+ if ("undefined" != typeof Reflect && Reflect.ownKeys) {
687
+ for (r3 = Reflect.ownKeys(Object(e3)), i3 = 0; i3 < r3.length; i3++) n2 = r3[i3], t3.indexOf(n2) >= 0 || Object.prototype.propertyIsEnumerable.call(e3, n2) && (o3[n2] = e3[n2]);
688
+ return o3;
689
+ }
690
+ if (o3 = (function(e4, t4) {
691
+ if (null == e4) return {};
692
+ var r4, n3, i4 = {}, o4 = Object.getOwnPropertyNames(e4);
693
+ for (n3 = 0; n3 < o4.length; n3++) r4 = o4[n3], t4.indexOf(r4) >= 0 || Object.prototype.propertyIsEnumerable.call(e4, r4) && (i4[r4] = e4[r4]);
694
+ return i4;
695
+ })(e3, t3), Object.getOwnPropertySymbols) for (r3 = Object.getOwnPropertySymbols(e3), i3 = 0; i3 < r3.length; i3++) n2 = r3[i3], t3.indexOf(n2) >= 0 || Object.prototype.propertyIsEnumerable.call(e3, n2) && (o3[n2] = e3[n2]);
696
+ return o3;
697
+ })(c2, ["type", "autoFocus"]), u2 = e2.paymentMethodScheme;
698
+ this.frameUrl = t2, this.parentOrigin = r2, this.type = l2, this.options = h2;
699
+ var p2 = Y(h2.styles), y2 = { parentOrigin: r2, type: l2, sessionId: o2, gr4vyId: a2, environment: s2 };
700
+ this.frame = document.createElement("iframe"), this.frame.id = l2, this.frame.src = n("".concat(t2, "/input.html"), y2), this.frame.title = "Secure Input", this.frame.style.display = "block", this.frame.style.height = "100%", this.frame.style.border = "none", this.frame.style.width = "100%", i2 && (this.frame.src += "&font=".concat(i2)), u2 && (this.frame.src += "&paymentMethodScheme=".concat(u2)), this.frame.onload = () => {
701
+ this._postMessage({ type: "update", data: V(G({}, this.options), { styles: p2, type: l2 }) }), g("Added field", this.options), d2 && this.focus();
702
+ };
703
+ }
704
+ }
705
+ }
706
+ var B = ["number", "expiryDate", "securityCode", "postalCode"], q = ["accesskey", "autocapitalize", "autocomplete", "autofocus", "aria-.", "class", "contenteditable", "data-.", "dir", "draggable", "enterkeyhint", "hidden", "id", "inert", "inputmode", "is", "itemid", "itemprop", "itemref", "itemscope", "itemtype", "lang", "nonce", "onabort", "onautocomplete", "onautocompleteerror", "onblur", "oncancel", "oncanplay", "oncanplaythrough", "onchange", "onclick", "onclose", "oncontextmenu", "oncuechange", "ondblclick", "ondrag", "ondragend", "ondragenter", "ondragleave", "ondragover", "ondragstart", "ondrop", "ondurationchange", "onemptied", "onended", "onerror", "onfocus", "oninput", "oninvalid", "onkeydown", "onkeypress", "onkeyup", "onload", "onloadeddata", "onloadedmetadata", "onloadstart", "onmousedown", "onmouseenter", "onmouseleave", "onmousemove", "onmouseout", "onmouseover", "onmouseup", "onmousewheel", "onpause", "onplay", "onplaying", "onprogress", "onratechange", "onreset", "onresize", "onscroll", "onseeked", "onseeking", "onselect", "onshow", "onsort", "onstalled", "onsubmit", "onsuspend", "ontimeupdate", "ontoggle", "onvolumechange", "onwaiting", "popover", "role", "slot", "spellcheck", "style", "tabindex", "title", "translate"];
707
+ function z(e2, t2, r2) {
708
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
709
+ }
710
+ var Z = ["visa", "mastercard", "amex"];
711
+ function Q(e2, t2, r2, n2, i2, o2, a2) {
712
+ try {
713
+ var s2 = e2[o2](a2), c2 = s2.value;
714
+ } catch (e3) {
715
+ return void r2(e3);
716
+ }
717
+ s2.done ? t2(c2) : Promise.resolve(c2).then(n2, i2);
718
+ }
719
+ function J(e2, t2, r2) {
720
+ return t2 in e2 ? Object.defineProperty(e2, t2, { value: r2, enumerable: true, configurable: true, writable: true }) : e2[t2] = r2, e2;
721
+ }
722
+ function $(e2) {
723
+ for (var t2 = 1; t2 < arguments.length; t2++) {
724
+ var r2 = null != arguments[t2] ? arguments[t2] : {}, n2 = Object.keys(r2);
725
+ "function" == typeof Object.getOwnPropertySymbols && (n2 = n2.concat(Object.getOwnPropertySymbols(r2).filter(function(e3) {
726
+ return Object.getOwnPropertyDescriptor(r2, e3).enumerable;
727
+ }))), n2.forEach(function(t3) {
728
+ J(e2, t3, r2[t3]);
729
+ });
730
+ }
731
+ return e2;
732
+ }
733
+ function X(e2, t2) {
734
+ return t2 = null != t2 ? t2 : {}, Object.getOwnPropertyDescriptors ? Object.defineProperties(e2, Object.getOwnPropertyDescriptors(t2)) : (function(e3) {
735
+ var t3 = Object.keys(e3);
736
+ if (Object.getOwnPropertySymbols) {
737
+ var r2 = Object.getOwnPropertySymbols(e3);
738
+ t3.push.apply(t3, r2);
739
+ }
740
+ return t3;
741
+ })(Object(t2)).forEach(function(r2) {
742
+ Object.defineProperty(e2, r2, Object.getOwnPropertyDescriptor(t2, r2));
743
+ }), e2;
744
+ }
745
+ function ee(e2, t2) {
746
+ if (null == e2) return {};
747
+ var r2, n2, i2, o2 = {};
748
+ if ("undefined" != typeof Reflect && Reflect.ownKeys) {
749
+ for (r2 = Reflect.ownKeys(Object(e2)), i2 = 0; i2 < r2.length; i2++) n2 = r2[i2], t2.indexOf(n2) >= 0 || Object.prototype.propertyIsEnumerable.call(e2, n2) && (o2[n2] = e2[n2]);
750
+ return o2;
751
+ }
752
+ if (o2 = (function(e3, t3) {
753
+ if (null == e3) return {};
754
+ var r3, n3, i3 = {}, o3 = Object.getOwnPropertyNames(e3);
755
+ for (n3 = 0; n3 < o3.length; n3++) r3 = o3[n3], t3.indexOf(r3) >= 0 || Object.prototype.propertyIsEnumerable.call(e3, r3) && (i3[r3] = e3[r3]);
756
+ return i3;
757
+ })(e2, t2), Object.getOwnPropertySymbols) for (r2 = Object.getOwnPropertySymbols(e2), i2 = 0; i2 < r2.length; i2++) n2 = r2[i2], t2.indexOf(n2) >= 0 || Object.prototype.propertyIsEnumerable.call(e2, n2) && (o2[n2] = e2[n2]);
758
+ return o2;
759
+ }
760
+ class te {
761
+ static get Events() {
762
+ return o;
763
+ }
764
+ static get version() {
765
+ return "#ffb6feb2e0f001ac7ebf45b5c1b5802e589b3a28";
766
+ }
767
+ update(e2, t2) {
768
+ this[e2] = t2;
769
+ }
770
+ updateMethod(e2, t2) {
771
+ var r2 = t2.data;
772
+ this.update("method", e2), y.publish(o.METHOD_CHANGE, r2), g("Method changed", { method: e2 }), this.controller.contentWindow.postMessage({ type: "method-change", channel: l }, this.frameUrl);
773
+ }
774
+ setAutoAdvance(e2) {
775
+ e2.enabled && (O(c.AUTO_ADVANCE_ENABLED), this.autoAdvance = ((e3) => {
776
+ var t2 = e3.enabled, r2 = e3.secureFields, n2 = ((e4) => {
777
+ if (!(null == e4 ? void 0 : e4.length)) return B;
778
+ var t3 = e4.filter((t4, r4) => B.includes(t4) && e4.indexOf(t4) === r4), r3 = B.filter((e5) => !t3.includes(e5));
779
+ return [...t3, ...r3];
780
+ })(e3.fieldOrder), i2 = (e4) => e4 ? "number" === e4 ? r2.cardNumber : "expiryDate" === e4 ? r2.expiryDate : "securityCode" === e4 ? r2.securityCode : r2.otherFields[e4] : null, o2 = (e4) => {
781
+ var t3 = e4.type, r3 = e4.nextIndex, a2 = null != r3 ? r3 : n2.indexOf(t3);
782
+ if (!(a2 < 0 || a2 >= n2.length - 1)) {
783
+ var s2 = i2(n2[a2 + 1]);
784
+ !(null == s2 ? void 0 : s2.complete) && (null == s2 ? void 0 : s2.frame) ? s2.focus() : o2({ nextIndex: a2 + 1 });
785
+ }
786
+ };
787
+ return { get enabled() {
788
+ return t2;
789
+ }, get fieldOrder() {
790
+ return n2;
791
+ }, updateEnterKeyHint: (e4) => {
792
+ var r3;
793
+ if (null == e4 ? void 0 : e4.frame) {
794
+ var o3 = n2.indexOf(e4.type), a2 = n2[o3 + 1], s2 = a2 && (null === (r3 = i2(a2)) || void 0 === r3 ? void 0 : r3.frame);
795
+ e4.setEnterKeyHint(t2 && s2 ? "next" : "done");
796
+ }
797
+ }, trigger: o2 };
798
+ })(X($({}, e2), { secureFields: this })));
799
+ }
800
+ _addField(e2, t2, r2) {
801
+ if (!(e2 = "string" == typeof e2 ? document.querySelector(e2) : e2) || !t2.frame) return t2.addEventListener = () => {
802
+ }, t2.removeEventListener = () => {
803
+ }, t2;
804
+ var n2 = e2.closest("[data-secure-fields-input-group]"), i2 = null != n2 ? n2 : document.createElement("div"), o2 = (e3) => {
805
+ var r3;
806
+ if (e3.origin === this.frameUrl && (null === (r3 = e3.data.data) || void 0 === r3 ? void 0 : r3.id) === t2.type) switch (e3.data.type) {
807
+ case "blur":
808
+ y.publish("".concat(t2.type, ":blur"), e3.data.data), i2.removeAttribute(s.FOCUSED), g("Field blurred", e3.data.data);
809
+ break;
810
+ case "focus":
811
+ y.publish("".concat(t2.type, ":focus"), e3.data.data), i2.setAttribute(s.FOCUSED, ""), g("Field focused", e3.data.data);
812
+ break;
813
+ case "input":
814
+ var n3, o3 = e3.data.data, a2 = o3.complete, c2 = o3.fromBlur, l2 = o3.isDeleteInputType, d2 = ee(o3, ["complete", "fromBlur", "isDeleteInputType"]);
815
+ if (y.publish("".concat(t2.type, ":input"), d2), t2.complete = a2, e3.data.data.valid ? i2.removeAttribute(s.INVALID) : i2.setAttribute(s.INVALID, ""), e3.data.data.autofilled ? i2.setAttribute(s.AUTOFILLED, "") : i2.removeAttribute(s.AUTOFILLED), (null === (n3 = this.autoAdvance) || void 0 === n3 ? void 0 : n3.enabled) && a2 && !d2.autofilled && false === c2 && !l2 && this.autoAdvance.trigger({ type: t2.type }), this.schemeIcons && "number" === t2.type) {
816
+ var h2, u2, p2;
817
+ d2.bin || (this.cardDetailsSchemes = { scheme: void 0, additionalSchemes: [] });
818
+ var m2 = null !== (h2 = null === (u2 = this.cardDetailsSchemes) || void 0 === u2 ? void 0 : u2.scheme) && void 0 !== h2 ? h2 : d2.schema, f2 = null === (p2 = this.cardDetailsSchemes) || void 0 === p2 ? void 0 : p2.additionalSchemes;
819
+ !m2 && d2.empty && this.schemeIcons.config.placeholders ? this.schemeIcons.showPlaceholders() : m2 ? this.schemeIcons.showSchemes({ scheme: m2, additionalSchemes: f2 }) : this.schemeIcons.hideSchemes();
820
+ }
821
+ g("Field input changed", d2);
822
+ break;
823
+ case "redacted":
824
+ y.publish("".concat(t2.type, ":redacted"), e3.data.data), g("Field redacted", e3.data.data);
825
+ break;
826
+ case "unredacted":
827
+ y.publish("".concat(t2.type, ":unredacted"), e3.data.data), g("Field unredacted", e3.data.data);
828
+ break;
829
+ case "card-details-changed":
830
+ var v2;
831
+ y.publish("".concat(t2.type, ":card-details-changed"), e3.data.data), this.schemeIcons && (this.cardDetailsSchemes = { scheme: e3.data.data.scheme, additionalSchemes: null !== (v2 = e3.data.data.additionalSchemes) && void 0 !== v2 ? v2 : [] }, this.schemeIcons.showSchemes(this.cardDetailsSchemes)), g("Card details changed", e3.data.data);
832
+ }
833
+ };
834
+ return v.remove("message", o2, t2.type), v.add("message", o2, t2.type), t2.addEventListener = this.addEventListener, t2.removeEventListener = this.removeEventListener, this.controllerReady.then(() => {
835
+ var o3, a2, s2, c2;
836
+ o3 = e2, a2 = i2, Array.from(o3.attributes).forEach((e3) => {
837
+ var t3 = e3.name, r3 = e3.value;
838
+ q.some((e4) => new RegExp(e4).test(t3)) && a2.setAttribute(t3, r3);
839
+ }), (i2 = a2).classList.add("secure-fields__input", "secure-fields__input--".concat(F(t2.type))), n2 ? (null === (s2 = e2.parentNode) || void 0 === s2 || s2.replaceChild(t2.frame, e2), n2.style.display = "inline-flex", n2.style.alignItems = "center", t2.frame.style.minWidth = "0") : (null === (c2 = e2.parentNode) || void 0 === c2 || c2.replaceChild(i2, e2), i2.appendChild(t2.frame)), "number" === t2.type && (null == r2 ? void 0 : r2.showSchemeIcons) && (i2.style.display = "inline-flex", i2.style.alignItems = "center", this.schemeIcons = ((e3) => {
840
+ var t3 = e3.baseUrl, r3 = ((e4) => {
841
+ var t4 = { scheme: false, additionalSchemes: false, placeholders: false };
842
+ return "boolean" == typeof e4 ? e4 ? { scheme: true, additionalSchemes: true, placeholders: false } : t4 : (function(e5) {
843
+ for (var t5 = 1; t5 < arguments.length; t5++) {
844
+ var r4 = null != arguments[t5] ? arguments[t5] : {}, n4 = Object.keys(r4);
845
+ "function" == typeof Object.getOwnPropertySymbols && (n4 = n4.concat(Object.getOwnPropertySymbols(r4).filter(function(e6) {
846
+ return Object.getOwnPropertyDescriptor(r4, e6).enumerable;
847
+ }))), n4.forEach(function(t6) {
848
+ z(e5, t6, r4[t6]);
849
+ });
850
+ }
851
+ return e5;
852
+ })({}, t4, e4);
853
+ })(e3.showSchemeIcons), n3 = /* @__PURE__ */ new Set(), i3 = document.createElement("div");
854
+ i3.classList.add("secure-fields__scheme-icons"), i3.style.display = "flex", i3.style.gap = "4px", i3.style.marginRight = "4px";
855
+ var o4 = Array.from({ length: 3 }, () => {
856
+ var e4 = document.createElement("img");
857
+ return e4.setAttribute("alt", ""), e4.setAttribute("aria-hidden", "true"), e4.style.display = "none", e4.onerror = () => {
858
+ var t4 = e4.getAttribute("src");
859
+ t4 && n3.add(t4), e4.style.display = "none";
860
+ }, e4.onload = () => {
861
+ e4.style.display = "block";
862
+ }, i3.appendChild(e4), e4;
863
+ }), a3 = (e4) => {
864
+ var i4 = e4.scheme, a4 = void 0 === i4 ? "" : i4, s3 = e4.additionalSchemes, c3 = void 0 === s3 ? [] : s3, l2 = e4.placeholders, d2 = void 0 !== l2 && l2, h2 = [...r3.scheme && a4 ? [a4] : [], ...r3.additionalSchemes && c3.length ? c3 : [], ...d2 ? Z : []].slice(0, 3);
865
+ o4.forEach((e5, r4) => {
866
+ var i5 = h2[r4];
867
+ if (i5) {
868
+ var o5 = "".concat(t3, "/").concat(i5, ".svg");
869
+ e5.getAttribute("src") !== o5 ? (e5.setAttribute("src", o5), e5.width = 48) : n3.has(o5) || (e5.style.display = "block");
870
+ } else e5.style.display = "none";
871
+ });
872
+ };
873
+ return { config: r3, container: i3, slots: o4, showSchemes: a3, showPlaceholders: () => a3({ placeholders: true }), hideSchemes: () => o4.forEach((e4) => e4.style.display = "none") };
874
+ })({ baseUrl: "".concat(this.cdnBaseUrl, "/assets/icons/card-schemes"), showSchemeIcons: r2.showSchemeIcons }), t2.frame.after(this.schemeIcons.container), this.schemeIcons.config.placeholders && this.schemeIcons.showPlaceholders()), t2._resolveReady(), t2.frame.addEventListener("load", () => {
875
+ var e3;
876
+ return null === (e3 = this.autoAdvance) || void 0 === e3 ? void 0 : e3.updateEnterKeyHint(t2);
877
+ });
878
+ }), t2;
879
+ }
880
+ addCardNumberField(e2, t2) {
881
+ return this.paymentMethodId && O(c.PAYMENT_METHOD_ID_IN_USE, { method: "addCardNumberField" }), this.cardNumber || (this.cardNumber = new W(X($({ frameUrl: this.frameUrl, parentOrigin: this.parentOrigin, font: this.font, sessionId: this.config.sessionId, gr4vyId: this.config.gr4vyId, environment: this.config.environment }, this.paymentMethodId ? { paymentMethodId: this.paymentMethodId } : {}), { options: X($({ label: "Card number" }, t2), { type: "number" }) }))), this._addField(e2, this.cardNumber, t2);
882
+ }
883
+ addSecurityCodeField(e2, t2) {
884
+ var r2, n2;
885
+ return this.securityCode || (this.securityCode = new W({ frameUrl: this.frameUrl, parentOrigin: this.parentOrigin, font: this.font, options: X($({ label: "Security code" }, this.paymentMethodId && !(null === (r2 = this.config.paymentMethod) || void 0 === r2 ? void 0 : r2.scheme) ? { lengths: [3, 4] } : {}, t2), { type: "securityCode" }), paymentMethodScheme: null === (n2 = this.config.paymentMethod) || void 0 === n2 ? void 0 : n2.scheme })), this._addField(e2, this.securityCode);
886
+ }
887
+ addExpiryDateField(e2, t2) {
888
+ return this.paymentMethodId && O(c.PAYMENT_METHOD_ID_IN_USE, { method: "addExpiryDateField" }), this.expiryDate || (this.expiryDate = new W({ frameUrl: this.frameUrl, parentOrigin: this.parentOrigin, font: this.font, options: X($({ label: "Expiry date" }, t2), { type: "expiryDate" }) })), this._addField(e2, this.expiryDate);
889
+ }
890
+ addField(e2, t2) {
891
+ if (["number", "expiryDate", "securityCode"].includes(t2.type)) {
892
+ t2.pattern && O(c.FIELD_PATTERN_IN_USE, $({ method: "addField" }, t2)), t2.pattern, t2.type;
893
+ var r2 = ee(t2, ["pattern", "type"]);
894
+ return this[d[t2.type]](e2, r2);
895
+ }
896
+ return this.otherFields[t2.type] || (this.otherFields = X($({}, this.otherFields), { [t2.type]: new W({ frameUrl: this.frameUrl, parentOrigin: this.parentOrigin, font: this.font, options: t2 }) })), this._addField(e2, this.otherFields[t2.type]);
897
+ }
898
+ addThreeDSecure(e2, t2) {
899
+ this.threeDS || (this.threeDS = new S(this), this.threeDS.init(e2, t2), this.setThreeDSecureEnabled(true), this.postThreeDSInit());
900
+ }
901
+ removeThreeDSecure() {
902
+ var e2, t2;
903
+ null === (e2 = this.threeDS) || void 0 === e2 || e2.destroy(), null === (t2 = this.threeDS) || void 0 === t2 || t2.controller.remove(), this.threeDS = void 0, this.setThreeDSecureEnabled(false);
904
+ }
905
+ setThreeDSecureEnabled(e2) {
906
+ this.threeDSEnabled = e2;
907
+ }
908
+ postThreeDSInit() {
909
+ this.controllerReady.then(() => {
910
+ var e2;
911
+ null === (e2 = this.controller.contentWindow) || void 0 === e2 || e2.postMessage({ type: "three-ds-init", channel: l }, this.frameUrl);
912
+ });
913
+ }
914
+ addClickToPay(e2, t2) {
915
+ return (r2 = function* () {
916
+ if (!this.paymentMethodId) return this.clickToPayInstance = yield new M(this), this.clickToPay = yield this.clickToPayInstance.init(e2, t2), this.clickToPay;
917
+ O(c.PAYMENT_METHOD_ID_IN_USE, { method: "addClickToPay" });
918
+ }, function() {
919
+ var e3 = this, t3 = arguments;
920
+ return new Promise(function(n2, i2) {
921
+ var o2 = r2.apply(e3, t3);
922
+ function a2(e4) {
923
+ Q(o2, n2, i2, a2, s2, "next", e4);
924
+ }
925
+ function s2(e4) {
926
+ Q(o2, n2, i2, a2, s2, "throw", e4);
927
+ }
928
+ a2(void 0);
929
+ });
930
+ }).call(this);
931
+ var r2;
932
+ }
933
+ addEventListener(e2, t2) {
934
+ var r2 = this.type, n2 = "".concat(this.constructor === W ? "".concat(r2, ":") : "").concat(e2);
935
+ y.subscribe(n2, t2);
936
+ }
937
+ removeEventListener(e2, t2) {
938
+ var r2 = this.type, n2 = "".concat(this.constructor === W ? "".concat(r2, ":") : "").concat(e2);
939
+ y.unsubscribe(n2, t2);
940
+ }
941
+ submit() {
942
+ var e2, t2, r2 = (e3) => {
943
+ var t3, n3 = [this.frameUrl, null === (t3 = this.clickToPayInstance) || void 0 === t3 ? void 0 : t3.origin].includes(e3.origin), i3 = e3.data.channel === l, a2 = ["success", "error", o.CLICK_TO_PAY_CANCEL, o.CLICK_TO_PAY_ERROR, o.CLICK_TO_PAY_AUTHENTICATE_FAILURE].includes(e3.data.type);
944
+ if (n3 && i3 && a2) {
945
+ switch (e3.data.type) {
946
+ case "success":
947
+ var s2;
948
+ y.publish(o.CARD_VAULT_SUCCESS, e3.data.data), (null === (s2 = e3.data.data) || void 0 === s2 ? void 0 : s2.warn) && (O(e3.data.data.warn), delete e3.data.data.warn), g("Payment method tokenized successfully", e3.data.data);
949
+ break;
950
+ case "error":
951
+ y.publish(o.CARD_VAULT_FAILURE, e3.data), g("Failed to update checkout session", e3.data.data);
952
+ }
953
+ window.removeEventListener("message", r2);
954
+ }
955
+ };
956
+ if (window.addEventListener("message", r2), "click-to-pay" === this.method || "card" === this.method && (null === (e2 = this.clickToPayInstance) || void 0 === e2 ? void 0 : e2.controller) && true === (null === (t2 = this.clickToPayInstance) || void 0 === t2 ? void 0 : t2.consent)) {
957
+ var n2;
958
+ this.clickToPayInstance.controller.contentWindow.postMessage({ type: "submit", channel: l, data: { checkoutOptions: null === (n2 = this.clickToPayInstance) || void 0 === n2 ? void 0 : n2.checkoutOptions } }, this.clickToPayInstance.url);
959
+ } else {
960
+ var i2 = () => this.controller.contentWindow.postMessage({ type: "submit", channel: l, data: { method: this.paymentMethodId ? "id" : "card", threeDSEnabled: !!this.threeDS && this.threeDSEnabled } }, this.frameUrl);
961
+ this.threeDS && this.threeDSEnabled ? this.threeDS.ready.then(i2) : i2();
962
+ }
963
+ }
964
+ setDebug(e2) {
965
+ localStorage.setItem(i, String(e2));
966
+ }
967
+ addFont(e2) {
968
+ this.font = e2.replace(/\s/g, "+");
969
+ }
970
+ constructor(e2) {
971
+ var t2, i2;
972
+ J(this, "config", void 0), J(this, "controller", void 0), J(this, "frameUrl", void 0), J(this, "apiUrl", void 0), J(this, "cdnBaseUrl", void 0), J(this, "parentOrigin", void 0), J(this, "font", void 0), J(this, "cardNumber", void 0), J(this, "securityCode", void 0), J(this, "expiryDate", void 0), J(this, "otherFields", {}), J(this, "method", "card"), J(this, "clickToPayInstance", void 0), J(this, "clickToPay", void 0), J(this, "threeDS", void 0), J(this, "threeDSEnabled", true), J(this, "environmentPath", void 0), J(this, "paymentMethodId", void 0), J(this, "autoAdvance", null), J(this, "schemeIcons", null), J(this, "cardDetailsSchemes", null), J(this, "controllerReady", void 0), J(this, "_resolveControllerReady", void 0), y.unsubscribeAll(), this.config = $({ environment: "production" }, e2), this.controllerReady = new Promise((e3) => {
973
+ var t3 = Date.now();
974
+ this._resolveControllerReady = () => e3(Date.now() - t3);
975
+ }), this.config.paymentMethodId && !this.config.paymentMethod && O(c.PAYMENT_METHOD_ID_DEPRECATED), this.environmentPath = "sandbox" === this.config.environment ? "sandbox." : "", this.frameUrl = window.SECURE_FIELDS_FRAME_URL || "https://secure-fields.".concat(this.environmentPath).concat(this.config.gr4vyId, ".gr4vy.app"), this.parentOrigin = window.location.origin, this.paymentMethodId = (null === (t2 = this.config.paymentMethod) || void 0 === t2 ? void 0 : t2.id) || this.config.paymentMethodId, this.cdnBaseUrl = (function(e3) {
976
+ return r(e3, arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : "production", "cdn");
977
+ })(this.config.gr4vyId, this.config.environment);
978
+ var a2 = $({ parentOrigin: this.parentOrigin, sessionId: this.config.sessionId, gr4vyId: this.config.gr4vyId, environment: this.config.environment }, this.paymentMethodId ? { paymentMethodId: this.paymentMethodId } : {});
979
+ null === (i2 = document.body.querySelector("iframe#controller[src*=secure-fields]")) || void 0 === i2 || i2.remove(), this.controller = document.createElement("iframe"), this.controller.id = "controller", this.controller.src = n("".concat(this.frameUrl, "/controller.html"), a2), this.controller.title = "Secure Controller", this.controller.style.position = "absolute", this.controller.style.left = "-9999999px", document.body.appendChild(this.controller), this.paymentMethodId && (this.cardNumber = new W(), this.expiryDate = new W()), g("Initialized", X($({}, this.config), { version: te.version, frameUrl: this.frameUrl, parentOrigin: this.parentOrigin }));
980
+ var s2 = (e3) => {
981
+ if (e3.origin === this.frameUrl) switch (e3.data.type) {
982
+ case "ready":
983
+ var t3 = $({ version: te.version }, this.config);
984
+ y.publish(o.READY, t3), this._resolveControllerReady(), g("Ready", t3);
985
+ break;
986
+ case "form-change":
987
+ y.publish(o.FORM_CHANGE, e3.data.data), g("Form change", e3.data.data);
988
+ }
989
+ };
990
+ v.remove("message", s2, "init"), v.add("message", s2, "init"), this.controllerReady.then((e3) => g("Loaded controller after ".concat(e3, " milliseconds")));
991
+ }
992
+ }
993
+ return t;
994
+ })());
995
+ }
996
+ });
997
+
1
998
  // src/CheckoutEmbed.tsx
2
999
  import { useCallback, useRef, useState as useState2 } from "react";
3
1000
 
@@ -642,6 +1639,7 @@ function useThrottleCheckout(options) {
642
1639
  }
643
1640
 
644
1641
  // src/useSecureCard.tsx
1642
+ var import_secure_fields2 = __toESM(require_lib(), 1);
645
1643
  import {
646
1644
  createContext,
647
1645
  useCallback as useCallback5,
@@ -650,17 +1648,16 @@ import {
650
1648
  useRef as useRef4,
651
1649
  useState as useState6
652
1650
  } from "react";
653
- import { SecureFields as SecureFields2 } from "@gr4vy/secure-fields";
654
1651
 
655
1652
  // src/threeDSecure.ts
656
- import { SecureFields } from "@gr4vy/secure-fields";
1653
+ var import_secure_fields = __toESM(require_lib(), 1);
657
1654
  function resolveChallenge({ instance, element, challengeWindowSize }) {
658
1655
  return new Promise((resolve) => {
659
1656
  const handleFinish = () => {
660
- instance.removeEventListener?.(SecureFields.Events.THREE_DS_FINISH, handleFinish);
1657
+ instance.removeEventListener?.(import_secure_fields.SecureFields.Events.THREE_DS_FINISH, handleFinish);
661
1658
  resolve();
662
1659
  };
663
- instance.addEventListener(SecureFields.Events.THREE_DS_FINISH, handleFinish);
1660
+ instance.addEventListener(import_secure_fields.SecureFields.Events.THREE_DS_FINISH, handleFinish);
664
1661
  instance.addThreeDSecure(element, challengeWindowSize ? { challengeWindowSize } : void 0);
665
1662
  });
666
1663
  }
@@ -692,7 +1689,7 @@ function SecureCardProvider({
692
1689
  const [instance, setInstance] = useState6(null);
693
1690
  const [threeDSMount, setThreeDSMount] = useState6(null);
694
1691
  useEffect5(() => {
695
- const created = new SecureFields2({ gr4vyId: providerInstanceId, environment, sessionId });
1692
+ const created = new import_secure_fields2.SecureFields({ gr4vyId: providerInstanceId, environment, sessionId });
696
1693
  setInstance(created);
697
1694
  setMountedCount(0);
698
1695
  setStatus((current) => current === "idle" || current === "ready" ? "mounting" : current);
@@ -717,15 +1714,15 @@ function SecureCardProvider({
717
1714
  if (!challengeWaiter.current) return;
718
1715
  setStatus((current) => current === "challenging" ? "vaulting" : current);
719
1716
  };
720
- instance.addEventListener(SecureFields2.Events.CARD_VAULT_SUCCESS, handleSuccess);
721
- instance.addEventListener(SecureFields2.Events.CARD_VAULT_FAILURE, handleFailure);
722
- instance.addEventListener(SecureFields2.Events.THREE_DS_START, handleThreeDSStart);
723
- instance.addEventListener(SecureFields2.Events.THREE_DS_FINISH, handleThreeDSFinish);
1717
+ instance.addEventListener(import_secure_fields2.SecureFields.Events.CARD_VAULT_SUCCESS, handleSuccess);
1718
+ instance.addEventListener(import_secure_fields2.SecureFields.Events.CARD_VAULT_FAILURE, handleFailure);
1719
+ instance.addEventListener(import_secure_fields2.SecureFields.Events.THREE_DS_START, handleThreeDSStart);
1720
+ instance.addEventListener(import_secure_fields2.SecureFields.Events.THREE_DS_FINISH, handleThreeDSFinish);
724
1721
  return () => {
725
- instance.removeEventListener?.(SecureFields2.Events.CARD_VAULT_SUCCESS, handleSuccess);
726
- instance.removeEventListener?.(SecureFields2.Events.CARD_VAULT_FAILURE, handleFailure);
727
- instance.removeEventListener?.(SecureFields2.Events.THREE_DS_START, handleThreeDSStart);
728
- instance.removeEventListener?.(SecureFields2.Events.THREE_DS_FINISH, handleThreeDSFinish);
1722
+ instance.removeEventListener?.(import_secure_fields2.SecureFields.Events.CARD_VAULT_SUCCESS, handleSuccess);
1723
+ instance.removeEventListener?.(import_secure_fields2.SecureFields.Events.CARD_VAULT_FAILURE, handleFailure);
1724
+ instance.removeEventListener?.(import_secure_fields2.SecureFields.Events.THREE_DS_START, handleThreeDSStart);
1725
+ instance.removeEventListener?.(import_secure_fields2.SecureFields.Events.THREE_DS_FINISH, handleThreeDSFinish);
729
1726
  };
730
1727
  }, [instance]);
731
1728
  const registerField = useCallback5(
@@ -959,7 +1956,23 @@ function SecurityCodeField({ className, style, options }) {
959
1956
  function PostalCodeField({ className, style, options }) {
960
1957
  return /* @__PURE__ */ jsx4("div", { ref: useField("postalCode", options), className, style });
961
1958
  }
1959
+
1960
+ // src/index.tsx
1961
+ import * as money from "@usethrottle/money";
1962
+ import {
1963
+ formatMoney,
1964
+ currencySymbol,
1965
+ minorUnitsOf,
1966
+ toDecimalString,
1967
+ toMinor,
1968
+ parseMoney,
1969
+ moneyValue,
1970
+ CURRENCIES,
1971
+ isKnownCurrency,
1972
+ UnknownCurrencyError
1973
+ } from "@usethrottle/money";
962
1974
  export {
1975
+ CURRENCIES,
963
1976
  CardNumberField,
964
1977
  CheckoutEmbed,
965
1978
  ExpiryField,
@@ -968,6 +1981,16 @@ export {
968
1981
  SecureCardProvider,
969
1982
  SecurityCodeField,
970
1983
  CheckoutEmbed as ThrottleCheckout,
1984
+ UnknownCurrencyError,
1985
+ currencySymbol,
1986
+ formatMoney,
1987
+ isKnownCurrency,
1988
+ minorUnitsOf,
1989
+ money,
1990
+ moneyValue,
1991
+ parseMoney,
1992
+ toDecimalString,
1993
+ toMinor,
971
1994
  useCartSession,
972
1995
  useSecureCard,
973
1996
  useThrottleCheckout,