@buoy-gg/events 7.0.63 → 7.0.65
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/README.md +2 -0
- package/lib/commonjs/components/UnifiedEventDetail.js +1 -1
- package/lib/commonjs/components/UnifiedEventItem.js +1 -1
- package/lib/commonjs/hooks/useUnifiedEvents.js +1 -1
- package/lib/commonjs/sources/sourceIds.js +1 -1
- package/lib/commonjs/stores/unifiedEventStore.js +1 -1
- package/lib/commonjs/utils/autoDiscoverEventSources.js +1 -1
- package/lib/commonjs/utils/eventExportFormatter.js +1 -1
- package/lib/commonjs/utils/eventVisibility.js +1 -1
- package/lib/module/components/UnifiedEventDetail.js +1 -1
- package/lib/module/components/UnifiedEventItem.js +1 -1
- package/lib/module/hooks/useUnifiedEvents.js +1 -1
- package/lib/module/sources/sourceIds.js +1 -1
- package/lib/module/stores/unifiedEventStore.js +1 -1
- package/lib/module/utils/autoDiscoverEventSources.js +1 -1
- package/lib/module/utils/eventExportFormatter.js +1 -1
- package/lib/module/utils/eventVisibility.js +1 -1
- package/lib/typescript/types/index.d.ts +1 -1
- package/lib/typescript/utils/eventVisibility.d.ts +2 -0
- package/lib/web/index.mjs +9 -9
- package/package.json +3 -3
package/lib/web/index.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
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()&&
|
|
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
|
-
`);
|
|
1
|
+
"use client";var Yt=Object.defineProperty;var no=Object.getOwnPropertyDescriptor;var io=Object.getOwnPropertyNames;var so=Object.prototype.hasOwnProperty;var lo=(e,t)=>{for(var r in t)Yt(e,r,{get:t[r],enumerable:true})},Xt=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of io(t))!so.call(e,a)&&a!==r&&Yt(e,a,{get:()=>t[a],enumerable:!(o=no(t,a))||o.enumerable});return e},uo=(e,t,r)=>(Xt(e,t,"default"),r&&Xt(r,t,"default"));var cs=(()=>{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 co,EVENTS_ICON_COLOR as po}from"@buoy-gg/floating-tools-core/web";var er={};lo(er,{AccessibilityInfo:()=>fo,ActivityIndicator:()=>fa,Alert:()=>ir,Animated:()=>yo,AppRegistry:()=>vo,AppState:()=>So,Appearance:()=>bo,BackHandler:()=>Co,Button:()=>ya,CheckBox:()=>Po,Clipboard:()=>wo,DeviceEventEmitter:()=>Yo,Dimensions:()=>Eo,Easing:()=>xo,FlatList:()=>tr,I18nManager:()=>ko,Image:()=>zo,ImageBackground:()=>No,InteractionManager:()=>Do,Keyboard:()=>$o,KeyboardAvoidingView:()=>Vo,LayoutAnimation:()=>To,Linking:()=>Ao,LogBox:()=>Zo,Modal:()=>ha,NativeEventEmitter:()=>Io,NativeModules:()=>go,PanResponder:()=>qo,Picker:()=>Oo,PixelRatio:()=>Fo,Platform:()=>Bo,Pressable:()=>ma,ProgressBar:()=>Lo,RefreshControl:()=>Uo,SafeAreaView:()=>Ho,ScrollView:()=>ue,SectionList:()=>Ko,Share:()=>Ro,StatusBar:()=>Jo,StyleSheet:()=>le,Switch:()=>ga,Text:()=>$,TextInput:()=>ca,Touchable:()=>Wo,TouchableHighlight:()=>da,TouchableNativeFeedback:()=>_o,TouchableOpacity:()=>ge,TouchableWithoutFeedback:()=>pa,UIManager:()=>jo,Vibration:()=>Mo,View:()=>f,VirtualizedList:()=>Qo,YellowBox:()=>Go,findNodeHandle:()=>ba,unstable_createElement:()=>ho,useColorScheme:()=>Xo,useLocaleContext:()=>ea,useWindowDimensions:()=>ta});uo(er,mo);import*as mo from"react-native-web";import{unstable_createElement as ho,NativeModules as go,AccessibilityInfo as fo,Animated as yo,Appearance as bo,AppRegistry as vo,AppState as So,BackHandler as Co,Clipboard as wo,Dimensions as Eo,Easing as xo,I18nManager as ko,Keyboard as $o,InteractionManager as Do,LayoutAnimation as To,Linking as Ao,NativeEventEmitter as Io,PanResponder as qo,PixelRatio as Fo,Platform as Bo,Share as Ro,StyleSheet as le,UIManager as jo,Vibration as Mo,CheckBox as Po,FlatList as tr,Image as zo,ImageBackground as No,KeyboardAvoidingView as Vo,Picker as Oo,ProgressBar as Lo,RefreshControl as Uo,SafeAreaView as Ho,SectionList as Ko,StatusBar as Jo,Touchable as Wo,TouchableNativeFeedback as _o,VirtualizedList as Qo,YellowBox as Go,LogBox as Zo,DeviceEventEmitter as Yo,useColorScheme as Xo,useLocaleContext as ea,useWindowDimensions as ta}from"react-native-web";import*as W from"react-native-web";import{createElement as St,forwardRef as rr,useCallback as ra,useRef as oa}from"react";import{useEffect as aa,useState as na}from"react";import{createPortal as ia}from"react-dom";var sa='-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif';import{jsx as la}from"react/jsx-runtime";var Oe=Symbol.for("@buoy-gg/portal-host"),or=e=>{if(!(e instanceof Element))return false;if(e.closest("input, textarea, select"))return true;let t=e.closest("[contenteditable]")?.getAttribute("contenteditable")?.toLowerCase();return t===""||t==="true"||t==="plaintext-only"};function ar(){let e=document;if(e[Oe])return e[Oe].host;let t=document.createElement("div");t.dataset.buoyPortalHost="",Object.assign(t.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",fontFamily:sa});let r=()=>{let u=document.fullscreenElement,d=u&&u.tagName!=="CANVAS"?u:document.body;t.parentElement!==d&&d.appendChild(t)},o=new Map,a=u=>{(!t.contains(u.target)||!or(u.target))&&o.set(u.code||u.key,{key:u.key,code:u.code,location:u.location,keyCode:u.keyCode,which:u.which,altKey:u.altKey,ctrlKey:u.ctrlKey,metaKey:u.metaKey,shiftKey:u.shiftKey})},n=u=>{o.delete(u.code||u.key)},i=()=>o.clear(),l=()=>{let u=[...o.values()];o.clear();for(let d of u)document.dispatchEvent(new KeyboardEvent("keyup",{...d,bubbles:true}))},s=u=>{or(u.target)&&u.stopPropagation()},c=u=>u.stopPropagation();return r(),document.addEventListener("fullscreenchange",r),document.addEventListener("keydown",a,true),document.addEventListener("keyup",n,true),window.addEventListener("blur",i),t.addEventListener("focusin",l),t.addEventListener("keydown",s),t.addEventListener("keyup",s),t.addEventListener("keypress",s),t.addEventListener("wheel",c,{passive:true}),e[Oe]={host:t,users:0,dispose:()=>{document.removeEventListener("fullscreenchange",r),document.removeEventListener("keydown",a,true),document.removeEventListener("keyup",n,true),window.removeEventListener("blur",i),t.remove(),delete e[Oe]}},t}function ua({children:e}){let[t,r]=na(null);return aa(()=>{let o=ar(),a=document[Oe];return a.users++,r(o),()=>{--a.users===0&&a.dispose()}},[]),t?ia(la("div",{"data-buoy-root":"",style:{display:"contents",pointerEvents:"auto"},children:e}),t):null}function Y(e){let t=rr((o,a)=>{let{accessibilityState:n,accessibilityValue:i,...l}=o;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,c]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))i?.[s]!==void 0&&l[`aria-${c}`]===void 0&&(l[`aria-${c}`]=i[s]);return St(e,{...l,ref:a})}),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),ca=Y(W.TextInput),ge=Y(W.TouchableOpacity),da=Y(W.TouchableHighlight),pa=Y(W.TouchableWithoutFeedback),ma=Y(W.Pressable),ue=Y(W.ScrollView),nr=rr((e,t)=>{let r=oa(null),o=ra(a=>{if(a){let n=a;for(;n.parentElement&&n.parentElement!==document.body;)n=n.parentElement;n.parentElement===document.body&&(r.current=n,Object.assign(n.style,{position:"relative",zIndex:"2147483647",pointerEvents:"auto"}),ar().appendChild(n))}else r.current&&(document.body.appendChild(r.current),r.current=null);typeof t=="function"?t(a):t&&(t.current=a)},[t]);return St(ua,null,St(W.Modal,{...e,ref:o}))});nr.displayName="Modal";var ha=Y(nr),ga=Y(W.Switch),fa=Y(W.ActivityIndicator),ya=Y(W.Button),ba=W.findNodeHandle,ir={alert(e,t,r,o){if(typeof document>"u")return;let a=document.createElement("dialog");a.dataset.buoyRoot="",a.setAttribute("aria-label",e),a.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",a.appendChild(n),t){let c=document.createElement("p");c.textContent=t,c.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",a.appendChild(c)}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=()=>{a.close?.(),a.remove()};for(let c of l){let u=document.createElement("button");u.type="button",u.textContent=c.text??"OK",u.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${c.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,u.onclick=()=>{s(),c.onPress?.()},i.appendChild(u)}a.addEventListener("cancel",c=>{c.preventDefault(),o?.cancelable!==false&&(s(),o?.onDismiss?.())}),a.appendChild(i),document.body.appendChild(a),a.showModal?a.showModal():a.setAttribute("open","")}};import{useState as at,useCallback as Ie,useEffect as va,useRef as Sa}from"react";import{JsModal as Ca,ModalHeader as X,buoyColors as wa,night as ee,Trash2 as Ea,Copy as xa,Search as ka,devToolsStorageKeys as $a,ToolbarCopyButton as Da,UpgradeModal as Ta,PowerToggleButton as Aa,useSafeRouter as Ia,windowDragProps as qa}from"@buoy-gg/shared-ui/web";import{useState as fe,useEffect as ye,useCallback as be,useMemo as ve,useRef as Ct}from"react";import{useFeatureGate as Fa,subscribeToSubscriberCountChanges as Ba,useIgnoredPatterns as Ra,useLimit as ja}from"@buoy-gg/shared-ui/web";import{appStorageEvent as sr,isDevToolsStorageKey as wt,isBuoyRequest as Ma,isUrlIgnored as Pa}from"@buoy-gg/shared-ui/web";function nt(e){let t=e.originalEvent;if(!t)return false;if((e.source==="storage-async"||e.source==="storage-mmkv")&&(!sr(t)||typeof t.key=="string"&&wt(t.key)))return true;if(e.source==="capacitor"&&t.plugin==="Preferences"){let r=t.options?.key;if(typeof r=="string"&&wt(r))return true}return!!(e.source==="network"&&Ma(t.url||`https://${t.host||""}`))}function Et(e,t){if(e.source!=="network"||t.length===0)return false;let r=e.originalEvent?.url??"";return Pa(r,t)}function za(e,t){return nt(e)||Et(e,t)}function lr(e){if(nt(e))return null;let t=e.originalEvent;if(!t)return e;if(e.source==="storage-async"||e.source==="storage-mmkv"){let r=sr(t);if(!r)return null;if(r===t)return e;let o=r.data?.pairs?.length??r.data?.keys?.length;return{...e,originalEvent:r,subtitle:o===void 0?e.subtitle:`${o} key${o===1?"":"s"}`}}if(e.source==="capacitor"&&t.plugin==="Preferences"&&Array.isArray(t.result?.keys)){let r=t.result.keys.filter(o=>!wt(o));if(r.length!==t.result.keys.length)return{...e,originalEvent:{...t,result:{...t.result,keys:r}}}}return e}import{loadToolModule as H,getToolModuleVersion as ur}from"@buoy-gg/shared-ui/web/utils";var Na=0;function ce(e){return`${e}-${Date.now()}-${++Na}`}function Va(){try{let{storageEventStore:e}=H("@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 o=Oa(r);t(o)})}}catch{return null}}function Oa(e){let t=e,r=t.storageType==="async"?"storage-async":"storage-mmkv",o=t.action;t.storageType==="async"&&(o={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 a="";if(t.storageType==="async")switch(t.action){case"setItem":case"removeItem":case"mergeItem":a=t.data?.key||"unknown key";break;case"multiSet":case"multiMerge":{let i=t.data?.pairs?.length||0;a=`${i} key${i!==1?"s":""}`;break}case"multiRemove":{let i=t.data?.keys?.length||0;a=`${i} key${i!==1?"s":""}`;break}case"clear":a="all keys";break}else a=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:o,subtitle:a,status:n,originalEvent:e}}function La(){try{let{reduxActionStore:e}=H("@buoy-gg/redux"),t=null;return{id:"redux",name:"Redux",eventSources:["redux"],available:true,subscribe:r=>e.subscribe(o=>{if(o.length>0){let a=o[0];if(a.id!==t){t=a.id;let n=Ua(a);r(n)}}})}}catch{return null}}function Ua(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 o="";return t.payloadPreview?o=t.payloadPreview:t.hasStateChange&&t.diffSummary?o=t.diffSummary:t.duration!==void 0?o=`${t.duration.toFixed(1)}ms`:o=t.sliceName||"",{id:ce("redux"),source:"redux",timestamp:t.timestamp,title:t.type,subtitle:o,status:r,originalEvent:e}}function Ha(){try{let{networkEventStore:e,networkListener:t,addNetworkListener:r}=H("@buoy-gg/network"),o=new Map;return{id:"network",name:"Network",eventSources:["network"],available:true,setup:()=>{let a=t();a.isActive||a.startListening(),a.listenerCount===0&&r(n=>{e.processNetworkEvent(n)})},subscribe:a=>{let n=Date.now();return e.onEvent(i=>{let l=i,s=o.get(l.id);if(s){let c=cr(i);c.id=s,a(c)}else{if(typeof l.timestamp=="number"&&l.timestamp<n)return;let c=cr(i);o.set(l.id,c.id),a(c)}},false)}}}catch{return null}}function cr(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 o=t.operationName||`${t.method} ${t.path||t.url}`,a=[];return t.status!==void 0?a.push(`${t.status}`):t.error?a.push("Error"):a.push("Pending"),t.duration!==void 0&&a.push(`${t.duration.toFixed(0)}ms`),t.host&&a.push(t.host),{id:ce("network"),source:"network",timestamp:t.timestamp,title:o,subtitle:a.join(" \xB7 "),status:r,originalEvent:e}}function Ka(){try{let{reactQueryEventStore:e}=H("@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 o=true,a=new Set,n=i=>i.queryHash??(i.mutationId!==void 0?`m-${i.mutationId}`:null);return e.subscribe(i=>{if(o){o=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??"",c=n(l);if(s==="query-fetch-start"||s==="mutation-start")c&&a.add(c);else if((s==="query-fetch-success"||s==="query-fetch-error"||s==="mutation-success"||s==="mutation-error")&&c&&!a.has(c))return;let u=Ja(l);r(u)}}})}}}catch{return null}}function dr(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 Ja(e){let t=e,r=t.type.startsWith("mutation-")?"react-query-mutation":"react-query-query",o="neutral";switch(t.type){case"query-fetch-start":case"mutation-start":o="pending";break;case"query-fetch-success":case"mutation-success":o="success";break;case"query-fetch-error":case"mutation-error":o="error";break}let a="";t.queryKey?a=dr(t.queryKey):t.mutationKey?a=dr(t.mutationKey):t.mutationId!==void 0?a=`Mutation #${t.mutationId}`:a=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:a,subtitle:n.join(" \xB7 "),status:o,originalEvent:e,correlationId:i,sequenceInGroup:l}}function Wa(){try{let{routeEventStore:e}=H("@buoy-gg/route-events");return{id:"route-events",name:"Routes",eventSources:["route"],available:true,subscribe:t=>e.onEvent(r=>{let o=_a(r);t(o)})}}catch{return null}}function _a(e){let t=e,r="neutral";(t.pathname==="/"||Object.keys(t.params).length>0)&&(r="success");let o=[],a=Object.keys(t.params).length;return a>0&&o.push(`${a} param${a!==1?"s":""}`),t.timeSincePrevious!==void 0&&t.timeSincePrevious>0&&(t.timeSincePrevious<1e3?o.push(`${t.timeSincePrevious}ms`):o.push(`${(t.timeSincePrevious/1e3).toFixed(1)}s`)),t.previousPathname&&t.previousPathname!==t.pathname&&o.push(`from ${t.previousPathname}`),{id:ce("route"),source:"route",timestamp:t.timestamp,title:t.pathname||"/",subtitle:o.join(" \xB7 ")||"navigation",status:r,originalEvent:e}}function Qa(){try{let{zustandStateStore:e}=H("@buoy-gg/zustand"),t=null;return{id:"zustand",name:"Zustand",eventSources:["zustand"],available:true,subscribe:r=>e.subscribe(o=>{if(o.length>0){let a=o[0];if(a.id!==t){t=a.id;let n=Ga(a);r(n)}}})}}catch{return null}}function Ga(e){let t=e,r="neutral";t.isSlowUpdate?r="pending":t.hasStateChange&&(r="success");let o=[];if(t.changedKeys&&t.changedKeys.length>0){let a=t.changedKeys.slice(0,3).join(", "),n=t.changedKeys.length>3?` +${t.changedKeys.length-3}`:"";o.push(`${a}${n}`)}else t.diffSummary&&o.push(t.diffSummary);return t.duration!==void 0&&o.push(`${t.duration.toFixed(1)}ms`),t.category==="replace"&&o.push("replace"),{id:ce("zustand"),source:"zustand",timestamp:t.timestamp,title:t.storeName,subtitle:o.join(" \xB7 ")||(t.hasStateChange?"state changed":"no change"),status:r,originalEvent:e}}function Za(){try{let{jotaiStateStore:e}=H("@buoy-gg/jotai"),t=null;return{id:"jotai",name:"Jotai",eventSources:["jotai"],available:true,subscribe:r=>e.subscribe(o=>{if(o.length>0){let a=o[0];if(a.id!==t){t=a.id;let n=Ya(a);r(n)}}})}}catch{return null}}function Ya(e){let t=e,r="neutral";t.category==="write"&&t.hasValueChange?r="success":t.category==="read"&&(r="neutral");let o=[];return t.valuePreview?o.push(t.valuePreview):t.diffSummary&&o.push(t.diffSummary),t.category&&o.push(t.category),{id:ce("jotai"),source:"jotai",timestamp:t.timestamp,title:t.atomLabel,subtitle:o.join(" \xB7 ")||(t.hasValueChange?"value changed":"no change"),status:r,originalEvent:e}}function Xa(){let e;try{e=H("@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:o=>{r&&!r.isBackgroundTrackingEnabled()&&r.enableBackgroundTracking();let a=t.onRenderEvent((n,i)=>{let l=en(n,i);o(l)});return()=>{a(),r.disableBackgroundTracking()}}}}catch{return null}}function en(e,t){let r=e,o=t,a=o.componentName||o.displayName||o.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(", "),c=r.cause.changedKeys.length>3?` +${r.cause.changedKeys.length-3}`:"";n.push(`[${s}${c}]`)}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:a,subtitle:n.join(" \xB7 "),status:l,originalEvent:{event:r,render:o}}}var tn=new Set(["CapacitorHttp","CapacitorCookies","Console","WebView"]),xt=/token|secret|password|passwd|auth|credential|api[-_]?key|session|cookie/i;function it(e,t=false,r=0){if(!e||typeof e!="object"||r>4)return e;if(Array.isArray(e))return e.map(i=>it(i,t,r+1));let o={},a=e,n=t||typeof a.key=="string"&&xt.test(a.key);for(let[i,l]of Object.entries(a))(xt.test(i)||n&&i==="value")&&l!=null&&l!==""?o[i]="[hidden]":o[i]=it(l,false,r+1);return o}function rn(){try{let e=H("@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,o=0,a=()=>{let i=e.getCapacitorCalls();for(let s of i){if(s.seq<=o||r.has(s.seq))continue;if(tn.has(s.plugin)){r.add(s.seq);continue}(s.end!==void 0||s.kind==="event"||s.method==="addListener")&&(r.add(s.seq),t(on(s)))}let l=i[0]?.seq??0;if(l>o+1){o=l-1;for(let s of Array.from(r))s<=o&&r.delete(s)}},n=e.getCapacitorCalls();return o=n.length?n[n.length-1].seq:0,e.subscribeCapacitorCalls(a)}}}catch{return null}}function on(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:it(e.options),result:it(e.result,typeof e.options.key=="string"&&xt.test(e.options.key)),error:e.error,durationMs:e.end!==void 0?e.end-e.start:void 0,answeredByBuoy:e.answeredByBuoy??false}}}function an(){let e=[],t=new Set,r=[Va,La,Ha,Ka,Wa,Qa,Za,Xa,rn,()=>{try{let o=H("@buoy-gg/three");return o?.onThreeLoad?{id:"three",name:"Scene loads",eventSources:["three"],available:true,subscribe:o.onThreeLoad}:null}catch{return null}}];for(let o of r){let a=o();a&&a.available&&(e.push(a),a.eventSources.forEach(n=>t.add(n)))}return{sources:e,availableEventSources:t}}function nn(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"},three:{label:"Scene loads",color:"#F59E0B",icon:"cube-outline"},capacitor:{label:"Capacitor",color:"#119EFF",icon:"hardware-chip-outline"}}[e]||{label:e,color:"#6B7280",icon:"help-outline"}}var kt=null,pr=-1;function K(){return(!kt||pr!==ur())&&(pr=ur(),kt=an()),kt}function sn(){let e=[],t=0;try{let{storageEventStore:r}=H("@buoy-gg/storage"),o=r.getSubscriberCounts();e.push({sourceId:"storage",counts:o}),t+=o.total}catch{}try{let{networkEventStore:r}=H("@buoy-gg/network"),o=r.getSubscriberCounts();e.push({sourceId:"network",counts:o}),t+=o.total}catch{}try{let{routeEventStore:r}=H("@buoy-gg/route-events"),o=r.getSubscriberCounts();e.push({sourceId:"route-events",counts:o}),t+=o.total}catch{}try{let{RenderTracker:r,HighlightUpdatesController:o}=H("@buoy-gg/highlight-updates"),a=r.getRenderEventCallbackCount(),n=o?.isEnabled?.()?1:0,i={eventCallbacks:a,arrayListeners:n,total:a+n};e.push({sourceId:"render",counts:i}),t+=i.total}catch{}return{sources:e,totalSubscribers:t}}import{ChangeLog as ln}from"@buoy-gg/shared-ui/web";var $t={"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",three:"three"};var un=200,mr=new Set(["render"]),cn=class extends ln{constructor(){super({max:un});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 K().sources}getAvailableEventSources(){return this.remoteAvailableSources?this.remoteAvailableSources:K().availableEventSources}setRemoteAvailableSources(e){let t=e?new Set(e):null,r=this.remoteAvailableSources,o=r===null&&t===null||!!r&&!!t&&r.size===t.size&&[...t].every(a=>r.has(a));this.remoteAvailableSources=t,o||this.notifyListeners()}replaceEvents(e){e=e.map(lr).filter(t=>t!==null),this.activeSources=new Set(e.map(t=>t.source)),this.setItems(e)}async subscribeToAll(){let{sources:e}=K();for(let t of e)mr.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 o=await e.subscribe(a=>{this.addEvent(a)});o&&(r.unsubscribe=o)}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}=K(),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}=K(),t=e.find(r=>r.id==="redux");t&&this.subscribeToSource(t)}unsubscribeFromRedux(){this.unsubscribeFromSource("redux"),this.activeSources.delete("redux")}subscribeToNetwork(){let{sources:e}=K(),t=e.find(r=>r.id==="network");t&&this.subscribeToSource(t)}unsubscribeFromNetwork(){this.unsubscribeFromSource("network"),this.activeSources.delete("network")}subscribeToReactQuery(){let{sources:e}=K(),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}=K(),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}=K(),t=e.find(r=>r.id==="zustand");t&&this.subscribeToSource(t)}unsubscribeFromZustand(){this.unsubscribeFromSource("zustand"),this.activeSources.delete("zustand")}subscribeToJotai(){let{sources:e}=K(),t=e.find(r=>r.id==="jotai");t&&this.subscribeToSource(t)}unsubscribeFromJotai(){this.unsubscribeFromSource("jotai"),this.activeSources.delete("jotai")}subscribeToRender(){let{sources:e}=K(),t=e.find(r=>r.id==="render");t&&this.subscribeToSource(t)}unsubscribeFromRender(){this.unsubscribeFromSource("render"),this.activeSources.delete("render")}addEvent(e){let t=lr(e);if(t){if(e=t,e.source==="network"){let r=e.originalEvent;if(r?.id){let o=this.networkEventIdMap.get(r.id);if(o){let a=this.items.findIndex(n=>n.id===o);if(a>=0){e.id=o,this.items=[...this.items.slice(0,a),e,...this.items.slice(a+1)],this.notifyListeners();return}}this.networkEventIdMap.set(r.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,three: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 o=new Set(e),a=new Set;for(let c of e){let u=$t[c];u&&a.add(u)}let{sources:n}=K(),i=[];for(let c of a){let u=n.find(d=>d.id===c);u&&(i.push(c),this.subscribeToSource(u))}let l=false,s=this.subscribe(c=>{l||t(c.filter(u=>u.timestamp>=r&&o.has(u.source)))});return()=>{if(!l){l=true,s();for(let c of i)this.unsubscribeFromSource(c)}}}setLocalEnabledSources(e){let t=async()=>{let r=new Set;for(let n of e){let i=$t[n];i&&r.add(i)}let o=this.localDiscoveryIds;this.localDiscoveryIds=r;let{sources:a}=K();for(let n of r)if(!o.has(n)){let i=a.find(l=>l.id===n);i&&await this.subscribeToSource(i)}for(let n of o)r.has(n)||this.unsubscribeFromSource(n)};return this.localSyncChain=this.localSyncChain.then(t,t),this.localSyncChain}async setRemoteEnabledSources(e){let{sources:t}=K(),r;if(e==="all")r=new Set(t.map(a=>a.id).filter(a=>!mr.has(a)));else{r=new Set;for(let a of e){let n=$t[a];n&&r.add(n)}}let o=this.remoteDiscoveryIds;this.remoteDiscoveryIds=r;for(let a of r)if(!o.has(a)){let n=t.find(i=>i.id===a);n&&await this.subscribeToSource(n)}for(let a of o)r.has(a)||this.unsubscribeFromSource(a)}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"three":return this.sourceUnsubscribers.has("three");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"),three:this.sourceUnsubscribers.has("three")}}getSubscriberCounts(){return sn()}},O=new cn;var dn=e=>O.getEvents(e);var pn=()=>O.clearEvents(),mn=e=>O.subscribe(e);var hr=e=>O.setLocalEnabledSources(e);var gr=()=>O.getAvailableEventSources();var hn=(e,t,r)=>O.watch(e,t,r),fr=()=>O.getSubscriberCounts();import{persistentStorage as Se,devToolsStorageKeys as qe}from"@buoy-gg/shared-ui/web";async function gn(e){try{let t=qe.events.enabledSources();await Se.setItem(t,JSON.stringify(e))}catch{}}async function fn(){try{let e=qe.events.enabledSources(),t=await Se.getItem(e);return t&&t!==""?JSON.parse(t):null}catch{return null}}async function yn(e){try{let t=qe.events.isCapturing();await Se.setItem(t,JSON.stringify(e))}catch{}}async function bn(){try{let e=qe.events.isCapturing(),t=await Se.getItem(e);return t!==null&&t!==""?JSON.parse(t):null}catch{return null}}async function yr(e){try{let t=qe.events.pausedAt();e===null?await Se.removeItem(t):await Se.setItem(t,JSON.stringify(e))}catch{}}async function vn(){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}}function Sn(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 br=["storage-async","redux","network","react-query-query","react-query-mutation","route","zustand","jotai","render","capacitor"],vr=br.filter(e=>e!=="render"),Dt={"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"],three:["three"]};function Tt(e){let{isPro:t}=Fa(),r=ja("events.entries"),{patterns:o}=Ra(),[a,n]=fe([]),[i,l]=fe(()=>new Set(vr)),[s,c]=fe(true),[u,d]=fe(""),h=Ct(false),b=e?.capturingOverride??s,v=Ct(null),m=Ct([]),[y,p]=fe(0);ye(()=>{b?v.current!==null&&(m.current=[...m.current,[v.current,Date.now()]],v.current=null,p(w=>w+1),yr(null)):v.current===null&&(v.current=Date.now(),p(w=>w+1),yr(v.current))},[b]);let g=be(w=>{let B=v.current;if(B!==null&&w>B)return true;for(let[M,G]of m.current)if(w>M&&w<=G)return true;return false},[]),[k,U]=fe(()=>gr()),[C,A]=fe(0);ye(()=>Ba(()=>{A(w=>w+1)}),[]);let x=ve(()=>br.filter(w=>(Dt[w]||[w]).some(B=>k.has(B))),[k]);ye(()=>{let w=null,B=mn(()=>{w==null&&(w=requestAnimationFrame(()=>{w=null,M()}))}),M=()=>{let G=dn();n(G),U(q=>{let R=gr();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 fn(),B,M=x.filter(R=>vr.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(M)}else B=new Set(M);l(B);let G=await bn(),q=G!==null?G:true;if(!q&&v.current===null){let R=await vn();v.current=R??Date.now(),p(ne=>ne+1)}c(q),h.current=true,hr(q?Array.from(B):[])})()},[x]),ye(()=>{h.current&&hr(s?Array.from(i):[])},[i,s]),ye(()=>{h.current&&gn(Array.from(i))},[i]),ye(()=>{h.current&&yn(s)},[s]);let j=ve(()=>{let w=new Set;return i.forEach(B=>{let M=Dt[B];M&&M.forEach(G=>w.add(G))}),w},[i]),N=u.trim().toLowerCase(),me=ve(()=>a.filter(w=>!g(w.timestamp)&&!nt(w)&&!Et(w,o)),[a,o,g,y]),_=ve(()=>j.size===0?[]:me.filter(w=>j.has(w.source)&&(N===""||Sn(w,N))),[me,j,N]),he=ve(()=>_.slice(0,r),[_,r]),Q=ve(()=>Math.max(0,_.length-r),[_,r]),et=ve(()=>{let w=me.reduce((q,R)=>(q[R.source]=(q[R.source]??0)+1,q),{}),B=fr(),M={};for(let q of B.sources)M[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",three:"three"};return x.map(q=>{let R=(Dt[q]||[q]).reduce((Z,vt)=>Z+(w[vt]||0),0),ne=nn(q),Ae=G[q],ot=Ae&&Ae in M?M[Ae]:void 0;return{source:q,...ne,count:R,enabled:i.has(q),subscriberCount:ot}}).sort((q,R)=>q.enabled&&!R.enabled?-1:!q.enabled&&R.enabled?1:0)},[me,i,x,C]),ft=be(w=>{l(B=>{let M=new Set(B);return M.has(w)?M.delete(w):M.add(w),M})},[]),tt=be(()=>{l(new Set(x))},[x]),Te=be(()=>{pn()},[]),Ve=be(()=>{c(true)},[]),yt=be(()=>{c(false)},[]),bt=be(()=>{c(w=>!w)},[]),rt=fr().totalSubscribers;return{events:a,filteredEvents:he,availableSources:et,enabledSources:i,searchText:u,setSearchText:d,toggleSource:ft,enableAllSources:tt,clearEvents:Te,totalCount:me.length,filteredCount:he.length,isCapturing:s,startCapturing:Ve,stopCapturing:yt,toggleCapturing:bt,discoveredSources:k,hiddenEventsCount:Q,isPro:t,totalSubscriberCount:rt}}import{memo as Cn}from"react";import{night as L}from"@buoy-gg/shared-ui/web";var S="buoy-events";function wn(e){return String(e??"").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"unknown"}function Sr(e){let t=e.originalEvent??{};switch(e.source){case"storage-async":case"storage-mmkv":{let r=t.data??{},o=r.key??(Array.isArray(r.keys)?r.keys.join("+"):void 0)??(Array.isArray(r.pairs)?r.pairs.map(a=>a[0]).join("+"):void 0);return`${e.title} ${o??""}`}case"network":{let r=String(t.url??""),o=r.split("?")[0]??r;return`${t.method??""} ${o}`}case"react-query":case"react-query-query":case"react-query-mutation":return`${e.title} ${t.type??""}`;default:return e.title}}function Cr(e){return`${S}-row-${e.source}-${wn(Sr(e))}`}function wr(e){return`${S}-filter-${e}`}import{jsx as Ce,jsxs as At}from"react/jsx-runtime";var It=Cn(function({availableSources:e,onToggleSource:t,totalCount:r,filteredCount:o}){return e.length===0?null:At(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(a=>{let n=a.enabled!==false,i=a.subscriberCount,l=i!==void 0,s=a.count||0,c=wr(a.source);return At(ge,{testID:c,accessibilityRole:"button",accessibilityLabel:`${a.label} filter, ${n?"on":"off"}, ${s} event${s===1?"":"s"}`,style:[re.badge,n?{backgroundColor:L.color.surface,borderColor:a.color+"50"}:re.badgeDisabled],onPress:()=>t(a.source),activeOpacity:.7,children:[l&&Ce(f,{style:[re.countBadge,{backgroundColor:n?i>0?a.color+"25":L.color.fillSecondary:L.color.fill}],children:Ce($,{style:[re.countText,{color:n?i>0?a.color:L.color.textTertiary:L.color.textTertiary}],testID:`${c}-subscribers`,children:i})}),Ce(f,{style:[re.dot,{backgroundColor:n?a.color:L.color.fillTertiary}]}),Ce($,{style:[re.badgeLabel,{color:n?L.color.text:L.color.textTertiary}],numberOfLines:1,testID:`${c}-label`,children:a.label}),Ce(f,{style:[re.countBadge,{backgroundColor:n?s>0?a.color+"20":L.color.fill:L.color.fill}],children:Ce($,{style:[re.countText,{color:n?s>0?a.color:L.color.textTertiary:L.color.textTertiary}],testID:`${c}-count`,children:s})})]},a.source)})}),o<r&&At($,{style:re.filterInfo,testID:`${S}-showing`,children:["Showing ",o," of ",r]})]})}),re=le.create({container:{paddingVertical:8,backgroundColor:"transparent",borderBottomWidth:1,borderBottomColor:L.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:L.color.surface,borderColor:L.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:L.color.textTertiary,textAlign:"center"}});import{memo as En,useCallback as qt,useMemo as xn}from"react";import{night as st,Zap as kn,ProBadge as $n,ToolEmptyState as Dn,resolveListEmptyState as Tn}from"@buoy-gg/shared-ui/web";import{loadToolModule as Fe,getToolModuleVersion as Er}from"@buoy-gg/shared-ui/web/utils";import{memo as An}from"react";import{CompactRow as In,formatRelativeTime as qn,Pill as Fn}from"@buoy-gg/shared-ui/web";import{jsx as V,jsxs as Bn}from"react/jsx-runtime";function Rn(){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 Ft,xr=-1;function jn(){return(!Ft||xr!==Er())&&(Ft=Rn(),xr=Er()),Ft}var kr={"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"},three:{label:"Scene loads",color:"#F59E0B"},capacitor:{label:"Capacitor",color:"#119EFF"}};function Mn(e){switch(e){case"success":return"#10B981";case"error":return"#EF4444";case"pending":return"#F59E0B";case"neutral":default:return"#6B7280"}}function Pn(e){return e==="storage-async"||e==="storage-mmkv"}function zn({label:e,color:t,testID:r}){return V(Fn,{label:e,color:t,variant:"soft",size:"sm",style:{marginLeft:6},testID:r})}var Nn={"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",three:"SCENE"};function Le({source:e,testID:t,children:r}){let o=kr[e].color,a=Nn[e];return Bn(f,{style:Bt.badgeWrapper,testID:t,children:[r,V(f,{style:[Bt.sourceBadge,{backgroundColor:`${o}20`}],children:V($,{style:[Bt.sourceBadgeText,{color:o}],testID:t?`${t}-badge`:void 0,children:a})})]})}var $r=An(function({event:e,onPress:t,isSelected:r=false,isExpanded:o=false,onNavigate:a,correlationCount:n=1,correlationLabel:i,correlationColor:l}){let{StorageEventCard:s,getValueType:c,ReduxActionItem:u,NetworkEventItemCompact:d,RouteEventItemCompact:h,ZustandStateChangeItem:b,JotaiAtomChangeItem:v}=jn(),m=kr[e.source],y=Mn(e.status),p=Cr(e);if(Pn(e.source)&&s&&c){let k=e.originalEvent,U={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?c(k.data.value):void 0};return V(Le,{source:e.source,testID:p,children:V(s,{data:U,onPress:t,isSelected:r})})}if(e.source==="redux"&&u){let k=e.originalEvent;return V(Le,{source:e.source,testID:p,children:V(u,{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(Le,{source:e.source,testID:p,children:V(h,{event:k,visitNumber:0,isExpanded:o,onPress:()=>t(),onNavigate:a})})}if(e.source==="zustand"&&b)return V(Le,{source:e.source,testID:p,children:V(b,{change:e.originalEvent,onPress:()=>t()})});if(e.source==="jotai"&&v)return V(Le,{source:e.source,testID:p,children:V(v,{change:e.originalEvent,onPress:()=>t()})});let g=i&&l?V(zn,{label:i,color:l,testID:`${p}-correlation`}):null;return V(In,{statusDotColor:m.color,statusLabel:m.label,primaryText:e.title,secondaryText:e.subtitle,badgeText:n>1&&!i?`${n}`:"",badgeColor:l||y,customBadge:g,bottomRightText:qn(new Date(e.timestamp)),showChevron:true,isSelected:r,onPress:t,testID:p})}),Bt=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 Vn(e,t){return e.correlationId?t.filter(r=>r.correlationId===e.correlationId&&r.id!==e.id).sort((r,o)=>r.timestamp-o.timestamp):[]}function On(e,t){return e.correlationId?t.some(r=>r.correlationId===e.correlationId&&r.id!==e.id):false}function Ln(e,t){return e.correlationId?t.filter(r=>r.correlationId===e.correlationId).length:1}function Dr(e){let t=new Map;for(let r of e)if(r.correlationId){let o=t.get(r.correlationId)||0;t.set(r.correlationId,o+1)}return t}function Tr(e,t){return t.filter(r=>r.correlationId===e).sort((r,o)=>{let a=r.sequenceInGroup??0,n=o.sequenceInGroup??0;return a!==n?a-n:r.timestamp-o.timestamp})}function Ar(e,t){if(!e.correlationId)return null;let r=Tr(e.correlationId,t);if(r.length<=1)return null;let o=r.findIndex(a=>a.id===e.id);return o===-1?null:`${o+1}/${r.length}`}var Ir=["#EC4899","#8B5CF6","#3B82F6","#10B981","#F59E0B","#EF4444","#06B6D4","#84CC16"];function qr(e){let t=0;for(let o=0;o<e.length;o++)t=(t<<5)-t+e.charCodeAt(o),t|=0;let r=Math.abs(t)%Ir.length;return Ir[r]}import{jsx as Be,jsxs as Rt}from"react/jsx-runtime";var jt=En(function({events:e,selectedEventId:t,expandedEventId:r,onEventPress:o,onNavigate:a,isCapturing:n,hiddenEventsCount:i=0,onUpgradePress:l,searchText:s="",totalCount:c=0,sourceCount:u,enabledSourceCount:d}){let h=xn(()=>Dr(e),[e]),b=qt(({item:y})=>{let p=y.correlationId&&h.get(y.correlationId)||1,g=Ar(y,e),k=y.correlationId?qr(y.correlationId):void 0;return Be($r,{event:y,isSelected:y.id===t,isExpanded:y.id===r,onPress:()=>o(y),onNavigate:a,correlationCount:p,correlationLabel:g,correlationColor:k})},[t,r,o,a,h,e]),v=qt(y=>y.id,[]),m=qt(()=>i<=0?null:Rt(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:[Rt(f,{style:we.hiddenBannerLeft,children:[Be(kn,{size:16,color:st.color.accent}),Rt($,{style:we.hiddenBannerText,testID:`${S}-hidden-count`,children:[i," hidden event",i!==1?"s":""]})]}),Be($n,{})]}),[i,l]);if(e.length===0){let y=u===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()&&c>0?{otto:"filtering",title:"Every Source Is Off",message:`${c} event${c===1?" is":"s are"} captured. Turn a source chip back on to see them.`}:Tn({subject:"events",search:s,total:c,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(Dn,{...g,testID:`${S}-empty`,style:we.emptyContainer})}return Be(tr,{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:st.color.surface,borderRadius:8,borderWidth:1,borderColor:st.color.border},hiddenBannerLeft:{flexDirection:"row",alignItems:"center",gap:8},hiddenBannerText:{fontSize:13,fontWeight:"500",color:st.color.text}});import{loadToolModule as Ee,getToolModuleVersion as Mt}from"@buoy-gg/shared-ui/web/utils";import{memo as Un,useMemo as Fr}from"react";import{night as de,formatRelativeTime as Hn,copyToClipboard as Kn,parseValue as Jn,useIgnoredPatterns as Wn,monoFont as _n}from"@buoy-gg/shared-ui/web";import{DataViewer as Qn}from"@buoy-gg/shared-ui/web/dataViewer";import{memo as Gn,useMemo as Zn}from"react";import{buoyColors as oe,night as P,displayValue as Yn,monoFont as Re}from"@buoy-gg/shared-ui/web";import{DataViewer as lt}from"@buoy-gg/shared-ui/web/dataViewer";import{jsx as T,jsxs as J}from"react/jsx-runtime";var Xn={"query-fetch-start":{label:"Query Fetching",color:P.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:P.color.accent,icon:"hourglass"},"mutation-success":{label:"Mutation Success",color:oe.success,icon:"checkmark"},"mutation-error":{label:"Mutation Error",color:oe.error,icon:"close"}},Br=Gn(function({event:e}){let t=e.originalEvent,r=Xn[t.type]||{label:t.type,color:P.color.textTertiary,icon:"help"},o=t.type.startsWith("query-"),a=t.type.startsWith("mutation-"),n=Zn(()=>{let u=o?t.queryKey:t.mutationKey;return u?Yn(u,true):a&&t.mutationId!==void 0?`Mutation #${t.mutationId}`:"No key"},[t,o,a]),i=new Date(t.timestamp).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:true}),l=o?!!t.queryData:!!t.mutationData,s=o?!!t.queryError:!!t.mutationError,c=a&&!!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(ei,{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})]}),o&&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})]}),a&&t.mutationId!==void 0&&J(f,{style:E.row,children:[T($,{style:E.labelText,children:"Mutation ID:"}),J($,{style:E.valueText,children:["#",t.mutationId]})]})]})]})}),c&&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(lt,{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:o?"Query Data":"Mutation Result"}),T(f,{style:E.dataContent,children:T(lt,{title:"",data:o?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(lt,{title:"",data:o?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(lt,{title:"",data:t,showTypeFilter:true,rawMode:true,initialExpanded:false})})]})})]})});function ei({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:P.color.surface,borderRadius:6,borderWidth:1,overflow:"hidden",shadowColor:P.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},eventTypeHeader:{paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,borderBottomWidth:1,borderBottomColor:P.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:P.color.separator},keyScrollView:{flex:1,marginRight:8},keyText:{fontSize:12,color:P.color.text,fontFamily:Re,lineHeight:18,backgroundColor:P.color.accentSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4,borderWidth:1,borderColor:P.color.accentBorderStrong},row:{flexDirection:"row",justifyContent:"space-between",alignItems:"center",paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:P.color.separator},labelText:{fontSize:10,color:P.color.textSecondary,fontWeight:"600",letterSpacing:.5,textTransform:"uppercase",fontFamily:Re},valueText:{fontSize:12,color:P.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:P.color.surface,borderRadius:6,borderWidth:1,borderColor:P.color.accentBorderStrong,overflow:"hidden",shadowColor:P.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},dataHeader:{backgroundColor:P.color.accentSoft,paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:P.color.accent,borderBottomWidth:1,borderBottomColor:P.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 ti,jsx as D,jsxs as Ue}from"react/jsx-runtime";function ri(){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 Pt,Rr=-1;function oi(){return(!Pt||Rr!==Mt())&&(Pt=ri(),Rr=Mt()),Pt}var ai={"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"},three:{label:"Scene loads",color:"#F59E0B"},capacitor:{label:"Capacitor",color:"#119EFF"}};function ni(e){return e==="storage-async"||e==="storage-mmkv"}function ii(e){let t=Jn(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 si({children:e}){return D(ti,{children:e})}var zt=Un(function({event:e,onBack:t,NetworkEventDetailViewComponent:r,networkDetailWrapper:o,RouteEventDetailComponent:a,detailComponents:n,onNavigate:i}){let l=Fr(()=>({...oi(),...n}),[n,Mt()]),s=ai[e.source],c=new Date(e.timestamp),{values:u,toggle:d}=Wn(),h=Fr(()=>{if(!ni(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:ii(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=o??si;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:u,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(Br,{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=a??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 Kn({source:e.source,timestamp:c.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:[c.toLocaleTimeString()," (",Hn(c),")"]})]}),Ue(f,{style:F.dataSection,children:[D($,{style:F.sectionLabel,children:"Event Data"}),D(f,{style:F.dataContainer,testID:`${S}-detail-data`,children:D(Qn,{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:_n},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 li,useMemo as ut,useState as Nt}from"react";import{DynamicFilterView as jr,macOSColors as He,night as Ke,FileText as Mr,FileCode as Pr,Hash as ui,Zap as ci,AlertTriangle as di,Settings as pi,Eye as mi,XCircle as zr,GitBranch as Nr,ToolbarCopyButton as hi,useFeatureGate as gi,ProFeatureBanner as fi,ExportPreview as yi,monoFont as bi}from"@buoy-gg/shared-ui/web";import{DataViewer as vi}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 Vr(e){for(let[t,r]of Object.entries(We))if(Object.keys(r).every(o=>{let a=e[o],n=r[o];return Array.isArray(a)&&Array.isArray(n)?a.length===n.length&&a.every((i,l)=>i===n[l]):a===n}))return t;return null}var z={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"}};import{isDevToolsStorageKey as Si}from"@buoy-gg/shared-ui/web";var Me={success:"\u2705",pending:"\u23F3",error:"\u274C",neutral:"\u2796"},Ci={success:"[OK]",pending:"[...]",error:"[ERR]",neutral:"[-]"},Vt={"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",three:"Scene loads"};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,o]of Object.entries(e))t[r]=ke(o);return t}return e}var wi=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 Ot(e){if(e==null)return e;if(Array.isArray(e))return e.map(Ot);if(typeof e=="object"){let t={};for(let[r,o]of Object.entries(e))wi.has(r)||typeof o=="string"&&Ei(o)||(t[r]=Ot(o));return t}return e}function Ei(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 xi(e){if(e instanceof Date)return e.toISOString();if(!(e&&typeof e=="object"&&Object.keys(e).length===0))return e}function ki(e,t){let r=s=>{if(typeof s!="object"||s===null)return null;let c=s;return typeof c.id=="string"?c.id:typeof c.orderId=="string"?c.orderId:typeof c.key=="string"?c.key:null},o=new Set(e.map(r).filter(Boolean)),a=new Set(t.map(r).filter(Boolean));if(o.size===0&&a.size===0)return null;let n=t.filter(s=>{let c=r(s);return c&&!o.has(c)}),i=e.filter(s=>{let c=r(s);return c&&!a.has(c)}),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 $i(e,t){let r={};if(e.action&&(r.action=e.action),e.storageType&&(r.storageType=e.storageType),e.timestamp!==void 0){let o=xi(e.timestamp);o!==void 0&&(r.timestamp=o)}if(e.data){let o={...e.data};if(t.smartJsonParsing&&(o.value!==void 0&&(o.value=xe(o.value)),o.prevValue!==void 0&&(o.prevValue=xe(o.prevValue))),t.showStorageDiff&&Array.isArray(o.value)&&Array.isArray(o.prevValue)){let a=ki(o.prevValue,o.value);if(a){let n={key:o.key};return a.added.length>0&&(n.added=a.added),a.removed.length>0&&(n.removed=a.removed),a.unchanged>0&&(n.unchangedCount=a.unchanged),r.data=n,r}}r.data=o}return r}function Di(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 o=e.sliceName;if(o&&e.prevState&&e.nextState){let a=e.prevState,n=e.nextState;(a[o]!==void 0||n[o]!==void 0)&&(r.stateChange={slice:o,before:a[o],after:n[o]})}}return r}function Or(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 _e(e,t){let r=typeof e=="string"?xe(e):e,o=typeof t=="string"?xe(t):t;if(r==null&&o!==null&&o!==void 0)return"Created";if(r!=null&&o==null)return"Deleted";if(Array.isArray(r)&&Array.isArray(o)){let a=r.length,n=o.length,i=r.map(Or).filter(Boolean),l=o.map(Or).filter(Boolean);if(a===n&&a>0){let s=new Set(i),c=new Set(l),u=i.filter(d=>c.has(d));if(u.length===0&&i.length>0&&l.length>0)return`\u26A0\uFE0F Replaced: [${i.join(", ")}] \u2192 [${l.join(", ")}]`;if(u.length<a){let d=i.filter(b=>!c.has(b)),h=l.filter(b=>!s.has(b));return`Changed: -${d.join(", ")} +${h.join(", ")}`}}if(a===0&&n>0)return l.length>0?`Added: [${l.join(", ")}]`:`Added ${n} item${n>1?"s":""}`;if(a>0&&n===0)return i.length>0?`Removed all: [${i.join(", ")}]`:`Removed all ${a} item${a>1?"s":""}`;if(n>a){let s=new Set(i),c=l.filter(u=>!s.has(u));return c.length>0?`Added: [${c.join(", ")}] (${a} \u2192 ${n})`:`Added ${n-a} item${n-a>1?"s":""} (${a} \u2192 ${n})`}if(n<a){let s=new Set(l),c=i.filter(u=>!s.has(u));return c.length>0?`Removed: [${c.join(", ")}] (${a} \u2192 ${n})`:`Removed ${a-n} item${a-n>1?"s":""} (${a} \u2192 ${n})`}return`Updated (${n} item${n>1?"s":""})`}if(typeof r=="object"&&typeof o=="object"&&r&&o){let a=Object.keys(r),n=Object.keys(o),i=n.filter(s=>!a.includes(s)),l=a.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 Ti(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 o=e.queryError;o&&typeof o=="object"?r.error=o.message||o.name||o:r.error=e.queryError}if(e.mutationError!==void 0){let o=e.mutationError;o&&typeof o=="object"?r.error=o.message||o.name||o:r.error=e.mutationError}if(e.query&&typeof e.query=="object"){let o=e.query;if(o.state&&typeof o.state=="object"){let a=o.state;if(a.status&&(r.status=a.status),a.fetchStatus&&(r.fetchStatus=a.fetchStatus),a.error){let n=a.error;n&&typeof n=="object"&&(r.error=n.message||n.name||n)}}}if(e.mutation&&typeof e.mutation=="object"){let o=e.mutation;if(o.state&&typeof o.state=="object"){let a=o.state;if(a.status&&(r.status=a.status),a.failureCount&&(r.failureCount=a.failureCount),a.error){let n=a.error;n&&typeof n=="object"&&(r.error=n.message||n.name||n)}if(a.failureReason){let n=a.failureReason;n&&typeof n=="object"&&(r.failureReason=n.message||n.name||n)}}}return r}function ct(e,t){let r=e.originalEvent;if(!r)return null;let o;return e.source==="storage-async"||e.source==="storage-mmkv"?o=$i(r,t):e.source==="redux"?o=Di(r,t):e.source==="react-query"||e.source==="react-query-query"||e.source==="react-query-mutation"?o=Ti(r,t):t.smartJsonParsing?o=ke(r):o=r,t.stripVerboseFields&&o&&(o=Ot(o)),o}function Qe(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,o=-1/0;for(let a of e)t[a.status]++,t.sources.add(a.source),a.timestamp<r&&(r=a.timestamp),a.timestamp>o&&(o=a.timestamp);return t.durationMs=o-r,t}function Ge(e,t){let r=[...e];if(t.filterMode!=="all"&&(r=r.filter(o=>{switch(t.filterMode){case"errors":return o.status==="error";case"success":return o.status==="success";case"pending":return o.status==="pending";default:return true}})),t.filterSources.length>0){let o=new Set(t.filterSources);r=r.filter(a=>o.has(a.source))}return r}function Lt(e){return e<1e3?`+${e}ms`:e<6e4?`+${(e/1e3).toFixed(1)}s`:`+${(e/6e4).toFixed(1)}m`}function Lr(e){return new Date(e).toISOString()}function dt(e,t,r){let o=Lt(e-t),a=Lr(e);switch(r){case"relative":return o;case"absolute":return a;case"both":return`${o} (${a})`}}function Ut(e,t){let r=0,o=[e],a=new Set;for(;o.length>0;){if(r>t)return{over:true,approxBytes:r};let n=o.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(a.has(n))continue;if(a.add(n),Array.isArray(n)){r+=2+n.length;for(let i=0;i<n.length;i++)o.push(n[i])}else{r+=2;for(let i in n)r+=i.length+4,o.push(n[i])}}else r+=4}return{over:r>t,approxBytes:r}}function pt(e,t){if(t===-1)return{data:e,truncated:false};let{over:r,approxBytes:o}=Ut(e,t*1024);if(r)return{data:`[Data truncated - \u2265${(o/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 Ur(e,t){let r=0;for(let o of e)if(t.includeSource&&(r+=20),t.includeStatus&&(r+=10),t.includeTitle&&(r+=(o.title?.length||0)+10),t.includeSubtitle&&(r+=(o.subtitle?.length||0)+10),t.includeCorrelation&&(r+=20),t.includeDuration&&(r+=15),r+=30,t.includeEventData&&o.originalEvent){let a=t.dataSizeThreshold===-1?1048576:t.dataSizeThreshold*1024,{approxBytes:n}=Ut(o.originalEvent,a);r+=Math.min(n,a)}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 Ai(e,t,r){let o=[],a=dt(e.timestamp,t,r.timestampFormat);if(o.push(`\`${a}\``),r.includeStatus&&o.push(Me[e.status]),r.includeSource&&o.push(`**${Vt[e.source]}**`),r.includeTitle&&o.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=_e(i.prevValue,i.value);l&&o.push(`\u2192 ${l}`)}}return e.source==="redux"&&e.originalEvent?.hasStateChange===false&&o.push("(no state change)"),r.includeSubtitle&&e.subtitle&&o.push(`- ${e.subtitle}`),o.join(" ")}function Ii(e,t){let r=[],o=e.originalEvent;if(!o?.data)return r;let a=o.data,n=t.smartJsonParsing?xe(a.prevValue):a.prevValue,i=t.smartJsonParsing?xe(a.value):a.value,l=_e(a.prevValue,a.value);if(l&&r.push(` **Change:** ${l}`),Array.isArray(n)&&Array.isArray(i)){let s=n.map(u=>typeof u=="object"&&u&&"name"in u?u.name:null).filter(Boolean),c=i.map(u=>typeof u=="object"&&u&&"name"in u?u.name:null).filter(Boolean);(s.length>0||c.length>0)&&(s.length>0&&r.push(` Before: [${s.join(", ")}]`),r.push(` After: [${c.join(", ")}]`))}return r}function Ht(e,t){let r=Ge(e,t);if(r.length===0)return"No events to export.";let o=[...r].sort((s,c)=>s.timestamp-c.timestamp),a=o[0].timestamp,n=Qe(o),i=[];if(i.push("## Event Flow"),t.includeSummaryHeader||t.includeTotalDuration){let s=[];if(t.includeTotalDuration&&s.push(`**Duration:** ${Lt(n.durationMs).replace("+","")}`),s.push(`**Events:** ${n.totalEvents}`),t.includeSummaryHeader){let c=[];n.success>0&&c.push(`${n.success} ${Me.success}`),n.pending>0&&c.push(`${n.pending} ${Me.pending}`),n.error>0&&c.push(`${n.error} ${Me.error}`),n.neutral>0&&c.push(`${n.neutral} ${Me.neutral}`),c.length>0&&s.push(`**Status:** ${c.join(" ")}`)}i.push(s.join(" | "))}if(i.push(""),i.push("### Timeline"),i.push(""),t.compactMode)return o.forEach((s,c)=>{i.push(`${c+1}. ${Ai(s,a,t)}`)}),i.join(`
|
|
4
|
+
`);o.forEach((s,c)=>{let u=[],d=dt(s.timestamp,a,t.timestampFormat);if(u.push(`${c+1}. \`${d}\``),t.includeStatus&&u.push(Me[s.status]),t.includeSource&&u.push(`**${Vt[s.source]}**`),t.includeTitle&&u.push(s.title),t.includeCorrelation&&s.correlationId&&s.sequenceInGroup&&u.push(`(${s.sequenceInGroup})`),i.push(u.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=Ii(s,t);i.push(...h)}if(t.includeEventData&&s.originalEvent){let h=ct(s,t),{data:b,truncated:v}=pt(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=_e(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=
|
|
7
|
-
`)}function
|
|
8
|
-
`)}var
|
|
6
|
+
`)}`),i.push(" ```")}}i.push("")});let l=o.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 c=dt(s.timestamp,a,t.timestampFormat);if(i.push(`**${s.title}** (${c})`),s.originalEvent){let u=ct(s,t),{data:d,truncated:h}=pt(u,t.dataSizeThreshold);h||(i.push("```json"),i.push(JSON.stringify(d,null,2)),i.push("```"))}i.push("")}}return i.join(`
|
|
7
|
+
`)}function Hr(e,t){let r=Ge(e,t);if(r.length===0)return"[]";let o=[...r].sort((l,s)=>l.timestamp-s.timestamp),a=o[0].timestamp,n=Qe(o),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=o.map(l=>{let s={};if(s.timestamp=Lr(l.timestamp),(t.timestampFormat==="relative"||t.timestampFormat==="both")&&(s.relativeMs=l.timestamp-a),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 c=ct(l,t),{data:u,truncated:d}=pt(c,t.dataSizeThreshold);if(s.data=u,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=_e(b.prevValue,b.value);v&&(s.changeSummary=v)}}}return s}),JSON.stringify(i,null,2)}function Kr(e,t){let r=Ge(e,t);if(r.length===0)return"No events to export.";let o=[...r].sort((l,s)=>l.timestamp-s.timestamp),a=o[0].timestamp,n=Qe(o),i=[];if(t.includeSummaryHeader||t.includeTotalDuration){let l=[`Event Flow (${n.totalEvents} events`];if(t.includeTotalDuration&&(l[0]+=`, ${Lt(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 o){let s=[],c=dt(l.timestamp,a,t.timestampFormat);if(s.push(c.padEnd(12)),t.includeStatus&&s.push(Ci[l.status]),t.includeSource&&s.push(`${Vt[l.source]}:`),t.includeTitle&&s.push(l.title),t.showStorageDiff&&(l.source==="storage-async"||l.source==="storage-mmkv")){let u=l.originalEvent;if(u?.data){let d=u.data,h=_e(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 u=ct(l,t),{data:d,truncated:h}=pt(u,t.dataSizeThreshold);h?i.push(` ${d}`):i.push(` Data: ${JSON.stringify(d)}`)}}return i.join(`
|
|
8
|
+
`)}var Kt=[{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 qi(e){let t=new Set;for(let o of e)t.add(o.source);let r=[];r.push(Kt[0]),r.push(Kt[1]);for(let o of Kt.slice(2))o.sources.some(a=>t.has(a))&&r.push(o);return r}function Fi(e){let t=e.some(o=>o.group==="client"),r=e.some(o=>o.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 Ze(e){return e.replace(/[#;:]/g," ").replace(/[\n\r]/g," ").replace(/"/g,"'").replace(/\s+/g," ").trim()}function Bi(e){if(Si(e))return true;let t=["last-route","@dev/last","__debug","_persist","devtools/internal"],r=e.toLowerCase();return t.some(o=>r.includes(o))}function Jt(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Ri(e){return Ut(e,1024*1024).approxBytes}function ji(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 Mi(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(o=>o.charAt(0).toUpperCase()+o.slice(1).toLowerCase()).join(" "),t.toLowerCase()==="saved"&&(t="Favorites"),t.substring(0,20)}function Jr(e){let t=e;try{t=new URL(e,"http://localhost").pathname}catch{let o=t.indexOf("?");o>0&&(t=t.substring(0,o))}let r=t.split("/").filter(Boolean);if(r.length>=2){let o=r[r.length-1];return/^\d+$/.test(o)||/^[a-f0-9-]{36}$/i.test(o)?null:o.charAt(0).toUpperCase()+o.slice(1)}return r.length===1?r[0].charAt(0).toUpperCase()+r[0].slice(1):null}function Pi(e,t){try{let r=new URL(t,"http://localhost"),o=r.pathname;if(o.includes("graphql"))return"GraphQL Request";o=o.replace(/^\/api\/v\d+/,"").replace(/^\/api/,"");let a=Jr(o),n=o.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 a?`Fetch ${a}`:`Fetch ${i}`;case"POST":return o.includes("search")?`Search ${i}`:a?`Create ${a}`:`Create ${i}`;case"PUT":case"PATCH":return a?`Update ${a}`:`Update ${i}`;case"DELETE":return a?`Delete ${a}`:`Delete ${i}`;default:return`${e} ${i}`}}catch{return`${e} request`}}function Wr(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 zi(e,t,r){let o=[],a=[],n=$e(e.timestamp-r);switch(e.source){case"route":{let i=e.originalEvent,l=String(i?.pathname||e.title),s=i?.previousPathname,c=i?.timeSincePrevious,u=Wr(l),d=s?Wr(s):null;d?(o.push(`U->>App: ${d} \u2192 ${u}`),c&&c>0&&a.push(`Note right of App: ${$e(c)} on ${d}`)):o.push(`U->>App: Open ${u}`);break}case"network":{let i=e.originalEvent,l=i?.method||"GET",s=i?.url||"",c=i?.status,u=i?.duration,d=i?.response||i?.data||i?.body,h=i?.responseSize||i?.size||i?.contentLength,b=Pi(l,s),v=Jr(s);if(o.push(`App->>+API: ${b}`),e.status==="error"){let y=c?`${c} Error`:"Failed";o.push(`API--x-App: ${y}`)}else{let y=v?`\u2713 ${v}`:"\u2713 Success";o.push(`API-->>-App: ${y}`)}let m=[];if(u&&m.push($e(u)),h&&h>0)m.push(Jt(h));else if(d){let y=Ri(d);y>1024&&m.push(Jt(y))}m.length>0&&a.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",c=l?.key||"data";if(Bi(c))return{messages:[],notes:[],skip:true};let u=Mi(c),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,A=k.length;if(p=`${C} \u2192 ${A} items`,A>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(A<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 U;y?U=`App->>${d}: ${v} ${m} ${y} \u2192 ${u}`:U=`App->>${d}: ${v} ${m} ${u}`,o.push(U),p&&a.push(`Note right of ${d}: ${p}`);break}case"react-query":case"react-query-query":{let i=e.originalEvent,l=i?.type||"",s=i?.queryKey,c=i?.duration,u="data";if(Array.isArray(s)&&s.length>0){let d=s[s.length-1];typeof d=="string"&&!/^\d+$/.test(d)?u=d.charAt(0).toUpperCase()+d.slice(1):s.length>1&&typeof s[0]=="string"&&(u=s[0].charAt(0).toUpperCase()+s[0].slice(1))}if(l.includes("start")||l.includes("fetch")||e.status==="pending")o.push(`App->>+Cache: Fetch ${u}`);else if(e.status==="error")o.push("Cache--x-App: Failed to load");else if(e.status==="success"){let d=`\u2713 ${u} ready`;c&&(d+=` (${$e(c)})`),o.push(`Cache-->>-App: ${d}`)}else l.includes("invalidate")?o.push(`App->>Cache: Refresh ${u}`):o.push(`Cache-->>App: ${Ze(l)}`);break}case"react-query-mutation":{let i=e.originalEvent,l=i?.type||"",s=i?.mutationKey,c=i?.duration,u="Update";if(Array.isArray(s)&&s.length>0){let d=String(s[0]);d.includes("add")||d.includes("create")?u="Add":d.includes("delete")||d.includes("remove")?u="Delete":d.includes("update")||d.includes("edit")?u="Update":u=d.charAt(0).toUpperCase()+d.slice(1)}if(l.includes("start")||l.includes("loading")||e.status==="pending")o.push(`App->>+Cache: ${u}`);else if(e.status==="error")o.push(`Cache--x-App: ${u} failed`);else if(e.status==="success"){let d=`\u2713 ${u} complete`;c&&(d+=` (${$e(c)})`),o.push(`Cache-->>-App: ${d}`)}break}case"redux":{let i=e.originalEvent,l=i?.type||e.title,s=i?.hasStateChange,c=i?.diffSummary,u=l.split("/"),d;if(u.length>=2){let h=u[0].charAt(0).toUpperCase()+u[0].slice(1),b=u[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=Ze(l).substring(0,25);o.push(`App->>Redux: ${d}`),s===false?a.push("Note right of Redux: No change"):c&&a.push(`Note right of Redux: ${Ze(c).substring(0,35)}`);break}case"render":{let i=e.originalEvent?.renderData,l=Ze(e.title).substring(0,20),s=i?.cause||"update",c=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;o.push(`App->>App: Render ${l}`),a.push(`Note right of App: ${c}`);break}default:o.push(`App->>App: ${Ze(e.title).substring(0,30)}`)}return{messages:o,notes:a}}function _r(e,t){let r=Ge(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
|
|
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};
|
|
11
|
+
Note over U,App: No events captured`;let o=[...r].sort((m,y)=>m.timestamp-y.timestamp),a=o[0].timestamp,n=qi(o),i=Fi(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=o[o.length-1].timestamp-a,c=o.filter(m=>m.source==="network"),u=c.reduce((m,y)=>{let p=y.originalEvent,g=p?.responseSize||p?.size||0;return m+g},0),d=o.filter(m=>m.status==="error").length,h=[];h.push(`\u23F1\uFE0F ${$e(s)}`),h.push(`\u{1F4CA} ${o.length} events`),c.length>0&&h.push(`\u{1F310} ${c.length} API calls`),u>0&&h.push(`\u{1F4E6} ${Jt(u)}`),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 o){let y=zi(m,t,a);if(y.skip){v++;continue}let{messages:p,notes:g}=y,k=false,U="";if(m.source==="network"){let C=m.originalEvent?.url;if(C){let A=ji(C),x=b.get(A);if(x&&m.timestamp-x.timestamp<3e4){k=true;let j=m.timestamp-x.timestamp;U=`\u26A0\uFE0F Already fetched ${$e(j)} ago`,b.set(A,{timestamp:m.timestamp,count:x.count+1})}else b.set(A,{timestamp:m.timestamp,count:1})}}if(k){l.push(" rect rgb(255, 245, 230)"),l.push(` Note over App,API: ${U}`);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 Wt(e,t){switch(t.format){case"markdown":return Ht(e,t);case"json":return Hr(e,t);case"plaintext":return Kr(e,t);case"mermaid":return _r(e,t);default:return Ht(e,t)}}import{definePersistedSetting as Ni,devToolsStorageKeys as Vi}from"@buoy-gg/shared-ui/web";var _t=Ni(Vi.events.copySettings(),Je,{sanitize:(e,t)=>({...e,filterSources:t?.filterSources??Je.filterSources})});async function Qr(e){await _t.save(e)}async function Gr(){return _t.loadOrNull()}async function Oi(){await _t.clear()}import{Fragment as Li,jsx as ae,jsxs as Qt}from"react/jsx-runtime";var Ui=50*1024,Hi=200*1024;function Ki(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function Ji(){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 Zr({events:e=[],initialSettings:t=Je,onSettingsChange:r}){let{isPro:o}=gi(),[a,n]=Nt(t),[i,l]=Nt(false),[s,c]=Nt(false);li(()=>{let A=true;return Gr().then(x=>{A&&x&&(n(x),r?.(x)),A&&c(true)}),()=>{A=false}},[r]);let u=je(A=>{n(A),r?.(A),Qr(A)},[r]),d=e.length>0,h=d?e:Ji(),b=ut(()=>Vr(a),[a]),v=ut(()=>Ur(h,a),[h,a]),m=ut(()=>v>=Hi?"danger":v>=Ui?"warning":"none",[v]),y=je(()=>Wt(h,a),[h,a]),p=je(A=>{let x=We[A];u({...x,filterSources:[...x.filterSources]})},[u]),g=je((A,x)=>{let[j,N]=A.split("::");if(j==="preset"){p(N);return}if(j==="include"){u({...a,[N]:!a[N]});return}if(j==="format"){u({...a,format:x});return}if(j==="timestamp"){u({...a,timestampFormat:x});return}if(j==="filter"){u({...a,filterMode:x});return}if(j==="threshold"){u({...a,dataSizeThreshold:x});return}},[a,u,p]),k=je(()=>{let A=h.length;return ae(yi,{expanded:i,onExpandedChange:l,summary:`${A} event${A!==1?"s":""} \xB7 ~${Ki(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 a.format==="json"?ae(vi,{testIDPrefix:`${S}-preview-json`,data:JSON.parse(x),title:"",showTypeFilter:true,rawMode:true,initialExpanded:true}):Qt(f,{children:[a.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:o,testID:`${S}-preview-text`,children:x})})]})}})},[i,h,a,v,m,d,y,o]),U=je(()=>{let A=Qe(h),x=d?`${A.totalEvents} events`:"Mock data (no events captured)";return Qt(Li,{children:[ae($,{style:De.statusLabel,testID:`${S}-export-status`,children:x}),ae(hi,{value:y()})]})},[d,h,y]),C=ut(()=>({sections:[{id:"presets",title:"Presets",type:"custom",data:[{id:"preset::llm",label:z.llm.label,icon:ci,color:z.llm.color,value:"llm",isActive:b==="llm",description:z.llm.description},{id:"preset::bugReport",label:z.bugReport.label,icon:di,color:z.bugReport.color,value:"bugReport",isActive:b==="bugReport",description:z.bugReport.description},{id:"preset::json",label:z.json.label,icon:Pr,color:z.json.color,value:"json",isActive:b==="json",description:z.json.description},{id:"preset::errors",label:z.errors.label,icon:zr,color:z.errors.color,value:"errors",isActive:b==="errors",description:z.errors.description},{id:"preset::minimal",label:z.minimal.label,icon:Mr,color:z.minimal.color,value:"minimal",isActive:b==="minimal",description:z.minimal.description},{id:"preset::mermaid",label:z.mermaid.label,icon:Nr,color:z.mermaid.color,value:"mermaid",isActive:b==="mermaid",description:z.mermaid.description},{id:"preset::custom",label:"Custom",icon:pi,color:Ke.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:a.includeSource},{id:"include::includeStatus",label:"Status",value:"includeStatus",isActive:a.includeStatus},{id:"include::includeTitle",label:"Title",value:"includeTitle",isActive:a.includeTitle},{id:"include::includeSubtitle",label:"Subtitle",value:"includeSubtitle",isActive:a.includeSubtitle},{id:"include::includeCorrelation",label:"Correlation",value:"includeCorrelation",isActive:a.includeCorrelation},{id:"include::includeDuration",label:"Duration",value:"includeDuration",isActive:a.includeDuration},{id:"include::includeSummaryHeader",label:"Summary",value:"includeSummaryHeader",isActive:a.includeSummaryHeader},{id:"include::includeEventData",label:"Data",value:"includeEventData",isActive:a.includeEventData}]},{id:"format",title:"Format",type:"custom",data:[{id:"format::markdown",label:"Markdown",icon:Mr,color:He.semantic.info,value:"markdown",isActive:a.format==="markdown"},{id:"format::json",label:"JSON",icon:Pr,color:He.semantic.warning,value:"json",isActive:a.format==="json"},{id:"format::plaintext",label:"Text",icon:ui,color:Ke.color.textSecondary,value:"plaintext",isActive:a.format==="plaintext"},{id:"format::mermaid",label:"Diagram",icon:Nr,color:"#A855F7",value:"mermaid",isActive:a.format==="mermaid",description:"Mermaid sequence diagram"}]},{id:"timestamp",title:"Timestamps",type:"custom",data:[{id:"timestamp::relative",label:"Relative",value:"relative",isActive:a.timestampFormat==="relative",description:"+0ms, +150ms"},{id:"timestamp::absolute",label:"Absolute",value:"absolute",isActive:a.timestampFormat==="absolute",description:"ISO format"},{id:"timestamp::both",label:"Both",value:"both",isActive:a.timestampFormat==="both",description:"Both formats"}]},{id:"filter",title:"Filter Events",type:"custom",data:[{id:"filter::all",label:"All",value:"all",isActive:a.filterMode==="all"},{id:"filter::errors",label:"Errors",icon:zr,color:He.semantic.error,value:"errors",isActive:a.filterMode==="errors"},{id:"filter::success",label:"Success",color:He.semantic.success,value:"success",isActive:a.filterMode==="success"},{id:"filter::pending",label:"Pending",color:He.semantic.warning,value:"pending",isActive:a.filterMode==="pending"}]},{id:"llmOptimization",title:"LLM Optimization",type:"custom",data:[{id:"include::compactMode",label:"Compact",value:"compactMode",isActive:a.compactMode,description:"One line per event"},{id:"include::smartJsonParsing",label:"Smart JSON",value:"smartJsonParsing",isActive:a.smartJsonParsing,description:"Parse nested JSON"},{id:"include::reduxChangedOnly",label:"Redux Diff",value:"reduxChangedOnly",isActive:a.reduxChangedOnly,description:"Only show changes"},{id:"include::showStorageDiff",label:"Storage Diff",value:"showStorageDiff",isActive:a.showStorageDiff,description:"Show what changed"},{id:"include::stripVerboseFields",label:"Strip Noise",value:"stripVerboseFields",isActive:a.stripVerboseFields,description:"Remove images/descriptions"}]}],previewSection:{enabled:true,title:"PREVIEW",icon:mi,content:k,headerActions:U},onFilterChange:g}),[a,b,g,k,U]);return o?ae(jr,{...C}):Qt(ue,{style:De.gatedContainer,contentContainerStyle:De.gatedContent,testID:`${S}-copy-settings-gated`,children:[ae(fi,{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(jr,{...C})})]})}var De=le.create({previewScroll:{maxHeight:300},previewText:{fontFamily:bi,fontSize:11,color:Ke.color.text,lineHeight:18},mermaidHint:{fontSize:11,color:Ke.color.textSecondary,marginBottom:8,paddingHorizontal:8,paddingVertical:6,backgroundColor:"#A855F715",borderRadius:6,overflow:"hidden"},statusLabel:{fontSize:11,fontWeight:"600",color:Ke.color.textTertiary,marginRight:8},gatedContainer:{flex:1},gatedContent:{padding:12,gap:12},gatedPreview:{}});import{TickProvider as Yr}from"@buoy-gg/shared-ui/web";import{Fragment as mt,jsx as I,jsxs as ie}from"react/jsx-runtime";function Gt({visible:e,onClose:t,onBack:r,onMinimize:o,enableSharedModalDimensions:a=false,inline:n=false,capturing:i,onCapturingChange:l,networkDetailWrapper:s,NetworkEventDetailViewComponent:c,RouteEventDetailComponent:u,detailComponents:d}){let h=Ia(),b=i!=null&&l!=null,{filteredEvents:v,availableSources:m,toggleSource:y,clearEvents:p,totalCount:g,filteredCount:k,isCapturing:U,toggleCapturing:C,hiddenEventsCount:A,searchText:x,setSearchText:j}=Tt(b?{capturingOverride:i}:void 0),N=b?i:U,me=b?()=>l(!i):C,[_,he]=at("list"),[Q,et]=at(null),[ft,tt]=at(false),[Te,Ve]=at(false),yt=Sa(null);va(()=>{if(!Te)return;let Z=requestAnimationFrame(()=>{yt.current?.focus()});return()=>cancelAnimationFrame(Z)},[Te]);let bt=Ie(()=>{Ve(false),j("")},[j]),rt=Ie(Z=>{try{h.push(Z)}catch(vt){ir.alert("Navigation Error",String(vt))}},[h]),w=Ie(Z=>{et(Z),he("detail")},[]),B=Ie(()=>{_==="detail"?(et(null),he("list")):_==="copySettings"&&he("list")},[_]),M=Ie(()=>{he("copySettings")},[]),G=Ie(Z=>{},[]),q=a?$a.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:[I(X.Navigation,{onBack:B}),I(X.Content,{title:Q.title,testID:`${S}-detail-heading`}),I(X.Actions,{children:I(Da,{value:Z})})]})}return _==="copySettings"?ie(X,{children:[I(X.Navigation,{onBack:B}),I(X.Content,{title:"Copy Settings",testID:`${S}-copy-settings-heading`})]}):ie(X,{children:[r&&I(X.Navigation,{onBack:r}),I(X.Content,{title:"",children:Te?I(X.Search,{value:x,onChangeText:j,onCancel:bt,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:[I($,{style:te.headerTitle,testID:`${S}-title`,children:"Events"}),ie($,{style:te.headerSubtitle,testID:`${S}-count`,children:[g," captured"]})]})}),ie(X.Actions,{children:[!Te&&I(ge,{onPress:()=>Ve(true),style:[te.headerActionButton,x.length>0&&te.headerActionButtonActive],testID:`${S}-search-open`,accessibilityRole:"button",accessibilityLabel:"Search events",children:I(ka,{size:14,color:x.length>0?ee.color.accent:ee.color.textSecondary})}),I(ge,{onPress:M,style:[te.headerActionButton,g===0&&te.headerActionButtonDisabled],disabled:g===0,testID:`${S}-copy`,accessibilityRole:"button",accessibilityLabel:"Copy events",children:I(xa,{size:14,color:g>0?ee.color.textSecondary:ee.color.textTertiary})}),I(Aa,{isEnabled:N,onToggle:me,testID:`${S}-power`,accessibilityLabel:"Toggle event capture"}),I(ge,{onPress:p,style:[te.headerActionButton,g===0&&te.headerActionButtonDisabled],disabled:g===0,testID:`${S}-clear`,accessibilityRole:"button",accessibilityLabel:"Clear events",children:I(Ea,{size:14,color:g>0?ee.color.textSecondary:ee.color.textTertiary})})]})]})},ne=I(f,{style:te.container,children:_==="copySettings"?I(Zr,{events:v}):_==="detail"&&Q?I(zt,{event:Q,onBack:B,onNavigate:rt,networkDetailWrapper:s,NetworkEventDetailViewComponent:c,RouteEventDetailComponent:u,detailComponents:d}):ie(mt,{children:[I(It,{availableSources:m,onToggleSource:y,totalCount:g,filteredCount:k}),I(jt,{events:v,selectedEventId:void 0,expandedEventId:void 0,onEventPress:w,onNavigate:rt,isCapturing:N,hiddenEventsCount:A,searchText:x,totalCount:g,sourceCount:m.length,enabledSourceCount:m.filter(Z=>Z.enabled!==false).length,onUpgradePress:()=>tt(true)})]})}),Ae=Yr?I(Yr,{children:ne}):ne,ot=I(mt,{children:I(Ta,{visible:ft,onClose:()=>tt(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(mt,{children:[ie(f,{style:te.inlineRoot,children:[I(f,{style:te.inlineHeader,...qa,children:R()}),Ae]}),ot]}):ie(mt,{children:[I(Ca,{visible:e,onClose:t,onMinimize:o,persistenceKey:q,header:{showToggleButton:true,customContent:R()},onModeChange:G,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},disableScrollWrapper:true,children:Ae}),ot]})}var te=le.create({inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:wa.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 Wi(e={}){return I(Gt,{...e,inline:true,visible:true,onClose:()=>{}})}import{createToolFactory as _i,defineToolPreset as Qi}from"@buoy-gg/shared-ui/web";import{jsx as Gi}from"react/jsx-runtime";var Xr=Qi({id:"events",name:"EVENTS",description:"Unified event timeline",slot:"both",icon:({size:e,color:t})=>Gi(co,{size:e,color:t||po}),component:Gt,props:{enableSharedModalDimensions:false}}),Zi=_i(Xr);import{useState as Yi,useCallback as eo}from"react";import{night as pe,Trash2 as Xi}from"@buoy-gg/shared-ui/web";import{jsx as Pe,jsxs as Ye}from"react/jsx-runtime";function es(){let{filteredEvents:e,availableSources:t,toggleSource:r,clearEvents:o,totalCount:a,filteredCount:n,isCapturing:i}=Tt(),[l,s]=Yi(null),c=eo(d=>{s(d)},[]),u=eo(()=>{s(null)},[]);return l?Pe(zt,{event:l,onBack:u}):Ye(f,{style:ze.container,children:[Ye(f,{style:ze.header,children:[Ye(f,{children:[Pe($,{style:ze.title,children:"Events"}),Ye($,{style:ze.subtitle,children:[a," event",a!==1?"s":""," captured"]})]}),Ye(ge,{style:ze.clearButton,onPress:o,activeOpacity:.7,disabled:a===0,children:[Pe(Xi,{size:16,color:a===0?pe.color.textTertiary:pe.color.danger}),Pe($,{style:[ze.clearText,{color:a===0?pe.color.textTertiary:pe.color.danger}],children:"Clear"})]})]}),Pe(It,{availableSources:t,onToggleSource:r,totalCount:a,filteredCount:n}),Pe(jt,{events:e,selectedEventId:void 0,onEventPress:c,isCapturing:i,totalCount:a,sourceCount:t.length,enabledSourceCount:t.filter(d=>d.enabled!==false).length})]})}var ze=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 ts,isJsonSerializable as rs,isOverWireBudget as os}from"@buoy-gg/shared-ui/web";var Ne=16*1024;function to(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 Xe={__buoyOmitted:"state-tree",note:"prevState/nextState stay on the device (use get_redux_state / the on-device tool)."},as={__buoyOmitted:"query-payload",note:"Query/mutation data stays on the device (open the Query tool or the on-device Events detail)."},ht={__buoyOmitted:"network-body",note:"Request/response body stays on the device (open the Network tool or the on-device Events detail)."},ro={__buoyOmitted:"network-headers",note:"Request/response headers stay on the device (open the Network tool or the on-device Events detail)."},ns={__buoyOmitted:"graphql-variables",note:"GraphQL variables stay on the device (open the Network tool or the on-device Events detail)."},Zt={__buoyOmitted:"storage-value",note:"Storage value stays on the device (open the Storage tool or the on-device Events detail)."},is={__buoyOmitted:"route-params",note:"Navigation params stay on the device (open the Routes tool or the on-device Events detail)."};function ss(e){return e==="react-query"||e==="react-query-query"||e==="react-query-mutation"}function se(e,t){if(e!==void 0)return os(e,Ne)?{...t}:e}function gt(e){return se(e,as)}function oo(e){return e==null?e:e instanceof Error?{name:e.name,message:e.message}:gt(e)}var ao=new WeakMap;function ls(e){let t=e.originalEvent;if(typeof t!="object"||t===null)return e;let r=ao.get(e);if(r!==void 0)return r;let o=e,a=t;if((e.source==="redux"||e.source==="zustand")&&("prevState"in a||"nextState"in a))a={...a,prevState:{...Xe},nextState:{...Xe},...e.source==="zustand"&&"partial"in a?{partial:{...Xe}}:{}},o={...e,originalEvent:a};else if(e.source==="jotai"&&("prevValue"in a||"nextValue"in a))a={...a,prevValue:{...Xe},nextValue:{...Xe}},o={...e,originalEvent:a};else if(e.source==="render"){let s=a.render,c=a.event,u=d=>{if(!d||typeof d!="object")return d;let{hookChanges:h,...b}=d;return b};a={...a,render:s&&{...s,renderHistory:void 0,lastRenderCause:u(s.lastRenderCause)},event:c&&{...c,capturedProps:void 0,capturedState:void 0,cause:u(c.cause)}},o={...e,originalEvent:a}}else if(ss(e.source)){let{query:s,mutation:c,...u}=a;a={...u,queryData:gt(u.queryData),mutationData:gt(u.mutationData),mutationVariables:gt(u.mutationVariables),queryError:oo(u.queryError),mutationError:oo(u.mutationError)},o={...e,originalEvent:a}}else if(e.source==="network"){let s=typeof a.requestSize=="number"?a.requestSize:void 0,c=typeof a.responseSize=="number"?a.responseSize:void 0;a={...a,requestData:s!==void 0&&s>Ne?{...ht}:se(a.requestData,ht),responseData:c!==void 0&&c>Ne?{...ht}:se(a.responseData,ht),graphqlVariables:se(a.graphqlVariables,ns),requestHeaders:se(a.requestHeaders,ro),responseHeaders:se(a.responseHeaders,ro)},o={...e,originalEvent:a}}else if(e.source==="storage-async"||e.source==="storage-mmkv"){let s=a.data;s&&(a={...a,data:{...s,value:se(s.value,Zt),prevValue:se(s.prevValue,Zt),pairs:se(s.pairs,Zt)}},o={...e,originalEvent:a})}else e.source==="route"&&(a={...a,params:se(a.params,is)},o={...e,originalEvent:a});let{bytes:n,sawRepeat:i,sawBigInt:l}=ts(a,Ne);return n>Ne?o={...e,originalEvent:to(n)}:(i||l)&&!rs(a)&&(o={...e,originalEvent:to(-1,"Payload is not JSON-serializable (cyclic or bigint) and stayed on the device.")}),ao.set(e,o),o}var us={version:2,getSnapshot:()=>({events:O.getEvents().map(ls),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??{}},o=O.getEvents(),a=typeof t.limit=="number"&&t.limit>0?t.limit:o.length,n=o.slice(0,a);return{output:Wt(n,r),returned:n.length,totalAvailable:o.length,includedData:r.includeEventData,format:r.format}}}};export{We as COPY_PRESETS,Je as DEFAULT_COPY_SETTINGS,S as EVENTS_TEST_ID,Zr as EventsCopySettingsView,Gt as EventsModal,Wi as EventsToolView,z as PRESET_METADATA,Br as ReactQueryEventDetail,zt as UnifiedEventDetail,It as UnifiedEventFilters,$r as UnifiedEventItem,jt as UnifiedEventList,es as UnifiedEventViewer,Dr as buildCorrelationCountMap,Oi as clearCopySettings,Zi as createEventsTool,Vr as detectActivePreset,Ur as estimateExportSize,wr as eventFilterTestID,Sr as eventIdentity,Cr as eventRowTestID,us as eventsSyncAdapter,Xr as eventsToolPreset,Ge as filterEvents,Vn as findRelatedEvents,Wt as generateExport,Hr as generateJsonExport,Ht as generateMarkdownExport,_r as generateMermaidExport,Kr as generatePlaintextExport,qr as getCorrelationColor,Tr as getCorrelationGroup,Ar as getCorrelationLabel,Qe as getExportSummary,Ln as getRelatedEventsCount,On as hasRelatedEvents,nt as isBuoyInternalEvent,za as isEventHiddenFromTool,Et as isNetworkEventIgnored,Gr as loadCopySettings,Qr as saveCopySettings,O as unifiedEventStore,Tt as useUnifiedEvents,hn as watchEvents};
|