@teactjs/runtime 0.1.0-alpha.6 → 0.1.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +120 -969
  2. package/package.json +4 -4
package/dist/index.js CHANGED
@@ -1,864 +1,15 @@
1
1
  // @bun
2
- var __create = Object.create;
3
- var __getProtoOf = Object.getPrototypeOf;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __toESM = (mod, isNodeMode, target) => {
8
- target = mod != null ? __create(__getProtoOf(mod)) : {};
9
- const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
10
- for (let key of __getOwnPropNames(mod))
11
- if (!__hasOwnProp.call(to, key))
12
- __defProp(to, key, {
13
- get: () => mod[key],
14
- enumerable: true
15
- });
16
- return to;
17
- };
18
- var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
19
-
20
- // ../../node_modules/.bun/react@19.2.4/node_modules/react/cjs/react.development.js
21
- var require_react_development = __commonJS((exports, module) => {
22
- (function() {
23
- function defineDeprecationWarning(methodName, info) {
24
- Object.defineProperty(Component.prototype, methodName, {
25
- get: function() {
26
- console.warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
27
- }
28
- });
29
- }
30
- function getIteratorFn(maybeIterable) {
31
- if (maybeIterable === null || typeof maybeIterable !== "object")
32
- return null;
33
- maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
34
- return typeof maybeIterable === "function" ? maybeIterable : null;
35
- }
36
- function warnNoop(publicInstance, callerName) {
37
- publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
38
- var warningKey = publicInstance + "." + callerName;
39
- didWarnStateUpdateForUnmountedComponent[warningKey] || (console.error("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.", callerName, publicInstance), didWarnStateUpdateForUnmountedComponent[warningKey] = true);
40
- }
41
- function Component(props, context, updater) {
42
- this.props = props;
43
- this.context = context;
44
- this.refs = emptyObject;
45
- this.updater = updater || ReactNoopUpdateQueue;
46
- }
47
- function ComponentDummy() {}
48
- function PureComponent(props, context, updater) {
49
- this.props = props;
50
- this.context = context;
51
- this.refs = emptyObject;
52
- this.updater = updater || ReactNoopUpdateQueue;
53
- }
54
- function noop() {}
55
- function testStringCoercion(value) {
56
- return "" + value;
57
- }
58
- function checkKeyStringCoercion(value) {
59
- try {
60
- testStringCoercion(value);
61
- var JSCompiler_inline_result = false;
62
- } catch (e) {
63
- JSCompiler_inline_result = true;
64
- }
65
- if (JSCompiler_inline_result) {
66
- JSCompiler_inline_result = console;
67
- var JSCompiler_temp_const = JSCompiler_inline_result.error;
68
- var JSCompiler_inline_result$jscomp$0 = typeof Symbol === "function" && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
69
- JSCompiler_temp_const.call(JSCompiler_inline_result, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", JSCompiler_inline_result$jscomp$0);
70
- return testStringCoercion(value);
71
- }
72
- }
73
- function getComponentNameFromType(type) {
74
- if (type == null)
75
- return null;
76
- if (typeof type === "function")
77
- return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
78
- if (typeof type === "string")
79
- return type;
80
- switch (type) {
81
- case REACT_FRAGMENT_TYPE:
82
- return "Fragment";
83
- case REACT_PROFILER_TYPE:
84
- return "Profiler";
85
- case REACT_STRICT_MODE_TYPE:
86
- return "StrictMode";
87
- case REACT_SUSPENSE_TYPE:
88
- return "Suspense";
89
- case REACT_SUSPENSE_LIST_TYPE:
90
- return "SuspenseList";
91
- case REACT_ACTIVITY_TYPE:
92
- return "Activity";
93
- }
94
- if (typeof type === "object")
95
- switch (typeof type.tag === "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), type.$$typeof) {
96
- case REACT_PORTAL_TYPE:
97
- return "Portal";
98
- case REACT_CONTEXT_TYPE:
99
- return type.displayName || "Context";
100
- case REACT_CONSUMER_TYPE:
101
- return (type._context.displayName || "Context") + ".Consumer";
102
- case REACT_FORWARD_REF_TYPE:
103
- var innerType = type.render;
104
- type = type.displayName;
105
- type || (type = innerType.displayName || innerType.name || "", type = type !== "" ? "ForwardRef(" + type + ")" : "ForwardRef");
106
- return type;
107
- case REACT_MEMO_TYPE:
108
- return innerType = type.displayName || null, innerType !== null ? innerType : getComponentNameFromType(type.type) || "Memo";
109
- case REACT_LAZY_TYPE:
110
- innerType = type._payload;
111
- type = type._init;
112
- try {
113
- return getComponentNameFromType(type(innerType));
114
- } catch (x) {}
115
- }
116
- return null;
117
- }
118
- function getTaskName(type) {
119
- if (type === REACT_FRAGMENT_TYPE)
120
- return "<>";
121
- if (typeof type === "object" && type !== null && type.$$typeof === REACT_LAZY_TYPE)
122
- return "<...>";
123
- try {
124
- var name = getComponentNameFromType(type);
125
- return name ? "<" + name + ">" : "<...>";
126
- } catch (x) {
127
- return "<...>";
128
- }
129
- }
130
- function getOwner() {
131
- var dispatcher = ReactSharedInternals.A;
132
- return dispatcher === null ? null : dispatcher.getOwner();
133
- }
134
- function UnknownOwner() {
135
- return Error("react-stack-top-frame");
136
- }
137
- function hasValidKey(config) {
138
- if (hasOwnProperty.call(config, "key")) {
139
- var getter = Object.getOwnPropertyDescriptor(config, "key").get;
140
- if (getter && getter.isReactWarning)
141
- return false;
142
- }
143
- return config.key !== undefined;
144
- }
145
- function defineKeyPropWarningGetter(props, displayName) {
146
- function warnAboutAccessingKey() {
147
- specialPropKeyWarningShown || (specialPropKeyWarningShown = true, console.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://react.dev/link/special-props)", displayName));
148
- }
149
- warnAboutAccessingKey.isReactWarning = true;
150
- Object.defineProperty(props, "key", {
151
- get: warnAboutAccessingKey,
152
- configurable: true
153
- });
154
- }
155
- function elementRefGetterWithDeprecationWarning() {
156
- var componentName = getComponentNameFromType(this.type);
157
- didWarnAboutElementRef[componentName] || (didWarnAboutElementRef[componentName] = true, console.error("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."));
158
- componentName = this.props.ref;
159
- return componentName !== undefined ? componentName : null;
160
- }
161
- function ReactElement(type, key, props, owner, debugStack, debugTask) {
162
- var refProp = props.ref;
163
- type = {
164
- $$typeof: REACT_ELEMENT_TYPE,
165
- type,
166
- key,
167
- props,
168
- _owner: owner
169
- };
170
- (refProp !== undefined ? refProp : null) !== null ? Object.defineProperty(type, "ref", {
171
- enumerable: false,
172
- get: elementRefGetterWithDeprecationWarning
173
- }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
174
- type._store = {};
175
- Object.defineProperty(type._store, "validated", {
176
- configurable: false,
177
- enumerable: false,
178
- writable: true,
179
- value: 0
180
- });
181
- Object.defineProperty(type, "_debugInfo", {
182
- configurable: false,
183
- enumerable: false,
184
- writable: true,
185
- value: null
186
- });
187
- Object.defineProperty(type, "_debugStack", {
188
- configurable: false,
189
- enumerable: false,
190
- writable: true,
191
- value: debugStack
192
- });
193
- Object.defineProperty(type, "_debugTask", {
194
- configurable: false,
195
- enumerable: false,
196
- writable: true,
197
- value: debugTask
198
- });
199
- Object.freeze && (Object.freeze(type.props), Object.freeze(type));
200
- return type;
201
- }
202
- function cloneAndReplaceKey(oldElement, newKey) {
203
- newKey = ReactElement(oldElement.type, newKey, oldElement.props, oldElement._owner, oldElement._debugStack, oldElement._debugTask);
204
- oldElement._store && (newKey._store.validated = oldElement._store.validated);
205
- return newKey;
206
- }
207
- function validateChildKeys(node) {
208
- isValidElement(node) ? node._store && (node._store.validated = 1) : typeof node === "object" && node !== null && node.$$typeof === REACT_LAZY_TYPE && (node._payload.status === "fulfilled" ? isValidElement(node._payload.value) && node._payload.value._store && (node._payload.value._store.validated = 1) : node._store && (node._store.validated = 1));
209
- }
210
- function isValidElement(object) {
211
- return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
212
- }
213
- function escape(key) {
214
- var escaperLookup = { "=": "=0", ":": "=2" };
215
- return "$" + key.replace(/[=:]/g, function(match) {
216
- return escaperLookup[match];
217
- });
218
- }
219
- function getElementKey(element, index) {
220
- return typeof element === "object" && element !== null && element.key != null ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
221
- }
222
- function resolveThenable(thenable) {
223
- switch (thenable.status) {
224
- case "fulfilled":
225
- return thenable.value;
226
- case "rejected":
227
- throw thenable.reason;
228
- default:
229
- switch (typeof thenable.status === "string" ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(function(fulfilledValue) {
230
- thenable.status === "pending" && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
231
- }, function(error) {
232
- thenable.status === "pending" && (thenable.status = "rejected", thenable.reason = error);
233
- })), thenable.status) {
234
- case "fulfilled":
235
- return thenable.value;
236
- case "rejected":
237
- throw thenable.reason;
238
- }
239
- }
240
- throw thenable;
241
- }
242
- function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
243
- var type = typeof children;
244
- if (type === "undefined" || type === "boolean")
245
- children = null;
246
- var invokeCallback = false;
247
- if (children === null)
248
- invokeCallback = true;
249
- else
250
- switch (type) {
251
- case "bigint":
252
- case "string":
253
- case "number":
254
- invokeCallback = true;
255
- break;
256
- case "object":
257
- switch (children.$$typeof) {
258
- case REACT_ELEMENT_TYPE:
259
- case REACT_PORTAL_TYPE:
260
- invokeCallback = true;
261
- break;
262
- case REACT_LAZY_TYPE:
263
- return invokeCallback = children._init, mapIntoArray(invokeCallback(children._payload), array, escapedPrefix, nameSoFar, callback);
264
- }
265
- }
266
- if (invokeCallback) {
267
- invokeCallback = children;
268
- callback = callback(invokeCallback);
269
- var childKey = nameSoFar === "" ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
270
- isArrayImpl(callback) ? (escapedPrefix = "", childKey != null && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
271
- return c;
272
- })) : callback != null && (isValidElement(callback) && (callback.key != null && (invokeCallback && invokeCallback.key === callback.key || checkKeyStringCoercion(callback.key)), escapedPrefix = cloneAndReplaceKey(callback, escapedPrefix + (callback.key == null || invokeCallback && invokeCallback.key === callback.key ? "" : ("" + callback.key).replace(userProvidedKeyEscapeRegex, "$&/") + "/") + childKey), nameSoFar !== "" && invokeCallback != null && isValidElement(invokeCallback) && invokeCallback.key == null && invokeCallback._store && !invokeCallback._store.validated && (escapedPrefix._store.validated = 2), callback = escapedPrefix), array.push(callback));
273
- return 1;
274
- }
275
- invokeCallback = 0;
276
- childKey = nameSoFar === "" ? "." : nameSoFar + ":";
277
- if (isArrayImpl(children))
278
- for (var i = 0;i < children.length; i++)
279
- nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
280
- else if (i = getIteratorFn(children), typeof i === "function")
281
- for (i === children.entries && (didWarnAboutMaps || console.warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead."), didWarnAboutMaps = true), children = i.call(children), i = 0;!(nameSoFar = children.next()).done; )
282
- nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
283
- else if (type === "object") {
284
- if (typeof children.then === "function")
285
- return mapIntoArray(resolveThenable(children), array, escapedPrefix, nameSoFar, callback);
286
- array = String(children);
287
- throw Error("Objects are not valid as a React child (found: " + (array === "[object Object]" ? "object with keys {" + Object.keys(children).join(", ") + "}" : array) + "). If you meant to render a collection of children, use an array instead.");
288
- }
289
- return invokeCallback;
290
- }
291
- function mapChildren(children, func, context) {
292
- if (children == null)
293
- return children;
294
- var result = [], count = 0;
295
- mapIntoArray(children, result, "", "", function(child) {
296
- return func.call(context, child, count++);
297
- });
298
- return result;
299
- }
300
- function lazyInitializer(payload) {
301
- if (payload._status === -1) {
302
- var ioInfo = payload._ioInfo;
303
- ioInfo != null && (ioInfo.start = ioInfo.end = performance.now());
304
- ioInfo = payload._result;
305
- var thenable = ioInfo();
306
- thenable.then(function(moduleObject) {
307
- if (payload._status === 0 || payload._status === -1) {
308
- payload._status = 1;
309
- payload._result = moduleObject;
310
- var _ioInfo = payload._ioInfo;
311
- _ioInfo != null && (_ioInfo.end = performance.now());
312
- thenable.status === undefined && (thenable.status = "fulfilled", thenable.value = moduleObject);
313
- }
314
- }, function(error) {
315
- if (payload._status === 0 || payload._status === -1) {
316
- payload._status = 2;
317
- payload._result = error;
318
- var _ioInfo2 = payload._ioInfo;
319
- _ioInfo2 != null && (_ioInfo2.end = performance.now());
320
- thenable.status === undefined && (thenable.status = "rejected", thenable.reason = error);
321
- }
322
- });
323
- ioInfo = payload._ioInfo;
324
- if (ioInfo != null) {
325
- ioInfo.value = thenable;
326
- var displayName = thenable.displayName;
327
- typeof displayName === "string" && (ioInfo.name = displayName);
328
- }
329
- payload._status === -1 && (payload._status = 0, payload._result = thenable);
330
- }
331
- if (payload._status === 1)
332
- return ioInfo = payload._result, ioInfo === undefined && console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
333
-
334
- Your code should look like:
335
- const MyComponent = lazy(() => import('./MyComponent'))
336
-
337
- Did you accidentally put curly braces around the import?`, ioInfo), "default" in ioInfo || console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
338
-
339
- Your code should look like:
340
- const MyComponent = lazy(() => import('./MyComponent'))`, ioInfo), ioInfo.default;
341
- throw payload._result;
342
- }
343
- function resolveDispatcher() {
344
- var dispatcher = ReactSharedInternals.H;
345
- dispatcher === null && console.error(`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:
346
- 1. You might have mismatching versions of React and the renderer (such as React DOM)
347
- 2. You might be breaking the Rules of Hooks
348
- 3. You might have more than one copy of React in the same app
349
- See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`);
350
- return dispatcher;
351
- }
352
- function releaseAsyncTransition() {
353
- ReactSharedInternals.asyncTransitions--;
354
- }
355
- function enqueueTask(task) {
356
- if (enqueueTaskImpl === null)
357
- try {
358
- var requireString = ("require" + Math.random()).slice(0, 7);
359
- enqueueTaskImpl = (module && module[requireString]).call(module, "timers").setImmediate;
360
- } catch (_err) {
361
- enqueueTaskImpl = function(callback) {
362
- didWarnAboutMessageChannel === false && (didWarnAboutMessageChannel = true, typeof MessageChannel === "undefined" && console.error("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."));
363
- var channel = new MessageChannel;
364
- channel.port1.onmessage = callback;
365
- channel.port2.postMessage(undefined);
366
- };
367
- }
368
- return enqueueTaskImpl(task);
369
- }
370
- function aggregateErrors(errors) {
371
- return 1 < errors.length && typeof AggregateError === "function" ? new AggregateError(errors) : errors[0];
372
- }
373
- function popActScope(prevActQueue, prevActScopeDepth) {
374
- prevActScopeDepth !== actScopeDepth - 1 && console.error("You seem to have overlapping act() calls, this is not supported. Be sure to await previous act() calls before making a new one. ");
375
- actScopeDepth = prevActScopeDepth;
376
- }
377
- function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
378
- var queue = ReactSharedInternals.actQueue;
379
- if (queue !== null)
380
- if (queue.length !== 0)
381
- try {
382
- flushActQueue(queue);
383
- enqueueTask(function() {
384
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
385
- });
386
- return;
387
- } catch (error) {
388
- ReactSharedInternals.thrownErrors.push(error);
389
- }
390
- else
391
- ReactSharedInternals.actQueue = null;
392
- 0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
393
- }
394
- function flushActQueue(queue) {
395
- if (!isFlushing) {
396
- isFlushing = true;
397
- var i = 0;
398
- try {
399
- for (;i < queue.length; i++) {
400
- var callback = queue[i];
401
- do {
402
- ReactSharedInternals.didUsePromise = false;
403
- var continuation = callback(false);
404
- if (continuation !== null) {
405
- if (ReactSharedInternals.didUsePromise) {
406
- queue[i] = callback;
407
- queue.splice(0, i);
408
- return;
409
- }
410
- callback = continuation;
411
- } else
412
- break;
413
- } while (1);
414
- }
415
- queue.length = 0;
416
- } catch (error) {
417
- queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
418
- } finally {
419
- isFlushing = false;
420
- }
421
- }
422
- }
423
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
424
- var REACT_ELEMENT_TYPE = Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = Symbol.for("react.memo"), REACT_LAZY_TYPE = Symbol.for("react.lazy"), REACT_ACTIVITY_TYPE = Symbol.for("react.activity"), MAYBE_ITERATOR_SYMBOL = Symbol.iterator, didWarnStateUpdateForUnmountedComponent = {}, ReactNoopUpdateQueue = {
425
- isMounted: function() {
426
- return false;
427
- },
428
- enqueueForceUpdate: function(publicInstance) {
429
- warnNoop(publicInstance, "forceUpdate");
430
- },
431
- enqueueReplaceState: function(publicInstance) {
432
- warnNoop(publicInstance, "replaceState");
433
- },
434
- enqueueSetState: function(publicInstance) {
435
- warnNoop(publicInstance, "setState");
436
- }
437
- }, assign = Object.assign, emptyObject = {};
438
- Object.freeze(emptyObject);
439
- Component.prototype.isReactComponent = {};
440
- Component.prototype.setState = function(partialState, callback) {
441
- if (typeof partialState !== "object" && typeof partialState !== "function" && partialState != null)
442
- throw Error("takes an object of state variables to update or a function which returns an object of state variables.");
443
- this.updater.enqueueSetState(this, partialState, callback, "setState");
444
- };
445
- Component.prototype.forceUpdate = function(callback) {
446
- this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
447
- };
448
- var deprecatedAPIs = {
449
- isMounted: [
450
- "isMounted",
451
- "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
452
- ],
453
- replaceState: [
454
- "replaceState",
455
- "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
456
- ]
457
- };
458
- for (fnName in deprecatedAPIs)
459
- deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
460
- ComponentDummy.prototype = Component.prototype;
461
- deprecatedAPIs = PureComponent.prototype = new ComponentDummy;
462
- deprecatedAPIs.constructor = PureComponent;
463
- assign(deprecatedAPIs, Component.prototype);
464
- deprecatedAPIs.isPureReactComponent = true;
465
- var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = {
466
- H: null,
467
- A: null,
468
- T: null,
469
- S: null,
470
- actQueue: null,
471
- asyncTransitions: 0,
472
- isBatchingLegacy: false,
473
- didScheduleLegacyUpdate: false,
474
- didUsePromise: false,
475
- thrownErrors: [],
476
- getCurrentStack: null,
477
- recentlyCreatedOwnerStacks: 0
478
- }, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
479
- return null;
480
- };
481
- deprecatedAPIs = {
482
- react_stack_bottom_frame: function(callStackForError) {
483
- return callStackForError();
484
- }
485
- };
486
- var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
487
- var didWarnAboutElementRef = {};
488
- var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(deprecatedAPIs, UnknownOwner)();
489
- var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
490
- var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = typeof reportError === "function" ? reportError : function(error) {
491
- if (typeof window === "object" && typeof window.ErrorEvent === "function") {
492
- var event = new window.ErrorEvent("error", {
493
- bubbles: true,
494
- cancelable: true,
495
- message: typeof error === "object" && error !== null && typeof error.message === "string" ? String(error.message) : String(error),
496
- error
497
- });
498
- if (!window.dispatchEvent(event))
499
- return;
500
- } else if (typeof process === "object" && typeof process.emit === "function") {
501
- process.emit("uncaughtException", error);
502
- return;
503
- }
504
- console.error(error);
505
- }, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = typeof queueMicrotask === "function" ? function(callback) {
506
- queueMicrotask(function() {
507
- return queueMicrotask(callback);
508
- });
509
- } : enqueueTask;
510
- deprecatedAPIs = Object.freeze({
511
- __proto__: null,
512
- c: function(size) {
513
- return resolveDispatcher().useMemoCache(size);
514
- }
515
- });
516
- var fnName = {
517
- map: mapChildren,
518
- forEach: function(children, forEachFunc, forEachContext) {
519
- mapChildren(children, function() {
520
- forEachFunc.apply(this, arguments);
521
- }, forEachContext);
522
- },
523
- count: function(children) {
524
- var n = 0;
525
- mapChildren(children, function() {
526
- n++;
527
- });
528
- return n;
529
- },
530
- toArray: function(children) {
531
- return mapChildren(children, function(child) {
532
- return child;
533
- }) || [];
534
- },
535
- only: function(children) {
536
- if (!isValidElement(children))
537
- throw Error("React.Children.only expected to receive a single React element child.");
538
- return children;
539
- }
540
- };
541
- exports.Activity = REACT_ACTIVITY_TYPE;
542
- exports.Children = fnName;
543
- exports.Component = Component;
544
- exports.Fragment = REACT_FRAGMENT_TYPE;
545
- exports.Profiler = REACT_PROFILER_TYPE;
546
- exports.PureComponent = PureComponent;
547
- exports.StrictMode = REACT_STRICT_MODE_TYPE;
548
- exports.Suspense = REACT_SUSPENSE_TYPE;
549
- exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
550
- exports.__COMPILER_RUNTIME = deprecatedAPIs;
551
- exports.act = function(callback) {
552
- var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
553
- actScopeDepth++;
554
- var queue = ReactSharedInternals.actQueue = prevActQueue !== null ? prevActQueue : [], didAwaitActCall = false;
555
- try {
556
- var result = callback();
557
- } catch (error) {
558
- ReactSharedInternals.thrownErrors.push(error);
559
- }
560
- if (0 < ReactSharedInternals.thrownErrors.length)
561
- throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
562
- if (result !== null && typeof result === "object" && typeof result.then === "function") {
563
- var thenable = result;
564
- queueSeveralMicrotasks(function() {
565
- didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error("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 () => ...);"));
566
- });
567
- return {
568
- then: function(resolve, reject) {
569
- didAwaitActCall = true;
570
- thenable.then(function(returnValue) {
571
- popActScope(prevActQueue, prevActScopeDepth);
572
- if (prevActScopeDepth === 0) {
573
- try {
574
- flushActQueue(queue), enqueueTask(function() {
575
- return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
576
- });
577
- } catch (error$0) {
578
- ReactSharedInternals.thrownErrors.push(error$0);
579
- }
580
- if (0 < ReactSharedInternals.thrownErrors.length) {
581
- var _thrownError = aggregateErrors(ReactSharedInternals.thrownErrors);
582
- ReactSharedInternals.thrownErrors.length = 0;
583
- reject(_thrownError);
584
- }
585
- } else
586
- resolve(returnValue);
587
- }, function(error) {
588
- popActScope(prevActQueue, prevActScopeDepth);
589
- 0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
590
- });
591
- }
592
- };
593
- }
594
- var returnValue$jscomp$0 = result;
595
- popActScope(prevActQueue, prevActScopeDepth);
596
- prevActScopeDepth === 0 && (flushActQueue(queue), queue.length !== 0 && queueSeveralMicrotasks(function() {
597
- didAwaitActCall || didWarnNoAwaitAct || (didWarnNoAwaitAct = true, console.error("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(() => ...)"));
598
- }), ReactSharedInternals.actQueue = null);
599
- if (0 < ReactSharedInternals.thrownErrors.length)
600
- throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
601
- return {
602
- then: function(resolve, reject) {
603
- didAwaitActCall = true;
604
- prevActScopeDepth === 0 ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
605
- return recursivelyFlushAsyncActWork(returnValue$jscomp$0, resolve, reject);
606
- })) : resolve(returnValue$jscomp$0);
607
- }
608
- };
609
- };
610
- exports.cache = function(fn) {
611
- return function() {
612
- return fn.apply(null, arguments);
613
- };
614
- };
615
- exports.cacheSignal = function() {
616
- return null;
617
- };
618
- exports.captureOwnerStack = function() {
619
- var getCurrentStack = ReactSharedInternals.getCurrentStack;
620
- return getCurrentStack === null ? null : getCurrentStack();
621
- };
622
- exports.cloneElement = function(element, config, children) {
623
- if (element === null || element === undefined)
624
- throw Error("The argument must be a React element, but you passed " + element + ".");
625
- var props = assign({}, element.props), key = element.key, owner = element._owner;
626
- if (config != null) {
627
- var JSCompiler_inline_result;
628
- a: {
629
- if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(config, "ref").get) && JSCompiler_inline_result.isReactWarning) {
630
- JSCompiler_inline_result = false;
631
- break a;
632
- }
633
- JSCompiler_inline_result = config.ref !== undefined;
634
- }
635
- JSCompiler_inline_result && (owner = getOwner());
636
- hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
637
- for (propName in config)
638
- !hasOwnProperty.call(config, propName) || propName === "key" || propName === "__self" || propName === "__source" || propName === "ref" && config.ref === undefined || (props[propName] = config[propName]);
639
- }
640
- var propName = arguments.length - 2;
641
- if (propName === 1)
642
- props.children = children;
643
- else if (1 < propName) {
644
- JSCompiler_inline_result = Array(propName);
645
- for (var i = 0;i < propName; i++)
646
- JSCompiler_inline_result[i] = arguments[i + 2];
647
- props.children = JSCompiler_inline_result;
648
- }
649
- props = ReactElement(element.type, key, props, owner, element._debugStack, element._debugTask);
650
- for (key = 2;key < arguments.length; key++)
651
- validateChildKeys(arguments[key]);
652
- return props;
653
- };
654
- exports.createContext = function(defaultValue) {
655
- defaultValue = {
656
- $$typeof: REACT_CONTEXT_TYPE,
657
- _currentValue: defaultValue,
658
- _currentValue2: defaultValue,
659
- _threadCount: 0,
660
- Provider: null,
661
- Consumer: null
662
- };
663
- defaultValue.Provider = defaultValue;
664
- defaultValue.Consumer = {
665
- $$typeof: REACT_CONSUMER_TYPE,
666
- _context: defaultValue
667
- };
668
- defaultValue._currentRenderer = null;
669
- defaultValue._currentRenderer2 = null;
670
- return defaultValue;
671
- };
672
- exports.createElement = function(type, config, children) {
673
- for (var i = 2;i < arguments.length; i++)
674
- validateChildKeys(arguments[i]);
675
- i = {};
676
- var key = null;
677
- if (config != null)
678
- for (propName in didWarnAboutOldJSXRuntime || !("__self" in config) || "key" in config || (didWarnAboutOldJSXRuntime = true, console.warn("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")), hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key), config)
679
- hasOwnProperty.call(config, propName) && propName !== "key" && propName !== "__self" && propName !== "__source" && (i[propName] = config[propName]);
680
- var childrenLength = arguments.length - 2;
681
- if (childrenLength === 1)
682
- i.children = children;
683
- else if (1 < childrenLength) {
684
- for (var childArray = Array(childrenLength), _i = 0;_i < childrenLength; _i++)
685
- childArray[_i] = arguments[_i + 2];
686
- Object.freeze && Object.freeze(childArray);
687
- i.children = childArray;
688
- }
689
- if (type && type.defaultProps)
690
- for (propName in childrenLength = type.defaultProps, childrenLength)
691
- i[propName] === undefined && (i[propName] = childrenLength[propName]);
692
- key && defineKeyPropWarningGetter(i, typeof type === "function" ? type.displayName || type.name || "Unknown" : type);
693
- var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
694
- return ReactElement(type, key, i, getOwner(), propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack, propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
695
- };
696
- exports.createRef = function() {
697
- var refObject = { current: null };
698
- Object.seal(refObject);
699
- return refObject;
700
- };
701
- exports.forwardRef = function(render) {
702
- render != null && render.$$typeof === REACT_MEMO_TYPE ? console.error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).") : typeof render !== "function" ? console.error("forwardRef requires a render function but was given %s.", render === null ? "null" : typeof render) : render.length !== 0 && render.length !== 2 && console.error("forwardRef render functions accept exactly two parameters: props and ref. %s", render.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined.");
703
- render != null && render.defaultProps != null && console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");
704
- var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
705
- Object.defineProperty(elementType, "displayName", {
706
- enumerable: false,
707
- configurable: true,
708
- get: function() {
709
- return ownName;
710
- },
711
- set: function(name) {
712
- ownName = name;
713
- render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
714
- }
715
- });
716
- return elementType;
717
- };
718
- exports.isValidElement = isValidElement;
719
- exports.lazy = function(ctor) {
720
- ctor = { _status: -1, _result: ctor };
721
- var lazyType = {
722
- $$typeof: REACT_LAZY_TYPE,
723
- _payload: ctor,
724
- _init: lazyInitializer
725
- }, ioInfo = {
726
- name: "lazy",
727
- start: -1,
728
- end: -1,
729
- value: null,
730
- owner: null,
731
- debugStack: Error("react-stack-top-frame"),
732
- debugTask: console.createTask ? console.createTask("lazy()") : null
733
- };
734
- ctor._ioInfo = ioInfo;
735
- lazyType._debugInfo = [{ awaited: ioInfo }];
736
- return lazyType;
737
- };
738
- exports.memo = function(type, compare) {
739
- type == null && console.error("memo: The first argument must be a component. Instead received: %s", type === null ? "null" : typeof type);
740
- compare = {
741
- $$typeof: REACT_MEMO_TYPE,
742
- type,
743
- compare: compare === undefined ? null : compare
744
- };
745
- var ownName;
746
- Object.defineProperty(compare, "displayName", {
747
- enumerable: false,
748
- configurable: true,
749
- get: function() {
750
- return ownName;
751
- },
752
- set: function(name) {
753
- ownName = name;
754
- type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
755
- }
756
- });
757
- return compare;
758
- };
759
- exports.startTransition = function(scope) {
760
- var prevTransition = ReactSharedInternals.T, currentTransition = {};
761
- currentTransition._updatedFibers = new Set;
762
- ReactSharedInternals.T = currentTransition;
763
- try {
764
- var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
765
- onStartTransitionFinish !== null && onStartTransitionFinish(currentTransition, returnValue);
766
- typeof returnValue === "object" && returnValue !== null && typeof returnValue.then === "function" && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
767
- } catch (error) {
768
- reportGlobalError(error);
769
- } finally {
770
- prevTransition === null && currentTransition._updatedFibers && (scope = currentTransition._updatedFibers.size, currentTransition._updatedFibers.clear(), 10 < scope && console.warn("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.")), prevTransition !== null && currentTransition.types !== null && (prevTransition.types !== null && prevTransition.types !== currentTransition.types && console.error("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."), prevTransition.types = currentTransition.types), ReactSharedInternals.T = prevTransition;
771
- }
772
- };
773
- exports.unstable_useCacheRefresh = function() {
774
- return resolveDispatcher().useCacheRefresh();
775
- };
776
- exports.use = function(usable) {
777
- return resolveDispatcher().use(usable);
778
- };
779
- exports.useActionState = function(action, initialState, permalink) {
780
- return resolveDispatcher().useActionState(action, initialState, permalink);
781
- };
782
- exports.useCallback = function(callback, deps) {
783
- return resolveDispatcher().useCallback(callback, deps);
784
- };
785
- exports.useContext = function(Context) {
786
- var dispatcher = resolveDispatcher();
787
- Context.$$typeof === REACT_CONSUMER_TYPE && console.error("Calling useContext(Context.Consumer) is not supported and will cause bugs. Did you mean to call useContext(Context) instead?");
788
- return dispatcher.useContext(Context);
789
- };
790
- exports.useDebugValue = function(value, formatterFn) {
791
- return resolveDispatcher().useDebugValue(value, formatterFn);
792
- };
793
- exports.useDeferredValue = function(value, initialValue) {
794
- return resolveDispatcher().useDeferredValue(value, initialValue);
795
- };
796
- exports.useEffect = function(create, deps) {
797
- create == null && console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?");
798
- return resolveDispatcher().useEffect(create, deps);
799
- };
800
- exports.useEffectEvent = function(callback) {
801
- return resolveDispatcher().useEffectEvent(callback);
802
- };
803
- exports.useId = function() {
804
- return resolveDispatcher().useId();
805
- };
806
- exports.useImperativeHandle = function(ref, create, deps) {
807
- return resolveDispatcher().useImperativeHandle(ref, create, deps);
808
- };
809
- exports.useInsertionEffect = function(create, deps) {
810
- create == null && console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?");
811
- return resolveDispatcher().useInsertionEffect(create, deps);
812
- };
813
- exports.useLayoutEffect = function(create, deps) {
814
- create == null && console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?");
815
- return resolveDispatcher().useLayoutEffect(create, deps);
816
- };
817
- exports.useMemo = function(create, deps) {
818
- return resolveDispatcher().useMemo(create, deps);
819
- };
820
- exports.useOptimistic = function(passthrough, reducer) {
821
- return resolveDispatcher().useOptimistic(passthrough, reducer);
822
- };
823
- exports.useReducer = function(reducer, initialArg, init) {
824
- return resolveDispatcher().useReducer(reducer, initialArg, init);
825
- };
826
- exports.useRef = function(initialValue) {
827
- return resolveDispatcher().useRef(initialValue);
828
- };
829
- exports.useState = function(initialState) {
830
- return resolveDispatcher().useState(initialState);
831
- };
832
- exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
833
- return resolveDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
834
- };
835
- exports.useTransition = function() {
836
- return resolveDispatcher().useTransition();
837
- };
838
- exports.version = "19.2.4";
839
- typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
840
- })();
841
- });
842
-
843
- // ../../node_modules/.bun/react@19.2.4/node_modules/react/index.js
844
- var require_react = __commonJS((exports, module) => {
845
- var react_development = __toESM(require_react_development());
846
- if (false) {} else {
847
- module.exports = react_development;
848
- }
849
- });
850
-
851
2
  // src/bot.ts
852
- var import_react3 = __toESM(require_react(), 1);
3
+ import React3, { Suspense } from "react";
853
4
  import { createRoot } from "@teactjs/renderer";
854
5
  import { serializeOutput } from "@teactjs/telegram";
855
6
  import { CallbackRegistryCtx, ErrorBoundary, SuspenseFallback } from "@teactjs/react";
856
7
 
857
8
  // src/context.ts
858
- var import_react = __toESM(require_react(), 1);
859
- var RuntimeContext = import_react.default.createContext(null);
9
+ import React, { useContext } from "react";
10
+ var RuntimeContext = React.createContext(null);
860
11
  function useRuntime() {
861
- const ctx = import_react.useContext(RuntimeContext);
12
+ const ctx = useContext(RuntimeContext);
862
13
  if (!ctx)
863
14
  throw new Error("Teact hooks must be used inside a bot component");
864
15
  return ctx;
@@ -962,18 +113,18 @@ function commandMiddleware(commands) {
962
113
  }
963
114
 
964
115
  // src/router.ts
965
- var import_react2 = __toESM(require_react(), 1);
116
+ import React2, { useState, useContext as useContext2, useCallback, createContext } from "react";
966
117
  var GUARD_REPLY_SYMBOL = Symbol.for("teact.guardReply");
967
118
  function createGuardReply(text, options) {
968
119
  return { __type: GUARD_REPLY_SYMBOL, text, buttons: options?.buttons };
969
120
  }
970
- var RouterCtx = import_react2.createContext(null);
971
- var CommitModeCtx = import_react2.createContext({ current: "replace" });
121
+ var RouterCtx = createContext(null);
122
+ var CommitModeCtx = createContext({ current: "replace" });
972
123
  function redirect(path) {
973
124
  return path;
974
125
  }
975
126
  function DefaultNotFound() {
976
- return import_react2.default.createElement("tg-message", { text: `\uD83D\uDD0D Page not found
127
+ return React2.createElement("tg-message", { text: `\uD83D\uDD0D Page not found
977
128
 
978
129
  The page you're looking for doesn't exist.
979
130
  Use /start to go back to the menu.` });
@@ -1069,55 +220,55 @@ function RouterProvider({
1069
220
  config,
1070
221
  initialPath
1071
222
  }) {
1072
- const commitMode = import_react2.useContext(CommitModeCtx);
1073
- const runtime = import_react2.useContext(RuntimeContext);
1074
- const [nav, setNav] = import_react2.useState({ path: initialPath, tick: 0 });
1075
- const navigate = import_react2.useCallback((path, opts) => {
223
+ const commitMode = useContext2(CommitModeCtx);
224
+ const runtime = useContext2(RuntimeContext);
225
+ const [nav, setNav] = useState({ path: initialPath, tick: 0 });
226
+ const navigate = useCallback((path, opts) => {
1076
227
  commitMode.current = opts?.mode ?? "replace";
1077
228
  setNav((prev) => ({ path, tick: prev.tick + 1 }));
1078
229
  }, [commitMode]);
1079
230
  const resolved = resolveRoute(config, nav.path, runtime?.session ?? {});
1080
231
  const providerValue = { path: nav.path, params: {}, navigate };
1081
232
  if (!resolved) {
1082
- return import_react2.default.createElement(RouterCtx.Provider, { value: providerValue }, import_react2.default.createElement(config.notFound));
233
+ return React2.createElement(RouterCtx.Provider, { value: providerValue }, React2.createElement(config.notFound));
1083
234
  }
1084
235
  if ("guardComponent" in resolved) {
1085
- return import_react2.default.createElement(RouterCtx.Provider, { value: providerValue }, import_react2.default.createElement(resolved.guardComponent));
236
+ return React2.createElement(RouterCtx.Provider, { value: providerValue }, React2.createElement(resolved.guardComponent));
1086
237
  }
1087
238
  if ("guardElement" in resolved) {
1088
- return import_react2.default.createElement(RouterCtx.Provider, { value: providerValue }, resolved.guardElement);
239
+ return React2.createElement(RouterCtx.Provider, { value: providerValue }, resolved.guardElement);
1089
240
  }
1090
241
  if ("guardReply" in resolved) {
1091
242
  const { text, buttons } = resolved.guardReply;
1092
243
  const children = [];
1093
244
  if (buttons?.length) {
1094
- const rows = buttons.map((row, ri) => import_react2.default.createElement("tg-button-row", { key: ri }, ...row.map((btn, bi) => import_react2.default.createElement("tg-button", {
245
+ const rows = buttons.map((row, ri) => React2.createElement("tg-button-row", { key: ri }, ...row.map((btn, bi) => React2.createElement("tg-button", {
1095
246
  key: bi,
1096
247
  text: btn.text,
1097
248
  url: btn.url,
1098
249
  callbackData: btn.route ? `__route:${btn.route}` : undefined
1099
250
  }))));
1100
- children.push(import_react2.default.createElement("tg-keyboard", { key: "kbd" }, ...rows));
251
+ children.push(React2.createElement("tg-keyboard", { key: "kbd" }, ...rows));
1101
252
  }
1102
- const msg = import_react2.default.createElement("tg-message", { text }, ...children);
1103
- return import_react2.default.createElement(RouterCtx.Provider, { value: providerValue }, msg);
253
+ const msg = React2.createElement("tg-message", { text }, ...children);
254
+ return React2.createElement(RouterCtx.Provider, { value: providerValue }, msg);
1104
255
  }
1105
- return import_react2.default.createElement(RouterCtx.Provider, { value: { path: resolved.path, params: resolved.params, navigate } }, import_react2.default.createElement(resolved.route.component));
256
+ return React2.createElement(RouterCtx.Provider, { value: { path: resolved.path, params: resolved.params, navigate } }, React2.createElement(resolved.route.component));
1106
257
  }
1107
258
  function useNavigate() {
1108
- const ctx = import_react2.useContext(RouterCtx);
259
+ const ctx = useContext2(RouterCtx);
1109
260
  if (!ctx)
1110
261
  throw new Error("useNavigate must be used inside a Router");
1111
262
  return ctx.navigate;
1112
263
  }
1113
264
  function useParams() {
1114
- const ctx = import_react2.useContext(RouterCtx);
265
+ const ctx = useContext2(RouterCtx);
1115
266
  if (!ctx)
1116
267
  throw new Error("useParams must be used inside a Router");
1117
268
  return ctx.params;
1118
269
  }
1119
270
  function useRoute() {
1120
- const ctx = import_react2.useContext(RouterCtx);
271
+ const ctx = useContext2(RouterCtx);
1121
272
  if (!ctx)
1122
273
  throw new Error("useRoute must be used inside a Router");
1123
274
  return { path: ctx.path, params: ctx.params };
@@ -1400,22 +551,22 @@ function createBot(options) {
1400
551
  let rootElement;
1401
552
  if (options.router) {
1402
553
  const initialPath = commandInfo?.initialRoute ?? options.router.defaultRoute;
1403
- rootElement = import_react3.default.createElement(RouterProvider, { config: options.router, initialPath });
554
+ rootElement = React3.createElement(RouterProvider, { config: options.router, initialPath });
1404
555
  } else {
1405
- rootElement = import_react3.default.createElement(options.component, {});
556
+ rootElement = React3.createElement(options.component, {});
1406
557
  }
1407
558
  for (const plugin of plugins) {
1408
559
  if (plugin.Provider) {
1409
- rootElement = import_react3.default.createElement(plugin.Provider, null, rootElement);
560
+ rootElement = React3.createElement(plugin.Provider, null, rootElement);
1410
561
  }
1411
562
  }
1412
563
  if (options.providers) {
1413
- rootElement = import_react3.default.createElement(options.providers, null, rootElement);
564
+ rootElement = React3.createElement(options.providers, null, rootElement);
1414
565
  }
1415
- const wrappedElement = import_react3.default.createElement(ErrorBoundary, {
566
+ const wrappedElement = React3.createElement(ErrorBoundary, {
1416
567
  onError: (err) => console.error(`[teact] Render error in chat ${chatState.chatId}:`, err)
1417
- }, import_react3.default.createElement(import_react3.Suspense, { fallback: import_react3.default.createElement(SuspenseFallback, null) }, rootElement));
1418
- const element = import_react3.default.createElement(CallbackRegistryCtx.Provider, { value: { handlers: chatState.handlers } }, import_react3.default.createElement(RuntimeContext.Provider, { value: runtimeValue }, import_react3.default.createElement(CommitModeCtx.Provider, { value: chatState.commitMode }, wrappedElement)));
568
+ }, React3.createElement(Suspense, { fallback: React3.createElement(SuspenseFallback, null) }, rootElement));
569
+ const element = React3.createElement(CallbackRegistryCtx.Provider, { value: { handlers: chatState.handlers } }, React3.createElement(RuntimeContext.Provider, { value: runtimeValue }, React3.createElement(CommitModeCtx.Provider, { value: chatState.commitMode }, wrappedElement)));
1419
570
  debugLog("rendering", { chatId: botCtx.chatId, hasRouter: !!options.router, plugins: plugins.length });
1420
571
  chatState.root.render(element);
1421
572
  }
@@ -1510,7 +661,7 @@ function createBot(options) {
1510
661
  return botInstance;
1511
662
  }
1512
663
  // src/conversation.ts
1513
- var import_react5 = __toESM(require_react(), 1);
664
+ import React4, { useState as useState2, useContext as useContext3, useId, useMemo, useCallback as useCallback2 } from "react";
1514
665
  import { CallbackRegistryCtx as CallbackRegistryCtx2 } from "@teactjs/react";
1515
666
  function runValidation(validator, value) {
1516
667
  if (typeof validator === "function")
@@ -1533,19 +684,19 @@ function useConversation(config) {
1533
684
  const stepsMode = config ? isStepsConfig(config) : false;
1534
685
  const steps = stepsMode ? config : undefined;
1535
686
  const opts = stepsMode ? undefined : config;
1536
- const [answers, setAnswers] = import_react5.useState({});
1537
- const [activeKey, setActiveKey] = import_react5.useState(null);
1538
- const [waitMode, setWaitMode] = import_react5.useState("text");
1539
- const [processedMsgId, setProcessedMsgId] = import_react5.useState("");
1540
- const [lastError, setLastError] = import_react5.useState(null);
687
+ const [answers, setAnswers] = useState2({});
688
+ const [activeKey, setActiveKey] = useState2(null);
689
+ const [waitMode, setWaitMode] = useState2("text");
690
+ const [processedMsgId, setProcessedMsgId] = useState2("");
691
+ const [lastError, setLastError] = useState2(null);
1541
692
  const bot = useBot();
1542
- const registry = import_react5.useContext(CallbackRegistryCtx2);
1543
- const hookId = import_react5.useId();
693
+ const registry = useContext3(CallbackRegistryCtx2);
694
+ const hookId = useId();
1544
695
  const text = bot.text;
1545
696
  const callbackData = bot.callbackData;
1546
697
  const msgId = bot.messageId ?? "";
1547
- const stepKeys = import_react5.useMemo(() => steps ? Object.keys(steps) : [], [steps]);
1548
- const validateFn = import_react5.useMemo(() => {
698
+ const stepKeys = useMemo(() => steps ? Object.keys(steps) : [], [steps]);
699
+ const validateFn = useMemo(() => {
1549
700
  if (steps) {
1550
701
  return (key, value) => {
1551
702
  const def = steps[key];
@@ -1574,7 +725,7 @@ function useConversation(config) {
1574
725
  setProcessedMsgId(msgId);
1575
726
  }
1576
727
  }
1577
- const setFn = import_react5.useCallback((key, value) => {
728
+ const setFn = useCallback2((key, value) => {
1578
729
  setAnswers((prev) => ({ ...prev, [key]: value }));
1579
730
  setActiveKey((prev) => prev === key ? null : prev);
1580
731
  setLastError(null);
@@ -1598,11 +749,11 @@ function useConversation(config) {
1598
749
  const optValue = typeof opt === "string" ? opt : opt.value;
1599
750
  const cbId = `__ask:${hookId}:${key}:${ri}:${ci}`;
1600
751
  registry?.handlers.set(cbId, () => setFn(key, optValue));
1601
- return import_react5.default.createElement("tg-button", { key: `${ri}:${ci}`, text: optText, callbackData: cbId });
752
+ return React4.createElement("tg-button", { key: `${ri}:${ci}`, text: optText, callbackData: cbId });
1602
753
  });
1603
- return import_react5.default.createElement("tg-button-row", { key: String(ri) }, ...buttons);
754
+ return React4.createElement("tg-button-row", { key: String(ri) }, ...buttons);
1604
755
  });
1605
- return import_react5.default.createElement("tg-message", { text: questionText }, import_react5.default.createElement("tg-keyboard", {}, ...rows));
756
+ return React4.createElement("tg-message", { text: questionText }, React4.createElement("tg-keyboard", {}, ...rows));
1606
757
  }
1607
758
  const currentKey = stepKeys.find((k) => !(k in answers)) ?? null;
1608
759
  function renderStep() {
@@ -1614,7 +765,7 @@ function useConversation(config) {
1614
765
 
1615
766
  ${def.prompt}` : def.prompt;
1616
767
  activateText(currentKey);
1617
- return import_react5.default.createElement("tg-message", { text: promptText });
768
+ return React4.createElement("tg-message", { text: promptText });
1618
769
  }
1619
770
  if ("ask" in def) {
1620
771
  const askText = lastError ? `\u26A0\uFE0F ${lastError}
@@ -1669,7 +820,7 @@ ${def.ask}` : def.ask;
1669
820
  clear: clearStep,
1670
821
  prompt(key, questionText) {
1671
822
  activateText(key);
1672
- return import_react5.default.createElement("tg-message", { text: questionText });
823
+ return React4.createElement("tg-message", { text: questionText });
1673
824
  },
1674
825
  ask: buildAsk,
1675
826
  waitFor(key) {
@@ -1702,9 +853,9 @@ function useForm(schema) {
1702
853
  return runValidation(field.validate, value);
1703
854
  }
1704
855
  });
1705
- const registry = import_react5.useContext(CallbackRegistryCtx2);
1706
- const formId = import_react5.useId();
1707
- const keys = import_react5.useMemo(() => Object.keys(schema), []);
856
+ const registry = useContext3(CallbackRegistryCtx2);
857
+ const formId = useId();
858
+ const keys = useMemo(() => Object.keys(schema), []);
1708
859
  const currentKey = keys.find((k) => !conv.has(k));
1709
860
  const complete = !currentKey;
1710
861
  function renderStep() {
@@ -1720,11 +871,11 @@ ${basePrompt}` : basePrompt;
1720
871
  const buttons = row.map((opt, ci) => {
1721
872
  const cbId = `__form:${formId}:${ri}:${ci}`;
1722
873
  registry?.handlers.set(cbId, () => conv.set(currentKey, opt));
1723
- return import_react5.default.createElement("tg-button", { key: `${ri}:${ci}`, text: opt, callbackData: cbId });
874
+ return React4.createElement("tg-button", { key: `${ri}:${ci}`, text: opt, callbackData: cbId });
1724
875
  });
1725
- return import_react5.default.createElement("tg-button-row", { key: String(ri) }, ...buttons);
876
+ return React4.createElement("tg-button-row", { key: String(ri) }, ...buttons);
1726
877
  });
1727
- return import_react5.default.createElement("tg-message", { text: promptText }, import_react5.default.createElement("tg-keyboard", {}, ...rows));
878
+ return React4.createElement("tg-message", { text: promptText }, React4.createElement("tg-keyboard", {}, ...rows));
1728
879
  }
1729
880
  return conv.prompt(currentKey, promptText);
1730
881
  }
@@ -1764,16 +915,16 @@ ${basePrompt}` : basePrompt;
1764
915
  reset: () => conv.reset()
1765
916
  };
1766
917
  }
1767
- var ConvCtx = import_react5.default.createContext(null);
1768
- var FormCtxInternal = import_react5.default.createContext(null);
918
+ var ConvCtx = React4.createContext(null);
919
+ var FormCtxInternal = React4.createContext(null);
1769
920
  function useConversationContext() {
1770
- const ctx = import_react5.default.useContext(ConvCtx);
921
+ const ctx = React4.useContext(ConvCtx);
1771
922
  if (!ctx)
1772
923
  throw new Error("useConversationContext must be used inside <Conversation>");
1773
924
  return ctx;
1774
925
  }
1775
926
  function useFormContext() {
1776
- const ctx = import_react5.default.useContext(FormCtxInternal);
927
+ const ctx = React4.useContext(FormCtxInternal);
1777
928
  if (!ctx)
1778
929
  throw new Error("useFormContext must be used inside <Form>");
1779
930
  return ctx;
@@ -1797,13 +948,13 @@ function FormCompleteChild(_) {
1797
948
  return null;
1798
949
  }
1799
950
  function ConversationRoot({ children, value }) {
1800
- const configRef = import_react5.default.useRef(undefined);
1801
- const built = import_react5.default.useRef(false);
951
+ const configRef = React4.useRef(undefined);
952
+ const built = React4.useRef(false);
1802
953
  if (!built.current) {
1803
954
  built.current = true;
1804
955
  const config = {};
1805
- import_react5.default.Children.forEach(children, (child) => {
1806
- if (!import_react5.default.isValidElement(child))
956
+ React4.Children.forEach(children, (child) => {
957
+ if (!React4.isValidElement(child))
1807
958
  return;
1808
959
  if (child.type === ConversationPrompt) {
1809
960
  const p = child.props;
@@ -1819,8 +970,8 @@ function ConversationRoot({ children, value }) {
1819
970
  configRef.current = Object.keys(config).length > 0 ? config : undefined;
1820
971
  }
1821
972
  if (configRef.current) {
1822
- import_react5.default.Children.forEach(children, (child) => {
1823
- if (import_react5.default.isValidElement(child) && child.type === ConversationStepChild) {
973
+ React4.Children.forEach(children, (child) => {
974
+ if (React4.isValidElement(child) && child.type === ConversationStepChild) {
1824
975
  const p = child.props;
1825
976
  const def = configRef.current[p.name];
1826
977
  if (def && "render" in def)
@@ -1831,17 +982,17 @@ function ConversationRoot({ children, value }) {
1831
982
  const internalConv = useConversation(configRef.current);
1832
983
  const conv = value ?? internalConv;
1833
984
  let completeContent = null;
1834
- import_react5.default.Children.forEach(children, (child) => {
1835
- if (import_react5.default.isValidElement(child) && child.type === ConversationComplete) {
985
+ React4.Children.forEach(children, (child) => {
986
+ if (React4.isValidElement(child) && child.type === ConversationComplete) {
1836
987
  completeContent = child.props.children;
1837
988
  }
1838
989
  });
1839
990
  const el = conv.render(() => {
1840
991
  if (typeof completeContent === "function")
1841
992
  return completeContent(conv);
1842
- return completeContent ?? import_react5.default.createElement("tg-message", { text: "\u2713" });
993
+ return completeContent ?? React4.createElement("tg-message", { text: "\u2713" });
1843
994
  });
1844
- return import_react5.default.createElement(ConvCtx.Provider, { value: conv }, el);
995
+ return React4.createElement(ConvCtx.Provider, { value: conv }, el);
1845
996
  }
1846
997
  var Conversation = Object.assign(ConversationRoot, {
1847
998
  Prompt: ConversationPrompt,
@@ -1850,13 +1001,13 @@ var Conversation = Object.assign(ConversationRoot, {
1850
1001
  Complete: ConversationComplete
1851
1002
  });
1852
1003
  function FormRoot({ children, value }) {
1853
- const schemaRef = import_react5.default.useRef(undefined);
1854
- const built = import_react5.default.useRef(false);
1004
+ const schemaRef = React4.useRef(undefined);
1005
+ const built = React4.useRef(false);
1855
1006
  if (!built.current) {
1856
1007
  built.current = true;
1857
1008
  const schema = {};
1858
- import_react5.default.Children.forEach(children, (child) => {
1859
- if (!import_react5.default.isValidElement(child))
1009
+ React4.Children.forEach(children, (child) => {
1010
+ if (!React4.isValidElement(child))
1860
1011
  return;
1861
1012
  if (child.type === FormFieldChild) {
1862
1013
  const p = child.props;
@@ -1868,30 +1019,30 @@ function FormRoot({ children, value }) {
1868
1019
  const internalForm = useForm(schemaRef.current ?? {});
1869
1020
  const form = value ?? internalForm;
1870
1021
  let completeContent = null;
1871
- import_react5.default.Children.forEach(children, (child) => {
1872
- if (import_react5.default.isValidElement(child) && child.type === FormCompleteChild) {
1022
+ React4.Children.forEach(children, (child) => {
1023
+ if (React4.isValidElement(child) && child.type === FormCompleteChild) {
1873
1024
  completeContent = child.props.children;
1874
1025
  }
1875
1026
  });
1876
1027
  const el = form.render(() => {
1877
1028
  if (typeof completeContent === "function")
1878
1029
  return completeContent(form);
1879
- return completeContent ?? import_react5.default.createElement("tg-message", { text: "\u2713" });
1030
+ return completeContent ?? React4.createElement("tg-message", { text: "\u2713" });
1880
1031
  });
1881
- return import_react5.default.createElement(FormCtxInternal.Provider, { value: form }, el);
1032
+ return React4.createElement(FormCtxInternal.Provider, { value: form }, el);
1882
1033
  }
1883
1034
  var Form = Object.assign(FormRoot, {
1884
1035
  Field: FormFieldChild,
1885
1036
  Complete: FormCompleteChild
1886
1037
  });
1887
1038
  // src/stream.ts
1888
- var import_react7 = __toESM(require_react(), 1);
1039
+ import { useState as useState3, useCallback as useCallback3, useRef } from "react";
1889
1040
  function useStream(opts) {
1890
- const [text, setText] = import_react7.useState("");
1891
- const [isStreaming, setIsStreaming] = import_react7.useState(false);
1041
+ const [text, setText] = useState3("");
1042
+ const [isStreaming, setIsStreaming] = useState3(false);
1892
1043
  const throttle = opts?.throttleMs ?? 500;
1893
- const generationRef = import_react7.useRef(0);
1894
- const startStream = import_react7.useCallback((source) => {
1044
+ const generationRef = useRef(0);
1045
+ const startStream = useCallback3((source) => {
1895
1046
  const id = ++generationRef.current;
1896
1047
  setIsStreaming(true);
1897
1048
  setText("");
@@ -1917,10 +1068,10 @@ function useStream(opts) {
1917
1068
  return { text, isStreaming, stream: startStream };
1918
1069
  }
1919
1070
  // src/auth.ts
1920
- var import_react8 = __toESM(require_react(), 1);
1921
- var AuthCtx = import_react8.createContext(null);
1071
+ import React5, { useContext as useContext4, createContext as createContext2 } from "react";
1072
+ var AuthCtx = createContext2(null);
1922
1073
  function useAuth() {
1923
- const ctx = import_react8.useContext(AuthCtx);
1074
+ const ctx = useContext4(AuthCtx);
1924
1075
  if (!ctx)
1925
1076
  throw new Error("useAuth requires the authPlugin to be registered");
1926
1077
  return ctx;
@@ -1959,7 +1110,7 @@ function authPlugin(config = {}) {
1959
1110
  return roles.some((r) => authState.is(r));
1960
1111
  }
1961
1112
  };
1962
- return import_react8.default.createElement(AuthCtx.Provider, { value: authState }, children);
1113
+ return React5.createElement(AuthCtx.Provider, { value: authState }, children);
1963
1114
  };
1964
1115
  return {
1965
1116
  name: "auth",
@@ -1967,26 +1118,26 @@ function authPlugin(config = {}) {
1967
1118
  };
1968
1119
  }
1969
1120
  // src/auth-session.ts
1970
- var import_react9 = __toESM(require_react(), 1);
1121
+ import { useCallback as useCallback4, useMemo as useMemo2 } from "react";
1971
1122
  var AUTH_KEY = "auth";
1972
1123
  function useAuthSession() {
1973
1124
  const [session, setSession] = useSession();
1974
1125
  const stored = session[AUTH_KEY];
1975
1126
  const isExpired = stored?.expiresAt ? Date.now() > stored.expiresAt : false;
1976
1127
  const isAuthenticated = !!stored?.accessToken && !isExpired;
1977
- const login = import_react9.useCallback((tokens) => {
1128
+ const login = useCallback4((tokens) => {
1978
1129
  setSession({ [AUTH_KEY]: tokens });
1979
1130
  }, [setSession]);
1980
- const logout = import_react9.useCallback(() => {
1131
+ const logout = useCallback4(() => {
1981
1132
  setSession({ [AUTH_KEY]: undefined });
1982
1133
  }, [setSession]);
1983
- const setAccessToken = import_react9.useCallback((token, expiresAt) => {
1134
+ const setAccessToken = useCallback4((token, expiresAt) => {
1984
1135
  const current = session[AUTH_KEY] ?? {};
1985
1136
  setSession({
1986
1137
  [AUTH_KEY]: { ...current, accessToken: token, ...expiresAt != null ? { expiresAt } : {} }
1987
1138
  });
1988
1139
  }, [session, setSession]);
1989
- return import_react9.useMemo(() => ({
1140
+ return useMemo2(() => ({
1990
1141
  isAuthenticated,
1991
1142
  accessToken: isAuthenticated ? stored?.accessToken ?? null : null,
1992
1143
  refreshToken: stored?.refreshToken ?? null,
@@ -2001,7 +1152,7 @@ function defineConfig(config) {
2001
1152
  return config;
2002
1153
  }
2003
1154
  // src/media-hooks.ts
2004
- var import_react10 = __toESM(require_react(), 1);
1155
+ import { useCallback as useCallback5 } from "react";
2005
1156
  function useChat() {
2006
1157
  const bot = useBot();
2007
1158
  return {
@@ -2027,53 +1178,53 @@ function useTelegram() {
2027
1178
  }
2028
1179
  function usePhoto() {
2029
1180
  const { api, chatId } = useTelegram();
2030
- return import_react10.useCallback((src, opts) => api?.sendPhoto(chatId, src, opts), [api, chatId]);
1181
+ return useCallback5((src, opts) => api?.sendPhoto(chatId, src, opts), [api, chatId]);
2031
1182
  }
2032
1183
  function useVideo() {
2033
1184
  const { api, chatId } = useTelegram();
2034
- return import_react10.useCallback((src, opts) => api?.sendVideo(chatId, src, opts), [api, chatId]);
1185
+ return useCallback5((src, opts) => api?.sendVideo(chatId, src, opts), [api, chatId]);
2035
1186
  }
2036
1187
  function useAnimation() {
2037
1188
  const { api, chatId } = useTelegram();
2038
- return import_react10.useCallback((src, opts) => api?.sendAnimation(chatId, src, opts), [api, chatId]);
1189
+ return useCallback5((src, opts) => api?.sendAnimation(chatId, src, opts), [api, chatId]);
2039
1190
  }
2040
1191
  function useAudio() {
2041
1192
  const { api, chatId } = useTelegram();
2042
- return import_react10.useCallback((src, opts) => api?.sendAudio(chatId, src, opts), [api, chatId]);
1193
+ return useCallback5((src, opts) => api?.sendAudio(chatId, src, opts), [api, chatId]);
2043
1194
  }
2044
1195
  function useVoice() {
2045
1196
  const { api, chatId } = useTelegram();
2046
- return import_react10.useCallback((src, opts) => api?.sendVoice(chatId, src, opts), [api, chatId]);
1197
+ return useCallback5((src, opts) => api?.sendVoice(chatId, src, opts), [api, chatId]);
2047
1198
  }
2048
1199
  function useDocument() {
2049
1200
  const { api, chatId } = useTelegram();
2050
- return import_react10.useCallback((src, opts) => api?.sendDocument(chatId, src, opts), [api, chatId]);
1201
+ return useCallback5((src, opts) => api?.sendDocument(chatId, src, opts), [api, chatId]);
2051
1202
  }
2052
1203
  function useSticker() {
2053
1204
  const { api, chatId } = useTelegram();
2054
- return import_react10.useCallback((src, opts) => api?.sendSticker(chatId, src, opts), [api, chatId]);
1205
+ return useCallback5((src, opts) => api?.sendSticker(chatId, src, opts), [api, chatId]);
2055
1206
  }
2056
1207
  function useLocation() {
2057
1208
  const { api, chatId } = useTelegram();
2058
- return import_react10.useCallback((latitude, longitude, opts) => api?.sendLocation(chatId, latitude, longitude, opts), [api, chatId]);
1209
+ return useCallback5((latitude, longitude, opts) => api?.sendLocation(chatId, latitude, longitude, opts), [api, chatId]);
2059
1210
  }
2060
1211
  function useContact() {
2061
1212
  const { api, chatId } = useTelegram();
2062
- return import_react10.useCallback((phoneNumber, firstName, opts) => api?.sendContact(chatId, phoneNumber, firstName, opts), [api, chatId]);
1213
+ return useCallback5((phoneNumber, firstName, opts) => api?.sendContact(chatId, phoneNumber, firstName, opts), [api, chatId]);
2063
1214
  }
2064
1215
  function useVenue() {
2065
1216
  const { api, chatId } = useTelegram();
2066
- return import_react10.useCallback((latitude, longitude, title, address, opts) => api?.sendVenue(chatId, latitude, longitude, title, address, opts), [api, chatId]);
1217
+ return useCallback5((latitude, longitude, title, address, opts) => api?.sendVenue(chatId, latitude, longitude, title, address, opts), [api, chatId]);
2067
1218
  }
2068
1219
  function usePoll() {
2069
1220
  const { api, chatId } = useTelegram();
2070
- return import_react10.useCallback((question, options, opts) => {
1221
+ return useCallback5((question, options, opts) => {
2071
1222
  const pollOptions = options.map((text) => ({ text }));
2072
1223
  return api?.sendPoll(chatId, question, pollOptions, opts);
2073
1224
  }, [api, chatId]);
2074
1225
  }
2075
1226
  // src/event-hooks.ts
2076
- var import_react11 = __toESM(require_react(), 1);
1227
+ import { useEffect, useRef as useRef2, useContext as useContext5 } from "react";
2077
1228
  function extractEventData(event, raw) {
2078
1229
  const msg = raw?.message;
2079
1230
  switch (event) {
@@ -2131,14 +1282,14 @@ function extractEventData(event, raw) {
2131
1282
  }
2132
1283
  function useOn(event, handler) {
2133
1284
  const bot = useBot();
2134
- const routerCtx = import_react11.useContext(RouterCtx);
1285
+ const routerCtx = useContext5(RouterCtx);
2135
1286
  const raw = bot.raw;
2136
- const handlerRef = import_react11.useRef(handler);
1287
+ const handlerRef = useRef2(handler);
2137
1288
  handlerRef.current = handler;
2138
- const lastProcessedRef = import_react11.useRef(null);
2139
- const navigateRef = import_react11.useRef(routerCtx?.navigate ?? (() => {}));
1289
+ const lastProcessedRef = useRef2(null);
1290
+ const navigateRef = useRef2(routerCtx?.navigate ?? (() => {}));
2140
1291
  navigateRef.current = routerCtx?.navigate ?? (() => {});
2141
- import_react11.useEffect(() => {
1292
+ useEffect(() => {
2142
1293
  if (!raw)
2143
1294
  return;
2144
1295
  const updateId = raw.update?.update_id ?? raw.message?.message_id ?? raw.callbackQuery?.id;
@@ -2177,10 +1328,10 @@ function useEventData(event) {
2177
1328
  return extractEventData(event, raw);
2178
1329
  }
2179
1330
  // src/i18n.ts
2180
- var import_react12 = __toESM(require_react(), 1);
1331
+ import React6, { useState as useState4, useContext as useContext6, useCallback as useCallback6, useMemo as useMemo3, createContext as createContext3 } from "react";
2181
1332
  import i18next from "i18next";
2182
1333
  import { initReactI18next, useTranslation, I18nextProvider } from "react-i18next";
2183
- var LocaleCtx = import_react12.createContext(null);
1334
+ var LocaleCtx = createContext3(null);
2184
1335
  function createI18n(config) {
2185
1336
  const instance = i18next.createInstance();
2186
1337
  instance.use(initReactI18next).init({
@@ -2190,20 +1341,20 @@ function createI18n(config) {
2190
1341
  interpolation: { escapeValue: false }
2191
1342
  });
2192
1343
  function Provider({ children }) {
2193
- const [locale, setLocaleState] = import_react12.useState(config.defaultLocale);
2194
- const setLocale = import_react12.useCallback((lng) => {
1344
+ const [locale, setLocaleState] = useState4(config.defaultLocale);
1345
+ const setLocale = useCallback6((lng) => {
2195
1346
  setLocaleState(lng);
2196
1347
  }, []);
2197
- const ctxValue = import_react12.useMemo(() => ({ locale, setLocale }), [locale, setLocale]);
2198
- return import_react12.default.createElement(LocaleCtx.Provider, { value: ctxValue }, import_react12.default.createElement(I18nextProvider, { i18n: instance }, children));
1348
+ const ctxValue = useMemo3(() => ({ locale, setLocale }), [locale, setLocale]);
1349
+ return React6.createElement(LocaleCtx.Provider, { value: ctxValue }, React6.createElement(I18nextProvider, { i18n: instance }, children));
2199
1350
  }
2200
1351
  return { Provider, instance };
2201
1352
  }
2202
1353
  function useLocale() {
2203
- const localeCtx = import_react12.useContext(LocaleCtx);
1354
+ const localeCtx = useContext6(LocaleCtx);
2204
1355
  const { i18n } = useTranslation();
2205
1356
  const locale = localeCtx?.locale ?? i18n.language;
2206
- const t = import_react12.useMemo(() => i18n.getFixedT(locale), [i18n, locale]);
1357
+ const t = useMemo3(() => i18n.getFixedT(locale), [i18n, locale]);
2207
1358
  return {
2208
1359
  t,
2209
1360
  locale,
@@ -2212,13 +1363,13 @@ function useLocale() {
2212
1363
  };
2213
1364
  }
2214
1365
  // src/invoice.ts
2215
- var import_react13 = __toESM(require_react(), 1);
1366
+ import { useState as useState5, useCallback as useCallback7, useRef as useRef3 } from "react";
2216
1367
  function useInvoice(config) {
2217
1368
  const bot = useBot();
2218
- const [status, setStatus] = import_react13.useState("idle");
2219
- const [receipt, setReceipt] = import_react13.useState(null);
2220
- const [error, setError] = import_react13.useState(null);
2221
- const configRef = import_react13.useRef(config);
1369
+ const [status, setStatus] = useState5("idle");
1370
+ const [receipt, setReceipt] = useState5(null);
1371
+ const [error, setError] = useState5(null);
1372
+ const configRef = useRef3(config);
2222
1373
  configRef.current = config;
2223
1374
  useOn("successful_payment", (data) => {
2224
1375
  if (data?.invoice_payload === configRef.current.payload) {
@@ -2233,7 +1384,7 @@ function useInvoice(config) {
2233
1384
  });
2234
1385
  }
2235
1386
  });
2236
- const send = import_react13.useCallback(async () => {
1387
+ const send = useCallback7(async () => {
2237
1388
  const raw = bot.raw;
2238
1389
  if (!raw?.api)
2239
1390
  return;