coinley-checkout 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2013 +0,0 @@
1
- (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("react")) : typeof define === "function" && define.amd ? define(["exports", "react"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.CoinleyCheckout = {}, global.React));
3
- })(this, function(exports2, require$$0) {
4
- "use strict";
5
- const styles = "";
6
- var jsxRuntime = { exports: {} };
7
- var reactJsxRuntime_production_min = {};
8
- /**
9
- * @license React
10
- * react-jsx-runtime.production.min.js
11
- *
12
- * Copyright (c) Facebook, Inc. and its affiliates.
13
- *
14
- * This source code is licensed under the MIT license found in the
15
- * LICENSE file in the root directory of this source tree.
16
- */
17
- var hasRequiredReactJsxRuntime_production_min;
18
- function requireReactJsxRuntime_production_min() {
19
- if (hasRequiredReactJsxRuntime_production_min)
20
- return reactJsxRuntime_production_min;
21
- hasRequiredReactJsxRuntime_production_min = 1;
22
- var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
23
- function q(c, a, g) {
24
- var b, d = {}, e = null, h = null;
25
- void 0 !== g && (e = "" + g);
26
- void 0 !== a.key && (e = "" + a.key);
27
- void 0 !== a.ref && (h = a.ref);
28
- for (b in a)
29
- m.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
30
- if (c && c.defaultProps)
31
- for (b in a = c.defaultProps, a)
32
- void 0 === d[b] && (d[b] = a[b]);
33
- return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
34
- }
35
- reactJsxRuntime_production_min.Fragment = l;
36
- reactJsxRuntime_production_min.jsx = q;
37
- reactJsxRuntime_production_min.jsxs = q;
38
- return reactJsxRuntime_production_min;
39
- }
40
- var reactJsxRuntime_development = {};
41
- /**
42
- * @license React
43
- * react-jsx-runtime.development.js
44
- *
45
- * Copyright (c) Facebook, Inc. and its affiliates.
46
- *
47
- * This source code is licensed under the MIT license found in the
48
- * LICENSE file in the root directory of this source tree.
49
- */
50
- var hasRequiredReactJsxRuntime_development;
51
- function requireReactJsxRuntime_development() {
52
- if (hasRequiredReactJsxRuntime_development)
53
- return reactJsxRuntime_development;
54
- hasRequiredReactJsxRuntime_development = 1;
55
- if (process.env.NODE_ENV !== "production") {
56
- (function() {
57
- var React = require$$0;
58
- var REACT_ELEMENT_TYPE = Symbol.for("react.element");
59
- var REACT_PORTAL_TYPE = Symbol.for("react.portal");
60
- var REACT_FRAGMENT_TYPE = Symbol.for("react.fragment");
61
- var REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode");
62
- var REACT_PROFILER_TYPE = Symbol.for("react.profiler");
63
- var REACT_PROVIDER_TYPE = Symbol.for("react.provider");
64
- var REACT_CONTEXT_TYPE = Symbol.for("react.context");
65
- var REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref");
66
- var REACT_SUSPENSE_TYPE = Symbol.for("react.suspense");
67
- var REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list");
68
- var REACT_MEMO_TYPE = Symbol.for("react.memo");
69
- var REACT_LAZY_TYPE = Symbol.for("react.lazy");
70
- var REACT_OFFSCREEN_TYPE = Symbol.for("react.offscreen");
71
- var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
72
- var FAUX_ITERATOR_SYMBOL = "@@iterator";
73
- function getIteratorFn(maybeIterable) {
74
- if (maybeIterable === null || typeof maybeIterable !== "object") {
75
- return null;
76
- }
77
- var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
78
- if (typeof maybeIterator === "function") {
79
- return maybeIterator;
80
- }
81
- return null;
82
- }
83
- var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
84
- function error(format) {
85
- {
86
- {
87
- for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
88
- args[_key2 - 1] = arguments[_key2];
89
- }
90
- printWarning("error", format, args);
91
- }
92
- }
93
- }
94
- function printWarning(level, format, args) {
95
- {
96
- var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
97
- var stack = ReactDebugCurrentFrame2.getStackAddendum();
98
- if (stack !== "") {
99
- format += "%s";
100
- args = args.concat([stack]);
101
- }
102
- var argsWithFormat = args.map(function(item) {
103
- return String(item);
104
- });
105
- argsWithFormat.unshift("Warning: " + format);
106
- Function.prototype.apply.call(console[level], console, argsWithFormat);
107
- }
108
- }
109
- var enableScopeAPI = false;
110
- var enableCacheElement = false;
111
- var enableTransitionTracing = false;
112
- var enableLegacyHidden = false;
113
- var enableDebugTracing = false;
114
- var REACT_MODULE_REFERENCE;
115
- {
116
- REACT_MODULE_REFERENCE = Symbol.for("react.module.reference");
117
- }
118
- function isValidElementType(type) {
119
- if (typeof type === "string" || typeof type === "function") {
120
- return true;
121
- }
122
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || enableDebugTracing || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || enableLegacyHidden || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCacheElement || enableTransitionTracing) {
123
- return true;
124
- }
125
- if (typeof type === "object" && type !== null) {
126
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || // This needs to include all possible module reference object
127
- // types supported by any Flight configuration anywhere since
128
- // we don't know which Flight build this will end up being used
129
- // with.
130
- type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== void 0) {
131
- return true;
132
- }
133
- }
134
- return false;
135
- }
136
- function getWrappedName(outerType, innerType, wrapperName) {
137
- var displayName = outerType.displayName;
138
- if (displayName) {
139
- return displayName;
140
- }
141
- var functionName = innerType.displayName || innerType.name || "";
142
- return functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName;
143
- }
144
- function getContextName(type) {
145
- return type.displayName || "Context";
146
- }
147
- function getComponentNameFromType(type) {
148
- if (type == null) {
149
- return null;
150
- }
151
- {
152
- if (typeof type.tag === "number") {
153
- error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue.");
154
- }
155
- }
156
- if (typeof type === "function") {
157
- return type.displayName || type.name || null;
158
- }
159
- if (typeof type === "string") {
160
- return type;
161
- }
162
- switch (type) {
163
- case REACT_FRAGMENT_TYPE:
164
- return "Fragment";
165
- case REACT_PORTAL_TYPE:
166
- return "Portal";
167
- case REACT_PROFILER_TYPE:
168
- return "Profiler";
169
- case REACT_STRICT_MODE_TYPE:
170
- return "StrictMode";
171
- case REACT_SUSPENSE_TYPE:
172
- return "Suspense";
173
- case REACT_SUSPENSE_LIST_TYPE:
174
- return "SuspenseList";
175
- }
176
- if (typeof type === "object") {
177
- switch (type.$$typeof) {
178
- case REACT_CONTEXT_TYPE:
179
- var context = type;
180
- return getContextName(context) + ".Consumer";
181
- case REACT_PROVIDER_TYPE:
182
- var provider = type;
183
- return getContextName(provider._context) + ".Provider";
184
- case REACT_FORWARD_REF_TYPE:
185
- return getWrappedName(type, type.render, "ForwardRef");
186
- case REACT_MEMO_TYPE:
187
- var outerName = type.displayName || null;
188
- if (outerName !== null) {
189
- return outerName;
190
- }
191
- return getComponentNameFromType(type.type) || "Memo";
192
- case REACT_LAZY_TYPE: {
193
- var lazyComponent = type;
194
- var payload = lazyComponent._payload;
195
- var init = lazyComponent._init;
196
- try {
197
- return getComponentNameFromType(init(payload));
198
- } catch (x) {
199
- return null;
200
- }
201
- }
202
- }
203
- }
204
- return null;
205
- }
206
- var assign = Object.assign;
207
- var disabledDepth = 0;
208
- var prevLog;
209
- var prevInfo;
210
- var prevWarn;
211
- var prevError;
212
- var prevGroup;
213
- var prevGroupCollapsed;
214
- var prevGroupEnd;
215
- function disabledLog() {
216
- }
217
- disabledLog.__reactDisabledLog = true;
218
- function disableLogs() {
219
- {
220
- if (disabledDepth === 0) {
221
- prevLog = console.log;
222
- prevInfo = console.info;
223
- prevWarn = console.warn;
224
- prevError = console.error;
225
- prevGroup = console.group;
226
- prevGroupCollapsed = console.groupCollapsed;
227
- prevGroupEnd = console.groupEnd;
228
- var props = {
229
- configurable: true,
230
- enumerable: true,
231
- value: disabledLog,
232
- writable: true
233
- };
234
- Object.defineProperties(console, {
235
- info: props,
236
- log: props,
237
- warn: props,
238
- error: props,
239
- group: props,
240
- groupCollapsed: props,
241
- groupEnd: props
242
- });
243
- }
244
- disabledDepth++;
245
- }
246
- }
247
- function reenableLogs() {
248
- {
249
- disabledDepth--;
250
- if (disabledDepth === 0) {
251
- var props = {
252
- configurable: true,
253
- enumerable: true,
254
- writable: true
255
- };
256
- Object.defineProperties(console, {
257
- log: assign({}, props, {
258
- value: prevLog
259
- }),
260
- info: assign({}, props, {
261
- value: prevInfo
262
- }),
263
- warn: assign({}, props, {
264
- value: prevWarn
265
- }),
266
- error: assign({}, props, {
267
- value: prevError
268
- }),
269
- group: assign({}, props, {
270
- value: prevGroup
271
- }),
272
- groupCollapsed: assign({}, props, {
273
- value: prevGroupCollapsed
274
- }),
275
- groupEnd: assign({}, props, {
276
- value: prevGroupEnd
277
- })
278
- });
279
- }
280
- if (disabledDepth < 0) {
281
- error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
282
- }
283
- }
284
- }
285
- var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
286
- var prefix;
287
- function describeBuiltInComponentFrame(name, source, ownerFn) {
288
- {
289
- if (prefix === void 0) {
290
- try {
291
- throw Error();
292
- } catch (x) {
293
- var match = x.stack.trim().match(/\n( *(at )?)/);
294
- prefix = match && match[1] || "";
295
- }
296
- }
297
- return "\n" + prefix + name;
298
- }
299
- }
300
- var reentry = false;
301
- var componentFrameCache;
302
- {
303
- var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
304
- componentFrameCache = new PossiblyWeakMap();
305
- }
306
- function describeNativeComponentFrame(fn, construct) {
307
- if (!fn || reentry) {
308
- return "";
309
- }
310
- {
311
- var frame = componentFrameCache.get(fn);
312
- if (frame !== void 0) {
313
- return frame;
314
- }
315
- }
316
- var control;
317
- reentry = true;
318
- var previousPrepareStackTrace = Error.prepareStackTrace;
319
- Error.prepareStackTrace = void 0;
320
- var previousDispatcher;
321
- {
322
- previousDispatcher = ReactCurrentDispatcher.current;
323
- ReactCurrentDispatcher.current = null;
324
- disableLogs();
325
- }
326
- try {
327
- if (construct) {
328
- var Fake = function() {
329
- throw Error();
330
- };
331
- Object.defineProperty(Fake.prototype, "props", {
332
- set: function() {
333
- throw Error();
334
- }
335
- });
336
- if (typeof Reflect === "object" && Reflect.construct) {
337
- try {
338
- Reflect.construct(Fake, []);
339
- } catch (x) {
340
- control = x;
341
- }
342
- Reflect.construct(fn, [], Fake);
343
- } else {
344
- try {
345
- Fake.call();
346
- } catch (x) {
347
- control = x;
348
- }
349
- fn.call(Fake.prototype);
350
- }
351
- } else {
352
- try {
353
- throw Error();
354
- } catch (x) {
355
- control = x;
356
- }
357
- fn();
358
- }
359
- } catch (sample) {
360
- if (sample && control && typeof sample.stack === "string") {
361
- var sampleLines = sample.stack.split("\n");
362
- var controlLines = control.stack.split("\n");
363
- var s = sampleLines.length - 1;
364
- var c = controlLines.length - 1;
365
- while (s >= 1 && c >= 0 && sampleLines[s] !== controlLines[c]) {
366
- c--;
367
- }
368
- for (; s >= 1 && c >= 0; s--, c--) {
369
- if (sampleLines[s] !== controlLines[c]) {
370
- if (s !== 1 || c !== 1) {
371
- do {
372
- s--;
373
- c--;
374
- if (c < 0 || sampleLines[s] !== controlLines[c]) {
375
- var _frame = "\n" + sampleLines[s].replace(" at new ", " at ");
376
- if (fn.displayName && _frame.includes("<anonymous>")) {
377
- _frame = _frame.replace("<anonymous>", fn.displayName);
378
- }
379
- {
380
- if (typeof fn === "function") {
381
- componentFrameCache.set(fn, _frame);
382
- }
383
- }
384
- return _frame;
385
- }
386
- } while (s >= 1 && c >= 0);
387
- }
388
- break;
389
- }
390
- }
391
- }
392
- } finally {
393
- reentry = false;
394
- {
395
- ReactCurrentDispatcher.current = previousDispatcher;
396
- reenableLogs();
397
- }
398
- Error.prepareStackTrace = previousPrepareStackTrace;
399
- }
400
- var name = fn ? fn.displayName || fn.name : "";
401
- var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
402
- {
403
- if (typeof fn === "function") {
404
- componentFrameCache.set(fn, syntheticFrame);
405
- }
406
- }
407
- return syntheticFrame;
408
- }
409
- function describeFunctionComponentFrame(fn, source, ownerFn) {
410
- {
411
- return describeNativeComponentFrame(fn, false);
412
- }
413
- }
414
- function shouldConstruct(Component) {
415
- var prototype = Component.prototype;
416
- return !!(prototype && prototype.isReactComponent);
417
- }
418
- function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
419
- if (type == null) {
420
- return "";
421
- }
422
- if (typeof type === "function") {
423
- {
424
- return describeNativeComponentFrame(type, shouldConstruct(type));
425
- }
426
- }
427
- if (typeof type === "string") {
428
- return describeBuiltInComponentFrame(type);
429
- }
430
- switch (type) {
431
- case REACT_SUSPENSE_TYPE:
432
- return describeBuiltInComponentFrame("Suspense");
433
- case REACT_SUSPENSE_LIST_TYPE:
434
- return describeBuiltInComponentFrame("SuspenseList");
435
- }
436
- if (typeof type === "object") {
437
- switch (type.$$typeof) {
438
- case REACT_FORWARD_REF_TYPE:
439
- return describeFunctionComponentFrame(type.render);
440
- case REACT_MEMO_TYPE:
441
- return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
442
- case REACT_LAZY_TYPE: {
443
- var lazyComponent = type;
444
- var payload = lazyComponent._payload;
445
- var init = lazyComponent._init;
446
- try {
447
- return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
448
- } catch (x) {
449
- }
450
- }
451
- }
452
- }
453
- return "";
454
- }
455
- var hasOwnProperty = Object.prototype.hasOwnProperty;
456
- var loggedTypeFailures = {};
457
- var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
458
- function setCurrentlyValidatingElement(element) {
459
- {
460
- if (element) {
461
- var owner = element._owner;
462
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
463
- ReactDebugCurrentFrame.setExtraStackFrame(stack);
464
- } else {
465
- ReactDebugCurrentFrame.setExtraStackFrame(null);
466
- }
467
- }
468
- }
469
- function checkPropTypes(typeSpecs, values, location, componentName, element) {
470
- {
471
- var has = Function.call.bind(hasOwnProperty);
472
- for (var typeSpecName in typeSpecs) {
473
- if (has(typeSpecs, typeSpecName)) {
474
- var error$1 = void 0;
475
- try {
476
- if (typeof typeSpecs[typeSpecName] !== "function") {
477
- var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
478
- err.name = "Invariant Violation";
479
- throw err;
480
- }
481
- error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
482
- } catch (ex) {
483
- error$1 = ex;
484
- }
485
- if (error$1 && !(error$1 instanceof Error)) {
486
- setCurrentlyValidatingElement(element);
487
- error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
488
- setCurrentlyValidatingElement(null);
489
- }
490
- if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
491
- loggedTypeFailures[error$1.message] = true;
492
- setCurrentlyValidatingElement(element);
493
- error("Failed %s type: %s", location, error$1.message);
494
- setCurrentlyValidatingElement(null);
495
- }
496
- }
497
- }
498
- }
499
- }
500
- var isArrayImpl = Array.isArray;
501
- function isArray(a) {
502
- return isArrayImpl(a);
503
- }
504
- function typeName(value) {
505
- {
506
- var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag;
507
- var type = hasToStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
508
- return type;
509
- }
510
- }
511
- function willCoercionThrow(value) {
512
- {
513
- try {
514
- testStringCoercion(value);
515
- return false;
516
- } catch (e) {
517
- return true;
518
- }
519
- }
520
- }
521
- function testStringCoercion(value) {
522
- return "" + value;
523
- }
524
- function checkKeyStringCoercion(value) {
525
- {
526
- if (willCoercionThrow(value)) {
527
- error("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", typeName(value));
528
- return testStringCoercion(value);
529
- }
530
- }
531
- }
532
- var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
533
- var RESERVED_PROPS = {
534
- key: true,
535
- ref: true,
536
- __self: true,
537
- __source: true
538
- };
539
- var specialPropKeyWarningShown;
540
- var specialPropRefWarningShown;
541
- var didWarnAboutStringRefs;
542
- {
543
- didWarnAboutStringRefs = {};
544
- }
545
- function hasValidRef(config) {
546
- {
547
- if (hasOwnProperty.call(config, "ref")) {
548
- var getter = Object.getOwnPropertyDescriptor(config, "ref").get;
549
- if (getter && getter.isReactWarning) {
550
- return false;
551
- }
552
- }
553
- }
554
- return config.ref !== void 0;
555
- }
556
- function hasValidKey(config) {
557
- {
558
- if (hasOwnProperty.call(config, "key")) {
559
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
560
- if (getter && getter.isReactWarning) {
561
- return false;
562
- }
563
- }
564
- }
565
- return config.key !== void 0;
566
- }
567
- function warnIfStringRefCannotBeAutoConverted(config, self2) {
568
- {
569
- if (typeof config.ref === "string" && ReactCurrentOwner.current && self2 && ReactCurrentOwner.current.stateNode !== self2) {
570
- var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
571
- if (!didWarnAboutStringRefs[componentName]) {
572
- error('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', getComponentNameFromType(ReactCurrentOwner.current.type), config.ref);
573
- didWarnAboutStringRefs[componentName] = true;
574
- }
575
- }
576
- }
577
- }
578
- function defineKeyPropWarningGetter(props, displayName) {
579
- {
580
- var warnAboutAccessingKey = function() {
581
- if (!specialPropKeyWarningShown) {
582
- specialPropKeyWarningShown = true;
583
- error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
584
- }
585
- };
586
- warnAboutAccessingKey.isReactWarning = true;
587
- Object.defineProperty(props, "key", {
588
- get: warnAboutAccessingKey,
589
- configurable: true
590
- });
591
- }
592
- }
593
- function defineRefPropWarningGetter(props, displayName) {
594
- {
595
- var warnAboutAccessingRef = function() {
596
- if (!specialPropRefWarningShown) {
597
- specialPropRefWarningShown = true;
598
- error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
599
- }
600
- };
601
- warnAboutAccessingRef.isReactWarning = true;
602
- Object.defineProperty(props, "ref", {
603
- get: warnAboutAccessingRef,
604
- configurable: true
605
- });
606
- }
607
- }
608
- var ReactElement = function(type, key, ref, self2, source, owner, props) {
609
- var element = {
610
- // This tag allows us to uniquely identify this as a React Element
611
- $$typeof: REACT_ELEMENT_TYPE,
612
- // Built-in properties that belong on the element
613
- type,
614
- key,
615
- ref,
616
- props,
617
- // Record the component responsible for creating this element.
618
- _owner: owner
619
- };
620
- {
621
- element._store = {};
622
- Object.defineProperty(element._store, "validated", {
623
- configurable: false,
624
- enumerable: false,
625
- writable: true,
626
- value: false
627
- });
628
- Object.defineProperty(element, "_self", {
629
- configurable: false,
630
- enumerable: false,
631
- writable: false,
632
- value: self2
633
- });
634
- Object.defineProperty(element, "_source", {
635
- configurable: false,
636
- enumerable: false,
637
- writable: false,
638
- value: source
639
- });
640
- if (Object.freeze) {
641
- Object.freeze(element.props);
642
- Object.freeze(element);
643
- }
644
- }
645
- return element;
646
- };
647
- function jsxDEV(type, config, maybeKey, source, self2) {
648
- {
649
- var propName;
650
- var props = {};
651
- var key = null;
652
- var ref = null;
653
- if (maybeKey !== void 0) {
654
- {
655
- checkKeyStringCoercion(maybeKey);
656
- }
657
- key = "" + maybeKey;
658
- }
659
- if (hasValidKey(config)) {
660
- {
661
- checkKeyStringCoercion(config.key);
662
- }
663
- key = "" + config.key;
664
- }
665
- if (hasValidRef(config)) {
666
- ref = config.ref;
667
- warnIfStringRefCannotBeAutoConverted(config, self2);
668
- }
669
- for (propName in config) {
670
- if (hasOwnProperty.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
671
- props[propName] = config[propName];
672
- }
673
- }
674
- if (type && type.defaultProps) {
675
- var defaultProps = type.defaultProps;
676
- for (propName in defaultProps) {
677
- if (props[propName] === void 0) {
678
- props[propName] = defaultProps[propName];
679
- }
680
- }
681
- }
682
- if (key || ref) {
683
- var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
684
- if (key) {
685
- defineKeyPropWarningGetter(props, displayName);
686
- }
687
- if (ref) {
688
- defineRefPropWarningGetter(props, displayName);
689
- }
690
- }
691
- return ReactElement(type, key, ref, self2, source, ReactCurrentOwner.current, props);
692
- }
693
- }
694
- var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
695
- var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
696
- function setCurrentlyValidatingElement$1(element) {
697
- {
698
- if (element) {
699
- var owner = element._owner;
700
- var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
701
- ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
702
- } else {
703
- ReactDebugCurrentFrame$1.setExtraStackFrame(null);
704
- }
705
- }
706
- }
707
- var propTypesMisspellWarningShown;
708
- {
709
- propTypesMisspellWarningShown = false;
710
- }
711
- function isValidElement(object) {
712
- {
713
- return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
714
- }
715
- }
716
- function getDeclarationErrorAddendum() {
717
- {
718
- if (ReactCurrentOwner$1.current) {
719
- var name = getComponentNameFromType(ReactCurrentOwner$1.current.type);
720
- if (name) {
721
- return "\n\nCheck the render method of `" + name + "`.";
722
- }
723
- }
724
- return "";
725
- }
726
- }
727
- function getSourceInfoErrorAddendum(source) {
728
- {
729
- if (source !== void 0) {
730
- var fileName = source.fileName.replace(/^.*[\\\/]/, "");
731
- var lineNumber = source.lineNumber;
732
- return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
733
- }
734
- return "";
735
- }
736
- }
737
- var ownerHasKeyUseWarning = {};
738
- function getCurrentComponentErrorInfo(parentType) {
739
- {
740
- var info = getDeclarationErrorAddendum();
741
- if (!info) {
742
- var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
743
- if (parentName) {
744
- info = "\n\nCheck the top-level render call using <" + parentName + ">.";
745
- }
746
- }
747
- return info;
748
- }
749
- }
750
- function validateExplicitKey(element, parentType) {
751
- {
752
- if (!element._store || element._store.validated || element.key != null) {
753
- return;
754
- }
755
- element._store.validated = true;
756
- var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
757
- if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
758
- return;
759
- }
760
- ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
761
- var childOwner = "";
762
- if (element && element._owner && element._owner !== ReactCurrentOwner$1.current) {
763
- childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
764
- }
765
- setCurrentlyValidatingElement$1(element);
766
- error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
767
- setCurrentlyValidatingElement$1(null);
768
- }
769
- }
770
- function validateChildKeys(node, parentType) {
771
- {
772
- if (typeof node !== "object") {
773
- return;
774
- }
775
- if (isArray(node)) {
776
- for (var i = 0; i < node.length; i++) {
777
- var child = node[i];
778
- if (isValidElement(child)) {
779
- validateExplicitKey(child, parentType);
780
- }
781
- }
782
- } else if (isValidElement(node)) {
783
- if (node._store) {
784
- node._store.validated = true;
785
- }
786
- } else if (node) {
787
- var iteratorFn = getIteratorFn(node);
788
- if (typeof iteratorFn === "function") {
789
- if (iteratorFn !== node.entries) {
790
- var iterator = iteratorFn.call(node);
791
- var step;
792
- while (!(step = iterator.next()).done) {
793
- if (isValidElement(step.value)) {
794
- validateExplicitKey(step.value, parentType);
795
- }
796
- }
797
- }
798
- }
799
- }
800
- }
801
- }
802
- function validatePropTypes(element) {
803
- {
804
- var type = element.type;
805
- if (type === null || type === void 0 || typeof type === "string") {
806
- return;
807
- }
808
- var propTypes;
809
- if (typeof type === "function") {
810
- propTypes = type.propTypes;
811
- } else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
812
- // Inner props are checked in the reconciler.
813
- type.$$typeof === REACT_MEMO_TYPE)) {
814
- propTypes = type.propTypes;
815
- } else {
816
- return;
817
- }
818
- if (propTypes) {
819
- var name = getComponentNameFromType(type);
820
- checkPropTypes(propTypes, element.props, "prop", name, element);
821
- } else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
822
- propTypesMisspellWarningShown = true;
823
- var _name = getComponentNameFromType(type);
824
- error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
825
- }
826
- if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
827
- error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
828
- }
829
- }
830
- }
831
- function validateFragmentProps(fragment) {
832
- {
833
- var keys = Object.keys(fragment.props);
834
- for (var i = 0; i < keys.length; i++) {
835
- var key = keys[i];
836
- if (key !== "children" && key !== "key") {
837
- setCurrentlyValidatingElement$1(fragment);
838
- error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
839
- setCurrentlyValidatingElement$1(null);
840
- break;
841
- }
842
- }
843
- if (fragment.ref !== null) {
844
- setCurrentlyValidatingElement$1(fragment);
845
- error("Invalid attribute `ref` supplied to `React.Fragment`.");
846
- setCurrentlyValidatingElement$1(null);
847
- }
848
- }
849
- }
850
- var didWarnAboutKeySpread = {};
851
- function jsxWithValidation(type, props, key, isStaticChildren, source, self2) {
852
- {
853
- var validType = isValidElementType(type);
854
- if (!validType) {
855
- var info = "";
856
- if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
857
- info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
858
- }
859
- var sourceInfo = getSourceInfoErrorAddendum(source);
860
- if (sourceInfo) {
861
- info += sourceInfo;
862
- } else {
863
- info += getDeclarationErrorAddendum();
864
- }
865
- var typeString;
866
- if (type === null) {
867
- typeString = "null";
868
- } else if (isArray(type)) {
869
- typeString = "array";
870
- } else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
871
- typeString = "<" + (getComponentNameFromType(type.type) || "Unknown") + " />";
872
- info = " Did you accidentally export a JSX literal instead of a component?";
873
- } else {
874
- typeString = typeof type;
875
- }
876
- error("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
877
- }
878
- var element = jsxDEV(type, props, key, source, self2);
879
- if (element == null) {
880
- return element;
881
- }
882
- if (validType) {
883
- var children = props.children;
884
- if (children !== void 0) {
885
- if (isStaticChildren) {
886
- if (isArray(children)) {
887
- for (var i = 0; i < children.length; i++) {
888
- validateChildKeys(children[i], type);
889
- }
890
- if (Object.freeze) {
891
- Object.freeze(children);
892
- }
893
- } else {
894
- error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
895
- }
896
- } else {
897
- validateChildKeys(children, type);
898
- }
899
- }
900
- }
901
- {
902
- if (hasOwnProperty.call(props, "key")) {
903
- var componentName = getComponentNameFromType(type);
904
- var keys = Object.keys(props).filter(function(k) {
905
- return k !== "key";
906
- });
907
- var beforeExample = keys.length > 0 ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
908
- if (!didWarnAboutKeySpread[componentName + beforeExample]) {
909
- var afterExample = keys.length > 0 ? "{" + keys.join(": ..., ") + ": ...}" : "{}";
910
- error('A props object containing a "key" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />', beforeExample, componentName, afterExample, componentName);
911
- didWarnAboutKeySpread[componentName + beforeExample] = true;
912
- }
913
- }
914
- }
915
- if (type === REACT_FRAGMENT_TYPE) {
916
- validateFragmentProps(element);
917
- } else {
918
- validatePropTypes(element);
919
- }
920
- return element;
921
- }
922
- }
923
- function jsxWithValidationStatic(type, props, key) {
924
- {
925
- return jsxWithValidation(type, props, key, true);
926
- }
927
- }
928
- function jsxWithValidationDynamic(type, props, key) {
929
- {
930
- return jsxWithValidation(type, props, key, false);
931
- }
932
- }
933
- var jsx = jsxWithValidationDynamic;
934
- var jsxs = jsxWithValidationStatic;
935
- reactJsxRuntime_development.Fragment = REACT_FRAGMENT_TYPE;
936
- reactJsxRuntime_development.jsx = jsx;
937
- reactJsxRuntime_development.jsxs = jsxs;
938
- })();
939
- }
940
- return reactJsxRuntime_development;
941
- }
942
- if (process.env.NODE_ENV === "production") {
943
- jsxRuntime.exports = requireReactJsxRuntime_production_min();
944
- } else {
945
- jsxRuntime.exports = requireReactJsxRuntime_development();
946
- }
947
- var jsxRuntimeExports = jsxRuntime.exports;
948
- const ThemeContext = require$$0.createContext();
949
- const useTheme = () => require$$0.useContext(ThemeContext);
950
- const ThemeProvider = ({ initialTheme = "light", children }) => {
951
- const [theme, setTheme] = require$$0.useState(initialTheme);
952
- const toggleTheme = () => {
953
- setTheme((prevTheme) => prevTheme === "light" ? "dark" : "light");
954
- };
955
- require$$0.useEffect(() => {
956
- document.documentElement.classList.remove("light", "dark");
957
- document.documentElement.classList.add(theme);
958
- }, [theme]);
959
- return /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeContext.Provider, { value: { theme, setTheme, toggleTheme }, children });
960
- };
961
- let apiConfig = {
962
- apiKey: null,
963
- apiSecret: null,
964
- apiUrl: "https://coinleyserver-production.up.railway.app"
965
- };
966
- const initializeApi = (config) => {
967
- apiConfig = { ...apiConfig, ...config };
968
- console.log("API initialized with:", apiConfig);
969
- };
970
- const getHeaders = () => {
971
- return {
972
- "Content-Type": "application/json",
973
- "x-api-key": apiConfig.apiKey,
974
- "x-api-secret": apiConfig.apiSecret
975
- };
976
- };
977
- const createPayment = async (paymentData) => {
978
- try {
979
- console.log("Creating payment with data:", paymentData);
980
- console.log("API URL:", `${apiConfig.apiUrl}/api/payments/create`);
981
- const response = await fetch(`${apiConfig.apiUrl}/api/payments/create`, {
982
- method: "POST",
983
- headers: getHeaders(),
984
- body: JSON.stringify(paymentData)
985
- });
986
- console.log("Create payment response status:", response.status);
987
- if (!response.ok) {
988
- const errorData = await response.json();
989
- console.error("Error creating payment:", errorData);
990
- throw new Error(errorData.error || `Failed to create payment: ${response.status}`);
991
- }
992
- const data = await response.json();
993
- console.log("Create payment response data:", data);
994
- return data;
995
- } catch (error) {
996
- console.error("Create payment error:", error);
997
- throw error;
998
- }
999
- };
1000
- const getPayment = async (paymentId) => {
1001
- try {
1002
- console.log("Getting payment:", paymentId);
1003
- const response = await fetch(`${apiConfig.apiUrl}/api/payments/${paymentId}`, {
1004
- method: "GET",
1005
- headers: getHeaders()
1006
- });
1007
- if (!response.ok) {
1008
- const errorData = await response.json();
1009
- console.error("Error getting payment:", errorData);
1010
- throw new Error(errorData.error || `Failed to get payment: ${response.status}`);
1011
- }
1012
- const data = await response.json();
1013
- console.log("Get payment response:", data);
1014
- return data;
1015
- } catch (error) {
1016
- console.error("Get payment error:", error);
1017
- throw error;
1018
- }
1019
- };
1020
- const processPayment = async (processData) => {
1021
- try {
1022
- console.log("Processing payment with data:", processData);
1023
- console.log("API URL:", `${apiConfig.apiUrl}/api/payments/process`);
1024
- const response = await fetch(`${apiConfig.apiUrl}/api/payments/process`, {
1025
- method: "POST",
1026
- headers: getHeaders(),
1027
- body: JSON.stringify(processData)
1028
- });
1029
- console.log("Process payment response status:", response.status);
1030
- if (!response.ok) {
1031
- const errorData = await response.json();
1032
- console.error("Error processing payment:", errorData);
1033
- throw new Error(errorData.error || `Failed to process payment: ${response.status}`);
1034
- }
1035
- const data = await response.json();
1036
- console.log("Process payment response data:", data);
1037
- return data;
1038
- } catch (error) {
1039
- console.error("Process payment error:", error);
1040
- throw error;
1041
- }
1042
- };
1043
- const getMerchantPayments = async (options = {}) => {
1044
- try {
1045
- const { page = 1, limit = 10, status, currency, startDate, endDate, search } = options;
1046
- const queryParams = new URLSearchParams();
1047
- queryParams.append("page", page);
1048
- queryParams.append("limit", limit);
1049
- if (status)
1050
- queryParams.append("status", status);
1051
- if (currency)
1052
- queryParams.append("currency", currency);
1053
- if (startDate)
1054
- queryParams.append("startDate", startDate);
1055
- if (endDate)
1056
- queryParams.append("endDate", endDate);
1057
- if (search)
1058
- queryParams.append("search", search);
1059
- const url = `${apiConfig.apiUrl}/api/payments/merchant/list?${queryParams.toString()}`;
1060
- const response = await fetch(url, {
1061
- method: "GET",
1062
- headers: getHeaders()
1063
- });
1064
- if (!response.ok) {
1065
- const errorData = await response.json();
1066
- throw new Error(errorData.error || `Failed to get payments: ${response.status}`);
1067
- }
1068
- return await response.json();
1069
- } catch (error) {
1070
- console.error("Get merchant payments error:", error);
1071
- throw error;
1072
- }
1073
- };
1074
- const getMerchantPaymentStats = async () => {
1075
- try {
1076
- const response = await fetch(`${apiConfig.apiUrl}/api/payments/merchant/stats`, {
1077
- method: "GET",
1078
- headers: getHeaders()
1079
- });
1080
- if (!response.ok) {
1081
- const errorData = await response.json();
1082
- throw new Error(errorData.error || `Failed to get payment stats: ${response.status}`);
1083
- }
1084
- return await response.json();
1085
- } catch (error) {
1086
- console.error("Get merchant payment stats error:", error);
1087
- throw error;
1088
- }
1089
- };
1090
- const getSupportedCurrencies = async () => {
1091
- try {
1092
- const response = await fetch(`${apiConfig.apiUrl}/api/payments/currencies`, {
1093
- method: "GET",
1094
- headers: getHeaders()
1095
- });
1096
- if (!response.ok) {
1097
- const errorData = await response.json();
1098
- throw new Error(errorData.error || `Failed to get currencies: ${response.status}`);
1099
- }
1100
- return await response.json();
1101
- } catch (error) {
1102
- console.error("Get supported currencies error:", error);
1103
- return {
1104
- currencies: [
1105
- { id: "USDT", name: "Tether USD", network: "ethereum" },
1106
- { id: "USDC", name: "USD Coin", network: "ethereum" },
1107
- { id: "BNB", name: "Binance Coin", network: "binance" },
1108
- { id: "SOL", name: "Solana", network: "solana" },
1109
- { id: "USDC_SOL", name: "USD Coin (Solana)", network: "solana" }
1110
- ]
1111
- };
1112
- }
1113
- };
1114
- const CoinleyContext = require$$0.createContext();
1115
- const useCoinley = () => require$$0.useContext(CoinleyContext);
1116
- const CoinleyProvider = ({
1117
- apiKey,
1118
- apiSecret,
1119
- apiUrl = "https://coinleyserver-production.up.railway.app",
1120
- debug = false,
1121
- children
1122
- }) => {
1123
- const [isInitialized, setIsInitialized] = require$$0.useState(false);
1124
- const [error, setError] = require$$0.useState(null);
1125
- require$$0.useEffect(() => {
1126
- if (!apiKey || !apiSecret) {
1127
- setError("API key and secret are required");
1128
- return;
1129
- }
1130
- try {
1131
- initializeApi({ apiKey, apiSecret, apiUrl });
1132
- setIsInitialized(true);
1133
- if (debug) {
1134
- console.log("Coinley SDK initialized with:", { apiKey, apiUrl });
1135
- }
1136
- } catch (err) {
1137
- setError(err.message);
1138
- if (debug) {
1139
- console.error("Coinley SDK initialization error:", err);
1140
- }
1141
- }
1142
- }, [apiKey, apiSecret, apiUrl, debug]);
1143
- const value = {
1144
- apiKey,
1145
- apiSecret,
1146
- apiUrl,
1147
- isInitialized,
1148
- error,
1149
- debug
1150
- };
1151
- return /* @__PURE__ */ jsxRuntimeExports.jsx(CoinleyContext.Provider, { value, children });
1152
- };
1153
- const QRCode = ({ walletAddress, amount, currency, theme = "light" }) => {
1154
- const qrPlaceholder = /* @__PURE__ */ jsxRuntimeExports.jsxs(
1155
- "div",
1156
- {
1157
- style: {
1158
- width: "200px",
1159
- height: "200px",
1160
- backgroundColor: theme === "dark" ? "#374151" : "#f3f4f6",
1161
- display: "flex",
1162
- alignItems: "center",
1163
- justifyContent: "center",
1164
- color: theme === "dark" ? "white" : "black",
1165
- fontWeight: "bold",
1166
- border: `1px solid ${theme === "dark" ? "#4b5563" : "#e5e7eb"}`,
1167
- margin: "0 auto"
1168
- },
1169
- children: [
1170
- currency,
1171
- " Payment QR"
1172
- ]
1173
- }
1174
- );
1175
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center", children: [
1176
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-4 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-white"} mb-3`, children: qrPlaceholder }),
1177
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `text-center text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-700"}`, children: "Scan with your wallet app to pay" }),
1178
- walletAddress && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-3 w-full", children: [
1179
- /* @__PURE__ */ jsxRuntimeExports.jsxs("p", { className: `text-xs ${theme === "dark" ? "text-gray-400" : "text-gray-500"} mb-1`, children: [
1180
- "Send ",
1181
- amount,
1182
- " ",
1183
- currency,
1184
- " to:"
1185
- ] }),
1186
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `text-xs font-mono p-2 rounded overflow-auto break-all ${theme === "dark" ? "bg-gray-800 text-gray-300" : "bg-gray-100 text-gray-700"}`, children: walletAddress })
1187
- ] }),
1188
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-4 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-3 rounded ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
1189
- /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: `text-sm font-medium mb-2 ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Payment Instructions" }),
1190
- /* @__PURE__ */ jsxRuntimeExports.jsxs("ol", { className: `text-xs space-y-2 ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: [
1191
- /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "1. Open your crypto wallet app" }),
1192
- /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: "2. Scan the QR code above" }),
1193
- /* @__PURE__ */ jsxRuntimeExports.jsxs("li", { children: [
1194
- "3. Send ",
1195
- amount,
1196
- " ",
1197
- currency
1198
- ] }),
1199
- /* @__PURE__ */ jsxRuntimeExports.jsx("li", { children: '4. Click "Pay Now" button after sending' })
1200
- ] })
1201
- ] }) })
1202
- ] });
1203
- };
1204
- const PaymentStatus = ({ status, message, theme = "light" }) => {
1205
- const renderIcon = () => {
1206
- switch (status) {
1207
- case "processing":
1208
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "animate-spin rounded-full h-12 w-12 border-4 border-t-blue-500 border-blue-500/20" });
1209
- case "success":
1210
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-full h-12 w-12 bg-green-100 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1211
- "svg",
1212
- {
1213
- xmlns: "http://www.w3.org/2000/svg",
1214
- className: "h-8 w-8 text-green-500",
1215
- fill: "none",
1216
- viewBox: "0 0 24 24",
1217
- stroke: "currentColor",
1218
- strokeWidth: 2,
1219
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M5 13l4 4L19 7" })
1220
- }
1221
- ) });
1222
- case "error":
1223
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-full h-12 w-12 bg-red-100 flex items-center justify-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1224
- "svg",
1225
- {
1226
- xmlns: "http://www.w3.org/2000/svg",
1227
- className: "h-8 w-8 text-red-500",
1228
- fill: "none",
1229
- viewBox: "0 0 24 24",
1230
- stroke: "currentColor",
1231
- strokeWidth: 2,
1232
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" })
1233
- }
1234
- ) });
1235
- default:
1236
- return null;
1237
- }
1238
- };
1239
- const getStatusTitle = () => {
1240
- switch (status) {
1241
- case "processing":
1242
- return "Processing Payment";
1243
- case "success":
1244
- return "Payment Successful";
1245
- case "error":
1246
- return "Payment Failed";
1247
- default:
1248
- return "Unknown Status";
1249
- }
1250
- };
1251
- const getMessageClasses = () => {
1252
- switch (status) {
1253
- case "processing":
1254
- return theme === "dark" ? "text-blue-300" : "text-blue-600";
1255
- case "success":
1256
- return theme === "dark" ? "text-green-300" : "text-green-600";
1257
- case "error":
1258
- return theme === "dark" ? "text-red-300" : "text-red-600";
1259
- default:
1260
- return theme === "dark" ? "text-gray-300" : "text-gray-600";
1261
- }
1262
- };
1263
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col items-center justify-center py-6", children: [
1264
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: renderIcon() }),
1265
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-xl font-bold mb-2 ${theme === "dark" ? "text-white" : "text-gray-900"}`, children: getStatusTitle() }),
1266
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-center ${getMessageClasses()}`, children: message }),
1267
- status === "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mt-4 text-xs ${theme === "dark" ? "text-gray-400" : "text-gray-500"}`, children: "This may take a few moments. Please do not close this window." }),
1268
- status === "success" && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `mt-4 p-2 rounded ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-xs ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Your payment has been successfully processed. You will receive a confirmation shortly." }) })
1269
- ] });
1270
- };
1271
- const PaymentMethods = ({ onSelect, selected, theme = "light" }) => {
1272
- const paymentMethods = [
1273
- {
1274
- id: "USDT",
1275
- name: "USDT",
1276
- description: "Tether USD",
1277
- logo: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAzMiAzMiI+PGcgZmlsbD0ibm9uZSIgZmlsbC1ydWxlPSJldmVub2RkIj48Y2lyY2xlIGN4PSIxNiIgY3k9IjE2IiByPSIxNiIgZmlsbD0iIzI2QTE3QiIvPjxwYXRoIGZpbGw9IiNGRkYiIGQ9Ik0xNy45MjIgMTcuMzgzdi0uMDAyYy0uMTEuMDA4LS42NzcuMDQyLTEuOTQyLjA0Mi0xLjAxIDAtMS43MjEtLjAzLTEuOTcxLS4wNDJ2LjAwM2MtMy44ODgtLjE3MS02Ljc5LS44NDgtNi43OS0xLjY1OCAwLS44MDkgMi45MDItMS40ODYgNi43OS0xLjY2di4wNDdjLjI1NC4wMTguOTgyLjA0NSAxLjk4OC4wNDUgMS4yMDcgMCAxLjgxMi0uMDM2IDEuOTI1LS4wNDZ2LS4wNDRjMy44OC4xNzQgNi43NzUuODUxIDYuNzc1IDEuNjU4IDAgLjgwNy0yLjg5NSAxLjQ4NS02Ljc3NSAxLjY1N3ptMC0zLjU2NnYtLjA0N2MuMS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MzgtLjIzLjY1LS42LjcyLTEuMDRsLjA4LS4zYy4wMy0uMTEuMS0uMi4xNi0uMjh6TTYuNTYgMTIuNTV2LTEuMnMuMDQtLjE3LjEzLS4yM2MuMDktLjA2LjIzLTEuMDQuMjMtMS4wNC4wMy0uMjIuMTYtLjQyLjM2LS41M2wuNC0uMjJjLjA4LS4wNC41My0uNDUuNTMtLjQ1LjEzLS4xLjMtLjAzLjM0LjEzIDAgMCAxLjg5IDkuMDEgMS44OSA5LjAxLjA1LjMtLjE3LjU2LS40NC42OWwtLjQ4LjI0Yy0uMy4xNS0xMS40NSA1LjgtMTEuNDUgNS44LS4yMi4xMi0uNTctLjA0LS41Ny0uMzJWMTJjLS4wMi0uMzUuMjQtLjY2LjU3LS43aDguNDRhLjY3LjY3IDAgMDAuNjEtLjM4di0uMDJjLjA3LS4xNi4yNC0uMjQuNC0uMmwuMjUuMDRjLjE0LjAyLjMuMTguMy4xOHoiIGZpbGw9IiNmZmYiLz48L2c+PC9zdmc+"
1296
- }
1297
- ];
1298
- const handleSelectPaymentMethod = (id) => {
1299
- onSelect(id);
1300
- };
1301
- return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1302
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-lg font-medium mb-3 ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Select Payment Method" }),
1303
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-2", children: paymentMethods.map((method) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
1304
- "button",
1305
- {
1306
- onClick: () => handleSelectPaymentMethod(method.id),
1307
- className: `w-full flex items-center p-3 rounded-lg transition-colors ${selected === method.id ? theme === "dark" ? "bg-blue-900/30 border border-blue-500" : "bg-blue-50 border border-blue-500" : theme === "dark" ? "bg-gray-700 hover:bg-gray-600 border border-gray-700" : "bg-white hover:bg-gray-50 border border-gray-200"}`,
1308
- children: [
1309
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-shrink-0 h-10 w-10 bg-white rounded-full flex items-center justify-center mr-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: method.logo, alt: method.name, className: "h-6 w-6" }) }),
1310
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-1 text-left", children: [
1311
- /* @__PURE__ */ jsxRuntimeExports.jsx("h4", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-900"}`, children: method.name }),
1312
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-500"}`, children: method.description })
1313
- ] }),
1314
- selected === method.id && /* @__PURE__ */ jsxRuntimeExports.jsx(
1315
- "svg",
1316
- {
1317
- xmlns: "http://www.w3.org/2000/svg",
1318
- className: "h-5 w-5 text-blue-500",
1319
- viewBox: "0 0 20 20",
1320
- fill: "currentColor",
1321
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1322
- "path",
1323
- {
1324
- fillRule: "evenodd",
1325
- d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
1326
- clipRule: "evenodd"
1327
- }
1328
- )
1329
- }
1330
- )
1331
- ]
1332
- },
1333
- method.id
1334
- )) })
1335
- ] });
1336
- };
1337
- const isMetaMaskInstalled = () => {
1338
- return typeof window !== "undefined" && typeof window.ethereum !== "undefined";
1339
- };
1340
- const connectWallet = async () => {
1341
- if (!isMetaMaskInstalled()) {
1342
- throw new Error("MetaMask is not installed");
1343
- }
1344
- try {
1345
- const accounts = await window.ethereum.request({ method: "eth_requestAccounts" });
1346
- return accounts;
1347
- } catch (error) {
1348
- console.error("Error connecting to wallet:", error);
1349
- throw error;
1350
- }
1351
- };
1352
- const getAccounts = async () => {
1353
- if (!isMetaMaskInstalled()) {
1354
- throw new Error("MetaMask is not installed");
1355
- }
1356
- try {
1357
- const accounts = await window.ethereum.request({ method: "eth_accounts" });
1358
- return accounts;
1359
- } catch (error) {
1360
- console.error("Error getting accounts:", error);
1361
- throw error;
1362
- }
1363
- };
1364
- const getChainId = async () => {
1365
- if (!isMetaMaskInstalled()) {
1366
- throw new Error("MetaMask is not installed");
1367
- }
1368
- try {
1369
- const chainId = await window.ethereum.request({ method: "eth_chainId" });
1370
- return chainId;
1371
- } catch (error) {
1372
- console.error("Error getting chain ID:", error);
1373
- throw error;
1374
- }
1375
- };
1376
- const sendTransaction = async (txParams) => {
1377
- if (!isMetaMaskInstalled()) {
1378
- throw new Error("MetaMask is not installed");
1379
- }
1380
- try {
1381
- const txHash = await window.ethereum.request({
1382
- method: "eth_sendTransaction",
1383
- params: [txParams]
1384
- });
1385
- return txHash;
1386
- } catch (error) {
1387
- console.error("Error sending transaction:", error);
1388
- throw error;
1389
- }
1390
- };
1391
- const sendToken = async (tokenAddress, toAddress, amount) => {
1392
- if (!isMetaMaskInstalled()) {
1393
- throw new Error("MetaMask is not installed");
1394
- }
1395
- try {
1396
- const accounts = await window.ethereum.request({ method: "eth_requestAccounts" });
1397
- const fromAddress = accounts[0];
1398
- const transferFunctionSignature = "0xa9059cbb";
1399
- const paddedToAddress = toAddress.slice(2).padStart(64, "0");
1400
- const paddedAmount = amount.toString(16).padStart(64, "0");
1401
- const data = `${transferFunctionSignature}${paddedToAddress}${paddedAmount}`;
1402
- const txParams = {
1403
- from: fromAddress,
1404
- to: tokenAddress,
1405
- data
1406
- };
1407
- const txHash = await window.ethereum.request({
1408
- method: "eth_sendTransaction",
1409
- params: [txParams]
1410
- });
1411
- return txHash;
1412
- } catch (error) {
1413
- console.error("Error sending token:", error);
1414
- throw error;
1415
- }
1416
- };
1417
- const isWalletConnected = async () => {
1418
- try {
1419
- const accounts = await getAccounts();
1420
- return accounts.length > 0;
1421
- } catch (error) {
1422
- return false;
1423
- }
1424
- };
1425
- const getNetworkName = (chainId) => {
1426
- const networks = {
1427
- "0x1": "Ethereum Mainnet",
1428
- "0x3": "Ropsten Testnet",
1429
- "0x4": "Rinkeby Testnet",
1430
- "0x5": "Goerli Testnet",
1431
- "0x2a": "Kovan Testnet",
1432
- "0x38": "Binance Smart Chain",
1433
- "0x89": "Polygon",
1434
- "0xa86a": "Avalanche"
1435
- };
1436
- return networks[chainId] || `Unknown Network (${chainId})`;
1437
- };
1438
- const getTokenBalance = async (tokenAddress, userAddress) => {
1439
- if (!isMetaMaskInstalled()) {
1440
- throw new Error("MetaMask is not installed");
1441
- }
1442
- try {
1443
- const balanceOfSignature = "0x70a08231";
1444
- const paddedAddress = userAddress.slice(2).padStart(64, "0");
1445
- const data = `${balanceOfSignature}${paddedAddress}`;
1446
- const balance = await window.ethereum.request({
1447
- method: "eth_call",
1448
- params: [
1449
- {
1450
- to: tokenAddress,
1451
- data
1452
- },
1453
- "latest"
1454
- ]
1455
- });
1456
- return parseInt(balance, 16).toString();
1457
- } catch (error) {
1458
- console.error("Error getting token balance:", error);
1459
- throw error;
1460
- }
1461
- };
1462
- const TOKEN_ADDRESSES = {
1463
- USDT: "0xdAC17F958D2ee523a2206206994597C13D831ec7",
1464
- USDC: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
1465
- DAI: "0x6B175474E89094C44Da98b954EedeAC495271d0F",
1466
- WETH: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
1467
- WBTC: "0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599"
1468
- };
1469
- const Logo = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAHgAAAAcCAYAAACqAXueAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAiaSURBVHgB7VrdddNIFL4zNuDAw2orQDQATgUoUABQAU4FOGcLiF0BpoI4FcQ0QLQVxAHOvqLtwDyQOBBr9rszI2n058jeBEhOvnNkS6M7o7m6c39HRA3Qf/bxLR+l9uDIR/sXHD26trjTJeoMiO6/pEuCEBuHOB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S5AC7RMbe6wqXTq8CnWpx4s4TRGVsdU3Wyf0rKke5PpWFG5liiFmpqPL0KjTSsxrr59ngYsG9pfny1WJu951z8HG85PozNRIug1OmUu0iKgqXUfyiw+e/IhFv/dkNhTKEabebFK/0hFvtNYR8wrsym27FpgBmaqjUvc1yznvaNxv3VJmzcrutRvVWqEFfEU5HXIlbwifZat1WtXATaJPv9MlyXxc5Ew2zOyh/d6Xe8SYDf+VBZo/VXh/jATa5jhd/JqVK+0UHm6gJzPea2qL3NB0NXEBwD6JmwtE+yx6cVzfdR/5V4JhBgt/YM/O9GzbkM2fubfk2KlLl94MV+XmRW2Ga77B83RQnKyX7TAcC5WBhzKesyaDXO1HWfIe0MjSDYaGNmkEzGdG1QTGaP7m4S2GDxsYJURVlQcDxAIHUQ+1z48V+Jhzp+OSFEWy8mECwdgXlfbYNsh6tF1Xfoh7GslnN9Z0btZay8MmOFkw5YpR2MKW3BCNLO0O0HZqP78QfVYP/jx2mW5TAmcbZYTHxsYFYVNer2XfRyobjxWh1cT607T7d4qejPsrO0EzAgv0u/HH4OBeGaxPO94Q6plv8FECovJc8uTjKNvgPcUpIo0ZgmzUAAAAASUVORK5CYII=";
1470
- const CoinleyModal = ({
1471
- isOpen,
1472
- onClose,
1473
- payment,
1474
- paymentStatus,
1475
- selectedCurrency,
1476
- onCurrencySelect,
1477
- onPayment,
1478
- error,
1479
- theme = "light",
1480
- merchantName,
1481
- transactionHash,
1482
- walletConnected,
1483
- onConnectWallet,
1484
- testMode = false
1485
- }) => {
1486
- const [step, setStep] = require$$0.useState("select-currency");
1487
- const [isMetaMaskAvailable, setIsMetaMaskAvailable] = require$$0.useState(false);
1488
- const [paymentMethod, setPaymentMethod] = require$$0.useState("wallet");
1489
- require$$0.useEffect(() => {
1490
- if (typeof window !== "undefined") {
1491
- setIsMetaMaskAvailable(isMetaMaskInstalled());
1492
- }
1493
- }, []);
1494
- require$$0.useEffect(() => {
1495
- if (paymentStatus === "loading") {
1496
- setStep("processing");
1497
- } else if (paymentStatus === "success") {
1498
- setStep("success");
1499
- } else if (paymentStatus === "error") {
1500
- setStep("error");
1501
- } else if (paymentStatus === "idle" && payment) {
1502
- setStep("select-currency");
1503
- }
1504
- }, [paymentStatus, payment]);
1505
- const handleCurrencySelect = (currency) => {
1506
- onCurrencySelect(currency);
1507
- setStep("confirm");
1508
- };
1509
- const handlePaymentConfirm = () => {
1510
- onPayment(paymentMethod === "qrcode");
1511
- };
1512
- const handleBack = () => {
1513
- if (step === "confirm") {
1514
- setStep("select-currency");
1515
- }
1516
- };
1517
- const handleClose = () => {
1518
- onClose();
1519
- };
1520
- const formatAmount = (amount) => {
1521
- return parseFloat(amount).toFixed(2);
1522
- };
1523
- const formatTransactionHash = (hash) => {
1524
- if (!hash)
1525
- return "";
1526
- if (hash.length <= 14)
1527
- return hash;
1528
- return `${hash.slice(0, 8)}...${hash.slice(-6)}`;
1529
- };
1530
- const togglePaymentMethod = (method) => {
1531
- setPaymentMethod(method);
1532
- };
1533
- const modalBaseClasses = `fixed inset-0 z-50 overflow-y-auto ${theme === "dark" ? "bg-gray-900/75" : "bg-black/50"}`;
1534
- const modalContentClasses = `relative p-6 w-full max-w-md mx-auto rounded-lg shadow-xl ${theme === "dark" ? "bg-gray-800 text-white" : "bg-white text-gray-800"}`;
1535
- const headerClasses = `text-xl font-bold mb-4 ${theme === "dark" ? "text-white" : "text-gray-900"}`;
1536
- const buttonPrimaryClasses = `w-full py-2 px-4 rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ${theme === "dark" ? "bg-blue-600 hover:bg-blue-700 text-white focus:ring-blue-500" : "bg-blue-500 hover:bg-blue-600 text-white focus:ring-blue-500"}`;
1537
- const buttonSecondaryClasses = `w-full py-2 px-4 rounded-md font-medium transition-colors focus:outline-none focus:ring-2 focus:ring-offset-2 ${theme === "dark" ? "bg-gray-700 hover:bg-gray-600 text-white focus:ring-gray-500" : "bg-gray-200 hover:bg-gray-300 text-gray-800 focus:ring-gray-500"}`;
1538
- const tabButtonClasses = `py-2 px-4 text-sm font-medium focus:outline-none transition-colors`;
1539
- const activeTabClasses = `${theme === "dark" ? "bg-gray-700 text-white" : "bg-gray-100 text-gray-800"} rounded-t-md`;
1540
- const inactiveTabClasses = `${theme === "dark" ? "text-gray-400 hover:text-gray-300" : "text-gray-500 hover:text-gray-700"}`;
1541
- if (!isOpen)
1542
- return null;
1543
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: modalBaseClasses, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex min-h-screen items-center justify-center p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: modalContentClasses, children: [
1544
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mb-6", children: [
1545
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1546
- /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: Logo, alt: "Coinley Logo", className: "h-8 mr-2" }),
1547
- /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: headerClasses, children: "Coinley Pay" })
1548
- ] }),
1549
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1550
- "button",
1551
- {
1552
- onClick: handleClose,
1553
- className: `text-gray-500 hover:text-gray-700 focus:outline-none ${theme === "dark" ? "text-gray-400 hover:text-gray-300" : ""}`,
1554
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M6 18L18 6M6 6l12 12" }) })
1555
- }
1556
- )
1557
- ] }),
1558
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-6", children: [
1559
- payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `mb-6 p-4 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
1560
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: merchantName }),
1561
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between items-center mt-2", children: [
1562
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `font-medium ${theme === "dark" ? "text-gray-300" : "text-gray-700"}`, children: "Amount:" }),
1563
- /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold text-xl", children: [
1564
- "$",
1565
- formatAmount(payment.totalAmount || payment.amount)
1566
- ] })
1567
- ] }),
1568
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs mt-1 text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: `${theme === "dark" ? "text-gray-400" : "text-gray-500"}`, children: [
1569
- "Payment ID: ",
1570
- payment.id && payment.id.slice(0, 8),
1571
- "..."
1572
- ] }) })
1573
- ] }),
1574
- step === "select-currency" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1575
- PaymentMethods,
1576
- {
1577
- onSelect: handleCurrencySelect,
1578
- selected: selectedCurrency,
1579
- theme
1580
- }
1581
- ),
1582
- step === "confirm" && payment && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1583
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
1584
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `text-lg font-medium mb-2 ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Payment Details" }),
1585
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-2", children: [
1586
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
1587
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: theme === "dark" ? "text-gray-300" : "text-gray-600", children: "Currency:" }),
1588
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency })
1589
- ] }),
1590
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
1591
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: theme === "dark" ? "text-gray-300" : "text-gray-600", children: "Network:" }),
1592
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL" ? "Solana" : "Ethereum" })
1593
- ] }),
1594
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-between", children: [
1595
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: theme === "dark" ? "text-gray-300" : "text-gray-600", children: "Fee:" }),
1596
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: "1.75%" })
1597
- ] })
1598
- ] })
1599
- ] }),
1600
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-4", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex border-b border-gray-200", children: [
1601
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1602
- "button",
1603
- {
1604
- onClick: () => togglePaymentMethod("wallet"),
1605
- className: `${tabButtonClasses} ${paymentMethod === "wallet" ? activeTabClasses : inactiveTabClasses}`,
1606
- children: "Connect Wallet"
1607
- }
1608
- ),
1609
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1610
- "button",
1611
- {
1612
- onClick: () => togglePaymentMethod("qrcode"),
1613
- className: `${tabButtonClasses} ${paymentMethod === "qrcode" ? activeTabClasses : inactiveTabClasses}`,
1614
- children: "QR Code"
1615
- }
1616
- )
1617
- ] }) }),
1618
- testMode ? (
1619
- // Test mode payment option
1620
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-blue-900/20" : "bg-blue-50"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1621
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "bg-blue-500 rounded-full p-2 mr-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6 text-white", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M13 10V3L4 14h7v7l9-11h-7z" }) }) }),
1622
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1623
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Test Mode Payment" }),
1624
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: 'Click "Pay Now" to simulate a successful payment' })
1625
- ] })
1626
- ] }) })
1627
- ) : paymentMethod === "qrcode" ? (
1628
- // QR Code payment option
1629
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-blue-900/20" : "bg-blue-50"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
1630
- QRCode,
1631
- {
1632
- walletAddress: payment.walletAddress || "0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
1633
- amount: payment.totalAmount || payment.amount,
1634
- currency: selectedCurrency,
1635
- theme
1636
- }
1637
- ) })
1638
- ) : isMetaMaskAvailable ? (
1639
- // MetaMask available option
1640
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-blue-900/20" : "bg-blue-50"}`, children: [
1641
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1642
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1643
- "img",
1644
- {
1645
- src: "https://metamask.io/images/metamask-fox.svg",
1646
- alt: "MetaMask",
1647
- className: "w-8 h-8 mr-2"
1648
- }
1649
- ),
1650
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1651
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "Pay with MetaMask" }),
1652
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: walletConnected ? "Your wallet is connected. Click 'Pay Now' to proceed." : "Click 'Connect Wallet' to proceed with payment." })
1653
- ] })
1654
- ] }),
1655
- !walletConnected && /* @__PURE__ */ jsxRuntimeExports.jsx(
1656
- "button",
1657
- {
1658
- onClick: onConnectWallet,
1659
- className: `mt-3 ${buttonPrimaryClasses}`,
1660
- children: "Connect Wallet"
1661
- }
1662
- )
1663
- ] })
1664
- ) : (
1665
- // MetaMask not available warning
1666
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `p-4 rounded-lg mb-4 ${theme === "dark" ? "bg-yellow-900/20" : "bg-yellow-50"}`, children: [
1667
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
1668
- /* @__PURE__ */ jsxRuntimeExports.jsx("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-6 w-6 text-yellow-500 mr-2", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ jsxRuntimeExports.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z" }) }),
1669
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1670
- /* @__PURE__ */ jsxRuntimeExports.jsx("h3", { className: `font-medium ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: "MetaMask Not Detected" }),
1671
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm ${theme === "dark" ? "text-gray-300" : "text-gray-600"}`, children: "Please install MetaMask extension to make payments" })
1672
- ] })
1673
- ] }),
1674
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1675
- "a",
1676
- {
1677
- href: "https://metamask.io/download/",
1678
- target: "_blank",
1679
- rel: "noopener noreferrer",
1680
- className: `block mt-3 text-center ${buttonPrimaryClasses}`,
1681
- children: "Install MetaMask"
1682
- }
1683
- )
1684
- ] })
1685
- ),
1686
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-6 grid grid-cols-2 gap-3", children: [
1687
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1688
- "button",
1689
- {
1690
- type: "button",
1691
- onClick: handleBack,
1692
- className: buttonSecondaryClasses,
1693
- children: "Back"
1694
- }
1695
- ),
1696
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1697
- "button",
1698
- {
1699
- type: "button",
1700
- onClick: handlePaymentConfirm,
1701
- className: buttonPrimaryClasses,
1702
- disabled: !testMode && paymentMethod === "wallet" && isMetaMaskAvailable && !walletConnected,
1703
- children: "Pay Now"
1704
- }
1705
- )
1706
- ] })
1707
- ] }),
1708
- step === "processing" && /* @__PURE__ */ jsxRuntimeExports.jsx(
1709
- PaymentStatus,
1710
- {
1711
- status: "processing",
1712
- theme,
1713
- message: "Processing your payment..."
1714
- }
1715
- ),
1716
- step === "success" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1717
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1718
- PaymentStatus,
1719
- {
1720
- status: "success",
1721
- theme,
1722
- message: "Payment successful!"
1723
- }
1724
- ),
1725
- transactionHash && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `mt-4 p-3 rounded-lg ${theme === "dark" ? "bg-gray-700" : "bg-gray-100"}`, children: [
1726
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-xs ${theme === "dark" ? "text-gray-300" : "text-gray-600"} mb-1`, children: "Transaction Hash:" }),
1727
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: `text-sm font-mono break-all ${theme === "dark" ? "text-white" : "text-gray-800"}`, children: formatTransactionHash(transactionHash) }),
1728
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1729
- "a",
1730
- {
1731
- href: `https://etherscan.io/tx/${transactionHash}`,
1732
- target: "_blank",
1733
- rel: "noopener noreferrer",
1734
- className: `text-xs ${theme === "dark" ? "text-blue-400" : "text-blue-600"} mt-2 inline-block`,
1735
- children: "View on Etherscan →"
1736
- }
1737
- )
1738
- ] })
1739
- ] }),
1740
- step === "error" && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
1741
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1742
- PaymentStatus,
1743
- {
1744
- status: "error",
1745
- theme,
1746
- message: error || "An error occurred while processing your payment."
1747
- }
1748
- ),
1749
- /* @__PURE__ */ jsxRuntimeExports.jsx(
1750
- "button",
1751
- {
1752
- type: "button",
1753
- onClick: handleBack,
1754
- className: `mt-4 ${buttonSecondaryClasses}`,
1755
- children: "Try Again"
1756
- }
1757
- )
1758
- ] })
1759
- ] }),
1760
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `text-center text-xs ${theme === "dark" ? "text-gray-400" : "text-gray-500"}`, children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Powered by Coinley - Secure Cryptocurrency Payments" }) })
1761
- ] }) }) });
1762
- };
1763
- const CoinleyCheckout = require$$0.forwardRef(({
1764
- apiKey,
1765
- apiSecret,
1766
- apiUrl,
1767
- customerEmail,
1768
- merchantName = "Merchant",
1769
- onSuccess,
1770
- onError,
1771
- onClose,
1772
- theme,
1773
- autoOpen = false,
1774
- debug = false,
1775
- testMode = false
1776
- }, ref) => {
1777
- const coinleyContext = useCoinley();
1778
- const { theme: contextTheme } = useTheme();
1779
- const [isOpen, setIsOpen] = require$$0.useState(autoOpen);
1780
- const [payment, setPayment] = require$$0.useState(null);
1781
- const [paymentStatus, setPaymentStatus] = require$$0.useState("idle");
1782
- const [selectedCurrency, setSelectedCurrency] = require$$0.useState("USDT");
1783
- const [error, setError] = require$$0.useState(null);
1784
- const [transactionHash, setTransactionHash] = require$$0.useState(null);
1785
- const [walletConnected, setWalletConnected] = require$$0.useState(false);
1786
- apiKey || (coinleyContext == null ? void 0 : coinleyContext.apiKey);
1787
- apiSecret || (coinleyContext == null ? void 0 : coinleyContext.apiSecret);
1788
- apiUrl || (coinleyContext == null ? void 0 : coinleyContext.apiUrl);
1789
- const effectiveTheme = theme || contextTheme;
1790
- const effectiveDebug = debug || (coinleyContext == null ? void 0 : coinleyContext.debug);
1791
- require$$0.useImperativeHandle(ref, () => ({
1792
- open: (paymentDetails) => {
1793
- handleOpen(paymentDetails);
1794
- },
1795
- close: () => {
1796
- handleClose();
1797
- },
1798
- getPayment: () => payment
1799
- }));
1800
- const log = (message, data) => {
1801
- if (effectiveDebug) {
1802
- console.log(`[Coinley SDK] ${message}`, data);
1803
- }
1804
- };
1805
- require$$0.useEffect(() => {
1806
- if (typeof window !== "undefined") {
1807
- const checkWalletConnection = async () => {
1808
- if (isMetaMaskInstalled()) {
1809
- try {
1810
- const accounts = await window.ethereum.request({ method: "eth_accounts" });
1811
- setWalletConnected(accounts && accounts.length > 0);
1812
- } catch (err) {
1813
- log("Error checking wallet connection:", err);
1814
- setWalletConnected(false);
1815
- }
1816
- } else {
1817
- setWalletConnected(false);
1818
- }
1819
- };
1820
- checkWalletConnection();
1821
- }
1822
- }, [effectiveDebug]);
1823
- require$$0.useEffect(() => {
1824
- if (typeof window !== "undefined" && window.ethereum) {
1825
- const handleAccountsChanged = (accounts) => {
1826
- setWalletConnected(accounts.length > 0);
1827
- };
1828
- window.ethereum.on("accountsChanged", handleAccountsChanged);
1829
- return () => {
1830
- window.ethereum.removeListener("accountsChanged", handleAccountsChanged);
1831
- };
1832
- }
1833
- return () => {
1834
- };
1835
- }, []);
1836
- const handleOpen = async (paymentDetails) => {
1837
- if (!paymentDetails || !paymentDetails.amount) {
1838
- setError("Payment amount is required");
1839
- if (onError)
1840
- onError(new Error("Payment amount is required"));
1841
- return;
1842
- }
1843
- setPaymentStatus("loading");
1844
- setIsOpen(true);
1845
- try {
1846
- log("Creating payment with details:", paymentDetails);
1847
- const paymentResponse = await createPayment({
1848
- amount: paymentDetails.amount,
1849
- currency: paymentDetails.currency || "USDT",
1850
- customerEmail: paymentDetails.customerEmail || customerEmail,
1851
- callbackUrl: paymentDetails.callbackUrl,
1852
- metadata: paymentDetails.metadata || {}
1853
- });
1854
- log("Payment created:", paymentResponse);
1855
- setPayment(paymentResponse.payment);
1856
- setPaymentStatus("idle");
1857
- setError(null);
1858
- log("Payment created and state updated:", {
1859
- payment: paymentResponse.payment,
1860
- status: "idle"
1861
- });
1862
- } catch (err) {
1863
- log("Error creating payment:", err);
1864
- setError(err.message || "Failed to create payment");
1865
- setPaymentStatus("error");
1866
- if (onError)
1867
- onError(err);
1868
- }
1869
- };
1870
- const handleClose = () => {
1871
- setIsOpen(false);
1872
- setTransactionHash(null);
1873
- if (onClose)
1874
- onClose();
1875
- };
1876
- const handlePaymentMethodSelect = (currency) => {
1877
- log("Currency selected:", currency);
1878
- setSelectedCurrency(currency);
1879
- };
1880
- const connectToWallet = async () => {
1881
- if (!isMetaMaskInstalled()) {
1882
- setError("MetaMask is not installed. Please install MetaMask to make payments.");
1883
- return false;
1884
- }
1885
- try {
1886
- const accounts = await connectWallet();
1887
- setWalletConnected(accounts.length > 0);
1888
- return accounts.length > 0;
1889
- } catch (err) {
1890
- log("Error connecting to wallet:", err);
1891
- setError(err.message || "Failed to connect to wallet");
1892
- return false;
1893
- }
1894
- };
1895
- const handlePayment = async (isQrCodeMode = false) => {
1896
- if (!payment) {
1897
- setError("No active payment to process");
1898
- return;
1899
- }
1900
- log("Starting payment process...", { isQrCodeMode });
1901
- setPaymentStatus("loading");
1902
- setTransactionHash(null);
1903
- try {
1904
- log("Processing payment:", { paymentId: payment.id, currency: selectedCurrency, isQrCodeMode });
1905
- let txHash;
1906
- if (testMode) {
1907
- log("Test mode: Generating mock transaction...");
1908
- txHash = `0x${Array.from({ length: 64 }, () => Math.floor(Math.random() * 16).toString(16)).join("")}`;
1909
- } else if (isQrCodeMode) {
1910
- log("QR code payment: User confirms payment was sent");
1911
- txHash = `qrcode_${Date.now().toString(16)}_${Math.random().toString(16).substring(2, 10)}`;
1912
- } else {
1913
- if (!walletConnected) {
1914
- const connected = await connectToWallet();
1915
- if (!connected) {
1916
- throw new Error("Please connect your wallet to proceed with payment");
1917
- }
1918
- }
1919
- const merchantAddress = payment.walletAddress || "0x742d35Cc6634C0532925a3b844Bc454e4438f44e";
1920
- const txParams = {
1921
- from: await window.ethereum.request({ method: "eth_requestAccounts" }).then((accounts) => accounts[0]),
1922
- to: merchantAddress,
1923
- value: "0x0",
1924
- // For ERC-20 tokens, value is 0
1925
- data: "0x"
1926
- // Would include token transfer data for ERC-20
1927
- };
1928
- log("Sending transaction to wallet for approval...");
1929
- txHash = await sendTransaction(txParams);
1930
- }
1931
- log("Transaction hash:", txHash);
1932
- setTransactionHash(txHash);
1933
- log("Sending process payment request to API...");
1934
- const processResponse = await processPayment({
1935
- paymentId: payment.id,
1936
- transactionHash: txHash,
1937
- network: selectedCurrency === "SOL" || selectedCurrency === "USDC_SOL" ? "solana" : "ethereum"
1938
- });
1939
- log("Payment processed successfully:", processResponse);
1940
- setPaymentStatus("success");
1941
- if (onSuccess) {
1942
- log("Calling onSuccess callback...");
1943
- onSuccess(payment.id, txHash);
1944
- }
1945
- } catch (err) {
1946
- log("Payment error:", err);
1947
- setError(err.message || "Failed to process payment");
1948
- setPaymentStatus("error");
1949
- if (onError)
1950
- onError(err);
1951
- }
1952
- };
1953
- require$$0.useEffect(() => {
1954
- if (autoOpen && payment) {
1955
- setIsOpen(true);
1956
- }
1957
- }, [autoOpen, payment]);
1958
- return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: isOpen && /* @__PURE__ */ jsxRuntimeExports.jsx(
1959
- CoinleyModal,
1960
- {
1961
- isOpen,
1962
- onClose: handleClose,
1963
- payment,
1964
- paymentStatus,
1965
- selectedCurrency,
1966
- onCurrencySelect: handlePaymentMethodSelect,
1967
- onPayment: handlePayment,
1968
- error,
1969
- theme: effectiveTheme,
1970
- merchantName,
1971
- transactionHash,
1972
- walletConnected,
1973
- onConnectWallet: connectToWallet,
1974
- testMode
1975
- }
1976
- ) });
1977
- });
1978
- CoinleyCheckout.displayName = "CoinleyCheckout";
1979
- const DEFAULT_CONFIG = {
1980
- apiUrl: "https://coinleyserver-production.up.railway.app",
1981
- debug: false,
1982
- testMode: false,
1983
- theme: "light"
1984
- };
1985
- const VERSION = "1.0.6";
1986
- exports2.CoinleyCheckout = CoinleyCheckout;
1987
- exports2.CoinleyModal = CoinleyModal;
1988
- exports2.CoinleyProvider = CoinleyProvider;
1989
- exports2.DEFAULT_CONFIG = DEFAULT_CONFIG;
1990
- exports2.PaymentMethods = PaymentMethods;
1991
- exports2.PaymentStatus = PaymentStatus;
1992
- exports2.QRCode = QRCode;
1993
- exports2.TOKEN_ADDRESSES = TOKEN_ADDRESSES;
1994
- exports2.ThemeProvider = ThemeProvider;
1995
- exports2.VERSION = VERSION;
1996
- exports2.connectWallet = connectWallet;
1997
- exports2.createPayment = createPayment;
1998
- exports2.getAccounts = getAccounts;
1999
- exports2.getChainId = getChainId;
2000
- exports2.getMerchantPaymentStats = getMerchantPaymentStats;
2001
- exports2.getMerchantPayments = getMerchantPayments;
2002
- exports2.getNetworkName = getNetworkName;
2003
- exports2.getPayment = getPayment;
2004
- exports2.getSupportedCurrencies = getSupportedCurrencies;
2005
- exports2.getTokenBalance = getTokenBalance;
2006
- exports2.isMetaMaskInstalled = isMetaMaskInstalled;
2007
- exports2.isWalletConnected = isWalletConnected;
2008
- exports2.processPayment = processPayment;
2009
- exports2.sendToken = sendToken;
2010
- exports2.sendTransaction = sendTransaction;
2011
- Object.defineProperty(exports2, Symbol.toStringTag, { value: "Module" });
2012
- });
2013
- //# sourceMappingURL=coinley-checkout.umd.js.map