@buoy-gg/events 7.0.56 → 7.0.57

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/web/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
- "use client";var Kt=Object.defineProperty;var Qr=Object.getOwnPropertyDescriptor;var Gr=Object.getOwnPropertyNames;var Zr=Object.prototype.hasOwnProperty;var Yr=(e,t)=>{for(var r in t)Kt(e,r,{get:t[r],enumerable:true})},_t=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Gr(t))!Zr.call(e,o)&&o!==r&&Kt(e,o,{get:()=>t[o],enumerable:!(a=Qr(t,o))||a.enumerable});return e},Xr=(e,t,r)=>(_t(e,t,"default"),r&&_t(r,t,"default"));typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis);import{EventsIcon as eo,EVENTS_ICON_COLOR as to}from"@buoy-gg/floating-tools-core/web";var Qt={};Yr(Qt,{AccessibilityInfo:()=>no,ActivityIndicator:()=>ea,Alert:()=>Zt,Animated:()=>io,AppRegistry:()=>lo,AppState:()=>uo,Appearance:()=>so,BackHandler:()=>co,Button:()=>ta,CheckBox:()=>Do,Clipboard:()=>po,DeviceEventEmitter:()=>Uo,Dimensions:()=>mo,Easing:()=>ho,FlatList:()=>Gt,I18nManager:()=>go,Image:()=>To,ImageBackground:()=>Io,InteractionManager:()=>yo,Keyboard:()=>fo,KeyboardAvoidingView:()=>Ao,LayoutAnimation:()=>bo,Linking:()=>vo,LogBox:()=>Oo,Modal:()=>Yo,NativeEventEmitter:()=>So,NativeModules:()=>ao,PanResponder:()=>Co,Picker:()=>qo,PixelRatio:()=>wo,Platform:()=>Eo,Pressable:()=>Zo,ProgressBar:()=>Bo,RefreshControl:()=>Fo,SafeAreaView:()=>Ro,ScrollView:()=>ue,SectionList:()=>jo,Share:()=>xo,StatusBar:()=>zo,StyleSheet:()=>le,Switch:()=>Xo,Text:()=>k,TextInput:()=>_o,Touchable:()=>Mo,TouchableHighlight:()=>Qo,TouchableNativeFeedback:()=>Po,TouchableOpacity:()=>ge,TouchableWithoutFeedback:()=>Go,UIManager:()=>$o,Vibration:()=>ko,View:()=>f,VirtualizedList:()=>No,YellowBox:()=>Vo,findNodeHandle:()=>ra,unstable_createElement:()=>oo,useColorScheme:()=>Lo,useLocaleContext:()=>Ho,useWindowDimensions:()=>Jo});Xr(Qt,ro);import*as ro from"react-native-web";import{unstable_createElement as oo,NativeModules as ao,AccessibilityInfo as no,Animated as io,Appearance as so,AppRegistry as lo,AppState as uo,BackHandler as co,Clipboard as po,Dimensions as mo,Easing as ho,I18nManager as go,Keyboard as fo,InteractionManager as yo,LayoutAnimation as bo,Linking as vo,NativeEventEmitter as So,PanResponder as Co,PixelRatio as wo,Platform as Eo,Share as xo,StyleSheet as le,UIManager as $o,Vibration as ko,CheckBox as Do,FlatList as Gt,Image as To,ImageBackground as Io,KeyboardAvoidingView as Ao,Picker as qo,ProgressBar as Bo,RefreshControl as Fo,SafeAreaView as Ro,SectionList as jo,StatusBar as zo,Touchable as Mo,TouchableNativeFeedback as Po,VirtualizedList as No,YellowBox as Vo,LogBox as Oo,DeviceEventEmitter as Uo,useColorScheme as Lo,useLocaleContext as Ho,useWindowDimensions as Jo}from"react-native-web";import*as W from"react-native-web";import{createElement as Wo,forwardRef as Ko}from"react";function Z(e){let t=Ko((a,o)=>{let{accessibilityState:n,accessibilityValue:i,...l}=a;for(let s of["busy","checked","disabled","expanded","selected"])n?.[s]!==void 0&&l[`aria-${s}`]===void 0&&(l[`aria-${s}`]=n[s]);for(let[s,u]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[s]!==void 0&&l[`aria-${u}`]===void 0&&(l[`aria-${u}`]=i[s]);return Wo(e,{...l,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var f=Z(W.View),k=Z(W.Text),_o=Z(W.TextInput),ge=Z(W.TouchableOpacity),Qo=Z(W.TouchableHighlight),Go=Z(W.TouchableWithoutFeedback),Zo=Z(W.Pressable),ue=Z(W.ScrollView),Yo=Z(W.Modal),Xo=Z(W.Switch),ea=Z(W.ActivityIndicator),ta=Z(W.Button),ra=W.findNodeHandle,Zt={alert(e,t,r,a){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.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 n=document.createElement("h2");if(n.textContent=e,n.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(n),t){let u=document.createElement("p");u.textContent=t,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(u)}let i=document.createElement("div");i.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=r?.length?r:[{text:"OK"}],s=()=>{o.close?.(),o.remove()};for(let u of l){let c=document.createElement("button");c.type="button",c.textContent=u.text??"OK",c.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,c.onclick=()=>{s(),u.onPress?.()},i.appendChild(c)}o.addEventListener("cancel",u=>{u.preventDefault(),a?.cancelable!==false&&(s(),a?.onDismiss?.())}),o.appendChild(i),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{useState as ot,useCallback as Ae,useEffect as oa,useRef as aa}from"react";import{JsModal as na,ModalHeader as Y,buoyColors as ia,night as X,Trash2 as sa,Copy as la,Search as ua,devToolsStorageKeys as ca,ToolbarCopyButton as da,UpgradeModal as pa,PowerToggleButton as ma,useSafeRouter as ha,windowDragProps as ga}from"@buoy-gg/shared-ui/web";import{useState as fe,useEffect as ye,useCallback as be,useMemo as ve,useRef as yt}from"react";import{useFeatureGate as fa,subscribeToSubscriberCountChanges as ya,useIgnoredPatterns as ba,useLimit as va}from"@buoy-gg/shared-ui/web";import{loadToolModule as ee,getToolModuleVersion as Yt}from"@buoy-gg/shared-ui/web/utils";var Sa=0;function pe(e){return`${e}-${Date.now()}-${++Sa}`}function Ca(){try{let{storageEventStore:e}=ee("@buoy-gg/storage");return{id:"storage",name:"Storage",eventSources:["storage-async","storage-mmkv"],available:true,subscribe:t=>e.onEvent(r=>{if(r?.data?.initialScan)return;let a=wa(r);t(a)})}}catch{return null}}function wa(e){let t=e,r=t.storageType==="async"?"storage-async":"storage-mmkv",a=t.action;t.storageType==="async"&&(a={setItem:"Set Item",removeItem:"Remove Item",mergeItem:"Merge Item",clear:"Clear All",multiSet:"Multi Set",multiRemove:"Multi Remove",multiMerge:"Multi Merge"}[t.action]||t.action);let o="";if(t.storageType==="async")switch(t.action){case"setItem":case"removeItem":case"mergeItem":o=t.data?.key||"unknown key";break;case"multiSet":case"multiMerge":{let i=t.data?.pairs?.length||0;o=`${i} key${i!==1?"s":""}`;break}case"multiRemove":{let i=t.data?.keys?.length||0;o=`${i} key${i!==1?"s":""}`;break}case"clear":o="all keys";break}else o=t.data?.key||t.data?.instanceId||"unknown";let n="neutral";return(t.action.includes("set")||t.action.includes("Set")||t.action.includes("merge")||t.action.includes("Merge"))&&(n="success"),{id:pe(r),source:r,timestamp:t.timestamp.getTime(),title:a,subtitle:o,status:n,originalEvent:e}}function Ea(){try{let{reduxActionStore:e}=ee("@buoy-gg/redux"),t=null;return{id:"redux",name:"Redux",eventSources:["redux"],available:true,subscribe:r=>e.subscribe(a=>{if(a.length>0){let o=a[0];if(o.id!==t){t=o.id;let n=xa(o);r(n)}}})}}catch{return null}}function xa(e){let t=e,r="neutral";switch(t.category){case"fulfilled":r="success";break;case"rejected":r="error";break;case"pending":r="pending";break;default:r=t.hasStateChange?"success":"neutral"}let a="";return t.payloadPreview?a=t.payloadPreview:t.hasStateChange&&t.diffSummary?a=t.diffSummary:t.duration!==void 0?a=`${t.duration.toFixed(1)}ms`:a=t.sliceName||"",{id:pe("redux"),source:"redux",timestamp:t.timestamp,title:t.type,subtitle:a,status:r,originalEvent:e}}function $a(){try{let{networkEventStore:e,networkListener:t,addNetworkListener:r}=ee("@buoy-gg/network"),a=new Map;return{id:"network",name:"Network",eventSources:["network"],available:true,setup:()=>{let o=t();o.isActive||o.startListening(),o.listenerCount===0&&r(n=>{e.processNetworkEvent(n)})},subscribe:o=>{let n=Date.now();return e.onEvent(i=>{let l=i,s=a.get(l.id);if(s){let u=Xt(i);u.id=s,o(u)}else{if(typeof l.timestamp=="number"&&l.timestamp<n)return;let u=Xt(i);a.set(l.id,u.id),o(u)}},false)}}}catch{return null}}function Xt(e){let t=e,r="neutral";t.status===void 0?r="pending":t.error||t.status>=400?r="error":t.status>=200&&t.status<400&&(r="success");let a=t.operationName||`${t.method} ${t.path||t.url}`,o=[];return t.status!==void 0?o.push(`${t.status}`):t.error?o.push("Error"):o.push("Pending"),t.duration!==void 0&&o.push(`${t.duration.toFixed(0)}ms`),t.host&&o.push(t.host),{id:pe("network"),source:"network",timestamp:t.timestamp,title:a,subtitle:o.join(" \xB7 "),status:r,originalEvent:e}}function ka(){try{let{reactQueryEventStore:e}=ee("@buoy-gg/react-query"),t=null;return{id:"react-query",name:"React Query",eventSources:["react-query","react-query-query","react-query-mutation"],available:true,subscribe:r=>{let a=true,o=new Set,n=i=>i.queryHash??(i.mutationId!==void 0?`m-${i.mutationId}`:null);return e.subscribe(i=>{if(a){a=false,i.length>0&&(t=i[0].id);return}if(i.length>0){let l=i[0];if(l.id!==t){t=l.id;let s=l.type??"",u=n(l);if(s==="query-fetch-start"||s==="mutation-start")u&&o.add(u);else if((s==="query-fetch-success"||s==="query-fetch-error"||s==="mutation-success"||s==="mutation-error")&&u&&!o.has(u))return;let c=Da(l);r(c)}}})}}}catch{return null}}function er(e){return!e||e.length===0?"unknown":e.map(t=>{if(typeof t=="string")return t;if(typeof t=="number")return String(t);if(typeof t=="object"&&t!==null){let r=Object.values(t)[0];return typeof r=="string"||typeof r=="number"?String(r):JSON.stringify(t).slice(0,20)}return String(t)}).join(" \u203A ")}function Da(e){let t=e,r=t.type.startsWith("mutation-")?"react-query-mutation":"react-query-query",a="neutral";switch(t.type){case"query-fetch-start":case"mutation-start":a="pending";break;case"query-fetch-success":case"mutation-success":a="success";break;case"query-fetch-error":case"mutation-error":a="error";break}let o="";t.queryKey?o=er(t.queryKey):t.mutationKey?o=er(t.mutationKey):t.mutationId!==void 0?o=`Mutation #${t.mutationId}`:o=t.type.replace(/-/g," ");let n=[];switch(t.type){case"query-fetch-start":n.push("Fetching");break;case"query-fetch-success":n.push("Success");break;case"query-fetch-error":n.push("Error");break;case"query-invalidated":n.push("Invalidated");break;case"mutation-start":n.push("Mutating");break;case"mutation-success":n.push("Success");break;case"mutation-error":n.push("Error");break}t.duration!==void 0&&n.push(`${t.duration.toFixed(0)}ms`);let i;t.queryHash?i=`rq-query-${t.queryHash}`:t.mutationId!==void 0&&(i=`rq-mutation-${t.mutationId}`);let l=1;switch(t.type){case"query-fetch-start":case"mutation-start":l=1;break;case"query-fetch-success":case"query-fetch-error":case"mutation-success":case"mutation-error":l=2;break;case"query-invalidated":l=3;break}return{id:pe(r),source:r,timestamp:t.timestamp,title:o,subtitle:n.join(" \xB7 "),status:a,originalEvent:e,correlationId:i,sequenceInGroup:l}}function Ta(){try{let{routeEventStore:e}=ee("@buoy-gg/route-events");return{id:"route-events",name:"Routes",eventSources:["route"],available:true,subscribe:t=>e.onEvent(r=>{let a=Ia(r);t(a)})}}catch{return null}}function Ia(e){let t=e,r="neutral";(t.pathname==="/"||Object.keys(t.params).length>0)&&(r="success");let a=[],o=Object.keys(t.params).length;return o>0&&a.push(`${o} param${o!==1?"s":""}`),t.timeSincePrevious!==void 0&&t.timeSincePrevious>0&&(t.timeSincePrevious<1e3?a.push(`${t.timeSincePrevious}ms`):a.push(`${(t.timeSincePrevious/1e3).toFixed(1)}s`)),t.previousPathname&&t.previousPathname!==t.pathname&&a.push(`from ${t.previousPathname}`),{id:pe("route"),source:"route",timestamp:t.timestamp,title:t.pathname||"/",subtitle:a.join(" \xB7 ")||"navigation",status:r,originalEvent:e}}function Aa(){try{let{zustandStateStore:e}=ee("@buoy-gg/zustand"),t=null;return{id:"zustand",name:"Zustand",eventSources:["zustand"],available:true,subscribe:r=>e.subscribe(a=>{if(a.length>0){let o=a[0];if(o.id!==t){t=o.id;let n=qa(o);r(n)}}})}}catch{return null}}function qa(e){let t=e,r="neutral";t.isSlowUpdate?r="pending":t.hasStateChange&&(r="success");let a=[];if(t.changedKeys&&t.changedKeys.length>0){let o=t.changedKeys.slice(0,3).join(", "),n=t.changedKeys.length>3?` +${t.changedKeys.length-3}`:"";a.push(`${o}${n}`)}else t.diffSummary&&a.push(t.diffSummary);return t.duration!==void 0&&a.push(`${t.duration.toFixed(1)}ms`),t.category==="replace"&&a.push("replace"),{id:pe("zustand"),source:"zustand",timestamp:t.timestamp,title:t.storeName,subtitle:a.join(" \xB7 ")||(t.hasStateChange?"state changed":"no change"),status:r,originalEvent:e}}function Ba(){try{let{jotaiStateStore:e}=ee("@buoy-gg/jotai"),t=null;return{id:"jotai",name:"Jotai",eventSources:["jotai"],available:true,subscribe:r=>e.subscribe(a=>{if(a.length>0){let o=a[0];if(o.id!==t){t=o.id;let n=Fa(o);r(n)}}})}}catch{return null}}function Fa(e){let t=e,r="neutral";t.category==="write"&&t.hasValueChange?r="success":t.category==="read"&&(r="neutral");let a=[];return t.valuePreview?a.push(t.valuePreview):t.diffSummary&&a.push(t.diffSummary),t.category&&a.push(t.category),{id:pe("jotai"),source:"jotai",timestamp:t.timestamp,title:t.atomLabel,subtitle:a.join(" \xB7 ")||(t.hasValueChange?"value changed":"no change"),status:r,originalEvent:e}}function Ra(){let e;try{e=ee("@buoy-gg/highlight-updates")}catch{return null}try{if(!e.RenderTracker||!e.HighlightUpdatesController)return null;let{RenderTracker:t,HighlightUpdatesController:r}=e;return{id:"render",name:"Render",eventSources:["render"],available:true,setup:()=>{r&&r.enableBackgroundTracking()},subscribe:a=>{r&&!r.isBackgroundTrackingEnabled()&&r.enableBackgroundTracking();let o=t.onRenderEvent((n,i)=>{let l=ja(n,i);a(l)});return()=>{o(),r.disableBackgroundTracking()}}}}catch{return null}}function ja(e,t){let r=e,a=t,o=a.componentName||a.displayName||a.viewType,n=[],i={mount:"mounted",props:"props changed",state:"state changed",hooks:"hooks changed",context:"context changed",parent:"parent re-rendered",unknown:"re-rendered"};if(n.push(i[r.cause.type]||r.cause.type),r.cause.type==="props"&&r.cause.changedKeys?.length){let s=r.cause.changedKeys.slice(0,3).join(", "),u=r.cause.changedKeys.length>3?` +${r.cause.changedKeys.length-3}`:"";n.push(`[${s}${u}]`)}if(r.cause.hookChanges?.length){let s=r.cause.hookChanges[0];s.description&&n.push(s.description)}n.push(`#${r.renderNumber}`);let l="neutral";switch(r.cause.type){case"mount":l="neutral";break;case"props":case"state":case"hooks":case"context":l="success";break;case"parent":l="pending";break;default:l="neutral"}return{id:pe("render"),source:"render",timestamp:r.timestamp,title:o,subtitle:n.join(" \xB7 "),status:l,originalEvent:{event:r,render:a}}}function za(){let e=[],t=new Set,r=[Ca,Ea,$a,ka,Ta,Aa,Ba,Ra];for(let a of r){let o=a();o&&o.available&&(e.push(o),o.eventSources.forEach(n=>t.add(n)))}return{sources:e,availableEventSources:t}}function Ma(e){return{"storage-async":{label:"Storage",color:"#8B5CF6",icon:"server-outline"},"storage-mmkv":{label:"MMKV",color:"#F59E0B",icon:"flash-outline"},redux:{label:"Redux",color:"#3B82F6",icon:"git-branch-outline"},network:{label:"Network",color:"#10B981",icon:"globe-outline"},"react-query":{label:"Query",color:"#EC4899",icon:"sync-outline"},"react-query-query":{label:"Query",color:"#EC4899",icon:"sync-outline"},"react-query-mutation":{label:"Mutation",color:"#F97316",icon:"flash-outline"},route:{label:"Route",color:"#06B6D4",icon:"navigate-outline"},zustand:{label:"Zustand",color:"#764ABC",icon:"cube-outline"},jotai:{label:"Jotai",color:"#14B8A6",icon:"ellipse-outline"},render:{label:"Render",color:"#F472B6",icon:"layers-outline"}}[e]||{label:e,color:"#6B7280",icon:"help-outline"}}var bt=null,tr=-1;function H(){return(!bt||tr!==Yt())&&(tr=Yt(),bt=za()),bt}function Pa(){let e=[],t=0;try{let{storageEventStore:r}=ee("@buoy-gg/storage"),a=r.getSubscriberCounts();e.push({sourceId:"storage",counts:a}),t+=a.total}catch{}try{let{networkEventStore:r}=ee("@buoy-gg/network"),a=r.getSubscriberCounts();e.push({sourceId:"network",counts:a}),t+=a.total}catch{}try{let{routeEventStore:r}=ee("@buoy-gg/route-events"),a=r.getSubscriberCounts();e.push({sourceId:"route-events",counts:a}),t+=a.total}catch{}try{let{RenderTracker:r,HighlightUpdatesController:a}=ee("@buoy-gg/highlight-updates"),o=r.getRenderEventCallbackCount(),n=a?.isEnabled?.()?1:0,i={eventCallbacks:o,arrayListeners:n,total:o+n};e.push({sourceId:"render",counts:i}),t+=i.total}catch{}return{sources:e,totalSubscribers:t}}import{ChangeLog as Na}from"@buoy-gg/shared-ui/web";var vt={"storage-async":"storage","storage-mmkv":"storage",redux:"redux",network:"network","react-query":"react-query","react-query-query":"react-query","react-query-mutation":"react-query",route:"route-events",zustand:"zustand",jotai:"jotai",render:"render"};var Va=200,rr=new Set(["render"]),Oa=class extends Na{constructor(){super({max:Va});this.activeSources=new Set;this.remoteAvailableSources=null;this.sourceUnsubscribers=new Map;this.remoteDiscoveryIds=new Set;this.localDiscoveryIds=new Set;this.localSyncChain=Promise.resolve();this.networkEventIdMap=new Map}getDiscoveredSources(){return H().sources}getAvailableEventSources(){return this.remoteAvailableSources?this.remoteAvailableSources:H().availableEventSources}setRemoteAvailableSources(e){let t=e?new Set(e):null,r=this.remoteAvailableSources,a=r===null&&t===null||!!r&&!!t&&r.size===t.size&&[...t].every(o=>r.has(o));this.remoteAvailableSources=t,a||this.notifyListeners()}replaceEvents(e){this.activeSources=new Set(e.map(t=>t.source)),this.setItems(e)}async subscribeToAll(){let{sources:e}=H();for(let t of e)rr.has(t.id)||await this.subscribeToSource(t)}async subscribeToSource(e){let t=this.sourceUnsubscribers.get(e.id);if(t){t.refCount++;return}let r={unsubscribe:()=>{},refCount:1};this.sourceUnsubscribers.set(e.id,r);try{e.setup&&await e.setup();let a=await e.subscribe(o=>{this.addEvent(o)});a&&(r.unsubscribe=a)}catch{this.sourceUnsubscribers.get(e.id)===r&&r.refCount<=1&&this.sourceUnsubscribers.delete(e.id)}}unsubscribeFromSource(e){let t=this.sourceUnsubscribers.get(e);t&&(t.refCount--,t.refCount<=0&&(t.unsubscribe(),this.sourceUnsubscribers.delete(e)))}async subscribeToStorage(){let{sources:e}=H(),t=e.find(r=>r.id==="storage");t&&await this.subscribeToSource(t)}unsubscribeFromStorage(){this.unsubscribeFromSource("storage"),this.activeSources.delete("storage-async"),this.activeSources.delete("storage-mmkv")}subscribeToRedux(){let{sources:e}=H(),t=e.find(r=>r.id==="redux");t&&this.subscribeToSource(t)}unsubscribeFromRedux(){this.unsubscribeFromSource("redux"),this.activeSources.delete("redux")}subscribeToNetwork(){let{sources:e}=H(),t=e.find(r=>r.id==="network");t&&this.subscribeToSource(t)}unsubscribeFromNetwork(){this.unsubscribeFromSource("network"),this.activeSources.delete("network")}subscribeToReactQuery(){let{sources:e}=H(),t=e.find(r=>r.id==="react-query");t&&this.subscribeToSource(t)}unsubscribeFromReactQuery(){this.unsubscribeFromSource("react-query"),this.activeSources.delete("react-query"),this.activeSources.delete("react-query-query"),this.activeSources.delete("react-query-mutation")}subscribeToRoutes(){let{sources:e}=H(),t=e.find(r=>r.id==="route-events");t&&this.subscribeToSource(t)}unsubscribeFromRoutes(){this.unsubscribeFromSource("route-events"),this.activeSources.delete("route")}subscribeToZustand(){let{sources:e}=H(),t=e.find(r=>r.id==="zustand");t&&this.subscribeToSource(t)}unsubscribeFromZustand(){this.unsubscribeFromSource("zustand"),this.activeSources.delete("zustand")}subscribeToJotai(){let{sources:e}=H(),t=e.find(r=>r.id==="jotai");t&&this.subscribeToSource(t)}unsubscribeFromJotai(){this.unsubscribeFromSource("jotai"),this.activeSources.delete("jotai")}subscribeToRender(){let{sources:e}=H(),t=e.find(r=>r.id==="render");t&&this.subscribeToSource(t)}unsubscribeFromRender(){this.unsubscribeFromSource("render"),this.activeSources.delete("render")}addEvent(e){if(e.source==="network"){let t=e.originalEvent;if(t?.id){let r=this.networkEventIdMap.get(t.id);if(r){let a=this.items.findIndex(o=>o.id===r);if(a>=0){e.id=r,this.items=[...this.items.slice(0,a),e,...this.items.slice(a+1)],this.notifyListeners();return}}this.networkEventIdMap.set(t.id,e.id)}}this.push(e),this.activeSources.add(e.source),this.notifyListeners()}getEvents(e){return!e||e.size===0?this.items:this.items.filter(t=>e.has(t.source))}getActiveSources(){return Array.from(this.activeSources)}getSourceCounts(){let e={"storage-async":0,"storage-mmkv":0,redux:0,network:0,"react-query":0,"react-query-query":0,"react-query-mutation":0,route:0,zustand:0,jotai:0,render:0};for(let t of this.items)e[t.source]++;return e}clearEvents(){this.activeSources.clear(),this.networkEventIdMap.clear(),this.clear()}subscribe(e){let t=super.subscribe(e);return e(this.items),t}getEventCount(){return this.items.length}unsubscribeAll(){for(let[,e]of this.sourceUnsubscribers)e.unsubscribe();this.sourceUnsubscribers.clear(),this.activeSources.clear(),this.remoteDiscoveryIds.clear(),this.localDiscoveryIds.clear()}watch(e,t,r=Date.now()){let a=new Set(e),o=new Set;for(let u of e){let c=vt[u];c&&o.add(c)}let{sources:n}=H(),i=[];for(let u of o){let c=n.find(d=>d.id===u);c&&(i.push(u),this.subscribeToSource(c))}let l=false,s=this.subscribe(u=>{l||t(u.filter(c=>c.timestamp>=r&&a.has(c.source)))});return()=>{if(!l){l=true,s();for(let u of i)this.unsubscribeFromSource(u)}}}setLocalEnabledSources(e){let t=async()=>{let r=new Set;for(let n of e){let i=vt[n];i&&r.add(i)}let a=this.localDiscoveryIds;this.localDiscoveryIds=r;let{sources:o}=H();for(let n of r)if(!a.has(n)){let i=o.find(l=>l.id===n);i&&await this.subscribeToSource(i)}for(let n of a)r.has(n)||this.unsubscribeFromSource(n)};return this.localSyncChain=this.localSyncChain.then(t,t),this.localSyncChain}async setRemoteEnabledSources(e){let{sources:t}=H(),r;if(e==="all")r=new Set(t.map(o=>o.id).filter(o=>!rr.has(o)));else{r=new Set;for(let o of e){let n=vt[o];n&&r.add(n)}}let a=this.remoteDiscoveryIds;this.remoteDiscoveryIds=r;for(let o of r)if(!a.has(o)){let n=t.find(i=>i.id===o);n&&await this.subscribeToSource(n)}for(let o of a)r.has(o)||this.unsubscribeFromSource(o)}ensureRemoteSourcesDefault(){this.remoteDiscoveryIds.size===0&&this.setRemoteEnabledSources("all")}clearRemoteSources(){for(let e of this.remoteDiscoveryIds)this.unsubscribeFromSource(e);this.remoteDiscoveryIds.clear()}isSourceSubscribed(e){switch(e){case"storage-async":case"storage-mmkv":return this.sourceUnsubscribers.has("storage");case"redux":return this.sourceUnsubscribers.has("redux");case"network":return this.sourceUnsubscribers.has("network");case"react-query":case"react-query-query":case"react-query-mutation":return this.sourceUnsubscribers.has("react-query");case"route":return this.sourceUnsubscribers.has("route-events");case"zustand":return this.sourceUnsubscribers.has("zustand");case"jotai":return this.sourceUnsubscribers.has("jotai");case"render":return this.sourceUnsubscribers.has("render");default:return false}}getSubscriptionStatus(){return{"storage-async":this.sourceUnsubscribers.has("storage"),"storage-mmkv":this.sourceUnsubscribers.has("storage"),redux:this.sourceUnsubscribers.has("redux"),network:this.sourceUnsubscribers.has("network"),"react-query":this.sourceUnsubscribers.has("react-query"),"react-query-query":this.sourceUnsubscribers.has("react-query"),"react-query-mutation":this.sourceUnsubscribers.has("react-query"),route:this.sourceUnsubscribers.has("route-events"),zustand:this.sourceUnsubscribers.has("zustand"),jotai:this.sourceUnsubscribers.has("jotai"),render:this.sourceUnsubscribers.has("render")}}getSubscriberCounts(){return Pa()}},O=new Oa;var Ua=e=>O.getEvents(e);var La=()=>O.clearEvents(),Ha=e=>O.subscribe(e);var or=e=>O.setLocalEnabledSources(e);var ar=()=>O.getAvailableEventSources();var Ja=(e,t,r)=>O.watch(e,t,r),nr=()=>O.getSubscriberCounts();import{persistentStorage as Se,devToolsStorageKeys as qe}from"@buoy-gg/shared-ui/web";async function Wa(e){try{let t=qe.events.enabledSources();await Se.setItem(t,JSON.stringify(e))}catch{}}async function Ka(){try{let e=qe.events.enabledSources(),t=await Se.getItem(e);return t&&t!==""?JSON.parse(t):null}catch{return null}}async function _a(e){try{let t=qe.events.isCapturing();await Se.setItem(t,JSON.stringify(e))}catch{}}async function Qa(){try{let e=qe.events.isCapturing(),t=await Se.getItem(e);return t!==null&&t!==""?JSON.parse(t):null}catch{return null}}async function ir(e){try{let t=qe.events.pausedAt();e===null?await Se.removeItem(t):await Se.setItem(t,JSON.stringify(e))}catch{}}async function Ga(){try{let e=qe.events.pausedAt(),t=await Se.getItem(e);if(t!==null&&t!==""){let r=JSON.parse(t);return typeof r=="number"?r:null}return null}catch{return null}}import{isDevToolsStorageKey as sr,isUrlIgnored as Za}from"@buoy-gg/shared-ui/web";var Ya=["api.keygen.sh","buoy.gg/api/license"];function St(e){let t=e.originalEvent;if(!t)return false;if(e.source==="storage-async"||e.source==="storage-mmkv"){let r=t.data?.key||t.key;if(r&&sr(r))return true;let a=t.data?.keys||t.data?.pairs?.map(o=>o[0]);if(a&&a.length>0&&a.every(o=>sr(o)))return true}if(e.source==="network"){let r=t.host||"",a=t.url||"";for(let o of Ya)if(r.includes(o)||a.includes(o))return true}return false}function Ct(e,t){if(e.source!=="network"||t.length===0)return false;let r=e.originalEvent?.url??"";return Za(r,t)}function Xa(e,t){return St(e)||Ct(e,t)}function en(e,t){if(e.title.toLowerCase().includes(t)||e.subtitle.toLowerCase().includes(t))return true;let r=e.originalEvent?.url;return typeof r=="string"&&r.toLowerCase().includes(t)}var lr=["storage-async","redux","network","react-query-query","react-query-mutation","route","zustand","jotai","render"],ur=lr.filter(e=>e!=="render"),wt={"storage-async":["storage-async","storage-mmkv"],"storage-mmkv":["storage-mmkv"],redux:["redux"],network:["network"],"react-query":["react-query","react-query-query"],"react-query-query":["react-query","react-query-query"],"react-query-mutation":["react-query-mutation"],route:["route"],zustand:["zustand"],jotai:["jotai"],render:["render"]};function Et(e){let{isPro:t}=fa(),r=va("events.entries"),{patterns:a}=ba(),[o,n]=fe([]),[i,l]=fe(()=>new Set(ur)),[s,u]=fe(true),[c,d]=fe(""),h=yt(false),b=e?.capturingOverride??s,v=yt(null),m=yt([]),[y,p]=fe(0);ye(()=>{b?v.current!==null&&(m.current=[...m.current,[v.current,Date.now()]],v.current=null,p(w=>w+1),ir(null)):v.current===null&&(v.current=Date.now(),p(w=>w+1),ir(v.current))},[b]);let g=be(w=>{let F=v.current;if(F!==null&&w>F)return true;for(let[z,Q]of m.current)if(w>z&&w<=Q)return true;return false},[]),[$,L]=fe(()=>ar()),[C,I]=fe(0);ye(()=>ya(()=>{I(w=>w+1)}),[]);let x=ve(()=>lr.filter(w=>(wt[w]||[w]).some(F=>$.has(F))),[$]);ye(()=>{let w=null,F=Ha(()=>{w==null&&(w=requestAnimationFrame(()=>{w=null,z()}))}),z=()=>{let Q=Ua();n(Q),L(q=>{let R=ar();return q.size===R.size&&[...R].every(ne=>q.has(ne))?q:new Set(R)})};return()=>{F(),w!=null&&cancelAnimationFrame(w)}},[]),ye(()=>{(async()=>{let w=await Ka(),F,z=x.filter(R=>ur.includes(R));if(w&&w.length>0){let R=w.filter(ne=>x.includes(ne));R.length>0?F=new Set(R):F=new Set(z)}else F=new Set(z);l(F);let Q=await Qa(),q=Q!==null?Q:true;if(!q&&v.current===null){let R=await Ga();v.current=R??Date.now(),p(ne=>ne+1)}u(q),h.current=true,or(q?Array.from(F):[])})()},[x]),ye(()=>{h.current&&or(s?Array.from(i):[])},[i,s]),ye(()=>{h.current&&Wa(Array.from(i))},[i]),ye(()=>{h.current&&_a(s)},[s]);let j=ve(()=>{let w=new Set;return i.forEach(F=>{let z=wt[F];z&&z.forEach(Q=>w.add(Q))}),w},[i]),N=c.trim().toLowerCase(),me=ve(()=>o.filter(w=>!g(w.timestamp)&&!St(w)&&!Ct(w,a)),[o,a,g,y]),K=ve(()=>j.size===0?[]:me.filter(w=>j.has(w.source)&&(N===""||en(w,N))),[me,j,N]),he=ve(()=>K.slice(0,r),[K,r]),_=ve(()=>Math.max(0,K.length-r),[K,r]),Xe=ve(()=>{let w=me.reduce((q,R)=>(q[R.source]=(q[R.source]??0)+1,q),{}),F=nr(),z={};for(let q of F.sources)z[q.sourceId]=q.counts.total;let Q={"storage-async":"storage","storage-mmkv":"storage",redux:"redux",network:"network","react-query":"react-query","react-query-query":"react-query","react-query-mutation":"react-query",route:"route-events",zustand:"zustand",jotai:"jotai",render:"render"};return x.map(q=>{let R=(wt[q]||[q]).reduce((G,ft)=>G+(w[ft]||0),0),ne=Ma(q),Ie=Q[q],rt=Ie&&Ie in z?z[Ie]:void 0;return{source:q,...ne,count:R,enabled:i.has(q),subscriberCount:rt}}).sort((q,R)=>q.enabled&&!R.enabled?-1:!q.enabled&&R.enabled?1:0)},[me,i,x,C]),mt=be(w=>{l(F=>{let z=new Set(F);return z.has(w)?z.delete(w):z.add(w),z})},[]),et=be(()=>{l(new Set(x))},[x]),Te=be(()=>{La()},[]),Ve=be(()=>{u(true)},[]),ht=be(()=>{u(false)},[]),gt=be(()=>{u(w=>!w)},[]),tt=nr().totalSubscribers;return{events:o,filteredEvents:he,availableSources:Xe,enabledSources:i,searchText:c,setSearchText:d,toggleSource:mt,enableAllSources:et,clearEvents:Te,totalCount:me.length,filteredCount:he.length,isCapturing:s,startCapturing:Ve,stopCapturing:ht,toggleCapturing:gt,discoveredSources:$,hiddenEventsCount:_,isPro:t,totalSubscriberCount:tt}}import{memo as tn}from"react";import{night as U}from"@buoy-gg/shared-ui/web";var S="buoy-events";function rn(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function cr(e){let t=e.originalEvent??{};switch(e.source){case"storage-async":case"storage-mmkv":{let r=t.data??{},a=r.key??(Array.isArray(r.keys)?r.keys.join("+"):void 0)??(Array.isArray(r.pairs)?r.pairs.map(o=>o[0]).join("+"):void 0);return`${e.title} ${a??""}`}case"network":{let r=String(t.url??""),a=r.split("?")[0]??r;return`${t.method??""} ${a}`}case"react-query":case"react-query-query":case"react-query-mutation":return`${e.title} ${t.type??""}`;default:return e.title}}function dr(e){return`${S}-row-${e.source}-${rn(cr(e))}`}function pr(e){return`${S}-filter-${e}`}import{jsx as Ce,jsxs as xt}from"react/jsx-runtime";var $t=tn(function({availableSources:e,onToggleSource:t,totalCount:r,filteredCount:a}){return e.length===0?null:xt(f,{style:re.container,testID:`${S}-filter-bar`,children:[Ce(ue,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:re.badgesRow,testID:`${S}-filter-scroll`,children:e.map(o=>{let n=o.enabled!==false,i=o.subscriberCount,l=i!==void 0,s=o.count||0,u=pr(o.source);return xt(ge,{testID:u,accessibilityRole:"button",accessibilityLabel:`${o.label} filter, ${n?"on":"off"}, ${s} event${s===1?"":"s"}`,style:[re.badge,n?{backgroundColor:U.color.surface,borderColor:o.color+"50"}:re.badgeDisabled],onPress:()=>t(o.source),activeOpacity:.7,children:[l&&Ce(f,{style:[re.countBadge,{backgroundColor:n?i>0?o.color+"25":U.color.fillSecondary:U.color.fill}],children:Ce(k,{style:[re.countText,{color:n?i>0?o.color:U.color.textTertiary:U.color.textTertiary}],testID:`${u}-subscribers`,children:i})}),Ce(f,{style:[re.dot,{backgroundColor:n?o.color:U.color.fillTertiary}]}),Ce(k,{style:[re.badgeLabel,{color:n?U.color.text:U.color.textTertiary}],numberOfLines:1,testID:`${u}-label`,children:o.label}),Ce(f,{style:[re.countBadge,{backgroundColor:n?s>0?o.color+"20":U.color.fill:U.color.fill}],children:Ce(k,{style:[re.countText,{color:n?s>0?o.color:U.color.textTertiary:U.color.textTertiary}],testID:`${u}-count`,children:s})})]},o.source)})}),a<r&&xt(k,{style:re.filterInfo,testID:`${S}-showing`,children:["Showing ",a," of ",r]})]})}),re=le.create({container:{paddingVertical:8,backgroundColor:"transparent",borderBottomWidth:1,borderBottomColor:U.color.border},badgesRow:{flexDirection:"row",gap:8,paddingHorizontal:12},badge:{flexDirection:"row",alignItems:"center",paddingVertical:5,paddingHorizontal:6,borderRadius:20,borderWidth:1,gap:6,flexShrink:0},badgeDisabled:{backgroundColor:U.color.surface,borderColor:U.color.border,opacity:.5},dot:{width:7,height:7,borderRadius:4},badgeLabel:{fontSize:12,fontWeight:"500"},countBadge:{minWidth:18,height:18,borderRadius:9,alignItems:"center",justifyContent:"center",paddingHorizontal:5},countText:{fontSize:10,fontWeight:"600",fontVariant:["tabular-nums"]},filterInfo:{marginTop:6,fontSize:11,color:U.color.textTertiary,textAlign:"center"}});import{memo as on,useCallback as kt,useMemo as an}from"react";import{night as at,Zap as nn,ProBadge as sn,ToolEmptyState as ln,resolveListEmptyState as un}from"@buoy-gg/shared-ui/web";import{loadToolModule as Be,getToolModuleVersion as mr}from"@buoy-gg/shared-ui/web/utils";import{memo as cn}from"react";import{CompactRow as dn,formatRelativeTime as pn,Pill as mn}from"@buoy-gg/shared-ui/web";import{jsx as V,jsxs as hn}from"react/jsx-runtime";function gn(){let e={StorageEventCard:null,getValueType:null,ReduxActionItem:null,NetworkEventItemCompact:null,RouteEventItemCompact:null,ZustandStateChangeItem:null,JotaiAtomChangeItem:null};try{let t=Be("@buoy-gg/storage");e.StorageEventCard=t.StorageEventCard,e.getValueType=t.getValueType}catch{}try{let t=Be("@buoy-gg/redux");e.ReduxActionItem=t.ReduxActionItem}catch{}try{let t=Be("@buoy-gg/network");e.NetworkEventItemCompact=t.NetworkEventItemCompact}catch{}try{let t=Be("@buoy-gg/route-events");e.RouteEventItemCompact=t.RouteEventItemCompact}catch{}try{let t=Be("@buoy-gg/zustand");e.ZustandStateChangeItem=t.ZustandStateChangeItem}catch{}try{let t=Be("@buoy-gg/jotai");e.JotaiAtomChangeItem=t.JotaiAtomChangeItem}catch{}return e}var Dt,hr=-1;function fn(){return(!Dt||hr!==mr())&&(Dt=gn(),hr=mr()),Dt}var gr={"storage-async":{label:"Storage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"}};function yn(e){switch(e){case"success":return"#10B981";case"error":return"#EF4444";case"pending":return"#F59E0B";case"neutral":default:return"#6B7280"}}function bn(e){return e==="storage-async"||e==="storage-mmkv"}function vn({label:e,color:t,testID:r}){return V(mn,{label:e,color:t,variant:"soft",size:"sm",style:{marginLeft:6},testID:r})}var Sn={"storage-async":"STORAGE","storage-mmkv":"MMKV",redux:"REDUX",network:"NET","react-query":"QUERY","react-query-query":"QUERY","react-query-mutation":"MUTATION",route:"ROUTE",zustand:"ZUSTAND",jotai:"JOTAI",render:"RENDER"};function Oe({source:e,testID:t,children:r}){let a=gr[e].color,o=Sn[e];return hn(f,{style:Tt.badgeWrapper,testID:t,children:[r,V(f,{style:[Tt.sourceBadge,{backgroundColor:`${a}20`}],children:V(k,{style:[Tt.sourceBadgeText,{color:a}],testID:t?`${t}-badge`:void 0,children:o})})]})}var fr=cn(function({event:e,onPress:t,isSelected:r=false,isExpanded:a=false,onNavigate:o,correlationCount:n=1,correlationLabel:i,correlationColor:l}){let{StorageEventCard:s,getValueType:u,ReduxActionItem:c,NetworkEventItemCompact:d,RouteEventItemCompact:h,ZustandStateChangeItem:b,JotaiAtomChangeItem:v}=fn(),m=gr[e.source],y=yn(e.status),p=dr(e);if(bn(e.source)&&s&&u){let $=e.originalEvent,L={key:$.data?.key||"unknown",lastAction:$.action,totalOperations:1,lastEventTimestamp:new Date(e.timestamp),storageTypes:new Set([$.storageType||"async"]),valueType:$.data?.value!==void 0?u($.data.value):void 0};return V(Oe,{source:e.source,testID:p,children:V(s,{data:L,onPress:t,isSelected:r})})}if(e.source==="redux"&&c){let $=e.originalEvent;return V(Oe,{source:e.source,testID:p,children:V(c,{action:$,onPress:()=>t()})})}if(e.source==="network"&&d){let $=e.originalEvent;return V(f,{testID:p,children:V(d,{event:$,onPress:()=>t()})})}if(e.source==="route"&&h){let $=e.originalEvent;return V(Oe,{source:e.source,testID:p,children:V(h,{event:$,visitNumber:0,isExpanded:a,onPress:()=>t(),onNavigate:o})})}if(e.source==="zustand"&&b)return V(Oe,{source:e.source,testID:p,children:V(b,{change:e.originalEvent,onPress:()=>t()})});if(e.source==="jotai"&&v)return V(Oe,{source:e.source,testID:p,children:V(v,{change:e.originalEvent,onPress:()=>t()})});let g=i&&l?V(vn,{label:i,color:l,testID:`${p}-correlation`}):null;return V(dn,{statusDotColor:m.color,statusLabel:m.label,primaryText:e.title,secondaryText:e.subtitle,badgeText:n>1&&!i?`${n}`:"",badgeColor:l||y,customBadge:g,bottomRightText:pn(new Date(e.timestamp)),showChevron:true,isSelected:r,onPress:t,testID:p})}),Tt=le.create({badgeWrapper:{position:"relative"},sourceBadge:{position:"absolute",top:4,right:12,paddingHorizontal:6,paddingVertical:2,borderRadius:4,zIndex:10},sourceBadgeText:{fontSize:8,fontWeight:"700",letterSpacing:.5}});function Cn(e,t){return e.correlationId?t.filter(r=>r.correlationId===e.correlationId&&r.id!==e.id).sort((r,a)=>r.timestamp-a.timestamp):[]}function wn(e,t){return e.correlationId?t.some(r=>r.correlationId===e.correlationId&&r.id!==e.id):false}function En(e,t){return e.correlationId?t.filter(r=>r.correlationId===e.correlationId).length:1}function yr(e){let t=new Map;for(let r of e)if(r.correlationId){let a=t.get(r.correlationId)||0;t.set(r.correlationId,a+1)}return t}function br(e,t){return t.filter(r=>r.correlationId===e).sort((r,a)=>{let o=r.sequenceInGroup??0,n=a.sequenceInGroup??0;return o!==n?o-n:r.timestamp-a.timestamp})}function vr(e,t){if(!e.correlationId)return null;let r=br(e.correlationId,t);if(r.length<=1)return null;let a=r.findIndex(o=>o.id===e.id);return a===-1?null:`${a+1}/${r.length}`}var Sr=["#EC4899","#8B5CF6","#3B82F6","#10B981","#F59E0B","#EF4444","#06B6D4","#84CC16"];function Cr(e){let t=0;for(let a=0;a<e.length;a++)t=(t<<5)-t+e.charCodeAt(a),t|=0;let r=Math.abs(t)%Sr.length;return Sr[r]}import{jsx as Fe,jsxs as It}from"react/jsx-runtime";var At=on(function({events:e,selectedEventId:t,expandedEventId:r,onEventPress:a,onNavigate:o,isCapturing:n,hiddenEventsCount:i=0,onUpgradePress:l,searchText:s="",totalCount:u=0,sourceCount:c,enabledSourceCount:d}){let h=an(()=>yr(e),[e]),b=kt(({item:y})=>{let p=y.correlationId&&h.get(y.correlationId)||1,g=vr(y,e),$=y.correlationId?Cr(y.correlationId):void 0;return Fe(fr,{event:y,isSelected:y.id===t,isExpanded:y.id===r,onPress:()=>a(y),onNavigate:o,correlationCount:p,correlationLabel:g,correlationColor:$})},[t,r,a,o,h,e]),v=kt(y=>y.id,[]),m=kt(()=>i<=0?null:It(ge,{style:we.hiddenBanner,onPress:l,activeOpacity:.8,testID:`${S}-hidden-banner`,accessibilityRole:"button",accessibilityLabel:`${i} hidden event${i!==1?"s":""}, upgrade for the full history`,children:[It(f,{style:we.hiddenBannerLeft,children:[Fe(nn,{size:16,color:at.color.accent}),It(k,{style:we.hiddenBannerText,testID:`${S}-hidden-count`,children:[i," hidden event",i!==1?"s":""]})]}),Fe(sn,{})]}),[i,l]);if(e.length===0){let y=c===0,p=d===0,g=y?{otto:"scanning",title:"No Event Sources",message:`This tool reports on the other Buoy tools.
2
- Install one \u2014 network, storage, redux, routes \u2014 and its events land here.`}:p&&!s.trim()&&u>0?{otto:"filtering",title:"Every Source Is Off",message:`${u} event${u===1?" is":"s are"} captured. Turn a source chip back on to see them.`}:un({subject:"events",search:s,total:u,capturing:n,blocked:p?"Every source chip is off, so there is nothing to search. Turn one back on.":void 0,waiting:{otto:"listening",title:"No Events Yet",message:`Events will appear here as they occur.
3
- Try interacting with your app.`},paused:{title:"Not Capturing",message:"Event capture is paused. Resume to see events."}});return Fe(ln,{...g,testID:`${S}-empty`,style:we.emptyContainer})}return Fe(Gt,{data:e,renderItem:b,keyExtractor:v,testID:`${S}-list`,style:we.list,contentContainerStyle:we.listContent,ItemSeparatorComponent:()=>Fe(f,{style:we.separator}),ListFooterComponent:m,showsVerticalScrollIndicator:true,initialNumToRender:15,maxToRenderPerBatch:10,windowSize:10,removeClippedSubviews:!(typeof process<"u"&&process.env?.EXPO_PUBLIC_E2E)})}),we=le.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingVertical:16},separator:{height:8},emptyContainer:{flex:1,justifyContent:"center",backgroundColor:"transparent"},hiddenBanner:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginHorizontal:16,marginTop:8,marginBottom:16,paddingVertical:12,paddingHorizontal:16,backgroundColor:at.color.surface,borderRadius:8,borderWidth:1,borderColor:at.color.border},hiddenBannerLeft:{flexDirection:"row",alignItems:"center",gap:8},hiddenBannerText:{fontSize:13,fontWeight:"500",color:at.color.text}});import{loadToolModule as Ee,getToolModuleVersion as qt}from"@buoy-gg/shared-ui/web/utils";import{memo as xn,useMemo as wr}from"react";import{night as ce,formatRelativeTime as $n,copyToClipboard as kn,parseValue as Dn,useIgnoredPatterns as Tn,monoFont as In}from"@buoy-gg/shared-ui/web";import{DataViewer as An}from"@buoy-gg/shared-ui/web/dataViewer";import{memo as qn,useMemo as Bn}from"react";import{buoyColors as oe,night as M,displayValue as Fn,monoFont as Re}from"@buoy-gg/shared-ui/web";import{DataViewer as nt}from"@buoy-gg/shared-ui/web/dataViewer";import{jsx as T,jsxs as J}from"react/jsx-runtime";var Rn={"query-fetch-start":{label:"Query Fetching",color:M.color.accent,icon:"hourglass"},"query-fetch-success":{label:"Query Success",color:oe.success,icon:"checkmark"},"query-fetch-error":{label:"Query Error",color:oe.error,icon:"close"},"query-invalidated":{label:"Query Invalidated",color:oe.warning,icon:"refresh"},"mutation-start":{label:"Mutation Started",color:M.color.accent,icon:"hourglass"},"mutation-success":{label:"Mutation Success",color:oe.success,icon:"checkmark"},"mutation-error":{label:"Mutation Error",color:oe.error,icon:"close"}},Er=qn(function({event:e}){let t=e.originalEvent,r=Rn[t.type]||{label:t.type,color:M.color.textTertiary,icon:"help"},a=t.type.startsWith("query-"),o=t.type.startsWith("mutation-"),n=Bn(()=>{let c=a?t.queryKey:t.mutationKey;return c?Fn(c,true):o&&t.mutationId!==void 0?`Mutation #${t.mutationId}`:"No key"},[t,a,o]),i=new Date(t.timestamp).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:true}),l=a?!!t.queryData:!!t.mutationData,s=a?!!t.queryError:!!t.mutationError,u=o&&!!t.mutationVariables;return J(ue,{style:E.container,contentContainerStyle:E.contentContainer,children:[T(f,{style:E.section,children:J(f,{style:[E.eventTypeContainer,{borderColor:r.color+"4D"}],children:[T(k,{style:[E.eventTypeHeader,{backgroundColor:r.color+"15",color:r.color}],children:r.label}),J(f,{style:E.eventTypeContent,children:[J(f,{style:E.keyRow,children:[T(ue,{horizontal:true,style:E.keyScrollView,children:T(k,{style:E.keyText,children:n})}),T(jn,{type:t.type,color:r.color})]}),t.duration!==void 0&&J(f,{style:E.row,children:[T(k,{style:E.labelText,children:"Duration:"}),J(k,{style:E.valueText,children:[t.duration.toFixed(0),"ms"]})]}),J(f,{style:E.row,children:[T(k,{style:E.labelText,children:"Timestamp:"}),T(k,{style:E.valueText,children:i})]}),a&&t.queryHash&&J(f,{style:E.row,children:[T(k,{style:E.labelText,children:"Query Hash:"}),T(k,{style:[E.valueText,E.hashText],numberOfLines:1,children:t.queryHash})]}),o&&t.mutationId!==void 0&&J(f,{style:E.row,children:[T(k,{style:E.labelText,children:"Mutation ID:"}),J(k,{style:E.valueText,children:["#",t.mutationId]})]})]})]})}),u&&T(f,{style:E.section,children:J(f,{style:E.dataContainer,children:[T(k,{style:[E.dataHeader,{color:oe.warning}],children:"Variables"}),T(f,{style:E.dataContent,children:T(nt,{title:"",data:t.mutationVariables,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})}),l&&T(f,{style:E.section,children:J(f,{style:E.dataContainer,children:[T(k,{style:[E.dataHeader,{color:oe.success}],children:a?"Query Data":"Mutation Result"}),T(f,{style:E.dataContent,children:T(nt,{title:"",data:a?t.queryData:t.mutationData,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})}),s&&T(f,{style:E.section,children:J(f,{style:[E.dataContainer,E.errorContainer],children:[T(k,{style:[E.dataHeader,E.errorHeader],children:"Error"}),T(f,{style:E.dataContent,children:T(nt,{title:"",data:a?t.queryError:t.mutationError,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})}),T(f,{style:E.section,children:J(f,{style:E.dataContainer,children:[T(k,{style:E.dataHeader,children:"Event Details"}),T(f,{style:E.dataContent,children:T(nt,{title:"",data:t,showTypeFilter:true,rawMode:true,initialExpanded:false})})]})})]})});function jn({type:e,color:t}){let r=()=>e.includes("start")?"PENDING":e.includes("success")?"SUCCESS":e.includes("error")?"ERROR":e.includes("invalidated")?"INVALIDATED":e.toUpperCase();return T(f,{style:[E.statusChip,{backgroundColor:t+"15",borderColor:t+"33"}],children:T(k,{style:[E.statusChipText,{color:t}],children:r()})})}var E=le.create({container:{flex:1,backgroundColor:"transparent"},contentContainer:{padding:8,paddingBottom:24},section:{marginBottom:12},eventTypeContainer:{minWidth:200,backgroundColor:M.color.surface,borderRadius:6,borderWidth:1,overflow:"hidden",shadowColor:M.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},eventTypeHeader:{paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,borderBottomWidth:1,borderBottomColor:M.color.accentBorder,letterSpacing:.5,textTransform:"uppercase",fontFamily:Re},eventTypeContent:{padding:0},keyRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:M.color.separator},keyScrollView:{flex:1,marginRight:8},keyText:{fontSize:12,color:M.color.text,fontFamily:Re,lineHeight:18,backgroundColor:M.color.accentSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4,borderWidth:1,borderColor:M.color.accentBorderStrong},row:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:M.color.separator},labelText:{fontSize:10,color:M.color.textSecondary,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:Re},valueText:{fontSize:12,color:M.color.text,fontWeight:"500",fontVariant:["tabular-nums"],fontFamily:Re},hashText:{flex:1,textAlign:"right",marginLeft:8},statusChip:{paddingHorizontal:8,paddingVertical:4,borderWidth:1,borderRadius:6,alignSelf:"flex-start"},statusChipText:{fontSize:11,fontWeight:"600",textTransform:"uppercase",letterSpacing:.5,fontFamily:Re},dataContainer:{minWidth:200,backgroundColor:M.color.surface,borderRadius:6,borderWidth:1,borderColor:M.color.accentBorderStrong,overflow:"hidden",shadowColor:M.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},dataHeader:{backgroundColor:M.color.accentSoft,paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:M.color.accent,borderBottomWidth:1,borderBottomColor:M.color.accentBorder,letterSpacing:.5,textTransform:"uppercase",fontFamily:Re},dataContent:{padding:8},errorContainer:{borderColor:oe.error+"4D"},errorHeader:{backgroundColor:oe.error+"1A",color:oe.error,borderBottomColor:oe.error+"33"}});import{Fragment as zn,jsx as D,jsxs as Ue}from"react/jsx-runtime";function Mn(){let e={StorageEventDetailContent:null,ReduxActionDetailContent:null,NetworkEventDetailView:null,RenderDetailView:null,ZustandStateDetailContent:null,JotaiAtomDetailContent:null,RouteEventDetail:null};try{let t=Ee("@buoy-gg/storage");e.StorageEventDetailContent=t.StorageEventDetailContent}catch{}try{let t=Ee("@buoy-gg/redux");e.ReduxActionDetailContent=t.ReduxActionDetailContent}catch{}try{let t=Ee("@buoy-gg/network");e.NetworkEventDetailView=t.NetworkEventDetailView}catch{}try{let t=Ee("@buoy-gg/highlight-updates");e.RenderDetailView=t.RenderDetailView}catch{}try{let t=Ee("@buoy-gg/zustand");e.ZustandStateDetailContent=t.ZustandStateDetailContent}catch{}try{let t=Ee("@buoy-gg/jotai");e.JotaiAtomDetailContent=t.JotaiAtomDetailContent}catch{}try{let t=Ee("@buoy-gg/route-events");e.RouteEventDetail=t.RouteEventDetail}catch{}return e}var Bt,xr=-1;function Pn(){return(!Bt||xr!==qt())&&(Bt=Mn(),xr=qt()),Bt}var Nn={"storage-async":{label:"AsyncStorage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"React Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"}};function Vn(e){return e==="storage-async"||e==="storage-mmkv"}function On(e){let t=Dn(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 Un({children:e}){return D(zn,{children:e})}var Ft=xn(function({event:e,onBack:t,NetworkEventDetailViewComponent:r,networkDetailWrapper:a,RouteEventDetailComponent:o,detailComponents:n,onNavigate:i}){let l=wr(()=>({...Pn(),...n}),[n,qt()]),s=Nn[e.source],u=new Date(e.timestamp),{values:c,toggle:d}=Tn(),h=wr(()=>{if(!Vn(e.source)||!l.StorageEventDetailContent)return null;let p=e.originalEvent,g={...p,timestamp:new Date(p.timestamp)};return{key:g.data?.key||"unknown",lastEvent:g,events:[g],totalOperations:1,currentValue:g.data?.value,valueType:On(g.data?.value),storageTypes:new Set([g.storageType||"async"])}},[e,l]);if(h&&l.StorageEventDetailContent){let{StorageEventDetailContent:p}=l;return D(f,{style:B.container,testID:`${S}-detail-storage`,children:D(p,{conversation:h,selectedEventIndex:0,onEventIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="redux"&&l.ReduxActionDetailContent){let{ReduxActionDetailContent:p}=l,g=e.originalEvent;return D(f,{style:B.container,testID:`${S}-detail-redux`,children:D(p,{action:g,actions:[g],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}let b=r??l.NetworkEventDetailView;if(e.source==="network"&&b){let p=e.originalEvent,g=a??Un;return D(f,{style:B.container,children:D(g,{children:D(ue,{style:B.content,testID:`${S}-detail-network`,children:D(b,{event:p,ignoredPatterns:c,onTogglePattern:d})})})})}if(e.source==="react-query"||e.source==="react-query-query"||e.source==="react-query-mutation")return D(f,{style:B.container,testID:`${S}-detail-react-query`,children:D(Er,{event:e})});if(e.source==="zustand"&&l.ZustandStateDetailContent){let{ZustandStateDetailContent:p}=l,g=e.originalEvent;return D(f,{style:B.container,testID:`${S}-detail-zustand`,children:D(p,{change:g,changes:[g],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="jotai"&&l.JotaiAtomDetailContent){let{JotaiAtomDetailContent:p}=l,g=e.originalEvent;return D(f,{style:B.container,testID:`${S}-detail-jotai`,children:D(p,{change:g,changes:[g],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="render"&&l.RenderDetailView){let{RenderDetailView:p}=l,g=e.originalEvent;return D(f,{style:B.container,children:D(ue,{style:B.content,testID:`${S}-detail-render`,children:D(p,{render:g.render})})})}let v=o??l.RouteEventDetail;if(e.source==="route"&&v)return D(f,{style:B.container,children:D(f,{style:B.container,testID:`${S}-detail-route`,children:D(v,{event:e.originalEvent,onNavigate:i})})});let m=()=>e.originalEvent,y=async()=>{await kn({source:e.source,timestamp:u.toISOString(),title:e.title,subtitle:e.subtitle,data:m()})};return D(f,{style:B.container,testID:`${S}-detail`,children:Ue(ue,{style:B.content,contentContainerStyle:B.contentContainer,testID:`${S}-detail-scroll`,children:[D(f,{style:B.sourceBadgeRow,children:Ue(f,{style:[B.sourceBadge,{backgroundColor:s.color+"20"}],children:[D(f,{style:[B.sourceDot,{backgroundColor:s.color}]}),D(k,{style:[B.sourceLabel,{color:s.color}],testID:`${S}-detail-source`,children:s.label})]})}),D(k,{style:B.title,testID:`${S}-detail-title`,children:e.title}),D(k,{style:B.subtitle,testID:`${S}-detail-subtitle`,children:e.subtitle}),Ue(f,{style:B.timestampRow,children:[D(k,{style:B.timestampLabel,children:"Timestamp"}),Ue(k,{style:B.timestampValue,testID:`${S}-detail-timestamp`,children:[u.toLocaleTimeString()," (",$n(u),")"]})]}),Ue(f,{style:B.dataSection,children:[D(k,{style:B.sectionLabel,children:"Event Data"}),D(f,{style:B.dataContainer,testID:`${S}-detail-data`,children:D(An,{testIDPrefix:`${S}-detail-data`,data:m(),title:"",showTypeFilter:true,rawMode:true,initialExpanded:true})})]})]})})}),B=le.create({container:{flex:1,backgroundColor:"transparent"},content:{flex:1},contentContainer:{padding:16},sourceBadgeRow:{flexDirection:"row",marginBottom:12},sourceBadge:{flexDirection:"row",alignItems:"center",paddingHorizontal:10,paddingVertical:6,borderRadius:12,gap:6},sourceDot:{width:6,height:6,borderRadius:3},sourceLabel:{fontSize:12,fontWeight:"600"},title:{fontSize:24,fontWeight:"700",color:ce.color.text,marginBottom:4},subtitle:{fontSize:16,color:ce.color.textTertiary,marginBottom:16},timestampRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,borderTopWidth:1,borderTopColor:ce.color.border,borderBottomWidth:1,borderBottomColor:ce.color.border,marginBottom:16},timestampLabel:{fontSize:14,color:ce.color.textTertiary},timestampValue:{fontSize:14,color:ce.color.text,fontFamily:In},dataSection:{marginTop:8},sectionLabel:{fontSize:12,fontWeight:"600",color:ce.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8},dataContainer:{backgroundColor:ce.color.surface,borderRadius:8,borderWidth:1,borderColor:ce.color.border,overflow:"hidden"}});import{useCallback as je,useEffect as Ln,useMemo as it,useState as Rt}from"react";import{DynamicFilterView as $r,macOSColors as Le,night as He,FileText as kr,FileCode as Dr,Hash as Hn,Zap as Jn,AlertTriangle as Wn,Settings as Kn,Eye as _n,XCircle as Tr,GitBranch as Ir,ToolbarCopyButton as Qn,useFeatureGate as Gn,ProFeatureBanner as Zn,ExportPreview as Yn,monoFont as Xn}from"@buoy-gg/shared-ui/web";import{DataViewer as ei}from"@buoy-gg/shared-ui/web/dataViewer";var Je={timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:true,includeEventData:false,dataSizeThreshold:5,format:"markdown",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},We={llm:{timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:true,includeEventData:false,dataSizeThreshold:5,format:"markdown",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},bugReport:{timestampFormat:"both",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:true,includeEventData:true,dataSizeThreshold:10,format:"markdown",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},json:{timestampFormat:"absolute",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:false,includeTotalDuration:false,includeEventData:true,dataSizeThreshold:-1,format:"json",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:false,showStorageDiff:false,stripVerboseFields:false},errors:{timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:false,includeEventData:true,dataSizeThreshold:10,format:"markdown",filterMode:"errors",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},minimal:{timestampFormat:"relative",includeSource:false,includeStatus:true,includeTitle:true,includeSubtitle:false,includeCorrelation:false,includeDuration:false,includeSummaryHeader:false,includeTotalDuration:false,includeEventData:false,dataSizeThreshold:1,format:"plaintext",filterMode:"all",filterSources:[],compactMode:true,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:false,stripVerboseFields:true},mermaid:{timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:false,includeCorrelation:true,includeDuration:true,includeSummaryHeader:false,includeTotalDuration:false,includeEventData:false,dataSizeThreshold:1,format:"mermaid",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true}};function Ar(e){for(let[t,r]of Object.entries(We))if(Object.keys(r).every(a=>{let o=e[a],n=r[a];return Array.isArray(o)&&Array.isArray(n)?o.length===n.length&&o.every((i,l)=>i===n[l]):o===n}))return t;return null}var P={llm:{label:"LLM",description:"AI-ready format",color:"#10B981"},bugReport:{label:"Bug Report",description:"Full context",color:"#EF4444"},json:{label:"JSON",description:"Machine-readable",color:"#F59E0B"},errors:{label:"Errors",description:"Failed only",color:"#EF4444"},minimal:{label:"Minimal",description:"Quick reference",color:"#6B7280"},mermaid:{label:"Diagram",description:"Visual flow",color:"#A855F7"}};var ze={success:"\u2705",pending:"\u23F3",error:"\u274C",neutral:"\u2796"},ti={success:"[OK]",pending:"[...]",error:"[ERR]",neutral:"[-]"},jt={"storage-async":"Storage","storage-mmkv":"MMKV",redux:"Redux",network:"Network","react-query":"Query","react-query-query":"Query","react-query-mutation":"Mutation",route:"Route",zustand:"Zustand",jotai:"Jotai",render:"Render"};function xe(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}}function $e(e){if(e==null)return e;if(typeof e=="string")return xe(e);if(Array.isArray(e))return e.map($e);if(typeof e=="object"){let t={};for(let[r,a]of Object.entries(e))t[r]=$e(a);return t}return e}var ri=new Set(["image","imageUrl","imageURL","image_url","thumbnail","thumbnailUrl","thumbnail_url","icon","iconUrl","avatar","avatarUrl","photo","photoUrl","picture","pictureUrl","description","desc","longDescription","shortDescription","meta_description"]);function zt(e){if(e==null)return e;if(Array.isArray(e))return e.map(zt);if(typeof e=="object"){let t={};for(let[r,a]of Object.entries(e))ri.has(r)||typeof a=="string"&&oi(a)||(t[r]=zt(a));return t}return e}function oi(e){if(!e.startsWith("http"))return false;let t=e.toLowerCase();return t.includes("/photo")||t.includes("/image")||t.includes("unsplash.com")||t.includes("cloudinary.com")||t.includes("imgur.com")||/\.(jpg|jpeg|png|gif|webp|svg|bmp)(\?|$)/i.test(e)}function ai(e){if(e instanceof Date)return e.toISOString();if(!(e&&typeof e=="object"&&Object.keys(e).length===0))return e}function ni(e,t){let r=s=>{if(typeof s!="object"||s===null)return null;let u=s;return typeof u.id=="string"?u.id:typeof u.orderId=="string"?u.orderId:typeof u.key=="string"?u.key:null},a=new Set(e.map(r).filter(Boolean)),o=new Set(t.map(r).filter(Boolean));if(a.size===0&&o.size===0)return null;let n=t.filter(s=>{let u=r(s);return u&&!a.has(u)}),i=e.filter(s=>{let u=r(s);return u&&!o.has(u)}),l=t.length-n.length;return n.length+i.length<e.length&&n.length+i.length<t.length?{added:n,removed:i,unchanged:l}:null}function ii(e,t){let r={};if(e.action&&(r.action=e.action),e.storageType&&(r.storageType=e.storageType),e.timestamp!==void 0){let a=ai(e.timestamp);a!==void 0&&(r.timestamp=a)}if(e.data){let a={...e.data};if(t.smartJsonParsing&&(a.value!==void 0&&(a.value=xe(a.value)),a.prevValue!==void 0&&(a.prevValue=xe(a.prevValue))),t.showStorageDiff&&Array.isArray(a.value)&&Array.isArray(a.prevValue)){let o=ni(a.prevValue,a.value);if(o){let n={key:a.key};return o.added.length>0&&(n.added=o.added),o.removed.length>0&&(n.removed=o.removed),o.unchanged>0&&(n.unchangedCount=o.unchanged),r.data=n,r}}r.data=a}return r}function si(e,t){if(!t.reduxChangedOnly)return t.smartJsonParsing?$e(e):e;let r={};if(e.type&&(r.type=e.type),e.payload&&(r.payload=t.smartJsonParsing?$e(e.payload):e.payload),e.sliceName&&(r.sliceName=e.sliceName),e.actionName&&(r.actionName=e.actionName),e.duration&&(r.duration=e.duration),e.hasStateChange!==void 0&&(r.hasStateChange=e.hasStateChange),e.diffSummary&&(r.diffSummary=e.diffSummary),e.changedKeysCount!==void 0&&(r.changedKeysCount=e.changedKeysCount),e.hasStateChange===true){let a=e.sliceName;if(a&&e.prevState&&e.nextState){let o=e.prevState,n=e.nextState;(o[a]!==void 0||n[a]!==void 0)&&(r.stateChange={slice:a,before:o[a],after:n[a]})}}return r}function qr(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.name=="string"?t.name:typeof t.id=="string"?t.id:typeof t.key=="string"?t.key:null}function Ke(e,t){let r=typeof e=="string"?xe(e):e,a=typeof t=="string"?xe(t):t;if(r==null&&a!==null&&a!==void 0)return"Created";if(r!=null&&a==null)return"Deleted";if(Array.isArray(r)&&Array.isArray(a)){let o=r.length,n=a.length,i=r.map(qr).filter(Boolean),l=a.map(qr).filter(Boolean);if(o===n&&o>0){let s=new Set(i),u=new Set(l),c=i.filter(d=>u.has(d));if(c.length===0&&i.length>0&&l.length>0)return`\u26A0\uFE0F Replaced: [${i.join(", ")}] \u2192 [${l.join(", ")}]`;if(c.length<o){let d=i.filter(b=>!u.has(b)),h=l.filter(b=>!s.has(b));return`Changed: -${d.join(", ")} +${h.join(", ")}`}}if(o===0&&n>0)return l.length>0?`Added: [${l.join(", ")}]`:`Added ${n} item${n>1?"s":""}`;if(o>0&&n===0)return i.length>0?`Removed all: [${i.join(", ")}]`:`Removed all ${o} item${o>1?"s":""}`;if(n>o){let s=new Set(i),u=l.filter(c=>!s.has(c));return u.length>0?`Added: [${u.join(", ")}] (${o} \u2192 ${n})`:`Added ${n-o} item${n-o>1?"s":""} (${o} \u2192 ${n})`}if(n<o){let s=new Set(l),u=i.filter(c=>!s.has(c));return u.length>0?`Removed: [${u.join(", ")}] (${o} \u2192 ${n})`:`Removed ${o-n} item${o-n>1?"s":""} (${o} \u2192 ${n})`}return`Updated (${n} item${n>1?"s":""})`}if(typeof r=="object"&&typeof a=="object"&&r&&a){let o=Object.keys(r),n=Object.keys(a),i=n.filter(s=>!o.includes(s)),l=o.filter(s=>!n.includes(s));return i.length>0&&l.length>0?`+${i.length} -${l.length} keys`:i.length>0?`Added: ${i.join(", ")}`:l.length>0?`Removed: ${l.join(", ")}`:"Updated"}return null}function li(e,t){let r={};if(e.id&&(r.id=e.id),e.type&&(r.type=e.type),e.timestamp&&(r.timestamp=e.timestamp),e.queryKey&&(r.queryKey=e.queryKey),e.mutationKey&&(r.mutationKey=e.mutationKey),e.mutationId&&(r.mutationId=e.mutationId),e.duration&&(r.duration=e.duration),e.queryData!==void 0&&(r.data=t.smartJsonParsing?$e(e.queryData):e.queryData),e.variables!==void 0&&(r.variables=t.smartJsonParsing?$e(e.variables):e.variables),e.queryError!==void 0){let a=e.queryError;a&&typeof a=="object"?r.error=a.message||a.name||a:r.error=e.queryError}if(e.mutationError!==void 0){let a=e.mutationError;a&&typeof a=="object"?r.error=a.message||a.name||a:r.error=e.mutationError}if(e.query&&typeof e.query=="object"){let a=e.query;if(a.state&&typeof a.state=="object"){let o=a.state;if(o.status&&(r.status=o.status),o.fetchStatus&&(r.fetchStatus=o.fetchStatus),o.error){let n=o.error;n&&typeof n=="object"&&(r.error=n.message||n.name||n)}}}if(e.mutation&&typeof e.mutation=="object"){let a=e.mutation;if(a.state&&typeof a.state=="object"){let o=a.state;if(o.status&&(r.status=o.status),o.failureCount&&(r.failureCount=o.failureCount),o.error){let n=o.error;n&&typeof n=="object"&&(r.error=n.message||n.name||n)}if(o.failureReason){let n=o.failureReason;n&&typeof n=="object"&&(r.failureReason=n.message||n.name||n)}}}return r}function st(e,t){let r=e.originalEvent;if(!r)return null;let a;return e.source==="storage-async"||e.source==="storage-mmkv"?a=ii(r,t):e.source==="redux"?a=si(r,t):e.source==="react-query"||e.source==="react-query-query"||e.source==="react-query-mutation"?a=li(r,t):t.smartJsonParsing?a=$e(r):a=r,t.stripVerboseFields&&a&&(a=zt(a)),a}function _e(e){let t={totalEvents:e.length,success:0,pending:0,error:0,neutral:0,durationMs:0,sources:new Set};if(e.length===0)return t;let r=1/0,a=-1/0;for(let o of e)t[o.status]++,t.sources.add(o.source),o.timestamp<r&&(r=o.timestamp),o.timestamp>a&&(a=o.timestamp);return t.durationMs=a-r,t}function Qe(e,t){let r=[...e];if(t.filterMode!=="all"&&(r=r.filter(a=>{switch(t.filterMode){case"errors":return a.status==="error";case"success":return a.status==="success";case"pending":return a.status==="pending";default:return true}})),t.filterSources.length>0){let a=new Set(t.filterSources);r=r.filter(o=>a.has(o.source))}return r}function Mt(e){return e<1e3?`+${e}ms`:e<6e4?`+${(e/1e3).toFixed(1)}s`:`+${(e/6e4).toFixed(1)}m`}function Br(e){return new Date(e).toISOString()}function lt(e,t,r){let a=Mt(e-t),o=Br(e);switch(r){case"relative":return a;case"absolute":return o;case"both":return`${a} (${o})`}}function Pt(e,t){let r=0,a=[e],o=new Set;for(;a.length>0;){if(r>t)return{over:true,approxBytes:r};let n=a.pop();if(n==null)r+=4;else if(typeof n=="string")r+=n.length+2;else if(typeof n=="number")r+=8;else if(typeof n=="boolean")r+=5;else if(typeof n=="object"){if(o.has(n))continue;if(o.add(n),Array.isArray(n)){r+=2+n.length;for(let i=0;i<n.length;i++)a.push(n[i])}else{r+=2;for(let i in n)r+=i.length+4,a.push(n[i])}}else r+=4}return{over:r>t,approxBytes:r}}function ut(e,t){if(t===-1)return{data:e,truncated:false};let{over:r,approxBytes:a}=Pt(e,t*1024);if(r)return{data:`[Data truncated - \u2265${(a/1024).toFixed(1)}KB exceeds ${t}KB limit]`,truncated:true};try{return JSON.stringify(e),{data:e,truncated:false}}catch{return{data:"[Unable to serialize data]",truncated:true}}}function Fr(e,t){let r=0;for(let a of e)if(t.includeSource&&(r+=20),t.includeStatus&&(r+=10),t.includeTitle&&(r+=(a.title?.length||0)+10),t.includeSubtitle&&(r+=(a.subtitle?.length||0)+10),t.includeCorrelation&&(r+=20),t.includeDuration&&(r+=15),r+=30,t.includeEventData&&a.originalEvent){let o=t.dataSizeThreshold===-1?1048576:t.dataSizeThreshold*1024,{approxBytes:n}=Pt(a.originalEvent,o);r+=Math.min(n,o)}return t.includeSummaryHeader&&(r+=100),t.includeTotalDuration&&(r+=50),t.format==="markdown"&&(r*=1.2),t.format==="json"&&(r*=1.3),Math.round(r)}function ui(e,t,r){let a=[],o=lt(e.timestamp,t,r.timestampFormat);if(a.push(`\`${o}\``),r.includeStatus&&a.push(ze[e.status]),r.includeSource&&a.push(`**${jt[e.source]}**`),r.includeTitle&&a.push(e.title),r.showStorageDiff&&(e.source==="storage-async"||e.source==="storage-mmkv")){let n=e.originalEvent;if(n?.data){let i=n.data,l=Ke(i.prevValue,i.value);l&&a.push(`\u2192 ${l}`)}}return e.source==="redux"&&e.originalEvent?.hasStateChange===false&&a.push("(no state change)"),r.includeSubtitle&&e.subtitle&&a.push(`- ${e.subtitle}`),a.join(" ")}function ci(e,t){let r=[],a=e.originalEvent;if(!a?.data)return r;let o=a.data,n=t.smartJsonParsing?xe(o.prevValue):o.prevValue,i=t.smartJsonParsing?xe(o.value):o.value,l=Ke(o.prevValue,o.value);if(l&&r.push(` **Change:** ${l}`),Array.isArray(n)&&Array.isArray(i)){let s=n.map(c=>typeof c=="object"&&c&&"name"in c?c.name:null).filter(Boolean),u=i.map(c=>typeof c=="object"&&c&&"name"in c?c.name:null).filter(Boolean);(s.length>0||u.length>0)&&(s.length>0&&r.push(` Before: [${s.join(", ")}]`),r.push(` After: [${u.join(", ")}]`))}return r}function Nt(e,t){let r=Qe(e,t);if(r.length===0)return"No events to export.";let a=[...r].sort((s,u)=>s.timestamp-u.timestamp),o=a[0].timestamp,n=_e(a),i=[];if(i.push("## Event Flow"),t.includeSummaryHeader||t.includeTotalDuration){let s=[];if(t.includeTotalDuration&&s.push(`**Duration:** ${Mt(n.durationMs).replace("+","")}`),s.push(`**Events:** ${n.totalEvents}`),t.includeSummaryHeader){let u=[];n.success>0&&u.push(`${n.success} ${ze.success}`),n.pending>0&&u.push(`${n.pending} ${ze.pending}`),n.error>0&&u.push(`${n.error} ${ze.error}`),n.neutral>0&&u.push(`${n.neutral} ${ze.neutral}`),u.length>0&&s.push(`**Status:** ${u.join(" ")}`)}i.push(s.join(" | "))}if(i.push(""),i.push("### Timeline"),i.push(""),t.compactMode)return a.forEach((s,u)=>{i.push(`${u+1}. ${ui(s,o,t)}`)}),i.join(`
4
- `);a.forEach((s,u)=>{let c=[],d=lt(s.timestamp,o,t.timestampFormat);if(c.push(`${u+1}. \`${d}\``),t.includeStatus&&c.push(ze[s.status]),t.includeSource&&c.push(`**${jt[s.source]}**`),t.includeTitle&&c.push(s.title),t.includeCorrelation&&s.correlationId&&s.sequenceInGroup&&c.push(`(${s.sequenceInGroup})`),i.push(c.join(" ")),t.includeSubtitle&&s.subtitle&&i.push(` \u2514\u2500 ${s.subtitle}`),t.showStorageDiff&&!t.includeEventData&&(s.source==="storage-async"||s.source==="storage-mmkv")){let h=ci(s,t);i.push(...h)}if(t.includeEventData&&s.originalEvent){let h=st(s,t),{data:b,truncated:v}=ut(h,t.dataSizeThreshold);if(v)i.push(` \u2514\u2500 ${b}`);else{if(t.showStorageDiff&&(s.source==="storage-async"||s.source==="storage-mmkv")){let m=s.originalEvent;if(m?.data){let y=m.data,p=Ke(y.prevValue,y.value);p&&i.push(` **Change:** ${p}`)}}i.push(" ```json"),i.push(` ${JSON.stringify(b,null,2).split(`
1
+ "use client";var Qt=Object.defineProperty;var Zr=Object.getOwnPropertyDescriptor;var Yr=Object.getOwnPropertyNames;var Xr=Object.prototype.hasOwnProperty;var eo=(e,t)=>{for(var r in t)Qt(e,r,{get:t[r],enumerable:true})},Gt=(e,t,r,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Yr(t))!Xr.call(e,o)&&o!==r&&Qt(e,o,{get:()=>t[o],enumerable:!(a=Zr(t,o))||a.enumerable});return e},to=(e,t,r)=>(Gt(e,t,"default"),r&&Gt(r,t,"default"));var Qi=(()=>{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{EventsIcon as ro,EVENTS_ICON_COLOR as oo}from"@buoy-gg/floating-tools-core/web";var Zt={};eo(Zt,{AccessibilityInfo:()=>so,ActivityIndicator:()=>ra,Alert:()=>Xt,Animated:()=>lo,AppRegistry:()=>co,AppState:()=>po,Appearance:()=>uo,BackHandler:()=>mo,Button:()=>oa,CheckBox:()=>Io,Clipboard:()=>ho,DeviceEventEmitter:()=>Ho,Dimensions:()=>go,Easing:()=>fo,FlatList:()=>Yt,I18nManager:()=>yo,Image:()=>Ao,ImageBackground:()=>qo,InteractionManager:()=>vo,Keyboard:()=>bo,KeyboardAvoidingView:()=>Fo,LayoutAnimation:()=>So,Linking:()=>Co,LogBox:()=>Lo,Modal:()=>ea,NativeEventEmitter:()=>wo,NativeModules:()=>io,PanResponder:()=>Eo,Picker:()=>Bo,PixelRatio:()=>xo,Platform:()=>ko,Pressable:()=>Xo,ProgressBar:()=>Ro,RefreshControl:()=>jo,SafeAreaView:()=>zo,ScrollView:()=>ue,SectionList:()=>Mo,Share:()=>$o,StatusBar:()=>Po,StyleSheet:()=>le,Switch:()=>ta,Text:()=>$,TextInput:()=>Go,Touchable:()=>No,TouchableHighlight:()=>Zo,TouchableNativeFeedback:()=>Vo,TouchableOpacity:()=>ge,TouchableWithoutFeedback:()=>Yo,UIManager:()=>Do,Vibration:()=>To,View:()=>f,VirtualizedList:()=>Oo,YellowBox:()=>Uo,findNodeHandle:()=>aa,unstable_createElement:()=>no,useColorScheme:()=>Jo,useLocaleContext:()=>Wo,useWindowDimensions:()=>Ko});to(Zt,ao);import*as ao from"react-native-web";import{unstable_createElement as no,NativeModules as io,AccessibilityInfo as so,Animated as lo,Appearance as uo,AppRegistry as co,AppState as po,BackHandler as mo,Clipboard as ho,Dimensions as go,Easing as fo,I18nManager as yo,Keyboard as bo,InteractionManager as vo,LayoutAnimation as So,Linking as Co,NativeEventEmitter as wo,PanResponder as Eo,PixelRatio as xo,Platform as ko,Share as $o,StyleSheet as le,UIManager as Do,Vibration as To,CheckBox as Io,FlatList as Yt,Image as Ao,ImageBackground as qo,KeyboardAvoidingView as Fo,Picker as Bo,ProgressBar as Ro,RefreshControl as jo,SafeAreaView as zo,SectionList as Mo,StatusBar as Po,Touchable as No,TouchableNativeFeedback as Vo,VirtualizedList as Oo,YellowBox as Uo,LogBox as Lo,DeviceEventEmitter as Ho,useColorScheme as Jo,useLocaleContext as Wo,useWindowDimensions as Ko}from"react-native-web";import*as W from"react-native-web";import{createElement as _o,forwardRef as Qo}from"react";function Y(e){let t=Qo((a,o)=>{let{accessibilityState:n,accessibilityValue:i,...l}=a;for(let s of["busy","checked","disabled","expanded","selected"])n?.[s]!==void 0&&l[`aria-${s}`]===void 0&&(l[`aria-${s}`]=n[s]);for(let[s,u]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[s]!==void 0&&l[`aria-${u}`]===void 0&&(l[`aria-${u}`]=i[s]);return _o(e,{...l,ref:o})}),r=e.State;return r&&Object.assign(t,{State:r}),t.displayName=e.displayName??e.name??"NativeWebView",t}var f=Y(W.View),$=Y(W.Text),Go=Y(W.TextInput),ge=Y(W.TouchableOpacity),Zo=Y(W.TouchableHighlight),Yo=Y(W.TouchableWithoutFeedback),Xo=Y(W.Pressable),ue=Y(W.ScrollView),ea=Y(W.Modal),ta=Y(W.Switch),ra=Y(W.ActivityIndicator),oa=Y(W.Button),aa=W.findNodeHandle,Xt={alert(e,t,r,a){if(typeof document>"u")return;let o=document.createElement("dialog");o.dataset.buoyRoot="",o.setAttribute("aria-label",e),o.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 n=document.createElement("h2");if(n.textContent=e,n.style.cssText="font-size:18px;margin:0 0 12px",o.appendChild(n),t){let u=document.createElement("p");u.textContent=t,u.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",o.appendChild(u)}let i=document.createElement("div");i.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let l=r?.length?r:[{text:"OK"}],s=()=>{o.close?.(),o.remove()};for(let u of l){let c=document.createElement("button");c.type="button",c.textContent=u.text??"OK",c.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${u.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,c.onclick=()=>{s(),u.onPress?.()},i.appendChild(c)}o.addEventListener("cancel",u=>{u.preventDefault(),a?.cancelable!==false&&(s(),a?.onDismiss?.())}),o.appendChild(i),document.body.appendChild(o),o.showModal?o.showModal():o.setAttribute("open","")}};import{useState as ot,useCallback as Ae,useEffect as na,useRef as ia}from"react";import{JsModal as sa,ModalHeader as X,buoyColors as la,night as ee,Trash2 as ua,Copy as ca,Search as da,devToolsStorageKeys as pa,ToolbarCopyButton as ma,UpgradeModal as ha,PowerToggleButton as ga,useSafeRouter as fa,windowDragProps as ya}from"@buoy-gg/shared-ui/web";import{useState as fe,useEffect as ye,useCallback as be,useMemo as ve,useRef as bt}from"react";import{useFeatureGate as ba,subscribeToSubscriberCountChanges as va,useIgnoredPatterns as Sa,useLimit as Ca}from"@buoy-gg/shared-ui/web";import{loadToolModule as K,getToolModuleVersion as er}from"@buoy-gg/shared-ui/web/utils";var wa=0;function ce(e){return`${e}-${Date.now()}-${++wa}`}function Ea(){try{let{storageEventStore:e}=K("@buoy-gg/storage");return{id:"storage",name:"Storage",eventSources:["storage-async","storage-mmkv"],available:true,subscribe:t=>e.onEvent(r=>{if(r?.data?.initialScan)return;let a=xa(r);t(a)})}}catch{return null}}function xa(e){let t=e,r=t.storageType==="async"?"storage-async":"storage-mmkv",a=t.action;t.storageType==="async"&&(a={setItem:"Set Item",removeItem:"Remove Item",mergeItem:"Merge Item",clear:"Clear All",multiSet:"Multi Set",multiRemove:"Multi Remove",multiMerge:"Multi Merge"}[t.action]||t.action);let o="";if(t.storageType==="async")switch(t.action){case"setItem":case"removeItem":case"mergeItem":o=t.data?.key||"unknown key";break;case"multiSet":case"multiMerge":{let i=t.data?.pairs?.length||0;o=`${i} key${i!==1?"s":""}`;break}case"multiRemove":{let i=t.data?.keys?.length||0;o=`${i} key${i!==1?"s":""}`;break}case"clear":o="all keys";break}else o=t.data?.key||t.data?.instanceId||"unknown";let n="neutral";return(t.action.includes("set")||t.action.includes("Set")||t.action.includes("merge")||t.action.includes("Merge"))&&(n="success"),{id:ce(r),source:r,timestamp:t.timestamp.getTime(),title:a,subtitle:o,status:n,originalEvent:e}}function ka(){try{let{reduxActionStore:e}=K("@buoy-gg/redux"),t=null;return{id:"redux",name:"Redux",eventSources:["redux"],available:true,subscribe:r=>e.subscribe(a=>{if(a.length>0){let o=a[0];if(o.id!==t){t=o.id;let n=$a(o);r(n)}}})}}catch{return null}}function $a(e){let t=e,r="neutral";switch(t.category){case"fulfilled":r="success";break;case"rejected":r="error";break;case"pending":r="pending";break;default:r=t.hasStateChange?"success":"neutral"}let a="";return t.payloadPreview?a=t.payloadPreview:t.hasStateChange&&t.diffSummary?a=t.diffSummary:t.duration!==void 0?a=`${t.duration.toFixed(1)}ms`:a=t.sliceName||"",{id:ce("redux"),source:"redux",timestamp:t.timestamp,title:t.type,subtitle:a,status:r,originalEvent:e}}function Da(){try{let{networkEventStore:e,networkListener:t,addNetworkListener:r}=K("@buoy-gg/network"),a=new Map;return{id:"network",name:"Network",eventSources:["network"],available:true,setup:()=>{let o=t();o.isActive||o.startListening(),o.listenerCount===0&&r(n=>{e.processNetworkEvent(n)})},subscribe:o=>{let n=Date.now();return e.onEvent(i=>{let l=i,s=a.get(l.id);if(s){let u=tr(i);u.id=s,o(u)}else{if(typeof l.timestamp=="number"&&l.timestamp<n)return;let u=tr(i);a.set(l.id,u.id),o(u)}},false)}}}catch{return null}}function tr(e){let t=e,r="neutral";t.status===void 0?r="pending":t.error||t.status>=400?r="error":t.status>=200&&t.status<400&&(r="success");let a=t.operationName||`${t.method} ${t.path||t.url}`,o=[];return t.status!==void 0?o.push(`${t.status}`):t.error?o.push("Error"):o.push("Pending"),t.duration!==void 0&&o.push(`${t.duration.toFixed(0)}ms`),t.host&&o.push(t.host),{id:ce("network"),source:"network",timestamp:t.timestamp,title:a,subtitle:o.join(" \xB7 "),status:r,originalEvent:e}}function Ta(){try{let{reactQueryEventStore:e}=K("@buoy-gg/react-query"),t=null;return{id:"react-query",name:"React Query",eventSources:["react-query","react-query-query","react-query-mutation"],available:true,subscribe:r=>{let a=true,o=new Set,n=i=>i.queryHash??(i.mutationId!==void 0?`m-${i.mutationId}`:null);return e.subscribe(i=>{if(a){a=false,i.length>0&&(t=i[0].id);return}if(i.length>0){let l=i[0];if(l.id!==t){t=l.id;let s=l.type??"",u=n(l);if(s==="query-fetch-start"||s==="mutation-start")u&&o.add(u);else if((s==="query-fetch-success"||s==="query-fetch-error"||s==="mutation-success"||s==="mutation-error")&&u&&!o.has(u))return;let c=Ia(l);r(c)}}})}}}catch{return null}}function rr(e){return!e||e.length===0?"unknown":e.map(t=>{if(typeof t=="string")return t;if(typeof t=="number")return String(t);if(typeof t=="object"&&t!==null){let r=Object.values(t)[0];return typeof r=="string"||typeof r=="number"?String(r):JSON.stringify(t).slice(0,20)}return String(t)}).join(" \u203A ")}function Ia(e){let t=e,r=t.type.startsWith("mutation-")?"react-query-mutation":"react-query-query",a="neutral";switch(t.type){case"query-fetch-start":case"mutation-start":a="pending";break;case"query-fetch-success":case"mutation-success":a="success";break;case"query-fetch-error":case"mutation-error":a="error";break}let o="";t.queryKey?o=rr(t.queryKey):t.mutationKey?o=rr(t.mutationKey):t.mutationId!==void 0?o=`Mutation #${t.mutationId}`:o=t.type.replace(/-/g," ");let n=[];switch(t.type){case"query-fetch-start":n.push("Fetching");break;case"query-fetch-success":n.push("Success");break;case"query-fetch-error":n.push("Error");break;case"query-invalidated":n.push("Invalidated");break;case"mutation-start":n.push("Mutating");break;case"mutation-success":n.push("Success");break;case"mutation-error":n.push("Error");break}t.duration!==void 0&&n.push(`${t.duration.toFixed(0)}ms`);let i;t.queryHash?i=`rq-query-${t.queryHash}`:t.mutationId!==void 0&&(i=`rq-mutation-${t.mutationId}`);let l=1;switch(t.type){case"query-fetch-start":case"mutation-start":l=1;break;case"query-fetch-success":case"query-fetch-error":case"mutation-success":case"mutation-error":l=2;break;case"query-invalidated":l=3;break}return{id:ce(r),source:r,timestamp:t.timestamp,title:o,subtitle:n.join(" \xB7 "),status:a,originalEvent:e,correlationId:i,sequenceInGroup:l}}function Aa(){try{let{routeEventStore:e}=K("@buoy-gg/route-events");return{id:"route-events",name:"Routes",eventSources:["route"],available:true,subscribe:t=>e.onEvent(r=>{let a=qa(r);t(a)})}}catch{return null}}function qa(e){let t=e,r="neutral";(t.pathname==="/"||Object.keys(t.params).length>0)&&(r="success");let a=[],o=Object.keys(t.params).length;return o>0&&a.push(`${o} param${o!==1?"s":""}`),t.timeSincePrevious!==void 0&&t.timeSincePrevious>0&&(t.timeSincePrevious<1e3?a.push(`${t.timeSincePrevious}ms`):a.push(`${(t.timeSincePrevious/1e3).toFixed(1)}s`)),t.previousPathname&&t.previousPathname!==t.pathname&&a.push(`from ${t.previousPathname}`),{id:ce("route"),source:"route",timestamp:t.timestamp,title:t.pathname||"/",subtitle:a.join(" \xB7 ")||"navigation",status:r,originalEvent:e}}function Fa(){try{let{zustandStateStore:e}=K("@buoy-gg/zustand"),t=null;return{id:"zustand",name:"Zustand",eventSources:["zustand"],available:true,subscribe:r=>e.subscribe(a=>{if(a.length>0){let o=a[0];if(o.id!==t){t=o.id;let n=Ba(o);r(n)}}})}}catch{return null}}function Ba(e){let t=e,r="neutral";t.isSlowUpdate?r="pending":t.hasStateChange&&(r="success");let a=[];if(t.changedKeys&&t.changedKeys.length>0){let o=t.changedKeys.slice(0,3).join(", "),n=t.changedKeys.length>3?` +${t.changedKeys.length-3}`:"";a.push(`${o}${n}`)}else t.diffSummary&&a.push(t.diffSummary);return t.duration!==void 0&&a.push(`${t.duration.toFixed(1)}ms`),t.category==="replace"&&a.push("replace"),{id:ce("zustand"),source:"zustand",timestamp:t.timestamp,title:t.storeName,subtitle:a.join(" \xB7 ")||(t.hasStateChange?"state changed":"no change"),status:r,originalEvent:e}}function Ra(){try{let{jotaiStateStore:e}=K("@buoy-gg/jotai"),t=null;return{id:"jotai",name:"Jotai",eventSources:["jotai"],available:true,subscribe:r=>e.subscribe(a=>{if(a.length>0){let o=a[0];if(o.id!==t){t=o.id;let n=ja(o);r(n)}}})}}catch{return null}}function ja(e){let t=e,r="neutral";t.category==="write"&&t.hasValueChange?r="success":t.category==="read"&&(r="neutral");let a=[];return t.valuePreview?a.push(t.valuePreview):t.diffSummary&&a.push(t.diffSummary),t.category&&a.push(t.category),{id:ce("jotai"),source:"jotai",timestamp:t.timestamp,title:t.atomLabel,subtitle:a.join(" \xB7 ")||(t.hasValueChange?"value changed":"no change"),status:r,originalEvent:e}}function za(){let e;try{e=K("@buoy-gg/highlight-updates")}catch{return null}try{if(!e.RenderTracker||!e.HighlightUpdatesController)return null;let{RenderTracker:t,HighlightUpdatesController:r}=e;return{id:"render",name:"Render",eventSources:["render"],available:true,setup:()=>{r&&r.enableBackgroundTracking()},subscribe:a=>{r&&!r.isBackgroundTrackingEnabled()&&r.enableBackgroundTracking();let o=t.onRenderEvent((n,i)=>{let l=Ma(n,i);a(l)});return()=>{o(),r.disableBackgroundTracking()}}}}catch{return null}}function Ma(e,t){let r=e,a=t,o=a.componentName||a.displayName||a.viewType,n=[],i={mount:"mounted",props:"props changed",state:"state changed",hooks:"hooks changed",context:"context changed",parent:"parent re-rendered",unknown:"re-rendered"};if(n.push(i[r.cause.type]||r.cause.type),r.cause.type==="props"&&r.cause.changedKeys?.length){let s=r.cause.changedKeys.slice(0,3).join(", "),u=r.cause.changedKeys.length>3?` +${r.cause.changedKeys.length-3}`:"";n.push(`[${s}${u}]`)}if(r.cause.hookChanges?.length){let s=r.cause.hookChanges[0];s.description&&n.push(s.description)}n.push(`#${r.renderNumber}`);let l="neutral";switch(r.cause.type){case"mount":l="neutral";break;case"props":case"state":case"hooks":case"context":l="success";break;case"parent":l="pending";break;default:l="neutral"}return{id:ce("render"),source:"render",timestamp:r.timestamp,title:o,subtitle:n.join(" \xB7 "),status:l,originalEvent:{event:r,render:a}}}var Pa=new Set(["CapacitorHttp","CapacitorCookies","Console","WebView"]),vt=/token|secret|password|passwd|auth|credential|api[-_]?key|session|cookie/i;function at(e,t=false,r=0){if(!e||typeof e!="object"||r>4)return e;if(Array.isArray(e))return e.map(i=>at(i,t,r+1));let a={},o=e,n=t||typeof o.key=="string"&&vt.test(o.key);for(let[i,l]of Object.entries(o))(vt.test(i)||n&&i==="value")&&l!=null&&l!==""?a[i]="[hidden]":a[i]=at(l,false,r+1);return a}function Na(){try{let e=K("@buoy-gg/license");return typeof e?.subscribeCapacitorCalls!="function"||!e.isCapacitorBridgeInstalled?.()?null:{id:"capacitor",name:"Capacitor",eventSources:["capacitor"],available:true,subscribe:t=>{let r=new Set,a=0,o=()=>{let i=e.getCapacitorCalls();for(let s of i){if(s.seq<=a||r.has(s.seq))continue;if(Pa.has(s.plugin)){r.add(s.seq);continue}(s.end!==void 0||s.kind==="event"||s.method==="addListener")&&(r.add(s.seq),t(Va(s)))}let l=i[0]?.seq??0;if(l>a+1){a=l-1;for(let s of Array.from(r))s<=a&&r.delete(s)}},n=e.getCapacitorCalls();return a=n.length?n[n.length-1].seq:0,e.subscribeCapacitorCalls(o)}}}catch{return null}}function Va(e){let t=[];if(e.kind==="event"?t.push("event"):e.method==="addListener"&&t.push(`listening for ${String(e.options.eventName??"events")}`),e.end!==void 0&&e.kind!=="event"&&t.push(`${Math.max(0,e.end-e.start)}ms`),e.answeredByBuoy&&t.push("answered by Buoy"),e.ok===false){let r=e.error?.message;t.push(typeof r=="string"?r:"failed")}return{id:ce("capacitor"),source:"capacitor",timestamp:e.kind==="event"?e.start:e.end??e.start,title:`${e.plugin}.${e.method}`,subtitle:t.join(" \xB7 ")||"call",status:e.ok===false?"error":e.kind==="event"?"neutral":"success",originalEvent:{plugin:e.plugin,method:e.method,kind:e.kind,options:at(e.options),result:at(e.result,typeof e.options.key=="string"&&vt.test(e.options.key)),error:e.error,durationMs:e.end!==void 0?e.end-e.start:void 0,answeredByBuoy:e.answeredByBuoy??false}}}function Oa(){let e=[],t=new Set,r=[Ea,ka,Da,Ta,Aa,Fa,Ra,za,Na];for(let a of r){let o=a();o&&o.available&&(e.push(o),o.eventSources.forEach(n=>t.add(n)))}return{sources:e,availableEventSources:t}}function Ua(e){return{"storage-async":{label:"Storage",color:"#8B5CF6",icon:"server-outline"},"storage-mmkv":{label:"MMKV",color:"#F59E0B",icon:"flash-outline"},redux:{label:"Redux",color:"#3B82F6",icon:"git-branch-outline"},network:{label:"Network",color:"#10B981",icon:"globe-outline"},"react-query":{label:"Query",color:"#EC4899",icon:"sync-outline"},"react-query-query":{label:"Query",color:"#EC4899",icon:"sync-outline"},"react-query-mutation":{label:"Mutation",color:"#F97316",icon:"flash-outline"},route:{label:"Route",color:"#06B6D4",icon:"navigate-outline"},zustand:{label:"Zustand",color:"#764ABC",icon:"cube-outline"},jotai:{label:"Jotai",color:"#14B8A6",icon:"ellipse-outline"},render:{label:"Render",color:"#F472B6",icon:"layers-outline"},capacitor:{label:"Capacitor",color:"#119EFF",icon:"hardware-chip-outline"}}[e]||{label:e,color:"#6B7280",icon:"help-outline"}}var St=null,or=-1;function H(){return(!St||or!==er())&&(or=er(),St=Oa()),St}function La(){let e=[],t=0;try{let{storageEventStore:r}=K("@buoy-gg/storage"),a=r.getSubscriberCounts();e.push({sourceId:"storage",counts:a}),t+=a.total}catch{}try{let{networkEventStore:r}=K("@buoy-gg/network"),a=r.getSubscriberCounts();e.push({sourceId:"network",counts:a}),t+=a.total}catch{}try{let{routeEventStore:r}=K("@buoy-gg/route-events"),a=r.getSubscriberCounts();e.push({sourceId:"route-events",counts:a}),t+=a.total}catch{}try{let{RenderTracker:r,HighlightUpdatesController:a}=K("@buoy-gg/highlight-updates"),o=r.getRenderEventCallbackCount(),n=a?.isEnabled?.()?1:0,i={eventCallbacks:o,arrayListeners:n,total:o+n};e.push({sourceId:"render",counts:i}),t+=i.total}catch{}return{sources:e,totalSubscribers:t}}import{ChangeLog as Ha}from"@buoy-gg/shared-ui/web";var Ct={"storage-async":"storage","storage-mmkv":"storage",redux:"redux",network:"network","react-query":"react-query","react-query-query":"react-query","react-query-mutation":"react-query",route:"route-events",zustand:"zustand",jotai:"jotai",render:"render",capacitor:"capacitor"};var Ja=200,ar=new Set(["render"]),Wa=class extends Ha{constructor(){super({max:Ja});this.activeSources=new Set;this.remoteAvailableSources=null;this.sourceUnsubscribers=new Map;this.remoteDiscoveryIds=new Set;this.localDiscoveryIds=new Set;this.localSyncChain=Promise.resolve();this.networkEventIdMap=new Map}getDiscoveredSources(){return H().sources}getAvailableEventSources(){return this.remoteAvailableSources?this.remoteAvailableSources:H().availableEventSources}setRemoteAvailableSources(e){let t=e?new Set(e):null,r=this.remoteAvailableSources,a=r===null&&t===null||!!r&&!!t&&r.size===t.size&&[...t].every(o=>r.has(o));this.remoteAvailableSources=t,a||this.notifyListeners()}replaceEvents(e){this.activeSources=new Set(e.map(t=>t.source)),this.setItems(e)}async subscribeToAll(){let{sources:e}=H();for(let t of e)ar.has(t.id)||await this.subscribeToSource(t)}async subscribeToSource(e){let t=this.sourceUnsubscribers.get(e.id);if(t){t.refCount++;return}let r={unsubscribe:()=>{},refCount:1};this.sourceUnsubscribers.set(e.id,r);try{e.setup&&await e.setup();let a=await e.subscribe(o=>{this.addEvent(o)});a&&(r.unsubscribe=a)}catch{this.sourceUnsubscribers.get(e.id)===r&&r.refCount<=1&&this.sourceUnsubscribers.delete(e.id)}}unsubscribeFromSource(e){let t=this.sourceUnsubscribers.get(e);t&&(t.refCount--,t.refCount<=0&&(t.unsubscribe(),this.sourceUnsubscribers.delete(e)))}async subscribeToStorage(){let{sources:e}=H(),t=e.find(r=>r.id==="storage");t&&await this.subscribeToSource(t)}unsubscribeFromStorage(){this.unsubscribeFromSource("storage"),this.activeSources.delete("storage-async"),this.activeSources.delete("storage-mmkv")}subscribeToRedux(){let{sources:e}=H(),t=e.find(r=>r.id==="redux");t&&this.subscribeToSource(t)}unsubscribeFromRedux(){this.unsubscribeFromSource("redux"),this.activeSources.delete("redux")}subscribeToNetwork(){let{sources:e}=H(),t=e.find(r=>r.id==="network");t&&this.subscribeToSource(t)}unsubscribeFromNetwork(){this.unsubscribeFromSource("network"),this.activeSources.delete("network")}subscribeToReactQuery(){let{sources:e}=H(),t=e.find(r=>r.id==="react-query");t&&this.subscribeToSource(t)}unsubscribeFromReactQuery(){this.unsubscribeFromSource("react-query"),this.activeSources.delete("react-query"),this.activeSources.delete("react-query-query"),this.activeSources.delete("react-query-mutation")}subscribeToRoutes(){let{sources:e}=H(),t=e.find(r=>r.id==="route-events");t&&this.subscribeToSource(t)}unsubscribeFromRoutes(){this.unsubscribeFromSource("route-events"),this.activeSources.delete("route")}subscribeToZustand(){let{sources:e}=H(),t=e.find(r=>r.id==="zustand");t&&this.subscribeToSource(t)}unsubscribeFromZustand(){this.unsubscribeFromSource("zustand"),this.activeSources.delete("zustand")}subscribeToJotai(){let{sources:e}=H(),t=e.find(r=>r.id==="jotai");t&&this.subscribeToSource(t)}unsubscribeFromJotai(){this.unsubscribeFromSource("jotai"),this.activeSources.delete("jotai")}subscribeToRender(){let{sources:e}=H(),t=e.find(r=>r.id==="render");t&&this.subscribeToSource(t)}unsubscribeFromRender(){this.unsubscribeFromSource("render"),this.activeSources.delete("render")}addEvent(e){if(e.source==="network"){let t=e.originalEvent;if(t?.id){let r=this.networkEventIdMap.get(t.id);if(r){let a=this.items.findIndex(o=>o.id===r);if(a>=0){e.id=r,this.items=[...this.items.slice(0,a),e,...this.items.slice(a+1)],this.notifyListeners();return}}this.networkEventIdMap.set(t.id,e.id)}}this.push(e),this.activeSources.add(e.source),this.notifyListeners()}getEvents(e){return!e||e.size===0?this.items:this.items.filter(t=>e.has(t.source))}getActiveSources(){return Array.from(this.activeSources)}getSourceCounts(){let e={"storage-async":0,"storage-mmkv":0,redux:0,network:0,"react-query":0,"react-query-query":0,"react-query-mutation":0,route:0,zustand:0,jotai:0,render:0,capacitor:0};for(let t of this.items)e[t.source]++;return e}clearEvents(){this.activeSources.clear(),this.networkEventIdMap.clear(),this.clear()}subscribe(e){let t=super.subscribe(e);return e(this.items),t}getEventCount(){return this.items.length}unsubscribeAll(){for(let[,e]of this.sourceUnsubscribers)e.unsubscribe();this.sourceUnsubscribers.clear(),this.activeSources.clear(),this.remoteDiscoveryIds.clear(),this.localDiscoveryIds.clear()}watch(e,t,r=Date.now()){let a=new Set(e),o=new Set;for(let u of e){let c=Ct[u];c&&o.add(c)}let{sources:n}=H(),i=[];for(let u of o){let c=n.find(d=>d.id===u);c&&(i.push(u),this.subscribeToSource(c))}let l=false,s=this.subscribe(u=>{l||t(u.filter(c=>c.timestamp>=r&&a.has(c.source)))});return()=>{if(!l){l=true,s();for(let u of i)this.unsubscribeFromSource(u)}}}setLocalEnabledSources(e){let t=async()=>{let r=new Set;for(let n of e){let i=Ct[n];i&&r.add(i)}let a=this.localDiscoveryIds;this.localDiscoveryIds=r;let{sources:o}=H();for(let n of r)if(!a.has(n)){let i=o.find(l=>l.id===n);i&&await this.subscribeToSource(i)}for(let n of a)r.has(n)||this.unsubscribeFromSource(n)};return this.localSyncChain=this.localSyncChain.then(t,t),this.localSyncChain}async setRemoteEnabledSources(e){let{sources:t}=H(),r;if(e==="all")r=new Set(t.map(o=>o.id).filter(o=>!ar.has(o)));else{r=new Set;for(let o of e){let n=Ct[o];n&&r.add(n)}}let a=this.remoteDiscoveryIds;this.remoteDiscoveryIds=r;for(let o of r)if(!a.has(o)){let n=t.find(i=>i.id===o);n&&await this.subscribeToSource(n)}for(let o of a)r.has(o)||this.unsubscribeFromSource(o)}ensureRemoteSourcesDefault(){this.remoteDiscoveryIds.size===0&&this.setRemoteEnabledSources("all")}clearRemoteSources(){for(let e of this.remoteDiscoveryIds)this.unsubscribeFromSource(e);this.remoteDiscoveryIds.clear()}isSourceSubscribed(e){switch(e){case"storage-async":case"storage-mmkv":return this.sourceUnsubscribers.has("storage");case"redux":return this.sourceUnsubscribers.has("redux");case"network":return this.sourceUnsubscribers.has("network");case"react-query":case"react-query-query":case"react-query-mutation":return this.sourceUnsubscribers.has("react-query");case"route":return this.sourceUnsubscribers.has("route-events");case"zustand":return this.sourceUnsubscribers.has("zustand");case"jotai":return this.sourceUnsubscribers.has("jotai");case"render":return this.sourceUnsubscribers.has("render");case"capacitor":return this.sourceUnsubscribers.has("capacitor");default:return false}}getSubscriptionStatus(){return{"storage-async":this.sourceUnsubscribers.has("storage"),"storage-mmkv":this.sourceUnsubscribers.has("storage"),redux:this.sourceUnsubscribers.has("redux"),network:this.sourceUnsubscribers.has("network"),"react-query":this.sourceUnsubscribers.has("react-query"),"react-query-query":this.sourceUnsubscribers.has("react-query"),"react-query-mutation":this.sourceUnsubscribers.has("react-query"),route:this.sourceUnsubscribers.has("route-events"),zustand:this.sourceUnsubscribers.has("zustand"),jotai:this.sourceUnsubscribers.has("jotai"),render:this.sourceUnsubscribers.has("render"),capacitor:this.sourceUnsubscribers.has("capacitor")}}getSubscriberCounts(){return La()}},O=new Wa;var Ka=e=>O.getEvents(e);var _a=()=>O.clearEvents(),Qa=e=>O.subscribe(e);var nr=e=>O.setLocalEnabledSources(e);var ir=()=>O.getAvailableEventSources();var Ga=(e,t,r)=>O.watch(e,t,r),sr=()=>O.getSubscriberCounts();import{persistentStorage as Se,devToolsStorageKeys as qe}from"@buoy-gg/shared-ui/web";async function Za(e){try{let t=qe.events.enabledSources();await Se.setItem(t,JSON.stringify(e))}catch{}}async function Ya(){try{let e=qe.events.enabledSources(),t=await Se.getItem(e);return t&&t!==""?JSON.parse(t):null}catch{return null}}async function Xa(e){try{let t=qe.events.isCapturing();await Se.setItem(t,JSON.stringify(e))}catch{}}async function en(){try{let e=qe.events.isCapturing(),t=await Se.getItem(e);return t!==null&&t!==""?JSON.parse(t):null}catch{return null}}async function lr(e){try{let t=qe.events.pausedAt();e===null?await Se.removeItem(t):await Se.setItem(t,JSON.stringify(e))}catch{}}async function tn(){try{let e=qe.events.pausedAt(),t=await Se.getItem(e);if(t!==null&&t!==""){let r=JSON.parse(t);return typeof r=="number"?r:null}return null}catch{return null}}import{isDevToolsStorageKey as ur,isUrlIgnored as rn}from"@buoy-gg/shared-ui/web";var on=["api.keygen.sh","buoy.gg/api/license"];function wt(e){let t=e.originalEvent;if(!t)return false;if(e.source==="storage-async"||e.source==="storage-mmkv"){let r=t.data?.key||t.key;if(r&&ur(r))return true;let a=t.data?.keys||t.data?.pairs?.map(o=>o[0]);if(a&&a.length>0&&a.every(o=>ur(o)))return true}if(e.source==="network"){let r=t.host||"",a=t.url||"";for(let o of on)if(r.includes(o)||a.includes(o))return true}return false}function Et(e,t){if(e.source!=="network"||t.length===0)return false;let r=e.originalEvent?.url??"";return rn(r,t)}function an(e,t){return wt(e)||Et(e,t)}function nn(e,t){if(e.title.toLowerCase().includes(t)||e.subtitle.toLowerCase().includes(t))return true;let r=e.originalEvent?.url;return typeof r=="string"&&r.toLowerCase().includes(t)}var cr=["storage-async","redux","network","react-query-query","react-query-mutation","route","zustand","jotai","render","capacitor"],dr=cr.filter(e=>e!=="render"),xt={"storage-async":["storage-async","storage-mmkv"],"storage-mmkv":["storage-mmkv"],redux:["redux"],network:["network"],"react-query":["react-query","react-query-query"],"react-query-query":["react-query","react-query-query"],"react-query-mutation":["react-query-mutation"],route:["route"],zustand:["zustand"],jotai:["jotai"],render:["render"],capacitor:["capacitor"]};function kt(e){let{isPro:t}=ba(),r=Ca("events.entries"),{patterns:a}=Sa(),[o,n]=fe([]),[i,l]=fe(()=>new Set(dr)),[s,u]=fe(true),[c,d]=fe(""),h=bt(false),b=e?.capturingOverride??s,v=bt(null),m=bt([]),[y,p]=fe(0);ye(()=>{b?v.current!==null&&(m.current=[...m.current,[v.current,Date.now()]],v.current=null,p(w=>w+1),lr(null)):v.current===null&&(v.current=Date.now(),p(w=>w+1),lr(v.current))},[b]);let g=be(w=>{let B=v.current;if(B!==null&&w>B)return true;for(let[z,G]of m.current)if(w>z&&w<=G)return true;return false},[]),[k,L]=fe(()=>ir()),[C,I]=fe(0);ye(()=>va(()=>{I(w=>w+1)}),[]);let x=ve(()=>cr.filter(w=>(xt[w]||[w]).some(B=>k.has(B))),[k]);ye(()=>{let w=null,B=Qa(()=>{w==null&&(w=requestAnimationFrame(()=>{w=null,z()}))}),z=()=>{let G=Ka();n(G),L(q=>{let R=ir();return q.size===R.size&&[...R].every(ne=>q.has(ne))?q:new Set(R)})};return()=>{B(),w!=null&&cancelAnimationFrame(w)}},[]),ye(()=>{(async()=>{let w=await Ya(),B,z=x.filter(R=>dr.includes(R));if(w&&w.length>0){let R=w.filter(ne=>x.includes(ne));R.length>0?B=new Set(R):B=new Set(z)}else B=new Set(z);l(B);let G=await en(),q=G!==null?G:true;if(!q&&v.current===null){let R=await tn();v.current=R??Date.now(),p(ne=>ne+1)}u(q),h.current=true,nr(q?Array.from(B):[])})()},[x]),ye(()=>{h.current&&nr(s?Array.from(i):[])},[i,s]),ye(()=>{h.current&&Za(Array.from(i))},[i]),ye(()=>{h.current&&Xa(s)},[s]);let j=ve(()=>{let w=new Set;return i.forEach(B=>{let z=xt[B];z&&z.forEach(G=>w.add(G))}),w},[i]),N=c.trim().toLowerCase(),me=ve(()=>o.filter(w=>!g(w.timestamp)&&!wt(w)&&!Et(w,a)),[o,a,g,y]),_=ve(()=>j.size===0?[]:me.filter(w=>j.has(w.source)&&(N===""||nn(w,N))),[me,j,N]),he=ve(()=>_.slice(0,r),[_,r]),Q=ve(()=>Math.max(0,_.length-r),[_,r]),Xe=ve(()=>{let w=me.reduce((q,R)=>(q[R.source]=(q[R.source]??0)+1,q),{}),B=sr(),z={};for(let q of B.sources)z[q.sourceId]=q.counts.total;let G={"storage-async":"storage","storage-mmkv":"storage",redux:"redux",network:"network","react-query":"react-query","react-query-query":"react-query","react-query-mutation":"react-query",route:"route-events",zustand:"zustand",jotai:"jotai",render:"render",capacitor:"capacitor"};return x.map(q=>{let R=(xt[q]||[q]).reduce((Z,yt)=>Z+(w[yt]||0),0),ne=Ua(q),Ie=G[q],rt=Ie&&Ie in z?z[Ie]:void 0;return{source:q,...ne,count:R,enabled:i.has(q),subscriberCount:rt}}).sort((q,R)=>q.enabled&&!R.enabled?-1:!q.enabled&&R.enabled?1:0)},[me,i,x,C]),ht=be(w=>{l(B=>{let z=new Set(B);return z.has(w)?z.delete(w):z.add(w),z})},[]),et=be(()=>{l(new Set(x))},[x]),Te=be(()=>{_a()},[]),Ve=be(()=>{u(true)},[]),gt=be(()=>{u(false)},[]),ft=be(()=>{u(w=>!w)},[]),tt=sr().totalSubscribers;return{events:o,filteredEvents:he,availableSources:Xe,enabledSources:i,searchText:c,setSearchText:d,toggleSource:ht,enableAllSources:et,clearEvents:Te,totalCount:me.length,filteredCount:he.length,isCapturing:s,startCapturing:Ve,stopCapturing:gt,toggleCapturing:ft,discoveredSources:k,hiddenEventsCount:Q,isPro:t,totalSubscriberCount:tt}}import{memo as sn}from"react";import{night as U}from"@buoy-gg/shared-ui/web";var S="buoy-events";function ln(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function pr(e){let t=e.originalEvent??{};switch(e.source){case"storage-async":case"storage-mmkv":{let r=t.data??{},a=r.key??(Array.isArray(r.keys)?r.keys.join("+"):void 0)??(Array.isArray(r.pairs)?r.pairs.map(o=>o[0]).join("+"):void 0);return`${e.title} ${a??""}`}case"network":{let r=String(t.url??""),a=r.split("?")[0]??r;return`${t.method??""} ${a}`}case"react-query":case"react-query-query":case"react-query-mutation":return`${e.title} ${t.type??""}`;default:return e.title}}function mr(e){return`${S}-row-${e.source}-${ln(pr(e))}`}function hr(e){return`${S}-filter-${e}`}import{jsx as Ce,jsxs as $t}from"react/jsx-runtime";var Dt=sn(function({availableSources:e,onToggleSource:t,totalCount:r,filteredCount:a}){return e.length===0?null:$t(f,{style:re.container,testID:`${S}-filter-bar`,children:[Ce(ue,{horizontal:true,showsHorizontalScrollIndicator:false,contentContainerStyle:re.badgesRow,testID:`${S}-filter-scroll`,children:e.map(o=>{let n=o.enabled!==false,i=o.subscriberCount,l=i!==void 0,s=o.count||0,u=hr(o.source);return $t(ge,{testID:u,accessibilityRole:"button",accessibilityLabel:`${o.label} filter, ${n?"on":"off"}, ${s} event${s===1?"":"s"}`,style:[re.badge,n?{backgroundColor:U.color.surface,borderColor:o.color+"50"}:re.badgeDisabled],onPress:()=>t(o.source),activeOpacity:.7,children:[l&&Ce(f,{style:[re.countBadge,{backgroundColor:n?i>0?o.color+"25":U.color.fillSecondary:U.color.fill}],children:Ce($,{style:[re.countText,{color:n?i>0?o.color:U.color.textTertiary:U.color.textTertiary}],testID:`${u}-subscribers`,children:i})}),Ce(f,{style:[re.dot,{backgroundColor:n?o.color:U.color.fillTertiary}]}),Ce($,{style:[re.badgeLabel,{color:n?U.color.text:U.color.textTertiary}],numberOfLines:1,testID:`${u}-label`,children:o.label}),Ce(f,{style:[re.countBadge,{backgroundColor:n?s>0?o.color+"20":U.color.fill:U.color.fill}],children:Ce($,{style:[re.countText,{color:n?s>0?o.color:U.color.textTertiary:U.color.textTertiary}],testID:`${u}-count`,children:s})})]},o.source)})}),a<r&&$t($,{style:re.filterInfo,testID:`${S}-showing`,children:["Showing ",a," of ",r]})]})}),re=le.create({container:{paddingVertical:8,backgroundColor:"transparent",borderBottomWidth:1,borderBottomColor:U.color.border},badgesRow:{flexDirection:"row",gap:8,paddingHorizontal:12},badge:{flexDirection:"row",alignItems:"center",paddingVertical:5,paddingHorizontal:6,borderRadius:20,borderWidth:1,gap:6,flexShrink:0},badgeDisabled:{backgroundColor:U.color.surface,borderColor:U.color.border,opacity:.5},dot:{width:7,height:7,borderRadius:4},badgeLabel:{fontSize:12,fontWeight:"500"},countBadge:{minWidth:18,height:18,borderRadius:9,alignItems:"center",justifyContent:"center",paddingHorizontal:5},countText:{fontSize:10,fontWeight:"600",fontVariant:["tabular-nums"]},filterInfo:{marginTop:6,fontSize:11,color:U.color.textTertiary,textAlign:"center"}});import{memo as un,useCallback as Tt,useMemo as cn}from"react";import{night as nt,Zap as dn,ProBadge as pn,ToolEmptyState as mn,resolveListEmptyState as hn}from"@buoy-gg/shared-ui/web";import{loadToolModule as Fe,getToolModuleVersion as gr}from"@buoy-gg/shared-ui/web/utils";import{memo as gn}from"react";import{CompactRow as fn,formatRelativeTime as yn,Pill as bn}from"@buoy-gg/shared-ui/web";import{jsx as V,jsxs as vn}from"react/jsx-runtime";function Sn(){let e={StorageEventCard:null,getValueType:null,ReduxActionItem:null,NetworkEventItemCompact:null,RouteEventItemCompact:null,ZustandStateChangeItem:null,JotaiAtomChangeItem:null};try{let t=Fe("@buoy-gg/storage");e.StorageEventCard=t.StorageEventCard,e.getValueType=t.getValueType}catch{}try{let t=Fe("@buoy-gg/redux");e.ReduxActionItem=t.ReduxActionItem}catch{}try{let t=Fe("@buoy-gg/network");e.NetworkEventItemCompact=t.NetworkEventItemCompact}catch{}try{let t=Fe("@buoy-gg/route-events");e.RouteEventItemCompact=t.RouteEventItemCompact}catch{}try{let t=Fe("@buoy-gg/zustand");e.ZustandStateChangeItem=t.ZustandStateChangeItem}catch{}try{let t=Fe("@buoy-gg/jotai");e.JotaiAtomChangeItem=t.JotaiAtomChangeItem}catch{}return e}var It,fr=-1;function Cn(){return(!It||fr!==gr())&&(It=Sn(),fr=gr()),It}var yr={"storage-async":{label:"Storage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"},capacitor:{label:"Capacitor",color:"#119EFF"}};function wn(e){switch(e){case"success":return"#10B981";case"error":return"#EF4444";case"pending":return"#F59E0B";case"neutral":default:return"#6B7280"}}function En(e){return e==="storage-async"||e==="storage-mmkv"}function xn({label:e,color:t,testID:r}){return V(bn,{label:e,color:t,variant:"soft",size:"sm",style:{marginLeft:6},testID:r})}var kn={"storage-async":"STORAGE","storage-mmkv":"MMKV",redux:"REDUX",network:"NET","react-query":"QUERY","react-query-query":"QUERY","react-query-mutation":"MUTATION",route:"ROUTE",zustand:"ZUSTAND",jotai:"JOTAI",render:"RENDER",capacitor:"CAPACITOR"};function Oe({source:e,testID:t,children:r}){let a=yr[e].color,o=kn[e];return vn(f,{style:At.badgeWrapper,testID:t,children:[r,V(f,{style:[At.sourceBadge,{backgroundColor:`${a}20`}],children:V($,{style:[At.sourceBadgeText,{color:a}],testID:t?`${t}-badge`:void 0,children:o})})]})}var br=gn(function({event:e,onPress:t,isSelected:r=false,isExpanded:a=false,onNavigate:o,correlationCount:n=1,correlationLabel:i,correlationColor:l}){let{StorageEventCard:s,getValueType:u,ReduxActionItem:c,NetworkEventItemCompact:d,RouteEventItemCompact:h,ZustandStateChangeItem:b,JotaiAtomChangeItem:v}=Cn(),m=yr[e.source],y=wn(e.status),p=mr(e);if(En(e.source)&&s&&u){let k=e.originalEvent,L={key:k.data?.key||"unknown",lastAction:k.action,totalOperations:1,lastEventTimestamp:new Date(e.timestamp),storageTypes:new Set([k.storageType||"async"]),valueType:k.data?.value!==void 0?u(k.data.value):void 0};return V(Oe,{source:e.source,testID:p,children:V(s,{data:L,onPress:t,isSelected:r})})}if(e.source==="redux"&&c){let k=e.originalEvent;return V(Oe,{source:e.source,testID:p,children:V(c,{action:k,onPress:()=>t()})})}if(e.source==="network"&&d){let k=e.originalEvent;return V(f,{testID:p,children:V(d,{event:k,onPress:()=>t()})})}if(e.source==="route"&&h){let k=e.originalEvent;return V(Oe,{source:e.source,testID:p,children:V(h,{event:k,visitNumber:0,isExpanded:a,onPress:()=>t(),onNavigate:o})})}if(e.source==="zustand"&&b)return V(Oe,{source:e.source,testID:p,children:V(b,{change:e.originalEvent,onPress:()=>t()})});if(e.source==="jotai"&&v)return V(Oe,{source:e.source,testID:p,children:V(v,{change:e.originalEvent,onPress:()=>t()})});let g=i&&l?V(xn,{label:i,color:l,testID:`${p}-correlation`}):null;return V(fn,{statusDotColor:m.color,statusLabel:m.label,primaryText:e.title,secondaryText:e.subtitle,badgeText:n>1&&!i?`${n}`:"",badgeColor:l||y,customBadge:g,bottomRightText:yn(new Date(e.timestamp)),showChevron:true,isSelected:r,onPress:t,testID:p})}),At=le.create({badgeWrapper:{position:"relative"},sourceBadge:{position:"absolute",top:4,right:12,paddingHorizontal:6,paddingVertical:2,borderRadius:4,zIndex:10},sourceBadgeText:{fontSize:8,fontWeight:"700",letterSpacing:.5}});function $n(e,t){return e.correlationId?t.filter(r=>r.correlationId===e.correlationId&&r.id!==e.id).sort((r,a)=>r.timestamp-a.timestamp):[]}function Dn(e,t){return e.correlationId?t.some(r=>r.correlationId===e.correlationId&&r.id!==e.id):false}function Tn(e,t){return e.correlationId?t.filter(r=>r.correlationId===e.correlationId).length:1}function vr(e){let t=new Map;for(let r of e)if(r.correlationId){let a=t.get(r.correlationId)||0;t.set(r.correlationId,a+1)}return t}function Sr(e,t){return t.filter(r=>r.correlationId===e).sort((r,a)=>{let o=r.sequenceInGroup??0,n=a.sequenceInGroup??0;return o!==n?o-n:r.timestamp-a.timestamp})}function Cr(e,t){if(!e.correlationId)return null;let r=Sr(e.correlationId,t);if(r.length<=1)return null;let a=r.findIndex(o=>o.id===e.id);return a===-1?null:`${a+1}/${r.length}`}var wr=["#EC4899","#8B5CF6","#3B82F6","#10B981","#F59E0B","#EF4444","#06B6D4","#84CC16"];function Er(e){let t=0;for(let a=0;a<e.length;a++)t=(t<<5)-t+e.charCodeAt(a),t|=0;let r=Math.abs(t)%wr.length;return wr[r]}import{jsx as Be,jsxs as qt}from"react/jsx-runtime";var Ft=un(function({events:e,selectedEventId:t,expandedEventId:r,onEventPress:a,onNavigate:o,isCapturing:n,hiddenEventsCount:i=0,onUpgradePress:l,searchText:s="",totalCount:u=0,sourceCount:c,enabledSourceCount:d}){let h=cn(()=>vr(e),[e]),b=Tt(({item:y})=>{let p=y.correlationId&&h.get(y.correlationId)||1,g=Cr(y,e),k=y.correlationId?Er(y.correlationId):void 0;return Be(br,{event:y,isSelected:y.id===t,isExpanded:y.id===r,onPress:()=>a(y),onNavigate:o,correlationCount:p,correlationLabel:g,correlationColor:k})},[t,r,a,o,h,e]),v=Tt(y=>y.id,[]),m=Tt(()=>i<=0?null:qt(ge,{style:we.hiddenBanner,onPress:l,activeOpacity:.8,testID:`${S}-hidden-banner`,accessibilityRole:"button",accessibilityLabel:`${i} hidden event${i!==1?"s":""}, upgrade for the full history`,children:[qt(f,{style:we.hiddenBannerLeft,children:[Be(dn,{size:16,color:nt.color.accent}),qt($,{style:we.hiddenBannerText,testID:`${S}-hidden-count`,children:[i," hidden event",i!==1?"s":""]})]}),Be(pn,{})]}),[i,l]);if(e.length===0){let y=c===0,p=d===0,g=y?{otto:"scanning",title:"No Event Sources",message:`This tool reports on the other Buoy tools.
2
+ Install one \u2014 network, storage, redux, routes \u2014 and its events land here.`}:p&&!s.trim()&&u>0?{otto:"filtering",title:"Every Source Is Off",message:`${u} event${u===1?" is":"s are"} captured. Turn a source chip back on to see them.`}:hn({subject:"events",search:s,total:u,capturing:n,blocked:p?"Every source chip is off, so there is nothing to search. Turn one back on.":void 0,waiting:{otto:"listening",title:"No Events Yet",message:`Events will appear here as they occur.
3
+ Try interacting with your app.`},paused:{title:"Not Capturing",message:"Event capture is paused. Resume to see events."}});return Be(mn,{...g,testID:`${S}-empty`,style:we.emptyContainer})}return Be(Yt,{data:e,renderItem:b,keyExtractor:v,testID:`${S}-list`,style:we.list,contentContainerStyle:we.listContent,ItemSeparatorComponent:()=>Be(f,{style:we.separator}),ListFooterComponent:m,showsVerticalScrollIndicator:true,initialNumToRender:15,maxToRenderPerBatch:10,windowSize:10,removeClippedSubviews:!(typeof process<"u"&&process.env?.EXPO_PUBLIC_E2E)})}),we=le.create({list:{flex:1,backgroundColor:"transparent"},listContent:{paddingVertical:16},separator:{height:8},emptyContainer:{flex:1,justifyContent:"center",backgroundColor:"transparent"},hiddenBanner:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginHorizontal:16,marginTop:8,marginBottom:16,paddingVertical:12,paddingHorizontal:16,backgroundColor:nt.color.surface,borderRadius:8,borderWidth:1,borderColor:nt.color.border},hiddenBannerLeft:{flexDirection:"row",alignItems:"center",gap:8},hiddenBannerText:{fontSize:13,fontWeight:"500",color:nt.color.text}});import{loadToolModule as Ee,getToolModuleVersion as Bt}from"@buoy-gg/shared-ui/web/utils";import{memo as In,useMemo as xr}from"react";import{night as de,formatRelativeTime as An,copyToClipboard as qn,parseValue as Fn,useIgnoredPatterns as Bn,monoFont as Rn}from"@buoy-gg/shared-ui/web";import{DataViewer as jn}from"@buoy-gg/shared-ui/web/dataViewer";import{memo as zn,useMemo as Mn}from"react";import{buoyColors as oe,night as M,displayValue as Pn,monoFont as Re}from"@buoy-gg/shared-ui/web";import{DataViewer as it}from"@buoy-gg/shared-ui/web/dataViewer";import{jsx as T,jsxs as J}from"react/jsx-runtime";var Nn={"query-fetch-start":{label:"Query Fetching",color:M.color.accent,icon:"hourglass"},"query-fetch-success":{label:"Query Success",color:oe.success,icon:"checkmark"},"query-fetch-error":{label:"Query Error",color:oe.error,icon:"close"},"query-invalidated":{label:"Query Invalidated",color:oe.warning,icon:"refresh"},"mutation-start":{label:"Mutation Started",color:M.color.accent,icon:"hourglass"},"mutation-success":{label:"Mutation Success",color:oe.success,icon:"checkmark"},"mutation-error":{label:"Mutation Error",color:oe.error,icon:"close"}},kr=zn(function({event:e}){let t=e.originalEvent,r=Nn[t.type]||{label:t.type,color:M.color.textTertiary,icon:"help"},a=t.type.startsWith("query-"),o=t.type.startsWith("mutation-"),n=Mn(()=>{let c=a?t.queryKey:t.mutationKey;return c?Pn(c,true):o&&t.mutationId!==void 0?`Mutation #${t.mutationId}`:"No key"},[t,a,o]),i=new Date(t.timestamp).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:true}),l=a?!!t.queryData:!!t.mutationData,s=a?!!t.queryError:!!t.mutationError,u=o&&!!t.mutationVariables;return J(ue,{style:E.container,contentContainerStyle:E.contentContainer,children:[T(f,{style:E.section,children:J(f,{style:[E.eventTypeContainer,{borderColor:r.color+"4D"}],children:[T($,{style:[E.eventTypeHeader,{backgroundColor:r.color+"15",color:r.color}],children:r.label}),J(f,{style:E.eventTypeContent,children:[J(f,{style:E.keyRow,children:[T(ue,{horizontal:true,style:E.keyScrollView,children:T($,{style:E.keyText,children:n})}),T(Vn,{type:t.type,color:r.color})]}),t.duration!==void 0&&J(f,{style:E.row,children:[T($,{style:E.labelText,children:"Duration:"}),J($,{style:E.valueText,children:[t.duration.toFixed(0),"ms"]})]}),J(f,{style:E.row,children:[T($,{style:E.labelText,children:"Timestamp:"}),T($,{style:E.valueText,children:i})]}),a&&t.queryHash&&J(f,{style:E.row,children:[T($,{style:E.labelText,children:"Query Hash:"}),T($,{style:[E.valueText,E.hashText],numberOfLines:1,children:t.queryHash})]}),o&&t.mutationId!==void 0&&J(f,{style:E.row,children:[T($,{style:E.labelText,children:"Mutation ID:"}),J($,{style:E.valueText,children:["#",t.mutationId]})]})]})]})}),u&&T(f,{style:E.section,children:J(f,{style:E.dataContainer,children:[T($,{style:[E.dataHeader,{color:oe.warning}],children:"Variables"}),T(f,{style:E.dataContent,children:T(it,{title:"",data:t.mutationVariables,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})}),l&&T(f,{style:E.section,children:J(f,{style:E.dataContainer,children:[T($,{style:[E.dataHeader,{color:oe.success}],children:a?"Query Data":"Mutation Result"}),T(f,{style:E.dataContent,children:T(it,{title:"",data:a?t.queryData:t.mutationData,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})}),s&&T(f,{style:E.section,children:J(f,{style:[E.dataContainer,E.errorContainer],children:[T($,{style:[E.dataHeader,E.errorHeader],children:"Error"}),T(f,{style:E.dataContent,children:T(it,{title:"",data:a?t.queryError:t.mutationError,showTypeFilter:true,rawMode:true,initialExpanded:true})})]})}),T(f,{style:E.section,children:J(f,{style:E.dataContainer,children:[T($,{style:E.dataHeader,children:"Event Details"}),T(f,{style:E.dataContent,children:T(it,{title:"",data:t,showTypeFilter:true,rawMode:true,initialExpanded:false})})]})})]})});function Vn({type:e,color:t}){let r=()=>e.includes("start")?"PENDING":e.includes("success")?"SUCCESS":e.includes("error")?"ERROR":e.includes("invalidated")?"INVALIDATED":e.toUpperCase();return T(f,{style:[E.statusChip,{backgroundColor:t+"15",borderColor:t+"33"}],children:T($,{style:[E.statusChipText,{color:t}],children:r()})})}var E=le.create({container:{flex:1,backgroundColor:"transparent"},contentContainer:{padding:8,paddingBottom:24},section:{marginBottom:12},eventTypeContainer:{minWidth:200,backgroundColor:M.color.surface,borderRadius:6,borderWidth:1,overflow:"hidden",shadowColor:M.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},eventTypeHeader:{paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,borderBottomWidth:1,borderBottomColor:M.color.accentBorder,letterSpacing:.5,textTransform:"uppercase",fontFamily:Re},eventTypeContent:{padding:0},keyRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:M.color.separator},keyScrollView:{flex:1,marginRight:8},keyText:{fontSize:12,color:M.color.text,fontFamily:Re,lineHeight:18,backgroundColor:M.color.accentSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4,borderWidth:1,borderColor:M.color.accentBorderStrong},row:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:M.color.separator},labelText:{fontSize:10,color:M.color.textSecondary,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:Re},valueText:{fontSize:12,color:M.color.text,fontWeight:"500",fontVariant:["tabular-nums"],fontFamily:Re},hashText:{flex:1,textAlign:"right",marginLeft:8},statusChip:{paddingHorizontal:8,paddingVertical:4,borderWidth:1,borderRadius:6,alignSelf:"flex-start"},statusChipText:{fontSize:11,fontWeight:"600",textTransform:"uppercase",letterSpacing:.5,fontFamily:Re},dataContainer:{minWidth:200,backgroundColor:M.color.surface,borderRadius:6,borderWidth:1,borderColor:M.color.accentBorderStrong,overflow:"hidden",shadowColor:M.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},dataHeader:{backgroundColor:M.color.accentSoft,paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:M.color.accent,borderBottomWidth:1,borderBottomColor:M.color.accentBorder,letterSpacing:.5,textTransform:"uppercase",fontFamily:Re},dataContent:{padding:8},errorContainer:{borderColor:oe.error+"4D"},errorHeader:{backgroundColor:oe.error+"1A",color:oe.error,borderBottomColor:oe.error+"33"}});import{Fragment as On,jsx as D,jsxs as Ue}from"react/jsx-runtime";function Un(){let e={StorageEventDetailContent:null,ReduxActionDetailContent:null,NetworkEventDetailView:null,RenderDetailView:null,ZustandStateDetailContent:null,JotaiAtomDetailContent:null,RouteEventDetail:null};try{let t=Ee("@buoy-gg/storage");e.StorageEventDetailContent=t.StorageEventDetailContent}catch{}try{let t=Ee("@buoy-gg/redux");e.ReduxActionDetailContent=t.ReduxActionDetailContent}catch{}try{let t=Ee("@buoy-gg/network");e.NetworkEventDetailView=t.NetworkEventDetailView}catch{}try{let t=Ee("@buoy-gg/highlight-updates");e.RenderDetailView=t.RenderDetailView}catch{}try{let t=Ee("@buoy-gg/zustand");e.ZustandStateDetailContent=t.ZustandStateDetailContent}catch{}try{let t=Ee("@buoy-gg/jotai");e.JotaiAtomDetailContent=t.JotaiAtomDetailContent}catch{}try{let t=Ee("@buoy-gg/route-events");e.RouteEventDetail=t.RouteEventDetail}catch{}return e}var Rt,$r=-1;function Ln(){return(!Rt||$r!==Bt())&&(Rt=Un(),$r=Bt()),Rt}var Hn={"storage-async":{label:"AsyncStorage",color:"#8B5CF6"},"storage-mmkv":{label:"MMKV",color:"#F59E0B"},redux:{label:"Redux",color:"#3B82F6"},network:{label:"Network",color:"#10B981"},"react-query":{label:"React Query",color:"#EC4899"},"react-query-query":{label:"Query",color:"#EC4899"},"react-query-mutation":{label:"Mutation",color:"#F97316"},route:{label:"Route",color:"#06B6D4"},zustand:{label:"Zustand",color:"#764ABC"},jotai:{label:"Jotai",color:"#14B8A6"},render:{label:"Render",color:"#F472B6"},capacitor:{label:"Capacitor",color:"#119EFF"}};function Jn(e){return e==="storage-async"||e==="storage-mmkv"}function Wn(e){let t=Fn(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 Kn({children:e}){return D(On,{children:e})}var jt=In(function({event:e,onBack:t,NetworkEventDetailViewComponent:r,networkDetailWrapper:a,RouteEventDetailComponent:o,detailComponents:n,onNavigate:i}){let l=xr(()=>({...Ln(),...n}),[n,Bt()]),s=Hn[e.source],u=new Date(e.timestamp),{values:c,toggle:d}=Bn(),h=xr(()=>{if(!Jn(e.source)||!l.StorageEventDetailContent)return null;let p=e.originalEvent,g={...p,timestamp:new Date(p.timestamp)};return{key:g.data?.key||"unknown",lastEvent:g,events:[g],totalOperations:1,currentValue:g.data?.value,valueType:Wn(g.data?.value),storageTypes:new Set([g.storageType||"async"])}},[e,l]);if(h&&l.StorageEventDetailContent){let{StorageEventDetailContent:p}=l;return D(f,{style:F.container,testID:`${S}-detail-storage`,children:D(p,{conversation:h,selectedEventIndex:0,onEventIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="redux"&&l.ReduxActionDetailContent){let{ReduxActionDetailContent:p}=l,g=e.originalEvent;return D(f,{style:F.container,testID:`${S}-detail-redux`,children:D(p,{action:g,actions:[g],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}let b=r??l.NetworkEventDetailView;if(e.source==="network"&&b){let p=e.originalEvent,g=a??Kn;return D(f,{style:F.container,children:D(g,{children:D(ue,{style:F.content,testID:`${S}-detail-network`,children:D(b,{event:p,ignoredPatterns:c,onTogglePattern:d})})})})}if(e.source==="react-query"||e.source==="react-query-query"||e.source==="react-query-mutation")return D(f,{style:F.container,testID:`${S}-detail-react-query`,children:D(kr,{event:e})});if(e.source==="zustand"&&l.ZustandStateDetailContent){let{ZustandStateDetailContent:p}=l,g=e.originalEvent;return D(f,{style:F.container,testID:`${S}-detail-zustand`,children:D(p,{change:g,changes:[g],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="jotai"&&l.JotaiAtomDetailContent){let{JotaiAtomDetailContent:p}=l,g=e.originalEvent;return D(f,{style:F.container,testID:`${S}-detail-jotai`,children:D(p,{change:g,changes:[g],selectedIndex:0,onIndexChange:()=>{},disableInternalFooter:true})})}if(e.source==="render"&&l.RenderDetailView){let{RenderDetailView:p}=l,g=e.originalEvent;return D(f,{style:F.container,children:D(ue,{style:F.content,testID:`${S}-detail-render`,children:D(p,{render:g.render})})})}let v=o??l.RouteEventDetail;if(e.source==="route"&&v)return D(f,{style:F.container,children:D(f,{style:F.container,testID:`${S}-detail-route`,children:D(v,{event:e.originalEvent,onNavigate:i})})});let m=()=>e.originalEvent,y=async()=>{await qn({source:e.source,timestamp:u.toISOString(),title:e.title,subtitle:e.subtitle,data:m()})};return D(f,{style:F.container,testID:`${S}-detail`,children:Ue(ue,{style:F.content,contentContainerStyle:F.contentContainer,testID:`${S}-detail-scroll`,children:[D(f,{style:F.sourceBadgeRow,children:Ue(f,{style:[F.sourceBadge,{backgroundColor:s.color+"20"}],children:[D(f,{style:[F.sourceDot,{backgroundColor:s.color}]}),D($,{style:[F.sourceLabel,{color:s.color}],testID:`${S}-detail-source`,children:s.label})]})}),D($,{style:F.title,testID:`${S}-detail-title`,children:e.title}),D($,{style:F.subtitle,testID:`${S}-detail-subtitle`,children:e.subtitle}),Ue(f,{style:F.timestampRow,children:[D($,{style:F.timestampLabel,children:"Timestamp"}),Ue($,{style:F.timestampValue,testID:`${S}-detail-timestamp`,children:[u.toLocaleTimeString()," (",An(u),")"]})]}),Ue(f,{style:F.dataSection,children:[D($,{style:F.sectionLabel,children:"Event Data"}),D(f,{style:F.dataContainer,testID:`${S}-detail-data`,children:D(jn,{testIDPrefix:`${S}-detail-data`,data:m(),title:"",showTypeFilter:true,rawMode:true,initialExpanded:true})})]})]})})}),F=le.create({container:{flex:1,backgroundColor:"transparent"},content:{flex:1},contentContainer:{padding:16},sourceBadgeRow:{flexDirection:"row",marginBottom:12},sourceBadge:{flexDirection:"row",alignItems:"center",paddingHorizontal:10,paddingVertical:6,borderRadius:12,gap:6},sourceDot:{width:6,height:6,borderRadius:3},sourceLabel:{fontSize:12,fontWeight:"600"},title:{fontSize:24,fontWeight:"700",color:de.color.text,marginBottom:4},subtitle:{fontSize:16,color:de.color.textTertiary,marginBottom:16},timestampRow:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingVertical:12,borderTopWidth:1,borderTopColor:de.color.border,borderBottomWidth:1,borderBottomColor:de.color.border,marginBottom:16},timestampLabel:{fontSize:14,color:de.color.textTertiary},timestampValue:{fontSize:14,color:de.color.text,fontFamily:Rn},dataSection:{marginTop:8},sectionLabel:{fontSize:12,fontWeight:"600",color:de.color.textTertiary,textTransform:"uppercase",letterSpacing:.5,marginBottom:8},dataContainer:{backgroundColor:de.color.surface,borderRadius:8,borderWidth:1,borderColor:de.color.border,overflow:"hidden"}});import{useCallback as je,useEffect as _n,useMemo as st,useState as zt}from"react";import{DynamicFilterView as Dr,macOSColors as Le,night as He,FileText as Tr,FileCode as Ir,Hash as Qn,Zap as Gn,AlertTriangle as Zn,Settings as Yn,Eye as Xn,XCircle as Ar,GitBranch as qr,ToolbarCopyButton as ei,useFeatureGate as ti,ProFeatureBanner as ri,ExportPreview as oi,monoFont as ai}from"@buoy-gg/shared-ui/web";import{DataViewer as ni}from"@buoy-gg/shared-ui/web/dataViewer";var Je={timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:true,includeEventData:false,dataSizeThreshold:5,format:"markdown",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},We={llm:{timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:true,includeEventData:false,dataSizeThreshold:5,format:"markdown",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},bugReport:{timestampFormat:"both",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:true,includeEventData:true,dataSizeThreshold:10,format:"markdown",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},json:{timestampFormat:"absolute",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:false,includeTotalDuration:false,includeEventData:true,dataSizeThreshold:-1,format:"json",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:false,showStorageDiff:false,stripVerboseFields:false},errors:{timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:true,includeCorrelation:true,includeDuration:true,includeSummaryHeader:true,includeTotalDuration:false,includeEventData:true,dataSizeThreshold:10,format:"markdown",filterMode:"errors",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true},minimal:{timestampFormat:"relative",includeSource:false,includeStatus:true,includeTitle:true,includeSubtitle:false,includeCorrelation:false,includeDuration:false,includeSummaryHeader:false,includeTotalDuration:false,includeEventData:false,dataSizeThreshold:1,format:"plaintext",filterMode:"all",filterSources:[],compactMode:true,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:false,stripVerboseFields:true},mermaid:{timestampFormat:"relative",includeSource:true,includeStatus:true,includeTitle:true,includeSubtitle:false,includeCorrelation:true,includeDuration:true,includeSummaryHeader:false,includeTotalDuration:false,includeEventData:false,dataSizeThreshold:1,format:"mermaid",filterMode:"all",filterSources:[],compactMode:false,smartJsonParsing:true,reduxChangedOnly:true,showStorageDiff:true,stripVerboseFields:true}};function Fr(e){for(let[t,r]of Object.entries(We))if(Object.keys(r).every(a=>{let o=e[a],n=r[a];return Array.isArray(o)&&Array.isArray(n)?o.length===n.length&&o.every((i,l)=>i===n[l]):o===n}))return t;return null}var P={llm:{label:"LLM",description:"AI-ready format",color:"#10B981"},bugReport:{label:"Bug Report",description:"Full context",color:"#EF4444"},json:{label:"JSON",description:"Machine-readable",color:"#F59E0B"},errors:{label:"Errors",description:"Failed only",color:"#EF4444"},minimal:{label:"Minimal",description:"Quick reference",color:"#6B7280"},mermaid:{label:"Diagram",description:"Visual flow",color:"#A855F7"}};var ze={success:"\u2705",pending:"\u23F3",error:"\u274C",neutral:"\u2796"},ii={success:"[OK]",pending:"[...]",error:"[ERR]",neutral:"[-]"},Mt={"storage-async":"Storage","storage-mmkv":"MMKV",redux:"Redux",network:"Network","react-query":"Query","react-query-query":"Query","react-query-mutation":"Mutation",route:"Route",zustand:"Zustand",jotai:"Jotai",render:"Render",capacitor:"Capacitor"};function xe(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}}function ke(e){if(e==null)return e;if(typeof e=="string")return xe(e);if(Array.isArray(e))return e.map(ke);if(typeof e=="object"){let t={};for(let[r,a]of Object.entries(e))t[r]=ke(a);return t}return e}var si=new Set(["image","imageUrl","imageURL","image_url","thumbnail","thumbnailUrl","thumbnail_url","icon","iconUrl","avatar","avatarUrl","photo","photoUrl","picture","pictureUrl","description","desc","longDescription","shortDescription","meta_description"]);function Pt(e){if(e==null)return e;if(Array.isArray(e))return e.map(Pt);if(typeof e=="object"){let t={};for(let[r,a]of Object.entries(e))si.has(r)||typeof a=="string"&&li(a)||(t[r]=Pt(a));return t}return e}function li(e){if(!e.startsWith("http"))return false;let t=e.toLowerCase();return t.includes("/photo")||t.includes("/image")||t.includes("unsplash.com")||t.includes("cloudinary.com")||t.includes("imgur.com")||/\.(jpg|jpeg|png|gif|webp|svg|bmp)(\?|$)/i.test(e)}function ui(e){if(e instanceof Date)return e.toISOString();if(!(e&&typeof e=="object"&&Object.keys(e).length===0))return e}function ci(e,t){let r=s=>{if(typeof s!="object"||s===null)return null;let u=s;return typeof u.id=="string"?u.id:typeof u.orderId=="string"?u.orderId:typeof u.key=="string"?u.key:null},a=new Set(e.map(r).filter(Boolean)),o=new Set(t.map(r).filter(Boolean));if(a.size===0&&o.size===0)return null;let n=t.filter(s=>{let u=r(s);return u&&!a.has(u)}),i=e.filter(s=>{let u=r(s);return u&&!o.has(u)}),l=t.length-n.length;return n.length+i.length<e.length&&n.length+i.length<t.length?{added:n,removed:i,unchanged:l}:null}function di(e,t){let r={};if(e.action&&(r.action=e.action),e.storageType&&(r.storageType=e.storageType),e.timestamp!==void 0){let a=ui(e.timestamp);a!==void 0&&(r.timestamp=a)}if(e.data){let a={...e.data};if(t.smartJsonParsing&&(a.value!==void 0&&(a.value=xe(a.value)),a.prevValue!==void 0&&(a.prevValue=xe(a.prevValue))),t.showStorageDiff&&Array.isArray(a.value)&&Array.isArray(a.prevValue)){let o=ci(a.prevValue,a.value);if(o){let n={key:a.key};return o.added.length>0&&(n.added=o.added),o.removed.length>0&&(n.removed=o.removed),o.unchanged>0&&(n.unchangedCount=o.unchanged),r.data=n,r}}r.data=a}return r}function pi(e,t){if(!t.reduxChangedOnly)return t.smartJsonParsing?ke(e):e;let r={};if(e.type&&(r.type=e.type),e.payload&&(r.payload=t.smartJsonParsing?ke(e.payload):e.payload),e.sliceName&&(r.sliceName=e.sliceName),e.actionName&&(r.actionName=e.actionName),e.duration&&(r.duration=e.duration),e.hasStateChange!==void 0&&(r.hasStateChange=e.hasStateChange),e.diffSummary&&(r.diffSummary=e.diffSummary),e.changedKeysCount!==void 0&&(r.changedKeysCount=e.changedKeysCount),e.hasStateChange===true){let a=e.sliceName;if(a&&e.prevState&&e.nextState){let o=e.prevState,n=e.nextState;(o[a]!==void 0||n[a]!==void 0)&&(r.stateChange={slice:a,before:o[a],after:n[a]})}}return r}function Br(e){if(typeof e!="object"||e===null)return null;let t=e;return typeof t.name=="string"?t.name:typeof t.id=="string"?t.id:typeof t.key=="string"?t.key:null}function Ke(e,t){let r=typeof e=="string"?xe(e):e,a=typeof t=="string"?xe(t):t;if(r==null&&a!==null&&a!==void 0)return"Created";if(r!=null&&a==null)return"Deleted";if(Array.isArray(r)&&Array.isArray(a)){let o=r.length,n=a.length,i=r.map(Br).filter(Boolean),l=a.map(Br).filter(Boolean);if(o===n&&o>0){let s=new Set(i),u=new Set(l),c=i.filter(d=>u.has(d));if(c.length===0&&i.length>0&&l.length>0)return`\u26A0\uFE0F Replaced: [${i.join(", ")}] \u2192 [${l.join(", ")}]`;if(c.length<o){let d=i.filter(b=>!u.has(b)),h=l.filter(b=>!s.has(b));return`Changed: -${d.join(", ")} +${h.join(", ")}`}}if(o===0&&n>0)return l.length>0?`Added: [${l.join(", ")}]`:`Added ${n} item${n>1?"s":""}`;if(o>0&&n===0)return i.length>0?`Removed all: [${i.join(", ")}]`:`Removed all ${o} item${o>1?"s":""}`;if(n>o){let s=new Set(i),u=l.filter(c=>!s.has(c));return u.length>0?`Added: [${u.join(", ")}] (${o} \u2192 ${n})`:`Added ${n-o} item${n-o>1?"s":""} (${o} \u2192 ${n})`}if(n<o){let s=new Set(l),u=i.filter(c=>!s.has(c));return u.length>0?`Removed: [${u.join(", ")}] (${o} \u2192 ${n})`:`Removed ${o-n} item${o-n>1?"s":""} (${o} \u2192 ${n})`}return`Updated (${n} item${n>1?"s":""})`}if(typeof r=="object"&&typeof a=="object"&&r&&a){let o=Object.keys(r),n=Object.keys(a),i=n.filter(s=>!o.includes(s)),l=o.filter(s=>!n.includes(s));return i.length>0&&l.length>0?`+${i.length} -${l.length} keys`:i.length>0?`Added: ${i.join(", ")}`:l.length>0?`Removed: ${l.join(", ")}`:"Updated"}return null}function mi(e,t){let r={};if(e.id&&(r.id=e.id),e.type&&(r.type=e.type),e.timestamp&&(r.timestamp=e.timestamp),e.queryKey&&(r.queryKey=e.queryKey),e.mutationKey&&(r.mutationKey=e.mutationKey),e.mutationId&&(r.mutationId=e.mutationId),e.duration&&(r.duration=e.duration),e.queryData!==void 0&&(r.data=t.smartJsonParsing?ke(e.queryData):e.queryData),e.variables!==void 0&&(r.variables=t.smartJsonParsing?ke(e.variables):e.variables),e.queryError!==void 0){let a=e.queryError;a&&typeof a=="object"?r.error=a.message||a.name||a:r.error=e.queryError}if(e.mutationError!==void 0){let a=e.mutationError;a&&typeof a=="object"?r.error=a.message||a.name||a:r.error=e.mutationError}if(e.query&&typeof e.query=="object"){let a=e.query;if(a.state&&typeof a.state=="object"){let o=a.state;if(o.status&&(r.status=o.status),o.fetchStatus&&(r.fetchStatus=o.fetchStatus),o.error){let n=o.error;n&&typeof n=="object"&&(r.error=n.message||n.name||n)}}}if(e.mutation&&typeof e.mutation=="object"){let a=e.mutation;if(a.state&&typeof a.state=="object"){let o=a.state;if(o.status&&(r.status=o.status),o.failureCount&&(r.failureCount=o.failureCount),o.error){let n=o.error;n&&typeof n=="object"&&(r.error=n.message||n.name||n)}if(o.failureReason){let n=o.failureReason;n&&typeof n=="object"&&(r.failureReason=n.message||n.name||n)}}}return r}function lt(e,t){let r=e.originalEvent;if(!r)return null;let a;return e.source==="storage-async"||e.source==="storage-mmkv"?a=di(r,t):e.source==="redux"?a=pi(r,t):e.source==="react-query"||e.source==="react-query-query"||e.source==="react-query-mutation"?a=mi(r,t):t.smartJsonParsing?a=ke(r):a=r,t.stripVerboseFields&&a&&(a=Pt(a)),a}function _e(e){let t={totalEvents:e.length,success:0,pending:0,error:0,neutral:0,durationMs:0,sources:new Set};if(e.length===0)return t;let r=1/0,a=-1/0;for(let o of e)t[o.status]++,t.sources.add(o.source),o.timestamp<r&&(r=o.timestamp),o.timestamp>a&&(a=o.timestamp);return t.durationMs=a-r,t}function Qe(e,t){let r=[...e];if(t.filterMode!=="all"&&(r=r.filter(a=>{switch(t.filterMode){case"errors":return a.status==="error";case"success":return a.status==="success";case"pending":return a.status==="pending";default:return true}})),t.filterSources.length>0){let a=new Set(t.filterSources);r=r.filter(o=>a.has(o.source))}return r}function Nt(e){return e<1e3?`+${e}ms`:e<6e4?`+${(e/1e3).toFixed(1)}s`:`+${(e/6e4).toFixed(1)}m`}function Rr(e){return new Date(e).toISOString()}function ut(e,t,r){let a=Nt(e-t),o=Rr(e);switch(r){case"relative":return a;case"absolute":return o;case"both":return`${a} (${o})`}}function Vt(e,t){let r=0,a=[e],o=new Set;for(;a.length>0;){if(r>t)return{over:true,approxBytes:r};let n=a.pop();if(n==null)r+=4;else if(typeof n=="string")r+=n.length+2;else if(typeof n=="number")r+=8;else if(typeof n=="boolean")r+=5;else if(typeof n=="object"){if(o.has(n))continue;if(o.add(n),Array.isArray(n)){r+=2+n.length;for(let i=0;i<n.length;i++)a.push(n[i])}else{r+=2;for(let i in n)r+=i.length+4,a.push(n[i])}}else r+=4}return{over:r>t,approxBytes:r}}function ct(e,t){if(t===-1)return{data:e,truncated:false};let{over:r,approxBytes:a}=Vt(e,t*1024);if(r)return{data:`[Data truncated - \u2265${(a/1024).toFixed(1)}KB exceeds ${t}KB limit]`,truncated:true};try{return JSON.stringify(e),{data:e,truncated:false}}catch{return{data:"[Unable to serialize data]",truncated:true}}}function jr(e,t){let r=0;for(let a of e)if(t.includeSource&&(r+=20),t.includeStatus&&(r+=10),t.includeTitle&&(r+=(a.title?.length||0)+10),t.includeSubtitle&&(r+=(a.subtitle?.length||0)+10),t.includeCorrelation&&(r+=20),t.includeDuration&&(r+=15),r+=30,t.includeEventData&&a.originalEvent){let o=t.dataSizeThreshold===-1?1048576:t.dataSizeThreshold*1024,{approxBytes:n}=Vt(a.originalEvent,o);r+=Math.min(n,o)}return t.includeSummaryHeader&&(r+=100),t.includeTotalDuration&&(r+=50),t.format==="markdown"&&(r*=1.2),t.format==="json"&&(r*=1.3),Math.round(r)}function hi(e,t,r){let a=[],o=ut(e.timestamp,t,r.timestampFormat);if(a.push(`\`${o}\``),r.includeStatus&&a.push(ze[e.status]),r.includeSource&&a.push(`**${Mt[e.source]}**`),r.includeTitle&&a.push(e.title),r.showStorageDiff&&(e.source==="storage-async"||e.source==="storage-mmkv")){let n=e.originalEvent;if(n?.data){let i=n.data,l=Ke(i.prevValue,i.value);l&&a.push(`\u2192 ${l}`)}}return e.source==="redux"&&e.originalEvent?.hasStateChange===false&&a.push("(no state change)"),r.includeSubtitle&&e.subtitle&&a.push(`- ${e.subtitle}`),a.join(" ")}function gi(e,t){let r=[],a=e.originalEvent;if(!a?.data)return r;let o=a.data,n=t.smartJsonParsing?xe(o.prevValue):o.prevValue,i=t.smartJsonParsing?xe(o.value):o.value,l=Ke(o.prevValue,o.value);if(l&&r.push(` **Change:** ${l}`),Array.isArray(n)&&Array.isArray(i)){let s=n.map(c=>typeof c=="object"&&c&&"name"in c?c.name:null).filter(Boolean),u=i.map(c=>typeof c=="object"&&c&&"name"in c?c.name:null).filter(Boolean);(s.length>0||u.length>0)&&(s.length>0&&r.push(` Before: [${s.join(", ")}]`),r.push(` After: [${u.join(", ")}]`))}return r}function Ot(e,t){let r=Qe(e,t);if(r.length===0)return"No events to export.";let a=[...r].sort((s,u)=>s.timestamp-u.timestamp),o=a[0].timestamp,n=_e(a),i=[];if(i.push("## Event Flow"),t.includeSummaryHeader||t.includeTotalDuration){let s=[];if(t.includeTotalDuration&&s.push(`**Duration:** ${Nt(n.durationMs).replace("+","")}`),s.push(`**Events:** ${n.totalEvents}`),t.includeSummaryHeader){let u=[];n.success>0&&u.push(`${n.success} ${ze.success}`),n.pending>0&&u.push(`${n.pending} ${ze.pending}`),n.error>0&&u.push(`${n.error} ${ze.error}`),n.neutral>0&&u.push(`${n.neutral} ${ze.neutral}`),u.length>0&&s.push(`**Status:** ${u.join(" ")}`)}i.push(s.join(" | "))}if(i.push(""),i.push("### Timeline"),i.push(""),t.compactMode)return a.forEach((s,u)=>{i.push(`${u+1}. ${hi(s,o,t)}`)}),i.join(`
4
+ `);a.forEach((s,u)=>{let c=[],d=ut(s.timestamp,o,t.timestampFormat);if(c.push(`${u+1}. \`${d}\``),t.includeStatus&&c.push(ze[s.status]),t.includeSource&&c.push(`**${Mt[s.source]}**`),t.includeTitle&&c.push(s.title),t.includeCorrelation&&s.correlationId&&s.sequenceInGroup&&c.push(`(${s.sequenceInGroup})`),i.push(c.join(" ")),t.includeSubtitle&&s.subtitle&&i.push(` \u2514\u2500 ${s.subtitle}`),t.showStorageDiff&&!t.includeEventData&&(s.source==="storage-async"||s.source==="storage-mmkv")){let h=gi(s,t);i.push(...h)}if(t.includeEventData&&s.originalEvent){let h=lt(s,t),{data:b,truncated:v}=ct(h,t.dataSizeThreshold);if(v)i.push(` \u2514\u2500 ${b}`);else{if(t.showStorageDiff&&(s.source==="storage-async"||s.source==="storage-mmkv")){let m=s.originalEvent;if(m?.data){let y=m.data,p=Ke(y.prevValue,y.value);p&&i.push(` **Change:** ${p}`)}}i.push(" ```json"),i.push(` ${JSON.stringify(b,null,2).split(`
5
5
  `).join(`
6
- `)}`),i.push(" ```")}}i.push("")});let l=a.filter(s=>s.status==="error");if(l.length>0&&t.includeEventData){i.push("---"),i.push(""),i.push("### Errors"),i.push("");for(let s of l){let u=lt(s.timestamp,o,t.timestampFormat);if(i.push(`**${s.title}** (${u})`),s.originalEvent){let c=st(s,t),{data:d,truncated:h}=ut(c,t.dataSizeThreshold);h||(i.push("```json"),i.push(JSON.stringify(d,null,2)),i.push("```"))}i.push("")}}return i.join(`
7
- `)}function Rr(e,t){let r=Qe(e,t);if(r.length===0)return"[]";let a=[...r].sort((l,s)=>l.timestamp-s.timestamp),o=a[0].timestamp,n=_e(a),i={exportedAt:new Date().toISOString()};return t.includeSummaryHeader&&(i.summary={totalEvents:n.totalEvents,success:n.success,pending:n.pending,error:n.error,neutral:n.neutral,durationMs:n.durationMs,sources:Array.from(n.sources)}),i.events=a.map(l=>{let s={};if(s.timestamp=Br(l.timestamp),(t.timestampFormat==="relative"||t.timestampFormat==="both")&&(s.relativeMs=l.timestamp-o),t.includeSource&&(s.source=l.source),t.includeStatus&&(s.status=l.status),t.includeTitle&&(s.title=l.title),t.includeSubtitle&&(s.subtitle=l.subtitle),t.includeCorrelation&&l.correlationId&&(s.correlationId=l.correlationId,s.sequenceInGroup=l.sequenceInGroup),t.includeEventData&&l.originalEvent){let u=st(l,t),{data:c,truncated:d}=ut(u,t.dataSizeThreshold);if(s.data=c,d&&(s.dataTruncated=true),t.showStorageDiff&&(l.source==="storage-async"||l.source==="storage-mmkv")){let h=l.originalEvent;if(h?.data){let b=h.data,v=Ke(b.prevValue,b.value);v&&(s.changeSummary=v)}}}return s}),JSON.stringify(i,null,2)}function jr(e,t){let r=Qe(e,t);if(r.length===0)return"No events to export.";let a=[...r].sort((l,s)=>l.timestamp-s.timestamp),o=a[0].timestamp,n=_e(a),i=[];if(t.includeSummaryHeader||t.includeTotalDuration){let l=[`Event Flow (${n.totalEvents} events`];if(t.includeTotalDuration&&(l[0]+=`, ${Mt(n.durationMs).replace("+","")}`),l[0]+=")",i.push(l[0]),t.includeSummaryHeader){let s=[];n.success>0&&s.push(`${n.success} success`),n.pending>0&&s.push(`${n.pending} pending`),n.error>0&&s.push(`${n.error} error`),n.neutral>0&&s.push(`${n.neutral} neutral`),s.length>0&&i.push(s.join(", "))}i.push("")}for(let l of a){let s=[],u=lt(l.timestamp,o,t.timestampFormat);if(s.push(u.padEnd(12)),t.includeStatus&&s.push(ti[l.status]),t.includeSource&&s.push(`${jt[l.source]}:`),t.includeTitle&&s.push(l.title),t.showStorageDiff&&(l.source==="storage-async"||l.source==="storage-mmkv")){let c=l.originalEvent;if(c?.data){let d=c.data,h=Ke(d.prevValue,d.value);h&&s.push(`-> ${h}`)}}if(l.source==="redux"&&l.originalEvent?.hasStateChange===false&&s.push("(no change)"),t.includeSubtitle&&l.subtitle&&s.push(`- ${l.subtitle}`),i.push(s.join(" ")),t.includeEventData&&l.originalEvent){let c=st(l,t),{data:d,truncated:h}=ut(c,t.dataSizeThreshold);h?i.push(` ${d}`):i.push(` Data: ${JSON.stringify(d)}`)}}return i.join(`
8
- `)}var Vt=[{id:"U",icon:"\u{1F464}",label:"User",sources:[],group:"client"},{id:"App",icon:"\u{1F4F1}",label:"App",sources:["route","render"],group:"client"},{id:"Async",icon:"\u{1F4BE}",label:"AsyncStorage",sources:["storage-async"],group:"client"},{id:"MMKV",icon:"\u26A1",label:"MMKV",sources:["storage-mmkv"],group:"client"},{id:"Redux",icon:"\u{1F504}",label:"Redux",sources:["redux"],group:"client"},{id:"API",icon:"\u{1F310}",label:"API",sources:["network"],group:"server"},{id:"Cache",icon:"\u{1F4E6}",label:"QueryCache",sources:["react-query","react-query-query","react-query-mutation"],group:"server"}];function di(e){let t=new Set;for(let a of e)t.add(a.source);let r=[];r.push(Vt[0]),r.push(Vt[1]);for(let a of Vt.slice(2))a.sources.some(o=>t.has(o))&&r.push(a);return r}function pi(e){let t=e.some(a=>a.group==="client"),r=e.some(a=>a.group==="server");return t&&r&&e.length>=3}function ke(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function Ge(e){return e.replace(/[#;:]/g," ").replace(/[\n\r]/g," ").replace(/"/g,"'").replace(/\s+/g," ").trim()}function mi(e){let t=["last-route","@dev/last","__debug","_persist","devtools/internal"],r=e.toLowerCase();return t.some(a=>r.includes(a))}function Ot(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function hi(e){return Pt(e,1024*1024).approxBytes}function gi(e){try{let t=new URL(e,"http://localhost");return["timestamp","t","_t","debug","client","version","cache","_"].forEach(r=>t.searchParams.delete(r)),t.pathname+(t.searchParams.toString()?"?"+t.searchParams.toString():"")}catch{return e}}function fi(e){let t=e.replace(/^@[\w-]+\//,"").replace(/^devtools\//,"").replace(/^dev\//,"").replace(/^buoy\//,"").replace(/^pokemon\//,""),r=t.split("/").filter(Boolean);return r.length>1&&(t=r.slice(-1).join("/")),t=t.replace(/-/g," ").replace(/_/g," "),t=t.split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" "),t.toLowerCase()==="saved"&&(t="Favorites"),t.substring(0,20)}function zr(e){let t=e;try{t=new URL(e,"http://localhost").pathname}catch{let a=t.indexOf("?");a>0&&(t=t.substring(0,a))}let r=t.split("/").filter(Boolean);if(r.length>=2){let a=r[r.length-1];return/^\d+$/.test(a)||/^[a-f0-9-]{36}$/i.test(a)?null:a.charAt(0).toUpperCase()+a.slice(1)}return r.length===1?r[0].charAt(0).toUpperCase()+r[0].slice(1):null}function yi(e,t){try{let r=new URL(t,"http://localhost"),a=r.pathname;if(a.includes("graphql"))return"GraphQL Request";a=a.replace(/^\/api\/v\d+/,"").replace(/^\/api/,"");let o=zr(a),n=a.split("/").filter(Boolean),i=n[0]?n[0].charAt(0).toUpperCase()+n[0].slice(1):"Data",l=r.searchParams.has("q")||r.searchParams.has("query")||r.searchParams.has("search");switch(e.toUpperCase()){case"GET":if(l){let s=r.searchParams.get("q")||r.searchParams.get("query")||r.searchParams.get("search");return s?`Search "${s}"`:`Search ${i}`}return o?`Fetch ${o}`:`Fetch ${i}`;case"POST":return a.includes("search")?`Search ${i}`:o?`Create ${o}`:`Create ${i}`;case"PUT":case"PATCH":return o?`Update ${o}`:`Update ${i}`;case"DELETE":return o?`Delete ${o}`:`Delete ${i}`;default:return`${e} ${i}`}}catch{return`${e} request`}}function Mr(e){if(e==="/"||e==="")return"Home";let t=e.split("/").filter(Boolean);if(t.length===0)return"Home";if(t.length===1)return`${t[0].charAt(0).toUpperCase()+t[0].slice(1)} List`;if(t.length>=2){let r=t[t.length-1];return/^\d+$/.test(r)?`${t[0].charAt(0).toUpperCase()+t[0].slice(1)} #${r}`:`${r.charAt(0).toUpperCase()+r.slice(1)} Details`}return e}function bi(e,t,r){let a=[],o=[],n=ke(e.timestamp-r);switch(e.source){case"route":{let i=e.originalEvent,l=String(i?.pathname||e.title),s=i?.previousPathname,u=i?.timeSincePrevious,c=Mr(l),d=s?Mr(s):null;d?(a.push(`U->>App: ${d} \u2192 ${c}`),u&&u>0&&o.push(`Note right of App: ${ke(u)} on ${d}`)):a.push(`U->>App: Open ${c}`);break}case"network":{let i=e.originalEvent,l=i?.method||"GET",s=i?.url||"",u=i?.status,c=i?.duration,d=i?.response||i?.data||i?.body,h=i?.responseSize||i?.size||i?.contentLength,b=yi(l,s),v=zr(s);if(a.push(`App->>+API: ${b}`),e.status==="error"){let y=u?`${u} Error`:"Failed";a.push(`API--x-App: ${y}`)}else{let y=v?`\u2713 ${v}`:"\u2713 Success";a.push(`API-->>-App: ${y}`)}let m=[];if(c&&m.push(ke(c)),h&&h>0)m.push(Ot(h));else if(d){let y=hi(d);y>1024&&m.push(Ot(y))}m.length>0&&o.push(`Note right of API: ${m.join(" \xB7 ")}`);break}case"storage-async":case"storage-mmkv":{let i=e.originalEvent,l=i?.data,s=i?.action||"access",u=l?.key||"data";if(mi(u))return{messages:[],notes:[],skip:true};let c=fi(u),d=e.source==="storage-mmkv"?"MMKV":"Async",h=C=>{if(typeof C=="string")return C;if(typeof C=="number")return String(C);if(typeof C=="object"&&C){if("name"in C)return String(C.name);if("id"in C)return String(C.id)}return null},b=C=>C.charAt(0).toUpperCase()+C.slice(1),v="",m="",y="",p="",g=l?.prevValue,$=l?.value;if(Array.isArray(g)&&Array.isArray($)){let C=g.length,I=$.length;if(p=`${C} \u2192 ${I} items`,I>C){v="\u2795",m="Add";let x=new Set(g.map(h).filter(Boolean));for(let j of $){let N=h(j);if(N&&!x.has(N)){y=b(N);break}}}else if(I<C){v="\u2796",m="Remove";let x=new Set($.map(h).filter(Boolean));for(let j of g){let N=h(j);if(N&&!x.has(N)){y=b(N);break}}}else v="\u{1F4DD}",m="Update"}else if(Array.isArray($)&&(!g||Array.isArray(g)&&g.length===0)){if(v="\u2795",m="Add",p=`\u2192 ${$.length} items`,$.length>0){let C=h($[0]);C&&(y=b(C))}}else Array.isArray(g)&&(!$||Array.isArray($)&&$.length===0)?(v="\u2796",m="Clear",p=`${g.length} \u2192 0 items`):s==="getItem"?(v="\u{1F4D6}",m="Load"):s==="removeItem"?(v="\u2796",m="Remove"):s==="clear"?(v="\u{1F5D1}\uFE0F",m="Clear"):(v="\u{1F4BE}",m="Save");let L;y?L=`App->>${d}: ${v} ${m} ${y} \u2192 ${c}`:L=`App->>${d}: ${v} ${m} ${c}`,a.push(L),p&&o.push(`Note right of ${d}: ${p}`);break}case"react-query":case"react-query-query":{let i=e.originalEvent,l=i?.type||"",s=i?.queryKey,u=i?.duration,c="data";if(Array.isArray(s)&&s.length>0){let d=s[s.length-1];typeof d=="string"&&!/^\d+$/.test(d)?c=d.charAt(0).toUpperCase()+d.slice(1):s.length>1&&typeof s[0]=="string"&&(c=s[0].charAt(0).toUpperCase()+s[0].slice(1))}if(l.includes("start")||l.includes("fetch")||e.status==="pending")a.push(`App->>+Cache: Fetch ${c}`);else if(e.status==="error")a.push("Cache--x-App: Failed to load");else if(e.status==="success"){let d=`\u2713 ${c} ready`;u&&(d+=` (${ke(u)})`),a.push(`Cache-->>-App: ${d}`)}else l.includes("invalidate")?a.push(`App->>Cache: Refresh ${c}`):a.push(`Cache-->>App: ${Ge(l)}`);break}case"react-query-mutation":{let i=e.originalEvent,l=i?.type||"",s=i?.mutationKey,u=i?.duration,c="Update";if(Array.isArray(s)&&s.length>0){let d=String(s[0]);d.includes("add")||d.includes("create")?c="Add":d.includes("delete")||d.includes("remove")?c="Delete":d.includes("update")||d.includes("edit")?c="Update":c=d.charAt(0).toUpperCase()+d.slice(1)}if(l.includes("start")||l.includes("loading")||e.status==="pending")a.push(`App->>+Cache: ${c}`);else if(e.status==="error")a.push(`Cache--x-App: ${c} failed`);else if(e.status==="success"){let d=`\u2713 ${c} complete`;u&&(d+=` (${ke(u)})`),a.push(`Cache-->>-App: ${d}`)}break}case"redux":{let i=e.originalEvent,l=i?.type||e.title,s=i?.hasStateChange,u=i?.diffSummary,c=l.split("/"),d;if(c.length>=2){let h=c[0].charAt(0).toUpperCase()+c[0].slice(1),b=c[1].replace(/([A-Z])/g," $1").replace(/(pending|fulfilled|rejected)$/i,"").trim();b=b.charAt(0).toUpperCase()+b.slice(1),d=`${b} (${h})`}else d=Ge(l).substring(0,25);a.push(`App->>Redux: ${d}`),s===false?o.push("Note right of Redux: No change"):u&&o.push(`Note right of Redux: ${Ge(u).substring(0,35)}`);break}case"render":{let i=e.originalEvent?.renderData,l=Ge(e.title).substring(0,20),s=i?.cause||"update",u=s==="mount"?"mounted":s==="props"?"props changed":s==="state"?"state changed":s==="context"?"context changed":s==="parent"?"parent re-rendered":s==="hooks"?"hook changed":s;a.push(`App->>App: Render ${l}`),o.push(`Note right of App: ${u}`);break}default:a.push(`App->>App: ${Ge(e.title).substring(0,30)}`)}return{messages:a,notes:o}}function Pr(e,t){let r=Qe(e,t);if(r.length===0)return`sequenceDiagram
6
+ `)}`),i.push(" ```")}}i.push("")});let l=a.filter(s=>s.status==="error");if(l.length>0&&t.includeEventData){i.push("---"),i.push(""),i.push("### Errors"),i.push("");for(let s of l){let u=ut(s.timestamp,o,t.timestampFormat);if(i.push(`**${s.title}** (${u})`),s.originalEvent){let c=lt(s,t),{data:d,truncated:h}=ct(c,t.dataSizeThreshold);h||(i.push("```json"),i.push(JSON.stringify(d,null,2)),i.push("```"))}i.push("")}}return i.join(`
7
+ `)}function zr(e,t){let r=Qe(e,t);if(r.length===0)return"[]";let a=[...r].sort((l,s)=>l.timestamp-s.timestamp),o=a[0].timestamp,n=_e(a),i={exportedAt:new Date().toISOString()};return t.includeSummaryHeader&&(i.summary={totalEvents:n.totalEvents,success:n.success,pending:n.pending,error:n.error,neutral:n.neutral,durationMs:n.durationMs,sources:Array.from(n.sources)}),i.events=a.map(l=>{let s={};if(s.timestamp=Rr(l.timestamp),(t.timestampFormat==="relative"||t.timestampFormat==="both")&&(s.relativeMs=l.timestamp-o),t.includeSource&&(s.source=l.source),t.includeStatus&&(s.status=l.status),t.includeTitle&&(s.title=l.title),t.includeSubtitle&&(s.subtitle=l.subtitle),t.includeCorrelation&&l.correlationId&&(s.correlationId=l.correlationId,s.sequenceInGroup=l.sequenceInGroup),t.includeEventData&&l.originalEvent){let u=lt(l,t),{data:c,truncated:d}=ct(u,t.dataSizeThreshold);if(s.data=c,d&&(s.dataTruncated=true),t.showStorageDiff&&(l.source==="storage-async"||l.source==="storage-mmkv")){let h=l.originalEvent;if(h?.data){let b=h.data,v=Ke(b.prevValue,b.value);v&&(s.changeSummary=v)}}}return s}),JSON.stringify(i,null,2)}function Mr(e,t){let r=Qe(e,t);if(r.length===0)return"No events to export.";let a=[...r].sort((l,s)=>l.timestamp-s.timestamp),o=a[0].timestamp,n=_e(a),i=[];if(t.includeSummaryHeader||t.includeTotalDuration){let l=[`Event Flow (${n.totalEvents} events`];if(t.includeTotalDuration&&(l[0]+=`, ${Nt(n.durationMs).replace("+","")}`),l[0]+=")",i.push(l[0]),t.includeSummaryHeader){let s=[];n.success>0&&s.push(`${n.success} success`),n.pending>0&&s.push(`${n.pending} pending`),n.error>0&&s.push(`${n.error} error`),n.neutral>0&&s.push(`${n.neutral} neutral`),s.length>0&&i.push(s.join(", "))}i.push("")}for(let l of a){let s=[],u=ut(l.timestamp,o,t.timestampFormat);if(s.push(u.padEnd(12)),t.includeStatus&&s.push(ii[l.status]),t.includeSource&&s.push(`${Mt[l.source]}:`),t.includeTitle&&s.push(l.title),t.showStorageDiff&&(l.source==="storage-async"||l.source==="storage-mmkv")){let c=l.originalEvent;if(c?.data){let d=c.data,h=Ke(d.prevValue,d.value);h&&s.push(`-> ${h}`)}}if(l.source==="redux"&&l.originalEvent?.hasStateChange===false&&s.push("(no change)"),t.includeSubtitle&&l.subtitle&&s.push(`- ${l.subtitle}`),i.push(s.join(" ")),t.includeEventData&&l.originalEvent){let c=lt(l,t),{data:d,truncated:h}=ct(c,t.dataSizeThreshold);h?i.push(` ${d}`):i.push(` Data: ${JSON.stringify(d)}`)}}return i.join(`
8
+ `)}var Ut=[{id:"U",icon:"\u{1F464}",label:"User",sources:[],group:"client"},{id:"App",icon:"\u{1F4F1}",label:"App",sources:["route","render"],group:"client"},{id:"Async",icon:"\u{1F4BE}",label:"AsyncStorage",sources:["storage-async"],group:"client"},{id:"MMKV",icon:"\u26A1",label:"MMKV",sources:["storage-mmkv"],group:"client"},{id:"Redux",icon:"\u{1F504}",label:"Redux",sources:["redux"],group:"client"},{id:"API",icon:"\u{1F310}",label:"API",sources:["network"],group:"server"},{id:"Cache",icon:"\u{1F4E6}",label:"QueryCache",sources:["react-query","react-query-query","react-query-mutation"],group:"server"}];function fi(e){let t=new Set;for(let a of e)t.add(a.source);let r=[];r.push(Ut[0]),r.push(Ut[1]);for(let a of Ut.slice(2))a.sources.some(o=>t.has(o))&&r.push(a);return r}function yi(e){let t=e.some(a=>a.group==="client"),r=e.some(a=>a.group==="server");return t&&r&&e.length>=3}function $e(e){return e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${(e/6e4).toFixed(1)}m`}function Ge(e){return e.replace(/[#;:]/g," ").replace(/[\n\r]/g," ").replace(/"/g,"'").replace(/\s+/g," ").trim()}function bi(e){let t=["last-route","@dev/last","__debug","_persist","devtools/internal"],r=e.toLowerCase();return t.some(a=>r.includes(a))}function Lt(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function vi(e){return Vt(e,1024*1024).approxBytes}function Si(e){try{let t=new URL(e,"http://localhost");return["timestamp","t","_t","debug","client","version","cache","_"].forEach(r=>t.searchParams.delete(r)),t.pathname+(t.searchParams.toString()?"?"+t.searchParams.toString():"")}catch{return e}}function Ci(e){let t=e.replace(/^@[\w-]+\//,"").replace(/^devtools\//,"").replace(/^dev\//,"").replace(/^buoy\//,"").replace(/^pokemon\//,""),r=t.split("/").filter(Boolean);return r.length>1&&(t=r.slice(-1).join("/")),t=t.replace(/-/g," ").replace(/_/g," "),t=t.split(" ").map(a=>a.charAt(0).toUpperCase()+a.slice(1).toLowerCase()).join(" "),t.toLowerCase()==="saved"&&(t="Favorites"),t.substring(0,20)}function Pr(e){let t=e;try{t=new URL(e,"http://localhost").pathname}catch{let a=t.indexOf("?");a>0&&(t=t.substring(0,a))}let r=t.split("/").filter(Boolean);if(r.length>=2){let a=r[r.length-1];return/^\d+$/.test(a)||/^[a-f0-9-]{36}$/i.test(a)?null:a.charAt(0).toUpperCase()+a.slice(1)}return r.length===1?r[0].charAt(0).toUpperCase()+r[0].slice(1):null}function wi(e,t){try{let r=new URL(t,"http://localhost"),a=r.pathname;if(a.includes("graphql"))return"GraphQL Request";a=a.replace(/^\/api\/v\d+/,"").replace(/^\/api/,"");let o=Pr(a),n=a.split("/").filter(Boolean),i=n[0]?n[0].charAt(0).toUpperCase()+n[0].slice(1):"Data",l=r.searchParams.has("q")||r.searchParams.has("query")||r.searchParams.has("search");switch(e.toUpperCase()){case"GET":if(l){let s=r.searchParams.get("q")||r.searchParams.get("query")||r.searchParams.get("search");return s?`Search "${s}"`:`Search ${i}`}return o?`Fetch ${o}`:`Fetch ${i}`;case"POST":return a.includes("search")?`Search ${i}`:o?`Create ${o}`:`Create ${i}`;case"PUT":case"PATCH":return o?`Update ${o}`:`Update ${i}`;case"DELETE":return o?`Delete ${o}`:`Delete ${i}`;default:return`${e} ${i}`}}catch{return`${e} request`}}function Nr(e){if(e==="/"||e==="")return"Home";let t=e.split("/").filter(Boolean);if(t.length===0)return"Home";if(t.length===1)return`${t[0].charAt(0).toUpperCase()+t[0].slice(1)} List`;if(t.length>=2){let r=t[t.length-1];return/^\d+$/.test(r)?`${t[0].charAt(0).toUpperCase()+t[0].slice(1)} #${r}`:`${r.charAt(0).toUpperCase()+r.slice(1)} Details`}return e}function Ei(e,t,r){let a=[],o=[],n=$e(e.timestamp-r);switch(e.source){case"route":{let i=e.originalEvent,l=String(i?.pathname||e.title),s=i?.previousPathname,u=i?.timeSincePrevious,c=Nr(l),d=s?Nr(s):null;d?(a.push(`U->>App: ${d} \u2192 ${c}`),u&&u>0&&o.push(`Note right of App: ${$e(u)} on ${d}`)):a.push(`U->>App: Open ${c}`);break}case"network":{let i=e.originalEvent,l=i?.method||"GET",s=i?.url||"",u=i?.status,c=i?.duration,d=i?.response||i?.data||i?.body,h=i?.responseSize||i?.size||i?.contentLength,b=wi(l,s),v=Pr(s);if(a.push(`App->>+API: ${b}`),e.status==="error"){let y=u?`${u} Error`:"Failed";a.push(`API--x-App: ${y}`)}else{let y=v?`\u2713 ${v}`:"\u2713 Success";a.push(`API-->>-App: ${y}`)}let m=[];if(c&&m.push($e(c)),h&&h>0)m.push(Lt(h));else if(d){let y=vi(d);y>1024&&m.push(Lt(y))}m.length>0&&o.push(`Note right of API: ${m.join(" \xB7 ")}`);break}case"storage-async":case"storage-mmkv":{let i=e.originalEvent,l=i?.data,s=i?.action||"access",u=l?.key||"data";if(bi(u))return{messages:[],notes:[],skip:true};let c=Ci(u),d=e.source==="storage-mmkv"?"MMKV":"Async",h=C=>{if(typeof C=="string")return C;if(typeof C=="number")return String(C);if(typeof C=="object"&&C){if("name"in C)return String(C.name);if("id"in C)return String(C.id)}return null},b=C=>C.charAt(0).toUpperCase()+C.slice(1),v="",m="",y="",p="",g=l?.prevValue,k=l?.value;if(Array.isArray(g)&&Array.isArray(k)){let C=g.length,I=k.length;if(p=`${C} \u2192 ${I} items`,I>C){v="\u2795",m="Add";let x=new Set(g.map(h).filter(Boolean));for(let j of k){let N=h(j);if(N&&!x.has(N)){y=b(N);break}}}else if(I<C){v="\u2796",m="Remove";let x=new Set(k.map(h).filter(Boolean));for(let j of g){let N=h(j);if(N&&!x.has(N)){y=b(N);break}}}else v="\u{1F4DD}",m="Update"}else if(Array.isArray(k)&&(!g||Array.isArray(g)&&g.length===0)){if(v="\u2795",m="Add",p=`\u2192 ${k.length} items`,k.length>0){let C=h(k[0]);C&&(y=b(C))}}else Array.isArray(g)&&(!k||Array.isArray(k)&&k.length===0)?(v="\u2796",m="Clear",p=`${g.length} \u2192 0 items`):s==="getItem"?(v="\u{1F4D6}",m="Load"):s==="removeItem"?(v="\u2796",m="Remove"):s==="clear"?(v="\u{1F5D1}\uFE0F",m="Clear"):(v="\u{1F4BE}",m="Save");let L;y?L=`App->>${d}: ${v} ${m} ${y} \u2192 ${c}`:L=`App->>${d}: ${v} ${m} ${c}`,a.push(L),p&&o.push(`Note right of ${d}: ${p}`);break}case"react-query":case"react-query-query":{let i=e.originalEvent,l=i?.type||"",s=i?.queryKey,u=i?.duration,c="data";if(Array.isArray(s)&&s.length>0){let d=s[s.length-1];typeof d=="string"&&!/^\d+$/.test(d)?c=d.charAt(0).toUpperCase()+d.slice(1):s.length>1&&typeof s[0]=="string"&&(c=s[0].charAt(0).toUpperCase()+s[0].slice(1))}if(l.includes("start")||l.includes("fetch")||e.status==="pending")a.push(`App->>+Cache: Fetch ${c}`);else if(e.status==="error")a.push("Cache--x-App: Failed to load");else if(e.status==="success"){let d=`\u2713 ${c} ready`;u&&(d+=` (${$e(u)})`),a.push(`Cache-->>-App: ${d}`)}else l.includes("invalidate")?a.push(`App->>Cache: Refresh ${c}`):a.push(`Cache-->>App: ${Ge(l)}`);break}case"react-query-mutation":{let i=e.originalEvent,l=i?.type||"",s=i?.mutationKey,u=i?.duration,c="Update";if(Array.isArray(s)&&s.length>0){let d=String(s[0]);d.includes("add")||d.includes("create")?c="Add":d.includes("delete")||d.includes("remove")?c="Delete":d.includes("update")||d.includes("edit")?c="Update":c=d.charAt(0).toUpperCase()+d.slice(1)}if(l.includes("start")||l.includes("loading")||e.status==="pending")a.push(`App->>+Cache: ${c}`);else if(e.status==="error")a.push(`Cache--x-App: ${c} failed`);else if(e.status==="success"){let d=`\u2713 ${c} complete`;u&&(d+=` (${$e(u)})`),a.push(`Cache-->>-App: ${d}`)}break}case"redux":{let i=e.originalEvent,l=i?.type||e.title,s=i?.hasStateChange,u=i?.diffSummary,c=l.split("/"),d;if(c.length>=2){let h=c[0].charAt(0).toUpperCase()+c[0].slice(1),b=c[1].replace(/([A-Z])/g," $1").replace(/(pending|fulfilled|rejected)$/i,"").trim();b=b.charAt(0).toUpperCase()+b.slice(1),d=`${b} (${h})`}else d=Ge(l).substring(0,25);a.push(`App->>Redux: ${d}`),s===false?o.push("Note right of Redux: No change"):u&&o.push(`Note right of Redux: ${Ge(u).substring(0,35)}`);break}case"render":{let i=e.originalEvent?.renderData,l=Ge(e.title).substring(0,20),s=i?.cause||"update",u=s==="mount"?"mounted":s==="props"?"props changed":s==="state"?"state changed":s==="context"?"context changed":s==="parent"?"parent re-rendered":s==="hooks"?"hook changed":s;a.push(`App->>App: Render ${l}`),o.push(`Note right of App: ${u}`);break}default:a.push(`App->>App: ${Ge(e.title).substring(0,30)}`)}return{messages:a,notes:o}}function Vr(e,t){let r=Qe(e,t);if(r.length===0)return`sequenceDiagram
9
9
  participant U as \u{1F464} User
10
10
  participant App as \u{1F4F1} App
11
- Note over U,App: No events captured`;let a=[...r].sort((m,y)=>m.timestamp-y.timestamp),o=a[0].timestamp,n=di(a),i=pi(n),l=["sequenceDiagram"];if(l.push(" autonumber"),l.push(""),i){let m=n.filter(p=>p.group==="client"),y=n.filter(p=>p.group==="server");if(m.length>0){l.push(" box rgb(240, 248, 255) Client");for(let p of m)l.push(` participant ${p.id} as ${p.icon} ${p.label}`);l.push(" end")}if(y.length>0){l.push(" box rgb(255, 248, 240) External");for(let p of y)l.push(` participant ${p.id} as ${p.icon} ${p.label}`);l.push(" end")}}else for(let m of n)l.push(` participant ${m.id} as ${m.icon} ${m.label}`);l.push("");let s=a[a.length-1].timestamp-o,u=a.filter(m=>m.source==="network"),c=u.reduce((m,y)=>{let p=y.originalEvent,g=p?.responseSize||p?.size||0;return m+g},0),d=a.filter(m=>m.status==="error").length,h=[];h.push(`\u23F1\uFE0F ${ke(s)}`),h.push(`\u{1F4CA} ${a.length} events`),u.length>0&&h.push(`\u{1F310} ${u.length} API calls`),c>0&&h.push(`\u{1F4E6} ${Ot(c)}`),d>0&&h.push(`\u274C ${d} errors`),l.push(` Note over U,API: ${h.join(" \xB7 ")}`),l.push("");let b=new Map,v=0;for(let m of a){let y=bi(m,t,o);if(y.skip){v++;continue}let{messages:p,notes:g}=y,$=false,L="";if(m.source==="network"){let C=m.originalEvent?.url;if(C){let I=gi(C),x=b.get(I);if(x&&m.timestamp-x.timestamp<3e4){$=true;let j=m.timestamp-x.timestamp;L=`\u26A0\uFE0F Already fetched ${ke(j)} ago`,b.set(I,{timestamp:m.timestamp,count:x.count+1})}else b.set(I,{timestamp:m.timestamp,count:1})}}if($){l.push(" rect rgb(255, 245, 230)"),l.push(` Note over App,API: ${L}`);for(let C of p)l.push(` ${C}`);for(let C of g)l.push(` ${C}`);l.push(" end")}else if(m.status==="error"){l.push(" rect rgb(255, 235, 235)");for(let C of p)l.push(` ${C}`);for(let C of g)l.push(` ${C}`);l.push(" end")}else{for(let C of p)l.push(` ${C}`);for(let C of g)l.push(` ${C}`)}}return v>0&&(l.push(""),l.push(` Note over App: ${v} internal events hidden`)),l.join(`
12
- `)}function Ut(e,t){switch(t.format){case"markdown":return Nt(e,t);case"json":return Rr(e,t);case"plaintext":return jr(e,t);case"mermaid":return Pr(e,t);default:return Nt(e,t)}}import{definePersistedSetting as vi,devToolsStorageKeys as Si}from"@buoy-gg/shared-ui/web";var Lt=vi(Si.events.copySettings(),Je,{sanitize:(e,t)=>({...e,filterSources:t?.filterSources??Je.filterSources})});async function Nr(e){await Lt.save(e)}async function Vr(){return Lt.loadOrNull()}async function Ci(){await Lt.clear()}import{Fragment as wi,jsx as ae,jsxs as Ht}from"react/jsx-runtime";var Ei=50*1024,xi=200*1024;function $i(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function ki(){let e=Date.now();return[{id:"mock-1",source:"storage-async",timestamp:e-2e3,title:"Set Item",subtitle:"user_cart",status:"success",originalEvent:{action:"setItem",key:"user_cart",value:{items:2}}},{id:"mock-2",source:"react-query-query",timestamp:e-1500,title:"cart \u203A items",subtitle:"Fetching...",status:"pending",originalEvent:{type:"query-fetch-start",queryKey:["cart","items"]},correlationId:"rq-query-cart",sequenceInGroup:1},{id:"mock-3",source:"react-query-query",timestamp:e-1e3,title:"cart \u203A items",subtitle:"Success \xB7 500ms",status:"success",originalEvent:{type:"query-fetch-success",queryKey:["cart","items"],data:{items:[]}},correlationId:"rq-query-cart",sequenceInGroup:2},{id:"mock-4",source:"network",timestamp:e-500,title:"POST /api/checkout",subtitle:"402 \xB7 450ms",status:"error",originalEvent:{method:"POST",url:"/api/checkout",status:402,error:"Payment required"}}]}function Or({events:e=[],initialSettings:t=Je,onSettingsChange:r}){let{isPro:a}=Gn(),[o,n]=Rt(t),[i,l]=Rt(false),[s,u]=Rt(false);Ln(()=>{let I=true;return Vr().then(x=>{I&&x&&(n(x),r?.(x)),I&&u(true)}),()=>{I=false}},[r]);let c=je(I=>{n(I),r?.(I),Nr(I)},[r]),d=e.length>0,h=d?e:ki(),b=it(()=>Ar(o),[o]),v=it(()=>Fr(h,o),[h,o]),m=it(()=>v>=xi?"danger":v>=Ei?"warning":"none",[v]),y=je(()=>Ut(h,o),[h,o]),p=je(I=>{let x=We[I];c({...x,filterSources:[...x.filterSources]})},[c]),g=je((I,x)=>{let[j,N]=I.split("::");if(j==="preset"){p(N);return}if(j==="include"){c({...o,[N]:!o[N]});return}if(j==="format"){c({...o,format:x});return}if(j==="timestamp"){c({...o,timestampFormat:x});return}if(j==="filter"){c({...o,filterMode:x});return}if(j==="threshold"){c({...o,dataSizeThreshold:x});return}},[o,c,p]),$=je(()=>{let I=h.length;return ae(Yn,{expanded:i,onExpandedChange:l,summary:`${I} event${I!==1?"s":""} \xB7 ~${$i(v)}${d?"":" (mock data)"}`,warningLevel:m,warningText:{warning:"Large payload - preview may be slow",danger:"Very large payload - may cause performance issues"},testIDs:{expand:`${S}-preview-expand`,collapse:`${S}-preview-collapse`,summary:`${S}-preview-summary`,warning:`${S}-preview-size-warning`},renderBody:()=>{let x=y();return o.format==="json"?ae(ei,{testIDPrefix:`${S}-preview-json`,data:JSON.parse(x),title:"",showTypeFilter:true,rawMode:true,initialExpanded:true}):Ht(f,{children:[o.format==="mermaid"&&ae(k,{style:De.mermaidHint,children:"\u{1F4A1} Paste into mermaid.live to visualize"}),ae(ue,{style:De.previewScroll,nestedScrollEnabled:true,testID:`${S}-preview-scroll`,children:ae(k,{style:De.previewText,selectable:a,testID:`${S}-preview-text`,children:x})})]})}})},[i,h,o,v,m,d,y,a]),L=je(()=>{let I=_e(h),x=d?`${I.totalEvents} events`:"Mock data (no events captured)";return Ht(wi,{children:[ae(k,{style:De.statusLabel,testID:`${S}-export-status`,children:x}),ae(Qn,{value:y()})]})},[d,h,y]),C=it(()=>({sections:[{id:"presets",title:"Presets",type:"custom",data:[{id:"preset::llm",label:P.llm.label,icon:Jn,color:P.llm.color,value:"llm",isActive:b==="llm",description:P.llm.description},{id:"preset::bugReport",label:P.bugReport.label,icon:Wn,color:P.bugReport.color,value:"bugReport",isActive:b==="bugReport",description:P.bugReport.description},{id:"preset::json",label:P.json.label,icon:Dr,color:P.json.color,value:"json",isActive:b==="json",description:P.json.description},{id:"preset::errors",label:P.errors.label,icon:Tr,color:P.errors.color,value:"errors",isActive:b==="errors",description:P.errors.description},{id:"preset::minimal",label:P.minimal.label,icon:kr,color:P.minimal.color,value:"minimal",isActive:b==="minimal",description:P.minimal.description},{id:"preset::mermaid",label:P.mermaid.label,icon:Ir,color:P.mermaid.color,value:"mermaid",isActive:b==="mermaid",description:P.mermaid.description},{id:"preset::custom",label:"Custom",icon:Kn,color:He.color.textSecondary,value:"custom",isActive:b===null,description:"User-configured"}]},{id:"include",title:"Include",type:"custom",data:[{id:"include::includeSource",label:"Source",value:"includeSource",isActive:o.includeSource},{id:"include::includeStatus",label:"Status",value:"includeStatus",isActive:o.includeStatus},{id:"include::includeTitle",label:"Title",value:"includeTitle",isActive:o.includeTitle},{id:"include::includeSubtitle",label:"Subtitle",value:"includeSubtitle",isActive:o.includeSubtitle},{id:"include::includeCorrelation",label:"Correlation",value:"includeCorrelation",isActive:o.includeCorrelation},{id:"include::includeDuration",label:"Duration",value:"includeDuration",isActive:o.includeDuration},{id:"include::includeSummaryHeader",label:"Summary",value:"includeSummaryHeader",isActive:o.includeSummaryHeader},{id:"include::includeEventData",label:"Data",value:"includeEventData",isActive:o.includeEventData}]},{id:"format",title:"Format",type:"custom",data:[{id:"format::markdown",label:"Markdown",icon:kr,color:Le.semantic.info,value:"markdown",isActive:o.format==="markdown"},{id:"format::json",label:"JSON",icon:Dr,color:Le.semantic.warning,value:"json",isActive:o.format==="json"},{id:"format::plaintext",label:"Text",icon:Hn,color:He.color.textSecondary,value:"plaintext",isActive:o.format==="plaintext"},{id:"format::mermaid",label:"Diagram",icon:Ir,color:"#A855F7",value:"mermaid",isActive:o.format==="mermaid",description:"Mermaid sequence diagram"}]},{id:"timestamp",title:"Timestamps",type:"custom",data:[{id:"timestamp::relative",label:"Relative",value:"relative",isActive:o.timestampFormat==="relative",description:"+0ms, +150ms"},{id:"timestamp::absolute",label:"Absolute",value:"absolute",isActive:o.timestampFormat==="absolute",description:"ISO format"},{id:"timestamp::both",label:"Both",value:"both",isActive:o.timestampFormat==="both",description:"Both formats"}]},{id:"filter",title:"Filter Events",type:"custom",data:[{id:"filter::all",label:"All",value:"all",isActive:o.filterMode==="all"},{id:"filter::errors",label:"Errors",icon:Tr,color:Le.semantic.error,value:"errors",isActive:o.filterMode==="errors"},{id:"filter::success",label:"Success",color:Le.semantic.success,value:"success",isActive:o.filterMode==="success"},{id:"filter::pending",label:"Pending",color:Le.semantic.warning,value:"pending",isActive:o.filterMode==="pending"}]},{id:"llmOptimization",title:"LLM Optimization",type:"custom",data:[{id:"include::compactMode",label:"Compact",value:"compactMode",isActive:o.compactMode,description:"One line per event"},{id:"include::smartJsonParsing",label:"Smart JSON",value:"smartJsonParsing",isActive:o.smartJsonParsing,description:"Parse nested JSON"},{id:"include::reduxChangedOnly",label:"Redux Diff",value:"reduxChangedOnly",isActive:o.reduxChangedOnly,description:"Only show changes"},{id:"include::showStorageDiff",label:"Storage Diff",value:"showStorageDiff",isActive:o.showStorageDiff,description:"Show what changed"},{id:"include::stripVerboseFields",label:"Strip Noise",value:"stripVerboseFields",isActive:o.stripVerboseFields,description:"Remove images/descriptions"}]}],previewSection:{enabled:true,title:"PREVIEW",icon:_n,content:$,headerActions:L},onFilterChange:g}),[o,b,g,$,L]);return a?ae($r,{...C}):Ht(ue,{style:De.gatedContainer,contentContainerStyle:De.gatedContent,testID:`${S}-copy-settings-gated`,children:[ae(Zn,{featureName:"Events Export",description:"Export event flows to share with your team, debug issues, or feed into AI tools.",benefits:["Export to Markdown, JSON, or plain text","Customizable presets (LLM-ready, Bug Report, JSON)","Share event flows with teammates","Feed event context directly to AI assistants"]}),ae(f,{style:De.gatedPreview,children:ae($r,{...C})})]})}var De=le.create({previewScroll:{maxHeight:300},previewText:{fontFamily:Xn,fontSize:11,color:He.color.text,lineHeight:18},mermaidHint:{fontSize:11,color:He.color.textSecondary,marginBottom:8,paddingHorizontal:8,paddingVertical:6,backgroundColor:"#A855F715",borderRadius:6,overflow:"hidden"},statusLabel:{fontSize:11,fontWeight:"600",color:He.color.textTertiary,marginRight:8},gatedContainer:{flex:1},gatedContent:{padding:12,gap:12},gatedPreview:{}});import{TickProvider as Ur}from"@buoy-gg/shared-ui/web";import{Fragment as ct,jsx as A,jsxs as ie}from"react/jsx-runtime";function Jt({visible:e,onClose:t,onBack:r,onMinimize:a,enableSharedModalDimensions:o=false,inline:n=false,capturing:i,onCapturingChange:l,networkDetailWrapper:s,NetworkEventDetailViewComponent:u,RouteEventDetailComponent:c,detailComponents:d}){let h=ha(),b=i!=null&&l!=null,{filteredEvents:v,availableSources:m,toggleSource:y,clearEvents:p,totalCount:g,filteredCount:$,isCapturing:L,toggleCapturing:C,hiddenEventsCount:I,searchText:x,setSearchText:j}=Et(b?{capturingOverride:i}:void 0),N=b?i:L,me=b?()=>l(!i):C,[K,he]=ot("list"),[_,Xe]=ot(null),[mt,et]=ot(false),[Te,Ve]=ot(false),ht=aa(null);oa(()=>{if(!Te)return;let G=requestAnimationFrame(()=>{ht.current?.focus()});return()=>cancelAnimationFrame(G)},[Te]);let gt=Ae(()=>{Ve(false),j("")},[j]),tt=Ae(G=>{try{h.push(G)}catch(ft){Zt.alert("Navigation Error",String(ft))}},[h]),w=Ae(G=>{Xe(G),he("detail")},[]),F=Ae(()=>{K==="detail"?(Xe(null),he("list")):K==="copySettings"&&he("list")},[K]),z=Ae(()=>{he("copySettings")},[]),Q=Ae(G=>{},[]),q=o?ca.modal.root():"buoy-events-modal";if(!e)return null;let R=()=>{if(K==="detail"&&_){let G={source:_.source,title:_.title,subtitle:_.subtitle,status:_.status,timestamp:new Date(_.timestamp).toISOString(),data:_.originalEvent};return ie(Y,{children:[A(Y.Navigation,{onBack:F}),A(Y.Content,{title:_.title,testID:`${S}-detail-heading`}),A(Y.Actions,{children:A(da,{value:G})})]})}return K==="copySettings"?ie(Y,{children:[A(Y.Navigation,{onBack:F}),A(Y.Content,{title:"Copy Settings",testID:`${S}-copy-settings-heading`})]}):ie(Y,{children:[r&&A(Y.Navigation,{onBack:r}),A(Y.Content,{title:"",children:Te?A(Y.Search,{value:x,onChangeText:j,onCancel:gt,placeholder:"Search events...",accessibilityLabel:"Search events",iconSize:14,testID:`${S}-search-field`,containerTestID:`${S}-search`,clearTestID:`${S}-search-clear`,onBlur:()=>{x.length===0&&Ve(false)}}):ie(f,{style:te.headerTitleContainer,children:[A(k,{style:te.headerTitle,testID:`${S}-title`,children:"Events"}),ie(k,{style:te.headerSubtitle,testID:`${S}-count`,children:[g," captured"]})]})}),ie(Y.Actions,{children:[!Te&&A(ge,{onPress:()=>Ve(true),style:[te.headerActionButton,x.length>0&&te.headerActionButtonActive],testID:`${S}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search events",children:A(ua,{size:14,color:x.length>0?X.color.accent:X.color.textSecondary})}),A(ge,{onPress:z,style:[te.headerActionButton,g===0&&te.headerActionButtonDisabled],disabled:g===0,testID:`${S}-copy`,accessibilityRole:"button",accessibilityLabel:"Copy events",children:A(la,{size:14,color:g>0?X.color.textSecondary:X.color.textTertiary})}),A(ma,{isEnabled:N,onToggle:me,testID:`${S}-power`,accessibilityLabel:"Toggle event capture"}),A(ge,{onPress:p,style:[te.headerActionButton,g===0&&te.headerActionButtonDisabled],disabled:g===0,testID:`${S}-clear`,accessibilityRole:"button",accessibilityLabel:"Clear events",children:A(sa,{size:14,color:g>0?X.color.textSecondary:X.color.textTertiary})})]})]})},ne=A(f,{style:te.container,children:K==="copySettings"?A(Or,{events:v}):K==="detail"&&_?A(Ft,{event:_,onBack:F,onNavigate:tt,networkDetailWrapper:s,NetworkEventDetailViewComponent:u,RouteEventDetailComponent:c,detailComponents:d}):ie(ct,{children:[A($t,{availableSources:m,onToggleSource:y,totalCount:g,filteredCount:$}),A(At,{events:v,selectedEventId:void 0,expandedEventId:void 0,onEventPress:w,onNavigate:tt,isCapturing:N,hiddenEventsCount:I,searchText:x,totalCount:g,sourceCount:m.length,enabledSourceCount:m.filter(G=>G.enabled!==false).length,onUpgradePress:()=>et(true)})]})}),Ie=Ur?A(Ur,{children:ne}):ne,rt=A(ct,{children:A(pa,{visible:mt,onClose:()=>et(false),featureName:"Unlimited Events",description:"View your complete event history to debug complex flows and track down issues.",benefits:["Unlimited event history (vs 25 events)","Export events to Markdown, JSON, or plain text","Share event flows with teammates","Feed event context directly to AI assistants"]})});return n?ie(ct,{children:[ie(f,{style:te.inlineRoot,children:[A(f,{style:te.inlineHeader,...ga,children:R()}),Ie]}),rt]}):ie(ct,{children:[A(na,{visible:e,onClose:t,onMinimize:a,persistenceKey:q,header:{showToggleButton:true,customContent:R()},onModeChange:Q,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},disableScrollWrapper:true,children:Ie}),rt]})}var te=le.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:ia.border,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerTitleContainer:{flexDirection:"row",alignItems:"baseline",gap:8},headerTitle:{fontSize:16,fontWeight:"600",color:X.color.text},headerSubtitle:{fontSize:12,color:X.color.textTertiary},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:X.color.buttonSurface,borderWidth:1,borderColor:X.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:X.color.accentSoft,borderColor:X.color.accentBorderStrong}});function Di(e={}){return A(Jt,{...e,inline:true,visible:true,onClose:()=>{}})}import{createToolFactory as Ti,defineToolPreset as Ii}from"@buoy-gg/shared-ui/web";import{jsx as Ai}from"react/jsx-runtime";var Lr=Ii({id:"events",name:"EVENTS",description:"Unified event timeline",slot:"both",icon:({size:e,color:t})=>Ai(eo,{size:e,color:t||to}),component:Jt,props:{enableSharedModalDimensions:false}}),qi=Ti(Lr);import{useState as Bi,useCallback as Hr}from"react";import{night as de,Trash2 as Fi}from"@buoy-gg/shared-ui/web";import{jsx as Me,jsxs as Ze}from"react/jsx-runtime";function Ri(){let{filteredEvents:e,availableSources:t,toggleSource:r,clearEvents:a,totalCount:o,filteredCount:n,isCapturing:i}=Et(),[l,s]=Bi(null),u=Hr(d=>{s(d)},[]),c=Hr(()=>{s(null)},[]);return l?Me(Ft,{event:l,onBack:c}):Ze(f,{style:Pe.container,children:[Ze(f,{style:Pe.header,children:[Ze(f,{children:[Me(k,{style:Pe.title,children:"Events"}),Ze(k,{style:Pe.subtitle,children:[o," event",o!==1?"s":""," captured"]})]}),Ze(ge,{style:Pe.clearButton,onPress:a,activeOpacity:.7,disabled:o===0,children:[Me(Fi,{size:16,color:o===0?de.color.textTertiary:de.color.danger}),Me(k,{style:[Pe.clearText,{color:o===0?de.color.textTertiary:de.color.danger}],children:"Clear"})]})]}),Me($t,{availableSources:t,onToggleSource:r,totalCount:o,filteredCount:n}),Me(At,{events:e,selectedEventId:void 0,onEventPress:u,isCapturing:i,totalCount:o,sourceCount:t.length,enabledSourceCount:t.filter(d=>d.enabled!==false).length})]})}var Pe=le.create({container:{flex:1,backgroundColor:"transparent"},header:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:16,paddingVertical:12,backgroundColor:de.color.surface,borderBottomWidth:1,borderBottomColor:de.color.border},title:{fontSize:20,fontWeight:"700",color:de.color.text},subtitle:{fontSize:12,color:de.color.textTertiary,marginTop:2},clearButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8,borderRadius:6,backgroundColor:de.color.dangerSoft},clearText:{fontSize:14,fontWeight:"600"}});import{approxJsonSize as ji,isJsonSerializable as zi,isOverWireBudget as Mi}from"@buoy-gg/shared-ui/web";var Ne=16*1024;function Jr(e,t){return{__buoyTruncated:true,approxBytes:e,note:t??`Payload (\u2265${(e/1024).toFixed(0)}KB approx) exceeds the ${Ne/1024}KB sync limit and stayed on the device. Open the tool on-device (or use the source tool's detail action) for the full payload.`}}var Ye={__buoyOmitted:"state-tree",note:"prevState/nextState stay on the device (use get_redux_state / the on-device tool)."},Pi={__buoyOmitted:"query-payload",note:"Query/mutation data stays on the device (open the Query tool or the on-device Events detail)."},dt={__buoyOmitted:"network-body",note:"Request/response body stays on the device (open the Network tool or the on-device Events detail)."},Wr={__buoyOmitted:"network-headers",note:"Request/response headers stay on the device (open the Network tool or the on-device Events detail)."},Ni={__buoyOmitted:"graphql-variables",note:"GraphQL variables stay on the device (open the Network tool or the on-device Events detail)."},Wt={__buoyOmitted:"storage-value",note:"Storage value stays on the device (open the Storage tool or the on-device Events detail)."},Vi={__buoyOmitted:"route-params",note:"Navigation params stay on the device (open the Routes tool or the on-device Events detail)."};function Oi(e){return e==="react-query"||e==="react-query-query"||e==="react-query-mutation"}function se(e,t){if(e!==void 0)return Mi(e,Ne)?{...t}:e}function pt(e){return se(e,Pi)}function Kr(e){return e==null?e:e instanceof Error?{name:e.name,message:e.message}:pt(e)}var _r=new WeakMap;function Ui(e){let t=e.originalEvent;if(typeof t!="object"||t===null)return e;let r=_r.get(e);if(r!==void 0)return r;let a=e,o=t;if((e.source==="redux"||e.source==="zustand")&&("prevState"in o||"nextState"in o))o={...o,prevState:{...Ye},nextState:{...Ye},...e.source==="zustand"&&"partial"in o?{partial:{...Ye}}:{}},a={...e,originalEvent:o};else if(e.source==="jotai"&&("prevValue"in o||"nextValue"in o))o={...o,prevValue:{...Ye},nextValue:{...Ye}},a={...e,originalEvent:o};else if(e.source==="render"){let s=o.render,u=o.event,c=d=>{if(!d||typeof d!="object")return d;let{hookChanges:h,...b}=d;return b};o={...o,render:s&&{...s,renderHistory:void 0,lastRenderCause:c(s.lastRenderCause)},event:u&&{...u,capturedProps:void 0,capturedState:void 0,cause:c(u.cause)}},a={...e,originalEvent:o}}else if(Oi(e.source)){let{query:s,mutation:u,...c}=o;o={...c,queryData:pt(c.queryData),mutationData:pt(c.mutationData),mutationVariables:pt(c.mutationVariables),queryError:Kr(c.queryError),mutationError:Kr(c.mutationError)},a={...e,originalEvent:o}}else if(e.source==="network"){let s=typeof o.requestSize=="number"?o.requestSize:void 0,u=typeof o.responseSize=="number"?o.responseSize:void 0;o={...o,requestData:s!==void 0&&s>Ne?{...dt}:se(o.requestData,dt),responseData:u!==void 0&&u>Ne?{...dt}:se(o.responseData,dt),graphqlVariables:se(o.graphqlVariables,Ni),requestHeaders:se(o.requestHeaders,Wr),responseHeaders:se(o.responseHeaders,Wr)},a={...e,originalEvent:o}}else if(e.source==="storage-async"||e.source==="storage-mmkv"){let s=o.data;s&&(o={...o,data:{...s,value:se(s.value,Wt),prevValue:se(s.prevValue,Wt),pairs:se(s.pairs,Wt)}},a={...e,originalEvent:o})}else e.source==="route"&&(o={...o,params:se(o.params,Vi)},a={...e,originalEvent:o});let{bytes:n,sawRepeat:i,sawBigInt:l}=ji(o,Ne);return n>Ne?a={...e,originalEvent:Jr(n)}:(i||l)&&!zi(o)&&(a={...e,originalEvent:Jr(-1,"Payload is not JSON-serializable (cyclic or bigint) and stayed on the device.")}),_r.set(e,a),a}var Li={version:2,getSnapshot:()=>({events:O.getEvents().map(Ui),availableSources:Array.from(O.getAvailableEventSources())}),subscribe:e=>{O.ensureRemoteSourcesDefault();let t=O.subscribe(()=>e());return()=>{t(),O.clearRemoteSources()}},actions:{clearEvents:()=>{O.clearEvents()},setEnabledSources:e=>{let t=e?.sources??[];return O.setRemoteEnabledSources(t),{enabledSources:t}},exportEvents:e=>{let t=e??{},r={...t.preset&&We[t.preset]?We[t.preset]:Je,...t.settings??{}},a=O.getEvents(),o=typeof t.limit=="number"&&t.limit>0?t.limit:a.length,n=a.slice(0,o);return{output:Ut(n,r),returned:n.length,totalAvailable:a.length,includedData:r.includeEventData,format:r.format}}}};export{We as COPY_PRESETS,Je as DEFAULT_COPY_SETTINGS,S as EVENTS_TEST_ID,Or as EventsCopySettingsView,Jt as EventsModal,Di as EventsToolView,P as PRESET_METADATA,Er as ReactQueryEventDetail,Ft as UnifiedEventDetail,$t as UnifiedEventFilters,fr as UnifiedEventItem,At as UnifiedEventList,Ri as UnifiedEventViewer,yr as buildCorrelationCountMap,Ci as clearCopySettings,qi as createEventsTool,Ar as detectActivePreset,Fr as estimateExportSize,pr as eventFilterTestID,cr as eventIdentity,dr as eventRowTestID,Li as eventsSyncAdapter,Lr as eventsToolPreset,Qe as filterEvents,Cn as findRelatedEvents,Ut as generateExport,Rr as generateJsonExport,Nt as generateMarkdownExport,Pr as generateMermaidExport,jr as generatePlaintextExport,Cr as getCorrelationColor,br as getCorrelationGroup,vr as getCorrelationLabel,_e as getExportSummary,En as getRelatedEventsCount,wn as hasRelatedEvents,St as isBuoyInternalEvent,Xa as isEventHiddenFromTool,Ct as isNetworkEventIgnored,Vr as loadCopySettings,Nr as saveCopySettings,O as unifiedEventStore,Et as useUnifiedEvents,Ja as watchEvents};
11
+ Note over U,App: No events captured`;let a=[...r].sort((m,y)=>m.timestamp-y.timestamp),o=a[0].timestamp,n=fi(a),i=yi(n),l=["sequenceDiagram"];if(l.push(" autonumber"),l.push(""),i){let m=n.filter(p=>p.group==="client"),y=n.filter(p=>p.group==="server");if(m.length>0){l.push(" box rgb(240, 248, 255) Client");for(let p of m)l.push(` participant ${p.id} as ${p.icon} ${p.label}`);l.push(" end")}if(y.length>0){l.push(" box rgb(255, 248, 240) External");for(let p of y)l.push(` participant ${p.id} as ${p.icon} ${p.label}`);l.push(" end")}}else for(let m of n)l.push(` participant ${m.id} as ${m.icon} ${m.label}`);l.push("");let s=a[a.length-1].timestamp-o,u=a.filter(m=>m.source==="network"),c=u.reduce((m,y)=>{let p=y.originalEvent,g=p?.responseSize||p?.size||0;return m+g},0),d=a.filter(m=>m.status==="error").length,h=[];h.push(`\u23F1\uFE0F ${$e(s)}`),h.push(`\u{1F4CA} ${a.length} events`),u.length>0&&h.push(`\u{1F310} ${u.length} API calls`),c>0&&h.push(`\u{1F4E6} ${Lt(c)}`),d>0&&h.push(`\u274C ${d} errors`),l.push(` Note over U,API: ${h.join(" \xB7 ")}`),l.push("");let b=new Map,v=0;for(let m of a){let y=Ei(m,t,o);if(y.skip){v++;continue}let{messages:p,notes:g}=y,k=false,L="";if(m.source==="network"){let C=m.originalEvent?.url;if(C){let I=Si(C),x=b.get(I);if(x&&m.timestamp-x.timestamp<3e4){k=true;let j=m.timestamp-x.timestamp;L=`\u26A0\uFE0F Already fetched ${$e(j)} ago`,b.set(I,{timestamp:m.timestamp,count:x.count+1})}else b.set(I,{timestamp:m.timestamp,count:1})}}if(k){l.push(" rect rgb(255, 245, 230)"),l.push(` Note over App,API: ${L}`);for(let C of p)l.push(` ${C}`);for(let C of g)l.push(` ${C}`);l.push(" end")}else if(m.status==="error"){l.push(" rect rgb(255, 235, 235)");for(let C of p)l.push(` ${C}`);for(let C of g)l.push(` ${C}`);l.push(" end")}else{for(let C of p)l.push(` ${C}`);for(let C of g)l.push(` ${C}`)}}return v>0&&(l.push(""),l.push(` Note over App: ${v} internal events hidden`)),l.join(`
12
+ `)}function Ht(e,t){switch(t.format){case"markdown":return Ot(e,t);case"json":return zr(e,t);case"plaintext":return Mr(e,t);case"mermaid":return Vr(e,t);default:return Ot(e,t)}}import{definePersistedSetting as xi,devToolsStorageKeys as ki}from"@buoy-gg/shared-ui/web";var Jt=xi(ki.events.copySettings(),Je,{sanitize:(e,t)=>({...e,filterSources:t?.filterSources??Je.filterSources})});async function Or(e){await Jt.save(e)}async function Ur(){return Jt.loadOrNull()}async function $i(){await Jt.clear()}import{Fragment as Di,jsx as ae,jsxs as Wt}from"react/jsx-runtime";var Ti=50*1024,Ii=200*1024;function Ai(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function qi(){let e=Date.now();return[{id:"mock-1",source:"storage-async",timestamp:e-2e3,title:"Set Item",subtitle:"user_cart",status:"success",originalEvent:{action:"setItem",key:"user_cart",value:{items:2}}},{id:"mock-2",source:"react-query-query",timestamp:e-1500,title:"cart \u203A items",subtitle:"Fetching...",status:"pending",originalEvent:{type:"query-fetch-start",queryKey:["cart","items"]},correlationId:"rq-query-cart",sequenceInGroup:1},{id:"mock-3",source:"react-query-query",timestamp:e-1e3,title:"cart \u203A items",subtitle:"Success \xB7 500ms",status:"success",originalEvent:{type:"query-fetch-success",queryKey:["cart","items"],data:{items:[]}},correlationId:"rq-query-cart",sequenceInGroup:2},{id:"mock-4",source:"network",timestamp:e-500,title:"POST /api/checkout",subtitle:"402 \xB7 450ms",status:"error",originalEvent:{method:"POST",url:"/api/checkout",status:402,error:"Payment required"}}]}function Lr({events:e=[],initialSettings:t=Je,onSettingsChange:r}){let{isPro:a}=ti(),[o,n]=zt(t),[i,l]=zt(false),[s,u]=zt(false);_n(()=>{let I=true;return Ur().then(x=>{I&&x&&(n(x),r?.(x)),I&&u(true)}),()=>{I=false}},[r]);let c=je(I=>{n(I),r?.(I),Or(I)},[r]),d=e.length>0,h=d?e:qi(),b=st(()=>Fr(o),[o]),v=st(()=>jr(h,o),[h,o]),m=st(()=>v>=Ii?"danger":v>=Ti?"warning":"none",[v]),y=je(()=>Ht(h,o),[h,o]),p=je(I=>{let x=We[I];c({...x,filterSources:[...x.filterSources]})},[c]),g=je((I,x)=>{let[j,N]=I.split("::");if(j==="preset"){p(N);return}if(j==="include"){c({...o,[N]:!o[N]});return}if(j==="format"){c({...o,format:x});return}if(j==="timestamp"){c({...o,timestampFormat:x});return}if(j==="filter"){c({...o,filterMode:x});return}if(j==="threshold"){c({...o,dataSizeThreshold:x});return}},[o,c,p]),k=je(()=>{let I=h.length;return ae(oi,{expanded:i,onExpandedChange:l,summary:`${I} event${I!==1?"s":""} \xB7 ~${Ai(v)}${d?"":" (mock data)"}`,warningLevel:m,warningText:{warning:"Large payload - preview may be slow",danger:"Very large payload - may cause performance issues"},testIDs:{expand:`${S}-preview-expand`,collapse:`${S}-preview-collapse`,summary:`${S}-preview-summary`,warning:`${S}-preview-size-warning`},renderBody:()=>{let x=y();return o.format==="json"?ae(ni,{testIDPrefix:`${S}-preview-json`,data:JSON.parse(x),title:"",showTypeFilter:true,rawMode:true,initialExpanded:true}):Wt(f,{children:[o.format==="mermaid"&&ae($,{style:De.mermaidHint,children:"\u{1F4A1} Paste into mermaid.live to visualize"}),ae(ue,{style:De.previewScroll,nestedScrollEnabled:true,testID:`${S}-preview-scroll`,children:ae($,{style:De.previewText,selectable:a,testID:`${S}-preview-text`,children:x})})]})}})},[i,h,o,v,m,d,y,a]),L=je(()=>{let I=_e(h),x=d?`${I.totalEvents} events`:"Mock data (no events captured)";return Wt(Di,{children:[ae($,{style:De.statusLabel,testID:`${S}-export-status`,children:x}),ae(ei,{value:y()})]})},[d,h,y]),C=st(()=>({sections:[{id:"presets",title:"Presets",type:"custom",data:[{id:"preset::llm",label:P.llm.label,icon:Gn,color:P.llm.color,value:"llm",isActive:b==="llm",description:P.llm.description},{id:"preset::bugReport",label:P.bugReport.label,icon:Zn,color:P.bugReport.color,value:"bugReport",isActive:b==="bugReport",description:P.bugReport.description},{id:"preset::json",label:P.json.label,icon:Ir,color:P.json.color,value:"json",isActive:b==="json",description:P.json.description},{id:"preset::errors",label:P.errors.label,icon:Ar,color:P.errors.color,value:"errors",isActive:b==="errors",description:P.errors.description},{id:"preset::minimal",label:P.minimal.label,icon:Tr,color:P.minimal.color,value:"minimal",isActive:b==="minimal",description:P.minimal.description},{id:"preset::mermaid",label:P.mermaid.label,icon:qr,color:P.mermaid.color,value:"mermaid",isActive:b==="mermaid",description:P.mermaid.description},{id:"preset::custom",label:"Custom",icon:Yn,color:He.color.textSecondary,value:"custom",isActive:b===null,description:"User-configured"}]},{id:"include",title:"Include",type:"custom",data:[{id:"include::includeSource",label:"Source",value:"includeSource",isActive:o.includeSource},{id:"include::includeStatus",label:"Status",value:"includeStatus",isActive:o.includeStatus},{id:"include::includeTitle",label:"Title",value:"includeTitle",isActive:o.includeTitle},{id:"include::includeSubtitle",label:"Subtitle",value:"includeSubtitle",isActive:o.includeSubtitle},{id:"include::includeCorrelation",label:"Correlation",value:"includeCorrelation",isActive:o.includeCorrelation},{id:"include::includeDuration",label:"Duration",value:"includeDuration",isActive:o.includeDuration},{id:"include::includeSummaryHeader",label:"Summary",value:"includeSummaryHeader",isActive:o.includeSummaryHeader},{id:"include::includeEventData",label:"Data",value:"includeEventData",isActive:o.includeEventData}]},{id:"format",title:"Format",type:"custom",data:[{id:"format::markdown",label:"Markdown",icon:Tr,color:Le.semantic.info,value:"markdown",isActive:o.format==="markdown"},{id:"format::json",label:"JSON",icon:Ir,color:Le.semantic.warning,value:"json",isActive:o.format==="json"},{id:"format::plaintext",label:"Text",icon:Qn,color:He.color.textSecondary,value:"plaintext",isActive:o.format==="plaintext"},{id:"format::mermaid",label:"Diagram",icon:qr,color:"#A855F7",value:"mermaid",isActive:o.format==="mermaid",description:"Mermaid sequence diagram"}]},{id:"timestamp",title:"Timestamps",type:"custom",data:[{id:"timestamp::relative",label:"Relative",value:"relative",isActive:o.timestampFormat==="relative",description:"+0ms, +150ms"},{id:"timestamp::absolute",label:"Absolute",value:"absolute",isActive:o.timestampFormat==="absolute",description:"ISO format"},{id:"timestamp::both",label:"Both",value:"both",isActive:o.timestampFormat==="both",description:"Both formats"}]},{id:"filter",title:"Filter Events",type:"custom",data:[{id:"filter::all",label:"All",value:"all",isActive:o.filterMode==="all"},{id:"filter::errors",label:"Errors",icon:Ar,color:Le.semantic.error,value:"errors",isActive:o.filterMode==="errors"},{id:"filter::success",label:"Success",color:Le.semantic.success,value:"success",isActive:o.filterMode==="success"},{id:"filter::pending",label:"Pending",color:Le.semantic.warning,value:"pending",isActive:o.filterMode==="pending"}]},{id:"llmOptimization",title:"LLM Optimization",type:"custom",data:[{id:"include::compactMode",label:"Compact",value:"compactMode",isActive:o.compactMode,description:"One line per event"},{id:"include::smartJsonParsing",label:"Smart JSON",value:"smartJsonParsing",isActive:o.smartJsonParsing,description:"Parse nested JSON"},{id:"include::reduxChangedOnly",label:"Redux Diff",value:"reduxChangedOnly",isActive:o.reduxChangedOnly,description:"Only show changes"},{id:"include::showStorageDiff",label:"Storage Diff",value:"showStorageDiff",isActive:o.showStorageDiff,description:"Show what changed"},{id:"include::stripVerboseFields",label:"Strip Noise",value:"stripVerboseFields",isActive:o.stripVerboseFields,description:"Remove images/descriptions"}]}],previewSection:{enabled:true,title:"PREVIEW",icon:Xn,content:k,headerActions:L},onFilterChange:g}),[o,b,g,k,L]);return a?ae(Dr,{...C}):Wt(ue,{style:De.gatedContainer,contentContainerStyle:De.gatedContent,testID:`${S}-copy-settings-gated`,children:[ae(ri,{featureName:"Events Export",description:"Export event flows to share with your team, debug issues, or feed into AI tools.",benefits:["Export to Markdown, JSON, or plain text","Customizable presets (LLM-ready, Bug Report, JSON)","Share event flows with teammates","Feed event context directly to AI assistants"]}),ae(f,{style:De.gatedPreview,children:ae(Dr,{...C})})]})}var De=le.create({previewScroll:{maxHeight:300},previewText:{fontFamily:ai,fontSize:11,color:He.color.text,lineHeight:18},mermaidHint:{fontSize:11,color:He.color.textSecondary,marginBottom:8,paddingHorizontal:8,paddingVertical:6,backgroundColor:"#A855F715",borderRadius:6,overflow:"hidden"},statusLabel:{fontSize:11,fontWeight:"600",color:He.color.textTertiary,marginRight:8},gatedContainer:{flex:1},gatedContent:{padding:12,gap:12},gatedPreview:{}});import{TickProvider as Hr}from"@buoy-gg/shared-ui/web";import{Fragment as dt,jsx as A,jsxs as ie}from"react/jsx-runtime";function Kt({visible:e,onClose:t,onBack:r,onMinimize:a,enableSharedModalDimensions:o=false,inline:n=false,capturing:i,onCapturingChange:l,networkDetailWrapper:s,NetworkEventDetailViewComponent:u,RouteEventDetailComponent:c,detailComponents:d}){let h=fa(),b=i!=null&&l!=null,{filteredEvents:v,availableSources:m,toggleSource:y,clearEvents:p,totalCount:g,filteredCount:k,isCapturing:L,toggleCapturing:C,hiddenEventsCount:I,searchText:x,setSearchText:j}=kt(b?{capturingOverride:i}:void 0),N=b?i:L,me=b?()=>l(!i):C,[_,he]=ot("list"),[Q,Xe]=ot(null),[ht,et]=ot(false),[Te,Ve]=ot(false),gt=ia(null);na(()=>{if(!Te)return;let Z=requestAnimationFrame(()=>{gt.current?.focus()});return()=>cancelAnimationFrame(Z)},[Te]);let ft=Ae(()=>{Ve(false),j("")},[j]),tt=Ae(Z=>{try{h.push(Z)}catch(yt){Xt.alert("Navigation Error",String(yt))}},[h]),w=Ae(Z=>{Xe(Z),he("detail")},[]),B=Ae(()=>{_==="detail"?(Xe(null),he("list")):_==="copySettings"&&he("list")},[_]),z=Ae(()=>{he("copySettings")},[]),G=Ae(Z=>{},[]),q=o?pa.modal.root():"buoy-events-modal";if(!e)return null;let R=()=>{if(_==="detail"&&Q){let Z={source:Q.source,title:Q.title,subtitle:Q.subtitle,status:Q.status,timestamp:new Date(Q.timestamp).toISOString(),data:Q.originalEvent};return ie(X,{children:[A(X.Navigation,{onBack:B}),A(X.Content,{title:Q.title,testID:`${S}-detail-heading`}),A(X.Actions,{children:A(ma,{value:Z})})]})}return _==="copySettings"?ie(X,{children:[A(X.Navigation,{onBack:B}),A(X.Content,{title:"Copy Settings",testID:`${S}-copy-settings-heading`})]}):ie(X,{children:[r&&A(X.Navigation,{onBack:r}),A(X.Content,{title:"",children:Te?A(X.Search,{value:x,onChangeText:j,onCancel:ft,placeholder:"Search events...",accessibilityLabel:"Search events",iconSize:14,testID:`${S}-search-field`,containerTestID:`${S}-search`,clearTestID:`${S}-search-clear`,onBlur:()=>{x.length===0&&Ve(false)}}):ie(f,{style:te.headerTitleContainer,children:[A($,{style:te.headerTitle,testID:`${S}-title`,children:"Events"}),ie($,{style:te.headerSubtitle,testID:`${S}-count`,children:[g," captured"]})]})}),ie(X.Actions,{children:[!Te&&A(ge,{onPress:()=>Ve(true),style:[te.headerActionButton,x.length>0&&te.headerActionButtonActive],testID:`${S}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search events",children:A(da,{size:14,color:x.length>0?ee.color.accent:ee.color.textSecondary})}),A(ge,{onPress:z,style:[te.headerActionButton,g===0&&te.headerActionButtonDisabled],disabled:g===0,testID:`${S}-copy`,accessibilityRole:"button",accessibilityLabel:"Copy events",children:A(ca,{size:14,color:g>0?ee.color.textSecondary:ee.color.textTertiary})}),A(ga,{isEnabled:N,onToggle:me,testID:`${S}-power`,accessibilityLabel:"Toggle event capture"}),A(ge,{onPress:p,style:[te.headerActionButton,g===0&&te.headerActionButtonDisabled],disabled:g===0,testID:`${S}-clear`,accessibilityRole:"button",accessibilityLabel:"Clear events",children:A(ua,{size:14,color:g>0?ee.color.textSecondary:ee.color.textTertiary})})]})]})},ne=A(f,{style:te.container,children:_==="copySettings"?A(Lr,{events:v}):_==="detail"&&Q?A(jt,{event:Q,onBack:B,onNavigate:tt,networkDetailWrapper:s,NetworkEventDetailViewComponent:u,RouteEventDetailComponent:c,detailComponents:d}):ie(dt,{children:[A(Dt,{availableSources:m,onToggleSource:y,totalCount:g,filteredCount:k}),A(Ft,{events:v,selectedEventId:void 0,expandedEventId:void 0,onEventPress:w,onNavigate:tt,isCapturing:N,hiddenEventsCount:I,searchText:x,totalCount:g,sourceCount:m.length,enabledSourceCount:m.filter(Z=>Z.enabled!==false).length,onUpgradePress:()=>et(true)})]})}),Ie=Hr?A(Hr,{children:ne}):ne,rt=A(dt,{children:A(ha,{visible:ht,onClose:()=>et(false),featureName:"Unlimited Events",description:"View your complete event history to debug complex flows and track down issues.",benefits:["Unlimited event history (vs 25 events)","Export events to Markdown, JSON, or plain text","Share event flows with teammates","Feed event context directly to AI assistants"]})});return n?ie(dt,{children:[ie(f,{style:te.inlineRoot,children:[A(f,{style:te.inlineHeader,...ya,children:R()}),Ie]}),rt]}):ie(dt,{children:[A(sa,{visible:e,onClose:t,onMinimize:a,persistenceKey:q,header:{showToggleButton:true,customContent:R()},onModeChange:G,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},disableScrollWrapper:true,children:Ie}),rt]})}var te=le.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:la.border,backgroundColor:"transparent"},container:{flex:1,backgroundColor:"transparent"},headerTitleContainer:{flexDirection:"row",alignItems:"baseline",gap:8},headerTitle:{fontSize:16,fontWeight:"600",color:ee.color.text},headerSubtitle:{fontSize:12,color:ee.color.textTertiary},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:ee.color.buttonSurface,borderWidth:1,borderColor:ee.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:ee.color.accentSoft,borderColor:ee.color.accentBorderStrong}});function Fi(e={}){return A(Kt,{...e,inline:true,visible:true,onClose:()=>{}})}import{createToolFactory as Bi,defineToolPreset as Ri}from"@buoy-gg/shared-ui/web";import{jsx as ji}from"react/jsx-runtime";var Jr=Ri({id:"events",name:"EVENTS",description:"Unified event timeline",slot:"both",icon:({size:e,color:t})=>ji(ro,{size:e,color:t||oo}),component:Kt,props:{enableSharedModalDimensions:false}}),zi=Bi(Jr);import{useState as Mi,useCallback as Wr}from"react";import{night as pe,Trash2 as Pi}from"@buoy-gg/shared-ui/web";import{jsx as Me,jsxs as Ze}from"react/jsx-runtime";function Ni(){let{filteredEvents:e,availableSources:t,toggleSource:r,clearEvents:a,totalCount:o,filteredCount:n,isCapturing:i}=kt(),[l,s]=Mi(null),u=Wr(d=>{s(d)},[]),c=Wr(()=>{s(null)},[]);return l?Me(jt,{event:l,onBack:c}):Ze(f,{style:Pe.container,children:[Ze(f,{style:Pe.header,children:[Ze(f,{children:[Me($,{style:Pe.title,children:"Events"}),Ze($,{style:Pe.subtitle,children:[o," event",o!==1?"s":""," captured"]})]}),Ze(ge,{style:Pe.clearButton,onPress:a,activeOpacity:.7,disabled:o===0,children:[Me(Pi,{size:16,color:o===0?pe.color.textTertiary:pe.color.danger}),Me($,{style:[Pe.clearText,{color:o===0?pe.color.textTertiary:pe.color.danger}],children:"Clear"})]})]}),Me(Dt,{availableSources:t,onToggleSource:r,totalCount:o,filteredCount:n}),Me(Ft,{events:e,selectedEventId:void 0,onEventPress:u,isCapturing:i,totalCount:o,sourceCount:t.length,enabledSourceCount:t.filter(d=>d.enabled!==false).length})]})}var Pe=le.create({container:{flex:1,backgroundColor:"transparent"},header:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:16,paddingVertical:12,backgroundColor:pe.color.surface,borderBottomWidth:1,borderBottomColor:pe.color.border},title:{fontSize:20,fontWeight:"700",color:pe.color.text},subtitle:{fontSize:12,color:pe.color.textTertiary,marginTop:2},clearButton:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingVertical:8,borderRadius:6,backgroundColor:pe.color.dangerSoft},clearText:{fontSize:14,fontWeight:"600"}});import{approxJsonSize as Vi,isJsonSerializable as Oi,isOverWireBudget as Ui}from"@buoy-gg/shared-ui/web";var Ne=16*1024;function Kr(e,t){return{__buoyTruncated:true,approxBytes:e,note:t??`Payload (\u2265${(e/1024).toFixed(0)}KB approx) exceeds the ${Ne/1024}KB sync limit and stayed on the device. Open the tool on-device (or use the source tool's detail action) for the full payload.`}}var Ye={__buoyOmitted:"state-tree",note:"prevState/nextState stay on the device (use get_redux_state / the on-device tool)."},Li={__buoyOmitted:"query-payload",note:"Query/mutation data stays on the device (open the Query tool or the on-device Events detail)."},pt={__buoyOmitted:"network-body",note:"Request/response body stays on the device (open the Network tool or the on-device Events detail)."},_r={__buoyOmitted:"network-headers",note:"Request/response headers stay on the device (open the Network tool or the on-device Events detail)."},Hi={__buoyOmitted:"graphql-variables",note:"GraphQL variables stay on the device (open the Network tool or the on-device Events detail)."},_t={__buoyOmitted:"storage-value",note:"Storage value stays on the device (open the Storage tool or the on-device Events detail)."},Ji={__buoyOmitted:"route-params",note:"Navigation params stay on the device (open the Routes tool or the on-device Events detail)."};function Wi(e){return e==="react-query"||e==="react-query-query"||e==="react-query-mutation"}function se(e,t){if(e!==void 0)return Ui(e,Ne)?{...t}:e}function mt(e){return se(e,Li)}function Qr(e){return e==null?e:e instanceof Error?{name:e.name,message:e.message}:mt(e)}var Gr=new WeakMap;function Ki(e){let t=e.originalEvent;if(typeof t!="object"||t===null)return e;let r=Gr.get(e);if(r!==void 0)return r;let a=e,o=t;if((e.source==="redux"||e.source==="zustand")&&("prevState"in o||"nextState"in o))o={...o,prevState:{...Ye},nextState:{...Ye},...e.source==="zustand"&&"partial"in o?{partial:{...Ye}}:{}},a={...e,originalEvent:o};else if(e.source==="jotai"&&("prevValue"in o||"nextValue"in o))o={...o,prevValue:{...Ye},nextValue:{...Ye}},a={...e,originalEvent:o};else if(e.source==="render"){let s=o.render,u=o.event,c=d=>{if(!d||typeof d!="object")return d;let{hookChanges:h,...b}=d;return b};o={...o,render:s&&{...s,renderHistory:void 0,lastRenderCause:c(s.lastRenderCause)},event:u&&{...u,capturedProps:void 0,capturedState:void 0,cause:c(u.cause)}},a={...e,originalEvent:o}}else if(Wi(e.source)){let{query:s,mutation:u,...c}=o;o={...c,queryData:mt(c.queryData),mutationData:mt(c.mutationData),mutationVariables:mt(c.mutationVariables),queryError:Qr(c.queryError),mutationError:Qr(c.mutationError)},a={...e,originalEvent:o}}else if(e.source==="network"){let s=typeof o.requestSize=="number"?o.requestSize:void 0,u=typeof o.responseSize=="number"?o.responseSize:void 0;o={...o,requestData:s!==void 0&&s>Ne?{...pt}:se(o.requestData,pt),responseData:u!==void 0&&u>Ne?{...pt}:se(o.responseData,pt),graphqlVariables:se(o.graphqlVariables,Hi),requestHeaders:se(o.requestHeaders,_r),responseHeaders:se(o.responseHeaders,_r)},a={...e,originalEvent:o}}else if(e.source==="storage-async"||e.source==="storage-mmkv"){let s=o.data;s&&(o={...o,data:{...s,value:se(s.value,_t),prevValue:se(s.prevValue,_t),pairs:se(s.pairs,_t)}},a={...e,originalEvent:o})}else e.source==="route"&&(o={...o,params:se(o.params,Ji)},a={...e,originalEvent:o});let{bytes:n,sawRepeat:i,sawBigInt:l}=Vi(o,Ne);return n>Ne?a={...e,originalEvent:Kr(n)}:(i||l)&&!Oi(o)&&(a={...e,originalEvent:Kr(-1,"Payload is not JSON-serializable (cyclic or bigint) and stayed on the device.")}),Gr.set(e,a),a}var _i={version:2,getSnapshot:()=>({events:O.getEvents().map(Ki),availableSources:Array.from(O.getAvailableEventSources())}),subscribe:e=>{O.ensureRemoteSourcesDefault();let t=O.subscribe(()=>e());return()=>{t(),O.clearRemoteSources()}},actions:{clearEvents:()=>{O.clearEvents()},setEnabledSources:e=>{let t=e?.sources??[];return O.setRemoteEnabledSources(t),{enabledSources:t}},exportEvents:e=>{let t=e??{},r={...t.preset&&We[t.preset]?We[t.preset]:Je,...t.settings??{}},a=O.getEvents(),o=typeof t.limit=="number"&&t.limit>0?t.limit:a.length,n=a.slice(0,o);return{output:Ht(n,r),returned:n.length,totalAvailable:a.length,includedData:r.includeEventData,format:r.format}}}};export{We as COPY_PRESETS,Je as DEFAULT_COPY_SETTINGS,S as EVENTS_TEST_ID,Lr as EventsCopySettingsView,Kt as EventsModal,Fi as EventsToolView,P as PRESET_METADATA,kr as ReactQueryEventDetail,jt as UnifiedEventDetail,Dt as UnifiedEventFilters,br as UnifiedEventItem,Ft as UnifiedEventList,Ni as UnifiedEventViewer,vr as buildCorrelationCountMap,$i as clearCopySettings,zi as createEventsTool,Fr as detectActivePreset,jr as estimateExportSize,hr as eventFilterTestID,pr as eventIdentity,mr as eventRowTestID,_i as eventsSyncAdapter,Jr as eventsToolPreset,Qe as filterEvents,$n as findRelatedEvents,Ht as generateExport,zr as generateJsonExport,Ot as generateMarkdownExport,Vr as generateMermaidExport,Mr as generatePlaintextExport,Er as getCorrelationColor,Sr as getCorrelationGroup,Cr as getCorrelationLabel,_e as getExportSummary,Tn as getRelatedEventsCount,Dn as hasRelatedEvents,wt as isBuoyInternalEvent,an as isEventHiddenFromTool,Et as isNetworkEventIgnored,Ur as loadCopySettings,Or as saveCopySettings,O as unifiedEventStore,kt as useUnifiedEvents,Ga as watchEvents};