@buoy-gg/zustand 7.0.76 → 7.0.78

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ZustandModal=ZustandModal;exports.ZustandToolView=ZustandToolView;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _license=require("@buoy-gg/license");var _useZustandStateChanges=require("../hooks/useZustandStateChanges");var _ZustandStateChangeItem=require("./ZustandStateChangeItem");var _ZustandStateDetailContent=require("./ZustandStateDetailContent");var _ZustandStoreBrowser=require("./ZustandStoreBrowser");var _ZustandStoreDetailContent=require("./ZustandStoreDetailContent");var _ZustandEventFilterView=require("./ZustandEventFilterView");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function EventsEmptyState({isEnabled:h,searchText:m,totalChanges:x}){const I=(0,_sharedUi.resolveListEmptyState)({subject:"changes",search:m,total:x,capturing:h,waiting:{otto:"waiting",title:"No state changes",message:"State changes will appear here as stores update."},paused:{title:"No state changes",message:"Enable capture to start recording state changes"}});return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{...I,testID:`${_testIDs.ZUSTAND_TEST_ID}-empty`})}function ZustandModal({visible:h,onClose:m,onBack:x,onMinimize:I,enableSharedModalDimensions:Y=false,inline:ee=false,storesLoading:te=false,initialTab:ne="stores",initialSelectedChangeId:g,initialDetailView:se,onChangeSelect:j,onStoreExpand:M}){const Ne=(0,_license.useIsPro)();const y=(0,_sharedUi.useLimit)("zustand.changes");const[oe,H]=(0,_react.useState)(false);const[l,re]=(0,_react.useState)(ne);const[s,_]=(0,_react.useState)(null);const[T,v]=(0,_react.useState)(null);const[E,k]=(0,_react.useState)(false);const[i,P]=(0,_react.useState)(new Set);const{stateChanges:$,filteredChanges:w,filter:Be,setFilter:b,stats:ae,stores:f,clearChanges:le,isEnabled:C,toggleCapture:ie}=(0,_useZustandStateChanges.useZustandStateChanges)();const r=(0,_react.useMemo)(()=>{if(i.size===0)return w;return w.filter(e=>!Array.from(i).some(t=>e.storeName.toLowerCase().includes(t.toLowerCase())))},[w,i]);const S=(0,_react.useMemo)(()=>{if(i.size===0)return f;return f.filter(e=>!Array.from(i).some(t=>e.name.toLowerCase().includes(t.toLowerCase())))},[f,i]);const ce=(0,_react.useMemo)(()=>{if(!s)return 0;return $.filter(e=>e.storeName===s).length},[$,s]);const p=(0,_react.useMemo)(()=>{if(!s)return r;return r.filter(e=>e.storeName===s)},[r,s]);const Z=(0,_react.useMemo)(()=>p.slice(0,y),[p,y]);const A=(0,_react.useMemo)(()=>Math.max(0,p.length-y),[p.length,y]);const de=A>0;const n=Z;const[N,d]=(0,_react.useState)(null);const u=(0,_react.useMemo)(()=>{if(N===null)return null;const e=n.findIndex(t=>t.id===N);return e>=0?e:null},[N,n]);const o=u!==null?n[u]:null;const U=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!j)return;const e=o?.id??null;if(e===null||e===U.current)return;U.current=e;j(o)},[o,j]);const R=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!g)return;if(R.current===g)return;const e=n.some(t=>t.id===g);if(!e)return;R.current=g;d(g)},[g,n]);const[c,B]=(0,_react.useState)("");const[ue,D]=(0,_react.useState)(false);const Me=(0,_react.useRef)(null);const he=(0,_react.useRef)(null);const ge=(0,_react.useCallback)(e=>{},[]);const Se=e=>{B(e);if(l==="events"){b(t=>({...t,searchText:e}))}};const Te=(0,_react.useCallback)(()=>{B("");b(e=>({...e,searchText:""}));D(false)},[b]);const F=(0,_react.useCallback)(e=>{d(e.id)},[]);const be=(0,_react.useCallback)(()=>{H(true)},[]);const fe=(0,_react.useCallback)(()=>{d(null)},[]);const L=(0,_react.useCallback)(e=>{const t=n[e];if(t){d(t.id)}},[n]);const xe=(0,_react.useCallback)(e=>{_(e);d(null)},[]);const ye=(0,_react.useCallback)(()=>{_(null);d(null)},[]);const Ce=(0,_react.useCallback)(e=>{v(e);M?.(e)},[M]);const pe=(0,_react.useCallback)(()=>{v(null)},[]);const De=(0,_react.useCallback)(()=>{return S.reduce((e,t)=>{try{const a=t.api.getState();if(a&&typeof a==="object"){const Q={};for(const[Ae,X]of Object.entries(a)){if(typeof X!=="function")Q[Ae]=(0,_sharedUi.truncatePayload)(X)}e[t.name]=Q}else{e[t.name]=(0,_sharedUi.truncatePayload)(a)}}catch{e[t.name]=null}return e},{})},[S]);const me=(0,_react.useCallback)(()=>{return r.map(e=>({id:e.id,storeName:e.storeName,timestamp:e.timestamp,prevState:(0,_sharedUi.truncatePayload)(e.prevState),nextState:(0,_sharedUi.truncatePayload)(e.nextState),hasStateChange:e.hasStateChange,changedKeys:e.changedKeys}))},[r]);const Ie=(0,_react.useCallback)(()=>{return n.map(e=>({id:e.id,storeName:e.storeName,timestamp:e.timestamp,prevState:(0,_sharedUi.truncatePayload)(e.prevState),nextState:(0,_sharedUi.truncatePayload)(e.nextState),hasStateChange:e.hasStateChange,changedKeys:e.changedKeys}))},[n]);const je=(0,_react.useCallback)(e=>{P(t=>{const a=new Set(t);if(a.has(e))a.delete(e);else a.add(e);return a})},[]);const _e=(0,_react.useCallback)(e=>{P(t=>new Set([...t,e]))},[]);const ve=(0,_react.useCallback)(e=>{re(e);_(null);v(null);d(null);k(false);if(c){B("");b(t=>({...t,searchText:""}))}D(false)},[c,b]);const V=(0,_react.useCallback)(e=>e.id,[]);const z=(0,_react.useMemo)(()=>(0,_testIDs.buildChangeRowTestIDs)(n),[n]);const q=(0,_react.useCallback)(({item:e})=>{return(0,_jsxRuntime.jsx)(_ZustandStateChangeItem.ZustandStateChangeItem,{change:e,onPress:F,testID:z.get(e.id)})},[F,z]);const O=i.size>0;const K=()=>{if(E){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:()=>k(false)}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"Filters",centered:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-filters-title`})]})}if(o){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:fe}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:`${o.storeName}/setState`,centered:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-detail-title`})]})}if(s){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:ye}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:`${s} History`,centered:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-history-title`}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Actions,{children:(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:Ie,disabled:n.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.ZUSTAND_TEST_ID}-copy`})})]})}if(T){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:pe}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:T,centered:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-store-detail-title`})]})}return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[x&&(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:x}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"",children:ue?(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Search,{value:c,onChangeText:Se,onCancel:Te,placeholder:l==="stores"?"Search stores...":"Search events...",accessibilityLabel:"Search Zustand stores and events",iconSize:14,testID:`${_testIDs.ZUSTAND_TEST_ID}-search-field`,containerTestID:`${_testIDs.ZUSTAND_TEST_ID}-search`,clearTestID:`${_testIDs.ZUSTAND_TEST_ID}-search-clear`,onBlur:()=>{if(c.length===0)D(false)}}):(0,_jsxRuntime.jsx)(_sharedUi.TabSelector,{tabs:[{key:"stores",label:`Stores${S.length>0?` (${S.length})`:""}`},{key:"events",label:`Events${r.length>0?` (${r.length})`:""}`}],activeTab:l,onTabChange:ve,testIDPrefix:`${_testIDs.ZUSTAND_TEST_ID}-tab`})}),(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader.Actions,{children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>D(true),style:styles.headerActionButton,testID:`${_testIDs.ZUSTAND_TEST_ID}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:(0,_jsxRuntime.jsx)(_sharedUi.Search,{size:14,color:_sharedUi.night.color.textSecondary})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>k(true),style:[styles.headerActionButton,O&&styles.headerActionButtonActive],testID:`${_testIDs.ZUSTAND_TEST_ID}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:(0,_jsxRuntime.jsx)(_sharedUi.Filter,{size:14,color:O?_sharedUi.night.color.accent:_sharedUi.night.color.textSecondary})}),l==="stores"&&(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:De,disabled:S.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.ZUSTAND_TEST_ID}-copy`}),l==="events"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:me,disabled:r.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.ZUSTAND_TEST_ID}-copy`}),(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:C,onToggle:ie,accessibilityLabel:"Toggle Zustand state capture",testID:`${_testIDs.ZUSTAND_TEST_ID}-power`}),(0,_jsxRuntime.jsx)(_sharedUi.ToolbarClearButton,{onPress:le,disabled:r.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.ZUSTAND_TEST_ID}-clear`})]})]})]})};const Ee=()=>{if(E){return(0,_jsxRuntime.jsx)(_ZustandEventFilterView.ZustandEventFilterView,{ignoredPatterns:i,onTogglePattern:je,onAddPattern:_e,stores:f})}if(o&&u!==null){return(0,_jsxRuntime.jsx)(_ZustandStateDetailContent.ZustandStateDetailContent,{change:o,changes:n,selectedIndex:u,onIndexChange:L,disableInternalFooter:true,initialView:se})}if(s){return n.length>0?(0,_jsxRuntime.jsx)(_reactNative.FlatList,{testID:`${_testIDs.ZUSTAND_TEST_ID}-history-list`,data:n,renderItem:q,keyExtractor:V,contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:true,..._sharedUi.EVENT_LIST_PRESET}):(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.ZUSTAND_TEST_ID}-history-empty`,...(0,_sharedUi.resolveListEmptyState)({subject:"changes",search:c,total:c.trim()?ce:0,capturing:C,waiting:{otto:"waiting",title:"No history yet",message:`State changes for ${s} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${s}.`}})})}if(T){const e=f.find(t=>t.name===T)??null;return e?(0,_jsxRuntime.jsx)(_ZustandStoreDetailContent.ZustandStoreDetailContent,{store:e,onViewHistory:xe}):(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.ZUSTAND_TEST_ID}-store-detail-gone`,otto:"ghost",title:"Store no longer registered",message:`${T} is not in the registry any more.`})}if(l==="stores"){return(0,_jsxRuntime.jsx)(_ZustandStoreBrowser.ZustandStoreBrowser,{stores:S,searchQuery:c,isLoading:te,onOpenStore:Ce})}return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[!C&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.disabledBanner,testID:`${_testIDs.ZUSTAND_TEST_ID}-banner-disabled`,children:[(0,_jsxRuntime.jsx)(_sharedUi.Power,{size:14,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.disabledText,children:"State capture is disabled"})]}),de&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.lockedBanner,onPress:be,activeOpacity:.8,testID:`${_testIDs.ZUSTAND_TEST_ID}-locked`,accessibilityRole:"button",children:[(0,_jsxRuntime.jsx)(_sharedUi.Lock,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.lockedText,testID:`${_testIDs.ZUSTAND_TEST_ID}-locked-text`,children:[A," older"," ",A===1?"change":"changes"," locked"]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.upgradeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.upgradeBadgeText,children:"UPGRADE"})})]}),Z.length>0?(0,_jsxRuntime.jsx)(_reactNative.FlatList,{ref:he,testID:`${_testIDs.ZUSTAND_TEST_ID}-list`,data:Z,renderItem:q,keyExtractor:V,contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:true,..._sharedUi.EVENT_LIST_PRESET}):(0,_jsxRuntime.jsx)(EventsEmptyState,{isEnabled:C,searchText:c,totalChanges:ae.totalChanges})]})};const ke=Y?_sharedUi.devToolsStorageKeys.modal.root():"buoy-zustand-modal";if(!h)return null;const W=o&&u!==null?(0,_jsxRuntime.jsx)(_ZustandStateDetailContent.ZustandStateDetailFooter,{change:o,changes:n,selectedIndex:u,onIndexChange:L}):null;const we=o&&n.length>1?68:0;const Ze=!E&&(o&&u!==null||s!=null||l==="events"||l==="stores");const G=(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:Ee()});const J=(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:oe,onClose:()=>H(false),featureName:"Full State History"});if(ee){return(0,_jsxRuntime.jsxs)(_sharedUi.TickProvider,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inlineRoot,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.inlineHeader,..._sharedUi.windowDragProps,children:K()}),G,W]}),J]})}return(0,_jsxRuntime.jsxs)(_sharedUi.TickProvider,{children:[(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:h,onClose:m,onMinimize:I,persistenceKey:ke,header:{showToggleButton:true,customContent:K()},onModeChange:ge,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:Ze,styles:{},footer:W,footerHeight:we,children:G}),J]})}function ZustandToolView(h={}){return(0,_jsxRuntime.jsx)(ZustandModal,{...h,inline:true,visible:true,onClose:()=>{}})}const styles=_reactNative.StyleSheet.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:_sharedUi.macOSColors.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:_sharedUi.night.color.buttonSurface,borderWidth:1,borderColor:_sharedUi.night.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:_sharedUi.night.color.accentSoft,borderColor:_sharedUi.night.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.warning+"20"},disabledText:{color:_sharedUi.night.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},lockedText:{color:_sharedUi.night.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:_sharedUi.night.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:_sharedUi.night.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ZustandModal=ZustandModal;exports.ZustandToolView=ZustandToolView;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _license=require("@buoy-gg/license");var _useZustandStateChanges=require("../hooks/useZustandStateChanges");var _ZustandStateChangeItem=require("./ZustandStateChangeItem");var _ZustandStateDetailContent=require("./ZustandStateDetailContent");var _ZustandStoreBrowser=require("./ZustandStoreBrowser");var _ZustandStoreDetailContent=require("./ZustandStoreDetailContent");var _ZustandEventFilterView=require("./ZustandEventFilterView");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function EventsEmptyState({isEnabled:h,searchText:m,totalChanges:x}){const I=(0,_sharedUi.resolveListEmptyState)({subject:"changes",search:m,total:x,capturing:h,waiting:{otto:"waiting",title:"No state changes",message:"State changes will appear here as stores update."},paused:{title:"No state changes",message:"Enable capture to start recording state changes"}});return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{...I,testID:`${_testIDs.ZUSTAND_TEST_ID}-empty`})}function ZustandModal({visible:h,onClose:m,onBack:x,onMinimize:I,enableSharedModalDimensions:Y=false,inline:ee=false,storesLoading:te=false,initialTab:se="stores",initialSelectedChangeId:g,initialDetailView:ne,onChangeSelect:j,onStoreExpand:M}){const Ne=(0,_license.useIsPro)();const y=(0,_sharedUi.useLimit)("zustand.changes");const[oe,P]=(0,_react.useState)(false);const[l,re]=(0,_react.useState)(se);const[n,_]=(0,_react.useState)(null);const[T,v]=(0,_react.useState)(null);const[k,E]=(0,_react.useState)(false);const[i,H]=(0,_react.useState)(new Set);const{stateChanges:$,filteredChanges:w,filter:Be,setFilter:b,stats:ae,stores:f,clearChanges:le,isEnabled:C,toggleCapture:ie}=(0,_useZustandStateChanges.useZustandStateChanges)();const r=(0,_react.useMemo)(()=>{if(i.size===0)return w;return w.filter(e=>!Array.from(i).some(t=>e.storeName.toLowerCase().includes(t.toLowerCase())))},[w,i]);const S=(0,_react.useMemo)(()=>{if(i.size===0)return f;return f.filter(e=>!Array.from(i).some(t=>e.name.toLowerCase().includes(t.toLowerCase())))},[f,i]);const ce=(0,_react.useMemo)(()=>{if(!n)return 0;return $.filter(e=>e.storeName===n).length},[$,n]);const p=(0,_react.useMemo)(()=>{if(!n)return r;return r.filter(e=>e.storeName===n)},[r,n]);const Z=(0,_react.useMemo)(()=>p.slice(0,y),[p,y]);const A=(0,_react.useMemo)(()=>Math.max(0,p.length-y),[p.length,y]);const de=A>0;const s=Z;const[N,d]=(0,_react.useState)(null);const u=(0,_react.useMemo)(()=>{if(N===null)return null;const e=s.findIndex(t=>t.id===N);return e>=0?e:null},[N,s]);const o=u!==null?s[u]:null;const U=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!j)return;const e=o?.id??null;if(e===null||e===U.current)return;U.current=e;j(o)},[o,j]);const R=(0,_react.useRef)(null);(0,_react.useEffect)(()=>{if(!g)return;if(R.current===g)return;const e=s.some(t=>t.id===g);if(!e)return;R.current=g;d(g)},[g,s]);const[c,B]=(0,_react.useState)("");const[ue,D]=(0,_react.useState)(false);const Me=(0,_react.useRef)(null);const he=(0,_react.useRef)(null);const ge=(0,_react.useCallback)(e=>{},[]);const Se=e=>{B(e);if(l==="events"){b(t=>({...t,searchText:e}))}};const Te=(0,_react.useCallback)(()=>{B("");b(e=>({...e,searchText:""}));D(false)},[b]);const F=(0,_react.useCallback)(e=>{d(e.id)},[]);const be=(0,_react.useCallback)(()=>{P(true)},[]);const fe=(0,_react.useCallback)(()=>{d(null)},[]);const L=(0,_react.useCallback)(e=>{const t=s[e];if(t){d(t.id)}},[s]);const xe=(0,_react.useCallback)(e=>{_(e);d(null)},[]);const ye=(0,_react.useCallback)(()=>{_(null);d(null)},[]);const Ce=(0,_react.useCallback)(e=>{v(e);M?.(e)},[M]);const pe=(0,_react.useCallback)(()=>{v(null)},[]);const De=(0,_react.useCallback)(()=>{return S.reduce((e,t)=>{try{const a=t.api.getState();if(a&&typeof a==="object"){const Q={};for(const[Ae,X]of Object.entries(a)){if(typeof X!=="function")Q[Ae]=(0,_sharedUi.truncatePayload)(X)}e[t.name]=Q}else{e[t.name]=(0,_sharedUi.truncatePayload)(a)}}catch{e[t.name]=null}return e},{})},[S]);const me=(0,_react.useCallback)(()=>{return r.map(e=>({id:e.id,storeName:e.storeName,timestamp:e.timestamp,prevState:(0,_sharedUi.truncatePayload)(e.prevState),nextState:(0,_sharedUi.truncatePayload)(e.nextState),hasStateChange:e.hasStateChange,changedKeys:e.changedKeys}))},[r]);const Ie=(0,_react.useCallback)(()=>{return s.map(e=>({id:e.id,storeName:e.storeName,timestamp:e.timestamp,prevState:(0,_sharedUi.truncatePayload)(e.prevState),nextState:(0,_sharedUi.truncatePayload)(e.nextState),hasStateChange:e.hasStateChange,changedKeys:e.changedKeys}))},[s]);const je=(0,_react.useCallback)(e=>{H(t=>{const a=new Set(t);if(a.has(e))a.delete(e);else a.add(e);return a})},[]);const _e=(0,_react.useCallback)(e=>{H(t=>new Set([...t,e]))},[]);const ve=(0,_react.useCallback)(e=>{re(e);_(null);v(null);d(null);E(false);if(c){B("");b(t=>({...t,searchText:""}))}D(false)},[c,b]);const V=(0,_react.useCallback)(e=>e.id,[]);const z=(0,_react.useMemo)(()=>(0,_testIDs.buildChangeRowTestIDs)(s),[s]);const q=(0,_react.useCallback)(({item:e})=>{return(0,_jsxRuntime.jsx)(_ZustandStateChangeItem.ZustandStateChangeItem,{change:e,onPress:F,testID:z.get(e.id)})},[F,z]);const O=i.size>0;const K=()=>{if(k){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:()=>E(false)}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"Filters",centered:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-filters-title`})]})}if(o){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:fe}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:`${o.storeName}/setState`,centered:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-detail-title`})]})}if(n){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:ye}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:`${n} History`,centered:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-history-title`}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Actions,{children:(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:Ie,disabled:s.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.ZUSTAND_TEST_ID}-copy`})})]})}if(T){return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:pe}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:T,centered:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-store-detail-title`})]})}return(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[x&&(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:x}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"",children:ue?(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Search,{value:c,onChangeText:Se,onCancel:Te,placeholder:l==="stores"?"Search stores...":"Search events...",accessibilityLabel:"Search Zustand stores and events",iconSize:14,testID:`${_testIDs.ZUSTAND_TEST_ID}-search-field`,containerTestID:`${_testIDs.ZUSTAND_TEST_ID}-search`,clearTestID:`${_testIDs.ZUSTAND_TEST_ID}-search-clear`,onBlur:()=>{if(c.length===0)D(false)}}):(0,_jsxRuntime.jsx)(_sharedUi.TabSelector,{tabs:[{key:"stores",label:`Stores${S.length>0?` (${S.length})`:""}`},{key:"events",label:`Events${r.length>0?` (${r.length})`:""}`}],activeTab:l,onTabChange:ve,testIDPrefix:`${_testIDs.ZUSTAND_TEST_ID}-tab`})}),(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader.Actions,{children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>D(true),style:styles.headerActionButton,testID:`${_testIDs.ZUSTAND_TEST_ID}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:(0,_jsxRuntime.jsx)(_sharedUi.Search,{size:14,color:_sharedUi.night.color.textSecondary})}),(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>E(true),style:[styles.headerActionButton,O&&styles.headerActionButtonActive],testID:`${_testIDs.ZUSTAND_TEST_ID}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:(0,_jsxRuntime.jsx)(_sharedUi.Filter,{size:14,color:O?_sharedUi.night.color.accent:_sharedUi.night.color.textSecondary})}),l==="stores"&&(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:De,disabled:S.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.ZUSTAND_TEST_ID}-copy`}),l==="events"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:me,disabled:r.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.ZUSTAND_TEST_ID}-copy`}),(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:C,onToggle:ie,accessibilityLabel:"Toggle Zustand state capture",testID:`${_testIDs.ZUSTAND_TEST_ID}-power`}),(0,_jsxRuntime.jsx)(_sharedUi.ToolbarClearButton,{onPress:le,disabled:r.length===0,buttonStyle:styles.headerActionButton,testID:`${_testIDs.ZUSTAND_TEST_ID}-clear`})]})]})]})};const ke=()=>{if(k){return(0,_jsxRuntime.jsx)(_ZustandEventFilterView.ZustandEventFilterView,{ignoredPatterns:i,onTogglePattern:je,onAddPattern:_e,stores:f})}if(o&&u!==null){return(0,_jsxRuntime.jsx)(_ZustandStateDetailContent.ZustandStateDetailContent,{change:o,changes:s,selectedIndex:u,onIndexChange:L,disableInternalFooter:true,initialView:ne})}if(n){return s.length>0?(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",testID:`${_testIDs.ZUSTAND_TEST_ID}-history-list`,data:s,renderItem:q,keyExtractor:V,contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:true,..._sharedUi.EVENT_LIST_PRESET}):(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.ZUSTAND_TEST_ID}-history-empty`,...(0,_sharedUi.resolveListEmptyState)({subject:"changes",search:c,total:c.trim()?ce:0,capturing:C,waiting:{otto:"waiting",title:"No history yet",message:`State changes for ${n} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${n}.`}})})}if(T){const e=f.find(t=>t.name===T)??null;return e?(0,_jsxRuntime.jsx)(_ZustandStoreDetailContent.ZustandStoreDetailContent,{store:e,onViewHistory:xe}):(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.ZUSTAND_TEST_ID}-store-detail-gone`,otto:"ghost",title:"Store no longer registered",message:`${T} is not in the registry any more.`})}if(l==="stores"){return(0,_jsxRuntime.jsx)(_ZustandStoreBrowser.ZustandStoreBrowser,{stores:S,searchQuery:c,isLoading:te,onOpenStore:Ce})}return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[!C&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.disabledBanner,testID:`${_testIDs.ZUSTAND_TEST_ID}-banner-disabled`,children:[(0,_jsxRuntime.jsx)(_sharedUi.Power,{size:14,color:_sharedUi.night.color.warning}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.disabledText,children:"State capture is disabled"})]}),de&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.lockedBanner,onPress:be,activeOpacity:.8,testID:`${_testIDs.ZUSTAND_TEST_ID}-locked`,accessibilityRole:"button",children:[(0,_jsxRuntime.jsx)(_sharedUi.Lock,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.lockedText,testID:`${_testIDs.ZUSTAND_TEST_ID}-locked-text`,children:[A," older"," ",A===1?"change":"changes"," locked"]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.upgradeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.upgradeBadgeText,children:"UPGRADE"})})]}),Z.length>0?(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",ref:he,testID:`${_testIDs.ZUSTAND_TEST_ID}-list`,data:Z,renderItem:q,keyExtractor:V,contentContainerStyle:styles.listContent,showsVerticalScrollIndicator:true,..._sharedUi.EVENT_LIST_PRESET}):(0,_jsxRuntime.jsx)(EventsEmptyState,{isEnabled:C,searchText:c,totalChanges:ae.totalChanges})]})};const Ee=Y?_sharedUi.devToolsStorageKeys.modal.root():"buoy-zustand-modal";if(!h)return null;const W=o&&u!==null?(0,_jsxRuntime.jsx)(_ZustandStateDetailContent.ZustandStateDetailFooter,{change:o,changes:s,selectedIndex:u,onIndexChange:L}):null;const we=o&&s.length>1?68:0;const Ze=!k&&(o&&u!==null||n!=null||l==="events"||l==="stores");const G=(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:ke()});const J=(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:oe,onClose:()=>P(false),featureName:"Full State History"});if(ee){return(0,_jsxRuntime.jsxs)(_sharedUi.TickProvider,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inlineRoot,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.inlineHeader,..._sharedUi.windowDragProps,children:K()}),G,W]}),J]})}return(0,_jsxRuntime.jsxs)(_sharedUi.TickProvider,{children:[(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:h,onClose:m,onMinimize:I,persistenceKey:Ee,header:{showToggleButton:true,customContent:K()},onModeChange:ge,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:Ze,styles:{},footer:W,footerHeight:we,children:G}),J]})}function ZustandToolView(h={}){return(0,_jsxRuntime.jsx)(ZustandModal,{...h,inline:true,visible:true,onClose:()=>{}})}const styles=_reactNative.StyleSheet.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:_sharedUi.macOSColors.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:_sharedUi.night.color.buttonSurface,borderWidth:1,borderColor:_sharedUi.night.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:_sharedUi.night.color.accentSoft,borderColor:_sharedUi.night.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.night.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.warning+"20"},disabledText:{color:_sharedUi.night.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},lockedText:{color:_sharedUi.night.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:_sharedUi.night.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:_sharedUi.night.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ZustandStateDetailContent=ZustandStateDetailContent;exports.ZustandStateDetailFooter=ZustandStateDetailFooter;var _reactNative=require("react-native");var _react=require("react");var _sharedUi=require("@buoy-gg/shared-ui");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _ZustandDetailViewToggle=require("./ZustandDetailViewToggle");var _ZustandStateInfoView=require("./ZustandStateInfoView");var _zustandStateStore=require("../utils/zustandStateStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function getChangeColor(e){return _zustandStateStore.zustandStateStore.getStoreColor(e.storeName)}function getChangeLabel(e){switch(e.category){case"replace":return"REPLACE";case"persist":return"HYDRATE";case"initial":return"INIT";default:return"SET"}}function getValueType(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";return typeof e}function formatTimestamp(e){const o=new Date(e);return o.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}const DIFF_MODE_TABS=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];function ZustandStateDetailContent({change:e,changes:o,selectedIndex:t,onIndexChange:r,disableInternalFooter:n=false,initialView:g="change"}){const[s,T]=(0,_react.useState)(g);const[m,b]=(0,_react.useState)("tree");const i=o.length;const l=getChangeColor(e);const d=getChangeLabel(e);const p=getValueType((0,_sharedUi.parseValue)(e.nextState));const u=i-t;const h=u-1;const c=t<i-1?t+1:null;const a=c!==null?o[c]:null;const w=(0,_react.useMemo)(()=>({index:c??0,label:h>0?`#${h}`:"Initial",timestamp:a?formatTimestamp(a.timestamp):"",relativeTime:a?(0,_sharedUi.formatRelativeTime)(new Date(a.timestamp)):"state",badge:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadgeSmall,{backgroundColor:`${getChangeColor(a)}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeTextSmall,{color:getChangeColor(a)}],children:getChangeLabel(a)})}):void 0}),[c,a,h]);const y=(0,_react.useMemo)(()=>({index:t,label:`#${u}`,timestamp:formatTimestamp(e.timestamp),relativeTime:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadgeSmall,{backgroundColor:`${l}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeTextSmall,{color:l}],children:d})})}),[t,e.timestamp,l,d,u]);const V=(0,_react.useCallback)(()=>{const f=(0,_sharedUi.parseValue)(e.nextState);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.contentCard,testID:`${_testIDs.ZUSTAND_TEST_ID}-state-card`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.valueHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.valueLabel,children:"STATE AFTER CHANGE"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.valueHeaderBadges,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadge,{backgroundColor:`${l}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeText,{color:l}],children:d})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.typeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.typeText,testID:`${_testIDs.ZUSTAND_TEST_ID}-state-type`,children:p.toUpperCase()})})]})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:f,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextState,l,d,p]);const v=(0,_react.useCallback)(()=>{const f=(0,_sharedUi.parseValue)(e.prevState);const x=(0,_sharedUi.parseValue)(e.nextState);if(m==="split"){return(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:{flex:1},showsVerticalScrollIndicator:true,children:(0,_jsxRuntime.jsx)(_dataViewer.SplitDiffViewer,{oldValue:f,newValue:x,theme:_dataViewer.diffThemes.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})})}return(0,_jsxRuntime.jsx)(_dataViewer.TreeDiffViewer,{oldValue:f,newValue:x})},[e.prevState,e.nextState,m]);const D=(0,_react.useCallback)(()=>{r(Math.min(i-1,t+1))},[t,i,r]);const C=(0,_react.useCallback)(()=>{r(Math.max(0,t-1))},[t,r]);const j=e.prevState===void 0;const S=!n&&i>1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsx)(_ZustandDetailViewToggle.ZustandDetailViewToggle,{activeView:s,onViewChange:T,diffDisabled:j}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.contentArea,S&&styles.contentAreaFooterPad],children:[s==="change"&&(0,_jsxRuntime.jsx)(_ZustandStateInfoView.ZustandStateInfoView,{change:e}),s==="state"&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.stateContainer,children:V()}),s==="diff"&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.diffContainer,testID:`${_testIDs.ZUSTAND_TEST_ID}-diff`,children:[(0,_jsxRuntime.jsx)(_sharedUi.DiffModeTabs,{tabs:DIFF_MODE_TABS,activeTab:m,onTabChange:b,testIDPrefix:`${_testIDs.ZUSTAND_TEST_ID}-diff-tab`}),(0,_jsxRuntime.jsx)(_sharedUi.CompareBar,{leftEvent:w,rightEvent:y}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.diffContent,testID:`${_testIDs.ZUSTAND_TEST_ID}-diff-content`,children:v()})]})]}),S&&(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:u-1,totalItems:i,onPrevious:D,onNext:C,itemLabel:"Change",subtitle:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),absolute:true})]})}function ZustandStateDetailFooter({change:e,changes:o,selectedIndex:t,onIndexChange:r}){const n=o.length;if(n<=1)return null;const g=n-t;return(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:g-1,totalItems:n,onPrevious:()=>r(Math.min(n-1,t+1)),onNext:()=>r(Math.max(0,t-1)),itemLabel:"Change",subtitle:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp))})}const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:_sharedUi.night.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:_sharedUi.night.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:_sharedUi.night.color.textSecondary,fontFamily:_sharedUi.monoFont,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:_sharedUi.monoFont,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:_sharedUi.night.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont},valueBox:{backgroundColor:_sharedUi.night.color.bg,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:8},valueText:{fontSize:12,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:_sharedUi.monoFont},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ZustandStateDetailContent=ZustandStateDetailContent;exports.ZustandStateDetailFooter=ZustandStateDetailFooter;var _reactNative=require("react-native");var _react=require("react");var _sharedUi=require("@buoy-gg/shared-ui");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _ZustandDetailViewToggle=require("./ZustandDetailViewToggle");var _ZustandStateInfoView=require("./ZustandStateInfoView");var _zustandStateStore=require("../utils/zustandStateStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function getChangeColor(e){return _zustandStateStore.zustandStateStore.getStoreColor(e.storeName)}function getChangeLabel(e){switch(e.category){case"replace":return"REPLACE";case"persist":return"HYDRATE";case"initial":return"INIT";default:return"SET"}}function getValueType(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";return typeof e}function formatTimestamp(e){const o=new Date(e);return o.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}const DIFF_MODE_TABS=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];function ZustandStateDetailContent({change:e,changes:o,selectedIndex:t,onIndexChange:r,disableInternalFooter:n=false,initialView:g="change"}){const[s,T]=(0,_react.useState)(g);const[m,b]=(0,_react.useState)("tree");const i=o.length;const l=getChangeColor(e);const d=getChangeLabel(e);const p=getValueType((0,_sharedUi.parseValue)(e.nextState));const u=i-t;const h=u-1;const c=t<i-1?t+1:null;const a=c!==null?o[c]:null;const w=(0,_react.useMemo)(()=>({index:c??0,label:h>0?`#${h}`:"Initial",timestamp:a?formatTimestamp(a.timestamp):"",relativeTime:a?(0,_sharedUi.formatRelativeTime)(new Date(a.timestamp)):"state",badge:a?(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadgeSmall,{backgroundColor:`${getChangeColor(a)}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeTextSmall,{color:getChangeColor(a)}],children:getChangeLabel(a)})}):void 0}),[c,a,h]);const y=(0,_react.useMemo)(()=>({index:t,label:`#${u}`,timestamp:formatTimestamp(e.timestamp),relativeTime:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadgeSmall,{backgroundColor:`${l}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeTextSmall,{color:l}],children:d})})}),[t,e.timestamp,l,d,u]);const V=(0,_react.useCallback)(()=>{const f=(0,_sharedUi.parseValue)(e.nextState);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.contentCard,testID:`${_testIDs.ZUSTAND_TEST_ID}-state-card`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.valueHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.valueLabel,children:"STATE AFTER CHANGE"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.valueHeaderBadges,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.changeBadge,{backgroundColor:`${l}20`}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.changeText,{color:l}],children:d})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.typeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.typeText,testID:`${_testIDs.ZUSTAND_TEST_ID}-state-type`,children:p.toUpperCase()})})]})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:f,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextState,l,d,p]);const v=(0,_react.useCallback)(()=>{const f=(0,_sharedUi.parseValue)(e.prevState);const x=(0,_sharedUi.parseValue)(e.nextState);if(m==="split"){return(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:{flex:1},showsVerticalScrollIndicator:true,children:(0,_jsxRuntime.jsx)(_dataViewer.SplitDiffViewer,{oldValue:f,newValue:x,theme:_dataViewer.diffThemes.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})})}return(0,_jsxRuntime.jsx)(_dataViewer.TreeDiffViewer,{oldValue:f,newValue:x})},[e.prevState,e.nextState,m]);const D=(0,_react.useCallback)(()=>{r(Math.min(i-1,t+1))},[t,i,r]);const C=(0,_react.useCallback)(()=>{r(Math.max(0,t-1))},[t,r]);const j=e.prevState===void 0;const S=!n&&i>1;return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsx)(_ZustandDetailViewToggle.ZustandDetailViewToggle,{activeView:s,onViewChange:T,diffDisabled:j}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.contentArea,S&&styles.contentAreaFooterPad],children:[s==="change"&&(0,_jsxRuntime.jsx)(_ZustandStateInfoView.ZustandStateInfoView,{change:e}),s==="state"&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.stateContainer,children:V()}),s==="diff"&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.diffContainer,testID:`${_testIDs.ZUSTAND_TEST_ID}-diff`,children:[(0,_jsxRuntime.jsx)(_sharedUi.DiffModeTabs,{tabs:DIFF_MODE_TABS,activeTab:m,onTabChange:b,testIDPrefix:`${_testIDs.ZUSTAND_TEST_ID}-diff-tab`}),(0,_jsxRuntime.jsx)(_sharedUi.CompareBar,{leftEvent:w,rightEvent:y}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.diffContent,testID:`${_testIDs.ZUSTAND_TEST_ID}-diff-content`,children:v()})]})]}),S&&(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:u-1,totalItems:i,onPrevious:D,onNext:C,itemLabel:"Change",subtitle:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp)),absolute:true})]})}function ZustandStateDetailFooter({change:e,changes:o,selectedIndex:t,onIndexChange:r}){const n=o.length;if(n<=1)return null;const g=n-t;return(0,_jsxRuntime.jsx)(_sharedUi.EventStepperFooter,{currentIndex:g-1,totalItems:n,onPrevious:()=>r(Math.min(n-1,t+1)),onNext:()=>r(Math.max(0,t-1)),itemLabel:"Change",subtitle:(0,_sharedUi.formatRelativeTime)(new Date(e.timestamp))})}const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:_sharedUi.night.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:_sharedUi.night.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:_sharedUi.night.color.textSecondary,fontFamily:_sharedUi.monoFont,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:_sharedUi.monoFont,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:_sharedUi.night.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont},valueBox:{backgroundColor:_sharedUi.night.color.bg,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:8},valueText:{fontSize:12,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:_sharedUi.monoFont},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ZustandStateInfoView=void 0;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _license=require("@buoy-gg/license");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _ZustandActionButton=require("./ZustandActionButton");var _zustandStateStore=require("../utils/zustandStateStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(o,t){if("function"==typeof WeakMap)var r=new WeakMap,i=new WeakMap;return(_interopRequireWildcard=function(e,a){if(!a&&e&&e.__esModule)return e;var s,c,d={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return d;if(s=a?i:r){if(s.has(e))return s.get(e);s.set(e,d)}for(const l in e)"default"!==l&&{}.hasOwnProperty.call(e,l)&&((c=(s=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,l))&&(c.get||c.set)?s(d,l,c):d[l]=e[l]);return d})(o,t)}function getCategoryInfo(o){switch(o){case"replace":return{label:"REPLACE",color:_sharedUi.buoyColors.warning,bgColor:_sharedUi.buoyColors.warning+"26"};case"persist":return{label:"PERSIST",color:_sharedUi.buoyColors.info,bgColor:_sharedUi.buoyColors.info+"26"};case"initial":return{label:"INITIAL",color:_sharedUi.night.color.textTertiary,bgColor:_sharedUi.night.color.textTertiary+"26"};default:return{label:"SET STATE",color:_sharedUi.buoyColors.success,bgColor:_sharedUi.buoyColors.success+"26"}}}function formatDuration(o){if(o===void 0)return"N/A";if(o<1)return"<1ms";return`${o.toFixed(1)}ms`}function SectionHeader({icon:o,title:t,badge:r,testID:i}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeader,testID:i,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeaderLeft,children:[(0,_jsxRuntime.jsx)(o,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionTitle,children:t})]}),r]})}function formatTime(o){const t=new Date(o);const r=t.getHours().toString().padStart(2,"0");const i=t.getMinutes().toString().padStart(2,"0");const e=t.getSeconds().toString().padStart(2,"0");const a=t.getMilliseconds().toString().padStart(3,"0");return`${r}:${i}:${e}.${a}`}const ZustandStateInfoView=exports.ZustandStateInfoView=(0,_react.memo)(function o({change:t}){const r=(0,_license.useIsPro)();const[i,e]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{if(i&&r){e(false)}},[i,r]);const a=getCategoryInfo(t.category);const s=t.partial!==void 0&&t.partial!=="(updater fn)";const c=t.changedKeys.length>0;const d=_zustandStateStore.zustandStateStore.getStoreColor(t.storeName);const l=(0,_react.useCallback)(async()=>{if(!r){e(true);return}await(0,_sharedUi.copyToClipboard)(t.nextState)},[t.nextState,r]);const u=(0,_react.useCallback)(()=>{const n=_zustandStateStore.zustandStateStore.getStore(t.storeName);if(n?.api.getInitialState){const S=n.api.getInitialState();n.api.setState(S,true)}},[t.storeName]);const g=(0,_react.useCallback)(()=>{const n=_zustandStateStore.zustandStateStore.getStore(t.storeName);if(n){n.api.setState(t.nextState,true)}},[t.storeName,t.nextState]);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.container,contentContainerStyle:styles.contentContainer,showsVerticalScrollIndicator:false,testID:`${_testIDs.ZUSTAND_TEST_ID}-detail-scroll`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-card`,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Info,title:"CHANGE INFO"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.cardContent,children:[(0,_jsxRuntime.jsx)(_sharedUi.InfoRow,{label:"Store",value:t.storeName,mono:true,valueColor:d,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-store`}),(0,_jsxRuntime.jsx)(_sharedUi.InfoRow,{label:"Time",value:formatTime(t.timestamp),mono:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-time`}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.badgeRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.categoryBadge,{backgroundColor:a.bgColor}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.categoryText,{color:a.color}],testID:`${_testIDs.ZUSTAND_TEST_ID}-info-category`,children:a.label})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.durationBadge,t.isSlowUpdate&&styles.durationBadgeSlow],children:[(0,_jsxRuntime.jsx)(_sharedUi.Clock,{size:10,color:t.isSlowUpdate?_sharedUi.buoyColors.error:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.durationText,t.isSlowUpdate&&styles.durationTextSlow],testID:`${_testIDs.ZUSTAND_TEST_ID}-info-duration`,children:formatDuration(t.duration)}),t.isSlowUpdate&&(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:10,color:_sharedUi.buoyColors.error})]}),t.hasStateChange?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.changesBadge,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:10,color:_sharedUi.buoyColors.success}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.changesText,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-changes`,children:t.diffSummary||"changed"})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.noChangesBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noChangesText,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-no-changes`,children:"no change"})}),t.isPersisted&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.persistBadge,children:[(0,_jsxRuntime.jsx)(_sharedUi.Database,{size:10,color:_sharedUi.buoyColors.info}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.persistText,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-persisted`,children:"PERSISTED"})]})]})]})]}),c&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,testID:`${_testIDs.ZUSTAND_TEST_ID}-keys-card`,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Zap,title:"CHANGED KEYS",badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.countBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.countText,testID:`${_testIDs.ZUSTAND_TEST_ID}-keys-count`,children:t.changedKeys.length})})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.cardContent,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.keysContainer,children:t.changedKeys.map(n=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.keyBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.keyText,testID:`${_testIDs.ZUSTAND_TEST_ID}-key-${n}`,children:n})},n))})})]}),s&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,testID:`${_testIDs.ZUSTAND_TEST_ID}-partial-card`,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Box,title:"PARTIAL (setState argument)",badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.typeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.typeText,testID:`${_testIDs.ZUSTAND_TEST_ID}-partial-type`,children:Array.isArray(t.partial)?"ARRAY":typeof t.partial==="object"?"OBJECT":String(typeof t.partial).toUpperCase()})})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:(0,_sharedUi.parseValue)(t.partial),showTypeFilter:true,rawMode:true,initialExpanded:true})})]}),t.partial==="(updater fn)"&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,testID:`${_testIDs.ZUSTAND_TEST_ID}-updater-card`,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Box,title:"SET STATE CALL"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.cardContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.updaterText,children:"Called with an updater function: set((state) => ...)"}),(0,_jsxRuntime.jsx)(_reactNative.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."})]})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionsGrid,children:[(0,_jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton,{type:"jump",text:"JUMP",onPress:g,testID:`${_testIDs.ZUSTAND_TEST_ID}-jump`}),(0,_jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton,{type:"reset",text:"RESET STORE",onPress:u,testID:`${_testIDs.ZUSTAND_TEST_ID}-reset`}),(0,_jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton,{type:"copy",text:"COPY STATE",onPress:l,testID:`${_testIDs.ZUSTAND_TEST_ID}-copy-state`})]}),(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:i,onClose:()=>e(false),featureName:"Copy"})]})});const styles=_reactNative.StyleSheet.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:_sharedUi.night.color.surface,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.accentBorderStrong,overflow:"hidden",shadowColor:_sharedUi.night.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.accentBorder,backgroundColor:_sharedUi.night.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},cardContent:{padding:14,gap:10},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:_sharedUi.night.color.surfaceElevated},durationBadgeSlow:{backgroundColor:_sharedUi.buoyColors.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:_sharedUi.night.color.textSecondary,fontFamily:_sharedUi.monoFont},durationTextSlow:{color:_sharedUi.buoyColors.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:_sharedUi.buoyColors.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.night.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:_sharedUi.night.color.textTertiary},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:_sharedUi.buoyColors.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:_sharedUi.night.color.accentSoft,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.night.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:_sharedUi.night.color.surfaceElevated},typeText:{fontSize:8,fontWeight:"600",color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont},dataViewerContainer:{backgroundColor:_sharedUi.night.color.bg,minHeight:60},updaterText:{fontSize:12,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},updaterSubtext:{fontSize:11,color:_sharedUi.night.color.textTertiary,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ZustandStateInfoView=void 0;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _license=require("@buoy-gg/license");var _dataViewer=require("@buoy-gg/shared-ui/dataViewer");var _ZustandActionButton=require("./ZustandActionButton");var _zustandStateStore=require("../utils/zustandStateStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(o,t){if("function"==typeof WeakMap)var r=new WeakMap,i=new WeakMap;return(_interopRequireWildcard=function(e,a){if(!a&&e&&e.__esModule)return e;var s,c,d={__proto__:null,default:e};if(null===e||"object"!=typeof e&&"function"!=typeof e)return d;if(s=a?i:r){if(s.has(e))return s.get(e);s.set(e,d)}for(const l in e)"default"!==l&&{}.hasOwnProperty.call(e,l)&&((c=(s=Object.defineProperty)&&Object.getOwnPropertyDescriptor(e,l))&&(c.get||c.set)?s(d,l,c):d[l]=e[l]);return d})(o,t)}function getCategoryInfo(o){switch(o){case"replace":return{label:"REPLACE",color:_sharedUi.buoyColors.warning,bgColor:_sharedUi.buoyColors.warning+"26"};case"persist":return{label:"PERSIST",color:_sharedUi.buoyColors.info,bgColor:_sharedUi.buoyColors.info+"26"};case"initial":return{label:"INITIAL",color:_sharedUi.night.color.textTertiary,bgColor:_sharedUi.night.color.textTertiary+"26"};default:return{label:"SET STATE",color:_sharedUi.buoyColors.success,bgColor:_sharedUi.buoyColors.success+"26"}}}function formatDuration(o){if(o===void 0)return"N/A";if(o<1)return"<1ms";return`${o.toFixed(1)}ms`}function SectionHeader({icon:o,title:t,badge:r,testID:i}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeader,testID:i,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeaderLeft,children:[(0,_jsxRuntime.jsx)(o,{size:14,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionTitle,children:t})]}),r]})}function formatTime(o){const t=new Date(o);const r=t.getHours().toString().padStart(2,"0");const i=t.getMinutes().toString().padStart(2,"0");const e=t.getSeconds().toString().padStart(2,"0");const a=t.getMilliseconds().toString().padStart(3,"0");return`${r}:${i}:${e}.${a}`}const ZustandStateInfoView=exports.ZustandStateInfoView=(0,_react.memo)(function o({change:t}){const r=(0,_license.useIsPro)();const[i,e]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{if(i&&r){e(false)}},[i,r]);const a=getCategoryInfo(t.category);const s=t.partial!==void 0&&t.partial!=="(updater fn)";const c=t.changedKeys.length>0;const d=_zustandStateStore.zustandStateStore.getStoreColor(t.storeName);const l=(0,_react.useCallback)(async()=>{if(!r){e(true);return}await(0,_sharedUi.copyToClipboard)(t.nextState)},[t.nextState,r]);const u=(0,_react.useCallback)(()=>{const n=_zustandStateStore.zustandStateStore.getStore(t.storeName);if(n?.api.getInitialState){const S=n.api.getInitialState();n.api.setState(S,true)}},[t.storeName]);const g=(0,_react.useCallback)(()=>{const n=_zustandStateStore.zustandStateStore.getStore(t.storeName);if(n){n.api.setState(t.nextState,true)}},[t.storeName,t.nextState]);return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:styles.container,contentContainerStyle:styles.contentContainer,showsVerticalScrollIndicator:false,testID:`${_testIDs.ZUSTAND_TEST_ID}-detail-scroll`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-card`,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Info,title:"CHANGE INFO"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.cardContent,children:[(0,_jsxRuntime.jsx)(_sharedUi.InfoRow,{label:"Store",value:t.storeName,mono:true,valueColor:d,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-store`}),(0,_jsxRuntime.jsx)(_sharedUi.InfoRow,{label:"Time",value:formatTime(t.timestamp),mono:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-time`}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.badgeRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.categoryBadge,{backgroundColor:a.bgColor}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.categoryText,{color:a.color}],testID:`${_testIDs.ZUSTAND_TEST_ID}-info-category`,children:a.label})}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:[styles.durationBadge,t.isSlowUpdate&&styles.durationBadgeSlow],children:[(0,_jsxRuntime.jsx)(_sharedUi.Clock,{size:10,color:t.isSlowUpdate?_sharedUi.buoyColors.error:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.durationText,t.isSlowUpdate&&styles.durationTextSlow],testID:`${_testIDs.ZUSTAND_TEST_ID}-info-duration`,children:formatDuration(t.duration)}),t.isSlowUpdate&&(0,_jsxRuntime.jsx)(_sharedUi.AlertTriangle,{size:10,color:_sharedUi.buoyColors.error})]}),t.hasStateChange?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.changesBadge,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:10,color:_sharedUi.buoyColors.success}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.changesText,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-changes`,children:t.diffSummary||"changed"})]}):(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.noChangesBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.noChangesText,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-no-changes`,children:"no change"})}),t.isPersisted&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.persistBadge,children:[(0,_jsxRuntime.jsx)(_sharedUi.Database,{size:10,color:_sharedUi.buoyColors.info}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.persistText,testID:`${_testIDs.ZUSTAND_TEST_ID}-info-persisted`,children:"PERSISTED"})]})]})]})]}),c&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,testID:`${_testIDs.ZUSTAND_TEST_ID}-keys-card`,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Zap,title:"CHANGED KEYS",badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.countBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.countText,testID:`${_testIDs.ZUSTAND_TEST_ID}-keys-count`,children:t.changedKeys.length})})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.cardContent,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.keysContainer,children:t.changedKeys.map(n=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.keyBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.keyText,testID:`${_testIDs.ZUSTAND_TEST_ID}-key-${n}`,children:n})},n))})})]}),s&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,testID:`${_testIDs.ZUSTAND_TEST_ID}-partial-card`,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Box,title:"PARTIAL (setState argument)",badge:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.typeBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.typeText,testID:`${_testIDs.ZUSTAND_TEST_ID}-partial-type`,children:Array.isArray(t.partial)?"ARRAY":typeof t.partial==="object"?"OBJECT":String(typeof t.partial).toUpperCase()})})}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.dataViewerContainer,children:(0,_jsxRuntime.jsx)(_dataViewer.DataViewer,{title:"",data:(0,_sharedUi.parseValue)(t.partial),showTypeFilter:true,rawMode:true,initialExpanded:true})})]}),t.partial==="(updater fn)"&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.card,testID:`${_testIDs.ZUSTAND_TEST_ID}-updater-card`,children:[(0,_jsxRuntime.jsx)(SectionHeader,{icon:_sharedUi.Box,title:"SET STATE CALL"}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.cardContent,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.updaterText,children:"Called with an updater function: set((state) => ...)"}),(0,_jsxRuntime.jsx)(_reactNative.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."})]})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.actionsGrid,children:[(0,_jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton,{type:"jump",text:"JUMP",onPress:g,testID:`${_testIDs.ZUSTAND_TEST_ID}-jump`}),(0,_jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton,{type:"reset",text:"RESET STORE",onPress:u,testID:`${_testIDs.ZUSTAND_TEST_ID}-reset`}),(0,_jsxRuntime.jsx)(_ZustandActionButton.ZustandActionButton,{type:"copy",text:"COPY STATE",onPress:l,testID:`${_testIDs.ZUSTAND_TEST_ID}-copy-state`})]}),(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:i,onClose:()=>e(false),featureName:"Copy"})]})});const styles=_reactNative.StyleSheet.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:_sharedUi.night.color.surface,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.accentBorderStrong,overflow:"hidden",shadowColor:_sharedUi.night.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.accentBorder,backgroundColor:_sharedUi.night.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},cardContent:{padding:14,gap:10},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:_sharedUi.night.color.surfaceElevated},durationBadgeSlow:{backgroundColor:_sharedUi.buoyColors.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:_sharedUi.night.color.textSecondary,fontFamily:_sharedUi.monoFont},durationTextSlow:{color:_sharedUi.buoyColors.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:_sharedUi.buoyColors.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.night.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:_sharedUi.night.color.textTertiary},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.buoyColors.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:_sharedUi.buoyColors.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:_sharedUi.night.color.accentSoft,borderWidth:1,borderColor:_sharedUi.night.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:_sharedUi.night.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:_sharedUi.night.color.surfaceElevated},typeText:{fontSize:8,fontWeight:"600",color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont},dataViewerContainer:{backgroundColor:_sharedUi.night.color.bg,minHeight:60},updaterText:{fontSize:12,color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},updaterSubtext:{fontSize:11,color:_sharedUi.night.color.textTertiary,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ZustandStoreBrowser=ZustandStoreBrowser;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _zustandStateStore=require("../utils/zustandStateStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function getKeysPreview(r){try{const t=r.api.getState();if(t&&typeof t==="object"&&t.__buoyStateOnDevice===true){return"on device"}if(t&&typeof t==="object"){const l=Object.keys(t);const o=l.filter(n=>{const e=t[n];return typeof e!=="function"});if(o.length===0)return"no data keys";if(o.length<=3)return o.join(", ");return`${o.slice(0,2).join(", ")} +${o.length-2}`}return""}catch{return""}}function LoadingBrowserState(){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.ZUSTAND_TEST_ID}-stores-loading`,otto:"loading",title:"Loading stores\u2026",message:"Waiting for the device to send its registered stores."})}function EmptyBrowserState(){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.ZUSTAND_TEST_ID}-stores-empty`,otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores.\nThey will appear here with their current state."})}function ZustandStoreBrowser({stores:r,searchQuery:t,isLoading:l=false,onOpenStore:o}){const n=(0,_react.useMemo)(()=>{if(!t)return r;const e=t.toLowerCase();return r.filter(s=>s.name.toLowerCase().includes(e)||s.persistName&&s.persistName.toLowerCase().includes(e))},[r,t]);if(n.length===0&&!t){return l?(0,_jsxRuntime.jsx)(LoadingBrowserState,{}):(0,_jsxRuntime.jsx)(EmptyBrowserState,{})}if(n.length===0&&t){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.ZUSTAND_TEST_ID}-stores-no-match`,...(0,_sharedUi.resolveListEmptyState)({subject:"stores",verb:"registered",search:t,total:r.length,waiting:{otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores."}})})}return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.container,contentContainerStyle:styles.scrollContent,showsVerticalScrollIndicator:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-stores-scroll`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionTitle,children:"STORES"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sectionCountBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionCountText,testID:`${_testIDs.ZUSTAND_TEST_ID}-stores-count`,children:n.length})})]}),n.map(e=>{const s=getKeysPreview(e);const a=_zustandStateStore.zustandStateStore.getStoreColor(e.name);const i=(0,_testIDs.storeRowTestID)(e.name);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.storeRowWrapper,children:[(0,_jsxRuntime.jsx)(_sharedUi.CompactRow,{statusDotColor:a,statusLabel:e.isPersisted?"persisted":"in-memory",primaryText:e.name,secondaryText:s||void 0,showChevron:true,onPress:()=>o(e.name),testID:i,statusTestID:`${i}-backing`,primaryTestID:`${i}-name`,secondaryTestID:`${i}-keys`}),e.stateChangeCount>0&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.absCountBadge,{backgroundColor:a+"22",borderColor:a+"55"}],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.absCountText,{color:a}],testID:`${i}-count`,children:String(e.stateChangeCount)})})]},e.name)})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},storeRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:_sharedUi.monoFont},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:_sharedUi.night.color.textTertiary},sectionCountBadge:{backgroundColor:_sharedUi.night.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ZustandStoreBrowser=ZustandStoreBrowser;var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _zustandStateStore=require("../utils/zustandStateStore");var _testIDs=require("../utils/testIDs");var _jsxRuntime=require("react/jsx-runtime");function getKeysPreview(r){try{const e=r.api.getState();if(e&&typeof e==="object"&&e.__buoyStateOnDevice===true){return"on device"}if(e&&typeof e==="object"){const l=Object.keys(e);const o=l.filter(n=>{const t=e[n];return typeof t!=="function"});if(o.length===0)return"no data keys";if(o.length<=3)return o.join(", ");return`${o.slice(0,2).join(", ")} +${o.length-2}`}return""}catch{return""}}function LoadingBrowserState(){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.ZUSTAND_TEST_ID}-stores-loading`,otto:"loading",title:"Loading stores\u2026",message:"Waiting for the device to send its registered stores."})}function EmptyBrowserState(){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.ZUSTAND_TEST_ID}-stores-empty`,otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores.\nThey will appear here with their current state."})}function ZustandStoreBrowser({stores:r,searchQuery:e,isLoading:l=false,onOpenStore:o}){const n=(0,_react.useMemo)(()=>{if(!e)return r;const t=e.toLowerCase();return r.filter(s=>s.name.toLowerCase().includes(t)||s.persistName&&s.persistName.toLowerCase().includes(t))},[r,e]);if(n.length===0&&!e){return l?(0,_jsxRuntime.jsx)(LoadingBrowserState,{}):(0,_jsxRuntime.jsx)(EmptyBrowserState,{})}if(n.length===0&&e){return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:`${_testIDs.ZUSTAND_TEST_ID}-stores-no-match`,...(0,_sharedUi.resolveListEmptyState)({subject:"stores",verb:"registered",search:e,total:r.length,waiting:{otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores."}})})}return(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:styles.container,contentContainerStyle:styles.scrollContent,showsVerticalScrollIndicator:true,testID:`${_testIDs.ZUSTAND_TEST_ID}-stores-scroll`,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionTitle,children:"STORES"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.sectionCountBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.sectionCountText,testID:`${_testIDs.ZUSTAND_TEST_ID}-stores-count`,children:n.length})})]}),n.map(t=>{const s=getKeysPreview(t);const a=_zustandStateStore.zustandStateStore.getStoreColor(t.name);const i=(0,_testIDs.storeRowTestID)(t.name);return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.storeRowWrapper,children:[(0,_jsxRuntime.jsx)(_sharedUi.CompactRow,{statusDotColor:a,statusLabel:t.isPersisted?"persisted":"in-memory",primaryText:t.name,secondaryText:s||void 0,showChevron:true,onPress:()=>o(t.name),testID:i,statusTestID:`${i}-backing`,primaryTestID:`${i}-name`,secondaryTestID:`${i}-keys`}),t.stateChangeCount>0&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.absCountBadge,{backgroundColor:a+"22",borderColor:a+"55"}],pointerEvents:"none",children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.absCountText,{color:a}],testID:`${i}-count`,children:String(t.stateChangeCount)})})]},t.name)})]})}const styles=_reactNative.StyleSheet.create({container:{flex:1},storeRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:_sharedUi.monoFont},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:_sharedUi.night.color.textTertiary},sectionCountBadge:{backgroundColor:_sharedUi.night.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont}});
@@ -1 +1 @@
1
- "use strict";import{useState as f,useMemo as b,useRef as H,useCallback as r,useEffect as me}from"react";import{View as k,Text as U,StyleSheet as tt,FlatList as pe,TouchableOpacity as G}from"react-native";import{JsModal as ot,ModalHeader as s,TabSelector as nt,macOSColors as rt,night as i,ToolEmptyState as J,resolveListEmptyState as Se,Search as st,Filter as at,Power as lt,Lock as it,devToolsStorageKeys as ct,ProUpgradeModal as dt,PowerToggleButton as ut,ToolbarCopyButton as Q,ToolbarClearButton as ht,truncatePayload as w,TickProvider as be,useLimit as gt,windowDragProps as ft,EVENT_LIST_PRESET as ye}from"@buoy-gg/shared-ui";import{useIsPro as mt}from"@buoy-gg/license";import{useZustandStateChanges as pt}from"../hooks/useZustandStateChanges";import{ZustandStateChangeItem as St}from"./ZustandStateChangeItem";import{ZustandStateDetailContent as bt,ZustandStateDetailFooter as yt}from"./ZustandStateDetailContent";import{ZustandStoreBrowser as Ct}from"./ZustandStoreBrowser";import{ZustandStoreDetailContent as It}from"./ZustandStoreDetailContent";import{ZustandEventFilterView as Tt}from"./ZustandEventFilterView";import{ZUSTAND_TEST_ID as n,buildChangeRowTestIDs as xt}from"../utils/testIDs";import{jsx as t,jsxs as c,Fragment as Ce}from"react/jsx-runtime";function wt({isEnabled:I,searchText:z,totalChanges:$}){const F=Se({subject:"changes",search:z,total:$,capturing:I,waiting:{otto:"waiting",title:"No state changes",message:"State changes will appear here as stores update."},paused:{title:"No state changes",message:"Enable capture to start recording state changes"}});return t(J,{...F,testID:`${n}-empty`})}export function ZustandModal({visible:I,onClose:z,onBack:$,onMinimize:F,enableSharedModalDimensions:Ie=false,inline:Te=false,storesLoading:xe=false,initialTab:we="stores",initialSelectedChangeId:T,initialDetailView:ve,onChangeSelect:L,onStoreExpand:q}){const vt=mt();const P=gt("zustand.changes");const[Be,X]=f(false);const[m,De]=f(we);const[d,R]=f(null);const[v,M]=f(null);const[Z,V]=f(false);const[p,Y]=f(new Set);const{stateChanges:ee,filteredChanges:j,filter:Bt,setFilter:B,stats:ke,stores:D,clearChanges:$e,isEnabled:A,toggleCapture:Pe}=pt();const h=b(()=>{if(p.size===0)return j;return j.filter(e=>!Array.from(p).some(o=>e.storeName.toLowerCase().includes(o.toLowerCase())))},[j,p]);const x=b(()=>{if(p.size===0)return D;return D.filter(e=>!Array.from(p).some(o=>e.name.toLowerCase().includes(o.toLowerCase())))},[D,p]);const Ae=b(()=>{if(!d)return 0;return ee.filter(e=>e.storeName===d).length},[ee,d]);const N=b(()=>{if(!d)return h;return h.filter(e=>e.storeName===d)},[h,d]);const _=b(()=>N.slice(0,P),[N,P]);const K=b(()=>Math.max(0,N.length-P),[N.length,P]);const Ne=K>0;const l=_;const[O,y]=f(null);const C=b(()=>{if(O===null)return null;const e=l.findIndex(o=>o.id===O);return e>=0?e:null},[O,l]);const u=C!==null?l[C]:null;const te=H(null);me(()=>{if(!L)return;const e=u?.id??null;if(e===null||e===te.current)return;te.current=e;L(u)},[u,L]);const oe=H(null);me(()=>{if(!T)return;if(oe.current===T)return;const e=l.some(o=>o.id===T);if(!e)return;oe.current=T;y(T)},[T,l]);const[S,W]=f("");const[Ee,E]=f(false);const Dt=H(null);const He=H(null);const ze=r(e=>{},[]);const Fe=e=>{W(e);if(m==="events"){B(o=>({...o,searchText:e}))}};const Le=r(()=>{W("");B(e=>({...e,searchText:""}));E(false)},[B]);const ne=r(e=>{y(e.id)},[]);const Re=r(()=>{X(true)},[]);const Me=r(()=>{y(null)},[]);const re=r(e=>{const o=l[e];if(o){y(o.id)}},[l]);const Ze=r(e=>{R(e);y(null)},[]);const Ve=r(()=>{R(null);y(null)},[]);const je=r(e=>{M(e);q?.(e)},[q]);const _e=r(()=>{M(null)},[]);const Ke=r(()=>{return x.reduce((e,o)=>{try{const g=o.api.getState();if(g&&typeof g==="object"){const ge={};for(const[et,fe]of Object.entries(g)){if(typeof fe!=="function")ge[et]=w(fe)}e[o.name]=ge}else{e[o.name]=w(g)}}catch{e[o.name]=null}return e},{})},[x]);const Oe=r(()=>{return h.map(e=>({id:e.id,storeName:e.storeName,timestamp:e.timestamp,prevState:w(e.prevState),nextState:w(e.nextState),hasStateChange:e.hasStateChange,changedKeys:e.changedKeys}))},[h]);const We=r(()=>{return l.map(e=>({id:e.id,storeName:e.storeName,timestamp:e.timestamp,prevState:w(e.prevState),nextState:w(e.nextState),hasStateChange:e.hasStateChange,changedKeys:e.changedKeys}))},[l]);const Ue=r(e=>{Y(o=>{const g=new Set(o);if(g.has(e))g.delete(e);else g.add(e);return g})},[]);const Ge=r(e=>{Y(o=>new Set([...o,e]))},[]);const Je=r(e=>{De(e);R(null);M(null);y(null);V(false);if(S){W("");B(o=>({...o,searchText:""}))}E(false)},[S,B]);const se=r(e=>e.id,[]);const ae=b(()=>xt(l),[l]);const le=r(({item:e})=>{return t(St,{change:e,onPress:ne,testID:ae.get(e.id)})},[ne,ae]);const ie=p.size>0;const ce=()=>{if(Z){return c(s,{children:[t(s.Navigation,{onBack:()=>V(false)}),t(s.Content,{title:"Filters",centered:true,testID:`${n}-filters-title`})]})}if(u){return c(s,{children:[t(s.Navigation,{onBack:Me}),t(s.Content,{title:`${u.storeName}/setState`,centered:true,testID:`${n}-detail-title`})]})}if(d){return c(s,{children:[t(s.Navigation,{onBack:Ve}),t(s.Content,{title:`${d} History`,centered:true,testID:`${n}-history-title`}),t(s.Actions,{children:t(Q,{value:We,disabled:l.length===0,buttonStyle:a.headerActionButton,testID:`${n}-copy`})})]})}if(v){return c(s,{children:[t(s.Navigation,{onBack:_e}),t(s.Content,{title:v,centered:true,testID:`${n}-store-detail-title`})]})}return c(s,{children:[$&&t(s.Navigation,{onBack:$}),t(s.Content,{title:"",children:Ee?t(s.Search,{value:S,onChangeText:Fe,onCancel:Le,placeholder:m==="stores"?"Search stores...":"Search events...",accessibilityLabel:"Search Zustand stores and events",iconSize:14,testID:`${n}-search-field`,containerTestID:`${n}-search`,clearTestID:`${n}-search-clear`,onBlur:()=>{if(S.length===0)E(false)}}):t(nt,{tabs:[{key:"stores",label:`Stores${x.length>0?` (${x.length})`:""}`},{key:"events",label:`Events${h.length>0?` (${h.length})`:""}`}],activeTab:m,onTabChange:Je,testIDPrefix:`${n}-tab`})}),c(s.Actions,{children:[t(G,{onPress:()=>E(true),style:a.headerActionButton,testID:`${n}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:t(st,{size:14,color:i.color.textSecondary})}),t(G,{onPress:()=>V(true),style:[a.headerActionButton,ie&&a.headerActionButtonActive],testID:`${n}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:t(at,{size:14,color:ie?i.color.accent:i.color.textSecondary})}),m==="stores"&&t(Q,{value:Ke,disabled:x.length===0,buttonStyle:a.headerActionButton,testID:`${n}-copy`}),m==="events"&&c(Ce,{children:[t(Q,{value:Oe,disabled:h.length===0,buttonStyle:a.headerActionButton,testID:`${n}-copy`}),t(ut,{isEnabled:A,onToggle:Pe,accessibilityLabel:"Toggle Zustand state capture",testID:`${n}-power`}),t(ht,{onPress:$e,disabled:h.length===0,buttonStyle:a.headerActionButton,testID:`${n}-clear`})]})]})]})};const Qe=()=>{if(Z){return t(Tt,{ignoredPatterns:p,onTogglePattern:Ue,onAddPattern:Ge,stores:D})}if(u&&C!==null){return t(bt,{change:u,changes:l,selectedIndex:C,onIndexChange:re,disableInternalFooter:true,initialView:ve})}if(d){return l.length>0?t(pe,{testID:`${n}-history-list`,data:l,renderItem:le,keyExtractor:se,contentContainerStyle:a.listContent,showsVerticalScrollIndicator:true,...ye}):t(J,{testID:`${n}-history-empty`,...Se({subject:"changes",search:S,total:S.trim()?Ae:0,capturing:A,waiting:{otto:"waiting",title:"No history yet",message:`State changes for ${d} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${d}.`}})})}if(v){const e=D.find(o=>o.name===v)??null;return e?t(It,{store:e,onViewHistory:Ze}):t(J,{testID:`${n}-store-detail-gone`,otto:"ghost",title:"Store no longer registered",message:`${v} is not in the registry any more.`})}if(m==="stores"){return t(Ct,{stores:x,searchQuery:S,isLoading:xe,onOpenStore:je})}return c(Ce,{children:[!A&&c(k,{style:a.disabledBanner,testID:`${n}-banner-disabled`,children:[t(lt,{size:14,color:i.color.warning}),t(U,{style:a.disabledText,children:"State capture is disabled"})]}),Ne&&c(G,{style:a.lockedBanner,onPress:Re,activeOpacity:.8,testID:`${n}-locked`,accessibilityRole:"button",children:[t(it,{size:14,color:i.color.accent}),c(U,{style:a.lockedText,testID:`${n}-locked-text`,children:[K," older"," ",K===1?"change":"changes"," locked"]}),t(k,{style:a.upgradeBadge,children:t(U,{style:a.upgradeBadgeText,children:"UPGRADE"})})]}),_.length>0?t(pe,{ref:He,testID:`${n}-list`,data:_,renderItem:le,keyExtractor:se,contentContainerStyle:a.listContent,showsVerticalScrollIndicator:true,...ye}):t(wt,{isEnabled:A,searchText:S,totalChanges:ke.totalChanges})]})};const qe=Ie?ct.modal.root():"buoy-zustand-modal";if(!I)return null;const de=u&&C!==null?t(yt,{change:u,changes:l,selectedIndex:C,onIndexChange:re}):null;const Xe=u&&l.length>1?68:0;const Ye=!Z&&(u&&C!==null||d!=null||m==="events"||m==="stores");const ue=t(k,{style:a.container,children:Qe()});const he=t(dt,{visible:Be,onClose:()=>X(false),featureName:"Full State History"});if(Te){return c(be,{children:[c(k,{style:a.inlineRoot,children:[t(k,{style:a.inlineHeader,...ft,children:ce()}),ue,de]}),he]})}return c(be,{children:[t(ot,{visible:I,onClose:z,onMinimize:F,persistenceKey:qe,header:{showToggleButton:true,customContent:ce()},onModeChange:ze,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:Ye,styles:{},footer:de,footerHeight:Xe,children:ue}),he]})}export function ZustandToolView(I={}){return t(ZustandModal,{...I,inline:true,visible:true,onClose:()=>{}})}const a=tt.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:rt.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:i.color.buttonSurface,borderWidth:1,borderColor:i.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:i.color.accentSoft,borderColor:i.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:i.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:i.color.warning+"20"},disabledText:{color:i.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:i.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:i.color.accentBorder},lockedText:{color:i.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:i.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:i.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});
1
+ "use strict";import{useState as f,useMemo as b,useRef as H,useCallback as r,useEffect as pe}from"react";import{View as k,Text as U,StyleSheet as tt,FlatList as me,TouchableOpacity as G}from"react-native";import{JsModal as ot,ModalHeader as s,TabSelector as nt,macOSColors as rt,night as i,ToolEmptyState as J,resolveListEmptyState as Se,Search as st,Filter as at,Power as lt,Lock as it,devToolsStorageKeys as ct,ProUpgradeModal as dt,PowerToggleButton as ut,ToolbarCopyButton as Q,ToolbarClearButton as ht,truncatePayload as w,TickProvider as be,useLimit as gt,windowDragProps as ft,EVENT_LIST_PRESET as ye}from"@buoy-gg/shared-ui";import{useIsPro as pt}from"@buoy-gg/license";import{useZustandStateChanges as mt}from"../hooks/useZustandStateChanges";import{ZustandStateChangeItem as St}from"./ZustandStateChangeItem";import{ZustandStateDetailContent as bt,ZustandStateDetailFooter as yt}from"./ZustandStateDetailContent";import{ZustandStoreBrowser as Ct}from"./ZustandStoreBrowser";import{ZustandStoreDetailContent as Tt}from"./ZustandStoreDetailContent";import{ZustandEventFilterView as It}from"./ZustandEventFilterView";import{ZUSTAND_TEST_ID as n,buildChangeRowTestIDs as xt}from"../utils/testIDs";import{jsx as t,jsxs as c,Fragment as Ce}from"react/jsx-runtime";function wt({isEnabled:T,searchText:z,totalChanges:$}){const F=Se({subject:"changes",search:z,total:$,capturing:T,waiting:{otto:"waiting",title:"No state changes",message:"State changes will appear here as stores update."},paused:{title:"No state changes",message:"Enable capture to start recording state changes"}});return t(J,{...F,testID:`${n}-empty`})}export function ZustandModal({visible:T,onClose:z,onBack:$,onMinimize:F,enableSharedModalDimensions:Te=false,inline:Ie=false,storesLoading:xe=false,initialTab:we="stores",initialSelectedChangeId:I,initialDetailView:ve,onChangeSelect:L,onStoreExpand:q}){const vt=pt();const P=gt("zustand.changes");const[Be,X]=f(false);const[p,De]=f(we);const[d,R]=f(null);const[v,M]=f(null);const[Z,V]=f(false);const[m,Y]=f(new Set);const{stateChanges:ee,filteredChanges:j,filter:Bt,setFilter:B,stats:ke,stores:D,clearChanges:$e,isEnabled:A,toggleCapture:Pe}=mt();const h=b(()=>{if(m.size===0)return j;return j.filter(e=>!Array.from(m).some(o=>e.storeName.toLowerCase().includes(o.toLowerCase())))},[j,m]);const x=b(()=>{if(m.size===0)return D;return D.filter(e=>!Array.from(m).some(o=>e.name.toLowerCase().includes(o.toLowerCase())))},[D,m]);const Ae=b(()=>{if(!d)return 0;return ee.filter(e=>e.storeName===d).length},[ee,d]);const N=b(()=>{if(!d)return h;return h.filter(e=>e.storeName===d)},[h,d]);const _=b(()=>N.slice(0,P),[N,P]);const K=b(()=>Math.max(0,N.length-P),[N.length,P]);const Ne=K>0;const l=_;const[O,y]=f(null);const C=b(()=>{if(O===null)return null;const e=l.findIndex(o=>o.id===O);return e>=0?e:null},[O,l]);const u=C!==null?l[C]:null;const te=H(null);pe(()=>{if(!L)return;const e=u?.id??null;if(e===null||e===te.current)return;te.current=e;L(u)},[u,L]);const oe=H(null);pe(()=>{if(!I)return;if(oe.current===I)return;const e=l.some(o=>o.id===I);if(!e)return;oe.current=I;y(I)},[I,l]);const[S,W]=f("");const[Ee,E]=f(false);const Dt=H(null);const He=H(null);const ze=r(e=>{},[]);const Fe=e=>{W(e);if(p==="events"){B(o=>({...o,searchText:e}))}};const Le=r(()=>{W("");B(e=>({...e,searchText:""}));E(false)},[B]);const ne=r(e=>{y(e.id)},[]);const Re=r(()=>{X(true)},[]);const Me=r(()=>{y(null)},[]);const re=r(e=>{const o=l[e];if(o){y(o.id)}},[l]);const Ze=r(e=>{R(e);y(null)},[]);const Ve=r(()=>{R(null);y(null)},[]);const je=r(e=>{M(e);q?.(e)},[q]);const _e=r(()=>{M(null)},[]);const Ke=r(()=>{return x.reduce((e,o)=>{try{const g=o.api.getState();if(g&&typeof g==="object"){const ge={};for(const[et,fe]of Object.entries(g)){if(typeof fe!=="function")ge[et]=w(fe)}e[o.name]=ge}else{e[o.name]=w(g)}}catch{e[o.name]=null}return e},{})},[x]);const Oe=r(()=>{return h.map(e=>({id:e.id,storeName:e.storeName,timestamp:e.timestamp,prevState:w(e.prevState),nextState:w(e.nextState),hasStateChange:e.hasStateChange,changedKeys:e.changedKeys}))},[h]);const We=r(()=>{return l.map(e=>({id:e.id,storeName:e.storeName,timestamp:e.timestamp,prevState:w(e.prevState),nextState:w(e.nextState),hasStateChange:e.hasStateChange,changedKeys:e.changedKeys}))},[l]);const Ue=r(e=>{Y(o=>{const g=new Set(o);if(g.has(e))g.delete(e);else g.add(e);return g})},[]);const Ge=r(e=>{Y(o=>new Set([...o,e]))},[]);const Je=r(e=>{De(e);R(null);M(null);y(null);V(false);if(S){W("");B(o=>({...o,searchText:""}))}E(false)},[S,B]);const se=r(e=>e.id,[]);const ae=b(()=>xt(l),[l]);const le=r(({item:e})=>{return t(St,{change:e,onPress:ne,testID:ae.get(e.id)})},[ne,ae]);const ie=m.size>0;const ce=()=>{if(Z){return c(s,{children:[t(s.Navigation,{onBack:()=>V(false)}),t(s.Content,{title:"Filters",centered:true,testID:`${n}-filters-title`})]})}if(u){return c(s,{children:[t(s.Navigation,{onBack:Me}),t(s.Content,{title:`${u.storeName}/setState`,centered:true,testID:`${n}-detail-title`})]})}if(d){return c(s,{children:[t(s.Navigation,{onBack:Ve}),t(s.Content,{title:`${d} History`,centered:true,testID:`${n}-history-title`}),t(s.Actions,{children:t(Q,{value:We,disabled:l.length===0,buttonStyle:a.headerActionButton,testID:`${n}-copy`})})]})}if(v){return c(s,{children:[t(s.Navigation,{onBack:_e}),t(s.Content,{title:v,centered:true,testID:`${n}-store-detail-title`})]})}return c(s,{children:[$&&t(s.Navigation,{onBack:$}),t(s.Content,{title:"",children:Ee?t(s.Search,{value:S,onChangeText:Fe,onCancel:Le,placeholder:p==="stores"?"Search stores...":"Search events...",accessibilityLabel:"Search Zustand stores and events",iconSize:14,testID:`${n}-search-field`,containerTestID:`${n}-search`,clearTestID:`${n}-search-clear`,onBlur:()=>{if(S.length===0)E(false)}}):t(nt,{tabs:[{key:"stores",label:`Stores${x.length>0?` (${x.length})`:""}`},{key:"events",label:`Events${h.length>0?` (${h.length})`:""}`}],activeTab:p,onTabChange:Je,testIDPrefix:`${n}-tab`})}),c(s.Actions,{children:[t(G,{onPress:()=>E(true),style:a.headerActionButton,testID:`${n}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:t(st,{size:14,color:i.color.textSecondary})}),t(G,{onPress:()=>V(true),style:[a.headerActionButton,ie&&a.headerActionButtonActive],testID:`${n}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:t(at,{size:14,color:ie?i.color.accent:i.color.textSecondary})}),p==="stores"&&t(Q,{value:Ke,disabled:x.length===0,buttonStyle:a.headerActionButton,testID:`${n}-copy`}),p==="events"&&c(Ce,{children:[t(Q,{value:Oe,disabled:h.length===0,buttonStyle:a.headerActionButton,testID:`${n}-copy`}),t(ut,{isEnabled:A,onToggle:Pe,accessibilityLabel:"Toggle Zustand state capture",testID:`${n}-power`}),t(ht,{onPress:$e,disabled:h.length===0,buttonStyle:a.headerActionButton,testID:`${n}-clear`})]})]})]})};const Qe=()=>{if(Z){return t(It,{ignoredPatterns:m,onTogglePattern:Ue,onAddPattern:Ge,stores:D})}if(u&&C!==null){return t(bt,{change:u,changes:l,selectedIndex:C,onIndexChange:re,disableInternalFooter:true,initialView:ve})}if(d){return l.length>0?t(me,{keyboardShouldPersistTaps:"handled",testID:`${n}-history-list`,data:l,renderItem:le,keyExtractor:se,contentContainerStyle:a.listContent,showsVerticalScrollIndicator:true,...ye}):t(J,{testID:`${n}-history-empty`,...Se({subject:"changes",search:S,total:S.trim()?Ae:0,capturing:A,waiting:{otto:"waiting",title:"No history yet",message:`State changes for ${d} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${d}.`}})})}if(v){const e=D.find(o=>o.name===v)??null;return e?t(Tt,{store:e,onViewHistory:Ze}):t(J,{testID:`${n}-store-detail-gone`,otto:"ghost",title:"Store no longer registered",message:`${v} is not in the registry any more.`})}if(p==="stores"){return t(Ct,{stores:x,searchQuery:S,isLoading:xe,onOpenStore:je})}return c(Ce,{children:[!A&&c(k,{style:a.disabledBanner,testID:`${n}-banner-disabled`,children:[t(lt,{size:14,color:i.color.warning}),t(U,{style:a.disabledText,children:"State capture is disabled"})]}),Ne&&c(G,{style:a.lockedBanner,onPress:Re,activeOpacity:.8,testID:`${n}-locked`,accessibilityRole:"button",children:[t(it,{size:14,color:i.color.accent}),c(U,{style:a.lockedText,testID:`${n}-locked-text`,children:[K," older"," ",K===1?"change":"changes"," locked"]}),t(k,{style:a.upgradeBadge,children:t(U,{style:a.upgradeBadgeText,children:"UPGRADE"})})]}),_.length>0?t(me,{keyboardShouldPersistTaps:"handled",ref:He,testID:`${n}-list`,data:_,renderItem:le,keyExtractor:se,contentContainerStyle:a.listContent,showsVerticalScrollIndicator:true,...ye}):t(wt,{isEnabled:A,searchText:S,totalChanges:ke.totalChanges})]})};const qe=Te?ct.modal.root():"buoy-zustand-modal";if(!T)return null;const de=u&&C!==null?t(yt,{change:u,changes:l,selectedIndex:C,onIndexChange:re}):null;const Xe=u&&l.length>1?68:0;const Ye=!Z&&(u&&C!==null||d!=null||p==="events"||p==="stores");const ue=t(k,{style:a.container,children:Qe()});const he=t(dt,{visible:Be,onClose:()=>X(false),featureName:"Full State History"});if(Ie){return c(be,{children:[c(k,{style:a.inlineRoot,children:[t(k,{style:a.inlineHeader,...ft,children:ce()}),ue,de]}),he]})}return c(be,{children:[t(ot,{visible:T,onClose:z,onMinimize:F,persistenceKey:qe,header:{showToggleButton:true,customContent:ce()},onModeChange:ze,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:Ye,styles:{},footer:de,footerHeight:Xe,children:ue}),he]})}export function ZustandToolView(T={}){return t(ZustandModal,{...T,inline:true,visible:true,onClose:()=>{}})}const a=tt.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:rt.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:i.color.buttonSurface,borderWidth:1,borderColor:i.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:i.color.accentSoft,borderColor:i.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:i.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:i.color.warning+"20"},disabledText:{color:i.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:i.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:i.color.accentBorder},lockedText:{color:i.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:i.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:i.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});
@@ -1 +1 @@
1
- "use strict";import{View as a,Text as m,StyleSheet as U,ScrollView as O}from"react-native";import{useState as H,useCallback as C,useMemo as N}from"react";import{night as i,EventStepperFooter as z,formatRelativeTime as w,parseValue as x,monoFont as p}from"@buoy-gg/shared-ui";import{DataViewer as G,SplitDiffViewer as Y,TreeDiffViewer as q,diffThemes as J}from"@buoy-gg/shared-ui/dataViewer";import{ZustandDetailViewToggle as K}from"./ZustandDetailViewToggle";import{ZustandStateInfoView as Q}from"./ZustandStateInfoView";import{DiffModeTabs as X,CompareBar as ee}from"@buoy-gg/shared-ui";import{zustandStateStore as te}from"../utils/zustandStateStore";import{ZUSTAND_TEST_ID as g}from"../utils/testIDs";import{jsx as t,jsxs as u}from"react/jsx-runtime";function E(e){return te.getStoreColor(e.storeName)}function L(e){switch(e.category){case"replace":return"REPLACE";case"persist":return"HYDRATE";case"initial":return"INIT";default:return"SET"}}function re(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";return typeof e}function M(e){const s=new Date(e);return s.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}const oe=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];export function ZustandStateDetailContent({change:e,changes:s,selectedIndex:o,onIndexChange:l,disableInternalFooter:d=false,initialView:D="change"}){const[h,k]=H(D);const[v,R]=H("tree");const c=s.length;const f=E(e);const b=L(e);const F=re(x(e.nextState));const S=c-o;const V=S-1;const y=o<c-1?o+1:null;const n=y!==null?s[y]:null;const $=N(()=>({index:y??0,label:V>0?`#${V}`:"Initial",timestamp:n?M(n.timestamp):"",relativeTime:n?w(new Date(n.timestamp)):"state",badge:n?t(a,{style:[r.changeBadgeSmall,{backgroundColor:`${E(n)}20`}],children:t(m,{style:[r.changeTextSmall,{color:E(n)}],children:L(n)})}):void 0}),[y,n,V]);const I=N(()=>({index:o,label:`#${S}`,timestamp:M(e.timestamp),relativeTime:w(new Date(e.timestamp)),badge:t(a,{style:[r.changeBadgeSmall,{backgroundColor:`${f}20`}],children:t(m,{style:[r.changeTextSmall,{color:f}],children:b})})}),[o,e.timestamp,f,b,S]);const W=C(()=>{const T=x(e.nextState);return u(a,{style:r.contentCard,testID:`${g}-state-card`,children:[u(a,{style:r.valueHeader,children:[t(m,{style:r.valueLabel,children:"STATE AFTER CHANGE"}),u(a,{style:r.valueHeaderBadges,children:[t(a,{style:[r.changeBadge,{backgroundColor:`${f}20`}],children:t(m,{style:[r.changeText,{color:f}],children:b})}),t(a,{style:r.typeBadge,children:t(m,{style:r.typeText,testID:`${g}-state-type`,children:F.toUpperCase()})})]})]}),t(a,{style:r.dataViewerContainer,children:t(G,{title:"",data:T,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextState,f,b,F]);const P=C(()=>{const T=x(e.prevState);const A=x(e.nextState);if(v==="split"){return t(O,{style:{flex:1},showsVerticalScrollIndicator:true,children:t(Y,{oldValue:T,newValue:A,theme:J.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})})}return t(q,{oldValue:T,newValue:A})},[e.prevState,e.nextState,v]);const _=C(()=>{l(Math.min(c-1,o+1))},[o,c,l]);const j=C(()=>{l(Math.max(0,o-1))},[o,l]);const Z=e.prevState===void 0;const B=!d&&c>1;return u(a,{style:r.container,children:[t(K,{activeView:h,onViewChange:k,diffDisabled:Z}),u(a,{style:[r.contentArea,B&&r.contentAreaFooterPad],children:[h==="change"&&t(Q,{change:e}),h==="state"&&t(a,{style:r.stateContainer,children:W()}),h==="diff"&&u(a,{style:r.diffContainer,testID:`${g}-diff`,children:[t(X,{tabs:oe,activeTab:v,onTabChange:R,testIDPrefix:`${g}-diff-tab`}),t(ee,{leftEvent:$,rightEvent:I}),t(a,{style:r.diffContent,testID:`${g}-diff-content`,children:P()})]})]}),B&&t(z,{currentIndex:S-1,totalItems:c,onPrevious:_,onNext:j,itemLabel:"Change",subtitle:w(new Date(e.timestamp)),absolute:true})]})}export function ZustandStateDetailFooter({change:e,changes:s,selectedIndex:o,onIndexChange:l}){const d=s.length;if(d<=1)return null;const D=d-o;return t(z,{currentIndex:D-1,totalItems:d,onPrevious:()=>l(Math.min(d-1,o+1)),onNext:()=>l(Math.max(0,o-1)),itemLabel:"Change",subtitle:w(new Date(e.timestamp))})}const r=U.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:i.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:i.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:i.color.textSecondary,fontFamily:p,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:p,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:i.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:i.color.textTertiary,fontFamily:p},valueBox:{backgroundColor:i.color.bg,borderRadius:6,borderWidth:1,borderColor:i.color.border,padding:8},valueText:{fontSize:12,color:i.color.text,fontFamily:p,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:p},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});
1
+ "use strict";import{View as a,Text as m,StyleSheet as U,ScrollView as O}from"react-native";import{useState as H,useCallback as C,useMemo as N}from"react";import{night as i,EventStepperFooter as k,formatRelativeTime as w,parseValue as x,monoFont as p}from"@buoy-gg/shared-ui";import{DataViewer as G,SplitDiffViewer as Y,TreeDiffViewer as q,diffThemes as J}from"@buoy-gg/shared-ui/dataViewer";import{ZustandDetailViewToggle as K}from"./ZustandDetailViewToggle";import{ZustandStateInfoView as Q}from"./ZustandStateInfoView";import{DiffModeTabs as X,CompareBar as ee}from"@buoy-gg/shared-ui";import{zustandStateStore as te}from"../utils/zustandStateStore";import{ZUSTAND_TEST_ID as g}from"../utils/testIDs";import{jsx as t,jsxs as u}from"react/jsx-runtime";function E(e){return te.getStoreColor(e.storeName)}function z(e){switch(e.category){case"replace":return"REPLACE";case"persist":return"HYDRATE";case"initial":return"INIT";default:return"SET"}}function re(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";return typeof e}function L(e){const s=new Date(e);return s.toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}const oe=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];export function ZustandStateDetailContent({change:e,changes:s,selectedIndex:o,onIndexChange:l,disableInternalFooter:d=false,initialView:D="change"}){const[h,M]=H(D);const[v,R]=H("tree");const c=s.length;const f=E(e);const b=z(e);const F=re(x(e.nextState));const S=c-o;const V=S-1;const y=o<c-1?o+1:null;const n=y!==null?s[y]:null;const $=N(()=>({index:y??0,label:V>0?`#${V}`:"Initial",timestamp:n?L(n.timestamp):"",relativeTime:n?w(new Date(n.timestamp)):"state",badge:n?t(a,{style:[r.changeBadgeSmall,{backgroundColor:`${E(n)}20`}],children:t(m,{style:[r.changeTextSmall,{color:E(n)}],children:z(n)})}):void 0}),[y,n,V]);const I=N(()=>({index:o,label:`#${S}`,timestamp:L(e.timestamp),relativeTime:w(new Date(e.timestamp)),badge:t(a,{style:[r.changeBadgeSmall,{backgroundColor:`${f}20`}],children:t(m,{style:[r.changeTextSmall,{color:f}],children:b})})}),[o,e.timestamp,f,b,S]);const P=C(()=>{const T=x(e.nextState);return u(a,{style:r.contentCard,testID:`${g}-state-card`,children:[u(a,{style:r.valueHeader,children:[t(m,{style:r.valueLabel,children:"STATE AFTER CHANGE"}),u(a,{style:r.valueHeaderBadges,children:[t(a,{style:[r.changeBadge,{backgroundColor:`${f}20`}],children:t(m,{style:[r.changeText,{color:f}],children:b})}),t(a,{style:r.typeBadge,children:t(m,{style:r.typeText,testID:`${g}-state-type`,children:F.toUpperCase()})})]})]}),t(a,{style:r.dataViewerContainer,children:t(G,{title:"",data:T,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextState,f,b,F]);const W=C(()=>{const T=x(e.prevState);const A=x(e.nextState);if(v==="split"){return t(O,{keyboardShouldPersistTaps:"handled",style:{flex:1},showsVerticalScrollIndicator:true,children:t(Y,{oldValue:T,newValue:A,theme:J.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})})}return t(q,{oldValue:T,newValue:A})},[e.prevState,e.nextState,v]);const _=C(()=>{l(Math.min(c-1,o+1))},[o,c,l]);const j=C(()=>{l(Math.max(0,o-1))},[o,l]);const Z=e.prevState===void 0;const B=!d&&c>1;return u(a,{style:r.container,children:[t(K,{activeView:h,onViewChange:M,diffDisabled:Z}),u(a,{style:[r.contentArea,B&&r.contentAreaFooterPad],children:[h==="change"&&t(Q,{change:e}),h==="state"&&t(a,{style:r.stateContainer,children:P()}),h==="diff"&&u(a,{style:r.diffContainer,testID:`${g}-diff`,children:[t(X,{tabs:oe,activeTab:v,onTabChange:R,testIDPrefix:`${g}-diff-tab`}),t(ee,{leftEvent:$,rightEvent:I}),t(a,{style:r.diffContent,testID:`${g}-diff-content`,children:W()})]})]}),B&&t(k,{currentIndex:S-1,totalItems:c,onPrevious:_,onNext:j,itemLabel:"Change",subtitle:w(new Date(e.timestamp)),absolute:true})]})}export function ZustandStateDetailFooter({change:e,changes:s,selectedIndex:o,onIndexChange:l}){const d=s.length;if(d<=1)return null;const D=d-o;return t(k,{currentIndex:D-1,totalItems:d,onPrevious:()=>l(Math.min(d-1,o+1)),onNext:()=>l(Math.max(0,o-1)),itemLabel:"Change",subtitle:w(new Date(e.timestamp))})}const r=U.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:i.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:i.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:i.color.textSecondary,fontFamily:p,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:p,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:i.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:i.color.textTertiary,fontFamily:p},valueBox:{backgroundColor:i.color.bg,borderRadius:6,borderWidth:1,borderColor:i.color.border,padding:8},valueText:{fontSize:12,color:i.color.text,fontFamily:p,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:p},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});
@@ -1 +1 @@
1
- "use strict";import _,{memo as R,useCallback as m,useState as k,useEffect as H}from"react";import{View as a,Text as s,StyleSheet as A,ScrollView as V}from"react-native";import{buoyColors as i,night as r,Clock as P,AlertTriangle as W,Zap as C,Info as F,Box as T,Database as N,parseValue as v,ProUpgradeModal as j,copyToClipboard as U,InfoRow as b,monoFont as g}from"@buoy-gg/shared-ui";import{useIsPro as L}from"@buoy-gg/license";import{DataViewer as M}from"@buoy-gg/shared-ui/dataViewer";import{ZustandActionButton as h}from"./ZustandActionButton";import{zustandStateStore as x}from"../utils/zustandStateStore";import{ZUSTAND_TEST_ID as n}from"../utils/testIDs";import{jsx as o,jsxs as l}from"react/jsx-runtime";function O(d){switch(d){case"replace":return{label:"REPLACE",color:i.warning,bgColor:i.warning+"26"};case"persist":return{label:"PERSIST",color:i.info,bgColor:i.info+"26"};case"initial":return{label:"INITIAL",color:r.color.textTertiary,bgColor:r.color.textTertiary+"26"};default:return{label:"SET STATE",color:i.success,bgColor:i.success+"26"}}}function K(d){if(d===void 0)return"N/A";if(d<1)return"<1ms";return`${d.toFixed(1)}ms`}function S({icon:d,title:t,badge:p,testID:u}){return l(a,{style:e.sectionHeader,testID:u,children:[l(a,{style:e.sectionHeaderLeft,children:[o(d,{size:14,color:r.color.accent}),o(s,{style:e.sectionTitle,children:t})]}),p]})}function Z(d){const t=new Date(d);const p=t.getHours().toString().padStart(2,"0");const u=t.getMinutes().toString().padStart(2,"0");const f=t.getSeconds().toString().padStart(2,"0");const y=t.getMilliseconds().toString().padStart(3,"0");return`${p}:${u}:${f}.${y}`}export const ZustandStateInfoView=R(function d({change:t}){const p=L();const[u,f]=k(false);H(()=>{if(u&&p){f(false)}},[u,p]);const y=O(t.category);const w=t.partial!==void 0&&t.partial!=="(updater fn)";const I=t.changedKeys.length>0;const D=x.getStoreColor(t.storeName);const B=m(async()=>{if(!p){f(true);return}await U(t.nextState)},[t.nextState,p]);const z=m(()=>{const c=x.getStore(t.storeName);if(c?.api.getInitialState){const E=c.api.getInitialState();c.api.setState(E,true)}},[t.storeName]);const $=m(()=>{const c=x.getStore(t.storeName);if(c){c.api.setState(t.nextState,true)}},[t.storeName,t.nextState]);return l(V,{style:e.container,contentContainerStyle:e.contentContainer,showsVerticalScrollIndicator:false,testID:`${n}-detail-scroll`,children:[l(a,{style:e.card,testID:`${n}-info-card`,children:[o(S,{icon:F,title:"CHANGE INFO"}),l(a,{style:e.cardContent,children:[o(b,{label:"Store",value:t.storeName,mono:true,valueColor:D,testID:`${n}-info-store`}),o(b,{label:"Time",value:Z(t.timestamp),mono:true,testID:`${n}-info-time`}),l(a,{style:e.badgeRow,children:[o(a,{style:[e.categoryBadge,{backgroundColor:y.bgColor}],children:o(s,{style:[e.categoryText,{color:y.color}],testID:`${n}-info-category`,children:y.label})}),l(a,{style:[e.durationBadge,t.isSlowUpdate&&e.durationBadgeSlow],children:[o(P,{size:10,color:t.isSlowUpdate?i.error:r.color.textSecondary}),o(s,{style:[e.durationText,t.isSlowUpdate&&e.durationTextSlow],testID:`${n}-info-duration`,children:K(t.duration)}),t.isSlowUpdate&&o(W,{size:10,color:i.error})]}),t.hasStateChange?l(a,{style:e.changesBadge,children:[o(C,{size:10,color:i.success}),o(s,{style:e.changesText,testID:`${n}-info-changes`,children:t.diffSummary||"changed"})]}):o(a,{style:e.noChangesBadge,children:o(s,{style:e.noChangesText,testID:`${n}-info-no-changes`,children:"no change"})}),t.isPersisted&&l(a,{style:e.persistBadge,children:[o(N,{size:10,color:i.info}),o(s,{style:e.persistText,testID:`${n}-info-persisted`,children:"PERSISTED"})]})]})]})]}),I&&l(a,{style:e.card,testID:`${n}-keys-card`,children:[o(S,{icon:C,title:"CHANGED KEYS",badge:o(a,{style:e.countBadge,children:o(s,{style:e.countText,testID:`${n}-keys-count`,children:t.changedKeys.length})})}),o(a,{style:e.cardContent,children:o(a,{style:e.keysContainer,children:t.changedKeys.map(c=>o(a,{style:e.keyBadge,children:o(s,{style:e.keyText,testID:`${n}-key-${c}`,children:c})},c))})})]}),w&&l(a,{style:e.card,testID:`${n}-partial-card`,children:[o(S,{icon:T,title:"PARTIAL (setState argument)",badge:o(a,{style:e.typeBadge,children:o(s,{style:e.typeText,testID:`${n}-partial-type`,children:Array.isArray(t.partial)?"ARRAY":typeof t.partial==="object"?"OBJECT":String(typeof t.partial).toUpperCase()})})}),o(a,{style:e.dataViewerContainer,children:o(M,{title:"",data:v(t.partial),showTypeFilter:true,rawMode:true,initialExpanded:true})})]}),t.partial==="(updater fn)"&&l(a,{style:e.card,testID:`${n}-updater-card`,children:[o(S,{icon:T,title:"SET STATE CALL"}),l(a,{style:e.cardContent,children:[o(s,{style:e.updaterText,children:"Called with an updater function: set((state) => ...)"}),o(s,{style:e.updaterSubtext,children:"The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."})]})]}),l(a,{style:e.actionsGrid,children:[o(h,{type:"jump",text:"JUMP",onPress:$,testID:`${n}-jump`}),o(h,{type:"reset",text:"RESET STORE",onPress:z,testID:`${n}-reset`}),o(h,{type:"copy",text:"COPY STATE",onPress:B,testID:`${n}-copy-state`})]}),o(j,{visible:u,onClose:()=>f(false),featureName:"Copy"})]})});const e=A.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:r.color.surface,borderRadius:6,borderWidth:1,borderColor:r.color.accentBorderStrong,overflow:"hidden",shadowColor:r.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:r.color.accentBorder,backgroundColor:r.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:r.color.accent,fontFamily:g},cardContent:{padding:14,gap:10},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:r.color.surfaceElevated},durationBadgeSlow:{backgroundColor:i.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:r.color.textSecondary,fontFamily:g},durationTextSlow:{color:i.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:i.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:i.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:r.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:r.color.textTertiary},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:i.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:i.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:r.color.accentSoft,borderWidth:1,borderColor:r.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:r.color.accent,fontFamily:g},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:r.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:r.color.accent,fontFamily:g},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:r.color.surfaceElevated},typeText:{fontSize:8,fontWeight:"600",color:r.color.textTertiary,fontFamily:g},dataViewerContainer:{backgroundColor:r.color.bg,minHeight:60},updaterText:{fontSize:12,color:r.color.text,fontFamily:g},updaterSubtext:{fontSize:11,color:r.color.textTertiary,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});
1
+ "use strict";import _,{memo as R,useCallback as m,useState as k,useEffect as H}from"react";import{View as a,Text as s,StyleSheet as A,ScrollView as V}from"react-native";import{buoyColors as i,night as r,Clock as P,AlertTriangle as W,Zap as C,Info as F,Box as T,Database as N,parseValue as v,ProUpgradeModal as j,copyToClipboard as U,InfoRow as b,monoFont as g}from"@buoy-gg/shared-ui";import{useIsPro as L}from"@buoy-gg/license";import{DataViewer as M}from"@buoy-gg/shared-ui/dataViewer";import{ZustandActionButton as h}from"./ZustandActionButton";import{zustandStateStore as x}from"../utils/zustandStateStore";import{ZUSTAND_TEST_ID as n}from"../utils/testIDs";import{jsx as o,jsxs as l}from"react/jsx-runtime";function O(d){switch(d){case"replace":return{label:"REPLACE",color:i.warning,bgColor:i.warning+"26"};case"persist":return{label:"PERSIST",color:i.info,bgColor:i.info+"26"};case"initial":return{label:"INITIAL",color:r.color.textTertiary,bgColor:r.color.textTertiary+"26"};default:return{label:"SET STATE",color:i.success,bgColor:i.success+"26"}}}function K(d){if(d===void 0)return"N/A";if(d<1)return"<1ms";return`${d.toFixed(1)}ms`}function S({icon:d,title:t,badge:p,testID:u}){return l(a,{style:e.sectionHeader,testID:u,children:[l(a,{style:e.sectionHeaderLeft,children:[o(d,{size:14,color:r.color.accent}),o(s,{style:e.sectionTitle,children:t})]}),p]})}function Z(d){const t=new Date(d);const p=t.getHours().toString().padStart(2,"0");const u=t.getMinutes().toString().padStart(2,"0");const f=t.getSeconds().toString().padStart(2,"0");const y=t.getMilliseconds().toString().padStart(3,"0");return`${p}:${u}:${f}.${y}`}export const ZustandStateInfoView=R(function d({change:t}){const p=L();const[u,f]=k(false);H(()=>{if(u&&p){f(false)}},[u,p]);const y=O(t.category);const w=t.partial!==void 0&&t.partial!=="(updater fn)";const I=t.changedKeys.length>0;const D=x.getStoreColor(t.storeName);const B=m(async()=>{if(!p){f(true);return}await U(t.nextState)},[t.nextState,p]);const z=m(()=>{const c=x.getStore(t.storeName);if(c?.api.getInitialState){const E=c.api.getInitialState();c.api.setState(E,true)}},[t.storeName]);const $=m(()=>{const c=x.getStore(t.storeName);if(c){c.api.setState(t.nextState,true)}},[t.storeName,t.nextState]);return l(V,{keyboardShouldPersistTaps:"handled",style:e.container,contentContainerStyle:e.contentContainer,showsVerticalScrollIndicator:false,testID:`${n}-detail-scroll`,children:[l(a,{style:e.card,testID:`${n}-info-card`,children:[o(S,{icon:F,title:"CHANGE INFO"}),l(a,{style:e.cardContent,children:[o(b,{label:"Store",value:t.storeName,mono:true,valueColor:D,testID:`${n}-info-store`}),o(b,{label:"Time",value:Z(t.timestamp),mono:true,testID:`${n}-info-time`}),l(a,{style:e.badgeRow,children:[o(a,{style:[e.categoryBadge,{backgroundColor:y.bgColor}],children:o(s,{style:[e.categoryText,{color:y.color}],testID:`${n}-info-category`,children:y.label})}),l(a,{style:[e.durationBadge,t.isSlowUpdate&&e.durationBadgeSlow],children:[o(P,{size:10,color:t.isSlowUpdate?i.error:r.color.textSecondary}),o(s,{style:[e.durationText,t.isSlowUpdate&&e.durationTextSlow],testID:`${n}-info-duration`,children:K(t.duration)}),t.isSlowUpdate&&o(W,{size:10,color:i.error})]}),t.hasStateChange?l(a,{style:e.changesBadge,children:[o(C,{size:10,color:i.success}),o(s,{style:e.changesText,testID:`${n}-info-changes`,children:t.diffSummary||"changed"})]}):o(a,{style:e.noChangesBadge,children:o(s,{style:e.noChangesText,testID:`${n}-info-no-changes`,children:"no change"})}),t.isPersisted&&l(a,{style:e.persistBadge,children:[o(N,{size:10,color:i.info}),o(s,{style:e.persistText,testID:`${n}-info-persisted`,children:"PERSISTED"})]})]})]})]}),I&&l(a,{style:e.card,testID:`${n}-keys-card`,children:[o(S,{icon:C,title:"CHANGED KEYS",badge:o(a,{style:e.countBadge,children:o(s,{style:e.countText,testID:`${n}-keys-count`,children:t.changedKeys.length})})}),o(a,{style:e.cardContent,children:o(a,{style:e.keysContainer,children:t.changedKeys.map(c=>o(a,{style:e.keyBadge,children:o(s,{style:e.keyText,testID:`${n}-key-${c}`,children:c})},c))})})]}),w&&l(a,{style:e.card,testID:`${n}-partial-card`,children:[o(S,{icon:T,title:"PARTIAL (setState argument)",badge:o(a,{style:e.typeBadge,children:o(s,{style:e.typeText,testID:`${n}-partial-type`,children:Array.isArray(t.partial)?"ARRAY":typeof t.partial==="object"?"OBJECT":String(typeof t.partial).toUpperCase()})})}),o(a,{style:e.dataViewerContainer,children:o(M,{title:"",data:v(t.partial),showTypeFilter:true,rawMode:true,initialExpanded:true})})]}),t.partial==="(updater fn)"&&l(a,{style:e.card,testID:`${n}-updater-card`,children:[o(S,{icon:T,title:"SET STATE CALL"}),l(a,{style:e.cardContent,children:[o(s,{style:e.updaterText,children:"Called with an updater function: set((state) => ...)"}),o(s,{style:e.updaterSubtext,children:"The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."})]})]}),l(a,{style:e.actionsGrid,children:[o(h,{type:"jump",text:"JUMP",onPress:$,testID:`${n}-jump`}),o(h,{type:"reset",text:"RESET STORE",onPress:z,testID:`${n}-reset`}),o(h,{type:"copy",text:"COPY STATE",onPress:B,testID:`${n}-copy-state`})]}),o(j,{visible:u,onClose:()=>f(false),featureName:"Copy"})]})});const e=A.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:r.color.surface,borderRadius:6,borderWidth:1,borderColor:r.color.accentBorderStrong,overflow:"hidden",shadowColor:r.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:r.color.accentBorder,backgroundColor:r.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:r.color.accent,fontFamily:g},cardContent:{padding:14,gap:10},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:r.color.surfaceElevated},durationBadgeSlow:{backgroundColor:i.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:r.color.textSecondary,fontFamily:g},durationTextSlow:{color:i.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:i.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:i.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:r.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:r.color.textTertiary},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:i.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:i.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:r.color.accentSoft,borderWidth:1,borderColor:r.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:r.color.accent,fontFamily:g},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:r.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:r.color.accent,fontFamily:g},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:r.color.surfaceElevated},typeText:{fontSize:8,fontWeight:"600",color:r.color.textTertiary,fontFamily:g},dataViewerContainer:{backgroundColor:r.color.bg,minHeight:60},updaterText:{fontSize:12,color:r.color.text,fontFamily:g},updaterSubtext:{fontSize:11,color:r.color.textTertiary,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});
@@ -1 +1 @@
1
- "use strict";import{useMemo as S}from"react";import{View as g,Text as p,StyleSheet as C,ScrollView as w}from"react-native";import{CompactRow as T,night as m,ToolEmptyState as f,resolveListEmptyState as b,monoFont as y}from"@buoy-gg/shared-ui";import{zustandStateStore as D}from"../utils/zustandStateStore";import{ZUSTAND_TEST_ID as c,storeRowTestID as x}from"../utils/testIDs";import{jsx as o,jsxs as h}from"react/jsx-runtime";function I(s){try{const t=s.api.getState();if(t&&typeof t==="object"&&t.__buoyStateOnDevice===true){return"on device"}if(t&&typeof t==="object"){const u=Object.keys(t);const r=u.filter(i=>{const e=t[i];return typeof e!=="function"});if(r.length===0)return"no data keys";if(r.length<=3)return r.join(", ");return`${r.slice(0,2).join(", ")} +${r.length-2}`}return""}catch{return""}}function v(){return o(f,{testID:`${c}-stores-loading`,otto:"loading",title:"Loading stores\u2026",message:"Waiting for the device to send its registered stores."})}function $(){return o(f,{testID:`${c}-stores-empty`,otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores.\nThey will appear here with their current state."})}export function ZustandStoreBrowser({stores:s,searchQuery:t,isLoading:u=false,onOpenStore:r}){const i=S(()=>{if(!t)return s;const e=t.toLowerCase();return s.filter(a=>a.name.toLowerCase().includes(e)||a.persistName&&a.persistName.toLowerCase().includes(e))},[s,t]);if(i.length===0&&!t){return u?o(v,{}):o($,{})}if(i.length===0&&t){return o(f,{testID:`${c}-stores-no-match`,...b({subject:"stores",verb:"registered",search:t,total:s.length,waiting:{otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores."}})})}return h(w,{style:n.container,contentContainerStyle:n.scrollContent,showsVerticalScrollIndicator:true,testID:`${c}-stores-scroll`,children:[h(g,{style:n.sectionHeader,children:[o(p,{style:n.sectionTitle,children:"STORES"}),o(g,{style:n.sectionCountBadge,children:o(p,{style:n.sectionCountText,testID:`${c}-stores-count`,children:i.length})})]}),i.map(e=>{const a=I(e);const d=D.getStoreColor(e.name);const l=x(e.name);return h(g,{style:n.storeRowWrapper,children:[o(T,{statusDotColor:d,statusLabel:e.isPersisted?"persisted":"in-memory",primaryText:e.name,secondaryText:a||void 0,showChevron:true,onPress:()=>r(e.name),testID:l,statusTestID:`${l}-backing`,primaryTestID:`${l}-name`,secondaryTestID:`${l}-keys`}),e.stateChangeCount>0&&o(g,{style:[n.absCountBadge,{backgroundColor:d+"22",borderColor:d+"55"}],pointerEvents:"none",children:o(p,{style:[n.absCountText,{color:d}],testID:`${l}-count`,children:String(e.stateChangeCount)})})]},e.name)})]})}const n=C.create({container:{flex:1},storeRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:y},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:m.color.textTertiary},sectionCountBadge:{backgroundColor:m.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:m.color.accent,fontFamily:y}});
1
+ "use strict";import{useMemo as S}from"react";import{View as u,Text as p,StyleSheet as C,ScrollView as w}from"react-native";import{CompactRow as T,night as m,ToolEmptyState as f,resolveListEmptyState as b,monoFont as y}from"@buoy-gg/shared-ui";import{zustandStateStore as D}from"../utils/zustandStateStore";import{ZUSTAND_TEST_ID as c,storeRowTestID as x}from"../utils/testIDs";import{jsx as o,jsxs as h}from"react/jsx-runtime";function I(s){try{const t=s.api.getState();if(t&&typeof t==="object"&&t.__buoyStateOnDevice===true){return"on device"}if(t&&typeof t==="object"){const g=Object.keys(t);const r=g.filter(i=>{const e=t[i];return typeof e!=="function"});if(r.length===0)return"no data keys";if(r.length<=3)return r.join(", ");return`${r.slice(0,2).join(", ")} +${r.length-2}`}return""}catch{return""}}function v(){return o(f,{testID:`${c}-stores-loading`,otto:"loading",title:"Loading stores\u2026",message:"Waiting for the device to send its registered stores."})}function $(){return o(f,{testID:`${c}-stores-empty`,otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores.\nThey will appear here with their current state."})}export function ZustandStoreBrowser({stores:s,searchQuery:t,isLoading:g=false,onOpenStore:r}){const i=S(()=>{if(!t)return s;const e=t.toLowerCase();return s.filter(a=>a.name.toLowerCase().includes(e)||a.persistName&&a.persistName.toLowerCase().includes(e))},[s,t]);if(i.length===0&&!t){return g?o(v,{}):o($,{})}if(i.length===0&&t){return o(f,{testID:`${c}-stores-no-match`,...b({subject:"stores",verb:"registered",search:t,total:s.length,waiting:{otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores."}})})}return h(w,{keyboardShouldPersistTaps:"handled",style:n.container,contentContainerStyle:n.scrollContent,showsVerticalScrollIndicator:true,testID:`${c}-stores-scroll`,children:[h(u,{style:n.sectionHeader,children:[o(p,{style:n.sectionTitle,children:"STORES"}),o(u,{style:n.sectionCountBadge,children:o(p,{style:n.sectionCountText,testID:`${c}-stores-count`,children:i.length})})]}),i.map(e=>{const a=I(e);const d=D.getStoreColor(e.name);const l=x(e.name);return h(u,{style:n.storeRowWrapper,children:[o(T,{statusDotColor:d,statusLabel:e.isPersisted?"persisted":"in-memory",primaryText:e.name,secondaryText:a||void 0,showChevron:true,onPress:()=>r(e.name),testID:l,statusTestID:`${l}-backing`,primaryTestID:`${l}-name`,secondaryTestID:`${l}-keys`}),e.stateChangeCount>0&&o(u,{style:[n.absCountBadge,{backgroundColor:d+"22",borderColor:d+"55"}],pointerEvents:"none",children:o(p,{style:[n.absCountText,{color:d}],testID:`${l}-count`,children:String(e.stateChangeCount)})})]},e.name)})]})}const n=C.create({container:{flex:1},storeRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:y},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:m.color.textTertiary},sectionCountBadge:{backgroundColor:m.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:m.color.accent,fontFamily:y}});
package/lib/web/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- "use client";var Dt=Object.defineProperty;var Mr=Object.getOwnPropertyDescriptor;var Kr=Object.getOwnPropertyNames;var Ur=Object.prototype.hasOwnProperty;var Zr=(e,t)=>{for(var r in t)Dt(e,r,{get:t[r],enumerable:true})},$t=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Kr(t))!Ur.call(e,n)&&n!==r&&Dt(e,n,{get:()=>t[n],enumerable:!(a=Mr(t,n))||a.enumerable});return e},_r=(e,t,r)=>($t(e,t,"default"),r&&$t(r,t,"default"));var zs=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{classifyPreviewItem as Gr,createRestoreScope as Jr,emptyRestoreResult as Yr,failedRestore as qr,registerStateSnapshotProvider as Qr,unionKeys as Xr}from"@buoy-gg/shared-ui/web";import{ChangeLog as ea,entityColor as ta,formatValuePreview as ra,shallowDiffSummary as aa}from"@buoy-gg/shared-ui/web";var oa={counter:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",navigation:"#F97316",form:"#EF4444"};function Et(e){return ta(e,oa)}function na(e,t=40){return ra(e,{maxLength:t,undefinedLabel:"",functionLabel:"(updater fn)"})}var sa=class extends ea{constructor(){super(...arguments);this.stores=new Map;this.storeListeners=new Set;this.remoteSetStateHandler=null}addStateChange(e){if(!this.canRecord())return;let{storeName:t,partial:r,replace:a,prevState:n,nextState:o,duration:s,category:d,isPersisted:i=false}=e,f=n!==o,{summary:l,changedKeys:u,changedCount:b}=aa(n,o),p=na(r),y=(s??0)>16,B=d??(a?"replace":"setState"),D={id:this.nextId(),storeName:t,timestamp:Date.now(),prevState:n,nextState:o,partial:r,duration:s,hasStateChange:f,replace:a,category:B,changedKeys:u,changedKeysCount:b,diffSummary:l,partialPreview:p,isSlowUpdate:y,isPersisted:i};this.push(D);let j=this.stores.get(t);j&&j.stateChangeCount++,this.notifyListeners()}getStateChanges(){return this.getAll()}getStateChangeById(e){return this.getById(e)}clearStateChanges(){for(let e of this.stores.values())e.stateChangeCount=0;this.clear(),this.notifyStoreListeners()}replaceStateChanges(e){if(!this.getEnabled())return;for(let r of this.stores.values())r.stateChangeCount=0;let t=e.slice(0,this.max);for(let r of t){let a=this.stores.get(r.storeName);a&&a.stateChangeCount++}this.setItems(t),this.notifyStoreListeners()}getStoreSnapshots(){return Array.from(this.stores.values()).map(e=>{let t;try{t=e.api.getState()}catch{t=void 0}return{name:e.name,stateChangeCount:e.stateChangeCount,isPersisted:e.isPersisted,persistName:e.persistName,canRehydrate:typeof e.rehydrate=="function",library:e.library,color:e.color,currentState:t}})}setRemoteSetStateHandler(e){this.remoteSetStateHandler=e}replaceFromSnapshot(e,t){if(!this.getEnabled())return;let r=new Map;for(let o of this.items){let s=o.prevState;(!s||s.__buoyStateOnDevice!==true)&&r.set(o.id,o)}let a=e.slice(0,this.max).map(o=>{let s=r.get(o.id),d=o.prevState;return s&&d?.__buoyStateOnDevice===true?{...o,prevState:s.prevState,nextState:s.nextState,partial:s.partial}:o}),n=new Map;for(let[o,s]of this.stores)try{let d=s.api.getState(),i=d;(!i||i.__buoyStateOnDevice!==true)&&n.set(o,d)}catch{}this.stores=new Map(t.map(o=>{let s=o.currentState,d=n.get(o.name),i=d!==void 0&&s?.__buoyStateOnDevice===true?d:o.currentState;return[o.name,{name:o.name,api:{getState:()=>i,setState:(f,l)=>{this.remoteSetStateHandler?.(o.name,f,l)},subscribe:()=>()=>{}},stateChangeCount:o.stateChangeCount,isPersisted:o.isPersisted,persistName:o.persistName,color:o.color}]})),this.setItems(a),this.notifyStoreListeners()}hydrateChange(e,t){this.hydrateById(e,t)}hydrateStoreState(e,t){let r=this.stores.get(e);r&&(this.stores.set(e,{...r,api:{...r.api,getState:()=>t}}),this.notifyStoreListeners())}registerStore(e,t,r){if(this.stores.has(e))return;let a={name:e,api:t,stateChangeCount:0,isPersisted:r?.isPersisted??false,persistName:r?.persistName,rehydrate:r?.rehydrate,library:r?.library,color:Et(e)};this.stores.set(e,a),this.notifyStoreListeners()}unregisterStore(e){this.stores.delete(e),this.notifyStoreListeners()}getStores(){return Array.from(this.stores.values())}getStore(e){return this.stores.get(e)}getStoreColor(e){return this.stores.get(e)?.color??Et(e)}filterStateChanges(e){let t=this.getAll();if(e.searchText){let r=e.searchText.toLowerCase();t=t.filter(a=>a.storeName.toLowerCase().includes(r)||a.partialPreview.toLowerCase().includes(r)||a.changedKeys.some(n=>n.toLowerCase().includes(r)))}return e.storeNames&&e.storeNames.length>0&&(t=t.filter(r=>e.storeNames.includes(r.storeName))),e.onlyWithChanges&&(t=t.filter(r=>r.hasStateChange)),t}getStats(){let e=this.items.length,t=this.items.filter(o=>o.hasStateChange).length,r=this.stores.size,a=this.items.filter(o=>o.duration!==void 0).map(o=>o.duration),n=a.length>0?a.reduce((o,s)=>o+s,0)/a.length:0;return{totalChanges:e,changesWithStateChange:t,changesWithoutStateChange:e-t,storeCount:r,averageDuration:Math.round(n*100)/100}}getUniqueStoreNames(){return Array.from(this.stores.keys()).sort()}setMaxChanges(e){this.setMax(e)}subscribeToStores(e){return this.storeListeners.add(e),()=>{this.storeListeners.delete(e)}}notifyStoreListeners(){let e=this.getStores();this.storeListeners.forEach(t=>t(e))}},S=new sa;function _(e){if(typeof e!="object"||e===null||Array.isArray(e))return false;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ie(e,t,r,a,n){if(typeof e=="function"){r.push(t);return}if(typeof e!="object"||e===null||n>=8)return e;if(a.has(e))return;if(a.add(e),Array.isArray(e))return e.map((s,d)=>typeof s=="function"?(r.push(`${t}[${d}]`),null):Ie(s,`${t}[${d}]`,r,a,n+1));if(!_(e))return e;let o={};for(let[s,d]of Object.entries(e)){if(typeof d=="function"){r.push(t?`${t}.${s}`:s);continue}o[s]=Ie(d,t?`${t}.${s}`:s,r,a,n+1)}return o}function Bt(e){if(_(e)&&e.__buoyStateOnDevice===true)return{data:null,fnPaths:[],blockedReason:"Store state hasn't synced from the device yet."};if(!_(e))return{data:null,fnPaths:[],blockedReason:"Only stores whose state is a plain object can be edited \u2014 a merge write has nothing to address in "+(Array.isArray(e)?"an array":`a ${typeof e}`)+"."};let t=[],r=Ie(e,"",t,new WeakSet,0),a=t.filter(n=>n.includes(".")||n.includes("["));return a.length>0?{data:null,fnPaths:t,blockedReason:`State keeps a function inside "${a[0]}" \u2014 a merge write of that key would drop it, so this store can't be edited here.`}:{data:r,fnPaths:t,blockedReason:null}}function ia(e,t){if(!_(t))throw new Error("The store's state must stay an object.");let r=Object.keys(e).filter(n=>!(n in t));if(r.length>0)throw new Error(`Can't remove top-level ${r.length===1?"key":"keys"} ${r.map(n=>`"${n}"`).join(", ")} \u2014 zustand merge writes can't delete. Edit the value instead.`);let a={};for(let n of Object.keys(t))(!(n in e)||JSON.stringify(t[n])!==JSON.stringify(e[n]))&&(a[n]=t[n]);return a}var Pt=8;function Nt(e,t,r,a){if(!(!_(t)||!_(e))&&!(a>=Pt||r.has(t))){r.add(t);for(let[n,o]of Object.entries(t))if(typeof o=="function")e[n]=o;else if(_(o)){if(!_(e[n])){if(!At(o,new WeakSet,a+1))continue;e[n]={}}Nt(e[n],o,r,a+1)}}}function At(e,t,r){if(r>=Pt||t.has(e))return false;t.add(e);for(let a of Object.values(e))if(typeof a=="function"||_(a)&&At(a,t,r+1))return true;return false}function la(){return S.getStores().length===0?{canCapture:false,canRestore:false,detail:"No Zustand stores registered \u2014 pass `zustandStores` to FloatingDevTools or add the buoyDevTools middleware"}:{canCapture:true,canRestore:true}}async function da(){let e=[],t={};for(let r of S.getStores()){let a=[],n;try{n=Ie(r.api.getState(),"",a,new WeakSet,0)}catch(o){e.push(`store "${r.name}": capture failed (${String(o)})`);continue}t[r.name]={state:n,fnPaths:a}}return{data:{stores:t},warnings:e}}async function ca(e,t){let r=e,a=Jr(t),n=Yr();if(!r?.stores)return qr("empty zustand snapshot");for(let[s,d]of Object.entries(r.stores)){if(!a.allows(s))continue;let i=S.getStore(s);if(!i){n.skipped.push({id:s,reason:"store not registered (renamed, or created after snapshot?)"});continue}try{let f=d.state;Nt(f,i.api.getState(),new WeakSet,0),i.api.setState(f,true),i.api.getState()===f?n.applied+=1:(n.warnings.push(`store "${s}": setState did not take effect`),n.ok=false)}catch(f){n.skipped.push({id:s,reason:String(f)}),n.ok=false}}let o=a.excludedWarning("store(s)");return o&&n.warnings.push(o),n}async function ua(e,t){let r=e?.stores??{},a=t===void 0,n={};if(a)for(let i of S.getStores()){let f=[];try{n[i.name]={state:Ie(i.api.getState(),"",f,new WeakSet,0),fnPaths:f}}catch{}}else Object.assign(n,t?.stores??{});let o=[],s=[],d=0;for(let i of Xr(n,r)){let f=i in r,l=i in n;if(!f){a?s.push(`store "${i}" not in snapshot \u2014 untouched`):o.push({key:i,label:i,verdict:"removed",oldValue:n[i].state});continue}if(d+=r[i].fnPaths?.length??0,a&&!S.getStore(i)){o.push({key:i,label:i,verdict:"wont-apply",reason:"store not registered (renamed, or created after snapshot?)"});continue}o.push(Gr({key:i,label:i,oldValue:n[i]?.state,newValue:r[i].state,inOld:l,inNew:true},{tooLargeReason:"store too large to render a diff \u2014 restore still applies it"}))}return d>0&&s.push(`${d} store action function${d===1?"":"s"} preserved on restore (not diffed)`),{items:o,notes:s}}Qr({id:"zustand",label:"Zustand",status:la,capture:da,restore:ca,previewItems:ua});import{useState as Q,useMemo as te,useRef as Ne,useCallback as N,useEffect as Rt}from"react";var Lt={};Zr(Lt,{AccessibilityInfo:()=>fa,ActivityIndicator:()=>bo,Alert:()=>wo,Animated:()=>uo,AppRegistry:()=>ya,AppState:()=>ba,Appearance:()=>ma,BackHandler:()=>Sa,Button:()=>So,CheckBox:()=>La,Clipboard:()=>Ca,DeviceEventEmitter:()=>Ya,Dimensions:()=>wa,Easing:()=>xa,FlatList:()=>Je,I18nManager:()=>va,Image:()=>za,ImageBackground:()=>Va,InteractionManager:()=>Ia,Keyboard:()=>Ta,KeyboardAvoidingView:()=>Oa,LayoutAnimation:()=>ka,Linking:()=>Da,LogBox:()=>Ja,Modal:()=>mo,NativeEventEmitter:()=>$a,NativeModules:()=>pa,PanResponder:()=>Ea,Picker:()=>ja,PixelRatio:()=>Ba,Platform:()=>Pa,Pressable:()=>fo,ProgressBar:()=>Ha,RefreshControl:()=>Wa,SafeAreaView:()=>Fa,ScrollView:()=>De,SectionList:()=>Ma,Share:()=>Na,StatusBar:()=>Ka,StyleSheet:()=>le,Switch:()=>yo,Text:()=>C,TextInput:()=>ho,Touchable:()=>Ua,TouchableHighlight:()=>go,TouchableNativeFeedback:()=>Za,TouchableOpacity:()=>re,TouchableWithoutFeedback:()=>po,UIManager:()=>Aa,Vibration:()=>Ra,View:()=>h,VirtualizedList:()=>_a,YellowBox:()=>Ga,findNodeHandle:()=>Co,unstable_createElement:()=>ga,useColorScheme:()=>qa,useLocaleContext:()=>Qa,useWindowDimensions:()=>Xa});_r(Lt,ha);import*as ha from"react-native-web";import{unstable_createElement as ga,NativeModules as pa,AccessibilityInfo as fa,Appearance as ma,AppRegistry as ya,AppState as ba,BackHandler as Sa,Clipboard as Ca,Dimensions as wa,Easing as xa,I18nManager as va,Keyboard as Ta,InteractionManager as Ia,LayoutAnimation as ka,Linking as Da,NativeEventEmitter as $a,PanResponder as Ea,PixelRatio as Ba,Platform as Pa,Share as Na,UIManager as Aa,Vibration as Ra,CheckBox as La,FlatList as Je,Image as za,ImageBackground as Va,KeyboardAvoidingView as Oa,Picker as ja,ProgressBar as Ha,RefreshControl as Wa,SafeAreaView as Fa,SectionList as Ma,StatusBar as Ka,Touchable as Ua,TouchableNativeFeedback as Za,VirtualizedList as _a,YellowBox as Ga,LogBox as Ja,DeviceEventEmitter as Ya,useColorScheme as qa,useLocaleContext as Qa,useWindowDimensions as Xa}from"react-native-web";import*as W from"react-native-web";import{createElement as Ye,forwardRef as zt,useCallback as eo,useRef as to}from"react";import{useEffect as ro,useState as ao}from"react";import{createPortal as oo}from"react-dom";var no='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as so}from"react/jsx-runtime";var ke=Symbol.for("@buoy-gg/portal-host"),Vt=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function Ot(){let e=document;if(e[ke])return e[ke].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:no});let r=()=>{let l=document.fullscreenElement,u=l&&l.tagName!=="CANVAS"?l:document.body;t.parentElement!==u&&u.appendChild(t)},a=new Map,n=l=>{(!t.contains(l.target)||!Vt(l.target))&&a.set(l.code||l.key,{key:l.key,code:l.code,location:l.location,keyCode:l.keyCode,which:l.which,altKey:l.altKey,ctrlKey:l.ctrlKey,metaKey:l.metaKey,shiftKey:l.shiftKey})},o=l=>{a.delete(l.code||l.key)},s=()=>a.clear(),d=()=>{let l=[...a.values()];a.clear();for(let u of l)document.dispatchEvent(new KeyboardEvent("keyup",{...u,bubbles:true}))},i=l=>{Vt(l.target)&&l.stopPropagation()},f=l=>l.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",n,true),document.addEventListener("keyup",o,true),window.addEventListener("blur",s),t.addEventListener("focusin",d),t.addEventListener("keydown",i),t.addEventListener("keyup",i),t.addEventListener("keypress",i),t.addEventListener("wheel",f,{passive:true}),e[ke]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",o,true),window.removeEventListener("blur",s),t.remove(),delete e[ke]}},t}function io({children:e}){let[t,r]=ao(null);return ro(()=>{let a=Ot(),n=document[ke];return n.users++,r(a),()=>{--n.users===0&&n.dispose()}},[]),t?oo(so("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var he=W,lo=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],ge=e=>typeof e=="number"?`${e}px`:e;function qe(e){if(Array.isArray(e)){let u=e.map(qe);return u.some((b,p)=>b!==e[p])?u:e}if(!e||typeof e!="object"||!lo.some(u=>e[u]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:a,shadowRadius:n,textShadowColor:o,textShadowOffset:s,textShadowRadius:d,...i}=e;if(t!=null||r!=null||a!=null||n!=null){let u=t??"black",b=a==null?u:`color-mix(in srgb, ${u} ${Math.min(a,1)*100}%, transparent)`,p=`${ge(r?.width??0)} ${ge(r?.height??0)} ${ge(n??0)} ${b}`;i.boxShadow=typeof i.boxShadow=="string"?`${i.boxShadow}, ${p}`:i.boxShadow??p}let{width:f=0,height:l=0}=s??{};if(o&&(f||l||d)){let u=`${ge(f)} ${ge(l)} ${ge(d??0)} ${o}`;i.textShadow=i.textShadow?`${i.textShadow}, ${u}`:u}return i}var co=he.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function jt(e,t){if(typeof e=="function")return a=>jt(e(a),t);let r=qe(e);return t?[r,co[t]]:r}var le={...he.StyleSheet,create:e=>he.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,qe(r)])))};function K(e){let t=zt((a,n)=>{let{accessibilityState:o,accessibilityValue:s,pointerEvents:d,...i}=a;for(let l of["busy","checked","disabled","expanded","selected"])o?.[l]!==void 0&&i[`aria-${l}`]===void 0&&(i[`aria-${l}`]=o[l]);for(let[l,u]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[l]!==void 0&&i[`aria-${u}`]===void 0&&(i[`aria-${u}`]=s[l]);let f=jt(i.style,d);return f!==i.style&&(i.style=f),Ye(e,{...i,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var h=K(W.View),C=K(W.Text),uo={...he.Animated,View:he.Animated.createAnimatedComponent(h),Text:he.Animated.createAnimatedComponent(C)},ho=K(W.TextInput),re=K(W.TouchableOpacity),go=K(W.TouchableHighlight),po=K(W.TouchableWithoutFeedback),fo=K(W.Pressable),De=K(W.ScrollView),Ht=zt((e,t)=>{let r=to(null),a=eo(n=>{if(n){let o=n;for(;o.parentElement&&o.parentElement!==document.body;)o=o.parentElement;o.parentElement===document.body&&(r.current=o,Object.assign(o.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Ot().appendChild(o))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return Ye(io,null,Ye(W.Modal,{...e,ref:a}))});Ht.displayName="Modal";var mo=K(Ht),yo=K(W.Switch),bo=K(W.ActivityIndicator),So=K(W.Button),Co=W.findNodeHandle,wo={alert(e,t,r,a){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let o=document.createElement("h2");if(o.textContent=e,o.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(o),t){let f=document.createElement("p");f.textContent=t,f.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(f)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let d=r?.length?r:[{text:"OK"}],i=()=>{n.close?.(),n.remove()};for(let f of d){let l=document.createElement("button");l.type="button",l.textContent=f.text??"OK",l.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${f.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,l.onclick=()=>{i(),f.onPress?.()},s.appendChild(l)}n.addEventListener("cancel",f=>{f.preventDefault(),a?.cancelable!==false&&(i(),a?.onDismiss?.())}),n.appendChild(s),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{JsModal as xo,ModalHeader as A,TabSelector as vo,macOSColors as To,night as V,ToolEmptyState as Qe,resolveListEmptyState as Wt,Search as Io,Filter as ko,Power as Do,Lock as $o,devToolsStorageKeys as Eo,ProUpgradeModal as Bo,PowerToggleButton as Po,ToolbarCopyButton as Xe,ToolbarClearButton as No,truncatePayload as pe,TickProvider as Ft,useLimit as Ao,windowDragProps as Ro,EVENT_LIST_PRESET as Mt}from"@buoy-gg/shared-ui/web";import{useIsPro as Lo}from"@buoy-gg/license/web";import{useCallback as zo,useMemo as Kt}from"react";import{useChangeLog as Vo,useSubscribedValue as Oo}from"@buoy-gg/shared-ui/web";function jo(e,t){let r=e;if(t.searchText){let a=t.searchText.toLowerCase();r=r.filter(n=>n.storeName.toLowerCase().includes(a)||n.partialPreview.toLowerCase().includes(a)||n.changedKeys.some(o=>o.toLowerCase().includes(a)))}return t.storeNames&&t.storeNames.length>0&&(r=r.filter(a=>t.storeNames.includes(a.storeName))),t.onlyWithChanges&&(r=r.filter(a=>a.hasStateChange)),r}var Ho=()=>S.getStores(),Wo=e=>S.subscribeToStores(e);function Ut(){let e=Vo(S,{filterItems:jo}),t=Oo(Ho,Wo),r=Kt(()=>{let o=e.items.length,s=e.items.filter(d=>d.hasStateChange).length;return{totalChanges:o,changesWithStateChange:s,changesWithoutStateChange:o-s,storeCount:t.length,averageDuration:0}},[e.items,t]),a=Kt(()=>S.getUniqueStoreNames(),[t]),n=zo(o=>S.getStateChangeById(o),[]);return{stateChanges:e.items,filteredChanges:e.filteredItems,filter:e.filter,setFilter:e.setFilter,stats:r,stores:t,clearChanges:S.clearStateChanges.bind(S),isEnabled:e.isEnabled,toggleCapture:e.toggleCapture,storeNames:a,getChangeById:n}}import{memo as Fo}from"react";import{ChangeRow as Mo,buoyColors as Zt,night as Ko}from"@buoy-gg/shared-ui/web";import{jsx as Uo}from"react/jsx-runtime";function Zo(e,t){switch(e){case"replace":return"Replace";case"persist":return"Hydrate";case"initial":return"Initial";default:return t.charAt(0).toUpperCase()+t.slice(1)}}function _o(e,t){switch(e){case"replace":return Zt.warning;case"persist":return Zt.info;case"initial":return Ko.color.textTertiary;default:return S.getStoreColor(t)}}function Go(e){let t=[];return e.duration!==void 0&&e.duration>=.1&&t.push(`${e.duration.toFixed(1)}ms`),e.hasStateChange?e.changedKeysCount>0?t.push(`${e.changedKeysCount} key${e.changedKeysCount>1?"s":""} changed`):t.push(e.diffSummary||"state changed"):t.push("no state change"),t.join(" \xB7 ")}function Jo(e){return e.category==="replace"?"REPLACE":e.category==="persist"?"HYDRATE":e.category==="initial"?"INIT":"SET"}function Yo(e){return e.changedKeys.length>0&&e.changedKeys.length<=3?e.changedKeys.join(", "):e.changedKeys.length>3?`${e.changedKeys.slice(0,2).join(", ")} +${e.changedKeys.length-2}`:e.partialPreview||"setState()"}var _t=Fo(function({change:e,onPress:t,testID:r}){let a=_o(e.category,e.storeName),n=Zo(e.category,e.storeName),o=Go(e),s=Yo(e),d=Jo(e);return Uo(Mo,{statusColor:a,statusLabel:n,sublabel:o,primaryText:s,timestamp:e.timestamp,badgeText:d,changed:e.hasStateChange,slow:e.isSlowUpdate,onPress:()=>t(e),testID:r})});import{useState as Gt,useCallback as Ae,useMemo as Jt}from"react";import{night as ae,EventStepperFooter as Yt,formatRelativeTime as Re,parseValue as Le,monoFont as $e}from"@buoy-gg/shared-ui/web";import{DataViewer as qo,SplitDiffViewer as Qo,TreeDiffViewer as Xo,diffThemes as en}from"@buoy-gg/shared-ui/web/dataViewer";import{memo as tn}from"react";import{DetailViewToggle as rn,FileText as an,Database as on,GitBranch as nn}from"@buoy-gg/shared-ui/web";import{jsx as sn}from"react/jsx-runtime";var ln=[{key:"change",label:"CHANGE",description:"View change details",icon:an},{key:"state",label:"STATE",description:"View current state",icon:on},{key:"diff",label:"DIFF",description:"Compare changes",icon:nn}],dn=["diff"],cn=tn(function({activeView:e,onViewChange:t,diffDisabled:r=false}){return sn(rn,{views:ln,activeView:e,onViewChange:t,disabledKeys:r?dn:void 0,testIDPrefix:"buoy-zustand"})});import{memo as un,useCallback as et,useState as hn,useEffect as gn}from"react";import{buoyColors as O,night as I,Clock as pn,AlertTriangle as fn,Zap as qt,Info as mn,Box as Qt,Database as yn,parseValue as bn,ProUpgradeModal as Sn,copyToClipboard as Cn,InfoRow as Xt,monoFont as fe}from"@buoy-gg/shared-ui/web";import{useIsPro as wn}from"@buoy-gg/license/web";import{DataViewer as xn}from"@buoy-gg/shared-ui/web/dataViewer";import{night as E,monoFont as vn}from"@buoy-gg/shared-ui/web";import{jsx as er,jsxs as Tn}from"react/jsx-runtime";var In={copy:{color:E.color.accent,backgroundColor:E.color.accentSoft,borderColor:E.color.accentBorder,textColor:E.color.accent},reset:{color:E.color.warning,backgroundColor:E.color.warningSoft,borderColor:E.color.warning+"40",textColor:E.color.warning},clear:{color:E.color.danger,backgroundColor:E.color.dangerSoft,borderColor:E.color.danger+"40",textColor:E.color.danger},jump:{color:E.color.warning,backgroundColor:E.color.warningSoft,borderColor:E.color.warning+"40",textColor:E.color.warning}};function tt({onPress:e,text:t,type:r,disabled:a=false,testID:n}){let o=In[r];return Tn(re,{disabled:a,onPress:e,style:[rt.button,{backgroundColor:a?E.color.textTertiary+"1A":o.backgroundColor,borderColor:a?E.color.textTertiary+"33":o.borderColor,opacity:a?.5:1}],activeOpacity:.7,testID:n,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:a},children:[er(h,{style:[rt.dot,{backgroundColor:a?E.color.textTertiary:o.color}]}),er(C,{style:[rt.text,{color:a?E.color.textTertiary:o.textColor}],children:t})]})}var rt=le.create({button:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:6,borderWidth:1,paddingHorizontal:12,paddingVertical:6,height:25,minWidth:80,shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2,elevation:2},dot:{width:5,height:5,borderRadius:3,marginRight:6,shadowColor:E.color.text,shadowOffset:{width:0,height:0},shadowOpacity:.6,shadowRadius:2},text:{fontSize:10,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:vn,height:12}});var g="buoy-zustand";function at(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function kn(e,t){return`${g}-row-${at(e)}-${t}`}function tr(e){return`${g}-store-${at(e)}`}function Dn(e){let t=new Map,r=new Map;for(let a of e){let n=(t.get(a.storeName)??0)+1;t.set(a.storeName,n),r.set(a.id,kn(a.storeName,n))}return r}import{jsx as x,jsxs as F}from"react/jsx-runtime";function $n(e){switch(e){case"replace":return{label:"REPLACE",color:O.warning,bgColor:O.warning+"26"};case"persist":return{label:"PERSIST",color:O.info,bgColor:O.info+"26"};case"initial":return{label:"INITIAL",color:I.color.textTertiary,bgColor:I.color.textTertiary+"26"};default:return{label:"SET STATE",color:O.success,bgColor:O.success+"26"}}}function En(e){return e===void 0?"N/A":e<1?"<1ms":`${e.toFixed(1)}ms`}function ze({icon:e,title:t,badge:r,testID:a}){return F(h,{style:w.sectionHeader,testID:a,children:[F(h,{style:w.sectionHeaderLeft,children:[x(e,{size:14,color:I.color.accent}),x(C,{style:w.sectionTitle,children:t})]}),r]})}function Bn(e){let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0"),n=t.getSeconds().toString().padStart(2,"0"),o=t.getMilliseconds().toString().padStart(3,"0");return`${r}:${a}:${n}.${o}`}var Pn=un(function({change:e}){let t=wn(),[r,a]=hn(false);gn(()=>{r&&t&&a(false)},[r,t]);let n=$n(e.category),o=e.partial!==void 0&&e.partial!=="(updater fn)",s=e.changedKeys.length>0,d=S.getStoreColor(e.storeName),i=et(async()=>{if(!t){a(true);return}await Cn(e.nextState)},[e.nextState,t]),f=et(()=>{let u=S.getStore(e.storeName);if(u?.api.getInitialState){let b=u.api.getInitialState();u.api.setState(b,true)}},[e.storeName]),l=et(()=>{let u=S.getStore(e.storeName);u&&u.api.setState(e.nextState,true)},[e.storeName,e.nextState]);return F(De,{style:w.container,contentContainerStyle:w.contentContainer,showsVerticalScrollIndicator:false,testID:`${g}-detail-scroll`,children:[F(h,{style:w.card,testID:`${g}-info-card`,children:[x(ze,{icon:mn,title:"CHANGE INFO"}),F(h,{style:w.cardContent,children:[x(Xt,{label:"Store",value:e.storeName,mono:true,valueColor:d,testID:`${g}-info-store`}),x(Xt,{label:"Time",value:Bn(e.timestamp),mono:true,testID:`${g}-info-time`}),F(h,{style:w.badgeRow,children:[x(h,{style:[w.categoryBadge,{backgroundColor:n.bgColor}],children:x(C,{style:[w.categoryText,{color:n.color}],testID:`${g}-info-category`,children:n.label})}),F(h,{style:[w.durationBadge,e.isSlowUpdate&&w.durationBadgeSlow],children:[x(pn,{size:10,color:e.isSlowUpdate?O.error:I.color.textSecondary}),x(C,{style:[w.durationText,e.isSlowUpdate&&w.durationTextSlow],testID:`${g}-info-duration`,children:En(e.duration)}),e.isSlowUpdate&&x(fn,{size:10,color:O.error})]}),e.hasStateChange?F(h,{style:w.changesBadge,children:[x(qt,{size:10,color:O.success}),x(C,{style:w.changesText,testID:`${g}-info-changes`,children:e.diffSummary||"changed"})]}):x(h,{style:w.noChangesBadge,children:x(C,{style:w.noChangesText,testID:`${g}-info-no-changes`,children:"no change"})}),e.isPersisted&&F(h,{style:w.persistBadge,children:[x(yn,{size:10,color:O.info}),x(C,{style:w.persistText,testID:`${g}-info-persisted`,children:"PERSISTED"})]})]})]})]}),s&&F(h,{style:w.card,testID:`${g}-keys-card`,children:[x(ze,{icon:qt,title:"CHANGED KEYS",badge:x(h,{style:w.countBadge,children:x(C,{style:w.countText,testID:`${g}-keys-count`,children:e.changedKeys.length})})}),x(h,{style:w.cardContent,children:x(h,{style:w.keysContainer,children:e.changedKeys.map(u=>x(h,{style:w.keyBadge,children:x(C,{style:w.keyText,testID:`${g}-key-${u}`,children:u})},u))})})]}),o&&F(h,{style:w.card,testID:`${g}-partial-card`,children:[x(ze,{icon:Qt,title:"PARTIAL (setState argument)",badge:x(h,{style:w.typeBadge,children:x(C,{style:w.typeText,testID:`${g}-partial-type`,children:Array.isArray(e.partial)?"ARRAY":typeof e.partial=="object"?"OBJECT":(typeof e.partial).toUpperCase()})})}),x(h,{style:w.dataViewerContainer,children:x(xn,{title:"",data:bn(e.partial),showTypeFilter:true,rawMode:true,initialExpanded:true})})]}),e.partial==="(updater fn)"&&F(h,{style:w.card,testID:`${g}-updater-card`,children:[x(ze,{icon:Qt,title:"SET STATE CALL"}),F(h,{style:w.cardContent,children:[x(C,{style:w.updaterText,children:"Called with an updater function: set((state) => ...)"}),x(C,{style:w.updaterSubtext,children:"The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."})]})]}),F(h,{style:w.actionsGrid,children:[x(tt,{type:"jump",text:"JUMP",onPress:l,testID:`${g}-jump`}),x(tt,{type:"reset",text:"RESET STORE",onPress:f,testID:`${g}-reset`}),x(tt,{type:"copy",text:"COPY STATE",onPress:i,testID:`${g}-copy-state`})]}),x(Sn,{visible:r,onClose:()=>a(false),featureName:"Copy"})]})}),w=le.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:I.color.surface,borderRadius:6,borderWidth:1,borderColor:I.color.accentBorderStrong,overflow:"hidden",shadowColor:I.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:I.color.accentBorder,backgroundColor:I.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:I.color.accent,fontFamily:fe},cardContent:{padding:14,gap:10},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:I.color.surfaceElevated},durationBadgeSlow:{backgroundColor:O.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:I.color.textSecondary,fontFamily:fe},durationTextSlow:{color:O.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:O.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:O.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:I.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:I.color.textTertiary},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:O.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:O.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:I.color.accentSoft,borderWidth:1,borderColor:I.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:I.color.accent,fontFamily:fe},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:I.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:I.color.accent,fontFamily:fe},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:I.color.surfaceElevated},typeText:{fontSize:8,fontWeight:"600",color:I.color.textTertiary,fontFamily:fe},dataViewerContainer:{backgroundColor:I.color.bg,minHeight:60},updaterText:{fontSize:12,color:I.color.text,fontFamily:fe},updaterSubtext:{fontSize:11,color:I.color.textTertiary,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});import{DiffModeTabs as Nn,CompareBar as An}from"@buoy-gg/shared-ui/web";import{jsx as $,jsxs as me}from"react/jsx-runtime";function ot(e){return S.getStoreColor(e.storeName)}function rr(e){switch(e.category){case"replace":return"REPLACE";case"persist":return"HYDRATE";case"initial":return"INIT";default:return"SET"}}function Rn(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function ar(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}var Ln=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];function or({change:e,changes:t,selectedIndex:r,onIndexChange:a,disableInternalFooter:n=false,initialView:o="change"}){let[s,d]=Gt(o),[i,f]=Gt("tree"),l=t.length,u=ot(e),b=rr(e),p=Rn(Le(e.nextState)),y=l-r,B=y-1,D=r<l-1?r+1:null,j=D!==null?t[D]:null,H=Jt(()=>({index:D??0,label:B>0?`#${B}`:"Initial",timestamp:j?ar(j.timestamp):"",relativeTime:j?Re(new Date(j.timestamp)):"state",badge:j?$(h,{style:[P.changeBadgeSmall,{backgroundColor:`${ot(j)}20`}],children:$(C,{style:[P.changeTextSmall,{color:ot(j)}],children:rr(j)})}):void 0}),[D,j,B]),be=Jt(()=>({index:r,label:`#${y}`,timestamp:ar(e.timestamp),relativeTime:Re(new Date(e.timestamp)),badge:$(h,{style:[P.changeBadgeSmall,{backgroundColor:`${u}20`}],children:$(C,{style:[P.changeTextSmall,{color:u}],children:b})})}),[r,e.timestamp,u,b,y]),oe=Ae(()=>{let ne=Le(e.nextState);return me(h,{style:P.contentCard,testID:`${g}-state-card`,children:[me(h,{style:P.valueHeader,children:[$(C,{style:P.valueLabel,children:"STATE AFTER CHANGE"}),me(h,{style:P.valueHeaderBadges,children:[$(h,{style:[P.changeBadge,{backgroundColor:`${u}20`}],children:$(C,{style:[P.changeText,{color:u}],children:b})}),$(h,{style:P.typeBadge,children:$(C,{style:P.typeText,testID:`${g}-state-type`,children:p.toUpperCase()})})]})]}),$(h,{style:P.dataViewerContainer,children:$(qo,{title:"",data:ne,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextState,u,b,p]),Se=Ae(()=>{let ne=Le(e.prevState),ce=Le(e.nextState);return i==="split"?$(De,{style:{flex:1},showsVerticalScrollIndicator:true,children:$(Qo,{oldValue:ne,newValue:ce,theme:en.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})}):$(Xo,{oldValue:ne,newValue:ce})},[e.prevState,e.nextState,i]),Ce=Ae(()=>{a(Math.min(l-1,r+1))},[r,l,a]),we=Ae(()=>{a(Math.max(0,r-1))},[r,a]),J=e.prevState===void 0,xe=!n&&l>1;return me(h,{style:P.container,children:[$(cn,{activeView:s,onViewChange:d,diffDisabled:J}),me(h,{style:[P.contentArea,xe&&P.contentAreaFooterPad],children:[s==="change"&&$(Pn,{change:e}),s==="state"&&$(h,{style:P.stateContainer,children:oe()}),s==="diff"&&me(h,{style:P.diffContainer,testID:`${g}-diff`,children:[$(Nn,{tabs:Ln,activeTab:i,onTabChange:f,testIDPrefix:`${g}-diff-tab`}),$(An,{leftEvent:H,rightEvent:be}),$(h,{style:P.diffContent,testID:`${g}-diff-content`,children:Se()})]})]}),xe&&$(Yt,{currentIndex:y-1,totalItems:l,onPrevious:Ce,onNext:we,itemLabel:"Change",subtitle:Re(new Date(e.timestamp)),absolute:true})]})}function nr({change:e,changes:t,selectedIndex:r,onIndexChange:a}){let n=t.length;if(n<=1)return null;let o=n-r;return $(Yt,{currentIndex:o-1,totalItems:n,onPrevious:()=>a(Math.min(n-1,r+1)),onNext:()=>a(Math.max(0,r-1)),itemLabel:"Change",subtitle:Re(new Date(e.timestamp))})}var P=le.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:ae.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:ae.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:ae.color.textSecondary,fontFamily:$e,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:$e,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:ae.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:ae.color.textTertiary,fontFamily:$e},valueBox:{backgroundColor:ae.color.bg,borderRadius:6,borderWidth:1,borderColor:ae.color.border,padding:8},valueText:{fontSize:12,color:ae.color.text,fontFamily:$e,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:$e},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});import{useMemo as zn}from"react";import{CompactRow as Vn,night as nt,ToolEmptyState as st,resolveListEmptyState as On,monoFont as sr}from"@buoy-gg/shared-ui/web";import{jsx as G,jsxs as it}from"react/jsx-runtime";function jn(e){try{let t=e.api.getState();if(t&&typeof t=="object"&&t.__buoyStateOnDevice===true)return"on device";if(t&&typeof t=="object"){let r=Object.keys(t).filter(a=>typeof t[a]!="function");return r.length===0?"no data keys":r.length<=3?r.join(", "):`${r.slice(0,2).join(", ")} +${r.length-2}`}return""}catch{return""}}function Hn(){return G(st,{testID:`${g}-stores-loading`,otto:"loading",title:"Loading stores\u2026",message:"Waiting for the device to send its registered stores."})}function Wn(){return G(st,{testID:`${g}-stores-empty`,otto:"scanning",title:"No stores registered",message:`Use watchStores() to register your Zustand stores.
2
- They will appear here with their current state.`})}function Fn({stores:e,searchQuery:t,isLoading:r=false,onOpenStore:a}){let n=zn(()=>{if(!t)return e;let o=t.toLowerCase();return e.filter(s=>s.name.toLowerCase().includes(o)||s.persistName&&s.persistName.toLowerCase().includes(o))},[e,t]);return n.length===0&&!t?r?G(Hn,{}):G(Wn,{}):n.length===0&&t?G(st,{testID:`${g}-stores-no-match`,...On({subject:"stores",verb:"registered",search:t,total:e.length,waiting:{otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores."}})}):it(De,{style:X.container,contentContainerStyle:X.scrollContent,showsVerticalScrollIndicator:true,testID:`${g}-stores-scroll`,children:[it(h,{style:X.sectionHeader,children:[G(C,{style:X.sectionTitle,children:"STORES"}),G(h,{style:X.sectionCountBadge,children:G(C,{style:X.sectionCountText,testID:`${g}-stores-count`,children:n.length})})]}),n.map(o=>{let s=jn(o),d=S.getStoreColor(o.name),i=tr(o.name);return it(h,{style:X.storeRowWrapper,children:[G(Vn,{statusDotColor:d,statusLabel:o.isPersisted?"persisted":"in-memory",primaryText:o.name,secondaryText:s||void 0,showChevron:true,onPress:()=>a(o.name),testID:i,statusTestID:`${i}-backing`,primaryTestID:`${i}-name`,secondaryTestID:`${i}-keys`}),o.stateChangeCount>0&&G(h,{style:[X.absCountBadge,{backgroundColor:d+"22",borderColor:d+"55"}],pointerEvents:"none",children:G(C,{style:[X.absCountText,{color:d}],testID:`${i}-count`,children:String(o.stateChangeCount)})})]},o.name)})]})}var X=le.create({container:{flex:1},storeRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:sr},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:nt.color.textTertiary},sectionCountBadge:{backgroundColor:nt.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:nt.color.accent,fontFamily:sr}});import{useCallback as Mn,useEffect as Kn,useMemo as lt,useState as Ve}from"react";import{buoyColors as dt,Database as Un,ExpandedInfoRow as Oe,FileJson as Zn,night as R,PillBadge as ct,parseValue as ir,monoFont as je}from"@buoy-gg/shared-ui/web";import{DataViewer as _n,LiveExplorer as Gn,ValueEditModal as Jn,updateNestedDataByPath as Yn,deleteNestedDataByPath as qn}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as lr,jsx as v,jsxs as U}from"react/jsx-runtime";var Qn=300,de=`${g}-detail`;function Xn(e){let t=r=>r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${de}-explorer-root`:`${de}-explorer-${e.map(t).filter(Boolean).join("-")}`}function es({store:e,onViewHistory:t}){let r=tr(e.name),[a,n]=Ve(0);Kn(()=>e.api.subscribe(()=>n(b=>b+1)),[e.api]);let o=e.api.getState(),s=lt(()=>Bt(o),[o,a]),[d,i]=Ve(false),f=lt(()=>{if(s.data!==null)return{update:(b,p)=>{let y=e.api.getState();if(!_(y)||b.length===0)return;let B=b[0],D=b.length===1?p:Yn(y[B],b.slice(1),p);e.api.setState({[B]:D},false)},remove:b=>{let p=e.api.getState();if(!_(p)||b.length<=1)return;let y=b[0],B=qn(p[y],b.slice(1));e.api.setState({[y]:B},false)},canRemove:b=>b.length>1}},[e.api,s.data===null]),l=Mn(b=>{let p=Bt(e.api.getState());if(p.data===null)return;let y=ia(p.data,b);Object.keys(y).length>0&&e.api.setState(y,false),i(false)},[e.api]),u=lt(()=>{if(o&&typeof o=="object"){let b={};for(let[p,y]of Object.entries(o))typeof y!="function"&&(b[p]=y);return ir(b)}return ir(o)},[o,a]);return U(h,{style:T.root,children:[U(De,{testID:`${de}-scroll`,style:T.scroll,contentContainerStyle:T.scrollContent,keyboardShouldPersistTaps:"handled",children:[v(h,{style:T.section,children:U(h,{style:T.editorContainer,children:[U(h,{style:T.sectionHeaderRow,children:[v(C,{testID:`${de}-editor-header`,style:T.sectionHeaderText,children:"State Editor"}),s.data!==null?U(re,{onPress:()=>i(true),testID:`${de}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:T.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[v(Zn,{size:13,color:R.color.accent}),v(C,{style:T.rawButtonText,children:"Raw"})]}):null]}),v(h,{style:T.sectionBody,children:s.data!==null?U(lr,{children:[v(Gn,{editable:true,label:"State",value:s.data,defaultExpanded:["State"],writer:f,dataVersion:a,testIDForPath:Xn,debounceMs:Qn}),v(C,{style:T.editorHint,children:"Edits write into the live store as you make them \u2014 merged, so the store's actions and untouched keys survive."})]}):v(C,{style:T.blockedText,testID:`${de}-edit-blocked`,children:s.blockedReason})})]})}),v(h,{style:T.section,children:U(h,{style:T.infoContainer,children:[v(C,{style:T.sectionHeaderTextPlain,children:"Store Details"}),U(h,{style:T.infoBody,children:[v(Oe,{label:"Type",children:v(ct,{color:e.color,testID:`${r}-type`,children:"ZUSTAND"})}),U(Oe,{label:"Backing",children:[v(ct,{color:dt.info,icon:e.isPersisted?v(Un,{size:9,color:dt.info}):void 0,testID:`${r}-persist`,children:e.isPersisted?e.persistName||"persisted":"in-memory"}),e.isPersisted?v(ts,{store:e,rowID:r}):null]}),e.stateChangeCount>0&&U(Oe,{label:"Changes",children:[v(ct,{color:dt.warning,testID:`${r}-changes`,children:String(e.stateChangeCount)}),v(re,{onPress:()=>t(e.name),style:T.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${r}-history`,accessibilityRole:"button",accessibilityLabel:`View ${e.name} history`,children:v(C,{style:[T.inlineLinkText,{color:e.color}],children:"view history \u2192"})})]}),s.fnPaths.length>0&&v(Oe,{label:"Actions",children:v(C,{style:T.actionsText,testID:`${de}-actions`,numberOfLines:2,children:s.fnPaths.join(" \xB7 ")})})]})]})}),v(h,{style:T.section,children:U(h,{style:T.infoContainer,children:[v(C,{style:T.sectionHeaderTextPlain,children:"State Explorer"}),v(h,{style:T.viewerBody,testID:`${r}-state`,children:u&&typeof u=="object"?v(_n,{title:"",data:u,showTypeFilter:true,rawMode:true,initialExpanded:false}):v(C,{style:T.blockedText,children:"Empty state"})})]})})]}),d&&s.data!==null?v(Jn,{path:[],value:s.data,onSave:b=>{try{l(b)}catch{}},onCancel:()=>i(false),saveLabel:"Apply",testIDPrefix:`${g}-value`}):null]})}function ts({store:e,rowID:t}){let[r,a]=Ve(false),[n,o]=Ve(null);return e.rehydrate?U(lr,{children:[v(re,{onPress:()=>{a(true),o(null),(async()=>{try{await e.rehydrate?.()}catch(s){o(s instanceof Error?s.message:String(s))}finally{a(false)}})()},disabled:r,style:T.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${t}-reread`,accessibilityRole:"button",accessibilityLabel:`Re-read ${e.name} from storage`,children:v(C,{style:[T.inlineLinkText,{color:e.color}],children:r?"re-reading\u2026":"re-read saved value \u2192"})}),n?v(C,{style:[T.inlineLinkText,{color:R.color.danger}],children:n}):null]}):null}var T=le.create({root:{flex:1,minHeight:0},scroll:{flex:1},scrollContent:{paddingHorizontal:8,paddingTop:8,paddingBottom:24},section:{marginBottom:16},editorContainer:{minWidth:200,backgroundColor:R.color.surface,borderRadius:6,borderWidth:1,borderColor:R.color.accent+"4D",overflow:"hidden",shadowColor:R.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:R.color.accent+"1A",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:R.color.accent+"33"},sectionHeaderText:{fontWeight:"600",fontSize:12,color:R.color.accent,letterSpacing:.5,textTransform:"uppercase",fontFamily:je},rawButton:{flexDirection:"row",alignItems:"center",gap:4},rawButtonText:{color:R.color.accent,fontSize:11,fontWeight:"700"},sectionBody:{padding:8},editorHint:{color:R.color.textTertiary,fontSize:10,paddingTop:8,paddingHorizontal:4,lineHeight:14},blockedText:{color:R.color.textSecondary,fontSize:12,padding:12,lineHeight:18},infoContainer:{minWidth:200,backgroundColor:R.color.surface,borderRadius:6,borderWidth:1,borderColor:R.color.border,overflow:"hidden"},sectionHeaderTextPlain:{backgroundColor:R.color.surfaceElevated,paddingHorizontal:12,paddingVertical:8,fontWeight:"600",fontSize:12,color:R.color.textSecondary,borderBottomWidth:1,borderBottomColor:R.color.border,letterSpacing:.5,textTransform:"uppercase",fontFamily:je},infoBody:{padding:12,gap:10},viewerBody:{backgroundColor:R.color.bg,minHeight:60},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:je},actionsText:{flex:1,color:R.color.textSecondary,fontSize:10,fontFamily:je,lineHeight:15}});import{useMemo as rs}from"react";import{EntityFilterView as as}from"@buoy-gg/shared-ui/web";import{jsx as os}from"react/jsx-runtime";var ns=["\u2022 auth \u2192 hides authStore from stores & events","\u2022 temp \u2192 hides tempStore, tempUserStore","\u2022 cart \u2192 hides cartStore from both tabs"];function ss({ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,stores:a}){let n=rs(()=>a.map(o=>({name:o.name,color:S.getStoreColor(o.name)})),[a]);return os(as,{entities:n,ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,entityNoun:"STORES",entitySingular:"store",entityKey:"store",testIDPrefix:g,slug:at,howItWorks:"Patterns hide matching stores from both the Stores tab and the Events tab. Tap a store above to quickly add it as a filter.",examples:ns})}import{Fragment as dr,jsx as m,jsxs as M}from"react/jsx-runtime";function is({isEnabled:e,searchText:t,totalChanges:r}){let a=Wt({subject:"changes",search:t,total:r,capturing:e,waiting:{otto:"waiting",title:"No state changes",message:"State changes will appear here as stores update."},paused:{title:"No state changes",message:"Enable capture to start recording state changes"}});return m(Qe,{...a,testID:`${g}-empty`})}function He({visible:e,onClose:t,onBack:r,onMinimize:a,enableSharedModalDimensions:n=false,inline:o=false,storesLoading:s=false,initialTab:d="stores",initialSelectedChangeId:i,initialDetailView:f,onChangeSelect:l,onStoreExpand:u}){let b=Lo(),p=Ao("zustand.changes"),[y,B]=Q(false),[D,j]=Q(d),[H,be]=Q(null),[oe,Se]=Q(null),[Ce,we]=Q(false),[J,xe]=Q(new Set),{stateChanges:ne,filteredChanges:ce,filter:Rs,setFilter:ve,stats:mr,stores:Te,clearChanges:yr,isEnabled:Ee,toggleCapture:br}=Ut(),Y=te(()=>J.size===0?ce:ce.filter(c=>!Array.from(J).some(k=>c.storeName.toLowerCase().includes(k.toLowerCase()))),[ce,J]),ue=te(()=>J.size===0?Te:Te.filter(c=>!Array.from(J).some(k=>c.name.toLowerCase().includes(k.toLowerCase()))),[Te,J]),Sr=te(()=>H?ne.filter(c=>c.storeName===H).length:0,[ne,H]),Be=te(()=>H?Y.filter(c=>c.storeName===H):Y,[Y,H]),Ue=te(()=>Be.slice(0,p),[Be,p]),Ze=te(()=>Math.max(0,Be.length-p),[Be.length,p]),Cr=Ze>0,z=Ue,[_e,se]=Q(null),ie=te(()=>{if(_e===null)return null;let c=z.findIndex(k=>k.id===_e);return c>=0?c:null},[_e,z]),Z=ie!==null?z[ie]:null,gt=Ne(null);Rt(()=>{if(!l)return;let c=Z?.id??null;c===null||c===gt.current||(gt.current=c,l(Z))},[Z,l]);let pt=Ne(null);Rt(()=>{!i||pt.current===i||!z.some(c=>c.id===i)||(pt.current=i,se(i))},[i,z]);let[ee,Ge]=Q(""),[wr,Pe]=Q(false),Ls=Ne(null),xr=Ne(null),vr=N(c=>{},[]),Tr=c=>{Ge(c),D==="events"&&ve(k=>({...k,searchText:c}))},Ir=N(()=>{Ge(""),ve(c=>({...c,searchText:""})),Pe(false)},[ve]),ft=N(c=>{se(c.id)},[]),kr=N(()=>{B(true)},[]),Dr=N(()=>{se(null)},[]),mt=N(c=>{let k=z[c];k&&se(k.id)},[z]),$r=N(c=>{be(c),se(null)},[]),Er=N(()=>{be(null),se(null)},[]),Br=N(c=>{Se(c),u?.(c)},[u]),Pr=N(()=>{Se(null)},[]),Nr=N(()=>ue.reduce((c,k)=>{try{let q=k.api.getState();if(q&&typeof q=="object"){let It={};for(let[Fr,kt]of Object.entries(q))typeof kt!="function"&&(It[Fr]=pe(kt));c[k.name]=It}else c[k.name]=pe(q)}catch{c[k.name]=null}return c},{}),[ue]),Ar=N(()=>Y.map(c=>({id:c.id,storeName:c.storeName,timestamp:c.timestamp,prevState:pe(c.prevState),nextState:pe(c.nextState),hasStateChange:c.hasStateChange,changedKeys:c.changedKeys})),[Y]),Rr=N(()=>z.map(c=>({id:c.id,storeName:c.storeName,timestamp:c.timestamp,prevState:pe(c.prevState),nextState:pe(c.nextState),hasStateChange:c.hasStateChange,changedKeys:c.changedKeys})),[z]),Lr=N(c=>{xe(k=>{let q=new Set(k);return q.has(c)?q.delete(c):q.add(c),q})},[]),zr=N(c=>{xe(k=>new Set([...k,c]))},[]),Vr=N(c=>{j(c),be(null),Se(null),se(null),we(false),ee&&(Ge(""),ve(k=>({...k,searchText:""}))),Pe(false)},[ee,ve]),yt=N(c=>c.id,[]),bt=te(()=>Dn(z),[z]),St=N(({item:c})=>m(_t,{change:c,onPress:ft,testID:bt.get(c.id)}),[ft,bt]),Ct=J.size>0,wt=()=>Ce?M(A,{children:[m(A.Navigation,{onBack:()=>we(false)}),m(A.Content,{title:"Filters",centered:true,testID:`${g}-filters-title`})]}):Z?M(A,{children:[m(A.Navigation,{onBack:Dr}),m(A.Content,{title:`${Z.storeName}/setState`,centered:true,testID:`${g}-detail-title`})]}):H?M(A,{children:[m(A.Navigation,{onBack:Er}),m(A.Content,{title:`${H} History`,centered:true,testID:`${g}-history-title`}),m(A.Actions,{children:m(Xe,{value:Rr,disabled:z.length===0,buttonStyle:L.headerActionButton,testID:`${g}-copy`})})]}):oe?M(A,{children:[m(A.Navigation,{onBack:Pr}),m(A.Content,{title:oe,centered:true,testID:`${g}-store-detail-title`})]}):M(A,{children:[r&&m(A.Navigation,{onBack:r}),m(A.Content,{title:"",children:wr?m(A.Search,{value:ee,onChangeText:Tr,onCancel:Ir,placeholder:D==="stores"?"Search stores...":"Search events...",accessibilityLabel:"Search Zustand stores and events",iconSize:14,testID:`${g}-search-field`,containerTestID:`${g}-search`,clearTestID:`${g}-search-clear`,onBlur:()=>{ee.length===0&&Pe(false)}}):m(vo,{tabs:[{key:"stores",label:`Stores${ue.length>0?` (${ue.length})`:""}`},{key:"events",label:`Events${Y.length>0?` (${Y.length})`:""}`}],activeTab:D,onTabChange:Vr,testIDPrefix:`${g}-tab`})}),M(A.Actions,{children:[m(re,{onPress:()=>Pe(true),style:L.headerActionButton,testID:`${g}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:m(Io,{size:14,color:V.color.textSecondary})}),m(re,{onPress:()=>we(true),style:[L.headerActionButton,Ct&&L.headerActionButtonActive],testID:`${g}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:m(ko,{size:14,color:Ct?V.color.accent:V.color.textSecondary})}),D==="stores"&&m(Xe,{value:Nr,disabled:ue.length===0,buttonStyle:L.headerActionButton,testID:`${g}-copy`}),D==="events"&&M(dr,{children:[m(Xe,{value:Ar,disabled:Y.length===0,buttonStyle:L.headerActionButton,testID:`${g}-copy`}),m(Po,{isEnabled:Ee,onToggle:br,accessibilityLabel:"Toggle Zustand state capture",testID:`${g}-power`}),m(No,{onPress:yr,disabled:Y.length===0,buttonStyle:L.headerActionButton,testID:`${g}-clear`})]})]})]}),Or=()=>{if(Ce)return m(ss,{ignoredPatterns:J,onTogglePattern:Lr,onAddPattern:zr,stores:Te});if(Z&&ie!==null)return m(or,{change:Z,changes:z,selectedIndex:ie,onIndexChange:mt,disableInternalFooter:true,initialView:f});if(H)return z.length>0?m(Je,{testID:`${g}-history-list`,data:z,renderItem:St,keyExtractor:yt,contentContainerStyle:L.listContent,showsVerticalScrollIndicator:true,...Mt}):m(Qe,{testID:`${g}-history-empty`,...Wt({subject:"changes",search:ee,total:ee.trim()?Sr:0,capturing:Ee,waiting:{otto:"waiting",title:"No history yet",message:`State changes for ${H} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${H}.`}})});if(oe){let c=Te.find(k=>k.name===oe)??null;return c?m(es,{store:c,onViewHistory:$r}):m(Qe,{testID:`${g}-store-detail-gone`,otto:"ghost",title:"Store no longer registered",message:`${oe} is not in the registry any more.`})}return D==="stores"?m(Fn,{stores:ue,searchQuery:ee,isLoading:s,onOpenStore:Br}):M(dr,{children:[!Ee&&M(h,{style:L.disabledBanner,testID:`${g}-banner-disabled`,children:[m(Do,{size:14,color:V.color.warning}),m(C,{style:L.disabledText,children:"State capture is disabled"})]}),Cr&&M(re,{style:L.lockedBanner,onPress:kr,activeOpacity:.8,testID:`${g}-locked`,accessibilityRole:"button",children:[m($o,{size:14,color:V.color.accent}),M(C,{style:L.lockedText,testID:`${g}-locked-text`,children:[Ze," older"," ",Ze===1?"change":"changes"," locked"]}),m(h,{style:L.upgradeBadge,children:m(C,{style:L.upgradeBadgeText,children:"UPGRADE"})})]}),Ue.length>0?m(Je,{ref:xr,testID:`${g}-list`,data:Ue,renderItem:St,keyExtractor:yt,contentContainerStyle:L.listContent,showsVerticalScrollIndicator:true,...Mt}):m(is,{isEnabled:Ee,searchText:ee,totalChanges:mr.totalChanges})]})},jr=n?Eo.modal.root():"buoy-zustand-modal";if(!e)return null;let xt=Z&&ie!==null?m(nr,{change:Z,changes:z,selectedIndex:ie,onIndexChange:mt}):null,Hr=Z&&z.length>1?68:0,Wr=!Ce&&(Z&&ie!==null||H!=null||D==="events"||D==="stores"),vt=m(h,{style:L.container,children:Or()}),Tt=m(Bo,{visible:y,onClose:()=>B(false),featureName:"Full State History"});return o?M(Ft,{children:[M(h,{style:L.inlineRoot,children:[m(h,{style:L.inlineHeader,...Ro,children:wt()}),vt,xt]}),Tt]}):M(Ft,{children:[m(xo,{visible:e,onClose:t,onMinimize:a,persistenceKey:jr,header:{showToggleButton:true,customContent:wt()},onModeChange:vr,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:Wr,styles:{},footer:xt,footerHeight:Hr,children:vt}),Tt]})}function ls(e={}){return m(He,{...e,inline:true,visible:true,onClose:()=>{}})}var L=le.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:To.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:V.color.buttonSurface,borderWidth:1,borderColor:V.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:V.color.accentSoft,borderColor:V.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:V.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:V.color.warning+"20"},disabledText:{color:V.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:V.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:V.color.accentBorder},lockedText:{color:V.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:V.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:V.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});import{ZustandIcon as ut,ZUSTAND_ICON_COLOR as ds}from"@buoy-gg/shared-ui/web";import{jsx as cr}from"react/jsx-runtime";var cs={id:"zustand",name:"ZUSTAND",description:"Zustand store & state inspector",slot:"both",icon:({size:e})=>cr(ut,{size:e}),component:He,props:{enableSharedModalDimensions:false}};function us(e){return{id:e?.id||"zustand",name:e?.name||"ZUSTAND",description:e?.description||"Zustand store & state inspector",slot:"both",icon:({size:t})=>cr(ut,{size:t,color:e?.iconColor}),component:He,props:{enableSharedModalDimensions:e?.enableSharedModalDimensions!==void 0?e.enableSharedModalDimensions:false}}}var ye=Symbol.for("@@buoy-zustand/watched");function ur(e){let t=e.persist;return t&&typeof t.getOptions=="function"?{isPersisted:true,persistName:t.getOptions()?.name,persistApi:t}:{isPersisted:false}}function hs(e){let t=[];for(let[r,a]of Object.entries(e)){let n=a;if(n[ye])continue;n[ye]=true;let{isPersisted:o,persistName:s,persistApi:d}=ur(a);S.registerStore(r,{getState:a.getState,getInitialState:a.getInitialState,setState:a.setState,subscribe:a.subscribe},{isPersisted:o,persistName:s,rehydrate:typeof d?.rehydrate=="function"?()=>d.rehydrate():void 0,library:a.buoyLibrary});let i=false,f=a.subscribe((l,u)=>{try{let b;if(!i&&o){let p=false;try{p=d?.hasHydrated?.()===false}catch{}p&&(i=true,b="persist")}S.addStateChange({storeName:r,partial:void 0,replace:false,prevState:u,nextState:l,duration:void 0,category:b,isPersisted:o})}catch{}});t.push(()=>{f(),delete a[ye],S.unregisterStore(r)})}return()=>{t.forEach(r=>r())}}var gs=0;function ps(e,t){return(r,a,n)=>{let o=t?.name??`store-${++gs}`,s=t?.enabled!==false,d=r,i=(l,u)=>{if(!s)return d(l,u);let b=performance.now(),p=a();d(l,u);let y=a(),B=performance.now()-b,D=typeof l=="function"?"(updater fn)":l;S.addStateChange({storeName:o,partial:D,replace:u??false,prevState:p,nextState:y,duration:B,isPersisted:S.getStore(o)?.isPersisted??false})},f=e(i,a,n);return setTimeout(()=>{if(n[ye])return;n[ye]=true;let{isPersisted:l,persistName:u}=ur(n);S.registerStore(o,{getState:a,getInitialState:n.getInitialState,setState:i,subscribe:n.subscribe},{isPersisted:l,persistName:u})},0),f}}function fs(e){return e[ye]===true}import{expandKeyedArrays as ms,patchFromPath as ys,readPath as bs,refusalText as Ss,shapeSummary as We,suggestedPatch as ht,typedEditViolations as Cs,unshapedLists as ws}from"@buoy-gg/shared-ui/web";import{WIRE_DETAIL_LIMIT_BYTES as hr,createSyncAdapter as xs,detailByIdAction as vs,isJsonSerializable as Ts,isOverWireBudget as Is,memoByIdentity as ks,onDeviceMarker as gr,readParams as Fe,toWire as pr,truncatedNote as Ds}from"@buoy-gg/shared-ui/web";var Me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype;function fr(e,t){if(!Me(e)||!Me(t))return t;let r={...e};for(let[a,n]of Object.entries(t))r[a]=a in e?fr(e[a],n):n;return r}var Ke=gr("State","State trees stay on the device \u2014 fetched on demand via getChangeDetail / getStoreState."),$s=gr("Payload","Partial stays on the device \u2014 fetched on demand via getChangeDetail.");function Es(e,t){let r=e;for(let a of t.split(".")){if(!r||typeof r!="object"||Array.isArray(r)||!(a in r))return false;r=r[a]}return Array.isArray(r)?r.length>0:!!r&&typeof r=="object"}function Bs(e){return e&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e):void 0}var Ps=ks(e=>({...e,prevState:Ke,nextState:Ke,partial:pr(e.partial,$s)})),Ns=e=>pr(e,Ke),As=xs({version:2,getSnapshot:()=>({changes:S.getStateChanges().map(Ps),stores:S.getStoreSnapshots().map(e=>({...e,currentState:Ns(e.currentState)}))}),subscribe:[e=>S.subscribe(e),e=>S.subscribeToStores(e)],actions:{clearEvents:()=>{S.clearStateChanges()},getChangeDetail:vs(e=>S.getStateChangeById(e),(e,t)=>({prevState:t(e.prevState),nextState:t(e.nextState),partial:t(e.partial)})),getStoreState:e=>{let{storeName:t,path:r}=Fe(e);if(!t)return{found:false,reason:"missing storeName"};let a=S.getStore(t);if(!a)return{found:false,reason:"unknown storeName"};let n;try{n=a.api.getState()}catch{n=void 0}if(r){let s=bs(n,r);return s.ok?{found:true,storeName:t,path:r,shape:We(s.value),currentState:s.value}:{found:false,reason:s.error}}let o=We(n);return Is(n,hr)?{found:true,storeName:t,...o?{shape:o}:{},currentState:Ts(n)?Ds(hr):Ke}:{found:true,storeName:t,...o?{shape:o}:{},currentState:n}},listStores:e=>{let{includeValues:t=false,limit:r}=Fe(e),a=S.getStoreSnapshots(),n=(typeof r=="number"&&r>0?a.slice(0,r):a).map(o=>({name:o.name,...o.library?{library:o.library}:{},changes:o.stateChangeCount,isPersisted:o.isPersisted,persistName:o.persistName,canRehydrate:o.canRehydrate,...t?{currentState:o.currentState}:{keys:Bs(o.currentState)},...We(o.currentState)?{shape:We(o.currentState)}:{}}));return{stores:n,total:a.length,returned:n.length,includedValues:t}},setState:e=>{let{storeName:t,state:r,replace:a,force:n,path:o,value:s}=Fe(e),d=r,i=[],f=[];if(!t)return{ok:false,error:"Missing storeName."};let l=S.getStore(t);if(!l)return{ok:false,error:`No store named "${t}".`};if(r===void 0&&o===void 0)return{ok:false,error:"Refused: no change was described. Send `state` with the fields to merge, or `path` and `value` to set one value."};let u=false;if(o!==void 0){if(s===void 0)return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${o}" to; if you mean to clear it, send value:null and the field must already be nullable.`};let p;try{p=l.api.getState()}catch{p=void 0}let y=ys(p,o,s);if(!y.ok)return{ok:false,error:`Refused: ${y.error}`};d=y.patch,u=true}if(!n&&(a===false||u)){let p;try{p=l.api.getState()}catch{p=void 0}if(p!==void 0){let y=ms(p,d);if(y.error)return{ok:false,error:`Refused: ${y.error}`};d=y.patch,i=y.notes}if(p!==void 0&&(f=ws(p).filter(y=>Es(d,y))),p!==void 0){let y=Cs(p,d,{noun:"store"});if(y.length>0)return{ok:false,error:Ss(y,"store",ht(d,y)),...ht(d,y)?{suggestedState:ht(d,y)}:{},violations:y}}}let b=u||a===false;if(b){let p;try{p=l.api.getState()}catch{p=void 0}if(Me(p)&&Me(d)){let y={};for(let[B,D]of Object.entries(d))y[B]=B in p?fr(p[B],D):D;d=y}}return l.api.setState(d,b?false:a??true),{ok:true,...o!==void 0?{path:o}:{},...i.length?{keyed:i}:{},...f.length?{unchecked:f.map(p=>`\`${p}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the app renders a field you left out, it will render undefined \u2014 read the store back and compare against how the screen uses it.`)}:{}}},rehydrate:async e=>{let{storeName:t}=Fe(e);if(!t)return{ok:false,error:"Missing storeName."};let r=S.getStore(t);return r?r.isPersisted?r.rehydrate?(await r.rehydrate(),{ok:true,storeName:t,persistName:r.persistName}):{ok:false,error:`"${t}" is persisted but Buoy has no rehydrate handle for it. It was probably registered before the app's persist middleware attached.`}:{ok:false,error:`"${t}" is not a persisted store \u2014 it has no saved copy to re-read.`}:{ok:false,error:`No store named "${t}".`}}}});export{ds as ZUSTAND_ICON_COLOR,ut as ZustandIcon,He as ZustandModal,_t as ZustandStateChangeItem,or as ZustandStateDetailContent,nr as ZustandStateDetailFooter,ls as ZustandToolView,ps as buoyDevTools,us as createZustandTool,fs as isStoreInstrumented,Ut as useZustandStateChanges,hs as watchStores,S as zustandStateStore,As as zustandSyncAdapter,cs as zustandToolPreset};
1
+ "use client";var Dt=Object.defineProperty;var Mr=Object.getOwnPropertyDescriptor;var Kr=Object.getOwnPropertyNames;var Ur=Object.prototype.hasOwnProperty;var Zr=(e,t)=>{for(var r in t)Dt(e,r,{get:t[r],enumerable:true})},$t=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Kr(t))!Ur.call(e,n)&&n!==r&&Dt(e,n,{get:()=>t[n],enumerable:!(a=Mr(t,n))||a.enumerable});return e},_r=(e,t,r)=>($t(e,t,"default"),r&&$t(r,t,"default"));var zs=(()=>{try{let e=globalThis.Capacitor;if(e&&typeof e.isNativePlatform=="function"&&e.isNativePlatform())return e.DEBUG===true}catch{}return process.env.NODE_ENV!=="production"})();typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{classifyPreviewItem as Gr,createRestoreScope as Jr,emptyRestoreResult as Yr,failedRestore as qr,registerStateSnapshotProvider as Qr,unionKeys as Xr}from"@buoy-gg/shared-ui/web";import{ChangeLog as ea,entityColor as ta,formatValuePreview as ra,shallowDiffSummary as aa}from"@buoy-gg/shared-ui/web";var oa={counter:"#10B981",auth:"#8B5CF6",user:"#3B82F6",cart:"#EC4899",app:"#6366F1",ui:"#F59E0B",settings:"#14B8A6",theme:"#06B6D4",navigation:"#F97316",form:"#EF4444"};function Et(e){return ta(e,oa)}function na(e,t=40){return ra(e,{maxLength:t,undefinedLabel:"",functionLabel:"(updater fn)"})}var sa=class extends ea{constructor(){super(...arguments);this.stores=new Map;this.storeListeners=new Set;this.remoteSetStateHandler=null}addStateChange(e){if(!this.canRecord())return;let{storeName:t,partial:r,replace:a,prevState:n,nextState:o,duration:s,category:d,isPersisted:i=false}=e,f=n!==o,{summary:l,changedKeys:u,changedCount:b}=aa(n,o),p=na(r),y=(s??0)>16,B=d??(a?"replace":"setState"),D={id:this.nextId(),storeName:t,timestamp:Date.now(),prevState:n,nextState:o,partial:r,duration:s,hasStateChange:f,replace:a,category:B,changedKeys:u,changedKeysCount:b,diffSummary:l,partialPreview:p,isSlowUpdate:y,isPersisted:i};this.push(D);let j=this.stores.get(t);j&&j.stateChangeCount++,this.notifyListeners()}getStateChanges(){return this.getAll()}getStateChangeById(e){return this.getById(e)}clearStateChanges(){for(let e of this.stores.values())e.stateChangeCount=0;this.clear(),this.notifyStoreListeners()}replaceStateChanges(e){if(!this.getEnabled())return;for(let r of this.stores.values())r.stateChangeCount=0;let t=e.slice(0,this.max);for(let r of t){let a=this.stores.get(r.storeName);a&&a.stateChangeCount++}this.setItems(t),this.notifyStoreListeners()}getStoreSnapshots(){return Array.from(this.stores.values()).map(e=>{let t;try{t=e.api.getState()}catch{t=void 0}return{name:e.name,stateChangeCount:e.stateChangeCount,isPersisted:e.isPersisted,persistName:e.persistName,canRehydrate:typeof e.rehydrate=="function",library:e.library,color:e.color,currentState:t}})}setRemoteSetStateHandler(e){this.remoteSetStateHandler=e}replaceFromSnapshot(e,t){if(!this.getEnabled())return;let r=new Map;for(let o of this.items){let s=o.prevState;(!s||s.__buoyStateOnDevice!==true)&&r.set(o.id,o)}let a=e.slice(0,this.max).map(o=>{let s=r.get(o.id),d=o.prevState;return s&&d?.__buoyStateOnDevice===true?{...o,prevState:s.prevState,nextState:s.nextState,partial:s.partial}:o}),n=new Map;for(let[o,s]of this.stores)try{let d=s.api.getState(),i=d;(!i||i.__buoyStateOnDevice!==true)&&n.set(o,d)}catch{}this.stores=new Map(t.map(o=>{let s=o.currentState,d=n.get(o.name),i=d!==void 0&&s?.__buoyStateOnDevice===true?d:o.currentState;return[o.name,{name:o.name,api:{getState:()=>i,setState:(f,l)=>{this.remoteSetStateHandler?.(o.name,f,l)},subscribe:()=>()=>{}},stateChangeCount:o.stateChangeCount,isPersisted:o.isPersisted,persistName:o.persistName,color:o.color}]})),this.setItems(a),this.notifyStoreListeners()}hydrateChange(e,t){this.hydrateById(e,t)}hydrateStoreState(e,t){let r=this.stores.get(e);r&&(this.stores.set(e,{...r,api:{...r.api,getState:()=>t}}),this.notifyStoreListeners())}registerStore(e,t,r){if(this.stores.has(e))return;let a={name:e,api:t,stateChangeCount:0,isPersisted:r?.isPersisted??false,persistName:r?.persistName,rehydrate:r?.rehydrate,library:r?.library,color:Et(e)};this.stores.set(e,a),this.notifyStoreListeners()}unregisterStore(e){this.stores.delete(e),this.notifyStoreListeners()}getStores(){return Array.from(this.stores.values())}getStore(e){return this.stores.get(e)}getStoreColor(e){return this.stores.get(e)?.color??Et(e)}filterStateChanges(e){let t=this.getAll();if(e.searchText){let r=e.searchText.toLowerCase();t=t.filter(a=>a.storeName.toLowerCase().includes(r)||a.partialPreview.toLowerCase().includes(r)||a.changedKeys.some(n=>n.toLowerCase().includes(r)))}return e.storeNames&&e.storeNames.length>0&&(t=t.filter(r=>e.storeNames.includes(r.storeName))),e.onlyWithChanges&&(t=t.filter(r=>r.hasStateChange)),t}getStats(){let e=this.items.length,t=this.items.filter(o=>o.hasStateChange).length,r=this.stores.size,a=this.items.filter(o=>o.duration!==void 0).map(o=>o.duration),n=a.length>0?a.reduce((o,s)=>o+s,0)/a.length:0;return{totalChanges:e,changesWithStateChange:t,changesWithoutStateChange:e-t,storeCount:r,averageDuration:Math.round(n*100)/100}}getUniqueStoreNames(){return Array.from(this.stores.keys()).sort()}setMaxChanges(e){this.setMax(e)}subscribeToStores(e){return this.storeListeners.add(e),()=>{this.storeListeners.delete(e)}}notifyStoreListeners(){let e=this.getStores();this.storeListeners.forEach(t=>t(e))}},S=new sa;function _(e){if(typeof e!="object"||e===null||Array.isArray(e))return false;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function ke(e,t,r,a,n){if(typeof e=="function"){r.push(t);return}if(typeof e!="object"||e===null||n>=8)return e;if(a.has(e))return;if(a.add(e),Array.isArray(e))return e.map((s,d)=>typeof s=="function"?(r.push(`${t}[${d}]`),null):ke(s,`${t}[${d}]`,r,a,n+1));if(!_(e))return e;let o={};for(let[s,d]of Object.entries(e)){if(typeof d=="function"){r.push(t?`${t}.${s}`:s);continue}o[s]=ke(d,t?`${t}.${s}`:s,r,a,n+1)}return o}function Bt(e){if(_(e)&&e.__buoyStateOnDevice===true)return{data:null,fnPaths:[],blockedReason:"Store state hasn't synced from the device yet."};if(!_(e))return{data:null,fnPaths:[],blockedReason:"Only stores whose state is a plain object can be edited \u2014 a merge write has nothing to address in "+(Array.isArray(e)?"an array":`a ${typeof e}`)+"."};let t=[],r=ke(e,"",t,new WeakSet,0),a=t.filter(n=>n.includes(".")||n.includes("["));return a.length>0?{data:null,fnPaths:t,blockedReason:`State keeps a function inside "${a[0]}" \u2014 a merge write of that key would drop it, so this store can't be edited here.`}:{data:r,fnPaths:t,blockedReason:null}}function ia(e,t){if(!_(t))throw new Error("The store's state must stay an object.");let r=Object.keys(e).filter(n=>!(n in t));if(r.length>0)throw new Error(`Can't remove top-level ${r.length===1?"key":"keys"} ${r.map(n=>`"${n}"`).join(", ")} \u2014 zustand merge writes can't delete. Edit the value instead.`);let a={};for(let n of Object.keys(t))(!(n in e)||JSON.stringify(t[n])!==JSON.stringify(e[n]))&&(a[n]=t[n]);return a}var Pt=8;function Nt(e,t,r,a){if(!(!_(t)||!_(e))&&!(a>=Pt||r.has(t))){r.add(t);for(let[n,o]of Object.entries(t))if(typeof o=="function")e[n]=o;else if(_(o)){if(!_(e[n])){if(!At(o,new WeakSet,a+1))continue;e[n]={}}Nt(e[n],o,r,a+1)}}}function At(e,t,r){if(r>=Pt||t.has(e))return false;t.add(e);for(let a of Object.values(e))if(typeof a=="function"||_(a)&&At(a,t,r+1))return true;return false}function la(){return S.getStores().length===0?{canCapture:false,canRestore:false,detail:"No Zustand stores registered \u2014 pass `zustandStores` to FloatingDevTools or add the buoyDevTools middleware"}:{canCapture:true,canRestore:true}}async function da(){let e=[],t={};for(let r of S.getStores()){let a=[],n;try{n=ke(r.api.getState(),"",a,new WeakSet,0)}catch(o){e.push(`store "${r.name}": capture failed (${String(o)})`);continue}t[r.name]={state:n,fnPaths:a}}return{data:{stores:t},warnings:e}}async function ca(e,t){let r=e,a=Jr(t),n=Yr();if(!r?.stores)return qr("empty zustand snapshot");for(let[s,d]of Object.entries(r.stores)){if(!a.allows(s))continue;let i=S.getStore(s);if(!i){n.skipped.push({id:s,reason:"store not registered (renamed, or created after snapshot?)"});continue}try{let f=d.state;Nt(f,i.api.getState(),new WeakSet,0),i.api.setState(f,true),i.api.getState()===f?n.applied+=1:(n.warnings.push(`store "${s}": setState did not take effect`),n.ok=false)}catch(f){n.skipped.push({id:s,reason:String(f)}),n.ok=false}}let o=a.excludedWarning("store(s)");return o&&n.warnings.push(o),n}async function ua(e,t){let r=e?.stores??{},a=t===void 0,n={};if(a)for(let i of S.getStores()){let f=[];try{n[i.name]={state:ke(i.api.getState(),"",f,new WeakSet,0),fnPaths:f}}catch{}}else Object.assign(n,t?.stores??{});let o=[],s=[],d=0;for(let i of Xr(n,r)){let f=i in r,l=i in n;if(!f){a?s.push(`store "${i}" not in snapshot \u2014 untouched`):o.push({key:i,label:i,verdict:"removed",oldValue:n[i].state});continue}if(d+=r[i].fnPaths?.length??0,a&&!S.getStore(i)){o.push({key:i,label:i,verdict:"wont-apply",reason:"store not registered (renamed, or created after snapshot?)"});continue}o.push(Gr({key:i,label:i,oldValue:n[i]?.state,newValue:r[i].state,inOld:l,inNew:true},{tooLargeReason:"store too large to render a diff \u2014 restore still applies it"}))}return d>0&&s.push(`${d} store action function${d===1?"":"s"} preserved on restore (not diffed)`),{items:o,notes:s}}Qr({id:"zustand",label:"Zustand",status:la,capture:da,restore:ca,previewItems:ua});import{useState as Q,useMemo as te,useRef as Ne,useCallback as N,useEffect as Rt}from"react";var Lt={};Zr(Lt,{AccessibilityInfo:()=>fa,ActivityIndicator:()=>bo,Alert:()=>wo,Animated:()=>uo,AppRegistry:()=>ya,AppState:()=>ba,Appearance:()=>ma,BackHandler:()=>Sa,Button:()=>So,CheckBox:()=>La,Clipboard:()=>Ca,DeviceEventEmitter:()=>Ya,Dimensions:()=>wa,Easing:()=>xa,FlatList:()=>Je,I18nManager:()=>va,Image:()=>za,ImageBackground:()=>Va,InteractionManager:()=>ka,Keyboard:()=>Ta,KeyboardAvoidingView:()=>Oa,LayoutAnimation:()=>Ia,Linking:()=>Da,LogBox:()=>Ja,Modal:()=>mo,NativeEventEmitter:()=>$a,NativeModules:()=>pa,PanResponder:()=>Ea,Picker:()=>ja,PixelRatio:()=>Ba,Platform:()=>Pa,Pressable:()=>fo,ProgressBar:()=>Ha,RefreshControl:()=>Wa,SafeAreaView:()=>Fa,ScrollView:()=>De,SectionList:()=>Ma,Share:()=>Na,StatusBar:()=>Ka,StyleSheet:()=>le,Switch:()=>yo,Text:()=>C,TextInput:()=>ho,Touchable:()=>Ua,TouchableHighlight:()=>go,TouchableNativeFeedback:()=>Za,TouchableOpacity:()=>re,TouchableWithoutFeedback:()=>po,UIManager:()=>Aa,Vibration:()=>Ra,View:()=>h,VirtualizedList:()=>_a,YellowBox:()=>Ga,findNodeHandle:()=>Co,unstable_createElement:()=>ga,useColorScheme:()=>qa,useLocaleContext:()=>Qa,useWindowDimensions:()=>Xa});_r(Lt,ha);import*as ha from"react-native-web";import{unstable_createElement as ga,NativeModules as pa,AccessibilityInfo as fa,Appearance as ma,AppRegistry as ya,AppState as ba,BackHandler as Sa,Clipboard as Ca,Dimensions as wa,Easing as xa,I18nManager as va,Keyboard as Ta,InteractionManager as ka,LayoutAnimation as Ia,Linking as Da,NativeEventEmitter as $a,PanResponder as Ea,PixelRatio as Ba,Platform as Pa,Share as Na,UIManager as Aa,Vibration as Ra,CheckBox as La,FlatList as Je,Image as za,ImageBackground as Va,KeyboardAvoidingView as Oa,Picker as ja,ProgressBar as Ha,RefreshControl as Wa,SafeAreaView as Fa,SectionList as Ma,StatusBar as Ka,Touchable as Ua,TouchableNativeFeedback as Za,VirtualizedList as _a,YellowBox as Ga,LogBox as Ja,DeviceEventEmitter as Ya,useColorScheme as qa,useLocaleContext as Qa,useWindowDimensions as Xa}from"react-native-web";import*as W from"react-native-web";import{createElement as Ye,forwardRef as zt,useCallback as eo,useRef as to}from"react";import{useEffect as ro,useState as ao}from"react";import{createPortal as oo}from"react-dom";var no='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as so}from"react/jsx-runtime";var Ie=Symbol.for("@buoy-gg/portal-host"),Vt=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function Ot(){let e=document;if(e[Ie])return e[Ie].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:no});let r=()=>{let l=document.fullscreenElement,u=l&&l.tagName!=="CANVAS"?l:document.body;t.parentElement!==u&&u.appendChild(t)},a=new Map,n=l=>{(!t.contains(l.target)||!Vt(l.target))&&a.set(l.code||l.key,{key:l.key,code:l.code,location:l.location,keyCode:l.keyCode,which:l.which,altKey:l.altKey,ctrlKey:l.ctrlKey,metaKey:l.metaKey,shiftKey:l.shiftKey})},o=l=>{a.delete(l.code||l.key)},s=()=>a.clear(),d=()=>{let l=[...a.values()];a.clear();for(let u of l)document.dispatchEvent(new KeyboardEvent("keyup",{...u,bubbles:true}))},i=l=>{Vt(l.target)&&l.stopPropagation()},f=l=>l.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",n,true),document.addEventListener("keyup",o,true),window.addEventListener("blur",s),t.addEventListener("focusin",d),t.addEventListener("keydown",i),t.addEventListener("keyup",i),t.addEventListener("keypress",i),t.addEventListener("wheel",f,{passive:true}),e[Ie]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",o,true),window.removeEventListener("blur",s),t.remove(),delete e[Ie]}},t}function io({children:e}){let[t,r]=ao(null);return ro(()=>{let a=Ot(),n=document[Ie];return n.users++,r(a),()=>{--n.users===0&&n.dispose()}},[]),t?oo(so("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var he=W,lo=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],ge=e=>typeof e=="number"?`${e}px`:e;function qe(e){if(Array.isArray(e)){let u=e.map(qe);return u.some((b,p)=>b!==e[p])?u:e}if(!e||typeof e!="object"||!lo.some(u=>e[u]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:a,shadowRadius:n,textShadowColor:o,textShadowOffset:s,textShadowRadius:d,...i}=e;if(t!=null||r!=null||a!=null||n!=null){let u=t??"black",b=a==null?u:`color-mix(in srgb, ${u} ${Math.min(a,1)*100}%, transparent)`,p=`${ge(r?.width??0)} ${ge(r?.height??0)} ${ge(n??0)} ${b}`;i.boxShadow=typeof i.boxShadow=="string"?`${i.boxShadow}, ${p}`:i.boxShadow??p}let{width:f=0,height:l=0}=s??{};if(o&&(f||l||d)){let u=`${ge(f)} ${ge(l)} ${ge(d??0)} ${o}`;i.textShadow=i.textShadow?`${i.textShadow}, ${u}`:u}return i}var co=he.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function jt(e,t){if(typeof e=="function")return a=>jt(e(a),t);let r=qe(e);return t?[r,co[t]]:r}var le={...he.StyleSheet,create:e=>he.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,qe(r)])))};function K(e){let t=zt((a,n)=>{let{accessibilityState:o,accessibilityValue:s,pointerEvents:d,...i}=a;for(let l of["busy","checked","disabled","expanded","selected"])o?.[l]!==void 0&&i[`aria-${l}`]===void 0&&(i[`aria-${l}`]=o[l]);for(let[l,u]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[l]!==void 0&&i[`aria-${u}`]===void 0&&(i[`aria-${u}`]=s[l]);let f=jt(i.style,d);return f!==i.style&&(i.style=f),Ye(e,{...i,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var h=K(W.View),C=K(W.Text),uo={...he.Animated,View:he.Animated.createAnimatedComponent(h),Text:he.Animated.createAnimatedComponent(C)},ho=K(W.TextInput),re=K(W.TouchableOpacity),go=K(W.TouchableHighlight),po=K(W.TouchableWithoutFeedback),fo=K(W.Pressable),De=K(W.ScrollView),Ht=zt((e,t)=>{let r=to(null),a=eo(n=>{if(n){let o=n;for(;o.parentElement&&o.parentElement!==document.body;)o=o.parentElement;o.parentElement===document.body&&(r.current=o,Object.assign(o.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),Ot().appendChild(o))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return Ye(io,null,Ye(W.Modal,{...e,ref:a}))});Ht.displayName="Modal";var mo=K(Ht),yo=K(W.Switch),bo=K(W.ActivityIndicator),So=K(W.Button),Co=W.findNodeHandle,wo={alert(e,t,r,a){if(typeof document>"u")return;let n=document.createElement("dialog");n.dataset.buoyRoot="",n.setAttribute("aria-label",e),n.style.cssText="position:fixed;inset:0;margin:auto;width:min(440px,90vw);padding:24px;border:1px solid #475569;border-radius:14px;background:#17212e;color:#f1f5f9;font:14px system-ui;box-shadow:0 20px 80px #0008;z-index:2147483647";let o=document.createElement("h2");if(o.textContent=e,o.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(o),t){let f=document.createElement("p");f.textContent=t,f.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(f)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let d=r?.length?r:[{text:"OK"}],i=()=>{n.close?.(),n.remove()};for(let f of d){let l=document.createElement("button");l.type="button",l.textContent=f.text??"OK",l.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${f.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,l.onclick=()=>{i(),f.onPress?.()},s.appendChild(l)}n.addEventListener("cancel",f=>{f.preventDefault(),a?.cancelable!==false&&(i(),a?.onDismiss?.())}),n.appendChild(s),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};import{JsModal as xo,ModalHeader as A,TabSelector as vo,macOSColors as To,night as V,ToolEmptyState as Qe,resolveListEmptyState as Wt,Search as ko,Filter as Io,Power as Do,Lock as $o,devToolsStorageKeys as Eo,ProUpgradeModal as Bo,PowerToggleButton as Po,ToolbarCopyButton as Xe,ToolbarClearButton as No,truncatePayload as pe,TickProvider as Ft,useLimit as Ao,windowDragProps as Ro,EVENT_LIST_PRESET as Mt}from"@buoy-gg/shared-ui/web";import{useIsPro as Lo}from"@buoy-gg/license/web";import{useCallback as zo,useMemo as Kt}from"react";import{useChangeLog as Vo,useSubscribedValue as Oo}from"@buoy-gg/shared-ui/web";function jo(e,t){let r=e;if(t.searchText){let a=t.searchText.toLowerCase();r=r.filter(n=>n.storeName.toLowerCase().includes(a)||n.partialPreview.toLowerCase().includes(a)||n.changedKeys.some(o=>o.toLowerCase().includes(a)))}return t.storeNames&&t.storeNames.length>0&&(r=r.filter(a=>t.storeNames.includes(a.storeName))),t.onlyWithChanges&&(r=r.filter(a=>a.hasStateChange)),r}var Ho=()=>S.getStores(),Wo=e=>S.subscribeToStores(e);function Ut(){let e=Vo(S,{filterItems:jo}),t=Oo(Ho,Wo),r=Kt(()=>{let o=e.items.length,s=e.items.filter(d=>d.hasStateChange).length;return{totalChanges:o,changesWithStateChange:s,changesWithoutStateChange:o-s,storeCount:t.length,averageDuration:0}},[e.items,t]),a=Kt(()=>S.getUniqueStoreNames(),[t]),n=zo(o=>S.getStateChangeById(o),[]);return{stateChanges:e.items,filteredChanges:e.filteredItems,filter:e.filter,setFilter:e.setFilter,stats:r,stores:t,clearChanges:S.clearStateChanges.bind(S),isEnabled:e.isEnabled,toggleCapture:e.toggleCapture,storeNames:a,getChangeById:n}}import{memo as Fo}from"react";import{ChangeRow as Mo,buoyColors as Zt,night as Ko}from"@buoy-gg/shared-ui/web";import{jsx as Uo}from"react/jsx-runtime";function Zo(e,t){switch(e){case"replace":return"Replace";case"persist":return"Hydrate";case"initial":return"Initial";default:return t.charAt(0).toUpperCase()+t.slice(1)}}function _o(e,t){switch(e){case"replace":return Zt.warning;case"persist":return Zt.info;case"initial":return Ko.color.textTertiary;default:return S.getStoreColor(t)}}function Go(e){let t=[];return e.duration!==void 0&&e.duration>=.1&&t.push(`${e.duration.toFixed(1)}ms`),e.hasStateChange?e.changedKeysCount>0?t.push(`${e.changedKeysCount} key${e.changedKeysCount>1?"s":""} changed`):t.push(e.diffSummary||"state changed"):t.push("no state change"),t.join(" \xB7 ")}function Jo(e){return e.category==="replace"?"REPLACE":e.category==="persist"?"HYDRATE":e.category==="initial"?"INIT":"SET"}function Yo(e){return e.changedKeys.length>0&&e.changedKeys.length<=3?e.changedKeys.join(", "):e.changedKeys.length>3?`${e.changedKeys.slice(0,2).join(", ")} +${e.changedKeys.length-2}`:e.partialPreview||"setState()"}var _t=Fo(function({change:e,onPress:t,testID:r}){let a=_o(e.category,e.storeName),n=Zo(e.category,e.storeName),o=Go(e),s=Yo(e),d=Jo(e);return Uo(Mo,{statusColor:a,statusLabel:n,sublabel:o,primaryText:s,timestamp:e.timestamp,badgeText:d,changed:e.hasStateChange,slow:e.isSlowUpdate,onPress:()=>t(e),testID:r})});import{useState as Gt,useCallback as Ae,useMemo as Jt}from"react";import{night as ae,EventStepperFooter as Yt,formatRelativeTime as Re,parseValue as Le,monoFont as $e}from"@buoy-gg/shared-ui/web";import{DataViewer as qo,SplitDiffViewer as Qo,TreeDiffViewer as Xo,diffThemes as en}from"@buoy-gg/shared-ui/web/dataViewer";import{memo as tn}from"react";import{DetailViewToggle as rn,FileText as an,Database as on,GitBranch as nn}from"@buoy-gg/shared-ui/web";import{jsx as sn}from"react/jsx-runtime";var ln=[{key:"change",label:"CHANGE",description:"View change details",icon:an},{key:"state",label:"STATE",description:"View current state",icon:on},{key:"diff",label:"DIFF",description:"Compare changes",icon:nn}],dn=["diff"],cn=tn(function({activeView:e,onViewChange:t,diffDisabled:r=false}){return sn(rn,{views:ln,activeView:e,onViewChange:t,disabledKeys:r?dn:void 0,testIDPrefix:"buoy-zustand"})});import{memo as un,useCallback as et,useState as hn,useEffect as gn}from"react";import{buoyColors as O,night as k,Clock as pn,AlertTriangle as fn,Zap as qt,Info as mn,Box as Qt,Database as yn,parseValue as bn,ProUpgradeModal as Sn,copyToClipboard as Cn,InfoRow as Xt,monoFont as fe}from"@buoy-gg/shared-ui/web";import{useIsPro as wn}from"@buoy-gg/license/web";import{DataViewer as xn}from"@buoy-gg/shared-ui/web/dataViewer";import{night as E,monoFont as vn}from"@buoy-gg/shared-ui/web";import{jsx as er,jsxs as Tn}from"react/jsx-runtime";var kn={copy:{color:E.color.accent,backgroundColor:E.color.accentSoft,borderColor:E.color.accentBorder,textColor:E.color.accent},reset:{color:E.color.warning,backgroundColor:E.color.warningSoft,borderColor:E.color.warning+"40",textColor:E.color.warning},clear:{color:E.color.danger,backgroundColor:E.color.dangerSoft,borderColor:E.color.danger+"40",textColor:E.color.danger},jump:{color:E.color.warning,backgroundColor:E.color.warningSoft,borderColor:E.color.warning+"40",textColor:E.color.warning}};function tt({onPress:e,text:t,type:r,disabled:a=false,testID:n}){let o=kn[r];return Tn(re,{disabled:a,onPress:e,style:[rt.button,{backgroundColor:a?E.color.textTertiary+"1A":o.backgroundColor,borderColor:a?E.color.textTertiary+"33":o.borderColor,opacity:a?.5:1}],activeOpacity:.7,testID:n,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:a},children:[er(h,{style:[rt.dot,{backgroundColor:a?E.color.textTertiary:o.color}]}),er(C,{style:[rt.text,{color:a?E.color.textTertiary:o.textColor}],children:t})]})}var rt=le.create({button:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:6,borderWidth:1,paddingHorizontal:12,paddingVertical:6,height:25,minWidth:80,shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2,elevation:2},dot:{width:5,height:5,borderRadius:3,marginRight:6,shadowColor:E.color.text,shadowOffset:{width:0,height:0},shadowOpacity:.6,shadowRadius:2},text:{fontSize:10,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:vn,height:12}});var g="buoy-zustand";function at(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function In(e,t){return`${g}-row-${at(e)}-${t}`}function tr(e){return`${g}-store-${at(e)}`}function Dn(e){let t=new Map,r=new Map;for(let a of e){let n=(t.get(a.storeName)??0)+1;t.set(a.storeName,n),r.set(a.id,In(a.storeName,n))}return r}import{jsx as x,jsxs as F}from"react/jsx-runtime";function $n(e){switch(e){case"replace":return{label:"REPLACE",color:O.warning,bgColor:O.warning+"26"};case"persist":return{label:"PERSIST",color:O.info,bgColor:O.info+"26"};case"initial":return{label:"INITIAL",color:k.color.textTertiary,bgColor:k.color.textTertiary+"26"};default:return{label:"SET STATE",color:O.success,bgColor:O.success+"26"}}}function En(e){return e===void 0?"N/A":e<1?"<1ms":`${e.toFixed(1)}ms`}function ze({icon:e,title:t,badge:r,testID:a}){return F(h,{style:w.sectionHeader,testID:a,children:[F(h,{style:w.sectionHeaderLeft,children:[x(e,{size:14,color:k.color.accent}),x(C,{style:w.sectionTitle,children:t})]}),r]})}function Bn(e){let t=new Date(e),r=t.getHours().toString().padStart(2,"0"),a=t.getMinutes().toString().padStart(2,"0"),n=t.getSeconds().toString().padStart(2,"0"),o=t.getMilliseconds().toString().padStart(3,"0");return`${r}:${a}:${n}.${o}`}var Pn=un(function({change:e}){let t=wn(),[r,a]=hn(false);gn(()=>{r&&t&&a(false)},[r,t]);let n=$n(e.category),o=e.partial!==void 0&&e.partial!=="(updater fn)",s=e.changedKeys.length>0,d=S.getStoreColor(e.storeName),i=et(async()=>{if(!t){a(true);return}await Cn(e.nextState)},[e.nextState,t]),f=et(()=>{let u=S.getStore(e.storeName);if(u?.api.getInitialState){let b=u.api.getInitialState();u.api.setState(b,true)}},[e.storeName]),l=et(()=>{let u=S.getStore(e.storeName);u&&u.api.setState(e.nextState,true)},[e.storeName,e.nextState]);return F(De,{keyboardShouldPersistTaps:"handled",style:w.container,contentContainerStyle:w.contentContainer,showsVerticalScrollIndicator:false,testID:`${g}-detail-scroll`,children:[F(h,{style:w.card,testID:`${g}-info-card`,children:[x(ze,{icon:mn,title:"CHANGE INFO"}),F(h,{style:w.cardContent,children:[x(Xt,{label:"Store",value:e.storeName,mono:true,valueColor:d,testID:`${g}-info-store`}),x(Xt,{label:"Time",value:Bn(e.timestamp),mono:true,testID:`${g}-info-time`}),F(h,{style:w.badgeRow,children:[x(h,{style:[w.categoryBadge,{backgroundColor:n.bgColor}],children:x(C,{style:[w.categoryText,{color:n.color}],testID:`${g}-info-category`,children:n.label})}),F(h,{style:[w.durationBadge,e.isSlowUpdate&&w.durationBadgeSlow],children:[x(pn,{size:10,color:e.isSlowUpdate?O.error:k.color.textSecondary}),x(C,{style:[w.durationText,e.isSlowUpdate&&w.durationTextSlow],testID:`${g}-info-duration`,children:En(e.duration)}),e.isSlowUpdate&&x(fn,{size:10,color:O.error})]}),e.hasStateChange?F(h,{style:w.changesBadge,children:[x(qt,{size:10,color:O.success}),x(C,{style:w.changesText,testID:`${g}-info-changes`,children:e.diffSummary||"changed"})]}):x(h,{style:w.noChangesBadge,children:x(C,{style:w.noChangesText,testID:`${g}-info-no-changes`,children:"no change"})}),e.isPersisted&&F(h,{style:w.persistBadge,children:[x(yn,{size:10,color:O.info}),x(C,{style:w.persistText,testID:`${g}-info-persisted`,children:"PERSISTED"})]})]})]})]}),s&&F(h,{style:w.card,testID:`${g}-keys-card`,children:[x(ze,{icon:qt,title:"CHANGED KEYS",badge:x(h,{style:w.countBadge,children:x(C,{style:w.countText,testID:`${g}-keys-count`,children:e.changedKeys.length})})}),x(h,{style:w.cardContent,children:x(h,{style:w.keysContainer,children:e.changedKeys.map(u=>x(h,{style:w.keyBadge,children:x(C,{style:w.keyText,testID:`${g}-key-${u}`,children:u})},u))})})]}),o&&F(h,{style:w.card,testID:`${g}-partial-card`,children:[x(ze,{icon:Qt,title:"PARTIAL (setState argument)",badge:x(h,{style:w.typeBadge,children:x(C,{style:w.typeText,testID:`${g}-partial-type`,children:Array.isArray(e.partial)?"ARRAY":typeof e.partial=="object"?"OBJECT":(typeof e.partial).toUpperCase()})})}),x(h,{style:w.dataViewerContainer,children:x(xn,{title:"",data:bn(e.partial),showTypeFilter:true,rawMode:true,initialExpanded:true})})]}),e.partial==="(updater fn)"&&F(h,{style:w.card,testID:`${g}-updater-card`,children:[x(ze,{icon:Qt,title:"SET STATE CALL"}),F(h,{style:w.cardContent,children:[x(C,{style:w.updaterText,children:"Called with an updater function: set((state) => ...)"}),x(C,{style:w.updaterSubtext,children:"The partial value is computed at runtime from the previous state. See the DIFF tab to view the resulting changes."})]})]}),F(h,{style:w.actionsGrid,children:[x(tt,{type:"jump",text:"JUMP",onPress:l,testID:`${g}-jump`}),x(tt,{type:"reset",text:"RESET STORE",onPress:f,testID:`${g}-reset`}),x(tt,{type:"copy",text:"COPY STATE",onPress:i,testID:`${g}-copy-state`})]}),x(Sn,{visible:r,onClose:()=>a(false),featureName:"Copy"})]})}),w=le.create({container:{flex:1},contentContainer:{padding:8,paddingBottom:100,gap:16},card:{backgroundColor:k.color.surface,borderRadius:6,borderWidth:1,borderColor:k.color.accentBorderStrong,overflow:"hidden",shadowColor:k.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:k.color.accentBorder,backgroundColor:k.color.accentSoft},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:6},sectionTitle:{fontSize:12,fontWeight:"600",letterSpacing:.5,color:k.color.accent,fontFamily:fe},cardContent:{padding:14,gap:10},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:k.color.surfaceElevated},durationBadgeSlow:{backgroundColor:O.error+"26"},durationText:{fontSize:9,fontWeight:"600",color:k.color.textSecondary,fontFamily:fe},durationTextSlow:{color:O.error},changesBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:O.success+"26"},changesText:{fontSize:9,fontWeight:"600",color:O.success},noChangesBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:k.color.surfaceElevated},noChangesText:{fontSize:9,fontWeight:"600",color:k.color.textTertiary},persistBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:O.info+"26"},persistText:{fontSize:9,fontWeight:"700",color:O.info,letterSpacing:.3},keysContainer:{flexDirection:"row",flexWrap:"wrap",gap:6},keyBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4,backgroundColor:k.color.accentSoft,borderWidth:1,borderColor:k.color.accentBorder},keyText:{fontSize:11,fontWeight:"600",color:k.color.accent,fontFamily:fe},countBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:4,backgroundColor:k.color.accentFill},countText:{fontSize:9,fontWeight:"700",color:k.color.accent,fontFamily:fe},typeBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:3,backgroundColor:k.color.surfaceElevated},typeText:{fontSize:8,fontWeight:"600",color:k.color.textTertiary,fontFamily:fe},dataViewerContainer:{backgroundColor:k.color.bg,minHeight:60},updaterText:{fontSize:12,color:k.color.text,fontFamily:fe},updaterSubtext:{fontSize:11,color:k.color.textTertiary,lineHeight:16,marginTop:4},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:12,justifyContent:"flex-start"}});import{DiffModeTabs as Nn,CompareBar as An}from"@buoy-gg/shared-ui/web";import{jsx as $,jsxs as me}from"react/jsx-runtime";function ot(e){return S.getStoreColor(e.storeName)}function rr(e){switch(e.category){case"replace":return"REPLACE";case"persist":return"HYDRATE";case"initial":return"INIT";default:return"SET"}}function Rn(e){return e===null?"null":e===void 0?"undefined":Array.isArray(e)?"array":typeof e}function ar(e){return new Date(e).toLocaleTimeString("en-US",{hour12:false,hour:"2-digit",minute:"2-digit",second:"2-digit"})}var Ln=[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}];function or({change:e,changes:t,selectedIndex:r,onIndexChange:a,disableInternalFooter:n=false,initialView:o="change"}){let[s,d]=Gt(o),[i,f]=Gt("tree"),l=t.length,u=ot(e),b=rr(e),p=Rn(Le(e.nextState)),y=l-r,B=y-1,D=r<l-1?r+1:null,j=D!==null?t[D]:null,H=Jt(()=>({index:D??0,label:B>0?`#${B}`:"Initial",timestamp:j?ar(j.timestamp):"",relativeTime:j?Re(new Date(j.timestamp)):"state",badge:j?$(h,{style:[P.changeBadgeSmall,{backgroundColor:`${ot(j)}20`}],children:$(C,{style:[P.changeTextSmall,{color:ot(j)}],children:rr(j)})}):void 0}),[D,j,B]),be=Jt(()=>({index:r,label:`#${y}`,timestamp:ar(e.timestamp),relativeTime:Re(new Date(e.timestamp)),badge:$(h,{style:[P.changeBadgeSmall,{backgroundColor:`${u}20`}],children:$(C,{style:[P.changeTextSmall,{color:u}],children:b})})}),[r,e.timestamp,u,b,y]),oe=Ae(()=>{let ne=Le(e.nextState);return me(h,{style:P.contentCard,testID:`${g}-state-card`,children:[me(h,{style:P.valueHeader,children:[$(C,{style:P.valueLabel,children:"STATE AFTER CHANGE"}),me(h,{style:P.valueHeaderBadges,children:[$(h,{style:[P.changeBadge,{backgroundColor:`${u}20`}],children:$(C,{style:[P.changeText,{color:u}],children:b})}),$(h,{style:P.typeBadge,children:$(C,{style:P.typeText,testID:`${g}-state-type`,children:p.toUpperCase()})})]})]}),$(h,{style:P.dataViewerContainer,children:$(qo,{title:"",data:ne,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})},[e.nextState,u,b,p]),Se=Ae(()=>{let ne=Le(e.prevState),ce=Le(e.nextState);return i==="split"?$(De,{keyboardShouldPersistTaps:"handled",style:{flex:1},showsVerticalScrollIndicator:true,children:$(Qo,{oldValue:ne,newValue:ce,theme:en.devToolsDefault,options:{hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3},showThemeName:false})}):$(Xo,{oldValue:ne,newValue:ce})},[e.prevState,e.nextState,i]),Ce=Ae(()=>{a(Math.min(l-1,r+1))},[r,l,a]),we=Ae(()=>{a(Math.max(0,r-1))},[r,a]),J=e.prevState===void 0,xe=!n&&l>1;return me(h,{style:P.container,children:[$(cn,{activeView:s,onViewChange:d,diffDisabled:J}),me(h,{style:[P.contentArea,xe&&P.contentAreaFooterPad],children:[s==="change"&&$(Pn,{change:e}),s==="state"&&$(h,{style:P.stateContainer,children:oe()}),s==="diff"&&me(h,{style:P.diffContainer,testID:`${g}-diff`,children:[$(Nn,{tabs:Ln,activeTab:i,onTabChange:f,testIDPrefix:`${g}-diff-tab`}),$(An,{leftEvent:H,rightEvent:be}),$(h,{style:P.diffContent,testID:`${g}-diff-content`,children:Se()})]})]}),xe&&$(Yt,{currentIndex:y-1,totalItems:l,onPrevious:Ce,onNext:we,itemLabel:"Change",subtitle:Re(new Date(e.timestamp)),absolute:true})]})}function nr({change:e,changes:t,selectedIndex:r,onIndexChange:a}){let n=t.length;if(n<=1)return null;let o=n-r;return $(Yt,{currentIndex:o-1,totalItems:n,onPrevious:()=>a(Math.min(n-1,r+1)),onNext:()=>a(Math.max(0,r-1)),itemLabel:"Change",subtitle:Re(new Date(e.timestamp))})}var P=le.create({container:{flex:1,backgroundColor:"transparent"},contentArea:{flex:1},contentAreaFooterPad:{paddingBottom:96},stateContainer:{flex:1,padding:14},contentCard:{backgroundColor:ae.color.surface,borderRadius:14,padding:14,borderWidth:1,borderColor:ae.color.border},valueHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8},valueLabel:{fontSize:10,color:ae.color.textSecondary,fontFamily:$e,letterSpacing:.5,fontWeight:"600"},valueHeaderBadges:{flexDirection:"row",alignItems:"center",gap:6},changeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4},changeText:{fontSize:9,fontWeight:"700",fontFamily:$e,letterSpacing:.3},typeBadge:{paddingHorizontal:8,paddingVertical:2,borderRadius:4,backgroundColor:ae.color.surfaceElevated},typeText:{fontSize:9,fontWeight:"600",color:ae.color.textTertiary,fontFamily:$e},valueBox:{backgroundColor:ae.color.bg,borderRadius:6,borderWidth:1,borderColor:ae.color.border,padding:8},valueText:{fontSize:12,color:ae.color.text,fontFamily:$e,lineHeight:18},diffContainer:{flex:1},diffContent:{flex:1,paddingHorizontal:14},changeBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},changeTextSmall:{fontSize:8,fontWeight:"700",fontFamily:$e},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12}});import{useMemo as zn}from"react";import{CompactRow as Vn,night as nt,ToolEmptyState as st,resolveListEmptyState as On,monoFont as sr}from"@buoy-gg/shared-ui/web";import{jsx as G,jsxs as it}from"react/jsx-runtime";function jn(e){try{let t=e.api.getState();if(t&&typeof t=="object"&&t.__buoyStateOnDevice===true)return"on device";if(t&&typeof t=="object"){let r=Object.keys(t).filter(a=>typeof t[a]!="function");return r.length===0?"no data keys":r.length<=3?r.join(", "):`${r.slice(0,2).join(", ")} +${r.length-2}`}return""}catch{return""}}function Hn(){return G(st,{testID:`${g}-stores-loading`,otto:"loading",title:"Loading stores\u2026",message:"Waiting for the device to send its registered stores."})}function Wn(){return G(st,{testID:`${g}-stores-empty`,otto:"scanning",title:"No stores registered",message:`Use watchStores() to register your Zustand stores.
2
+ They will appear here with their current state.`})}function Fn({stores:e,searchQuery:t,isLoading:r=false,onOpenStore:a}){let n=zn(()=>{if(!t)return e;let o=t.toLowerCase();return e.filter(s=>s.name.toLowerCase().includes(o)||s.persistName&&s.persistName.toLowerCase().includes(o))},[e,t]);return n.length===0&&!t?r?G(Hn,{}):G(Wn,{}):n.length===0&&t?G(st,{testID:`${g}-stores-no-match`,...On({subject:"stores",verb:"registered",search:t,total:e.length,waiting:{otto:"scanning",title:"No stores registered",message:"Use watchStores() to register your Zustand stores."}})}):it(De,{keyboardShouldPersistTaps:"handled",style:X.container,contentContainerStyle:X.scrollContent,showsVerticalScrollIndicator:true,testID:`${g}-stores-scroll`,children:[it(h,{style:X.sectionHeader,children:[G(C,{style:X.sectionTitle,children:"STORES"}),G(h,{style:X.sectionCountBadge,children:G(C,{style:X.sectionCountText,testID:`${g}-stores-count`,children:n.length})})]}),n.map(o=>{let s=jn(o),d=S.getStoreColor(o.name),i=tr(o.name);return it(h,{style:X.storeRowWrapper,children:[G(Vn,{statusDotColor:d,statusLabel:o.isPersisted?"persisted":"in-memory",primaryText:o.name,secondaryText:s||void 0,showChevron:true,onPress:()=>a(o.name),testID:i,statusTestID:`${i}-backing`,primaryTestID:`${i}-name`,secondaryTestID:`${i}-keys`}),o.stateChangeCount>0&&G(h,{style:[X.absCountBadge,{backgroundColor:d+"22",borderColor:d+"55"}],pointerEvents:"none",children:G(C,{style:[X.absCountText,{color:d}],testID:`${i}-count`,children:String(o.stateChangeCount)})})]},o.name)})]})}var X=le.create({container:{flex:1},storeRowWrapper:{position:"relative"},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountText:{fontSize:9,fontWeight:"700",fontFamily:sr},scrollContent:{paddingTop:8,paddingBottom:20},sectionHeader:{flexDirection:"row",alignItems:"center",paddingHorizontal:16,paddingVertical:8,gap:8},sectionTitle:{fontSize:11,fontWeight:"700",letterSpacing:.5,color:nt.color.textTertiary},sectionCountBadge:{backgroundColor:nt.color.accentFill,paddingHorizontal:8,paddingVertical:2,borderRadius:4},sectionCountText:{fontSize:10,fontWeight:"700",color:nt.color.accent,fontFamily:sr}});import{useCallback as Mn,useEffect as Kn,useMemo as lt,useState as Ve}from"react";import{buoyColors as dt,Database as Un,ExpandedInfoRow as Oe,FileJson as Zn,night as R,PillBadge as ct,parseValue as ir,monoFont as je}from"@buoy-gg/shared-ui/web";import{DataViewer as _n,LiveExplorer as Gn,ValueEditModal as Jn,updateNestedDataByPath as Yn,deleteNestedDataByPath as qn}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as lr,jsx as v,jsxs as U}from"react/jsx-runtime";var Qn=300,de=`${g}-detail`;function Xn(e){let t=r=>r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${de}-explorer-root`:`${de}-explorer-${e.map(t).filter(Boolean).join("-")}`}function es({store:e,onViewHistory:t}){let r=tr(e.name),[a,n]=Ve(0);Kn(()=>e.api.subscribe(()=>n(b=>b+1)),[e.api]);let o=e.api.getState(),s=lt(()=>Bt(o),[o,a]),[d,i]=Ve(false),f=lt(()=>{if(s.data!==null)return{update:(b,p)=>{let y=e.api.getState();if(!_(y)||b.length===0)return;let B=b[0],D=b.length===1?p:Yn(y[B],b.slice(1),p);e.api.setState({[B]:D},false)},remove:b=>{let p=e.api.getState();if(!_(p)||b.length<=1)return;let y=b[0],B=qn(p[y],b.slice(1));e.api.setState({[y]:B},false)},canRemove:b=>b.length>1}},[e.api,s.data===null]),l=Mn(b=>{let p=Bt(e.api.getState());if(p.data===null)return;let y=ia(p.data,b);Object.keys(y).length>0&&e.api.setState(y,false),i(false)},[e.api]),u=lt(()=>{if(o&&typeof o=="object"){let b={};for(let[p,y]of Object.entries(o))typeof y!="function"&&(b[p]=y);return ir(b)}return ir(o)},[o,a]);return U(h,{style:T.root,children:[U(De,{testID:`${de}-scroll`,style:T.scroll,contentContainerStyle:T.scrollContent,keyboardShouldPersistTaps:"handled",children:[v(h,{style:T.section,children:U(h,{style:T.editorContainer,children:[U(h,{style:T.sectionHeaderRow,children:[v(C,{testID:`${de}-editor-header`,style:T.sectionHeaderText,children:"State Editor"}),s.data!==null?U(re,{onPress:()=>i(true),testID:`${de}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:T.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[v(Zn,{size:13,color:R.color.accent}),v(C,{style:T.rawButtonText,children:"Raw"})]}):null]}),v(h,{style:T.sectionBody,children:s.data!==null?U(lr,{children:[v(Gn,{editable:true,label:"State",value:s.data,defaultExpanded:["State"],writer:f,dataVersion:a,testIDForPath:Xn,debounceMs:Qn}),v(C,{style:T.editorHint,children:"Edits write into the live store as you make them \u2014 merged, so the store's actions and untouched keys survive."})]}):v(C,{style:T.blockedText,testID:`${de}-edit-blocked`,children:s.blockedReason})})]})}),v(h,{style:T.section,children:U(h,{style:T.infoContainer,children:[v(C,{style:T.sectionHeaderTextPlain,children:"Store Details"}),U(h,{style:T.infoBody,children:[v(Oe,{label:"Type",children:v(ct,{color:e.color,testID:`${r}-type`,children:"ZUSTAND"})}),U(Oe,{label:"Backing",children:[v(ct,{color:dt.info,icon:e.isPersisted?v(Un,{size:9,color:dt.info}):void 0,testID:`${r}-persist`,children:e.isPersisted?e.persistName||"persisted":"in-memory"}),e.isPersisted?v(ts,{store:e,rowID:r}):null]}),e.stateChangeCount>0&&U(Oe,{label:"Changes",children:[v(ct,{color:dt.warning,testID:`${r}-changes`,children:String(e.stateChangeCount)}),v(re,{onPress:()=>t(e.name),style:T.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${r}-history`,accessibilityRole:"button",accessibilityLabel:`View ${e.name} history`,children:v(C,{style:[T.inlineLinkText,{color:e.color}],children:"view history \u2192"})})]}),s.fnPaths.length>0&&v(Oe,{label:"Actions",children:v(C,{style:T.actionsText,testID:`${de}-actions`,numberOfLines:2,children:s.fnPaths.join(" \xB7 ")})})]})]})}),v(h,{style:T.section,children:U(h,{style:T.infoContainer,children:[v(C,{style:T.sectionHeaderTextPlain,children:"State Explorer"}),v(h,{style:T.viewerBody,testID:`${r}-state`,children:u&&typeof u=="object"?v(_n,{title:"",data:u,showTypeFilter:true,rawMode:true,initialExpanded:false}):v(C,{style:T.blockedText,children:"Empty state"})})]})})]}),d&&s.data!==null?v(Jn,{path:[],value:s.data,onSave:b=>{try{l(b)}catch{}},onCancel:()=>i(false),saveLabel:"Apply",testIDPrefix:`${g}-value`}):null]})}function ts({store:e,rowID:t}){let[r,a]=Ve(false),[n,o]=Ve(null);return e.rehydrate?U(lr,{children:[v(re,{onPress:()=>{a(true),o(null),(async()=>{try{await e.rehydrate?.()}catch(s){o(s instanceof Error?s.message:String(s))}finally{a(false)}})()},disabled:r,style:T.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},testID:`${t}-reread`,accessibilityRole:"button",accessibilityLabel:`Re-read ${e.name} from storage`,children:v(C,{style:[T.inlineLinkText,{color:e.color}],children:r?"re-reading\u2026":"re-read saved value \u2192"})}),n?v(C,{style:[T.inlineLinkText,{color:R.color.danger}],children:n}):null]}):null}var T=le.create({root:{flex:1,minHeight:0},scroll:{flex:1},scrollContent:{paddingHorizontal:8,paddingTop:8,paddingBottom:24},section:{marginBottom:16},editorContainer:{minWidth:200,backgroundColor:R.color.surface,borderRadius:6,borderWidth:1,borderColor:R.color.accent+"4D",overflow:"hidden",shadowColor:R.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:R.color.accent+"1A",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:R.color.accent+"33"},sectionHeaderText:{fontWeight:"600",fontSize:12,color:R.color.accent,letterSpacing:.5,textTransform:"uppercase",fontFamily:je},rawButton:{flexDirection:"row",alignItems:"center",gap:4},rawButtonText:{color:R.color.accent,fontSize:11,fontWeight:"700"},sectionBody:{padding:8},editorHint:{color:R.color.textTertiary,fontSize:10,paddingTop:8,paddingHorizontal:4,lineHeight:14},blockedText:{color:R.color.textSecondary,fontSize:12,padding:12,lineHeight:18},infoContainer:{minWidth:200,backgroundColor:R.color.surface,borderRadius:6,borderWidth:1,borderColor:R.color.border,overflow:"hidden"},sectionHeaderTextPlain:{backgroundColor:R.color.surfaceElevated,paddingHorizontal:12,paddingVertical:8,fontWeight:"600",fontSize:12,color:R.color.textSecondary,borderBottomWidth:1,borderBottomColor:R.color.border,letterSpacing:.5,textTransform:"uppercase",fontFamily:je},infoBody:{padding:12,gap:10},viewerBody:{backgroundColor:R.color.bg,minHeight:60},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:je},actionsText:{flex:1,color:R.color.textSecondary,fontSize:10,fontFamily:je,lineHeight:15}});import{useMemo as rs}from"react";import{EntityFilterView as as}from"@buoy-gg/shared-ui/web";import{jsx as os}from"react/jsx-runtime";var ns=["\u2022 auth \u2192 hides authStore from stores & events","\u2022 temp \u2192 hides tempStore, tempUserStore","\u2022 cart \u2192 hides cartStore from both tabs"];function ss({ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,stores:a}){let n=rs(()=>a.map(o=>({name:o.name,color:S.getStoreColor(o.name)})),[a]);return os(as,{entities:n,ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,entityNoun:"STORES",entitySingular:"store",entityKey:"store",testIDPrefix:g,slug:at,howItWorks:"Patterns hide matching stores from both the Stores tab and the Events tab. Tap a store above to quickly add it as a filter.",examples:ns})}import{Fragment as dr,jsx as m,jsxs as M}from"react/jsx-runtime";function is({isEnabled:e,searchText:t,totalChanges:r}){let a=Wt({subject:"changes",search:t,total:r,capturing:e,waiting:{otto:"waiting",title:"No state changes",message:"State changes will appear here as stores update."},paused:{title:"No state changes",message:"Enable capture to start recording state changes"}});return m(Qe,{...a,testID:`${g}-empty`})}function He({visible:e,onClose:t,onBack:r,onMinimize:a,enableSharedModalDimensions:n=false,inline:o=false,storesLoading:s=false,initialTab:d="stores",initialSelectedChangeId:i,initialDetailView:f,onChangeSelect:l,onStoreExpand:u}){let b=Lo(),p=Ao("zustand.changes"),[y,B]=Q(false),[D,j]=Q(d),[H,be]=Q(null),[oe,Se]=Q(null),[Ce,we]=Q(false),[J,xe]=Q(new Set),{stateChanges:ne,filteredChanges:ce,filter:Rs,setFilter:ve,stats:mr,stores:Te,clearChanges:yr,isEnabled:Ee,toggleCapture:br}=Ut(),Y=te(()=>J.size===0?ce:ce.filter(c=>!Array.from(J).some(I=>c.storeName.toLowerCase().includes(I.toLowerCase()))),[ce,J]),ue=te(()=>J.size===0?Te:Te.filter(c=>!Array.from(J).some(I=>c.name.toLowerCase().includes(I.toLowerCase()))),[Te,J]),Sr=te(()=>H?ne.filter(c=>c.storeName===H).length:0,[ne,H]),Be=te(()=>H?Y.filter(c=>c.storeName===H):Y,[Y,H]),Ue=te(()=>Be.slice(0,p),[Be,p]),Ze=te(()=>Math.max(0,Be.length-p),[Be.length,p]),Cr=Ze>0,z=Ue,[_e,se]=Q(null),ie=te(()=>{if(_e===null)return null;let c=z.findIndex(I=>I.id===_e);return c>=0?c:null},[_e,z]),Z=ie!==null?z[ie]:null,gt=Ne(null);Rt(()=>{if(!l)return;let c=Z?.id??null;c===null||c===gt.current||(gt.current=c,l(Z))},[Z,l]);let pt=Ne(null);Rt(()=>{!i||pt.current===i||!z.some(c=>c.id===i)||(pt.current=i,se(i))},[i,z]);let[ee,Ge]=Q(""),[wr,Pe]=Q(false),Ls=Ne(null),xr=Ne(null),vr=N(c=>{},[]),Tr=c=>{Ge(c),D==="events"&&ve(I=>({...I,searchText:c}))},kr=N(()=>{Ge(""),ve(c=>({...c,searchText:""})),Pe(false)},[ve]),ft=N(c=>{se(c.id)},[]),Ir=N(()=>{B(true)},[]),Dr=N(()=>{se(null)},[]),mt=N(c=>{let I=z[c];I&&se(I.id)},[z]),$r=N(c=>{be(c),se(null)},[]),Er=N(()=>{be(null),se(null)},[]),Br=N(c=>{Se(c),u?.(c)},[u]),Pr=N(()=>{Se(null)},[]),Nr=N(()=>ue.reduce((c,I)=>{try{let q=I.api.getState();if(q&&typeof q=="object"){let kt={};for(let[Fr,It]of Object.entries(q))typeof It!="function"&&(kt[Fr]=pe(It));c[I.name]=kt}else c[I.name]=pe(q)}catch{c[I.name]=null}return c},{}),[ue]),Ar=N(()=>Y.map(c=>({id:c.id,storeName:c.storeName,timestamp:c.timestamp,prevState:pe(c.prevState),nextState:pe(c.nextState),hasStateChange:c.hasStateChange,changedKeys:c.changedKeys})),[Y]),Rr=N(()=>z.map(c=>({id:c.id,storeName:c.storeName,timestamp:c.timestamp,prevState:pe(c.prevState),nextState:pe(c.nextState),hasStateChange:c.hasStateChange,changedKeys:c.changedKeys})),[z]),Lr=N(c=>{xe(I=>{let q=new Set(I);return q.has(c)?q.delete(c):q.add(c),q})},[]),zr=N(c=>{xe(I=>new Set([...I,c]))},[]),Vr=N(c=>{j(c),be(null),Se(null),se(null),we(false),ee&&(Ge(""),ve(I=>({...I,searchText:""}))),Pe(false)},[ee,ve]),yt=N(c=>c.id,[]),bt=te(()=>Dn(z),[z]),St=N(({item:c})=>m(_t,{change:c,onPress:ft,testID:bt.get(c.id)}),[ft,bt]),Ct=J.size>0,wt=()=>Ce?M(A,{children:[m(A.Navigation,{onBack:()=>we(false)}),m(A.Content,{title:"Filters",centered:true,testID:`${g}-filters-title`})]}):Z?M(A,{children:[m(A.Navigation,{onBack:Dr}),m(A.Content,{title:`${Z.storeName}/setState`,centered:true,testID:`${g}-detail-title`})]}):H?M(A,{children:[m(A.Navigation,{onBack:Er}),m(A.Content,{title:`${H} History`,centered:true,testID:`${g}-history-title`}),m(A.Actions,{children:m(Xe,{value:Rr,disabled:z.length===0,buttonStyle:L.headerActionButton,testID:`${g}-copy`})})]}):oe?M(A,{children:[m(A.Navigation,{onBack:Pr}),m(A.Content,{title:oe,centered:true,testID:`${g}-store-detail-title`})]}):M(A,{children:[r&&m(A.Navigation,{onBack:r}),m(A.Content,{title:"",children:wr?m(A.Search,{value:ee,onChangeText:Tr,onCancel:kr,placeholder:D==="stores"?"Search stores...":"Search events...",accessibilityLabel:"Search Zustand stores and events",iconSize:14,testID:`${g}-search-field`,containerTestID:`${g}-search`,clearTestID:`${g}-search-clear`,onBlur:()=>{ee.length===0&&Pe(false)}}):m(vo,{tabs:[{key:"stores",label:`Stores${ue.length>0?` (${ue.length})`:""}`},{key:"events",label:`Events${Y.length>0?` (${Y.length})`:""}`}],activeTab:D,onTabChange:Vr,testIDPrefix:`${g}-tab`})}),M(A.Actions,{children:[m(re,{onPress:()=>Pe(true),style:L.headerActionButton,testID:`${g}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search",children:m(ko,{size:14,color:V.color.textSecondary})}),m(re,{onPress:()=>we(true),style:[L.headerActionButton,Ct&&L.headerActionButtonActive],testID:`${g}-filters-open`,accessibilityRole:"button",accessibilityLabel:"Filters",children:m(Io,{size:14,color:Ct?V.color.accent:V.color.textSecondary})}),D==="stores"&&m(Xe,{value:Nr,disabled:ue.length===0,buttonStyle:L.headerActionButton,testID:`${g}-copy`}),D==="events"&&M(dr,{children:[m(Xe,{value:Ar,disabled:Y.length===0,buttonStyle:L.headerActionButton,testID:`${g}-copy`}),m(Po,{isEnabled:Ee,onToggle:br,accessibilityLabel:"Toggle Zustand state capture",testID:`${g}-power`}),m(No,{onPress:yr,disabled:Y.length===0,buttonStyle:L.headerActionButton,testID:`${g}-clear`})]})]})]}),Or=()=>{if(Ce)return m(ss,{ignoredPatterns:J,onTogglePattern:Lr,onAddPattern:zr,stores:Te});if(Z&&ie!==null)return m(or,{change:Z,changes:z,selectedIndex:ie,onIndexChange:mt,disableInternalFooter:true,initialView:f});if(H)return z.length>0?m(Je,{keyboardShouldPersistTaps:"handled",testID:`${g}-history-list`,data:z,renderItem:St,keyExtractor:yt,contentContainerStyle:L.listContent,showsVerticalScrollIndicator:true,...Mt}):m(Qe,{testID:`${g}-history-empty`,...Wt({subject:"changes",search:ee,total:ee.trim()?Sr:0,capturing:Ee,waiting:{otto:"waiting",title:"No history yet",message:`State changes for ${H} will appear here.`},paused:{title:"No history yet",message:`Capture is off, so nothing is being recorded for ${H}.`}})});if(oe){let c=Te.find(I=>I.name===oe)??null;return c?m(es,{store:c,onViewHistory:$r}):m(Qe,{testID:`${g}-store-detail-gone`,otto:"ghost",title:"Store no longer registered",message:`${oe} is not in the registry any more.`})}return D==="stores"?m(Fn,{stores:ue,searchQuery:ee,isLoading:s,onOpenStore:Br}):M(dr,{children:[!Ee&&M(h,{style:L.disabledBanner,testID:`${g}-banner-disabled`,children:[m(Do,{size:14,color:V.color.warning}),m(C,{style:L.disabledText,children:"State capture is disabled"})]}),Cr&&M(re,{style:L.lockedBanner,onPress:Ir,activeOpacity:.8,testID:`${g}-locked`,accessibilityRole:"button",children:[m($o,{size:14,color:V.color.accent}),M(C,{style:L.lockedText,testID:`${g}-locked-text`,children:[Ze," older"," ",Ze===1?"change":"changes"," locked"]}),m(h,{style:L.upgradeBadge,children:m(C,{style:L.upgradeBadgeText,children:"UPGRADE"})})]}),Ue.length>0?m(Je,{keyboardShouldPersistTaps:"handled",ref:xr,testID:`${g}-list`,data:Ue,renderItem:St,keyExtractor:yt,contentContainerStyle:L.listContent,showsVerticalScrollIndicator:true,...Mt}):m(is,{isEnabled:Ee,searchText:ee,totalChanges:mr.totalChanges})]})},jr=n?Eo.modal.root():"buoy-zustand-modal";if(!e)return null;let xt=Z&&ie!==null?m(nr,{change:Z,changes:z,selectedIndex:ie,onIndexChange:mt}):null,Hr=Z&&z.length>1?68:0,Wr=!Ce&&(Z&&ie!==null||H!=null||D==="events"||D==="stores"),vt=m(h,{style:L.container,children:Or()}),Tt=m(Bo,{visible:y,onClose:()=>B(false),featureName:"Full State History"});return o?M(Ft,{children:[M(h,{style:L.inlineRoot,children:[m(h,{style:L.inlineHeader,...Ro,children:wt()}),vt,xt]}),Tt]}):M(Ft,{children:[m(xo,{visible:e,onClose:t,onMinimize:a,persistenceKey:jr,header:{showToggleButton:true,customContent:wt()},onModeChange:vr,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:Wr,styles:{},footer:xt,footerHeight:Hr,children:vt}),Tt]})}function ls(e={}){return m(He,{...e,inline:true,visible:true,onClose:()=>{}})}var L=le.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:To.border.default,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:V.color.buttonSurface,borderWidth:1,borderColor:V.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:V.color.accentSoft,borderColor:V.color.accentBorderStrong},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:V.color.warningSoft,borderRadius:8,borderWidth:1,borderColor:V.color.warning+"20"},disabledText:{color:V.color.warning,fontSize:11,flex:1},listContent:{paddingTop:8,paddingBottom:20},lockedBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:V.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:V.color.accentBorder},lockedText:{color:V.color.accent,fontSize:11,fontWeight:"500",flex:1},upgradeBadge:{backgroundColor:V.color.accent,paddingHorizontal:8,paddingVertical:3,borderRadius:4},upgradeBadgeText:{color:V.color.onAccent,fontSize:9,fontWeight:"700",letterSpacing:.5}});import{ZustandIcon as ut,ZUSTAND_ICON_COLOR as ds}from"@buoy-gg/shared-ui/web";import{jsx as cr}from"react/jsx-runtime";var cs={id:"zustand",name:"ZUSTAND",description:"Zustand store & state inspector",slot:"both",icon:({size:e})=>cr(ut,{size:e}),component:He,props:{enableSharedModalDimensions:false}};function us(e){return{id:e?.id||"zustand",name:e?.name||"ZUSTAND",description:e?.description||"Zustand store & state inspector",slot:"both",icon:({size:t})=>cr(ut,{size:t,color:e?.iconColor}),component:He,props:{enableSharedModalDimensions:e?.enableSharedModalDimensions!==void 0?e.enableSharedModalDimensions:false}}}var ye=Symbol.for("@@buoy-zustand/watched");function ur(e){let t=e.persist;return t&&typeof t.getOptions=="function"?{isPersisted:true,persistName:t.getOptions()?.name,persistApi:t}:{isPersisted:false}}function hs(e){let t=[];for(let[r,a]of Object.entries(e)){let n=a;if(n[ye])continue;n[ye]=true;let{isPersisted:o,persistName:s,persistApi:d}=ur(a);S.registerStore(r,{getState:a.getState,getInitialState:a.getInitialState,setState:a.setState,subscribe:a.subscribe},{isPersisted:o,persistName:s,rehydrate:typeof d?.rehydrate=="function"?()=>d.rehydrate():void 0,library:a.buoyLibrary});let i=false,f=a.subscribe((l,u)=>{try{let b;if(!i&&o){let p=false;try{p=d?.hasHydrated?.()===false}catch{}p&&(i=true,b="persist")}S.addStateChange({storeName:r,partial:void 0,replace:false,prevState:u,nextState:l,duration:void 0,category:b,isPersisted:o})}catch{}});t.push(()=>{f(),delete a[ye],S.unregisterStore(r)})}return()=>{t.forEach(r=>r())}}var gs=0;function ps(e,t){return(r,a,n)=>{let o=t?.name??`store-${++gs}`,s=t?.enabled!==false,d=r,i=(l,u)=>{if(!s)return d(l,u);let b=performance.now(),p=a();d(l,u);let y=a(),B=performance.now()-b,D=typeof l=="function"?"(updater fn)":l;S.addStateChange({storeName:o,partial:D,replace:u??false,prevState:p,nextState:y,duration:B,isPersisted:S.getStore(o)?.isPersisted??false})},f=e(i,a,n);return setTimeout(()=>{if(n[ye])return;n[ye]=true;let{isPersisted:l,persistName:u}=ur(n);S.registerStore(o,{getState:a,getInitialState:n.getInitialState,setState:i,subscribe:n.subscribe},{isPersisted:l,persistName:u})},0),f}}function fs(e){return e[ye]===true}import{expandKeyedArrays as ms,patchFromPath as ys,readPath as bs,refusalText as Ss,shapeSummary as We,suggestedPatch as ht,typedEditViolations as Cs,unshapedLists as ws}from"@buoy-gg/shared-ui/web";import{WIRE_DETAIL_LIMIT_BYTES as hr,createSyncAdapter as xs,detailByIdAction as vs,isJsonSerializable as Ts,isOverWireBudget as ks,memoByIdentity as Is,onDeviceMarker as gr,readParams as Fe,toWire as pr,truncatedNote as Ds}from"@buoy-gg/shared-ui/web";var Me=e=>typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===Object.prototype;function fr(e,t){if(!Me(e)||!Me(t))return t;let r={...e};for(let[a,n]of Object.entries(t))r[a]=a in e?fr(e[a],n):n;return r}var Ke=gr("State","State trees stay on the device \u2014 fetched on demand via getChangeDetail / getStoreState."),$s=gr("Payload","Partial stays on the device \u2014 fetched on demand via getChangeDetail.");function Es(e,t){let r=e;for(let a of t.split(".")){if(!r||typeof r!="object"||Array.isArray(r)||!(a in r))return false;r=r[a]}return Array.isArray(r)?r.length>0:!!r&&typeof r=="object"}function Bs(e){return e&&typeof e=="object"&&!Array.isArray(e)?Object.keys(e):void 0}var Ps=Is(e=>({...e,prevState:Ke,nextState:Ke,partial:pr(e.partial,$s)})),Ns=e=>pr(e,Ke),As=xs({version:2,getSnapshot:()=>({changes:S.getStateChanges().map(Ps),stores:S.getStoreSnapshots().map(e=>({...e,currentState:Ns(e.currentState)}))}),subscribe:[e=>S.subscribe(e),e=>S.subscribeToStores(e)],actions:{clearEvents:()=>{S.clearStateChanges()},getChangeDetail:vs(e=>S.getStateChangeById(e),(e,t)=>({prevState:t(e.prevState),nextState:t(e.nextState),partial:t(e.partial)})),getStoreState:e=>{let{storeName:t,path:r}=Fe(e);if(!t)return{found:false,reason:"missing storeName"};let a=S.getStore(t);if(!a)return{found:false,reason:"unknown storeName"};let n;try{n=a.api.getState()}catch{n=void 0}if(r){let s=bs(n,r);return s.ok?{found:true,storeName:t,path:r,shape:We(s.value),currentState:s.value}:{found:false,reason:s.error}}let o=We(n);return ks(n,hr)?{found:true,storeName:t,...o?{shape:o}:{},currentState:Ts(n)?Ds(hr):Ke}:{found:true,storeName:t,...o?{shape:o}:{},currentState:n}},listStores:e=>{let{includeValues:t=false,limit:r}=Fe(e),a=S.getStoreSnapshots(),n=(typeof r=="number"&&r>0?a.slice(0,r):a).map(o=>({name:o.name,...o.library?{library:o.library}:{},changes:o.stateChangeCount,isPersisted:o.isPersisted,persistName:o.persistName,canRehydrate:o.canRehydrate,...t?{currentState:o.currentState}:{keys:Bs(o.currentState)},...We(o.currentState)?{shape:We(o.currentState)}:{}}));return{stores:n,total:a.length,returned:n.length,includedValues:t}},setState:e=>{let{storeName:t,state:r,replace:a,force:n,path:o,value:s}=Fe(e),d=r,i=[],f=[];if(!t)return{ok:false,error:"Missing storeName."};let l=S.getStore(t);if(!l)return{ok:false,error:`No store named "${t}".`};if(r===void 0&&o===void 0)return{ok:false,error:"Refused: no change was described. Send `state` with the fields to merge, or `path` and `value` to set one value."};let u=false;if(o!==void 0){if(s===void 0)return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${o}" to; if you mean to clear it, send value:null and the field must already be nullable.`};let p;try{p=l.api.getState()}catch{p=void 0}let y=ys(p,o,s);if(!y.ok)return{ok:false,error:`Refused: ${y.error}`};d=y.patch,u=true}if(!n&&(a===false||u)){let p;try{p=l.api.getState()}catch{p=void 0}if(p!==void 0){let y=ms(p,d);if(y.error)return{ok:false,error:`Refused: ${y.error}`};d=y.patch,i=y.notes}if(p!==void 0&&(f=ws(p).filter(y=>Es(d,y))),p!==void 0){let y=Cs(p,d,{noun:"store"});if(y.length>0)return{ok:false,error:Ss(y,"store",ht(d,y)),...ht(d,y)?{suggestedState:ht(d,y)}:{},violations:y}}}let b=u||a===false;if(b){let p;try{p=l.api.getState()}catch{p=void 0}if(Me(p)&&Me(d)){let y={};for(let[B,D]of Object.entries(d))y[B]=B in p?fr(p[B],D):D;d=y}}return l.api.setState(d,b?false:a??true),{ok:true,...o!==void 0?{path:o}:{},...i.length?{keyed:i}:{},...f.length?{unchecked:f.map(p=>`\`${p}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the app renders a field you left out, it will render undefined \u2014 read the store back and compare against how the screen uses it.`)}:{}}},rehydrate:async e=>{let{storeName:t}=Fe(e);if(!t)return{ok:false,error:"Missing storeName."};let r=S.getStore(t);return r?r.isPersisted?r.rehydrate?(await r.rehydrate(),{ok:true,storeName:t,persistName:r.persistName}):{ok:false,error:`"${t}" is persisted but Buoy has no rehydrate handle for it. It was probably registered before the app's persist middleware attached.`}:{ok:false,error:`"${t}" is not a persisted store \u2014 it has no saved copy to re-read.`}:{ok:false,error:`No store named "${t}".`}}}});export{ds as ZUSTAND_ICON_COLOR,ut as ZustandIcon,He as ZustandModal,_t as ZustandStateChangeItem,or as ZustandStateDetailContent,nr as ZustandStateDetailFooter,ls as ZustandToolView,ps as buoyDevTools,us as createZustandTool,fs as isStoreInstrumented,Ut as useZustandStateChanges,hs as watchStores,S as zustandStateStore,As as zustandSyncAdapter,cs as zustandToolPreset};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/zustand",
3
- "version": "7.0.76",
3
+ "version": "7.0.78",
4
4
  "description": "Inspect registered Zustand stores, compare captured state changes and use supported reset or state-update actions.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -38,8 +38,8 @@
38
38
  "./lib/web/**/*.mjs"
39
39
  ],
40
40
  "dependencies": {
41
- "@buoy-gg/shared-ui": "^7.0.76",
42
- "@buoy-gg/license": "^7.0.76"
41
+ "@buoy-gg/shared-ui": "^7.0.78",
42
+ "@buoy-gg/license": "^7.0.78"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "react": "*",