@buoy-gg/zustand 2.1.11 → 2.1.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/LICENSE +58 -0
  2. package/lib/commonjs/index.js +1 -91
  3. package/lib/commonjs/preset.js +1 -102
  4. package/lib/commonjs/zustand/components/ZustandActionButton.js +1 -116
  5. package/lib/commonjs/zustand/components/ZustandDetailViewToggle.js +1 -134
  6. package/lib/commonjs/zustand/components/ZustandEventFilterView.js +1 -291
  7. package/lib/commonjs/zustand/components/ZustandIcon.js +1 -35
  8. package/lib/commonjs/zustand/components/ZustandModal.js +1 -603
  9. package/lib/commonjs/zustand/components/ZustandStateChangeItem.js +1 -165
  10. package/lib/commonjs/zustand/components/ZustandStateDetailContent.js +1 -352
  11. package/lib/commonjs/zustand/components/ZustandStateInfoView.js +1 -508
  12. package/lib/commonjs/zustand/components/ZustandStoreBrowser.js +1 -307
  13. package/lib/commonjs/zustand/components/index.js +1 -73
  14. package/lib/commonjs/zustand/hooks/index.js +1 -12
  15. package/lib/commonjs/zustand/hooks/useZustandStateChanges.js +1 -92
  16. package/lib/commonjs/zustand/index.js +1 -99
  17. package/lib/commonjs/zustand/utils/buoyZustandMiddleware.js +1 -220
  18. package/lib/commonjs/zustand/utils/index.js +1 -31
  19. package/lib/commonjs/zustand/utils/zustandStateStore.js +1 -361
  20. package/lib/module/index.js +1 -80
  21. package/lib/module/preset.js +1 -98
  22. package/lib/module/zustand/components/ZustandActionButton.js +1 -112
  23. package/lib/module/zustand/components/ZustandDetailViewToggle.js +1 -129
  24. package/lib/module/zustand/components/ZustandEventFilterView.js +1 -287
  25. package/lib/module/zustand/components/ZustandIcon.js +1 -32
  26. package/lib/module/zustand/components/ZustandModal.js +1 -599
  27. package/lib/module/zustand/components/ZustandStateChangeItem.js +1 -161
  28. package/lib/module/zustand/components/ZustandStateDetailContent.js +1 -348
  29. package/lib/module/zustand/components/ZustandStateInfoView.js +1 -503
  30. package/lib/module/zustand/components/ZustandStoreBrowser.js +1 -303
  31. package/lib/module/zustand/components/index.js +1 -10
  32. package/lib/module/zustand/hooks/index.js +1 -3
  33. package/lib/module/zustand/hooks/useZustandStateChanges.js +1 -88
  34. package/lib/module/zustand/index.js +1 -12
  35. package/lib/module/zustand/utils/buoyZustandMiddleware.js +1 -214
  36. package/lib/module/zustand/utils/index.js +1 -4
  37. package/lib/module/zustand/utils/zustandStateStore.js +1 -357
  38. package/package.json +10 -10
  39. package/lib/typescript/index.d.ts.map +0 -1
  40. package/lib/typescript/preset.d.ts.map +0 -1
  41. package/lib/typescript/zustand/components/ZustandActionButton.d.ts.map +0 -1
  42. package/lib/typescript/zustand/components/ZustandDetailViewToggle.d.ts.map +0 -1
  43. package/lib/typescript/zustand/components/ZustandEventFilterView.d.ts.map +0 -1
  44. package/lib/typescript/zustand/components/ZustandIcon.d.ts.map +0 -1
  45. package/lib/typescript/zustand/components/ZustandModal.d.ts.map +0 -1
  46. package/lib/typescript/zustand/components/ZustandStateChangeItem.d.ts.map +0 -1
  47. package/lib/typescript/zustand/components/ZustandStateDetailContent.d.ts.map +0 -1
  48. package/lib/typescript/zustand/components/ZustandStateInfoView.d.ts.map +0 -1
  49. package/lib/typescript/zustand/components/ZustandStoreBrowser.d.ts.map +0 -1
  50. package/lib/typescript/zustand/components/index.d.ts.map +0 -1
  51. package/lib/typescript/zustand/hooks/index.d.ts.map +0 -1
  52. package/lib/typescript/zustand/hooks/useZustandStateChanges.d.ts.map +0 -1
  53. package/lib/typescript/zustand/index.d.ts.map +0 -1
  54. package/lib/typescript/zustand/types/index.d.ts.map +0 -1
  55. package/lib/typescript/zustand/utils/buoyZustandMiddleware.d.ts.map +0 -1
  56. package/lib/typescript/zustand/utils/index.d.ts.map +0 -1
  57. package/lib/typescript/zustand/utils/zustandStateStore.d.ts.map +0 -1
@@ -1,503 +1 @@
1
- "use strict";
2
-
3
- /**
4
- * ZustandStateInfoView
5
- *
6
- * Displays comprehensive state change information including:
7
- * - Change metadata (store, category, duration)
8
- * - Partial data passed to setState
9
- * - Changed keys list
10
- *
11
- * Mirrors ReduxActionInfoView.tsx
12
- */
13
-
14
- import React, { memo, useCallback, useState, useEffect } from "react";
15
- import { View, Text, StyleSheet, ScrollView } from "react-native";
16
- import { buoyColors, Clock, AlertTriangle, Zap, Info, Box, Database, parseValue, ProUpgradeModal, copyToClipboard } from "@buoy-gg/shared-ui";
17
- import { useIsPro } from "@buoy-gg/license";
18
- import { DataViewer } from "@buoy-gg/shared-ui/dataViewer";
19
- import { ZustandActionButton } from "./ZustandActionButton";
20
- import { zustandStateStore } from "../utils/zustandStateStore";
21
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
22
- function getCategoryInfo(category) {
23
- switch (category) {
24
- case "replace":
25
- return {
26
- label: "REPLACE",
27
- color: buoyColors.warning,
28
- bgColor: buoyColors.warning + "26"
29
- };
30
- case "persist":
31
- return {
32
- label: "PERSIST",
33
- color: buoyColors.info,
34
- bgColor: buoyColors.info + "26"
35
- };
36
- case "initial":
37
- return {
38
- label: "INITIAL",
39
- color: buoyColors.textMuted,
40
- bgColor: buoyColors.textMuted + "26"
41
- };
42
- default:
43
- return {
44
- label: "SET STATE",
45
- color: buoyColors.success,
46
- bgColor: buoyColors.success + "26"
47
- };
48
- }
49
- }
50
- function formatDuration(duration) {
51
- if (duration === undefined) return "N/A";
52
- if (duration < 1) return "<1ms";
53
- return `${duration.toFixed(1)}ms`;
54
- }
55
- function SectionHeader({
56
- icon: Icon,
57
- title,
58
- badge
59
- }) {
60
- return /*#__PURE__*/_jsxs(View, {
61
- style: styles.sectionHeader,
62
- children: [/*#__PURE__*/_jsxs(View, {
63
- style: styles.sectionHeaderLeft,
64
- children: [/*#__PURE__*/_jsx(Icon, {
65
- size: 14,
66
- color: buoyColors.primary
67
- }), /*#__PURE__*/_jsx(Text, {
68
- style: styles.sectionTitle,
69
- children: title
70
- })]
71
- }), badge]
72
- });
73
- }
74
- function InfoRow({
75
- label,
76
- value,
77
- valueColor,
78
- mono = false
79
- }) {
80
- return /*#__PURE__*/_jsxs(View, {
81
- style: styles.infoRow,
82
- children: [/*#__PURE__*/_jsx(Text, {
83
- style: styles.infoLabel,
84
- children: label
85
- }), /*#__PURE__*/_jsx(Text, {
86
- style: [styles.infoValue, mono && styles.infoValueMono, valueColor ? {
87
- color: valueColor
88
- } : undefined],
89
- numberOfLines: 1,
90
- ellipsizeMode: "middle",
91
- children: value
92
- })]
93
- });
94
- }
95
- function formatTime(timestamp) {
96
- const date = new Date(timestamp);
97
- const hours = date.getHours().toString().padStart(2, "0");
98
- const minutes = date.getMinutes().toString().padStart(2, "0");
99
- const seconds = date.getSeconds().toString().padStart(2, "0");
100
- const ms = date.getMilliseconds().toString().padStart(3, "0");
101
- return `${hours}:${minutes}:${seconds}.${ms}`;
102
- }
103
- export const ZustandStateInfoView = /*#__PURE__*/memo(function ZustandStateInfoView({
104
- change
105
- }) {
106
- const isPro = useIsPro();
107
- const [showProModal, setShowProModal] = useState(false);
108
- useEffect(() => {
109
- if (showProModal && isPro) {
110
- setShowProModal(false);
111
- }
112
- }, [showProModal, isPro]);
113
- const categoryInfo = getCategoryInfo(change.category);
114
- const hasPartial = change.partial !== undefined && change.partial !== "(updater fn)";
115
- const hasChangedKeys = change.changedKeys.length > 0;
116
- const storeColor = zustandStateStore.getStoreColor(change.storeName);
117
- const handleCopyState = useCallback(async () => {
118
- if (!isPro) {
119
- setShowProModal(true);
120
- return;
121
- }
122
- await copyToClipboard(change.nextState);
123
- }, [change.nextState, isPro]);
124
- const handleResetStore = useCallback(() => {
125
- const storeInfo = zustandStateStore.getStore(change.storeName);
126
- if (storeInfo?.api.getInitialState) {
127
- const initialState = storeInfo.api.getInitialState();
128
- storeInfo.api.setState(initialState, true);
129
- }
130
- }, [change.storeName]);
131
- const handleJumpToState = useCallback(() => {
132
- const storeInfo = zustandStateStore.getStore(change.storeName);
133
- if (storeInfo) {
134
- storeInfo.api.setState(change.nextState, true);
135
- }
136
- }, [change.storeName, change.nextState]);
137
- return /*#__PURE__*/_jsxs(ScrollView, {
138
- style: styles.container,
139
- contentContainerStyle: styles.contentContainer,
140
- showsVerticalScrollIndicator: false,
141
- children: [/*#__PURE__*/_jsxs(View, {
142
- style: styles.card,
143
- children: [/*#__PURE__*/_jsx(SectionHeader, {
144
- icon: Info,
145
- title: "CHANGE INFO"
146
- }), /*#__PURE__*/_jsxs(View, {
147
- style: styles.cardContent,
148
- children: [/*#__PURE__*/_jsx(InfoRow, {
149
- label: "Store",
150
- value: change.storeName,
151
- mono: true,
152
- valueColor: storeColor
153
- }), /*#__PURE__*/_jsx(InfoRow, {
154
- label: "Time",
155
- value: formatTime(change.timestamp),
156
- mono: true
157
- }), /*#__PURE__*/_jsxs(View, {
158
- style: styles.badgeRow,
159
- children: [/*#__PURE__*/_jsx(View, {
160
- style: [styles.categoryBadge, {
161
- backgroundColor: categoryInfo.bgColor
162
- }],
163
- children: /*#__PURE__*/_jsx(Text, {
164
- style: [styles.categoryText, {
165
- color: categoryInfo.color
166
- }],
167
- children: categoryInfo.label
168
- })
169
- }), /*#__PURE__*/_jsxs(View, {
170
- style: [styles.durationBadge, change.isSlowUpdate && styles.durationBadgeSlow],
171
- children: [/*#__PURE__*/_jsx(Clock, {
172
- size: 10,
173
- color: change.isSlowUpdate ? buoyColors.error : buoyColors.textSecondary
174
- }), /*#__PURE__*/_jsx(Text, {
175
- style: [styles.durationText, change.isSlowUpdate && styles.durationTextSlow],
176
- children: formatDuration(change.duration)
177
- }), change.isSlowUpdate && /*#__PURE__*/_jsx(AlertTriangle, {
178
- size: 10,
179
- color: buoyColors.error
180
- })]
181
- }), change.hasStateChange ? /*#__PURE__*/_jsxs(View, {
182
- style: styles.changesBadge,
183
- children: [/*#__PURE__*/_jsx(Zap, {
184
- size: 10,
185
- color: buoyColors.success
186
- }), /*#__PURE__*/_jsx(Text, {
187
- style: styles.changesText,
188
- children: change.diffSummary || "changed"
189
- })]
190
- }) : /*#__PURE__*/_jsx(View, {
191
- style: styles.noChangesBadge,
192
- children: /*#__PURE__*/_jsx(Text, {
193
- style: styles.noChangesText,
194
- children: "no change"
195
- })
196
- }), change.isPersisted && /*#__PURE__*/_jsxs(View, {
197
- style: styles.persistBadge,
198
- children: [/*#__PURE__*/_jsx(Database, {
199
- size: 10,
200
- color: buoyColors.info
201
- }), /*#__PURE__*/_jsx(Text, {
202
- style: styles.persistText,
203
- children: "PERSISTED"
204
- })]
205
- })]
206
- })]
207
- })]
208
- }), hasChangedKeys && /*#__PURE__*/_jsxs(View, {
209
- style: styles.card,
210
- children: [/*#__PURE__*/_jsx(SectionHeader, {
211
- icon: Zap,
212
- title: "CHANGED KEYS",
213
- badge: /*#__PURE__*/_jsx(View, {
214
- style: styles.countBadge,
215
- children: /*#__PURE__*/_jsx(Text, {
216
- style: styles.countText,
217
- children: change.changedKeys.length
218
- })
219
- })
220
- }), /*#__PURE__*/_jsx(View, {
221
- style: styles.cardContent,
222
- children: /*#__PURE__*/_jsx(View, {
223
- style: styles.keysContainer,
224
- children: change.changedKeys.map(key => /*#__PURE__*/_jsx(View, {
225
- style: styles.keyBadge,
226
- children: /*#__PURE__*/_jsx(Text, {
227
- style: styles.keyText,
228
- children: key
229
- })
230
- }, key))
231
- })
232
- })]
233
- }), hasPartial && /*#__PURE__*/_jsxs(View, {
234
- style: styles.card,
235
- children: [/*#__PURE__*/_jsx(SectionHeader, {
236
- icon: Box,
237
- title: "PARTIAL (setState argument)",
238
- badge: /*#__PURE__*/_jsx(View, {
239
- style: styles.typeBadge,
240
- children: /*#__PURE__*/_jsx(Text, {
241
- style: styles.typeText,
242
- children: Array.isArray(change.partial) ? "ARRAY" : typeof change.partial === "object" ? "OBJECT" : String(typeof change.partial).toUpperCase()
243
- })
244
- })
245
- }), /*#__PURE__*/_jsx(View, {
246
- style: styles.dataViewerContainer,
247
- children: /*#__PURE__*/_jsx(DataViewer, {
248
- title: "",
249
- data: parseValue(change.partial),
250
- showTypeFilter: true,
251
- rawMode: true,
252
- initialExpanded: true
253
- })
254
- })]
255
- }), change.partial === "(updater fn)" && /*#__PURE__*/_jsxs(View, {
256
- style: styles.card,
257
- children: [/*#__PURE__*/_jsx(SectionHeader, {
258
- icon: Box,
259
- title: "SET STATE CALL"
260
- }), /*#__PURE__*/_jsxs(View, {
261
- style: styles.cardContent,
262
- children: [/*#__PURE__*/_jsx(Text, {
263
- style: styles.updaterText,
264
- children: "Called with an updater function: set((state) => ...)"
265
- }), /*#__PURE__*/_jsx(Text, {
266
- style: styles.updaterSubtext,
267
- children: "The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."
268
- })]
269
- })]
270
- }), /*#__PURE__*/_jsxs(View, {
271
- style: styles.actionsGrid,
272
- children: [/*#__PURE__*/_jsx(ZustandActionButton, {
273
- type: "jump",
274
- text: "JUMP",
275
- onPress: handleJumpToState
276
- }), /*#__PURE__*/_jsx(ZustandActionButton, {
277
- type: "reset",
278
- text: "RESET STORE",
279
- onPress: handleResetStore
280
- }), /*#__PURE__*/_jsx(ZustandActionButton, {
281
- type: "copy",
282
- text: "COPY STATE",
283
- onPress: handleCopyState
284
- })]
285
- }), /*#__PURE__*/_jsx(ProUpgradeModal, {
286
- visible: showProModal,
287
- onClose: () => setShowProModal(false),
288
- featureName: "Copy"
289
- })]
290
- });
291
- });
292
- const styles = StyleSheet.create({
293
- container: {
294
- flex: 1
295
- },
296
- contentContainer: {
297
- padding: 8,
298
- paddingBottom: 100,
299
- gap: 16
300
- },
301
- card: {
302
- backgroundColor: buoyColors.card,
303
- borderRadius: 6,
304
- borderWidth: 1,
305
- borderColor: buoyColors.primary + "4D",
306
- overflow: "hidden",
307
- shadowColor: buoyColors.primary,
308
- shadowOffset: {
309
- width: 0,
310
- height: 0
311
- },
312
- shadowOpacity: 0.1,
313
- shadowRadius: 6
314
- },
315
- sectionHeader: {
316
- flexDirection: "row",
317
- alignItems: "center",
318
- justifyContent: "space-between",
319
- paddingHorizontal: 12,
320
- paddingVertical: 10,
321
- borderBottomWidth: 1,
322
- borderBottomColor: buoyColors.primary + "33",
323
- backgroundColor: buoyColors.primary + "15"
324
- },
325
- sectionHeaderLeft: {
326
- flexDirection: "row",
327
- alignItems: "center",
328
- gap: 6
329
- },
330
- sectionTitle: {
331
- fontSize: 12,
332
- fontWeight: "600",
333
- letterSpacing: 0.5,
334
- color: buoyColors.primary,
335
- fontFamily: "monospace"
336
- },
337
- cardContent: {
338
- padding: 14,
339
- gap: 10
340
- },
341
- infoRow: {
342
- flexDirection: "row",
343
- alignItems: "center",
344
- justifyContent: "space-between"
345
- },
346
- infoLabel: {
347
- fontSize: 11,
348
- color: buoyColors.textMuted,
349
- fontWeight: "500"
350
- },
351
- infoValue: {
352
- fontSize: 11,
353
- color: buoyColors.text,
354
- fontWeight: "500",
355
- flex: 1,
356
- textAlign: "right",
357
- marginLeft: 12
358
- },
359
- infoValueMono: {
360
- fontFamily: "monospace"
361
- },
362
- badgeRow: {
363
- flexDirection: "row",
364
- flexWrap: "wrap",
365
- gap: 8,
366
- marginTop: 6
367
- },
368
- categoryBadge: {
369
- paddingHorizontal: 8,
370
- paddingVertical: 3,
371
- borderRadius: 4
372
- },
373
- categoryText: {
374
- fontSize: 9,
375
- fontWeight: "700",
376
- letterSpacing: 0.3
377
- },
378
- durationBadge: {
379
- flexDirection: "row",
380
- alignItems: "center",
381
- gap: 4,
382
- paddingHorizontal: 8,
383
- paddingVertical: 3,
384
- borderRadius: 4,
385
- backgroundColor: buoyColors.input
386
- },
387
- durationBadgeSlow: {
388
- backgroundColor: buoyColors.error + "26"
389
- },
390
- durationText: {
391
- fontSize: 9,
392
- fontWeight: "600",
393
- color: buoyColors.textSecondary,
394
- fontFamily: "monospace"
395
- },
396
- durationTextSlow: {
397
- color: buoyColors.error
398
- },
399
- changesBadge: {
400
- flexDirection: "row",
401
- alignItems: "center",
402
- gap: 4,
403
- paddingHorizontal: 8,
404
- paddingVertical: 3,
405
- borderRadius: 4,
406
- backgroundColor: buoyColors.success + "26"
407
- },
408
- changesText: {
409
- fontSize: 9,
410
- fontWeight: "600",
411
- color: buoyColors.success
412
- },
413
- noChangesBadge: {
414
- paddingHorizontal: 8,
415
- paddingVertical: 3,
416
- borderRadius: 4,
417
- backgroundColor: buoyColors.input
418
- },
419
- noChangesText: {
420
- fontSize: 9,
421
- fontWeight: "600",
422
- color: buoyColors.textMuted
423
- },
424
- persistBadge: {
425
- flexDirection: "row",
426
- alignItems: "center",
427
- gap: 4,
428
- paddingHorizontal: 8,
429
- paddingVertical: 3,
430
- borderRadius: 4,
431
- backgroundColor: buoyColors.info + "26"
432
- },
433
- persistText: {
434
- fontSize: 9,
435
- fontWeight: "700",
436
- color: buoyColors.info,
437
- letterSpacing: 0.3
438
- },
439
- keysContainer: {
440
- flexDirection: "row",
441
- flexWrap: "wrap",
442
- gap: 6
443
- },
444
- keyBadge: {
445
- paddingHorizontal: 8,
446
- paddingVertical: 4,
447
- borderRadius: 4,
448
- backgroundColor: buoyColors.primary + "20",
449
- borderWidth: 1,
450
- borderColor: buoyColors.primary + "40"
451
- },
452
- keyText: {
453
- fontSize: 11,
454
- fontWeight: "600",
455
- color: buoyColors.primary,
456
- fontFamily: "monospace"
457
- },
458
- countBadge: {
459
- paddingHorizontal: 8,
460
- paddingVertical: 3,
461
- borderRadius: 4,
462
- backgroundColor: buoyColors.primary + "26"
463
- },
464
- countText: {
465
- fontSize: 9,
466
- fontWeight: "700",
467
- color: buoyColors.primary,
468
- fontFamily: "monospace"
469
- },
470
- typeBadge: {
471
- paddingHorizontal: 6,
472
- paddingVertical: 2,
473
- borderRadius: 3,
474
- backgroundColor: buoyColors.input
475
- },
476
- typeText: {
477
- fontSize: 8,
478
- fontWeight: "600",
479
- color: buoyColors.textMuted,
480
- fontFamily: "monospace"
481
- },
482
- dataViewerContainer: {
483
- backgroundColor: buoyColors.base,
484
- minHeight: 60
485
- },
486
- updaterText: {
487
- fontSize: 12,
488
- color: buoyColors.text,
489
- fontFamily: "monospace"
490
- },
491
- updaterSubtext: {
492
- fontSize: 11,
493
- color: buoyColors.textMuted,
494
- lineHeight: 16,
495
- marginTop: 4
496
- },
497
- actionsGrid: {
498
- flexDirection: "row",
499
- flexWrap: "wrap",
500
- gap: 12,
501
- justifyContent: "flex-start"
502
- }
503
- });
1
+ "use strict";import React,{memo,useCallback,useState,useEffect}from"react";import{View,Text,StyleSheet,ScrollView}from"react-native";import{buoyColors,Clock,AlertTriangle,Zap,Info,Box,Database,parseValue,ProUpgradeModal,copyToClipboard}from"@buoy-gg/shared-ui";import{useIsPro}from"@buoy-gg/license";import{DataViewer}from"@buoy-gg/shared-ui/dataViewer";import{ZustandActionButton}from"./ZustandActionButton";import{zustandStateStore}from"../utils/zustandStateStore";import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";function getCategoryInfo(e){switch(e){case"replace":return{label:"REPLACE",color:buoyColors.warning,bgColor:buoyColors.warning+"26"};case"persist":return{label:"PERSIST",color:buoyColors.info,bgColor:buoyColors.info+"26"};case"initial":return{label:"INITIAL",color:buoyColors.textMuted,bgColor:buoyColors.textMuted+"26"};default:return{label:"SET STATE",color:buoyColors.success,bgColor:buoyColors.success+"26"}}}function formatDuration(e){return void 0===e?"N/A":e<1?"<1ms":`${e.toFixed(1)}ms`}function SectionHeader({icon:e,title:t,badge:o}){return _jsxs(View,{style:styles.sectionHeader,children:[_jsxs(View,{style:styles.sectionHeaderLeft,children:[_jsx(e,{size:14,color:buoyColors.primary}),_jsx(Text,{style:styles.sectionTitle,children:t})]}),o]})}function InfoRow({label:e,value:t,valueColor:o,mono:r=!1}){return _jsxs(View,{style:styles.infoRow,children:[_jsx(Text,{style:styles.infoLabel,children:e}),_jsx(Text,{style:[styles.infoValue,r&&styles.infoValueMono,o?{color:o}:void 0],numberOfLines:1,ellipsizeMode:"middle",children:t})]})}function formatTime(e){const t=new Date(e);return`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}export const ZustandStateInfoView=memo(function({change:e}){const t=useIsPro(),[o,r]=useState(!1);useEffect(()=>{o&&t&&r(!1)},[o,t]);const s=getCategoryInfo(e.category),a=void 0!==e.partial&&"(updater fn)"!==e.partial,i=e.changedKeys.length>0,n=zustandStateStore.getStoreColor(e.storeName),l=useCallback(async()=>{t?await copyToClipboard(e.nextState):r(!0)},[e.nextState,t]),d=useCallback(()=>{const t=zustandStateStore.getStore(e.storeName);if(t?.api.getInitialState){const e=t.api.getInitialState();t.api.setState(e,!0)}},[e.storeName]),c=useCallback(()=>{const t=zustandStateStore.getStore(e.storeName);t&&t.api.setState(e.nextState,!0)},[e.storeName,e.nextState]);return _jsxs(ScrollView,{style:styles.container,contentContainerStyle:styles.contentContainer,showsVerticalScrollIndicator:!1,children:[_jsxs(View,{style:styles.card,children:[_jsx(SectionHeader,{icon:Info,title:"CHANGE INFO"}),_jsxs(View,{style:styles.cardContent,children:[_jsx(InfoRow,{label:"Store",value:e.storeName,mono:!0,valueColor:n}),_jsx(InfoRow,{label:"Time",value:formatTime(e.timestamp),mono:!0}),_jsxs(View,{style:styles.badgeRow,children:[_jsx(View,{style:[styles.categoryBadge,{backgroundColor:s.bgColor}],children:_jsx(Text,{style:[styles.categoryText,{color:s.color}],children:s.label})}),_jsxs(View,{style:[styles.durationBadge,e.isSlowUpdate&&styles.durationBadgeSlow],children:[_jsx(Clock,{size:10,color:e.isSlowUpdate?buoyColors.error:buoyColors.textSecondary}),_jsx(Text,{style:[styles.durationText,e.isSlowUpdate&&styles.durationTextSlow],children:formatDuration(e.duration)}),e.isSlowUpdate&&_jsx(AlertTriangle,{size:10,color:buoyColors.error})]}),e.hasStateChange?_jsxs(View,{style:styles.changesBadge,children:[_jsx(Zap,{size:10,color:buoyColors.success}),_jsx(Text,{style:styles.changesText,children:e.diffSummary||"changed"})]}):_jsx(View,{style:styles.noChangesBadge,children:_jsx(Text,{style:styles.noChangesText,children:"no change"})}),e.isPersisted&&_jsxs(View,{style:styles.persistBadge,children:[_jsx(Database,{size:10,color:buoyColors.info}),_jsx(Text,{style:styles.persistText,children:"PERSISTED"})]})]})]})]}),i&&_jsxs(View,{style:styles.card,children:[_jsx(SectionHeader,{icon:Zap,title:"CHANGED KEYS",badge:_jsx(View,{style:styles.countBadge,children:_jsx(Text,{style:styles.countText,children:e.changedKeys.length})})}),_jsx(View,{style:styles.cardContent,children:_jsx(View,{style:styles.keysContainer,children:e.changedKeys.map(e=>_jsx(View,{style:styles.keyBadge,children:_jsx(Text,{style:styles.keyText,children:e})},e))})})]}),a&&_jsxs(View,{style:styles.card,children:[_jsx(SectionHeader,{icon:Box,title:"PARTIAL (setState argument)",badge:_jsx(View,{style:styles.typeBadge,children:_jsx(Text,{style:styles.typeText,children:Array.isArray(e.partial)?"ARRAY":"object"==typeof e.partial?"OBJECT":String(typeof e.partial).toUpperCase()})})}),_jsx(View,{style:styles.dataViewerContainer,children:_jsx(DataViewer,{title:"",data:parseValue(e.partial),showTypeFilter:!0,rawMode:!0,initialExpanded:!0})})]}),"(updater fn)"===e.partial&&_jsxs(View,{style:styles.card,children:[_jsx(SectionHeader,{icon:Box,title:"SET STATE CALL"}),_jsxs(View,{style:styles.cardContent,children:[_jsx(Text,{style:styles.updaterText,children:"Called with an updater function: set((state) => ...)"}),_jsx(Text,{style:styles.updaterSubtext,children:"The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."})]})]}),_jsxs(View,{style:styles.actionsGrid,children:[_jsx(ZustandActionButton,{type:"jump",text:"JUMP",onPress:c}),_jsx(ZustandActionButton,{type:"reset",text:"RESET STORE",onPress:d}),_jsx(ZustandActionButton,{type:"copy",text:"COPY STATE",onPress:l})]}),_jsx(ProUpgradeModal,{visible:o,onClose:()=>r(!1),featureName:"Copy"})]})});const styles=StyleSheet.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:buoyColors.card,borderRadius:6,borderWidth:1,borderColor:buoyColors.primary+"4D",overflow:"hidden",shadowColor:buoyColors.primary,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:buoyColors.primary+"33",backgroundColor:buoyColors.primary+"15"},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:buoyColors.primary,fontFamily:"monospace"},cardContent:{padding:14,gap:10},infoRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},infoLabel:{fontSize:11,color:buoyColors.textMuted,fontWeight:"500"},infoValue:{fontSize:11,color:buoyColors.text,fontWeight:"500",flex:1,textAlign:"right",marginLeft:12},infoValueMono:{fontFamily:"monospace"},badgeRow:{flexDirection:"row",flexWrap:"wrap",gap:8,marginTop:6},categoryBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4},categoryText:{fontSize:9,fontWeight:"700",letterSpacing:.3},durationBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:buoyColors.input},durationBadgeSlow:{backgroundColor:buoyColors.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:buoyColors.textSecondary,fontFamily:"monospace"},durationTextSlow:{color:buoyColors.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:buoyColors.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:buoyColors.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:buoyColors.input},noChangesText:{fontSize:9,fontWeight:"600",color:buoyColors.textMuted},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:buoyColors.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:buoyColors.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:buoyColors.primary+"20",borderWidth:1,borderColor:buoyColors.primary+"40"},keyText:{fontSize:11,fontWeight:"600",color:buoyColors.primary,fontFamily:"monospace"},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:buoyColors.primary+"26"},countText:{fontSize:9,fontWeight:"700",color:buoyColors.primary,fontFamily:"monospace"},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:buoyColors.input},typeText:{fontSize:8,fontWeight:"600",color:buoyColors.textMuted,fontFamily:"monospace"},dataViewerContainer:{backgroundColor:buoyColors.base,minHeight:60},updaterText:{fontSize:12,color:buoyColors.text,fontFamily:"monospace"},updaterSubtext:{fontSize:11,color:buoyColors.textMuted,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});