@alleyboss/micropay-solana-x402-paywall 3.1.4 → 3.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
@@ -3,10 +3,1457 @@ export * from '@x402/core/types';
3
3
  export * from '@x402/core/client';
4
4
  export * from '@x402/svm';
5
5
  import { decodePaymentRequiredHeader, encodePaymentSignatureHeader } from '@x402/core/http';
6
- import { PublicKey, SystemProgram, LAMPORTS_PER_SOL, Keypair, TransactionMessage, VersionedTransaction, ComputeBudgetProgram } from '@solana/web3.js';
6
+ import { PublicKey, Transaction, SystemProgram, LAMPORTS_PER_SOL, Keypair, TransactionMessage, VersionedTransaction, ComputeBudgetProgram } from '@solana/web3.js';
7
+ import bs58 from 'bs58';
7
8
  import { SignJWT, jwtVerify } from 'jose';
8
9
 
9
- // src/index.ts
10
+ var __create = Object.create;
11
+ var __defProp = Object.defineProperty;
12
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
13
+ var __getOwnPropNames = Object.getOwnPropertyNames;
14
+ var __getProtoOf = Object.getPrototypeOf;
15
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
16
+ var __commonJS = (cb, mod) => function __require() {
17
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18
+ };
19
+ var __copyProps = (to, from, except, desc) => {
20
+ if (from && typeof from === "object" || typeof from === "function") {
21
+ for (let key of __getOwnPropNames(from))
22
+ if (!__hasOwnProp.call(to, key) && key !== except)
23
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
24
+ }
25
+ return to;
26
+ };
27
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
28
+ // If the importer is in node compatibility mode or this is not an ESM
29
+ // file that has been converted to a CommonJS file using a Babel-
30
+ // compatible transform (i.e. "__esModule" has not been set), then set
31
+ // "default" to the CommonJS "module.exports" for node compatibility.
32
+ __defProp(target, "default", { value: mod, enumerable: true }) ,
33
+ mod
34
+ ));
35
+
36
+ // ../../node_modules/react/cjs/react.production.js
37
+ var require_react_production = __commonJS({
38
+ "../../node_modules/react/cjs/react.production.js"(exports$1) {
39
+ var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element");
40
+ var REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal");
41
+ var REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment");
42
+ var REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode");
43
+ var REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler");
44
+ var REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer");
45
+ var REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context");
46
+ var REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref");
47
+ var REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense");
48
+ var REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo");
49
+ var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
50
+ var REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity");
51
+ var MAYBE_ITERATOR_SYMBOL = Symbol.iterator;
52
+ function getIteratorFn(maybeIterable) {
53
+ if (null === maybeIterable || "object" !== typeof maybeIterable) return null;
54
+ maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
55
+ return "function" === typeof maybeIterable ? maybeIterable : null;
56
+ }
57
+ var ReactNoopUpdateQueue = {
58
+ isMounted: function() {
59
+ return false;
60
+ },
61
+ enqueueForceUpdate: function() {
62
+ },
63
+ enqueueReplaceState: function() {
64
+ },
65
+ enqueueSetState: function() {
66
+ }
67
+ };
68
+ var assign = Object.assign;
69
+ var emptyObject = {};
70
+ function Component(props, context, updater) {
71
+ this.props = props;
72
+ this.context = context;
73
+ this.refs = emptyObject;
74
+ this.updater = updater || ReactNoopUpdateQueue;
75
+ }
76
+ Component.prototype.isReactComponent = {};
77
+ Component.prototype.setState = function(partialState, callback) {
78
+ if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
79
+ throw Error(
80
+ "takes an object of state variables to update or a function which returns an object of state variables."
81
+ );
82
+ this.updater.enqueueSetState(this, partialState, callback, "setState");
83
+ };
84
+ Component.prototype.forceUpdate = function(callback) {
85
+ this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
86
+ };
87
+ function ComponentDummy() {
88
+ }
89
+ ComponentDummy.prototype = Component.prototype;
90
+ function PureComponent(props, context, updater) {
91
+ this.props = props;
92
+ this.context = context;
93
+ this.refs = emptyObject;
94
+ this.updater = updater || ReactNoopUpdateQueue;
95
+ }
96
+ var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
97
+ pureComponentPrototype.constructor = PureComponent;
98
+ assign(pureComponentPrototype, Component.prototype);
99
+ pureComponentPrototype.isPureReactComponent = true;
100
+ var isArrayImpl = Array.isArray;
101
+ function noop() {
102
+ }
103
+ var ReactSharedInternals = { H: null, A: null, T: null, S: null };
104
+ var hasOwnProperty = Object.prototype.hasOwnProperty;
105
+ function ReactElement(type, key, props) {
106
+ var refProp = props.ref;
107
+ return {
108
+ $$typeof: REACT_ELEMENT_TYPE,
109
+ type,
110
+ key,
111
+ ref: void 0 !== refProp ? refProp : null,
112
+ props
113
+ };
114
+ }
115
+ function cloneAndReplaceKey(oldElement, newKey) {
116
+ return ReactElement(oldElement.type, newKey, oldElement.props);
117
+ }
118
+ function isValidElement(object) {
119
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
120
+ }
121
+ function escape(key) {
122
+ var escaperLookup = { "=": "=0", ":": "=2" };
123
+ return "$" + key.replace(/[=:]/g, function(match) {
124
+ return escaperLookup[match];
125
+ });
126
+ }
127
+ var userProvidedKeyEscapeRegex = /\/+/g;
128
+ function getElementKey(element, index) {
129
+ return "object" === typeof element && null !== element && null != element.key ? escape("" + element.key) : index.toString(36);
130
+ }
131
+ function resolveThenable(thenable) {
132
+ switch (thenable.status) {
133
+ case "fulfilled":
134
+ return thenable.value;
135
+ case "rejected":
136
+ throw thenable.reason;
137
+ default:
138
+ switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
139
+ function(fulfilledValue) {
140
+ "pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
141
+ },
142
+ function(error) {
143
+ "pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
144
+ }
145
+ )), thenable.status) {
146
+ case "fulfilled":
147
+ return thenable.value;
148
+ case "rejected":
149
+ throw thenable.reason;
150
+ }
151
+ }
152
+ throw thenable;
153
+ }
154
+ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
155
+ var type = typeof children;
156
+ if ("undefined" === type || "boolean" === type) children = null;
157
+ var invokeCallback = false;
158
+ if (null === children) invokeCallback = true;
159
+ else
160
+ switch (type) {
161
+ case "bigint":
162
+ case "string":
163
+ case "number":
164
+ invokeCallback = true;
165
+ break;
166
+ case "object":
167
+ switch (children.$$typeof) {
168
+ case REACT_ELEMENT_TYPE:
169
+ case REACT_PORTAL_TYPE:
170
+ invokeCallback = true;
171
+ break;
172
+ case REACT_LAZY_TYPE:
173
+ return invokeCallback = children._init, mapIntoArray(
174
+ invokeCallback(children._payload),
175
+ array,
176
+ escapedPrefix,
177
+ nameSoFar,
178
+ callback
179
+ );
180
+ }
181
+ }
182
+ if (invokeCallback)
183
+ return callback = callback(children), invokeCallback = "" === nameSoFar ? "." + getElementKey(children, 0) : nameSoFar, isArrayImpl(callback) ? (escapedPrefix = "", null != invokeCallback && (escapedPrefix = invokeCallback.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
184
+ return c;
185
+ })) : null != callback && (isValidElement(callback) && (callback = cloneAndReplaceKey(
186
+ callback,
187
+ escapedPrefix + (null == callback.key || children && children.key === callback.key ? "" : ("" + callback.key).replace(
188
+ userProvidedKeyEscapeRegex,
189
+ "$&/"
190
+ ) + "/") + invokeCallback
191
+ )), array.push(callback)), 1;
192
+ invokeCallback = 0;
193
+ var nextNamePrefix = "" === nameSoFar ? "." : nameSoFar + ":";
194
+ if (isArrayImpl(children))
195
+ for (var i = 0; i < children.length; i++)
196
+ nameSoFar = children[i], type = nextNamePrefix + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
197
+ nameSoFar,
198
+ array,
199
+ escapedPrefix,
200
+ type,
201
+ callback
202
+ );
203
+ else if (i = getIteratorFn(children), "function" === typeof i)
204
+ for (children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
205
+ nameSoFar = nameSoFar.value, type = nextNamePrefix + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
206
+ nameSoFar,
207
+ array,
208
+ escapedPrefix,
209
+ type,
210
+ callback
211
+ );
212
+ else if ("object" === type) {
213
+ if ("function" === typeof children.then)
214
+ return mapIntoArray(
215
+ resolveThenable(children),
216
+ array,
217
+ escapedPrefix,
218
+ nameSoFar,
219
+ callback
220
+ );
221
+ array = String(children);
222
+ throw Error(
223
+ "Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
224
+ );
225
+ }
226
+ return invokeCallback;
227
+ }
228
+ function mapChildren(children, func, context) {
229
+ if (null == children) return children;
230
+ var result = [], count = 0;
231
+ mapIntoArray(children, result, "", "", function(child) {
232
+ return func.call(context, child, count++);
233
+ });
234
+ return result;
235
+ }
236
+ function lazyInitializer(payload) {
237
+ if (-1 === payload._status) {
238
+ var ctor = payload._result;
239
+ ctor = ctor();
240
+ ctor.then(
241
+ function(moduleObject) {
242
+ if (0 === payload._status || -1 === payload._status)
243
+ payload._status = 1, payload._result = moduleObject;
244
+ },
245
+ function(error) {
246
+ if (0 === payload._status || -1 === payload._status)
247
+ payload._status = 2, payload._result = error;
248
+ }
249
+ );
250
+ -1 === payload._status && (payload._status = 0, payload._result = ctor);
251
+ }
252
+ if (1 === payload._status) return payload._result.default;
253
+ throw payload._result;
254
+ }
255
+ var reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
256
+ if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
257
+ var event = new window.ErrorEvent("error", {
258
+ bubbles: true,
259
+ cancelable: true,
260
+ message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
261
+ error
262
+ });
263
+ if (!window.dispatchEvent(event)) return;
264
+ } else if ("object" === typeof process && "function" === typeof process.emit) {
265
+ process.emit("uncaughtException", error);
266
+ return;
267
+ }
268
+ console.error(error);
269
+ };
270
+ var Children = {
271
+ map: mapChildren,
272
+ forEach: function(children, forEachFunc, forEachContext) {
273
+ mapChildren(
274
+ children,
275
+ function() {
276
+ forEachFunc.apply(this, arguments);
277
+ },
278
+ forEachContext
279
+ );
280
+ },
281
+ count: function(children) {
282
+ var n = 0;
283
+ mapChildren(children, function() {
284
+ n++;
285
+ });
286
+ return n;
287
+ },
288
+ toArray: function(children) {
289
+ return mapChildren(children, function(child) {
290
+ return child;
291
+ }) || [];
292
+ },
293
+ only: function(children) {
294
+ if (!isValidElement(children))
295
+ throw Error(
296
+ "React.Children.only expected to receive a single React element child."
297
+ );
298
+ return children;
299
+ }
300
+ };
301
+ exports$1.Activity = REACT_ACTIVITY_TYPE;
302
+ exports$1.Children = Children;
303
+ exports$1.Component = Component;
304
+ exports$1.Fragment = REACT_FRAGMENT_TYPE;
305
+ exports$1.Profiler = REACT_PROFILER_TYPE;
306
+ exports$1.PureComponent = PureComponent;
307
+ exports$1.StrictMode = REACT_STRICT_MODE_TYPE;
308
+ exports$1.Suspense = REACT_SUSPENSE_TYPE;
309
+ exports$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
310
+ exports$1.__COMPILER_RUNTIME = {
311
+ __proto__: null,
312
+ c: function(size) {
313
+ return ReactSharedInternals.H.useMemoCache(size);
314
+ }
315
+ };
316
+ exports$1.cache = function(fn) {
317
+ return function() {
318
+ return fn.apply(null, arguments);
319
+ };
320
+ };
321
+ exports$1.cacheSignal = function() {
322
+ return null;
323
+ };
324
+ exports$1.cloneElement = function(element, config2, children) {
325
+ if (null === element || void 0 === element)
326
+ throw Error(
327
+ "The argument must be a React element, but you passed " + element + "."
328
+ );
329
+ var props = assign({}, element.props), key = element.key;
330
+ if (null != config2)
331
+ for (propName in void 0 !== config2.key && (key = "" + config2.key), config2)
332
+ !hasOwnProperty.call(config2, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config2.ref || (props[propName] = config2[propName]);
333
+ var propName = arguments.length - 2;
334
+ if (1 === propName) props.children = children;
335
+ else if (1 < propName) {
336
+ for (var childArray = Array(propName), i = 0; i < propName; i++)
337
+ childArray[i] = arguments[i + 2];
338
+ props.children = childArray;
339
+ }
340
+ return ReactElement(element.type, key, props);
341
+ };
342
+ exports$1.createContext = function(defaultValue) {
343
+ defaultValue = {
344
+ $$typeof: REACT_CONTEXT_TYPE,
345
+ _currentValue: defaultValue,
346
+ _currentValue2: defaultValue,
347
+ _threadCount: 0,
348
+ Provider: null,
349
+ Consumer: null
350
+ };
351
+ defaultValue.Provider = defaultValue;
352
+ defaultValue.Consumer = {
353
+ $$typeof: REACT_CONSUMER_TYPE,
354
+ _context: defaultValue
355
+ };
356
+ return defaultValue;
357
+ };
358
+ exports$1.createElement = function(type, config2, children) {
359
+ var propName, props = {}, key = null;
360
+ if (null != config2)
361
+ for (propName in void 0 !== config2.key && (key = "" + config2.key), config2)
362
+ hasOwnProperty.call(config2, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (props[propName] = config2[propName]);
363
+ var childrenLength = arguments.length - 2;
364
+ if (1 === childrenLength) props.children = children;
365
+ else if (1 < childrenLength) {
366
+ for (var childArray = Array(childrenLength), i = 0; i < childrenLength; i++)
367
+ childArray[i] = arguments[i + 2];
368
+ props.children = childArray;
369
+ }
370
+ if (type && type.defaultProps)
371
+ for (propName in childrenLength = type.defaultProps, childrenLength)
372
+ void 0 === props[propName] && (props[propName] = childrenLength[propName]);
373
+ return ReactElement(type, key, props);
374
+ };
375
+ exports$1.createRef = function() {
376
+ return { current: null };
377
+ };
378
+ exports$1.forwardRef = function(render) {
379
+ return { $$typeof: REACT_FORWARD_REF_TYPE, render };
380
+ };
381
+ exports$1.isValidElement = isValidElement;
382
+ exports$1.lazy = function(ctor) {
383
+ return {
384
+ $$typeof: REACT_LAZY_TYPE,
385
+ _payload: { _status: -1, _result: ctor },
386
+ _init: lazyInitializer
387
+ };
388
+ };
389
+ exports$1.memo = function(type, compare) {
390
+ return {
391
+ $$typeof: REACT_MEMO_TYPE,
392
+ type,
393
+ compare: void 0 === compare ? null : compare
394
+ };
395
+ };
396
+ exports$1.startTransition = function(scope) {
397
+ var prevTransition = ReactSharedInternals.T, currentTransition = {};
398
+ ReactSharedInternals.T = currentTransition;
399
+ try {
400
+ var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
401
+ null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
402
+ "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && returnValue.then(noop, reportGlobalError);
403
+ } catch (error) {
404
+ reportGlobalError(error);
405
+ } finally {
406
+ null !== prevTransition && null !== currentTransition.types && (prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
407
+ }
408
+ };
409
+ exports$1.unstable_useCacheRefresh = function() {
410
+ return ReactSharedInternals.H.useCacheRefresh();
411
+ };
412
+ exports$1.use = function(usable) {
413
+ return ReactSharedInternals.H.use(usable);
414
+ };
415
+ exports$1.useActionState = function(action, initialState, permalink) {
416
+ return ReactSharedInternals.H.useActionState(action, initialState, permalink);
417
+ };
418
+ exports$1.useCallback = function(callback, deps) {
419
+ return ReactSharedInternals.H.useCallback(callback, deps);
420
+ };
421
+ exports$1.useContext = function(Context) {
422
+ return ReactSharedInternals.H.useContext(Context);
423
+ };
424
+ exports$1.useDebugValue = function() {
425
+ };
426
+ exports$1.useDeferredValue = function(value, initialValue) {
427
+ return ReactSharedInternals.H.useDeferredValue(value, initialValue);
428
+ };
429
+ exports$1.useEffect = function(create, deps) {
430
+ return ReactSharedInternals.H.useEffect(create, deps);
431
+ };
432
+ exports$1.useEffectEvent = function(callback) {
433
+ return ReactSharedInternals.H.useEffectEvent(callback);
434
+ };
435
+ exports$1.useId = function() {
436
+ return ReactSharedInternals.H.useId();
437
+ };
438
+ exports$1.useImperativeHandle = function(ref, create, deps) {
439
+ return ReactSharedInternals.H.useImperativeHandle(ref, create, deps);
440
+ };
441
+ exports$1.useInsertionEffect = function(create, deps) {
442
+ return ReactSharedInternals.H.useInsertionEffect(create, deps);
443
+ };
444
+ exports$1.useLayoutEffect = function(create, deps) {
445
+ return ReactSharedInternals.H.useLayoutEffect(create, deps);
446
+ };
447
+ exports$1.useMemo = function(create, deps) {
448
+ return ReactSharedInternals.H.useMemo(create, deps);
449
+ };
450
+ exports$1.useOptimistic = function(passthrough, reducer) {
451
+ return ReactSharedInternals.H.useOptimistic(passthrough, reducer);
452
+ };
453
+ exports$1.useReducer = function(reducer, initialArg, init) {
454
+ return ReactSharedInternals.H.useReducer(reducer, initialArg, init);
455
+ };
456
+ exports$1.useRef = function(initialValue) {
457
+ return ReactSharedInternals.H.useRef(initialValue);
458
+ };
459
+ exports$1.useState = function(initialState) {
460
+ return ReactSharedInternals.H.useState(initialState);
461
+ };
462
+ exports$1.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
463
+ return ReactSharedInternals.H.useSyncExternalStore(
464
+ subscribe,
465
+ getSnapshot,
466
+ getServerSnapshot
467
+ );
468
+ };
469
+ exports$1.useTransition = function() {
470
+ return ReactSharedInternals.H.useTransition();
471
+ };
472
+ exports$1.version = "19.2.3";
473
+ }
474
+ });
475
+
476
+ // ../../node_modules/react/cjs/react.development.js
477
+ var require_react_development = __commonJS({
478
+ "../../node_modules/react/cjs/react.development.js"(exports$1, module) {
479
+ "production" !== process.env.NODE_ENV && (function() {
480
+ function defineDeprecationWarning(methodName, info) {
481
+ Object.defineProperty(Component.prototype, methodName, {
482
+ get: function() {
483
+ console.warn(
484
+ "%s(...) is deprecated in plain JavaScript React classes. %s",
485
+ info[0],
486
+ info[1]
487
+ );
488
+ }
489
+ });
490
+ }
491
+ function getIteratorFn(maybeIterable) {
492
+ if (null === maybeIterable || "object" !== typeof maybeIterable)
493
+ return null;
494
+ maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
495
+ return "function" === typeof maybeIterable ? maybeIterable : null;
496
+ }
497
+ function warnNoop(publicInstance, callerName) {
498
+ publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
499
+ var warningKey = publicInstance + "." + callerName;
500
+ didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error(
501
+ "Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.",
502
+ callerName,
503
+ publicInstance
504
+ ), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
505
+ }
506
+ function Component(props, context, updater) {
507
+ this.props = props;
508
+ this.context = context;
509
+ this.refs = emptyObject;
510
+ this.updater = updater || ReactNoopUpdateQueue;
511
+ }
512
+ function ComponentDummy() {
513
+ }
514
+ function PureComponent(props, context, updater) {
515
+ this.props = props;
516
+ this.context = context;
517
+ this.refs = emptyObject;
518
+ this.updater = updater || ReactNoopUpdateQueue;
519
+ }
520
+ function noop() {
521
+ }
522
+ function testStringCoercion(value) {
523
+ return "" + value;
524
+ }
525
+ function checkKeyStringCoercion(value) {
526
+ try {
527
+ testStringCoercion(value);
528
+ var JSCompiler_inline_result = false;
529
+ } catch (e) {
530
+ JSCompiler_inline_result = true;
531
+ }
532
+ if (JSCompiler_inline_result) {
533
+ JSCompiler_inline_result = console;
534
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
535
+ var JSCompiler_inline_result$jscomp$0 = "function" === typeof Symbol && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
536
+ JSCompiler_temp_const.call(
537
+ JSCompiler_inline_result,
538
+ "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
539
+ JSCompiler_inline_result$jscomp$0
540
+ );
541
+ return testStringCoercion(value);
542
+ }
543
+ }
544
+ function getComponentNameFromType(type) {
545
+ if (null == type) return null;
546
+ if ("function" === typeof type)
547
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
548
+ if ("string" === typeof type) return type;
549
+ switch (type) {
550
+ case REACT_FRAGMENT_TYPE:
551
+ return "Fragment";
552
+ case REACT_PROFILER_TYPE:
553
+ return "Profiler";
554
+ case REACT_STRICT_MODE_TYPE:
555
+ return "StrictMode";
556
+ case REACT_SUSPENSE_TYPE:
557
+ return "Suspense";
558
+ case REACT_SUSPENSE_LIST_TYPE:
559
+ return "SuspenseList";
560
+ case REACT_ACTIVITY_TYPE:
561
+ return "Activity";
562
+ }
563
+ if ("object" === typeof type)
564
+ switch ("number" === typeof type.tag && console.error(
565
+ "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
566
+ ), type.$$typeof) {
567
+ case REACT_PORTAL_TYPE:
568
+ return "Portal";
569
+ case REACT_CONTEXT_TYPE:
570
+ return type.displayName || "Context";
571
+ case REACT_CONSUMER_TYPE:
572
+ return (type._context.displayName || "Context") + ".Consumer";
573
+ case REACT_FORWARD_REF_TYPE:
574
+ var innerType = type.render;
575
+ type = type.displayName;
576
+ type || (type = innerType.displayName || innerType.name || "", type = "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef");
577
+ return type;
578
+ case REACT_MEMO_TYPE:
579
+ return innerType = type.displayName || null, null !== innerType ? innerType : getComponentNameFromType(type.type) || "Memo";
580
+ case REACT_LAZY_TYPE:
581
+ innerType = type._payload;
582
+ type = type._init;
583
+ try {
584
+ return getComponentNameFromType(type(innerType));
585
+ } catch (x) {
586
+ }
587
+ }
588
+ return null;
589
+ }
590
+ function getTaskName(type) {
591
+ if (type === REACT_FRAGMENT_TYPE) return "<>";
592
+ if ("object" === typeof type && null !== type && type.$$typeof === REACT_LAZY_TYPE)
593
+ return "<...>";
594
+ try {
595
+ var name = getComponentNameFromType(type);
596
+ return name ? "<" + name + ">" : "<...>";
597
+ } catch (x) {
598
+ return "<...>";
599
+ }
600
+ }
601
+ function getOwner() {
602
+ var dispatcher = ReactSharedInternals.A;
603
+ return null === dispatcher ? null : dispatcher.getOwner();
604
+ }
605
+ function UnknownOwner() {
606
+ return Error("react-stack-top-frame");
607
+ }
608
+ function hasValidKey(config2) {
609
+ if (hasOwnProperty.call(config2, "key")) {
610
+ var getter = Object.getOwnPropertyDescriptor(config2, "key").get;
611
+ if (getter && getter.isReactWarning) return false;
612
+ }
613
+ return void 0 !== config2.key;
614
+ }
615
+ function defineKeyPropWarningGetter(props, displayName) {
616
+ function warnAboutAccessingKey() {
617
+ specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.error(
618
+ "%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://react.dev/link/special-props)",
619
+ displayName
620
+ ));
621
+ }
622
+ warnAboutAccessingKey.isReactWarning = true;
623
+ Object.defineProperty(props, "key", {
624
+ get: warnAboutAccessingKey,
625
+ configurable: true
626
+ });
627
+ }
628
+ function elementRefGetterWithDeprecationWarning() {
629
+ var componentName = getComponentNameFromType(this.type);
630
+ didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error(
631
+ "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
632
+ ));
633
+ componentName = this.props.ref;
634
+ return void 0 !== componentName ? componentName : null;
635
+ }
636
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
637
+ var refProp = props.ref;
638
+ type = {
639
+ $$typeof: REACT_ELEMENT_TYPE,
640
+ type,
641
+ key,
642
+ props,
643
+ _owner: owner
644
+ };
645
+ null !== (void 0 !== refProp ? refProp : null) ? Object.defineProperty(type, "ref", {
646
+ enumerable: false,
647
+ get: elementRefGetterWithDeprecationWarning
648
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
649
+ type._store = {};
650
+ Object.defineProperty(type._store, "validated", {
651
+ configurable: false,
652
+ enumerable: false,
653
+ writable: true,
654
+ value: 0
655
+ });
656
+ Object.defineProperty(type, "_debugInfo", {
657
+ configurable: false,
658
+ enumerable: false,
659
+ writable: true,
660
+ value: null
661
+ });
662
+ Object.defineProperty(type, "_debugStack", {
663
+ configurable: false,
664
+ enumerable: false,
665
+ writable: true,
666
+ value: debugStack
667
+ });
668
+ Object.defineProperty(type, "_debugTask", {
669
+ configurable: false,
670
+ enumerable: false,
671
+ writable: true,
672
+ value: debugTask
673
+ });
674
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
675
+ return type;
676
+ }
677
+ function cloneAndReplaceKey(oldElement, newKey) {
678
+ newKey = ReactElement(
679
+ oldElement.type,
680
+ newKey,
681
+ oldElement.props,
682
+ oldElement._owner,
683
+ oldElement._debugStack,
684
+ oldElement._debugTask
685
+ );
686
+ oldElement._store && (newKey._store.validated = oldElement._store.validated);
687
+ return newKey;
688
+ }
689
+ function validateChildKeys(node) {
690
+ isValidElement(node) ? node._store && (node._store.validated = 1) : "object" === typeof node && null !== node && node.$$typeof === REACT_LAZY_TYPE && ("fulfilled" === node._payload.status ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
691
+ }
692
+ function isValidElement(object) {
693
+ return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
694
+ }
695
+ function escape(key) {
696
+ var escaperLookup = { "=": "=0", ":": "=2" };
697
+ return "$" + key.replace(/[=:]/g, function(match) {
698
+ return escaperLookup[match];
699
+ });
700
+ }
701
+ function getElementKey(element, index) {
702
+ return "object" === typeof element && null !== element && null != element.key ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
703
+ }
704
+ function resolveThenable(thenable) {
705
+ switch (thenable.status) {
706
+ case "fulfilled":
707
+ return thenable.value;
708
+ case "rejected":
709
+ throw thenable.reason;
710
+ default:
711
+ switch ("string" === typeof thenable.status ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(
712
+ function(fulfilledValue) {
713
+ "pending" === thenable.status && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
714
+ },
715
+ function(error) {
716
+ "pending" === thenable.status && (thenable.status = "rejected", thenable.reason = error);
717
+ }
718
+ )), thenable.status) {
719
+ case "fulfilled":
720
+ return thenable.value;
721
+ case "rejected":
722
+ throw thenable.reason;
723
+ }
724
+ }
725
+ throw thenable;
726
+ }
727
+ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
728
+ var type = typeof children;
729
+ if ("undefined" === type || "boolean" === type) children = null;
730
+ var invokeCallback = false;
731
+ if (null === children) invokeCallback = true;
732
+ else
733
+ switch (type) {
734
+ case "bigint":
735
+ case "string":
736
+ case "number":
737
+ invokeCallback = true;
738
+ break;
739
+ case "object":
740
+ switch (children.$$typeof) {
741
+ case REACT_ELEMENT_TYPE:
742
+ case REACT_PORTAL_TYPE:
743
+ invokeCallback = true;
744
+ break;
745
+ case REACT_LAZY_TYPE:
746
+ return invokeCallback = children._init, mapIntoArray(
747
+ invokeCallback(children._payload),
748
+ array,
749
+ escapedPrefix,
750
+ nameSoFar,
751
+ callback
752
+ );
753
+ }
754
+ }
755
+ if (invokeCallback) {
756
+ invokeCallback = children;
757
+ callback = callback(invokeCallback);
758
+ var childKey = "" === nameSoFar ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
759
+ isArrayImpl(callback) ? (escapedPrefix = "", null != childKey && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
760
+ return c;
761
+ })) : null != callback && (isValidElement(callback) && (null != callback.key && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(
762
+ callback,
763
+ escapedPrefix + (null == callback.key || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(
764
+ userProvidedKeyEscapeRegex,
765
+ "$&/"
766
+ ) + "/") + childKey
767
+ ), "" !== nameSoFar && null != invokeCallback && isValidElement(invokeCallback) && null == invokeCallback.key && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
768
+ return 1;
769
+ }
770
+ invokeCallback = 0;
771
+ childKey = "" === nameSoFar ? "." : nameSoFar + ":";
772
+ if (isArrayImpl(children))
773
+ for (var i = 0; i < children.length; i++)
774
+ nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(
775
+ nameSoFar,
776
+ array,
777
+ escapedPrefix,
778
+ type,
779
+ callback
780
+ );
781
+ else if (i = getIteratorFn(children), "function" === typeof i)
782
+ for (i === children.entries && (didWarnAboutMaps || console.warn(
783
+ "Using Maps as children is not supported. Use an array of keyed ReactElements instead."
784
+ ), didWarnAboutMaps = true), children = i.call(children), i = 0; !(nameSoFar = children.next()).done; )
785
+ nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(
786
+ nameSoFar,
787
+ array,
788
+ escapedPrefix,
789
+ type,
790
+ callback
791
+ );
792
+ else if ("object" === type) {
793
+ if ("function" === typeof children.then)
794
+ return mapIntoArray(
795
+ resolveThenable(children),
796
+ array,
797
+ escapedPrefix,
798
+ nameSoFar,
799
+ callback
800
+ );
801
+ array = String(children);
802
+ throw Error(
803
+ "Objects are not valid as a React child (found: " + ("[object Object]" === array ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead."
804
+ );
805
+ }
806
+ return invokeCallback;
807
+ }
808
+ function mapChildren(children, func, context) {
809
+ if (null == children) return children;
810
+ var result = [], count = 0;
811
+ mapIntoArray(children, result, "", "", function(child) {
812
+ return func.call(context, child, count++);
813
+ });
814
+ return result;
815
+ }
816
+ function lazyInitializer(payload) {
817
+ if (-1 === payload._status) {
818
+ var ioInfo = payload._ioInfo;
819
+ null != ioInfo && (ioInfo.start = ioInfo.end = performance.now());
820
+ ioInfo = payload._result;
821
+ var thenable = ioInfo();
822
+ thenable.then(
823
+ function(moduleObject) {
824
+ if (0 === payload._status || -1 === payload._status) {
825
+ payload._status = 1;
826
+ payload._result = moduleObject;
827
+ var _ioInfo = payload._ioInfo;
828
+ null != _ioInfo && (_ioInfo.end = performance.now());
829
+ void 0 === thenable.status && (thenable.status = "fulfilled", thenable.value = moduleObject);
830
+ }
831
+ },
832
+ function(error) {
833
+ if (0 === payload._status || -1 === payload._status) {
834
+ payload._status = 2;
835
+ payload._result = error;
836
+ var _ioInfo2 = payload._ioInfo;
837
+ null != _ioInfo2 && (_ioInfo2.end = performance.now());
838
+ void 0 === thenable.status && (thenable.status = "rejected", thenable.reason = error);
839
+ }
840
+ }
841
+ );
842
+ ioInfo = payload._ioInfo;
843
+ if (null != ioInfo) {
844
+ ioInfo.value = thenable;
845
+ var displayName = thenable.displayName;
846
+ "string" === typeof displayName && (ioInfo.name = displayName);
847
+ }
848
+ -1 === payload._status && (payload._status = 0, payload._result = thenable);
849
+ }
850
+ if (1 === payload._status)
851
+ return ioInfo = payload._result, void 0 === ioInfo && console.error(
852
+ "lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))\n\nDid you accidentally put curly braces around the import?",
853
+ ioInfo
854
+ ), "default" in ioInfo || console.error(
855
+ "lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))",
856
+ ioInfo
857
+ ), ioInfo.default;
858
+ throw payload._result;
859
+ }
860
+ function resolveDispatcher() {
861
+ var dispatcher = ReactSharedInternals.H;
862
+ null === dispatcher && console.error(
863
+ "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem."
864
+ );
865
+ return dispatcher;
866
+ }
867
+ function releaseAsyncTransition() {
868
+ ReactSharedInternals.asyncTransitions--;
869
+ }
870
+ function enqueueTask(task) {
871
+ if (null === enqueueTaskImpl)
872
+ try {
873
+ var requireString = ("require" + Math.random()).slice(0, 7);
874
+ enqueueTaskImpl = (module && module[requireString]).call(
875
+ module,
876
+ "timers"
877
+ ).setImmediate;
878
+ } catch (_err) {
879
+ enqueueTaskImpl = function(callback) {
880
+ false === didWarnAboutMessageChannel && (didWarnAboutMessageChannel = true, "undefined" === typeof MessageChannel && console.error(
881
+ "This browser does not have a MessageChannel implementation, so enqueuing tasks via await act(async () => ...) will fail. Please file an issue at https://github.com/facebook/react/issues if you encounter this warning."
882
+ ));
883
+ var channel = new MessageChannel();
884
+ channel.port1.onmessage = callback;
885
+ channel.port2.postMessage(void 0);
886
+ };
887
+ }
888
+ return enqueueTaskImpl(task);
889
+ }
890
+ function aggregateErrors(errors) {
891
+ return 1 < errors.length && "function" === typeof AggregateError ? new AggregateError(errors) : errors[0];
892
+ }
893
+ function popActScope(prevActQueue, prevActScopeDepth) {
894
+ prevActScopeDepth !== actScopeDepth - 1 && console.error(
895
+ "You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. "
896
+ );
897
+ actScopeDepth = prevActScopeDepth;
898
+ }
899
+ function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
900
+ var queue = ReactSharedInternals.actQueue;
901
+ if (null !== queue)
902
+ if (0 !== queue.length)
903
+ try {
904
+ flushActQueue(queue);
905
+ enqueueTask(function() {
906
+ return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
907
+ });
908
+ return;
909
+ } catch (error) {
910
+ ReactSharedInternals.thrownErrors.push(error);
911
+ }
912
+ else ReactSharedInternals.actQueue = null;
913
+ 0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
914
+ }
915
+ function flushActQueue(queue) {
916
+ if (!isFlushing) {
917
+ isFlushing = true;
918
+ var i = 0;
919
+ try {
920
+ for (; i < queue.length; i++) {
921
+ var callback = queue[i];
922
+ do {
923
+ ReactSharedInternals.didUsePromise = false;
924
+ var continuation = callback(false);
925
+ if (null !== continuation) {
926
+ if (ReactSharedInternals.didUsePromise) {
927
+ queue[i] = callback;
928
+ queue.splice(0, i);
929
+ return;
930
+ }
931
+ callback = continuation;
932
+ } else break;
933
+ } while (1);
934
+ }
935
+ queue.length = 0;
936
+ } catch (error) {
937
+ queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
938
+ } finally {
939
+ isFlushing = false;
940
+ }
941
+ }
942
+ }
943
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
944
+ var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = /* @__PURE__ */ Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
945
+ isMounted: function() {
946
+ return false;
947
+ },
948
+ enqueueForceUpdate: function(publicInstance) {
949
+ warnNoop(publicInstance, "forceUpdate");
950
+ },
951
+ enqueueReplaceState: function(publicInstance) {
952
+ warnNoop(publicInstance, "replaceState");
953
+ },
954
+ enqueueSetState: function(publicInstance) {
955
+ warnNoop(publicInstance, "setState");
956
+ }
957
+ }, assign = Object.assign, emptyObject = {};
958
+ Object.freeze(emptyObject);
959
+ Component.prototype.isReactComponent = {};
960
+ Component.prototype.setState = function(partialState, callback) {
961
+ if ("object" !== typeof partialState && "function" !== typeof partialState && null != partialState)
962
+ throw Error(
963
+ "takes an object of state variables to update or a function which returns an object of state variables."
964
+ );
965
+ this.updater.enqueueSetState(this, partialState, callback, "setState");
966
+ };
967
+ Component.prototype.forceUpdate = function(callback) {
968
+ this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
969
+ };
970
+ var deprecatedAPIs = {
971
+ isMounted: [
972
+ "isMounted",
973
+ "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
974
+ ],
975
+ replaceState: [
976
+ "replaceState",
977
+ "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
978
+ ]
979
+ };
980
+ for (fnName in deprecatedAPIs)
981
+ deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
982
+ ComponentDummy.prototype = Component.prototype;
983
+ deprecatedAPIs = PureComponent.prototype = new ComponentDummy();
984
+ deprecatedAPIs.constructor = PureComponent;
985
+ assign(deprecatedAPIs, Component.prototype);
986
+ deprecatedAPIs.isPureReactComponent = true;
987
+ var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference"), ReactSharedInternals = {
988
+ H: null,
989
+ A: null,
990
+ T: null,
991
+ S: null,
992
+ actQueue: null,
993
+ asyncTransitions: 0,
994
+ isBatchingLegacy: false,
995
+ didScheduleLegacyUpdate: false,
996
+ didUsePromise: false,
997
+ thrownErrors: [],
998
+ getCurrentStack: null,
999
+ recentlyCreatedOwnerStacks: 0
1000
+ }, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
1001
+ return null;
1002
+ };
1003
+ deprecatedAPIs = {
1004
+ react_stack_bottom_frame: function(callStackForError) {
1005
+ return callStackForError();
1006
+ }
1007
+ };
1008
+ var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
1009
+ var didWarnAboutElementRef = {};
1010
+ var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(
1011
+ deprecatedAPIs,
1012
+ UnknownOwner
1013
+ )();
1014
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
1015
+ var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = "function" === typeof reportError ? reportError : function(error) {
1016
+ if ("object" === typeof window && "function" === typeof window.ErrorEvent) {
1017
+ var event = new window.ErrorEvent("error", {
1018
+ bubbles: true,
1019
+ cancelable: true,
1020
+ message: "object" === typeof error && null !== error && "string" === typeof error.message ? String(error.message) : String(error),
1021
+ error
1022
+ });
1023
+ if (!window.dispatchEvent(event)) return;
1024
+ } else if ("object" === typeof process && "function" === typeof process.emit) {
1025
+ process.emit("uncaughtException", error);
1026
+ return;
1027
+ }
1028
+ console.error(error);
1029
+ }, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = "function" === typeof queueMicrotask ? function(callback) {
1030
+ queueMicrotask(function() {
1031
+ return queueMicrotask(callback);
1032
+ });
1033
+ } : enqueueTask;
1034
+ deprecatedAPIs = Object.freeze({
1035
+ __proto__: null,
1036
+ c: function(size) {
1037
+ return resolveDispatcher().useMemoCache(size);
1038
+ }
1039
+ });
1040
+ var fnName = {
1041
+ map: mapChildren,
1042
+ forEach: function(children, forEachFunc, forEachContext) {
1043
+ mapChildren(
1044
+ children,
1045
+ function() {
1046
+ forEachFunc.apply(this, arguments);
1047
+ },
1048
+ forEachContext
1049
+ );
1050
+ },
1051
+ count: function(children) {
1052
+ var n = 0;
1053
+ mapChildren(children, function() {
1054
+ n++;
1055
+ });
1056
+ return n;
1057
+ },
1058
+ toArray: function(children) {
1059
+ return mapChildren(children, function(child) {
1060
+ return child;
1061
+ }) || [];
1062
+ },
1063
+ only: function(children) {
1064
+ if (!isValidElement(children))
1065
+ throw Error(
1066
+ "React.Children.only expected to receive a single React element child."
1067
+ );
1068
+ return children;
1069
+ }
1070
+ };
1071
+ exports$1.Activity = REACT_ACTIVITY_TYPE;
1072
+ exports$1.Children = fnName;
1073
+ exports$1.Component = Component;
1074
+ exports$1.Fragment = REACT_FRAGMENT_TYPE;
1075
+ exports$1.Profiler = REACT_PROFILER_TYPE;
1076
+ exports$1.PureComponent = PureComponent;
1077
+ exports$1.StrictMode = REACT_STRICT_MODE_TYPE;
1078
+ exports$1.Suspense = REACT_SUSPENSE_TYPE;
1079
+ exports$1.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
1080
+ exports$1.__COMPILER_RUNTIME = deprecatedAPIs;
1081
+ exports$1.act = function(callback) {
1082
+ var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
1083
+ actScopeDepth++;
1084
+ var queue = ReactSharedInternals.actQueue = null !== prevActQueue ? prevActQueue : [], didAwaitActCall = false;
1085
+ try {
1086
+ var result = callback();
1087
+ } catch (error) {
1088
+ ReactSharedInternals.thrownErrors.push(error);
1089
+ }
1090
+ if (0 < ReactSharedInternals.thrownErrors.length)
1091
+ throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
1092
+ if (null !== result && "object" === typeof result && "function" === typeof result.then) {
1093
+ var thenable = result;
1094
+ queueSeveralMicrotasks(function() {
1095
+ didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
1096
+ "You called act(async () => ...) without await. This could lead to unexpected testing behaviour, interleaving multiple act calls and mixing their scopes. You should - await act(async () => ...);"
1097
+ ));
1098
+ });
1099
+ return {
1100
+ then: function(resolve, reject) {
1101
+ didAwaitActCall = true;
1102
+ thenable.then(
1103
+ function(returnValue) {
1104
+ popActScope(prevActQueue, prevActScopeDepth);
1105
+ if (0 === prevActScopeDepth) {
1106
+ try {
1107
+ flushActQueue(queue), enqueueTask(function() {
1108
+ return recursivelyFlushAsyncActWork(
1109
+ returnValue,
1110
+ resolve,
1111
+ reject
1112
+ );
1113
+ });
1114
+ } catch (error$0) {
1115
+ ReactSharedInternals.thrownErrors.push(error$0);
1116
+ }
1117
+ if (0 < ReactSharedInternals.thrownErrors.length) {
1118
+ var _thrownError = aggregateErrors(
1119
+ ReactSharedInternals.thrownErrors
1120
+ );
1121
+ ReactSharedInternals.thrownErrors.length = 0;
1122
+ reject(_thrownError);
1123
+ }
1124
+ } else resolve(returnValue);
1125
+ },
1126
+ function(error) {
1127
+ popActScope(prevActQueue, prevActScopeDepth);
1128
+ 0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(
1129
+ ReactSharedInternals.thrownErrors
1130
+ ), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
1131
+ }
1132
+ );
1133
+ }
1134
+ };
1135
+ }
1136
+ var returnValue$jscomp$0 = result;
1137
+ popActScope(prevActQueue, prevActScopeDepth);
1138
+ 0 === prevActScopeDepth && (flushActQueue(queue), 0 !== queue.length && queueSeveralMicrotasks(function() {
1139
+ didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error(
1140
+ "A component suspended inside an `act` scope, but the `act` call was not awaited. When testing React components that depend on asynchronous data, you must await the result:\n\nawait act(() => ...)"
1141
+ ));
1142
+ }), ReactSharedInternals.actQueue = null);
1143
+ if (0 < ReactSharedInternals.thrownErrors.length)
1144
+ throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
1145
+ return {
1146
+ then: function(resolve, reject) {
1147
+ didAwaitActCall = true;
1148
+ 0 === prevActScopeDepth ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
1149
+ return recursivelyFlushAsyncActWork(
1150
+ returnValue$jscomp$0,
1151
+ resolve,
1152
+ reject
1153
+ );
1154
+ })) : resolve(returnValue$jscomp$0);
1155
+ }
1156
+ };
1157
+ };
1158
+ exports$1.cache = function(fn) {
1159
+ return function() {
1160
+ return fn.apply(null, arguments);
1161
+ };
1162
+ };
1163
+ exports$1.cacheSignal = function() {
1164
+ return null;
1165
+ };
1166
+ exports$1.captureOwnerStack = function() {
1167
+ var getCurrentStack = ReactSharedInternals.getCurrentStack;
1168
+ return null === getCurrentStack ? null : getCurrentStack();
1169
+ };
1170
+ exports$1.cloneElement = function(element, config2, children) {
1171
+ if (null === element || void 0 === element)
1172
+ throw Error(
1173
+ "The argument must be a React element, but you passed " + element + "."
1174
+ );
1175
+ var props = assign({}, element.props), key = element.key, owner = element._owner;
1176
+ if (null != config2) {
1177
+ var JSCompiler_inline_result;
1178
+ a: {
1179
+ if (hasOwnProperty.call(config2, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(
1180
+ config2,
1181
+ "ref"
1182
+ ).get) && JSCompiler_inline_result.isReactWarning) {
1183
+ JSCompiler_inline_result = false;
1184
+ break a;
1185
+ }
1186
+ JSCompiler_inline_result = void 0 !== config2.ref;
1187
+ }
1188
+ JSCompiler_inline_result && (owner = getOwner());
1189
+ hasValidKey(config2) && (checkKeyStringCoercion(config2.key), key = "" + config2.key);
1190
+ for (propName in config2)
1191
+ !hasOwnProperty.call(config2, propName) || "key" === propName || "__self" === propName || "__source" === propName || "ref" === propName && void 0 === config2.ref || (props[propName] = config2[propName]);
1192
+ }
1193
+ var propName = arguments.length - 2;
1194
+ if (1 === propName) props.children = children;
1195
+ else if (1 < propName) {
1196
+ JSCompiler_inline_result = Array(propName);
1197
+ for (var i = 0; i < propName; i++)
1198
+ JSCompiler_inline_result[i] = arguments[i + 2];
1199
+ props.children = JSCompiler_inline_result;
1200
+ }
1201
+ props = ReactElement(
1202
+ element.type,
1203
+ key,
1204
+ props,
1205
+ owner,
1206
+ element._debugStack,
1207
+ element._debugTask
1208
+ );
1209
+ for (key = 2; key < arguments.length; key++)
1210
+ validateChildKeys(arguments[key]);
1211
+ return props;
1212
+ };
1213
+ exports$1.createContext = function(defaultValue) {
1214
+ defaultValue = {
1215
+ $$typeof: REACT_CONTEXT_TYPE,
1216
+ _currentValue: defaultValue,
1217
+ _currentValue2: defaultValue,
1218
+ _threadCount: 0,
1219
+ Provider: null,
1220
+ Consumer: null
1221
+ };
1222
+ defaultValue.Provider = defaultValue;
1223
+ defaultValue.Consumer = {
1224
+ $$typeof: REACT_CONSUMER_TYPE,
1225
+ _context: defaultValue
1226
+ };
1227
+ defaultValue._currentRenderer = null;
1228
+ defaultValue._currentRenderer2 = null;
1229
+ return defaultValue;
1230
+ };
1231
+ exports$1.createElement = function(type, config2, children) {
1232
+ for (var i = 2; i < arguments.length; i++)
1233
+ validateChildKeys(arguments[i]);
1234
+ i = {};
1235
+ var key = null;
1236
+ if (null != config2)
1237
+ for (propName in didWarnAboutOldJSXRuntime || !("__self" in config2) || "key" in config2 || (didWarnAboutOldJSXRuntime = true, console.warn(
1238
+ "Your app (or one of its dependencies) is using an outdated JSX transform. Update to the modern JSX transform for faster performance: https://react.dev/link/new-jsx-transform"
1239
+ )), hasValidKey(config2) && (checkKeyStringCoercion(config2.key), key = "" + config2.key), config2)
1240
+ hasOwnProperty.call(config2, propName) && "key" !== propName && "__self" !== propName && "__source" !== propName && (i[propName] = config2[propName]);
1241
+ var childrenLength = arguments.length - 2;
1242
+ if (1 === childrenLength) i.children = children;
1243
+ else if (1 < childrenLength) {
1244
+ for (var childArray = Array(childrenLength), _i = 0; _i < childrenLength; _i++)
1245
+ childArray[_i] = arguments[_i + 2];
1246
+ Object.freeze && Object.freeze(childArray);
1247
+ i.children = childArray;
1248
+ }
1249
+ if (type && type.defaultProps)
1250
+ for (propName in childrenLength = type.defaultProps, childrenLength)
1251
+ void 0 === i[propName] && (i[propName] = childrenLength[propName]);
1252
+ key && defineKeyPropWarningGetter(
1253
+ i,
1254
+ "function" === typeof type ? type.displayName || type.name || "Unknown" : type
1255
+ );
1256
+ var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
1257
+ return ReactElement(
1258
+ type,
1259
+ key,
1260
+ i,
1261
+ getOwner(),
1262
+ propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack,
1263
+ propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask
1264
+ );
1265
+ };
1266
+ exports$1.createRef = function() {
1267
+ var refObject = { current: null };
1268
+ Object.seal(refObject);
1269
+ return refObject;
1270
+ };
1271
+ exports$1.forwardRef = function(render) {
1272
+ null != render && render.$$typeof === REACT_MEMO_TYPE ? console.error(
1273
+ "forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...))."
1274
+ ) : "function" !== typeof render ? console.error(
1275
+ "forwardRef requires a render function but was given %s.",
1276
+ null === render ? "null" : typeof render
1277
+ ) : 0 !== render.length && 2 !== render.length && console.error(
1278
+ "forwardRef render functions accept exactly two parameters: props and ref. %s",
1279
+ 1 === render.length ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined."
1280
+ );
1281
+ null != render && null != render.defaultProps && console.error(
1282
+ "forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?"
1283
+ );
1284
+ var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
1285
+ Object.defineProperty(elementType, "displayName", {
1286
+ enumerable: false,
1287
+ configurable: true,
1288
+ get: function() {
1289
+ return ownName;
1290
+ },
1291
+ set: function(name) {
1292
+ ownName = name;
1293
+ render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
1294
+ }
1295
+ });
1296
+ return elementType;
1297
+ };
1298
+ exports$1.isValidElement = isValidElement;
1299
+ exports$1.lazy = function(ctor) {
1300
+ ctor = { _status: -1, _result: ctor };
1301
+ var lazyType = {
1302
+ $$typeof: REACT_LAZY_TYPE,
1303
+ _payload: ctor,
1304
+ _init: lazyInitializer
1305
+ }, ioInfo = {
1306
+ name: "lazy",
1307
+ start: -1,
1308
+ end: -1,
1309
+ value: null,
1310
+ owner: null,
1311
+ debugStack: Error("react-stack-top-frame"),
1312
+ debugTask: console.createTask ? console.createTask("lazy()") : null
1313
+ };
1314
+ ctor._ioInfo = ioInfo;
1315
+ lazyType._debugInfo = [{ awaited: ioInfo }];
1316
+ return lazyType;
1317
+ };
1318
+ exports$1.memo = function(type, compare) {
1319
+ null == type && console.error(
1320
+ "memo: The first argument must be a component. Instead received: %s",
1321
+ null === type ? "null" : typeof type
1322
+ );
1323
+ compare = {
1324
+ $$typeof: REACT_MEMO_TYPE,
1325
+ type,
1326
+ compare: void 0 === compare ? null : compare
1327
+ };
1328
+ var ownName;
1329
+ Object.defineProperty(compare, "displayName", {
1330
+ enumerable: false,
1331
+ configurable: true,
1332
+ get: function() {
1333
+ return ownName;
1334
+ },
1335
+ set: function(name) {
1336
+ ownName = name;
1337
+ type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
1338
+ }
1339
+ });
1340
+ return compare;
1341
+ };
1342
+ exports$1.startTransition = function(scope) {
1343
+ var prevTransition = ReactSharedInternals.T, currentTransition = {};
1344
+ currentTransition._updatedFibers = /* @__PURE__ */ new Set();
1345
+ ReactSharedInternals.T = currentTransition;
1346
+ try {
1347
+ var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
1348
+ null !== onStartTransitionFinish && onStartTransitionFinish(currentTransition, returnValue);
1349
+ "object" === typeof returnValue && null !== returnValue && "function" === typeof returnValue.then && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
1350
+ } catch (error) {
1351
+ reportGlobalError(error);
1352
+ } finally {
1353
+ null === prevTransition && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn(
1354
+ "Detected a large number of updates inside startTransition. If this is due to a subscription please re-write it to use React provided hooks. Otherwise concurrent mode guarantees are off the table."
1355
+ )), null !== prevTransition && null !== currentTransition.types && (null !== prevTransition.types && prevTransition.types !== currentTransition.types && console.error(
1356
+ "We expected inner Transitions to have transferred the outer types set and that you cannot add to the outer Transition while inside the inner.This is a bug in React."
1357
+ ), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
1358
+ }
1359
+ };
1360
+ exports$1.unstable_useCacheRefresh = function() {
1361
+ return resolveDispatcher().useCacheRefresh();
1362
+ };
1363
+ exports$1.use = function(usable) {
1364
+ return resolveDispatcher().use(usable);
1365
+ };
1366
+ exports$1.useActionState = function(action, initialState, permalink) {
1367
+ return resolveDispatcher().useActionState(
1368
+ action,
1369
+ initialState,
1370
+ permalink
1371
+ );
1372
+ };
1373
+ exports$1.useCallback = function(callback, deps) {
1374
+ return resolveDispatcher().useCallback(callback, deps);
1375
+ };
1376
+ exports$1.useContext = function(Context) {
1377
+ var dispatcher = resolveDispatcher();
1378
+ Context.$$typeof === REACT_CONSUMER_TYPE && console.error(
1379
+ "Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?"
1380
+ );
1381
+ return dispatcher.useContext(Context);
1382
+ };
1383
+ exports$1.useDebugValue = function(value, formatterFn) {
1384
+ return resolveDispatcher().useDebugValue(value, formatterFn);
1385
+ };
1386
+ exports$1.useDeferredValue = function(value, initialValue) {
1387
+ return resolveDispatcher().useDeferredValue(value, initialValue);
1388
+ };
1389
+ exports$1.useEffect = function(create, deps) {
1390
+ null == create && console.warn(
1391
+ "React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1392
+ );
1393
+ return resolveDispatcher().useEffect(create, deps);
1394
+ };
1395
+ exports$1.useEffectEvent = function(callback) {
1396
+ return resolveDispatcher().useEffectEvent(callback);
1397
+ };
1398
+ exports$1.useId = function() {
1399
+ return resolveDispatcher().useId();
1400
+ };
1401
+ exports$1.useImperativeHandle = function(ref, create, deps) {
1402
+ return resolveDispatcher().useImperativeHandle(ref, create, deps);
1403
+ };
1404
+ exports$1.useInsertionEffect = function(create, deps) {
1405
+ null == create && console.warn(
1406
+ "React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1407
+ );
1408
+ return resolveDispatcher().useInsertionEffect(create, deps);
1409
+ };
1410
+ exports$1.useLayoutEffect = function(create, deps) {
1411
+ null == create && console.warn(
1412
+ "React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?"
1413
+ );
1414
+ return resolveDispatcher().useLayoutEffect(create, deps);
1415
+ };
1416
+ exports$1.useMemo = function(create, deps) {
1417
+ return resolveDispatcher().useMemo(create, deps);
1418
+ };
1419
+ exports$1.useOptimistic = function(passthrough, reducer) {
1420
+ return resolveDispatcher().useOptimistic(passthrough, reducer);
1421
+ };
1422
+ exports$1.useReducer = function(reducer, initialArg, init) {
1423
+ return resolveDispatcher().useReducer(reducer, initialArg, init);
1424
+ };
1425
+ exports$1.useRef = function(initialValue) {
1426
+ return resolveDispatcher().useRef(initialValue);
1427
+ };
1428
+ exports$1.useState = function(initialState) {
1429
+ return resolveDispatcher().useState(initialState);
1430
+ };
1431
+ exports$1.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
1432
+ return resolveDispatcher().useSyncExternalStore(
1433
+ subscribe,
1434
+ getSnapshot,
1435
+ getServerSnapshot
1436
+ );
1437
+ };
1438
+ exports$1.useTransition = function() {
1439
+ return resolveDispatcher().useTransition();
1440
+ };
1441
+ exports$1.version = "19.2.3";
1442
+ "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
1443
+ })();
1444
+ }
1445
+ });
1446
+
1447
+ // ../../node_modules/react/index.js
1448
+ var require_react = __commonJS({
1449
+ "../../node_modules/react/index.js"(exports$1, module) {
1450
+ if (process.env.NODE_ENV === "production") {
1451
+ module.exports = require_react_production();
1452
+ } else {
1453
+ module.exports = require_react_development();
1454
+ }
1455
+ }
1456
+ });
10
1457
 
11
1458
  // src/client/types.ts
12
1459
  var TOKEN_MINTS = {
@@ -117,6 +1564,136 @@ function createX402AuthorizationHeader(signature, paymentRequiredHeader) {
117
1564
  const token = encodePaymentSignatureHeader(payload);
118
1565
  return `x402 ${token}`;
119
1566
  }
1567
+ async function sendSolanaPayment({
1568
+ connection,
1569
+ wallet,
1570
+ recipientAddress,
1571
+ amount,
1572
+ // memo, // TODO: Add memo support to transaction
1573
+ commitment = "confirmed"
1574
+ }) {
1575
+ if (!wallet.publicKey) {
1576
+ throw new Error("Wallet not connected");
1577
+ }
1578
+ if (amount <= 0n) {
1579
+ throw new Error("Amount must be greater than 0");
1580
+ }
1581
+ try {
1582
+ const recipientPubkey = new PublicKey(recipientAddress);
1583
+ const transaction = new Transaction().add(
1584
+ SystemProgram.transfer({
1585
+ fromPubkey: wallet.publicKey,
1586
+ toPubkey: recipientPubkey,
1587
+ lamports: amount
1588
+ })
1589
+ );
1590
+ const { blockhash, lastValidBlockHeight } = await connection.getLatestBlockhash(commitment);
1591
+ transaction.recentBlockhash = blockhash;
1592
+ transaction.feePayer = wallet.publicKey;
1593
+ const signature = await wallet.sendTransaction(transaction, connection);
1594
+ await connection.confirmTransaction({
1595
+ signature,
1596
+ blockhash,
1597
+ lastValidBlockHeight
1598
+ }, commitment);
1599
+ return {
1600
+ signature,
1601
+ amountSol: Number(amount) / LAMPORTS_PER_SOL
1602
+ };
1603
+ } catch (error) {
1604
+ console.error("Payment failed:", error);
1605
+ throw new Error(error.message || "Payment failed");
1606
+ }
1607
+ }
1608
+
1609
+ // src/client/react.ts
1610
+ var import_react = __toESM(require_react());
1611
+ function usePaywallResource({
1612
+ url,
1613
+ connection,
1614
+ wallet
1615
+ }) {
1616
+ const [data, setData] = (0, import_react.useState)(null);
1617
+ const [isLocked, setIsLocked] = (0, import_react.useState)(true);
1618
+ const [isLoading, setIsLoading] = (0, import_react.useState)(true);
1619
+ const [error, setError] = (0, import_react.useState)(null);
1620
+ const [paymentHeader, setPaymentHeader] = (0, import_react.useState)(null);
1621
+ const [price, setPrice] = (0, import_react.useState)();
1622
+ const [recipient, setRecipient] = (0, import_react.useState)();
1623
+ const fetchData = (0, import_react.useCallback)(async (authHeader) => {
1624
+ setIsLoading(true);
1625
+ setError(null);
1626
+ try {
1627
+ const headers = {
1628
+ "Content-Type": "application/json"
1629
+ };
1630
+ if (authHeader) {
1631
+ headers["Authorization"] = authHeader;
1632
+ }
1633
+ const res = await fetch(url, { headers });
1634
+ if (res.status === 402) {
1635
+ const wwwAuth = res.headers.get("WWW-Authenticate");
1636
+ if (wwwAuth) {
1637
+ setPaymentHeader(wwwAuth);
1638
+ try {
1639
+ const match = wwwAuth.match(/amount="([^"]+)",\s*payTo="([^"]+)"/);
1640
+ if (match) {
1641
+ setPrice(BigInt(match[1]));
1642
+ setRecipient(match[2]);
1643
+ }
1644
+ } catch (e) {
1645
+ console.warn("Failed to parse 402 details from header", e);
1646
+ }
1647
+ }
1648
+ setIsLocked(true);
1649
+ setData(null);
1650
+ } else if (res.ok) {
1651
+ const json = await res.json();
1652
+ setData(json);
1653
+ setIsLocked(false);
1654
+ } else {
1655
+ throw new Error(`Request failed with status ${res.status}`);
1656
+ }
1657
+ } catch (err) {
1658
+ setError(err.message || "Failed to fetch resource");
1659
+ } finally {
1660
+ setIsLoading(false);
1661
+ }
1662
+ }, [url]);
1663
+ (0, import_react.useEffect)(() => {
1664
+ fetchData();
1665
+ }, [fetchData]);
1666
+ const unlock = (0, import_react.useCallback)(async () => {
1667
+ if (!paymentHeader || !price || !recipient) {
1668
+ setError("Missing payment requirements");
1669
+ return;
1670
+ }
1671
+ setIsLoading(true);
1672
+ try {
1673
+ const { signature } = await sendSolanaPayment({
1674
+ connection,
1675
+ wallet,
1676
+ recipientAddress: recipient,
1677
+ amount: price
1678
+ });
1679
+ const authHeader = createX402AuthorizationHeader(signature, paymentHeader);
1680
+ await fetchData(authHeader);
1681
+ } catch (err) {
1682
+ console.error("Unlock failed", err);
1683
+ setError(err.message || "Payment/Unlock failed");
1684
+ setIsLoading(false);
1685
+ }
1686
+ }, [connection, wallet, paymentHeader, price, recipient, fetchData]);
1687
+ return {
1688
+ data,
1689
+ isLocked,
1690
+ isLoading,
1691
+ price,
1692
+ recipient,
1693
+ error,
1694
+ unlock
1695
+ };
1696
+ }
120
1697
  var DEFAULT_COMPUTE_UNITS = 2e5;
121
1698
  var DEFAULT_MICRO_LAMPORTS = 1e3;
122
1699
  function createPriorityFeeInstructions(config2 = {}) {
@@ -164,8 +1741,6 @@ async function buildVersionedTransaction(config2) {
164
1741
  lastValidBlockHeight
165
1742
  };
166
1743
  }
167
-
168
- // src/agent/agentPayment.ts
169
1744
  var WALLET_REGEX = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;
170
1745
  function isValidWalletAddress(address) {
171
1746
  if (!address || typeof address !== "string") return false;
@@ -266,15 +1841,19 @@ async function hasAgentSufficientBalance(connection, agentKeypair, requiredLampo
266
1841
  };
267
1842
  }
268
1843
  function keypairFromBase58(base58Secret) {
269
- const bytes = Buffer.from(base58Secret, "base64");
270
- if (bytes.length !== 64) {
1844
+ try {
1845
+ const bytes = bs58.decode(base58Secret);
1846
+ if (bytes.length !== 64) {
1847
+ throw new Error("Invalid secret key length. Expected 64 bytes.");
1848
+ }
1849
+ return Keypair.fromSecretKey(bytes);
1850
+ } catch (error) {
271
1851
  const parts = base58Secret.split(",").map((n) => parseInt(n.trim(), 10));
272
1852
  if (parts.length === 64) {
273
1853
  return Keypair.fromSecretKey(Uint8Array.from(parts));
274
1854
  }
275
1855
  throw new Error("Invalid secret key format. Expected base58 string or comma-separated bytes.");
276
1856
  }
277
- return Keypair.fromSecretKey(bytes);
278
1857
  }
279
1858
  function generateAgentKeypair() {
280
1859
  const keypair = Keypair.generate();
@@ -591,5 +2170,29 @@ function clearPriceCache() {
591
2170
  function getProviders() {
592
2171
  return PROVIDERS.map((p) => ({ name: p.name, url: p.url }));
593
2172
  }
2173
+ /*! Bundled license information:
2174
+
2175
+ react/cjs/react.production.js:
2176
+ (**
2177
+ * @license React
2178
+ * react.production.js
2179
+ *
2180
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2181
+ *
2182
+ * This source code is licensed under the MIT license found in the
2183
+ * LICENSE file in the root directory of this source tree.
2184
+ *)
2185
+
2186
+ react/cjs/react.development.js:
2187
+ (**
2188
+ * @license React
2189
+ * react.development.js
2190
+ *
2191
+ * Copyright (c) Meta Platforms, Inc. and affiliates.
2192
+ *
2193
+ * This source code is licensed under the MIT license found in the
2194
+ * LICENSE file in the root directory of this source tree.
2195
+ *)
2196
+ */
594
2197
 
595
- export { addCredits, buildSolanaPayUrl, clearPriceCache, configurePricing, createCreditSession, createPaymentFlow, createPaymentReference, createX402AuthorizationHeader, executeAgentPayment, formatPriceDisplay, formatPriceSync, generateAgentKeypair, getAgentBalance, getProviders, getRemainingCredits, getSolPrice, hasAgentSufficientBalance, keypairFromBase58, lamportsToSol, lamportsToUsd, usdToLamports, useCredit, validateCreditSession };
2198
+ export { addCredits, buildSolanaPayUrl, clearPriceCache, configurePricing, createCreditSession, createPaymentFlow, createPaymentReference, createX402AuthorizationHeader, executeAgentPayment, formatPriceDisplay, formatPriceSync, generateAgentKeypair, getAgentBalance, getProviders, getRemainingCredits, getSolPrice, hasAgentSufficientBalance, keypairFromBase58, lamportsToSol, lamportsToUsd, sendSolanaPayment, usdToLamports, useCredit, usePaywallResource, validateCreditSession };