@react-devtools-plus/kit 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs ADDED
@@ -0,0 +1,3732 @@
1
+ //#region rolldown:runtime
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __copyProps = (to, from, except, desc) => {
9
+ if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
10
+ key = keys[i];
11
+ if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
12
+ get: ((k) => from[k]).bind(null, key),
13
+ enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
14
+ });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target$1) => (target$1 = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target$1, "default", {
19
+ value: mod,
20
+ enumerable: true
21
+ }) : target$1, mod));
22
+
23
+ //#endregion
24
+ let __react_devtools_plus_shared = require("@react-devtools-plus/shared");
25
+ __react_devtools_plus_shared = __toESM(__react_devtools_plus_shared);
26
+
27
+ //#region src/types/index.ts
28
+ const REACT_TAGS = {
29
+ FunctionComponent: 0,
30
+ ClassComponent: 1,
31
+ IndeterminateComponent: 2,
32
+ HostRoot: 3,
33
+ HostComponent: 5,
34
+ HostText: 6,
35
+ Fragment: 7,
36
+ Mode: 8,
37
+ ContextConsumer: 9,
38
+ ContextProvider: 10,
39
+ ForwardRef: 11,
40
+ SuspenseComponent: 13,
41
+ MemoComponent: 14,
42
+ SimpleMemoComponent: 15
43
+ };
44
+
45
+ //#endregion
46
+ //#region src/core/fiber/utils.ts
47
+ function getDisplayName(fiber) {
48
+ var _resolvedType$render;
49
+ const { elementType, type, tag } = fiber;
50
+ const resolvedType = elementType || type;
51
+ if (!resolvedType) {
52
+ if (tag === REACT_TAGS.HostRoot) return "Root";
53
+ if (tag === REACT_TAGS.HostComponent) return typeof fiber.type === "string" ? fiber.type : "Host";
54
+ return "Unknown";
55
+ }
56
+ if (typeof resolvedType === "string") return resolvedType;
57
+ if (resolvedType.displayName) return resolvedType.displayName;
58
+ if (resolvedType.name) return resolvedType.name;
59
+ if (resolvedType.__name) return resolvedType.__name;
60
+ if (resolvedType.type) {
61
+ const innerType = resolvedType.type;
62
+ if (innerType === null || innerType === void 0 ? void 0 : innerType.displayName) return innerType.displayName;
63
+ if (innerType === null || innerType === void 0 ? void 0 : innerType.name) return innerType.name;
64
+ if (innerType === null || innerType === void 0 ? void 0 : innerType.__name) return innerType.__name;
65
+ }
66
+ if ((_resolvedType$render = resolvedType.render) === null || _resolvedType$render === void 0 ? void 0 : _resolvedType$render.name) return resolvedType.render.name;
67
+ if (typeof resolvedType === "function") {
68
+ const funcName = resolvedType.name;
69
+ if (funcName && funcName !== "") return funcName;
70
+ }
71
+ return "Anonymous";
72
+ }
73
+ function shouldIncludeFiber(fiber, showHostComponents) {
74
+ if (fiber.tag === REACT_TAGS.HostText) return false;
75
+ if (fiber.tag === REACT_TAGS.Fragment || fiber.tag === REACT_TAGS.Mode || fiber.tag === REACT_TAGS.HostRoot) return false;
76
+ if (!showHostComponents && fiber.tag === REACT_TAGS.HostComponent) return false;
77
+ return [
78
+ REACT_TAGS.HostComponent,
79
+ REACT_TAGS.FunctionComponent,
80
+ REACT_TAGS.ClassComponent,
81
+ REACT_TAGS.ForwardRef,
82
+ REACT_TAGS.MemoComponent,
83
+ REACT_TAGS.SimpleMemoComponent,
84
+ REACT_TAGS.IndeterminateComponent,
85
+ REACT_TAGS.ContextProvider,
86
+ REACT_TAGS.ContextConsumer,
87
+ REACT_TAGS.SuspenseComponent
88
+ ].includes(fiber.tag);
89
+ }
90
+ let fiberIdCounter = 0;
91
+ const fiberIdMap = /* @__PURE__ */ new WeakMap();
92
+ function getFiberId(fiber) {
93
+ if (!fiberIdMap.has(fiber)) fiberIdMap.set(fiber, `react-fiber-${++fiberIdCounter}`);
94
+ return fiberIdMap.get(fiber);
95
+ }
96
+ function getFiberFromElement(element) {
97
+ const keys = Object.keys(element);
98
+ for (const key of keys) {
99
+ if (key.startsWith("__reactFiber")) return element[key];
100
+ if (key.startsWith("__reactInternalInstance")) return element[key];
101
+ }
102
+ return null;
103
+ }
104
+
105
+ //#endregion
106
+ //#region src/core/context/index.ts
107
+ /**
108
+ * Serialize a value into a displayable PropValue
109
+ */
110
+ function serializeValue$1(value, depth = 0, maxDepth = 6) {
111
+ if (value === null) return {
112
+ type: "null",
113
+ value: "null"
114
+ };
115
+ if (value === void 0) return {
116
+ type: "undefined",
117
+ value: "undefined"
118
+ };
119
+ const type = typeof value;
120
+ if (type === "string") return {
121
+ type: "string",
122
+ value: `"${value.length > 100 ? `${value.slice(0, 100)}...` : value}"`
123
+ };
124
+ if (type === "number") return {
125
+ type: "number",
126
+ value: String(value)
127
+ };
128
+ if (type === "boolean") return {
129
+ type: "boolean",
130
+ value: String(value)
131
+ };
132
+ if (type === "function") return {
133
+ type: "function",
134
+ value: `ƒ ${value.name || "anonymous"}()`
135
+ };
136
+ if (type === "symbol") return {
137
+ type: "symbol",
138
+ value: value.toString()
139
+ };
140
+ if (depth > maxDepth) {
141
+ if (Array.isArray(value)) return {
142
+ type: "array",
143
+ value: `Array(${value.length})`
144
+ };
145
+ return {
146
+ type: "object",
147
+ value: "Object"
148
+ };
149
+ }
150
+ if (Array.isArray(value)) {
151
+ const children = {};
152
+ value.forEach((item, index) => {
153
+ children[String(index)] = serializeValue$1(item, depth + 1, maxDepth);
154
+ });
155
+ return {
156
+ type: "array",
157
+ value: `Array(${value.length})`,
158
+ children: Object.keys(children).length > 0 ? children : void 0
159
+ };
160
+ }
161
+ if (type === "object") {
162
+ if (value.$$typeof) {
163
+ var _value$type, _value$type2;
164
+ return {
165
+ type: "element",
166
+ value: `<${((_value$type = value.type) === null || _value$type === void 0 ? void 0 : _value$type.displayName) || ((_value$type2 = value.type) === null || _value$type2 === void 0 ? void 0 : _value$type2.name) || value.type || "Unknown"} />`
167
+ };
168
+ }
169
+ const keys = Object.keys(value);
170
+ const children = {};
171
+ for (const key of keys) try {
172
+ children[key] = serializeValue$1(value[key], depth + 1, maxDepth);
173
+ } catch (_unused) {
174
+ children[key] = {
175
+ type: "unknown",
176
+ value: "[Error]"
177
+ };
178
+ }
179
+ return {
180
+ type: "object",
181
+ value: `Object`,
182
+ preview: keys.length > 0 ? `{${keys.slice(0, 3).join(", ")}${keys.length > 3 ? ", ..." : ""}}` : "{}",
183
+ children: Object.keys(children).length > 0 ? children : void 0
184
+ };
185
+ }
186
+ return {
187
+ type: "unknown",
188
+ value: String(value)
189
+ };
190
+ }
191
+ /**
192
+ * Get the display name of a Context
193
+ */
194
+ function getContextDisplayName(fiber) {
195
+ var _fiber$type, _contextType$Provider, _contextType$Consumer;
196
+ const contextType = ((_fiber$type = fiber.type) === null || _fiber$type === void 0 ? void 0 : _fiber$type._context) || fiber.type;
197
+ if (!contextType) return "Unknown Context";
198
+ if (contextType.displayName) return contextType.displayName;
199
+ if ((_contextType$Provider = contextType.Provider) === null || _contextType$Provider === void 0 ? void 0 : _contextType$Provider.displayName) return contextType.Provider.displayName.replace(".Provider", "");
200
+ if ((_contextType$Consumer = contextType.Consumer) === null || _contextType$Consumer === void 0 ? void 0 : _contextType$Consumer.displayName) return contextType.Consumer.displayName.replace(".Consumer", "");
201
+ const componentName = getDisplayName(fiber);
202
+ if (componentName && componentName !== "Anonymous") return componentName.replace(".Provider", "").replace(".Consumer", "");
203
+ return "Context";
204
+ }
205
+ /**
206
+ * Get the context value from a Provider fiber
207
+ */
208
+ function getContextValue(fiber) {
209
+ if (fiber.memoizedProps && "value" in fiber.memoizedProps) return fiber.memoizedProps.value;
210
+ }
211
+ /**
212
+ * Check if a fiber is a Context Provider
213
+ */
214
+ function isContextProvider(fiber) {
215
+ return fiber.tag === REACT_TAGS.ContextProvider;
216
+ }
217
+ /**
218
+ * Find all consumers of a specific context type
219
+ */
220
+ function findConsumers(fiber, contextType, consumers, visited) {
221
+ if (!fiber || visited.has(fiber)) return;
222
+ visited.add(fiber);
223
+ if (fiber.tag === REACT_TAGS.ContextConsumer) {
224
+ var _fiber$type2;
225
+ if ((((_fiber$type2 = fiber.type) === null || _fiber$type2 === void 0 ? void 0 : _fiber$type2._context) || fiber.type) === contextType) consumers.push({
226
+ id: getFiberId(fiber),
227
+ name: getDisplayName(fiber),
228
+ fiberId: getFiberId(fiber)
229
+ });
230
+ }
231
+ if (fiber.tag === REACT_TAGS.FunctionComponent || fiber.tag === REACT_TAGS.ForwardRef || fiber.tag === REACT_TAGS.MemoComponent || fiber.tag === REACT_TAGS.SimpleMemoComponent) {
232
+ let hookState = fiber.memoizedState;
233
+ while (hookState) {
234
+ if (hookState.memoizedState !== void 0) {
235
+ const dependencies = fiber.dependencies;
236
+ if (dependencies === null || dependencies === void 0 ? void 0 : dependencies.firstContext) {
237
+ let contextItem = dependencies.firstContext;
238
+ while (contextItem) {
239
+ if (contextItem.context === contextType) {
240
+ consumers.push({
241
+ id: getFiberId(fiber),
242
+ name: getDisplayName(fiber),
243
+ fiberId: getFiberId(fiber)
244
+ });
245
+ break;
246
+ }
247
+ contextItem = contextItem.next;
248
+ }
249
+ }
250
+ }
251
+ hookState = hookState.next;
252
+ }
253
+ }
254
+ if (fiber.child) findConsumers(fiber.child, contextType, consumers, visited);
255
+ if (fiber.sibling) findConsumers(fiber.sibling, contextType, consumers, visited);
256
+ }
257
+ /**
258
+ * Build context provider info from a fiber
259
+ */
260
+ function buildProviderInfo(fiber, visited) {
261
+ var _fiber$type3;
262
+ if (!isContextProvider(fiber)) return null;
263
+ const contextType = (_fiber$type3 = fiber.type) === null || _fiber$type3 === void 0 ? void 0 : _fiber$type3._context;
264
+ const consumers = [];
265
+ if (fiber.child) findConsumers(fiber.child, contextType, consumers, /* @__PURE__ */ new WeakSet());
266
+ const uniqueConsumers = consumers.filter((consumer, index, self) => index === self.findIndex((c) => c.id === consumer.id));
267
+ const info = {
268
+ id: getFiberId(fiber),
269
+ name: getContextDisplayName(fiber),
270
+ value: serializeValue$1(getContextValue(fiber)),
271
+ fiberId: getFiberId(fiber),
272
+ consumerCount: uniqueConsumers.length,
273
+ consumers: uniqueConsumers,
274
+ children: [],
275
+ source: fiber._debugSource ? {
276
+ fileName: fiber._debugSource.fileName,
277
+ lineNumber: fiber._debugSource.lineNumber,
278
+ columnNumber: fiber._debugSource.columnNumber
279
+ } : void 0
280
+ };
281
+ const findNestedProviders = (child) => {
282
+ var _child$type;
283
+ if (!child || visited.has(child)) return;
284
+ visited.add(child);
285
+ if (isContextProvider(child) && ((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type._context) === contextType) {
286
+ const nestedInfo = buildProviderInfo(child, visited);
287
+ if (nestedInfo) info.children.push(nestedInfo);
288
+ } else {
289
+ if (child.child) findNestedProviders(child.child);
290
+ if (child.sibling) findNestedProviders(child.sibling);
291
+ }
292
+ };
293
+ if (fiber.child) findNestedProviders(fiber.child);
294
+ return info;
295
+ }
296
+ /**
297
+ * Collect all context providers from the fiber tree
298
+ */
299
+ function collectProviders(fiber, providers, visited, processedContextTypes) {
300
+ if (!fiber || visited.has(fiber)) return;
301
+ visited.add(fiber);
302
+ if (isContextProvider(fiber)) {
303
+ var _fiber$type4;
304
+ const contextType = (_fiber$type4 = fiber.type) === null || _fiber$type4 === void 0 ? void 0 : _fiber$type4._context;
305
+ if (contextType && !processedContextTypes.has(contextType)) {
306
+ const info = buildProviderInfo(fiber, new WeakSet([fiber]));
307
+ if (info) {
308
+ providers.push(info);
309
+ processedContextTypes.add(contextType);
310
+ }
311
+ }
312
+ }
313
+ if (fiber.child) collectProviders(fiber.child, providers, visited, processedContextTypes);
314
+ if (fiber.sibling) collectProviders(fiber.sibling, providers, visited, processedContextTypes);
315
+ }
316
+ /**
317
+ * Get the context tree from a fiber root
318
+ */
319
+ function getContextTree(root) {
320
+ var _root$current;
321
+ const providers = [];
322
+ const visited = /* @__PURE__ */ new WeakSet();
323
+ const processedContextTypes = /* @__PURE__ */ new Set();
324
+ if (root === null || root === void 0 || (_root$current = root.current) === null || _root$current === void 0 ? void 0 : _root$current.child) collectProviders(root.current.child, providers, visited, processedContextTypes);
325
+ let totalConsumers = 0;
326
+ const countConsumers = (providerList) => {
327
+ for (const provider of providerList) {
328
+ totalConsumers += provider.consumerCount;
329
+ if (provider.children.length > 0) countConsumers(provider.children);
330
+ }
331
+ };
332
+ countConsumers(providers);
333
+ return {
334
+ providers,
335
+ totalProviders: providers.length,
336
+ totalConsumers
337
+ };
338
+ }
339
+ /**
340
+ * Get context info for a specific provider by fiber ID
341
+ */
342
+ function getContextProviderInfo(root, fiberId) {
343
+ const tree = getContextTree(root);
344
+ const findProvider = (providers) => {
345
+ for (const provider of providers) {
346
+ if (provider.fiberId === fiberId) return provider;
347
+ const found = findProvider(provider.children);
348
+ if (found) return found;
349
+ }
350
+ return null;
351
+ };
352
+ return findProvider(tree.providers);
353
+ }
354
+ /**
355
+ * Get all contexts available in the application
356
+ */
357
+ function getAllContexts(root) {
358
+ return getContextTree(root);
359
+ }
360
+
361
+ //#endregion
362
+ //#region src/core/fiber/details.ts
363
+ /**
364
+ * Serialize a value into a displayable PropValue
365
+ */
366
+ function serializeValue(value, depth = 0, maxDepth = 8) {
367
+ if (value === null) return {
368
+ type: "null",
369
+ value: "null"
370
+ };
371
+ if (value === void 0) return {
372
+ type: "undefined",
373
+ value: "undefined"
374
+ };
375
+ const type = typeof value;
376
+ if (type === "string") return {
377
+ type: "string",
378
+ value: `"${value.length > 100 ? `${value.slice(0, 100)}...` : value}"`
379
+ };
380
+ if (type === "number") return {
381
+ type: "number",
382
+ value: String(value)
383
+ };
384
+ if (type === "boolean") return {
385
+ type: "boolean",
386
+ value: String(value)
387
+ };
388
+ if (type === "function") return {
389
+ type: "function",
390
+ value: `ƒ ${value.name || "anonymous"}()`
391
+ };
392
+ if (type === "symbol") return {
393
+ type: "symbol",
394
+ value: value.toString()
395
+ };
396
+ if (depth > maxDepth) {
397
+ if (Array.isArray(value)) return {
398
+ type: "array",
399
+ value: `Array(${value.length})`
400
+ };
401
+ return {
402
+ type: "object",
403
+ value: "Object"
404
+ };
405
+ }
406
+ if (Array.isArray(value)) {
407
+ const children = {};
408
+ value.forEach((item, index) => {
409
+ children[String(index)] = serializeValue(item, depth + 1, maxDepth);
410
+ });
411
+ return {
412
+ type: "array",
413
+ value: `Array(${value.length})`,
414
+ children: Object.keys(children).length > 0 ? children : void 0
415
+ };
416
+ }
417
+ if (type === "object") {
418
+ if (value.$$typeof) {
419
+ var _value$type, _value$type2;
420
+ return {
421
+ type: "element",
422
+ value: `<${((_value$type = value.type) === null || _value$type === void 0 ? void 0 : _value$type.displayName) || ((_value$type2 = value.type) === null || _value$type2 === void 0 ? void 0 : _value$type2.name) || value.type || "Unknown"} />`
423
+ };
424
+ }
425
+ const keys = Object.keys(value);
426
+ const children = {};
427
+ for (const key of keys) try {
428
+ children[key] = serializeValue(value[key], depth + 1, maxDepth);
429
+ } catch (_unused) {
430
+ children[key] = {
431
+ type: "unknown",
432
+ value: "[Error]"
433
+ };
434
+ }
435
+ return {
436
+ type: "object",
437
+ value: `Object`,
438
+ preview: keys.length > 0 ? `{${keys.slice(0, 3).join(", ")}${keys.length > 3 ? ", ..." : ""}}` : "{}",
439
+ children: Object.keys(children).length > 0 ? children : void 0
440
+ };
441
+ }
442
+ return {
443
+ type: "unknown",
444
+ value: String(value)
445
+ };
446
+ }
447
+ /**
448
+ * Extract props from fiber
449
+ */
450
+ function extractProps(fiber) {
451
+ const props = {};
452
+ const memoizedProps = fiber.memoizedProps;
453
+ if (!memoizedProps || typeof memoizedProps !== "object") return props;
454
+ for (const [key, value] of Object.entries(memoizedProps)) {
455
+ if (key === "children") {
456
+ if (value) if (Array.isArray(value)) props[key] = {
457
+ type: "array",
458
+ value: `[${value.length} children]`
459
+ };
460
+ else if (typeof value === "object" && value.$$typeof) {
461
+ var _type, _type2;
462
+ props[key] = {
463
+ type: "element",
464
+ value: `<${((_type = value.type) === null || _type === void 0 ? void 0 : _type.displayName) || ((_type2 = value.type) === null || _type2 === void 0 ? void 0 : _type2.name) || value.type || "Element"} />`
465
+ };
466
+ } else if (typeof value === "string") props[key] = {
467
+ type: "string",
468
+ value: `"${value.slice(0, 50)}${value.length > 50 ? "..." : ""}"`
469
+ };
470
+ else props[key] = serializeValue(value);
471
+ continue;
472
+ }
473
+ props[key] = serializeValue(value);
474
+ }
475
+ return props;
476
+ }
477
+ /**
478
+ * Hook type names from React internals
479
+ */
480
+ const HOOK_NAMES = {
481
+ 0: "useState",
482
+ 1: "useReducer",
483
+ 2: "useContext",
484
+ 3: "useRef",
485
+ 4: "useEffect",
486
+ 5: "useInsertionEffect",
487
+ 6: "useLayoutEffect",
488
+ 7: "useCallback",
489
+ 8: "useMemo",
490
+ 9: "useImperativeHandle",
491
+ 10: "useDebugValue",
492
+ 11: "useDeferredValue",
493
+ 12: "useTransition",
494
+ 13: "useMutableSource",
495
+ 14: "useSyncExternalStore",
496
+ 15: "useId",
497
+ 16: "useCacheRefresh"
498
+ };
499
+ /**
500
+ * Extract hooks from fiber's memoizedState
501
+ */
502
+ function extractHooks(fiber) {
503
+ const hooks = [];
504
+ if (fiber.tag !== REACT_TAGS.FunctionComponent && fiber.tag !== REACT_TAGS.ForwardRef && fiber.tag !== REACT_TAGS.SimpleMemoComponent && fiber.tag !== REACT_TAGS.MemoComponent) return hooks;
505
+ const debugHookTypes = fiber._debugHookTypes;
506
+ let hookState = fiber.memoizedState;
507
+ let hookIndex = 0;
508
+ while (hookState) {
509
+ let hookName = "Hook";
510
+ if (debugHookTypes && debugHookTypes[hookIndex]) hookName = debugHookTypes[hookIndex];
511
+ else if (hookState.tag !== void 0 && HOOK_NAMES[hookState.tag]) hookName = HOOK_NAMES[hookState.tag];
512
+ else if (hookState.queue !== void 0 && hookState.baseState !== void 0) hookName = "useState";
513
+ else if (hookState.memoizedState !== void 0 && hookState.deps !== void 0) hookName = "useMemo/useCallback";
514
+ else if (hookState.current !== void 0) hookName = "useRef";
515
+ let value;
516
+ if (hookName === "useState" || hookName === "useReducer") value = serializeValue(hookState.memoizedState);
517
+ else if (hookName === "useRef") {
518
+ var _hookState$memoizedSt;
519
+ value = serializeValue((_hookState$memoizedSt = hookState.memoizedState) === null || _hookState$memoizedSt === void 0 ? void 0 : _hookState$memoizedSt.current);
520
+ } else if (hookName === "useContext") value = serializeValue(hookState.memoizedState);
521
+ else if (hookName === "useMemo" || hookName === "useCallback" || hookName === "useMemo/useCallback") {
522
+ const memoValue = hookState.memoizedState;
523
+ if (Array.isArray(memoValue) && memoValue.length >= 1) value = serializeValue(memoValue[0]);
524
+ else value = serializeValue(memoValue);
525
+ } else value = {
526
+ type: "unknown",
527
+ value: "..."
528
+ };
529
+ hooks.push({
530
+ name: hookName,
531
+ value
532
+ });
533
+ hookState = hookState.next;
534
+ hookIndex++;
535
+ }
536
+ return hooks;
537
+ }
538
+ /**
539
+ * Extract parent component chain (rendered by)
540
+ */
541
+ function extractRenderedBy(fiber) {
542
+ const renderedBy = [];
543
+ let parent = fiber.return;
544
+ let depth = 0;
545
+ const maxDepth = 10;
546
+ while (parent && depth < maxDepth) {
547
+ if (parent.tag === REACT_TAGS.FunctionComponent || parent.tag === REACT_TAGS.ClassComponent || parent.tag === REACT_TAGS.ForwardRef || parent.tag === REACT_TAGS.MemoComponent || parent.tag === REACT_TAGS.SimpleMemoComponent || parent.tag === REACT_TAGS.ContextProvider) {
548
+ const name = getDisplayName(parent);
549
+ if (name && name !== "Anonymous") renderedBy.push({
550
+ id: getFiberId(parent),
551
+ name,
552
+ tag: parent.tag
553
+ });
554
+ }
555
+ parent = parent.return;
556
+ depth++;
557
+ }
558
+ return renderedBy;
559
+ }
560
+ /**
561
+ * Extract source location from fiber
562
+ */
563
+ function extractSource(fiber) {
564
+ if (fiber._debugSource) return {
565
+ fileName: fiber._debugSource.fileName,
566
+ lineNumber: fiber._debugSource.lineNumber,
567
+ columnNumber: fiber._debugSource.columnNumber
568
+ };
569
+ }
570
+ /**
571
+ * Get detailed information about a component from its fiber
572
+ */
573
+ function getComponentDetails(fiber) {
574
+ return {
575
+ id: getFiberId(fiber),
576
+ name: getDisplayName(fiber),
577
+ tag: fiber.tag,
578
+ props: extractProps(fiber),
579
+ hooks: extractHooks(fiber),
580
+ renderedBy: extractRenderedBy(fiber),
581
+ source: extractSource(fiber),
582
+ key: fiber.key
583
+ };
584
+ }
585
+
586
+ //#endregion
587
+ //#region \0@oxc-project+runtime@0.95.0/helpers/typeof.js
588
+ function _typeof(o) {
589
+ "@babel/helpers - typeof";
590
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o$1) {
591
+ return typeof o$1;
592
+ } : function(o$1) {
593
+ return o$1 && "function" == typeof Symbol && o$1.constructor === Symbol && o$1 !== Symbol.prototype ? "symbol" : typeof o$1;
594
+ }, _typeof(o);
595
+ }
596
+
597
+ //#endregion
598
+ //#region \0@oxc-project+runtime@0.95.0/helpers/toPrimitive.js
599
+ function toPrimitive(t, r) {
600
+ if ("object" != _typeof(t) || !t) return t;
601
+ var e = t[Symbol.toPrimitive];
602
+ if (void 0 !== e) {
603
+ var i = e.call(t, r || "default");
604
+ if ("object" != _typeof(i)) return i;
605
+ throw new TypeError("@@toPrimitive must return a primitive value.");
606
+ }
607
+ return ("string" === r ? String : Number)(t);
608
+ }
609
+
610
+ //#endregion
611
+ //#region \0@oxc-project+runtime@0.95.0/helpers/toPropertyKey.js
612
+ function toPropertyKey(t) {
613
+ var i = toPrimitive(t, "string");
614
+ return "symbol" == _typeof(i) ? i : i + "";
615
+ }
616
+
617
+ //#endregion
618
+ //#region \0@oxc-project+runtime@0.95.0/helpers/defineProperty.js
619
+ function _defineProperty(e, r, t) {
620
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
621
+ value: t,
622
+ enumerable: !0,
623
+ configurable: !0,
624
+ writable: !0
625
+ }) : e[r] = t, e;
626
+ }
627
+
628
+ //#endregion
629
+ //#region \0@oxc-project+runtime@0.95.0/helpers/objectSpread2.js
630
+ function ownKeys(e, r) {
631
+ var t = Object.keys(e);
632
+ if (Object.getOwnPropertySymbols) {
633
+ var o = Object.getOwnPropertySymbols(e);
634
+ r && (o = o.filter(function(r$1) {
635
+ return Object.getOwnPropertyDescriptor(e, r$1).enumerable;
636
+ })), t.push.apply(t, o);
637
+ }
638
+ return t;
639
+ }
640
+ function _objectSpread2(e) {
641
+ for (var r = 1; r < arguments.length; r++) {
642
+ var t = null != arguments[r] ? arguments[r] : {};
643
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r$1) {
644
+ _defineProperty(e, r$1, t[r$1]);
645
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r$1) {
646
+ Object.defineProperty(e, r$1, Object.getOwnPropertyDescriptor(t, r$1));
647
+ });
648
+ }
649
+ return e;
650
+ }
651
+
652
+ //#endregion
653
+ //#region src/core/fiber/highlight.ts
654
+ const CONTAINER_ELEMENT_ID = "__react-devtools-component-inspector__";
655
+ const CARD_ELEMENT_ID = "__react-devtools-component-inspector__card__";
656
+ const COMPONENT_NAME_ELEMENT_ID = "__react-devtools-component-inspector__name__";
657
+ const INDICATOR_ELEMENT_ID = "__react-devtools-component-inspector__indicator__";
658
+ const SOURCE_FILE_ELEMENT_ID = "__react-devtools-component-inspector__source-file__";
659
+ const SOURCE_HINT_ELEMENT_ID = "__react-devtools-component-inspector__source-hint__";
660
+ let highlightHideTimer;
661
+ const containerStyles = {
662
+ display: "block",
663
+ zIndex: "2147483640",
664
+ position: "fixed",
665
+ backgroundColor: "color-mix(in srgb, var(--color-primary-500, #61dafb), transparent 85%)",
666
+ border: "1px solid color-mix(in srgb, var(--color-primary-500, #61dafb), transparent 50%)",
667
+ borderRadius: "5px",
668
+ transition: "all 0.1s ease-in",
669
+ pointerEvents: "none"
670
+ };
671
+ const baseCardStyles = {
672
+ fontFamily: "Arial, Helvetica, sans-serif",
673
+ padding: "5px 8px",
674
+ borderRadius: "4px",
675
+ textAlign: "left",
676
+ position: "absolute",
677
+ left: "0",
678
+ color: "#fff",
679
+ fontSize: "14px",
680
+ fontWeight: "600",
681
+ lineHeight: "24px",
682
+ backgroundColor: "var(--color-primary-500, #61dafb)",
683
+ boxShadow: "0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1)",
684
+ whiteSpace: "nowrap"
685
+ };
686
+ const cardStyles = _objectSpread2({}, baseCardStyles);
687
+ const sourceCardStyles = _objectSpread2(_objectSpread2({}, baseCardStyles), {}, {
688
+ fontFamily: "Menlo, Monaco, Consolas, \"Courier New\", monospace",
689
+ padding: "6px 10px",
690
+ boxShadow: "0 4px 12px rgba(0, 0, 0, 0.15)",
691
+ display: "flex",
692
+ flexDirection: "column",
693
+ gap: "2px"
694
+ });
695
+ const indicatorStyles = {
696
+ display: "inline-block",
697
+ fontWeight: "400",
698
+ fontStyle: "normal",
699
+ fontSize: "12px",
700
+ opacity: "0.7",
701
+ marginLeft: "6px"
702
+ };
703
+ const sourceFileStyles = {
704
+ fontSize: "12px",
705
+ fontWeight: "500"
706
+ };
707
+ const sourceHintStyles = {
708
+ fontSize: "10px",
709
+ opacity: "0.8",
710
+ fontWeight: "normal"
711
+ };
712
+ function getContainerElement() {
713
+ return document.getElementById(CONTAINER_ELEMENT_ID);
714
+ }
715
+ function createHighlightElement(rect, name, source) {
716
+ const containerEl = document.createElement("div");
717
+ containerEl.id = CONTAINER_ELEMENT_ID;
718
+ Object.assign(containerEl.style, containerStyles);
719
+ const cardEl = document.createElement("div");
720
+ cardEl.id = CARD_ELEMENT_ID;
721
+ if (source) {
722
+ Object.assign(cardEl.style, sourceCardStyles);
723
+ const sourceFileEl = document.createElement("div");
724
+ sourceFileEl.id = SOURCE_FILE_ELEMENT_ID;
725
+ Object.assign(sourceFileEl.style, sourceFileStyles);
726
+ cardEl.appendChild(sourceFileEl);
727
+ const sourceHintEl = document.createElement("div");
728
+ sourceHintEl.id = SOURCE_HINT_ELEMENT_ID;
729
+ Object.assign(sourceHintEl.style, sourceHintStyles);
730
+ sourceHintEl.textContent = "Click to go to the file";
731
+ cardEl.appendChild(sourceHintEl);
732
+ } else {
733
+ Object.assign(cardEl.style, cardStyles);
734
+ const nameEl = document.createElement("span");
735
+ nameEl.id = COMPONENT_NAME_ELEMENT_ID;
736
+ cardEl.appendChild(nameEl);
737
+ const indicatorEl = document.createElement("i");
738
+ indicatorEl.id = INDICATOR_ELEMENT_ID;
739
+ Object.assign(indicatorEl.style, indicatorStyles);
740
+ cardEl.appendChild(indicatorEl);
741
+ }
742
+ containerEl.appendChild(cardEl);
743
+ document.body.appendChild(containerEl);
744
+ updateHighlightElement(rect, name, source);
745
+ return containerEl;
746
+ }
747
+ function updateHighlightElement(rect, name, source) {
748
+ let containerEl = getContainerElement();
749
+ const cardEl = document.getElementById(CARD_ELEMENT_ID);
750
+ const hasSourceElement = document.getElementById(SOURCE_FILE_ELEMENT_ID);
751
+ if (containerEl && (!!source && !hasSourceElement || !source && hasSourceElement)) {
752
+ containerEl.remove();
753
+ containerEl = null;
754
+ }
755
+ if (!containerEl) {
756
+ createHighlightElement(rect, name, source);
757
+ return;
758
+ }
759
+ Object.assign(containerEl.style, {
760
+ left: `${Math.round(rect.left * 100) / 100}px`,
761
+ top: `${Math.round(rect.top * 100) / 100}px`,
762
+ width: `${Math.round(rect.width * 100) / 100}px`,
763
+ height: `${Math.round(rect.height * 100) / 100}px`,
764
+ display: "block",
765
+ opacity: "1",
766
+ backgroundColor: "color-mix(in srgb, var(--color-primary-500, #61dafb), transparent 85%)",
767
+ border: "1px solid color-mix(in srgb, var(--color-primary-500, #61dafb), transparent 50%)"
768
+ });
769
+ if (cardEl) Object.assign(cardEl.style, {
770
+ top: rect.top < 45 ? "100%" : "auto",
771
+ bottom: rect.top < 45 ? "auto" : "100%",
772
+ marginTop: rect.top < 45 ? "4px" : "0",
773
+ marginBottom: rect.top < 45 ? "0" : "4px"
774
+ });
775
+ if (source) {
776
+ const sourceFileEl = document.getElementById(SOURCE_FILE_ELEMENT_ID);
777
+ if (sourceFileEl) {
778
+ let cleanFileName = source.fileName;
779
+ const segments = cleanFileName.split("/");
780
+ const srcIndex = segments.findIndex((seg) => seg === "src");
781
+ if (srcIndex > 0) cleanFileName = segments.slice(srcIndex).join("/");
782
+ else if (segments.length > 1 && !cleanFileName.startsWith("/")) cleanFileName = segments.slice(1).join("/");
783
+ sourceFileEl.textContent = `${cleanFileName}:${source.lineNumber}:${source.columnNumber}`;
784
+ }
785
+ } else {
786
+ const nameEl = document.getElementById(COMPONENT_NAME_ELEMENT_ID);
787
+ if (nameEl) nameEl.textContent = name === "Element" ? "Element" : `<${name}>`;
788
+ const indicatorEl = document.getElementById(INDICATOR_ELEMENT_ID);
789
+ if (indicatorEl) indicatorEl.textContent = `${Math.round(rect.width * 100) / 100} x ${Math.round(rect.height * 100) / 100}`;
790
+ }
791
+ }
792
+ function hideHighlight() {
793
+ const highlight = getContainerElement();
794
+ if (!highlight) return;
795
+ window.clearTimeout(highlightHideTimer);
796
+ highlight.style.opacity = "0";
797
+ highlightHideTimer = window.setTimeout(() => {
798
+ highlight.style.display = "none";
799
+ }, 150);
800
+ }
801
+ function showHighlight(rect, name, source) {
802
+ const highlight = getContainerElement();
803
+ window.clearTimeout(highlightHideTimer);
804
+ if (highlight) updateHighlightElement(rect, name, source);
805
+ else createHighlightElement(rect, name, source);
806
+ }
807
+ function mergeClientRects(rects) {
808
+ if (!rects.length) return null;
809
+ let top = Number.POSITIVE_INFINITY;
810
+ let left = Number.POSITIVE_INFINITY;
811
+ let right = Number.NEGATIVE_INFINITY;
812
+ let bottom = Number.NEGATIVE_INFINITY;
813
+ rects.forEach((rect) => {
814
+ top = Math.min(top, rect.top);
815
+ left = Math.min(left, rect.left);
816
+ right = Math.max(right, rect.right);
817
+ bottom = Math.max(bottom, rect.bottom);
818
+ });
819
+ return new DOMRect(left, top, Math.max(0, right - left), Math.max(0, bottom - top));
820
+ }
821
+ function isInOverlay(node) {
822
+ var _overlayContainer$con;
823
+ if (!node) return false;
824
+ const overlayContainer = document.getElementById("react-devtools-overlay");
825
+ return (_overlayContainer$con = overlayContainer === null || overlayContainer === void 0 ? void 0 : overlayContainer.contains(node)) !== null && _overlayContainer$con !== void 0 ? _overlayContainer$con : false;
826
+ }
827
+ function collectHostElements(fiber, elements, visited = /* @__PURE__ */ new WeakSet()) {
828
+ if (!fiber || visited.has(fiber)) return;
829
+ visited.add(fiber);
830
+ if (fiber.stateNode && isInOverlay(fiber.stateNode)) return;
831
+ if (fiber.tag === REACT_TAGS.HostComponent && fiber.stateNode instanceof Element) {
832
+ if (!isInOverlay(fiber.stateNode)) elements.add(fiber.stateNode);
833
+ return;
834
+ }
835
+ if (fiber.tag === REACT_TAGS.HostText) {
836
+ var _fiber$stateNode;
837
+ const parent = (_fiber$stateNode = fiber.stateNode) === null || _fiber$stateNode === void 0 ? void 0 : _fiber$stateNode.parentElement;
838
+ if (parent && !isInOverlay(parent)) elements.add(parent);
839
+ return;
840
+ }
841
+ let child = fiber.child;
842
+ while (child) {
843
+ collectHostElements(child, elements, visited);
844
+ child = child.sibling;
845
+ }
846
+ }
847
+ function highlightNode(fiber, source) {
848
+ if (!fiber) {
849
+ hideHighlight();
850
+ return;
851
+ }
852
+ if (fiber.tag === REACT_TAGS.HostComponent && fiber.stateNode instanceof Element) {
853
+ const element = fiber.stateNode;
854
+ const rect = element.getBoundingClientRect();
855
+ if (rect.width > 0 || rect.height > 0) {
856
+ showHighlight(rect, fiber.type || element.tagName.toLowerCase(), source);
857
+ return;
858
+ }
859
+ }
860
+ const elements = /* @__PURE__ */ new Set();
861
+ collectHostElements(fiber, elements);
862
+ if (elements.size === 0) {
863
+ hideHighlight();
864
+ return;
865
+ }
866
+ const merged = mergeClientRects(Array.from(elements).map((element) => element.getBoundingClientRect()).filter((rect) => rect.width > 0 || rect.height > 0));
867
+ if (!merged || merged.width === 0 && merged.height === 0) {
868
+ hideHighlight();
869
+ return;
870
+ }
871
+ showHighlight(merged, getDisplayName(fiber), source);
872
+ }
873
+ function cleanupHighlight() {
874
+ const el = getContainerElement();
875
+ el === null || el === void 0 || el.remove();
876
+ window.clearTimeout(highlightHideTimer);
877
+ }
878
+ /**
879
+ * Scroll the page to make the component visible
880
+ */
881
+ function scrollToNode(fiber) {
882
+ if (!fiber) return;
883
+ if (fiber.tag === REACT_TAGS.HostComponent && fiber.stateNode instanceof Element) {
884
+ fiber.stateNode.scrollIntoView({
885
+ behavior: "smooth",
886
+ block: "center",
887
+ inline: "center"
888
+ });
889
+ return;
890
+ }
891
+ const elements = /* @__PURE__ */ new Set();
892
+ collectHostElements(fiber, elements);
893
+ if (elements.size === 0) return;
894
+ const firstElement = Array.from(elements)[0];
895
+ if (firstElement) firstElement.scrollIntoView({
896
+ behavior: "smooth",
897
+ block: "center",
898
+ inline: "center"
899
+ });
900
+ }
901
+
902
+ //#endregion
903
+ //#region src/core/fiber/tree.ts
904
+ const fiberRegistry = /* @__PURE__ */ new Map();
905
+ function getFiberById(id) {
906
+ return fiberRegistry.get(id);
907
+ }
908
+ function collectVisibleChildren(fiber, showHostComponents, nodes, visited) {
909
+ let current = fiber;
910
+ while (current) {
911
+ if (visited.has(current)) {
912
+ current = current.sibling;
913
+ continue;
914
+ }
915
+ if (shouldIncludeFiber(current, showHostComponents)) {
916
+ visited.add(current);
917
+ const treeChild = fiberToTree(current, showHostComponents, visited);
918
+ if (treeChild) nodes.push(treeChild);
919
+ } else if (current.child) collectVisibleChildren(current.child, showHostComponents, nodes, visited);
920
+ current = current.sibling;
921
+ }
922
+ }
923
+ function fiberToTree(fiber, showHostComponents, visited) {
924
+ if (!fiber) return null;
925
+ if (fiber.tag === REACT_TAGS.Mode || fiber.tag === REACT_TAGS.Fragment || fiber.tag === REACT_TAGS.HostRoot) return null;
926
+ const displayName = getDisplayName(fiber);
927
+ const node = {
928
+ id: getFiberId(fiber),
929
+ name: displayName,
930
+ children: [],
931
+ meta: { tag: fiber.tag }
932
+ };
933
+ fiberRegistry.set(node.id, fiber);
934
+ const childVisited = /* @__PURE__ */ new WeakSet();
935
+ collectVisibleChildren(fiber.child, showHostComponents, node.children, childVisited);
936
+ return node;
937
+ }
938
+ function buildTree(root, showHostComponents) {
939
+ if (!(root === null || root === void 0 ? void 0 : root.current)) return null;
940
+ const current = root.current;
941
+ const visited = /* @__PURE__ */ new WeakSet();
942
+ let fiber = current.child;
943
+ let depth = 0;
944
+ while (fiber && depth < 20) {
945
+ depth++;
946
+ if (fiber.tag === REACT_TAGS.Mode || fiber.tag === REACT_TAGS.Fragment || fiber.tag === REACT_TAGS.HostRoot) {
947
+ fiber = fiber.child || fiber.sibling;
948
+ continue;
949
+ }
950
+ if (shouldIncludeFiber(fiber, showHostComponents)) return fiberToTree(fiber, showHostComponents, visited);
951
+ if (fiber.child) {
952
+ fiber = fiber.child;
953
+ continue;
954
+ }
955
+ fiber = fiber.sibling;
956
+ }
957
+ return null;
958
+ }
959
+ function clearFiberRegistry() {
960
+ fiberRegistry.clear();
961
+ }
962
+
963
+ //#endregion
964
+ //#region src/core/fiber/props.ts
965
+ /** Stores overridden props for UI display */
966
+ const overriddenProps = /* @__PURE__ */ new Map();
967
+ /** Stores overridden context values for UI display */
968
+ const overriddenContexts = /* @__PURE__ */ new Map();
969
+ /**
970
+ * Get the React renderer that has overrideProps API
971
+ *
972
+ * React DevTools hook may have multiple renderers. We need to find the one
973
+ * that provides the official overrideProps API (React's native renderer).
974
+ */
975
+ function getRenderer() {
976
+ const hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
977
+ if (!(hook === null || hook === void 0 ? void 0 : hook.renderers)) return null;
978
+ for (const renderer of hook.renderers.values()) if (renderer === null || renderer === void 0 ? void 0 : renderer.overrideProps) return renderer;
979
+ for (const renderer of hook.renderers.values()) if (renderer) return renderer;
980
+ return null;
981
+ }
982
+ /**
983
+ * Parse a string value to the appropriate JavaScript type
984
+ *
985
+ * @param value - The string representation of the value
986
+ * @param expectedType - The expected type of the value
987
+ * @returns The parsed value in the correct type
988
+ */
989
+ function parseValue(value, expectedType) {
990
+ if (expectedType === "null" || expectedType === "undefined") {
991
+ if (value === "null") return null;
992
+ if (value === "undefined") return void 0;
993
+ return inferValueType(value);
994
+ }
995
+ switch (expectedType) {
996
+ case "number": return Number(value);
997
+ case "boolean": return value === "true";
998
+ case "object":
999
+ case "array": try {
1000
+ return JSON.parse(value);
1001
+ } catch (_unused) {
1002
+ return value;
1003
+ }
1004
+ case "string":
1005
+ default:
1006
+ if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) return value.slice(1, -1);
1007
+ return value;
1008
+ }
1009
+ }
1010
+ /**
1011
+ * Infer the type of a value from its string representation
1012
+ *
1013
+ * Used when the original type is null/undefined and user enters a new value.
1014
+ */
1015
+ function inferValueType(value) {
1016
+ const trimmed = value.trim();
1017
+ if (trimmed === "true") return true;
1018
+ if (trimmed === "false") return false;
1019
+ if (trimmed === "null") return null;
1020
+ if (trimmed === "undefined") return void 0;
1021
+ const num = Number(trimmed);
1022
+ if (!Number.isNaN(num) && trimmed !== "") return num;
1023
+ if (trimmed.startsWith("{") && trimmed.endsWith("}") || trimmed.startsWith("[") && trimmed.endsWith("]")) try {
1024
+ return JSON.parse(trimmed);
1025
+ } catch (_unused2) {}
1026
+ if (trimmed.startsWith("\"") && trimmed.endsWith("\"") || trimmed.startsWith("'") && trimmed.endsWith("'")) return trimmed.slice(1, -1);
1027
+ return trimmed;
1028
+ }
1029
+ /**
1030
+ * Set a nested property on an object immutably
1031
+ *
1032
+ * @param obj - The source object
1033
+ * @param path - Array of keys representing the path to the property
1034
+ * @param value - The value to set
1035
+ * @returns A new object with the updated value
1036
+ */
1037
+ function setNestedValue(obj, path, value) {
1038
+ if (path.length === 0) return value;
1039
+ const result = Array.isArray(obj) ? [...obj] : _objectSpread2({}, obj);
1040
+ let current = result;
1041
+ for (let i = 0; i < path.length - 1; i++) {
1042
+ const key = path[i];
1043
+ const nextKey = path[i + 1];
1044
+ const isNextArray = !Number.isNaN(Number(nextKey));
1045
+ current[key] = current[key] ? Array.isArray(current[key]) ? [...current[key]] : _objectSpread2({}, current[key]) : isNextArray ? [] : {};
1046
+ current = current[key];
1047
+ }
1048
+ current[path[path.length - 1]] = value;
1049
+ return result;
1050
+ }
1051
+ /**
1052
+ * Force update a specific component and its ancestors
1053
+ *
1054
+ * Strategy:
1055
+ * 1. Try class component forceUpdate (safest)
1056
+ * 2. Try function component hooks with object/array state
1057
+ * 3. Try primitive state with toggle-and-restore
1058
+ */
1059
+ function forceComponentUpdate(fiber) {
1060
+ if (fiber.stateNode && typeof fiber.stateNode.forceUpdate === "function") try {
1061
+ fiber.stateNode.forceUpdate();
1062
+ return true;
1063
+ } catch (_unused3) {}
1064
+ let current = fiber;
1065
+ let depth = 0;
1066
+ while (current && depth < 50) {
1067
+ if (current.stateNode && typeof current.stateNode.forceUpdate === "function") try {
1068
+ current.stateNode.forceUpdate();
1069
+ return true;
1070
+ } catch (_unused4) {}
1071
+ if (current.memoizedState !== null && typeof current.memoizedState === "object") {
1072
+ if (tryDispatchStateUpdate(current.memoizedState)) return true;
1073
+ }
1074
+ current = current.return;
1075
+ depth++;
1076
+ }
1077
+ return false;
1078
+ }
1079
+ /**
1080
+ * Try to dispatch a state update through hook state
1081
+ */
1082
+ function tryDispatchStateUpdate(hookState) {
1083
+ while (hookState) {
1084
+ const queue = hookState.queue;
1085
+ const currentState = hookState.memoizedState;
1086
+ if (queue === null || queue === void 0 ? void 0 : queue.dispatch) try {
1087
+ const dispatch = queue.dispatch;
1088
+ if (currentState !== null && typeof currentState === "object") {
1089
+ dispatch(Array.isArray(currentState) ? [...currentState] : _objectSpread2({}, currentState));
1090
+ return true;
1091
+ } else if (typeof currentState === "boolean") {
1092
+ dispatch(!currentState);
1093
+ setTimeout(() => dispatch(currentState), 0);
1094
+ return true;
1095
+ } else if (typeof currentState === "number") {
1096
+ dispatch(currentState + 1e-7);
1097
+ setTimeout(() => dispatch(currentState), 0);
1098
+ return true;
1099
+ }
1100
+ } catch (_unused5) {}
1101
+ hookState = hookState.next;
1102
+ }
1103
+ return false;
1104
+ }
1105
+ /**
1106
+ * Force update by finding any component in the tree with updatable state
1107
+ */
1108
+ function forceGlobalUpdate() {
1109
+ try {
1110
+ const hook = window.__REACT_DEVTOOLS_GLOBAL_HOOK__;
1111
+ if (!(hook === null || hook === void 0 ? void 0 : hook.renderers)) return false;
1112
+ for (const [rendererID] of hook.renderers.entries()) {
1113
+ var _hook$getFiberRoots;
1114
+ const roots = (_hook$getFiberRoots = hook.getFiberRoots) === null || _hook$getFiberRoots === void 0 ? void 0 : _hook$getFiberRoots.call(hook, rendererID);
1115
+ if (roots) {
1116
+ for (const root of roots) if (root.current) {
1117
+ if (findAndForceUpdate(root.current)) return true;
1118
+ }
1119
+ }
1120
+ }
1121
+ } catch (_unused6) {}
1122
+ return false;
1123
+ }
1124
+ /**
1125
+ * Walk fiber tree to find a component that can be force-updated
1126
+ */
1127
+ function findAndForceUpdate(fiber, depth = 0) {
1128
+ if (!fiber || depth > 100) return false;
1129
+ if (fiber.stateNode && typeof fiber.stateNode.forceUpdate === "function") try {
1130
+ fiber.stateNode.forceUpdate();
1131
+ return true;
1132
+ } catch (_unused7) {}
1133
+ if (fiber.memoizedState !== null && typeof fiber.memoizedState === "object") {
1134
+ if (tryDispatchStateUpdate(fiber.memoizedState)) return true;
1135
+ }
1136
+ if (fiber.child && findAndForceUpdate(fiber.child, depth + 1)) return true;
1137
+ if (fiber.sibling && findAndForceUpdate(fiber.sibling, depth + 1)) return true;
1138
+ return false;
1139
+ }
1140
+ /**
1141
+ * Set a prop value on a component
1142
+ *
1143
+ * Uses React's official overrideProps API when available,
1144
+ * falls back to direct fiber manipulation otherwise.
1145
+ *
1146
+ * @param fiberId - The fiber ID of the component
1147
+ * @param propPath - Dot-separated path to the prop (e.g., "user.name")
1148
+ * @param value - The string representation of the new value
1149
+ * @param valueType - The expected type of the value
1150
+ * @returns Whether the operation succeeded
1151
+ */
1152
+ function setComponentProp(fiberId, propPath, value, valueType) {
1153
+ const fiber = getFiberById(fiberId);
1154
+ if (!fiber) {
1155
+ console.warn(`[React DevTools] Fiber not found: ${fiberId}`);
1156
+ return false;
1157
+ }
1158
+ const parsedValue = parseValue(value, valueType);
1159
+ const pathParts = propPath.split(".");
1160
+ try {
1161
+ if (!overriddenProps.has(fiberId)) overriddenProps.set(fiberId, /* @__PURE__ */ new Map());
1162
+ overriddenProps.get(fiberId).set(propPath, parsedValue);
1163
+ const renderer = getRenderer();
1164
+ if (renderer === null || renderer === void 0 ? void 0 : renderer.overrideProps) try {
1165
+ renderer.overrideProps(fiber, pathParts, parsedValue);
1166
+ return true;
1167
+ } catch (_unused8) {
1168
+ const numericId = Number.parseInt(fiberId.replace("react-fiber-", ""), 10);
1169
+ if (!Number.isNaN(numericId)) try {
1170
+ renderer.overrideProps(numericId, pathParts, parsedValue);
1171
+ return true;
1172
+ } catch (_unused9) {}
1173
+ }
1174
+ const newProps = setNestedValue(fiber.memoizedProps || {}, pathParts, parsedValue);
1175
+ fiber.memoizedProps = newProps;
1176
+ fiber.pendingProps = newProps;
1177
+ if (fiber.alternate) {
1178
+ fiber.alternate.memoizedProps = newProps;
1179
+ fiber.alternate.pendingProps = newProps;
1180
+ }
1181
+ forceComponentUpdate(fiber) || forceGlobalUpdate();
1182
+ return true;
1183
+ } catch (error) {
1184
+ console.warn("[React DevTools] Failed to set prop:", error);
1185
+ return false;
1186
+ }
1187
+ }
1188
+ /**
1189
+ * Get an overridden prop value for UI display
1190
+ */
1191
+ function getOverriddenProp(fiberId, propPath) {
1192
+ var _overriddenProps$get;
1193
+ return (_overriddenProps$get = overriddenProps.get(fiberId)) === null || _overriddenProps$get === void 0 ? void 0 : _overriddenProps$get.get(propPath);
1194
+ }
1195
+ /**
1196
+ * Check if a prop is editable
1197
+ *
1198
+ * Some props cannot be edited (children, key, ref, etc.)
1199
+ * Some types cannot be edited (functions, symbols, elements)
1200
+ */
1201
+ function isEditableProp(propName, valueType) {
1202
+ if ([
1203
+ "children",
1204
+ "key",
1205
+ "ref",
1206
+ "$$typeof"
1207
+ ].includes(propName)) return false;
1208
+ if ([
1209
+ "element",
1210
+ "function",
1211
+ "symbol"
1212
+ ].includes(valueType)) return false;
1213
+ return true;
1214
+ }
1215
+ /**
1216
+ * Set a Context Provider's value
1217
+ *
1218
+ * @param fiberId - The fiber ID of the Context Provider
1219
+ * @param value - The string representation of the new value
1220
+ * @param valueType - The expected type of the value
1221
+ * @returns Whether the operation succeeded
1222
+ */
1223
+ function setContextValue(fiberId, value, valueType) {
1224
+ const fiber = getFiberById(fiberId);
1225
+ if (!fiber) {
1226
+ console.warn(`[React DevTools] Fiber not found: ${fiberId}`);
1227
+ return false;
1228
+ }
1229
+ if (fiber.tag !== REACT_TAGS.ContextProvider) {
1230
+ console.warn(`[React DevTools] Fiber is not a Context Provider`);
1231
+ return false;
1232
+ }
1233
+ try {
1234
+ return applyContextValue(fiber, parseValue(value, valueType), fiberId);
1235
+ } catch (error) {
1236
+ console.warn("[React DevTools] Failed to set context value:", error);
1237
+ return false;
1238
+ }
1239
+ }
1240
+ /**
1241
+ * Set a Context Provider's value from a JSON string
1242
+ *
1243
+ * Used for complex objects where JSON editing is more convenient.
1244
+ */
1245
+ function setContextValueFromJson(fiberId, jsonValue) {
1246
+ const fiber = getFiberById(fiberId);
1247
+ if (!fiber) {
1248
+ console.warn(`[React DevTools] Fiber not found: ${fiberId}`);
1249
+ return false;
1250
+ }
1251
+ if (fiber.tag !== REACT_TAGS.ContextProvider) {
1252
+ console.warn(`[React DevTools] Fiber is not a Context Provider`);
1253
+ return false;
1254
+ }
1255
+ try {
1256
+ return applyContextValue(fiber, JSON.parse(jsonValue), fiberId);
1257
+ } catch (error) {
1258
+ console.warn("[React DevTools] Failed to set context value from JSON:", error);
1259
+ return false;
1260
+ }
1261
+ }
1262
+ /**
1263
+ * Set a nested property within a Context Provider's value
1264
+ *
1265
+ * @param fiberId - The fiber ID of the Context Provider
1266
+ * @param path - Dot-separated path to the property (e.g., "theme.mode")
1267
+ * @param value - The string representation of the new value
1268
+ * @param valueType - The expected type of the value
1269
+ * @returns Whether the operation succeeded
1270
+ */
1271
+ function setContextValueAtPath(fiberId, path, value, valueType) {
1272
+ const fiber = getFiberById(fiberId);
1273
+ if (!fiber) {
1274
+ console.warn(`[React DevTools] Fiber not found: ${fiberId}`);
1275
+ return false;
1276
+ }
1277
+ if (fiber.tag !== REACT_TAGS.ContextProvider) {
1278
+ console.warn(`[React DevTools] Fiber is not a Context Provider`);
1279
+ return false;
1280
+ }
1281
+ try {
1282
+ var _fiber$memoizedProps;
1283
+ const parsedValue = parseValue(value, valueType);
1284
+ const pathParts = path.split(".");
1285
+ return applyContextValue(fiber, setNestedValue((_fiber$memoizedProps = fiber.memoizedProps) === null || _fiber$memoizedProps === void 0 ? void 0 : _fiber$memoizedProps.value, pathParts, parsedValue), fiberId);
1286
+ } catch (error) {
1287
+ console.warn("[React DevTools] Failed to set context value at path:", error);
1288
+ return false;
1289
+ }
1290
+ }
1291
+ /**
1292
+ * Apply a value to a Context Provider
1293
+ *
1294
+ * Context Provider is essentially a component with a `value` prop.
1295
+ * We use overrideProps to modify this prop.
1296
+ */
1297
+ function applyContextValue(fiber, newValue, fiberId) {
1298
+ var _fiber$type;
1299
+ overriddenContexts.set(fiberId, newValue);
1300
+ const renderer = getRenderer();
1301
+ if (renderer === null || renderer === void 0 ? void 0 : renderer.overrideProps) try {
1302
+ renderer.overrideProps(fiber, ["value"], newValue);
1303
+ return true;
1304
+ } catch (_unused10) {
1305
+ const numericId = Number.parseInt(fiberId.replace("react-fiber-", ""), 10);
1306
+ if (!Number.isNaN(numericId)) try {
1307
+ renderer.overrideProps(numericId, ["value"], newValue);
1308
+ return true;
1309
+ } catch (_unused11) {}
1310
+ }
1311
+ const newProps = _objectSpread2(_objectSpread2({}, fiber.memoizedProps || {}), {}, { value: newValue });
1312
+ fiber.memoizedProps = newProps;
1313
+ fiber.pendingProps = newProps;
1314
+ if (fiber.alternate) {
1315
+ fiber.alternate.memoizedProps = newProps;
1316
+ fiber.alternate.pendingProps = newProps;
1317
+ }
1318
+ const contextType = (_fiber$type = fiber.type) === null || _fiber$type === void 0 ? void 0 : _fiber$type._context;
1319
+ if (contextType) {
1320
+ contextType._currentValue = newValue;
1321
+ if ("_currentValue2" in contextType) contextType._currentValue2 = newValue;
1322
+ }
1323
+ forceComponentUpdate(fiber) || forceGlobalUpdate();
1324
+ return true;
1325
+ }
1326
+ /**
1327
+ * Get an overridden context value for UI display
1328
+ */
1329
+ function getOverriddenContext(fiberId) {
1330
+ return overriddenContexts.get(fiberId);
1331
+ }
1332
+ /**
1333
+ * Clear all overrides
1334
+ *
1335
+ * Should be called when the page refreshes or DevTools disconnects.
1336
+ */
1337
+ function clearOverrides() {
1338
+ overriddenProps.clear();
1339
+ overriddenContexts.clear();
1340
+ }
1341
+
1342
+ //#endregion
1343
+ //#region src/core/fiber/state.ts
1344
+ /**
1345
+ * Get all useState/useReducer hooks from a component
1346
+ */
1347
+ function getComponentHookStates(fiberId) {
1348
+ const fiber = getFiberById(fiberId);
1349
+ if (!fiber) return [];
1350
+ if (fiber.tag !== REACT_TAGS.FunctionComponent && fiber.tag !== REACT_TAGS.ForwardRef && fiber.tag !== REACT_TAGS.SimpleMemoComponent && fiber.tag !== REACT_TAGS.MemoComponent) return [];
1351
+ const states = [];
1352
+ const debugHookTypes = fiber._debugHookTypes;
1353
+ let hookState = fiber.memoizedState;
1354
+ let index = 0;
1355
+ while (hookState) {
1356
+ var _hookState$queue;
1357
+ if ((_hookState$queue = hookState.queue) === null || _hookState$queue === void 0 ? void 0 : _hookState$queue.dispatch) {
1358
+ const hookName = (debugHookTypes === null || debugHookTypes === void 0 ? void 0 : debugHookTypes[index]) || "State";
1359
+ const value = hookState.memoizedState;
1360
+ const valueType = getValueType(value);
1361
+ states.push({
1362
+ index,
1363
+ name: hookName,
1364
+ value: serializeForDisplay(value),
1365
+ type: valueType,
1366
+ canEdit: isEditableType(valueType)
1367
+ });
1368
+ }
1369
+ hookState = hookState.next;
1370
+ index++;
1371
+ }
1372
+ return states;
1373
+ }
1374
+ /**
1375
+ * Set a hook state value
1376
+ * This directly calls the useState setter, which is the most reliable way to update React state
1377
+ */
1378
+ function setHookState(fiberId, hookIndex, value, valueType) {
1379
+ const fiber = getFiberById(fiberId);
1380
+ if (!fiber) {
1381
+ console.warn(`[React DevTools] Fiber not found: ${fiberId}`);
1382
+ return false;
1383
+ }
1384
+ let hookState = fiber.memoizedState;
1385
+ let currentIndex = 0;
1386
+ let targetHook = null;
1387
+ while (hookState) {
1388
+ var _hookState$queue2;
1389
+ if ((_hookState$queue2 = hookState.queue) === null || _hookState$queue2 === void 0 ? void 0 : _hookState$queue2.dispatch) {
1390
+ if (currentIndex === hookIndex) {
1391
+ targetHook = hookState;
1392
+ break;
1393
+ }
1394
+ currentIndex++;
1395
+ }
1396
+ hookState = hookState.next;
1397
+ }
1398
+ if (!targetHook) {
1399
+ console.warn(`[React DevTools] Hook at index ${hookIndex} not found`);
1400
+ return false;
1401
+ }
1402
+ const dispatch = targetHook.queue.dispatch;
1403
+ if (!dispatch) {
1404
+ console.warn(`[React DevTools] Hook has no dispatch function`);
1405
+ return false;
1406
+ }
1407
+ try {
1408
+ dispatch(parseValue$1(value, valueType));
1409
+ return true;
1410
+ } catch (error) {
1411
+ console.warn("[React DevTools] Failed to set hook state:", error);
1412
+ return false;
1413
+ }
1414
+ }
1415
+ /**
1416
+ * Set a hook state value using JSON (for objects/arrays)
1417
+ */
1418
+ function setHookStateFromJson(fiberId, hookIndex, jsonValue) {
1419
+ try {
1420
+ const parsedValue = JSON.parse(jsonValue);
1421
+ const fiber = getFiberById(fiberId);
1422
+ if (!fiber) return false;
1423
+ let hookState = fiber.memoizedState;
1424
+ let currentIndex = 0;
1425
+ while (hookState) {
1426
+ var _hookState$queue3;
1427
+ if ((_hookState$queue3 = hookState.queue) === null || _hookState$queue3 === void 0 ? void 0 : _hookState$queue3.dispatch) {
1428
+ if (currentIndex === hookIndex) {
1429
+ hookState.queue.dispatch(parsedValue);
1430
+ return true;
1431
+ }
1432
+ currentIndex++;
1433
+ }
1434
+ hookState = hookState.next;
1435
+ }
1436
+ return false;
1437
+ } catch (error) {
1438
+ console.warn("[React DevTools] Failed to set hook state from JSON:", error);
1439
+ return false;
1440
+ }
1441
+ }
1442
+ function getValueType(value) {
1443
+ if (value === null) return "null";
1444
+ if (value === void 0) return "undefined";
1445
+ if (Array.isArray(value)) return "array";
1446
+ return typeof value;
1447
+ }
1448
+ function isEditableType(type) {
1449
+ return [
1450
+ "string",
1451
+ "number",
1452
+ "boolean",
1453
+ "null",
1454
+ "undefined",
1455
+ "object",
1456
+ "array"
1457
+ ].includes(type);
1458
+ }
1459
+ function parseValue$1(value, valueType) {
1460
+ switch (valueType) {
1461
+ case "number": return Number(value);
1462
+ case "boolean": return value === "true";
1463
+ case "null": return null;
1464
+ case "undefined": return;
1465
+ case "object":
1466
+ case "array": try {
1467
+ return JSON.parse(value);
1468
+ } catch (_unused) {
1469
+ return value;
1470
+ }
1471
+ case "string":
1472
+ default:
1473
+ if (value.startsWith("\"") && value.endsWith("\"") || value.startsWith("'") && value.endsWith("'")) return value.slice(1, -1);
1474
+ return value;
1475
+ }
1476
+ }
1477
+ function serializeForDisplay(value) {
1478
+ if (value === null) return null;
1479
+ if (value === void 0) return void 0;
1480
+ if (typeof value === "function") return `ƒ ${value.name || "anonymous"}()`;
1481
+ if (typeof value === "symbol") return value.toString();
1482
+ return value;
1483
+ }
1484
+
1485
+ //#endregion
1486
+ //#region src/core/router/index.ts
1487
+ /**
1488
+ * Global variable to store the React fiber root reference
1489
+ */
1490
+ let fiberRoot = null;
1491
+ /**
1492
+ * Navigation history storage
1493
+ */
1494
+ const navigationHistory = [];
1495
+ let lastNavigationStart = null;
1496
+ let lastNavigationDuration;
1497
+ /**
1498
+ * Max history entries to keep
1499
+ */
1500
+ const MAX_HISTORY_ENTRIES = 50;
1501
+ /**
1502
+ * Set the fiber root reference (called from hook)
1503
+ */
1504
+ function setFiberRoot(root) {
1505
+ fiberRoot = root;
1506
+ }
1507
+ /**
1508
+ * Get the current fiber root
1509
+ */
1510
+ function getFiberRoot() {
1511
+ return fiberRoot;
1512
+ }
1513
+ /**
1514
+ * Extract dynamic params from a path pattern
1515
+ */
1516
+ function extractParamsFromPath(path) {
1517
+ const params = [];
1518
+ const regex = /:([^/]+)/g;
1519
+ let match = regex.exec(path);
1520
+ while (match !== null) {
1521
+ params.push(match[1]);
1522
+ match = regex.exec(path);
1523
+ }
1524
+ return params;
1525
+ }
1526
+ /**
1527
+ * Check if element is lazy loaded
1528
+ */
1529
+ function isLazyElement(element) {
1530
+ var _element$$$typeof, _element$type;
1531
+ if (!element) return false;
1532
+ if (((_element$$$typeof = element.$$typeof) === null || _element$$$typeof === void 0 ? void 0 : _element$$$typeof.toString()) === "Symbol(react.lazy)") return true;
1533
+ if (((_element$type = element.type) === null || _element$type === void 0 || (_element$type = _element$type.$$typeof) === null || _element$type === void 0 ? void 0 : _element$type.toString()) === "Symbol(react.lazy)") return true;
1534
+ return false;
1535
+ }
1536
+ /**
1537
+ * Get element name from React element
1538
+ */
1539
+ function getElementName(element) {
1540
+ var _element$type2, _element$type3, _element$type4;
1541
+ if (!element) return void 0;
1542
+ if (typeof element.type === "string") return element.type;
1543
+ if ((_element$type2 = element.type) === null || _element$type2 === void 0 ? void 0 : _element$type2.name) return element.type.name;
1544
+ if ((_element$type3 = element.type) === null || _element$type3 === void 0 ? void 0 : _element$type3.displayName) return element.type.displayName;
1545
+ if ((_element$type4 = element.type) === null || _element$type4 === void 0 || (_element$type4 = _element$type4._payload) === null || _element$type4 === void 0 || (_element$type4 = _element$type4._result) === null || _element$type4 === void 0 ? void 0 : _element$type4.name) return element.type._payload._result.name;
1546
+ }
1547
+ /**
1548
+ * Extract route info from a React Router Route element (JSX props)
1549
+ */
1550
+ function extractRouteFromElement(element, parentPath = "") {
1551
+ if (!element || !element.props) return null;
1552
+ const props = element.props;
1553
+ const isIndex = props.index === true;
1554
+ let fullPath = "";
1555
+ if (isIndex) fullPath = parentPath || "/";
1556
+ else if (props.path) {
1557
+ props.path;
1558
+ fullPath = props.path.startsWith("/") ? props.path : `${parentPath}/${props.path}`.replace(/\/+/g, "/");
1559
+ } else fullPath = parentPath || "/";
1560
+ const childRoutes = [];
1561
+ if (props.children) {
1562
+ const children = Array.isArray(props.children) ? props.children : [props.children];
1563
+ for (const child of children) {
1564
+ var _child$type;
1565
+ if (child && child.type && (child.type.name === "Route" || ((_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.displayName) === "Route")) {
1566
+ const childRoute = extractRouteFromElement(child, fullPath);
1567
+ if (childRoute) childRoutes.push(childRoute);
1568
+ }
1569
+ }
1570
+ }
1571
+ const hasChildren = childRoutes.length > 0;
1572
+ const params = extractParamsFromPath(props.path || "");
1573
+ const routeInfo = {
1574
+ path: fullPath || "/",
1575
+ name: props.id || void 0,
1576
+ element: getElementName(props.element),
1577
+ isIndex,
1578
+ isLayout: hasChildren,
1579
+ hasLoader: !!props.loader,
1580
+ hasAction: !!props.action,
1581
+ isLazy: isLazyElement(props.element) || !!props.lazy,
1582
+ hasErrorBoundary: !!props.errorElement || !!props.ErrorBoundary,
1583
+ params: params.length > 0 ? params : void 0
1584
+ };
1585
+ if (hasChildren) routeInfo.children = childRoutes;
1586
+ return routeInfo;
1587
+ }
1588
+ /**
1589
+ * Extract routes from Routes component's children prop
1590
+ */
1591
+ function extractRoutesFromProps(props) {
1592
+ const routes = [];
1593
+ if (!(props === null || props === void 0 ? void 0 : props.children)) return routes;
1594
+ const children = Array.isArray(props.children) ? props.children : [props.children];
1595
+ for (const child of children) {
1596
+ var _child$type2;
1597
+ if (child && child.type && (child.type.name === "Route" || ((_child$type2 = child.type) === null || _child$type2 === void 0 ? void 0 : _child$type2.displayName) === "Route")) {
1598
+ const route = extractRouteFromElement(child);
1599
+ if (route) routes.push(route);
1600
+ }
1601
+ }
1602
+ return routes;
1603
+ }
1604
+ /**
1605
+ * Extract route configuration from fiber tree
1606
+ */
1607
+ function extractRoutesFromFiber(fiber) {
1608
+ const routes = [];
1609
+ const visited = /* @__PURE__ */ new WeakSet();
1610
+ function traverse$1(node, parentPath = "") {
1611
+ if (!node || visited.has(node)) return;
1612
+ visited.add(node);
1613
+ const name = getDisplayName(node);
1614
+ const props = node.memoizedProps || node.pendingProps;
1615
+ if ((name === "Route" || name === "RenderedRoute" || name === "RouteContext.Provider") && props) {
1616
+ var _props$value, _props$value2;
1617
+ const match = props.match || ((_props$value = props.value) === null || _props$value === void 0 ? void 0 : _props$value.match);
1618
+ const route = props.route || ((_props$value2 = props.value) === null || _props$value2 === void 0 ? void 0 : _props$value2.route);
1619
+ if (match || route) {
1620
+ var _route$element, _route$element2;
1621
+ const routeInfo = {
1622
+ path: (match === null || match === void 0 ? void 0 : match.pathname) || (route === null || route === void 0 ? void 0 : route.path) || parentPath || "/",
1623
+ name: (route === null || route === void 0 ? void 0 : route.id) || void 0,
1624
+ element: (route === null || route === void 0 || (_route$element = route.element) === null || _route$element === void 0 || (_route$element = _route$element.type) === null || _route$element === void 0 ? void 0 : _route$element.name) || (route === null || route === void 0 || (_route$element2 = route.element) === null || _route$element2 === void 0 || (_route$element2 = _route$element2.type) === null || _route$element2 === void 0 ? void 0 : _route$element2.displayName) || getElementName(props.element),
1625
+ hasLoader: !!(route === null || route === void 0 ? void 0 : route.loader),
1626
+ hasAction: !!(route === null || route === void 0 ? void 0 : route.action),
1627
+ hasErrorBoundary: !!(route === null || route === void 0 ? void 0 : route.errorElement)
1628
+ };
1629
+ if (!routes.some((r) => r.path === routeInfo.path)) routes.push(routeInfo);
1630
+ }
1631
+ }
1632
+ if (node.child) traverse$1(node.child, parentPath);
1633
+ if (node.sibling) traverse$1(node.sibling, parentPath);
1634
+ }
1635
+ traverse$1(fiber);
1636
+ return routes;
1637
+ }
1638
+ /**
1639
+ * Find Routes component and extract route configuration
1640
+ */
1641
+ function findAndExtractRoutes(fiber) {
1642
+ if (!fiber) return [];
1643
+ const visited = /* @__PURE__ */ new WeakSet();
1644
+ let routes = [];
1645
+ function traverse$1(node) {
1646
+ if (!node || visited.has(node)) return;
1647
+ visited.add(node);
1648
+ const name = getDisplayName(node);
1649
+ const props = node.memoizedProps || node.pendingProps;
1650
+ if (name === "Routes") {
1651
+ const propsRoutes = extractRoutesFromProps(props);
1652
+ if (propsRoutes.length > 0) {
1653
+ routes = propsRoutes;
1654
+ return;
1655
+ }
1656
+ }
1657
+ if (name === "DataRoutes" || name === "RoutesRenderer") {
1658
+ const fiberRoutes = extractRoutesFromFiber(node);
1659
+ if (fiberRoutes.length > 0) routes.push(...fiberRoutes);
1660
+ }
1661
+ if (node.child) traverse$1(node.child);
1662
+ if (node.sibling) traverse$1(node.sibling);
1663
+ }
1664
+ traverse$1(fiber);
1665
+ return routes;
1666
+ }
1667
+ /**
1668
+ * Match a path against a route pattern and extract params
1669
+ */
1670
+ function matchPath(pattern, pathname) {
1671
+ const params = {};
1672
+ const patternParts = pattern.split("/").filter(Boolean);
1673
+ const pathParts = pathname.split("/").filter(Boolean);
1674
+ if (patternParts.length === 0 && pathParts.length === 0) return {
1675
+ matched: true,
1676
+ params
1677
+ };
1678
+ let patternIndex = 0;
1679
+ let pathIndex = 0;
1680
+ while (patternIndex < patternParts.length && pathIndex < pathParts.length) {
1681
+ const patternPart = patternParts[patternIndex];
1682
+ const pathPart = pathParts[pathIndex];
1683
+ if (patternPart.startsWith(":")) {
1684
+ const paramName = patternPart.slice(1).replace("?", "");
1685
+ params[paramName] = pathPart;
1686
+ } else if (patternPart === "*") {
1687
+ params["*"] = pathParts.slice(pathIndex).join("/");
1688
+ return {
1689
+ matched: true,
1690
+ params
1691
+ };
1692
+ } else if (patternPart !== pathPart) return {
1693
+ matched: false,
1694
+ params: {}
1695
+ };
1696
+ patternIndex++;
1697
+ pathIndex++;
1698
+ }
1699
+ while (patternIndex < patternParts.length) {
1700
+ const part = patternParts[patternIndex];
1701
+ if (!part.endsWith("?") && !part.startsWith(":")) return {
1702
+ matched: false,
1703
+ params: {}
1704
+ };
1705
+ patternIndex++;
1706
+ }
1707
+ return {
1708
+ matched: true,
1709
+ params
1710
+ };
1711
+ }
1712
+ /**
1713
+ * Find matched routes for a given path
1714
+ */
1715
+ function findMatchedRoutes(routes, pathname) {
1716
+ const matched = [];
1717
+ function findInRoutes(routeList, currentPath) {
1718
+ for (const route of routeList) {
1719
+ const { matched: isMatch, params } = matchPath(route.path, pathname);
1720
+ if (isMatch) {
1721
+ matched.push({
1722
+ path: route.path,
1723
+ params,
1724
+ element: route.element
1725
+ });
1726
+ if (route.children && route.children.length > 0) findInRoutes(route.children, route.path);
1727
+ if (route.path === pathname || route.isIndex) return true;
1728
+ }
1729
+ }
1730
+ return matched.length > 0;
1731
+ }
1732
+ findInRoutes(routes, pathname);
1733
+ return matched;
1734
+ }
1735
+ /**
1736
+ * Get current URL information
1737
+ */
1738
+ function getCurrentUrlInfo() {
1739
+ if (window.location.hash && window.location.hash.startsWith("#/")) {
1740
+ const [pathAndSearch, hash] = window.location.hash.slice(1).split("#");
1741
+ const [path, search] = (pathAndSearch || "/").split("?");
1742
+ return {
1743
+ path: path || "/",
1744
+ search: search ? `?${search}` : "",
1745
+ hash: hash ? `#${hash}` : ""
1746
+ };
1747
+ }
1748
+ return {
1749
+ path: window.location.pathname || "/",
1750
+ search: window.location.search || "",
1751
+ hash: window.location.hash || ""
1752
+ };
1753
+ }
1754
+ /**
1755
+ * Extract all params from matched routes
1756
+ */
1757
+ function extractAllParams(matchedRoutes) {
1758
+ const params = {};
1759
+ for (const route of matchedRoutes) Object.assign(params, route.params);
1760
+ return params;
1761
+ }
1762
+ /**
1763
+ * Detect router type from fiber tree
1764
+ */
1765
+ function detectRouterType(fiber) {
1766
+ if (!fiber) return null;
1767
+ const visited = /* @__PURE__ */ new WeakSet();
1768
+ function traverse$1(node) {
1769
+ if (!node || visited.has(node)) return null;
1770
+ visited.add(node);
1771
+ const name = getDisplayName(node);
1772
+ if (name === "Router" || name === "BrowserRouter" || name === "HashRouter" || name === "MemoryRouter" || name === "Routes" || name === "Route") return "react-router";
1773
+ if (node.child) {
1774
+ const result = traverse$1(node.child);
1775
+ if (result) return result;
1776
+ }
1777
+ if (node.sibling) {
1778
+ const result = traverse$1(node.sibling);
1779
+ if (result) return result;
1780
+ }
1781
+ return null;
1782
+ }
1783
+ return traverse$1(fiber);
1784
+ }
1785
+ /**
1786
+ * Record navigation to history
1787
+ */
1788
+ function recordNavigation(path, search, hash) {
1789
+ const now = Date.now();
1790
+ if (lastNavigationStart !== null) lastNavigationDuration = now - lastNavigationStart;
1791
+ navigationHistory.unshift({
1792
+ path,
1793
+ search,
1794
+ hash,
1795
+ timestamp: now,
1796
+ duration: lastNavigationDuration
1797
+ });
1798
+ if (navigationHistory.length > MAX_HISTORY_ENTRIES) navigationHistory.pop();
1799
+ lastNavigationStart = null;
1800
+ }
1801
+ /**
1802
+ * Get router information from the current React app
1803
+ */
1804
+ function getRouterInfo() {
1805
+ const root = fiberRoot;
1806
+ const urlInfo = getCurrentUrlInfo();
1807
+ if (!(root === null || root === void 0 ? void 0 : root.current)) return {
1808
+ currentPath: urlInfo.path,
1809
+ search: urlInfo.search,
1810
+ hash: urlInfo.hash,
1811
+ routes: [],
1812
+ routerType: null,
1813
+ matchedRoutes: [],
1814
+ params: {},
1815
+ history: [...navigationHistory],
1816
+ lastNavigationDuration
1817
+ };
1818
+ const fiber = root.current;
1819
+ const routerType = detectRouterType(fiber);
1820
+ const routes = findAndExtractRoutes(fiber.child);
1821
+ const matchedRoutes = findMatchedRoutes(routes, urlInfo.path);
1822
+ const params = extractAllParams(matchedRoutes);
1823
+ return {
1824
+ currentPath: urlInfo.path,
1825
+ search: urlInfo.search,
1826
+ hash: urlInfo.hash,
1827
+ routes,
1828
+ routerType,
1829
+ matchedRoutes,
1830
+ params,
1831
+ history: [...navigationHistory],
1832
+ lastNavigationDuration
1833
+ };
1834
+ }
1835
+ /**
1836
+ * Navigate to a path using various methods
1837
+ */
1838
+ function navigateTo(path) {
1839
+ try {
1840
+ lastNavigationStart = Date.now();
1841
+ if (window.history && window.history.pushState) {
1842
+ if (window.location.hash && window.location.hash.startsWith("#/")) window.location.hash = path;
1843
+ else {
1844
+ window.history.pushState({}, "", path);
1845
+ window.dispatchEvent(new PopStateEvent("popstate"));
1846
+ }
1847
+ return true;
1848
+ }
1849
+ window.location.href = path;
1850
+ return true;
1851
+ } catch (e) {
1852
+ console.error("[React DevTools] Failed to navigate:", e);
1853
+ lastNavigationStart = null;
1854
+ return false;
1855
+ }
1856
+ }
1857
+ /**
1858
+ * Clear navigation history
1859
+ */
1860
+ function clearNavigationHistory() {
1861
+ navigationHistory.length = 0;
1862
+ lastNavigationDuration = void 0;
1863
+ }
1864
+ /**
1865
+ * Initialize navigation tracking by listening to navigation events
1866
+ */
1867
+ if (typeof window !== "undefined") {
1868
+ let currentFullPath = "";
1869
+ const updateCurrentPath = () => {
1870
+ const urlInfo$1 = getCurrentUrlInfo();
1871
+ currentFullPath = `${urlInfo$1.path}${urlInfo$1.search}${urlInfo$1.hash}`;
1872
+ };
1873
+ const handleNavigation = () => {
1874
+ const urlInfo$1 = getCurrentUrlInfo();
1875
+ const newFullPath = `${urlInfo$1.path}${urlInfo$1.search}${urlInfo$1.hash}`;
1876
+ if (newFullPath !== currentFullPath) {
1877
+ recordNavigation(urlInfo$1.path, urlInfo$1.search, urlInfo$1.hash);
1878
+ currentFullPath = newFullPath;
1879
+ }
1880
+ };
1881
+ window.addEventListener("popstate", handleNavigation);
1882
+ window.addEventListener("hashchange", handleNavigation);
1883
+ const originalPushState = window.history.pushState;
1884
+ const originalReplaceState = window.history.replaceState;
1885
+ window.history.pushState = function(...args) {
1886
+ const result = originalPushState.apply(this, args);
1887
+ handleNavigation();
1888
+ return result;
1889
+ };
1890
+ window.history.replaceState = function(...args) {
1891
+ const result = originalReplaceState.apply(this, args);
1892
+ updateCurrentPath();
1893
+ return result;
1894
+ };
1895
+ const urlInfo = getCurrentUrlInfo();
1896
+ recordNavigation(urlInfo.path, urlInfo.search, urlInfo.hash);
1897
+ currentFullPath = `${urlInfo.path}${urlInfo.search}${urlInfo.hash}`;
1898
+ }
1899
+
1900
+ //#endregion
1901
+ //#region src/core/hook/index.ts
1902
+ const fiberRoots = /* @__PURE__ */ new Map();
1903
+ let updateTimer = null;
1904
+ let lastRootCurrent = null;
1905
+ const treeUpdateCallbacks = /* @__PURE__ */ new Set();
1906
+ function onTreeUpdated(callback) {
1907
+ treeUpdateCallbacks.add(callback);
1908
+ return () => {
1909
+ treeUpdateCallbacks.delete(callback);
1910
+ };
1911
+ }
1912
+ function emitTree(tree) {
1913
+ treeUpdateCallbacks.forEach((callback) => {
1914
+ try {
1915
+ callback(tree);
1916
+ } catch (e) {}
1917
+ });
1918
+ }
1919
+ function getRoots(rendererID) {
1920
+ if (!fiberRoots.has(rendererID)) fiberRoots.set(rendererID, /* @__PURE__ */ new Set());
1921
+ return fiberRoots.get(rendererID);
1922
+ }
1923
+ /**
1924
+ * Get root selector from runtime config
1925
+ */
1926
+ function getRootSelector() {
1927
+ if (typeof window !== "undefined") {
1928
+ var _REACT_DEVTOOLS_CONFI;
1929
+ return (_REACT_DEVTOOLS_CONFI = window.__REACT_DEVTOOLS_CONFIG__) === null || _REACT_DEVTOOLS_CONFI === void 0 ? void 0 : _REACT_DEVTOOLS_CONFI.rootSelector;
1930
+ }
1931
+ }
1932
+ function isOverlayRoot(root) {
1933
+ const overlayContainer = document.getElementById("react-devtools-overlay");
1934
+ if (!overlayContainer) return false;
1935
+ const containerInfo = root.containerInfo;
1936
+ return containerInfo && containerInfo instanceof Node && overlayContainer.contains(containerInfo);
1937
+ }
1938
+ /**
1939
+ * Check if a root belongs to the specified rootSelector container
1940
+ */
1941
+ function isRootInSelector(root, selector) {
1942
+ const containerInfo = root.containerInfo;
1943
+ if (!containerInfo || !(containerInfo instanceof Node)) return false;
1944
+ const targetContainer = document.querySelector(selector);
1945
+ if (!targetContainer) return false;
1946
+ return containerInfo === targetContainer || targetContainer.contains(containerInfo);
1947
+ }
1948
+ /**
1949
+ * Check if a root should be tracked based on rootSelector config
1950
+ */
1951
+ function shouldTrackRoot(root) {
1952
+ if (isOverlayRoot(root)) return false;
1953
+ const rootSelector = getRootSelector();
1954
+ if (!rootSelector) return true;
1955
+ return isRootInSelector(root, rootSelector);
1956
+ }
1957
+ function findAppRoot() {
1958
+ for (const roots of fiberRoots.values()) for (const root of roots) if (root && shouldTrackRoot(root)) return root;
1959
+ if (!getRootSelector()) {
1960
+ for (const roots of fiberRoots.values()) for (const root of roots) if (root && !isOverlayRoot(root)) return root;
1961
+ }
1962
+ return null;
1963
+ }
1964
+ /**
1965
+ * Get the current app fiber root (exported for context debugging)
1966
+ */
1967
+ function getAppFiberRoot() {
1968
+ return findAppRoot();
1969
+ }
1970
+ function handleTreeUpdate(root, showHostComponents) {
1971
+ if (lastRootCurrent === (root === null || root === void 0 ? void 0 : root.current)) return;
1972
+ lastRootCurrent = root === null || root === void 0 ? void 0 : root.current;
1973
+ setFiberRoot(root);
1974
+ if (updateTimer) clearTimeout(updateTimer);
1975
+ updateTimer = setTimeout(() => {
1976
+ const tree = buildTree(root, showHostComponents());
1977
+ if (tree) emitTree(tree);
1978
+ updateTimer = null;
1979
+ }, 200);
1980
+ }
1981
+ function rebuildTree(showHostComponents) {
1982
+ const appRoot = findAppRoot();
1983
+ if (!appRoot) return;
1984
+ setTimeout(() => {
1985
+ const tree = buildTree(appRoot, showHostComponents);
1986
+ if (tree) emitTree(tree);
1987
+ }, 100);
1988
+ }
1989
+ function createHook(showHostComponents) {
1990
+ let rendererIDCounter = 0;
1991
+ const renderers = /* @__PURE__ */ new Map();
1992
+ return {
1993
+ supportsFiber: true,
1994
+ renderers,
1995
+ inject(renderer) {
1996
+ const id = ++rendererIDCounter;
1997
+ renderers.set(id, renderer);
1998
+ return id;
1999
+ },
2000
+ getFiberRoots(rendererID) {
2001
+ return new Set(getRoots(rendererID));
2002
+ },
2003
+ onCommitFiberRoot(rendererID, root) {
2004
+ getRoots(rendererID).add(root);
2005
+ handleTreeUpdate(root, showHostComponents);
2006
+ },
2007
+ onCommitFiberUnmount() {}
2008
+ };
2009
+ }
2010
+ function patchHook(existingHook, showHostComponents) {
2011
+ if (existingHook.__REACT_DEVTOOLS_PATCHED__) return existingHook;
2012
+ if ((existingHook._instrumentationSource || "").includes("bippy") || window.__REACT_SCAN_INTERNALS__) {
2013
+ if (existingHook.renderers) for (const rendererID of existingHook.renderers.keys()) detectExistingRoots(rendererID);
2014
+ try {
2015
+ const scanInternals = window.__REACT_SCAN_INTERNALS__;
2016
+ if (scanInternals && scanInternals.options) setInterval(() => {
2017
+ if (existingHook.renderers) for (const rendererID of existingHook.renderers.keys()) getRoots(rendererID).forEach((root) => handleTreeUpdate(root, showHostComponents));
2018
+ }, 1e3);
2019
+ } catch (e) {
2020
+ console.warn("[React DevTools] Failed to attach to React Scan", e);
2021
+ }
2022
+ return existingHook;
2023
+ }
2024
+ const originalCommit = existingHook.onCommitFiberRoot;
2025
+ if (originalCommit) {
2026
+ const patchedCallback = function(rendererID, root) {
2027
+ let originalResult;
2028
+ try {
2029
+ originalResult = originalCommit.call(this, rendererID, root);
2030
+ } catch (e) {
2031
+ console.error("[React DevTools] Error in other devtools hook:", e);
2032
+ }
2033
+ try {
2034
+ getRoots(rendererID).add(root);
2035
+ handleTreeUpdate(root, showHostComponents);
2036
+ } catch (error) {}
2037
+ return originalResult;
2038
+ };
2039
+ Object.setPrototypeOf(patchedCallback, Object.getPrototypeOf(originalCommit));
2040
+ existingHook.onCommitFiberRoot = patchedCallback;
2041
+ } else existingHook.onCommitFiberRoot = (rendererID, root) => {
2042
+ getRoots(rendererID).add(root);
2043
+ handleTreeUpdate(root, showHostComponents);
2044
+ };
2045
+ if (!existingHook.getFiberRoots) existingHook.getFiberRoots = (rendererID) => new Set(getRoots(rendererID));
2046
+ existingHook.__REACT_DEVTOOLS_PATCHED__ = true;
2047
+ return existingHook;
2048
+ }
2049
+ function detectExistingRoots(rendererID) {
2050
+ const rootSelector = getRootSelector();
2051
+ function findRootFromContainer(container) {
2052
+ if (!container || typeof container !== "object") return null;
2053
+ if (container.containerInfo) return container;
2054
+ if (container.current) {
2055
+ const fiber = container.current;
2056
+ if (fiber.tag === 3 || fiber.tag === 24) return fiber.stateNode || container;
2057
+ const root = findRootFromFiber(fiber);
2058
+ if (root) return root;
2059
+ }
2060
+ if (container._reactRootContainer) {
2061
+ const root = findRootFromContainer(container._reactRootContainer);
2062
+ if (root) return root;
2063
+ }
2064
+ if (container._internalRoot) {
2065
+ const root = findRootFromContainer(container._internalRoot);
2066
+ if (root) return root;
2067
+ }
2068
+ return null;
2069
+ }
2070
+ function findRootFromFiber(fiber) {
2071
+ let current = fiber;
2072
+ let depth = 0;
2073
+ const maxDepth = 100;
2074
+ while (current && depth < maxDepth) {
2075
+ if (current.tag === 3 || current.tag === 24) return current.stateNode;
2076
+ current = current.return || current._debugOwner;
2077
+ depth++;
2078
+ }
2079
+ return null;
2080
+ }
2081
+ /**
2082
+ * Try to find React root from a single element
2083
+ */
2084
+ function findRootFromElement(element) {
2085
+ const keys = [...Object.keys(element), ...Object.getOwnPropertyNames(element)];
2086
+ const seenKeys = /* @__PURE__ */ new Set();
2087
+ for (const key of keys) {
2088
+ if (seenKeys.has(key)) continue;
2089
+ seenKeys.add(key);
2090
+ try {
2091
+ const value = element[key];
2092
+ if (!value || typeof value !== "object") continue;
2093
+ if (key.startsWith("__reactContainer")) {
2094
+ if (value && (value.tag === 3 || value.tag === 24)) {
2095
+ const fiberRoot$1 = value.stateNode;
2096
+ if (fiberRoot$1) return fiberRoot$1;
2097
+ }
2098
+ const root = findRootFromFiber(value);
2099
+ if (root) return root;
2100
+ } else if (key.startsWith("__reactFiber")) {
2101
+ const root = findRootFromFiber(value);
2102
+ if (root) return root;
2103
+ } else if (key.startsWith("__reactInternalInstance")) {
2104
+ const root = findRootFromFiber(value);
2105
+ if (root) return root;
2106
+ }
2107
+ } catch (e) {
2108
+ continue;
2109
+ }
2110
+ }
2111
+ return null;
2112
+ }
2113
+ /**
2114
+ * Check if a root's containerInfo is inside the target selector
2115
+ */
2116
+ function isRootContainerInSelector(root, selector) {
2117
+ const containerInfo = root.containerInfo;
2118
+ if (!containerInfo || !(containerInfo instanceof Element)) return false;
2119
+ const targetContainer = document.querySelector(selector);
2120
+ if (!targetContainer) return false;
2121
+ return containerInfo === targetContainer || targetContainer.contains(containerInfo);
2122
+ }
2123
+ function walkDOM(element) {
2124
+ if (rootSelector) {
2125
+ const targetElement = document.querySelector(rootSelector);
2126
+ if (targetElement) {
2127
+ const directRoot = findRootFromElement(targetElement);
2128
+ if (directRoot && isRootContainerInSelector(directRoot, rootSelector)) return directRoot;
2129
+ const walker$2 = document.createTreeWalker(targetElement, NodeFilter.SHOW_ELEMENT);
2130
+ let node$1 = walker$2.currentNode;
2131
+ while (node$1) {
2132
+ const root = findRootFromElement(node$1);
2133
+ if (root) {
2134
+ if (isRootContainerInSelector(root, rootSelector)) return root;
2135
+ }
2136
+ node$1 = walker$2.nextNode();
2137
+ }
2138
+ }
2139
+ return null;
2140
+ }
2141
+ for (const id of [
2142
+ "root",
2143
+ "app",
2144
+ "main",
2145
+ "app-root"
2146
+ ]) {
2147
+ const rootElement = document.getElementById(id);
2148
+ if (!rootElement) continue;
2149
+ const root = findRootFromElement(rootElement);
2150
+ if (root) return root;
2151
+ }
2152
+ const walker$1 = document.createTreeWalker(element, NodeFilter.SHOW_ELEMENT);
2153
+ let node = walker$1.currentNode;
2154
+ while (node) {
2155
+ const root = findRootFromElement(node);
2156
+ if (root) return root;
2157
+ node = walker$1.nextNode();
2158
+ }
2159
+ return null;
2160
+ }
2161
+ const existingRoot = walkDOM(document.body || document);
2162
+ if (existingRoot) {
2163
+ getRoots(rendererID).add(existingRoot);
2164
+ setTimeout(() => {
2165
+ handleTreeUpdate(existingRoot, () => false);
2166
+ }, 50);
2167
+ return true;
2168
+ }
2169
+ return false;
2170
+ }
2171
+ /**
2172
+ * Get the React version from the renderer
2173
+ */
2174
+ function getReactVersion() {
2175
+ const hook = globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__;
2176
+ if (!hook || !hook.renderers) return null;
2177
+ for (const renderer of hook.renderers.values()) {
2178
+ if (renderer && renderer.version) return renderer.version;
2179
+ if (renderer && renderer.reconcilerVersion) return renderer.reconcilerVersion;
2180
+ }
2181
+ if (typeof window !== "undefined") {
2182
+ const React = window.React;
2183
+ if (React && React.version) return React.version;
2184
+ }
2185
+ return null;
2186
+ }
2187
+ function installReactHook(showHostComponents) {
2188
+ const globalObj = globalThis;
2189
+ if (globalObj.__REACT_DEVTOOLS_GLOBAL_HOOK__) {
2190
+ const hook$1 = patchHook(globalObj.__REACT_DEVTOOLS_GLOBAL_HOOK__, showHostComponents);
2191
+ if (hook$1.renderers && hook$1.renderers.size > 0) for (const rendererID of hook$1.renderers.keys()) detectExistingRoots(rendererID);
2192
+ else detectExistingRoots(hook$1.inject({}));
2193
+ return;
2194
+ }
2195
+ const hook = createHook(showHostComponents);
2196
+ globalObj.__REACT_DEVTOOLS_GLOBAL_HOOK__ = hook;
2197
+ let attempts = 0;
2198
+ const maxAttempts = 10;
2199
+ function tryDetect() {
2200
+ attempts++;
2201
+ if (detectExistingRoots(hook.inject({}))) return;
2202
+ if (hook.renderers && hook.renderers.size > 0) {
2203
+ for (const rendererID of hook.renderers.keys()) if (detectExistingRoots(rendererID)) return;
2204
+ }
2205
+ if (attempts < maxAttempts) setTimeout(tryDetect, 200 * attempts);
2206
+ }
2207
+ tryDetect();
2208
+ setTimeout(() => {
2209
+ tryDetect();
2210
+ }, 50);
2211
+ }
2212
+
2213
+ //#endregion
2214
+ //#region src/core/inspector/index.ts
2215
+ let isInspectorEnabled = false;
2216
+ let inspectorMode = "select-component";
2217
+ const selectCallbacks = /* @__PURE__ */ new Set();
2218
+ const openInEditorCallbacks = /* @__PURE__ */ new Set();
2219
+ function onInspectorSelect(callback) {
2220
+ selectCallbacks.add(callback);
2221
+ return () => selectCallbacks.delete(callback);
2222
+ }
2223
+ function onOpenInEditor(callback) {
2224
+ openInEditorCallbacks.add(callback);
2225
+ return () => openInEditorCallbacks.delete(callback);
2226
+ }
2227
+ function emitSelect(fiberId) {
2228
+ selectCallbacks.forEach((cb) => cb(fiberId));
2229
+ }
2230
+ function emitOpenInEditor(fileName, line, column) {
2231
+ openInEditorCallbacks.forEach((cb) => cb(fileName, line, column));
2232
+ }
2233
+ function findNearestComponentFiber(fiber) {
2234
+ let current = fiber;
2235
+ while (current) {
2236
+ if (shouldIncludeFiber(current, false)) return current;
2237
+ current = current.return;
2238
+ }
2239
+ return null;
2240
+ }
2241
+ function findSourceFiber(fiber) {
2242
+ let current = fiber;
2243
+ while (current) {
2244
+ if (current._debugSource) return current;
2245
+ current = current.return;
2246
+ }
2247
+ return null;
2248
+ }
2249
+ function parseSourcePath(sourcePath) {
2250
+ const lastColon = sourcePath.lastIndexOf(":");
2251
+ if (lastColon === -1) return null;
2252
+ const secondLastColon = sourcePath.lastIndexOf(":", lastColon - 1);
2253
+ if (secondLastColon === -1) return null;
2254
+ const fileName = sourcePath.substring(0, secondLastColon);
2255
+ const lineNumber = Number.parseInt(sourcePath.substring(secondLastColon + 1, lastColon), 10);
2256
+ const columnNumber = Number.parseInt(sourcePath.substring(lastColon + 1), 10);
2257
+ if (Number.isNaN(lineNumber) || Number.isNaN(columnNumber)) return null;
2258
+ return {
2259
+ fileName,
2260
+ lineNumber,
2261
+ columnNumber
2262
+ };
2263
+ }
2264
+ function getSourceFromElement(element) {
2265
+ if (!element) return null;
2266
+ let current = element;
2267
+ while (current && current !== document.body) {
2268
+ const sourcePath = current.getAttribute("data-source-path");
2269
+ if (sourcePath) return parseSourcePath(sourcePath);
2270
+ current = current.parentElement;
2271
+ }
2272
+ return null;
2273
+ }
2274
+ function handleMouseOver(e) {
2275
+ if (!isInspectorEnabled) return;
2276
+ const target$1 = e.target;
2277
+ const fiber = getFiberFromElement(target$1);
2278
+ if (inspectorMode === "select-component") {
2279
+ const componentFiber = findNearestComponentFiber(fiber);
2280
+ if (componentFiber) highlightNode(componentFiber);
2281
+ else hideHighlight();
2282
+ } else if (inspectorMode === "open-in-editor") {
2283
+ const source = getSourceFromElement(target$1);
2284
+ if (source && fiber) highlightNode(fiber, source);
2285
+ else {
2286
+ const sourceFiber = findSourceFiber(fiber);
2287
+ if (sourceFiber) {
2288
+ const fallbackSource = sourceFiber._debugSource ? {
2289
+ fileName: sourceFiber._debugSource.fileName,
2290
+ lineNumber: sourceFiber._debugSource.lineNumber,
2291
+ columnNumber: sourceFiber._debugSource.columnNumber
2292
+ } : void 0;
2293
+ if (fiber) highlightNode(fiber, fallbackSource);
2294
+ else highlightNode(sourceFiber, fallbackSource);
2295
+ } else hideHighlight();
2296
+ }
2297
+ }
2298
+ }
2299
+ function handleClick(e) {
2300
+ if (!isInspectorEnabled) return;
2301
+ e.preventDefault();
2302
+ e.stopPropagation();
2303
+ const target$1 = e.target;
2304
+ const fiber = getFiberFromElement(target$1);
2305
+ if (inspectorMode === "select-component") {
2306
+ const componentFiber = findNearestComponentFiber(fiber);
2307
+ if (componentFiber) {
2308
+ emitSelect(getFiberId(componentFiber));
2309
+ toggleInspector(false);
2310
+ hideHighlight();
2311
+ }
2312
+ } else if (inspectorMode === "open-in-editor") {
2313
+ const source = getSourceFromElement(target$1);
2314
+ if (source) {
2315
+ const { fileName, lineNumber, columnNumber } = source;
2316
+ emitOpenInEditor(fileName, lineNumber, columnNumber);
2317
+ toggleInspector(false);
2318
+ hideHighlight();
2319
+ } else {
2320
+ const sourceFiber = findSourceFiber(fiber);
2321
+ if (sourceFiber && sourceFiber._debugSource) {
2322
+ const { fileName, lineNumber, columnNumber } = sourceFiber._debugSource;
2323
+ emitOpenInEditor(fileName, lineNumber, columnNumber);
2324
+ toggleInspector(false);
2325
+ hideHighlight();
2326
+ }
2327
+ }
2328
+ }
2329
+ }
2330
+ function toggleInspector(enabled, options = {}) {
2331
+ isInspectorEnabled = enabled;
2332
+ if (options.mode) inspectorMode = options.mode;
2333
+ if (enabled) {
2334
+ window.addEventListener("mouseover", handleMouseOver, true);
2335
+ window.addEventListener("click", handleClick, true);
2336
+ document.body.style.cursor = "default";
2337
+ } else {
2338
+ window.removeEventListener("mouseover", handleMouseOver, true);
2339
+ window.removeEventListener("click", handleClick, true);
2340
+ document.body.style.cursor = "";
2341
+ hideHighlight();
2342
+ }
2343
+ }
2344
+
2345
+ //#endregion
2346
+ //#region src/core/open-in-editor/index.ts
2347
+ /**
2348
+ * Try to open a file in the editor using URL protocol (fallback)
2349
+ */
2350
+ function tryOpenWithProtocol(fileName, line, column) {
2351
+ try {
2352
+ const protocolUrl = `${localStorage.getItem("react_devtools_editor") || "vscode"}://file/${fileName}:${line}:${column}`;
2353
+ const link = document.createElement("a");
2354
+ link.href = protocolUrl;
2355
+ link.click();
2356
+ link.remove();
2357
+ return true;
2358
+ } catch (e) {
2359
+ console.warn("[React DevTools] Failed to open with URL protocol:", e);
2360
+ return false;
2361
+ }
2362
+ }
2363
+ function openInEditor(fileName, line, column) {
2364
+ try {
2365
+ const url = `/__open-in-editor?file=${encodeURIComponent(`${fileName}:${line}:${column}`)}`;
2366
+ fetch(url).then((response) => {
2367
+ if (!response.ok) {
2368
+ console.warn("[React DevTools] Server endpoint failed, trying URL protocol fallback");
2369
+ tryOpenWithProtocol(fileName, line, column);
2370
+ }
2371
+ }).catch(() => {
2372
+ console.warn("[React DevTools] Fetch failed, trying URL protocol fallback");
2373
+ tryOpenWithProtocol(fileName, line, column);
2374
+ });
2375
+ } catch (e) {
2376
+ console.error("[React DevTools] Failed to open in editor:", e);
2377
+ tryOpenWithProtocol(fileName, line, column);
2378
+ }
2379
+ }
2380
+
2381
+ //#endregion
2382
+ //#region src/core/timeline/index.ts
2383
+ const TIMELINE_LAYERS = [
2384
+ {
2385
+ id: "mouse",
2386
+ label: "Mouse",
2387
+ color: "#A451AF",
2388
+ enabled: true
2389
+ },
2390
+ {
2391
+ id: "keyboard",
2392
+ label: "Keyboard",
2393
+ color: "#8151AF",
2394
+ enabled: true
2395
+ },
2396
+ {
2397
+ id: "component-event",
2398
+ label: "Component events",
2399
+ color: "#4FC08D",
2400
+ enabled: true
2401
+ },
2402
+ {
2403
+ id: "performance",
2404
+ label: "Performance",
2405
+ color: "#41B86A",
2406
+ enabled: true
2407
+ }
2408
+ ];
2409
+ let timelineState = {
2410
+ recordingState: false,
2411
+ mouseEventEnabled: true,
2412
+ keyboardEventEnabled: true,
2413
+ componentEventEnabled: true,
2414
+ performanceEventEnabled: true,
2415
+ selected: "mouse"
2416
+ };
2417
+ let eventIdCounter = 0;
2418
+ let groupIdCounter = 0;
2419
+ const perfGroupIds = /* @__PURE__ */ new Map();
2420
+ const timelineEventCallbacks = /* @__PURE__ */ new Set();
2421
+ function onTimelineEvent(callback) {
2422
+ timelineEventCallbacks.add(callback);
2423
+ return () => {
2424
+ timelineEventCallbacks.delete(callback);
2425
+ };
2426
+ }
2427
+ function emitTimelineEvent(layerId, event) {
2428
+ timelineEventCallbacks.forEach((callback) => {
2429
+ try {
2430
+ callback(layerId, event);
2431
+ } catch (e) {}
2432
+ });
2433
+ }
2434
+ function getTimelineState() {
2435
+ return _objectSpread2({}, timelineState);
2436
+ }
2437
+ function updateTimelineState(state) {
2438
+ timelineState = _objectSpread2(_objectSpread2({}, timelineState), state);
2439
+ }
2440
+ function clearTimeline() {
2441
+ eventIdCounter = 0;
2442
+ groupIdCounter = 0;
2443
+ perfGroupIds.clear();
2444
+ }
2445
+ function addMouseEvent(eventType, x, y) {
2446
+ if (!timelineState.recordingState || !timelineState.mouseEventEnabled) return;
2447
+ emitTimelineEvent("mouse", {
2448
+ id: ++eventIdCounter,
2449
+ time: Date.now(),
2450
+ data: {
2451
+ type: eventType,
2452
+ x,
2453
+ y
2454
+ },
2455
+ title: eventType
2456
+ });
2457
+ }
2458
+ function addKeyboardEvent(eventType, key, modifiers) {
2459
+ if (!timelineState.recordingState || !timelineState.keyboardEventEnabled) return;
2460
+ emitTimelineEvent("keyboard", {
2461
+ id: ++eventIdCounter,
2462
+ time: Date.now(),
2463
+ data: _objectSpread2({
2464
+ type: eventType,
2465
+ key
2466
+ }, modifiers),
2467
+ title: key,
2468
+ subtitle: eventType
2469
+ });
2470
+ }
2471
+ function addComponentEvent(componentName, eventName, params) {
2472
+ if (!timelineState.recordingState || !timelineState.componentEventEnabled) return;
2473
+ emitTimelineEvent("component-event", {
2474
+ id: ++eventIdCounter,
2475
+ time: Date.now(),
2476
+ data: {
2477
+ component: componentName,
2478
+ event: eventName,
2479
+ params
2480
+ },
2481
+ title: eventName,
2482
+ subtitle: `by ${componentName}`
2483
+ });
2484
+ }
2485
+ function getComponentName(fiber) {
2486
+ if (!fiber) return "Unknown";
2487
+ const type = fiber.elementType || fiber.type;
2488
+ if (!type) return "Unknown";
2489
+ if (typeof type === "string") return type;
2490
+ return type.displayName || type.name || "Anonymous";
2491
+ }
2492
+ function addPerformanceEvent(type, componentName, measure, duration, groupKey) {
2493
+ if (!timelineState.recordingState || !timelineState.performanceEventEnabled) return;
2494
+ let groupId;
2495
+ if (groupKey) if (measure === "start") {
2496
+ groupId = ++groupIdCounter;
2497
+ perfGroupIds.set(groupKey, {
2498
+ groupId,
2499
+ time: Date.now()
2500
+ });
2501
+ } else {
2502
+ const groupInfo = perfGroupIds.get(groupKey);
2503
+ if (groupInfo) {
2504
+ groupId = groupInfo.groupId;
2505
+ if (!duration) duration = Date.now() - groupInfo.time;
2506
+ perfGroupIds.delete(groupKey);
2507
+ }
2508
+ }
2509
+ emitTimelineEvent("performance", {
2510
+ id: ++eventIdCounter,
2511
+ time: Date.now(),
2512
+ data: _objectSpread2({
2513
+ component: componentName,
2514
+ type,
2515
+ measure
2516
+ }, duration !== void 0 && { duration: {
2517
+ value: duration,
2518
+ display: `${duration.toFixed(2)} ms`
2519
+ } }),
2520
+ title: componentName,
2521
+ subtitle: type,
2522
+ groupId
2523
+ });
2524
+ }
2525
+ const fiberPerfMap = /* @__PURE__ */ new Map();
2526
+ function trackFiberPerformanceStart(fiber, type) {
2527
+ const componentName = getComponentName(fiber);
2528
+ const key = `${fiber.key || "null"}-${componentName}-${type}`;
2529
+ fiberPerfMap.set(key, {
2530
+ time: performance.now(),
2531
+ fiber
2532
+ });
2533
+ addPerformanceEvent(type, componentName, "start", void 0, key);
2534
+ }
2535
+ function trackFiberPerformanceEnd(fiber, type) {
2536
+ const componentName = getComponentName(fiber);
2537
+ const key = `${fiber.key || "null"}-${componentName}-${type}`;
2538
+ const perfData = fiberPerfMap.get(key);
2539
+ if (perfData) {
2540
+ const duration = performance.now() - perfData.time;
2541
+ fiberPerfMap.delete(key);
2542
+ addPerformanceEvent(type, componentName, "end", duration, key);
2543
+ }
2544
+ }
2545
+ let eventListenersInstalled = false;
2546
+ function installTimelineEventListeners() {
2547
+ if (typeof window === "undefined" || eventListenersInstalled) return;
2548
+ eventListenersInstalled = true;
2549
+ [
2550
+ "mousedown",
2551
+ "mouseup",
2552
+ "click",
2553
+ "dblclick"
2554
+ ].forEach((eventType) => {
2555
+ window.addEventListener(eventType, (event) => {
2556
+ addMouseEvent(eventType, event.clientX, event.clientY);
2557
+ }, {
2558
+ capture: true,
2559
+ passive: true
2560
+ });
2561
+ });
2562
+ [
2563
+ "keyup",
2564
+ "keydown",
2565
+ "keypress"
2566
+ ].forEach((eventType) => {
2567
+ window.addEventListener(eventType, (event) => {
2568
+ addKeyboardEvent(eventType, event.key, {
2569
+ ctrlKey: event.ctrlKey,
2570
+ shiftKey: event.shiftKey,
2571
+ altKey: event.altKey,
2572
+ metaKey: event.metaKey
2573
+ });
2574
+ }, {
2575
+ capture: true,
2576
+ passive: true
2577
+ });
2578
+ });
2579
+ }
2580
+
2581
+ //#endregion
2582
+ //#region ../../node_modules/.pnpm/birpc@2.8.0/node_modules/birpc/dist/index.mjs
2583
+ const TYPE_REQUEST = "q";
2584
+ const TYPE_RESPONSE = "s";
2585
+ const DEFAULT_TIMEOUT = 6e4;
2586
+ function defaultSerialize(i) {
2587
+ return i;
2588
+ }
2589
+ const defaultDeserialize = defaultSerialize;
2590
+ const { clearTimeout: clearTimeout$1, setTimeout: setTimeout$1 } = globalThis;
2591
+ const random = Math.random.bind(Math);
2592
+ function createBirpc($functions, options) {
2593
+ const { post, on, off = () => {}, eventNames = [], serialize: serialize$1 = defaultSerialize, deserialize: deserialize$1 = defaultDeserialize, resolver, bind = "rpc", timeout = DEFAULT_TIMEOUT } = options;
2594
+ let $closed = false;
2595
+ const _rpcPromiseMap = /* @__PURE__ */ new Map();
2596
+ let _promiseInit;
2597
+ async function _call(method, args, event, optional) {
2598
+ if ($closed) throw new Error(`[birpc] rpc is closed, cannot call "${method}"`);
2599
+ const req = {
2600
+ m: method,
2601
+ a: args,
2602
+ t: TYPE_REQUEST
2603
+ };
2604
+ if (optional) req.o = true;
2605
+ const send = async (_req) => post(serialize$1(_req));
2606
+ if (event) {
2607
+ await send(req);
2608
+ return;
2609
+ }
2610
+ if (_promiseInit) try {
2611
+ await _promiseInit;
2612
+ } finally {
2613
+ _promiseInit = void 0;
2614
+ }
2615
+ let { promise, resolve, reject } = createPromiseWithResolvers();
2616
+ const id = nanoid();
2617
+ req.i = id;
2618
+ let timeoutId;
2619
+ async function handler(newReq = req) {
2620
+ if (timeout >= 0) {
2621
+ var _timeoutId$unref;
2622
+ timeoutId = setTimeout$1(() => {
2623
+ try {
2624
+ var _options$onTimeoutErr;
2625
+ if (((_options$onTimeoutErr = options.onTimeoutError) === null || _options$onTimeoutErr === void 0 ? void 0 : _options$onTimeoutErr.call(options, method, args)) !== true) throw new Error(`[birpc] timeout on calling "${method}"`);
2626
+ } catch (e) {
2627
+ reject(e);
2628
+ }
2629
+ _rpcPromiseMap.delete(id);
2630
+ }, timeout);
2631
+ if (typeof timeoutId === "object") timeoutId = (_timeoutId$unref = timeoutId.unref) === null || _timeoutId$unref === void 0 ? void 0 : _timeoutId$unref.call(timeoutId);
2632
+ }
2633
+ _rpcPromiseMap.set(id, {
2634
+ resolve,
2635
+ reject,
2636
+ timeoutId,
2637
+ method
2638
+ });
2639
+ await send(newReq);
2640
+ return promise;
2641
+ }
2642
+ try {
2643
+ if (options.onRequest) await options.onRequest(req, handler, resolve);
2644
+ else await handler();
2645
+ } catch (e) {
2646
+ var _options$onGeneralErr;
2647
+ if (((_options$onGeneralErr = options.onGeneralError) === null || _options$onGeneralErr === void 0 ? void 0 : _options$onGeneralErr.call(options, e)) !== true) throw e;
2648
+ return;
2649
+ } finally {
2650
+ clearTimeout$1(timeoutId);
2651
+ _rpcPromiseMap.delete(id);
2652
+ }
2653
+ return promise;
2654
+ }
2655
+ const $call = (method, ...args) => _call(method, args, false);
2656
+ const $callOptional = (method, ...args) => _call(method, args, false, true);
2657
+ const $callEvent = (method, ...args) => _call(method, args, true);
2658
+ const $callRaw = (options2) => _call(options2.method, options2.args, options2.event, options2.optional);
2659
+ const builtinMethods = {
2660
+ $call,
2661
+ $callOptional,
2662
+ $callEvent,
2663
+ $callRaw,
2664
+ $rejectPendingCalls,
2665
+ get $closed() {
2666
+ return $closed;
2667
+ },
2668
+ $close,
2669
+ $functions
2670
+ };
2671
+ const rpc = new Proxy({}, { get(_, method) {
2672
+ if (Object.prototype.hasOwnProperty.call(builtinMethods, method)) return builtinMethods[method];
2673
+ if (method === "then" && !eventNames.includes("then") && !("then" in $functions)) return void 0;
2674
+ const sendEvent = (...args) => _call(method, args, true);
2675
+ if (eventNames.includes(method)) {
2676
+ sendEvent.asEvent = sendEvent;
2677
+ return sendEvent;
2678
+ }
2679
+ const sendCall = (...args) => _call(method, args, false);
2680
+ sendCall.asEvent = sendEvent;
2681
+ return sendCall;
2682
+ } });
2683
+ function $close(customError) {
2684
+ $closed = true;
2685
+ _rpcPromiseMap.forEach(({ reject, method }) => {
2686
+ const error = /* @__PURE__ */ new Error(`[birpc] rpc is closed, cannot call "${method}"`);
2687
+ if (customError) {
2688
+ var _customError$cause;
2689
+ (_customError$cause = customError.cause) !== null && _customError$cause !== void 0 || (customError.cause = error);
2690
+ return reject(customError);
2691
+ }
2692
+ reject(error);
2693
+ });
2694
+ _rpcPromiseMap.clear();
2695
+ off(onMessage);
2696
+ }
2697
+ function $rejectPendingCalls(handler) {
2698
+ const handlerResults = Array.from(_rpcPromiseMap.values()).map(({ method, reject }) => {
2699
+ if (!handler) return reject(/* @__PURE__ */ new Error(`[birpc]: rejected pending call "${method}".`));
2700
+ return handler({
2701
+ method,
2702
+ reject
2703
+ });
2704
+ });
2705
+ _rpcPromiseMap.clear();
2706
+ return handlerResults;
2707
+ }
2708
+ async function onMessage(data, ...extra) {
2709
+ let msg;
2710
+ try {
2711
+ msg = deserialize$1(data);
2712
+ } catch (e) {
2713
+ var _options$onGeneralErr2;
2714
+ if (((_options$onGeneralErr2 = options.onGeneralError) === null || _options$onGeneralErr2 === void 0 ? void 0 : _options$onGeneralErr2.call(options, e)) !== true) throw e;
2715
+ return;
2716
+ }
2717
+ if (msg.t === TYPE_REQUEST) {
2718
+ const { m: method, a: args, o: optional } = msg;
2719
+ let result, error;
2720
+ let fn = await (resolver ? resolver(method, $functions[method]) : $functions[method]);
2721
+ if (optional) fn || (fn = () => void 0);
2722
+ if (!fn) error = /* @__PURE__ */ new Error(`[birpc] function "${method}" not found`);
2723
+ else try {
2724
+ result = await fn.apply(bind === "rpc" ? rpc : $functions, args);
2725
+ } catch (e) {
2726
+ error = e;
2727
+ }
2728
+ if (msg.i) {
2729
+ if (error && options.onError) options.onError(error, method, args);
2730
+ if (error && options.onFunctionError) {
2731
+ if (options.onFunctionError(error, method, args) === true) return;
2732
+ }
2733
+ if (!error) try {
2734
+ await post(serialize$1({
2735
+ t: TYPE_RESPONSE,
2736
+ i: msg.i,
2737
+ r: result
2738
+ }), ...extra);
2739
+ return;
2740
+ } catch (e) {
2741
+ var _options$onGeneralErr3;
2742
+ error = e;
2743
+ if (((_options$onGeneralErr3 = options.onGeneralError) === null || _options$onGeneralErr3 === void 0 ? void 0 : _options$onGeneralErr3.call(options, e, method, args)) !== true) throw e;
2744
+ }
2745
+ try {
2746
+ await post(serialize$1({
2747
+ t: TYPE_RESPONSE,
2748
+ i: msg.i,
2749
+ e: error
2750
+ }), ...extra);
2751
+ } catch (e) {
2752
+ var _options$onGeneralErr4;
2753
+ if (((_options$onGeneralErr4 = options.onGeneralError) === null || _options$onGeneralErr4 === void 0 ? void 0 : _options$onGeneralErr4.call(options, e, method, args)) !== true) throw e;
2754
+ }
2755
+ }
2756
+ } else {
2757
+ const { i: ack, r: result, e: error } = msg;
2758
+ const promise = _rpcPromiseMap.get(ack);
2759
+ if (promise) {
2760
+ clearTimeout$1(promise.timeoutId);
2761
+ if (error) promise.reject(error);
2762
+ else promise.resolve(result);
2763
+ }
2764
+ _rpcPromiseMap.delete(ack);
2765
+ }
2766
+ }
2767
+ _promiseInit = on(onMessage);
2768
+ return rpc;
2769
+ }
2770
+ const cacheMap = /* @__PURE__ */ new WeakMap();
2771
+ function cachedMap(items, fn) {
2772
+ return items.map((i) => {
2773
+ let r = cacheMap.get(i);
2774
+ if (!r) {
2775
+ r = fn(i);
2776
+ cacheMap.set(i, r);
2777
+ }
2778
+ return r;
2779
+ });
2780
+ }
2781
+ function createBirpcGroup(functions, channels, options = {}) {
2782
+ const getChannels = () => typeof channels === "function" ? channels() : channels;
2783
+ const getClients = (channels2 = getChannels()) => cachedMap(channels2, (s) => createBirpc(functions, _objectSpread2(_objectSpread2({}, options), s)));
2784
+ function _boardcast(method, args, event, optional) {
2785
+ const clients = getClients();
2786
+ return Promise.all(clients.map((c) => c.$callRaw({
2787
+ method,
2788
+ args,
2789
+ event,
2790
+ optional
2791
+ })));
2792
+ }
2793
+ function $call(method, ...args) {
2794
+ return _boardcast(method, args, false);
2795
+ }
2796
+ function $callOptional(method, ...args) {
2797
+ return _boardcast(method, args, false, true);
2798
+ }
2799
+ function $callEvent(method, ...args) {
2800
+ return _boardcast(method, args, true);
2801
+ }
2802
+ const broadcastBuiltin = {
2803
+ $call,
2804
+ $callOptional,
2805
+ $callEvent
2806
+ };
2807
+ const broadcastProxy = new Proxy({}, { get(_, method) {
2808
+ if (Object.prototype.hasOwnProperty.call(broadcastBuiltin, method)) return broadcastBuiltin[method];
2809
+ const callbacks = getClients().map((c) => c[method]);
2810
+ const sendCall = (...args) => {
2811
+ return Promise.all(callbacks.map((i) => i(...args)));
2812
+ };
2813
+ sendCall.asEvent = async (...args) => {
2814
+ await Promise.all(callbacks.map((i) => i.asEvent(...args)));
2815
+ };
2816
+ return sendCall;
2817
+ } });
2818
+ function updateChannels(fn) {
2819
+ const channels2 = getChannels();
2820
+ fn === null || fn === void 0 || fn(channels2);
2821
+ return getClients(channels2);
2822
+ }
2823
+ getClients();
2824
+ return {
2825
+ get clients() {
2826
+ return getClients();
2827
+ },
2828
+ functions,
2829
+ updateChannels,
2830
+ broadcast: broadcastProxy,
2831
+ boardcast: broadcastProxy
2832
+ };
2833
+ }
2834
+ function createPromiseWithResolvers() {
2835
+ let resolve;
2836
+ let reject;
2837
+ return {
2838
+ promise: new Promise((res, rej) => {
2839
+ resolve = res;
2840
+ reject = rej;
2841
+ }),
2842
+ resolve,
2843
+ reject
2844
+ };
2845
+ }
2846
+ const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
2847
+ function nanoid(size = 21) {
2848
+ let id = "";
2849
+ let i = size;
2850
+ while (i--) id += urlAlphabet[random() * 64 | 0];
2851
+ return id;
2852
+ }
2853
+
2854
+ //#endregion
2855
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/double-indexed-kv.js
2856
+ var DoubleIndexedKV = class {
2857
+ constructor() {
2858
+ this.keyToValue = /* @__PURE__ */ new Map();
2859
+ this.valueToKey = /* @__PURE__ */ new Map();
2860
+ }
2861
+ set(key, value) {
2862
+ this.keyToValue.set(key, value);
2863
+ this.valueToKey.set(value, key);
2864
+ }
2865
+ getByKey(key) {
2866
+ return this.keyToValue.get(key);
2867
+ }
2868
+ getByValue(value) {
2869
+ return this.valueToKey.get(value);
2870
+ }
2871
+ clear() {
2872
+ this.keyToValue.clear();
2873
+ this.valueToKey.clear();
2874
+ }
2875
+ };
2876
+
2877
+ //#endregion
2878
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/registry.js
2879
+ var Registry = class {
2880
+ constructor(generateIdentifier) {
2881
+ this.generateIdentifier = generateIdentifier;
2882
+ this.kv = new DoubleIndexedKV();
2883
+ }
2884
+ register(value, identifier) {
2885
+ if (this.kv.getByValue(value)) return;
2886
+ if (!identifier) identifier = this.generateIdentifier(value);
2887
+ this.kv.set(identifier, value);
2888
+ }
2889
+ clear() {
2890
+ this.kv.clear();
2891
+ }
2892
+ getIdentifier(value) {
2893
+ return this.kv.getByValue(value);
2894
+ }
2895
+ getValue(identifier) {
2896
+ return this.kv.getByKey(identifier);
2897
+ }
2898
+ };
2899
+
2900
+ //#endregion
2901
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/class-registry.js
2902
+ var ClassRegistry = class extends Registry {
2903
+ constructor() {
2904
+ super((c) => c.name);
2905
+ this.classToAllowedProps = /* @__PURE__ */ new Map();
2906
+ }
2907
+ register(value, options) {
2908
+ if (typeof options === "object") {
2909
+ if (options.allowProps) this.classToAllowedProps.set(value, options.allowProps);
2910
+ super.register(value, options.identifier);
2911
+ } else super.register(value, options);
2912
+ }
2913
+ getAllowedProps(value) {
2914
+ return this.classToAllowedProps.get(value);
2915
+ }
2916
+ };
2917
+
2918
+ //#endregion
2919
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/util.js
2920
+ function valuesOfObj(record) {
2921
+ if ("values" in Object) return Object.values(record);
2922
+ const values = [];
2923
+ for (const key in record) if (record.hasOwnProperty(key)) values.push(record[key]);
2924
+ return values;
2925
+ }
2926
+ function find(record, predicate) {
2927
+ const values = valuesOfObj(record);
2928
+ if ("find" in values) return values.find(predicate);
2929
+ const valuesNotNever = values;
2930
+ for (let i = 0; i < valuesNotNever.length; i++) {
2931
+ const value = valuesNotNever[i];
2932
+ if (predicate(value)) return value;
2933
+ }
2934
+ }
2935
+ function forEach(record, run) {
2936
+ Object.entries(record).forEach(([key, value]) => run(value, key));
2937
+ }
2938
+ function includes(arr, value) {
2939
+ return arr.indexOf(value) !== -1;
2940
+ }
2941
+ function findArr(record, predicate) {
2942
+ for (let i = 0; i < record.length; i++) {
2943
+ const value = record[i];
2944
+ if (predicate(value)) return value;
2945
+ }
2946
+ }
2947
+
2948
+ //#endregion
2949
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/custom-transformer-registry.js
2950
+ var CustomTransformerRegistry = class {
2951
+ constructor() {
2952
+ this.transfomers = {};
2953
+ }
2954
+ register(transformer) {
2955
+ this.transfomers[transformer.name] = transformer;
2956
+ }
2957
+ findApplicable(v) {
2958
+ return find(this.transfomers, (transformer) => transformer.isApplicable(v));
2959
+ }
2960
+ findByName(name) {
2961
+ return this.transfomers[name];
2962
+ }
2963
+ };
2964
+
2965
+ //#endregion
2966
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/is.js
2967
+ const getType$1 = (payload) => Object.prototype.toString.call(payload).slice(8, -1);
2968
+ const isUndefined = (payload) => typeof payload === "undefined";
2969
+ const isNull = (payload) => payload === null;
2970
+ const isPlainObject$1 = (payload) => {
2971
+ if (typeof payload !== "object" || payload === null) return false;
2972
+ if (payload === Object.prototype) return false;
2973
+ if (Object.getPrototypeOf(payload) === null) return true;
2974
+ return Object.getPrototypeOf(payload) === Object.prototype;
2975
+ };
2976
+ const isEmptyObject = (payload) => isPlainObject$1(payload) && Object.keys(payload).length === 0;
2977
+ const isArray$1 = (payload) => Array.isArray(payload);
2978
+ const isString = (payload) => typeof payload === "string";
2979
+ const isNumber = (payload) => typeof payload === "number" && !isNaN(payload);
2980
+ const isBoolean = (payload) => typeof payload === "boolean";
2981
+ const isRegExp = (payload) => payload instanceof RegExp;
2982
+ const isMap = (payload) => payload instanceof Map;
2983
+ const isSet = (payload) => payload instanceof Set;
2984
+ const isSymbol = (payload) => getType$1(payload) === "Symbol";
2985
+ const isDate = (payload) => payload instanceof Date && !isNaN(payload.valueOf());
2986
+ const isError = (payload) => payload instanceof Error;
2987
+ const isNaNValue = (payload) => typeof payload === "number" && isNaN(payload);
2988
+ const isPrimitive = (payload) => isBoolean(payload) || isNull(payload) || isUndefined(payload) || isNumber(payload) || isString(payload) || isSymbol(payload);
2989
+ const isBigint = (payload) => typeof payload === "bigint";
2990
+ const isInfinite = (payload) => payload === Infinity || payload === -Infinity;
2991
+ const isTypedArray = (payload) => ArrayBuffer.isView(payload) && !(payload instanceof DataView);
2992
+ const isURL = (payload) => payload instanceof URL;
2993
+
2994
+ //#endregion
2995
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/pathstringifier.js
2996
+ const escapeKey = (key) => key.replace(/\\/g, "\\\\").replace(/\./g, "\\.");
2997
+ const stringifyPath = (path) => path.map(String).map(escapeKey).join(".");
2998
+ const parsePath = (string, legacyPaths) => {
2999
+ const result = [];
3000
+ let segment = "";
3001
+ for (let i = 0; i < string.length; i++) {
3002
+ let char = string.charAt(i);
3003
+ if (!legacyPaths && char === "\\") {
3004
+ const escaped = string.charAt(i + 1);
3005
+ if (escaped === "\\") {
3006
+ segment += "\\";
3007
+ i++;
3008
+ continue;
3009
+ } else if (escaped !== ".") throw Error("invalid path");
3010
+ }
3011
+ if (char === "\\" && string.charAt(i + 1) === ".") {
3012
+ segment += ".";
3013
+ i++;
3014
+ continue;
3015
+ }
3016
+ if (char === ".") {
3017
+ result.push(segment);
3018
+ segment = "";
3019
+ continue;
3020
+ }
3021
+ segment += char;
3022
+ }
3023
+ const lastSegment = segment;
3024
+ result.push(lastSegment);
3025
+ return result;
3026
+ };
3027
+
3028
+ //#endregion
3029
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/transformer.js
3030
+ function simpleTransformation(isApplicable, annotation, transform, untransform) {
3031
+ return {
3032
+ isApplicable,
3033
+ annotation,
3034
+ transform,
3035
+ untransform
3036
+ };
3037
+ }
3038
+ const simpleRules = [
3039
+ simpleTransformation(isUndefined, "undefined", () => null, () => void 0),
3040
+ simpleTransformation(isBigint, "bigint", (v) => v.toString(), (v) => {
3041
+ if (typeof BigInt !== "undefined") return BigInt(v);
3042
+ console.error("Please add a BigInt polyfill.");
3043
+ return v;
3044
+ }),
3045
+ simpleTransformation(isDate, "Date", (v) => v.toISOString(), (v) => new Date(v)),
3046
+ simpleTransformation(isError, "Error", (v, superJson) => {
3047
+ const baseError = {
3048
+ name: v.name,
3049
+ message: v.message
3050
+ };
3051
+ if ("cause" in v) baseError.cause = v.cause;
3052
+ superJson.allowedErrorProps.forEach((prop) => {
3053
+ baseError[prop] = v[prop];
3054
+ });
3055
+ return baseError;
3056
+ }, (v, superJson) => {
3057
+ const e = new Error(v.message, { cause: v.cause });
3058
+ e.name = v.name;
3059
+ e.stack = v.stack;
3060
+ superJson.allowedErrorProps.forEach((prop) => {
3061
+ e[prop] = v[prop];
3062
+ });
3063
+ return e;
3064
+ }),
3065
+ simpleTransformation(isRegExp, "regexp", (v) => "" + v, (regex) => {
3066
+ const body = regex.slice(1, regex.lastIndexOf("/"));
3067
+ const flags = regex.slice(regex.lastIndexOf("/") + 1);
3068
+ return new RegExp(body, flags);
3069
+ }),
3070
+ simpleTransformation(isSet, "set", (v) => [...v.values()], (v) => new Set(v)),
3071
+ simpleTransformation(isMap, "map", (v) => [...v.entries()], (v) => new Map(v)),
3072
+ simpleTransformation((v) => isNaNValue(v) || isInfinite(v), "number", (v) => {
3073
+ if (isNaNValue(v)) return "NaN";
3074
+ if (v > 0) return "Infinity";
3075
+ else return "-Infinity";
3076
+ }, Number),
3077
+ simpleTransformation((v) => v === 0 && 1 / v === -Infinity, "number", () => {
3078
+ return "-0";
3079
+ }, Number),
3080
+ simpleTransformation(isURL, "URL", (v) => v.toString(), (v) => new URL(v))
3081
+ ];
3082
+ function compositeTransformation(isApplicable, annotation, transform, untransform) {
3083
+ return {
3084
+ isApplicable,
3085
+ annotation,
3086
+ transform,
3087
+ untransform
3088
+ };
3089
+ }
3090
+ const symbolRule = compositeTransformation((s, superJson) => {
3091
+ if (isSymbol(s)) return !!superJson.symbolRegistry.getIdentifier(s);
3092
+ return false;
3093
+ }, (s, superJson) => {
3094
+ return ["symbol", superJson.symbolRegistry.getIdentifier(s)];
3095
+ }, (v) => v.description, (_, a, superJson) => {
3096
+ const value = superJson.symbolRegistry.getValue(a[1]);
3097
+ if (!value) throw new Error("Trying to deserialize unknown symbol");
3098
+ return value;
3099
+ });
3100
+ const constructorToName = [
3101
+ Int8Array,
3102
+ Uint8Array,
3103
+ Int16Array,
3104
+ Uint16Array,
3105
+ Int32Array,
3106
+ Uint32Array,
3107
+ Float32Array,
3108
+ Float64Array,
3109
+ Uint8ClampedArray
3110
+ ].reduce((obj, ctor) => {
3111
+ obj[ctor.name] = ctor;
3112
+ return obj;
3113
+ }, {});
3114
+ const typedArrayRule = compositeTransformation(isTypedArray, (v) => ["typed-array", v.constructor.name], (v) => [...v], (v, a) => {
3115
+ const ctor = constructorToName[a[1]];
3116
+ if (!ctor) throw new Error("Trying to deserialize unknown typed array");
3117
+ return new ctor(v);
3118
+ });
3119
+ function isInstanceOfRegisteredClass(potentialClass, superJson) {
3120
+ if (potentialClass === null || potentialClass === void 0 ? void 0 : potentialClass.constructor) return !!superJson.classRegistry.getIdentifier(potentialClass.constructor);
3121
+ return false;
3122
+ }
3123
+ const classRule = compositeTransformation(isInstanceOfRegisteredClass, (clazz, superJson) => {
3124
+ return ["class", superJson.classRegistry.getIdentifier(clazz.constructor)];
3125
+ }, (clazz, superJson) => {
3126
+ const allowedProps = superJson.classRegistry.getAllowedProps(clazz.constructor);
3127
+ if (!allowedProps) return _objectSpread2({}, clazz);
3128
+ const result = {};
3129
+ allowedProps.forEach((prop) => {
3130
+ result[prop] = clazz[prop];
3131
+ });
3132
+ return result;
3133
+ }, (v, a, superJson) => {
3134
+ const clazz = superJson.classRegistry.getValue(a[1]);
3135
+ if (!clazz) throw new Error(`Trying to deserialize unknown class '${a[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
3136
+ return Object.assign(Object.create(clazz.prototype), v);
3137
+ });
3138
+ const customRule = compositeTransformation((value, superJson) => {
3139
+ return !!superJson.customTransformerRegistry.findApplicable(value);
3140
+ }, (value, superJson) => {
3141
+ return ["custom", superJson.customTransformerRegistry.findApplicable(value).name];
3142
+ }, (value, superJson) => {
3143
+ return superJson.customTransformerRegistry.findApplicable(value).serialize(value);
3144
+ }, (v, a, superJson) => {
3145
+ const transformer = superJson.customTransformerRegistry.findByName(a[1]);
3146
+ if (!transformer) throw new Error("Trying to deserialize unknown custom value");
3147
+ return transformer.deserialize(v);
3148
+ });
3149
+ const compositeRules = [
3150
+ classRule,
3151
+ symbolRule,
3152
+ customRule,
3153
+ typedArrayRule
3154
+ ];
3155
+ const transformValue = (value, superJson) => {
3156
+ const applicableCompositeRule = findArr(compositeRules, (rule) => rule.isApplicable(value, superJson));
3157
+ if (applicableCompositeRule) return {
3158
+ value: applicableCompositeRule.transform(value, superJson),
3159
+ type: applicableCompositeRule.annotation(value, superJson)
3160
+ };
3161
+ const applicableSimpleRule = findArr(simpleRules, (rule) => rule.isApplicable(value, superJson));
3162
+ if (applicableSimpleRule) return {
3163
+ value: applicableSimpleRule.transform(value, superJson),
3164
+ type: applicableSimpleRule.annotation
3165
+ };
3166
+ };
3167
+ const simpleRulesByAnnotation = {};
3168
+ simpleRules.forEach((rule) => {
3169
+ simpleRulesByAnnotation[rule.annotation] = rule;
3170
+ });
3171
+ const untransformValue = (json, type, superJson) => {
3172
+ if (isArray$1(type)) switch (type[0]) {
3173
+ case "symbol": return symbolRule.untransform(json, type, superJson);
3174
+ case "class": return classRule.untransform(json, type, superJson);
3175
+ case "custom": return customRule.untransform(json, type, superJson);
3176
+ case "typed-array": return typedArrayRule.untransform(json, type, superJson);
3177
+ default: throw new Error("Unknown transformation: " + type);
3178
+ }
3179
+ else {
3180
+ const transformation = simpleRulesByAnnotation[type];
3181
+ if (!transformation) throw new Error("Unknown transformation: " + type);
3182
+ return transformation.untransform(json, superJson);
3183
+ }
3184
+ };
3185
+
3186
+ //#endregion
3187
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/accessDeep.js
3188
+ const getNthKey = (value, n) => {
3189
+ if (n > value.size) throw new Error("index out of bounds");
3190
+ const keys = value.keys();
3191
+ while (n > 0) {
3192
+ keys.next();
3193
+ n--;
3194
+ }
3195
+ return keys.next().value;
3196
+ };
3197
+ function validatePath(path) {
3198
+ if (includes(path, "__proto__")) throw new Error("__proto__ is not allowed as a property");
3199
+ if (includes(path, "prototype")) throw new Error("prototype is not allowed as a property");
3200
+ if (includes(path, "constructor")) throw new Error("constructor is not allowed as a property");
3201
+ }
3202
+ const getDeep = (object, path) => {
3203
+ validatePath(path);
3204
+ for (let i = 0; i < path.length; i++) {
3205
+ const key = path[i];
3206
+ if (isSet(object)) object = getNthKey(object, +key);
3207
+ else if (isMap(object)) {
3208
+ const row = +key;
3209
+ const type = +path[++i] === 0 ? "key" : "value";
3210
+ const keyOfRow = getNthKey(object, row);
3211
+ switch (type) {
3212
+ case "key":
3213
+ object = keyOfRow;
3214
+ break;
3215
+ case "value":
3216
+ object = object.get(keyOfRow);
3217
+ break;
3218
+ }
3219
+ } else object = object[key];
3220
+ }
3221
+ return object;
3222
+ };
3223
+ const setDeep = (object, path, mapper) => {
3224
+ validatePath(path);
3225
+ if (path.length === 0) return mapper(object);
3226
+ let parent = object;
3227
+ for (let i = 0; i < path.length - 1; i++) {
3228
+ const key = path[i];
3229
+ if (isArray$1(parent)) {
3230
+ const index = +key;
3231
+ parent = parent[index];
3232
+ } else if (isPlainObject$1(parent)) parent = parent[key];
3233
+ else if (isSet(parent)) {
3234
+ const row = +key;
3235
+ parent = getNthKey(parent, row);
3236
+ } else if (isMap(parent)) {
3237
+ if (i === path.length - 2) break;
3238
+ const row = +key;
3239
+ const type = +path[++i] === 0 ? "key" : "value";
3240
+ const keyOfRow = getNthKey(parent, row);
3241
+ switch (type) {
3242
+ case "key":
3243
+ parent = keyOfRow;
3244
+ break;
3245
+ case "value":
3246
+ parent = parent.get(keyOfRow);
3247
+ break;
3248
+ }
3249
+ }
3250
+ }
3251
+ const lastKey = path[path.length - 1];
3252
+ if (isArray$1(parent)) parent[+lastKey] = mapper(parent[+lastKey]);
3253
+ else if (isPlainObject$1(parent)) parent[lastKey] = mapper(parent[lastKey]);
3254
+ if (isSet(parent)) {
3255
+ const oldValue = getNthKey(parent, +lastKey);
3256
+ const newValue = mapper(oldValue);
3257
+ if (oldValue !== newValue) {
3258
+ parent.delete(oldValue);
3259
+ parent.add(newValue);
3260
+ }
3261
+ }
3262
+ if (isMap(parent)) {
3263
+ const row = +path[path.length - 2];
3264
+ const keyToRow = getNthKey(parent, row);
3265
+ switch (+lastKey === 0 ? "key" : "value") {
3266
+ case "key": {
3267
+ const newKey = mapper(keyToRow);
3268
+ parent.set(newKey, parent.get(keyToRow));
3269
+ if (newKey !== keyToRow) parent.delete(keyToRow);
3270
+ break;
3271
+ }
3272
+ case "value":
3273
+ parent.set(keyToRow, mapper(parent.get(keyToRow)));
3274
+ break;
3275
+ }
3276
+ }
3277
+ return object;
3278
+ };
3279
+
3280
+ //#endregion
3281
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/plainer.js
3282
+ const enableLegacyPaths = (version) => version < 1;
3283
+ function traverse(tree, walker$1, version, origin = []) {
3284
+ if (!tree) return;
3285
+ const legacyPaths = enableLegacyPaths(version);
3286
+ if (!isArray$1(tree)) {
3287
+ forEach(tree, (subtree, key) => traverse(subtree, walker$1, version, [...origin, ...parsePath(key, legacyPaths)]));
3288
+ return;
3289
+ }
3290
+ const [nodeValue, children] = tree;
3291
+ if (children) forEach(children, (child, key) => {
3292
+ traverse(child, walker$1, version, [...origin, ...parsePath(key, legacyPaths)]);
3293
+ });
3294
+ walker$1(nodeValue, origin);
3295
+ }
3296
+ function applyValueAnnotations(plain, annotations, version, superJson) {
3297
+ traverse(annotations, (type, path) => {
3298
+ plain = setDeep(plain, path, (v) => untransformValue(v, type, superJson));
3299
+ }, version);
3300
+ return plain;
3301
+ }
3302
+ function applyReferentialEqualityAnnotations(plain, annotations, version) {
3303
+ const legacyPaths = enableLegacyPaths(version);
3304
+ function apply(identicalPaths, path) {
3305
+ const object = getDeep(plain, parsePath(path, legacyPaths));
3306
+ identicalPaths.map((path$1) => parsePath(path$1, legacyPaths)).forEach((identicalObjectPath) => {
3307
+ plain = setDeep(plain, identicalObjectPath, () => object);
3308
+ });
3309
+ }
3310
+ if (isArray$1(annotations)) {
3311
+ const [root, other] = annotations;
3312
+ root.forEach((identicalPath) => {
3313
+ plain = setDeep(plain, parsePath(identicalPath, legacyPaths), () => plain);
3314
+ });
3315
+ if (other) forEach(other, apply);
3316
+ } else forEach(annotations, apply);
3317
+ return plain;
3318
+ }
3319
+ const isDeep = (object, superJson) => isPlainObject$1(object) || isArray$1(object) || isMap(object) || isSet(object) || isError(object) || isInstanceOfRegisteredClass(object, superJson);
3320
+ function addIdentity(object, path, identities) {
3321
+ const existingSet = identities.get(object);
3322
+ if (existingSet) existingSet.push(path);
3323
+ else identities.set(object, [path]);
3324
+ }
3325
+ function generateReferentialEqualityAnnotations(identitites, dedupe) {
3326
+ const result = {};
3327
+ let rootEqualityPaths = void 0;
3328
+ identitites.forEach((paths) => {
3329
+ if (paths.length <= 1) return;
3330
+ if (!dedupe) paths = paths.map((path) => path.map(String)).sort((a, b) => a.length - b.length);
3331
+ const [representativePath, ...identicalPaths] = paths;
3332
+ if (representativePath.length === 0) rootEqualityPaths = identicalPaths.map(stringifyPath);
3333
+ else result[stringifyPath(representativePath)] = identicalPaths.map(stringifyPath);
3334
+ });
3335
+ if (rootEqualityPaths) if (isEmptyObject(result)) return [rootEqualityPaths];
3336
+ else return [rootEqualityPaths, result];
3337
+ else return isEmptyObject(result) ? void 0 : result;
3338
+ }
3339
+ const walker = (object, identities, superJson, dedupe, path = [], objectsInThisPath = [], seenObjects = /* @__PURE__ */ new Map()) => {
3340
+ var _transformationResult;
3341
+ const primitive = isPrimitive(object);
3342
+ if (!primitive) {
3343
+ addIdentity(object, path, identities);
3344
+ const seen = seenObjects.get(object);
3345
+ if (seen) return dedupe ? { transformedValue: null } : seen;
3346
+ }
3347
+ if (!isDeep(object, superJson)) {
3348
+ const transformed$1 = transformValue(object, superJson);
3349
+ const result$1 = transformed$1 ? {
3350
+ transformedValue: transformed$1.value,
3351
+ annotations: [transformed$1.type]
3352
+ } : { transformedValue: object };
3353
+ if (!primitive) seenObjects.set(object, result$1);
3354
+ return result$1;
3355
+ }
3356
+ if (includes(objectsInThisPath, object)) return { transformedValue: null };
3357
+ const transformationResult = transformValue(object, superJson);
3358
+ const transformed = (_transformationResult = transformationResult === null || transformationResult === void 0 ? void 0 : transformationResult.value) !== null && _transformationResult !== void 0 ? _transformationResult : object;
3359
+ const transformedValue = isArray$1(transformed) ? [] : {};
3360
+ const innerAnnotations = {};
3361
+ forEach(transformed, (value, index) => {
3362
+ if (index === "__proto__" || index === "constructor" || index === "prototype") throw new Error(`Detected property ${index}. This is a prototype pollution risk, please remove it from your object.`);
3363
+ const recursiveResult = walker(value, identities, superJson, dedupe, [...path, index], [...objectsInThisPath, object], seenObjects);
3364
+ transformedValue[index] = recursiveResult.transformedValue;
3365
+ if (isArray$1(recursiveResult.annotations)) innerAnnotations[escapeKey(index)] = recursiveResult.annotations;
3366
+ else if (isPlainObject$1(recursiveResult.annotations)) forEach(recursiveResult.annotations, (tree, key) => {
3367
+ innerAnnotations[escapeKey(index) + "." + key] = tree;
3368
+ });
3369
+ });
3370
+ const result = isEmptyObject(innerAnnotations) ? {
3371
+ transformedValue,
3372
+ annotations: !!transformationResult ? [transformationResult.type] : void 0
3373
+ } : {
3374
+ transformedValue,
3375
+ annotations: !!transformationResult ? [transformationResult.type, innerAnnotations] : innerAnnotations
3376
+ };
3377
+ if (!primitive) seenObjects.set(object, result);
3378
+ return result;
3379
+ };
3380
+
3381
+ //#endregion
3382
+ //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/getType.js
3383
+ /** Returns the object type of the given payload */
3384
+ function getType(payload) {
3385
+ return Object.prototype.toString.call(payload).slice(8, -1);
3386
+ }
3387
+
3388
+ //#endregion
3389
+ //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isArray.js
3390
+ /** Returns whether the payload is an array */
3391
+ function isArray(payload) {
3392
+ return getType(payload) === "Array";
3393
+ }
3394
+
3395
+ //#endregion
3396
+ //#region ../../node_modules/.pnpm/is-what@5.5.0/node_modules/is-what/dist/isPlainObject.js
3397
+ /**
3398
+ * Returns whether the payload is a plain JavaScript object (excluding special classes or objects
3399
+ * with other prototypes)
3400
+ */
3401
+ function isPlainObject(payload) {
3402
+ if (getType(payload) !== "Object") return false;
3403
+ const prototype = Object.getPrototypeOf(payload);
3404
+ return !!prototype && prototype.constructor === Object && prototype === Object.prototype;
3405
+ }
3406
+
3407
+ //#endregion
3408
+ //#region ../../node_modules/.pnpm/copy-anything@4.0.5/node_modules/copy-anything/dist/index.js
3409
+ function assignProp(carry, key, newVal, originalObject, includeNonenumerable) {
3410
+ const propType = {}.propertyIsEnumerable.call(originalObject, key) ? "enumerable" : "nonenumerable";
3411
+ if (propType === "enumerable") carry[key] = newVal;
3412
+ if (includeNonenumerable && propType === "nonenumerable") Object.defineProperty(carry, key, {
3413
+ value: newVal,
3414
+ enumerable: false,
3415
+ writable: true,
3416
+ configurable: true
3417
+ });
3418
+ }
3419
+ /**
3420
+ * Copy (clone) an object and all its props recursively to get rid of any prop referenced of the
3421
+ * original object. Arrays are also cloned, however objects inside arrays are still linked.
3422
+ *
3423
+ * @param target Target can be anything
3424
+ * @param [options={}] See type {@link Options} for more details.
3425
+ *
3426
+ * - `{ props: ['key1'] }` will only copy the `key1` property. When using this you will need to cast
3427
+ * the return type manually (in order to keep the TS implementation in here simple I didn't
3428
+ * built a complex auto resolved type for those few cases people want to use this option)
3429
+ * - `{ nonenumerable: true }` will copy all non-enumerable properties. Default is `{}`
3430
+ *
3431
+ * @returns The target with replaced values
3432
+ */
3433
+ function copy(target$1, options = {}) {
3434
+ if (isArray(target$1)) return target$1.map((item) => copy(item, options));
3435
+ if (!isPlainObject(target$1)) return target$1;
3436
+ const props = Object.getOwnPropertyNames(target$1);
3437
+ const symbols = Object.getOwnPropertySymbols(target$1);
3438
+ return [...props, ...symbols].reduce((carry, key) => {
3439
+ if (key === "__proto__") return carry;
3440
+ if (isArray(options.props) && !options.props.includes(key)) return carry;
3441
+ const val = target$1[key];
3442
+ assignProp(carry, key, copy(val, options), target$1, options.nonenumerable);
3443
+ return carry;
3444
+ }, {});
3445
+ }
3446
+
3447
+ //#endregion
3448
+ //#region ../../node_modules/.pnpm/superjson@2.2.5/node_modules/superjson/dist/index.js
3449
+ var SuperJSON = class {
3450
+ /**
3451
+ * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
3452
+ */
3453
+ constructor({ dedupe = false } = {}) {
3454
+ this.classRegistry = new ClassRegistry();
3455
+ this.symbolRegistry = new Registry((s) => {
3456
+ var _s$description;
3457
+ return (_s$description = s.description) !== null && _s$description !== void 0 ? _s$description : "";
3458
+ });
3459
+ this.customTransformerRegistry = new CustomTransformerRegistry();
3460
+ this.allowedErrorProps = [];
3461
+ this.dedupe = dedupe;
3462
+ }
3463
+ serialize(object) {
3464
+ const identities = /* @__PURE__ */ new Map();
3465
+ const output = walker(object, identities, this, this.dedupe);
3466
+ const res = { json: output.transformedValue };
3467
+ if (output.annotations) res.meta = _objectSpread2(_objectSpread2({}, res.meta), {}, { values: output.annotations });
3468
+ const equalityAnnotations = generateReferentialEqualityAnnotations(identities, this.dedupe);
3469
+ if (equalityAnnotations) res.meta = _objectSpread2(_objectSpread2({}, res.meta), {}, { referentialEqualities: equalityAnnotations });
3470
+ if (res.meta) res.meta.v = 1;
3471
+ return res;
3472
+ }
3473
+ deserialize(payload, options) {
3474
+ const { json, meta } = payload;
3475
+ let result = (options === null || options === void 0 ? void 0 : options.inPlace) ? json : copy(json);
3476
+ if (meta === null || meta === void 0 ? void 0 : meta.values) {
3477
+ var _meta$v;
3478
+ result = applyValueAnnotations(result, meta.values, (_meta$v = meta.v) !== null && _meta$v !== void 0 ? _meta$v : 0, this);
3479
+ }
3480
+ if (meta === null || meta === void 0 ? void 0 : meta.referentialEqualities) {
3481
+ var _meta$v2;
3482
+ result = applyReferentialEqualityAnnotations(result, meta.referentialEqualities, (_meta$v2 = meta.v) !== null && _meta$v2 !== void 0 ? _meta$v2 : 0);
3483
+ }
3484
+ return result;
3485
+ }
3486
+ stringify(object) {
3487
+ return JSON.stringify(this.serialize(object));
3488
+ }
3489
+ parse(string) {
3490
+ return this.deserialize(JSON.parse(string), { inPlace: true });
3491
+ }
3492
+ registerClass(v, options) {
3493
+ this.classRegistry.register(v, options);
3494
+ }
3495
+ registerSymbol(v, identifier) {
3496
+ this.symbolRegistry.register(v, identifier);
3497
+ }
3498
+ registerCustom(transformer, name) {
3499
+ this.customTransformerRegistry.register(_objectSpread2({ name }, transformer));
3500
+ }
3501
+ allowErrorProps(...props) {
3502
+ this.allowedErrorProps.push(...props);
3503
+ }
3504
+ };
3505
+ SuperJSON.defaultInstance = new SuperJSON();
3506
+ SuperJSON.serialize = SuperJSON.defaultInstance.serialize.bind(SuperJSON.defaultInstance);
3507
+ SuperJSON.deserialize = SuperJSON.defaultInstance.deserialize.bind(SuperJSON.defaultInstance);
3508
+ SuperJSON.stringify = SuperJSON.defaultInstance.stringify.bind(SuperJSON.defaultInstance);
3509
+ SuperJSON.parse = SuperJSON.defaultInstance.parse.bind(SuperJSON.defaultInstance);
3510
+ SuperJSON.registerClass = SuperJSON.defaultInstance.registerClass.bind(SuperJSON.defaultInstance);
3511
+ SuperJSON.registerSymbol = SuperJSON.defaultInstance.registerSymbol.bind(SuperJSON.defaultInstance);
3512
+ SuperJSON.registerCustom = SuperJSON.defaultInstance.registerCustom.bind(SuperJSON.defaultInstance);
3513
+ SuperJSON.allowErrorProps = SuperJSON.defaultInstance.allowErrorProps.bind(SuperJSON.defaultInstance);
3514
+ const serialize = SuperJSON.serialize;
3515
+ const deserialize = SuperJSON.deserialize;
3516
+ const stringify = SuperJSON.stringify;
3517
+ const parse = SuperJSON.parse;
3518
+ const registerClass = SuperJSON.registerClass;
3519
+ const registerCustom = SuperJSON.registerCustom;
3520
+ const registerSymbol = SuperJSON.registerSymbol;
3521
+ const allowErrorProps = SuperJSON.allowErrorProps;
3522
+
3523
+ //#endregion
3524
+ //#region src/messaging/presets/broadcast/client.ts
3525
+ const __REACT_DEVTOOLS_KIT_BROADCAST_MESSAGING_EVENT_KEY$1 = "__REACT_DEVTOOLS_KIT_BROADCAST_MESSAGE__";
3526
+ function createBroadcastClientChannel() {
3527
+ if (!__react_devtools_plus_shared.isBrowser) return {
3528
+ post: () => {},
3529
+ on: () => {}
3530
+ };
3531
+ const channel = new BroadcastChannel(__REACT_DEVTOOLS_KIT_BROADCAST_MESSAGING_EVENT_KEY$1);
3532
+ return {
3533
+ post: (data) => channel.postMessage(SuperJSON.stringify(data)),
3534
+ on: (handler) => channel.addEventListener("message", (event) => {
3535
+ try {
3536
+ handler(SuperJSON.parse(event.data));
3537
+ } catch (e) {}
3538
+ })
3539
+ };
3540
+ }
3541
+
3542
+ //#endregion
3543
+ //#region src/messaging/presets/broadcast/server.ts
3544
+ const __REACT_DEVTOOLS_KIT_BROADCAST_MESSAGING_EVENT_KEY = "__REACT_DEVTOOLS_KIT_BROADCAST_MESSAGE__";
3545
+ function createBroadcastServerChannel() {
3546
+ if (!__react_devtools_plus_shared.isBrowser) return {
3547
+ post: () => {},
3548
+ on: () => {}
3549
+ };
3550
+ const channel = new BroadcastChannel(__REACT_DEVTOOLS_KIT_BROADCAST_MESSAGING_EVENT_KEY);
3551
+ return {
3552
+ post: (data) => channel.postMessage(SuperJSON.stringify(data)),
3553
+ on: (handler) => channel.addEventListener("message", (event) => {
3554
+ try {
3555
+ handler(SuperJSON.parse(event.data));
3556
+ } catch (e) {}
3557
+ })
3558
+ };
3559
+ }
3560
+
3561
+ //#endregion
3562
+ //#region src/messaging/presets/iframe/context.ts
3563
+ let iframeServerContext = null;
3564
+ function setIframeServerContext(iframe) {
3565
+ iframeServerContext = iframe;
3566
+ }
3567
+ function getIframeServerContext() {
3568
+ return iframeServerContext;
3569
+ }
3570
+ const __REACT_DEVTOOLS_KIT_IFRAME_MESSAGING_EVENT_KEY = "__REACT_DEVTOOLS_KIT_IFRAME_MESSAGE__";
3571
+
3572
+ //#endregion
3573
+ //#region src/messaging/presets/iframe/client.ts
3574
+ function createIframeClientChannel() {
3575
+ if (!__react_devtools_plus_shared.isBrowser) return {
3576
+ post: () => {},
3577
+ on: () => {}
3578
+ };
3579
+ return {
3580
+ post: (data) => window.parent.postMessage(SuperJSON.stringify({
3581
+ event: __REACT_DEVTOOLS_KIT_IFRAME_MESSAGING_EVENT_KEY,
3582
+ data
3583
+ }), "*"),
3584
+ on: (handler) => window.addEventListener("message", (event) => {
3585
+ try {
3586
+ const parsed = SuperJSON.parse(event.data);
3587
+ if (event.source === window.parent && parsed.event === __REACT_DEVTOOLS_KIT_IFRAME_MESSAGING_EVENT_KEY) handler(parsed.data);
3588
+ } catch (e) {}
3589
+ })
3590
+ };
3591
+ }
3592
+
3593
+ //#endregion
3594
+ //#region src/messaging/presets/iframe/server.ts
3595
+ function createIframeServerChannel() {
3596
+ if (!__react_devtools_plus_shared.isBrowser) return {
3597
+ post: () => {},
3598
+ on: () => {}
3599
+ };
3600
+ return {
3601
+ post: (data) => {
3602
+ var _iframe$contentWindow;
3603
+ const iframe = getIframeServerContext();
3604
+ iframe === null || iframe === void 0 || (_iframe$contentWindow = iframe.contentWindow) === null || _iframe$contentWindow === void 0 || _iframe$contentWindow.postMessage(SuperJSON.stringify({
3605
+ event: __REACT_DEVTOOLS_KIT_IFRAME_MESSAGING_EVENT_KEY,
3606
+ data
3607
+ }), "*");
3608
+ },
3609
+ on: (handler) => {
3610
+ window.addEventListener("message", (event) => {
3611
+ const iframe = getIframeServerContext();
3612
+ try {
3613
+ const parsed = SuperJSON.parse(event.data);
3614
+ if (event.source === (iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) && parsed.event === __REACT_DEVTOOLS_KIT_IFRAME_MESSAGING_EVENT_KEY) handler(parsed.data);
3615
+ } catch (e) {}
3616
+ });
3617
+ }
3618
+ };
3619
+ }
3620
+
3621
+ //#endregion
3622
+ //#region src/messaging/presets/index.ts
3623
+ function getChannel(preset, host = "client") {
3624
+ return {
3625
+ iframe: {
3626
+ client: createIframeClientChannel,
3627
+ server: createIframeServerChannel
3628
+ },
3629
+ broadcast: {
3630
+ client: createBroadcastClientChannel,
3631
+ server: createBroadcastServerChannel
3632
+ }
3633
+ }[preset][host]();
3634
+ }
3635
+
3636
+ //#endregion
3637
+ //#region src/messaging/index.ts
3638
+ var _target$__REACT_DEVTO, _target$__REACT_DEVTO2;
3639
+ (_target$__REACT_DEVTO = __react_devtools_plus_shared.target.__REACT_DEVTOOLS_KIT_RPC_CLIENT__) !== null && _target$__REACT_DEVTO !== void 0 || (__react_devtools_plus_shared.target.__REACT_DEVTOOLS_KIT_RPC_CLIENT__ = null);
3640
+ (_target$__REACT_DEVTO2 = __react_devtools_plus_shared.target.__REACT_DEVTOOLS_KIT_RPC_SERVER__) !== null && _target$__REACT_DEVTO2 !== void 0 || (__react_devtools_plus_shared.target.__REACT_DEVTOOLS_KIT_RPC_SERVER__ = null);
3641
+ function setRpcClientToGlobal(rpc) {
3642
+ __react_devtools_plus_shared.target.__REACT_DEVTOOLS_KIT_RPC_CLIENT__ = rpc;
3643
+ }
3644
+ function setRpcServerToGlobal(rpc) {
3645
+ __react_devtools_plus_shared.target.__REACT_DEVTOOLS_KIT_RPC_SERVER__ = rpc;
3646
+ }
3647
+ function getRpcClient() {
3648
+ var _target$__REACT_DEVTO3;
3649
+ return (_target$__REACT_DEVTO3 = __react_devtools_plus_shared.target.__REACT_DEVTOOLS_KIT_RPC_CLIENT__) !== null && _target$__REACT_DEVTO3 !== void 0 ? _target$__REACT_DEVTO3 : null;
3650
+ }
3651
+ function getRpcServer() {
3652
+ var _target$__REACT_DEVTO4;
3653
+ return (_target$__REACT_DEVTO4 = __react_devtools_plus_shared.target.__REACT_DEVTOOLS_KIT_RPC_SERVER__) !== null && _target$__REACT_DEVTO4 !== void 0 ? _target$__REACT_DEVTO4 : null;
3654
+ }
3655
+ function createRpcClient(functions, options = {}) {
3656
+ const { channel: _channel, options: _options, preset } = options;
3657
+ const channel = preset ? getChannel(preset, "client") : _channel;
3658
+ const rpc = createBirpc(functions, _objectSpread2(_objectSpread2(_objectSpread2({}, _options), channel), {}, { timeout: -1 }));
3659
+ setRpcClientToGlobal(rpc);
3660
+ return rpc;
3661
+ }
3662
+ function createRpcServer(functions, options = {}) {
3663
+ const { channel: _channel, preset } = options;
3664
+ const channel = preset ? getChannel(preset, "server") : _channel;
3665
+ const rpcServer = getRpcServer();
3666
+ if (!rpcServer) setRpcServerToGlobal(createBirpcGroup(functions, [channel], { timeout: -1 }));
3667
+ else rpcServer.updateChannels((channels) => {
3668
+ channels.push(channel);
3669
+ });
3670
+ }
3671
+
3672
+ //#endregion
3673
+ exports.REACT_TAGS = REACT_TAGS;
3674
+ exports.TIMELINE_LAYERS = TIMELINE_LAYERS;
3675
+ exports.addComponentEvent = addComponentEvent;
3676
+ exports.addPerformanceEvent = addPerformanceEvent;
3677
+ exports.buildTree = buildTree;
3678
+ exports.cleanupHighlight = cleanupHighlight;
3679
+ exports.clearFiberRegistry = clearFiberRegistry;
3680
+ exports.clearNavigationHistory = clearNavigationHistory;
3681
+ exports.clearOverrides = clearOverrides;
3682
+ exports.clearTimeline = clearTimeline;
3683
+ exports.createRpcClient = createRpcClient;
3684
+ exports.createRpcServer = createRpcServer;
3685
+ exports.getAllContexts = getAllContexts;
3686
+ exports.getAppFiberRoot = getAppFiberRoot;
3687
+ exports.getComponentDetails = getComponentDetails;
3688
+ exports.getComponentHookStates = getComponentHookStates;
3689
+ exports.getContextProviderInfo = getContextProviderInfo;
3690
+ exports.getContextTree = getContextTree;
3691
+ exports.getDisplayName = getDisplayName;
3692
+ exports.getFiberById = getFiberById;
3693
+ exports.getFiberFromElement = getFiberFromElement;
3694
+ exports.getFiberId = getFiberId;
3695
+ exports.getFiberRoot = getFiberRoot;
3696
+ exports.getOverriddenContext = getOverriddenContext;
3697
+ exports.getOverriddenProp = getOverriddenProp;
3698
+ exports.getReactVersion = getReactVersion;
3699
+ exports.getRouterInfo = getRouterInfo;
3700
+ exports.getRpcClient = getRpcClient;
3701
+ exports.getRpcServer = getRpcServer;
3702
+ exports.getTimelineState = getTimelineState;
3703
+ exports.hideHighlight = hideHighlight;
3704
+ exports.highlightNode = highlightNode;
3705
+ exports.installReactHook = installReactHook;
3706
+ exports.installTimelineEventListeners = installTimelineEventListeners;
3707
+ exports.isEditableProp = isEditableProp;
3708
+ exports.mergeClientRects = mergeClientRects;
3709
+ exports.navigateTo = navigateTo;
3710
+ exports.onInspectorSelect = onInspectorSelect;
3711
+ exports.onOpenInEditor = onOpenInEditor;
3712
+ exports.onTimelineEvent = onTimelineEvent;
3713
+ exports.onTreeUpdated = onTreeUpdated;
3714
+ exports.openInEditor = openInEditor;
3715
+ exports.parseValue = parseValue;
3716
+ exports.rebuildTree = rebuildTree;
3717
+ exports.scrollToNode = scrollToNode;
3718
+ exports.setComponentProp = setComponentProp;
3719
+ exports.setContextValue = setContextValue;
3720
+ exports.setContextValueAtPath = setContextValueAtPath;
3721
+ exports.setContextValueFromJson = setContextValueFromJson;
3722
+ exports.setFiberRoot = setFiberRoot;
3723
+ exports.setHookState = setHookState;
3724
+ exports.setHookStateFromJson = setHookStateFromJson;
3725
+ exports.setIframeServerContext = setIframeServerContext;
3726
+ exports.setRpcServerToGlobal = setRpcServerToGlobal;
3727
+ exports.shouldIncludeFiber = shouldIncludeFiber;
3728
+ exports.showHighlight = showHighlight;
3729
+ exports.toggleInspector = toggleInspector;
3730
+ exports.trackFiberPerformanceEnd = trackFiberPerformanceEnd;
3731
+ exports.trackFiberPerformanceStart = trackFiberPerformanceStart;
3732
+ exports.updateTimelineState = updateTimelineState;