@siran/chat-react-hooks 0.1.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.
Files changed (3) hide show
  1. package/README.md +424 -0
  2. package/dist/index.js +1774 -0
  3. package/package.json +33 -0
package/dist/index.js ADDED
@@ -0,0 +1,1774 @@
1
+ var __create = Object.create;
2
+ var __getProtoOf = Object.getPrototypeOf;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __toESM = (mod, isNodeMode, target) => {
7
+ target = mod != null ? __create(__getProtoOf(mod)) : {};
8
+ const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
9
+ for (let key of __getOwnPropNames(mod))
10
+ if (!__hasOwnProp.call(to, key))
11
+ __defProp(to, key, {
12
+ get: () => mod[key],
13
+ enumerable: true
14
+ });
15
+ return to;
16
+ };
17
+ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
18
+
19
+ // ../../node_modules/.bun/react@19.2.3/node_modules/react/cjs/react.development.js
20
+ var require_react_development = __commonJS((exports, module) => {
21
+ (function() {
22
+ function defineDeprecationWarning(methodName, info) {
23
+ Object.defineProperty(Component.prototype, methodName, {
24
+ get: function() {
25
+ console.warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
26
+ }
27
+ });
28
+ }
29
+ function getIteratorFn(maybeIterable) {
30
+ if (maybeIterable === null || typeof maybeIterable !== "object")
31
+ return null;
32
+ maybeIterable = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable["@@iterator"];
33
+ return typeof maybeIterable === "function" ? maybeIterable : null;
34
+ }
35
+ function warnNoop(publicInstance, callerName) {
36
+ publicInstance = (publicInstance = publicInstance.constructor) && (publicInstance.displayName || publicInstance.name) || "ReactClass";
37
+ var warningKey = publicInstance + "." + callerName;
38
+ 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);
39
+ }
40
+ function Component(props, context, updater) {
41
+ this.props = props;
42
+ this.context = context;
43
+ this.refs = emptyObject;
44
+ this.updater = updater || ReactNoopUpdateQueue;
45
+ }
46
+ function ComponentDummy() {}
47
+ function PureComponent(props, context, updater) {
48
+ this.props = props;
49
+ this.context = context;
50
+ this.refs = emptyObject;
51
+ this.updater = updater || ReactNoopUpdateQueue;
52
+ }
53
+ function noop() {}
54
+ function testStringCoercion(value) {
55
+ return "" + value;
56
+ }
57
+ function checkKeyStringCoercion(value) {
58
+ try {
59
+ testStringCoercion(value);
60
+ var JSCompiler_inline_result = false;
61
+ } catch (e) {
62
+ JSCompiler_inline_result = true;
63
+ }
64
+ if (JSCompiler_inline_result) {
65
+ JSCompiler_inline_result = console;
66
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
67
+ var JSCompiler_inline_result$jscomp$0 = typeof Symbol === "function" && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
68
+ 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);
69
+ return testStringCoercion(value);
70
+ }
71
+ }
72
+ function getComponentNameFromType(type) {
73
+ if (type == null)
74
+ return null;
75
+ if (typeof type === "function")
76
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
77
+ if (typeof type === "string")
78
+ return type;
79
+ switch (type) {
80
+ case REACT_FRAGMENT_TYPE:
81
+ return "Fragment";
82
+ case REACT_PROFILER_TYPE:
83
+ return "Profiler";
84
+ case REACT_STRICT_MODE_TYPE:
85
+ return "StrictMode";
86
+ case REACT_SUSPENSE_TYPE:
87
+ return "Suspense";
88
+ case REACT_SUSPENSE_LIST_TYPE:
89
+ return "SuspenseList";
90
+ case REACT_ACTIVITY_TYPE:
91
+ return "Activity";
92
+ }
93
+ if (typeof type === "object")
94
+ 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) {
95
+ case REACT_PORTAL_TYPE:
96
+ return "Portal";
97
+ case REACT_CONTEXT_TYPE:
98
+ return type.displayName || "Context";
99
+ case REACT_CONSUMER_TYPE:
100
+ return (type._context.displayName || "Context") + ".Consumer";
101
+ case REACT_FORWARD_REF_TYPE:
102
+ var innerType = type.render;
103
+ type = type.displayName;
104
+ type || (type = innerType.displayName || innerType.name || "", type = type !== "" ? "ForwardRef(" + type + ")" : "ForwardRef");
105
+ return type;
106
+ case REACT_MEMO_TYPE:
107
+ return innerType = type.displayName || null, innerType !== null ? innerType : getComponentNameFromType(type.type) || "Memo";
108
+ case REACT_LAZY_TYPE:
109
+ innerType = type._payload;
110
+ type = type._init;
111
+ try {
112
+ return getComponentNameFromType(type(innerType));
113
+ } catch (x) {}
114
+ }
115
+ return null;
116
+ }
117
+ function getTaskName(type) {
118
+ if (type === REACT_FRAGMENT_TYPE)
119
+ return "<>";
120
+ if (typeof type === "object" && type !== null && type.$$typeof === REACT_LAZY_TYPE)
121
+ return "<...>";
122
+ try {
123
+ var name = getComponentNameFromType(type);
124
+ return name ? "<" + name + ">" : "<...>";
125
+ } catch (x) {
126
+ return "<...>";
127
+ }
128
+ }
129
+ function getOwner() {
130
+ var dispatcher = ReactSharedInternals.A;
131
+ return dispatcher === null ? null : dispatcher.getOwner();
132
+ }
133
+ function UnknownOwner() {
134
+ return Error("react-stack-top-frame");
135
+ }
136
+ function hasValidKey(config) {
137
+ if (hasOwnProperty.call(config, "key")) {
138
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
139
+ if (getter && getter.isReactWarning)
140
+ return false;
141
+ }
142
+ return config.key !== undefined;
143
+ }
144
+ function defineKeyPropWarningGetter(props, displayName) {
145
+ function warnAboutAccessingKey() {
146
+ 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));
147
+ }
148
+ warnAboutAccessingKey.isReactWarning = true;
149
+ Object.defineProperty(props, "key", {
150
+ get: warnAboutAccessingKey,
151
+ configurable: true
152
+ });
153
+ }
154
+ function elementRefGetterWithDeprecationWarning() {
155
+ var componentName = getComponentNameFromType(this.type);
156
+ 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."));
157
+ componentName = this.props.ref;
158
+ return componentName !== undefined ? componentName : null;
159
+ }
160
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
161
+ var refProp = props.ref;
162
+ type = {
163
+ $$typeof: REACT_ELEMENT_TYPE,
164
+ type,
165
+ key,
166
+ props,
167
+ _owner: owner
168
+ };
169
+ (refProp !== undefined ? refProp : null) !== null ? Object.defineProperty(type, "ref", {
170
+ enumerable: false,
171
+ get: elementRefGetterWithDeprecationWarning
172
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
173
+ type._store = {};
174
+ Object.defineProperty(type._store, "validated", {
175
+ configurable: false,
176
+ enumerable: false,
177
+ writable: true,
178
+ value: 0
179
+ });
180
+ Object.defineProperty(type, "_debugInfo", {
181
+ configurable: false,
182
+ enumerable: false,
183
+ writable: true,
184
+ value: null
185
+ });
186
+ Object.defineProperty(type, "_debugStack", {
187
+ configurable: false,
188
+ enumerable: false,
189
+ writable: true,
190
+ value: debugStack
191
+ });
192
+ Object.defineProperty(type, "_debugTask", {
193
+ configurable: false,
194
+ enumerable: false,
195
+ writable: true,
196
+ value: debugTask
197
+ });
198
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
199
+ return type;
200
+ }
201
+ function cloneAndReplaceKey(oldElement, newKey) {
202
+ newKey = ReactElement(oldElement.type, newKey, oldElement.props, oldElement._owner, oldElement._debugStack, oldElement._debugTask);
203
+ oldElement._store && (newKey._store.validated = oldElement._store.validated);
204
+ return newKey;
205
+ }
206
+ function validateChildKeys(node) {
207
+ 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));
208
+ }
209
+ function isValidElement(object) {
210
+ return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
211
+ }
212
+ function escape(key) {
213
+ var escaperLookup = { "=": "=0", ":": "=2" };
214
+ return "$" + key.replace(/[=:]/g, function(match) {
215
+ return escaperLookup[match];
216
+ });
217
+ }
218
+ function getElementKey(element, index) {
219
+ return typeof element === "object" && element !== null && element.key != null ? (checkKeyStringCoercion(element.key), escape("" + element.key)) : index.toString(36);
220
+ }
221
+ function resolveThenable(thenable) {
222
+ switch (thenable.status) {
223
+ case "fulfilled":
224
+ return thenable.value;
225
+ case "rejected":
226
+ throw thenable.reason;
227
+ default:
228
+ switch (typeof thenable.status === "string" ? thenable.then(noop, noop) : (thenable.status = "pending", thenable.then(function(fulfilledValue) {
229
+ thenable.status === "pending" && (thenable.status = "fulfilled", thenable.value = fulfilledValue);
230
+ }, function(error) {
231
+ thenable.status === "pending" && (thenable.status = "rejected", thenable.reason = error);
232
+ })), thenable.status) {
233
+ case "fulfilled":
234
+ return thenable.value;
235
+ case "rejected":
236
+ throw thenable.reason;
237
+ }
238
+ }
239
+ throw thenable;
240
+ }
241
+ function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
242
+ var type = typeof children;
243
+ if (type === "undefined" || type === "boolean")
244
+ children = null;
245
+ var invokeCallback = false;
246
+ if (children === null)
247
+ invokeCallback = true;
248
+ else
249
+ switch (type) {
250
+ case "bigint":
251
+ case "string":
252
+ case "number":
253
+ invokeCallback = true;
254
+ break;
255
+ case "object":
256
+ switch (children.$$typeof) {
257
+ case REACT_ELEMENT_TYPE:
258
+ case REACT_PORTAL_TYPE:
259
+ invokeCallback = true;
260
+ break;
261
+ case REACT_LAZY_TYPE:
262
+ return invokeCallback = children._init, mapIntoArray(invokeCallback(children._payload), array, escapedPrefix, nameSoFar, callback);
263
+ }
264
+ }
265
+ if (invokeCallback) {
266
+ invokeCallback = children;
267
+ callback = callback(invokeCallback);
268
+ var childKey = nameSoFar === "" ? "." + getElementKey(invokeCallback, 0) : nameSoFar;
269
+ isArrayImpl(callback) ? (escapedPrefix = "", childKey != null && (escapedPrefix = childKey.replace(userProvidedKeyEscapeRegex, "$&/") + "/"), mapIntoArray(callback, array, escapedPrefix, "", function(c) {
270
+ return c;
271
+ })) : 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));
272
+ return 1;
273
+ }
274
+ invokeCallback = 0;
275
+ childKey = nameSoFar === "" ? "." : nameSoFar + ":";
276
+ if (isArrayImpl(children))
277
+ for (var i = 0;i < children.length; i++)
278
+ nameSoFar = children[i], type = childKey + getElementKey(nameSoFar, i), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
279
+ else if (i = getIteratorFn(children), typeof i === "function")
280
+ 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; )
281
+ nameSoFar = nameSoFar.value, type = childKey + getElementKey(nameSoFar, i++), invokeCallback += mapIntoArray(nameSoFar, array, escapedPrefix, type, callback);
282
+ else if (type === "object") {
283
+ if (typeof children.then === "function")
284
+ return mapIntoArray(resolveThenable(children), array, escapedPrefix, nameSoFar, callback);
285
+ array = String(children);
286
+ 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.");
287
+ }
288
+ return invokeCallback;
289
+ }
290
+ function mapChildren(children, func, context) {
291
+ if (children == null)
292
+ return children;
293
+ var result = [], count = 0;
294
+ mapIntoArray(children, result, "", "", function(child) {
295
+ return func.call(context, child, count++);
296
+ });
297
+ return result;
298
+ }
299
+ function lazyInitializer(payload) {
300
+ if (payload._status === -1) {
301
+ var ioInfo = payload._ioInfo;
302
+ ioInfo != null && (ioInfo.start = ioInfo.end = performance.now());
303
+ ioInfo = payload._result;
304
+ var thenable = ioInfo();
305
+ thenable.then(function(moduleObject) {
306
+ if (payload._status === 0 || payload._status === -1) {
307
+ payload._status = 1;
308
+ payload._result = moduleObject;
309
+ var _ioInfo = payload._ioInfo;
310
+ _ioInfo != null && (_ioInfo.end = performance.now());
311
+ thenable.status === undefined && (thenable.status = "fulfilled", thenable.value = moduleObject);
312
+ }
313
+ }, function(error) {
314
+ if (payload._status === 0 || payload._status === -1) {
315
+ payload._status = 2;
316
+ payload._result = error;
317
+ var _ioInfo2 = payload._ioInfo;
318
+ _ioInfo2 != null && (_ioInfo2.end = performance.now());
319
+ thenable.status === undefined && (thenable.status = "rejected", thenable.reason = error);
320
+ }
321
+ });
322
+ ioInfo = payload._ioInfo;
323
+ if (ioInfo != null) {
324
+ ioInfo.value = thenable;
325
+ var displayName = thenable.displayName;
326
+ typeof displayName === "string" && (ioInfo.name = displayName);
327
+ }
328
+ payload._status === -1 && (payload._status = 0, payload._result = thenable);
329
+ }
330
+ if (payload._status === 1)
331
+ return ioInfo = payload._result, ioInfo === undefined && console.error(`lazy: Expected the result of a dynamic import() call. Instead received: %s
332
+
333
+ Your code should look like:
334
+ const MyComponent = lazy(() => import('./MyComponent'))
335
+
336
+ 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
337
+
338
+ Your code should look like:
339
+ const MyComponent = lazy(() => import('./MyComponent'))`, ioInfo), ioInfo.default;
340
+ throw payload._result;
341
+ }
342
+ function resolveDispatcher() {
343
+ var dispatcher = ReactSharedInternals.H;
344
+ 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:
345
+ 1. You might have mismatching versions of React and the renderer (such as React DOM)
346
+ 2. You might be breaking the Rules of Hooks
347
+ 3. You might have more than one copy of React in the same app
348
+ See https://react.dev/link/invalid-hook-call for tips about how to debug and fix this problem.`);
349
+ return dispatcher;
350
+ }
351
+ function releaseAsyncTransition() {
352
+ ReactSharedInternals.asyncTransitions--;
353
+ }
354
+ function enqueueTask(task) {
355
+ if (enqueueTaskImpl === null)
356
+ try {
357
+ var requireString = ("require" + Math.random()).slice(0, 7);
358
+ enqueueTaskImpl = (module && module[requireString]).call(module, "timers").setImmediate;
359
+ } catch (_err) {
360
+ enqueueTaskImpl = function(callback) {
361
+ 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."));
362
+ var channel = new MessageChannel;
363
+ channel.port1.onmessage = callback;
364
+ channel.port2.postMessage(undefined);
365
+ };
366
+ }
367
+ return enqueueTaskImpl(task);
368
+ }
369
+ function aggregateErrors(errors) {
370
+ return 1 < errors.length && typeof AggregateError === "function" ? new AggregateError(errors) : errors[0];
371
+ }
372
+ function popActScope(prevActQueue, prevActScopeDepth) {
373
+ 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. ");
374
+ actScopeDepth = prevActScopeDepth;
375
+ }
376
+ function recursivelyFlushAsyncActWork(returnValue, resolve, reject) {
377
+ var queue = ReactSharedInternals.actQueue;
378
+ if (queue !== null)
379
+ if (queue.length !== 0)
380
+ try {
381
+ flushActQueue(queue);
382
+ enqueueTask(function() {
383
+ return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
384
+ });
385
+ return;
386
+ } catch (error) {
387
+ ReactSharedInternals.thrownErrors.push(error);
388
+ }
389
+ else
390
+ ReactSharedInternals.actQueue = null;
391
+ 0 < ReactSharedInternals.thrownErrors.length ? (queue = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(queue)) : resolve(returnValue);
392
+ }
393
+ function flushActQueue(queue) {
394
+ if (!isFlushing) {
395
+ isFlushing = true;
396
+ var i = 0;
397
+ try {
398
+ for (;i < queue.length; i++) {
399
+ var callback = queue[i];
400
+ do {
401
+ ReactSharedInternals.didUsePromise = false;
402
+ var continuation = callback(false);
403
+ if (continuation !== null) {
404
+ if (ReactSharedInternals.didUsePromise) {
405
+ queue[i] = callback;
406
+ queue.splice(0, i);
407
+ return;
408
+ }
409
+ callback = continuation;
410
+ } else
411
+ break;
412
+ } while (1);
413
+ }
414
+ queue.length = 0;
415
+ } catch (error) {
416
+ queue.splice(0, i + 1), ReactSharedInternals.thrownErrors.push(error);
417
+ } finally {
418
+ isFlushing = false;
419
+ }
420
+ }
421
+ }
422
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
423
+ 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 = {
424
+ isMounted: function() {
425
+ return false;
426
+ },
427
+ enqueueForceUpdate: function(publicInstance) {
428
+ warnNoop(publicInstance, "forceUpdate");
429
+ },
430
+ enqueueReplaceState: function(publicInstance) {
431
+ warnNoop(publicInstance, "replaceState");
432
+ },
433
+ enqueueSetState: function(publicInstance) {
434
+ warnNoop(publicInstance, "setState");
435
+ }
436
+ }, assign = Object.assign, emptyObject = {};
437
+ Object.freeze(emptyObject);
438
+ Component.prototype.isReactComponent = {};
439
+ Component.prototype.setState = function(partialState, callback) {
440
+ if (typeof partialState !== "object" && typeof partialState !== "function" && partialState != null)
441
+ throw Error("takes an object of state variables to update or a function which returns an object of state variables.");
442
+ this.updater.enqueueSetState(this, partialState, callback, "setState");
443
+ };
444
+ Component.prototype.forceUpdate = function(callback) {
445
+ this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
446
+ };
447
+ var deprecatedAPIs = {
448
+ isMounted: [
449
+ "isMounted",
450
+ "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."
451
+ ],
452
+ replaceState: [
453
+ "replaceState",
454
+ "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."
455
+ ]
456
+ };
457
+ for (fnName in deprecatedAPIs)
458
+ deprecatedAPIs.hasOwnProperty(fnName) && defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
459
+ ComponentDummy.prototype = Component.prototype;
460
+ deprecatedAPIs = PureComponent.prototype = new ComponentDummy;
461
+ deprecatedAPIs.constructor = PureComponent;
462
+ assign(deprecatedAPIs, Component.prototype);
463
+ deprecatedAPIs.isPureReactComponent = true;
464
+ var isArrayImpl = Array.isArray, REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = {
465
+ H: null,
466
+ A: null,
467
+ T: null,
468
+ S: null,
469
+ actQueue: null,
470
+ asyncTransitions: 0,
471
+ isBatchingLegacy: false,
472
+ didScheduleLegacyUpdate: false,
473
+ didUsePromise: false,
474
+ thrownErrors: [],
475
+ getCurrentStack: null,
476
+ recentlyCreatedOwnerStacks: 0
477
+ }, hasOwnProperty = Object.prototype.hasOwnProperty, createTask = console.createTask ? console.createTask : function() {
478
+ return null;
479
+ };
480
+ deprecatedAPIs = {
481
+ react_stack_bottom_frame: function(callStackForError) {
482
+ return callStackForError();
483
+ }
484
+ };
485
+ var specialPropKeyWarningShown, didWarnAboutOldJSXRuntime;
486
+ var didWarnAboutElementRef = {};
487
+ var unknownOwnerDebugStack = deprecatedAPIs.react_stack_bottom_frame.bind(deprecatedAPIs, UnknownOwner)();
488
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
489
+ var didWarnAboutMaps = false, userProvidedKeyEscapeRegex = /\/+/g, reportGlobalError = typeof reportError === "function" ? reportError : function(error) {
490
+ if (typeof window === "object" && typeof window.ErrorEvent === "function") {
491
+ var event = new window.ErrorEvent("error", {
492
+ bubbles: true,
493
+ cancelable: true,
494
+ message: typeof error === "object" && error !== null && typeof error.message === "string" ? String(error.message) : String(error),
495
+ error
496
+ });
497
+ if (!window.dispatchEvent(event))
498
+ return;
499
+ } else if (typeof process === "object" && typeof process.emit === "function") {
500
+ process.emit("uncaughtException", error);
501
+ return;
502
+ }
503
+ console.error(error);
504
+ }, didWarnAboutMessageChannel = false, enqueueTaskImpl = null, actScopeDepth = 0, didWarnNoAwaitAct = false, isFlushing = false, queueSeveralMicrotasks = typeof queueMicrotask === "function" ? function(callback) {
505
+ queueMicrotask(function() {
506
+ return queueMicrotask(callback);
507
+ });
508
+ } : enqueueTask;
509
+ deprecatedAPIs = Object.freeze({
510
+ __proto__: null,
511
+ c: function(size) {
512
+ return resolveDispatcher().useMemoCache(size);
513
+ }
514
+ });
515
+ var fnName = {
516
+ map: mapChildren,
517
+ forEach: function(children, forEachFunc, forEachContext) {
518
+ mapChildren(children, function() {
519
+ forEachFunc.apply(this, arguments);
520
+ }, forEachContext);
521
+ },
522
+ count: function(children) {
523
+ var n = 0;
524
+ mapChildren(children, function() {
525
+ n++;
526
+ });
527
+ return n;
528
+ },
529
+ toArray: function(children) {
530
+ return mapChildren(children, function(child) {
531
+ return child;
532
+ }) || [];
533
+ },
534
+ only: function(children) {
535
+ if (!isValidElement(children))
536
+ throw Error("React.Children.only expected to receive a single React element child.");
537
+ return children;
538
+ }
539
+ };
540
+ exports.Activity = REACT_ACTIVITY_TYPE;
541
+ exports.Children = fnName;
542
+ exports.Component = Component;
543
+ exports.Fragment = REACT_FRAGMENT_TYPE;
544
+ exports.Profiler = REACT_PROFILER_TYPE;
545
+ exports.PureComponent = PureComponent;
546
+ exports.StrictMode = REACT_STRICT_MODE_TYPE;
547
+ exports.Suspense = REACT_SUSPENSE_TYPE;
548
+ exports.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE = ReactSharedInternals;
549
+ exports.__COMPILER_RUNTIME = deprecatedAPIs;
550
+ exports.act = function(callback) {
551
+ var prevActQueue = ReactSharedInternals.actQueue, prevActScopeDepth = actScopeDepth;
552
+ actScopeDepth++;
553
+ var queue = ReactSharedInternals.actQueue = prevActQueue !== null ? prevActQueue : [], didAwaitActCall = false;
554
+ try {
555
+ var result = callback();
556
+ } catch (error) {
557
+ ReactSharedInternals.thrownErrors.push(error);
558
+ }
559
+ if (0 < ReactSharedInternals.thrownErrors.length)
560
+ throw popActScope(prevActQueue, prevActScopeDepth), callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
561
+ if (result !== null && typeof result === "object" && typeof result.then === "function") {
562
+ var thenable = result;
563
+ queueSeveralMicrotasks(function() {
564
+ 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 () => ...);"));
565
+ });
566
+ return {
567
+ then: function(resolve, reject) {
568
+ didAwaitActCall = true;
569
+ thenable.then(function(returnValue) {
570
+ popActScope(prevActQueue, prevActScopeDepth);
571
+ if (prevActScopeDepth === 0) {
572
+ try {
573
+ flushActQueue(queue), enqueueTask(function() {
574
+ return recursivelyFlushAsyncActWork(returnValue, resolve, reject);
575
+ });
576
+ } catch (error$0) {
577
+ ReactSharedInternals.thrownErrors.push(error$0);
578
+ }
579
+ if (0 < ReactSharedInternals.thrownErrors.length) {
580
+ var _thrownError = aggregateErrors(ReactSharedInternals.thrownErrors);
581
+ ReactSharedInternals.thrownErrors.length = 0;
582
+ reject(_thrownError);
583
+ }
584
+ } else
585
+ resolve(returnValue);
586
+ }, function(error) {
587
+ popActScope(prevActQueue, prevActScopeDepth);
588
+ 0 < ReactSharedInternals.thrownErrors.length ? (error = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, reject(error)) : reject(error);
589
+ });
590
+ }
591
+ };
592
+ }
593
+ var returnValue$jscomp$0 = result;
594
+ popActScope(prevActQueue, prevActScopeDepth);
595
+ prevActScopeDepth === 0 && (flushActQueue(queue), queue.length !== 0 && queueSeveralMicrotasks(function() {
596
+ 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(() => ...)"));
597
+ }), ReactSharedInternals.actQueue = null);
598
+ if (0 < ReactSharedInternals.thrownErrors.length)
599
+ throw callback = aggregateErrors(ReactSharedInternals.thrownErrors), ReactSharedInternals.thrownErrors.length = 0, callback;
600
+ return {
601
+ then: function(resolve, reject) {
602
+ didAwaitActCall = true;
603
+ prevActScopeDepth === 0 ? (ReactSharedInternals.actQueue = queue, enqueueTask(function() {
604
+ return recursivelyFlushAsyncActWork(returnValue$jscomp$0, resolve, reject);
605
+ })) : resolve(returnValue$jscomp$0);
606
+ }
607
+ };
608
+ };
609
+ exports.cache = function(fn) {
610
+ return function() {
611
+ return fn.apply(null, arguments);
612
+ };
613
+ };
614
+ exports.cacheSignal = function() {
615
+ return null;
616
+ };
617
+ exports.captureOwnerStack = function() {
618
+ var getCurrentStack = ReactSharedInternals.getCurrentStack;
619
+ return getCurrentStack === null ? null : getCurrentStack();
620
+ };
621
+ exports.cloneElement = function(element, config, children) {
622
+ if (element === null || element === undefined)
623
+ throw Error("The argument must be a React element, but you passed " + element + ".");
624
+ var props = assign({}, element.props), key = element.key, owner = element._owner;
625
+ if (config != null) {
626
+ var JSCompiler_inline_result;
627
+ a: {
628
+ if (hasOwnProperty.call(config, "ref") && (JSCompiler_inline_result = Object.getOwnPropertyDescriptor(config, "ref").get) && JSCompiler_inline_result.isReactWarning) {
629
+ JSCompiler_inline_result = false;
630
+ break a;
631
+ }
632
+ JSCompiler_inline_result = config.ref !== undefined;
633
+ }
634
+ JSCompiler_inline_result && (owner = getOwner());
635
+ hasValidKey(config) && (checkKeyStringCoercion(config.key), key = "" + config.key);
636
+ for (propName in config)
637
+ !hasOwnProperty.call(config, propName) || propName === "key" || propName === "__self" || propName === "__source" || propName === "ref" && config.ref === undefined || (props[propName] = config[propName]);
638
+ }
639
+ var propName = arguments.length - 2;
640
+ if (propName === 1)
641
+ props.children = children;
642
+ else if (1 < propName) {
643
+ JSCompiler_inline_result = Array(propName);
644
+ for (var i = 0;i < propName; i++)
645
+ JSCompiler_inline_result[i] = arguments[i + 2];
646
+ props.children = JSCompiler_inline_result;
647
+ }
648
+ props = ReactElement(element.type, key, props, owner, element._debugStack, element._debugTask);
649
+ for (key = 2;key < arguments.length; key++)
650
+ validateChildKeys(arguments[key]);
651
+ return props;
652
+ };
653
+ exports.createContext = function(defaultValue) {
654
+ defaultValue = {
655
+ $$typeof: REACT_CONTEXT_TYPE,
656
+ _currentValue: defaultValue,
657
+ _currentValue2: defaultValue,
658
+ _threadCount: 0,
659
+ Provider: null,
660
+ Consumer: null
661
+ };
662
+ defaultValue.Provider = defaultValue;
663
+ defaultValue.Consumer = {
664
+ $$typeof: REACT_CONSUMER_TYPE,
665
+ _context: defaultValue
666
+ };
667
+ defaultValue._currentRenderer = null;
668
+ defaultValue._currentRenderer2 = null;
669
+ return defaultValue;
670
+ };
671
+ exports.createElement = function(type, config, children) {
672
+ for (var i = 2;i < arguments.length; i++)
673
+ validateChildKeys(arguments[i]);
674
+ i = {};
675
+ var key = null;
676
+ if (config != null)
677
+ 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)
678
+ hasOwnProperty.call(config, propName) && propName !== "key" && propName !== "__self" && propName !== "__source" && (i[propName] = config[propName]);
679
+ var childrenLength = arguments.length - 2;
680
+ if (childrenLength === 1)
681
+ i.children = children;
682
+ else if (1 < childrenLength) {
683
+ for (var childArray = Array(childrenLength), _i = 0;_i < childrenLength; _i++)
684
+ childArray[_i] = arguments[_i + 2];
685
+ Object.freeze && Object.freeze(childArray);
686
+ i.children = childArray;
687
+ }
688
+ if (type && type.defaultProps)
689
+ for (propName in childrenLength = type.defaultProps, childrenLength)
690
+ i[propName] === undefined && (i[propName] = childrenLength[propName]);
691
+ key && defineKeyPropWarningGetter(i, typeof type === "function" ? type.displayName || type.name || "Unknown" : type);
692
+ var propName = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
693
+ return ReactElement(type, key, i, getOwner(), propName ? Error("react-stack-top-frame") : unknownOwnerDebugStack, propName ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
694
+ };
695
+ exports.createRef = function() {
696
+ var refObject = { current: null };
697
+ Object.seal(refObject);
698
+ return refObject;
699
+ };
700
+ exports.forwardRef = function(render) {
701
+ 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.");
702
+ render != null && render.defaultProps != null && console.error("forwardRef render functions do not support defaultProps. Did you accidentally pass a React component?");
703
+ var elementType = { $$typeof: REACT_FORWARD_REF_TYPE, render }, ownName;
704
+ Object.defineProperty(elementType, "displayName", {
705
+ enumerable: false,
706
+ configurable: true,
707
+ get: function() {
708
+ return ownName;
709
+ },
710
+ set: function(name) {
711
+ ownName = name;
712
+ render.name || render.displayName || (Object.defineProperty(render, "name", { value: name }), render.displayName = name);
713
+ }
714
+ });
715
+ return elementType;
716
+ };
717
+ exports.isValidElement = isValidElement;
718
+ exports.lazy = function(ctor) {
719
+ ctor = { _status: -1, _result: ctor };
720
+ var lazyType = {
721
+ $$typeof: REACT_LAZY_TYPE,
722
+ _payload: ctor,
723
+ _init: lazyInitializer
724
+ }, ioInfo = {
725
+ name: "lazy",
726
+ start: -1,
727
+ end: -1,
728
+ value: null,
729
+ owner: null,
730
+ debugStack: Error("react-stack-top-frame"),
731
+ debugTask: console.createTask ? console.createTask("lazy()") : null
732
+ };
733
+ ctor._ioInfo = ioInfo;
734
+ lazyType._debugInfo = [{ awaited: ioInfo }];
735
+ return lazyType;
736
+ };
737
+ exports.memo = function(type, compare) {
738
+ type == null && console.error("memo: The first argument must be a component. Instead received: %s", type === null ? "null" : typeof type);
739
+ compare = {
740
+ $$typeof: REACT_MEMO_TYPE,
741
+ type,
742
+ compare: compare === undefined ? null : compare
743
+ };
744
+ var ownName;
745
+ Object.defineProperty(compare, "displayName", {
746
+ enumerable: false,
747
+ configurable: true,
748
+ get: function() {
749
+ return ownName;
750
+ },
751
+ set: function(name) {
752
+ ownName = name;
753
+ type.name || type.displayName || (Object.defineProperty(type, "name", { value: name }), type.displayName = name);
754
+ }
755
+ });
756
+ return compare;
757
+ };
758
+ exports.startTransition = function(scope) {
759
+ var prevTransition = ReactSharedInternals.T, currentTransition = {};
760
+ currentTransition._updatedFibers = new Set;
761
+ ReactSharedInternals.T = currentTransition;
762
+ try {
763
+ var returnValue = scope(), onStartTransitionFinish = ReactSharedInternals.S;
764
+ onStartTransitionFinish !== null && onStartTransitionFinish(currentTransition, returnValue);
765
+ typeof returnValue === "object" && returnValue !== null && typeof returnValue.then === "function" && (ReactSharedInternals.asyncTransitions++, returnValue.then(releaseAsyncTransition, releaseAsyncTransition), returnValue.then(noop, reportGlobalError));
766
+ } catch (error) {
767
+ reportGlobalError(error);
768
+ } finally {
769
+ 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;
770
+ }
771
+ };
772
+ exports.unstable_useCacheRefresh = function() {
773
+ return resolveDispatcher().useCacheRefresh();
774
+ };
775
+ exports.use = function(usable) {
776
+ return resolveDispatcher().use(usable);
777
+ };
778
+ exports.useActionState = function(action, initialState, permalink) {
779
+ return resolveDispatcher().useActionState(action, initialState, permalink);
780
+ };
781
+ exports.useCallback = function(callback, deps) {
782
+ return resolveDispatcher().useCallback(callback, deps);
783
+ };
784
+ exports.useContext = function(Context) {
785
+ var dispatcher = resolveDispatcher();
786
+ 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?");
787
+ return dispatcher.useContext(Context);
788
+ };
789
+ exports.useDebugValue = function(value, formatterFn) {
790
+ return resolveDispatcher().useDebugValue(value, formatterFn);
791
+ };
792
+ exports.useDeferredValue = function(value, initialValue) {
793
+ return resolveDispatcher().useDeferredValue(value, initialValue);
794
+ };
795
+ exports.useEffect = function(create, deps) {
796
+ create == null && console.warn("React Hook useEffect requires an effect callback. Did you forget to pass a callback to the hook?");
797
+ return resolveDispatcher().useEffect(create, deps);
798
+ };
799
+ exports.useEffectEvent = function(callback) {
800
+ return resolveDispatcher().useEffectEvent(callback);
801
+ };
802
+ exports.useId = function() {
803
+ return resolveDispatcher().useId();
804
+ };
805
+ exports.useImperativeHandle = function(ref, create, deps) {
806
+ return resolveDispatcher().useImperativeHandle(ref, create, deps);
807
+ };
808
+ exports.useInsertionEffect = function(create, deps) {
809
+ create == null && console.warn("React Hook useInsertionEffect requires an effect callback. Did you forget to pass a callback to the hook?");
810
+ return resolveDispatcher().useInsertionEffect(create, deps);
811
+ };
812
+ exports.useLayoutEffect = function(create, deps) {
813
+ create == null && console.warn("React Hook useLayoutEffect requires an effect callback. Did you forget to pass a callback to the hook?");
814
+ return resolveDispatcher().useLayoutEffect(create, deps);
815
+ };
816
+ exports.useMemo = function(create, deps) {
817
+ return resolveDispatcher().useMemo(create, deps);
818
+ };
819
+ exports.useOptimistic = function(passthrough, reducer) {
820
+ return resolveDispatcher().useOptimistic(passthrough, reducer);
821
+ };
822
+ exports.useReducer = function(reducer, initialArg, init) {
823
+ return resolveDispatcher().useReducer(reducer, initialArg, init);
824
+ };
825
+ exports.useRef = function(initialValue) {
826
+ return resolveDispatcher().useRef(initialValue);
827
+ };
828
+ exports.useState = function(initialState) {
829
+ return resolveDispatcher().useState(initialState);
830
+ };
831
+ exports.useSyncExternalStore = function(subscribe, getSnapshot, getServerSnapshot) {
832
+ return resolveDispatcher().useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
833
+ };
834
+ exports.useTransition = function() {
835
+ return resolveDispatcher().useTransition();
836
+ };
837
+ exports.version = "19.2.3";
838
+ typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === "function" && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
839
+ })();
840
+ });
841
+
842
+ // ../../node_modules/.bun/react@19.2.3/node_modules/react/index.js
843
+ var require_react = __commonJS((exports, module) => {
844
+ var react_development = __toESM(require_react_development());
845
+ if (false) {} else {
846
+ module.exports = react_development;
847
+ }
848
+ });
849
+
850
+ // ../../node_modules/.bun/react@19.2.3/node_modules/react/cjs/react-jsx-dev-runtime.development.js
851
+ var require_react_jsx_dev_runtime_development = __commonJS((exports) => {
852
+ var React = __toESM(require_react());
853
+ (function() {
854
+ function getComponentNameFromType(type) {
855
+ if (type == null)
856
+ return null;
857
+ if (typeof type === "function")
858
+ return type.$$typeof === REACT_CLIENT_REFERENCE ? null : type.displayName || type.name || null;
859
+ if (typeof type === "string")
860
+ return type;
861
+ switch (type) {
862
+ case REACT_FRAGMENT_TYPE:
863
+ return "Fragment";
864
+ case REACT_PROFILER_TYPE:
865
+ return "Profiler";
866
+ case REACT_STRICT_MODE_TYPE:
867
+ return "StrictMode";
868
+ case REACT_SUSPENSE_TYPE:
869
+ return "Suspense";
870
+ case REACT_SUSPENSE_LIST_TYPE:
871
+ return "SuspenseList";
872
+ case REACT_ACTIVITY_TYPE:
873
+ return "Activity";
874
+ }
875
+ if (typeof type === "object")
876
+ 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) {
877
+ case REACT_PORTAL_TYPE:
878
+ return "Portal";
879
+ case REACT_CONTEXT_TYPE:
880
+ return type.displayName || "Context";
881
+ case REACT_CONSUMER_TYPE:
882
+ return (type._context.displayName || "Context") + ".Consumer";
883
+ case REACT_FORWARD_REF_TYPE:
884
+ var innerType = type.render;
885
+ type = type.displayName;
886
+ type || (type = innerType.displayName || innerType.name || "", type = type !== "" ? "ForwardRef(" + type + ")" : "ForwardRef");
887
+ return type;
888
+ case REACT_MEMO_TYPE:
889
+ return innerType = type.displayName || null, innerType !== null ? innerType : getComponentNameFromType(type.type) || "Memo";
890
+ case REACT_LAZY_TYPE:
891
+ innerType = type._payload;
892
+ type = type._init;
893
+ try {
894
+ return getComponentNameFromType(type(innerType));
895
+ } catch (x) {}
896
+ }
897
+ return null;
898
+ }
899
+ function testStringCoercion(value) {
900
+ return "" + value;
901
+ }
902
+ function checkKeyStringCoercion(value) {
903
+ try {
904
+ testStringCoercion(value);
905
+ var JSCompiler_inline_result = false;
906
+ } catch (e) {
907
+ JSCompiler_inline_result = true;
908
+ }
909
+ if (JSCompiler_inline_result) {
910
+ JSCompiler_inline_result = console;
911
+ var JSCompiler_temp_const = JSCompiler_inline_result.error;
912
+ var JSCompiler_inline_result$jscomp$0 = typeof Symbol === "function" && Symbol.toStringTag && value[Symbol.toStringTag] || value.constructor.name || "Object";
913
+ 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);
914
+ return testStringCoercion(value);
915
+ }
916
+ }
917
+ function getTaskName(type) {
918
+ if (type === REACT_FRAGMENT_TYPE)
919
+ return "<>";
920
+ if (typeof type === "object" && type !== null && type.$$typeof === REACT_LAZY_TYPE)
921
+ return "<...>";
922
+ try {
923
+ var name = getComponentNameFromType(type);
924
+ return name ? "<" + name + ">" : "<...>";
925
+ } catch (x) {
926
+ return "<...>";
927
+ }
928
+ }
929
+ function getOwner() {
930
+ var dispatcher = ReactSharedInternals.A;
931
+ return dispatcher === null ? null : dispatcher.getOwner();
932
+ }
933
+ function UnknownOwner() {
934
+ return Error("react-stack-top-frame");
935
+ }
936
+ function hasValidKey(config) {
937
+ if (hasOwnProperty.call(config, "key")) {
938
+ var getter = Object.getOwnPropertyDescriptor(config, "key").get;
939
+ if (getter && getter.isReactWarning)
940
+ return false;
941
+ }
942
+ return config.key !== undefined;
943
+ }
944
+ function defineKeyPropWarningGetter(props, displayName) {
945
+ function warnAboutAccessingKey() {
946
+ 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));
947
+ }
948
+ warnAboutAccessingKey.isReactWarning = true;
949
+ Object.defineProperty(props, "key", {
950
+ get: warnAboutAccessingKey,
951
+ configurable: true
952
+ });
953
+ }
954
+ function elementRefGetterWithDeprecationWarning() {
955
+ var componentName = getComponentNameFromType(this.type);
956
+ 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."));
957
+ componentName = this.props.ref;
958
+ return componentName !== undefined ? componentName : null;
959
+ }
960
+ function ReactElement(type, key, props, owner, debugStack, debugTask) {
961
+ var refProp = props.ref;
962
+ type = {
963
+ $$typeof: REACT_ELEMENT_TYPE,
964
+ type,
965
+ key,
966
+ props,
967
+ _owner: owner
968
+ };
969
+ (refProp !== undefined ? refProp : null) !== null ? Object.defineProperty(type, "ref", {
970
+ enumerable: false,
971
+ get: elementRefGetterWithDeprecationWarning
972
+ }) : Object.defineProperty(type, "ref", { enumerable: false, value: null });
973
+ type._store = {};
974
+ Object.defineProperty(type._store, "validated", {
975
+ configurable: false,
976
+ enumerable: false,
977
+ writable: true,
978
+ value: 0
979
+ });
980
+ Object.defineProperty(type, "_debugInfo", {
981
+ configurable: false,
982
+ enumerable: false,
983
+ writable: true,
984
+ value: null
985
+ });
986
+ Object.defineProperty(type, "_debugStack", {
987
+ configurable: false,
988
+ enumerable: false,
989
+ writable: true,
990
+ value: debugStack
991
+ });
992
+ Object.defineProperty(type, "_debugTask", {
993
+ configurable: false,
994
+ enumerable: false,
995
+ writable: true,
996
+ value: debugTask
997
+ });
998
+ Object.freeze && (Object.freeze(type.props), Object.freeze(type));
999
+ return type;
1000
+ }
1001
+ function jsxDEVImpl(type, config, maybeKey, isStaticChildren, debugStack, debugTask) {
1002
+ var children = config.children;
1003
+ if (children !== undefined)
1004
+ if (isStaticChildren)
1005
+ if (isArrayImpl(children)) {
1006
+ for (isStaticChildren = 0;isStaticChildren < children.length; isStaticChildren++)
1007
+ validateChildKeys(children[isStaticChildren]);
1008
+ Object.freeze && Object.freeze(children);
1009
+ } else
1010
+ console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
1011
+ else
1012
+ validateChildKeys(children);
1013
+ if (hasOwnProperty.call(config, "key")) {
1014
+ children = getComponentNameFromType(type);
1015
+ var keys = Object.keys(config).filter(function(k) {
1016
+ return k !== "key";
1017
+ });
1018
+ isStaticChildren = 0 < keys.length ? "{key: someKey, " + keys.join(": ..., ") + ": ...}" : "{key: someKey}";
1019
+ didWarnAboutKeySpread[children + isStaticChildren] || (keys = 0 < keys.length ? "{" + keys.join(": ..., ") + ": ...}" : "{}", console.error(`A props object containing a "key" prop is being spread into JSX:
1020
+ let props = %s;
1021
+ <%s {...props} />
1022
+ React keys must be passed directly to JSX without using spread:
1023
+ let props = %s;
1024
+ <%s key={someKey} {...props} />`, isStaticChildren, children, keys, children), didWarnAboutKeySpread[children + isStaticChildren] = true);
1025
+ }
1026
+ children = null;
1027
+ maybeKey !== undefined && (checkKeyStringCoercion(maybeKey), children = "" + maybeKey);
1028
+ hasValidKey(config) && (checkKeyStringCoercion(config.key), children = "" + config.key);
1029
+ if ("key" in config) {
1030
+ maybeKey = {};
1031
+ for (var propName in config)
1032
+ propName !== "key" && (maybeKey[propName] = config[propName]);
1033
+ } else
1034
+ maybeKey = config;
1035
+ children && defineKeyPropWarningGetter(maybeKey, typeof type === "function" ? type.displayName || type.name || "Unknown" : type);
1036
+ return ReactElement(type, children, maybeKey, getOwner(), debugStack, debugTask);
1037
+ }
1038
+ function validateChildKeys(node) {
1039
+ 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));
1040
+ }
1041
+ function isValidElement(object) {
1042
+ return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1043
+ }
1044
+ 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"), REACT_CLIENT_REFERENCE = Symbol.for("react.client.reference"), ReactSharedInternals = React.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, hasOwnProperty = Object.prototype.hasOwnProperty, isArrayImpl = Array.isArray, createTask = console.createTask ? console.createTask : function() {
1045
+ return null;
1046
+ };
1047
+ React = {
1048
+ react_stack_bottom_frame: function(callStackForError) {
1049
+ return callStackForError();
1050
+ }
1051
+ };
1052
+ var specialPropKeyWarningShown;
1053
+ var didWarnAboutElementRef = {};
1054
+ var unknownOwnerDebugStack = React.react_stack_bottom_frame.bind(React, UnknownOwner)();
1055
+ var unknownOwnerDebugTask = createTask(getTaskName(UnknownOwner));
1056
+ var didWarnAboutKeySpread = {};
1057
+ exports.Fragment = REACT_FRAGMENT_TYPE;
1058
+ exports.jsxDEV = function(type, config, maybeKey, isStaticChildren) {
1059
+ var trackActualOwner = 1e4 > ReactSharedInternals.recentlyCreatedOwnerStacks++;
1060
+ return jsxDEVImpl(type, config, maybeKey, isStaticChildren, trackActualOwner ? Error("react-stack-top-frame") : unknownOwnerDebugStack, trackActualOwner ? createTask(getTaskName(type)) : unknownOwnerDebugTask);
1061
+ };
1062
+ })();
1063
+ });
1064
+
1065
+ // ../../node_modules/.bun/react@19.2.3/node_modules/react/jsx-dev-runtime.js
1066
+ var require_jsx_dev_runtime = __commonJS((exports, module) => {
1067
+ var react_jsx_dev_runtime_development = __toESM(require_react_jsx_dev_runtime_development());
1068
+ if (false) {} else {
1069
+ module.exports = react_jsx_dev_runtime_development;
1070
+ }
1071
+ });
1072
+
1073
+ // src/ChatContext.tsx
1074
+ var import_react = __toESM(require_react(), 1);
1075
+ var jsx_dev_runtime = __toESM(require_jsx_dev_runtime(), 1);
1076
+ var ChatContext = import_react.createContext(null);
1077
+ function ChatProvider({ client, children }) {
1078
+ return /* @__PURE__ */ jsx_dev_runtime.jsxDEV(ChatContext.Provider, {
1079
+ value: client,
1080
+ children
1081
+ }, undefined, false, undefined, this);
1082
+ }
1083
+ function useChat() {
1084
+ const client = import_react.useContext(ChatContext);
1085
+ if (!client) {
1086
+ throw new Error("useChat must be used within a ChatProvider");
1087
+ }
1088
+ return client;
1089
+ }
1090
+ // src/hooks/useConversations.ts
1091
+ var import_react2 = __toESM(require_react(), 1);
1092
+ function useConversations(input, options) {
1093
+ const chat = useChat();
1094
+ const [state, setState] = import_react2.useState({
1095
+ data: null,
1096
+ loading: false,
1097
+ error: null
1098
+ });
1099
+ const inputKey = input ? JSON.stringify(input) : null;
1100
+ const autoLoad = options?.autoLoad;
1101
+ const lastConversationsRef = import_react2.useRef([]);
1102
+ const storeConversations = import_react2.useSyncExternalStore((onStoreChange) => chat.store.subscribe(onStoreChange), () => {
1103
+ const conversations2 = chat.store.conversations();
1104
+ const hasChanged = conversations2.length !== lastConversationsRef.current.length || conversations2.some((conv, idx) => {
1105
+ const prevConv = lastConversationsRef.current[idx];
1106
+ return !prevConv || prevConv.id !== conv.id || prevConv.lastMessageAt?.getTime() !== conv.lastMessageAt?.getTime();
1107
+ });
1108
+ if (!hasChanged) {
1109
+ return lastConversationsRef.current;
1110
+ }
1111
+ lastConversationsRef.current = conversations2;
1112
+ return conversations2;
1113
+ });
1114
+ const loadConversations = import_react2.useCallback(async () => {
1115
+ if (!input) {
1116
+ setState((prev) => ({ ...prev, loading: false }));
1117
+ return;
1118
+ }
1119
+ if (!input.userId) {
1120
+ setState((prev) => ({ ...prev, loading: false }));
1121
+ return;
1122
+ }
1123
+ setState((prev) => ({ ...prev, loading: true, error: null }));
1124
+ try {
1125
+ const result = await chat.getConversations(input);
1126
+ if (result.ok) {
1127
+ setState({
1128
+ data: result.value,
1129
+ loading: false,
1130
+ error: null
1131
+ });
1132
+ } else {
1133
+ setState({
1134
+ data: null,
1135
+ loading: false,
1136
+ error: new Error(result.message || "Erreur lors du chargement des conversations")
1137
+ });
1138
+ }
1139
+ } catch (error) {
1140
+ setState({
1141
+ data: null,
1142
+ loading: false,
1143
+ error: error instanceof Error ? error : new Error("Erreur inconnue")
1144
+ });
1145
+ }
1146
+ }, [chat, inputKey]);
1147
+ import_react2.useEffect(() => {
1148
+ if (autoLoad !== false && inputKey) {
1149
+ loadConversations();
1150
+ }
1151
+ }, [loadConversations, autoLoad, inputKey]);
1152
+ const conversations = storeConversations.length > 0 ? storeConversations : state.data || [];
1153
+ return {
1154
+ conversations,
1155
+ loading: state.loading,
1156
+ error: state.error,
1157
+ refetch: loadConversations
1158
+ };
1159
+ }
1160
+ // src/hooks/useConversationsWithLastMessages.ts
1161
+ var import_react3 = __toESM(require_react(), 1);
1162
+ function useConversationsWithLastMessages(input, options) {
1163
+ const chat = useChat();
1164
+ const [state, setState] = import_react3.useState({
1165
+ data: null,
1166
+ loading: false,
1167
+ error: null
1168
+ });
1169
+ const inputKey = input ? JSON.stringify(input) : null;
1170
+ const autoLoad = options?.autoLoad;
1171
+ const lastResultRef = import_react3.useRef([]);
1172
+ const storeData = import_react3.useSyncExternalStore((onStoreChange) => chat.store.subscribe(onStoreChange), () => {
1173
+ const conversations = chat.store.conversations();
1174
+ const result = conversations.map((conversation) => ({
1175
+ conversation,
1176
+ lastMessage: chat.store.lastMessage(conversation.id)
1177
+ }));
1178
+ const hasChanged = result.length !== lastResultRef.current.length || result.some((item, idx) => {
1179
+ const prev = lastResultRef.current[idx];
1180
+ if (!prev)
1181
+ return true;
1182
+ if (prev.conversation.id !== item.conversation.id || prev.conversation.lastMessageAt?.getTime() !== item.conversation.lastMessageAt?.getTime()) {
1183
+ return true;
1184
+ }
1185
+ if (prev.lastMessage?.id !== item.lastMessage?.id || prev.lastMessage?.status !== item.lastMessage?.status || prev.lastMessage?.content !== item.lastMessage?.content) {
1186
+ return true;
1187
+ }
1188
+ return false;
1189
+ });
1190
+ if (!hasChanged) {
1191
+ return lastResultRef.current;
1192
+ }
1193
+ lastResultRef.current = result;
1194
+ return result;
1195
+ });
1196
+ const loadConversations = import_react3.useCallback(async () => {
1197
+ if (!input?.userId) {
1198
+ setState((prev) => ({ ...prev, loading: false }));
1199
+ return;
1200
+ }
1201
+ setState((prev) => ({ ...prev, loading: true, error: null }));
1202
+ try {
1203
+ const result = await chat.getConversations(input);
1204
+ if (result.ok) {
1205
+ setState({
1206
+ data: null,
1207
+ loading: false,
1208
+ error: null
1209
+ });
1210
+ } else {
1211
+ setState({
1212
+ data: null,
1213
+ loading: false,
1214
+ error: new Error(result.message || "Erreur lors du chargement des conversations")
1215
+ });
1216
+ }
1217
+ } catch (error) {
1218
+ setState({
1219
+ data: null,
1220
+ loading: false,
1221
+ error: error instanceof Error ? error : new Error("Erreur inconnue")
1222
+ });
1223
+ }
1224
+ }, [chat, inputKey]);
1225
+ import_react3.useEffect(() => {
1226
+ if (autoLoad !== false && inputKey) {
1227
+ loadConversations();
1228
+ }
1229
+ }, [loadConversations, autoLoad, inputKey]);
1230
+ return {
1231
+ conversationsWithLastMessages: storeData,
1232
+ loading: state.loading,
1233
+ error: state.error,
1234
+ refetch: loadConversations
1235
+ };
1236
+ }
1237
+ // src/hooks/useConversation.ts
1238
+ var import_react4 = __toESM(require_react(), 1);
1239
+ function useConversation(conversationId) {
1240
+ const chat = useChat();
1241
+ const lastValueRef = import_react4.useRef(undefined);
1242
+ const lastIdRef = import_react4.useRef(undefined);
1243
+ return import_react4.useSyncExternalStore((onStoreChange) => chat.store.subscribe(onStoreChange), () => {
1244
+ if (!conversationId) {
1245
+ const value = undefined;
1246
+ if (lastIdRef.current !== undefined) {
1247
+ lastIdRef.current = undefined;
1248
+ lastValueRef.current = value;
1249
+ }
1250
+ return value;
1251
+ }
1252
+ if (lastIdRef.current !== conversationId) {
1253
+ const conversations2 = chat.store.conversations();
1254
+ const found2 = conversations2.find((conv) => conv.id === conversationId);
1255
+ lastIdRef.current = conversationId;
1256
+ lastValueRef.current = found2;
1257
+ return found2;
1258
+ }
1259
+ const conversations = chat.store.conversations();
1260
+ const found = conversations.find((conv) => conv.id === conversationId);
1261
+ if (found === lastValueRef.current) {
1262
+ return lastValueRef.current;
1263
+ }
1264
+ lastValueRef.current = found;
1265
+ return found;
1266
+ });
1267
+ }
1268
+ // src/hooks/useMessages.ts
1269
+ var import_react6 = __toESM(require_react(), 1);
1270
+
1271
+ // src/hooks/useChatStore.ts
1272
+ var import_react5 = __toESM(require_react(), 1);
1273
+ function useChatStore() {
1274
+ const chat = useChat();
1275
+ return import_react5.useSyncExternalStore((onStoreChange) => {
1276
+ return chat.store.subscribe(onStoreChange);
1277
+ }, () => {
1278
+ return chat.store.getSnapshot();
1279
+ });
1280
+ }
1281
+
1282
+ // src/hooks/useMessages.ts
1283
+ function useMessages(conversationId, userId, input, options) {
1284
+ const chat = useChat();
1285
+ const store = useChatStore();
1286
+ const [state, setState] = import_react6.useState({
1287
+ data: null,
1288
+ loading: false,
1289
+ error: null
1290
+ });
1291
+ const inputKey = input ? JSON.stringify(input) : null;
1292
+ const autoLoad = options?.autoLoad;
1293
+ const loadMessages = import_react6.useCallback(async () => {
1294
+ setState((prev) => ({ ...prev, loading: true, error: null }));
1295
+ try {
1296
+ const result = await chat.getMessages({
1297
+ conversationId,
1298
+ userId,
1299
+ options: input?.options
1300
+ });
1301
+ if (result.ok) {
1302
+ setState({
1303
+ data: result.value,
1304
+ loading: false,
1305
+ error: null
1306
+ });
1307
+ } else {
1308
+ setState({
1309
+ data: null,
1310
+ loading: false,
1311
+ error: new Error(result.message || "Erreur lors du chargement des messages")
1312
+ });
1313
+ }
1314
+ } catch (error) {
1315
+ setState({
1316
+ data: null,
1317
+ loading: false,
1318
+ error: error instanceof Error ? error : new Error("Erreur inconnue")
1319
+ });
1320
+ }
1321
+ }, [chat, conversationId, userId, inputKey]);
1322
+ import_react6.useEffect(() => {
1323
+ if (autoLoad !== false) {
1324
+ loadMessages();
1325
+ }
1326
+ }, [loadMessages, autoLoad]);
1327
+ const storeMessages = store.messages[conversationId] || [];
1328
+ const messages = storeMessages.length > 0 ? storeMessages : state.data || [];
1329
+ return {
1330
+ messages,
1331
+ loading: state.loading,
1332
+ error: state.error,
1333
+ refetch: loadMessages
1334
+ };
1335
+ }
1336
+ // src/hooks/useMessage.ts
1337
+ var import_react7 = __toESM(require_react(), 1);
1338
+ function useMessage(messageId) {
1339
+ const store = useChatStore();
1340
+ return import_react7.useMemo(() => {
1341
+ if (!messageId)
1342
+ return;
1343
+ for (const conversationId in store.messages) {
1344
+ const messages = store.messages[conversationId];
1345
+ if (!messages)
1346
+ continue;
1347
+ const found = messages.find((msg) => msg.id === messageId);
1348
+ if (found) {
1349
+ return found;
1350
+ }
1351
+ }
1352
+ return;
1353
+ }, [store.messages, messageId]);
1354
+ }
1355
+ // src/hooks/useLastMessage.ts
1356
+ var import_react8 = __toESM(require_react(), 1);
1357
+ function useLastMessage(conversationId) {
1358
+ const chat = useChat();
1359
+ const lastValueRef = import_react8.useRef(undefined);
1360
+ const lastIdRef = import_react8.useRef(undefined);
1361
+ return import_react8.useSyncExternalStore((onStoreChange) => chat.store.subscribe(onStoreChange), () => {
1362
+ if (!conversationId) {
1363
+ if (lastIdRef.current !== undefined) {
1364
+ lastIdRef.current = undefined;
1365
+ lastValueRef.current = undefined;
1366
+ }
1367
+ return;
1368
+ }
1369
+ const msg = chat.store.lastMessage(conversationId);
1370
+ const cached = lastValueRef.current;
1371
+ if (lastIdRef.current !== conversationId) {
1372
+ lastIdRef.current = conversationId;
1373
+ lastValueRef.current = msg ? { ...msg } : undefined;
1374
+ return lastValueRef.current;
1375
+ }
1376
+ if (!msg && !cached) {
1377
+ return;
1378
+ }
1379
+ if (!msg || !cached) {
1380
+ lastValueRef.current = msg ? { ...msg } : undefined;
1381
+ return lastValueRef.current;
1382
+ }
1383
+ if (msg.id === cached.id && msg.status === cached.status && msg.content === cached.content && msg.type === cached.type) {
1384
+ return cached;
1385
+ }
1386
+ lastValueRef.current = { ...msg };
1387
+ return lastValueRef.current;
1388
+ });
1389
+ }
1390
+ // src/hooks/useTyping.ts
1391
+ function useTyping(conversationId) {
1392
+ const store = useChatStore();
1393
+ return store.typing[conversationId] || [];
1394
+ }
1395
+ // src/hooks/usePresence.ts
1396
+ function usePresence(userId) {
1397
+ const store = useChatStore();
1398
+ return store.presence[userId];
1399
+ }
1400
+ // src/hooks/useMessagesPagination.ts
1401
+ var import_react9 = __toESM(require_react(), 1);
1402
+ var MESSAGES_PER_PAGE = 50;
1403
+ var defaultPagination = {
1404
+ loading: false,
1405
+ loadingMore: false,
1406
+ hasMore: true,
1407
+ error: null
1408
+ };
1409
+ function useMessagesPagination({
1410
+ conversationId,
1411
+ userId,
1412
+ autoLoad = true
1413
+ }) {
1414
+ const chat = useChat();
1415
+ const lastPaginationRef = import_react9.useRef(undefined);
1416
+ const lastConversationIdRefPagination = import_react9.useRef(undefined);
1417
+ const hasLoadedRef = import_react9.useRef(false);
1418
+ const prevConversationIdRef = import_react9.useRef(undefined);
1419
+ const messagesCache = import_react9.useRef(null);
1420
+ const emptyArray = import_react9.useRef([]);
1421
+ const messages = import_react9.useSyncExternalStore((onStoreChange) => chat.store.subscribe(onStoreChange), () => {
1422
+ if (!conversationId) {
1423
+ return emptyArray.current;
1424
+ }
1425
+ const storeMessages = chat.store.messages(conversationId);
1426
+ if (!storeMessages || storeMessages.length === 0) {
1427
+ return emptyArray.current;
1428
+ }
1429
+ if (messagesCache.current?.conversationId !== conversationId) {
1430
+ messagesCache.current = {
1431
+ conversationId,
1432
+ messages: storeMessages
1433
+ };
1434
+ return storeMessages;
1435
+ }
1436
+ if (messagesCache.current.messages !== storeMessages) {
1437
+ messagesCache.current = {
1438
+ conversationId,
1439
+ messages: storeMessages
1440
+ };
1441
+ return storeMessages;
1442
+ }
1443
+ return messagesCache.current.messages;
1444
+ });
1445
+ const pagination = import_react9.useSyncExternalStore((onStoreChange) => chat.store.subscribe(onStoreChange), () => {
1446
+ if (!conversationId) {
1447
+ return;
1448
+ }
1449
+ const pag = chat.store.pagination(conversationId);
1450
+ if (lastConversationIdRefPagination.current !== conversationId) {
1451
+ lastConversationIdRefPagination.current = conversationId;
1452
+ lastPaginationRef.current = pag;
1453
+ return pag;
1454
+ }
1455
+ if (pag === lastPaginationRef.current) {
1456
+ return lastPaginationRef.current;
1457
+ }
1458
+ if (pag && lastPaginationRef.current && pag.loading === lastPaginationRef.current.loading && pag.loadingMore === lastPaginationRef.current.loadingMore && pag.hasMore === lastPaginationRef.current.hasMore && pag.error === lastPaginationRef.current.error) {
1459
+ return lastPaginationRef.current;
1460
+ }
1461
+ lastPaginationRef.current = pag;
1462
+ return pag;
1463
+ });
1464
+ import_react9.useEffect(() => {
1465
+ if (prevConversationIdRef.current !== conversationId) {
1466
+ hasLoadedRef.current = false;
1467
+ prevConversationIdRef.current = conversationId;
1468
+ }
1469
+ if (autoLoad && conversationId && !pagination?.loading && !hasLoadedRef.current && pagination?.hasMore !== false && !pagination?.error) {
1470
+ hasLoadedRef.current = true;
1471
+ chat.getMessages({
1472
+ conversationId,
1473
+ userId,
1474
+ options: { limit: MESSAGES_PER_PAGE }
1475
+ });
1476
+ }
1477
+ }, [autoLoad, conversationId, userId, pagination?.loading, pagination?.hasMore, pagination?.error, chat]);
1478
+ const loadMoreMessages = import_react9.useCallback(() => {
1479
+ if (!conversationId || pagination?.loadingMore || !pagination?.hasMore || messages.length === 0 || pagination?.loading) {
1480
+ return;
1481
+ }
1482
+ const oldestMessage = messages[messages.length - 1];
1483
+ if (!oldestMessage) {
1484
+ return;
1485
+ }
1486
+ chat.getMessages({
1487
+ conversationId,
1488
+ userId,
1489
+ options: {
1490
+ limit: MESSAGES_PER_PAGE,
1491
+ before: oldestMessage.sentAt
1492
+ }
1493
+ });
1494
+ }, [conversationId, userId, messages, pagination, chat]);
1495
+ const paginationState = pagination ?? defaultPagination;
1496
+ return {
1497
+ messages,
1498
+ loading: paginationState.loading,
1499
+ error: paginationState.error ? new Error(paginationState.error) : null,
1500
+ loadingMore: paginationState.loadingMore,
1501
+ hasMoreMessages: paginationState.hasMore,
1502
+ loadMoreMessages
1503
+ };
1504
+ }
1505
+ // src/hooks/useSendMessage.ts
1506
+ var import_react10 = __toESM(require_react(), 1);
1507
+ function useSendMessage() {
1508
+ const chat = useChat();
1509
+ const [state, setState] = import_react10.useState({
1510
+ loading: false,
1511
+ error: null
1512
+ });
1513
+ const sendMessage = import_react10.useCallback(async (input) => {
1514
+ setState({ loading: true, error: null });
1515
+ try {
1516
+ const result = await chat.sendMessage(input);
1517
+ if (result.ok) {
1518
+ setState({ loading: false, error: null });
1519
+ } else {
1520
+ const error = new Error(result.message || "Erreur lors de l'envoi du message");
1521
+ setState({ loading: false, error });
1522
+ }
1523
+ return result;
1524
+ } catch (error) {
1525
+ const err = error instanceof Error ? error : new Error("Erreur inconnue");
1526
+ setState({ loading: false, error: err });
1527
+ return {
1528
+ ok: false,
1529
+ error: "SEND_ERROR",
1530
+ message: err.message
1531
+ };
1532
+ }
1533
+ }, [chat]);
1534
+ return {
1535
+ sendMessage,
1536
+ loading: state.loading,
1537
+ error: state.error
1538
+ };
1539
+ }
1540
+ // src/hooks/useCreateConversation.ts
1541
+ var import_react11 = __toESM(require_react(), 1);
1542
+ function useCreateConversation() {
1543
+ const chat = useChat();
1544
+ const [state, setState] = import_react11.useState({
1545
+ loading: false,
1546
+ error: null
1547
+ });
1548
+ const createConversation = import_react11.useCallback(async (input) => {
1549
+ setState({ loading: true, error: null });
1550
+ try {
1551
+ const result = await chat.createConversation(input);
1552
+ if (result.ok) {
1553
+ setState({ loading: false, error: null });
1554
+ } else {
1555
+ const error = new Error(result.message || "Erreur lors de la création de la conversation");
1556
+ setState({ loading: false, error });
1557
+ }
1558
+ return result;
1559
+ } catch (error) {
1560
+ const err = error instanceof Error ? error : new Error("Erreur inconnue");
1561
+ setState({ loading: false, error: err });
1562
+ return {
1563
+ ok: false,
1564
+ error: "CREATE_ERROR",
1565
+ message: err.message
1566
+ };
1567
+ }
1568
+ }, [chat]);
1569
+ return {
1570
+ createConversation,
1571
+ loading: state.loading,
1572
+ error: state.error
1573
+ };
1574
+ }
1575
+ // src/hooks/useEditMessage.ts
1576
+ var import_react12 = __toESM(require_react(), 1);
1577
+ function useEditMessage() {
1578
+ const chat = useChat();
1579
+ const [state, setState] = import_react12.useState({
1580
+ loading: false,
1581
+ error: null
1582
+ });
1583
+ const editMessage = import_react12.useCallback(async (input) => {
1584
+ setState({ loading: true, error: null });
1585
+ try {
1586
+ const result = await chat.editMessage(input);
1587
+ if (result.ok) {
1588
+ setState({ loading: false, error: null });
1589
+ } else {
1590
+ const error = new Error(result.message || "Erreur lors de l'édition du message");
1591
+ setState({ loading: false, error });
1592
+ }
1593
+ return result;
1594
+ } catch (error) {
1595
+ const err = error instanceof Error ? error : new Error("Erreur inconnue");
1596
+ setState({ loading: false, error: err });
1597
+ return {
1598
+ ok: false,
1599
+ error: "UPDATE_ERROR",
1600
+ message: err.message
1601
+ };
1602
+ }
1603
+ }, [chat]);
1604
+ return {
1605
+ editMessage,
1606
+ loading: state.loading,
1607
+ error: state.error
1608
+ };
1609
+ }
1610
+ // src/hooks/useDeleteMessage.ts
1611
+ var import_react13 = __toESM(require_react(), 1);
1612
+ function useDeleteMessage() {
1613
+ const chat = useChat();
1614
+ const [state, setState] = import_react13.useState({
1615
+ loading: false,
1616
+ error: null
1617
+ });
1618
+ const deleteMessage = import_react13.useCallback(async (input) => {
1619
+ setState({ loading: true, error: null });
1620
+ try {
1621
+ const result = await chat.deleteMessage(input);
1622
+ if (result.ok) {
1623
+ setState({ loading: false, error: null });
1624
+ } else {
1625
+ const error = new Error(result.message || "Erreur lors de la suppression du message");
1626
+ setState({ loading: false, error });
1627
+ }
1628
+ return result;
1629
+ } catch (error) {
1630
+ const err = error instanceof Error ? error : new Error("Erreur inconnue");
1631
+ setState({ loading: false, error: err });
1632
+ return {
1633
+ ok: false,
1634
+ error: "DELETE_ERROR",
1635
+ message: err.message
1636
+ };
1637
+ }
1638
+ }, [chat]);
1639
+ return {
1640
+ deleteMessage,
1641
+ loading: state.loading,
1642
+ error: state.error
1643
+ };
1644
+ }
1645
+ // src/hooks/useMarkMessageAsRead.ts
1646
+ var import_react14 = __toESM(require_react(), 1);
1647
+ function useMarkMessageAsRead() {
1648
+ const chat = useChat();
1649
+ const [state, setState] = import_react14.useState({
1650
+ loading: false,
1651
+ error: null
1652
+ });
1653
+ const markAsRead = import_react14.useCallback(async (input) => {
1654
+ setState({ loading: true, error: null });
1655
+ try {
1656
+ const result = await chat.markMessageAsRead(input);
1657
+ if (result.ok) {
1658
+ setState({ loading: false, error: null });
1659
+ } else {
1660
+ const error = new Error(result.message || "Erreur lors du marquage du message comme lu");
1661
+ setState({ loading: false, error });
1662
+ }
1663
+ return result;
1664
+ } catch (error) {
1665
+ const err = error instanceof Error ? error : new Error("Erreur inconnue");
1666
+ setState({ loading: false, error: err });
1667
+ return {
1668
+ ok: false,
1669
+ error: "UPDATE_ERROR",
1670
+ message: err.message
1671
+ };
1672
+ }
1673
+ }, [chat]);
1674
+ return {
1675
+ markAsRead,
1676
+ loading: state.loading,
1677
+ error: state.error
1678
+ };
1679
+ }
1680
+ // src/hooks/useSubscribeToConversation.ts
1681
+ var import_react15 = __toESM(require_react(), 1);
1682
+ function useSubscribeToConversation(conversationId, options = {}) {
1683
+ const { enabled = true, userId } = options;
1684
+ const chat = useChat();
1685
+ import_react15.useEffect(() => {
1686
+ if (!enabled) {
1687
+ return;
1688
+ }
1689
+ const unsubscribe = chat.subscribeToConversation(conversationId, userId, { markAsRead: true });
1690
+ return unsubscribe;
1691
+ }, [chat, conversationId, enabled, userId]);
1692
+ }
1693
+ // src/hooks/useSubscribeToUser.ts
1694
+ var import_react16 = __toESM(require_react(), 1);
1695
+ function useSubscribeToUser(userId, enabled = true) {
1696
+ const chat = useChat();
1697
+ import_react16.useEffect(() => {
1698
+ if (!enabled) {
1699
+ return;
1700
+ }
1701
+ const unsubscribe = chat.subscribeToUser(userId);
1702
+ return unsubscribe;
1703
+ }, [chat, userId, enabled]);
1704
+ }
1705
+ // src/hooks/useTrackPresence.ts
1706
+ var import_react17 = __toESM(require_react(), 1);
1707
+ function useTrackPresence(userId, enabled = true) {
1708
+ const chat = useChat();
1709
+ import_react17.useEffect(() => {
1710
+ if (!enabled || !userId) {
1711
+ return;
1712
+ }
1713
+ const untrack = chat.trackPresence(userId);
1714
+ return untrack;
1715
+ }, [chat, userId, enabled]);
1716
+ }
1717
+ // src/hooks/useSubscribeToAllConversations.ts
1718
+ var import_react18 = __toESM(require_react(), 1);
1719
+ function useSubscribeToAllConversations({
1720
+ userId,
1721
+ enabled = true
1722
+ }) {
1723
+ const chat = useChat();
1724
+ const unsubscribeFunctionsRef = import_react18.useRef([]);
1725
+ const hasSubscribedRef = import_react18.useRef(false);
1726
+ import_react18.useEffect(() => {
1727
+ if (!enabled || !userId) {
1728
+ return;
1729
+ }
1730
+ if (hasSubscribedRef.current) {
1731
+ return;
1732
+ }
1733
+ chat.getConversations({ userId }).then((result) => {
1734
+ if (!result.ok) {
1735
+ return;
1736
+ }
1737
+ const conversations = result.value;
1738
+ conversations.forEach((conversation) => {
1739
+ const unsubscribe = chat.subscribeToConversation(conversation.id, userId);
1740
+ unsubscribeFunctionsRef.current.push(unsubscribe);
1741
+ });
1742
+ hasSubscribedRef.current = true;
1743
+ }).catch((error) => {
1744
+ console.error("[useSubscribeToAllConversations] Error:", error);
1745
+ });
1746
+ return () => {
1747
+ unsubscribeFunctionsRef.current.forEach((unsubscribe) => unsubscribe());
1748
+ unsubscribeFunctionsRef.current = [];
1749
+ hasSubscribedRef.current = false;
1750
+ };
1751
+ }, [chat, userId, enabled]);
1752
+ }
1753
+ export {
1754
+ useTyping,
1755
+ useTrackPresence,
1756
+ useSubscribeToUser,
1757
+ useSubscribeToConversation,
1758
+ useSubscribeToAllConversations,
1759
+ useSendMessage,
1760
+ usePresence,
1761
+ useMessagesPagination,
1762
+ useMessages,
1763
+ useMessage,
1764
+ useMarkMessageAsRead,
1765
+ useLastMessage,
1766
+ useEditMessage,
1767
+ useDeleteMessage,
1768
+ useCreateConversation,
1769
+ useConversationsWithLastMessages,
1770
+ useConversations,
1771
+ useConversation,
1772
+ useChat,
1773
+ ChatProvider
1774
+ };