@buoy-gg/storage 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,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FREE_TIER_KEY_LIMIT=void 0;exports.GameUIStorageBrowser=GameUIStorageBrowser;var _storageLabels=require("../utils/storageLabels");var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _StorageKeySection=require("./StorageKeySection");var _StorageKeyDetailScreen=require("./StorageKeyDetailScreen");var _StorageFilterCards=require("./StorageFilterCards");var _useAsyncStorageKeys=require("../hooks/useAsyncStorageKeys");var _AsyncStorageListener=require("../utils/AsyncStorageListener");var _useMMKVKeys=require("../hooks/useMMKVKeys");var _useSecureStoreKeys=require("../hooks/useSecureStoreKeys");var _useMMKVInstances=require("../hooks/useMMKVInstances");var _StorageSaveNotice=require("./StorageSaveNotice");var _StorageActionButtons=require("./StorageActionButtons");var _SelectionActionBar=require("./SelectionActionBar");var _MMKVListener=require("../utils/MMKVListener");var _storageBrowserRefresh=require("../utils/storageBrowserRefresh");var _deleteStorageKeys=require("../utils/deleteStorageKeys");var _setStorageValue=require("../utils/setStorageValue");var _license=require("@buoy-gg/license");var _jsxRuntime=require("react/jsx-runtime");const INSTANCE_COLORS=[_sharedUi.macOSColors.semantic.info,_sharedUi.macOSColors.semantic.success,_sharedUi.macOSColors.semantic.warning,_sharedUi.macOSColors.semantic.debug,"#FF6B9D","#00D9FF"];function getInstanceColor(M){const U=M.split("").reduce((_,P)=>_+P.charCodeAt(0),0);return INSTANCE_COLORS[U%INSTANCE_COLORS.length]}const FREE_TIER_KEY_LIMIT=exports.FREE_TIER_KEY_LIMIT=_sharedUi.TIER_LIMITS["storage.keys"].free;function GameUIStorageBrowser({requiredStorageKeys:M=[],showFilters:U=false,ignoredPatterns:_=new Set(["@react_buoy"]),onTogglePattern:P,onAddPattern:$,searchQuery:m="",storageDataRef:R,eventCountByKey:G,lastWriteByKey:Ze,onViewHistory:A,enabledStorageTypes:I,statusFilter:Y,onStatusFilterChange:J,onStatusCountsChange:X,pinnedKeys:S,onTogglePin:Z,storageTypeFilter:Q,onStorageTypeFilterChange:ee,applySafeAreaInset:fe,detailKey:q=null,onOpenKey:Se,onCloseDetail:te}){const p=(0,_license.useIsPro)();const B=(0,_sharedUi.useLimit)("storage.keys");const re=(0,_sharedUi.useLimit)("storage.mmkvInstances");const[D,T]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{if(D&&p){T(false)}},[D,p]);const[pe,ve]=(0,_react.useState)("all");const L=Y!=null&&J!=null;const y=L?Y:pe;const be=L?J:ve;const[Ce,Te]=(0,_react.useState)("all");const oe=Q!=null&&ee!=null;const d=oe?Q:Ce;const xe=oe?ee:Te;const[l,se]=(0,_react.useState)(null);const we=(0,_react.useRef)(null);const Me=(0,_react.useRef)(0);const ne=(0,_react.useRef)(new Map);const ke=(0,_react.useCallback)((e,t)=>{if(t)ne.current.set(e,t);else ne.current.delete(e)},[]);const[ae,ie]=(0,_react.useState)(0);const[F,z]=(0,_react.useState)(false);const[V,x]=(0,_react.useState)(new Set);const{instances:c}=(0,_useMMKVInstances.useMMKVInstances)(false);const{storageKeys:le,isLoading:Ke,error:_e,refresh:j}=(0,_useAsyncStorageKeys.useAsyncStorageKeys)(M);const Ie=(0,_react.useMemo)(()=>c.map(e=>({instance:e.instance,id:e.id})),[c]);const{storageKeys:O,isLoading:qe,error:Be,refresh:N}=(0,_useMMKVKeys.useMultiMMKVKeys)(Ie,M);const ce=(0,_react.useMemo)(()=>{if(!l){return O}return O.filter(e=>e.instanceId===l)},[O,l]);const{storageKeys:ue,isLoading:Ve,error:je,refresh:de}=(0,_useSecureStoreKeys.useSecureStoreKeys)(M);const a=(0,_react.useMemo)(()=>{return[...le,...ce,...ue].filter(e=>!(0,_sharedUi.isDevToolsStorageKey)(e.key))},[le,ce,ue]);const v=(0,_react.useMemo)(()=>{if(!q)return null;const e=(0,_StorageKeySection.storageRowId)(q);return a.find(t=>(0,_StorageKeySection.storageRowId)(t)===e)??q},[q,a]);const Ne=Ke||qe||Ve;const ge=_e||Be||je;const h=(0,_react.useCallback)(()=>{j();N();de()},[j,N,de]);const w=(0,_react.useCallback)(e=>{return e.instanceId?`${e.storageType}-${e.instanceId}-${e.key}`:`${e.storageType}-${e.key}`},[]);const Ee=(0,_react.useCallback)(()=>{z(e=>{if(e){x(new Set)}return!e})},[]);const Re=(0,_react.useCallback)((e,t)=>{const r=w(e);x(u=>{const s=new Set(u);if(t){s.add(r)}else{s.delete(r)}return s})},[w]);const Ae=(0,_react.useCallback)(()=>{x(new Set);z(false);h()},[h]);const W=(0,_react.useCallback)(e=>{e.forEach(t=>$?.(t.key));x(new Set);z(false)},[$]);const H=(0,_react.useCallback)(async(e,t)=>{if(!p){T(true);throw new Error("Editing storage values is a Pro feature.")}await(0,_setStorageValue.setStorageValue)(e,t,c);h();ie(r=>r+1)},[p,c,h]);const De=(0,_react.useCallback)(e=>{void H(e,JSON.stringify(!e.value)).catch(t=>{_reactNative.Alert.alert("Couldn't save",t instanceof Error?t.message:String(t))})},[H]);const ye=(0,_react.useCallback)((e,t)=>{if(!p){T(true);return}_reactNative.Alert.alert("Delete key",`Delete "${e.key}"? This cannot be undone.`,[{text:"Cancel",style:"cancel"},{text:"Delete",style:"destructive",onPress:async()=>{try{await(0,_deleteStorageKeys.deleteStorageKeys)([e],c.map(r=>({id:r.id,instance:r.instance})));h();t?.()}catch(r){_reactNative.Alert.alert("Error",`Failed to delete key: ${r}`)}}}])},[p,c,h]);const he=(0,_react.useCallback)(e=>(0,_setStorageValue.storageEditBlockedReason)(e,c),[c]);const Le=(0,_react.useMemo)(()=>{const e=a;const t={valid:e.filter(n=>n.status==="required_present"||n.status==="optional_present").length,missing:e.filter(n=>n.status==="required_missing").length,issues:e.filter(n=>n.status==="required_wrong_value"||n.status==="required_wrong_type").length,total:e.length};const r=e.filter(n=>n.storageType==="async");const u=e.filter(n=>n.storageType==="mmkv");const s=e.filter(n=>n.storageType==="secure");return{summary:{valid:t.valid,missing:t.missing,issues:t.issues,total:t.total,timestamp:new Date().toISOString()},asyncStorage:r.reduce((n,i)=>{n[i.key]=i.value;return n},{}),mmkv:u.reduce((n,i)=>{const f=i.instanceId||"default";if(!n[f])n[f]={};n[f][i.key]=i.value;return n},{}),secure:s.reduce((n,i)=>{n[i.key]=i.value;return n},{})}},[a]);(0,_react.useEffect)(()=>{if(R){R.current=a}},[a,R]);(0,_react.useEffect)(()=>{let e;const t=(0,_AsyncStorageListener.addListener)(r=>{clearTimeout(e);e=setTimeout(()=>{j()},100)});return()=>{clearTimeout(e);t()}},[j]);(0,_react.useEffect)(()=>{let e;const t=(0,_storageBrowserRefresh.onStorageBrowserRefresh)(()=>{clearTimeout(e);e=setTimeout(h,100)});return()=>{clearTimeout(e);t()}},[h]);(0,_react.useEffect)(()=>{let e;const t=(0,_MMKVListener.addMMKVListener)(r=>{const u=l===null||r.instanceId===l;if(u){clearTimeout(e);e=setTimeout(()=>{N()},100)}});return()=>{clearTimeout(e);t()}},[N,l]);const k=(0,_react.useMemo)(()=>{const e=a;const t=e.filter(s=>!(0,_sharedUi.isDevToolsStorageKey)(s.key));const r=e.filter(s=>(0,_sharedUi.isDevToolsStorageKey)(s.key));const u={totalCount:e.length,requiredCount:t.filter(s=>s.category==="required").length,missingCount:t.filter(s=>s.status==="required_missing").length,wrongValueCount:t.filter(s=>s.status==="required_wrong_value").length,wrongTypeCount:t.filter(s=>s.status==="required_wrong_type").length,presentRequiredCount:t.filter(s=>s.status==="required_present").length,optionalCount:t.filter(s=>s.category==="optional").length,mmkvCount:e.filter(s=>s.storageType==="mmkv").length,asyncCount:e.filter(s=>s.storageType==="async").length,secureCount:e.filter(s=>s.storageType==="secure").length,devToolsCount:r.length};return u},[a]);const b=(0,_react.useMemo)(()=>{let e=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key));if(d!=="all"){e=e.filter(o=>o.storageType===d)}const t=e.filter(o=>o.status==="required_present"||o.status==="optional_present").length;const r=e.filter(o=>o.status==="required_missing").length;const u=e.filter(o=>o.status==="required_wrong_type"||o.status==="required_wrong_value").length;let s=0;let n=0;let i=0;let f=0;if(y==="all"){s=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="async"&&(o.status==="required_present"||o.status==="optional_present")).length;n=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="mmkv"&&(o.status==="required_present"||o.status==="optional_present")).length;i=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="secure"&&(o.status==="required_present"||o.status==="optional_present")).length;f=s+n+i}else if(y==="missing"){s=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="async"&&o.status==="required_missing").length;n=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="mmkv"&&o.status==="required_missing").length;i=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="secure"&&o.status==="required_missing").length;f=s+n+i}else if(y==="issues"){s=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="async"&&(o.status==="required_wrong_type"||o.status==="required_wrong_value")).length;n=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="mmkv"&&(o.status==="required_wrong_type"||o.status==="required_wrong_value")).length;i=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="secure"&&(o.status==="required_wrong_type"||o.status==="required_wrong_value")).length;f=s+n+i}return{validCount:t,missingCount:r,issuesCount:u,asyncCount:s,mmkvCount:n,secureCount:i,totalCount:f}},[a,y,d]);(0,_react.useEffect)(()=>{X?.({validCount:b.validCount,missingCount:b.missingCount,issuesCount:b.issuesCount})},[X,b.validCount,b.missingCount,b.issuesCount]);const me=(0,_react.useMemo)(()=>{return[...a].sort((e,t)=>{const r={required_missing:1,required_wrong_type:2,required_wrong_value:3,required_present:4,optional_present:5};return(r[e.status]||999)-(r[t.status]||999)})},[a]);const Qe=(0,_react.useMemo)(()=>{return Array.from(new Set(a.map(e=>e.key))).sort()},[a]);const g=(0,_react.useMemo)(()=>{let e=me;if(I&&I.size>0){e=e.filter(t=>I.has(t.storageType))}e=e.filter(t=>{const r=Array.from(_).some(u=>t.key.includes(u));return!r});if(m){const t=m.toLowerCase();e=e.filter(r=>r.key.toLowerCase().includes(t))}switch(y){case"all":e=e.filter(t=>t.status==="required_present"||t.status==="optional_present");break;case"missing":e=e.filter(t=>t.status==="required_missing");break;case"issues":e=e.filter(t=>t.status==="required_wrong_type"||t.status==="required_wrong_value");break}if(d!=="all"){e=e.filter(t=>t.storageType===d)}if(S&&S.size>0){const t=e.filter(u=>S.has(u.key));const r=e.filter(u=>!S.has(u.key));e=[...t,...r]}return e},[me,y,d,_,m,l,I,S]);const C=(0,_react.useMemo)(()=>g.slice(0,B),[g,B]);const E=(0,_react.useMemo)(()=>{return Math.max(0,g.length-B)},[g.length,B]);const Fe=E>0;const et=(0,_react.useMemo)(()=>{const e=g.filter(r=>!(0,_sharedUi.isDevToolsStorageKey)(r.key));const t={totalCount:g.length,requiredCount:e.filter(r=>r.category==="required").length,missingCount:e.filter(r=>r.status==="required_missing").length,wrongValueCount:e.filter(r=>r.status==="required_wrong_value").length,wrongTypeCount:e.filter(r=>r.status==="required_wrong_type").length,presentRequiredCount:e.filter(r=>r.status==="required_present").length,optionalCount:e.filter(r=>r.category==="optional").length,mmkvCount:g.filter(r=>r.storageType==="mmkv").length,asyncCount:g.filter(r=>r.storageType==="async").length,secureCount:g.filter(r=>r.storageType==="secure").length,devToolsCount:g.filter(r=>(0,_sharedUi.isDevToolsStorageKey)(r.key)).length};return t},[g]);const ze=(0,_react.useMemo)(()=>{return C.filter(e=>V.has(w(e)))},[C,V,w]);const Oe=(0,_react.useCallback)(()=>{const e=new Set(C.map(w));x(e)},[C,w]);const We=(0,_react.useCallback)(()=>{x(new Set)},[]);const K=k.requiredCount>0?Math.round(k.presentRequiredCount/k.requiredCount*100):k.totalCount>0?100:0;const He=K>=90?"OPTIMAL":K>=70?"WARNING":"CRITICAL";const Ue=K>=90?_sharedUi.gameUIColors.success:K>=70?_sharedUi.gameUIColors.warning:_sharedUi.gameUIColors.error;if(v){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.root,children:(0,_jsxRuntime.jsx)(_StorageKeyDetailScreen.StorageKeyDetailScreen,{storageKey:v,editBlockedReason:he(v),eventCount:G?.[v.key],onSave:e=>H(v,e),onViewHistory:A?()=>A(v.key):void 0,onDeleteKey:e=>ye(e,()=>te?.()),onHideKey:e=>{W([e]);te?.()},isPinned:S?.has(v.key)??false,onTogglePin:Z,applySafeAreaInset:fe})})}if(Ne&&a.length===0){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyState,children:[(0,_jsxRuntime.jsx)(_sharedUi.Database,{size:48,color:_sharedUi.night.color.textTertiary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyTitle,children:"Loading storage keys..."})]})}if(ge){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyState,children:[(0,_jsxRuntime.jsx)(_sharedUi.Database,{size:48,color:_sharedUi.gameUIColors.error}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.emptyTitle,{color:_sharedUi.gameUIColors.error}],children:"Error loading storage"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptySubtitle,children:ge.message})]})}const Pe=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[d==="mmkv"&&c.length===0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyMMKVState,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyMMKVTitle,children:"No MMKV Instances Detected"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyMMKVSubtitle,children:"MMKV instances must be registered with registerMMKVInstance()"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyMMKVCode,children:`import { registerMMKVInstance } from '@buoy-gg/storage';
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FREE_TIER_KEY_LIMIT=void 0;exports.GameUIStorageBrowser=GameUIStorageBrowser;var _storageLabels=require("../utils/storageLabels");var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _StorageKeySection=require("./StorageKeySection");var _StorageKeyDetailScreen=require("./StorageKeyDetailScreen");var _StorageFilterCards=require("./StorageFilterCards");var _useAsyncStorageKeys=require("../hooks/useAsyncStorageKeys");var _AsyncStorageListener=require("../utils/AsyncStorageListener");var _useMMKVKeys=require("../hooks/useMMKVKeys");var _useSecureStoreKeys=require("../hooks/useSecureStoreKeys");var _useMMKVInstances=require("../hooks/useMMKVInstances");var _StorageSaveNotice=require("./StorageSaveNotice");var _StorageActionButtons=require("./StorageActionButtons");var _SelectionActionBar=require("./SelectionActionBar");var _MMKVListener=require("../utils/MMKVListener");var _storageBrowserRefresh=require("../utils/storageBrowserRefresh");var _deleteStorageKeys=require("../utils/deleteStorageKeys");var _setStorageValue=require("../utils/setStorageValue");var _license=require("@buoy-gg/license");var _jsxRuntime=require("react/jsx-runtime");const INSTANCE_COLORS=[_sharedUi.macOSColors.semantic.info,_sharedUi.macOSColors.semantic.success,_sharedUi.macOSColors.semantic.warning,_sharedUi.macOSColors.semantic.debug,"#FF6B9D","#00D9FF"];function getInstanceColor(k){const P=k.split("").reduce((_,U)=>_+U.charCodeAt(0),0);return INSTANCE_COLORS[P%INSTANCE_COLORS.length]}const FREE_TIER_KEY_LIMIT=exports.FREE_TIER_KEY_LIMIT=_sharedUi.TIER_LIMITS["storage.keys"].free;function GameUIStorageBrowser({requiredStorageKeys:k=[],showFilters:P=false,ignoredPatterns:_=new Set(["@react_buoy"]),onTogglePattern:U,onAddPattern:$,searchQuery:m="",storageDataRef:R,eventCountByKey:G,lastWriteByKey:Ze,onViewHistory:A,enabledStorageTypes:I,statusFilter:Y,onStatusFilterChange:J,onStatusCountsChange:X,pinnedKeys:S,onTogglePin:Z,storageTypeFilter:Q,onStorageTypeFilterChange:ee,applySafeAreaInset:fe,detailKey:q=null,onOpenKey:Se,onCloseDetail:te}){const p=(0,_license.useIsPro)();const B=(0,_sharedUi.useLimit)("storage.keys");const re=(0,_sharedUi.useLimit)("storage.mmkvInstances");const[D,T]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{if(D&&p){T(false)}},[D,p]);const[pe,be]=(0,_react.useState)("all");const L=Y!=null&&J!=null;const y=L?Y:pe;const ve=L?J:be;const[Ce,Te]=(0,_react.useState)("all");const oe=Q!=null&&ee!=null;const d=oe?Q:Ce;const xe=oe?ee:Te;const[l,se]=(0,_react.useState)(null);const we=(0,_react.useRef)(null);const ke=(0,_react.useRef)(0);const ne=(0,_react.useRef)(new Map);const Me=(0,_react.useCallback)((e,t)=>{if(t)ne.current.set(e,t);else ne.current.delete(e)},[]);const[ae,ie]=(0,_react.useState)(0);const[F,z]=(0,_react.useState)(false);const[V,x]=(0,_react.useState)(new Set);const{instances:c}=(0,_useMMKVInstances.useMMKVInstances)(false);const{storageKeys:le,isLoading:Ke,error:_e,refresh:j}=(0,_useAsyncStorageKeys.useAsyncStorageKeys)(k);const Ie=(0,_react.useMemo)(()=>c.map(e=>({instance:e.instance,id:e.id})),[c]);const{storageKeys:O,isLoading:qe,error:Be,refresh:N}=(0,_useMMKVKeys.useMultiMMKVKeys)(Ie,k);const ce=(0,_react.useMemo)(()=>{if(!l){return O}return O.filter(e=>e.instanceId===l)},[O,l]);const{storageKeys:ue,isLoading:Ve,error:je,refresh:de}=(0,_useSecureStoreKeys.useSecureStoreKeys)(k);const a=(0,_react.useMemo)(()=>{return[...le,...ce,...ue].filter(e=>!(0,_sharedUi.isDevToolsStorageKey)(e.key))},[le,ce,ue]);const b=(0,_react.useMemo)(()=>{if(!q)return null;const e=(0,_StorageKeySection.storageRowId)(q);return a.find(t=>(0,_StorageKeySection.storageRowId)(t)===e)??q},[q,a]);const Ne=Ke||qe||Ve;const ge=_e||Be||je;const h=(0,_react.useCallback)(()=>{j();N();de()},[j,N,de]);const w=(0,_react.useCallback)(e=>{return e.instanceId?`${e.storageType}-${e.instanceId}-${e.key}`:`${e.storageType}-${e.key}`},[]);const Ee=(0,_react.useCallback)(()=>{z(e=>{if(e){x(new Set)}return!e})},[]);const Re=(0,_react.useCallback)((e,t)=>{const r=w(e);x(u=>{const s=new Set(u);if(t){s.add(r)}else{s.delete(r)}return s})},[w]);const Ae=(0,_react.useCallback)(()=>{x(new Set);z(false);h()},[h]);const W=(0,_react.useCallback)(e=>{e.forEach(t=>$?.(t.key));x(new Set);z(false)},[$]);const H=(0,_react.useCallback)(async(e,t)=>{if(!p){T(true);throw new Error("Editing storage values is a Pro feature.")}await(0,_setStorageValue.setStorageValue)(e,t,c);h();ie(r=>r+1)},[p,c,h]);const De=(0,_react.useCallback)(e=>{void H(e,JSON.stringify(!e.value)).catch(t=>{_reactNative.Alert.alert("Couldn't save",t instanceof Error?t.message:String(t))})},[H]);const ye=(0,_react.useCallback)((e,t)=>{if(!p){T(true);return}_reactNative.Alert.alert("Delete key",`Delete "${e.key}"? This cannot be undone.`,[{text:"Cancel",style:"cancel"},{text:"Delete",style:"destructive",onPress:async()=>{try{await(0,_deleteStorageKeys.deleteStorageKeys)([e],c.map(r=>({id:r.id,instance:r.instance})));h();t?.()}catch(r){_reactNative.Alert.alert("Error",`Failed to delete key: ${r}`)}}}])},[p,c,h]);const he=(0,_react.useCallback)(e=>(0,_setStorageValue.storageEditBlockedReason)(e,c),[c]);const Le=(0,_react.useMemo)(()=>{const e=a;const t={valid:e.filter(n=>n.status==="required_present"||n.status==="optional_present").length,missing:e.filter(n=>n.status==="required_missing").length,issues:e.filter(n=>n.status==="required_wrong_value"||n.status==="required_wrong_type").length,total:e.length};const r=e.filter(n=>n.storageType==="async");const u=e.filter(n=>n.storageType==="mmkv");const s=e.filter(n=>n.storageType==="secure");return{summary:{valid:t.valid,missing:t.missing,issues:t.issues,total:t.total,timestamp:new Date().toISOString()},asyncStorage:r.reduce((n,i)=>{n[i.key]=i.value;return n},{}),mmkv:u.reduce((n,i)=>{const f=i.instanceId||"default";if(!n[f])n[f]={};n[f][i.key]=i.value;return n},{}),secure:s.reduce((n,i)=>{n[i.key]=i.value;return n},{})}},[a]);(0,_react.useEffect)(()=>{if(R){R.current=a}},[a,R]);(0,_react.useEffect)(()=>{let e;const t=(0,_AsyncStorageListener.addListener)(r=>{clearTimeout(e);e=setTimeout(()=>{j()},100)});return()=>{clearTimeout(e);t()}},[j]);(0,_react.useEffect)(()=>{let e;const t=(0,_storageBrowserRefresh.onStorageBrowserRefresh)(()=>{clearTimeout(e);e=setTimeout(h,100)});return()=>{clearTimeout(e);t()}},[h]);(0,_react.useEffect)(()=>{let e;const t=(0,_MMKVListener.addMMKVListener)(r=>{const u=l===null||r.instanceId===l;if(u){clearTimeout(e);e=setTimeout(()=>{N()},100)}});return()=>{clearTimeout(e);t()}},[N,l]);const M=(0,_react.useMemo)(()=>{const e=a;const t=e.filter(s=>!(0,_sharedUi.isDevToolsStorageKey)(s.key));const r=e.filter(s=>(0,_sharedUi.isDevToolsStorageKey)(s.key));const u={totalCount:e.length,requiredCount:t.filter(s=>s.category==="required").length,missingCount:t.filter(s=>s.status==="required_missing").length,wrongValueCount:t.filter(s=>s.status==="required_wrong_value").length,wrongTypeCount:t.filter(s=>s.status==="required_wrong_type").length,presentRequiredCount:t.filter(s=>s.status==="required_present").length,optionalCount:t.filter(s=>s.category==="optional").length,mmkvCount:e.filter(s=>s.storageType==="mmkv").length,asyncCount:e.filter(s=>s.storageType==="async").length,secureCount:e.filter(s=>s.storageType==="secure").length,devToolsCount:r.length};return u},[a]);const v=(0,_react.useMemo)(()=>{let e=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key));if(d!=="all"){e=e.filter(o=>o.storageType===d)}const t=e.filter(o=>o.status==="required_present"||o.status==="optional_present").length;const r=e.filter(o=>o.status==="required_missing").length;const u=e.filter(o=>o.status==="required_wrong_type"||o.status==="required_wrong_value").length;let s=0;let n=0;let i=0;let f=0;if(y==="all"){s=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="async"&&(o.status==="required_present"||o.status==="optional_present")).length;n=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="mmkv"&&(o.status==="required_present"||o.status==="optional_present")).length;i=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="secure"&&(o.status==="required_present"||o.status==="optional_present")).length;f=s+n+i}else if(y==="missing"){s=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="async"&&o.status==="required_missing").length;n=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="mmkv"&&o.status==="required_missing").length;i=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="secure"&&o.status==="required_missing").length;f=s+n+i}else if(y==="issues"){s=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="async"&&(o.status==="required_wrong_type"||o.status==="required_wrong_value")).length;n=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="mmkv"&&(o.status==="required_wrong_type"||o.status==="required_wrong_value")).length;i=a.filter(o=>!(0,_sharedUi.isDevToolsStorageKey)(o.key)&&o.storageType==="secure"&&(o.status==="required_wrong_type"||o.status==="required_wrong_value")).length;f=s+n+i}return{validCount:t,missingCount:r,issuesCount:u,asyncCount:s,mmkvCount:n,secureCount:i,totalCount:f}},[a,y,d]);(0,_react.useEffect)(()=>{X?.({validCount:v.validCount,missingCount:v.missingCount,issuesCount:v.issuesCount})},[X,v.validCount,v.missingCount,v.issuesCount]);const me=(0,_react.useMemo)(()=>{return[...a].sort((e,t)=>{const r={required_missing:1,required_wrong_type:2,required_wrong_value:3,required_present:4,optional_present:5};return(r[e.status]||999)-(r[t.status]||999)})},[a]);const Qe=(0,_react.useMemo)(()=>{return Array.from(new Set(a.map(e=>e.key))).sort()},[a]);const g=(0,_react.useMemo)(()=>{let e=me;if(I&&I.size>0){e=e.filter(t=>I.has(t.storageType))}e=e.filter(t=>{const r=Array.from(_).some(u=>t.key.includes(u));return!r});if(m){const t=m.toLowerCase();e=e.filter(r=>r.key.toLowerCase().includes(t))}switch(y){case"all":e=e.filter(t=>t.status==="required_present"||t.status==="optional_present");break;case"missing":e=e.filter(t=>t.status==="required_missing");break;case"issues":e=e.filter(t=>t.status==="required_wrong_type"||t.status==="required_wrong_value");break}if(d!=="all"){e=e.filter(t=>t.storageType===d)}if(S&&S.size>0){const t=e.filter(u=>S.has(u.key));const r=e.filter(u=>!S.has(u.key));e=[...t,...r]}return e},[me,y,d,_,m,l,I,S]);const C=(0,_react.useMemo)(()=>g.slice(0,B),[g,B]);const E=(0,_react.useMemo)(()=>{return Math.max(0,g.length-B)},[g.length,B]);const Fe=E>0;const et=(0,_react.useMemo)(()=>{const e=g.filter(r=>!(0,_sharedUi.isDevToolsStorageKey)(r.key));const t={totalCount:g.length,requiredCount:e.filter(r=>r.category==="required").length,missingCount:e.filter(r=>r.status==="required_missing").length,wrongValueCount:e.filter(r=>r.status==="required_wrong_value").length,wrongTypeCount:e.filter(r=>r.status==="required_wrong_type").length,presentRequiredCount:e.filter(r=>r.status==="required_present").length,optionalCount:e.filter(r=>r.category==="optional").length,mmkvCount:g.filter(r=>r.storageType==="mmkv").length,asyncCount:g.filter(r=>r.storageType==="async").length,secureCount:g.filter(r=>r.storageType==="secure").length,devToolsCount:g.filter(r=>(0,_sharedUi.isDevToolsStorageKey)(r.key)).length};return t},[g]);const ze=(0,_react.useMemo)(()=>{return C.filter(e=>V.has(w(e)))},[C,V,w]);const Oe=(0,_react.useCallback)(()=>{const e=new Set(C.map(w));x(e)},[C,w]);const We=(0,_react.useCallback)(()=>{x(new Set)},[]);const K=M.requiredCount>0?Math.round(M.presentRequiredCount/M.requiredCount*100):M.totalCount>0?100:0;const He=K>=90?"OPTIMAL":K>=70?"WARNING":"CRITICAL";const Pe=K>=90?_sharedUi.gameUIColors.success:K>=70?_sharedUi.gameUIColors.warning:_sharedUi.gameUIColors.error;if(b){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.root,children:(0,_jsxRuntime.jsx)(_StorageKeyDetailScreen.StorageKeyDetailScreen,{storageKey:b,editBlockedReason:he(b),eventCount:G?.[b.key],onSave:e=>H(b,e),onViewHistory:A?()=>A(b.key):void 0,onDeleteKey:e=>ye(e,()=>te?.()),onHideKey:e=>{W([e]);te?.()},isPinned:S?.has(b.key)??false,onTogglePin:Z,applySafeAreaInset:fe})})}if(Ne&&a.length===0){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyState,children:[(0,_jsxRuntime.jsx)(_sharedUi.Database,{size:48,color:_sharedUi.night.color.textTertiary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyTitle,children:"Loading storage keys..."})]})}if(ge){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyState,children:[(0,_jsxRuntime.jsx)(_sharedUi.Database,{size:48,color:_sharedUi.gameUIColors.error}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.emptyTitle,{color:_sharedUi.gameUIColors.error}],children:"Error loading storage"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptySubtitle,children:ge.message})]})}const Ue=(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[d==="mmkv"&&c.length===0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyMMKVState,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyMMKVTitle,children:"No MMKV Instances Detected"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyMMKVSubtitle,children:"MMKV instances must be registered with registerMMKVInstance()"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyMMKVCode,children:`import { registerMMKVInstance } from '@buoy-gg/storage';
2
2
 
3
3
  const storage = createMMKV();
4
- registerMMKVInstance('mmkv.default', storage);`})]}),d==="mmkv"&&c.length>0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceNavbar,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceNavbarHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.instanceNavbarLabel,children:"INSTANCES"}),c.length>re&&(0,_jsxRuntime.jsx)(_sharedUi.ProBadge,{style:{transform:[{scale:.85}]}})]}),(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:styles.instanceNavbarScroll,children:[(p||c.length===1)&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{onPress:()=>se(null),testID:"buoy-storage-instance-all",accessibilityRole:"button",accessibilityLabel:`All ${_storageLabels.storageLabels.mmkv} instances`,style:[styles.instanceNavbarButton,l===null&&styles.instanceNavbarButtonActive],children:[(0,_jsxRuntime.jsx)(_sharedUi.HardDrive,{size:12,color:l===null?_sharedUi.night.color.text:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.instanceNavbarButtonText,l===null&&styles.instanceNavbarButtonTextActive],children:"All"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.instanceNavbarBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.instanceNavbarBadgeText,children:c.reduce((e,t)=>e+t.keyCount,0)})})]}),c.map((e,t)=>{const r=t>=re;return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:`buoy-storage-instance-${e.id}`,accessibilityRole:"button",accessibilityLabel:`MMKV instance ${e.id}`,onPress:()=>{if(r){T(true)}else{se(e.id)}},style:[styles.instanceNavbarButton,e.id===l&&styles.instanceNavbarButtonActive,{borderColor:r?_sharedUi.night.color.border:getInstanceColor(e.id)+"40",backgroundColor:e.id===l?getInstanceColor(e.id)+"20":_sharedUi.night.color.surfaceElevated,opacity:r?.5:1}],children:[(0,_jsxRuntime.jsx)(_sharedUi.HardDrive,{size:12,color:e.id===l?getInstanceColor(e.id):_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.instanceNavbarButtonText,e.id===l&&{color:getInstanceColor(e.id),fontWeight:"700"}],children:e.id}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.instanceNavbarBadge,e.id===l&&{backgroundColor:getInstanceColor(e.id)+"30"}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.instanceNavbarBadgeText,e.id===l&&{color:getInstanceColor(e.id)}],children:e.keyCount})})]},e.id)})]})]})]});const $e=(0,_jsxRuntime.jsx)(_StorageActionButtons.StorageActionButtons,{copyValue:Le,mmkvInstances:c.map(e=>({id:e.id,instance:e.instance})),activeStorageType:d,onClearComplete:h,isSelectMode:F,onToggleSelectMode:Ee,selectedCount:V.size});const Ge=F?(0,_jsxRuntime.jsx)(_SelectionActionBar.SelectionActionBar,{selectedKeys:ze,mmkvInstances:c.map(e=>({id:e.id,instance:e.instance})),onDeleteComplete:Ae,onHideKeys:W,onSelectAll:Oe,onClearSelection:We,totalVisibleKeys:C.length}):null;const Ye=Fe?(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.limitBanner,onPress:()=>T(true),activeOpacity:.8,testID:"buoy-storage-locked-banner",accessibilityRole:"button",children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.limitBannerContent,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.limitBannerLeft,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:16,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.limitBannerText,children:m?`${E} matching ${E===1?"key":"keys"} in locked storage`:`${E} keys locked`})]}),(0,_jsxRuntime.jsx)(_sharedUi.ProBadge,{})]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.limitBannerSubtext,children:m?"Upgrade to Pro to search your full storage":"Upgrade to Pro to unlock full storage access"})]}):null;const Je=(()=>{const e=a.some(r=>!(0,_sharedUi.isDevToolsStorageKey)(r.key));let t;if(m||!e){t=(0,_sharedUi.resolveListEmptyState)({subject:"keys",verb:"registered",search:m,total:e?1:0,waiting:{otto:"empty",title:"No storage keys",message:"Nothing is registered for this tool to read."}});if(m&&e){t={...t,message:"No keys match. Clear the search to see them."}}}else if(y==="missing"){t={otto:"thumbsup",title:"No missing keys",message:"All required keys are present"}}else if(y==="issues"){t={otto:"cool",title:"No issues found",message:"All storage keys are correctly configured"}}else{t={otto:"broken",title:"No valid keys found",message:"All keys have issues or are missing"}}return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{...t,testID:"buoy-storage-keys-empty"})})();const Xe=(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:D,onClose:()=>T(false),featureName:"Storage Keys"});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.root,children:[ae>0?(0,_jsxRuntime.jsx)(_StorageSaveNotice.StorageSaveNotice,{onDone:()=>ie(0)},ae):null,(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{testID:"buoy-storage-scroll",ref:we,onScroll:e=>{Me.current=e.nativeEvent.contentOffset.y},scrollEventThrottle:32,style:styles.scrollContainer,contentContainerStyle:styles.container,showsVerticalScrollIndicator:false,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.backgroundGrid}),(0,_jsxRuntime.jsx)(_StorageFilterCards.StorageFilterCards,{stats:k,tabStats:b,healthPercentage:K,healthStatus:He,healthColor:Ue,activeFilter:y,onFilterChange:be,activeStorageType:d,onStorageTypeChange:xe,showStatus:!L}),Pe,g.length>0?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.keysSection,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeader,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeaderLeft,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.sectionTitle,children:[y==="all"?"KEYS":y==="missing"?"MISSING KEYS":"ISSUES TO FIX",d!=="all"&&` (${d.toUpperCase()})`]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.countBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.countText,children:C.length})})]}),$e]}),Ge,(0,_jsxRuntime.jsx)(_StorageKeySection.StorageKeySection,{title:"",count:-1,keys:C,emptyMessage:"",isSelectMode:F,selectedKeys:V,onSelectionChange:Re,eventCountByKey:G,onViewHistory:A,onHideKey:e=>W([e]),onToggleKey:De,onDeleteKey:ye,editBlockedFor:he,pinnedKeys:S,onTogglePin:Z,onRowRef:ke,onOpenKey:Se}),Ye]}):Je,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.techFooter,children:"ASYNC STORAGE | MMKV | SECURE STORAGE BACKENDS"}),Xe]})]})}const styles=_reactNative.StyleSheet.create({root:{flex:1,minHeight:0},editorOverlay:{..._sharedUi.absoluteFill,zIndex:10},scrollContainer:{flex:1,backgroundColor:"transparent"},container:{padding:12,paddingBottom:120},backgroundGrid:{..._sharedUi.absoluteFill,opacity:.006,backgroundColor:_sharedUi.gameUIColors.info},techFooter:{fontSize:8,color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont,textAlign:"center",marginTop:20,letterSpacing:1,opacity:.5},keysSection:{marginTop:8,backgroundColor:_sharedUi.night.color.bg,borderRadius:12,padding:12,borderWidth:1,borderColor:_sharedUi.night.color.border},sectionHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:10,paddingBottom:6,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.separator},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:8},sectionTitle:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textSecondary,letterSpacing:.4,textTransform:"uppercase"},countBadge:{backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border},countText:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},emptyState:{alignItems:"center",justifyContent:"center",paddingVertical:48},emptyTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,marginTop:12,marginBottom:8},emptySubtitle:{fontSize:13,color:_sharedUi.night.color.textSecondary,textAlign:"center"},emptyMMKVState:{backgroundColor:_sharedUi.night.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:_sharedUi.night.color.border,marginTop:8,alignItems:"center"},emptyMMKVTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.night.color.text,marginBottom:6},emptyMMKVSubtitle:{fontSize:12,color:_sharedUi.night.color.textSecondary,textAlign:"center",marginBottom:12},emptyMMKVCode:{fontSize:10,fontFamily:_sharedUi.monoFont,color:_sharedUi.night.color.accent,backgroundColor:_sharedUi.night.color.bg,padding:12,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,alignSelf:"stretch"},instanceNavbar:{marginTop:12,marginBottom:8,backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:10,shadowColor:"#000",shadowOpacity:.08,shadowRadius:6,shadowOffset:{width:0,height:2}},instanceNavbarHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8,paddingLeft:2},instanceNavbarLabel:{fontSize:9,fontWeight:"700",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:1},instanceNavbarScroll:{gap:8,paddingRight:8},instanceNavbarButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8,backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,minWidth:90},instanceNavbarButtonActive:{borderWidth:1.5,shadowColor:"#000",shadowOpacity:.1,shadowRadius:4,shadowOffset:{width:0,height:1}},instanceNavbarButtonText:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.textSecondary,fontFamily:_sharedUi.monoFont,flex:1},instanceNavbarButtonTextActive:{fontWeight:"700",color:_sharedUi.night.color.text},instanceNavbarBadge:{backgroundColor:_sharedUi.night.color.bg,paddingHorizontal:6,paddingVertical:2,borderRadius:6,minWidth:24,alignItems:"center"},instanceNavbarBadgeText:{fontSize:10,fontWeight:"700",color:_sharedUi.night.color.textSecondary,fontFamily:_sharedUi.monoFont},clearSearchButton:{marginTop:16,paddingHorizontal:16,paddingVertical:8,backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border},clearSearchText:{fontSize:13,color:_sharedUi.night.color.text,fontWeight:"500"},limitBanner:{backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.accentBorderStrong,padding:12,marginTop:12},limitBannerContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:4},limitBannerLeft:{flexDirection:"row",alignItems:"center",gap:8},limitBannerText:{color:_sharedUi.night.color.text,fontSize:13,fontWeight:"600"},limitBannerSubtext:{color:_sharedUi.night.color.textTertiary,fontSize:11}});
4
+ registerMMKVInstance('mmkv.default', storage);`})]}),d==="mmkv"&&c.length>0&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceNavbar,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceNavbarHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.instanceNavbarLabel,children:"INSTANCES"}),c.length>re&&(0,_jsxRuntime.jsx)(_sharedUi.ProBadge,{style:{transform:[{scale:.85}]}})]}),(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:styles.instanceNavbarScroll,children:[(p||c.length===1)&&(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{onPress:()=>se(null),testID:"buoy-storage-instance-all",accessibilityRole:"button",accessibilityLabel:`All ${_storageLabels.storageLabels.mmkv} instances`,style:[styles.instanceNavbarButton,l===null&&styles.instanceNavbarButtonActive],children:[(0,_jsxRuntime.jsx)(_sharedUi.HardDrive,{size:12,color:l===null?_sharedUi.night.color.text:_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.instanceNavbarButtonText,l===null&&styles.instanceNavbarButtonTextActive],children:"All"}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.instanceNavbarBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.instanceNavbarBadgeText,children:c.reduce((e,t)=>e+t.keyCount,0)})})]}),c.map((e,t)=>{const r=t>=re;return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{testID:`buoy-storage-instance-${e.id}`,accessibilityRole:"button",accessibilityLabel:`MMKV instance ${e.id}`,onPress:()=>{if(r){T(true)}else{se(e.id)}},style:[styles.instanceNavbarButton,e.id===l&&styles.instanceNavbarButtonActive,{borderColor:r?_sharedUi.night.color.border:getInstanceColor(e.id)+"40",backgroundColor:e.id===l?getInstanceColor(e.id)+"20":_sharedUi.night.color.surfaceElevated,opacity:r?.5:1}],children:[(0,_jsxRuntime.jsx)(_sharedUi.HardDrive,{size:12,color:e.id===l?getInstanceColor(e.id):_sharedUi.night.color.textSecondary}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.instanceNavbarButtonText,e.id===l&&{color:getInstanceColor(e.id),fontWeight:"700"}],children:e.id}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.instanceNavbarBadge,e.id===l&&{backgroundColor:getInstanceColor(e.id)+"30"}],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.instanceNavbarBadgeText,e.id===l&&{color:getInstanceColor(e.id)}],children:e.keyCount})})]},e.id)})]})]})]});const $e=(0,_jsxRuntime.jsx)(_StorageActionButtons.StorageActionButtons,{copyValue:Le,mmkvInstances:c.map(e=>({id:e.id,instance:e.instance})),activeStorageType:d,onClearComplete:h,isSelectMode:F,onToggleSelectMode:Ee,selectedCount:V.size});const Ge=F?(0,_jsxRuntime.jsx)(_SelectionActionBar.SelectionActionBar,{selectedKeys:ze,mmkvInstances:c.map(e=>({id:e.id,instance:e.instance})),onDeleteComplete:Ae,onHideKeys:W,onSelectAll:Oe,onClearSelection:We,totalVisibleKeys:C.length}):null;const Ye=Fe?(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.limitBanner,onPress:()=>T(true),activeOpacity:.8,testID:"buoy-storage-locked-banner",accessibilityRole:"button",children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.limitBannerContent,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.limitBannerLeft,children:[(0,_jsxRuntime.jsx)(_sharedUi.Zap,{size:16,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.limitBannerText,children:m?`${E} matching ${E===1?"key":"keys"} in locked storage`:`${E} keys locked`})]}),(0,_jsxRuntime.jsx)(_sharedUi.ProBadge,{})]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.limitBannerSubtext,children:m?"Upgrade to Pro to search your full storage":"Upgrade to Pro to unlock full storage access"})]}):null;const Je=(()=>{const e=a.some(r=>!(0,_sharedUi.isDevToolsStorageKey)(r.key));let t;if(m||!e){t=(0,_sharedUi.resolveListEmptyState)({subject:"keys",verb:"registered",search:m,total:e?1:0,waiting:{otto:"empty",title:"No storage keys",message:"Nothing is registered for this tool to read."}});if(m&&e){t={...t,message:"No keys match. Clear the search to see them."}}}else if(y==="missing"){t={otto:"thumbsup",title:"No missing keys",message:"All required keys are present"}}else if(y==="issues"){t={otto:"cool",title:"No issues found",message:"All storage keys are correctly configured"}}else{t={otto:"broken",title:"No valid keys found",message:"All keys have issues or are missing"}}return(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{...t,testID:"buoy-storage-keys-empty"})})();const Xe=(0,_jsxRuntime.jsx)(_sharedUi.ProUpgradeModal,{visible:D,onClose:()=>T(false),featureName:"Storage Keys"});return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.root,children:[ae>0?(0,_jsxRuntime.jsx)(_StorageSaveNotice.StorageSaveNotice,{onDone:()=>ie(0)},ae):null,(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",testID:"buoy-storage-scroll",ref:we,onScroll:e=>{ke.current=e.nativeEvent.contentOffset.y},scrollEventThrottle:32,style:styles.scrollContainer,contentContainerStyle:styles.container,showsVerticalScrollIndicator:false,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.backgroundGrid}),(0,_jsxRuntime.jsx)(_StorageFilterCards.StorageFilterCards,{stats:M,tabStats:v,healthPercentage:K,healthStatus:He,healthColor:Pe,activeFilter:y,onFilterChange:ve,activeStorageType:d,onStorageTypeChange:xe,showStatus:!L}),Ue,g.length>0?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.keysSection,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeader,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.sectionHeaderLeft,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.sectionTitle,children:[y==="all"?"KEYS":y==="missing"?"MISSING KEYS":"ISSUES TO FIX",d!=="all"&&` (${d.toUpperCase()})`]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.countBadge,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.countText,children:C.length})})]}),$e]}),Ge,(0,_jsxRuntime.jsx)(_StorageKeySection.StorageKeySection,{title:"",count:-1,keys:C,emptyMessage:"",isSelectMode:F,selectedKeys:V,onSelectionChange:Re,eventCountByKey:G,onViewHistory:A,onHideKey:e=>W([e]),onToggleKey:De,onDeleteKey:ye,editBlockedFor:he,pinnedKeys:S,onTogglePin:Z,onRowRef:Me,onOpenKey:Se}),Ye]}):Je,(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.techFooter,children:"ASYNC STORAGE | MMKV | SECURE STORAGE BACKENDS"}),Xe]})]})}const styles=_reactNative.StyleSheet.create({root:{flex:1,minHeight:0},editorOverlay:{..._sharedUi.absoluteFill,zIndex:10},scrollContainer:{flex:1,backgroundColor:"transparent"},container:{padding:12,paddingBottom:120},backgroundGrid:{..._sharedUi.absoluteFill,opacity:.006,backgroundColor:_sharedUi.gameUIColors.info},techFooter:{fontSize:8,color:_sharedUi.night.color.textTertiary,fontFamily:_sharedUi.monoFont,textAlign:"center",marginTop:20,letterSpacing:1,opacity:.5},keysSection:{marginTop:8,backgroundColor:_sharedUi.night.color.bg,borderRadius:12,padding:12,borderWidth:1,borderColor:_sharedUi.night.color.border},sectionHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:10,paddingBottom:6,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.separator},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:8},sectionTitle:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.textSecondary,letterSpacing:.4,textTransform:"uppercase"},countBadge:{backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border},countText:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},emptyState:{alignItems:"center",justifyContent:"center",paddingVertical:48},emptyTitle:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,marginTop:12,marginBottom:8},emptySubtitle:{fontSize:13,color:_sharedUi.night.color.textSecondary,textAlign:"center"},emptyMMKVState:{backgroundColor:_sharedUi.night.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:_sharedUi.night.color.border,marginTop:8,alignItems:"center"},emptyMMKVTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.night.color.text,marginBottom:6},emptyMMKVSubtitle:{fontSize:12,color:_sharedUi.night.color.textSecondary,textAlign:"center",marginBottom:12},emptyMMKVCode:{fontSize:10,fontFamily:_sharedUi.monoFont,color:_sharedUi.night.color.accent,backgroundColor:_sharedUi.night.color.bg,padding:12,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,alignSelf:"stretch"},instanceNavbar:{marginTop:12,marginBottom:8,backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:10,shadowColor:"#000",shadowOpacity:.08,shadowRadius:6,shadowOffset:{width:0,height:2}},instanceNavbarHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8,paddingLeft:2},instanceNavbarLabel:{fontSize:9,fontWeight:"700",color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:1},instanceNavbarScroll:{gap:8,paddingRight:8},instanceNavbarButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8,backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.border,minWidth:90},instanceNavbarButtonActive:{borderWidth:1.5,shadowColor:"#000",shadowOpacity:.1,shadowRadius:4,shadowOffset:{width:0,height:1}},instanceNavbarButtonText:{fontSize:11,fontWeight:"600",color:_sharedUi.night.color.textSecondary,fontFamily:_sharedUi.monoFont,flex:1},instanceNavbarButtonTextActive:{fontWeight:"700",color:_sharedUi.night.color.text},instanceNavbarBadge:{backgroundColor:_sharedUi.night.color.bg,paddingHorizontal:6,paddingVertical:2,borderRadius:6,minWidth:24,alignItems:"center"},instanceNavbarBadgeText:{fontSize:10,fontWeight:"700",color:_sharedUi.night.color.textSecondary,fontFamily:_sharedUi.monoFont},clearSearchButton:{marginTop:16,paddingHorizontal:16,paddingVertical:8,backgroundColor:_sharedUi.night.color.surfaceElevated,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border},clearSearchText:{fontSize:13,color:_sharedUi.night.color.text,fontWeight:"500"},limitBanner:{backgroundColor:_sharedUi.night.color.surface,borderRadius:10,borderWidth:1,borderColor:_sharedUi.night.color.accentBorderStrong,padding:12,marginTop:12},limitBannerContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:4},limitBannerLeft:{flexDirection:"row",alignItems:"center",gap:8},limitBannerText:{color:_sharedUi.night.color.text,fontSize:13,fontWeight:"600"},limitBannerSubtext:{color:_sharedUi.night.color.textTertiary,fontSize:11}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MMKVInstanceSelector=MMKVInstanceSelector;var _storageLabels=require("../utils/storageLabels");var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _useMMKVInstances=require("../hooks/useMMKVInstances");var _mmkvAvailability=require("../utils/mmkvAvailability");var _jsxRuntime=require("react/jsx-runtime");function MMKVInstanceSelector({selectedInstanceId:t,onSelectInstance:r,showRefreshButton:n=true}){const[c,o]=(0,_react.useState)(false);const{instances:i,instanceCount:a,refresh:s}=(0,_useMMKVInstances.useMMKVInstances)(false);const l=i.find(e=>e.id===t);const d=e=>{r(e);o(false)};if(!(0,_mmkvAvailability.isMMKVAvailable)()){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.unavailableState,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.unavailableTitle,children:[_storageLabels.storageLabels.mmkv," Not Available"]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.unavailableDescription,children:(0,_mmkvAvailability.getMMKVUnavailableMessage)()})]})})}if(a===0){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyState,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateTitle,children:"No MMKV Instances Registered"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateDescription,children:"Register MMKV instances using registerMMKVInstance() to monitor them in dev tools."}),n&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.refreshButton,onPress:s,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.refreshButtonText,children:"\u21BB Refresh"})})]})})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.selectorButton,onPress:()=>o(true),activeOpacity:.7,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.selectorContent,children:l?(0,_jsxRuntime.jsx)(InstanceRow,{instance:l,isSelected:true}):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.placeholderText,children:"Select MMKV Instance"})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.dropdownArrow,children:"\u25BC"})]}),(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:c,transparent:true,animationType:"fade",onRequestClose:()=>o(false),children:(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.modalOverlay,activeOpacity:1,onPress:()=>o(false),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.dropdownContainer,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.dropdownHeader,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.dropdownTitle,children:["Select MMKV Instance (",a,")"]}),n&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.headerRefreshButton,onPress:s,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.headerRefreshText,children:"\u21BB"})})]}),(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:styles.dropdownList,children:i.map(e=>(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:[styles.dropdownItem,e.id===t&&styles.dropdownItemSelected],onPress:()=>d(e.id),activeOpacity:.7,children:(0,_jsxRuntime.jsx)(InstanceRow,{instance:e,isSelected:e.id===t})},e.id))})]})})})]})}function InstanceRow({instance:t,isSelected:r}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceRow,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceLeft,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.instanceId,r&&styles.instanceIdSelected],numberOfLines:1,children:t.id}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceBadges,children:[t.encrypted&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.badge,styles.badgeEncrypted],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.badgeText,children:"\u{1F512} Encrypted"})}),t.readOnly&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.badge,styles.badgeReadOnly],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.badgeText,children:"\u{1F441}\uFE0F Read-only"})})]})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceRight,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.keyCount,children:t.keyCount}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.keyCountLabel,children:"keys"})]})]})}const styles=_reactNative.StyleSheet.create({container:{marginBottom:12},unavailableState:{backgroundColor:_sharedUi.macOSColors.semantic.warning+"15",borderRadius:12,padding:20,borderWidth:1,borderColor:_sharedUi.macOSColors.semantic.warning+"40",alignItems:"center",gap:12},unavailableTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.macOSColors.semantic.warning},unavailableDescription:{fontSize:12,color:_sharedUi.night.color.textSecondary,textAlign:"center",lineHeight:18},emptyState:{backgroundColor:_sharedUi.night.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:_sharedUi.night.color.border,alignItems:"center",gap:12},emptyStateTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.night.color.text},emptyStateDescription:{fontSize:12,color:_sharedUi.night.color.textTertiary,textAlign:"center",lineHeight:18},refreshButton:{marginTop:8,paddingHorizontal:16,paddingVertical:8,backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorderStrong},refreshButtonText:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.accent},selectorButton:{backgroundColor:_sharedUi.night.color.surface,borderRadius:12,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between",shadowColor:"#000000",shadowOpacity:.03,shadowRadius:8,shadowOffset:{width:0,height:2}},selectorContent:{flex:1},placeholderText:{fontSize:13,color:_sharedUi.night.color.placeholder,fontStyle:"italic"},dropdownArrow:{fontSize:10,color:_sharedUi.night.color.textTertiary,marginLeft:8},modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center",padding:20},dropdownContainer:{backgroundColor:_sharedUi.night.color.surface,borderRadius:16,borderWidth:1,borderColor:_sharedUi.night.color.border,width:"100%",maxWidth:500,maxHeight:"70%",shadowColor:"#000000",shadowOpacity:.2,shadowRadius:20,shadowOffset:{width:0,height:10},overflow:"hidden"},dropdownHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.separator},dropdownTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.night.color.text},headerRefreshButton:{padding:4},headerRefreshText:{fontSize:18,color:_sharedUi.night.color.accent},dropdownList:{maxHeight:400},dropdownItem:{padding:12,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.separator},dropdownItemSelected:{backgroundColor:_sharedUi.night.color.accentSoft},instanceRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},instanceLeft:{flex:1,gap:6},instanceId:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},instanceIdSelected:{fontWeight:"600",color:_sharedUi.night.color.accent},instanceBadges:{flexDirection:"row",flexWrap:"wrap",gap:6},badge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4,borderWidth:1},badgeEncrypted:{backgroundColor:_sharedUi.macOSColors.semantic.success+"15",borderColor:_sharedUi.macOSColors.semantic.success+"40"},badgeReadOnly:{backgroundColor:_sharedUi.macOSColors.semantic.warning+"15",borderColor:_sharedUi.macOSColors.semantic.warning+"40"},badgeText:{fontSize:9,fontWeight:"500",color:_sharedUi.night.color.textSecondary},instanceRight:{alignItems:"flex-end"},keyCount:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},keyCountLabel:{fontSize:9,color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.MMKVInstanceSelector=MMKVInstanceSelector;var _storageLabels=require("../utils/storageLabels");var _react=require("react");var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _useMMKVInstances=require("../hooks/useMMKVInstances");var _mmkvAvailability=require("../utils/mmkvAvailability");var _jsxRuntime=require("react/jsx-runtime");function MMKVInstanceSelector({selectedInstanceId:t,onSelectInstance:r,showRefreshButton:n=true}){const[c,o]=(0,_react.useState)(false);const{instances:i,instanceCount:a,refresh:s}=(0,_useMMKVInstances.useMMKVInstances)(false);const l=i.find(e=>e.id===t);const d=e=>{r(e);o(false)};if(!(0,_mmkvAvailability.isMMKVAvailable)()){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.unavailableState,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.unavailableTitle,children:[_storageLabels.storageLabels.mmkv," Not Available"]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.unavailableDescription,children:(0,_mmkvAvailability.getMMKVUnavailableMessage)()})]})})}if(a===0){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.emptyState,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateTitle,children:"No MMKV Instances Registered"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.emptyStateDescription,children:"Register MMKV instances using registerMMKVInstance() to monitor them in dev tools."}),n&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.refreshButton,onPress:s,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.refreshButtonText,children:"\u21BB Refresh"})})]})})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{style:styles.selectorButton,onPress:()=>o(true),activeOpacity:.7,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.selectorContent,children:l?(0,_jsxRuntime.jsx)(InstanceRow,{instance:l,isSelected:true}):(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.placeholderText,children:"Select MMKV Instance"})}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.dropdownArrow,children:"\u25BC"})]}),(0,_jsxRuntime.jsx)(_reactNative.Modal,{visible:c,transparent:true,animationType:"fade",onRequestClose:()=>o(false),children:(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.modalOverlay,activeOpacity:1,onPress:()=>o(false),children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.dropdownContainer,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.dropdownHeader,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.dropdownTitle,children:["Select MMKV Instance (",a,")"]}),n&&(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:styles.headerRefreshButton,onPress:s,activeOpacity:.7,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.headerRefreshText,children:"\u21BB"})})]}),(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{keyboardShouldPersistTaps:"handled",style:styles.dropdownList,children:i.map(e=>(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{style:[styles.dropdownItem,e.id===t&&styles.dropdownItemSelected],onPress:()=>d(e.id),activeOpacity:.7,children:(0,_jsxRuntime.jsx)(InstanceRow,{instance:e,isSelected:e.id===t})},e.id))})]})})})]})}function InstanceRow({instance:t,isSelected:r}){return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceRow,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceLeft,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.instanceId,r&&styles.instanceIdSelected],numberOfLines:1,children:t.id}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceBadges,children:[t.encrypted&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.badge,styles.badgeEncrypted],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.badgeText,children:"\u{1F512} Encrypted"})}),t.readOnly&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:[styles.badge,styles.badgeReadOnly],children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.badgeText,children:"\u{1F441}\uFE0F Read-only"})})]})]}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.instanceRight,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.keyCount,children:t.keyCount}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.keyCountLabel,children:"keys"})]})]})}const styles=_reactNative.StyleSheet.create({container:{marginBottom:12},unavailableState:{backgroundColor:_sharedUi.macOSColors.semantic.warning+"15",borderRadius:12,padding:20,borderWidth:1,borderColor:_sharedUi.macOSColors.semantic.warning+"40",alignItems:"center",gap:12},unavailableTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.macOSColors.semantic.warning},unavailableDescription:{fontSize:12,color:_sharedUi.night.color.textSecondary,textAlign:"center",lineHeight:18},emptyState:{backgroundColor:_sharedUi.night.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:_sharedUi.night.color.border,alignItems:"center",gap:12},emptyStateTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.night.color.text},emptyStateDescription:{fontSize:12,color:_sharedUi.night.color.textTertiary,textAlign:"center",lineHeight:18},refreshButton:{marginTop:8,paddingHorizontal:16,paddingVertical:8,backgroundColor:_sharedUi.night.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:_sharedUi.night.color.accentBorderStrong},refreshButtonText:{fontSize:12,fontWeight:"600",color:_sharedUi.night.color.accent},selectorButton:{backgroundColor:_sharedUi.night.color.surface,borderRadius:12,borderWidth:1,borderColor:_sharedUi.night.color.border,padding:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between",shadowColor:"#000000",shadowOpacity:.03,shadowRadius:8,shadowOffset:{width:0,height:2}},selectorContent:{flex:1},placeholderText:{fontSize:13,color:_sharedUi.night.color.placeholder,fontStyle:"italic"},dropdownArrow:{fontSize:10,color:_sharedUi.night.color.textTertiary,marginLeft:8},modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center",padding:20},dropdownContainer:{backgroundColor:_sharedUi.night.color.surface,borderRadius:16,borderWidth:1,borderColor:_sharedUi.night.color.border,width:"100%",maxWidth:500,maxHeight:"70%",shadowColor:"#000000",shadowOpacity:.2,shadowRadius:20,shadowOffset:{width:0,height:10},overflow:"hidden"},dropdownHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.separator},dropdownTitle:{fontSize:14,fontWeight:"600",color:_sharedUi.night.color.text},headerRefreshButton:{padding:4},headerRefreshText:{fontSize:18,color:_sharedUi.night.color.accent},dropdownList:{maxHeight:400},dropdownItem:{padding:12,borderBottomWidth:1,borderBottomColor:_sharedUi.night.color.separator},dropdownItemSelected:{backgroundColor:_sharedUi.night.color.accentSoft},instanceRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},instanceLeft:{flex:1,gap:6},instanceId:{fontSize:13,fontWeight:"500",color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},instanceIdSelected:{fontWeight:"600",color:_sharedUi.night.color.accent},instanceBadges:{flexDirection:"row",flexWrap:"wrap",gap:6},badge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4,borderWidth:1},badgeEncrypted:{backgroundColor:_sharedUi.macOSColors.semantic.success+"15",borderColor:_sharedUi.macOSColors.semantic.success+"40"},badgeReadOnly:{backgroundColor:_sharedUi.macOSColors.semantic.warning+"15",borderColor:_sharedUi.macOSColors.semantic.warning+"40"},badgeText:{fontSize:9,fontWeight:"500",color:_sharedUi.night.color.textSecondary},instanceRight:{alignItems:"flex-end"},keyCount:{fontSize:16,fontWeight:"600",color:_sharedUi.night.color.text,fontFamily:_sharedUi.monoFont},keyCountLabel:{fontSize:9,color:_sharedUi.night.color.textTertiary,textTransform:"uppercase",letterSpacing:.5}});
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FREE_TIER_EVENT_LIMIT=void 0;exports.StorageModalWithTabs=StorageModalWithTabs;exports.StorageToolView=StorageToolView;var _react=require("react");var _reactNative=require("react-native");var _appAsyncStorage=_interopRequireDefault(require("../utils/appAsyncStorage"));var _sharedUi=require("@buoy-gg/shared-ui");var _StorageBrowserMode=require("./StorageBrowserMode");var _StorageTypeFilterBar=require("./StorageTypeFilterBar");var _clearAllStorage=require("../utils/clearAllStorage");var _useStorageEvents=require("../hooks/useStorageEvents");var _StorageEventDetailContent=require("./StorageEventDetailContent");var _StorageEventFilterView=require("./StorageEventFilterView");var _StorageEventCard=require("./StorageEventCard");var _license=require("@buoy-gg/license");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(o){return o&&o.__esModule?o:{default:o}}const FREE_TIER_EVENT_LIMIT=exports.FREE_TIER_EVENT_LIMIT=_sharedUi.TIER_LIMITS["storage.events"].free;const ASYNC_STORAGE_BACKEND={getItem:o=>_appAsyncStorage.default.getItem(o),setItem:(o,p)=>_appAsyncStorage.default.setItem(o,p)};const TAB_PERSISTENCE={storage:ASYNC_STORAGE_BACKEND,parse:o=>o==="browser"||o==="events"?o:void 0,serialize:o=>o};const BOOLEAN_PERSISTENCE={storage:ASYNC_STORAGE_BACKEND,parse:o=>o==="true",serialize:o=>o.toString()};const STRING_SET_PERSISTENCE={storage:ASYNC_STORAGE_BACKEND,parse:o=>new Set(JSON.parse(o)),serialize:o=>JSON.stringify(Array.from(o))};const IGNORED_PATTERNS_PERSISTENCE={...STRING_SET_PERSISTENCE,parse:o=>{const p=JSON.parse(o);if(!p.includes("@react_buoy"))p.push("@react_buoy");return new Set(p)}};function StorageModalWithTabs({visible:o,onClose:p,onBack:F,onMinimize:oe,enableSharedModalDimensions:ne=false,requiredStorageKeys:ae=[],inline:se=false,onTabChange:O,onRefresh:z,onEventSelect:C}){const De=(0,_license.useIsPro)();const I=(0,_sharedUi.useLimit)("storage.events");const[m,le]=(0,_sharedUi.usePersistedState)(_sharedUi.devToolsStorageKeys.storage.activeTab(),"browser",TAB_PERSISTENCE);(0,_react.useEffect)(()=>{O?.(m)},[m,O]);const[L,q]=(0,_react.useState)("");const[B,k]=(0,_react.useState)(null);const[M,P]=(0,_react.useState)(false);const[W,ie]=(0,_sharedUi.usePersistedState)(_sharedUi.devToolsStorageKeys.storage.isMonitoring(),true,BOOLEAN_PERSISTENCE);const{events:T,clearEvents:$,isCapturing:ce}=(0,_useStorageEvents.useStorageEvents)({enabled:W});const[A,b]=(0,_react.useState)(null);const[S,D]=(0,_react.useState)(null);const[c,d]=(0,_react.useState)(null);const[j,h]=(0,_react.useState)(0);const[x,_]=(0,_react.useState)(false);const[u,G]=(0,_sharedUi.usePersistedState)(_sharedUi.devToolsStorageKeys.storage.eventFilters(),new Set(["@react_buoy","@RNAsyncStorage","redux-persist","persist:"]),IGNORED_PATTERNS_PERSISTENCE);const[f,J]=(0,_react.useState)("all");const[g,de]=(0,_react.useState)(new Set(["async","mmkv","secure"]));const[ue,ge]=(0,_sharedUi.usePersistedState)(_sharedUi.devToolsStorageKeys.storage.pinnedKeys(),new Set,STRING_SET_PERSISTENCE);const _e=(0,_react.useRef)(null);const Q=W&&ce;const[R,ye]=(0,_react.useState)("bottomSheet");const pe=(0,_react.useCallback)(e=>{ye(e)},[]);const Se=(0,_react.useCallback)(()=>{ie(e=>!e)},[]);const he=(0,_react.useCallback)(()=>{$();b(null);h(0)},[$]);const fe=(0,_react.useCallback)(e=>{D(e);d(null)},[]);const U=(0,_react.useCallback)(()=>{D(null);d(null)},[]);const Y=(0,_react.useCallback)(e=>{G(t=>{const r=new Set(t);if(r.has(e)){r.delete(e)}else{r.add(e)}return r})},[]);const X=(0,_react.useCallback)(e=>{G(t=>new Set([...t,e]))},[]);const ve=(0,_react.useCallback)(e=>{ge(t=>{const r=new Set(t);if(r.has(e)){r.delete(e)}else{r.add(e)}return r})},[]);const me=(0,_react.useCallback)(()=>{_(!x)},[x]);const Te=(0,_react.useCallback)(e=>{de(t=>{const r=new Set(t);if(r.has(e)){r.delete(e)}else{r.add(e)}return r})},[]);const H=(0,_react.useRef)([]);const be=(0,_react.useCallback)(()=>{const e=H.current;return{timestamp:new Date().toISOString(),totalKeys:e.length,asyncStorage:e.filter(t=>t.storageType==="async").reduce((t,r)=>{t[r.key]=(0,_sharedUi.truncatePayload)(r.value);return t},{}),mmkv:e.filter(t=>t.storageType==="mmkv").reduce((t,r)=>{const n=r.instanceId||"default";if(!t[n])t[n]={};t[n][r.key]=(0,_sharedUi.truncatePayload)(r.value);return t},{}),secure:e.filter(t=>t.storageType==="secure").reduce((t,r)=>{t[r.key]=(0,_sharedUi.truncatePayload)(r.value);return t},{})}},[]);const Re=(0,_react.useCallback)(async()=>{_reactNative.Alert.alert("Clear Storage","Choose what to clear:",[{text:"Cancel",style:"cancel"},{text:"Clear App Storage",onPress:async()=>{try{await(0,_clearAllStorage.clearAllAppStorage)()}catch(e){_reactNative.Alert.alert("Error","Failed to clear app storage")}}},{text:"Clear All (Including Dev Tools)",style:"destructive",onPress:async()=>{try{await(0,_clearAllStorage.clearAllStorageIncludingDevTools)()}catch(e){_reactNative.Alert.alert("Error","Failed to clear all storage")}}}])},[]);const w=e=>{const t=(0,_sharedUi.parseValue)(e);if(t===null)return"null";if(t===void 0)return"undefined";if(Array.isArray(t))return"array";if(typeof t==="boolean")return"boolean";if(typeof t==="number")return"number";if(typeof t==="string")return"string";if(typeof t==="object")return"object";return"undefined"};const[Z,xe]=(0,_react.useState)([]);(0,_react.useEffect)(()=>{const e=async()=>{try{const t=await _appAsyncStorage.default.getAllKeys();xe([...t].sort())}catch(t){}};if(o){e()}},[o]);const Ee=(0,_react.useMemo)(()=>{const e=new Set(Z);T.forEach(t=>{if(t.data?.key){e.add(t.data.key)}});return Array.from(e).sort()},[T,Z]);const l=(0,_react.useMemo)(()=>{const e=new Map;T.forEach(t=>{if(!t.data?.key)return;const r=t.data.key;if(!g.has(t.storageType))return;const n=Array.from(u).some(v=>r.includes(v));if(n)return;const a=e.get(r);if(!a){e.set(r,{key:r,lastEvent:t,events:[t],totalOperations:1,currentValue:t.data.value,valueType:w(t.data.value),storageTypes:new Set([t.storageType])})}else{a.events.push(t);a.totalOperations++;a.storageTypes.add(t.storageType);if(t.timestamp>a.lastEvent.timestamp){a.lastEvent=t;a.currentValue=t.data.value;a.valueType=w(t.data.value)}}});return Array.from(e.values()).sort((t,r)=>r.lastEvent.timestamp.getTime()-t.lastEvent.timestamp.getTime())},[T,u,g]);const s=(0,_react.useMemo)(()=>{if(!A)return null;return l.find(e=>e.key===A)||null},[A,l]);const Ce=(0,_react.useMemo)(()=>{const e={};l.forEach(t=>{e[t.key]=t.totalOperations});return e},[l]);const Ie=(0,_react.useMemo)(()=>{const e={};l.forEach(t=>{e[t.key]=t.lastEvent.timestamp.getTime()});return e},[l]);const y=(0,_react.useMemo)(()=>{if(!S)return null;return l.find(e=>e.key===S)||null},[S,l]);(0,_react.useEffect)(()=>{if(!C)return;const e=s?s:c!==null?y:null;const t=s?j:c;if(!e||t==null)return;const r=[...e.events].sort((v,V)=>v.timestamp.getTime()-V.timestamp.getTime());const n=r[t];const a=r[t-1];if(n)C(n);if(a)C(a)},[C,s,j,y,c]);const E=(0,_react.useMemo)(()=>{return T.filter(e=>{if(!e.data?.key)return false;if(!g.has(e.storageType))return false;const t=e.data.key;return!Array.from(u).some(r=>t.includes(r))})},[T,u,g]);const ke=(0,_react.useMemo)(()=>(0,_StorageTypeFilterBar.countByStorageType)(E),[E]);const i=(0,_react.useMemo)(()=>{if(f==="all")return E;return E.filter(e=>e.storageType===f)},[E,f]);const je=(0,_react.useCallback)(()=>{return i.map(e=>({key:e.data?.key,action:e.action,value:(0,_sharedUi.truncatePayload)(e.data?.value),storageType:e.storageType,timestamp:e.timestamp.toISOString()}))},[i]);const we=(0,_react.useMemo)(()=>i.slice(0,I),[i,I]);const K=(0,_react.useMemo)(()=>Math.max(0,i.length-I),[i.length,I]);const Fe=.8;const Be=(0,_react.useCallback)(e=>e.id,[]);const ee=(0,_react.useCallback)(e=>{const t=l.find(a=>a.key===e.data?.key);if(!t)return;const r=[...t.events].sort((a,v)=>a.timestamp.getTime()-v.timestamp.getTime());const n=r.findIndex(a=>a.timestamp.getTime()===e.timestamp.getTime());b(t.key);h(n>=0?n:0)},[l]);const Me=(0,_react.useCallback)(({item:e})=>{const t={key:e.data?.key||"",lastAction:e.action,totalOperations:1,lastEventTimestamp:e.timestamp,storageTypes:new Set([e.storageType]),valueType:w(e.data?.value)};return(0,_jsxRuntime.jsx)(_StorageEventCard.StorageEventCard,{data:t,onPress:()=>ee(e),testID:`buoy-storage-event-${e.id}`})},[ee]);if(!o)return null;const Pe=ne?_sharedUi.devToolsStorageKeys.modal.root():_sharedUi.devToolsStorageKeys.storage.modal();const te=()=>{if(x){return(0,_jsxRuntime.jsx)(_StorageEventFilterView.StorageEventFilterView,{ignoredPatterns:u,onTogglePattern:Y,onAddPattern:X,availableKeys:Ee,enabledStorageTypes:g,onToggleStorageType:Te})}if(m==="browser"){if(S&&y){if(c!==null){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.contentWrapper,children:(0,_jsxRuntime.jsx)(_StorageEventDetailContent.StorageEventDetailContent,{conversation:y,selectedEventIndex:c,onEventIndexChange:d,disableInternalFooter:true})})}const t=[...y.events].sort((n,a)=>n.timestamp.getTime()-a.timestamp.getTime());const r=[...t].reverse();return(0,_jsxRuntime.jsx)(_reactNative.FlatList,{testID:"buoy-storage-history-list",style:styles.flexFill,data:r,keyExtractor:n=>n.id,renderItem:({item:n})=>{const a=t.findIndex(V=>V.timestamp.getTime()===n.timestamp.getTime());const v={key:n.data?.key||"",lastAction:n.action,totalOperations:1,lastEventTimestamp:n.timestamp,storageTypes:new Set([n.storageType]),valueType:w(n.data?.value)};return(0,_jsxRuntime.jsx)(_StorageEventCard.StorageEventCard,{data:v,onPress:()=>d(a>=0?a:0),testID:`buoy-storage-history-event-${n.id}`})},contentContainerStyle:styles.listContent,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),initialNumToRender:20})}return(0,_jsxRuntime.jsx)(_StorageBrowserMode.StorageBrowserMode,{requiredStorageKeys:ae,ignoredPatterns:u,onTogglePattern:Y,onAddPattern:X,searchQuery:L,storageDataRef:H,eventCountByKey:Ce,lastWriteByKey:Ie,onViewHistory:fe,enabledStorageTypes:g,pinnedKeys:ue,onTogglePin:ve,applySafeAreaInset:R==="bottomSheet",storageTypeFilter:f,onStorageTypeFilterChange:J,detailKey:B,onOpenKey:k,onCloseDetail:()=>k(null)})}if(s){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.contentWrapper,children:(0,_jsxRuntime.jsx)(_StorageEventDetailContent.StorageEventDetailContent,{conversation:s,selectedEventIndex:j,onEventIndexChange:h,disableInternalFooter:true})})}const e=(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.eventFilterBar,children:(0,_jsxRuntime.jsx)(_StorageTypeFilterBar.StorageTypeFilterBar,{active:f,onChange:J,counts:ke})});if(i.length===0){const t=f!=="all";return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.flexFill,children:[e,(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:"buoy-storage-events-empty",...!Q?{otto:"paused",title:"Event listener is paused",message:"Press play to start monitoring"}:t?{otto:"filtering",title:`No ${f} events`,message:"Other backends have events \u2014 pick All Types to see them"}:{otto:"listening",title:"No storage events yet",message:"Storage operations will appear here"}})]})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.flexFill,children:[e,(0,_jsxRuntime.jsx)(_reactNative.FlatList,{testID:"buoy-storage-events-list",style:styles.flexFill,data:we,renderItem:Me,keyExtractor:Be,onEndReachedThreshold:Fe,contentContainerStyle:styles.listContent,ListFooterComponent:K>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.lockedBannerContainer,children:(0,_jsxRuntime.jsx)(_sharedUi.ProFeatureBanner,{featureName:`${K} event${K>1?"s":""} locked`,description:"Upgrade to Pro to unlock full event history"})}):null,initialNumToRender:10,maxToRenderPerBatch:10,windowSize:10})]})};const N=s&&s.events.length>1?(0,_jsxRuntime.jsx)(_StorageEventDetailContent.StorageEventDetailFooter,{conversation:s,selectedEventIndex:j,onEventIndexChange:h,applySafeAreaInset:R==="bottomSheet"}):y&&c!==null&&y.events.length>1?(0,_jsxRuntime.jsx)(_StorageEventDetailContent.StorageEventDetailFooter,{conversation:y,selectedEventIndex:c,onEventIndexChange:d,applySafeAreaInset:R==="bottomSheet"}):null;const Ae=x?()=>_(false):c!==null?()=>d(null):S?U:s?()=>{b(null);h(0)}:F;const re=x?(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:()=>_(false)}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"Filters"})]}):S?(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:c!==null?()=>d(null):U}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:`${S} History`,centered:true})]}):s?(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:()=>{b(null);h(0)}}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:s.key})]}):B?(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:()=>k(null)}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:B.key,centered:true,testID:"buoy-storage-detail-title"})]}):(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[F&&(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:F}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"",children:M?(0,_jsxRuntime.jsx)(_sharedUi.SearchBar,{value:L,onChange:q,onClear:()=>{q("");P(false)},placeholder:"Search storage keys...",testID:"buoy-storage-search",autoFocus:true,onSubmitEditing:()=>P(false),returnKeyType:"search",containerStyle:styles.headerSearchContainer}):(0,_jsxRuntime.jsx)(_sharedUi.TabSelector,{tabs:[{key:"browser",label:"Storage"},{key:"events",label:`Events${i.length>0?` (${i.length})`:""}`}],activeTab:m,testIDPrefix:"buoy-storage-tab",onTabChange:e=>{le(e);D(null);d(null);b(null);h(0);k(null)}})}),(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader.Actions,{children:[z&&!M?(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:z,style:styles.iconButton,testID:"buoy-storage-refresh",accessibilityLabel:"Refresh storage",accessibilityRole:"button",children:(0,_jsxRuntime.jsx)(_sharedUi.RefreshCw,{size:14,color:_sharedUi.night.color.textSecondary})}):null,(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:me,testID:"buoy-storage-filters",accessibilityLabel:"Storage filters",accessibilityRole:"button",style:[styles.iconButton,(u.size>0||g.size<3)&&styles.activeFilterButton],children:(0,_jsxRuntime.jsx)(_sharedUi.Filter,{size:14,color:u.size>0||g.size<3?_sharedUi.night.color.accent:_sharedUi.night.color.textSecondary})}),m==="browser"&&!M&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>P(true),testID:"buoy-storage-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Search,{size:14,color:_sharedUi.night.color.textSecondary})}),(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:be,disabled:H.current.length===0,buttonStyle:styles.iconButton,testID:"buoy-storage-copy"})]}),m==="events"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:je,disabled:i.length===0,buttonStyle:styles.iconButton,testID:"buoy-storage-events-copy"}),(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:Q,onToggle:Se,accessibilityLabel:"Toggle storage event monitoring",testID:"buoy-storage-power"}),(0,_jsxRuntime.jsx)(_sharedUi.ToolbarClearButton,{onPress:he,buttonStyle:styles.iconButton,testID:"buoy-storage-clear-events"})]})]})]});if(se){return(0,_jsxRuntime.jsx)(_sharedUi.TickProvider,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inlineRoot,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.inlineHeader,..._sharedUi.windowDragProps,children:re}),te(),N]})})}return(0,_jsxRuntime.jsx)(_sharedUi.TickProvider,{children:(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:o,onClose:p,onBack:Ae,onMinimize:oe,persistenceKey:Pe,header:{showToggleButton:true,customContent:re},onModeChange:pe,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:N,footerHeight:N?68:0,disableScrollWrapper:true,children:te()})})}function StorageToolView(o={}){return(0,_jsxRuntime.jsx)(StorageModalWithTabs,{...o,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"},headerSearchContainer:{flex:1},flexFill:{flex:1},iconButton:{width:32,height:32,borderRadius:8,backgroundColor:_sharedUi.night.color.buttonSurface,borderWidth:1,borderColor:_sharedUi.night.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:_sharedUi.night.color.accentSoft,borderColor:_sharedUi.night.color.accentBorderStrong},separator:{height:8},listContent:{paddingVertical:6},lockedBannerContainer:{marginTop:8,marginHorizontal:16},eventFilterBar:{paddingHorizontal:12,paddingTop:8,paddingBottom:4},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:_sharedUi.night.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:_sharedUi.monoFont,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:_sharedUi.night.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:_sharedUi.monoFont},eventNavigation:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:8},navButton:{padding:4,borderRadius:4},navButtonDisabled:{opacity:.3},eventCounter:{color:_sharedUi.night.color.text,fontSize:12,fontWeight:"600",fontFamily:_sharedUi.monoFont,paddingHorizontal:8},headerTopRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12},keyNameContainer:{flex:1,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:10,paddingVertical:4,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border,height:28},keyNameText:{flex:1,fontSize:13,fontWeight:"600",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont,letterSpacing:.5},contentWrapper:{flex:1}});
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FREE_TIER_EVENT_LIMIT=void 0;exports.StorageModalWithTabs=StorageModalWithTabs;exports.StorageToolView=StorageToolView;var _react=require("react");var _reactNative=require("react-native");var _appAsyncStorage=_interopRequireDefault(require("../utils/appAsyncStorage"));var _sharedUi=require("@buoy-gg/shared-ui");var _StorageBrowserMode=require("./StorageBrowserMode");var _StorageTypeFilterBar=require("./StorageTypeFilterBar");var _clearAllStorage=require("../utils/clearAllStorage");var _useStorageEvents=require("../hooks/useStorageEvents");var _StorageEventDetailContent=require("./StorageEventDetailContent");var _StorageEventFilterView=require("./StorageEventFilterView");var _StorageEventCard=require("./StorageEventCard");var _license=require("@buoy-gg/license");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(o){return o&&o.__esModule?o:{default:o}}const FREE_TIER_EVENT_LIMIT=exports.FREE_TIER_EVENT_LIMIT=_sharedUi.TIER_LIMITS["storage.events"].free;const ASYNC_STORAGE_BACKEND={getItem:o=>_appAsyncStorage.default.getItem(o),setItem:(o,p)=>_appAsyncStorage.default.setItem(o,p)};const TAB_PERSISTENCE={storage:ASYNC_STORAGE_BACKEND,parse:o=>o==="browser"||o==="events"?o:void 0,serialize:o=>o};const BOOLEAN_PERSISTENCE={storage:ASYNC_STORAGE_BACKEND,parse:o=>o==="true",serialize:o=>o.toString()};const STRING_SET_PERSISTENCE={storage:ASYNC_STORAGE_BACKEND,parse:o=>new Set(JSON.parse(o)),serialize:o=>JSON.stringify(Array.from(o))};const IGNORED_PATTERNS_PERSISTENCE={...STRING_SET_PERSISTENCE,parse:o=>{const p=JSON.parse(o);if(!p.includes("@react_buoy"))p.push("@react_buoy");return new Set(p)}};function StorageModalWithTabs({visible:o,onClose:p,onBack:F,onMinimize:oe,enableSharedModalDimensions:ne=false,requiredStorageKeys:ae=[],inline:se=false,onTabChange:O,onRefresh:z,onEventSelect:C}){const De=(0,_license.useIsPro)();const I=(0,_sharedUi.useLimit)("storage.events");const[m,le]=(0,_sharedUi.usePersistedState)(_sharedUi.devToolsStorageKeys.storage.activeTab(),"browser",TAB_PERSISTENCE);(0,_react.useEffect)(()=>{O?.(m)},[m,O]);const[L,q]=(0,_react.useState)("");const[B,k]=(0,_react.useState)(null);const[P,M]=(0,_react.useState)(false);const[W,ie]=(0,_sharedUi.usePersistedState)(_sharedUi.devToolsStorageKeys.storage.isMonitoring(),true,BOOLEAN_PERSISTENCE);const{events:T,clearEvents:$,isCapturing:ce}=(0,_useStorageEvents.useStorageEvents)({enabled:W});const[A,b]=(0,_react.useState)(null);const[S,D]=(0,_react.useState)(null);const[c,d]=(0,_react.useState)(null);const[j,h]=(0,_react.useState)(0);const[x,_]=(0,_react.useState)(false);const[u,G]=(0,_sharedUi.usePersistedState)(_sharedUi.devToolsStorageKeys.storage.eventFilters(),new Set(["@react_buoy","@RNAsyncStorage","redux-persist","persist:"]),IGNORED_PATTERNS_PERSISTENCE);const[f,J]=(0,_react.useState)("all");const[g,de]=(0,_react.useState)(new Set(["async","mmkv","secure"]));const[ue,ge]=(0,_sharedUi.usePersistedState)(_sharedUi.devToolsStorageKeys.storage.pinnedKeys(),new Set,STRING_SET_PERSISTENCE);const _e=(0,_react.useRef)(null);const Q=W&&ce;const[R,ye]=(0,_react.useState)("bottomSheet");const pe=(0,_react.useCallback)(e=>{ye(e)},[]);const Se=(0,_react.useCallback)(()=>{ie(e=>!e)},[]);const he=(0,_react.useCallback)(()=>{$();b(null);h(0)},[$]);const fe=(0,_react.useCallback)(e=>{D(e);d(null)},[]);const U=(0,_react.useCallback)(()=>{D(null);d(null)},[]);const Y=(0,_react.useCallback)(e=>{G(t=>{const r=new Set(t);if(r.has(e)){r.delete(e)}else{r.add(e)}return r})},[]);const X=(0,_react.useCallback)(e=>{G(t=>new Set([...t,e]))},[]);const ve=(0,_react.useCallback)(e=>{ge(t=>{const r=new Set(t);if(r.has(e)){r.delete(e)}else{r.add(e)}return r})},[]);const me=(0,_react.useCallback)(()=>{_(!x)},[x]);const Te=(0,_react.useCallback)(e=>{de(t=>{const r=new Set(t);if(r.has(e)){r.delete(e)}else{r.add(e)}return r})},[]);const H=(0,_react.useRef)([]);const be=(0,_react.useCallback)(()=>{const e=H.current;return{timestamp:new Date().toISOString(),totalKeys:e.length,asyncStorage:e.filter(t=>t.storageType==="async").reduce((t,r)=>{t[r.key]=(0,_sharedUi.truncatePayload)(r.value);return t},{}),mmkv:e.filter(t=>t.storageType==="mmkv").reduce((t,r)=>{const n=r.instanceId||"default";if(!t[n])t[n]={};t[n][r.key]=(0,_sharedUi.truncatePayload)(r.value);return t},{}),secure:e.filter(t=>t.storageType==="secure").reduce((t,r)=>{t[r.key]=(0,_sharedUi.truncatePayload)(r.value);return t},{})}},[]);const Re=(0,_react.useCallback)(async()=>{_reactNative.Alert.alert("Clear Storage","Choose what to clear:",[{text:"Cancel",style:"cancel"},{text:"Clear App Storage",onPress:async()=>{try{await(0,_clearAllStorage.clearAllAppStorage)()}catch(e){_reactNative.Alert.alert("Error","Failed to clear app storage")}}},{text:"Clear All (Including Dev Tools)",style:"destructive",onPress:async()=>{try{await(0,_clearAllStorage.clearAllStorageIncludingDevTools)()}catch(e){_reactNative.Alert.alert("Error","Failed to clear all storage")}}}])},[]);const w=e=>{const t=(0,_sharedUi.parseValue)(e);if(t===null)return"null";if(t===void 0)return"undefined";if(Array.isArray(t))return"array";if(typeof t==="boolean")return"boolean";if(typeof t==="number")return"number";if(typeof t==="string")return"string";if(typeof t==="object")return"object";return"undefined"};const[Z,xe]=(0,_react.useState)([]);(0,_react.useEffect)(()=>{const e=async()=>{try{const t=await _appAsyncStorage.default.getAllKeys();xe([...t].sort())}catch(t){}};if(o){e()}},[o]);const Ee=(0,_react.useMemo)(()=>{const e=new Set(Z);T.forEach(t=>{if(t.data?.key){e.add(t.data.key)}});return Array.from(e).sort()},[T,Z]);const l=(0,_react.useMemo)(()=>{const e=new Map;T.forEach(t=>{if(!t.data?.key)return;const r=t.data.key;if(!g.has(t.storageType))return;const n=Array.from(u).some(v=>r.includes(v));if(n)return;const a=e.get(r);if(!a){e.set(r,{key:r,lastEvent:t,events:[t],totalOperations:1,currentValue:t.data.value,valueType:w(t.data.value),storageTypes:new Set([t.storageType])})}else{a.events.push(t);a.totalOperations++;a.storageTypes.add(t.storageType);if(t.timestamp>a.lastEvent.timestamp){a.lastEvent=t;a.currentValue=t.data.value;a.valueType=w(t.data.value)}}});return Array.from(e.values()).sort((t,r)=>r.lastEvent.timestamp.getTime()-t.lastEvent.timestamp.getTime())},[T,u,g]);const s=(0,_react.useMemo)(()=>{if(!A)return null;return l.find(e=>e.key===A)||null},[A,l]);const Ce=(0,_react.useMemo)(()=>{const e={};l.forEach(t=>{e[t.key]=t.totalOperations});return e},[l]);const Ie=(0,_react.useMemo)(()=>{const e={};l.forEach(t=>{e[t.key]=t.lastEvent.timestamp.getTime()});return e},[l]);const y=(0,_react.useMemo)(()=>{if(!S)return null;return l.find(e=>e.key===S)||null},[S,l]);(0,_react.useEffect)(()=>{if(!C)return;const e=s?s:c!==null?y:null;const t=s?j:c;if(!e||t==null)return;const r=[...e.events].sort((v,V)=>v.timestamp.getTime()-V.timestamp.getTime());const n=r[t];const a=r[t-1];if(n)C(n);if(a)C(a)},[C,s,j,y,c]);const E=(0,_react.useMemo)(()=>{return T.filter(e=>{if(!e.data?.key)return false;if(!g.has(e.storageType))return false;const t=e.data.key;return!Array.from(u).some(r=>t.includes(r))})},[T,u,g]);const ke=(0,_react.useMemo)(()=>(0,_StorageTypeFilterBar.countByStorageType)(E),[E]);const i=(0,_react.useMemo)(()=>{if(f==="all")return E;return E.filter(e=>e.storageType===f)},[E,f]);const je=(0,_react.useCallback)(()=>{return i.map(e=>({key:e.data?.key,action:e.action,value:(0,_sharedUi.truncatePayload)(e.data?.value),storageType:e.storageType,timestamp:e.timestamp.toISOString()}))},[i]);const we=(0,_react.useMemo)(()=>i.slice(0,I),[i,I]);const K=(0,_react.useMemo)(()=>Math.max(0,i.length-I),[i.length,I]);const Fe=.8;const Be=(0,_react.useCallback)(e=>e.id,[]);const ee=(0,_react.useCallback)(e=>{const t=l.find(a=>a.key===e.data?.key);if(!t)return;const r=[...t.events].sort((a,v)=>a.timestamp.getTime()-v.timestamp.getTime());const n=r.findIndex(a=>a.timestamp.getTime()===e.timestamp.getTime());b(t.key);h(n>=0?n:0)},[l]);const Pe=(0,_react.useCallback)(({item:e})=>{const t={key:e.data?.key||"",lastAction:e.action,totalOperations:1,lastEventTimestamp:e.timestamp,storageTypes:new Set([e.storageType]),valueType:w(e.data?.value)};return(0,_jsxRuntime.jsx)(_StorageEventCard.StorageEventCard,{data:t,onPress:()=>ee(e),testID:`buoy-storage-event-${e.id}`})},[ee]);if(!o)return null;const Me=ne?_sharedUi.devToolsStorageKeys.modal.root():_sharedUi.devToolsStorageKeys.storage.modal();const te=()=>{if(x){return(0,_jsxRuntime.jsx)(_StorageEventFilterView.StorageEventFilterView,{ignoredPatterns:u,onTogglePattern:Y,onAddPattern:X,availableKeys:Ee,enabledStorageTypes:g,onToggleStorageType:Te})}if(m==="browser"){if(S&&y){if(c!==null){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.contentWrapper,children:(0,_jsxRuntime.jsx)(_StorageEventDetailContent.StorageEventDetailContent,{conversation:y,selectedEventIndex:c,onEventIndexChange:d,disableInternalFooter:true})})}const t=[...y.events].sort((n,a)=>n.timestamp.getTime()-a.timestamp.getTime());const r=[...t].reverse();return(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",testID:"buoy-storage-history-list",style:styles.flexFill,data:r,keyExtractor:n=>n.id,renderItem:({item:n})=>{const a=t.findIndex(V=>V.timestamp.getTime()===n.timestamp.getTime());const v={key:n.data?.key||"",lastAction:n.action,totalOperations:1,lastEventTimestamp:n.timestamp,storageTypes:new Set([n.storageType]),valueType:w(n.data?.value)};return(0,_jsxRuntime.jsx)(_StorageEventCard.StorageEventCard,{data:v,onPress:()=>d(a>=0?a:0),testID:`buoy-storage-history-event-${n.id}`})},contentContainerStyle:styles.listContent,ItemSeparatorComponent:()=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.separator}),initialNumToRender:20})}return(0,_jsxRuntime.jsx)(_StorageBrowserMode.StorageBrowserMode,{requiredStorageKeys:ae,ignoredPatterns:u,onTogglePattern:Y,onAddPattern:X,searchQuery:L,storageDataRef:H,eventCountByKey:Ce,lastWriteByKey:Ie,onViewHistory:fe,enabledStorageTypes:g,pinnedKeys:ue,onTogglePin:ve,applySafeAreaInset:R==="bottomSheet",storageTypeFilter:f,onStorageTypeFilterChange:J,detailKey:B,onOpenKey:k,onCloseDetail:()=>k(null)})}if(s){return(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.contentWrapper,children:(0,_jsxRuntime.jsx)(_StorageEventDetailContent.StorageEventDetailContent,{conversation:s,selectedEventIndex:j,onEventIndexChange:h,disableInternalFooter:true})})}const e=(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.eventFilterBar,children:(0,_jsxRuntime.jsx)(_StorageTypeFilterBar.StorageTypeFilterBar,{active:f,onChange:J,counts:ke})});if(i.length===0){const t=f!=="all";return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.flexFill,children:[e,(0,_jsxRuntime.jsx)(_sharedUi.ToolEmptyState,{testID:"buoy-storage-events-empty",...!Q?{otto:"paused",title:"Event listener is paused",message:"Press play to start monitoring"}:t?{otto:"filtering",title:`No ${f} events`,message:"Other backends have events \u2014 pick All Types to see them"}:{otto:"listening",title:"No storage events yet",message:"Storage operations will appear here"}})]})}return(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.flexFill,children:[e,(0,_jsxRuntime.jsx)(_reactNative.FlatList,{keyboardShouldPersistTaps:"handled",testID:"buoy-storage-events-list",style:styles.flexFill,data:we,renderItem:Pe,keyExtractor:Be,onEndReachedThreshold:Fe,contentContainerStyle:styles.listContent,ListFooterComponent:K>0?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.lockedBannerContainer,children:(0,_jsxRuntime.jsx)(_sharedUi.ProFeatureBanner,{featureName:`${K} event${K>1?"s":""} locked`,description:"Upgrade to Pro to unlock full event history"})}):null,initialNumToRender:10,maxToRenderPerBatch:10,windowSize:10})]})};const N=s&&s.events.length>1?(0,_jsxRuntime.jsx)(_StorageEventDetailContent.StorageEventDetailFooter,{conversation:s,selectedEventIndex:j,onEventIndexChange:h,applySafeAreaInset:R==="bottomSheet"}):y&&c!==null&&y.events.length>1?(0,_jsxRuntime.jsx)(_StorageEventDetailContent.StorageEventDetailFooter,{conversation:y,selectedEventIndex:c,onEventIndexChange:d,applySafeAreaInset:R==="bottomSheet"}):null;const Ae=x?()=>_(false):c!==null?()=>d(null):S?U:s?()=>{b(null);h(0)}:F;const re=x?(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:()=>_(false)}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"Filters"})]}):S?(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:c!==null?()=>d(null):U}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:`${S} History`,centered:true})]}):s?(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:()=>{b(null);h(0)}}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:s.key})]}):B?(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:()=>k(null)}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:B.key,centered:true,testID:"buoy-storage-detail-title"})]}):(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader,{children:[F&&(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Navigation,{onBack:F}),(0,_jsxRuntime.jsx)(_sharedUi.ModalHeader.Content,{title:"",children:P?(0,_jsxRuntime.jsx)(_sharedUi.SearchBar,{value:L,onChange:q,onClear:()=>{q("");M(false)},placeholder:"Search storage keys...",testID:"buoy-storage-search",autoFocus:true,onSubmitEditing:()=>M(false),returnKeyType:"search",containerStyle:styles.headerSearchContainer}):(0,_jsxRuntime.jsx)(_sharedUi.TabSelector,{tabs:[{key:"browser",label:"Storage"},{key:"events",label:`Events${i.length>0?` (${i.length})`:""}`}],activeTab:m,testIDPrefix:"buoy-storage-tab",onTabChange:e=>{le(e);D(null);d(null);b(null);h(0);k(null)}})}),(0,_jsxRuntime.jsxs)(_sharedUi.ModalHeader.Actions,{children:[z&&!P?(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:z,style:styles.iconButton,testID:"buoy-storage-refresh",accessibilityLabel:"Refresh storage",accessibilityRole:"button",children:(0,_jsxRuntime.jsx)(_sharedUi.RefreshCw,{size:14,color:_sharedUi.night.color.textSecondary})}):null,(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:me,testID:"buoy-storage-filters",accessibilityLabel:"Storage filters",accessibilityRole:"button",style:[styles.iconButton,(u.size>0||g.size<3)&&styles.activeFilterButton],children:(0,_jsxRuntime.jsx)(_sharedUi.Filter,{size:14,color:u.size>0||g.size<3?_sharedUi.night.color.accent:_sharedUi.night.color.textSecondary})}),m==="browser"&&!P&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{onPress:()=>M(true),testID:"buoy-storage-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",style:styles.iconButton,children:(0,_jsxRuntime.jsx)(_sharedUi.Search,{size:14,color:_sharedUi.night.color.textSecondary})}),(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:be,disabled:H.current.length===0,buttonStyle:styles.iconButton,testID:"buoy-storage-copy"})]}),m==="events"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_sharedUi.ToolbarCopyButton,{value:je,disabled:i.length===0,buttonStyle:styles.iconButton,testID:"buoy-storage-events-copy"}),(0,_jsxRuntime.jsx)(_sharedUi.PowerToggleButton,{isEnabled:Q,onToggle:Se,accessibilityLabel:"Toggle storage event monitoring",testID:"buoy-storage-power"}),(0,_jsxRuntime.jsx)(_sharedUi.ToolbarClearButton,{onPress:he,buttonStyle:styles.iconButton,testID:"buoy-storage-clear-events"})]})]})]});if(se){return(0,_jsxRuntime.jsx)(_sharedUi.TickProvider,{children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.inlineRoot,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.inlineHeader,..._sharedUi.windowDragProps,children:re}),te(),N]})})}return(0,_jsxRuntime.jsx)(_sharedUi.TickProvider,{children:(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:o,onClose:p,onBack:Ae,onMinimize:oe,persistenceKey:Me,header:{showToggleButton:true,customContent:re},onModeChange:pe,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:N,footerHeight:N?68:0,disableScrollWrapper:true,children:te()})})}function StorageToolView(o={}){return(0,_jsxRuntime.jsx)(StorageModalWithTabs,{...o,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"},headerSearchContainer:{flex:1},flexFill:{flex:1},iconButton:{width:32,height:32,borderRadius:8,backgroundColor:_sharedUi.night.color.buttonSurface,borderWidth:1,borderColor:_sharedUi.night.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:_sharedUi.night.color.accentSoft,borderColor:_sharedUi.night.color.accentBorderStrong},separator:{height:8},listContent:{paddingVertical:6},lockedBannerContainer:{marginTop:8,marginHorizontal:16},eventFilterBar:{paddingHorizontal:12,paddingTop:8,paddingBottom:4},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:_sharedUi.night.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:_sharedUi.monoFont,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:_sharedUi.night.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:_sharedUi.monoFont},eventNavigation:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:8},navButton:{padding:4,borderRadius:4},navButtonDisabled:{opacity:.3},eventCounter:{color:_sharedUi.night.color.text,fontSize:12,fontWeight:"600",fontFamily:_sharedUi.monoFont,paddingHorizontal:8},headerTopRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12},keyNameContainer:{flex:1,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:_sharedUi.night.color.surfaceElevated,paddingHorizontal:10,paddingVertical:4,borderRadius:6,borderWidth:1,borderColor:_sharedUi.night.color.border,height:28},keyNameText:{flex:1,fontSize:13,fontWeight:"600",color:_sharedUi.night.color.accent,fontFamily:_sharedUi.monoFont,letterSpacing:.5},contentWrapper:{flex:1}});
@@ -1,4 +1,4 @@
1
1
  "use strict";import{storageLabels as wt}from"../utils/storageLabels";import{useMemo as S,useCallback as b,useState as N,useEffect as A,useRef as ie}from"react";import{StyleSheet as It,Text as m,View as f,TouchableOpacity as ae,ScrollView as Re,Alert as le}from"react-native";import{absoluteFill as Ae,useLimit as Ee,TIER_LIMITS as _t,monoFont as W}from"@buoy-gg/shared-ui";import{Database as Le,Zap as Mt,ProBadge as ze,ProUpgradeModal as Kt,ToolEmptyState as xt,resolveListEmptyState as Bt}from"@buoy-gg/shared-ui";import{isDevToolsStorageKey as h}from"@buoy-gg/shared-ui";import{StorageKeySection as Nt,storageRowId as De}from"./StorageKeySection";import{StorageKeyDetailScreen as qt}from"./StorageKeyDetailScreen";import{StorageFilterCards as Vt}from"./StorageFilterCards";import{useAsyncStorageKeys as Rt}from"../hooks/useAsyncStorageKeys";import{addListener as At}from"../utils/AsyncStorageListener";import{useMultiMMKVKeys as Et}from"../hooks/useMMKVKeys";import{useSecureStoreKeys as Lt}from"../hooks/useSecureStoreKeys";import{useMMKVInstances as zt}from"../hooks/useMMKVInstances";import{StorageSaveNotice as Dt}from"./StorageSaveNotice";import{StorageActionButtons as Ft}from"./StorageActionButtons";import{SelectionActionBar as Wt}from"./SelectionActionBar";import{addMMKVListener as Ot}from"../utils/MMKVListener";import{onStorageBrowserRefresh as Ht}from"../utils/storageBrowserRefresh";import{deleteStorageKeys as Pt}from"../utils/deleteStorageKeys";import{setStorageValue as $t,storageEditBlockedReason as Ut}from"../utils/setStorageValue";import{gameUIColors as E,macOSColors as J,night as s,HardDrive as Fe}from"@buoy-gg/shared-ui";import{useIsPro as jt}from"@buoy-gg/license";import{jsx as a,jsxs as d,Fragment as Gt}from"react/jsx-runtime";const We=[J.semantic.info,J.semantic.success,J.semantic.warning,J.semantic.debug,"#FF6B9D","#00D9FF"];function L(z){const ce=z.split("").reduce((O,de)=>O+de.charCodeAt(0),0);return We[ce%We.length]}export const FREE_TIER_KEY_LIMIT=_t["storage.keys"].free;export function GameUIStorageBrowser({requiredStorageKeys:z=[],showFilters:ce=false,ignoredPatterns:O=new Set(["@react_buoy"]),onTogglePattern:de,onAddPattern:ue,searchQuery:w="",storageDataRef:X,eventCountByKey:ge,lastWriteByKey:Yt,onViewHistory:Z,enabledStorageTypes:H,statusFilter:ye,onStatusFilterChange:me,onStatusCountsChange:fe,pinnedKeys:_,onTogglePin:he,storageTypeFilter:pe,onStorageTypeFilterChange:Se,applySafeAreaInset:Oe,detailKey:P=null,onOpenKey:He,onCloseDetail:be}){const M=jt();const $=Ee("storage.keys");const Ce=Ee("storage.mmkvInstances");const[Q,q]=N(false);A(()=>{if(Q&&M){q(false)}},[Q,M]);const[Pe,$e]=N("all");const ee=ye!=null&&me!=null;const T=ee?ye:Pe;const Ue=ee?me:$e;const[je,Ge]=N("all");const ve=pe!=null&&Se!=null;const C=ve?pe:je;const Ye=ve?Se:Ge;const[g,Te]=N(null);const Je=ie(null);const Xe=ie(0);const ke=ie(new Map);const Ze=b((e,t)=>{if(t)ke.current.set(e,t);else ke.current.delete(e)},[]);const[we,Ie]=N(0);const[te,re]=N(false);const[U,V]=N(new Set);const{instances:y}=zt(false);const{storageKeys:_e,isLoading:Qe,error:et,refresh:j}=Rt(z);const tt=S(()=>y.map(e=>({instance:e.instance,id:e.id})),[y]);const{storageKeys:oe,isLoading:rt,error:ot,refresh:G}=Et(tt,z);const Me=S(()=>{if(!g){return oe}return oe.filter(e=>e.instanceId===g)},[oe,g]);const{storageKeys:Ke,isLoading:nt,error:st,refresh:xe}=Lt(z);const c=S(()=>{return[..._e,...Me,...Ke].filter(e=>!h(e.key))},[_e,Me,Ke]);const K=S(()=>{if(!P)return null;const e=De(P);return c.find(t=>De(t)===e)??P},[P,c]);const it=Qe||rt||nt;const Be=et||ot||st;const k=b(()=>{j();G();xe()},[j,G,xe]);const R=b(e=>{return e.instanceId?`${e.storageType}-${e.instanceId}-${e.key}`:`${e.storageType}-${e.key}`},[]);const at=b(()=>{re(e=>{if(e){V(new Set)}return!e})},[]);const lt=b((e,t)=>{const r=R(e);V(p=>{const i=new Set(p);if(t){i.add(r)}else{i.delete(r)}return i})},[R]);const ct=b(()=>{V(new Set);re(false);k()},[k]);const ne=b(e=>{e.forEach(t=>ue?.(t.key));V(new Set);re(false)},[ue]);const se=b(async(e,t)=>{if(!M){q(true);throw new Error("Editing storage values is a Pro feature.")}await $t(e,t,y);k();Ie(r=>r+1)},[M,y,k]);const dt=b(e=>{void se(e,JSON.stringify(!e.value)).catch(t=>{le.alert("Couldn't save",t instanceof Error?t.message:String(t))})},[se]);const Ne=b((e,t)=>{if(!M){q(true);return}le.alert("Delete key",`Delete "${e.key}"? This cannot be undone.`,[{text:"Cancel",style:"cancel"},{text:"Delete",style:"destructive",onPress:async()=>{try{await Pt([e],y.map(r=>({id:r.id,instance:r.instance})));k();t?.()}catch(r){le.alert("Error",`Failed to delete key: ${r}`)}}}])},[M,y,k]);const qe=b(e=>Ut(e,y),[y]);const ut=S(()=>{const e=c;const t={valid:e.filter(l=>l.status==="required_present"||l.status==="optional_present").length,missing:e.filter(l=>l.status==="required_missing").length,issues:e.filter(l=>l.status==="required_wrong_value"||l.status==="required_wrong_type").length,total:e.length};const r=e.filter(l=>l.storageType==="async");const p=e.filter(l=>l.storageType==="mmkv");const i=e.filter(l=>l.storageType==="secure");return{summary:{valid:t.valid,missing:t.missing,issues:t.issues,total:t.total,timestamp:new Date().toISOString()},asyncStorage:r.reduce((l,u)=>{l[u.key]=u.value;return l},{}),mmkv:p.reduce((l,u)=>{const I=u.instanceId||"default";if(!l[I])l[I]={};l[I][u.key]=u.value;return l},{}),secure:i.reduce((l,u)=>{l[u.key]=u.value;return l},{})}},[c]);A(()=>{if(X){X.current=c}},[c,X]);A(()=>{let e;const t=At(r=>{clearTimeout(e);e=setTimeout(()=>{j()},100)});return()=>{clearTimeout(e);t()}},[j]);A(()=>{let e;const t=Ht(()=>{clearTimeout(e);e=setTimeout(k,100)});return()=>{clearTimeout(e);t()}},[k]);A(()=>{let e;const t=Ot(r=>{const p=g===null||r.instanceId===g;if(p){clearTimeout(e);e=setTimeout(()=>{G()},100)}});return()=>{clearTimeout(e);t()}},[G,g]);const D=S(()=>{const e=c;const t=e.filter(i=>!h(i.key));const r=e.filter(i=>h(i.key));const p={totalCount:e.length,requiredCount:t.filter(i=>i.category==="required").length,missingCount:t.filter(i=>i.status==="required_missing").length,wrongValueCount:t.filter(i=>i.status==="required_wrong_value").length,wrongTypeCount:t.filter(i=>i.status==="required_wrong_type").length,presentRequiredCount:t.filter(i=>i.status==="required_present").length,optionalCount:t.filter(i=>i.category==="optional").length,mmkvCount:e.filter(i=>i.storageType==="mmkv").length,asyncCount:e.filter(i=>i.storageType==="async").length,secureCount:e.filter(i=>i.storageType==="secure").length,devToolsCount:r.length};return p},[c]);const x=S(()=>{let e=c.filter(o=>!h(o.key));if(C!=="all"){e=e.filter(o=>o.storageType===C)}const t=e.filter(o=>o.status==="required_present"||o.status==="optional_present").length;const r=e.filter(o=>o.status==="required_missing").length;const p=e.filter(o=>o.status==="required_wrong_type"||o.status==="required_wrong_value").length;let i=0;let l=0;let u=0;let I=0;if(T==="all"){i=c.filter(o=>!h(o.key)&&o.storageType==="async"&&(o.status==="required_present"||o.status==="optional_present")).length;l=c.filter(o=>!h(o.key)&&o.storageType==="mmkv"&&(o.status==="required_present"||o.status==="optional_present")).length;u=c.filter(o=>!h(o.key)&&o.storageType==="secure"&&(o.status==="required_present"||o.status==="optional_present")).length;I=i+l+u}else if(T==="missing"){i=c.filter(o=>!h(o.key)&&o.storageType==="async"&&o.status==="required_missing").length;l=c.filter(o=>!h(o.key)&&o.storageType==="mmkv"&&o.status==="required_missing").length;u=c.filter(o=>!h(o.key)&&o.storageType==="secure"&&o.status==="required_missing").length;I=i+l+u}else if(T==="issues"){i=c.filter(o=>!h(o.key)&&o.storageType==="async"&&(o.status==="required_wrong_type"||o.status==="required_wrong_value")).length;l=c.filter(o=>!h(o.key)&&o.storageType==="mmkv"&&(o.status==="required_wrong_type"||o.status==="required_wrong_value")).length;u=c.filter(o=>!h(o.key)&&o.storageType==="secure"&&(o.status==="required_wrong_type"||o.status==="required_wrong_value")).length;I=i+l+u}return{validCount:t,missingCount:r,issuesCount:p,asyncCount:i,mmkvCount:l,secureCount:u,totalCount:I}},[c,T,C]);A(()=>{fe?.({validCount:x.validCount,missingCount:x.missingCount,issuesCount:x.issuesCount})},[fe,x.validCount,x.missingCount,x.issuesCount]);const Ve=S(()=>{return[...c].sort((e,t)=>{const r={required_missing:1,required_wrong_type:2,required_wrong_value:3,required_present:4,optional_present:5};return(r[e.status]||999)-(r[t.status]||999)})},[c]);const Jt=S(()=>{return Array.from(new Set(c.map(e=>e.key))).sort()},[c]);const v=S(()=>{let e=Ve;if(H&&H.size>0){e=e.filter(t=>H.has(t.storageType))}e=e.filter(t=>{const r=Array.from(O).some(p=>t.key.includes(p));return!r});if(w){const t=w.toLowerCase();e=e.filter(r=>r.key.toLowerCase().includes(t))}switch(T){case"all":e=e.filter(t=>t.status==="required_present"||t.status==="optional_present");break;case"missing":e=e.filter(t=>t.status==="required_missing");break;case"issues":e=e.filter(t=>t.status==="required_wrong_type"||t.status==="required_wrong_value");break}if(C!=="all"){e=e.filter(t=>t.storageType===C)}if(_&&_.size>0){const t=e.filter(p=>_.has(p.key));const r=e.filter(p=>!_.has(p.key));e=[...t,...r]}return e},[Ve,T,C,O,w,g,H,_]);const B=S(()=>v.slice(0,$),[v,$]);const Y=S(()=>{return Math.max(0,v.length-$)},[v.length,$]);const gt=Y>0;const Xt=S(()=>{const e=v.filter(r=>!h(r.key));const t={totalCount:v.length,requiredCount:e.filter(r=>r.category==="required").length,missingCount:e.filter(r=>r.status==="required_missing").length,wrongValueCount:e.filter(r=>r.status==="required_wrong_value").length,wrongTypeCount:e.filter(r=>r.status==="required_wrong_type").length,presentRequiredCount:e.filter(r=>r.status==="required_present").length,optionalCount:e.filter(r=>r.category==="optional").length,mmkvCount:v.filter(r=>r.storageType==="mmkv").length,asyncCount:v.filter(r=>r.storageType==="async").length,secureCount:v.filter(r=>r.storageType==="secure").length,devToolsCount:v.filter(r=>h(r.key)).length};return t},[v]);const yt=S(()=>{return B.filter(e=>U.has(R(e)))},[B,U,R]);const mt=b(()=>{const e=new Set(B.map(R));V(e)},[B,R]);const ft=b(()=>{V(new Set)},[]);const F=D.requiredCount>0?Math.round(D.presentRequiredCount/D.requiredCount*100):D.totalCount>0?100:0;const ht=F>=90?"OPTIMAL":F>=70?"WARNING":"CRITICAL";const pt=F>=90?E.success:F>=70?E.warning:E.error;if(K){return a(f,{style:n.root,children:a(qt,{storageKey:K,editBlockedReason:qe(K),eventCount:ge?.[K.key],onSave:e=>se(K,e),onViewHistory:Z?()=>Z(K.key):void 0,onDeleteKey:e=>Ne(e,()=>be?.()),onHideKey:e=>{ne([e]);be?.()},isPinned:_?.has(K.key)??false,onTogglePin:he,applySafeAreaInset:Oe})})}if(it&&c.length===0){return d(f,{style:n.emptyState,children:[a(Le,{size:48,color:s.color.textTertiary}),a(m,{style:n.emptyTitle,children:"Loading storage keys..."})]})}if(Be){return d(f,{style:n.emptyState,children:[a(Le,{size:48,color:E.error}),a(m,{style:[n.emptyTitle,{color:E.error}],children:"Error loading storage"}),a(m,{style:n.emptySubtitle,children:Be.message})]})}const St=d(Gt,{children:[C==="mmkv"&&y.length===0&&d(f,{style:n.emptyMMKVState,children:[a(m,{style:n.emptyMMKVTitle,children:"No MMKV Instances Detected"}),a(m,{style:n.emptyMMKVSubtitle,children:"MMKV instances must be registered with registerMMKVInstance()"}),a(m,{style:n.emptyMMKVCode,children:`import { registerMMKVInstance } from '@buoy-gg/storage';
2
2
 
3
3
  const storage = createMMKV();
4
- registerMMKVInstance('mmkv.default', storage);`})]}),C==="mmkv"&&y.length>0&&d(f,{style:n.instanceNavbar,children:[d(f,{style:n.instanceNavbarHeader,children:[a(m,{style:n.instanceNavbarLabel,children:"INSTANCES"}),y.length>Ce&&a(ze,{style:{transform:[{scale:.85}]}})]}),d(Re,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:n.instanceNavbarScroll,children:[(M||y.length===1)&&d(ae,{onPress:()=>Te(null),testID:"buoy-storage-instance-all",accessibilityRole:"button",accessibilityLabel:`All ${wt.mmkv} instances`,style:[n.instanceNavbarButton,g===null&&n.instanceNavbarButtonActive],children:[a(Fe,{size:12,color:g===null?s.color.text:s.color.textSecondary}),a(m,{style:[n.instanceNavbarButtonText,g===null&&n.instanceNavbarButtonTextActive],children:"All"}),a(f,{style:n.instanceNavbarBadge,children:a(m,{style:n.instanceNavbarBadgeText,children:y.reduce((e,t)=>e+t.keyCount,0)})})]}),y.map((e,t)=>{const r=t>=Ce;return d(ae,{testID:`buoy-storage-instance-${e.id}`,accessibilityRole:"button",accessibilityLabel:`MMKV instance ${e.id}`,onPress:()=>{if(r){q(true)}else{Te(e.id)}},style:[n.instanceNavbarButton,e.id===g&&n.instanceNavbarButtonActive,{borderColor:r?s.color.border:L(e.id)+"40",backgroundColor:e.id===g?L(e.id)+"20":s.color.surfaceElevated,opacity:r?.5:1}],children:[a(Fe,{size:12,color:e.id===g?L(e.id):s.color.textSecondary}),a(m,{style:[n.instanceNavbarButtonText,e.id===g&&{color:L(e.id),fontWeight:"700"}],children:e.id}),a(f,{style:[n.instanceNavbarBadge,e.id===g&&{backgroundColor:L(e.id)+"30"}],children:a(m,{style:[n.instanceNavbarBadgeText,e.id===g&&{color:L(e.id)}],children:e.keyCount})})]},e.id)})]})]})]});const bt=a(Ft,{copyValue:ut,mmkvInstances:y.map(e=>({id:e.id,instance:e.instance})),activeStorageType:C,onClearComplete:k,isSelectMode:te,onToggleSelectMode:at,selectedCount:U.size});const Ct=te?a(Wt,{selectedKeys:yt,mmkvInstances:y.map(e=>({id:e.id,instance:e.instance})),onDeleteComplete:ct,onHideKeys:ne,onSelectAll:mt,onClearSelection:ft,totalVisibleKeys:B.length}):null;const vt=gt?d(ae,{style:n.limitBanner,onPress:()=>q(true),activeOpacity:.8,testID:"buoy-storage-locked-banner",accessibilityRole:"button",children:[d(f,{style:n.limitBannerContent,children:[d(f,{style:n.limitBannerLeft,children:[a(Mt,{size:16,color:s.color.accent}),a(m,{style:n.limitBannerText,children:w?`${Y} matching ${Y===1?"key":"keys"} in locked storage`:`${Y} keys locked`})]}),a(ze,{})]}),a(m,{style:n.limitBannerSubtext,children:w?"Upgrade to Pro to search your full storage":"Upgrade to Pro to unlock full storage access"})]}):null;const Tt=(()=>{const e=c.some(r=>!h(r.key));let t;if(w||!e){t=Bt({subject:"keys",verb:"registered",search:w,total:e?1:0,waiting:{otto:"empty",title:"No storage keys",message:"Nothing is registered for this tool to read."}});if(w&&e){t={...t,message:"No keys match. Clear the search to see them."}}}else if(T==="missing"){t={otto:"thumbsup",title:"No missing keys",message:"All required keys are present"}}else if(T==="issues"){t={otto:"cool",title:"No issues found",message:"All storage keys are correctly configured"}}else{t={otto:"broken",title:"No valid keys found",message:"All keys have issues or are missing"}}return a(xt,{...t,testID:"buoy-storage-keys-empty"})})();const kt=a(Kt,{visible:Q,onClose:()=>q(false),featureName:"Storage Keys"});return d(f,{style:n.root,children:[we>0?a(Dt,{onDone:()=>Ie(0)},we):null,d(Re,{testID:"buoy-storage-scroll",ref:Je,onScroll:e=>{Xe.current=e.nativeEvent.contentOffset.y},scrollEventThrottle:32,style:n.scrollContainer,contentContainerStyle:n.container,showsVerticalScrollIndicator:false,children:[a(f,{style:n.backgroundGrid}),a(Vt,{stats:D,tabStats:x,healthPercentage:F,healthStatus:ht,healthColor:pt,activeFilter:T,onFilterChange:Ue,activeStorageType:C,onStorageTypeChange:Ye,showStatus:!ee}),St,v.length>0?d(f,{style:n.keysSection,children:[d(f,{style:n.sectionHeader,children:[d(f,{style:n.sectionHeaderLeft,children:[d(m,{style:n.sectionTitle,children:[T==="all"?"KEYS":T==="missing"?"MISSING KEYS":"ISSUES TO FIX",C!=="all"&&` (${C.toUpperCase()})`]}),a(f,{style:n.countBadge,children:a(m,{style:n.countText,children:B.length})})]}),bt]}),Ct,a(Nt,{title:"",count:-1,keys:B,emptyMessage:"",isSelectMode:te,selectedKeys:U,onSelectionChange:lt,eventCountByKey:ge,onViewHistory:Z,onHideKey:e=>ne([e]),onToggleKey:dt,onDeleteKey:Ne,editBlockedFor:qe,pinnedKeys:_,onTogglePin:he,onRowRef:Ze,onOpenKey:He}),vt]}):Tt,a(m,{style:n.techFooter,children:"ASYNC STORAGE | MMKV | SECURE STORAGE BACKENDS"}),kt]})]})}const n=It.create({root:{flex:1,minHeight:0},editorOverlay:{...Ae,zIndex:10},scrollContainer:{flex:1,backgroundColor:"transparent"},container:{padding:12,paddingBottom:120},backgroundGrid:{...Ae,opacity:.006,backgroundColor:E.info},techFooter:{fontSize:8,color:s.color.textTertiary,fontFamily:W,textAlign:"center",marginTop:20,letterSpacing:1,opacity:.5},keysSection:{marginTop:8,backgroundColor:s.color.bg,borderRadius:12,padding:12,borderWidth:1,borderColor:s.color.border},sectionHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:10,paddingBottom:6,borderBottomWidth:1,borderBottomColor:s.color.separator},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:8},sectionTitle:{fontSize:12,fontWeight:"600",color:s.color.textSecondary,letterSpacing:.4,textTransform:"uppercase"},countBadge:{backgroundColor:s.color.surfaceElevated,paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1,borderColor:s.color.border},countText:{fontSize:11,fontWeight:"600",color:s.color.text,fontFamily:W},emptyState:{alignItems:"center",justifyContent:"center",paddingVertical:48},emptyTitle:{fontSize:16,fontWeight:"600",color:s.color.text,marginTop:12,marginBottom:8},emptySubtitle:{fontSize:13,color:s.color.textSecondary,textAlign:"center"},emptyMMKVState:{backgroundColor:s.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:s.color.border,marginTop:8,alignItems:"center"},emptyMMKVTitle:{fontSize:14,fontWeight:"600",color:s.color.text,marginBottom:6},emptyMMKVSubtitle:{fontSize:12,color:s.color.textSecondary,textAlign:"center",marginBottom:12},emptyMMKVCode:{fontSize:10,fontFamily:W,color:s.color.accent,backgroundColor:s.color.bg,padding:12,borderRadius:8,borderWidth:1,borderColor:s.color.border,alignSelf:"stretch"},instanceNavbar:{marginTop:12,marginBottom:8,backgroundColor:s.color.surface,borderRadius:10,borderWidth:1,borderColor:s.color.border,padding:10,shadowColor:"#000",shadowOpacity:.08,shadowRadius:6,shadowOffset:{width:0,height:2}},instanceNavbarHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8,paddingLeft:2},instanceNavbarLabel:{fontSize:9,fontWeight:"700",color:s.color.textTertiary,textTransform:"uppercase",letterSpacing:1},instanceNavbarScroll:{gap:8,paddingRight:8},instanceNavbarButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8,backgroundColor:s.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:s.color.border,minWidth:90},instanceNavbarButtonActive:{borderWidth:1.5,shadowColor:"#000",shadowOpacity:.1,shadowRadius:4,shadowOffset:{width:0,height:1}},instanceNavbarButtonText:{fontSize:11,fontWeight:"600",color:s.color.textSecondary,fontFamily:W,flex:1},instanceNavbarButtonTextActive:{fontWeight:"700",color:s.color.text},instanceNavbarBadge:{backgroundColor:s.color.bg,paddingHorizontal:6,paddingVertical:2,borderRadius:6,minWidth:24,alignItems:"center"},instanceNavbarBadgeText:{fontSize:10,fontWeight:"700",color:s.color.textSecondary,fontFamily:W},clearSearchButton:{marginTop:16,paddingHorizontal:16,paddingVertical:8,backgroundColor:s.color.surfaceElevated,borderRadius:6,borderWidth:1,borderColor:s.color.border},clearSearchText:{fontSize:13,color:s.color.text,fontWeight:"500"},limitBanner:{backgroundColor:s.color.surface,borderRadius:10,borderWidth:1,borderColor:s.color.accentBorderStrong,padding:12,marginTop:12},limitBannerContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:4},limitBannerLeft:{flexDirection:"row",alignItems:"center",gap:8},limitBannerText:{color:s.color.text,fontSize:13,fontWeight:"600"},limitBannerSubtext:{color:s.color.textTertiary,fontSize:11}});
4
+ registerMMKVInstance('mmkv.default', storage);`})]}),C==="mmkv"&&y.length>0&&d(f,{style:n.instanceNavbar,children:[d(f,{style:n.instanceNavbarHeader,children:[a(m,{style:n.instanceNavbarLabel,children:"INSTANCES"}),y.length>Ce&&a(ze,{style:{transform:[{scale:.85}]}})]}),d(Re,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:n.instanceNavbarScroll,children:[(M||y.length===1)&&d(ae,{onPress:()=>Te(null),testID:"buoy-storage-instance-all",accessibilityRole:"button",accessibilityLabel:`All ${wt.mmkv} instances`,style:[n.instanceNavbarButton,g===null&&n.instanceNavbarButtonActive],children:[a(Fe,{size:12,color:g===null?s.color.text:s.color.textSecondary}),a(m,{style:[n.instanceNavbarButtonText,g===null&&n.instanceNavbarButtonTextActive],children:"All"}),a(f,{style:n.instanceNavbarBadge,children:a(m,{style:n.instanceNavbarBadgeText,children:y.reduce((e,t)=>e+t.keyCount,0)})})]}),y.map((e,t)=>{const r=t>=Ce;return d(ae,{testID:`buoy-storage-instance-${e.id}`,accessibilityRole:"button",accessibilityLabel:`MMKV instance ${e.id}`,onPress:()=>{if(r){q(true)}else{Te(e.id)}},style:[n.instanceNavbarButton,e.id===g&&n.instanceNavbarButtonActive,{borderColor:r?s.color.border:L(e.id)+"40",backgroundColor:e.id===g?L(e.id)+"20":s.color.surfaceElevated,opacity:r?.5:1}],children:[a(Fe,{size:12,color:e.id===g?L(e.id):s.color.textSecondary}),a(m,{style:[n.instanceNavbarButtonText,e.id===g&&{color:L(e.id),fontWeight:"700"}],children:e.id}),a(f,{style:[n.instanceNavbarBadge,e.id===g&&{backgroundColor:L(e.id)+"30"}],children:a(m,{style:[n.instanceNavbarBadgeText,e.id===g&&{color:L(e.id)}],children:e.keyCount})})]},e.id)})]})]})]});const bt=a(Ft,{copyValue:ut,mmkvInstances:y.map(e=>({id:e.id,instance:e.instance})),activeStorageType:C,onClearComplete:k,isSelectMode:te,onToggleSelectMode:at,selectedCount:U.size});const Ct=te?a(Wt,{selectedKeys:yt,mmkvInstances:y.map(e=>({id:e.id,instance:e.instance})),onDeleteComplete:ct,onHideKeys:ne,onSelectAll:mt,onClearSelection:ft,totalVisibleKeys:B.length}):null;const vt=gt?d(ae,{style:n.limitBanner,onPress:()=>q(true),activeOpacity:.8,testID:"buoy-storage-locked-banner",accessibilityRole:"button",children:[d(f,{style:n.limitBannerContent,children:[d(f,{style:n.limitBannerLeft,children:[a(Mt,{size:16,color:s.color.accent}),a(m,{style:n.limitBannerText,children:w?`${Y} matching ${Y===1?"key":"keys"} in locked storage`:`${Y} keys locked`})]}),a(ze,{})]}),a(m,{style:n.limitBannerSubtext,children:w?"Upgrade to Pro to search your full storage":"Upgrade to Pro to unlock full storage access"})]}):null;const Tt=(()=>{const e=c.some(r=>!h(r.key));let t;if(w||!e){t=Bt({subject:"keys",verb:"registered",search:w,total:e?1:0,waiting:{otto:"empty",title:"No storage keys",message:"Nothing is registered for this tool to read."}});if(w&&e){t={...t,message:"No keys match. Clear the search to see them."}}}else if(T==="missing"){t={otto:"thumbsup",title:"No missing keys",message:"All required keys are present"}}else if(T==="issues"){t={otto:"cool",title:"No issues found",message:"All storage keys are correctly configured"}}else{t={otto:"broken",title:"No valid keys found",message:"All keys have issues or are missing"}}return a(xt,{...t,testID:"buoy-storage-keys-empty"})})();const kt=a(Kt,{visible:Q,onClose:()=>q(false),featureName:"Storage Keys"});return d(f,{style:n.root,children:[we>0?a(Dt,{onDone:()=>Ie(0)},we):null,d(Re,{keyboardShouldPersistTaps:"handled",testID:"buoy-storage-scroll",ref:Je,onScroll:e=>{Xe.current=e.nativeEvent.contentOffset.y},scrollEventThrottle:32,style:n.scrollContainer,contentContainerStyle:n.container,showsVerticalScrollIndicator:false,children:[a(f,{style:n.backgroundGrid}),a(Vt,{stats:D,tabStats:x,healthPercentage:F,healthStatus:ht,healthColor:pt,activeFilter:T,onFilterChange:Ue,activeStorageType:C,onStorageTypeChange:Ye,showStatus:!ee}),St,v.length>0?d(f,{style:n.keysSection,children:[d(f,{style:n.sectionHeader,children:[d(f,{style:n.sectionHeaderLeft,children:[d(m,{style:n.sectionTitle,children:[T==="all"?"KEYS":T==="missing"?"MISSING KEYS":"ISSUES TO FIX",C!=="all"&&` (${C.toUpperCase()})`]}),a(f,{style:n.countBadge,children:a(m,{style:n.countText,children:B.length})})]}),bt]}),Ct,a(Nt,{title:"",count:-1,keys:B,emptyMessage:"",isSelectMode:te,selectedKeys:U,onSelectionChange:lt,eventCountByKey:ge,onViewHistory:Z,onHideKey:e=>ne([e]),onToggleKey:dt,onDeleteKey:Ne,editBlockedFor:qe,pinnedKeys:_,onTogglePin:he,onRowRef:Ze,onOpenKey:He}),vt]}):Tt,a(m,{style:n.techFooter,children:"ASYNC STORAGE | MMKV | SECURE STORAGE BACKENDS"}),kt]})]})}const n=It.create({root:{flex:1,minHeight:0},editorOverlay:{...Ae,zIndex:10},scrollContainer:{flex:1,backgroundColor:"transparent"},container:{padding:12,paddingBottom:120},backgroundGrid:{...Ae,opacity:.006,backgroundColor:E.info},techFooter:{fontSize:8,color:s.color.textTertiary,fontFamily:W,textAlign:"center",marginTop:20,letterSpacing:1,opacity:.5},keysSection:{marginTop:8,backgroundColor:s.color.bg,borderRadius:12,padding:12,borderWidth:1,borderColor:s.color.border},sectionHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:10,paddingBottom:6,borderBottomWidth:1,borderBottomColor:s.color.separator},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:8},sectionTitle:{fontSize:12,fontWeight:"600",color:s.color.textSecondary,letterSpacing:.4,textTransform:"uppercase"},countBadge:{backgroundColor:s.color.surfaceElevated,paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1,borderColor:s.color.border},countText:{fontSize:11,fontWeight:"600",color:s.color.text,fontFamily:W},emptyState:{alignItems:"center",justifyContent:"center",paddingVertical:48},emptyTitle:{fontSize:16,fontWeight:"600",color:s.color.text,marginTop:12,marginBottom:8},emptySubtitle:{fontSize:13,color:s.color.textSecondary,textAlign:"center"},emptyMMKVState:{backgroundColor:s.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:s.color.border,marginTop:8,alignItems:"center"},emptyMMKVTitle:{fontSize:14,fontWeight:"600",color:s.color.text,marginBottom:6},emptyMMKVSubtitle:{fontSize:12,color:s.color.textSecondary,textAlign:"center",marginBottom:12},emptyMMKVCode:{fontSize:10,fontFamily:W,color:s.color.accent,backgroundColor:s.color.bg,padding:12,borderRadius:8,borderWidth:1,borderColor:s.color.border,alignSelf:"stretch"},instanceNavbar:{marginTop:12,marginBottom:8,backgroundColor:s.color.surface,borderRadius:10,borderWidth:1,borderColor:s.color.border,padding:10,shadowColor:"#000",shadowOpacity:.08,shadowRadius:6,shadowOffset:{width:0,height:2}},instanceNavbarHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8,paddingLeft:2},instanceNavbarLabel:{fontSize:9,fontWeight:"700",color:s.color.textTertiary,textTransform:"uppercase",letterSpacing:1},instanceNavbarScroll:{gap:8,paddingRight:8},instanceNavbarButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8,backgroundColor:s.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:s.color.border,minWidth:90},instanceNavbarButtonActive:{borderWidth:1.5,shadowColor:"#000",shadowOpacity:.1,shadowRadius:4,shadowOffset:{width:0,height:1}},instanceNavbarButtonText:{fontSize:11,fontWeight:"600",color:s.color.textSecondary,fontFamily:W,flex:1},instanceNavbarButtonTextActive:{fontWeight:"700",color:s.color.text},instanceNavbarBadge:{backgroundColor:s.color.bg,paddingHorizontal:6,paddingVertical:2,borderRadius:6,minWidth:24,alignItems:"center"},instanceNavbarBadgeText:{fontSize:10,fontWeight:"700",color:s.color.textSecondary,fontFamily:W},clearSearchButton:{marginTop:16,paddingHorizontal:16,paddingVertical:8,backgroundColor:s.color.surfaceElevated,borderRadius:6,borderWidth:1,borderColor:s.color.border},clearSearchText:{fontSize:13,color:s.color.text,fontWeight:"500"},limitBanner:{backgroundColor:s.color.surface,borderRadius:10,borderWidth:1,borderColor:s.color.accentBorderStrong,padding:12,marginTop:12},limitBannerContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:4},limitBannerLeft:{flexDirection:"row",alignItems:"center",gap:8},limitBannerText:{color:s.color.text,fontSize:13,fontWeight:"600"},limitBannerSubtext:{color:s.color.textTertiary,fontSize:11}});
@@ -1 +1 @@
1
- "use strict";import{storageLabels as x}from"../utils/storageLabels";import{useState as C}from"react";import{View as r,Text as n,StyleSheet as R,TouchableOpacity as c,ScrollView as T,Modal as I}from"react-native";import{macOSColors as d,night as o,monoFont as b}from"@buoy-gg/shared-ui";import{useMMKVInstances as v}from"../hooks/useMMKVInstances";import{isMMKVAvailable as B,getMMKVUnavailableMessage as M}from"../utils/mmkvAvailability";import{jsxs as i,jsx as t}from"react/jsx-runtime";export function MMKVInstanceSelector({selectedInstanceId:a,onSelectInstance:h,showRefreshButton:g=true}){const[w,s]=C(false);const{instances:p,instanceCount:f,refresh:y}=v(false);const u=p.find(l=>l.id===a);const S=l=>{h(l);s(false)};if(!B()){return t(r,{style:e.container,children:i(r,{style:e.unavailableState,children:[i(n,{style:e.unavailableTitle,children:[x.mmkv," Not Available"]}),t(n,{style:e.unavailableDescription,children:M()})]})})}if(f===0){return t(r,{style:e.container,children:i(r,{style:e.emptyState,children:[t(n,{style:e.emptyStateTitle,children:"No MMKV Instances Registered"}),t(n,{style:e.emptyStateDescription,children:"Register MMKV instances using registerMMKVInstance() to monitor them in dev tools."}),g&&t(c,{style:e.refreshButton,onPress:y,activeOpacity:.7,children:t(n,{style:e.refreshButtonText,children:"\u21BB Refresh"})})]})})}return i(r,{style:e.container,children:[i(c,{style:e.selectorButton,onPress:()=>s(true),activeOpacity:.7,children:[t(r,{style:e.selectorContent,children:u?t(m,{instance:u,isSelected:true}):t(n,{style:e.placeholderText,children:"Select MMKV Instance"})}),t(n,{style:e.dropdownArrow,children:"\u25BC"})]}),t(I,{visible:w,transparent:true,animationType:"fade",onRequestClose:()=>s(false),children:t(c,{style:e.modalOverlay,activeOpacity:1,onPress:()=>s(false),children:i(r,{style:e.dropdownContainer,children:[i(r,{style:e.dropdownHeader,children:[i(n,{style:e.dropdownTitle,children:["Select MMKV Instance (",f,")"]}),g&&t(c,{style:e.headerRefreshButton,onPress:y,activeOpacity:.7,children:t(n,{style:e.headerRefreshText,children:"\u21BB"})})]}),t(T,{style:e.dropdownList,children:p.map(l=>t(c,{style:[e.dropdownItem,l.id===a&&e.dropdownItemSelected],onPress:()=>S(l.id),activeOpacity:.7,children:t(m,{instance:l,isSelected:l.id===a})},l.id))})]})})})]})}function m({instance:a,isSelected:h}){return i(r,{style:e.instanceRow,children:[i(r,{style:e.instanceLeft,children:[t(n,{style:[e.instanceId,h&&e.instanceIdSelected],numberOfLines:1,children:a.id}),i(r,{style:e.instanceBadges,children:[a.encrypted&&t(r,{style:[e.badge,e.badgeEncrypted],children:t(n,{style:e.badgeText,children:"\u{1F512} Encrypted"})}),a.readOnly&&t(r,{style:[e.badge,e.badgeReadOnly],children:t(n,{style:e.badgeText,children:"\u{1F441}\uFE0F Read-only"})})]})]}),i(r,{style:e.instanceRight,children:[t(n,{style:e.keyCount,children:a.keyCount}),t(n,{style:e.keyCountLabel,children:"keys"})]})]})}const e=R.create({container:{marginBottom:12},unavailableState:{backgroundColor:d.semantic.warning+"15",borderRadius:12,padding:20,borderWidth:1,borderColor:d.semantic.warning+"40",alignItems:"center",gap:12},unavailableTitle:{fontSize:14,fontWeight:"600",color:d.semantic.warning},unavailableDescription:{fontSize:12,color:o.color.textSecondary,textAlign:"center",lineHeight:18},emptyState:{backgroundColor:o.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:o.color.border,alignItems:"center",gap:12},emptyStateTitle:{fontSize:14,fontWeight:"600",color:o.color.text},emptyStateDescription:{fontSize:12,color:o.color.textTertiary,textAlign:"center",lineHeight:18},refreshButton:{marginTop:8,paddingHorizontal:16,paddingVertical:8,backgroundColor:o.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:o.color.accentBorderStrong},refreshButtonText:{fontSize:12,fontWeight:"600",color:o.color.accent},selectorButton:{backgroundColor:o.color.surface,borderRadius:12,borderWidth:1,borderColor:o.color.border,padding:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between",shadowColor:"#000000",shadowOpacity:.03,shadowRadius:8,shadowOffset:{width:0,height:2}},selectorContent:{flex:1},placeholderText:{fontSize:13,color:o.color.placeholder,fontStyle:"italic"},dropdownArrow:{fontSize:10,color:o.color.textTertiary,marginLeft:8},modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center",padding:20},dropdownContainer:{backgroundColor:o.color.surface,borderRadius:16,borderWidth:1,borderColor:o.color.border,width:"100%",maxWidth:500,maxHeight:"70%",shadowColor:"#000000",shadowOpacity:.2,shadowRadius:20,shadowOffset:{width:0,height:10},overflow:"hidden"},dropdownHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16,borderBottomWidth:1,borderBottomColor:o.color.separator},dropdownTitle:{fontSize:14,fontWeight:"600",color:o.color.text},headerRefreshButton:{padding:4},headerRefreshText:{fontSize:18,color:o.color.accent},dropdownList:{maxHeight:400},dropdownItem:{padding:12,borderBottomWidth:1,borderBottomColor:o.color.separator},dropdownItemSelected:{backgroundColor:o.color.accentSoft},instanceRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},instanceLeft:{flex:1,gap:6},instanceId:{fontSize:13,fontWeight:"500",color:o.color.text,fontFamily:b},instanceIdSelected:{fontWeight:"600",color:o.color.accent},instanceBadges:{flexDirection:"row",flexWrap:"wrap",gap:6},badge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4,borderWidth:1},badgeEncrypted:{backgroundColor:d.semantic.success+"15",borderColor:d.semantic.success+"40"},badgeReadOnly:{backgroundColor:d.semantic.warning+"15",borderColor:d.semantic.warning+"40"},badgeText:{fontSize:9,fontWeight:"500",color:o.color.textSecondary},instanceRight:{alignItems:"flex-end"},keyCount:{fontSize:16,fontWeight:"600",color:o.color.text,fontFamily:b},keyCountLabel:{fontSize:9,color:o.color.textTertiary,textTransform:"uppercase",letterSpacing:.5}});
1
+ "use strict";import{storageLabels as x}from"../utils/storageLabels";import{useState as C}from"react";import{View as r,Text as n,StyleSheet as T,TouchableOpacity as c,ScrollView as R,Modal as I}from"react-native";import{macOSColors as d,night as o,monoFont as b}from"@buoy-gg/shared-ui";import{useMMKVInstances as v}from"../hooks/useMMKVInstances";import{isMMKVAvailable as B,getMMKVUnavailableMessage as M}from"../utils/mmkvAvailability";import{jsxs as i,jsx as t}from"react/jsx-runtime";export function MMKVInstanceSelector({selectedInstanceId:a,onSelectInstance:h,showRefreshButton:p=true}){const[w,s]=C(false);const{instances:g,instanceCount:y,refresh:f}=v(false);const u=g.find(l=>l.id===a);const S=l=>{h(l);s(false)};if(!B()){return t(r,{style:e.container,children:i(r,{style:e.unavailableState,children:[i(n,{style:e.unavailableTitle,children:[x.mmkv," Not Available"]}),t(n,{style:e.unavailableDescription,children:M()})]})})}if(y===0){return t(r,{style:e.container,children:i(r,{style:e.emptyState,children:[t(n,{style:e.emptyStateTitle,children:"No MMKV Instances Registered"}),t(n,{style:e.emptyStateDescription,children:"Register MMKV instances using registerMMKVInstance() to monitor them in dev tools."}),p&&t(c,{style:e.refreshButton,onPress:f,activeOpacity:.7,children:t(n,{style:e.refreshButtonText,children:"\u21BB Refresh"})})]})})}return i(r,{style:e.container,children:[i(c,{style:e.selectorButton,onPress:()=>s(true),activeOpacity:.7,children:[t(r,{style:e.selectorContent,children:u?t(m,{instance:u,isSelected:true}):t(n,{style:e.placeholderText,children:"Select MMKV Instance"})}),t(n,{style:e.dropdownArrow,children:"\u25BC"})]}),t(I,{visible:w,transparent:true,animationType:"fade",onRequestClose:()=>s(false),children:t(c,{style:e.modalOverlay,activeOpacity:1,onPress:()=>s(false),children:i(r,{style:e.dropdownContainer,children:[i(r,{style:e.dropdownHeader,children:[i(n,{style:e.dropdownTitle,children:["Select MMKV Instance (",y,")"]}),p&&t(c,{style:e.headerRefreshButton,onPress:f,activeOpacity:.7,children:t(n,{style:e.headerRefreshText,children:"\u21BB"})})]}),t(R,{keyboardShouldPersistTaps:"handled",style:e.dropdownList,children:g.map(l=>t(c,{style:[e.dropdownItem,l.id===a&&e.dropdownItemSelected],onPress:()=>S(l.id),activeOpacity:.7,children:t(m,{instance:l,isSelected:l.id===a})},l.id))})]})})})]})}function m({instance:a,isSelected:h}){return i(r,{style:e.instanceRow,children:[i(r,{style:e.instanceLeft,children:[t(n,{style:[e.instanceId,h&&e.instanceIdSelected],numberOfLines:1,children:a.id}),i(r,{style:e.instanceBadges,children:[a.encrypted&&t(r,{style:[e.badge,e.badgeEncrypted],children:t(n,{style:e.badgeText,children:"\u{1F512} Encrypted"})}),a.readOnly&&t(r,{style:[e.badge,e.badgeReadOnly],children:t(n,{style:e.badgeText,children:"\u{1F441}\uFE0F Read-only"})})]})]}),i(r,{style:e.instanceRight,children:[t(n,{style:e.keyCount,children:a.keyCount}),t(n,{style:e.keyCountLabel,children:"keys"})]})]})}const e=T.create({container:{marginBottom:12},unavailableState:{backgroundColor:d.semantic.warning+"15",borderRadius:12,padding:20,borderWidth:1,borderColor:d.semantic.warning+"40",alignItems:"center",gap:12},unavailableTitle:{fontSize:14,fontWeight:"600",color:d.semantic.warning},unavailableDescription:{fontSize:12,color:o.color.textSecondary,textAlign:"center",lineHeight:18},emptyState:{backgroundColor:o.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:o.color.border,alignItems:"center",gap:12},emptyStateTitle:{fontSize:14,fontWeight:"600",color:o.color.text},emptyStateDescription:{fontSize:12,color:o.color.textTertiary,textAlign:"center",lineHeight:18},refreshButton:{marginTop:8,paddingHorizontal:16,paddingVertical:8,backgroundColor:o.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:o.color.accentBorderStrong},refreshButtonText:{fontSize:12,fontWeight:"600",color:o.color.accent},selectorButton:{backgroundColor:o.color.surface,borderRadius:12,borderWidth:1,borderColor:o.color.border,padding:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between",shadowColor:"#000000",shadowOpacity:.03,shadowRadius:8,shadowOffset:{width:0,height:2}},selectorContent:{flex:1},placeholderText:{fontSize:13,color:o.color.placeholder,fontStyle:"italic"},dropdownArrow:{fontSize:10,color:o.color.textTertiary,marginLeft:8},modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center",padding:20},dropdownContainer:{backgroundColor:o.color.surface,borderRadius:16,borderWidth:1,borderColor:o.color.border,width:"100%",maxWidth:500,maxHeight:"70%",shadowColor:"#000000",shadowOpacity:.2,shadowRadius:20,shadowOffset:{width:0,height:10},overflow:"hidden"},dropdownHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16,borderBottomWidth:1,borderBottomColor:o.color.separator},dropdownTitle:{fontSize:14,fontWeight:"600",color:o.color.text},headerRefreshButton:{padding:4},headerRefreshText:{fontSize:18,color:o.color.accent},dropdownList:{maxHeight:400},dropdownItem:{padding:12,borderBottomWidth:1,borderBottomColor:o.color.separator},dropdownItemSelected:{backgroundColor:o.color.accentSoft},instanceRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},instanceLeft:{flex:1,gap:6},instanceId:{fontSize:13,fontWeight:"500",color:o.color.text,fontFamily:b},instanceIdSelected:{fontWeight:"600",color:o.color.accent},instanceBadges:{flexDirection:"row",flexWrap:"wrap",gap:6},badge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4,borderWidth:1},badgeEncrypted:{backgroundColor:d.semantic.success+"15",borderColor:d.semantic.success+"40"},badgeReadOnly:{backgroundColor:d.semantic.warning+"15",borderColor:d.semantic.warning+"40"},badgeText:{fontSize:9,fontWeight:"500",color:o.color.textSecondary},instanceRight:{alignItems:"flex-end"},keyCount:{fontSize:16,fontWeight:"600",color:o.color.text,fontFamily:b},keyCountLabel:{fontSize:9,color:o.color.textTertiary,textTransform:"uppercase",letterSpacing:.5}});
@@ -1 +1 @@
1
- "use strict";import{useState as g,useCallback as i,useEffect as ee,useRef as be,useMemo as y}from"react";import{View as S,TouchableOpacity as te,StyleSheet as lt,FlatList as Ee,Alert as ne}from"react-native";import oe from"../utils/appAsyncStorage";import{JsModal as it,ModalHeader as c,TabSelector as ct,parseValue as dt,devToolsStorageKeys as P,macOSColors as ut,night as d,ToolEmptyState as gt,Filter as yt,RefreshCw as pt,Search as mt,SearchBar as ft,PowerToggleButton as ht,ToolbarCopyButton as Ce,ToolbarClearButton as St,truncatePayload as _,TickProvider as Ie,useLimit as vt,TIER_LIMITS as Tt,windowDragProps as bt,usePersistedState as M,monoFont as L}from"@buoy-gg/shared-ui";import{StorageBrowserMode as Et}from"./StorageBrowserMode";import{StorageTypeFilterBar as Ct,countByStorageType as It}from"./StorageTypeFilterBar";import{clearAllAppStorage as xt,clearAllStorageIncludingDevTools as kt}from"../utils/clearAllStorage";import{ProFeatureBanner as wt}from"@buoy-gg/shared-ui";import{useStorageEvents as Bt}from"../hooks/useStorageEvents";import{StorageEventDetailContent as xe,StorageEventDetailFooter as ke}from"./StorageEventDetailContent";import{StorageEventFilterView as Ft}from"./StorageEventFilterView";import{StorageEventCard as we}from"./StorageEventCard";import{useIsPro as Pt}from"@buoy-gg/license";import{jsx as n,jsxs as p,Fragment as Be}from"react/jsx-runtime";export const FREE_TIER_EVENT_LIMIT=Tt["storage.events"].free;const re={getItem:r=>oe.getItem(r),setItem:(r,C)=>oe.setItem(r,C)};const At={storage:re,parse:r=>r==="browser"||r==="events"?r:void 0,serialize:r=>r};const Dt={storage:re,parse:r=>r==="true",serialize:r=>r.toString()};const Fe={storage:re,parse:r=>new Set(JSON.parse(r)),serialize:r=>JSON.stringify(Array.from(r))};const Rt={...Fe,parse:r=>{const C=JSON.parse(r);if(!C.includes("@react_buoy"))C.push("@react_buoy");return new Set(C)}};export function StorageModalWithTabs({visible:r,onClose:C,onBack:V,onMinimize:Pe,enableSharedModalDimensions:Ae=false,requiredStorageKeys:De=[],inline:Re=false,onTabChange:ae,onRefresh:se,onEventSelect:K}){const Kt=Pt();const N=vt("storage.events");const[B,Ke]=M(P.storage.activeTab(),"browser",At);ee(()=>{ae?.(B)},[B,ae]);const[le,ie]=g("");const[W,H]=g(null);const[j,$]=g(false);const[ce,Ne]=M(P.storage.isMonitoring(),true,Dt);const{events:F,clearEvents:de,isCapturing:He}=Bt({enabled:ce});const[G,A]=g(null);const[I,J]=g(null);const[h,v]=g(null);const[z,x]=g(0);const[D,Q]=g(false);const[T,ue]=M(P.storage.eventFilters(),new Set(["@react_buoy","@RNAsyncStorage","redux-persist","persist:"]),Rt);const[k,ge]=g("all");const[b,ze]=g(new Set(["async","mmkv","secure"]));const[Oe,_e]=M(P.storage.pinnedKeys(),new Set,Fe);const Nt=be(null);const ye=ce&&He;const[q,Me]=g("bottomSheet");const Le=i(e=>{Me(e)},[]);const Ve=i(()=>{Ne(e=>!e)},[]);const We=i(()=>{de();A(null);x(0)},[de]);const je=i(e=>{J(e);v(null)},[]);const pe=i(()=>{J(null);v(null)},[]);const me=i(e=>{ue(t=>{const o=new Set(t);if(o.has(e)){o.delete(e)}else{o.add(e)}return o})},[]);const fe=i(e=>{ue(t=>new Set([...t,e]))},[]);const $e=i(e=>{_e(t=>{const o=new Set(t);if(o.has(e)){o.delete(e)}else{o.add(e)}return o})},[]);const Ge=i(()=>{Q(!D)},[D]);const Je=i(e=>{ze(t=>{const o=new Set(t);if(o.has(e)){o.delete(e)}else{o.add(e)}return o})},[]);const U=be([]);const Qe=i(()=>{const e=U.current;return{timestamp:new Date().toISOString(),totalKeys:e.length,asyncStorage:e.filter(t=>t.storageType==="async").reduce((t,o)=>{t[o.key]=_(o.value);return t},{}),mmkv:e.filter(t=>t.storageType==="mmkv").reduce((t,o)=>{const a=o.instanceId||"default";if(!t[a])t[a]={};t[a][o.key]=_(o.value);return t},{}),secure:e.filter(t=>t.storageType==="secure").reduce((t,o)=>{t[o.key]=_(o.value);return t},{})}},[]);const Ht=i(async()=>{ne.alert("Clear Storage","Choose what to clear:",[{text:"Cancel",style:"cancel"},{text:"Clear App Storage",onPress:async()=>{try{await xt()}catch(e){ne.alert("Error","Failed to clear app storage")}}},{text:"Clear All (Including Dev Tools)",style:"destructive",onPress:async()=>{try{await kt()}catch(e){ne.alert("Error","Failed to clear all storage")}}}])},[]);const O=e=>{const t=dt(e);if(t===null)return"null";if(t===void 0)return"undefined";if(Array.isArray(t))return"array";if(typeof t==="boolean")return"boolean";if(typeof t==="number")return"number";if(typeof t==="string")return"string";if(typeof t==="object")return"object";return"undefined"};const[he,qe]=g([]);ee(()=>{const e=async()=>{try{const t=await oe.getAllKeys();qe([...t].sort())}catch(t){}};if(r){e()}},[r]);const Ue=y(()=>{const e=new Set(he);F.forEach(t=>{if(t.data?.key){e.add(t.data.key)}});return Array.from(e).sort()},[F,he]);const m=y(()=>{const e=new Map;F.forEach(t=>{if(!t.data?.key)return;const o=t.data.key;if(!b.has(t.storageType))return;const a=Array.from(T).some(w=>o.includes(w));if(a)return;const s=e.get(o);if(!s){e.set(o,{key:o,lastEvent:t,events:[t],totalOperations:1,currentValue:t.data.value,valueType:O(t.data.value),storageTypes:new Set([t.storageType])})}else{s.events.push(t);s.totalOperations++;s.storageTypes.add(t.storageType);if(t.timestamp>s.lastEvent.timestamp){s.lastEvent=t;s.currentValue=t.data.value;s.valueType=O(t.data.value)}}});return Array.from(e.values()).sort((t,o)=>o.lastEvent.timestamp.getTime()-t.lastEvent.timestamp.getTime())},[F,T,b]);const u=y(()=>{if(!G)return null;return m.find(e=>e.key===G)||null},[G,m]);const Ye=y(()=>{const e={};m.forEach(t=>{e[t.key]=t.totalOperations});return e},[m]);const Xe=y(()=>{const e={};m.forEach(t=>{e[t.key]=t.lastEvent.timestamp.getTime()});return e},[m]);const E=y(()=>{if(!I)return null;return m.find(e=>e.key===I)||null},[I,m]);ee(()=>{if(!K)return;const e=u?u:h!==null?E:null;const t=u?z:h;if(!e||t==null)return;const o=[...e.events].sort((w,Z)=>w.timestamp.getTime()-Z.timestamp.getTime());const a=o[t];const s=o[t-1];if(a)K(a);if(s)K(s)},[K,u,z,E,h]);const R=y(()=>{return F.filter(e=>{if(!e.data?.key)return false;if(!b.has(e.storageType))return false;const t=e.data.key;return!Array.from(T).some(o=>t.includes(o))})},[F,T,b]);const Ze=y(()=>It(R),[R]);const f=y(()=>{if(k==="all")return R;return R.filter(e=>e.storageType===k)},[R,k]);const et=i(()=>{return f.map(e=>({key:e.data?.key,action:e.action,value:_(e.data?.value),storageType:e.storageType,timestamp:e.timestamp.toISOString()}))},[f]);const tt=y(()=>f.slice(0,N),[f,N]);const Y=y(()=>Math.max(0,f.length-N),[f.length,N]);const nt=.8;const ot=i(e=>e.id,[]);const Se=i(e=>{const t=m.find(s=>s.key===e.data?.key);if(!t)return;const o=[...t.events].sort((s,w)=>s.timestamp.getTime()-w.timestamp.getTime());const a=o.findIndex(s=>s.timestamp.getTime()===e.timestamp.getTime());A(t.key);x(a>=0?a:0)},[m]);const rt=i(({item:e})=>{const t={key:e.data?.key||"",lastAction:e.action,totalOperations:1,lastEventTimestamp:e.timestamp,storageTypes:new Set([e.storageType]),valueType:O(e.data?.value)};return n(we,{data:t,onPress:()=>Se(e),testID:`buoy-storage-event-${e.id}`})},[Se]);if(!r)return null;const at=Ae?P.modal.root():P.storage.modal();const ve=()=>{if(D){return n(Ft,{ignoredPatterns:T,onTogglePattern:me,onAddPattern:fe,availableKeys:Ue,enabledStorageTypes:b,onToggleStorageType:Je})}if(B==="browser"){if(I&&E){if(h!==null){return n(S,{style:l.contentWrapper,children:n(xe,{conversation:E,selectedEventIndex:h,onEventIndexChange:v,disableInternalFooter:true})})}const t=[...E.events].sort((a,s)=>a.timestamp.getTime()-s.timestamp.getTime());const o=[...t].reverse();return n(Ee,{testID:"buoy-storage-history-list",style:l.flexFill,data:o,keyExtractor:a=>a.id,renderItem:({item:a})=>{const s=t.findIndex(Z=>Z.timestamp.getTime()===a.timestamp.getTime());const w={key:a.data?.key||"",lastAction:a.action,totalOperations:1,lastEventTimestamp:a.timestamp,storageTypes:new Set([a.storageType]),valueType:O(a.data?.value)};return n(we,{data:w,onPress:()=>v(s>=0?s:0),testID:`buoy-storage-history-event-${a.id}`})},contentContainerStyle:l.listContent,ItemSeparatorComponent:()=>n(S,{style:l.separator}),initialNumToRender:20})}return n(Et,{requiredStorageKeys:De,ignoredPatterns:T,onTogglePattern:me,onAddPattern:fe,searchQuery:le,storageDataRef:U,eventCountByKey:Ye,lastWriteByKey:Xe,onViewHistory:je,enabledStorageTypes:b,pinnedKeys:Oe,onTogglePin:$e,applySafeAreaInset:q==="bottomSheet",storageTypeFilter:k,onStorageTypeFilterChange:ge,detailKey:W,onOpenKey:H,onCloseDetail:()=>H(null)})}if(u){return n(S,{style:l.contentWrapper,children:n(xe,{conversation:u,selectedEventIndex:z,onEventIndexChange:x,disableInternalFooter:true})})}const e=n(S,{style:l.eventFilterBar,children:n(Ct,{active:k,onChange:ge,counts:Ze})});if(f.length===0){const t=k!=="all";return p(S,{style:l.flexFill,children:[e,n(gt,{testID:"buoy-storage-events-empty",...!ye?{otto:"paused",title:"Event listener is paused",message:"Press play to start monitoring"}:t?{otto:"filtering",title:`No ${k} events`,message:"Other backends have events \u2014 pick All Types to see them"}:{otto:"listening",title:"No storage events yet",message:"Storage operations will appear here"}})]})}return p(S,{style:l.flexFill,children:[e,n(Ee,{testID:"buoy-storage-events-list",style:l.flexFill,data:tt,renderItem:rt,keyExtractor:ot,onEndReachedThreshold:nt,contentContainerStyle:l.listContent,ListFooterComponent:Y>0?n(S,{style:l.lockedBannerContainer,children:n(wt,{featureName:`${Y} event${Y>1?"s":""} locked`,description:"Upgrade to Pro to unlock full event history"})}):null,initialNumToRender:10,maxToRenderPerBatch:10,windowSize:10})]})};const X=u&&u.events.length>1?n(ke,{conversation:u,selectedEventIndex:z,onEventIndexChange:x,applySafeAreaInset:q==="bottomSheet"}):E&&h!==null&&E.events.length>1?n(ke,{conversation:E,selectedEventIndex:h,onEventIndexChange:v,applySafeAreaInset:q==="bottomSheet"}):null;const st=D?()=>Q(false):h!==null?()=>v(null):I?pe:u?()=>{A(null);x(0)}:V;const Te=D?p(c,{children:[n(c.Navigation,{onBack:()=>Q(false)}),n(c.Content,{title:"Filters"})]}):I?p(c,{children:[n(c.Navigation,{onBack:h!==null?()=>v(null):pe}),n(c.Content,{title:`${I} History`,centered:true})]}):u?p(c,{children:[n(c.Navigation,{onBack:()=>{A(null);x(0)}}),n(c.Content,{title:u.key})]}):W?p(c,{children:[n(c.Navigation,{onBack:()=>H(null)}),n(c.Content,{title:W.key,centered:true,testID:"buoy-storage-detail-title"})]}):p(c,{children:[V&&n(c.Navigation,{onBack:V}),n(c.Content,{title:"",children:j?n(ft,{value:le,onChange:ie,onClear:()=>{ie("");$(false)},placeholder:"Search storage keys...",testID:"buoy-storage-search",autoFocus:true,onSubmitEditing:()=>$(false),returnKeyType:"search",containerStyle:l.headerSearchContainer}):n(ct,{tabs:[{key:"browser",label:"Storage"},{key:"events",label:`Events${f.length>0?` (${f.length})`:""}`}],activeTab:B,testIDPrefix:"buoy-storage-tab",onTabChange:e=>{Ke(e);J(null);v(null);A(null);x(0);H(null)}})}),p(c.Actions,{children:[se&&!j?n(te,{onPress:se,style:l.iconButton,testID:"buoy-storage-refresh",accessibilityLabel:"Refresh storage",accessibilityRole:"button",children:n(pt,{size:14,color:d.color.textSecondary})}):null,n(te,{onPress:Ge,testID:"buoy-storage-filters",accessibilityLabel:"Storage filters",accessibilityRole:"button",style:[l.iconButton,(T.size>0||b.size<3)&&l.activeFilterButton],children:n(yt,{size:14,color:T.size>0||b.size<3?d.color.accent:d.color.textSecondary})}),B==="browser"&&!j&&p(Be,{children:[n(te,{onPress:()=>$(true),testID:"buoy-storage-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",style:l.iconButton,children:n(mt,{size:14,color:d.color.textSecondary})}),n(Ce,{value:Qe,disabled:U.current.length===0,buttonStyle:l.iconButton,testID:"buoy-storage-copy"})]}),B==="events"&&p(Be,{children:[n(Ce,{value:et,disabled:f.length===0,buttonStyle:l.iconButton,testID:"buoy-storage-events-copy"}),n(ht,{isEnabled:ye,onToggle:Ve,accessibilityLabel:"Toggle storage event monitoring",testID:"buoy-storage-power"}),n(St,{onPress:We,buttonStyle:l.iconButton,testID:"buoy-storage-clear-events"})]})]})]});if(Re){return n(Ie,{children:p(S,{style:l.inlineRoot,children:[n(S,{style:l.inlineHeader,...bt,children:Te}),ve(),X]})})}return n(Ie,{children:n(it,{visible:r,onClose:C,onBack:st,onMinimize:Pe,persistenceKey:at,header:{showToggleButton:true,customContent:Te},onModeChange:Le,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:X,footerHeight:X?68:0,disableScrollWrapper:true,children:ve()})})}export function StorageToolView(r={}){return n(StorageModalWithTabs,{...r,inline:true,visible:true,onClose:()=>{}})}const l=lt.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:ut.border.default,backgroundColor:"transparent"},headerSearchContainer:{flex:1},flexFill:{flex:1},iconButton:{width:32,height:32,borderRadius:8,backgroundColor:d.color.buttonSurface,borderWidth:1,borderColor:d.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:d.color.accentSoft,borderColor:d.color.accentBorderStrong},separator:{height:8},listContent:{paddingVertical:6},lockedBannerContainer:{marginTop:8,marginHorizontal:16},eventFilterBar:{paddingHorizontal:12,paddingTop:8,paddingBottom:4},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:d.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:L,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:d.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:L},eventNavigation:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:8},navButton:{padding:4,borderRadius:4},navButtonDisabled:{opacity:.3},eventCounter:{color:d.color.text,fontSize:12,fontWeight:"600",fontFamily:L,paddingHorizontal:8},headerTopRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12},keyNameContainer:{flex:1,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:d.color.surfaceElevated,paddingHorizontal:10,paddingVertical:4,borderRadius:6,borderWidth:1,borderColor:d.color.border,height:28},keyNameText:{flex:1,fontSize:13,fontWeight:"600",color:d.color.accent,fontFamily:L,letterSpacing:.5},contentWrapper:{flex:1}});
1
+ "use strict";import{useState as g,useCallback as i,useEffect as ee,useRef as be,useMemo as y}from"react";import{View as S,TouchableOpacity as te,StyleSheet as lt,FlatList as Ee,Alert as ne}from"react-native";import oe from"../utils/appAsyncStorage";import{JsModal as it,ModalHeader as c,TabSelector as ct,parseValue as dt,devToolsStorageKeys as P,macOSColors as ut,night as d,ToolEmptyState as gt,Filter as yt,RefreshCw as pt,Search as mt,SearchBar as ft,PowerToggleButton as ht,ToolbarCopyButton as Ce,ToolbarClearButton as St,truncatePayload as _,TickProvider as Ie,useLimit as vt,TIER_LIMITS as Tt,windowDragProps as bt,usePersistedState as M,monoFont as L}from"@buoy-gg/shared-ui";import{StorageBrowserMode as Et}from"./StorageBrowserMode";import{StorageTypeFilterBar as Ct,countByStorageType as It}from"./StorageTypeFilterBar";import{clearAllAppStorage as xt,clearAllStorageIncludingDevTools as kt}from"../utils/clearAllStorage";import{ProFeatureBanner as wt}from"@buoy-gg/shared-ui";import{useStorageEvents as Bt}from"../hooks/useStorageEvents";import{StorageEventDetailContent as xe,StorageEventDetailFooter as ke}from"./StorageEventDetailContent";import{StorageEventFilterView as Ft}from"./StorageEventFilterView";import{StorageEventCard as we}from"./StorageEventCard";import{useIsPro as Pt}from"@buoy-gg/license";import{jsx as n,jsxs as p,Fragment as Be}from"react/jsx-runtime";export const FREE_TIER_EVENT_LIMIT=Tt["storage.events"].free;const re={getItem:r=>oe.getItem(r),setItem:(r,C)=>oe.setItem(r,C)};const At={storage:re,parse:r=>r==="browser"||r==="events"?r:void 0,serialize:r=>r};const Dt={storage:re,parse:r=>r==="true",serialize:r=>r.toString()};const Fe={storage:re,parse:r=>new Set(JSON.parse(r)),serialize:r=>JSON.stringify(Array.from(r))};const Rt={...Fe,parse:r=>{const C=JSON.parse(r);if(!C.includes("@react_buoy"))C.push("@react_buoy");return new Set(C)}};export function StorageModalWithTabs({visible:r,onClose:C,onBack:V,onMinimize:Pe,enableSharedModalDimensions:Ae=false,requiredStorageKeys:De=[],inline:Re=false,onTabChange:ae,onRefresh:se,onEventSelect:K}){const Kt=Pt();const N=vt("storage.events");const[B,Ke]=M(P.storage.activeTab(),"browser",At);ee(()=>{ae?.(B)},[B,ae]);const[le,ie]=g("");const[W,H]=g(null);const[j,$]=g(false);const[ce,Ne]=M(P.storage.isMonitoring(),true,Dt);const{events:F,clearEvents:de,isCapturing:He}=Bt({enabled:ce});const[G,A]=g(null);const[I,J]=g(null);const[h,v]=g(null);const[z,x]=g(0);const[D,Q]=g(false);const[T,ue]=M(P.storage.eventFilters(),new Set(["@react_buoy","@RNAsyncStorage","redux-persist","persist:"]),Rt);const[k,ge]=g("all");const[b,ze]=g(new Set(["async","mmkv","secure"]));const[Oe,_e]=M(P.storage.pinnedKeys(),new Set,Fe);const Nt=be(null);const ye=ce&&He;const[q,Me]=g("bottomSheet");const Le=i(e=>{Me(e)},[]);const Ve=i(()=>{Ne(e=>!e)},[]);const We=i(()=>{de();A(null);x(0)},[de]);const je=i(e=>{J(e);v(null)},[]);const pe=i(()=>{J(null);v(null)},[]);const me=i(e=>{ue(t=>{const o=new Set(t);if(o.has(e)){o.delete(e)}else{o.add(e)}return o})},[]);const fe=i(e=>{ue(t=>new Set([...t,e]))},[]);const $e=i(e=>{_e(t=>{const o=new Set(t);if(o.has(e)){o.delete(e)}else{o.add(e)}return o})},[]);const Ge=i(()=>{Q(!D)},[D]);const Je=i(e=>{ze(t=>{const o=new Set(t);if(o.has(e)){o.delete(e)}else{o.add(e)}return o})},[]);const U=be([]);const Qe=i(()=>{const e=U.current;return{timestamp:new Date().toISOString(),totalKeys:e.length,asyncStorage:e.filter(t=>t.storageType==="async").reduce((t,o)=>{t[o.key]=_(o.value);return t},{}),mmkv:e.filter(t=>t.storageType==="mmkv").reduce((t,o)=>{const a=o.instanceId||"default";if(!t[a])t[a]={};t[a][o.key]=_(o.value);return t},{}),secure:e.filter(t=>t.storageType==="secure").reduce((t,o)=>{t[o.key]=_(o.value);return t},{})}},[]);const Ht=i(async()=>{ne.alert("Clear Storage","Choose what to clear:",[{text:"Cancel",style:"cancel"},{text:"Clear App Storage",onPress:async()=>{try{await xt()}catch(e){ne.alert("Error","Failed to clear app storage")}}},{text:"Clear All (Including Dev Tools)",style:"destructive",onPress:async()=>{try{await kt()}catch(e){ne.alert("Error","Failed to clear all storage")}}}])},[]);const O=e=>{const t=dt(e);if(t===null)return"null";if(t===void 0)return"undefined";if(Array.isArray(t))return"array";if(typeof t==="boolean")return"boolean";if(typeof t==="number")return"number";if(typeof t==="string")return"string";if(typeof t==="object")return"object";return"undefined"};const[he,qe]=g([]);ee(()=>{const e=async()=>{try{const t=await oe.getAllKeys();qe([...t].sort())}catch(t){}};if(r){e()}},[r]);const Ue=y(()=>{const e=new Set(he);F.forEach(t=>{if(t.data?.key){e.add(t.data.key)}});return Array.from(e).sort()},[F,he]);const m=y(()=>{const e=new Map;F.forEach(t=>{if(!t.data?.key)return;const o=t.data.key;if(!b.has(t.storageType))return;const a=Array.from(T).some(w=>o.includes(w));if(a)return;const s=e.get(o);if(!s){e.set(o,{key:o,lastEvent:t,events:[t],totalOperations:1,currentValue:t.data.value,valueType:O(t.data.value),storageTypes:new Set([t.storageType])})}else{s.events.push(t);s.totalOperations++;s.storageTypes.add(t.storageType);if(t.timestamp>s.lastEvent.timestamp){s.lastEvent=t;s.currentValue=t.data.value;s.valueType=O(t.data.value)}}});return Array.from(e.values()).sort((t,o)=>o.lastEvent.timestamp.getTime()-t.lastEvent.timestamp.getTime())},[F,T,b]);const u=y(()=>{if(!G)return null;return m.find(e=>e.key===G)||null},[G,m]);const Ye=y(()=>{const e={};m.forEach(t=>{e[t.key]=t.totalOperations});return e},[m]);const Xe=y(()=>{const e={};m.forEach(t=>{e[t.key]=t.lastEvent.timestamp.getTime()});return e},[m]);const E=y(()=>{if(!I)return null;return m.find(e=>e.key===I)||null},[I,m]);ee(()=>{if(!K)return;const e=u?u:h!==null?E:null;const t=u?z:h;if(!e||t==null)return;const o=[...e.events].sort((w,Z)=>w.timestamp.getTime()-Z.timestamp.getTime());const a=o[t];const s=o[t-1];if(a)K(a);if(s)K(s)},[K,u,z,E,h]);const R=y(()=>{return F.filter(e=>{if(!e.data?.key)return false;if(!b.has(e.storageType))return false;const t=e.data.key;return!Array.from(T).some(o=>t.includes(o))})},[F,T,b]);const Ze=y(()=>It(R),[R]);const f=y(()=>{if(k==="all")return R;return R.filter(e=>e.storageType===k)},[R,k]);const et=i(()=>{return f.map(e=>({key:e.data?.key,action:e.action,value:_(e.data?.value),storageType:e.storageType,timestamp:e.timestamp.toISOString()}))},[f]);const tt=y(()=>f.slice(0,N),[f,N]);const Y=y(()=>Math.max(0,f.length-N),[f.length,N]);const nt=.8;const ot=i(e=>e.id,[]);const Se=i(e=>{const t=m.find(s=>s.key===e.data?.key);if(!t)return;const o=[...t.events].sort((s,w)=>s.timestamp.getTime()-w.timestamp.getTime());const a=o.findIndex(s=>s.timestamp.getTime()===e.timestamp.getTime());A(t.key);x(a>=0?a:0)},[m]);const rt=i(({item:e})=>{const t={key:e.data?.key||"",lastAction:e.action,totalOperations:1,lastEventTimestamp:e.timestamp,storageTypes:new Set([e.storageType]),valueType:O(e.data?.value)};return n(we,{data:t,onPress:()=>Se(e),testID:`buoy-storage-event-${e.id}`})},[Se]);if(!r)return null;const at=Ae?P.modal.root():P.storage.modal();const ve=()=>{if(D){return n(Ft,{ignoredPatterns:T,onTogglePattern:me,onAddPattern:fe,availableKeys:Ue,enabledStorageTypes:b,onToggleStorageType:Je})}if(B==="browser"){if(I&&E){if(h!==null){return n(S,{style:l.contentWrapper,children:n(xe,{conversation:E,selectedEventIndex:h,onEventIndexChange:v,disableInternalFooter:true})})}const t=[...E.events].sort((a,s)=>a.timestamp.getTime()-s.timestamp.getTime());const o=[...t].reverse();return n(Ee,{keyboardShouldPersistTaps:"handled",testID:"buoy-storage-history-list",style:l.flexFill,data:o,keyExtractor:a=>a.id,renderItem:({item:a})=>{const s=t.findIndex(Z=>Z.timestamp.getTime()===a.timestamp.getTime());const w={key:a.data?.key||"",lastAction:a.action,totalOperations:1,lastEventTimestamp:a.timestamp,storageTypes:new Set([a.storageType]),valueType:O(a.data?.value)};return n(we,{data:w,onPress:()=>v(s>=0?s:0),testID:`buoy-storage-history-event-${a.id}`})},contentContainerStyle:l.listContent,ItemSeparatorComponent:()=>n(S,{style:l.separator}),initialNumToRender:20})}return n(Et,{requiredStorageKeys:De,ignoredPatterns:T,onTogglePattern:me,onAddPattern:fe,searchQuery:le,storageDataRef:U,eventCountByKey:Ye,lastWriteByKey:Xe,onViewHistory:je,enabledStorageTypes:b,pinnedKeys:Oe,onTogglePin:$e,applySafeAreaInset:q==="bottomSheet",storageTypeFilter:k,onStorageTypeFilterChange:ge,detailKey:W,onOpenKey:H,onCloseDetail:()=>H(null)})}if(u){return n(S,{style:l.contentWrapper,children:n(xe,{conversation:u,selectedEventIndex:z,onEventIndexChange:x,disableInternalFooter:true})})}const e=n(S,{style:l.eventFilterBar,children:n(Ct,{active:k,onChange:ge,counts:Ze})});if(f.length===0){const t=k!=="all";return p(S,{style:l.flexFill,children:[e,n(gt,{testID:"buoy-storage-events-empty",...!ye?{otto:"paused",title:"Event listener is paused",message:"Press play to start monitoring"}:t?{otto:"filtering",title:`No ${k} events`,message:"Other backends have events \u2014 pick All Types to see them"}:{otto:"listening",title:"No storage events yet",message:"Storage operations will appear here"}})]})}return p(S,{style:l.flexFill,children:[e,n(Ee,{keyboardShouldPersistTaps:"handled",testID:"buoy-storage-events-list",style:l.flexFill,data:tt,renderItem:rt,keyExtractor:ot,onEndReachedThreshold:nt,contentContainerStyle:l.listContent,ListFooterComponent:Y>0?n(S,{style:l.lockedBannerContainer,children:n(wt,{featureName:`${Y} event${Y>1?"s":""} locked`,description:"Upgrade to Pro to unlock full event history"})}):null,initialNumToRender:10,maxToRenderPerBatch:10,windowSize:10})]})};const X=u&&u.events.length>1?n(ke,{conversation:u,selectedEventIndex:z,onEventIndexChange:x,applySafeAreaInset:q==="bottomSheet"}):E&&h!==null&&E.events.length>1?n(ke,{conversation:E,selectedEventIndex:h,onEventIndexChange:v,applySafeAreaInset:q==="bottomSheet"}):null;const st=D?()=>Q(false):h!==null?()=>v(null):I?pe:u?()=>{A(null);x(0)}:V;const Te=D?p(c,{children:[n(c.Navigation,{onBack:()=>Q(false)}),n(c.Content,{title:"Filters"})]}):I?p(c,{children:[n(c.Navigation,{onBack:h!==null?()=>v(null):pe}),n(c.Content,{title:`${I} History`,centered:true})]}):u?p(c,{children:[n(c.Navigation,{onBack:()=>{A(null);x(0)}}),n(c.Content,{title:u.key})]}):W?p(c,{children:[n(c.Navigation,{onBack:()=>H(null)}),n(c.Content,{title:W.key,centered:true,testID:"buoy-storage-detail-title"})]}):p(c,{children:[V&&n(c.Navigation,{onBack:V}),n(c.Content,{title:"",children:j?n(ft,{value:le,onChange:ie,onClear:()=>{ie("");$(false)},placeholder:"Search storage keys...",testID:"buoy-storage-search",autoFocus:true,onSubmitEditing:()=>$(false),returnKeyType:"search",containerStyle:l.headerSearchContainer}):n(ct,{tabs:[{key:"browser",label:"Storage"},{key:"events",label:`Events${f.length>0?` (${f.length})`:""}`}],activeTab:B,testIDPrefix:"buoy-storage-tab",onTabChange:e=>{Ke(e);J(null);v(null);A(null);x(0);H(null)}})}),p(c.Actions,{children:[se&&!j?n(te,{onPress:se,style:l.iconButton,testID:"buoy-storage-refresh",accessibilityLabel:"Refresh storage",accessibilityRole:"button",children:n(pt,{size:14,color:d.color.textSecondary})}):null,n(te,{onPress:Ge,testID:"buoy-storage-filters",accessibilityLabel:"Storage filters",accessibilityRole:"button",style:[l.iconButton,(T.size>0||b.size<3)&&l.activeFilterButton],children:n(yt,{size:14,color:T.size>0||b.size<3?d.color.accent:d.color.textSecondary})}),B==="browser"&&!j&&p(Be,{children:[n(te,{onPress:()=>$(true),testID:"buoy-storage-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",style:l.iconButton,children:n(mt,{size:14,color:d.color.textSecondary})}),n(Ce,{value:Qe,disabled:U.current.length===0,buttonStyle:l.iconButton,testID:"buoy-storage-copy"})]}),B==="events"&&p(Be,{children:[n(Ce,{value:et,disabled:f.length===0,buttonStyle:l.iconButton,testID:"buoy-storage-events-copy"}),n(ht,{isEnabled:ye,onToggle:Ve,accessibilityLabel:"Toggle storage event monitoring",testID:"buoy-storage-power"}),n(St,{onPress:We,buttonStyle:l.iconButton,testID:"buoy-storage-clear-events"})]})]})]});if(Re){return n(Ie,{children:p(S,{style:l.inlineRoot,children:[n(S,{style:l.inlineHeader,...bt,children:Te}),ve(),X]})})}return n(Ie,{children:n(it,{visible:r,onClose:C,onBack:st,onMinimize:Pe,persistenceKey:at,header:{showToggleButton:true,customContent:Te},onModeChange:Le,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:X,footerHeight:X?68:0,disableScrollWrapper:true,children:ve()})})}export function StorageToolView(r={}){return n(StorageModalWithTabs,{...r,inline:true,visible:true,onClose:()=>{}})}const l=lt.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:ut.border.default,backgroundColor:"transparent"},headerSearchContainer:{flex:1},flexFill:{flex:1},iconButton:{width:32,height:32,borderRadius:8,backgroundColor:d.color.buttonSurface,borderWidth:1,borderColor:d.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:d.color.accentSoft,borderColor:d.color.accentBorderStrong},separator:{height:8},listContent:{paddingVertical:6},lockedBannerContainer:{marginTop:8,marginHorizontal:16},eventFilterBar:{paddingHorizontal:12,paddingTop:8,paddingBottom:4},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:d.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:L,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:d.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:L},eventNavigation:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:8},navButton:{padding:4,borderRadius:4},navButtonDisabled:{opacity:.3},eventCounter:{color:d.color.text,fontSize:12,fontWeight:"600",fontFamily:L,paddingHorizontal:8},headerTopRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12},keyNameContainer:{flex:1,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:d.color.surfaceElevated,paddingHorizontal:10,paddingVertical:4,borderRadius:6,borderWidth:1,borderColor:d.color.border,height:28},keyNameText:{flex:1,fontSize:13,fontWeight:"600",color:d.color.accent,fontFamily:L,letterSpacing:.5},contentWrapper:{flex:1}});
package/lib/web/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  "use client";var Uo=Object.defineProperty;var Hi=Object.getOwnPropertyDescriptor;var qi=Object.getOwnPropertyNames;var ji=Object.prototype.hasOwnProperty;var no=(e,t)=>()=>(e&&(t=e(e=0)),t);var Fn=(e,t)=>{for(var r in t)Uo(e,r,{get:t[r],enumerable:true})},Go=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of qi(t))!ji.call(e,n)&&n!==r&&Uo(e,n,{get:()=>t[n],enumerable:!(o=Hi(t,n))||o.enumerable});return e},Ui=(e,t,r)=>(Go(e,t,"default"),r&&Go(r,t,"default"));var Gi=e=>Go(Uo({},"__esModule",{value:true}),e);var Ji,E=no(()=>{"use strict";Ji=(()=>{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{callCapacitorNative as Gt,hasCapacitorPlugin as Yi,installCapacitorBridge as Qi,interceptCapacitor as Zi,isCapacitorNative as Xi}from"@buoy-gg/license/web";function zr(){return Xi()&&Yi(ft)}function At(e,t){let r={action:e,data:t,timestamp:new Date};for(let o of Array.from(Kr))try{o(r)}catch{}}function el(e){return Kr.add(e),tl(),()=>{Kr.delete(e)}}async function lr(e){let{value:t}=await Gt(ft,"get",{key:e});return t??null}async function Jo(){let{keys:e}=await Gt(ft,"keys");return Array.isArray(e)?e:[]}async function ao(e){return Promise.all(e.map(async t=>[t,await lr(t)]))}function tl(){Yo||!zr()||!Qi()||(Yo=true,Zi({plugin:ft,methods:["set","remove","clear"],promise:async(e,t)=>{if(Kr.size===0)return t();let r=typeof e.options.key=="string"?e.options.key:void 0;if(e.method==="clear"){let i=Jo().catch(()=>[]),y=await t();return At("clear",{keys:await i}),y}if(r===void 0)return t();let o=lr(r).catch(()=>null),n=await t(),a=await o;return e.method==="set"?At("setItem",{key:r,value:String(e.options.value??""),prevValue:a}):At("removeItem",{key:r,prevValue:a}),n}}))}function Wn(e,t){if(!e||!t||typeof e!="object"||typeof t!="object"||Array.isArray(e)||Array.isArray(t))return t;let r={...e};for(let[o,n]of Object.entries(t))r[o]=o in r?Wn(r[o],n):n;return r}function $n(e){if(e===null)return null;try{return JSON.parse(e)}catch{return null}}var ft,Kr,Yo,io,lo=no(()=>{"use strict";E();ft="Preferences";Kr=new Set;Yo=false;io={getItem(e){return lr(e)},async setItem(e,t){let r=lr(e).catch(()=>null);await Gt(ft,"set",{key:e,value:String(t)}),At("setItem",{key:e,value:String(t),prevValue:await r})},async removeItem(e){let t=lr(e).catch(()=>null);await Gt(ft,"remove",{key:e}),At("removeItem",{key:e,prevValue:await t})},async clear(){let e=await ao(await Jo()).catch(()=>{});await Gt(ft,"clear"),At("clear",{prevPairs:e?.filter(t=>t[1]!==null)})},getAllKeys(){return Jo()},multiGet(e){return ao(e)},async multiSet(e){let t=ao(e.map(([r])=>r)).catch(()=>{});await Promise.all(e.map(([r,o])=>Gt(ft,"set",{key:r,value:String(o)}))),At("multiSet",{pairs:e.map(([r,o])=>[r,String(o)]),prevPairs:await t})},async multiRemove(e){let t=ao(e).catch(()=>{});await Promise.all(e.map(r=>Gt(ft,"remove",{key:r}))),At("multiRemove",{keys:[...e],prevPairs:await t})},async mergeItem(e,t){let r=await lr(e);await io.setItem(e,JSON.stringify(Wn($n(r),$n(t))))},async multiMerge(e){for(let[t,r]of e)await io.mergeItem(t,r)}}});import rl from"@buoy-gg/shared-ui/web/asyncStorage";var lt,_n,oe,mt=no(()=>{"use strict";E();lo();lt=()=>zr()?io:rl,_n={getItem:e=>lt().getItem(e),setItem:(e,t)=>lt().setItem(e,t),removeItem:e=>lt().removeItem(e),clear:()=>lt().clear(),getAllKeys:()=>lt().getAllKeys(),multiGet:e=>lt().multiGet(e),multiSet:e=>lt().multiSet(e),multiRemove:e=>lt().multiRemove(e),mergeItem:(e,t)=>lt().mergeItem(e,t),multiMerge:e=>lt().multiMerge(e)},oe=_n});var Nn={};Fn(Nn,{asyncStorage:()=>Fe,asyncStorageCaps:()=>Hn,default:()=>qn,readMany:()=>so,removeMany:()=>sr,writeMany:()=>Or});async function so(e){if(typeof Fe.multiGet=="function")return await Fe.multiGet(e);let t=await Fe.getMany(e);return e.map(r=>[r,t[r]??null])}async function Or(e){if(typeof Fe.multiSet=="function")return Fe.multiSet(e);let t={};for(let[r,o]of e)t[r]=o;return Fe.setMany(t)}async function sr(e){return typeof Fe.multiRemove=="function"?Fe.multiRemove(e):Fe.removeMany(e)}var Fe,Hn,qn,Jt=no(()=>{"use strict";E();mt();Fe=oe,Hn={hasLegacyMultiApi:typeof Fe?.multiGet=="function",hasMergeApi:typeof Fe?.mergeItem=="function"};qn=Fe});E();E();mt();Jt();import{classifyPreviewItem as ol,createRestoreScope as nl,emptyRestoreResult as jn,failedRestore as al,isDevToolsStorageKey as we,registerStateSnapshotProvider as il,unionKeys as co,wontApply as Lr}from"@buoy-gg/shared-ui/web";E();mt();Jt();import{isDevToolsStorageKey as ll}from"@buoy-gg/shared-ui/web";async function uo(){let e=await oe.getAllKeys();if(!e||e.length===0)return;let t=e.filter(r=>!ll(r));t.length!==0&&await sr(t)}async function sl(){await oe.clear()}E();E();import{isDevToolsStorageKey as cl}from"@buoy-gg/shared-ui/web";E();function kt(e,t){let r=e.getString(t);if(r!==void 0&&r!=="")return{value:r,type:"string"};let o=e.getNumber(t);if(o!==void 0)return{value:o,type:"number"};let n=e.getBoolean(t);if(n!==void 0)return{value:n,type:"boolean"};if(r==="")return{value:"",type:"string"};let a=e.getBuffer(t);return a!==void 0?{value:`<ArrayBuffer ${a.byteLength} bytes>`,type:"buffer"}:{value:void 0,type:"unknown"}}function dl(e,t){if(e===void 0)return"undefined";if(e===null)return"null";switch(t){case"string":return`"${e}"`;case"number":return String(e);case"boolean":return e?"true":"false";case"buffer":return e;case"unknown":return"unknown";default:return String(e)}}function Qo(e,t){return e===t}var ul=class{constructor(){this.listeners=[];this.instances=new Map;this.ignoredKeys=new Set(["@react_buoy_storage_event_filters","@react_buoy_storage_key_filters","@react_buoy_storage_is_monitoring","REACT_QUERY_OFFLINE_CACHE"])}shouldIgnoreKey(e){if(cl(e)||this.ignoredKeys.has(e))return true;for(let t of this.ignoredKeys)if(e.startsWith(t))return true;return false}emit(e){this.listeners.length!==0&&this.listeners.forEach(t=>{try{t(e)}catch{}})}addInstance(e,t){if(this.instances.has(t))return;let r,o=new Map;try{for(let n of e.getAllKeys()??[])this.shouldIgnoreKey(n)||o.set(n,kt(e,n).value)}catch{}if(typeof e.addOnValueChangedListener=="function")try{r=e.addOnValueChangedListener(n=>{if(this.shouldIgnoreKey(n))return;let{value:a,type:i}=kt(e,n),y=o.get(n);if(i==="unknown"||a===void 0){o.delete(n);let d={action:"delete",timestamp:new Date,instanceId:t,data:{key:n,prevValue:y,success:true}};this.emit(d)}else{o.set(n,a);let d={action:i==="string"?"set.string":i==="number"?"set.number":i==="boolean"?"set.boolean":i==="buffer"?"set.buffer":"set.string",timestamp:new Date,instanceId:t,data:{key:n,value:a,prevValue:y,valueType:i,success:true}};this.emit(d)}})}catch{}this.instances.set(t,{instance:e,instanceId:t,originalMethods:{},nativeListenerUnsubscribe:r,lastKnownValues:o})}removeInstance(e){let t=this.instances.get(e);if(!t)return;let{nativeListenerUnsubscribe:r}=t;try{typeof r=="function"?r():typeof r?.remove=="function"&&r.remove()}catch{}this.instances.delete(e)}removeAllInstances(){Array.from(this.instances.keys()).forEach(e=>this.removeInstance(e))}addListener(e){return this.listeners.push(e),()=>{let t=this.listeners.indexOf(e);t>-1&&this.listeners.splice(t,1)}}removeAllListeners(){this.listeners=[]}hasInstance(e){return this.instances.has(e)}getMonitoredInstances(){return Array.from(this.instances.keys())}get instanceCount(){return this.instances.size}get listenerCount(){return this.listeners.length}get isActive(){return this.instances.size>0}},Zo=new ul;var Un=e=>Zo.addListener(e);var yl=class{constructor(){this.instances=new Map}register(e,t,r){let o={id:e,instance:t,encrypted:r?.encrypted??false,readOnly:t.isReadOnly??false};this.instances.set(e,o)}unregister(e){this.instances.delete(e)}get(e){return this.instances.get(e)}getAll(){return Array.from(this.instances.values())}has(e){return this.instances.has(e)}count(){return this.instances.size}},Le=new yl;function Gn(e,t,r){Le.register(e,t,r),Zo.addInstance(t,e)}function Jn(e){Zo.removeInstance(e),Le.unregister(e)}E();var gl=class{constructor(){this.module=null;this.keys=new Map;this.listeners=new Set}register(e,t){let r=this.signature();this.module=e;for(let o of t){let n=typeof o=="string"?{key:o,options:{}}:{key:o.key,description:o.description,options:{keychainService:o.keychainService,requireAuthentication:o.requireAuthentication,authenticationPrompt:o.authenticationPrompt}};this.keys.set(n.key,n)}this.signature()!==r&&this.notify()}unregister(e){this.keys.delete(e)&&this.notify()}subscribe(e){return this.listeners.add(e),()=>{this.listeners.delete(e)}}signature(){return JSON.stringify(Array.from(this.keys.values()))}notify(){this.listeners.forEach(e=>{try{e()}catch{}})}getModule(){return this.module}getAll(){return Array.from(this.keys.values())}count(){return this.keys.size}async deleteValue(e){let t=this.keys.get(e);!this.module||!t||await this.module.deleteItemAsync(e,t.options)}async setValue(e,t){let r=this.keys.get(e);if(!this.module)throw new Error("No SecureStore module is registered");if(!r)throw new Error(`SecureStore key "${e}" is not registered`);if(r.options.requireAuthentication)throw new Error(`SecureStore key "${e}" is biometric-protected \u2014 DevTools never writes it`);await this.module.setItemAsync(e,t,r.options)}},ee=new gl;function pl(e,t){ee.register(e,t)}function fl(e){ee.unregister(e)}function Yn(e,t){e.remove?e.remove(t):e.delete?.(t)}function ml(){return{canCapture:true,canRestore:true}}async function Qn(){let e=[],t=(await oe.getAllKeys()).filter(i=>!we(i)),r=(await so(t)).filter(i=>i[1]!==null),o={};for(let{id:i,instance:y}of Le.getAll().filter(({id:d})=>!we(d)))try{o[i]=y.getAllKeys().filter(d=>!we(d)).map(d=>{let{value:p,type:s}=kt(y,d);return s==="buffer"&&e.push(`mmkv "${i}"/"${d}": ArrayBuffer value not capturable`),{key:d,value:p,valueType:s}})}catch{e.push(`mmkv "${i}": unreadable, captured without entries`),o[i]=[]}let n={},a=ee.getModule();for(let{key:i,options:y}of ee.getAll().filter(({key:d})=>!we(d))){if(y.requireAuthentication){e.push(`secure "${i}": biometric-protected, not capturable`);continue}let d=null;if(a)try{d=await a.getItemAsync(i,y)}catch{e.push(`secure "${i}": unreadable, captured as unset`)}n[i]=d}return{data:{async:r,mmkv:o,secure:n},warnings:e}}async function hl(){let{data:e,warnings:t}=await Qn();return{data:e,warnings:t}}async function bl(e,t){let r=e,o=nl(t),n=o.touch,a=jn();if(!r)return al("empty storage snapshot");try{let d=(r.async??[]).filter(([g])=>!we(g)&&n(`async:${g}`)),p=new Set(d.map(([g])=>g)),s=(await oe.getAllKeys()).filter(g=>!we(g)).filter(g=>!p.has(g)&&n(`async:${g}`));o.countExcluded((r.async??[]).length-d.length),s.length>0&&await sr(s),d.length>0&&await Or(d),a.applied+=d.length+s.length}catch(d){a.ok=false,a.warnings.push(`asyncstorage restore failed: ${String(d)}`)}for(let[d,p]of Object.entries(r.mmkv??{})){if(we(d))continue;let s=Le.get(d);if(!s){a.skipped.push({id:`mmkv:${d}`,reason:"instance not registered"});continue}if(s.instance.isReadOnly){a.skipped.push({id:`mmkv:${d}`,reason:"instance registered read-only"});continue}let{instance:g}=s;try{let f=new Set(p.map(m=>m.key)),C=g.getAllKeys().filter(m=>!we(m));for(let m of C)o.allows(`mmkv:${d}/${m}`)&&(f.has(m)||(Yn(g,m),a.applied+=1));for(let m of p)if(!we(m.key)&&n(`mmkv:${d}/${m.key}`)){if(m.valueType==="buffer"){a.skipped.push({id:`mmkv:${d}/${m.key}`,reason:"ArrayBuffer values cannot be restored"});continue}g.set(m.key,m.value),a.applied+=1}}catch(f){a.ok=false,a.warnings.push(`mmkv "${d}" restore failed: ${String(f)}`)}}let i=r.secure??{};for(let{key:d,options:p}of ee.getAll().filter(({key:s})=>!we(s)))if(o.allows(`secure:${d}`)){if(p.requireAuthentication){d in i&&a.skipped.push({id:`secure:${d}`,reason:"biometric-protected keys are never written"});continue}try{if(d in i){let s=i[d];s===null?await ee.deleteValue(d):await ee.setValue(d,s)}else await ee.deleteValue(d);a.applied+=1}catch(s){a.ok=false,a.warnings.push(`secure "${d}" restore failed: ${String(s)}`)}}for(let d of Object.keys(i))we(d)||n(`secure:${d}`)&&(ee.getAll().filter(({key:p})=>!we(p)).some(p=>p.key===d)||a.skipped.push({id:`secure:${d}`,reason:"key no longer registered with registerSecureStoreKeys"}));let y=o.excludedWarning("item(s)");return y&&a.warnings.push(y),a}async function vl(){let e=jn();try{await uo(),e.applied+=1}catch(t){e.ok=false,e.warnings.push(`asyncstorage clear failed: ${String(t)}`)}for(let{id:t,instance:r}of Le.getAll().filter(({id:o})=>!we(o))){if(r.isReadOnly){e.skipped.push({id:`mmkv:${t}`,reason:"instance registered read-only"});continue}try{for(let o of r.getAllKeys().filter(n=>!we(n)))Yn(r,o),e.applied+=1}catch(o){e.ok=false,e.warnings.push(`mmkv "${t}" clear failed: ${String(o)}`)}}for(let{key:t,options:r}of ee.getAll().filter(({key:o})=>!we(o))){if(r.requireAuthentication){e.skipped.push({id:`secure:${t}`,reason:"biometric-protected keys are never written"});continue}try{await ee.deleteValue(t),e.applied+=1}catch(o){e.ok=false,e.warnings.push(`secure "${t}" clear failed: ${String(o)}`)}}return e}var Sl=256*1024;function Xo(e,t,r,o,n,a){return ol({key:e,label:t,oldValue:r,newValue:o,inOld:n,inNew:a},{equal:Object.is,tooLarge:i=>typeof i=="string"&&i.length>Sl,tooLargeReason:"value too large to render a diff \u2014 restore still applies it"})}async function wl(e,t){let r=e??{async:[],mmkv:{},secure:{}},o=t===void 0,n=o?(await Qn()).data:t??{async:[],mmkv:{},secure:{}},a=[],i=[],y=new Map(n.async??[]),d=new Map(r.async??[]);for(let f of co(y,d))we(f)||a.push(Xo(`async:${f}`,f,y.get(f),d.get(f),y.has(f),d.has(f)));for(let f of co(n.mmkv,r.mmkv)){if(we(f))continue;let C=o?Le.get(f):null,m=o&&!C,b=o&&C?.instance.isReadOnly===true,S=new Map((n.mmkv?.[f]??[]).map(T=>[T.key,T])),w=new Map((r.mmkv?.[f]??[]).map(T=>[T.key,T]));for(let T of co(S,w)){if(we(T))continue;let I=`mmkv:${f}/${T}`,R=`${f} \xB7 ${T}`,D=S.get(T),x=w.get(T),B=Xo(I,R,D?.value,x?.value,S.has(T),w.has(T));m?B=Lr(B,"MMKV instance not registered"):b?B=Lr(B,"MMKV instance registered read-only"):(x?.valueType==="buffer"||D?.valueType==="buffer")&&(B=Lr(B,"ArrayBuffer values cannot be restored")),a.push(B)}}let p=n.secure??{},s=r.secure??{},g=o?new Map(ee.getAll().filter(({key:f})=>!we(f)).map(f=>[f.key,f])):null;for(let f of co(p,s)){if(we(f))continue;let C=Xo(`secure:${f}`,f,p[f],s[f],f in p,f in s);if(o){let m=g?.get(f);m?m.options.requireAuthentication&&(C=Lr(C,"biometric-protected keys are never written")):C=Lr(C,"key no longer registered with registerSecureStoreKeys")}a.push(C)}return{items:a,notes:i}}il({id:"storage",label:"Storage",status:ml,capture:hl,restore:bl,clear:vl,previewItems:wl});E();import{StorageIcon as kl}from"@buoy-gg/floating-tools-core/web";import{createToolFactory as Cl,defineToolPreset as xl}from"@buoy-gg/shared-ui/web";E();import{useState as ot,useCallback as De,useEffect as en,useRef as Zn,useMemo as st}from"react";var Xn={};Fn(Xn,{AccessibilityInfo:()=>Rl,ActivityIndicator:()=>Es,Alert:()=>Ie,Animated:()=>Yt,AppRegistry:()=>Vl,AppState:()=>Al,Appearance:()=>Bl,BackHandler:()=>Dl,Button:()=>Rs,CheckBox:()=>Ul,Clipboard:()=>Ml,DeviceEventEmitter:()=>ss,Dimensions:()=>zl,Easing:()=>Pr,FlatList:()=>tn,I18nManager:()=>Kl,Image:()=>Gl,ImageBackground:()=>Jl,InteractionManager:()=>Ll,Keyboard:()=>Ol,KeyboardAvoidingView:()=>Yl,LayoutAnimation:()=>Pl,Linking:()=>Fl,LogBox:()=>ls,Modal:()=>aa,NativeEventEmitter:()=>Wl,NativeModules:()=>El,PanResponder:()=>$l,Picker:()=>Ql,PixelRatio:()=>_l,Platform:()=>Nl,Pressable:()=>Ts,ProgressBar:()=>Zl,RefreshControl:()=>Xl,SafeAreaView:()=>es,ScrollView:()=>Wr,SectionList:()=>ts,Share:()=>Hl,StatusBar:()=>rs,StyleSheet:()=>pe,Switch:()=>Is,Text:()=>u,TextInput:()=>ks,Touchable:()=>os,TouchableHighlight:()=>Cs,TouchableNativeFeedback:()=>ns,TouchableOpacity:()=>O,TouchableWithoutFeedback:()=>xs,UIManager:()=>ql,Vibration:()=>jl,View:()=>l,VirtualizedList:()=>as,YellowBox:()=>is,findNodeHandle:()=>Bs,unstable_createElement:()=>Il,useColorScheme:()=>cs,useLocaleContext:()=>ds,useWindowDimensions:()=>us});E();Ui(Xn,Tl);import*as Tl from"react-native-web";import{unstable_createElement as Il,NativeModules as El,AccessibilityInfo as Rl,Appearance as Bl,AppRegistry as Vl,AppState as Al,BackHandler as Dl,Clipboard as Ml,Dimensions as zl,Easing as Pr,I18nManager as Kl,Keyboard as Ol,InteractionManager as Ll,LayoutAnimation as Pl,Linking as Fl,NativeEventEmitter as Wl,PanResponder as $l,PixelRatio as _l,Platform as Nl,Share as Hl,UIManager as ql,Vibration as jl,CheckBox as Ul,FlatList as tn,Image as Gl,ImageBackground as Jl,KeyboardAvoidingView as Yl,Picker as Ql,ProgressBar as Zl,RefreshControl as Xl,SafeAreaView as es,SectionList as ts,StatusBar as rs,Touchable as os,TouchableNativeFeedback as ns,VirtualizedList as as,YellowBox as is,LogBox as ls,DeviceEventEmitter as ss,useColorScheme as cs,useLocaleContext as ds,useWindowDimensions as us}from"react-native-web";import*as We from"react-native-web";import{createElement as rn,forwardRef as ea,useCallback as ys,useRef as gs}from"react";E();import{useEffect as ps,useState as fs}from"react";import{createPortal as ms}from"react-dom";E();var hs='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as bs}from"react/jsx-runtime";var Fr=Symbol.for("@buoy-gg/portal-host"),ta=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 ra(){let e=document;if(e[Fr])return e[Fr].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:hs});let r=()=>{let s=document.fullscreenElement,g=s&&s.tagName!=="CANVAS"?s:document.body;t.parentElement!==g&&g.appendChild(t)},o=new Map,n=s=>{(!t.contains(s.target)||!ta(s.target))&&o.set(s.code||s.key,{key:s.key,code:s.code,location:s.location,keyCode:s.keyCode,which:s.which,altKey:s.altKey,ctrlKey:s.ctrlKey,metaKey:s.metaKey,shiftKey:s.shiftKey})},a=s=>{o.delete(s.code||s.key)},i=()=>o.clear(),y=()=>{let s=[...o.values()];o.clear();for(let g of s)document.dispatchEvent(new KeyboardEvent("keyup",{...g,bubbles:true}))},d=s=>{ta(s.target)&&s.stopPropagation()},p=s=>s.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",n,true),document.addEventListener("keyup",a,true),window.addEventListener("blur",i),t.addEventListener("focusin",y),t.addEventListener("keydown",d),t.addEventListener("keyup",d),t.addEventListener("keypress",d),t.addEventListener("wheel",p,{passive:true}),e[Fr]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",n,true),document.removeEventListener("keyup",a,true),window.removeEventListener("blur",i),t.remove(),delete e[Fr]}},t}function vs({children:e}){let[t,r]=fs(null);return ps(()=>{let o=ra(),n=document[Fr];return n.users++,r(o),()=>{--n.users===0&&n.dispose()}},[]),t?ms(bs("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}var cr=We,Ss=["shadowColor","shadowOffset","shadowOpacity","shadowRadius","textShadowColor","textShadowOffset","textShadowRadius"],dr=e=>typeof e=="number"?`${e}px`:e;function on(e){if(Array.isArray(e)){let g=e.map(on);return g.some((f,C)=>f!==e[C])?g:e}if(!e||typeof e!="object"||!Ss.some(g=>e[g]!=null))return e;let{shadowColor:t,shadowOffset:r,shadowOpacity:o,shadowRadius:n,textShadowColor:a,textShadowOffset:i,textShadowRadius:y,...d}=e;if(t!=null||r!=null||o!=null||n!=null){let g=t??"black",f=o==null?g:`color-mix(in srgb, ${g} ${Math.min(o,1)*100}%, transparent)`,C=`${dr(r?.width??0)} ${dr(r?.height??0)} ${dr(n??0)} ${f}`;d.boxShadow=typeof d.boxShadow=="string"?`${d.boxShadow}, ${C}`:d.boxShadow??C}let{width:p=0,height:s=0}=i??{};if(a&&(p||s||y)){let g=`${dr(p)} ${dr(s)} ${dr(y??0)} ${a}`;d.textShadow=d.textShadow?`${d.textShadow}, ${g}`:g}return d}var ws=cr.StyleSheet.create({auto:{pointerEvents:"auto"},none:{pointerEvents:"none"},"box-none":{pointerEvents:"box-none"},"box-only":{pointerEvents:"box-only"}});function oa(e,t){if(typeof e=="function")return o=>oa(e(o),t);let r=on(e);return t?[r,ws[t]]:r}var pe={...cr.StyleSheet,create:e=>cr.StyleSheet.create(Object.fromEntries(Object.entries(e).map(([t,r])=>[t,on(r)])))};function nt(e){let t=ea((o,n)=>{let{accessibilityState:a,accessibilityValue:i,pointerEvents:y,...d}=o;for(let s of["busy","checked","disabled","expanded","selected"])a?.[s]!==void 0&&d[`aria-${s}`]===void 0&&(d[`aria-${s}`]=a[s]);for(let[s,g]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[s]!==void 0&&d[`aria-${g}`]===void 0&&(d[`aria-${g}`]=i[s]);let p=oa(d.style,y);return p!==d.style&&(d.style=p),rn(e,{...d,ref:n})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var l=nt(We.View),u=nt(We.Text),Yt={...cr.Animated,View:cr.Animated.createAnimatedComponent(l),Text:cr.Animated.createAnimatedComponent(u)},ks=nt(We.TextInput),O=nt(We.TouchableOpacity),Cs=nt(We.TouchableHighlight),xs=nt(We.TouchableWithoutFeedback),Ts=nt(We.Pressable),Wr=nt(We.ScrollView),na=ea((e,t)=>{let r=gs(null),o=ys(n=>{if(n){let a=n;for(;a.parentElement&&a.parentElement!==document.body;)a=a.parentElement;a.parentElement===document.body&&(r.current=a,Object.assign(a.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),ra().appendChild(a))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(n):t&&(t.current=n)},[t]);return rn(vs,null,rn(We.Modal,{...e,ref:o}))});na.displayName="Modal";var aa=nt(na),Is=nt(We.Switch),Es=nt(We.ActivityIndicator),Rs=nt(We.Button),Bs=We.findNodeHandle,Ie={alert(e,t,r,o){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 a=document.createElement("h2");if(a.textContent=e,a.style.cssText="font-size:18px;margin:0 0 12px",n.appendChild(a),t){let p=document.createElement("p");p.textContent=t,p.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",n.appendChild(p)}let i=document.createElement("div");i.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let y=r?.length?r:[{text:"OK"}],d=()=>{n.close?.(),n.remove()};for(let p of y){let s=document.createElement("button");s.type="button",s.textContent=p.text??"OK",s.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${p.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,s.onclick=()=>{d(),p.onPress?.()},i.appendChild(s)}n.addEventListener("cancel",p=>{p.preventDefault(),o?.cancelable!==false&&(d(),o?.onDismiss?.())}),n.appendChild(i),document.body.appendChild(n),n.showModal?n.showModal():n.setAttribute("open","")}};mt();import{JsModal as Vs,ModalHeader as Me,TabSelector as As,parseValue as Ds,devToolsStorageKeys as ur,macOSColors as Ms,night as $e,ToolEmptyState as zs,Filter as Ks,RefreshCw as Os,Search as Ls,SearchBar as Ps,PowerToggleButton as Fs,ToolbarCopyButton as ia,ToolbarClearButton as Ws,truncatePayload as yo,TickProvider as la,useLimit as $s,TIER_LIMITS as _s,windowDragProps as Ns,usePersistedState as go,monoFont as po}from"@buoy-gg/shared-ui/web";E();E();E();lo();var ae=zr()?{async:"Preferences",asyncFull:"Capacitor Preferences",mmkv:"Web",secure:"Secure",hasSecure:false}:{async:"Local",asyncFull:"localStorage",mmkv:"Session",secure:"Secure",hasSecure:false};import{useMemo as _e,useCallback as Xe,useState as Qt,useEffect as yr,useRef as nn}from"react";import{absoluteFill as sa,useLimit as ca,TIER_LIMITS as Hs,monoFont as $r}from"@buoy-gg/shared-ui/web";import{Database as da,Zap as qs,ProBadge as ua,ProUpgradeModal as js,ToolEmptyState as Us,resolveListEmptyState as Gs}from"@buoy-gg/shared-ui/web";import{isDevToolsStorageKey as ze}from"@buoy-gg/shared-ui/web";E();import{useCallback as ya,useState as Js}from"react";E();import{memo as Ys}from"react";import{macOSColors as fe,night as ce,CompactRow as Qs,TypeBadge as ga,HardDrive as Zs,Square as Xs,CheckSquare as ec,Edit3 as tc,EyeOff as rc,Pin as pa,Trash2 as oc,ExpandedInfoRow as an,PillBadge as _r,monoFont as gr}from"@buoy-gg/shared-ui/web";E();import{gameUIColors as fo}from"@buoy-gg/shared-ui/web";var nc=new Set(["sessionStorage","localStorage"]);function ln(e,t){switch(e){case"mmkv":return t&&!nc.has(t)?"MMKV":ae.mmkv;case"async":return ae.async;case"secure":return"Secure";default:return e}}function fa(e){switch(e){case"mmkv":return fo.info;case"async":return fo.warning;case"secure":return fo.success;default:return fo.muted}}E();function Dt(e){if(e===null)return"null";if(e===void 0)return"undefined";if(Array.isArray(e))return"array";let t=typeof e;return t==="object"?"object":t==="boolean"?"boolean":t==="number"?"number":t==="string"?"string":"unknown"}function ma(e){if(typeof e!="string")return e;let t=e.trim();if(!t.startsWith("{")&&!t.startsWith("["))return e;try{return JSON.parse(e)}catch{return e}}var ac=40;function ic(e){switch(typeof e){case"boolean":return e?"true":"false";case"number":return Number.isFinite(e)?String(e):null;case"string":return e.length===0?'""':e.length>ac?null:`"${e.replace(/\s+/g," ")}"`;default:return null}}function lc(e){let t=Dt(e),r=ic(e);return r?`${t} \xB7 ${r}`:t}import{DataViewer as sc}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as cc,jsx as W,jsxs as Ve}from"react/jsx-runtime";var ha=[fe.semantic.info,fe.semantic.success,fe.semantic.warning,fe.semantic.debug,"#FF6B9D","#00D9FF"];function ba(e){let t=e.split("").reduce((r,o)=>r+o.charCodeAt(0),0);return ha[t%ha.length]}var va=e=>{switch(e){case"required_present":return{label:"Valid",color:fe.semantic.success,sublabel:"Required"};case"required_missing":return{label:"Missing",color:fe.semantic.error,sublabel:"Required"};case"required_wrong_value":return{label:"Wrong",color:fe.semantic.warning,sublabel:"Invalid value"};case"required_wrong_type":return{label:"Type Error",color:fe.semantic.info,sublabel:"Wrong type"};case"optional_present":return{label:"Set",color:fe.semantic.debug,sublabel:"Optional"};default:return{label:"Set",color:fe.text.secondary,sublabel:String(e)}}},dc=e=>e==null?"undefined":typeof e=="string"?e:JSON.stringify(e),uc=Ys(function({storageKey:e,isExpanded:t,onPress:r,isSelectMode:o=false,isSelected:n=false,onSelectionChange:a,eventCount:i,onViewHistory:y,onHideKey:d,isPinned:p=false,onTogglePin:s,onEditKey:g,onToggleKey:f,onDeleteKey:C,editBlockedReason:m}){let b=g!=null&&m==null,S=va(e.status),w=e.value!==void 0&&e.value!==null,T=w&&typeof e.value=="boolean",I=e.key,R=ln(e.storageType,e.instanceId),D=ma(e.value),x=D!==null&&typeof D=="object",B=Ve(l,{style:$.expandedContainer,children:[W(an,{label:"Storage",children:W(_r,{color:sn(e.storageType),children:R})}),e.storageType==="mmkv"&&e.instanceId&&W(an,{label:"Instance",children:W(_r,{color:ba(e.instanceId),icon:W(Zs,{size:9,color:ba(e.instanceId)}),children:e.instanceId})}),i!=null&&i>0&&Ve(an,{label:"Updates",children:[W(_r,{color:fe.semantic.warning,children:String(i)}),i>1&&y&&W(O,{onPress:y,testID:"buoy-storage-key-history",accessibilityLabel:`View history for ${e.key}`,accessibilityRole:"button",style:$.viewHistoryButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:W(u,{style:$.viewHistoryText,children:"view history \u2192"})})]}),x?W(l,{style:$.dataViewerContainer,children:W(sc,{data:D,title:"",showTypeFilter:true,rawMode:true,initialExpanded:true})}):Ve(l,{style:$.expandedRow,children:[W(u,{style:$.expandedLabel,children:"Value:"}),W(u,{style:$.expandedValue,numberOfLines:3,children:dc(e.value)||"undefined"})]}),e.status==="required_wrong_type"&&e.expectedType&&Ve(cc,{children:[Ve(l,{style:$.expandedRow,children:[W(u,{style:$.expandedLabel,children:"Type:"}),W(ga,{type:Dt(e.value)})]}),Ve(l,{style:$.expandedRow,children:[W(u,{style:$.expandedLabel,children:"Expected:"}),W(ga,{type:e.expectedType})]})]}),e.status==="required_wrong_value"&&e.expectedValue&&Ve(l,{style:$.expandedRow,children:[W(u,{style:$.expandedLabel,children:"Expected:"}),W(u,{style:$.expandedExpected,children:String(e.expectedValue)})]}),e.description?Ve(l,{style:$.expandedRow,children:[W(u,{style:$.expandedLabel,children:"Info:"}),W(u,{style:$.expandedDescription,children:e.description})]}):null,m?Ve(l,{style:$.expandedRow,children:[W(u,{style:$.expandedLabel,children:"Edit:"}),W(u,{style:$.expandedDescription,children:m})]}):null,s||d||b?Ve(l,{style:$.actionRow,children:[b?Ve(O,{style:$.editButton,testID:"buoy-storage-key-edit",accessibilityLabel:T&&f?`Toggle ${e.key}`:`Edit ${e.key}`,accessibilityRole:"button",onPress:()=>T&&f?f(e):g?.(e),hitSlop:{top:6,bottom:6,left:6,right:6},children:[W(tc,{size:13,color:ce.color.onAccent}),W(u,{style:$.editButtonText,children:T&&f?"Toggle":"Edit"})]}):null,s?Ve(O,{style:[$.actionChip,p&&$.actionChipActive],testID:"buoy-storage-key-pin",accessibilityLabel:p?`Unpin ${e.key}`:`Pin ${e.key} to top`,accessibilityRole:"button",onPress:()=>s(e.key),hitSlop:{top:6,bottom:6,left:6,right:6},children:[W(pa,{size:12,active:p,color:ce.color.accent}),W(u,{style:[$.actionChipText,{color:ce.color.accent}],children:p?"Unpin":"Pin to top"})]}):null,d?Ve(O,{style:$.actionChip,testID:"buoy-storage-key-hide",accessibilityLabel:`Hide ${e.key} from list`,accessibilityRole:"button",onPress:()=>d(e),hitSlop:{top:6,bottom:6,left:6,right:6},children:[W(rc,{size:12,color:ce.color.warning}),W(u,{style:[$.actionChipText,{color:ce.color.warning}],children:"Hide from list"})]}):null,b&&C?Ve(O,{style:[$.actionChip,$.dangerChip],testID:"buoy-storage-key-delete",accessibilityLabel:`Delete key ${e.key}`,accessibilityRole:"button",onPress:()=>C(e),hitSlop:{top:6,bottom:6,left:6,right:6},children:[W(oc,{size:12,color:ce.color.danger}),W(u,{style:[$.actionChipText,{color:ce.color.danger}],children:"Delete key"})]}):null]}):null]}),Q=()=>{a?.(e,!n)},ve=o?W(O,{onPress:Q,testID:`buoy-storage-checkbox-${e.storageType}-${e.key}`,accessibilityLabel:`Select ${e.key}`,accessibilityRole:"checkbox",accessibilityState:{checked:n},style:$.checkboxContainer,hitSlop:{top:8,bottom:8,left:8,right:8},children:n?W(ec,{size:18,color:ce.color.accent}):W(Xs,{size:18,color:ce.color.textTertiary})}):null;return Ve(l,{style:[$.rowContainer,n&&$.rowContainerSelected],children:[ve,Ve(l,{style:$.compactRowWrapper,children:[W(Qs,{statusDotColor:S.color,statusLabel:S.label,statusSublabel:S.sublabel,primaryText:I,secondaryText:w?T?Dt(e.value):lc(e.value):void 0,secondaryAccessory:T?W(_r,{size:"sm",color:e.value?fe.semantic.success:fe.semantic.error,children:e.value?"true":"false"}):void 0,expandedContent:B,isExpanded:t,expandedGlowColor:S.color,customBadge:Ve(l,{style:$.badgeRow,children:[p&&W(pa,{size:12,active:true,color:ce.color.accent}),W(_r,{color:sn(e.storageType),children:R})]}),showChevron:!o,onPress:o?Q:r?()=>r(e):void 0,testID:`buoy-storage-row-${e.storageType}-${e.key}`,accessibilityLabel:`${R} ${e.key}`}),i!=null&&i>1&&W(l,{style:[$.absCountBadge,t&&$.absCountBadgeExpanded,{backgroundColor:fe.semantic.warning+"22",borderColor:fe.semantic.warning+"55"}],pointerEvents:"none",children:W(u,{style:[$.absCountText,{color:fe.semantic.warning}],children:String(i)})})]})]})}),sn=e=>{switch(e){case"mmkv":return fe.semantic.info;case"async":return fe.semantic.warning;case"secure":return fe.semantic.success;default:return fe.text.secondary}},$=pe.create({badgeRow:{flexDirection:"row",alignItems:"center",gap:6},expandedContainer:{gap:8},expandedRow:{flexDirection:"row",alignItems:"center",gap:10},expandedLabel:{fontSize:10,color:ce.color.textTertiary,fontWeight:"600",minWidth:70,fontFamily:gr},expandedValue:{fontSize:11,color:ce.color.textSecondary,fontFamily:gr,flex:1},expandedExpected:{fontSize:11,color:fe.semantic.warning,fontFamily:gr,flex:1},expandedDescription:{fontSize:11,color:ce.color.textSecondary,flex:1},dataViewerContainer:{marginTop:6,marginBottom:6,backgroundColor:ce.color.bg,borderRadius:6,borderWidth:1,borderColor:ce.color.border,padding:6},rowContainer:{flexDirection:"row",alignItems:"flex-start"},rowContainerSelected:{backgroundColor:ce.color.accentSoft,borderRadius:8},checkboxContainer:{paddingLeft:4,paddingRight:8,paddingTop:10,alignSelf:"flex-start"},compactRowWrapper:{flex:1},absCountBadge:{position:"absolute",top:4,right:10,paddingHorizontal:5,paddingVertical:1,borderRadius:4,borderWidth:1,zIndex:1},absCountBadgeExpanded:{top:13},absCountText:{fontSize:9,fontWeight:"700",fontFamily:gr},actionRow:{flexDirection:"row",alignItems:"center",flexWrap:"wrap",gap:8,marginTop:4},actionChip:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:6,paddingHorizontal:10,borderRadius:6,backgroundColor:ce.color.surface,borderWidth:1,borderColor:ce.color.border},dangerChip:{borderColor:ce.color.danger+"55"},actionChipActive:{backgroundColor:ce.color.accentSoft,borderColor:ce.color.accentBorderStrong},editButton:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:8,paddingHorizontal:14,borderRadius:8,backgroundColor:ce.color.accent},editButtonText:{color:ce.color.onAccent,fontSize:12,fontWeight:"700"},actionChipText:{fontSize:11,fontWeight:"600",fontFamily:gr},viewHistoryButton:{marginLeft:4},viewHistoryText:{fontSize:10,fontWeight:"600",fontFamily:gr,color:ce.color.accent}});import{SectionHeader as pr,night as cn}from"@buoy-gg/shared-ui/web";import{jsx as Ct,jsxs as mo}from"react/jsx-runtime";function dn(e){return e.instanceId?`${e.storageType}-${e.instanceId}-${e.key}`:`${e.storageType}-${e.key}`}function Sa({title:e,count:t,keys:r,emptyMessage:o,headerColor:n,isSelectMode:a=false,selectedKeys:i=new Set,onSelectionChange:y,eventCountByKey:d,onViewHistory:p,onHideKey:s,pinnedKeys:g,onTogglePin:f,onEditKey:C,onToggleKey:m,onDeleteKey:b,editBlockedFor:S,onRowRef:w,onOpenKey:T}){let I=ya(B=>dn(B),[]),[R,D]=Js(null),x=ya(B=>{if(!B||typeof B.key!="string")return;if(T){T(B);return}let Q=I(B);D(ve=>ve===Q?null:Q)},[I,T]);return r.length===0&&e==="Required Keys"?mo(l,{style:Nr.sectionContainer,children:[mo(pr,{children:[Ct(pr.Title,{children:e}),Ct(pr.Badge,{count:0,color:n})]}),Ct(l,{style:Nr.emptySection,children:Ct(u,{style:Nr.emptySectionText,children:o})})]}):r.length===0?null:mo(l,{style:Nr.sectionContainer,children:[e?mo(pr,{children:[Ct(pr.Title,{children:e}),t>=0&&Ct(pr.Badge,{count:t,color:n})]}):null,Ct(l,{style:Nr.sectionContent,children:r.map(B=>{let Q=I(B);return Ct(l,{ref:w?ve=>w(Q,ve):void 0,collapsable:false,children:Ct(uc,{storageKey:B,isExpanded:!a&&R===Q,onPress:x,isSelectMode:a,isSelected:i.has(Q),onSelectionChange:y,eventCount:d?.[B.key],onViewHistory:p?()=>p(B.key):void 0,onHideKey:s,onEditKey:C,onToggleKey:m,onDeleteKey:b,editBlockedReason:S?.(B),isPinned:g?.has(B.key),onTogglePin:f})},Q)})})]})}var Nr=pe.create({sectionContainer:{gap:8},sectionContent:{},emptySection:{backgroundColor:cn.color.surface,borderRadius:6,padding:16,borderWidth:1,borderColor:cn.color.border,alignItems:"center"},emptySectionText:{color:cn.color.textTertiary,fontSize:11,textAlign:"center"}});E();import{useCallback as yc,useMemo as wa,useRef as ka,useState as Ca}from"react";import{EyeOff as gc,FileJson as pc,HardDrive as fc,night as J,macOSColors as fr,Pin as mc,PillBadge as ho,Trash2 as hc,TypeBadge as bc,useSafeAreaInsets as vc,monoFont as Mt}from"@buoy-gg/shared-ui/web";import{DataViewer as Sc,LiveExplorer as wc,ValueEditModal as kc,updateNestedDataByPath as Cc,deleteNestedDataByPath as xc}from"@buoy-gg/shared-ui/web/dataViewer";import{jsx as L,jsxs as me}from"react/jsx-runtime";var Tc=300,ht="buoy-storage-detail";function Ic(e){let t=r=>r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"");return e.length===0?`${ht}-explorer-root`:`${ht}-explorer-${e.map(t).filter(Boolean).join("-")}`}var xa=[fr.semantic.info,fr.semantic.success,fr.semantic.warning,fr.semantic.debug,"#FF6B9D","#00D9FF"];function Ta(e){let t=e.split("").reduce((r,o)=>r+o.charCodeAt(0),0);return xa[t%xa.length]}function Ec({storageKey:e,editBlockedReason:t,eventCount:r,onSave:o,onViewHistory:n,onDeleteKey:a,onHideKey:i,isPinned:y=false,onTogglePin:d,applySafeAreaInset:p}){let s=vc(),g=p?s.bottom:0,f=t==null,C=va(e.status),m=ln(e.storageType,e.instanceId),[b,S]=Ca(false),[w,T]=Ca(0),I=ka(null),R=wa(()=>ma(e.value),[e.value]),D=typeof e.value=="string"?e.value:JSON.stringify(e.value);I.current&&I.current.raw===D&&(I.current=null);let x=I.current?I.current.value:R,B=yc(q=>{let ue=typeof q=="string"?q:JSON.stringify(q);I.current={raw:ue,value:q},o(ue).catch(te=>{I.current=null,Ie.alert("Couldn't save",te instanceof Error?te.message:String(te))})},[o]),Q=ka(x);Q.current=x;let ve=wa(()=>{if(f)return{update:(q,ue)=>{let te=q.length===0?ue:Cc(Q.current,q,ue);B(te)},remove:q=>{q.length!==0&&B(xc(Q.current,q))}}},[f,B]),Se=d||i||f&&a;return me(l,{style:A.screen,children:[L(l,{testID:`${ht}-key`,accessibilityLabel:e.key}),me(Wr,{testID:`${ht}-scroll`,style:A.scroll,contentContainerStyle:[A.scrollContent,{paddingBottom:24+g}],keyboardShouldPersistTaps:"handled",children:[L(l,{style:A.section,children:me(l,{style:A.editorContainer,children:[me(l,{style:A.sectionHeaderRow,children:[L(u,{testID:`${ht}-editor-header`,style:A.sectionHeaderAccentText,children:"Value Editor"}),f?me(O,{onPress:()=>S(true),testID:`${ht}-raw`,accessibilityRole:"button",accessibilityLabel:"Edit raw JSON",style:A.rawButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:[L(pc,{size:13,color:J.color.accent}),L(u,{style:A.rawButtonText,children:"Raw"})]}):null]}),me(l,{style:A.sectionBody,children:[L(wc,{editable:f,label:"Value",value:x,defaultExpanded:["Value"],writer:ve,dataVersion:w,testIDForPath:Ic,debounceMs:Tc}),f?L(u,{style:A.editorHint,children:"Edits write to the device as you make them \u2014 undo lives in the key's history."}):L(u,{style:A.blockedText,testID:`${ht}-edit-blocked`,children:t})]})]})}),L(l,{style:A.section,children:me(l,{style:A.infoContainer,children:[L(u,{style:A.sectionHeaderPlain,children:"Key Details"}),me(l,{style:A.infoBody,children:[me(l,{style:A.infoRow,children:[L(u,{style:A.infoLabel,children:"Status:"}),L(ho,{color:C.color,testID:`${ht}-status`,children:C.label}),L(u,{style:A.infoDim,children:C.sublabel})]}),me(l,{style:A.infoRow,children:[L(u,{style:A.infoLabel,children:"Storage:"}),L(ho,{color:sn(e.storageType),testID:`${ht}-backend`,children:m}),L(u,{style:A.infoDim,children:Dt(e.value)})]}),e.storageType==="mmkv"&&e.instanceId&&me(l,{style:A.infoRow,children:[L(u,{style:A.infoLabel,children:"Instance:"}),L(ho,{color:Ta(e.instanceId),icon:L(fc,{size:9,color:Ta(e.instanceId)}),children:e.instanceId})]}),r!=null&&r>0&&me(l,{style:A.infoRow,children:[L(u,{style:A.infoLabel,children:"Updates:"}),L(ho,{color:fr.semantic.warning,children:String(r)}),r>1&&n&&L(O,{onPress:n,testID:"buoy-storage-key-history",accessibilityLabel:`View history for ${e.key}`,accessibilityRole:"button",style:A.inlineLinkButton,hitSlop:{top:6,bottom:6,left:6,right:6},children:L(u,{style:A.inlineLinkText,children:"view history \u2192"})})]}),e.status==="required_wrong_type"&&e.expectedType&&me(l,{style:A.infoRow,children:[L(u,{style:A.infoLabel,children:"Expected:"}),L(bc,{type:e.expectedType}),me(u,{style:A.infoDim,children:["got ",Dt(e.value)]})]}),e.status==="required_wrong_value"&&e.expectedValue&&me(l,{style:A.infoRow,children:[L(u,{style:A.infoLabel,children:"Expected:"}),L(u,{style:A.infoExpected,children:String(e.expectedValue)})]}),e.description?me(l,{style:A.infoRow,children:[L(u,{style:A.infoLabel,children:"Info:"}),L(u,{style:A.infoDescription,children:e.description})]}):null]})]})}),L(l,{style:A.section,children:me(l,{style:A.infoContainer,children:[L(u,{style:A.sectionHeaderPlain,children:"Value Explorer"}),L(l,{style:A.viewerBody,testID:`${ht}-viewer`,children:x!==null&&typeof x=="object"?L(Sc,{title:"",data:x,showTypeFilter:true,rawMode:true,initialExpanded:false}):L(u,{style:A.rawValueText,selectable:true,children:D??"undefined"})})]})}),Se?me(l,{style:A.actionRow,children:[d?me(O,{style:[A.actionChip,y&&A.actionChipActive],testID:"buoy-storage-key-pin",accessibilityLabel:y?`Unpin ${e.key}`:`Pin ${e.key} to top`,accessibilityRole:"button",onPress:()=>d(e.key),hitSlop:{top:6,bottom:6,left:6,right:6},children:[L(mc,{size:12,active:y,color:J.color.accent}),L(u,{style:[A.actionChipText,{color:J.color.accent}],children:y?"Unpin":"Pin to top"})]}):null,i?me(O,{style:A.actionChip,testID:"buoy-storage-key-hide",accessibilityLabel:`Hide ${e.key} from list`,accessibilityRole:"button",onPress:()=>i(e),hitSlop:{top:6,bottom:6,left:6,right:6},children:[L(gc,{size:12,color:J.color.warning}),L(u,{style:[A.actionChipText,{color:J.color.warning}],children:"Hide from list"})]}):null,f&&a?me(O,{style:[A.actionChip,A.dangerChip],testID:"buoy-storage-key-delete",accessibilityLabel:`Delete key ${e.key}`,accessibilityRole:"button",onPress:()=>a(e),hitSlop:{top:6,bottom:6,left:6,right:6},children:[L(hc,{size:12,color:J.color.danger}),L(u,{style:[A.actionChipText,{color:J.color.danger}],children:"Delete key"})]}):null]}):null]}),b&&f?L(kc,{path:[],value:x,onSave:q=>{B(q),T(ue=>ue+1),S(false)},onCancel:()=>S(false),saveLabel:"Apply",testIDPrefix:"buoy-storage-value"}):null]})}var A=pe.create({screen:{flex:1,minHeight:0},scroll:{flex:1},scrollContent:{paddingHorizontal:8,paddingTop:8},section:{marginBottom:16},editorContainer:{minWidth:200,backgroundColor:J.color.surface,borderRadius:6,borderWidth:1,borderColor:J.color.accent+"4D",overflow:"hidden",shadowColor:J.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},sectionHeaderRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:J.color.accent+"1A",paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:J.color.accent+"33"},sectionHeaderAccentText:{fontWeight:"600",fontSize:12,color:J.color.accent,letterSpacing:.5,textTransform:"uppercase",fontFamily:Mt},rawButton:{flexDirection:"row",alignItems:"center",gap:4},rawButtonText:{color:J.color.accent,fontSize:11,fontWeight:"700"},sectionBody:{padding:8},editorHint:{color:J.color.textTertiary,fontSize:10,paddingTop:8,paddingHorizontal:4,lineHeight:14},blockedText:{color:J.color.textSecondary,fontSize:12,padding:12,lineHeight:18},infoContainer:{minWidth:200,backgroundColor:J.color.surface,borderRadius:6,borderWidth:1,borderColor:J.color.border,overflow:"hidden"},sectionHeaderPlain:{backgroundColor:J.color.surfaceElevated,paddingHorizontal:12,paddingVertical:8,fontWeight:"600",fontSize:12,color:J.color.textSecondary,borderBottomWidth:1,borderBottomColor:J.color.border,letterSpacing:.5,textTransform:"uppercase",fontFamily:Mt},infoBody:{padding:12,gap:10},infoRow:{flexDirection:"row",alignItems:"center",gap:8},infoLabel:{fontSize:10,color:J.color.textTertiary,fontWeight:"600",minWidth:64,fontFamily:Mt},infoDim:{color:J.color.textTertiary,fontSize:10,fontFamily:Mt},infoExpected:{fontSize:11,color:fr.semantic.warning,fontFamily:Mt,flex:1},infoDescription:{fontSize:11,color:J.color.textSecondary,flex:1},rawValueText:{color:J.color.textSecondary,fontSize:11,fontFamily:Mt,lineHeight:16,padding:12},viewerBody:{backgroundColor:J.color.bg,minHeight:48},inlineLinkButton:{marginLeft:4},inlineLinkText:{fontSize:10,fontWeight:"600",fontFamily:Mt,color:J.color.accent},actionRow:{flexDirection:"row",alignItems:"center",flexWrap:"wrap",gap:8,paddingHorizontal:4},actionChip:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:6,paddingHorizontal:10,borderRadius:6,backgroundColor:J.color.surface,borderWidth:1,borderColor:J.color.border},dangerChip:{borderColor:J.color.danger+"55"},actionChipActive:{backgroundColor:J.color.accentSoft,borderColor:J.color.accentBorderStrong},actionChipText:{fontSize:11,fontWeight:"600",fontFamily:Mt}});E();E();E();function Ia(){return ae.hasSecure||ee.count()>0}import{macOSColors as un,night as zt,monoFont as Rc}from"@buoy-gg/shared-ui/web";import{jsx as yn,jsxs as Bc}from"react/jsx-runtime";var Vc=[{id:"all",label:"All Types",color:null},{id:"async",label:ae.async,color:un.semantic.warning},{id:"mmkv",label:ae.mmkv,color:un.semantic.info},{id:"secure",label:"Secure",color:un.semantic.success}];function gn({active:e,onChange:t,counts:r}){return yn(l,{style:Hr.row,children:Vc.filter(o=>Ia()||o.id!=="secure").map(o=>{let n=e===o.id,a=o.color??zt.color.accent;return Bc(O,{testID:`buoy-storage-type-${o.id}`,accessibilityRole:"button",accessibilityLabel:`Filter by ${o.label}`,accessibilityState:{selected:n},activeOpacity:.8,onPress:()=>t(o.id),style:[Hr.pill,{borderColor:zt.color.border},n&&[Hr.pillActive,o.color?{backgroundColor:o.color+"15",borderColor:o.color+"40"}:{backgroundColor:zt.color.accentSoft,borderColor:zt.color.accentBorderStrong}]],children:[yn(u,{style:[Hr.label,n&&{color:a,fontWeight:"600"}],children:o.label}),yn(u,{style:[Hr.value,{color:n?a:zt.color.textTertiary}],children:r[o.id]})]},o.id)})})}function Ea(e){let t={all:e.length,async:0,mmkv:0,secure:0};for(let r of e)t[r.storageType]+=1;return t}var Hr=pe.create({row:{flexDirection:"row",gap:8,marginTop:2},pill:{flex:1,backgroundColor:zt.color.buttonSurface,borderRadius:8,borderWidth:1,borderColor:zt.color.border,paddingVertical:6,paddingHorizontal:8,alignItems:"center",justifyContent:"center",minHeight:32},pillActive:{borderWidth:1,transform:[{scale:1.005}]},label:{fontSize:9,color:zt.color.textSecondary,textTransform:"uppercase",letterSpacing:.4,fontWeight:"500",marginBottom:1},value:{fontSize:12,fontWeight:"600",fontFamily:Rc,lineHeight:14}});import{macOSColors as Kt,night as Pe,monoFont as Ac}from"@buoy-gg/shared-ui/web";E();function pn(){try{return typeof window<"u"&&!!window.sessionStorage}catch{return false}}function Dc(){return null}function Ra(){return"Session storage is unavailable in this browser context."}import{jsx as Zt,jsxs as qr}from"react/jsx-runtime";var jy=pn();function Mc({stats:e,tabStats:t,healthPercentage:r,healthStatus:o,healthColor:n,activeFilter:a="all",onFilterChange:i,activeStorageType:y="all",onStorageTypeChange:d,showStatus:p=true}){let s=t||{validCount:e.presentRequiredCount+e.optionalCount,missingCount:e.missingCount,issuesCount:e.wrongValueCount+e.wrongTypeCount,asyncCount:e.asyncCount||0,mmkvCount:e.mmkvCount||0,secureCount:e.secureCount||0,totalCount:e.totalCount};return qr(l,{style:Ne.container,children:[p?qr(l,{style:Ne.filtersRow,children:[qr(O,{style:[Ne.filterChip,a==="all"&&[Ne.filterChipActive,{backgroundColor:Pe.color.accentSoft,borderColor:Pe.color.accentBorderStrong,shadowColor:Pe.color.accent}]],onPress:()=>i?.("all"),activeOpacity:.8,testID:"buoy-storage-status-all",accessibilityRole:"button",accessibilityLabel:"Valid keys",children:[Zt(u,{style:[Ne.filterValue,{color:Pe.color.text}],children:s.validCount}),Zt(u,{style:Ne.filterLabel,children:"Valid"})]}),qr(O,{style:[Ne.filterChip,a==="missing"&&[Ne.filterChipActive,{backgroundColor:Kt.semantic.error+"10",borderColor:Kt.semantic.error+"30",shadowColor:Kt.semantic.error}]],onPress:()=>i?.("missing"),activeOpacity:.8,testID:"buoy-storage-status-missing",accessibilityRole:"button",accessibilityLabel:"Missing keys",children:[Zt(u,{style:[Ne.filterValue,{color:s.missingCount>0?Kt.semantic.error:Pe.color.textTertiary}],children:s.missingCount}),Zt(u,{style:Ne.filterLabel,children:"Missing"})]}),qr(O,{style:[Ne.filterChip,a==="issues"&&[Ne.filterChipActive,{backgroundColor:Kt.semantic.warning+"10",borderColor:Kt.semantic.warning+"30",shadowColor:Kt.semantic.warning}]],onPress:()=>i?.("issues"),activeOpacity:.8,testID:"buoy-storage-status-issues",accessibilityRole:"button",accessibilityLabel:"Issues keys",children:[Zt(u,{style:[Ne.filterValue,{color:s.issuesCount>0?Kt.semantic.warning:Pe.color.textTertiary}],children:s.issuesCount}),Zt(u,{style:Ne.filterLabel,children:"Issues"})]})]}):null,d&&Zt(gn,{active:y,onChange:d,counts:{all:s.totalCount,async:s.asyncCount,mmkv:s.mmkvCount,secure:s.secureCount}})]})}var Ne=pe.create({container:{backgroundColor:Pe.color.surface,borderRadius:12,padding:16,borderWidth:1,borderColor:Pe.color.border,gap:14,shadowColor:"#000000",shadowOpacity:.03,shadowRadius:12,shadowOffset:{width:0,height:2}},topRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},titleLeft:{flexDirection:"row",alignItems:"center",gap:8,flexShrink:1},healthDot:{width:6,height:6,borderRadius:3},titleText:{fontSize:12,fontWeight:"600",color:Pe.color.text,letterSpacing:.5,textTransform:"uppercase"},titleDivider:{width:4,height:1,backgroundColor:Pe.color.border,marginHorizontal:4},subtitleText:{color:Pe.color.textTertiary,fontSize:11},healthBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:6,borderWidth:1},healthBadgeText:{fontSize:10,fontWeight:"600",fontVariant:["tabular-nums"]},healthProgressBar:{height:3,borderRadius:1.5,backgroundColor:Pe.color.bg,overflow:"hidden"},healthProgressFill:{height:3,borderRadius:1.5},filtersRow:{flexDirection:"row",gap:10},filterChip:{flex:1,backgroundColor:Pe.color.buttonSurface,borderRadius:8,borderWidth:1,borderColor:Pe.color.border,paddingVertical:10,paddingHorizontal:12,alignItems:"center",justifyContent:"center",minHeight:44},filterChipActive:{borderWidth:1,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6,elevation:2,transform:[{scale:1.005}]},filterLabel:{fontSize:9,color:Pe.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,fontWeight:"500",marginTop:3},filterValue:{fontSize:18,fontWeight:"600",fontFamily:Ac,lineHeight:20}});E();mt();Jt();import{isDevToolsStorageKey as zc}from"@buoy-gg/shared-ui/web";import{useState as fn,useEffect as Kc,useCallback as Oc,useRef as Lc}from"react";E();function Ot(e,t){return typeof e=="string"?t==="async":e.storageType?e.storageType===t:true}function mn(e=[]){let[t,r]=fn([]),[o,n]=fn(true),[a,i]=fn(null),y=JSON.stringify(e),d=Lc(e);d.current=e;let p=Oc(async()=>{let s=d.current;n(true),i(null);try{let g=(await oe.getAllKeys()).filter(m=>!zc(m));if(!g||g.length===0){r([]),n(false);return}let f=await so(g),C=[];f.forEach(([m,b])=>{let S=b;if(b)try{S=JSON.parse(b)}catch{S=b}let w=s.find(R=>Ot(R,"async")?typeof R=="string"?R===m:R.key===m:false),T="optional_present";w&&(S==null?T="required_missing":typeof w=="object"&&w.expectedValue!==void 0?T=S===w.expectedValue?"required_present":"required_wrong_value":typeof w=="object"&&w.expectedType!==void 0?T=(S===null?"null":typeof S).toLowerCase()===w.expectedType.toLowerCase()?"required_present":"required_wrong_type":T="required_present");let I={key:m,value:S,storageType:"async",status:T,category:w?"required":"optional",...typeof w=="object"&&w.expectedValue!==void 0&&{expectedValue:w.expectedValue},...typeof w=="object"&&w.expectedType!==void 0&&{expectedType:w.expectedType},...typeof w=="object"&&w.description!==void 0&&{description:w.description}};C.push(I)}),s.forEach(m=>{if(!Ot(m,"async"))return;let b=typeof m=="string"?m:m.key;C.some(S=>S.key===b)||C.push({key:b,value:void 0,storageType:"async",status:"required_missing",category:"required",...typeof m=="object"&&m.expectedValue!==void 0&&{expectedValue:m.expectedValue},...typeof m=="object"&&m.expectedType!==void 0&&{expectedType:m.expectedType},...typeof m=="object"&&m.description!==void 0&&{description:m.description}})}),r(C)}catch(g){i(g instanceof Error?g:new Error("Failed to fetch storage data")),r([])}finally{n(false)}},[y]);return Kc(()=>{p()},[p]),{storageKeys:t,isLoading:o,error:a,refresh:p}}E();lo();import{isDevToolsStorageKey as Pc,appStorageEvent as Fc}from"@buoy-gg/shared-ui/web";import{subscribeToBrowserStorage as Wc}from"@buoy-gg/shared-ui/web/utils";var hn=new Set,bo,Ba=false,$c=new Set(["@react_buoy_storage_event_filters","@react_buoy_storage_key_filters","@react_buoy_storage_is_monitoring","REACT_QUERY_OFFLINE_CACHE"]),Va=e=>Pc(e)||[...$c].some(t=>e.startsWith(t));function Aa(e){let t=Fc(e);if(t){e=t;for(let r of[...hn])try{r(e)}catch{}}}async function _c(){if(!(bo||typeof window>"u")){if(zr()){bo=el(e=>{Ba||Aa(e)});return}bo=Wc(e=>{if(Ba||e.area!=="localStorage"||e.key!==void 0&&Va(e.key))return;let{area:t,action:r,...o}=e;o.prevPairs&&(o.prevPairs=o.prevPairs.filter(([n])=>!Va(n))),Aa({action:r,data:o,timestamp:new Date})})}}function Da(e){return hn.add(e),()=>{hn.delete(e)}}function Nc(){return!!bo}E();import{isDevToolsStorageKey as Ma}from"@buoy-gg/shared-ui/web";import{useState as mr,useEffect as za,useCallback as Ka,useRef as Oa}from"react";function Hc(e,t,r=[]){let[o,n]=mr([]),[a,i]=mr(true),[y,d]=mr(null),p=JSON.stringify(r),s=Oa(r);s.current=r;let g=Ka(()=>{let f=s.current;i(true),d(null);try{if(!e){n([]),i(false);return}let C=e.getAllKeys().filter(b=>!Ma(b));if(!C||C.length===0){let b=f.filter(S=>Ot(S,"mmkv")).map(S=>{let w=typeof S=="string"?S:S.key,T=typeof S=="object"?S.description:void 0,I=typeof S=="object"?S.expectedValue:void 0,R=typeof S=="object"?S.expectedType:void 0;return{key:w,value:void 0,valueType:void 0,storageType:"mmkv",instanceId:t,status:"required_missing",category:"required",description:T,expectedValue:I,expectedType:R}});n(b),i(false);return}let m=[];C.forEach(b=>{let{value:S,type:w}=kt(e,b),T=f.find(D=>Ot(D,"mmkv")?typeof D=="string"?D===b:D.key===b:false),I="optional_present";T&&(S===void 0?I="required_missing":typeof T=="object"&&T.expectedValue!==void 0?I=String(S)===String(T.expectedValue)?"required_present":"required_wrong_value":typeof T=="object"&&T.expectedType!==void 0?I=Qo(w,T.expectedType)?"required_present":"required_wrong_type":I="required_present");let R={key:b,value:S,valueType:w!=="unknown"?w:void 0,storageType:"mmkv",instanceId:t,status:I,category:T?"required":"optional",lastUpdated:new Date,...typeof T=="object"&&T.expectedValue!==void 0&&{expectedValue:T.expectedValue},...typeof T=="object"&&T.expectedType!==void 0&&{expectedType:T.expectedType},...typeof T=="object"&&T.description!==void 0&&{description:T.description}};m.push(R)}),f.forEach(b=>{if(!Ot(b,"mmkv"))return;let S=typeof b=="string"?b:b.key;m.some(w=>w.key===S)||m.push({key:S,value:void 0,valueType:void 0,storageType:"mmkv",instanceId:t,status:"required_missing",category:"required",...typeof b=="object"&&b.expectedValue!==void 0&&{expectedValue:b.expectedValue},...typeof b=="object"&&b.expectedType!==void 0&&{expectedType:b.expectedType},...typeof b=="object"&&b.description!==void 0&&{description:b.description}})}),n(m)}catch(C){d(C instanceof Error?C:new Error("Failed to fetch MMKV storage data")),n([])}finally{i(false)}},[e,t,p]);return za(()=>{g()},[g]),{storageKeys:o,isLoading:a,error:y,refresh:g}}function La(e,t=[]){let[r,o]=mr([]),[n,a]=mr(true),[i,y]=mr(null),d=JSON.stringify(t),p=Oa(t);p.current=t;let s=Ka(()=>{let g=p.current;a(true),y(null);try{let f=[];e.forEach(({instance:C,id:m})=>{let b=C.getAllKeys().filter(S=>!Ma(S));!b||b.length===0||b.forEach(S=>{let{value:w,type:T}=kt(C,S),I=g.find(x=>Ot(x,"mmkv")?typeof x=="string"?x===S:x.key===S:false),R="optional_present";I&&(w===void 0?R="required_missing":typeof I=="object"&&I.expectedValue!==void 0?R=String(w)===String(I.expectedValue)?"required_present":"required_wrong_value":typeof I=="object"&&I.expectedType!==void 0?R=Qo(T,I.expectedType)?"required_present":"required_wrong_type":R="required_present");let D={key:S,value:w,valueType:T!=="unknown"?T:void 0,storageType:"mmkv",instanceId:m,status:R,category:I?"required":"optional",lastUpdated:new Date,...typeof I=="object"&&I.expectedValue!==void 0&&{expectedValue:I.expectedValue},...typeof I=="object"&&I.expectedType!==void 0&&{expectedType:I.expectedType},...typeof I=="object"&&I.description!==void 0&&{description:I.description}};f.push(D)})}),g.forEach(C=>{if(!Ot(C,"mmkv"))return;let m=typeof C=="string"?C:C.key;if(!f.some(b=>b.key===m)){let b=e[0]?.id||"mmkv.default";f.push({key:m,value:void 0,valueType:void 0,storageType:"mmkv",instanceId:b,status:"required_missing",category:"required",...typeof C=="object"&&C.expectedValue!==void 0&&{expectedValue:C.expectedValue},...typeof C=="object"&&C.expectedType!==void 0&&{expectedType:C.expectedType},...typeof C=="object"&&C.description!==void 0&&{description:C.description}})}}),o(f)}catch(f){y(f instanceof Error?f:new Error("Failed to fetch multi-MMKV storage data")),o([])}finally{a(false)}},[e,d]);return za(()=>{s()},[s]),{storageKeys:r,isLoading:n,error:i,refresh:s}}E();import{isDevToolsStorageKey as qc}from"@buoy-gg/shared-ui/web";import{useState as bn,useEffect as jc,useCallback as Pa,useRef as vo}from"react";var Uc="\u2022\u2022\u2022\u2022\u2022\u2022 (biometric protected)",Gc=3e3;function Fa(e){return JSON.stringify(e)}function Jc(e=[],t={}){let{pollMs:r=Gc}=t,o=vo(e);o.current=e;let n=JSON.stringify(e),[a,i]=bn([]),[y,d]=bn(true),[p,s]=bn(null),g=vo(Fa([])),f=vo(false),C=vo(false),m=Pa(S=>{let w=Fa(S);w!==g.current&&(g.current=w,i(S))},[]),b=Pa(async()=>{if(!C.current){C.current=true;try{let S=ee.getModule(),w=ee.getAll().filter(({key:x})=>!qc(x)),T=o.current.filter(x=>Ot(x,"secure")),I=x=>T.find(B=>(typeof B=="string"?B:B.key)===x);if(!S||w.length===0&&T.length===0){m([]),f.current=true,d(false);return}f.current||d(true),s(null);let R=[],D=[...w,...T.map(x=>typeof x=="string"?x:x.key).filter(x=>!w.some(B=>B.key===x)).map(x=>({key:x,options:{},description:void 0}))];for(let x of D){let B=I(x.key),Q=typeof B=="object"?B:void 0,ve={...Q?.expectedValue!==void 0&&{expectedValue:Q.expectedValue},...Q?.expectedType!==void 0&&{expectedType:Q.expectedType}},Se=Q?.description??x.description;if(x.options.requireAuthentication){R.push({key:x.key,value:Uc,storageType:"secure",status:B?"required_present":"optional_present",category:B?"required":"optional",description:Se??"Protected by biometric authentication \u2014 value not read by DevTools",...ve,...x.options.keychainService&&{instanceId:x.options.keychainService}});continue}let q=null;try{q=await S.getItemAsync(x.key,x.options)}catch{}if(q===null&&!B)continue;let ue=q;if(q)try{ue=JSON.parse(q)}catch{ue=q}let te="optional_present";if(B)if(q===null)te="required_missing";else if(Q?.expectedValue!==void 0)te=String(ue)===String(Q.expectedValue)?"required_present":"required_wrong_value";else if(Q?.expectedType!==void 0){let se=ue===null?"null":Array.isArray(ue)?"array":typeof ue,Ge=Q.expectedType.toLowerCase();te=se===Ge||Ge==="string"&&typeof q=="string"?"required_present":"required_wrong_type"}else te="required_present";R.push({key:x.key,value:q===null?void 0:ue,storageType:"secure",status:te,category:B?"required":"optional",...Se&&{description:Se},...ve,...x.options.keychainService&&{instanceId:x.options.keychainService}})}m(R)}catch(S){s(S instanceof Error?S:new Error("Failed to read SecureStore")),m([])}finally{f.current=true,C.current=false,d(false)}}},[m,n]);return jc(()=>{b();let S=ee.subscribe(()=>{b()});if(r<=0)return S;let w=setInterval(b,r);return()=>{S(),clearInterval(w)}},[b,r]),{storageKeys:a,isLoading:y,error:p,refresh:b}}E();import{isDevToolsStorageKey as vn}from"@buoy-gg/shared-ui/web";import{useState as So,useEffect as wo}from"react";function Sn(e=false){let[t,r]=So([]),[o,n]=So(true),a=()=>{n(true);try{let i=Le.getAll().filter(({id:y})=>!vn(y)).map(y=>{let{instance:d,id:p,encrypted:s,readOnly:g}=y,f=d.getAllKeys().filter(C=>!vn(C))?.length||0;return{id:p,instance:d,encrypted:s,readOnly:g,keyCount:f,size:void 0}});r(i)}catch{r([])}finally{n(false)}};return wo(()=>{a()},[]),wo(()=>{if(!e)return;let i=setInterval(()=>{a()},1e3);return()=>clearInterval(i)},[e]),{instances:t,instanceCount:t.length,isLoading:o,refresh:a}}function Wa(e){let[t,r]=So(null);return wo(()=>{if(!Le){r(null);return}let o=Le.get(e);if(!o){r(null);return}let n=o.instance.getAllKeys().filter(a=>!vn(a))?.length||0;r({...o,keyCount:n,size:void 0})},[e]),t}function Yc(e){let[t,r]=So(false);return wo(()=>{if(!Le){r(false);return}r(Le.has(e))},[e]),t}E();import{useEffect as Qc,useRef as $a}from"react";import{Check as Zc,macOSColors as Xt}from"@buoy-gg/shared-ui/web";import{jsx as hr,jsxs as Xc}from"react/jsx-runtime";var ed=2600,_a=180;function td({onDone:e}){let t=$a(new Yt.Value(0)).current,r=$a(e);return r.current=e,Qc(()=>{let o=Yt.sequence([Yt.timing(t,{toValue:1,duration:_a,easing:Pr.out(Pr.quad),useNativeDriver:true}),Yt.delay(ed),Yt.timing(t,{toValue:0,duration:_a,easing:Pr.in(Pr.quad),useNativeDriver:true})]);return o.start(({finished:n})=>{n&&r.current()}),()=>o.stop()},[t]),hr(Yt.View,{pointerEvents:"box-none",style:[br.wrap,{opacity:t,transform:[{translateY:t.interpolate({inputRange:[0,1],outputRange:[-10,0]})}]}],testID:"buoy-storage-save-notice",children:Xc(O,{activeOpacity:.85,onPress:()=>r.current(),style:br.toast,accessibilityRole:"button",accessibilityLabel:"Saved. Applies on the app's next launch. Tap to dismiss.",testID:"buoy-storage-save-notice-dismiss",children:[hr(l,{style:br.tick,children:hr(Zc,{size:10,color:Xt.semantic.success})}),hr(u,{style:br.saved,children:"Saved"}),hr(l,{style:br.divider}),hr(u,{style:br.detail,children:"applies on next launch"})]})})}var br=pe.create({wrap:{position:"absolute",top:10,left:12,right:12,zIndex:100,elevation:100,alignItems:"center"},toast:{flexDirection:"row",alignItems:"center",paddingVertical:7,paddingLeft:8,paddingRight:12,borderRadius:999,backgroundColor:Xt.background.card,borderWidth:pe.hairlineWidth,borderColor:Xt.border.default,shadowColor:"#000",shadowOpacity:.4,shadowRadius:14,shadowOffset:{width:0,height:5}},tick:{width:16,height:16,borderRadius:8,marginRight:7,alignItems:"center",justifyContent:"center",backgroundColor:Xt.semantic.successBackground},saved:{color:Xt.text.primary,fontSize:12,fontWeight:"600"},divider:{width:pe.hairlineWidth,alignSelf:"stretch",marginHorizontal:8,backgroundColor:Xt.border.default},detail:{color:Xt.text.muted,fontSize:12}});E();import{useState as rd,useEffect as od}from"react";mt();import{Trash2 as ko,CopyButton as nd,SquareDashed as ad,X as id,ProUpgradeModal as ld,monoFont as sd}from"@buoy-gg/shared-ui/web";import{macOSColors as Na,night as at}from"@buoy-gg/shared-ui/web";import{useIsPro as cd}from"@buoy-gg/license/web";import{jsx as He,jsxs as Ha}from"react/jsx-runtime";function dd({copyValue:e,mmkvInstances:t=[],activeStorageType:r="all",onClearComplete:o,isSelectMode:n=false,onToggleSelectMode:a,selectedCount:i=0}){let[y,d]=rd(false),p=cd();od(()=>{y&&p&&d(false)},[y,p]);let s=()=>{if(!p){d(true);return}Ie.alert(`Clear ${ae.asyncFull}`,`Delete all ${ae.asyncFull} keys? This cannot be undone.`,[{text:"Cancel",style:"cancel"},{text:"Clear",style:"destructive",onPress:async()=>{try{await oe.clear(),o?.()}catch(R){Ie.alert("Error",`Failed: ${R}`)}}}])},g=(R,D)=>{if(!p){d(true);return}Ie.alert(`Clear ${D}`,`Delete all keys from ${D}? This cannot be undone.`,[{text:"Cancel",style:"cancel"},{text:"Clear",style:"destructive",onPress:()=>{try{let x=t.find(B=>B.id===R);x&&(x.instance.clearAll(),o?.())}catch(x){Ie.alert("Error",`Failed: ${x}`)}}}])},f=()=>{if(!p){d(true);return}Ie.alert(`Clear All ${ae.mmkv}`,`Delete all keys from ${t.length} instances? This cannot be undone.`,[{text:"Cancel",style:"cancel"},{text:"Clear All",style:"destructive",onPress:()=>{try{t.forEach(R=>R.instance.clearAll()),o?.()}catch(R){Ie.alert("Error",`Failed: ${R}`)}}}])},C=()=>{if(!p){d(true);return}Ie.alert("Clear All Storage","Delete all storage data? This cannot be undone.",[{text:"Cancel",style:"cancel"},{text:"Clear All",style:"destructive",onPress:async()=>{try{await oe.clear(),t.forEach(R=>R.instance.clearAll()),o?.()}catch(R){Ie.alert("Error",`Failed: ${R}`)}}}])},m=r==="all"||r==="async",b=r==="all"||r==="mmkv",S=r==="all",w=m&&!S,T=b&&!S,I=b&&t.length>1&&!S;return Ha(l,{style:bt.container,children:[a&&He(O,{onPress:a,testID:"buoy-storage-select-mode",accessibilityLabel:n?"Exit selection mode":"Select keys",accessibilityRole:"button",style:[bt.actionButton,n&&bt.actionButtonActive],children:n?Ha(l,{style:bt.selectModeActiveContainer,children:[He(id,{size:14,color:at.color.accent}),i>0&&He(u,{style:bt.selectedCountText,children:i})]}):He(ad,{size:16,color:at.color.textSecondary})}),!n&&He(nd,{value:e,size:16,testID:"buoy-storage-export-copy",buttonStyle:bt.actionButton,colors:{idle:at.color.textSecondary,success:Na.semantic.success,error:Na.semantic.error}}),!n&&S&&He(O,{onPress:C,testID:"buoy-storage-clear-all",accessibilityLabel:"Clear all storage",accessibilityRole:"button",style:bt.actionButton,children:He(ko,{size:16,color:at.color.danger})}),!n&&w&&He(O,{onPress:s,testID:"buoy-storage-clear-async",accessibilityLabel:`Clear ${ae.asyncFull}`,accessibilityRole:"button",style:bt.actionButton,children:He(ko,{size:16,color:at.color.danger})}),!n&&I&&He(O,{onPress:f,testID:"buoy-storage-clear-mmkv-all",accessibilityLabel:`Clear all ${ae.mmkv} instances`,accessibilityRole:"button",style:bt.actionButton,children:He(ko,{size:16,color:at.color.danger})}),!n&&T&&t.length===1&&He(O,{onPress:()=>g(t[0].id,t[0].id),testID:"buoy-storage-clear-mmkv",accessibilityLabel:`Clear ${ae.mmkv} instance`,accessibilityRole:"button",style:bt.actionButton,children:He(ko,{size:16,color:at.color.danger})}),He(ld,{visible:y,onClose:()=>d(false),featureName:"Storage Editing"})]})}var bt=pe.create({container:{flexDirection:"row",alignItems:"center",gap:8},actionButton:{width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:6,backgroundColor:at.color.buttonSurface,borderWidth:1,borderColor:at.color.border},actionButtonActive:{backgroundColor:at.color.accentSoft,borderColor:at.color.accentBorderStrong},selectModeActiveContainer:{flexDirection:"row",alignItems:"center",gap:2},selectedCountText:{fontSize:10,fontWeight:"700",color:at.color.accent,fontFamily:sd}});E();import{useState as ud,useEffect as yd}from"react";import{Trash2 as gd,CopyButton as pd,CheckSquare as fd,EyeOff as md,ProUpgradeModal as hd,monoFont as bd}from"@buoy-gg/shared-ui/web";import{macOSColors as qa,night as qe}from"@buoy-gg/shared-ui/web";import{useIsPro as vd}from"@buoy-gg/license/web";E();Jt();function Sd(e,t){if(typeof e.remove=="function"){e.remove(t);return}if(typeof e.delete=="function"){e.delete(t);return}throw new Error("MMKV instance exposes neither remove() nor delete()")}async function ja(e,t){if(e.length===0)return;let r=e.filter(a=>a.storageType==="async"),o=e.filter(a=>a.storageType==="mmkv"),n=e.filter(a=>a.storageType==="secure");r.length>0&&await sr(r.map(a=>a.key));for(let a of n)await ee.deleteValue(a.key);if(o.length>0){let a={};o.forEach(i=>{let y=i.instanceId||"default";a[y]||(a[y]=[]),a[y].push(i.key)}),Object.entries(a).forEach(([i,y])=>{let d=t.find(p=>p.id===i);d&&y.forEach(p=>Sd(d.instance,p))})}}import{jsx as xt,jsxs as jr}from"react/jsx-runtime";function wd({selectedKeys:e,mmkvInstances:t,onDeleteComplete:r,onHideKeys:o,onSelectAll:n,onClearSelection:a,totalVisibleKeys:i}){let[y,d]=ud(false),p=vd();yd(()=>{y&&p&&d(false)},[y,p]);let s=e.length,g=s===i&&i>0,f=()=>{let b={};return e.forEach(S=>{let w=S.instanceId?`[${S.storageType}:${S.instanceId}]`:`[${S.storageType}]`;b[`${w} ${S.key}`]=S.value}),{selectedCount:s,keys:b,timestamp:new Date().toISOString()}},C=()=>{s!==0&&o?.(e)},m=()=>{if(s!==0){if(!p){d(true);return}Ie.alert("Delete Selected Keys",`Delete ${s} selected key${s>1?"s":""}? This cannot be undone.`,[{text:"Cancel",style:"cancel"},{text:"Delete",style:"destructive",onPress:async()=>{try{await ja(e,t),r?.()}catch(b){Ie.alert("Error",`Failed to delete keys: ${b}`)}}}])}};return s===0?null:jr(l,{style:vt.container,children:[jr(l,{style:vt.leftSection,children:[jr(O,{style:vt.selectAllButton,onPress:g?a:n,testID:"buoy-storage-select-all",accessibilityLabel:g?"Deselect all keys":"Select all keys",accessibilityRole:"button",children:[xt(fd,{size:14,color:g?qe.color.accent:qe.color.textSecondary}),xt(u,{style:vt.selectAllText,children:g?"Deselect All":"Select All"})]}),xt(l,{style:vt.countBadge,children:jr(u,{style:vt.countText,children:[s," selected"]})})]}),jr(l,{style:vt.actionsSection,children:[xt(pd,{value:f(),size:14,testID:"buoy-storage-selection-copy",buttonStyle:vt.actionButton,colors:{idle:qe.color.accent,success:qa.semantic.success,error:qa.semantic.error}}),o&&xt(O,{style:vt.actionButton,onPress:C,testID:"buoy-storage-selection-hide",accessibilityLabel:"Hide selected keys",accessibilityRole:"button",children:xt(md,{size:14,color:qe.color.warning})}),xt(O,{style:vt.actionButton,onPress:m,testID:"buoy-storage-selection-delete",accessibilityLabel:"Delete selected keys",accessibilityRole:"button",children:xt(gd,{size:14,color:qe.color.danger})})]}),xt(hd,{visible:y,onClose:()=>d(false),featureName:"Storage Editing"})]})}var vt=pe.create({container:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:qe.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:qe.color.accentBorderStrong,paddingHorizontal:12,paddingVertical:8,marginBottom:10},leftSection:{flexDirection:"row",alignItems:"center",gap:12},selectAllButton:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:4,paddingHorizontal:8,backgroundColor:qe.color.surface,borderRadius:6,borderWidth:1,borderColor:qe.color.border},selectAllText:{fontSize:11,fontWeight:"600",color:qe.color.textSecondary},countBadge:{backgroundColor:qe.color.accentFill,paddingHorizontal:8,paddingVertical:4,borderRadius:6},countText:{fontSize:11,fontWeight:"700",color:qe.color.accent,fontFamily:bd},actionsSection:{flexDirection:"row",alignItems:"center",gap:8},actionButton:{width:28,height:28,alignItems:"center",justifyContent:"center",borderRadius:6,backgroundColor:qe.color.surface,borderWidth:1,borderColor:qe.color.border}});E();var wn=new Set;function kd(e){return wn.add(e),()=>{wn.delete(e)}}function Cd(){wn.forEach(e=>{try{e()}catch{}})}E();mt();function kn(e,t=[]){if(e.storageType==="mmkv"){if(e.valueType==="buffer")return"Buffer values can't be edited \u2014 the tool only ever sees their byte length, not their contents.";let r=t.find(o=>o.id===(e.instanceId||"default"));if(r?.readOnly)return`MMKV instance "${r.id}" is registered read-only.`}if(e.storageType==="secure"){if(ee.getAll().find(r=>r.key===e.key)?.options.requireAuthentication)return"Biometric-protected keys can't be edited \u2014 writing one would fire an auth prompt.";if(!ee.getModule())return"No SecureStore module is registered."}return null}function Ua(e,t){if(e.storageType==="mmkv"){let r=Qa(e);if(r==="number"&&(t.trim()===""||Number.isNaN(Number(t))))return"Must be a number \u2014 this MMKV key is stored as a number.";if(r==="boolean"){let o=t.trim().toLowerCase();if(o!=="true"&&o!=="false")return'Must be "true" or "false" \u2014 this MMKV key is stored as a boolean.'}return null}if(Ja(e.value))try{JSON.parse(t)}catch(r){return`This key holds JSON \u2014 ${r instanceof Error?r.message:"invalid JSON"}`}return null}function xd(e){if(e==null)return"";if(typeof e=="string"){let t=e.trim();if(t.startsWith("{")||t.startsWith("["))try{return JSON.stringify(JSON.parse(e),null,2)}catch{return e}return e}return typeof e=="object"?JSON.stringify(e,null,2):String(e)}async function Ga(e,t,r=[]){let o=kn(e,r);if(o)throw new Error(o);let n=Ua(e,t);if(n)throw new Error(n);switch(e.storageType){case"async":{await oe.setItem(e.key,Ya(e,t));return}case"secure":{await ee.setValue(e.key,Ya(e,t));return}case"mmkv":{let a=e.instanceId||"default",i=r.find(y=>y.id===a);if(!i)throw new Error(`MMKV instance "${a}" is not registered.`);i.instance.set(e.key,Td(e,t));return}default:throw new Error(`Unsupported storage type "${String(e.storageType)}"`)}}function Ja(e){return e!==null&&typeof e=="object"}function Ya(e,t){return Ja(e.value)?JSON.stringify(JSON.parse(t)):t}function Qa(e){return e.valueType?e.valueType:typeof e.value=="number"?"number":typeof e.value=="boolean"?"boolean":"string"}function Td(e,t){switch(Qa(e)){case"number":return Number(t);case"boolean":return t.trim().toLowerCase()==="true";default:return t}}import{gameUIColors as vr,macOSColors as Co,night as F,HardDrive as Za}from"@buoy-gg/shared-ui/web";import{useIsPro as Id}from"@buoy-gg/license/web";import{Fragment as Ed,jsx as H,jsxs as Ee}from"react/jsx-runtime";var Xa=[Co.semantic.info,Co.semantic.success,Co.semantic.warning,Co.semantic.debug,"#FF6B9D","#00D9FF"];function Sr(e){let t=e.split("").reduce((r,o)=>r+o.charCodeAt(0),0);return Xa[t%Xa.length]}var vg=Hs["storage.keys"].free;function Rd({requiredStorageKeys:e=[],showFilters:t=false,ignoredPatterns:r=new Set(["@react_buoy"]),onTogglePattern:o,onAddPattern:n,searchQuery:a="",storageDataRef:i,eventCountByKey:y,lastWriteByKey:d,onViewHistory:p,enabledStorageTypes:s,statusFilter:g,onStatusFilterChange:f,onStatusCountsChange:C,pinnedKeys:m,onTogglePin:b,storageTypeFilter:S,onStorageTypeFilterChange:w,applySafeAreaInset:T,detailKey:I=null,onOpenKey:R,onCloseDetail:D}){let x=Id(),B=ca("storage.keys"),Q=ca("storage.mmkvInstances"),[ve,Se]=Qt(false);yr(()=>{ve&&x&&Se(false)},[ve,x]);let[q,ue]=Qt("all"),te=g!=null&&f!=null,se=te?g:q,Ge=te?f:ue,[Je,wt]=Qt("all"),Rt=S!=null&&w!=null,ye=Rt?S:Je,or=Rt?w:wt,[re,$t]=Qt(null),Ye=nn(null),xr=nn(0),ne=nn(new Map),gt=Xe((c,h)=>{h?ne.current.set(c,h):ne.current.delete(c)},[]),[_t,Tr]=Qt(0),[Nt,Ir]=Qt(false),[nr,Bt]=Qt(new Set),{instances:xe}=Sn(false),{storageKeys:Qr,isLoading:Zr,error:Xr,refresh:Ht}=mn(e),Po=_e(()=>xe.map(c=>({instance:c.instance,id:c.id})),[xe]),{storageKeys:Er,isLoading:Fo,error:Rr,refresh:ar}=La(Po,e),Wo=_e(()=>re?Er.filter(c=>c.instanceId===re):Er,[Er,re]),{storageKeys:qt,isLoading:eo,error:$o,refresh:to}=Jc(e),N=_e(()=>[...Qr,...Wo,...qt].filter(c=>!ze(c.key)),[Qr,Wo,qt]),ke=_e(()=>{if(!I)return null;let c=dn(I);return N.find(h=>dn(h)===c)??I},[I,N]),_o=Zr||Fo||eo,ro=Xr||Rr||$o,Te=Xe(()=>{Ht(),ar(),to()},[Ht,ar,to]),tt=Xe(c=>c.instanceId?`${c.storageType}-${c.instanceId}-${c.key}`:`${c.storageType}-${c.key}`,[]),No=Xe(()=>{Ir(c=>(c&&Bt(new Set),!c))},[]),rt=Xe((c,h)=>{let U=tt(c);Bt(Z=>{let Ze=new Set(Z);return h?Ze.add(U):Ze.delete(U),Ze})},[tt]),Ho=Xe(()=>{Bt(new Set),Ir(false),Te()},[Te]),Br=Xe(c=>{c.forEach(h=>n?.(h.key)),Bt(new Set),Ir(false)},[n]),jt=Xe(async(c,h)=>{if(!x)throw Se(true),new Error("Editing storage values is a Pro feature.");await Ga(c,h,xe),Te(),Tr(U=>U+1)},[x,xe,Te]),qo=Xe(c=>{jt(c,JSON.stringify(!c.value)).catch(h=>{Ie.alert("Couldn't save",h instanceof Error?h.message:String(h))})},[jt]),oo=Xe((c,h)=>{if(!x){Se(true);return}Ie.alert("Delete key",`Delete "${c.key}"? This cannot be undone.`,[{text:"Cancel",style:"cancel"},{text:"Delete",style:"destructive",onPress:async()=>{try{await ja([c],xe.map(U=>({id:U.id,instance:U.instance}))),Te(),h?.()}catch(U){Ie.alert("Error",`Failed to delete key: ${U}`)}}}])},[x,xe,Te]),Vr=Xe(c=>kn(c,xe),[xe]),jo=_e(()=>{let c=N,h={valid:c.filter(G=>G.status==="required_present"||G.status==="optional_present").length,missing:c.filter(G=>G.status==="required_missing").length,issues:c.filter(G=>G.status==="required_wrong_value"||G.status==="required_wrong_type").length,total:c.length},U=c.filter(G=>G.storageType==="async"),Z=c.filter(G=>G.storageType==="mmkv"),Ze=c.filter(G=>G.storageType==="secure");return{summary:{valid:h.valid,missing:h.missing,issues:h.issues,total:h.total,timestamp:new Date().toISOString()},asyncStorage:U.reduce((G,Be)=>(G[Be.key]=Be.value,G),{}),mmkv:Z.reduce((G,Be)=>{let Vt=Be.instanceId||"default";return G[Vt]||(G[Vt]={}),G[Vt][Be.key]=Be.value,G},{}),secure:Ze.reduce((G,Be)=>(G[Be.key]=Be.value,G),{})}},[N]);yr(()=>{i&&(i.current=N)},[N,i]),yr(()=>{let c,h=Da(U=>{clearTimeout(c),c=setTimeout(()=>{Ht()},100)});return()=>{clearTimeout(c),h()}},[Ht]),yr(()=>{let c,h=kd(()=>{clearTimeout(c),c=setTimeout(Te,100)});return()=>{clearTimeout(c),h()}},[Te]),yr(()=>{let c,h=Un(U=>{(re===null||U.instanceId===re)&&(clearTimeout(c),c=setTimeout(()=>{ar()},100))});return()=>{clearTimeout(c),h()}},[ar,re]);let Ut=_e(()=>{let c=N,h=c.filter(Z=>!ze(Z.key)),U=c.filter(Z=>ze(Z.key));return{totalCount:c.length,requiredCount:h.filter(Z=>Z.category==="required").length,missingCount:h.filter(Z=>Z.status==="required_missing").length,wrongValueCount:h.filter(Z=>Z.status==="required_wrong_value").length,wrongTypeCount:h.filter(Z=>Z.status==="required_wrong_type").length,presentRequiredCount:h.filter(Z=>Z.status==="required_present").length,optionalCount:h.filter(Z=>Z.category==="optional").length,mmkvCount:c.filter(Z=>Z.storageType==="mmkv").length,asyncCount:c.filter(Z=>Z.storageType==="async").length,secureCount:c.filter(Z=>Z.storageType==="secure").length,devToolsCount:U.length}},[N]),pt=_e(()=>{let c=N.filter(V=>!ze(V.key));ye!=="all"&&(c=c.filter(V=>V.storageType===ye));let h=c.filter(V=>V.status==="required_present"||V.status==="optional_present").length,U=c.filter(V=>V.status==="required_missing").length,Z=c.filter(V=>V.status==="required_wrong_type"||V.status==="required_wrong_value").length,Ze=0,G=0,Be=0,Vt=0;return se==="all"?(Ze=N.filter(V=>!ze(V.key)&&V.storageType==="async"&&(V.status==="required_present"||V.status==="optional_present")).length,G=N.filter(V=>!ze(V.key)&&V.storageType==="mmkv"&&(V.status==="required_present"||V.status==="optional_present")).length,Be=N.filter(V=>!ze(V.key)&&V.storageType==="secure"&&(V.status==="required_present"||V.status==="optional_present")).length,Vt=Ze+G+Be):se==="missing"?(Ze=N.filter(V=>!ze(V.key)&&V.storageType==="async"&&V.status==="required_missing").length,G=N.filter(V=>!ze(V.key)&&V.storageType==="mmkv"&&V.status==="required_missing").length,Be=N.filter(V=>!ze(V.key)&&V.storageType==="secure"&&V.status==="required_missing").length,Vt=Ze+G+Be):se==="issues"&&(Ze=N.filter(V=>!ze(V.key)&&V.storageType==="async"&&(V.status==="required_wrong_type"||V.status==="required_wrong_value")).length,G=N.filter(V=>!ze(V.key)&&V.storageType==="mmkv"&&(V.status==="required_wrong_type"||V.status==="required_wrong_value")).length,Be=N.filter(V=>!ze(V.key)&&V.storageType==="secure"&&(V.status==="required_wrong_type"||V.status==="required_wrong_value")).length,Vt=Ze+G+Be),{validCount:h,missingCount:U,issuesCount:Z,asyncCount:Ze,mmkvCount:G,secureCount:Be,totalCount:Vt}},[N,se,ye]);yr(()=>{C?.({validCount:pt.validCount,missingCount:pt.missingCount,issuesCount:pt.issuesCount})},[C,pt.validCount,pt.missingCount,pt.issuesCount]);let ir=_e(()=>[...N].sort((c,h)=>{let U={required_missing:1,required_wrong_type:2,required_wrong_value:3,required_present:4,optional_present:5};return(U[c.status]||999)-(U[h.status]||999)}),[N]),Pn=_e(()=>Array.from(new Set(N.map(c=>c.key))).sort(),[N]),Oe=_e(()=>{let c=ir;if(s&&s.size>0&&(c=c.filter(h=>s.has(h.storageType))),c=c.filter(h=>!Array.from(r).some(U=>h.key.includes(U))),a){let h=a.toLowerCase();c=c.filter(U=>U.key.toLowerCase().includes(h))}switch(se){case"all":c=c.filter(h=>h.status==="required_present"||h.status==="optional_present");break;case"missing":c=c.filter(h=>h.status==="required_missing");break;case"issues":c=c.filter(h=>h.status==="required_wrong_type"||h.status==="required_wrong_value");break}if(ye!=="all"&&(c=c.filter(h=>h.storageType===ye)),m&&m.size>0){let h=c.filter(Z=>m.has(Z.key)),U=c.filter(Z=>!m.has(Z.key));c=[...h,...U]}return c},[ir,se,ye,r,a,re,s,m]),v=_e(()=>Oe.slice(0,B),[Oe,B]),k=_e(()=>Math.max(0,Oe.length-B),[Oe.length,B]),z=k>0,j=_e(()=>{let c=Oe.filter(h=>!ze(h.key));return{totalCount:Oe.length,requiredCount:c.filter(h=>h.category==="required").length,missingCount:c.filter(h=>h.status==="required_missing").length,wrongValueCount:c.filter(h=>h.status==="required_wrong_value").length,wrongTypeCount:c.filter(h=>h.status==="required_wrong_type").length,presentRequiredCount:c.filter(h=>h.status==="required_present").length,optionalCount:c.filter(h=>h.category==="optional").length,mmkvCount:Oe.filter(h=>h.storageType==="mmkv").length,asyncCount:Oe.filter(h=>h.storageType==="async").length,secureCount:Oe.filter(h=>h.storageType==="secure").length,devToolsCount:Oe.filter(h=>ze(h.key)).length}},[Oe]),Qe=_e(()=>v.filter(c=>nr.has(tt(c))),[v,nr,tt]),Ar=Xe(()=>{let c=new Set(v.map(tt));Bt(c)},[v,tt]),Dr=Xe(()=>{Bt(new Set)},[]),Mr=Ut.requiredCount>0?Math.round(Ut.presentRequiredCount/Ut.requiredCount*100):Ut.totalCount>0?100:0,Oi=Mr>=90?"OPTIMAL":Mr>=70?"WARNING":"CRITICAL",Li=Mr>=90?vr.success:Mr>=70?vr.warning:vr.error;if(ke)return H(l,{style:P.root,children:H(Ec,{storageKey:ke,editBlockedReason:Vr(ke),eventCount:y?.[ke.key],onSave:c=>jt(ke,c),onViewHistory:p?()=>p(ke.key):void 0,onDeleteKey:c=>oo(c,()=>D?.()),onHideKey:c=>{Br([c]),D?.()},isPinned:m?.has(ke.key)??false,onTogglePin:b,applySafeAreaInset:T})});if(_o&&N.length===0)return Ee(l,{style:P.emptyState,children:[H(da,{size:48,color:F.color.textTertiary}),H(u,{style:P.emptyTitle,children:"Loading storage keys..."})]});if(ro)return Ee(l,{style:P.emptyState,children:[H(da,{size:48,color:vr.error}),H(u,{style:[P.emptyTitle,{color:vr.error}],children:"Error loading storage"}),H(u,{style:P.emptySubtitle,children:ro.message})]});let Pi=Ee(Ed,{children:[ye==="mmkv"&&xe.length===0&&Ee(l,{style:P.emptyMMKVState,children:[H(u,{style:P.emptyMMKVTitle,children:"No MMKV Instances Detected"}),H(u,{style:P.emptyMMKVSubtitle,children:"MMKV instances must be registered with registerMMKVInstance()"}),H(u,{style:P.emptyMMKVCode,children:`import { registerMMKVInstance } from '@buoy-gg/storage';
2
2
 
3
3
  const storage = createMMKV();
4
- registerMMKVInstance('mmkv.default', storage);`})]}),ye==="mmkv"&&xe.length>0&&Ee(l,{style:P.instanceNavbar,children:[Ee(l,{style:P.instanceNavbarHeader,children:[H(u,{style:P.instanceNavbarLabel,children:"INSTANCES"}),xe.length>Q&&H(ua,{style:{transform:[{scale:.85}]}})]}),Ee(Wr,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:P.instanceNavbarScroll,children:[(x||xe.length===1)&&Ee(O,{onPress:()=>$t(null),testID:"buoy-storage-instance-all",accessibilityRole:"button",accessibilityLabel:`All ${ae.mmkv} instances`,style:[P.instanceNavbarButton,re===null&&P.instanceNavbarButtonActive],children:[H(Za,{size:12,color:re===null?F.color.text:F.color.textSecondary}),H(u,{style:[P.instanceNavbarButtonText,re===null&&P.instanceNavbarButtonTextActive],children:"All"}),H(l,{style:P.instanceNavbarBadge,children:H(u,{style:P.instanceNavbarBadgeText,children:xe.reduce((c,h)=>c+h.keyCount,0)})})]}),xe.map((c,h)=>{let U=h>=Q;return Ee(O,{testID:`buoy-storage-instance-${c.id}`,accessibilityRole:"button",accessibilityLabel:`MMKV instance ${c.id}`,onPress:()=>{U?Se(true):$t(c.id)},style:[P.instanceNavbarButton,c.id===re&&P.instanceNavbarButtonActive,{borderColor:U?F.color.border:Sr(c.id)+"40",backgroundColor:c.id===re?Sr(c.id)+"20":F.color.surfaceElevated,opacity:U?.5:1}],children:[H(Za,{size:12,color:c.id===re?Sr(c.id):F.color.textSecondary}),H(u,{style:[P.instanceNavbarButtonText,c.id===re&&{color:Sr(c.id),fontWeight:"700"}],children:c.id}),H(l,{style:[P.instanceNavbarBadge,c.id===re&&{backgroundColor:Sr(c.id)+"30"}],children:H(u,{style:[P.instanceNavbarBadgeText,c.id===re&&{color:Sr(c.id)}],children:c.keyCount})})]},c.id)})]})]})]}),Fi=H(dd,{copyValue:jo,mmkvInstances:xe.map(c=>({id:c.id,instance:c.instance})),activeStorageType:ye,onClearComplete:Te,isSelectMode:Nt,onToggleSelectMode:No,selectedCount:nr.size}),Wi=Nt?H(wd,{selectedKeys:Qe,mmkvInstances:xe.map(c=>({id:c.id,instance:c.instance})),onDeleteComplete:Ho,onHideKeys:Br,onSelectAll:Ar,onClearSelection:Dr,totalVisibleKeys:v.length}):null,$i=z?Ee(O,{style:P.limitBanner,onPress:()=>Se(true),activeOpacity:.8,testID:"buoy-storage-locked-banner",accessibilityRole:"button",children:[Ee(l,{style:P.limitBannerContent,children:[Ee(l,{style:P.limitBannerLeft,children:[H(qs,{size:16,color:F.color.accent}),H(u,{style:P.limitBannerText,children:a?`${k} matching ${k===1?"key":"keys"} in locked storage`:`${k} keys locked`})]}),H(ua,{})]}),H(u,{style:P.limitBannerSubtext,children:a?"Upgrade to Pro to search your full storage":"Upgrade to Pro to unlock full storage access"})]}):null,_i=(()=>{let c=N.some(U=>!ze(U.key)),h;return a||!c?(h=Gs({subject:"keys",verb:"registered",search:a,total:c?1:0,waiting:{otto:"empty",title:"No storage keys",message:"Nothing is registered for this tool to read."}}),a&&c&&(h={...h,message:"No keys match. Clear the search to see them."})):se==="missing"?h={otto:"thumbsup",title:"No missing keys",message:"All required keys are present"}:se==="issues"?h={otto:"cool",title:"No issues found",message:"All storage keys are correctly configured"}:h={otto:"broken",title:"No valid keys found",message:"All keys have issues or are missing"},H(Us,{...h,testID:"buoy-storage-keys-empty"})})(),Ni=H(js,{visible:ve,onClose:()=>Se(false),featureName:"Storage Keys"});return Ee(l,{style:P.root,children:[_t>0?H(td,{onDone:()=>Tr(0)},_t):null,Ee(Wr,{testID:"buoy-storage-scroll",ref:Ye,onScroll:c=>{xr.current=c.nativeEvent.contentOffset.y},scrollEventThrottle:32,style:P.scrollContainer,contentContainerStyle:P.container,showsVerticalScrollIndicator:false,children:[H(l,{style:P.backgroundGrid}),H(Mc,{stats:Ut,tabStats:pt,healthPercentage:Mr,healthStatus:Oi,healthColor:Li,activeFilter:se,onFilterChange:Ge,activeStorageType:ye,onStorageTypeChange:or,showStatus:!te}),Pi,Oe.length>0?Ee(l,{style:P.keysSection,children:[Ee(l,{style:P.sectionHeader,children:[Ee(l,{style:P.sectionHeaderLeft,children:[Ee(u,{style:P.sectionTitle,children:[se==="all"?"KEYS":se==="missing"?"MISSING KEYS":"ISSUES TO FIX",ye!=="all"&&` (${ye.toUpperCase()})`]}),H(l,{style:P.countBadge,children:H(u,{style:P.countText,children:v.length})})]}),Fi]}),Wi,H(Sa,{title:"",count:-1,keys:v,emptyMessage:"",isSelectMode:Nt,selectedKeys:nr,onSelectionChange:rt,eventCountByKey:y,onViewHistory:p,onHideKey:c=>Br([c]),onToggleKey:qo,onDeleteKey:oo,editBlockedFor:Vr,pinnedKeys:m,onTogglePin:b,onRowRef:gt,onOpenKey:R}),$i]}):_i,H(u,{style:P.techFooter,children:"ASYNC STORAGE | MMKV | SECURE STORAGE BACKENDS"}),Ni]})]})}var P=pe.create({root:{flex:1,minHeight:0},editorOverlay:{...sa,zIndex:10},scrollContainer:{flex:1,backgroundColor:"transparent"},container:{padding:12,paddingBottom:120},backgroundGrid:{...sa,opacity:.006,backgroundColor:vr.info},techFooter:{fontSize:8,color:F.color.textTertiary,fontFamily:$r,textAlign:"center",marginTop:20,letterSpacing:1,opacity:.5},keysSection:{marginTop:8,backgroundColor:F.color.bg,borderRadius:12,padding:12,borderWidth:1,borderColor:F.color.border},sectionHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:10,paddingBottom:6,borderBottomWidth:1,borderBottomColor:F.color.separator},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:8},sectionTitle:{fontSize:12,fontWeight:"600",color:F.color.textSecondary,letterSpacing:.4,textTransform:"uppercase"},countBadge:{backgroundColor:F.color.surfaceElevated,paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1,borderColor:F.color.border},countText:{fontSize:11,fontWeight:"600",color:F.color.text,fontFamily:$r},emptyState:{alignItems:"center",justifyContent:"center",paddingVertical:48},emptyTitle:{fontSize:16,fontWeight:"600",color:F.color.text,marginTop:12,marginBottom:8},emptySubtitle:{fontSize:13,color:F.color.textSecondary,textAlign:"center"},emptyMMKVState:{backgroundColor:F.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:F.color.border,marginTop:8,alignItems:"center"},emptyMMKVTitle:{fontSize:14,fontWeight:"600",color:F.color.text,marginBottom:6},emptyMMKVSubtitle:{fontSize:12,color:F.color.textSecondary,textAlign:"center",marginBottom:12},emptyMMKVCode:{fontSize:10,fontFamily:$r,color:F.color.accent,backgroundColor:F.color.bg,padding:12,borderRadius:8,borderWidth:1,borderColor:F.color.border,alignSelf:"stretch"},instanceNavbar:{marginTop:12,marginBottom:8,backgroundColor:F.color.surface,borderRadius:10,borderWidth:1,borderColor:F.color.border,padding:10,shadowColor:"#000",shadowOpacity:.08,shadowRadius:6,shadowOffset:{width:0,height:2}},instanceNavbarHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8,paddingLeft:2},instanceNavbarLabel:{fontSize:9,fontWeight:"700",color:F.color.textTertiary,textTransform:"uppercase",letterSpacing:1},instanceNavbarScroll:{gap:8,paddingRight:8},instanceNavbarButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8,backgroundColor:F.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:F.color.border,minWidth:90},instanceNavbarButtonActive:{borderWidth:1.5,shadowColor:"#000",shadowOpacity:.1,shadowRadius:4,shadowOffset:{width:0,height:1}},instanceNavbarButtonText:{fontSize:11,fontWeight:"600",color:F.color.textSecondary,fontFamily:$r,flex:1},instanceNavbarButtonTextActive:{fontWeight:"700",color:F.color.text},instanceNavbarBadge:{backgroundColor:F.color.bg,paddingHorizontal:6,paddingVertical:2,borderRadius:6,minWidth:24,alignItems:"center"},instanceNavbarBadgeText:{fontSize:10,fontWeight:"700",color:F.color.textSecondary,fontFamily:$r},clearSearchButton:{marginTop:16,paddingHorizontal:16,paddingVertical:8,backgroundColor:F.color.surfaceElevated,borderRadius:6,borderWidth:1,borderColor:F.color.border},clearSearchText:{fontSize:13,color:F.color.text,fontWeight:"500"},limitBanner:{backgroundColor:F.color.surface,borderRadius:10,borderWidth:1,borderColor:F.color.accentBorderStrong,padding:12,marginTop:12},limitBannerContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:4},limitBannerLeft:{flexDirection:"row",alignItems:"center",gap:8},limitBannerText:{color:F.color.text,fontSize:13,fontWeight:"600"},limitBannerSubtext:{color:F.color.textTertiary,fontSize:11}});import{jsx as Bd}from"react/jsx-runtime";function ei({requiredStorageKeys:e=[],showFilters:t=false,ignoredPatterns:r=new Set,onTogglePattern:o,onAddPattern:n,searchQuery:a="",storageDataRef:i,eventCountByKey:y,lastWriteByKey:d,onViewHistory:p,enabledStorageTypes:s,statusFilter:g,onStatusFilterChange:f,onStatusCountsChange:C,pinnedKeys:m,onTogglePin:b,applySafeAreaInset:S,storageTypeFilter:w,onStorageTypeFilterChange:T,detailKey:I,onOpenKey:R,onCloseDetail:D}){return Bd(Rd,{requiredStorageKeys:e,showFilters:t,ignoredPatterns:r,onTogglePattern:o,onAddPattern:n,searchQuery:a,storageDataRef:i,eventCountByKey:y,lastWriteByKey:d,onViewHistory:p,enabledStorageTypes:s,statusFilter:g,onStatusFilterChange:f,onStatusCountsChange:C,pinnedKeys:m,onTogglePin:b,applySafeAreaInset:S,storageTypeFilter:w,onStorageTypeFilterChange:T,detailKey:I,onOpenKey:R,onCloseDetail:D})}import{ProFeatureBanner as Vd}from"@buoy-gg/shared-ui/web";E();import{useMemo as Ad}from"react";import{useEventStoreEvents as Dd}from"@buoy-gg/shared-ui/web";E();import{BaseEventStore as Md,appStorageEvent as Cn}from"@buoy-gg/shared-ui/web";function Ur(e){return!!e&&typeof e=="object"&&e.__buoyValueOnDevice===true}function xo(e){return e.storageType!=="async"||!e.data?{}:{pairs:e.data.pairs,prevPairs:e.data.prevPairs}}function ti(e){let t=e.data;if(!t)return false;let{pairs:r,prevPairs:o}=xo(e);return Ur(t.value)||Ur(t.prevValue)||Ur(r)||Ur(o)}var zd=0;function To(){return`se-${Date.now()}-${++zd}`}var Kd=class extends Md{constructor(){super({storeName:"storage",maxEvents:500});this.asyncStorageUnsubscribe=null;this.mmkvUnsubscribe=null;this.hasScannedInitialState=false}addEvent(e){let t=Cn(e);t&&super.addEvent(t)}async scanExistingState(){if(this.hasScannedInitialState)return;this.hasScannedInitialState=true;let e=new Date,t=Le.getAll();for(let{id:r,instance:o}of t)try{let n=o.getAllKeys();for(let a of n){let{value:i,type:y}=kt(o,a),d={string:"set.string",number:"set.number",boolean:"set.boolean",buffer:"set.buffer"}[y]??"set.string";this.addEvent({action:d,timestamp:e,instanceId:r,data:{key:a,value:i,valueType:y,initialScan:true},storageType:"mmkv",id:To()})}}catch{}try{let{asyncStorage:r,readMany:o}=(Jt(),Gi(Nn));if(r){let n=await r.getAllKeys();if(n.length>0){let a=await o(n);for(let[i,y]of a)this.addEvent({action:"setItem",timestamp:e,data:{key:i,value:y??void 0,initialScan:true},storageType:"async",id:To()})}}}catch{}}async startCapturing(){Nc()||await _c(),this.asyncStorageUnsubscribe||(this.asyncStorageUnsubscribe=Da(e=>{let t={...e,storageType:"async",id:To()};this.addEvent(t)})),this.mmkvUnsubscribe||(this.mmkvUnsubscribe=Un(e=>{let t={...e,storageType:"mmkv",id:To()};this.addEvent(t)})),await this.scanExistingState()}stopCapturing(){this.asyncStorageUnsubscribe&&(this.asyncStorageUnsubscribe(),this.asyncStorageUnsubscribe=null),this.mmkvUnsubscribe&&(this.mmkvUnsubscribe(),this.mmkvUnsubscribe=null)}isCapturing(){return this.asyncStorageUnsubscribe!==null||this.mmkvUnsubscribe!==null}getEventsByType(e){return this.events.filter(t=>t.storageType===e)}replaceEvents(e){let t=new Map;for(let o of this.events)ti(o)||t.set(o.id,o);let r=e.map(Cn).filter(o=>o!==null).map(o=>{let n=t.get(o.id);return!n||!ti(o)?o:{...o,data:{...o.data,value:n.data?.value,prevValue:n.data?.prevValue,...xo(n)}}});super.replaceEvents(r)}hydrateEvent(e){let t=Cn(e);if(!t)return;e=t;let r=this.events.findIndex(a=>a.id===e.id);if(r===-1)return;let o=this.events[r],n=this.events.slice();n[r]={...o,...e,timestamp:o.timestamp,data:{...o.data,...e.data}},super.replaceEvents(n)}},Lt=new Kd;function ri(e={}){let{storageType:t="all",maxEvents:r=500,enabled:o=true}=e,n=Ad(()=>t==="all"?void 0:d=>d.filter(p=>p.storageType===t),[t]),{events:a,clearEvents:i,isActive:y}=Dd(Lt,{maxEvents:r,enabled:o,select:n});return{events:a,clearEvents:i,isCapturing:y}}E();mt();import{useState as Io,useCallback as ct,useMemo as Pt,useEffect as oi,useRef as Od}from"react";import{formatRelativeTime as Eo,macOSColors as Ro,night as er,parseValue as Bo,devToolsStorageKeys as ni,GitBranch as Ld,EventStepperFooter as Pd,EventHistoryViewer as Fd,copyToClipboard as Wd,ProUpgradeModal as $d,monoFont as ai}from"@buoy-gg/shared-ui/web";import{useIsPro as _d}from"@buoy-gg/license/web";E();import{computeLineDiff as Bg,DiffType as Vg,ABSENT_VALUE as Nd,isAbsent as Ag}from"@buoy-gg/shared-ui/web/dataViewer";E();import{ThemedSplitView as Hd}from"@buoy-gg/shared-ui/web/dataViewer";E();import{diffThemes as qd,gitClassicTheme as zg,devToolsDefaultTheme as Kg}from"@buoy-gg/shared-ui/web/dataViewer";E();import{night as ii}from"@buoy-gg/shared-ui/web";import{TreeDiffViewer as jd}from"@buoy-gg/shared-ui/web/dataViewer";import{jsx as li}from"react/jsx-runtime";function Ud({oldValue:e,newValue:t,scrollEnabled:r=true}){return li(l,{style:r?si.container:si.containerInline,children:li(jd,{oldValue:e,newValue:t,theme:"dark",scrollEnabled:r})})}var si=pe.create({container:{flex:1,backgroundColor:ii.color.bg},containerInline:{backgroundColor:ii.color.bg}});E();function xn(e){switch(e){case"setItem":return"SET";case"removeItem":return"REMOVE";case"mergeItem":return"MERGE";case"clear":return"CLEAR";case"multiSet":return"MULTI SET";case"multiRemove":return"MULTI REMOVE";case"multiMerge":return"MULTI MERGE";case"set.string":case"set.number":case"set.boolean":case"set.buffer":return"SET";case"delete":return"REMOVE";case"clearAll":return"CLEAR";case"get.string":case"get.number":case"get.boolean":case"get.buffer":return"GET";default:return"UNKNOWN ACTION"}}E();import{night as Re,Lock as Gd,monoFont as Jd}from"@buoy-gg/shared-ui/web";import{jsx as Tn,jsxs as Yd}from"react/jsx-runtime";var Qd={copy:{color:Re.color.accent,backgroundColor:Re.color.accentSoft,borderColor:Re.color.accentBorderStrong,textColor:Re.color.accent},jump:{color:Re.color.warning,backgroundColor:Re.color.warningSoft,borderColor:Re.color.warning+"40",textColor:Re.color.warning},undo:{color:Re.color.info,backgroundColor:Re.color.infoSoft,borderColor:Re.color.info+"40",textColor:Re.color.info}};function In({onPress:e,text:t,type:r,disabled:o=false,locked:n=false}){let a=Qd[r],i=o||n;return Yd(O,{disabled:i,onPress:e,style:[Vo.button,{backgroundColor:i?Re.color.fill:a.backgroundColor,borderColor:i?Re.color.fillTertiary:a.borderColor,opacity:o?.5:1}],activeOpacity:.7,testID:`buoy-storage-action-${r}`,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:i},children:[n?Tn(Gd,{size:10,color:Re.color.textTertiary,style:Vo.lockIcon}):Tn(l,{style:[Vo.dot,{backgroundColor:i?Re.color.textTertiary:a.color}]}),Tn(u,{style:[Vo.text,{color:i?Re.color.textTertiary:a.textColor}],children:t})]})}var Vo=pe.create({button:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:6,borderWidth:1,paddingHorizontal:12,paddingVertical:6,height:25,minWidth:70,shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2,elevation:2},dot:{width:5,height:5,borderRadius:3,marginRight:6,shadowColor:Re.color.text,shadowOffset:{width:0,height:0},shadowOpacity:.6,shadowRadius:2},lockIcon:{marginRight:4},text:{fontSize:10,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:Jd,height:12}});E();mt();Jt();import{isDevToolsStorageKey as Zd}from"@buoy-gg/shared-ui/web";function Ft(e){return!!e&&typeof e=="object"&&e.__buoyValueOnDevice===true}async function En(e){let{action:t,data:r}=e;if(Ft(r?.prevValue)||Ft(r?.prevPairs))throw new Error("Cannot undo: previous value is still on the device \u2014 fetch getEventDetail first");switch(t){case"setItem":case"mergeItem":r?.key&&(r.prevValue===null||r.prevValue===void 0?await oe.removeItem(r.key):await oe.setItem(r.key,r.prevValue));break;case"removeItem":r?.key&&r.prevValue!==null&&r.prevValue!==void 0&&await oe.setItem(r.key,r.prevValue);break;case"multiSet":case"multiMerge":if(r?.prevPairs&&r.prevPairs.length>0)for(let[o,n]of r.prevPairs)n===null?await oe.removeItem(o):await oe.setItem(o,n);break;case"multiRemove":if(r?.prevPairs&&r.prevPairs.length>0)for(let[o,n]of r.prevPairs)n!==null&&await oe.setItem(o,n);break;case"clear":if(r?.prevPairs&&r.prevPairs.length>0){let o=r.prevPairs.filter(([,n])=>n!==null);o.length>0&&await Or(o)}break;default:throw new Error(`Cannot undo unknown action type: ${t}`)}}async function Rn(e,t){if(t<0||t>=e.length)throw new Error(`Invalid event index: ${t}`);for(let i of e){let y=i.data;if(Ft(y?.value)||Ft(y?.prevValue)||Ft(y?.pairs)||Ft(y?.prevPairs))throw new Error("Cannot jump: some event values are still on the device \u2014 fetch getEventDetail first")}let r=new Map;for(let i=0;i<=t;i++)eu(e[i],r);let o=new Set;for(let i of e)Xd(i,o);let n=[],a=[];for(let i of o){if(Zd(i))continue;let y=r.get(i);y==null?a.push(i):n.push([i,y])}a.length>0&&await sr(a),n.length>0&&await Or(n)}function Xd(e,t){let{data:r}=e;if(r){if(r.key&&t.add(r.key),r.keys)for(let o of r.keys)t.add(o);if(r.pairs)for(let[o]of r.pairs)t.add(o);if(r.prevPairs)for(let[o]of r.prevPairs)t.add(o)}}function eu(e,t){let{action:r,data:o}=e;switch(r){case"setItem":o?.key&&o?.value!==void 0&&t.set(o.key,o.value);break;case"removeItem":o?.key&&t.set(o.key,null);break;case"mergeItem":if(o?.key&&o?.value!==void 0){let n=t.get(o.key);if(n)try{let a=JSON.parse(n),i=JSON.parse(o.value),y={...a,...i};t.set(o.key,JSON.stringify(y))}catch{t.set(o.key,o.value)}else t.set(o.key,o.value)}break;case"multiSet":if(o?.pairs)for(let[n,a]of o.pairs)t.set(n,a);break;case"multiRemove":if(o?.keys)for(let n of o.keys)t.set(n,null);break;case"multiMerge":if(o?.pairs)for(let[n,a]of o.pairs){let i=t.get(n);if(i)try{let y=JSON.parse(i),d=JSON.parse(a),p={...y,...d};t.set(n,JSON.stringify(p))}catch{t.set(n,a)}else t.set(n,a)}break;case"clear":t.clear();break}}function Bn(e){let{action:t,data:r}=e;switch(t){case"setItem":case"mergeItem":case"removeItem":return!!r?.key&&!Ft(r.prevValue);case"multiSet":case"multiRemove":case"multiMerge":case"clear":return!!r?.prevPairs&&r.prevPairs.length>0&&!Ft(r.prevPairs);default:return false}}import{Fragment as tu,jsx as je,jsxs as ci}from"react/jsx-runtime";var wr=-1,Ao={prior:{label:"BEFORE #1",timestamp:"value before first event",relativeTime:"not captured",badge:"PRIOR"},absent:{label:"NO PRIOR VALUE",timestamp:"key did not exist",relativeTime:"created here",badge:"ABSENT"},scanned:{label:"ALREADY PRESENT",timestamp:"value found at startup",relativeTime:"not a write",badge:"SCANNED"}};function Do(e){switch(e){case"setItem":case"multiSet":return Ro.semantic.success;case"removeItem":case"multiRemove":case"clear":return Ro.semantic.error;case"mergeItem":case"multiMerge":return Ro.semantic.info;default:return Ro.text.muted}}function di(e){let t=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0"),n=String(e.getMilliseconds()).padStart(3,"0");return`${t}:${r}:${o}.${n}`}var ru={hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3,lineOffset:0},ou=[];function Vn({conversation:e,selectedEventIndex:t=0,onEventIndexChange:r=()=>{},disableInternalFooter:o=false}){let n=_d(),[a,i]=Io(false),[y,d]=Io("split"),[p,s]=Io(Math.max(wr,t-1)),[g,f]=Io(t),C=Od(false),m=Pt(()=>e.events.sort((ne,gt)=>ne.timestamp.getTime()-gt.timestamp.getTime()),[e.events]),b=m.length;oi(()=>{if(C.current)return;(async()=>{try{let ne=await oe.getItem(ni.storage.diffViewerMode());(ne==="split"||ne==="tree")&&d(ne),C.current=true}catch{}})()},[]),oi(()=>{let ne=Math.min(b-1,Math.max(0,t)),gt=Math.max(wr,Math.min(ne-1,t-1));s(gt),f(ne)},[t,b]);let S=ct(async ne=>{d(ne);try{await oe.setItem(ni.storage.diffViewerMode(),ne)}catch{}},[]),w=m[t],T=w?.action,I=p===wr,R=I?void 0:m[Math.max(0,Math.min(b-1,p))],D=m[Math.max(0,Math.min(b-1,g))],x=Pt(()=>{let ne=D?.data;return ne?.initialScan?"scanned":ne?.prevValue===null||ne?.prevValue===void 0?"absent":"prior"},[D]),B=Pt(()=>x==="absent"?Nd:x==="scanned"?Bo(D?.data?.value):Bo(D?.data?.prevValue),[x,D]),Q=Pt(()=>I?{index:wr,label:Ao[x].label,timestamp:Ao[x].timestamp,relativeTime:Ao[x].relativeTime,badge:je(l,{style:[tr.actionBadgeSmall,{backgroundColor:`${er.color.textTertiary}20`}],children:je(u,{style:[tr.actionTextSmall,{color:er.color.textTertiary}],children:Ao[x].badge})})}:{index:p,label:`#${p+1} / ${b}`,timestamp:R?di(R.timestamp):"",relativeTime:R?Eo(R.timestamp):"",badge:R?je(l,{style:[tr.actionBadgeSmall,{backgroundColor:`${Do(R.action)}20`}],children:je(u,{style:[tr.actionTextSmall,{color:Do(R.action)}],children:xn(R.action)})}):void 0},[p,R,b,I,x]),ve=Pt(()=>({index:g,label:`#${g+1} / ${b}`,timestamp:D?di(D.timestamp):"",relativeTime:D?Eo(D.timestamp):"",badge:D?je(l,{style:[tr.actionBadgeSmall,{backgroundColor:`${Do(D.action)}20`}],children:je(u,{style:[tr.actionTextSmall,{color:Do(D.action)}],children:xn(D.action)})}):void 0}),[g,D,b]),Se=Pt(()=>[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}],[]),q=ct(()=>{p>wr&&s(p-1)},[p]),ue=ct(()=>{p<g-1&&s(p+1)},[p,g]),te=ct(()=>{g>p+1&&f(g-1)},[g,p]),se=ct(()=>{g<b-1&&f(g+1)},[g,b]),Ge=Pt(()=>I?B:Bo(R?.data?.value??null),[I,B,R]),Je=Pt(()=>Bo(D?.data?.value),[D]),wt=ct(()=>y==="split"?je(Hd,{oldValue:Ge,newValue:Je,differences:ou,theme:qd.devToolsDefault,options:ru,showThemeName:false,scrollEnabled:false}):je(Ud,{oldValue:Ge,newValue:Je,scrollEnabled:false}),[Ge,Je,y]),Rt=ct(()=>{r(Math.max(0,t-1))},[t,r]),ye=ct(()=>{r(Math.min(b-1,t+1))},[t,b,r]),or=ct(async()=>{if(!n){i(true);return}if(!(!w||w.storageType==="mmkv"))try{await En(w)}catch{}},[w,n]),re=ct(async()=>{if(!n){i(true);return}if(!w||w.storageType==="mmkv")return;let ne=m.filter(_t=>_t.storageType!=="mmkv"),gt=ne.findIndex(_t=>_t.timestamp.getTime()===w.timestamp.getTime());if(gt!==-1)try{await Rn(ne,gt)}catch{}},[w,m,n]),$t=ct(async()=>{if(!w)return;let ne={action:w.action,timestamp:w.timestamp.toISOString(),data:w.data};await Wd(ne)},[w]),Ye=w?.storageType!=="mmkv",xr=Ye&&w&&Bn(w);return ci(tu,{children:[Ye&&ci(l,{style:tr.actionButtonsContainer,children:[je(In,{type:"undo",text:"UNDO",onPress:or,disabled:!xr,locked:!n}),je(In,{type:"jump",text:"JUMP",onPress:re,locked:!n}),je(In,{type:"copy",text:"COPY",onPress:$t})]}),je(Fd,{activeView:"diff",diffViewLabel:"DIFF VIEW",diffViewDescription:"Compare changes between versions",diffViewIcon:Ld,diffModeTabs:Se,activeDiffMode:y,onDiffModeChange:S,renderDiffContent:wt,scrollDiffSection:true,leftEvent:Q,rightEvent:ve,showCompareNavigation:true,onLeftPrevious:q,onLeftNext:ue,onRightPrevious:te,onRightNext:se,canLeftPrevious:p>wr,canLeftNext:p<g-1,canRightPrevious:g>p+1,canRightNext:g<b-1,disableInternalFooter:o,footerCurrentIndex:t,footerTotalItems:b,footerItemLabel:"Event",footerSubtitle:Eo(w?.timestamp),onFooterPrevious:Rt,onFooterNext:ye}),je($d,{visible:a,onClose:()=>i(false),featureName:"Storage Time-Travel"})]})}function An({conversation:e,selectedEventIndex:t=0,onEventIndexChange:r=()=>{},applySafeAreaInset:o=true}){let n=e.events.sort((i,y)=>i.timestamp.getTime()-y.timestamp.getTime()),a=n.length;return je(Pd,{currentIndex:t,totalItems:a,onPrevious:()=>r(Math.max(0,t-1)),onNext:()=>r(Math.min(a-1,t+1)),itemLabel:"Event",subtitle:Eo(n[t]?.timestamp),applySafeAreaInset:o})}var tr=pe.create({actionButtonsContainer:{flexDirection:"row",justifyContent:"center",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:10,backgroundColor:er.color.surface,borderBottomWidth:1,borderBottomColor:er.color.border},valueBox:{backgroundColor:er.color.bg,borderRadius:6,borderWidth:1,borderColor:er.color.border,padding:8},valueText:{fontSize:12,color:er.color.text,fontFamily:ai,lineHeight:18},actionBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},actionTextSmall:{fontSize:8,fontWeight:"700",fontFamily:ai}});E();import{Filter as ui,DynamicFilterView as nu,Database as au,HardDrive as iu,Shield as lu,macOSColors as Tt,night as It}from"@buoy-gg/shared-ui/web";import{jsx as Wt,jsxs as kr}from"react/jsx-runtime";function su({ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,availableKeys:o=[],enabledStorageTypes:n,onToggleStorageType:a}){let i={addFilterSection:{enabled:true,placeholder:"Enter key pattern to hide...",title:"KEY FILTERS",icon:ui},availableItemsSection:{enabled:true,title:"AVAILABLE EVENT KEYS",emptyMessage:"No storage event keys available. Events will appear here once captured.",items:o},howItWorksSection:{enabled:true,title:"HOW EVENT FILTERS WORK",description:"Patterns hide matching storage keys from the event list. Storage type toggles control which storage backends are monitored.",examples:["\u2022 react_buoy \u2192 hides keys containing react_buoy","\u2022 @temp \u2192 hides @temp_user, @temp_data","\u2022 redux \u2192 hides redux-persist:root",`\u2022 ${ae.asyncFull}: show or hide captured events`,`\u2022 ${ae.mmkv}: show or hide captured events`],icon:ui},onPatternToggle:t,onPatternAdd:r,activePatterns:e};return kr(l,{style:et.container,children:[kr(l,{style:et.storageTypeSection,children:[Wt(u,{style:et.sectionTitle,children:"STORAGE TYPES"}),kr(l,{style:et.storageTypeButtons,children:[kr(O,{style:[et.storageTypeButton,n.has("async")&&et.storageTypeButtonActive,{borderColor:Tt.semantic.warning+"40"}],onPress:()=>a("async"),testID:"buoy-storage-backend-async",accessibilityRole:"button",accessibilityLabel:`Toggle ${ae.asyncFull} capture`,accessibilityState:{selected:n.has("async")},children:[Wt(au,{size:16,color:n.has("async")?Tt.semantic.warning:It.color.textTertiary}),Wt(u,{style:[et.storageTypeButtonText,n.has("async")&&{color:Tt.semantic.warning}],children:ae.asyncFull})]}),kr(O,{style:[et.storageTypeButton,n.has("mmkv")&&et.storageTypeButtonActive,{borderColor:Tt.semantic.info+"40"}],onPress:()=>a("mmkv"),testID:"buoy-storage-backend-mmkv",accessibilityRole:"button",accessibilityLabel:`Toggle ${ae.mmkv} capture`,accessibilityState:{selected:n.has("mmkv")},children:[Wt(iu,{size:16,color:n.has("mmkv")?Tt.semantic.info:It.color.textTertiary}),Wt(u,{style:[et.storageTypeButtonText,n.has("mmkv")&&{color:Tt.semantic.info}],children:ae.mmkv})]}),Ia()&&kr(O,{style:[et.storageTypeButton,n.has("secure")&&et.storageTypeButtonActive,{borderColor:Tt.semantic.success+"40"}],onPress:()=>a("secure"),testID:"buoy-storage-backend-secure",accessibilityRole:"button",accessibilityLabel:"Toggle Secure Storage capture",accessibilityState:{selected:n.has("secure")},children:[Wt(lu,{size:16,color:n.has("secure")?Tt.semantic.success:It.color.textTertiary}),Wt(u,{style:[et.storageTypeButtonText,n.has("secure")&&{color:Tt.semantic.success}],children:"Secure Storage"})]})]})]}),Wt(nu,{...i})]})}var et=pe.create({container:{flex:1},storageTypeSection:{padding:16,borderBottomWidth:1,borderBottomColor:It.color.border},sectionTitle:{fontSize:11,fontWeight:"700",color:It.color.textSecondary,letterSpacing:.8,marginBottom:12},storageTypeButtons:{flexDirection:"row",gap:8},storageTypeButton:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:6,paddingVertical:10,paddingHorizontal:12,backgroundColor:It.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:It.color.border},storageTypeButtonActive:{backgroundColor:It.color.surface},storageTypeButtonText:{fontSize:11,fontWeight:"600",color:It.color.textTertiary}});E();import{memo as cu}from"react";import{RelativeTime as du,macOSColors as Gr,parseValue as uu,CompactRow as yu}from"@buoy-gg/shared-ui/web";import{jsx as yi}from"react/jsx-runtime";function gu(e){let t=uu(e);return t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t=="boolean"?"boolean":typeof t=="number"?"number":typeof t=="string"?"string":typeof t=="object"?"object":"undefined"}function pu(e){switch(e){case"setItem":case"multiSet":case"set.string":case"set.number":case"set.boolean":case"set.buffer":return Gr.semantic.success;case"removeItem":case"multiRemove":case"clear":case"delete":case"clearAll":return Gr.semantic.error;case"mergeItem":case"multiMerge":return Gr.semantic.info;case"get.string":case"get.number":case"get.boolean":case"get.buffer":return Gr.semantic.warning;default:return Gr.text.muted}}function fu(e,t){return`${Array.from(e).map(r=>r==="async"?ae.async:ae.mmkv).join("/")} \xB7 ${t} op${t!==1?"s":""}`}var Dn=cu(function({data:e,onPress:t,isSelected:r=false,showChevron:o=true,testID:n}){let a=pu(e.lastAction),i=xn(e.lastAction),y=e.totalOperations??1;return yi(yu,{statusDotColor:a,statusLabel:"Storage",statusSublabel:fu(e.storageTypes,y),primaryText:e.key,badgeText:i,badgeColor:a,showChevron:o,bottomRightText:yi(du,{timestamp:e.lastEventTimestamp}),isSelected:r,onPress:t,testID:n,accessibilityLabel:`${i} ${e.key}`})});import{useIsPro as mu}from"@buoy-gg/license/web";import{Fragment as gi,jsx as M,jsxs as dt}from"react/jsx-runtime";var Yg=_s["storage.events"].free,Mn={getItem:e=>oe.getItem(e),setItem:(e,t)=>oe.setItem(e,t)},hu={storage:Mn,parse:e=>e==="browser"||e==="events"?e:void 0,serialize:e=>e},bu={storage:Mn,parse:e=>e==="true",serialize:e=>e.toString()},pi={storage:Mn,parse:e=>new Set(JSON.parse(e)),serialize:e=>JSON.stringify(Array.from(e))},vu={...pi,parse:e=>{let t=JSON.parse(e);return t.includes("@react_buoy")||t.push("@react_buoy"),new Set(t)}};function zn({visible:e,onClose:t,onBack:r,onMinimize:o,enableSharedModalDimensions:n=false,requiredStorageKeys:a=[],inline:i=false,onTabChange:y,onRefresh:d,onEventSelect:p}){let s=mu(),g=$s("storage.events"),[f,C]=go(ur.storage.activeTab(),"browser",hu);en(()=>{y?.(f)},[f,y]);let[m,b]=ot(""),[S,w]=ot(null),[T,I]=ot(false),[R,D]=go(ur.storage.isMonitoring(),true,bu),{events:x,clearEvents:B,isCapturing:Q}=ri({enabled:R}),[ve,Se]=ot(null),[q,ue]=ot(null),[te,se]=ot(null),[Ge,Je]=ot(0),[wt,Rt]=ot(false),[ye,or]=go(ur.storage.eventFilters(),new Set(["@react_buoy","@RNAsyncStorage","redux-persist","persist:"]),vu),[re,$t]=ot("all"),[Ye,xr]=ot(new Set(["async","mmkv","secure"])),[ne,gt]=go(ur.storage.pinnedKeys(),new Set,pi),_t=Zn(null),Tr=R&&Q,[Nt,Ir]=ot("bottomSheet"),nr=De(v=>{Ir(v)},[]),Bt=De(()=>{D(v=>!v)},[]),xe=De(()=>{B(),Se(null),Je(0)},[B]),Qr=De(v=>{ue(v),se(null)},[]),Zr=De(()=>{ue(null),se(null)},[]),Xr=De(v=>{or(k=>{let z=new Set(k);return z.has(v)?z.delete(v):z.add(v),z})},[]),Ht=De(v=>{or(k=>new Set([...k,v]))},[]),Po=De(v=>{gt(k=>{let z=new Set(k);return z.has(v)?z.delete(v):z.add(v),z})},[]),Er=De(()=>{Rt(!wt)},[wt]),Fo=De(v=>{xr(k=>{let z=new Set(k);return z.has(v)?z.delete(v):z.add(v),z})},[]),Rr=Zn([]),ar=De(()=>{let v=Rr.current;return{timestamp:new Date().toISOString(),totalKeys:v.length,asyncStorage:v.filter(k=>k.storageType==="async").reduce((k,z)=>(k[z.key]=yo(z.value),k),{}),mmkv:v.filter(k=>k.storageType==="mmkv").reduce((k,z)=>{let j=z.instanceId||"default";return k[j]||(k[j]={}),k[j][z.key]=yo(z.value),k},{}),secure:v.filter(k=>k.storageType==="secure").reduce((k,z)=>(k[z.key]=yo(z.value),k),{})}},[]),Wo=De(async()=>{Ie.alert("Clear Storage","Choose what to clear:",[{text:"Cancel",style:"cancel"},{text:"Clear App Storage",onPress:async()=>{try{await uo()}catch{Ie.alert("Error","Failed to clear app storage")}}},{text:"Clear All (Including Dev Tools)",style:"destructive",onPress:async()=>{try{await sl()}catch{Ie.alert("Error","Failed to clear all storage")}}}])},[]),qt=v=>{let k=Ds(v);return k===null?"null":k===void 0?"undefined":Array.isArray(k)?"array":typeof k=="boolean"?"boolean":typeof k=="number"?"number":typeof k=="string"?"string":typeof k=="object"?"object":"undefined"},[eo,$o]=ot([]);en(()=>{e&&(async()=>{try{let v=await oe.getAllKeys();$o([...v].sort())}catch{}})()},[e]);let to=st(()=>{let v=new Set(eo);return x.forEach(k=>{k.data?.key&&v.add(k.data.key)}),Array.from(v).sort()},[x,eo]),N=st(()=>{let v=new Map;return x.forEach(k=>{if(!k.data?.key)return;let z=k.data.key;if(!Ye.has(k.storageType)||Array.from(ye).some(Qe=>z.includes(Qe)))return;let j=v.get(z);j?(j.events.push(k),j.totalOperations++,j.storageTypes.add(k.storageType),k.timestamp>j.lastEvent.timestamp&&(j.lastEvent=k,j.currentValue=k.data.value,j.valueType=qt(k.data.value))):v.set(z,{key:z,lastEvent:k,events:[k],totalOperations:1,currentValue:k.data.value,valueType:qt(k.data.value),storageTypes:new Set([k.storageType])})}),Array.from(v.values()).sort((k,z)=>z.lastEvent.timestamp.getTime()-k.lastEvent.timestamp.getTime())},[x,ye,Ye]),ke=st(()=>ve&&N.find(v=>v.key===ve)||null,[ve,N]),_o=st(()=>{let v={};return N.forEach(k=>{v[k.key]=k.totalOperations}),v},[N]),ro=st(()=>{let v={};return N.forEach(k=>{v[k.key]=k.lastEvent.timestamp.getTime()}),v},[N]),Te=st(()=>q&&N.find(v=>v.key===q)||null,[q,N]);en(()=>{if(!p)return;let v=ke||(te!==null?Te:null),k=ke?Ge:te;if(!v||k==null)return;let z=[...v.events].sort((Ar,Dr)=>Ar.timestamp.getTime()-Dr.timestamp.getTime()),j=z[k],Qe=z[k-1];j&&p(j),Qe&&p(Qe)},[p,ke,Ge,Te,te]);let tt=st(()=>x.filter(v=>{if(!v.data?.key||!Ye.has(v.storageType))return false;let k=v.data.key;return!Array.from(ye).some(z=>k.includes(z))}),[x,ye,Ye]),No=st(()=>Ea(tt),[tt]),rt=st(()=>re==="all"?tt:tt.filter(v=>v.storageType===re),[tt,re]),Ho=De(()=>rt.map(v=>({key:v.data?.key,action:v.action,value:yo(v.data?.value),storageType:v.storageType,timestamp:v.timestamp.toISOString()})),[rt]),Br=st(()=>rt.slice(0,g),[rt,g]),jt=st(()=>Math.max(0,rt.length-g),[rt.length,g]),qo=.8,oo=De(v=>v.id,[]),Vr=De(v=>{let k=N.find(j=>j.key===v.data?.key);if(!k)return;let z=[...k.events].sort((j,Qe)=>j.timestamp.getTime()-Qe.timestamp.getTime()).findIndex(j=>j.timestamp.getTime()===v.timestamp.getTime());Se(k.key),Je(z>=0?z:0)},[N]),jo=De(({item:v})=>{let k={key:v.data?.key||"",lastAction:v.action,totalOperations:1,lastEventTimestamp:v.timestamp,storageTypes:new Set([v.storageType]),valueType:qt(v.data?.value)};return M(Dn,{data:k,onPress:()=>Vr(v),testID:`buoy-storage-event-${v.id}`})},[Vr]);if(!e)return null;let Ut=n?ur.modal.root():ur.storage.modal(),pt=()=>{if(wt)return M(su,{ignoredPatterns:ye,onTogglePattern:Xr,onAddPattern:Ht,availableKeys:to,enabledStorageTypes:Ye,onToggleStorageType:Fo});if(f==="browser"){if(q&&Te){if(te!==null)return M(l,{style:he.contentWrapper,children:M(Vn,{conversation:Te,selectedEventIndex:te,onEventIndexChange:se,disableInternalFooter:true})});let k=[...Te.events].sort((j,Qe)=>j.timestamp.getTime()-Qe.timestamp.getTime()),z=[...k].reverse();return M(tn,{testID:"buoy-storage-history-list",style:he.flexFill,data:z,keyExtractor:j=>j.id,renderItem:({item:j})=>{let Qe=k.findIndex(Dr=>Dr.timestamp.getTime()===j.timestamp.getTime()),Ar={key:j.data?.key||"",lastAction:j.action,totalOperations:1,lastEventTimestamp:j.timestamp,storageTypes:new Set([j.storageType]),valueType:qt(j.data?.value)};return M(Dn,{data:Ar,onPress:()=>se(Qe>=0?Qe:0),testID:`buoy-storage-history-event-${j.id}`})},contentContainerStyle:he.listContent,ItemSeparatorComponent:()=>M(l,{style:he.separator}),initialNumToRender:20})}return M(ei,{requiredStorageKeys:a,ignoredPatterns:ye,onTogglePattern:Xr,onAddPattern:Ht,searchQuery:m,storageDataRef:Rr,eventCountByKey:_o,lastWriteByKey:ro,onViewHistory:Qr,enabledStorageTypes:Ye,pinnedKeys:ne,onTogglePin:Po,applySafeAreaInset:Nt==="bottomSheet",storageTypeFilter:re,onStorageTypeFilterChange:$t,detailKey:S,onOpenKey:w,onCloseDetail:()=>w(null)})}if(ke)return M(l,{style:he.contentWrapper,children:M(Vn,{conversation:ke,selectedEventIndex:Ge,onEventIndexChange:Je,disableInternalFooter:true})});let v=M(l,{style:he.eventFilterBar,children:M(gn,{active:re,onChange:$t,counts:No})});if(rt.length===0){let k=re!=="all";return dt(l,{style:he.flexFill,children:[v,M(zs,{testID:"buoy-storage-events-empty",...Tr?k?{otto:"filtering",title:`No ${re} events`,message:"Other backends have events \u2014 pick All Types to see them"}:{otto:"listening",title:"No storage events yet",message:"Storage operations will appear here"}:{otto:"paused",title:"Event listener is paused",message:"Press play to start monitoring"}})]})}return dt(l,{style:he.flexFill,children:[v,M(tn,{testID:"buoy-storage-events-list",style:he.flexFill,data:Br,renderItem:jo,keyExtractor:oo,onEndReachedThreshold:qo,contentContainerStyle:he.listContent,ListFooterComponent:jt>0?M(l,{style:he.lockedBannerContainer,children:M(Vd,{featureName:`${jt} event${jt>1?"s":""} locked`,description:"Upgrade to Pro to unlock full event history"})}):null,initialNumToRender:10,maxToRenderPerBatch:10,windowSize:10})]})},ir=ke&&ke.events.length>1?M(An,{conversation:ke,selectedEventIndex:Ge,onEventIndexChange:Je,applySafeAreaInset:Nt==="bottomSheet"}):Te&&te!==null&&Te.events.length>1?M(An,{conversation:Te,selectedEventIndex:te,onEventIndexChange:se,applySafeAreaInset:Nt==="bottomSheet"}):null,Pn=wt?()=>Rt(false):te!==null?()=>se(null):q?Zr:ke?()=>{Se(null),Je(0)}:r,Oe=wt?dt(Me,{children:[M(Me.Navigation,{onBack:()=>Rt(false)}),M(Me.Content,{title:"Filters"})]}):q?dt(Me,{children:[M(Me.Navigation,{onBack:te!==null?()=>se(null):Zr}),M(Me.Content,{title:`${q} History`,centered:true})]}):ke?dt(Me,{children:[M(Me.Navigation,{onBack:()=>{Se(null),Je(0)}}),M(Me.Content,{title:ke.key})]}):S?dt(Me,{children:[M(Me.Navigation,{onBack:()=>w(null)}),M(Me.Content,{title:S.key,centered:true,testID:"buoy-storage-detail-title"})]}):dt(Me,{children:[r&&M(Me.Navigation,{onBack:r}),M(Me.Content,{title:"",children:T?M(Ps,{value:m,onChange:b,onClear:()=>{b(""),I(false)},placeholder:"Search storage keys...",testID:"buoy-storage-search",autoFocus:true,onSubmitEditing:()=>I(false),returnKeyType:"search",containerStyle:he.headerSearchContainer}):M(As,{tabs:[{key:"browser",label:"Storage"},{key:"events",label:`Events${rt.length>0?` (${rt.length})`:""}`}],activeTab:f,testIDPrefix:"buoy-storage-tab",onTabChange:v=>{C(v),ue(null),se(null),Se(null),Je(0),w(null)}})}),dt(Me.Actions,{children:[d&&!T?M(O,{onPress:d,style:he.iconButton,testID:"buoy-storage-refresh",accessibilityLabel:"Refresh storage",accessibilityRole:"button",children:M(Os,{size:14,color:$e.color.textSecondary})}):null,M(O,{onPress:Er,testID:"buoy-storage-filters",accessibilityLabel:"Storage filters",accessibilityRole:"button",style:[he.iconButton,(ye.size>0||Ye.size<3)&&he.activeFilterButton],children:M(Ks,{size:14,color:ye.size>0||Ye.size<3?$e.color.accent:$e.color.textSecondary})}),f==="browser"&&!T&&dt(gi,{children:[M(O,{onPress:()=>I(true),testID:"buoy-storage-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",style:he.iconButton,children:M(Ls,{size:14,color:$e.color.textSecondary})}),M(ia,{value:ar,disabled:Rr.current.length===0,buttonStyle:he.iconButton,testID:"buoy-storage-copy"})]}),f==="events"&&dt(gi,{children:[M(ia,{value:Ho,disabled:rt.length===0,buttonStyle:he.iconButton,testID:"buoy-storage-events-copy"}),M(Fs,{isEnabled:Tr,onToggle:Bt,accessibilityLabel:"Toggle storage event monitoring",testID:"buoy-storage-power"}),M(Ws,{onPress:xe,buttonStyle:he.iconButton,testID:"buoy-storage-clear-events"})]})]})]});return i?M(la,{children:dt(l,{style:he.inlineRoot,children:[M(l,{style:he.inlineHeader,...Ns,children:Oe}),pt(),ir]})}):M(la,{children:M(Vs,{visible:e,onClose:t,onBack:Pn,onMinimize:o,persistenceKey:Ut,header:{showToggleButton:true,customContent:Oe},onModeChange:nr,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:ir,footerHeight:ir?68:0,disableScrollWrapper:true,children:pt()})})}function Su(e={}){return M(zn,{...e,inline:true,visible:true,onClose:()=>{}})}var he=pe.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Ms.border.default,backgroundColor:"transparent"},headerSearchContainer:{flex:1},flexFill:{flex:1},iconButton:{width:32,height:32,borderRadius:8,backgroundColor:$e.color.buttonSurface,borderWidth:1,borderColor:$e.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:$e.color.accentSoft,borderColor:$e.color.accentBorderStrong},separator:{height:8},listContent:{paddingVertical:6},lockedBannerContainer:{marginTop:8,marginHorizontal:16},eventFilterBar:{paddingHorizontal:12,paddingTop:8,paddingBottom:4},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:$e.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:po,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:$e.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:po},eventNavigation:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:8},navButton:{padding:4,borderRadius:4},navButtonDisabled:{opacity:.3},eventCounter:{color:$e.color.text,fontSize:12,fontWeight:"600",fontFamily:po,paddingHorizontal:8},headerTopRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12},keyNameContainer:{flex:1,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:$e.color.surfaceElevated,paddingHorizontal:10,paddingVertical:4,borderRadius:6,borderWidth:1,borderColor:$e.color.border,height:28},keyNameText:{flex:1,fontSize:13,fontWeight:"600",color:$e.color.accent,fontFamily:po,letterSpacing:.5},contentWrapper:{flex:1}});E();mt();Jt();import{approxJsonSize as fi,isDevToolsStorageKey as ut,isOverWireBudget as mi,isJsonSerializable as wu}from"@buoy-gg/shared-ui/web";var Mo=Object.freeze({__buoyValueOnDevice:true,note:"Value stays on the device \u2014 fetched on demand via getEventDetail / mmkv.get / secure.get."}),ku=16*1024,Kn=1.25*1024*1024,hi=8*1024*1024;function On(e){return e===void 0?e:mi(e,ku)?Mo:e}function zo(e,t){let r=e.data;if(!r)return e;let o=t(r.value),n=t(r.prevValue),a=xo(e),i=t(a.pairs),y=t(a.prevPairs);return o===r.value&&n===r.prevValue&&i===a.pairs&&y===a.prevPairs?e:{...e,data:{...r,value:o,prevValue:n,...e.storageType==="async"?{pairs:i,prevPairs:y}:{}}}}function bi(e){return e===void 0||!mi(e,hi)?e:wu(e)?{__buoyTruncated:true,note:`Exceeds the ${hi/(1024*1024)}MB detail limit \u2014 inspect it on-device.`}:Mo}var vi=new WeakMap,Si=new WeakMap;function Cu(e){let t=vi.get(e);if(t)return t;let r;try{let o=zo(e,On);r={event:o,bytes:fi(o,Kn).bytes}}catch{r={event:zo(e,()=>Mo),bytes:1024}}return vi.set(e,r),r}function xu(e){let t=Si.get(e);if(t)return t;let r=zo(e,n=>n===void 0?void 0:Mo),o={event:r,bytes:fi(r,Kn).bytes};return Si.set(e,o),o}function Tu(e){let t=new Array(e.length),r=0;for(let o=0;o<e.length;o++){let n=Cu(e[o]);if(r+n.bytes<=Kn)t[o]=n.event,r+=n.bytes;else{let a=xu(e[o]);t[o]=a.event,r+=a.bytes}}return t}function wi(e){let t=Le.get(e);if(!t)throw new Error(`No MMKV instance registered as "${e}"`);if(t.instance?.isReadOnly)throw new Error(`MMKV instance "${e}" is registered read-only`);return t.instance}var ki=[];function Iu(e){ki=e}var Eu={version:3,getSnapshot:()=>Tu(Lt.getEvents().filter(e=>{let t=e.data?.key;return!(typeof t=="string"&&ut(t))})),subscribe:e=>Lt.subscribeToEvents(e),actions:{clearEvents:()=>{Lt.clearEvents()},getRequiredKeys:()=>ki,getEventDetail:e=>{let{id:t}=e??{};if(!t)return{found:false,reason:"missing id"};let r=Lt.getEvents().find(n=>n.id===t);if(!r)return{found:false,reason:"unknown id"};let o=zo(r,bi);return{found:true,id:t,event:o}},clearAppStorage:()=>uo(),"timeTravel.undo":async e=>{let t=e?.id;if(!t)throw new Error("timeTravel.undo requires an event `id`");let r=Lt.getEvents().find(n=>n.id===t);if(!r)throw new Error(`No storage event with id "${t}"`);if(r.storageType==="mmkv")throw new Error("Time travel supports AsyncStorage events only");let o=r;if(!Bn(o))throw new Error(`Event "${t}" (${o.action}) has no previous value captured, so it cannot be undone`);return await En(o),{undone:true,action:o.action,key:o.data?.key}},"timeTravel.jump":async e=>{let{id:t,scope:r="key"}=e??{};if(!t)throw new Error("timeTravel.jump requires an event `id`");let o=Lt.getEvents().filter(y=>y.storageType!=="mmkv").slice().reverse(),n=o.find(y=>y.id===t);if(!n)throw new Error(`No AsyncStorage event with id "${t}"`);let a=r==="all"?o:o.filter(y=>y.data?.key===n.data?.key),i=a.findIndex(y=>y.id===t);if(i===-1)throw new Error(`Event "${t}" is not in the timeline`);return await Rn(a,i),{jumped:true,scope:r,replayed:i+1,of:a.length,key:n.data?.key}},"async.getAllKeys":async()=>(await oe.getAllKeys()).filter(e=>!ut(e)),"async.multiGet":async e=>(await so(e.keys)).filter(([t])=>!ut(t)),"async.getItem":e=>{let{key:t}=e;return ut(t)?Promise.resolve(null):oe.getItem(t)},"async.setItem":e=>{let{key:t,value:r}=e;return oe.setItem(t,r)},"async.removeItem":e=>oe.removeItem(e.key),"async.multiRemove":e=>sr(e.keys),"async.multiSet":e=>Or(e.pairs),"async.clear":()=>oe.clear(),"mmkv.snapshot":()=>Le.getAll().filter(({id:e})=>!ut(e)).map(({id:e,instance:t,encrypted:r,readOnly:o})=>{let n=[];try{n=t.getAllKeys().filter(a=>!ut(a)).map(a=>{let{value:i,type:y}=kt(t,a);return{key:a,value:On(i),valueType:y}})}catch{}return{id:e,encrypted:r,readOnly:o,entries:n}}),"mmkv.get":e=>{let{instanceId:t,key:r}=e??{};if(!t||!r||ut(r)||ut(t))return{found:false,reason:"missing instanceId/key"};let o=Le.get(t);if(!o)return{found:false,reason:"unknown instance"};let{value:n,type:a}=kt(o.instance,r);return{found:true,instanceId:t,key:r,value:bi(n),valueType:a}},"mmkv.set":e=>{let{instanceId:t,key:r,value:o}=e;wi(t).set(r,o)},"mmkv.remove":e=>{let{instanceId:t,key:r}=e,o=wi(t);o.remove?o.remove(r):o.delete?.(r)},"secure.keys":async()=>{let e=ee.getModule();return Promise.all(ee.getAll().filter(({key:t})=>!ut(t)).map(async({key:t,options:r,description:o})=>{let n=null;if(e&&!r.requireAuthentication)try{n=await e.getItemAsync(t,r)!=null}catch{n=null}return{key:t,description:o,keychainService:r.keychainService,requireAuthentication:r.requireAuthentication??false,hasValue:n}}))},"secure.snapshot":async()=>{let e=ee.getModule(),t=ee.getAll().filter(({key:o})=>!ut(o)),r=[];for(let{key:o,options:n,description:a}of t){let i=null;if(e&&!n.requireAuthentication)try{i=await e.getItemAsync(o,n)}catch{}r.push({key:o,description:a,keychainService:n.keychainService,requireAuthentication:n.requireAuthentication??false,value:i==null?i:On(i)})}return r},"secure.get":e=>{let{key:t}=e;if(ut(t))return null;let r=ee.getAll().find(n=>n.key===t),o=ee.getModule();return!r||!o||r.options.requireAuthentication?Promise.resolve(null):o.getItemAsync(t,r.options)},"secure.set":e=>{let{key:t,value:r}=e;return ee.setValue(t,r)},"secure.delete":e=>ee.deleteValue(e.key)}};import{jsx as Ru}from"react/jsx-runtime";var Ci=xl({id:"storage",name:"STORAGE",description:"AsyncStorage browser",slot:"both",icon:({size:e})=>Ru(kl,{size:e}),component:zn,props:{requiredStorageKeys:[],enableSharedModalDimensions:false}}),Bu=Cl(Ci,e=>(Iu(e.requiredStorageKeys||[]),{requiredStorageKeys:e.requiredStorageKeys||[],enableSharedModalDimensions:e.enableSharedModalDimensions??false}));E();import{HardDrive as Vu,CyberpunkSectionButton as Au}from"@buoy-gg/shared-ui/web";import{isDevToolsStorageKey as Du}from"@buoy-gg/shared-ui/web";import{jsx as Mu}from"react/jsx-runtime";function zu({onPress:e}){let{storageKeys:t}=mn(),r=t.filter(n=>!Du(n.key)).length,o=r;return Mu(Au,{id:"storage",title:"STORAGE",subtitle:o===0?"Empty":`${r} Async`,icon:Vu,iconColor:"#00FF88",iconBackgroundColor:"rgba(0, 255, 136, 0.1)",onPress:e,index:2})}E();import{AlertCircle as xi,CheckCircle2 as Ku,Eye as Ti,XCircle as Ii,HardDrive as Ei,Database as Ri,Shield as Ou,gameUIColors as Ko,macOSColors as ie,night as be,monoFont as Oo}from"@buoy-gg/shared-ui/web";import{DataViewer as Lu}from"@buoy-gg/shared-ui/web/dataViewer";import{jsx as Y,jsxs as Ae}from"react/jsx-runtime";var Bi=[ie.semantic.info,ie.semantic.success,ie.semantic.warning,ie.semantic.debug,"#FF6B9D","#00D9FF"];function Lo(e){let t=e.split("").reduce((r,o)=>r+o.charCodeAt(0),0);return Bi[t%Bi.length]}var Pu=e=>{switch(e){case"required_present":return{icon:Ku,color:ie.semantic.success,bgColor:ie.semantic.successBackground,borderColor:ie.semantic.success+"40",label:"REQUIRED",labelColor:ie.semantic.success};case"required_missing":return{icon:xi,color:ie.semantic.error,bgColor:ie.semantic.errorBackground,borderColor:ie.semantic.error+"50",label:"MISSING",labelColor:ie.semantic.error};case"required_wrong_value":return{icon:Ii,color:ie.semantic.warning,bgColor:ie.semantic.warningBackground,borderColor:ie.semantic.warning+"50",label:"WRONG S",labelColor:ie.semantic.warning};case"required_wrong_type":return{icon:Ii,color:ie.semantic.info,bgColor:ie.semantic.infoBackground,borderColor:ie.semantic.info+"50",label:"WRONG TYPE",labelColor:ie.semantic.info};case"optional_present":return{icon:Ti,color:ie.semantic.debug,bgColor:ie.semantic.infoBackground,borderColor:ie.semantic.debug+"40",label:"OPTIONAL",labelColor:ie.semantic.debug}}},Fu=e=>{switch(e){case"mmkv":return Ei;case"async":return Ri;case"secure":return Ou;default:return Ri}};function Wu({storageKey:e,isExpanded:t,onToggle:r}){let o=Pu(e.status),n=o.icon,a=Fu(e.storageType),i=e.value!==void 0&&e.value!==null,y=e.expectedValue!==void 0,d=e.expectedType!==void 0,p=fa(e.storageType),s=ln(e.storageType,e.instanceId);return Ae(l,{style:[K.storageKeyCard,{borderColor:o.borderColor}],children:[Ae(O,{accessibilityLabel:"Storage key card",accessibilityHint:"View storage key card","sentry-label":`ignore storage key card ${e.key}`,accessibilityRole:"button",style:K.cardHeader,onPress:r,children:[Ae(l,{style:K.cardHeaderLeft,children:[Y(l,{style:[K.iconContainer,{backgroundColor:o.bgColor}],children:Y(n,{size:14,color:o.color})}),Ae(l,{style:K.cardHeaderInfo,children:[Y(u,{style:K.storageKeyText,children:e.key}),e.description?Y(u,{style:K.descriptionText,children:e.description}):null,Ae(l,{style:K.cardHeaderMeta,children:[Y(l,{style:[K.statusBadge,{backgroundColor:o.bgColor}],children:Y(u,{style:[K.statusText,{color:o.labelColor}],children:o.label})}),Ae(l,{style:[K.storageBadge,{backgroundColor:`${p}15`}],children:[Y(a,{size:10,color:p}),Y(u,{style:[K.storageText,{color:p}],children:s})]}),e.storageType==="mmkv"&&e.instanceId&&Ae(l,{style:[K.instanceBadge,{backgroundColor:Lo(e.instanceId)+"20",borderColor:Lo(e.instanceId)+"40"}],children:[Y(Ei,{size:9,color:Lo(e.instanceId)}),Y(u,{style:[K.instanceText,{color:Lo(e.instanceId)}],children:e.instanceId})]}),i&&Y(l,{style:K.valueBadge,children:Y(u,{style:K.valueText,children:e.valueType?e.valueType.toUpperCase():Dt(e.value)})})]})]})]}),Y(l,{style:K.cardHeaderRight,children:Y(l,{style:K.actionButton,children:Y(Ti,{size:12,color:be.color.textSecondary})})})]}),t&&i&&Ae(l,{style:K.cardBody,children:[Y(l,{style:K.dataViewerContainer,children:(()=>{let g=typeof e.value=="string"?(()=>{try{return JSON.parse(e.value)}catch{return e.value}})():e.value;return typeof g=="string"||typeof g=="number"||typeof g=="boolean"?Ae(l,{style:K.simpleValueContainer,children:[Y(u,{style:K.simpleValueLabel,children:"Current Value:"}),Y(l,{style:K.simpleValueBox,children:Y(u,{style:K.simpleValueContent,selectable:true,children:String(g)})}),Ae(u,{style:K.valueTypeText,children:["Type: ",Dt(e.value)]})]}):Y(Lu,{title:"Current Value",data:g,showTypeFilter:false,rawMode:true})})()}),y&&Ae(l,{style:K.valueContainer,children:[Y(u,{style:K.valueLabel,children:"Expected Value:"}),Y(l,{style:K.expectedValueBox,children:Y(u,{style:K.expectedValueContent,selectable:true,children:e.expectedValue})})]}),d&&e.expectedType&&Ae(l,{style:K.valueContainer,children:[Y(u,{style:K.valueLabel,children:"Expected Type:"}),Y(l,{style:K.expectedValueBox,children:Y(u,{style:K.expectedValueContent,selectable:true,children:e.expectedType.toUpperCase()})}),Ae(u,{style:K.typeHelperText,children:["Current type: ",Dt(e.value)]})]}),e.lastUpdated?Y(l,{style:K.metaInfo,children:Ae(u,{style:K.metaLabel,children:["Last updated: ",e.lastUpdated.toLocaleString()]})}):null]}),t&&!i&&Ae(l,{style:K.cardBody,children:[Ae(l,{style:K.emptyValueContainer,children:[Y(xi,{size:16,color:ie.semantic.warning}),Y(u,{style:K.emptyValueText,children:"Storage key not found or empty"})]}),y&&Ae(l,{style:K.valueContainer,children:[Y(u,{style:K.valueLabel,children:"Expected Value:"}),Y(l,{style:K.expectedValueBox,children:Y(u,{style:K.expectedValueContent,selectable:true,children:e.expectedValue})})]})]})]})}var K=pe.create({storageKeyCard:{backgroundColor:be.color.surface,borderRadius:8,borderWidth:1,overflow:"hidden"},cardHeader:{padding:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between"},cardHeaderLeft:{flexDirection:"row",alignItems:"center",flex:1,minWidth:0},iconContainer:{padding:6,borderRadius:6,marginRight:10},cardHeaderInfo:{flex:1,minWidth:0,gap:4},storageKeyText:{color:be.color.text,fontWeight:"500",fontSize:12,flexWrap:"wrap",flex:1},descriptionText:{color:be.color.textSecondary,fontSize:10,marginTop:2,flexWrap:"wrap"},cardHeaderMeta:{flexDirection:"row",alignItems:"center",gap:6,flexWrap:"wrap"},statusBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4},statusText:{fontSize:9,fontWeight:"600",letterSpacing:.5},storageBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4,flexDirection:"row",alignItems:"center",gap:4},storageText:{fontSize:9,fontWeight:"600"},instanceBadge:{paddingHorizontal:6,paddingVertical:3,borderRadius:4,borderWidth:1,flexDirection:"row",alignItems:"center",gap:4},instanceText:{fontSize:9,fontWeight:"700",fontFamily:Oo,letterSpacing:.3},valueBadge:{paddingHorizontal:4,paddingVertical:2,backgroundColor:be.color.surfaceElevated,borderRadius:3},valueText:{fontSize:8,color:be.color.textSecondary,fontWeight:"500"},cardHeaderRight:{marginLeft:8},actionButton:{padding:4,borderRadius:4,backgroundColor:be.color.surfaceElevated},cardBody:{borderTopWidth:1,borderTopColor:be.color.separator,padding:12,gap:12},dataViewerContainer:{marginTop:8},simpleValueContainer:{gap:8},simpleValueLabel:{color:be.color.textSecondary,fontSize:10,fontWeight:"500",textTransform:"uppercase",letterSpacing:.5},simpleValueBox:{backgroundColor:be.color.bg,borderRadius:4,padding:10,borderWidth:1,borderColor:be.color.border},simpleValueContent:{color:Ko.success,fontSize:12,fontFamily:Oo,lineHeight:16},valueTypeText:{color:be.color.textTertiary,fontSize:9,fontStyle:"italic"},valueContainer:{gap:6},valueLabel:{color:be.color.textSecondary,fontSize:10,fontWeight:"500",textTransform:"uppercase",letterSpacing:.5},valueBox:{backgroundColor:be.color.bg,borderRadius:4,padding:8,borderWidth:1,borderColor:be.color.border},valueContent:{color:be.color.text,fontSize:10,fontFamily:Oo,lineHeight:14},expectedValueBox:{backgroundColor:be.color.bg,borderRadius:4,padding:8,borderWidth:1,borderColor:be.color.border},expectedValueContent:{color:be.color.text,fontSize:10,fontFamily:Oo,lineHeight:14},emptyValueContainer:{flexDirection:"row",alignItems:"center",gap:6,padding:8,backgroundColor:Ko.warning+"0D",borderRadius:4,borderWidth:1,borderColor:Ko.warning+"1A"},emptyValueText:{color:Ko.warning,fontSize:10,fontStyle:"italic"},typeHelperText:{color:be.color.textSecondary,fontSize:9,marginTop:4,textAlign:"center"},metaInfo:{marginTop:8},metaLabel:{color:be.color.textTertiary,fontSize:9,fontStyle:"italic"}});E();import{AlertCircle as $u,CheckCircle2 as _u,XCircle as Vi,Eye as Nu,Database as Ai,Shield as Hu}from"@buoy-gg/shared-ui/web";import{night as St}from"@buoy-gg/shared-ui/web";import{jsx as Ce,jsxs as Ue}from"react/jsx-runtime";var qu=[{key:"valid",label:"Valid Keys",description:"Correctly stored and accessible",icon:_u,color:"#10B981",textColor:"#10B981",bgColor:"rgba(16, 185, 129, 0.1)"},{key:"missing",label:"Missing Keys",description:"Required but not found",icon:$u,color:"#EF4444",textColor:"#EF4444",bgColor:"rgba(239, 68, 68, 0.1)"},{key:"wrongValue",label:"Wrong Values",description:"Stored but incorrect value",icon:Vi,color:"#F97316",textColor:"#F97316",bgColor:"rgba(249, 115, 22, 0.1)"},{key:"wrongType",label:"Wrong Types",description:"Value has incorrect data type",icon:Vi,color:"#0891B2",textColor:"#0891B2",bgColor:"rgba(8, 145, 178, 0.1)"},{key:"optional",label:"Optional Keys",description:"Available but not required",icon:Nu,color:"#8B5CF6",textColor:"#8B5CF6",bgColor:"rgba(139, 92, 246, 0.1)"}],ju=[{key:"mmkv",label:ae.mmkv,description:ae.hasSecure?"Synchronous key-value storage":"Storage for this browser tab",icon:Ai},{key:"async",label:ae.asyncFull,description:ae.hasSecure?"React Native async storage":"Persistent storage for this origin",icon:Ai},{key:"secure",label:"SecureStorage",description:"Encrypted secure storage",icon:Hu}];function Uu({stats:e}){let{totalCount:t,missingCount:r,wrongValueCount:o,wrongTypeCount:n,presentRequiredCount:a,optionalCount:i,mmkvCount:y,asyncCount:d,secureCount:p}=e;return t===0?Ue(l,{style:X.statsContainer,children:[Ce(u,{style:X.sectionTitle,children:"STORAGE BREAKDOWN"}),Ce(l,{style:X.emptyState,children:Ce(u,{style:X.emptyStateText,children:"No storage keys detected"})})]}):Ue(l,{style:X.statsContainer,children:[Ue(l,{style:X.breakdownSection,children:[Ce(u,{style:X.sectionTitle,children:"KEY STATUS BREAKDOWN"}),Ce(l,{style:X.breakdownList,children:qu.map(s=>{let g=0,f=false;switch(s.key){case"valid":g=a,f=g>0;break;case"missing":g=r,f=g>0;break;case"wrongValue":g=o,f=g>0;break;case"wrongType":g=n,f=g>0;break;case"optional":g=i,f=g>0;break}if(!f)return null;let C=t>0?(g/t*100).toFixed(1):"0",m=s.icon;return Ce(l,{style:X.breakdownItem,children:Ue(l,{style:X.breakdownItemRow,children:[Ue(l,{style:X.breakdownItemLeft,children:[Ce(l,{style:[X.breakdownIcon,{backgroundColor:s.bgColor}],children:Ce(m,{size:14,color:s.color})}),Ue(l,{style:X.breakdownItemInfo,children:[Ce(u,{style:X.breakdownItemLabel,children:s.label}),Ce(u,{style:X.breakdownItemDesc,children:s.description})]})]}),Ue(l,{style:X.breakdownItemRight,children:[Ce(u,{style:[X.breakdownCount,{color:s.textColor}],children:g}),Ue(u,{style:X.breakdownPercentage,children:[C,"%"]})]})]})},s.key)})})]}),(y>0||d>0||p>0)&&Ue(l,{style:X.breakdownSection,children:[Ce(u,{style:X.sectionTitle,children:"STORAGE TYPE BREAKDOWN"}),Ce(l,{style:X.breakdownList,children:ju.map(s=>{let g=0,f=false;switch(s.key){case"mmkv":g=y,f=g>0;break;case"async":g=d,f=g>0;break;case"secure":g=p,f=g>0;break}if(!f)return null;let C=t>0?(g/t*100).toFixed(1):"0",m=s.icon,b=fa(s.key);return Ce(l,{style:X.breakdownItem,children:Ue(l,{style:X.breakdownItemRow,children:[Ue(l,{style:X.breakdownItemLeft,children:[Ce(l,{style:[X.breakdownIcon,{backgroundColor:`${b}15`}],children:Ce(m,{size:14,color:b})}),Ue(l,{style:X.breakdownItemInfo,children:[Ce(u,{style:X.breakdownItemLabel,children:s.label}),Ce(u,{style:X.breakdownItemDesc,children:s.description})]})]}),Ue(l,{style:X.breakdownItemRight,children:[Ce(u,{style:[X.breakdownCount,{color:b}],children:g}),Ue(u,{style:X.breakdownPercentage,children:[C,"%"]})]})]})},s.key)})})]})]})}var X=pe.create({statsContainer:{marginBottom:24,backgroundColor:St.color.surface,borderRadius:8,padding:16,borderWidth:1,borderColor:St.color.border},sectionTitle:{color:St.color.textSecondary,fontSize:12,fontWeight:"500",marginBottom:16,textTransform:"uppercase",letterSpacing:.5},breakdownSection:{gap:12,marginBottom:20},breakdownList:{gap:12},breakdownItem:{backgroundColor:St.color.surfaceElevated,padding:12,borderRadius:8,borderWidth:1,borderColor:St.color.border},breakdownItemRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},breakdownItemLeft:{flexDirection:"row",alignItems:"center",gap:12,flex:1,minWidth:0},breakdownIcon:{padding:8,borderRadius:8},breakdownItemInfo:{flex:1,minWidth:0},breakdownItemLabel:{color:St.color.text,fontSize:14,fontWeight:"500"},breakdownItemDesc:{color:St.color.textSecondary,fontSize:12},breakdownItemRight:{alignItems:"flex-end"},breakdownCount:{fontSize:16,fontWeight:"600"},breakdownPercentage:{color:St.color.textTertiary,fontSize:10},emptyState:{padding:16,backgroundColor:St.color.surfaceElevated,borderRadius:6,alignItems:"center"},emptyStateText:{color:St.color.textTertiary,fontSize:11,textAlign:"center"}});E();import{Database as Gu,CyberpunkSectionButton as Ju}from"@buoy-gg/shared-ui/web";import{jsx as Yu}from"react/jsx-runtime";function Qu({onPress:e,eventCount:t=0}){let r=t>0?`${t} events`:"Monitoring";return Yu(Ju,{id:"storage-events",title:"EVENTS",subtitle:r,icon:Gu,iconColor:"#00E5FF",iconBackgroundColor:"rgba(0, 229, 255, 0.1)",onPress:e,index:3})}E();import{macOSColors as Jr}from"@buoy-gg/shared-ui/web";var Zu=["SET","GET","MERGE","DELETE","CLEAR"],Xu={SET:Jr.semantic.info,GET:Jr.text.muted,MERGE:Jr.semantic.debug,DELETE:Jr.semantic.error,CLEAR:Jr.semantic.warning};function ey(e){return Xu[e]}function ty(e){let t=e.action;return t==="clear"||t==="clearAll"?"CLEAR":t.startsWith("get.")?"GET":t==="removeItem"||t==="multiRemove"||t==="delete"?"DELETE":t==="mergeItem"||t==="multiMerge"?"MERGE":"SET"}function ry(e){return!!e.data?.initialScan}E();import{useState as oy}from"react";import{macOSColors as rr,night as de,monoFont as Di}from"@buoy-gg/shared-ui/web";import{jsx as le,jsxs as it}from"react/jsx-runtime";function ny({selectedInstanceId:e,onSelectInstance:t,showRefreshButton:r=true}){let[o,n]=oy(false),{instances:a,instanceCount:i,refresh:y}=Sn(false),d=a.find(s=>s.id===e),p=s=>{t(s),n(false)};return pn()?i===0?le(l,{style:_.container,children:it(l,{style:_.emptyState,children:[le(u,{style:_.emptyStateTitle,children:"No MMKV Instances Registered"}),le(u,{style:_.emptyStateDescription,children:"Register MMKV instances using registerMMKVInstance() to monitor them in dev tools."}),r&&le(O,{style:_.refreshButton,onPress:y,activeOpacity:.7,children:le(u,{style:_.refreshButtonText,children:"\u21BB Refresh"})})]})}):it(l,{style:_.container,children:[it(O,{style:_.selectorButton,onPress:()=>n(true),activeOpacity:.7,children:[le(l,{style:_.selectorContent,children:d?le(Mi,{instance:d,isSelected:true}):le(u,{style:_.placeholderText,children:"Select MMKV Instance"})}),le(u,{style:_.dropdownArrow,children:"\u25BC"})]}),le(aa,{visible:o,transparent:true,animationType:"fade",onRequestClose:()=>n(false),children:le(O,{style:_.modalOverlay,activeOpacity:1,onPress:()=>n(false),children:it(l,{style:_.dropdownContainer,children:[it(l,{style:_.dropdownHeader,children:[it(u,{style:_.dropdownTitle,children:["Select MMKV Instance (",i,")"]}),r&&le(O,{style:_.headerRefreshButton,onPress:y,activeOpacity:.7,children:le(u,{style:_.headerRefreshText,children:"\u21BB"})})]}),le(Wr,{style:_.dropdownList,children:a.map(s=>le(O,{style:[_.dropdownItem,s.id===e&&_.dropdownItemSelected],onPress:()=>p(s.id),activeOpacity:.7,children:le(Mi,{instance:s,isSelected:s.id===e})},s.id))})]})})})]}):le(l,{style:_.container,children:it(l,{style:_.unavailableState,children:[it(u,{style:_.unavailableTitle,children:[ae.mmkv," Not Available"]}),le(u,{style:_.unavailableDescription,children:Ra()})]})})}function Mi({instance:e,isSelected:t}){return it(l,{style:_.instanceRow,children:[it(l,{style:_.instanceLeft,children:[le(u,{style:[_.instanceId,t&&_.instanceIdSelected],numberOfLines:1,children:e.id}),it(l,{style:_.instanceBadges,children:[e.encrypted&&le(l,{style:[_.badge,_.badgeEncrypted],children:le(u,{style:_.badgeText,children:"\u{1F512} Encrypted"})}),e.readOnly&&le(l,{style:[_.badge,_.badgeReadOnly],children:le(u,{style:_.badgeText,children:"\u{1F441}\uFE0F Read-only"})})]})]}),it(l,{style:_.instanceRight,children:[le(u,{style:_.keyCount,children:e.keyCount}),le(u,{style:_.keyCountLabel,children:"keys"})]})]})}var _=pe.create({container:{marginBottom:12},unavailableState:{backgroundColor:rr.semantic.warning+"15",borderRadius:12,padding:20,borderWidth:1,borderColor:rr.semantic.warning+"40",alignItems:"center",gap:12},unavailableTitle:{fontSize:14,fontWeight:"600",color:rr.semantic.warning},unavailableDescription:{fontSize:12,color:de.color.textSecondary,textAlign:"center",lineHeight:18},emptyState:{backgroundColor:de.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:de.color.border,alignItems:"center",gap:12},emptyStateTitle:{fontSize:14,fontWeight:"600",color:de.color.text},emptyStateDescription:{fontSize:12,color:de.color.textTertiary,textAlign:"center",lineHeight:18},refreshButton:{marginTop:8,paddingHorizontal:16,paddingVertical:8,backgroundColor:de.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:de.color.accentBorderStrong},refreshButtonText:{fontSize:12,fontWeight:"600",color:de.color.accent},selectorButton:{backgroundColor:de.color.surface,borderRadius:12,borderWidth:1,borderColor:de.color.border,padding:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between",shadowColor:"#000000",shadowOpacity:.03,shadowRadius:8,shadowOffset:{width:0,height:2}},selectorContent:{flex:1},placeholderText:{fontSize:13,color:de.color.placeholder,fontStyle:"italic"},dropdownArrow:{fontSize:10,color:de.color.textTertiary,marginLeft:8},modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center",padding:20},dropdownContainer:{backgroundColor:de.color.surface,borderRadius:16,borderWidth:1,borderColor:de.color.border,width:"100%",maxWidth:500,maxHeight:"70%",shadowColor:"#000000",shadowOpacity:.2,shadowRadius:20,shadowOffset:{width:0,height:10},overflow:"hidden"},dropdownHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16,borderBottomWidth:1,borderBottomColor:de.color.separator},dropdownTitle:{fontSize:14,fontWeight:"600",color:de.color.text},headerRefreshButton:{padding:4},headerRefreshText:{fontSize:18,color:de.color.accent},dropdownList:{maxHeight:400},dropdownItem:{padding:12,borderBottomWidth:1,borderBottomColor:de.color.separator},dropdownItemSelected:{backgroundColor:de.color.accentSoft},instanceRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},instanceLeft:{flex:1,gap:6},instanceId:{fontSize:13,fontWeight:"500",color:de.color.text,fontFamily:Di},instanceIdSelected:{fontWeight:"600",color:de.color.accent},instanceBadges:{flexDirection:"row",flexWrap:"wrap",gap:6},badge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4,borderWidth:1},badgeEncrypted:{backgroundColor:rr.semantic.success+"15",borderColor:rr.semantic.success+"40"},badgeReadOnly:{backgroundColor:rr.semantic.warning+"15",borderColor:rr.semantic.warning+"40"},badgeText:{fontSize:9,fontWeight:"500",color:de.color.textSecondary},instanceRight:{alignItems:"flex-end"},keyCount:{fontSize:16,fontWeight:"600",color:de.color.text,fontFamily:Di},keyCountLabel:{fontSize:9,color:de.color.textTertiary,textTransform:"uppercase",letterSpacing:.5}});E();import{macOSColors as yt,night as Et,monoFont as ay}from"@buoy-gg/shared-ui/web";import{jsx as Ke,jsxs as Cr}from"react/jsx-runtime";function iy({instanceId:e}){let t=Wa(e);return t?Ke(l,{style:ge.container,children:Cr(l,{style:ge.panel,children:[Ke(l,{style:ge.header,children:Ke(u,{style:ge.headerTitle,children:"Instance Details"})}),Cr(l,{style:ge.infoGrid,children:[Ke(Yr,{label:"Instance ID",value:t.id,valueStyle:ge.monoValue}),Ke(Yr,{label:"Keys",value:`${t.keyCount} ${t.keyCount===1?"key":"keys"}`,highlight:true}),Ke(Yr,{label:"Encryption",value:t.encrypted?"\u{1F512} Encrypted":"\u{1F513} Not encrypted",valueColor:t.encrypted?yt.semantic.success:Et.color.textTertiary}),Ke(Yr,{label:"Access",value:t.readOnly?"\u{1F441}\uFE0F Read-only":"\u270F\uFE0F Read-write",valueColor:t.readOnly?yt.semantic.warning:Et.color.textTertiary}),t.size!==void 0&&Ke(Yr,{label:"Size",value:ly(t.size),valueStyle:ge.monoValue})]}),t.encrypted&&Cr(l,{style:ge.notice,children:[Ke(u,{style:ge.noticeIcon,children:"\u{1F512}"}),Ke(u,{style:ge.noticeText,children:"This instance is encrypted. Values are protected at rest."})]}),t.readOnly&&Cr(l,{style:[ge.notice,ge.noticeWarning],children:[Ke(u,{style:ge.noticeIcon,children:"\u{1F441}\uFE0F"}),Ke(u,{style:[ge.noticeText,ge.noticeTextWarning],children:"Read-only mode. Cannot modify values in this instance."})]})]})}):Ke(l,{style:ge.container,children:Ke(l,{style:ge.errorState,children:Cr(u,{style:ge.errorText,children:["Instance not found: ",e]})})})}function Yr({label:e,value:t,valueStyle:r,valueColor:o,highlight:n}){return Cr(l,{style:ge.infoItem,children:[Ke(u,{style:ge.infoLabel,children:e}),Ke(u,{style:[ge.infoValue,r,o&&{color:o},n&&ge.infoValueHighlight],children:t})]})}function ly(e){if(e===0)return"0 Bytes";let t=1024,r=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,o)).toFixed(2))} ${r[o]}`}var ge=pe.create({container:{marginBottom:12},errorState:{backgroundColor:yt.semantic.error+"15",borderRadius:12,padding:12,borderWidth:1,borderColor:yt.semantic.error+"40"},errorText:{fontSize:12,color:yt.semantic.error,textAlign:"center"},panel:{backgroundColor:Et.color.surface,borderRadius:12,borderWidth:1,borderColor:Et.color.border,overflow:"hidden",shadowColor:"#000000",shadowOpacity:.03,shadowRadius:8,shadowOffset:{width:0,height:2}},header:{padding:12,borderBottomWidth:1,borderBottomColor:Et.color.separator},headerTitle:{fontSize:11,fontWeight:"600",color:Et.color.text,textTransform:"uppercase",letterSpacing:.5},infoGrid:{padding:12,gap:10},infoItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:4},infoLabel:{fontSize:12,color:Et.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:12,color:Et.color.text,fontWeight:"500"},infoValueHighlight:{fontSize:14,fontWeight:"600",color:Et.color.accent},monoValue:{fontFamily:ay},notice:{flexDirection:"row",alignItems:"center",gap:8,padding:10,margin:12,marginTop:0,backgroundColor:yt.semantic.success+"10",borderRadius:8,borderWidth:1,borderColor:yt.semantic.success+"30"},noticeWarning:{backgroundColor:yt.semantic.warning+"10",borderColor:yt.semantic.warning+"30"},noticeIcon:{fontSize:14},noticeText:{flex:1,fontSize:11,color:yt.semantic.success,lineHeight:16},noticeTextWarning:{color:yt.semantic.warning}});E();import{getBrowserStorage as zi,subscribeToBrowserStorage as sy}from"@buoy-gg/shared-ui/web/utils";import{isDevToolsStorageKey as Ln}from"@buoy-gg/shared-ui/web";lo();var Ki=0;function cy(e){let t=()=>zi(e),r=()=>Array.from({length:t().length},(n,a)=>t().key(a)).filter(n=>n!==null&&!Ln(n)),o=n=>{try{return JSON.parse(t().getItem(n)??"")}catch{return}};return{set(n,a){t().setItem(n,String(a))},getString(n){let a=typeof o(n);return a==="number"||a==="boolean"?void 0:t().getItem(n)??void 0},getNumber(n){let a=o(n);return typeof a=="number"?a:void 0},getBoolean(n){let a=o(n);return typeof a=="boolean"?a:void 0},getBuffer(){},contains(n){return t().getItem(n)!==null},delete(n){let a=this.contains(n);return t().removeItem(n),a},getAllKeys:r,clearAll(){for(let n of r())t().removeItem(n)},get size(){return r().reduce((n,a)=>n+2*(a.length+(t().getItem(a)?.length??0)),0)},addOnValueChangedListener(n){return{remove:sy(a=>{a.area===e&&(a.key!==void 0?Ln(a.key)||n(a.key):a.prevPairs?.forEach(([i])=>{Ln(i)||n(i)}))})}}}}function dy(){return zr()?["localStorage","sessionStorage"]:["sessionStorage"]}function uy(){if(typeof window>"u")return()=>{};try{zi("sessionStorage")}catch{return()=>{}}let e=dy();if(++Ki===1)for(let r of e)Gn(r,cy(r));let t=true;return()=>{if(t&&(t=false,--Ki===0))for(let r of e)Jn(r)}}export{iy as MMKVInstanceInfoPanel,ny as MMKVInstanceSelector,Zu as STORAGE_OPS,ei as StorageBrowserMode,Dn as StorageEventCard,Vn as StorageEventDetailContent,An as StorageEventDetailFooter,Qu as StorageEventsSection,Wu as StorageKeyCard,Sa as StorageKeySection,Uu as StorageKeyStatsSection,zn as StorageModalWithTabs,zu as StorageSection,Su as StorageToolView,gn as StorageTypeFilterBar,xo as batchPairsOf,Bn as canUndo,uo as clearAllAppStorage,Ea as countByStorageType,Bu as createStorageTool,kt as detectMMKVType,dl as formatMMKVValue,Dc as getMMKVClass,Ra as getMMKVUnavailableMessage,gu as getValueType,ry as isInitialScan,pn as isMMKVAvailable,Qo as isTypeMatch,Ur as isValueOnDevice,Rn as jumpToState,Gn as registerMMKVInstance,pl as registerSecureStoreKeys,Cd as requestStorageBrowserRefresh,Ga as setStorageValue,uy as startBrowserStorageCapture,kn as storageEditBlockedReason,Lt as storageEventStore,ey as storageOpDot,ty as storageOpOf,Eu as storageSyncAdapter,Ci as storageToolPreset,xd as storageValueToEditableText,En as undoOperation,Jn as unregisterMMKVInstance,fl as unregisterSecureStoreKey,mn as useAsyncStorageKeys,Wa as useMMKVInstance,Yc as useMMKVInstanceExists,Sn as useMMKVInstances,Hc as useMMKVKeys,La as useMultiMMKVKeys,ri as useStorageEvents,Ua as validateStorageValue};
4
+ registerMMKVInstance('mmkv.default', storage);`})]}),ye==="mmkv"&&xe.length>0&&Ee(l,{style:P.instanceNavbar,children:[Ee(l,{style:P.instanceNavbarHeader,children:[H(u,{style:P.instanceNavbarLabel,children:"INSTANCES"}),xe.length>Q&&H(ua,{style:{transform:[{scale:.85}]}})]}),Ee(Wr,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:P.instanceNavbarScroll,children:[(x||xe.length===1)&&Ee(O,{onPress:()=>$t(null),testID:"buoy-storage-instance-all",accessibilityRole:"button",accessibilityLabel:`All ${ae.mmkv} instances`,style:[P.instanceNavbarButton,re===null&&P.instanceNavbarButtonActive],children:[H(Za,{size:12,color:re===null?F.color.text:F.color.textSecondary}),H(u,{style:[P.instanceNavbarButtonText,re===null&&P.instanceNavbarButtonTextActive],children:"All"}),H(l,{style:P.instanceNavbarBadge,children:H(u,{style:P.instanceNavbarBadgeText,children:xe.reduce((c,h)=>c+h.keyCount,0)})})]}),xe.map((c,h)=>{let U=h>=Q;return Ee(O,{testID:`buoy-storage-instance-${c.id}`,accessibilityRole:"button",accessibilityLabel:`MMKV instance ${c.id}`,onPress:()=>{U?Se(true):$t(c.id)},style:[P.instanceNavbarButton,c.id===re&&P.instanceNavbarButtonActive,{borderColor:U?F.color.border:Sr(c.id)+"40",backgroundColor:c.id===re?Sr(c.id)+"20":F.color.surfaceElevated,opacity:U?.5:1}],children:[H(Za,{size:12,color:c.id===re?Sr(c.id):F.color.textSecondary}),H(u,{style:[P.instanceNavbarButtonText,c.id===re&&{color:Sr(c.id),fontWeight:"700"}],children:c.id}),H(l,{style:[P.instanceNavbarBadge,c.id===re&&{backgroundColor:Sr(c.id)+"30"}],children:H(u,{style:[P.instanceNavbarBadgeText,c.id===re&&{color:Sr(c.id)}],children:c.keyCount})})]},c.id)})]})]})]}),Fi=H(dd,{copyValue:jo,mmkvInstances:xe.map(c=>({id:c.id,instance:c.instance})),activeStorageType:ye,onClearComplete:Te,isSelectMode:Nt,onToggleSelectMode:No,selectedCount:nr.size}),Wi=Nt?H(wd,{selectedKeys:Qe,mmkvInstances:xe.map(c=>({id:c.id,instance:c.instance})),onDeleteComplete:Ho,onHideKeys:Br,onSelectAll:Ar,onClearSelection:Dr,totalVisibleKeys:v.length}):null,$i=z?Ee(O,{style:P.limitBanner,onPress:()=>Se(true),activeOpacity:.8,testID:"buoy-storage-locked-banner",accessibilityRole:"button",children:[Ee(l,{style:P.limitBannerContent,children:[Ee(l,{style:P.limitBannerLeft,children:[H(qs,{size:16,color:F.color.accent}),H(u,{style:P.limitBannerText,children:a?`${k} matching ${k===1?"key":"keys"} in locked storage`:`${k} keys locked`})]}),H(ua,{})]}),H(u,{style:P.limitBannerSubtext,children:a?"Upgrade to Pro to search your full storage":"Upgrade to Pro to unlock full storage access"})]}):null,_i=(()=>{let c=N.some(U=>!ze(U.key)),h;return a||!c?(h=Gs({subject:"keys",verb:"registered",search:a,total:c?1:0,waiting:{otto:"empty",title:"No storage keys",message:"Nothing is registered for this tool to read."}}),a&&c&&(h={...h,message:"No keys match. Clear the search to see them."})):se==="missing"?h={otto:"thumbsup",title:"No missing keys",message:"All required keys are present"}:se==="issues"?h={otto:"cool",title:"No issues found",message:"All storage keys are correctly configured"}:h={otto:"broken",title:"No valid keys found",message:"All keys have issues or are missing"},H(Us,{...h,testID:"buoy-storage-keys-empty"})})(),Ni=H(js,{visible:ve,onClose:()=>Se(false),featureName:"Storage Keys"});return Ee(l,{style:P.root,children:[_t>0?H(td,{onDone:()=>Tr(0)},_t):null,Ee(Wr,{keyboardShouldPersistTaps:"handled",testID:"buoy-storage-scroll",ref:Ye,onScroll:c=>{xr.current=c.nativeEvent.contentOffset.y},scrollEventThrottle:32,style:P.scrollContainer,contentContainerStyle:P.container,showsVerticalScrollIndicator:false,children:[H(l,{style:P.backgroundGrid}),H(Mc,{stats:Ut,tabStats:pt,healthPercentage:Mr,healthStatus:Oi,healthColor:Li,activeFilter:se,onFilterChange:Ge,activeStorageType:ye,onStorageTypeChange:or,showStatus:!te}),Pi,Oe.length>0?Ee(l,{style:P.keysSection,children:[Ee(l,{style:P.sectionHeader,children:[Ee(l,{style:P.sectionHeaderLeft,children:[Ee(u,{style:P.sectionTitle,children:[se==="all"?"KEYS":se==="missing"?"MISSING KEYS":"ISSUES TO FIX",ye!=="all"&&` (${ye.toUpperCase()})`]}),H(l,{style:P.countBadge,children:H(u,{style:P.countText,children:v.length})})]}),Fi]}),Wi,H(Sa,{title:"",count:-1,keys:v,emptyMessage:"",isSelectMode:Nt,selectedKeys:nr,onSelectionChange:rt,eventCountByKey:y,onViewHistory:p,onHideKey:c=>Br([c]),onToggleKey:qo,onDeleteKey:oo,editBlockedFor:Vr,pinnedKeys:m,onTogglePin:b,onRowRef:gt,onOpenKey:R}),$i]}):_i,H(u,{style:P.techFooter,children:"ASYNC STORAGE | MMKV | SECURE STORAGE BACKENDS"}),Ni]})]})}var P=pe.create({root:{flex:1,minHeight:0},editorOverlay:{...sa,zIndex:10},scrollContainer:{flex:1,backgroundColor:"transparent"},container:{padding:12,paddingBottom:120},backgroundGrid:{...sa,opacity:.006,backgroundColor:vr.info},techFooter:{fontSize:8,color:F.color.textTertiary,fontFamily:$r,textAlign:"center",marginTop:20,letterSpacing:1,opacity:.5},keysSection:{marginTop:8,backgroundColor:F.color.bg,borderRadius:12,padding:12,borderWidth:1,borderColor:F.color.border},sectionHeader:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",marginBottom:10,paddingBottom:6,borderBottomWidth:1,borderBottomColor:F.color.separator},sectionHeaderLeft:{flexDirection:"row",alignItems:"center",gap:8},sectionTitle:{fontSize:12,fontWeight:"600",color:F.color.textSecondary,letterSpacing:.4,textTransform:"uppercase"},countBadge:{backgroundColor:F.color.surfaceElevated,paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1,borderColor:F.color.border},countText:{fontSize:11,fontWeight:"600",color:F.color.text,fontFamily:$r},emptyState:{alignItems:"center",justifyContent:"center",paddingVertical:48},emptyTitle:{fontSize:16,fontWeight:"600",color:F.color.text,marginTop:12,marginBottom:8},emptySubtitle:{fontSize:13,color:F.color.textSecondary,textAlign:"center"},emptyMMKVState:{backgroundColor:F.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:F.color.border,marginTop:8,alignItems:"center"},emptyMMKVTitle:{fontSize:14,fontWeight:"600",color:F.color.text,marginBottom:6},emptyMMKVSubtitle:{fontSize:12,color:F.color.textSecondary,textAlign:"center",marginBottom:12},emptyMMKVCode:{fontSize:10,fontFamily:$r,color:F.color.accent,backgroundColor:F.color.bg,padding:12,borderRadius:8,borderWidth:1,borderColor:F.color.border,alignSelf:"stretch"},instanceNavbar:{marginTop:12,marginBottom:8,backgroundColor:F.color.surface,borderRadius:10,borderWidth:1,borderColor:F.color.border,padding:10,shadowColor:"#000",shadowOpacity:.08,shadowRadius:6,shadowOffset:{width:0,height:2}},instanceNavbarHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:8,paddingLeft:2},instanceNavbarLabel:{fontSize:9,fontWeight:"700",color:F.color.textTertiary,textTransform:"uppercase",letterSpacing:1},instanceNavbarScroll:{gap:8,paddingRight:8},instanceNavbarButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8,backgroundColor:F.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:F.color.border,minWidth:90},instanceNavbarButtonActive:{borderWidth:1.5,shadowColor:"#000",shadowOpacity:.1,shadowRadius:4,shadowOffset:{width:0,height:1}},instanceNavbarButtonText:{fontSize:11,fontWeight:"600",color:F.color.textSecondary,fontFamily:$r,flex:1},instanceNavbarButtonTextActive:{fontWeight:"700",color:F.color.text},instanceNavbarBadge:{backgroundColor:F.color.bg,paddingHorizontal:6,paddingVertical:2,borderRadius:6,minWidth:24,alignItems:"center"},instanceNavbarBadgeText:{fontSize:10,fontWeight:"700",color:F.color.textSecondary,fontFamily:$r},clearSearchButton:{marginTop:16,paddingHorizontal:16,paddingVertical:8,backgroundColor:F.color.surfaceElevated,borderRadius:6,borderWidth:1,borderColor:F.color.border},clearSearchText:{fontSize:13,color:F.color.text,fontWeight:"500"},limitBanner:{backgroundColor:F.color.surface,borderRadius:10,borderWidth:1,borderColor:F.color.accentBorderStrong,padding:12,marginTop:12},limitBannerContent:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:4},limitBannerLeft:{flexDirection:"row",alignItems:"center",gap:8},limitBannerText:{color:F.color.text,fontSize:13,fontWeight:"600"},limitBannerSubtext:{color:F.color.textTertiary,fontSize:11}});import{jsx as Bd}from"react/jsx-runtime";function ei({requiredStorageKeys:e=[],showFilters:t=false,ignoredPatterns:r=new Set,onTogglePattern:o,onAddPattern:n,searchQuery:a="",storageDataRef:i,eventCountByKey:y,lastWriteByKey:d,onViewHistory:p,enabledStorageTypes:s,statusFilter:g,onStatusFilterChange:f,onStatusCountsChange:C,pinnedKeys:m,onTogglePin:b,applySafeAreaInset:S,storageTypeFilter:w,onStorageTypeFilterChange:T,detailKey:I,onOpenKey:R,onCloseDetail:D}){return Bd(Rd,{requiredStorageKeys:e,showFilters:t,ignoredPatterns:r,onTogglePattern:o,onAddPattern:n,searchQuery:a,storageDataRef:i,eventCountByKey:y,lastWriteByKey:d,onViewHistory:p,enabledStorageTypes:s,statusFilter:g,onStatusFilterChange:f,onStatusCountsChange:C,pinnedKeys:m,onTogglePin:b,applySafeAreaInset:S,storageTypeFilter:w,onStorageTypeFilterChange:T,detailKey:I,onOpenKey:R,onCloseDetail:D})}import{ProFeatureBanner as Vd}from"@buoy-gg/shared-ui/web";E();import{useMemo as Ad}from"react";import{useEventStoreEvents as Dd}from"@buoy-gg/shared-ui/web";E();import{BaseEventStore as Md,appStorageEvent as Cn}from"@buoy-gg/shared-ui/web";function Ur(e){return!!e&&typeof e=="object"&&e.__buoyValueOnDevice===true}function xo(e){return e.storageType!=="async"||!e.data?{}:{pairs:e.data.pairs,prevPairs:e.data.prevPairs}}function ti(e){let t=e.data;if(!t)return false;let{pairs:r,prevPairs:o}=xo(e);return Ur(t.value)||Ur(t.prevValue)||Ur(r)||Ur(o)}var zd=0;function To(){return`se-${Date.now()}-${++zd}`}var Kd=class extends Md{constructor(){super({storeName:"storage",maxEvents:500});this.asyncStorageUnsubscribe=null;this.mmkvUnsubscribe=null;this.hasScannedInitialState=false}addEvent(e){let t=Cn(e);t&&super.addEvent(t)}async scanExistingState(){if(this.hasScannedInitialState)return;this.hasScannedInitialState=true;let e=new Date,t=Le.getAll();for(let{id:r,instance:o}of t)try{let n=o.getAllKeys();for(let a of n){let{value:i,type:y}=kt(o,a),d={string:"set.string",number:"set.number",boolean:"set.boolean",buffer:"set.buffer"}[y]??"set.string";this.addEvent({action:d,timestamp:e,instanceId:r,data:{key:a,value:i,valueType:y,initialScan:true},storageType:"mmkv",id:To()})}}catch{}try{let{asyncStorage:r,readMany:o}=(Jt(),Gi(Nn));if(r){let n=await r.getAllKeys();if(n.length>0){let a=await o(n);for(let[i,y]of a)this.addEvent({action:"setItem",timestamp:e,data:{key:i,value:y??void 0,initialScan:true},storageType:"async",id:To()})}}}catch{}}async startCapturing(){Nc()||await _c(),this.asyncStorageUnsubscribe||(this.asyncStorageUnsubscribe=Da(e=>{let t={...e,storageType:"async",id:To()};this.addEvent(t)})),this.mmkvUnsubscribe||(this.mmkvUnsubscribe=Un(e=>{let t={...e,storageType:"mmkv",id:To()};this.addEvent(t)})),await this.scanExistingState()}stopCapturing(){this.asyncStorageUnsubscribe&&(this.asyncStorageUnsubscribe(),this.asyncStorageUnsubscribe=null),this.mmkvUnsubscribe&&(this.mmkvUnsubscribe(),this.mmkvUnsubscribe=null)}isCapturing(){return this.asyncStorageUnsubscribe!==null||this.mmkvUnsubscribe!==null}getEventsByType(e){return this.events.filter(t=>t.storageType===e)}replaceEvents(e){let t=new Map;for(let o of this.events)ti(o)||t.set(o.id,o);let r=e.map(Cn).filter(o=>o!==null).map(o=>{let n=t.get(o.id);return!n||!ti(o)?o:{...o,data:{...o.data,value:n.data?.value,prevValue:n.data?.prevValue,...xo(n)}}});super.replaceEvents(r)}hydrateEvent(e){let t=Cn(e);if(!t)return;e=t;let r=this.events.findIndex(a=>a.id===e.id);if(r===-1)return;let o=this.events[r],n=this.events.slice();n[r]={...o,...e,timestamp:o.timestamp,data:{...o.data,...e.data}},super.replaceEvents(n)}},Lt=new Kd;function ri(e={}){let{storageType:t="all",maxEvents:r=500,enabled:o=true}=e,n=Ad(()=>t==="all"?void 0:d=>d.filter(p=>p.storageType===t),[t]),{events:a,clearEvents:i,isActive:y}=Dd(Lt,{maxEvents:r,enabled:o,select:n});return{events:a,clearEvents:i,isCapturing:y}}E();mt();import{useState as Io,useCallback as ct,useMemo as Pt,useEffect as oi,useRef as Od}from"react";import{formatRelativeTime as Eo,macOSColors as Ro,night as er,parseValue as Bo,devToolsStorageKeys as ni,GitBranch as Ld,EventStepperFooter as Pd,EventHistoryViewer as Fd,copyToClipboard as Wd,ProUpgradeModal as $d,monoFont as ai}from"@buoy-gg/shared-ui/web";import{useIsPro as _d}from"@buoy-gg/license/web";E();import{computeLineDiff as Bg,DiffType as Vg,ABSENT_VALUE as Nd,isAbsent as Ag}from"@buoy-gg/shared-ui/web/dataViewer";E();import{ThemedSplitView as Hd}from"@buoy-gg/shared-ui/web/dataViewer";E();import{diffThemes as qd,gitClassicTheme as zg,devToolsDefaultTheme as Kg}from"@buoy-gg/shared-ui/web/dataViewer";E();import{night as ii}from"@buoy-gg/shared-ui/web";import{TreeDiffViewer as jd}from"@buoy-gg/shared-ui/web/dataViewer";import{jsx as li}from"react/jsx-runtime";function Ud({oldValue:e,newValue:t,scrollEnabled:r=true}){return li(l,{style:r?si.container:si.containerInline,children:li(jd,{oldValue:e,newValue:t,theme:"dark",scrollEnabled:r})})}var si=pe.create({container:{flex:1,backgroundColor:ii.color.bg},containerInline:{backgroundColor:ii.color.bg}});E();function xn(e){switch(e){case"setItem":return"SET";case"removeItem":return"REMOVE";case"mergeItem":return"MERGE";case"clear":return"CLEAR";case"multiSet":return"MULTI SET";case"multiRemove":return"MULTI REMOVE";case"multiMerge":return"MULTI MERGE";case"set.string":case"set.number":case"set.boolean":case"set.buffer":return"SET";case"delete":return"REMOVE";case"clearAll":return"CLEAR";case"get.string":case"get.number":case"get.boolean":case"get.buffer":return"GET";default:return"UNKNOWN ACTION"}}E();import{night as Re,Lock as Gd,monoFont as Jd}from"@buoy-gg/shared-ui/web";import{jsx as Tn,jsxs as Yd}from"react/jsx-runtime";var Qd={copy:{color:Re.color.accent,backgroundColor:Re.color.accentSoft,borderColor:Re.color.accentBorderStrong,textColor:Re.color.accent},jump:{color:Re.color.warning,backgroundColor:Re.color.warningSoft,borderColor:Re.color.warning+"40",textColor:Re.color.warning},undo:{color:Re.color.info,backgroundColor:Re.color.infoSoft,borderColor:Re.color.info+"40",textColor:Re.color.info}};function In({onPress:e,text:t,type:r,disabled:o=false,locked:n=false}){let a=Qd[r],i=o||n;return Yd(O,{disabled:i,onPress:e,style:[Vo.button,{backgroundColor:i?Re.color.fill:a.backgroundColor,borderColor:i?Re.color.fillTertiary:a.borderColor,opacity:o?.5:1}],activeOpacity:.7,testID:`buoy-storage-action-${r}`,accessibilityRole:"button",accessibilityLabel:t,accessibilityState:{disabled:i},children:[n?Tn(Gd,{size:10,color:Re.color.textTertiary,style:Vo.lockIcon}):Tn(l,{style:[Vo.dot,{backgroundColor:i?Re.color.textTertiary:a.color}]}),Tn(u,{style:[Vo.text,{color:i?Re.color.textTertiary:a.textColor}],children:t})]})}var Vo=pe.create({button:{flexDirection:"row",alignItems:"center",justifyContent:"center",borderRadius:6,borderWidth:1,paddingHorizontal:12,paddingVertical:6,height:25,minWidth:70,shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2,elevation:2},dot:{width:5,height:5,borderRadius:3,marginRight:6,shadowColor:Re.color.text,shadowOffset:{width:0,height:0},shadowOpacity:.6,shadowRadius:2},lockIcon:{marginRight:4},text:{fontSize:10,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:Jd,height:12}});E();mt();Jt();import{isDevToolsStorageKey as Zd}from"@buoy-gg/shared-ui/web";function Ft(e){return!!e&&typeof e=="object"&&e.__buoyValueOnDevice===true}async function En(e){let{action:t,data:r}=e;if(Ft(r?.prevValue)||Ft(r?.prevPairs))throw new Error("Cannot undo: previous value is still on the device \u2014 fetch getEventDetail first");switch(t){case"setItem":case"mergeItem":r?.key&&(r.prevValue===null||r.prevValue===void 0?await oe.removeItem(r.key):await oe.setItem(r.key,r.prevValue));break;case"removeItem":r?.key&&r.prevValue!==null&&r.prevValue!==void 0&&await oe.setItem(r.key,r.prevValue);break;case"multiSet":case"multiMerge":if(r?.prevPairs&&r.prevPairs.length>0)for(let[o,n]of r.prevPairs)n===null?await oe.removeItem(o):await oe.setItem(o,n);break;case"multiRemove":if(r?.prevPairs&&r.prevPairs.length>0)for(let[o,n]of r.prevPairs)n!==null&&await oe.setItem(o,n);break;case"clear":if(r?.prevPairs&&r.prevPairs.length>0){let o=r.prevPairs.filter(([,n])=>n!==null);o.length>0&&await Or(o)}break;default:throw new Error(`Cannot undo unknown action type: ${t}`)}}async function Rn(e,t){if(t<0||t>=e.length)throw new Error(`Invalid event index: ${t}`);for(let i of e){let y=i.data;if(Ft(y?.value)||Ft(y?.prevValue)||Ft(y?.pairs)||Ft(y?.prevPairs))throw new Error("Cannot jump: some event values are still on the device \u2014 fetch getEventDetail first")}let r=new Map;for(let i=0;i<=t;i++)eu(e[i],r);let o=new Set;for(let i of e)Xd(i,o);let n=[],a=[];for(let i of o){if(Zd(i))continue;let y=r.get(i);y==null?a.push(i):n.push([i,y])}a.length>0&&await sr(a),n.length>0&&await Or(n)}function Xd(e,t){let{data:r}=e;if(r){if(r.key&&t.add(r.key),r.keys)for(let o of r.keys)t.add(o);if(r.pairs)for(let[o]of r.pairs)t.add(o);if(r.prevPairs)for(let[o]of r.prevPairs)t.add(o)}}function eu(e,t){let{action:r,data:o}=e;switch(r){case"setItem":o?.key&&o?.value!==void 0&&t.set(o.key,o.value);break;case"removeItem":o?.key&&t.set(o.key,null);break;case"mergeItem":if(o?.key&&o?.value!==void 0){let n=t.get(o.key);if(n)try{let a=JSON.parse(n),i=JSON.parse(o.value),y={...a,...i};t.set(o.key,JSON.stringify(y))}catch{t.set(o.key,o.value)}else t.set(o.key,o.value)}break;case"multiSet":if(o?.pairs)for(let[n,a]of o.pairs)t.set(n,a);break;case"multiRemove":if(o?.keys)for(let n of o.keys)t.set(n,null);break;case"multiMerge":if(o?.pairs)for(let[n,a]of o.pairs){let i=t.get(n);if(i)try{let y=JSON.parse(i),d=JSON.parse(a),p={...y,...d};t.set(n,JSON.stringify(p))}catch{t.set(n,a)}else t.set(n,a)}break;case"clear":t.clear();break}}function Bn(e){let{action:t,data:r}=e;switch(t){case"setItem":case"mergeItem":case"removeItem":return!!r?.key&&!Ft(r.prevValue);case"multiSet":case"multiRemove":case"multiMerge":case"clear":return!!r?.prevPairs&&r.prevPairs.length>0&&!Ft(r.prevPairs);default:return false}}import{Fragment as tu,jsx as je,jsxs as ci}from"react/jsx-runtime";var wr=-1,Ao={prior:{label:"BEFORE #1",timestamp:"value before first event",relativeTime:"not captured",badge:"PRIOR"},absent:{label:"NO PRIOR VALUE",timestamp:"key did not exist",relativeTime:"created here",badge:"ABSENT"},scanned:{label:"ALREADY PRESENT",timestamp:"value found at startup",relativeTime:"not a write",badge:"SCANNED"}};function Do(e){switch(e){case"setItem":case"multiSet":return Ro.semantic.success;case"removeItem":case"multiRemove":case"clear":return Ro.semantic.error;case"mergeItem":case"multiMerge":return Ro.semantic.info;default:return Ro.text.muted}}function di(e){let t=String(e.getHours()).padStart(2,"0"),r=String(e.getMinutes()).padStart(2,"0"),o=String(e.getSeconds()).padStart(2,"0"),n=String(e.getMilliseconds()).padStart(3,"0");return`${t}:${r}:${o}.${n}`}var ru={hideLineNumbers:false,disableWordDiff:false,showDiffOnly:false,compareMethod:"words",contextLines:3,lineOffset:0},ou=[];function Vn({conversation:e,selectedEventIndex:t=0,onEventIndexChange:r=()=>{},disableInternalFooter:o=false}){let n=_d(),[a,i]=Io(false),[y,d]=Io("split"),[p,s]=Io(Math.max(wr,t-1)),[g,f]=Io(t),C=Od(false),m=Pt(()=>e.events.sort((ne,gt)=>ne.timestamp.getTime()-gt.timestamp.getTime()),[e.events]),b=m.length;oi(()=>{if(C.current)return;(async()=>{try{let ne=await oe.getItem(ni.storage.diffViewerMode());(ne==="split"||ne==="tree")&&d(ne),C.current=true}catch{}})()},[]),oi(()=>{let ne=Math.min(b-1,Math.max(0,t)),gt=Math.max(wr,Math.min(ne-1,t-1));s(gt),f(ne)},[t,b]);let S=ct(async ne=>{d(ne);try{await oe.setItem(ni.storage.diffViewerMode(),ne)}catch{}},[]),w=m[t],T=w?.action,I=p===wr,R=I?void 0:m[Math.max(0,Math.min(b-1,p))],D=m[Math.max(0,Math.min(b-1,g))],x=Pt(()=>{let ne=D?.data;return ne?.initialScan?"scanned":ne?.prevValue===null||ne?.prevValue===void 0?"absent":"prior"},[D]),B=Pt(()=>x==="absent"?Nd:x==="scanned"?Bo(D?.data?.value):Bo(D?.data?.prevValue),[x,D]),Q=Pt(()=>I?{index:wr,label:Ao[x].label,timestamp:Ao[x].timestamp,relativeTime:Ao[x].relativeTime,badge:je(l,{style:[tr.actionBadgeSmall,{backgroundColor:`${er.color.textTertiary}20`}],children:je(u,{style:[tr.actionTextSmall,{color:er.color.textTertiary}],children:Ao[x].badge})})}:{index:p,label:`#${p+1} / ${b}`,timestamp:R?di(R.timestamp):"",relativeTime:R?Eo(R.timestamp):"",badge:R?je(l,{style:[tr.actionBadgeSmall,{backgroundColor:`${Do(R.action)}20`}],children:je(u,{style:[tr.actionTextSmall,{color:Do(R.action)}],children:xn(R.action)})}):void 0},[p,R,b,I,x]),ve=Pt(()=>({index:g,label:`#${g+1} / ${b}`,timestamp:D?di(D.timestamp):"",relativeTime:D?Eo(D.timestamp):"",badge:D?je(l,{style:[tr.actionBadgeSmall,{backgroundColor:`${Do(D.action)}20`}],children:je(u,{style:[tr.actionTextSmall,{color:Do(D.action)}],children:xn(D.action)})}):void 0}),[g,D,b]),Se=Pt(()=>[{key:"tree",label:"TREE VIEW"},{key:"split",label:"SPLIT VIEW"}],[]),q=ct(()=>{p>wr&&s(p-1)},[p]),ue=ct(()=>{p<g-1&&s(p+1)},[p,g]),te=ct(()=>{g>p+1&&f(g-1)},[g,p]),se=ct(()=>{g<b-1&&f(g+1)},[g,b]),Ge=Pt(()=>I?B:Bo(R?.data?.value??null),[I,B,R]),Je=Pt(()=>Bo(D?.data?.value),[D]),wt=ct(()=>y==="split"?je(Hd,{oldValue:Ge,newValue:Je,differences:ou,theme:qd.devToolsDefault,options:ru,showThemeName:false,scrollEnabled:false}):je(Ud,{oldValue:Ge,newValue:Je,scrollEnabled:false}),[Ge,Je,y]),Rt=ct(()=>{r(Math.max(0,t-1))},[t,r]),ye=ct(()=>{r(Math.min(b-1,t+1))},[t,b,r]),or=ct(async()=>{if(!n){i(true);return}if(!(!w||w.storageType==="mmkv"))try{await En(w)}catch{}},[w,n]),re=ct(async()=>{if(!n){i(true);return}if(!w||w.storageType==="mmkv")return;let ne=m.filter(_t=>_t.storageType!=="mmkv"),gt=ne.findIndex(_t=>_t.timestamp.getTime()===w.timestamp.getTime());if(gt!==-1)try{await Rn(ne,gt)}catch{}},[w,m,n]),$t=ct(async()=>{if(!w)return;let ne={action:w.action,timestamp:w.timestamp.toISOString(),data:w.data};await Wd(ne)},[w]),Ye=w?.storageType!=="mmkv",xr=Ye&&w&&Bn(w);return ci(tu,{children:[Ye&&ci(l,{style:tr.actionButtonsContainer,children:[je(In,{type:"undo",text:"UNDO",onPress:or,disabled:!xr,locked:!n}),je(In,{type:"jump",text:"JUMP",onPress:re,locked:!n}),je(In,{type:"copy",text:"COPY",onPress:$t})]}),je(Fd,{activeView:"diff",diffViewLabel:"DIFF VIEW",diffViewDescription:"Compare changes between versions",diffViewIcon:Ld,diffModeTabs:Se,activeDiffMode:y,onDiffModeChange:S,renderDiffContent:wt,scrollDiffSection:true,leftEvent:Q,rightEvent:ve,showCompareNavigation:true,onLeftPrevious:q,onLeftNext:ue,onRightPrevious:te,onRightNext:se,canLeftPrevious:p>wr,canLeftNext:p<g-1,canRightPrevious:g>p+1,canRightNext:g<b-1,disableInternalFooter:o,footerCurrentIndex:t,footerTotalItems:b,footerItemLabel:"Event",footerSubtitle:Eo(w?.timestamp),onFooterPrevious:Rt,onFooterNext:ye}),je($d,{visible:a,onClose:()=>i(false),featureName:"Storage Time-Travel"})]})}function An({conversation:e,selectedEventIndex:t=0,onEventIndexChange:r=()=>{},applySafeAreaInset:o=true}){let n=e.events.sort((i,y)=>i.timestamp.getTime()-y.timestamp.getTime()),a=n.length;return je(Pd,{currentIndex:t,totalItems:a,onPrevious:()=>r(Math.max(0,t-1)),onNext:()=>r(Math.min(a-1,t+1)),itemLabel:"Event",subtitle:Eo(n[t]?.timestamp),applySafeAreaInset:o})}var tr=pe.create({actionButtonsContainer:{flexDirection:"row",justifyContent:"center",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:10,backgroundColor:er.color.surface,borderBottomWidth:1,borderBottomColor:er.color.border},valueBox:{backgroundColor:er.color.bg,borderRadius:6,borderWidth:1,borderColor:er.color.border,padding:8},valueText:{fontSize:12,color:er.color.text,fontFamily:ai,lineHeight:18},actionBadgeSmall:{paddingHorizontal:6,paddingVertical:1,borderRadius:3},actionTextSmall:{fontSize:8,fontWeight:"700",fontFamily:ai}});E();import{Filter as ui,DynamicFilterView as nu,Database as au,HardDrive as iu,Shield as lu,macOSColors as Tt,night as It}from"@buoy-gg/shared-ui/web";import{jsx as Wt,jsxs as kr}from"react/jsx-runtime";function su({ignoredPatterns:e,onTogglePattern:t,onAddPattern:r,availableKeys:o=[],enabledStorageTypes:n,onToggleStorageType:a}){let i={addFilterSection:{enabled:true,placeholder:"Enter key pattern to hide...",title:"KEY FILTERS",icon:ui},availableItemsSection:{enabled:true,title:"AVAILABLE EVENT KEYS",emptyMessage:"No storage event keys available. Events will appear here once captured.",items:o},howItWorksSection:{enabled:true,title:"HOW EVENT FILTERS WORK",description:"Patterns hide matching storage keys from the event list. Storage type toggles control which storage backends are monitored.",examples:["\u2022 react_buoy \u2192 hides keys containing react_buoy","\u2022 @temp \u2192 hides @temp_user, @temp_data","\u2022 redux \u2192 hides redux-persist:root",`\u2022 ${ae.asyncFull}: show or hide captured events`,`\u2022 ${ae.mmkv}: show or hide captured events`],icon:ui},onPatternToggle:t,onPatternAdd:r,activePatterns:e};return kr(l,{style:et.container,children:[kr(l,{style:et.storageTypeSection,children:[Wt(u,{style:et.sectionTitle,children:"STORAGE TYPES"}),kr(l,{style:et.storageTypeButtons,children:[kr(O,{style:[et.storageTypeButton,n.has("async")&&et.storageTypeButtonActive,{borderColor:Tt.semantic.warning+"40"}],onPress:()=>a("async"),testID:"buoy-storage-backend-async",accessibilityRole:"button",accessibilityLabel:`Toggle ${ae.asyncFull} capture`,accessibilityState:{selected:n.has("async")},children:[Wt(au,{size:16,color:n.has("async")?Tt.semantic.warning:It.color.textTertiary}),Wt(u,{style:[et.storageTypeButtonText,n.has("async")&&{color:Tt.semantic.warning}],children:ae.asyncFull})]}),kr(O,{style:[et.storageTypeButton,n.has("mmkv")&&et.storageTypeButtonActive,{borderColor:Tt.semantic.info+"40"}],onPress:()=>a("mmkv"),testID:"buoy-storage-backend-mmkv",accessibilityRole:"button",accessibilityLabel:`Toggle ${ae.mmkv} capture`,accessibilityState:{selected:n.has("mmkv")},children:[Wt(iu,{size:16,color:n.has("mmkv")?Tt.semantic.info:It.color.textTertiary}),Wt(u,{style:[et.storageTypeButtonText,n.has("mmkv")&&{color:Tt.semantic.info}],children:ae.mmkv})]}),Ia()&&kr(O,{style:[et.storageTypeButton,n.has("secure")&&et.storageTypeButtonActive,{borderColor:Tt.semantic.success+"40"}],onPress:()=>a("secure"),testID:"buoy-storage-backend-secure",accessibilityRole:"button",accessibilityLabel:"Toggle Secure Storage capture",accessibilityState:{selected:n.has("secure")},children:[Wt(lu,{size:16,color:n.has("secure")?Tt.semantic.success:It.color.textTertiary}),Wt(u,{style:[et.storageTypeButtonText,n.has("secure")&&{color:Tt.semantic.success}],children:"Secure Storage"})]})]})]}),Wt(nu,{...i})]})}var et=pe.create({container:{flex:1},storageTypeSection:{padding:16,borderBottomWidth:1,borderBottomColor:It.color.border},sectionTitle:{fontSize:11,fontWeight:"700",color:It.color.textSecondary,letterSpacing:.8,marginBottom:12},storageTypeButtons:{flexDirection:"row",gap:8},storageTypeButton:{flex:1,flexDirection:"row",alignItems:"center",justifyContent:"center",gap:6,paddingVertical:10,paddingHorizontal:12,backgroundColor:It.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:It.color.border},storageTypeButtonActive:{backgroundColor:It.color.surface},storageTypeButtonText:{fontSize:11,fontWeight:"600",color:It.color.textTertiary}});E();import{memo as cu}from"react";import{RelativeTime as du,macOSColors as Gr,parseValue as uu,CompactRow as yu}from"@buoy-gg/shared-ui/web";import{jsx as yi}from"react/jsx-runtime";function gu(e){let t=uu(e);return t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t=="boolean"?"boolean":typeof t=="number"?"number":typeof t=="string"?"string":typeof t=="object"?"object":"undefined"}function pu(e){switch(e){case"setItem":case"multiSet":case"set.string":case"set.number":case"set.boolean":case"set.buffer":return Gr.semantic.success;case"removeItem":case"multiRemove":case"clear":case"delete":case"clearAll":return Gr.semantic.error;case"mergeItem":case"multiMerge":return Gr.semantic.info;case"get.string":case"get.number":case"get.boolean":case"get.buffer":return Gr.semantic.warning;default:return Gr.text.muted}}function fu(e,t){return`${Array.from(e).map(r=>r==="async"?ae.async:ae.mmkv).join("/")} \xB7 ${t} op${t!==1?"s":""}`}var Dn=cu(function({data:e,onPress:t,isSelected:r=false,showChevron:o=true,testID:n}){let a=pu(e.lastAction),i=xn(e.lastAction),y=e.totalOperations??1;return yi(yu,{statusDotColor:a,statusLabel:"Storage",statusSublabel:fu(e.storageTypes,y),primaryText:e.key,badgeText:i,badgeColor:a,showChevron:o,bottomRightText:yi(du,{timestamp:e.lastEventTimestamp}),isSelected:r,onPress:t,testID:n,accessibilityLabel:`${i} ${e.key}`})});import{useIsPro as mu}from"@buoy-gg/license/web";import{Fragment as gi,jsx as M,jsxs as dt}from"react/jsx-runtime";var Yg=_s["storage.events"].free,Mn={getItem:e=>oe.getItem(e),setItem:(e,t)=>oe.setItem(e,t)},hu={storage:Mn,parse:e=>e==="browser"||e==="events"?e:void 0,serialize:e=>e},bu={storage:Mn,parse:e=>e==="true",serialize:e=>e.toString()},pi={storage:Mn,parse:e=>new Set(JSON.parse(e)),serialize:e=>JSON.stringify(Array.from(e))},vu={...pi,parse:e=>{let t=JSON.parse(e);return t.includes("@react_buoy")||t.push("@react_buoy"),new Set(t)}};function zn({visible:e,onClose:t,onBack:r,onMinimize:o,enableSharedModalDimensions:n=false,requiredStorageKeys:a=[],inline:i=false,onTabChange:y,onRefresh:d,onEventSelect:p}){let s=mu(),g=$s("storage.events"),[f,C]=go(ur.storage.activeTab(),"browser",hu);en(()=>{y?.(f)},[f,y]);let[m,b]=ot(""),[S,w]=ot(null),[T,I]=ot(false),[R,D]=go(ur.storage.isMonitoring(),true,bu),{events:x,clearEvents:B,isCapturing:Q}=ri({enabled:R}),[ve,Se]=ot(null),[q,ue]=ot(null),[te,se]=ot(null),[Ge,Je]=ot(0),[wt,Rt]=ot(false),[ye,or]=go(ur.storage.eventFilters(),new Set(["@react_buoy","@RNAsyncStorage","redux-persist","persist:"]),vu),[re,$t]=ot("all"),[Ye,xr]=ot(new Set(["async","mmkv","secure"])),[ne,gt]=go(ur.storage.pinnedKeys(),new Set,pi),_t=Zn(null),Tr=R&&Q,[Nt,Ir]=ot("bottomSheet"),nr=De(v=>{Ir(v)},[]),Bt=De(()=>{D(v=>!v)},[]),xe=De(()=>{B(),Se(null),Je(0)},[B]),Qr=De(v=>{ue(v),se(null)},[]),Zr=De(()=>{ue(null),se(null)},[]),Xr=De(v=>{or(k=>{let z=new Set(k);return z.has(v)?z.delete(v):z.add(v),z})},[]),Ht=De(v=>{or(k=>new Set([...k,v]))},[]),Po=De(v=>{gt(k=>{let z=new Set(k);return z.has(v)?z.delete(v):z.add(v),z})},[]),Er=De(()=>{Rt(!wt)},[wt]),Fo=De(v=>{xr(k=>{let z=new Set(k);return z.has(v)?z.delete(v):z.add(v),z})},[]),Rr=Zn([]),ar=De(()=>{let v=Rr.current;return{timestamp:new Date().toISOString(),totalKeys:v.length,asyncStorage:v.filter(k=>k.storageType==="async").reduce((k,z)=>(k[z.key]=yo(z.value),k),{}),mmkv:v.filter(k=>k.storageType==="mmkv").reduce((k,z)=>{let j=z.instanceId||"default";return k[j]||(k[j]={}),k[j][z.key]=yo(z.value),k},{}),secure:v.filter(k=>k.storageType==="secure").reduce((k,z)=>(k[z.key]=yo(z.value),k),{})}},[]),Wo=De(async()=>{Ie.alert("Clear Storage","Choose what to clear:",[{text:"Cancel",style:"cancel"},{text:"Clear App Storage",onPress:async()=>{try{await uo()}catch{Ie.alert("Error","Failed to clear app storage")}}},{text:"Clear All (Including Dev Tools)",style:"destructive",onPress:async()=>{try{await sl()}catch{Ie.alert("Error","Failed to clear all storage")}}}])},[]),qt=v=>{let k=Ds(v);return k===null?"null":k===void 0?"undefined":Array.isArray(k)?"array":typeof k=="boolean"?"boolean":typeof k=="number"?"number":typeof k=="string"?"string":typeof k=="object"?"object":"undefined"},[eo,$o]=ot([]);en(()=>{e&&(async()=>{try{let v=await oe.getAllKeys();$o([...v].sort())}catch{}})()},[e]);let to=st(()=>{let v=new Set(eo);return x.forEach(k=>{k.data?.key&&v.add(k.data.key)}),Array.from(v).sort()},[x,eo]),N=st(()=>{let v=new Map;return x.forEach(k=>{if(!k.data?.key)return;let z=k.data.key;if(!Ye.has(k.storageType)||Array.from(ye).some(Qe=>z.includes(Qe)))return;let j=v.get(z);j?(j.events.push(k),j.totalOperations++,j.storageTypes.add(k.storageType),k.timestamp>j.lastEvent.timestamp&&(j.lastEvent=k,j.currentValue=k.data.value,j.valueType=qt(k.data.value))):v.set(z,{key:z,lastEvent:k,events:[k],totalOperations:1,currentValue:k.data.value,valueType:qt(k.data.value),storageTypes:new Set([k.storageType])})}),Array.from(v.values()).sort((k,z)=>z.lastEvent.timestamp.getTime()-k.lastEvent.timestamp.getTime())},[x,ye,Ye]),ke=st(()=>ve&&N.find(v=>v.key===ve)||null,[ve,N]),_o=st(()=>{let v={};return N.forEach(k=>{v[k.key]=k.totalOperations}),v},[N]),ro=st(()=>{let v={};return N.forEach(k=>{v[k.key]=k.lastEvent.timestamp.getTime()}),v},[N]),Te=st(()=>q&&N.find(v=>v.key===q)||null,[q,N]);en(()=>{if(!p)return;let v=ke||(te!==null?Te:null),k=ke?Ge:te;if(!v||k==null)return;let z=[...v.events].sort((Ar,Dr)=>Ar.timestamp.getTime()-Dr.timestamp.getTime()),j=z[k],Qe=z[k-1];j&&p(j),Qe&&p(Qe)},[p,ke,Ge,Te,te]);let tt=st(()=>x.filter(v=>{if(!v.data?.key||!Ye.has(v.storageType))return false;let k=v.data.key;return!Array.from(ye).some(z=>k.includes(z))}),[x,ye,Ye]),No=st(()=>Ea(tt),[tt]),rt=st(()=>re==="all"?tt:tt.filter(v=>v.storageType===re),[tt,re]),Ho=De(()=>rt.map(v=>({key:v.data?.key,action:v.action,value:yo(v.data?.value),storageType:v.storageType,timestamp:v.timestamp.toISOString()})),[rt]),Br=st(()=>rt.slice(0,g),[rt,g]),jt=st(()=>Math.max(0,rt.length-g),[rt.length,g]),qo=.8,oo=De(v=>v.id,[]),Vr=De(v=>{let k=N.find(j=>j.key===v.data?.key);if(!k)return;let z=[...k.events].sort((j,Qe)=>j.timestamp.getTime()-Qe.timestamp.getTime()).findIndex(j=>j.timestamp.getTime()===v.timestamp.getTime());Se(k.key),Je(z>=0?z:0)},[N]),jo=De(({item:v})=>{let k={key:v.data?.key||"",lastAction:v.action,totalOperations:1,lastEventTimestamp:v.timestamp,storageTypes:new Set([v.storageType]),valueType:qt(v.data?.value)};return M(Dn,{data:k,onPress:()=>Vr(v),testID:`buoy-storage-event-${v.id}`})},[Vr]);if(!e)return null;let Ut=n?ur.modal.root():ur.storage.modal(),pt=()=>{if(wt)return M(su,{ignoredPatterns:ye,onTogglePattern:Xr,onAddPattern:Ht,availableKeys:to,enabledStorageTypes:Ye,onToggleStorageType:Fo});if(f==="browser"){if(q&&Te){if(te!==null)return M(l,{style:he.contentWrapper,children:M(Vn,{conversation:Te,selectedEventIndex:te,onEventIndexChange:se,disableInternalFooter:true})});let k=[...Te.events].sort((j,Qe)=>j.timestamp.getTime()-Qe.timestamp.getTime()),z=[...k].reverse();return M(tn,{keyboardShouldPersistTaps:"handled",testID:"buoy-storage-history-list",style:he.flexFill,data:z,keyExtractor:j=>j.id,renderItem:({item:j})=>{let Qe=k.findIndex(Dr=>Dr.timestamp.getTime()===j.timestamp.getTime()),Ar={key:j.data?.key||"",lastAction:j.action,totalOperations:1,lastEventTimestamp:j.timestamp,storageTypes:new Set([j.storageType]),valueType:qt(j.data?.value)};return M(Dn,{data:Ar,onPress:()=>se(Qe>=0?Qe:0),testID:`buoy-storage-history-event-${j.id}`})},contentContainerStyle:he.listContent,ItemSeparatorComponent:()=>M(l,{style:he.separator}),initialNumToRender:20})}return M(ei,{requiredStorageKeys:a,ignoredPatterns:ye,onTogglePattern:Xr,onAddPattern:Ht,searchQuery:m,storageDataRef:Rr,eventCountByKey:_o,lastWriteByKey:ro,onViewHistory:Qr,enabledStorageTypes:Ye,pinnedKeys:ne,onTogglePin:Po,applySafeAreaInset:Nt==="bottomSheet",storageTypeFilter:re,onStorageTypeFilterChange:$t,detailKey:S,onOpenKey:w,onCloseDetail:()=>w(null)})}if(ke)return M(l,{style:he.contentWrapper,children:M(Vn,{conversation:ke,selectedEventIndex:Ge,onEventIndexChange:Je,disableInternalFooter:true})});let v=M(l,{style:he.eventFilterBar,children:M(gn,{active:re,onChange:$t,counts:No})});if(rt.length===0){let k=re!=="all";return dt(l,{style:he.flexFill,children:[v,M(zs,{testID:"buoy-storage-events-empty",...Tr?k?{otto:"filtering",title:`No ${re} events`,message:"Other backends have events \u2014 pick All Types to see them"}:{otto:"listening",title:"No storage events yet",message:"Storage operations will appear here"}:{otto:"paused",title:"Event listener is paused",message:"Press play to start monitoring"}})]})}return dt(l,{style:he.flexFill,children:[v,M(tn,{keyboardShouldPersistTaps:"handled",testID:"buoy-storage-events-list",style:he.flexFill,data:Br,renderItem:jo,keyExtractor:oo,onEndReachedThreshold:qo,contentContainerStyle:he.listContent,ListFooterComponent:jt>0?M(l,{style:he.lockedBannerContainer,children:M(Vd,{featureName:`${jt} event${jt>1?"s":""} locked`,description:"Upgrade to Pro to unlock full event history"})}):null,initialNumToRender:10,maxToRenderPerBatch:10,windowSize:10})]})},ir=ke&&ke.events.length>1?M(An,{conversation:ke,selectedEventIndex:Ge,onEventIndexChange:Je,applySafeAreaInset:Nt==="bottomSheet"}):Te&&te!==null&&Te.events.length>1?M(An,{conversation:Te,selectedEventIndex:te,onEventIndexChange:se,applySafeAreaInset:Nt==="bottomSheet"}):null,Pn=wt?()=>Rt(false):te!==null?()=>se(null):q?Zr:ke?()=>{Se(null),Je(0)}:r,Oe=wt?dt(Me,{children:[M(Me.Navigation,{onBack:()=>Rt(false)}),M(Me.Content,{title:"Filters"})]}):q?dt(Me,{children:[M(Me.Navigation,{onBack:te!==null?()=>se(null):Zr}),M(Me.Content,{title:`${q} History`,centered:true})]}):ke?dt(Me,{children:[M(Me.Navigation,{onBack:()=>{Se(null),Je(0)}}),M(Me.Content,{title:ke.key})]}):S?dt(Me,{children:[M(Me.Navigation,{onBack:()=>w(null)}),M(Me.Content,{title:S.key,centered:true,testID:"buoy-storage-detail-title"})]}):dt(Me,{children:[r&&M(Me.Navigation,{onBack:r}),M(Me.Content,{title:"",children:T?M(Ps,{value:m,onChange:b,onClear:()=>{b(""),I(false)},placeholder:"Search storage keys...",testID:"buoy-storage-search",autoFocus:true,onSubmitEditing:()=>I(false),returnKeyType:"search",containerStyle:he.headerSearchContainer}):M(As,{tabs:[{key:"browser",label:"Storage"},{key:"events",label:`Events${rt.length>0?` (${rt.length})`:""}`}],activeTab:f,testIDPrefix:"buoy-storage-tab",onTabChange:v=>{C(v),ue(null),se(null),Se(null),Je(0),w(null)}})}),dt(Me.Actions,{children:[d&&!T?M(O,{onPress:d,style:he.iconButton,testID:"buoy-storage-refresh",accessibilityLabel:"Refresh storage",accessibilityRole:"button",children:M(Os,{size:14,color:$e.color.textSecondary})}):null,M(O,{onPress:Er,testID:"buoy-storage-filters",accessibilityLabel:"Storage filters",accessibilityRole:"button",style:[he.iconButton,(ye.size>0||Ye.size<3)&&he.activeFilterButton],children:M(Ks,{size:14,color:ye.size>0||Ye.size<3?$e.color.accent:$e.color.textSecondary})}),f==="browser"&&!T&&dt(gi,{children:[M(O,{onPress:()=>I(true),testID:"buoy-storage-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",style:he.iconButton,children:M(Ls,{size:14,color:$e.color.textSecondary})}),M(ia,{value:ar,disabled:Rr.current.length===0,buttonStyle:he.iconButton,testID:"buoy-storage-copy"})]}),f==="events"&&dt(gi,{children:[M(ia,{value:Ho,disabled:rt.length===0,buttonStyle:he.iconButton,testID:"buoy-storage-events-copy"}),M(Fs,{isEnabled:Tr,onToggle:Bt,accessibilityLabel:"Toggle storage event monitoring",testID:"buoy-storage-power"}),M(Ws,{onPress:xe,buttonStyle:he.iconButton,testID:"buoy-storage-clear-events"})]})]})]});return i?M(la,{children:dt(l,{style:he.inlineRoot,children:[M(l,{style:he.inlineHeader,...Ns,children:Oe}),pt(),ir]})}):M(la,{children:M(Vs,{visible:e,onClose:t,onBack:Pn,onMinimize:o,persistenceKey:Ut,header:{showToggleButton:true,customContent:Oe},onModeChange:nr,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:ir,footerHeight:ir?68:0,disableScrollWrapper:true,children:pt()})})}function Su(e={}){return M(zn,{...e,inline:true,visible:true,onClose:()=>{}})}var he=pe.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:Ms.border.default,backgroundColor:"transparent"},headerSearchContainer:{flex:1},flexFill:{flex:1},iconButton:{width:32,height:32,borderRadius:8,backgroundColor:$e.color.buttonSurface,borderWidth:1,borderColor:$e.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:$e.color.accentSoft,borderColor:$e.color.accentBorderStrong},separator:{height:8},listContent:{paddingVertical:6},lockedBannerContainer:{marginTop:8,marginHorizontal:16},eventFilterBar:{paddingHorizontal:12,paddingTop:8,paddingBottom:4},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:$e.color.text,fontSize:16,fontWeight:"600",marginTop:16,marginBottom:8,fontFamily:po,letterSpacing:.5,textTransform:"uppercase"},emptySubtitle:{color:$e.color.textSecondary,fontSize:14,textAlign:"center",fontFamily:po},eventNavigation:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:8},navButton:{padding:4,borderRadius:4},navButtonDisabled:{opacity:.3},eventCounter:{color:$e.color.text,fontSize:12,fontWeight:"600",fontFamily:po,paddingHorizontal:8},headerTopRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12},keyNameContainer:{flex:1,flexDirection:"row",alignItems:"center",gap:6,backgroundColor:$e.color.surfaceElevated,paddingHorizontal:10,paddingVertical:4,borderRadius:6,borderWidth:1,borderColor:$e.color.border,height:28},keyNameText:{flex:1,fontSize:13,fontWeight:"600",color:$e.color.accent,fontFamily:po,letterSpacing:.5},contentWrapper:{flex:1}});E();mt();Jt();import{approxJsonSize as fi,isDevToolsStorageKey as ut,isOverWireBudget as mi,isJsonSerializable as wu}from"@buoy-gg/shared-ui/web";var Mo=Object.freeze({__buoyValueOnDevice:true,note:"Value stays on the device \u2014 fetched on demand via getEventDetail / mmkv.get / secure.get."}),ku=16*1024,Kn=1.25*1024*1024,hi=8*1024*1024;function On(e){return e===void 0?e:mi(e,ku)?Mo:e}function zo(e,t){let r=e.data;if(!r)return e;let o=t(r.value),n=t(r.prevValue),a=xo(e),i=t(a.pairs),y=t(a.prevPairs);return o===r.value&&n===r.prevValue&&i===a.pairs&&y===a.prevPairs?e:{...e,data:{...r,value:o,prevValue:n,...e.storageType==="async"?{pairs:i,prevPairs:y}:{}}}}function bi(e){return e===void 0||!mi(e,hi)?e:wu(e)?{__buoyTruncated:true,note:`Exceeds the ${hi/(1024*1024)}MB detail limit \u2014 inspect it on-device.`}:Mo}var vi=new WeakMap,Si=new WeakMap;function Cu(e){let t=vi.get(e);if(t)return t;let r;try{let o=zo(e,On);r={event:o,bytes:fi(o,Kn).bytes}}catch{r={event:zo(e,()=>Mo),bytes:1024}}return vi.set(e,r),r}function xu(e){let t=Si.get(e);if(t)return t;let r=zo(e,n=>n===void 0?void 0:Mo),o={event:r,bytes:fi(r,Kn).bytes};return Si.set(e,o),o}function Tu(e){let t=new Array(e.length),r=0;for(let o=0;o<e.length;o++){let n=Cu(e[o]);if(r+n.bytes<=Kn)t[o]=n.event,r+=n.bytes;else{let a=xu(e[o]);t[o]=a.event,r+=a.bytes}}return t}function wi(e){let t=Le.get(e);if(!t)throw new Error(`No MMKV instance registered as "${e}"`);if(t.instance?.isReadOnly)throw new Error(`MMKV instance "${e}" is registered read-only`);return t.instance}var ki=[];function Iu(e){ki=e}var Eu={version:3,getSnapshot:()=>Tu(Lt.getEvents().filter(e=>{let t=e.data?.key;return!(typeof t=="string"&&ut(t))})),subscribe:e=>Lt.subscribeToEvents(e),actions:{clearEvents:()=>{Lt.clearEvents()},getRequiredKeys:()=>ki,getEventDetail:e=>{let{id:t}=e??{};if(!t)return{found:false,reason:"missing id"};let r=Lt.getEvents().find(n=>n.id===t);if(!r)return{found:false,reason:"unknown id"};let o=zo(r,bi);return{found:true,id:t,event:o}},clearAppStorage:()=>uo(),"timeTravel.undo":async e=>{let t=e?.id;if(!t)throw new Error("timeTravel.undo requires an event `id`");let r=Lt.getEvents().find(n=>n.id===t);if(!r)throw new Error(`No storage event with id "${t}"`);if(r.storageType==="mmkv")throw new Error("Time travel supports AsyncStorage events only");let o=r;if(!Bn(o))throw new Error(`Event "${t}" (${o.action}) has no previous value captured, so it cannot be undone`);return await En(o),{undone:true,action:o.action,key:o.data?.key}},"timeTravel.jump":async e=>{let{id:t,scope:r="key"}=e??{};if(!t)throw new Error("timeTravel.jump requires an event `id`");let o=Lt.getEvents().filter(y=>y.storageType!=="mmkv").slice().reverse(),n=o.find(y=>y.id===t);if(!n)throw new Error(`No AsyncStorage event with id "${t}"`);let a=r==="all"?o:o.filter(y=>y.data?.key===n.data?.key),i=a.findIndex(y=>y.id===t);if(i===-1)throw new Error(`Event "${t}" is not in the timeline`);return await Rn(a,i),{jumped:true,scope:r,replayed:i+1,of:a.length,key:n.data?.key}},"async.getAllKeys":async()=>(await oe.getAllKeys()).filter(e=>!ut(e)),"async.multiGet":async e=>(await so(e.keys)).filter(([t])=>!ut(t)),"async.getItem":e=>{let{key:t}=e;return ut(t)?Promise.resolve(null):oe.getItem(t)},"async.setItem":e=>{let{key:t,value:r}=e;return oe.setItem(t,r)},"async.removeItem":e=>oe.removeItem(e.key),"async.multiRemove":e=>sr(e.keys),"async.multiSet":e=>Or(e.pairs),"async.clear":()=>oe.clear(),"mmkv.snapshot":()=>Le.getAll().filter(({id:e})=>!ut(e)).map(({id:e,instance:t,encrypted:r,readOnly:o})=>{let n=[];try{n=t.getAllKeys().filter(a=>!ut(a)).map(a=>{let{value:i,type:y}=kt(t,a);return{key:a,value:On(i),valueType:y}})}catch{}return{id:e,encrypted:r,readOnly:o,entries:n}}),"mmkv.get":e=>{let{instanceId:t,key:r}=e??{};if(!t||!r||ut(r)||ut(t))return{found:false,reason:"missing instanceId/key"};let o=Le.get(t);if(!o)return{found:false,reason:"unknown instance"};let{value:n,type:a}=kt(o.instance,r);return{found:true,instanceId:t,key:r,value:bi(n),valueType:a}},"mmkv.set":e=>{let{instanceId:t,key:r,value:o}=e;wi(t).set(r,o)},"mmkv.remove":e=>{let{instanceId:t,key:r}=e,o=wi(t);o.remove?o.remove(r):o.delete?.(r)},"secure.keys":async()=>{let e=ee.getModule();return Promise.all(ee.getAll().filter(({key:t})=>!ut(t)).map(async({key:t,options:r,description:o})=>{let n=null;if(e&&!r.requireAuthentication)try{n=await e.getItemAsync(t,r)!=null}catch{n=null}return{key:t,description:o,keychainService:r.keychainService,requireAuthentication:r.requireAuthentication??false,hasValue:n}}))},"secure.snapshot":async()=>{let e=ee.getModule(),t=ee.getAll().filter(({key:o})=>!ut(o)),r=[];for(let{key:o,options:n,description:a}of t){let i=null;if(e&&!n.requireAuthentication)try{i=await e.getItemAsync(o,n)}catch{}r.push({key:o,description:a,keychainService:n.keychainService,requireAuthentication:n.requireAuthentication??false,value:i==null?i:On(i)})}return r},"secure.get":e=>{let{key:t}=e;if(ut(t))return null;let r=ee.getAll().find(n=>n.key===t),o=ee.getModule();return!r||!o||r.options.requireAuthentication?Promise.resolve(null):o.getItemAsync(t,r.options)},"secure.set":e=>{let{key:t,value:r}=e;return ee.setValue(t,r)},"secure.delete":e=>ee.deleteValue(e.key)}};import{jsx as Ru}from"react/jsx-runtime";var Ci=xl({id:"storage",name:"STORAGE",description:"AsyncStorage browser",slot:"both",icon:({size:e})=>Ru(kl,{size:e}),component:zn,props:{requiredStorageKeys:[],enableSharedModalDimensions:false}}),Bu=Cl(Ci,e=>(Iu(e.requiredStorageKeys||[]),{requiredStorageKeys:e.requiredStorageKeys||[],enableSharedModalDimensions:e.enableSharedModalDimensions??false}));E();import{HardDrive as Vu,CyberpunkSectionButton as Au}from"@buoy-gg/shared-ui/web";import{isDevToolsStorageKey as Du}from"@buoy-gg/shared-ui/web";import{jsx as Mu}from"react/jsx-runtime";function zu({onPress:e}){let{storageKeys:t}=mn(),r=t.filter(n=>!Du(n.key)).length,o=r;return Mu(Au,{id:"storage",title:"STORAGE",subtitle:o===0?"Empty":`${r} Async`,icon:Vu,iconColor:"#00FF88",iconBackgroundColor:"rgba(0, 255, 136, 0.1)",onPress:e,index:2})}E();import{AlertCircle as xi,CheckCircle2 as Ku,Eye as Ti,XCircle as Ii,HardDrive as Ei,Database as Ri,Shield as Ou,gameUIColors as Ko,macOSColors as ie,night as be,monoFont as Oo}from"@buoy-gg/shared-ui/web";import{DataViewer as Lu}from"@buoy-gg/shared-ui/web/dataViewer";import{jsx as Y,jsxs as Ae}from"react/jsx-runtime";var Bi=[ie.semantic.info,ie.semantic.success,ie.semantic.warning,ie.semantic.debug,"#FF6B9D","#00D9FF"];function Lo(e){let t=e.split("").reduce((r,o)=>r+o.charCodeAt(0),0);return Bi[t%Bi.length]}var Pu=e=>{switch(e){case"required_present":return{icon:Ku,color:ie.semantic.success,bgColor:ie.semantic.successBackground,borderColor:ie.semantic.success+"40",label:"REQUIRED",labelColor:ie.semantic.success};case"required_missing":return{icon:xi,color:ie.semantic.error,bgColor:ie.semantic.errorBackground,borderColor:ie.semantic.error+"50",label:"MISSING",labelColor:ie.semantic.error};case"required_wrong_value":return{icon:Ii,color:ie.semantic.warning,bgColor:ie.semantic.warningBackground,borderColor:ie.semantic.warning+"50",label:"WRONG S",labelColor:ie.semantic.warning};case"required_wrong_type":return{icon:Ii,color:ie.semantic.info,bgColor:ie.semantic.infoBackground,borderColor:ie.semantic.info+"50",label:"WRONG TYPE",labelColor:ie.semantic.info};case"optional_present":return{icon:Ti,color:ie.semantic.debug,bgColor:ie.semantic.infoBackground,borderColor:ie.semantic.debug+"40",label:"OPTIONAL",labelColor:ie.semantic.debug}}},Fu=e=>{switch(e){case"mmkv":return Ei;case"async":return Ri;case"secure":return Ou;default:return Ri}};function Wu({storageKey:e,isExpanded:t,onToggle:r}){let o=Pu(e.status),n=o.icon,a=Fu(e.storageType),i=e.value!==void 0&&e.value!==null,y=e.expectedValue!==void 0,d=e.expectedType!==void 0,p=fa(e.storageType),s=ln(e.storageType,e.instanceId);return Ae(l,{style:[K.storageKeyCard,{borderColor:o.borderColor}],children:[Ae(O,{accessibilityLabel:"Storage key card",accessibilityHint:"View storage key card","sentry-label":`ignore storage key card ${e.key}`,accessibilityRole:"button",style:K.cardHeader,onPress:r,children:[Ae(l,{style:K.cardHeaderLeft,children:[Y(l,{style:[K.iconContainer,{backgroundColor:o.bgColor}],children:Y(n,{size:14,color:o.color})}),Ae(l,{style:K.cardHeaderInfo,children:[Y(u,{style:K.storageKeyText,children:e.key}),e.description?Y(u,{style:K.descriptionText,children:e.description}):null,Ae(l,{style:K.cardHeaderMeta,children:[Y(l,{style:[K.statusBadge,{backgroundColor:o.bgColor}],children:Y(u,{style:[K.statusText,{color:o.labelColor}],children:o.label})}),Ae(l,{style:[K.storageBadge,{backgroundColor:`${p}15`}],children:[Y(a,{size:10,color:p}),Y(u,{style:[K.storageText,{color:p}],children:s})]}),e.storageType==="mmkv"&&e.instanceId&&Ae(l,{style:[K.instanceBadge,{backgroundColor:Lo(e.instanceId)+"20",borderColor:Lo(e.instanceId)+"40"}],children:[Y(Ei,{size:9,color:Lo(e.instanceId)}),Y(u,{style:[K.instanceText,{color:Lo(e.instanceId)}],children:e.instanceId})]}),i&&Y(l,{style:K.valueBadge,children:Y(u,{style:K.valueText,children:e.valueType?e.valueType.toUpperCase():Dt(e.value)})})]})]})]}),Y(l,{style:K.cardHeaderRight,children:Y(l,{style:K.actionButton,children:Y(Ti,{size:12,color:be.color.textSecondary})})})]}),t&&i&&Ae(l,{style:K.cardBody,children:[Y(l,{style:K.dataViewerContainer,children:(()=>{let g=typeof e.value=="string"?(()=>{try{return JSON.parse(e.value)}catch{return e.value}})():e.value;return typeof g=="string"||typeof g=="number"||typeof g=="boolean"?Ae(l,{style:K.simpleValueContainer,children:[Y(u,{style:K.simpleValueLabel,children:"Current Value:"}),Y(l,{style:K.simpleValueBox,children:Y(u,{style:K.simpleValueContent,selectable:true,children:String(g)})}),Ae(u,{style:K.valueTypeText,children:["Type: ",Dt(e.value)]})]}):Y(Lu,{title:"Current Value",data:g,showTypeFilter:false,rawMode:true})})()}),y&&Ae(l,{style:K.valueContainer,children:[Y(u,{style:K.valueLabel,children:"Expected Value:"}),Y(l,{style:K.expectedValueBox,children:Y(u,{style:K.expectedValueContent,selectable:true,children:e.expectedValue})})]}),d&&e.expectedType&&Ae(l,{style:K.valueContainer,children:[Y(u,{style:K.valueLabel,children:"Expected Type:"}),Y(l,{style:K.expectedValueBox,children:Y(u,{style:K.expectedValueContent,selectable:true,children:e.expectedType.toUpperCase()})}),Ae(u,{style:K.typeHelperText,children:["Current type: ",Dt(e.value)]})]}),e.lastUpdated?Y(l,{style:K.metaInfo,children:Ae(u,{style:K.metaLabel,children:["Last updated: ",e.lastUpdated.toLocaleString()]})}):null]}),t&&!i&&Ae(l,{style:K.cardBody,children:[Ae(l,{style:K.emptyValueContainer,children:[Y(xi,{size:16,color:ie.semantic.warning}),Y(u,{style:K.emptyValueText,children:"Storage key not found or empty"})]}),y&&Ae(l,{style:K.valueContainer,children:[Y(u,{style:K.valueLabel,children:"Expected Value:"}),Y(l,{style:K.expectedValueBox,children:Y(u,{style:K.expectedValueContent,selectable:true,children:e.expectedValue})})]})]})]})}var K=pe.create({storageKeyCard:{backgroundColor:be.color.surface,borderRadius:8,borderWidth:1,overflow:"hidden"},cardHeader:{padding:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between"},cardHeaderLeft:{flexDirection:"row",alignItems:"center",flex:1,minWidth:0},iconContainer:{padding:6,borderRadius:6,marginRight:10},cardHeaderInfo:{flex:1,minWidth:0,gap:4},storageKeyText:{color:be.color.text,fontWeight:"500",fontSize:12,flexWrap:"wrap",flex:1},descriptionText:{color:be.color.textSecondary,fontSize:10,marginTop:2,flexWrap:"wrap"},cardHeaderMeta:{flexDirection:"row",alignItems:"center",gap:6,flexWrap:"wrap"},statusBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4},statusText:{fontSize:9,fontWeight:"600",letterSpacing:.5},storageBadge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4,flexDirection:"row",alignItems:"center",gap:4},storageText:{fontSize:9,fontWeight:"600"},instanceBadge:{paddingHorizontal:6,paddingVertical:3,borderRadius:4,borderWidth:1,flexDirection:"row",alignItems:"center",gap:4},instanceText:{fontSize:9,fontWeight:"700",fontFamily:Oo,letterSpacing:.3},valueBadge:{paddingHorizontal:4,paddingVertical:2,backgroundColor:be.color.surfaceElevated,borderRadius:3},valueText:{fontSize:8,color:be.color.textSecondary,fontWeight:"500"},cardHeaderRight:{marginLeft:8},actionButton:{padding:4,borderRadius:4,backgroundColor:be.color.surfaceElevated},cardBody:{borderTopWidth:1,borderTopColor:be.color.separator,padding:12,gap:12},dataViewerContainer:{marginTop:8},simpleValueContainer:{gap:8},simpleValueLabel:{color:be.color.textSecondary,fontSize:10,fontWeight:"500",textTransform:"uppercase",letterSpacing:.5},simpleValueBox:{backgroundColor:be.color.bg,borderRadius:4,padding:10,borderWidth:1,borderColor:be.color.border},simpleValueContent:{color:Ko.success,fontSize:12,fontFamily:Oo,lineHeight:16},valueTypeText:{color:be.color.textTertiary,fontSize:9,fontStyle:"italic"},valueContainer:{gap:6},valueLabel:{color:be.color.textSecondary,fontSize:10,fontWeight:"500",textTransform:"uppercase",letterSpacing:.5},valueBox:{backgroundColor:be.color.bg,borderRadius:4,padding:8,borderWidth:1,borderColor:be.color.border},valueContent:{color:be.color.text,fontSize:10,fontFamily:Oo,lineHeight:14},expectedValueBox:{backgroundColor:be.color.bg,borderRadius:4,padding:8,borderWidth:1,borderColor:be.color.border},expectedValueContent:{color:be.color.text,fontSize:10,fontFamily:Oo,lineHeight:14},emptyValueContainer:{flexDirection:"row",alignItems:"center",gap:6,padding:8,backgroundColor:Ko.warning+"0D",borderRadius:4,borderWidth:1,borderColor:Ko.warning+"1A"},emptyValueText:{color:Ko.warning,fontSize:10,fontStyle:"italic"},typeHelperText:{color:be.color.textSecondary,fontSize:9,marginTop:4,textAlign:"center"},metaInfo:{marginTop:8},metaLabel:{color:be.color.textTertiary,fontSize:9,fontStyle:"italic"}});E();import{AlertCircle as $u,CheckCircle2 as _u,XCircle as Vi,Eye as Nu,Database as Ai,Shield as Hu}from"@buoy-gg/shared-ui/web";import{night as St}from"@buoy-gg/shared-ui/web";import{jsx as Ce,jsxs as Ue}from"react/jsx-runtime";var qu=[{key:"valid",label:"Valid Keys",description:"Correctly stored and accessible",icon:_u,color:"#10B981",textColor:"#10B981",bgColor:"rgba(16, 185, 129, 0.1)"},{key:"missing",label:"Missing Keys",description:"Required but not found",icon:$u,color:"#EF4444",textColor:"#EF4444",bgColor:"rgba(239, 68, 68, 0.1)"},{key:"wrongValue",label:"Wrong Values",description:"Stored but incorrect value",icon:Vi,color:"#F97316",textColor:"#F97316",bgColor:"rgba(249, 115, 22, 0.1)"},{key:"wrongType",label:"Wrong Types",description:"Value has incorrect data type",icon:Vi,color:"#0891B2",textColor:"#0891B2",bgColor:"rgba(8, 145, 178, 0.1)"},{key:"optional",label:"Optional Keys",description:"Available but not required",icon:Nu,color:"#8B5CF6",textColor:"#8B5CF6",bgColor:"rgba(139, 92, 246, 0.1)"}],ju=[{key:"mmkv",label:ae.mmkv,description:ae.hasSecure?"Synchronous key-value storage":"Storage for this browser tab",icon:Ai},{key:"async",label:ae.asyncFull,description:ae.hasSecure?"React Native async storage":"Persistent storage for this origin",icon:Ai},{key:"secure",label:"SecureStorage",description:"Encrypted secure storage",icon:Hu}];function Uu({stats:e}){let{totalCount:t,missingCount:r,wrongValueCount:o,wrongTypeCount:n,presentRequiredCount:a,optionalCount:i,mmkvCount:y,asyncCount:d,secureCount:p}=e;return t===0?Ue(l,{style:X.statsContainer,children:[Ce(u,{style:X.sectionTitle,children:"STORAGE BREAKDOWN"}),Ce(l,{style:X.emptyState,children:Ce(u,{style:X.emptyStateText,children:"No storage keys detected"})})]}):Ue(l,{style:X.statsContainer,children:[Ue(l,{style:X.breakdownSection,children:[Ce(u,{style:X.sectionTitle,children:"KEY STATUS BREAKDOWN"}),Ce(l,{style:X.breakdownList,children:qu.map(s=>{let g=0,f=false;switch(s.key){case"valid":g=a,f=g>0;break;case"missing":g=r,f=g>0;break;case"wrongValue":g=o,f=g>0;break;case"wrongType":g=n,f=g>0;break;case"optional":g=i,f=g>0;break}if(!f)return null;let C=t>0?(g/t*100).toFixed(1):"0",m=s.icon;return Ce(l,{style:X.breakdownItem,children:Ue(l,{style:X.breakdownItemRow,children:[Ue(l,{style:X.breakdownItemLeft,children:[Ce(l,{style:[X.breakdownIcon,{backgroundColor:s.bgColor}],children:Ce(m,{size:14,color:s.color})}),Ue(l,{style:X.breakdownItemInfo,children:[Ce(u,{style:X.breakdownItemLabel,children:s.label}),Ce(u,{style:X.breakdownItemDesc,children:s.description})]})]}),Ue(l,{style:X.breakdownItemRight,children:[Ce(u,{style:[X.breakdownCount,{color:s.textColor}],children:g}),Ue(u,{style:X.breakdownPercentage,children:[C,"%"]})]})]})},s.key)})})]}),(y>0||d>0||p>0)&&Ue(l,{style:X.breakdownSection,children:[Ce(u,{style:X.sectionTitle,children:"STORAGE TYPE BREAKDOWN"}),Ce(l,{style:X.breakdownList,children:ju.map(s=>{let g=0,f=false;switch(s.key){case"mmkv":g=y,f=g>0;break;case"async":g=d,f=g>0;break;case"secure":g=p,f=g>0;break}if(!f)return null;let C=t>0?(g/t*100).toFixed(1):"0",m=s.icon,b=fa(s.key);return Ce(l,{style:X.breakdownItem,children:Ue(l,{style:X.breakdownItemRow,children:[Ue(l,{style:X.breakdownItemLeft,children:[Ce(l,{style:[X.breakdownIcon,{backgroundColor:`${b}15`}],children:Ce(m,{size:14,color:b})}),Ue(l,{style:X.breakdownItemInfo,children:[Ce(u,{style:X.breakdownItemLabel,children:s.label}),Ce(u,{style:X.breakdownItemDesc,children:s.description})]})]}),Ue(l,{style:X.breakdownItemRight,children:[Ce(u,{style:[X.breakdownCount,{color:b}],children:g}),Ue(u,{style:X.breakdownPercentage,children:[C,"%"]})]})]})},s.key)})})]})]})}var X=pe.create({statsContainer:{marginBottom:24,backgroundColor:St.color.surface,borderRadius:8,padding:16,borderWidth:1,borderColor:St.color.border},sectionTitle:{color:St.color.textSecondary,fontSize:12,fontWeight:"500",marginBottom:16,textTransform:"uppercase",letterSpacing:.5},breakdownSection:{gap:12,marginBottom:20},breakdownList:{gap:12},breakdownItem:{backgroundColor:St.color.surfaceElevated,padding:12,borderRadius:8,borderWidth:1,borderColor:St.color.border},breakdownItemRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},breakdownItemLeft:{flexDirection:"row",alignItems:"center",gap:12,flex:1,minWidth:0},breakdownIcon:{padding:8,borderRadius:8},breakdownItemInfo:{flex:1,minWidth:0},breakdownItemLabel:{color:St.color.text,fontSize:14,fontWeight:"500"},breakdownItemDesc:{color:St.color.textSecondary,fontSize:12},breakdownItemRight:{alignItems:"flex-end"},breakdownCount:{fontSize:16,fontWeight:"600"},breakdownPercentage:{color:St.color.textTertiary,fontSize:10},emptyState:{padding:16,backgroundColor:St.color.surfaceElevated,borderRadius:6,alignItems:"center"},emptyStateText:{color:St.color.textTertiary,fontSize:11,textAlign:"center"}});E();import{Database as Gu,CyberpunkSectionButton as Ju}from"@buoy-gg/shared-ui/web";import{jsx as Yu}from"react/jsx-runtime";function Qu({onPress:e,eventCount:t=0}){let r=t>0?`${t} events`:"Monitoring";return Yu(Ju,{id:"storage-events",title:"EVENTS",subtitle:r,icon:Gu,iconColor:"#00E5FF",iconBackgroundColor:"rgba(0, 229, 255, 0.1)",onPress:e,index:3})}E();import{macOSColors as Jr}from"@buoy-gg/shared-ui/web";var Zu=["SET","GET","MERGE","DELETE","CLEAR"],Xu={SET:Jr.semantic.info,GET:Jr.text.muted,MERGE:Jr.semantic.debug,DELETE:Jr.semantic.error,CLEAR:Jr.semantic.warning};function ey(e){return Xu[e]}function ty(e){let t=e.action;return t==="clear"||t==="clearAll"?"CLEAR":t.startsWith("get.")?"GET":t==="removeItem"||t==="multiRemove"||t==="delete"?"DELETE":t==="mergeItem"||t==="multiMerge"?"MERGE":"SET"}function ry(e){return!!e.data?.initialScan}E();import{useState as oy}from"react";import{macOSColors as rr,night as de,monoFont as Di}from"@buoy-gg/shared-ui/web";import{jsx as le,jsxs as it}from"react/jsx-runtime";function ny({selectedInstanceId:e,onSelectInstance:t,showRefreshButton:r=true}){let[o,n]=oy(false),{instances:a,instanceCount:i,refresh:y}=Sn(false),d=a.find(s=>s.id===e),p=s=>{t(s),n(false)};return pn()?i===0?le(l,{style:_.container,children:it(l,{style:_.emptyState,children:[le(u,{style:_.emptyStateTitle,children:"No MMKV Instances Registered"}),le(u,{style:_.emptyStateDescription,children:"Register MMKV instances using registerMMKVInstance() to monitor them in dev tools."}),r&&le(O,{style:_.refreshButton,onPress:y,activeOpacity:.7,children:le(u,{style:_.refreshButtonText,children:"\u21BB Refresh"})})]})}):it(l,{style:_.container,children:[it(O,{style:_.selectorButton,onPress:()=>n(true),activeOpacity:.7,children:[le(l,{style:_.selectorContent,children:d?le(Mi,{instance:d,isSelected:true}):le(u,{style:_.placeholderText,children:"Select MMKV Instance"})}),le(u,{style:_.dropdownArrow,children:"\u25BC"})]}),le(aa,{visible:o,transparent:true,animationType:"fade",onRequestClose:()=>n(false),children:le(O,{style:_.modalOverlay,activeOpacity:1,onPress:()=>n(false),children:it(l,{style:_.dropdownContainer,children:[it(l,{style:_.dropdownHeader,children:[it(u,{style:_.dropdownTitle,children:["Select MMKV Instance (",i,")"]}),r&&le(O,{style:_.headerRefreshButton,onPress:y,activeOpacity:.7,children:le(u,{style:_.headerRefreshText,children:"\u21BB"})})]}),le(Wr,{keyboardShouldPersistTaps:"handled",style:_.dropdownList,children:a.map(s=>le(O,{style:[_.dropdownItem,s.id===e&&_.dropdownItemSelected],onPress:()=>p(s.id),activeOpacity:.7,children:le(Mi,{instance:s,isSelected:s.id===e})},s.id))})]})})})]}):le(l,{style:_.container,children:it(l,{style:_.unavailableState,children:[it(u,{style:_.unavailableTitle,children:[ae.mmkv," Not Available"]}),le(u,{style:_.unavailableDescription,children:Ra()})]})})}function Mi({instance:e,isSelected:t}){return it(l,{style:_.instanceRow,children:[it(l,{style:_.instanceLeft,children:[le(u,{style:[_.instanceId,t&&_.instanceIdSelected],numberOfLines:1,children:e.id}),it(l,{style:_.instanceBadges,children:[e.encrypted&&le(l,{style:[_.badge,_.badgeEncrypted],children:le(u,{style:_.badgeText,children:"\u{1F512} Encrypted"})}),e.readOnly&&le(l,{style:[_.badge,_.badgeReadOnly],children:le(u,{style:_.badgeText,children:"\u{1F441}\uFE0F Read-only"})})]})]}),it(l,{style:_.instanceRight,children:[le(u,{style:_.keyCount,children:e.keyCount}),le(u,{style:_.keyCountLabel,children:"keys"})]})]})}var _=pe.create({container:{marginBottom:12},unavailableState:{backgroundColor:rr.semantic.warning+"15",borderRadius:12,padding:20,borderWidth:1,borderColor:rr.semantic.warning+"40",alignItems:"center",gap:12},unavailableTitle:{fontSize:14,fontWeight:"600",color:rr.semantic.warning},unavailableDescription:{fontSize:12,color:de.color.textSecondary,textAlign:"center",lineHeight:18},emptyState:{backgroundColor:de.color.surface,borderRadius:12,padding:20,borderWidth:1,borderColor:de.color.border,alignItems:"center",gap:12},emptyStateTitle:{fontSize:14,fontWeight:"600",color:de.color.text},emptyStateDescription:{fontSize:12,color:de.color.textTertiary,textAlign:"center",lineHeight:18},refreshButton:{marginTop:8,paddingHorizontal:16,paddingVertical:8,backgroundColor:de.color.accentSoft,borderRadius:8,borderWidth:1,borderColor:de.color.accentBorderStrong},refreshButtonText:{fontSize:12,fontWeight:"600",color:de.color.accent},selectorButton:{backgroundColor:de.color.surface,borderRadius:12,borderWidth:1,borderColor:de.color.border,padding:12,flexDirection:"row",alignItems:"center",justifyContent:"space-between",shadowColor:"#000000",shadowOpacity:.03,shadowRadius:8,shadowOffset:{width:0,height:2}},selectorContent:{flex:1},placeholderText:{fontSize:13,color:de.color.placeholder,fontStyle:"italic"},dropdownArrow:{fontSize:10,color:de.color.textTertiary,marginLeft:8},modalOverlay:{flex:1,backgroundColor:"rgba(0, 0, 0, 0.5)",justifyContent:"center",alignItems:"center",padding:20},dropdownContainer:{backgroundColor:de.color.surface,borderRadius:16,borderWidth:1,borderColor:de.color.border,width:"100%",maxWidth:500,maxHeight:"70%",shadowColor:"#000000",shadowOpacity:.2,shadowRadius:20,shadowOffset:{width:0,height:10},overflow:"hidden"},dropdownHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:16,borderBottomWidth:1,borderBottomColor:de.color.separator},dropdownTitle:{fontSize:14,fontWeight:"600",color:de.color.text},headerRefreshButton:{padding:4},headerRefreshText:{fontSize:18,color:de.color.accent},dropdownList:{maxHeight:400},dropdownItem:{padding:12,borderBottomWidth:1,borderBottomColor:de.color.separator},dropdownItemSelected:{backgroundColor:de.color.accentSoft},instanceRow:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",gap:12},instanceLeft:{flex:1,gap:6},instanceId:{fontSize:13,fontWeight:"500",color:de.color.text,fontFamily:Di},instanceIdSelected:{fontWeight:"600",color:de.color.accent},instanceBadges:{flexDirection:"row",flexWrap:"wrap",gap:6},badge:{paddingHorizontal:6,paddingVertical:2,borderRadius:4,borderWidth:1},badgeEncrypted:{backgroundColor:rr.semantic.success+"15",borderColor:rr.semantic.success+"40"},badgeReadOnly:{backgroundColor:rr.semantic.warning+"15",borderColor:rr.semantic.warning+"40"},badgeText:{fontSize:9,fontWeight:"500",color:de.color.textSecondary},instanceRight:{alignItems:"flex-end"},keyCount:{fontSize:16,fontWeight:"600",color:de.color.text,fontFamily:Di},keyCountLabel:{fontSize:9,color:de.color.textTertiary,textTransform:"uppercase",letterSpacing:.5}});E();import{macOSColors as yt,night as Et,monoFont as ay}from"@buoy-gg/shared-ui/web";import{jsx as Ke,jsxs as Cr}from"react/jsx-runtime";function iy({instanceId:e}){let t=Wa(e);return t?Ke(l,{style:ge.container,children:Cr(l,{style:ge.panel,children:[Ke(l,{style:ge.header,children:Ke(u,{style:ge.headerTitle,children:"Instance Details"})}),Cr(l,{style:ge.infoGrid,children:[Ke(Yr,{label:"Instance ID",value:t.id,valueStyle:ge.monoValue}),Ke(Yr,{label:"Keys",value:`${t.keyCount} ${t.keyCount===1?"key":"keys"}`,highlight:true}),Ke(Yr,{label:"Encryption",value:t.encrypted?"\u{1F512} Encrypted":"\u{1F513} Not encrypted",valueColor:t.encrypted?yt.semantic.success:Et.color.textTertiary}),Ke(Yr,{label:"Access",value:t.readOnly?"\u{1F441}\uFE0F Read-only":"\u270F\uFE0F Read-write",valueColor:t.readOnly?yt.semantic.warning:Et.color.textTertiary}),t.size!==void 0&&Ke(Yr,{label:"Size",value:ly(t.size),valueStyle:ge.monoValue})]}),t.encrypted&&Cr(l,{style:ge.notice,children:[Ke(u,{style:ge.noticeIcon,children:"\u{1F512}"}),Ke(u,{style:ge.noticeText,children:"This instance is encrypted. Values are protected at rest."})]}),t.readOnly&&Cr(l,{style:[ge.notice,ge.noticeWarning],children:[Ke(u,{style:ge.noticeIcon,children:"\u{1F441}\uFE0F"}),Ke(u,{style:[ge.noticeText,ge.noticeTextWarning],children:"Read-only mode. Cannot modify values in this instance."})]})]})}):Ke(l,{style:ge.container,children:Ke(l,{style:ge.errorState,children:Cr(u,{style:ge.errorText,children:["Instance not found: ",e]})})})}function Yr({label:e,value:t,valueStyle:r,valueColor:o,highlight:n}){return Cr(l,{style:ge.infoItem,children:[Ke(u,{style:ge.infoLabel,children:e}),Ke(u,{style:[ge.infoValue,r,o&&{color:o},n&&ge.infoValueHighlight],children:t})]})}function ly(e){if(e===0)return"0 Bytes";let t=1024,r=["Bytes","KB","MB","GB"],o=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/Math.pow(t,o)).toFixed(2))} ${r[o]}`}var ge=pe.create({container:{marginBottom:12},errorState:{backgroundColor:yt.semantic.error+"15",borderRadius:12,padding:12,borderWidth:1,borderColor:yt.semantic.error+"40"},errorText:{fontSize:12,color:yt.semantic.error,textAlign:"center"},panel:{backgroundColor:Et.color.surface,borderRadius:12,borderWidth:1,borderColor:Et.color.border,overflow:"hidden",shadowColor:"#000000",shadowOpacity:.03,shadowRadius:8,shadowOffset:{width:0,height:2}},header:{padding:12,borderBottomWidth:1,borderBottomColor:Et.color.separator},headerTitle:{fontSize:11,fontWeight:"600",color:Et.color.text,textTransform:"uppercase",letterSpacing:.5},infoGrid:{padding:12,gap:10},infoItem:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:4},infoLabel:{fontSize:12,color:Et.color.textTertiary,fontWeight:"500"},infoValue:{fontSize:12,color:Et.color.text,fontWeight:"500"},infoValueHighlight:{fontSize:14,fontWeight:"600",color:Et.color.accent},monoValue:{fontFamily:ay},notice:{flexDirection:"row",alignItems:"center",gap:8,padding:10,margin:12,marginTop:0,backgroundColor:yt.semantic.success+"10",borderRadius:8,borderWidth:1,borderColor:yt.semantic.success+"30"},noticeWarning:{backgroundColor:yt.semantic.warning+"10",borderColor:yt.semantic.warning+"30"},noticeIcon:{fontSize:14},noticeText:{flex:1,fontSize:11,color:yt.semantic.success,lineHeight:16},noticeTextWarning:{color:yt.semantic.warning}});E();import{getBrowserStorage as zi,subscribeToBrowserStorage as sy}from"@buoy-gg/shared-ui/web/utils";import{isDevToolsStorageKey as Ln}from"@buoy-gg/shared-ui/web";lo();var Ki=0;function cy(e){let t=()=>zi(e),r=()=>Array.from({length:t().length},(n,a)=>t().key(a)).filter(n=>n!==null&&!Ln(n)),o=n=>{try{return JSON.parse(t().getItem(n)??"")}catch{return}};return{set(n,a){t().setItem(n,String(a))},getString(n){let a=typeof o(n);return a==="number"||a==="boolean"?void 0:t().getItem(n)??void 0},getNumber(n){let a=o(n);return typeof a=="number"?a:void 0},getBoolean(n){let a=o(n);return typeof a=="boolean"?a:void 0},getBuffer(){},contains(n){return t().getItem(n)!==null},delete(n){let a=this.contains(n);return t().removeItem(n),a},getAllKeys:r,clearAll(){for(let n of r())t().removeItem(n)},get size(){return r().reduce((n,a)=>n+2*(a.length+(t().getItem(a)?.length??0)),0)},addOnValueChangedListener(n){return{remove:sy(a=>{a.area===e&&(a.key!==void 0?Ln(a.key)||n(a.key):a.prevPairs?.forEach(([i])=>{Ln(i)||n(i)}))})}}}}function dy(){return zr()?["localStorage","sessionStorage"]:["sessionStorage"]}function uy(){if(typeof window>"u")return()=>{};try{zi("sessionStorage")}catch{return()=>{}}let e=dy();if(++Ki===1)for(let r of e)Gn(r,cy(r));let t=true;return()=>{if(t&&(t=false,--Ki===0))for(let r of e)Jn(r)}}export{iy as MMKVInstanceInfoPanel,ny as MMKVInstanceSelector,Zu as STORAGE_OPS,ei as StorageBrowserMode,Dn as StorageEventCard,Vn as StorageEventDetailContent,An as StorageEventDetailFooter,Qu as StorageEventsSection,Wu as StorageKeyCard,Sa as StorageKeySection,Uu as StorageKeyStatsSection,zn as StorageModalWithTabs,zu as StorageSection,Su as StorageToolView,gn as StorageTypeFilterBar,xo as batchPairsOf,Bn as canUndo,uo as clearAllAppStorage,Ea as countByStorageType,Bu as createStorageTool,kt as detectMMKVType,dl as formatMMKVValue,Dc as getMMKVClass,Ra as getMMKVUnavailableMessage,gu as getValueType,ry as isInitialScan,pn as isMMKVAvailable,Qo as isTypeMatch,Ur as isValueOnDevice,Rn as jumpToState,Gn as registerMMKVInstance,pl as registerSecureStoreKeys,Cd as requestStorageBrowserRefresh,Ga as setStorageValue,uy as startBrowserStorageCapture,kn as storageEditBlockedReason,Lt as storageEventStore,ey as storageOpDot,ty as storageOpOf,Eu as storageSyncAdapter,Ci as storageToolPreset,xd as storageValueToEditableText,En as undoOperation,Jn as unregisterMMKVInstance,fl as unregisterSecureStoreKey,mn as useAsyncStorageKeys,Wa as useMMKVInstance,Yc as useMMKVInstanceExists,Sn as useMMKVInstances,Hc as useMMKVKeys,La as useMultiMMKVKeys,ri as useStorageEvents,Ua as validateStorageValue};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/storage",
3
- "version": "7.0.76",
3
+ "version": "7.0.78",
4
4
  "description": "Inspect supported AsyncStorage data, registered MMKV instances and registered SecureStore keys in a React Native app.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -38,11 +38,11 @@
38
38
  "./lib/web/**/*.mjs"
39
39
  ],
40
40
  "dependencies": {
41
- "@buoy-gg/floating-tools-core": "^7.0.76",
42
- "@buoy-gg/shared-ui": "^7.0.76"
41
+ "@buoy-gg/floating-tools-core": "^7.0.78",
42
+ "@buoy-gg/shared-ui": "^7.0.78"
43
43
  },
44
44
  "peerDependencies": {
45
- "@buoy-gg/license": "7.0.76",
45
+ "@buoy-gg/license": "7.0.78",
46
46
  "react": "*"
47
47
  },
48
48
  "devDependencies": {
@@ -50,7 +50,7 @@
50
50
  "@types/react": "^19.1.0",
51
51
  "@types/react-native": "^0.73.0",
52
52
  "typescript": "~5.8.3",
53
- "@buoy-gg/license": "^7.0.76"
53
+ "@buoy-gg/license": "^7.0.78"
54
54
  },
55
55
  "react-native-builder-bob": {
56
56
  "source": "src",