@buoy-gg/network 7.0.39 → 7.0.41
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 +6 -0
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/network/components/NetworkListScreen.js +2 -3
- package/lib/commonjs/network/components/NetworkListScreen.web.js +2 -3
- package/lib/commonjs/network/components/NetworkModal.js +1 -1
- package/lib/commonjs/network/conditions/xhr.js +26 -1
- package/lib/commonjs/network/overrides/applyToXhr.js +99 -42
- package/lib/commonjs/network/overrides/matchRule.js +7 -1
- package/lib/commonjs/network/overrides/overriddenRows.js +37 -0
- package/lib/commonjs/network/overrides/resolveOverride.js +1 -1
- package/lib/commonjs/network/utils/networkEventStore.js +24 -6
- package/lib/commonjs/network/utils/networkListener.js +106 -11
- package/lib/commonjs/network/utils/networkSavedStore.js +4 -4
- package/lib/commonjs/network/utils/requestId.js +16 -0
- package/lib/commonjs/network/utils/resolveRequestUrl.js +15 -0
- package/lib/commonjs/network/utils/startNetworkCapture.js +24 -0
- package/lib/commonjs/preset.js +3 -12
- package/lib/module/index.js +1 -0
- package/lib/module/network/components/NetworkListScreen.js +2 -3
- package/lib/module/network/components/NetworkListScreen.web.js +2 -3
- package/lib/module/network/components/NetworkModal.js +1 -1
- package/lib/module/network/conditions/xhr.js +27 -2
- package/lib/module/network/overrides/applyToXhr.js +98 -42
- package/lib/module/network/overrides/matchRule.js +7 -1
- package/lib/module/network/overrides/overriddenRows.js +33 -0
- package/lib/module/network/overrides/resolveOverride.js +1 -1
- package/lib/module/network/utils/networkEventStore.js +25 -7
- package/lib/module/network/utils/networkListener.js +106 -12
- package/lib/module/network/utils/networkSavedStore.js +4 -4
- package/lib/module/network/utils/requestId.js +12 -0
- package/lib/module/network/utils/resolveRequestUrl.js +11 -0
- package/lib/module/network/utils/startNetworkCapture.js +21 -0
- package/lib/module/preset.js +3 -12
- package/lib/typescript/index.d.ts +1 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/network/components/NetworkListScreen.d.ts.map +1 -1
- package/lib/typescript/network/components/NetworkListScreen.web.d.ts.map +1 -1
- package/lib/typescript/network/conditions/xhr.d.ts.map +1 -1
- package/lib/typescript/network/overrides/applyToXhr.d.ts +1 -0
- package/lib/typescript/network/overrides/applyToXhr.d.ts.map +1 -1
- package/lib/typescript/network/overrides/matchRule.d.ts.map +1 -1
- package/lib/typescript/network/overrides/overriddenRows.d.ts +16 -0
- package/lib/typescript/network/overrides/overriddenRows.d.ts.map +1 -0
- package/lib/typescript/network/utils/networkEventStore.d.ts.map +1 -1
- package/lib/typescript/network/utils/networkListener.d.ts +3 -4
- package/lib/typescript/network/utils/networkListener.d.ts.map +1 -1
- package/lib/typescript/network/utils/networkSavedStore.d.ts +4 -4
- package/lib/typescript/network/utils/requestId.d.ts +2 -0
- package/lib/typescript/network/utils/requestId.d.ts.map +1 -0
- package/lib/typescript/network/utils/resolveRequestUrl.d.ts +3 -0
- package/lib/typescript/network/utils/resolveRequestUrl.d.ts.map +1 -0
- package/lib/typescript/network/utils/startNetworkCapture.d.ts +6 -0
- package/lib/typescript/network/utils/startNetworkCapture.d.ts.map +1 -0
- package/lib/typescript/preset.d.ts.map +1 -1
- package/lib/web/index.mjs +146 -0
- package/package.json +32 -10
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var So=Object.defineProperty;var Ks=Object.getOwnPropertyDescriptor;var Ys=Object.getOwnPropertyNames;var Qs=Object.prototype.hasOwnProperty;var Pn=(t,e)=>()=>(t&&(e=t(t=0)),e);var Zs=(t,e)=>{for(var r in e)So(t,r,{get:e[r],enumerable:!0})},vo=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Ys(e))!Qs.call(t,i)&&i!==r&&So(t,i,{get:()=>e[i],enumerable:!(o=Ks(e,i))||o.enumerable});return t},ge=(t,e,r)=>(vo(t,e,"default"),r&&vo(r,e,"default"));var ea=t=>vo(So({},"__esModule",{value:!0}),t);var I,g=Pn(()=>{"use strict";I=process.env.NODE_ENV!=="production";typeof window<"u"&&typeof globalThis.global>"u"&&(globalThis.global=globalThis)});var ce={};Zs(ce,{AccessibilityInfo:()=>fa,ActivityIndicator:()=>ko,Alert:()=>ua,Animated:()=>ga,AppRegistry:()=>ha,AppState:()=>ya,Appearance:()=>ma,BackHandler:()=>ba,Button:()=>la,CheckBox:()=>qa,Clipboard:()=>wa,DeviceEventEmitter:()=>Ga,Dimensions:()=>va,Easing:()=>Sa,FlatList:()=>sr,I18nManager:()=>ka,Image:()=>Ma,ImageBackground:()=>Da,InteractionManager:()=>Ra,Keyboard:()=>xa,KeyboardAvoidingView:()=>Aa,LayoutAnimation:()=>Ta,Linking:()=>Ca,LogBox:()=>Ja,Modal:()=>sa,NativeEventEmitter:()=>Ea,NativeModules:()=>pa,PanResponder:()=>Na,Picker:()=>Ha,PixelRatio:()=>Oa,Platform:()=>Ia,Pressable:()=>ia,ProgressBar:()=>za,RefreshControl:()=>Va,SafeAreaView:()=>Fa,ScrollView:()=>Ge,SectionList:()=>_a,Share:()=>Pa,StatusBar:()=>Wa,StyleSheet:()=>K,Switch:()=>aa,Text:()=>f,TextInput:()=>ft,Touchable:()=>$a,TouchableHighlight:()=>oa,TouchableNativeFeedback:()=>Ua,TouchableOpacity:()=>D,TouchableWithoutFeedback:()=>na,UIManager:()=>La,Vibration:()=>Ba,View:()=>u,VirtualizedList:()=>ja,YellowBox:()=>Xa,findNodeHandle:()=>da,unstable_createElement:()=>ca,useColorScheme:()=>Ka,useLocaleContext:()=>Ya,useWindowDimensions:()=>xo});import*as Gp from"react-native-web";import{unstable_createElement as ca,NativeModules as pa,AccessibilityInfo as fa,Animated as ga,Appearance as ma,AppRegistry as ha,AppState as ya,BackHandler as ba,Clipboard as wa,Dimensions as va,Easing as Sa,I18nManager as ka,Keyboard as xa,InteractionManager as Ra,LayoutAnimation as Ta,Linking as Ca,NativeEventEmitter as Ea,PanResponder as Na,PixelRatio as Oa,Platform as Ia,Share as Pa,StyleSheet as K,UIManager as La,Vibration as Ba,CheckBox as qa,FlatList as sr,Image as Ma,ImageBackground as Da,KeyboardAvoidingView as Aa,Picker as Ha,ProgressBar as za,RefreshControl as Va,SafeAreaView as Fa,SectionList as _a,StatusBar as Wa,Touchable as $a,TouchableNativeFeedback as Ua,VirtualizedList as ja,YellowBox as Xa,LogBox as Ja,DeviceEventEmitter as Ga,useColorScheme as Ka,useLocaleContext as Ya,useWindowDimensions as xo}from"react-native-web";import*as le from"react-native-web";import{createElement as ta,forwardRef as ra}from"react";function Ve(t){let e=ra((o,i)=>{let{accessibilityState:n,accessibilityValue:s,...a}=o;for(let l of["busy","checked","disabled","expanded","selected"])n?.[l]!==void 0&&a[`aria-${l}`]===void 0&&(a[`aria-${l}`]=n[l]);for(let[l,p]of Object.entries({min:"valuemin",max:"valuemax",now:"valuenow",text:"valuetext"}))s?.[l]!==void 0&&a[`aria-${p}`]===void 0&&(a[`aria-${p}`]=s[l]);return ta(t,{...a,ref:i})}),r=t.State;return r&&Object.assign(e,{State:r}),e.displayName=t.displayName??t.name??"NativeWebView",e}var u,f,ft,D,oa,na,ia,Ge,sa,aa,ko,la,da,ua,he=Pn(()=>{g();ge(ce,Gp);u=Ve(le.View),f=Ve(le.Text),ft=Ve(le.TextInput),D=Ve(le.TouchableOpacity),oa=Ve(le.TouchableHighlight),na=Ve(le.TouchableWithoutFeedback),ia=Ve(le.Pressable),Ge=Ve(le.ScrollView),sa=Ve(le.Modal),aa=Ve(le.Switch),ko=Ve(le.ActivityIndicator),la=Ve(le.Button),da=le.findNodeHandle,ua={alert(t,e,r,o){if(typeof document>"u")return;let i=document.createElement("dialog");i.dataset.buoyRoot="",i.setAttribute("aria-label",t),i.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=t,n.style.cssText="font-size:18px;margin:0 0 12px",i.appendChild(n),e){let p=document.createElement("p");p.textContent=e,p.style.cssText="line-height:1.5;white-space:pre-wrap;margin:0 0 20px",i.appendChild(p)}let s=document.createElement("div");s.style.cssText="display:flex;justify-content:flex-end;flex-wrap:wrap;gap:8px";let a=r?.length?r:[{text:"OK"}],l=()=>{i.close?.(),i.remove()};for(let p of a){let c=document.createElement("button");c.type="button",c.textContent=p.text??"OK",c.style.cssText=`padding:9px 14px;border:1px solid #64748b;border-radius:7px;color:white;background:${p.style==="destructive"?"#a52b38":"#283a4d"};cursor:pointer;font:inherit`,c.onclick=()=>{l(),p.onPress?.()},s.appendChild(c)}i.addEventListener("cancel",p=>{p.preventDefault(),o?.cancelable!==!1&&(l(),o?.onDismiss?.())}),i.appendChild(s),document.body.appendChild(i),i.showModal?i.showModal():i.setAttribute("open","")}}});g();g();g();he();import{useSyncExternalStore as Sl}from"react";import{NetworkIcon as kl}from"@buoy-gg/shared-ui/web";g();import{hasAccountAccess as ei,subscribeAccountAccess as vl}from"@buoy-gg/shared-ui/web";g();g();function Ro(t){if(typeof document>"u")return t;try{return new URL(t,document.baseURI).href}catch{return t}}g();var To=globalThis;function Co(t){let e=To.__BUOY_NETWORK_REQUEST_SEQUENCE__??(To.__BUOY_NETWORK_REQUEST_SEQUENCE__={session:`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`,next:0});return`${t}_${e.session}_${++e.next}`}g();g();var Er=t=>t,Ln=!1;function No(t){let e=Er(t);return typeof e.setReadyState=="function"&&typeof e.setResponseHeaders=="function"}function Qa(t){return typeof t.addEventListener=="function"&&typeof t.removeEventListener=="function"&&typeof t.dispatchEvent=="function"}function Za(){Ln||(Ln=!0,typeof I<"u"&&I&&console.warn("[Buoy] Network overrides need an XMLHttpRequest they can drive (React Native's, or a standards EventTarget one) and this environment provides neither \u2014 requests will run normally."))}function Bn(t,e,r){let o=Er(t);o.responseURL=e,o.status=r.status,o.statusText=r.statusText,o.setResponseHeaders?.(r.headers),o.setReadyState?.(2),!o._aborted&&(o._responseType="text",o._response=r.body,o._cachedResponse=void 0,o.setReadyState?.(3),!o._aborted&&o.setReadyState?.(4))}function qn(t,e){let r=Er(t),o=e.failKind==="timeout";r._hasError=!0,r._timedOut=o,r._responseType="text",r._response=o?"Request timed out (Buoy override)":"Network request failed (Buoy override)",r._cachedResponse=void 0,r.setReadyState?.(4)}function st(t,e,r){Object.defineProperty(t,e,{value:r,configurable:!0,enumerable:!0,writable:!1})}function el(t){if(t!=="readystatechange"&&typeof ProgressEvent=="function")try{return new ProgressEvent(t)}catch{}if(typeof Event=="function")try{return new Event(t)}catch{}return{type:t}}function Pt(t,e){t.dispatchEvent(el(e))}function ar(t,e){st(t,"readyState",e),Pt(t,"readystatechange")}function tl(t,e){let r="";try{r=t.responseType}catch{}switch(r){case"":case"text":return e.body;case"json":try{return JSON.parse(e.body)}catch{return null}case"arraybuffer":return typeof TextEncoder=="function"?new TextEncoder().encode(e.body).buffer:e.body;case"blob":if(typeof Blob=="function"){let o=Object.entries(e.headers).find(([i])=>i.toLowerCase()==="content-type")?.[1]??"";return new Blob([e.body],{type:o})}return e.body;default:return e.body}}function rl(t,e,r,o){let i=r.headers,n=Object.entries(i).map(([s,a])=>`${s.toLowerCase()}: ${a}\r
|
|
3
|
+
`).join("");st(t,"getAllResponseHeaders",()=>n),st(t,"getResponseHeader",s=>{let a=String(s).toLowerCase();for(let[l,p]of Object.entries(i))if(l.toLowerCase()===a)return p;return null}),st(t,"responseURL",e),st(t,"status",r.status),st(t,"statusText",r.statusText),st(t,"response",tl(t,r)),st(t,"responseText",r.body),ar(t,2),!o()&&(ar(t,3),!o()&&(ar(t,4),!o()&&(Pt(t,"load"),Pt(t,"loadend"))))}function Eo(t,e){ar(t,4),Pt(t,e.failKind==="timeout"?"timeout":"error"),Pt(t,"loadend")}var $t=new WeakMap;function Mn(t){return $t.has(t)}function ol(t,e,r,o){let i=Date.now(),n={},s,a,l=!1,p=!1,c=!1,x=t.timeout,O=t.abort,E=t.open,P=["abort","open","timeout","readyState","status","statusText","response","responseText","responseURL","getAllResponseHeaders","getResponseHeader"],N=new Map(P.map(H=>[H,Object.getOwnPropertyDescriptor(t,H)])),w=Object.getPrototypeOf(t),R;for(;w&&!R;)R=Object.getOwnPropertyDescriptor(w,"timeout"),w=Object.getPrototypeOf(w);let S=()=>{l=!0,$t.get(t)===n&&$t.delete(t),clearTimeout(s),clearTimeout(a),t.removeEventListener("loadend",S)},v=()=>{S();for(let[H,L]of N)L?Object.defineProperty(t,H,L):delete t[H];t.timeout=x},A=()=>{clearTimeout(a),c?R?.set?.call(t,x>0?Math.max(1,x-(Date.now()-i)):0):x>0&&(a=setTimeout(()=>{l||(clearTimeout(s),Eo(t,{...r,kind:"fail",failKind:"timeout"}),S())},Math.max(0,x-(Date.now()-i))))};return Object.defineProperty(t,"timeout",{configurable:!0,get:()=>x,set:H=>{x=Math.max(0,Number(H)||0),A()}}),Object.defineProperty(t,"open",{configurable:!0,value:(...H)=>(v(),Reflect.apply(E,t,H))}),Object.defineProperty(t,"abort",{configurable:!0,value:()=>{if(c||l){v(),O.call(t);return}p=!0,clearTimeout(s),ar(t,4),Pt(t,"abort"),Pt(t,"loadend"),S(),$t.has(t)||st(t,"readyState",0)}}),$t.set(t,n),t.addEventListener("loadend",S),A(),s=setTimeout(()=>{if(!(l||p)){if(r.kind==="delay"){c=!0,A();try{o()}catch{Eo(t,{...r,kind:"fail",failKind:"network"}),S()}return}r.kind==="fail"?Eo(t,r):rl(t,e,r,()=>p||$t.get(t)!==n),S()}},r.delayMs),!0}function Nr(t,e,r,o){if(!No(t))return Qa(t)?ol(t,e,r,o):(Za(),!1);let i=Er(t);i._sent=!0,i._requestId=null;let n=null,s=()=>{t.removeEventListener("abort",s),n!==null&&(clearTimeout(n),n=null)};return t.addEventListener("abort",s),n=setTimeout(()=>{if(n=null,t.removeEventListener("abort",s),!i._aborted){if(r.kind==="delay"){i._sent=!1,o();return}if(r.kind==="fail"){qn(t,r);return}Bn(t,e,r)}},r.delayMs),!0}function Dn(t,e,r){r.kind==="fail"?qn(t,r):r.kind==="respond"&&Bn(t,e,r)}function An(t,e,r,o,i){if(!No(t)){let L={id:"condition",enabled:!0,urlPattern:e,kind:"delay",hits:0,seen:0,createdAt:Date.now()},m=r.profile==="offline"?{kind:"fail",rule:L,failKind:"network",delayMs:0}:o?{...o,delayMs:r.delayMs+o.delayMs}:{kind:"delay",rule:L,delayMs:r.delayMs};if(!Nr(t,e,m,i))throw new Error("Network conditions are unavailable for this XMLHttpRequest implementation.");return}let n=t;if(n.readyState!==1||n._sent)throw new Error("Request is not open or has already been sent.");let s=Date.now(),a=n.timeout,l=!1,p=!1,c,x,O=n.abort,E=n.open,P=Object.getOwnPropertyDescriptor(n,"abort"),N=Object.getOwnPropertyDescriptor(n,"open"),w=Object.getOwnPropertyDescriptor(n,"timeout"),R=(L,m)=>{m?Object.defineProperty(n,L,m):delete n[L]},S=()=>{l||(l=!0,clearTimeout(x),clearTimeout(c),n.removeEventListener("loadend",S),R("abort",P),R("open",N),R("timeout",w),n.timeout=a)},v=L=>{l||(Object.assign(n,{readyState:4}),O.call(n),n._aborted=!1,n._hasError=!0,n._timedOut=L,n._response=L?"Request timed out (Buoy conditions)":"Network request failed (Buoy Offline)",n.setReadyState(4),S())},A=()=>a>0&&Date.now()-s>=a,H=()=>{clearTimeout(c),a>0&&(c=setTimeout(()=>v(!0),Math.max(0,a-(Date.now()-s))))};Object.defineProperty(n,"timeout",{configurable:!0,get:()=>p?0:a,set:L=>{a=Math.max(0,Number(L)||0),H()}}),Object.defineProperty(n,"abort",{configurable:!0,value:()=>{l||(O.call(n),S())}}),Object.defineProperty(n,"open",{configurable:!0,value:(...L)=>{let m=Reflect.apply(E,n,L);return S(),m}}),n._sent=!0,n._requestId=null,n.addEventListener("loadend",S),H(),x=setTimeout(()=>{if(!l){if(A()){v(!0);return}if(r.profile==="offline"){v(!1);return}if(o&&o.kind!=="delay"){Dn(n,e,o);return}n._sent=!1,p=!0;try{i()}catch{v(!1)}finally{p=!1}}},r.delayMs+(o?.delayMs??0))}g();function lr(t){if(!t?.aborted)return;if(t.reason!==void 0)throw t.reason;let e=new Error("The request was aborted.");throw e.name="AbortError",e}function Hn(t,e){return new Promise((r,o)=>{try{lr(e)}catch(a){o(a);return}let i=()=>e?.removeEventListener("abort",n),n=()=>{clearTimeout(s),i();try{lr(e)}catch(a){o(a)}},s=setTimeout(()=>{i(),r()},t);e?.addEventListener("abort",n,{once:!0})})}g();import{hasAccountAccess as cl}from"@buoy-gg/shared-ui/web";g();g();var nl="[]{}()\\.^$+|-,?";function zn(t){let e="";for(let r=0;r<t.length;r++){let o=t.charAt(r);nl.indexOf(o)!==-1&&(e+="\\"),e+=o}return e.split("*").join(".*")}var Or=new Map;function il(t){let e=Or.get(t);if(e)return e;let r=t.startsWith("/")?`[a-zA-Z][a-zA-Z0-9+.-]*://[^/]*${zn(t)}`:zn(t),o=new RegExp(`^${r}$`);return Or.size>200&&Or.clear(),Or.set(t,o),o}function Ut(t,e,r){if(t.methods&&t.methods.length>0&&!t.methods.includes(r.toUpperCase()))return!1;try{return il(t.urlPattern).test(e)}catch{return!1}}g();import{TIER_LIMITS as sl}from"@buoy-gg/shared-ui/web";var gt=200,mt=599,Ue=50,Oo=sl["network.overrideRules"].free;function Io(t){return{ruleId:t.rule.id,ruleName:t.rule.name,kind:t.kind,delayMs:t.delayMs||void 0}}var al=[/(^|\.)keygen\.sh/i,/^https?:\/\/(www\.)?buoy\.gg\/api\/license(\/|$)/i];function ll(t){return al.some(e=>e.test(t))}function dl(t){let e=t.trim();if(e==="")return"text/plain; charset=utf-8";if(e.startsWith("{")||e.startsWith("["))try{return JSON.parse(e),"application/json"}catch{}return"text/plain; charset=utf-8"}function ul(t,e){let r=e.toLowerCase();return Object.keys(t).some(o=>o.toLowerCase()===r)}function Vn(t){let e=Math.max(0,t.delayMs??0);if(t.kind==="delay")return{kind:"delay",rule:t,delayMs:e};if(t.kind==="fail")return{kind:"fail",rule:t,delayMs:e,failKind:t.failKind??"network"};let r=t.body??"",o={...t.headers??{}};return ul(o,"content-type")||(o["content-type"]=dl(r)),{kind:"respond",rule:t,delayMs:e,status:Math.min(mt,Math.max(gt,t.status??200)),statusText:t.statusText??"",headers:o,body:r}}function dr(t){return typeof t.times=="number"&&t.hits>=t.times}function Fn(t){return t.alternate?t.seen%2===1:!0}function Po(t,e,r){if(r.length===0||e.toUpperCase()==="OPTIONS"||ll(t))return null;for(let o of r)if(o.enabled&&!dr(o)&&Ut(o,t,e))return o;return null}var Ke=null;function _n(t){Ke=t}function Lo(){return cl()&&!(typeof I<"u"&&!I)}var Wn="Response overrides never apply in a release build \u2014 the rule is saved but will not affect any request.";function $n(t,e){return{hooksInstalled:Ke!==null,devFlag:typeof I>"u"?"undefined":I,ruleCount:Ke?Ke.getRules().length:0,matches:Ke?Po(t,e,Ke.getRules())!==null:!1}}function Bo(t,e){if(!Ke||!Lo())return null;let r=Ke.getRules();if(r.length===0)return null;let o=Po(t,e,r);if(!o)return null;let i=Fn(o);return Ke.recordMatch(o.id),i?(Ke.recordHit(o.id),Vn(o)):null}g();function Un(){return typeof Response=="function"}function jn(t,e){let r=new Response(e.body,{status:e.status,statusText:e.statusText,headers:e.headers});try{Object.defineProperty(r,"url",{value:t,configurable:!0})}catch{}return r}function Xn(t){return new TypeError(t.failKind==="timeout"?"Network request timed out":"Network request failed")}g();var pl={400:"Bad Request",401:"Unauthorized",403:"Forbidden",404:"Not Found",408:"Request Timeout",429:"Too Many Requests",500:"Internal Server Error",502:"Bad Gateway",503:"Service Unavailable",504:"Gateway Timeout"};function Jn(t){return typeof t=="number"&&t>0?"response":"error"}function Gn(t,e){let r=(e??"").trim();return r||(pl[t]??"")}var Lt;function Kn(t){let e=globalThis.__buoyHeaderInjectors;if(!e||e.length===0)return;let r;for(let o of e)try{let i=o(t);i&&(r={...r,...i})}catch{}return r}function fl(){if(Lt!==void 0)return Lt;Lt=null;try{if(typeof I<"u"&&!I)return Lt;let e=(he(),ea(ce))?.NativeModules?.SourceCode,r=e?.getConstants?.().scriptURL??e?.scriptURL;if(typeof r=="string"&&/^https?:\/\//.test(r)){let o=new URL(r);Lt=`${o.protocol}//${o.host}`}}catch{Lt=null}return Lt}var Ir=!1,Yn="__buoyNetworkFetchIntercepted",Qn="__buoyNetworkXhrIntercepted",gl=["text/event-stream","application/x-ndjson","application/stream+json"],ml="[streaming\u2026]";function hl(t){if(!t)return!1;let e=t.toLowerCase();return gl.some(r=>e.includes(r))}var yl="__BUOY_INTERNAL_HOSTS__";function bl(t){let e=globalThis[yl];if(!(e instanceof Set)||e.size===0)return!1;let r;try{r=new URL(t).host.toLowerCase()}catch{return!1}for(let o of e)if(typeof o=="string"&&o&&r===o.toLowerCase())return!0;return!1}var qo=class{constructor(){this.listeners=[];this.isListening=!1;this.patchedFetch=null;this.patchedXHROpen=null;this.patchedXHRSend=null;this.patchedXHRSetRequestHeader=null;this.fetchGeneration=0;this.xhrGeneration=0;this.originalFetch=globalThis.fetch,this.originalXHROpen=XMLHttpRequest.prototype.open,this.originalXHRSend=XMLHttpRequest.prototype.send,this.originalXHRSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader}shouldIgnoreUrl(e){try{let r=new URL(e);if(r.hostname==="keygen.sh"||r.hostname.endsWith(".keygen.sh")||(r.hostname==="buoy.gg"||r.hostname==="www.buoy.gg")&&r.pathname.startsWith("/api/license")||(r.hostname==="localhost"||r.hostname==="127.0.0.1"||r.hostname==="10.0.2.2")&&["8081","8802"].includes(r.port))return!0;let i=fl();if(i&&`${r.protocol}//${r.host}`===i)return!0}catch{return!1}return bl(e)}emit(e){this.listeners.forEach(r=>{try{r(e)}catch{}})}parseUrl(e){let r=null,o=e.indexOf("?");return o>-1&&(r={},e.substring(o+1).split("&").forEach(i=>{let[n,s]=i.split("=");n&&s!==void 0&&(r[n]=decodeURIComponent(s.replace(/\+/g," ")))})),{url:o>-1?e.substring(0,o):e,params:r}}async readStreamedBody(e,r=256*1024){let o=e.body;if(!o||typeof o.getReader!="function"){let p=await e.text();return p.length>r?{body:`${p.slice(0,r)}
|
|
4
|
+
|
|
5
|
+
... [truncated]`,size:p.length}:{body:p,size:p.length}}let i=o.getReader(),n=new TextDecoder,s="",a=0,l=!1;try{for(;;){let{done:p,value:c}=await i.read();if(p)break;if(a+=c?.byteLength??0,!l&&(s+=n.decode(c,{stream:!0}),a>=r)){s=`${s.slice(0,r)}
|
|
6
|
+
|
|
7
|
+
... [truncated]`,l=!0;break}}l||(s+=n.decode())}finally{try{Promise.resolve(i.cancel()).catch(()=>{})}catch{}try{i.releaseLock()}catch{}}return{body:s,size:a}}async processResponseBody(e,r=1024*1024){try{let o=e.headers.get("content-length");if(o){let s=parseInt(o,10);if(!isNaN(s)&&s>r)return{body:`[Response too large: ${this.formatBytes(s)}]`,size:s,truncated:!0}}let i=await e.text(),n=i.length;if(n>r){let s=i.substring(0,r),a=n-r;return{body:`${s}
|
|
8
|
+
|
|
9
|
+
... [truncated, ${this.formatBytes(a)} omitted]`,size:n,truncated:!0}}try{return{body:JSON.parse(i),size:n,truncated:!1}}catch{return{body:i,size:n,truncated:!1}}}catch{return{body:"~~~ unable to read body ~~~",size:0,truncated:!1}}}formatBytes(e){if(e===0)return"0 B";let r=1024,o=["B","KB","MB","GB"],i=Math.floor(Math.log(e)/Math.log(r));return`${Math.round(e/Math.pow(r,i)*100)/100} ${o[i]}`}handleXHRResponse(e,r,o,i,n,s,a,l,p=!1,c="xhr",x,O){let E=l?Date.now()-l:0,P=e._buoyTtfb,N=P===void 0?void 0:{ttfb:P,download:Math.max(0,E-P)};if(p||e.status===0){this.emit({type:"error",timestamp:new Date,duration:E,request:{id:r||"unknown",url:o,method:i,headers:n,data:s,params:a||void 0,client:c},error:{message:p?"Request failed":"Network error or request aborted"},override:x,condition:O});return}let w,R=0;try{let v=e.response;if(e.responseType==="json"&&v)w=v,R=JSON.stringify(v).length;else if(e.responseType===""||e.responseType==="text"){if(e.responseText){R=e.responseText.length;try{w=JSON.parse(e.responseText)}catch{w=e.responseText}}}else if(e.responseType==="arraybuffer")if(v)try{let A=new TextDecoder("utf-8").decode(v);R=A.length;try{w=JSON.parse(A)}catch{w=A}}catch{w=`[arraybuffer response - ${v.byteLength||0} bytes]`,R=v.byteLength||0}else w="[arraybuffer response - no data]",R=0;else if(e.responseType==="blob")if(v instanceof Blob)w=`[blob response - ${v.size} bytes, type: ${v.type||"unknown"}]`,R=v.size;else if(v)try{w=typeof v=="string"?JSON.parse(v):v,R=JSON.stringify(w).length}catch{w="[blob response - unable to parse]",R=0}else w="[blob response - no data]",R=0;else if(v)if(typeof v=="string"){w=v,R=v.length;try{w=JSON.parse(v)}catch{}}else typeof v=="object"?(w=v,R=JSON.stringify(v).length):(w=String(v),R=String(v).length)}catch{w="~~~ unable to read body ~~~"}let S={};try{let v=e.getAllResponseHeaders();v&&v.split(`\r
|
|
10
|
+
`).forEach(A=>{if(A){let H=A.indexOf(": ");if(H>0){let L=A.substring(0,H).toLowerCase(),m=A.substring(H+2);S[L]=m}}})}catch{}Jn(e.status)==="response"?this.emit({type:"response",timestamp:new Date,duration:E,timings:N,request:{id:r||"unknown",url:o,method:i,headers:n,data:s,params:a||void 0,client:c},response:{status:e.status,statusText:Gn(e.status,e.statusText),headers:S,body:w,size:R},override:x,condition:O}):this.emit({type:"error",timestamp:new Date,duration:E,request:{id:r||"unknown",url:o,method:i,headers:n,data:s,params:a||void 0,client:c},response:{status:e.status,statusText:e.statusText,headers:S,body:w,size:R},error:{message:"Network Error"},override:x,condition:O})}isFetchInterceptionLive(){return globalThis.fetch[Yn]===!0}isXhrInterceptionLive(){return XMLHttpRequest.prototype.send[Qn]===!0}isInterceptionLive(){return this.isFetchInterceptionLive()&&this.isXhrInterceptionLive()}startListening(){let e=this.isListening&&this.isFetchInterceptionLive(),r=this.isListening&&this.isXhrInterceptionLive();e&&r||(e||this.installFetchInterceptor(),r||this.installXhrInterceptor(),this.isListening=!0)}installFetchInterceptor(){let e=this,r=globalThis.fetch.bind(globalThis);this.originalFetch=globalThis.fetch;let o=++this.fetchGeneration,i=async(n,s)=>{let a=Ro(typeof n=="string"?n:n instanceof URL?n.href:n.url);if(o!==e.fetchGeneration||e.shouldIgnoreUrl(a))return r(n,s);let l=Date.now(),p=Co("fetch"),c=typeof n=="object"&&"method"in n?n:void 0,x=s?.method??c?.method??"GET",O=s?.signal!==void 0?s.signal:c?.signal;lr(O);let E=Mo(a),{url:P,params:N}=e.parseUrl(a),w={},R=s?.headers??c?.headers;R&&(R instanceof Headers?R.forEach((L,m)=>{w[m]=L}):Array.isArray(R)?R.forEach(([L,m])=>{w[L]=m}):w={...R}),Object.assign(w,Kn(a));let S;if(s?.body)if(typeof s.body=="string")try{S=JSON.parse(s.body)}catch{S=s.body}else S=s.body;let v=w["X-Request-Client"]||w["x-request-client"]||"fetch",A=E?.profile!=="offline"&&Un()?Bo(a,x):null,H=A?Io(A):void 0;if(e.emit({type:"request",timestamp:new Date,request:{id:p||"unknown",url:P,method:x,headers:w,data:S,params:N||void 0,client:v},override:H,condition:E}),s?.body===void 0&&c?.body&&!c.bodyUsed)try{let L=c.clone();e.readStreamedBody(L).then(({body:m})=>{try{S=JSON.parse(m)}catch{S=m}e.emit({type:"request-body",timestamp:new Date,request:{id:p||"unknown",url:P,method:x,data:S,client:v}})}).catch(()=>{})}catch{}try{if((E||A)&&await Hn((E?.delayMs??0)+(A?.delayMs??0),O),lr(O),E?.profile==="offline")throw new TypeError("Network request failed (Buoy Offline)");if(A?.kind==="fail")throw Xn(A);let L;if(A?.kind==="respond")L=jn(a,A);else{let re=Ir;Ir=!0;let X;try{X=r(n,s)}finally{Ir=re}L=await X}let m=Date.now()-l,y=typeof L.body?.getReader=="function"||hl(L.headers?.get?.("content-type")),k=L.clone(),{body:d,size:b}=y?{body:ml,size:0}:await e.processResponseBody(k),h=Date.now()-l,M=Math.max(0,h-m),ae=M>0?{ttfb:m,download:M}:void 0,pe={};return L.headers.forEach((re,X)=>{pe[X.toLowerCase()]=re}),e.emit({type:"response",timestamp:new Date,duration:h,timings:ae,request:{id:p||"unknown",url:P,method:x,headers:w,data:S,params:N||void 0,client:v},response:{status:L.status,statusText:L.statusText,headers:pe,body:d,size:b},override:H,condition:E}),y&&e.readStreamedBody(k).then(re=>{let X=re.body;if(L.headers?.get?.("content-type")?.includes("json"))try{X=JSON.parse(re.body)}catch{}e.emit({type:"response",timestamp:new Date,duration:Date.now()-l,timings:ae,request:{id:p||"unknown",url:P,method:x,headers:w,data:S,params:N||void 0,client:v},response:{status:L.status,statusText:L.statusText,headers:pe,body:X,size:re.size},override:H,condition:E})}).catch(()=>{}),L}catch(L){let m=Date.now()-l;throw e.emit({type:"error",timestamp:new Date,duration:m,request:{id:p||"unknown",url:P,method:x,headers:w,data:S,params:N||void 0,client:v},error:{message:L instanceof Error?L.message:"Network error",stack:L instanceof Error?L.stack:void 0},override:H,condition:E}),L}};i[Yn]=!0,this.patchedFetch=i,globalThis.fetch=this.patchedFetch}installXhrInterceptor(){let e=this,r=XMLHttpRequest.prototype.open,o=XMLHttpRequest.prototype.send,i=XMLHttpRequest.prototype.setRequestHeader;this.originalXHROpen=r,this.originalXHRSend=o,this.originalXHRSetRequestHeader=i;let n=++this.xhrGeneration,s=new WeakMap,a=function(c,x,O,E,P){let N=r.call(this,c,x,O??!0,E,P);if(n===e.xhrGeneration){s.get(this)?.();let w=this;w._buoyRequestId=Co("xhr"),w._method=c,w._url=Ro(x),w._buoyStartTime=Date.now(),w._requestHeaders={}}return N},l=function(c,x){let O=this;return n===e.xhrGeneration&&O._requestHeaders&&(O._requestHeaders[c]=x),i.call(this,c,x)},p=function(c){if(n!==e.xhrGeneration||Ir)return o.call(this,c);if(Mn(this))throw new DOMException("The request has already been sent.","InvalidStateError");if(this.readyState!==1||this._sent)return o.call(this,c);let x=this,O=x._buoyRequestId,E=x._method||"GET",P=x._url||"",N=Date.now();x._buoyStartTime=N,x._buoyTtfb=void 0;let w=x._requestHeaders||{};if(Object.assign(w,Kn(P)),e.shouldIgnoreUrl(P))return o.call(this,c);let{url:R,params:S}=e.parseUrl(P),v;if(c)if(typeof c=="string")try{v=JSON.parse(c)}catch{v=c}else v=c;let A=w["X-Request-Client"]||w["x-request-client"],H=w.Accept||w.accept||"",L=H.includes("application/json")&&H.includes("text/plain")&&H.includes("*/*"),m=A||(L?"axios":"xhr"),y=Mo(P),k=y?.profile==="offline"?null:Bo(P,E),d=k?Io(k):void 0;e.emit({type:"request",timestamp:new Date,request:{id:O||"unknown",url:R,method:E,headers:w,data:v,params:S||void 0,client:m},override:d,condition:y});let b=!1,h=(ie=!1)=>{b||(b=!0,e.handleXHRResponse(this,O||"unknown",R,E,w,v,S,N||0,ie,m,d,y),M())},M=()=>{s.delete(this),this.removeEventListener("load",ae),this.removeEventListener("error",pe),this.removeEventListener("abort",re),this.removeEventListener("readystatechange",X)};s.set(this,M);let ae=()=>{h(!1)},pe=()=>{h(!0)},re=()=>{h(!0)},X=()=>{if(this.readyState===2){let ie=this;ie._buoyTtfb===void 0&&ie._buoyStartTime&&(ie._buoyTtfb=Date.now()-ie._buoyStartTime)}this.readyState===4&&!b&&h(!1)};if(this.addEventListener("load",ae),this.addEventListener("error",pe),this.addEventListener("abort",re),this.addEventListener("readystatechange",X),y){An(this,P,y,k,()=>o.call(this,c));return}if(!(k&&Nr(this,P,k,()=>o.call(this,c))))return o.call(this,c)};p[Qn]=!0,this.patchedXHROpen=a,this.patchedXHRSend=p,this.patchedXHRSetRequestHeader=l,XMLHttpRequest.prototype.open=this.patchedXHROpen,XMLHttpRequest.prototype.send=this.patchedXHRSend,XMLHttpRequest.prototype.setRequestHeader=this.patchedXHRSetRequestHeader}stopListening(){this.isListening&&(this.fetchGeneration++,this.xhrGeneration++,this.patchedFetch&&globalThis.fetch===this.patchedFetch&&(globalThis.fetch=this.originalFetch),this.patchedXHROpen&&XMLHttpRequest.prototype.open===this.patchedXHROpen&&(XMLHttpRequest.prototype.open=this.originalXHROpen),this.patchedXHRSend&&XMLHttpRequest.prototype.send===this.patchedXHRSend&&(XMLHttpRequest.prototype.send=this.originalXHRSend),this.patchedXHRSetRequestHeader&&XMLHttpRequest.prototype.setRequestHeader===this.patchedXHRSetRequestHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXHRSetRequestHeader),this.patchedFetch=null,this.patchedXHROpen=null,this.patchedXHRSend=null,this.patchedXHRSetRequestHeader=null,this.isListening=!1)}addListener(e){return this.listeners.push(e),()=>{let r=this.listeners.indexOf(e);r>-1&&this.listeners.splice(r,1)}}removeAllListeners(){this.listeners=[]}get isActive(){return this.isListening}get listenerCount(){return this.listeners.length}},ht=null,Do=()=>(ht||(ht=new qo),ht),ur=Do,Pr=()=>Do().startListening(),yt=()=>ht?.stopListening(),bt=t=>Do().addListener(t),wl=()=>ht?.removeAllListeners(),Ao=()=>ht?.isActive??!1,je=()=>ht?.listenerCount??0,Zn=()=>ht?.isInterceptionLive()??!1;var jt={normal:{label:"Normal",delayMs:0},offline:{label:"Offline (requests)",delayMs:0},slow:{label:"Slow (+500 ms)",delayMs:500},verySlow:{label:"Very slow (+2000 ms)",delayMs:2e3}},qr=`${Date.now()}-${Math.random().toString(36).slice(2)}`,wt="normal",Lr,Br=new Set,at=()=>typeof I<"u"&&I&&ei(),Ye=()=>wt,vt=t=>(Br.add(t),()=>{Br.delete(t)});function Xt(t){if(typeof t!="string"||!Object.prototype.hasOwnProperty.call(jt,t))throw new Error("Choose normal, offline, slow, or verySlow.");if(t!=="normal"&&!at())throw new Error("Network conditions require an admitted account and a development build.");return t===wt||(t!=="normal"&&!Lr?(Pr(),Lr=bt(()=>{})):t==="normal"&&(Lr?.(),Lr=void 0,je()===0&&yt()),wt=t,Br.forEach(e=>e())),wt}function Mo(t){if(!(wt==="normal"||!at()||!/^https?:\/\//i.test(t)))return Object.freeze({profile:wt,delayMs:jt[wt].delayMs})}vl(()=>{ei()||Xt("normal"),Br.forEach(t=>t())});import{jsx as ti,jsxs as xl}from"react/jsx-runtime";function ri({size:t}){let e=Sl(vt,Ye,Ye);return xl(u,{accessibilityLabel:e==="normal"?"Network":`Network: ${jt[e].label}`,children:[ti(kl,{size:t}),e!=="normal"&&ti(f,{testID:"buoy-network-condition-indicator",style:{position:"absolute",top:-6,right:-8,color:"#FFCC66",fontSize:10,fontWeight:"700"},children:e==="offline"?"OFF":`+${jt[e].delayMs}`})]})}import{createToolFactory as fp,defineToolPreset as gp}from"@buoy-gg/shared-ui/web";g();g();he();import{useEffect as oi,useRef as Ho,useState as ni,useSyncExternalStore as zo}from"react";import{FloatingTool as Rl,night as Ie,openFloatingTool as Tl,persistentStorage as Cl,registerPersistentFloatingTool as El}from"@buoy-gg/shared-ui/web";import{jsx as Oe,jsxs as si}from"react/jsx-runtime";function ai(){let t,e=new Set;return{getSnapshot:()=>t,subscribe:r=>(e.add(r),()=>{e.delete(r)}),update(r){t=r,e.forEach(o=>o())}}}var Nl=()=>()=>{},ii=()=>{},Mr=[{id:"normal",label:"No throttling",detail:"No added delay"},{id:"slow",label:"Slow",detail:"+500 ms before sending"},{id:"verySlow",label:"Very slow",detail:"+2 seconds before sending"},{id:"offline",label:"Offline",detail:"New requests fail"}],Ol={id:"network-throttling",render:t=>Oe(di,{...t})};typeof I<"u"&&I&&typeof navigator<"u"&&navigator.product==="ReactNative"&&El(Ol,Cl);function li(t){Tl({id:"network-throttling",render:e=>Oe(di,{...e,source:t})})}function di({id:t,revealToken:e,dismiss:r,source:o}){let i=zo(vt,Ye,Ye),n=zo(vt,at,at),s=zo(o?.subscribe??Nl,o?.getSnapshot??ii,ii),a=o?s?.profile??null:i,l=o?s?.available===!0:n,[p,c]=ni(!1),[x,O]=ni(),E=Ho(!1),P=Ho(0),N=Ho(!0),{width:w}=xo();oi(()=>(N.current=!0,()=>{N.current=!1}),[]),oi(()=>{P.current+=1,E.current=!1,c(!1),O(void 0)},[o,s?.targetId]);let R=a!==null&&a!=="normal",S=a??"normal",v=Mr.find(k=>k.id===S),A=Mr[(Mr.findIndex(k=>k.id===S)+1)%Mr.length],H=!l||S==="offline"?0:S==="verySlow"?1:S==="slow"?2:4,L=p?"Applying\u2026":l?S==="normal"?"0 ms":S==="slow"?"+500 ms":S==="verySlow"?"+2000 ms":"Blocked":"Unavailable";async function m(k,d=!1){if(E.current)return;let b=++P.current;E.current=!0,c(!0),O(void 0);let h=o?.getSnapshot();try{if(o){if(!h?.available)throw new Error("Device unavailable. Open Network again to reconnect these controls.");await h.onChange(k)}else Xt(k);N.current&&P.current===b&&d&&r()}catch(M){N.current&&P.current===b&&O(M instanceof Error?M.message:String(M))}finally{P.current===b&&(E.current=!1,N.current&&c(!1))}}let y=x?Oe(u,{style:qe.menu,children:Oe(f,{accessibilityRole:"alert",style:qe.error,children:x})}):void 0;return Oe(Rl,{id:t,revealToken:e,variant:"strip",dragFromSurface:!0,accessibilityLabel:`Move or hide network throttling. ${R?"Active":"Off"}`,accessory:y,children:si(u,{style:[qe.row,{width:Math.max(220,Math.min(292,w-64))}],children:[Oe(D,{testID:"throttling-cycle",accessibilityRole:"button",accessibilityLabel:`Network: ${v.label}. Switch to ${A.label}`,accessibilityState:{disabled:p||!l},disabled:p||!l,onPress:()=>void m(A.id),style:qe.signalButton,children:p?Oe(ko,{size:"small",color:Ie.color.accent}):si(u,{testID:`throttling-signal-${S}`,style:qe.signal,children:[[7,12,18,24].map((k,d)=>Oe(u,{style:{width:4,height:k,borderRadius:2,backgroundColor:d<H?S==="offline"?Ie.color.danger:Ie.color.accent:Ie.color.fillTertiary}},k)),S==="offline"&&Oe(u,{style:qe.slash})]})}),Oe(u,{style:qe.profile,children:Oe(f,{testID:"throttling-profile",accessibilityLabel:`Connection profile: ${v.label}`,accessibilityLiveRegion:"polite",numberOfLines:1,style:qe.profileLabel,children:v.label})}),Oe(f,{testID:"throttling-status",numberOfLines:1,accessibilityLiveRegion:"polite",style:qe.status,children:L}),Oe(u,{style:qe.separator}),Oe(D,{testID:"throttling-close",accessibilityRole:"button",accessibilityLabel:"Close and turn off throttling",disabled:p,accessibilityState:{disabled:p},onPress:()=>{a==="normal"?r():m("normal",!0)},style:[qe.action,p&&qe.disabled],children:Oe(f,{style:qe.actionText,children:"Close"})})]})})}var qe=K.create({row:{flexDirection:"row",alignItems:"center",gap:6,paddingVertical:4,minHeight:48},signalButton:{width:36,minHeight:44,alignItems:"center",justifyContent:"center"},signal:{flexDirection:"row",alignItems:"flex-end",gap:3,height:24},slash:{position:"absolute",width:30,height:2,backgroundColor:Ie.color.danger,top:11,left:-2,transform:[{rotate:"-45deg"}]},separator:{height:20,width:1,backgroundColor:Ie.color.separator,marginHorizontal:2},status:{color:Ie.color.textSecondary,fontSize:10,lineHeight:15,flexShrink:1},profile:{flex:1,flexDirection:"row",alignItems:"center",gap:6,minHeight:44},profileLabel:{color:Ie.color.text,fontSize:13,fontWeight:"500",flexShrink:1},action:{minHeight:36,minWidth:52,borderRadius:Ie.radius.input,borderWidth:1,borderColor:Ie.color.accentBorderStrong,alignItems:"center",justifyContent:"center",paddingHorizontal:10},actionText:{color:Ie.color.accent,fontSize:12,fontWeight:"600"},disabled:{opacity:.4},menu:{marginVertical:8,padding:6,borderRadius:Ie.radius.card,borderWidth:1,borderColor:Ie.color.separator,backgroundColor:Ie.color.surface,shadowColor:"#000",shadowOffset:{width:0,height:6},shadowOpacity:.25,shadowRadius:16,elevation:8},error:{color:Ie.color.danger,fontSize:12,lineHeight:18,padding:10}});he();import{useState as Re,useRef as uo,useEffect as Ft,useCallback as gn}from"react";import{Search as Gc,Wifi as Kc,Filter as Yc,Bookmark as Qc,JsModal as Zc,ModalHeader as be,devToolsStorageKeys as co,macOSColors as ep,night as ct,persistentStorage as Ts,NightSegmented as tp,useFeatureGate as rp,UpgradeModal as op,PowerToggleButton as np,useIgnoredPatterns as ip,windowDragProps as sp}from"@buoy-gg/shared-ui/web";g();he();import{CheckCircle as Il,Clock as Pl,DynamicFilterView as Ll,Film as Bl,FileJson as ql,FileText as Ml,Filter as ui,Globe as pi,Image as Dl,macOSColors as we,night as Me,Music as Al,XCircle as Hl,monoFont as Vo}from"@buoy-gg/shared-ui/web";import{useCallback as Dr,useMemo as Qe,useState as zl}from"react";import{jsx as Bt,jsxs as ci}from"react/jsx-runtime";function Fo(t){let e=t.responseHeaders||t.requestHeaders,r=e?.["content-type"]||e?.["Content-Type"]||"";return r.includes("json")?{type:"JSON",color:we.semantic.info}:r.includes("xml")?{type:"XML",color:we.semantic.success}:r.includes("html")?{type:"HTML",color:we.semantic.warning}:r.includes("text")?{type:"TEXT",color:we.semantic.success}:r.includes("image")?{type:"IMAGE",color:we.semantic.error}:r.includes("video")?{type:"VIDEO",color:we.semantic.error}:r.includes("audio")?{type:"AUDIO",color:we.semantic.debug}:r.includes("form")?{type:"FORM",color:we.semantic.info}:{type:"OTHER",color:Me.color.textTertiary}}function Vl(t){switch(t){case"JSON":return ql;case"HTML":case"XML":case"TEXT":return Ml;case"IMAGE":return Dl;case"VIDEO":return Bl;case"AUDIO":return Al;default:return pi}}function Fl(t){switch(t){case"GET":return we.semantic.success;case"POST":return we.semantic.info;case"PUT":return we.semantic.warning;case"DELETE":return we.semantic.error;case"PATCH":return we.semantic.success;default:return Me.color.textTertiary}}function fi({events:t,filter:e,onFilterChange:r,ignoredPatterns:o=[],onRemovePattern:i=()=>{},onAddPattern:n=()=>{},onTogglePatternMode:s=()=>{}}){let[a,l]=zl("contains"),p=Qe(()=>{let m=new Map;for(let y of o)m.set(y.value,y.mode);return m},[o]),c=Qe(()=>new Set(o.map(m=>m.value)),[o]),x=Dr(m=>{n({value:m,mode:a})},[n,a]),O=Dr(m=>{let y=p.get(m)??"contains",k=y==="exact",d=k?Me.color.warning:Me.color.info;return Bt(D,{accessibilityRole:"button",accessibilityLabel:`Match mode: ${y}. Tap to toggle.`,onPress:()=>s(m),style:[Ze.modeBadge,{borderColor:`${d}60`,backgroundColor:`${d}15`}],hitSlop:{top:6,bottom:6,left:6,right:6},children:Bt(f,{style:[Ze.modeBadgeText,{color:d}],children:k?"EXACT":"CONTAINS"})})},[p,s]),E=Dr(()=>{let m=[{label:"Contains",value:"contains",hint:"substring"},{label:"Exact",value:"exact",hint:"whole path/host/url"}];return ci(u,{style:Ze.modeToggleRow,children:[Bt(f,{style:Ze.modeToggleLabel,children:"Match:"}),Bt(u,{style:Ze.modeToggleGroup,children:m.map(y=>{let k=a===y.value;return ci(D,{onPress:()=>l(y.value),style:[Ze.modeToggleButton,k&&Ze.modeToggleButtonActive],accessibilityRole:"button",accessibilityState:{selected:k},children:[Bt(f,{style:[Ze.modeToggleButtonText,k&&Ze.modeToggleButtonTextActive],children:y.label}),Bt(f,{style:Ze.modeToggleButtonHint,children:y.hint})]},y.value)})})]})},[a]),P=Qe(()=>{let m={all:t.length,success:0,error:0,pending:0};return t.forEach(y=>{if(y.error||y.status&&y.status>=400){m.error+=1;return}if(y.status&&y.status>=200&&y.status<300){m.success+=1;return}!y.status&&!y.error&&(m.pending+=1)}),m},[t]),N=Qe(()=>t.reduce((m,y)=>(y.method&&(m[y.method]=(m[y.method]||0)+1),m),{}),[t]),w=Qe(()=>t.reduce((m,y)=>{let{type:k}=Fo(y);return m[k]=(m[k]||0)+1,m},{}),[t]),R=Qe(()=>{let m=new Set;return t.forEach(y=>{if(y.host){m.add(y.host);return}try{if(y.url){let k=new URL(y.url),d=String(k.host||"");d&&m.add(d)}}catch{}}),Array.from(m).filter(y=>y&&y!=="").sort((y,k)=>y.localeCompare(k))},[t]),S=Qe(()=>{let m=new Set;return t.forEach(y=>{if(y.url)try{let k=new URL(y.url),d=String(k.origin||""),b=String(k.pathname||""),h=`${d}${b}`;m.add(h)}catch{m.add(y.url)}}),Array.from(m).filter(y=>y&&y!=="").sort((y,k)=>y.localeCompare(k))},[t]),v=Qe(()=>{let y=R.slice(0,30),k=S.slice(0,30);return[...y,...k]},[R,S]),A=Dr((m,y)=>{let[k]=m.split("::");if(k==="status"){r({...e,status:y==="all"?void 0:y});return}if(k==="method"){let d=String(y),b=e.method||[],M=b.includes(d)?b.filter(ae=>ae!==d):[d];r({...e,method:M.length>0?M:void 0});return}if(k==="contentType"){let d=String(y),b=e.contentType||[],M=b.includes(d)?b.filter(ae=>ae!==d):[d];r({...e,contentType:M.length>0?M:void 0})}},[e,r]),H=Qe(()=>{let m=[];m.push({id:"status",title:"Status",type:"status",data:["all","success","error","pending"].map(d=>({id:`status::${d}`,label:d.charAt(0).toUpperCase()+d.slice(1),count:P[d],icon:d==="success"?Il:d==="error"?Hl:d==="pending"?Pl:pi,color:d==="success"?we.semantic.success:d==="error"?we.semantic.error:d==="pending"?we.semantic.warning:we.semantic.info,isActive:e.status===d||!e.status&&d==="all",value:d}))});let y=Object.entries(N);y.length>0&&m.push({id:"method",title:"Method",type:"method",data:y.map(([d,b])=>({id:`method::${d}`,label:d,count:b,color:Fl(d),isActive:e.method?.includes(d)??!1,value:d}))});let k=Object.entries(w);return k.length>0&&m.push({id:"contentType",title:"Content Type",type:"contentType",data:k.map(([d,b])=>{let h=t.find(ae=>Fo(ae).type===d),{color:M}=h?Fo(h):{color:Me.color.textTertiary};return{id:`contentType::${d}`,label:d,count:b,icon:Vl(d),color:M,isActive:e.contentType?.includes(d)??!1,value:d}})}),m},[w,t,e.contentType,e.method,e.status,N,P]),L=Qe(()=>({sections:H,addFilterSection:{enabled:!0,placeholder:"Enter domain or URL pattern...",title:"ACTIVE FILTERS",icon:ui,renderExtra:E},availableItemsSection:{enabled:!0,title:"AVAILABLE DOMAINS & URLS",emptyMessage:"No network events captured yet. Domains and URLs will appear here.",items:v},howItWorksSection:{enabled:!0,title:"HOW NETWORK FILTERS WORK",description:"Patterns hide matching requests from the network event list. Each pattern has a match mode you can toggle on its badge: CONTAINS hides any URL containing the text; EXACT hides only an exact path/host/url match.",examples:["\u2022 example.com (CONTAINS) \u2192 any request whose URL contains example.com","\u2022 example.com (EXACT) \u2192 only requests served by that exact host","\u2022 /v1 (CONTAINS) \u2192 any URL containing /v1 (e.g. /v1, /v1/users)","\u2022 /v1 (EXACT) \u2192 only requests whose pathname is exactly /v1"],icon:ui},onFilterChange:A,onPatternAdd:x,onPatternToggle:i,activePatterns:c,renderPatternMeta:O}),[c,H,A,x,i,E,O,v]);return Bt(Ll,{...L})}var Ze=K.create({modeBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1},modeBadgeText:{fontSize:9,fontFamily:Vo,fontWeight:"700",letterSpacing:.5},modeToggleRow:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:8},modeToggleLabel:{fontSize:11,fontWeight:"600",color:Me.color.textSecondary,fontFamily:Vo,letterSpacing:.3},modeToggleGroup:{flexDirection:"row",gap:6,flex:1},modeToggleButton:{flex:1,paddingVertical:6,paddingHorizontal:10,borderRadius:8,borderWidth:1,borderColor:Me.color.border,backgroundColor:Me.color.buttonSurface,alignItems:"center"},modeToggleButtonActive:{borderColor:Me.color.accentBorderStrong,backgroundColor:Me.color.accentSoft},modeToggleButtonText:{fontSize:11,fontWeight:"700",color:Me.color.textSecondary,fontFamily:Vo,letterSpacing:.3},modeToggleButtonTextActive:{color:Me.color.accent},modeToggleButtonHint:{fontSize:9,color:Me.color.textTertiary,marginTop:1}});g();import{TickProvider as Ar}from"@buoy-gg/shared-ui/web";import{useTick as _l}from"@buoy-gg/shared-ui/web";function cr(){return _l()??Date.now()}g();he();import{useState as fr,useEffect as hi,useMemo as Jl,memo as Gl}from"react";import{Clock as Uo,Upload as yi,Download as bi,AlertCircle as Kl,ChevronDown as vi,ChevronUp as Si,Lock as Yl,Unlock as Ql,FileJson as Vr,Filter as Zl,Globe as ed,Link as td,Copy as ki,FlaskConical as rd,InlineCopyButton as xi,macOSColors as _r,night as q,useFeatureGate as od,UpgradeModal as nd,monoFont as Gt}from"@buoy-gg/shared-ui/web";g();import{formatBytes as Xe,formatDuration as Jt,formatHttpStatus as _o,getMethodColor as mg}from"@buoy-gg/shared-ui/web";import{formatRelativeTime as id}from"@buoy-gg/shared-ui/web";import{DataViewer as pr}from"@buoy-gg/shared-ui/web/dataViewer";g();function Wo(t,e=30){if(t==null)return null;if(typeof t=="boolean"||typeof t=="number")return String(t);if(typeof t=="string")return t.length>e?t.substring(0,e-1)+"\u2026":t;if(Array.isArray(t))return t.length===0?null:t.length===1?Wo(t[0],e):`${t.length} items`;if(typeof t=="object"){let r=Object.entries(t);if(r.length===0)return null;for(let[o,i]of r){let n=Wo(i,e);if(n)return n}return null}return null}function Wl(t,e=3){if(!t||typeof t!="object")return null;let r=[];for(let[o,i]of Object.entries(t)){let n=Wo(i);if(n&&r.push(n),r.length>=e)break}return r.length>0?r:null}function Hr(t,e){let r=Wl(e);return!r||r.length===0?t:[t,...r].join(" \u203A ")}function zr(t,e){if(!t||typeof t!="object")return!1;for(let r of Object.values(t))if($o(r,e))return!0;return!1}function $o(t,e){return typeof t=="string"?t.toLowerCase().includes(e):typeof t=="number"||typeof t=="boolean"?String(t).includes(e):Array.isArray(t)?t.some(r=>$o(r,e)):typeof t=="object"&&t!==null?Object.values(t).some(r=>$o(r,e)):!1}g();import{createContext as $l,useContext as Ul}from"react";import{jsx as Xl}from"react/jsx-runtime";var gi=$l(null);function jl({resolver:t,children:e}){return Xl(gi.Provider,{value:t,children:e})}function mi(){return Ul(gi)}import{Fragment as jo,jsx as T,jsxs as G}from"react/jsx-runtime";var Fr=q.color.accent,sd=new Set,ad=()=>{},ld=({timings:t,total:e})=>{let r=Math.max(1,e),o=[{label:"Waiting (TTFB)",hint:"incl. queue, DNS, TLS",value:t.ttfb,color:_r.semantic.warning},{label:"Content download",hint:void 0,value:t.download,color:_r.semantic.success}];return T(u,{style:C.phaseList,children:o.map(i=>G(u,{style:C.phaseRow,children:[G(u,{style:C.phaseLabelGroup,children:[T(f,{style:C.phaseLabel,children:i.label}),i.hint?T(f,{style:C.phaseHint,children:i.hint}):null]}),T(u,{style:C.phaseTrack,children:T(u,{style:[C.phaseBar,{backgroundColor:i.color,width:`${Math.min(100,Math.max(1,i.value/r*100))}%`}]})}),T(f,{style:C.phaseValue,children:Jt(i.value)})]},i.label))})},wi=()=>T(u,{style:C.bodyDeferred}),qt=({title:t,icon:e,children:r,defaultOpen:o=!1,count:i})=>{let[n,s]=fr(o);return G(u,{style:C.collapsibleSection,children:[G(D,{style:C.collapsibleHeader,onPress:()=>s(!n),testID:`buoy-network-section-${t.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:t,children:[G(u,{style:C.collapsibleTitle,children:[e,T(f,{style:C.collapsibleTitleText,children:t}),i!==void 0?T(f,{style:C.collapsibleCount,children:i}):null]}),n?T(Si,{size:16,color:q.color.textSecondary}):T(vi,{size:16,color:q.color.textSecondary})]}),n?T(u,{style:C.collapsibleContent,children:r}):null]})},dd=({url:t,requestData:e,operationName:r,graphqlVariables:o,requestClient:i,isPro:n=!1,onUpgradePress:s})=>{let a=x=>{try{let O=new URL(x),E=String(O.protocol||""),P=String(O.host||""),N=E==="https:",w=String(O.pathname||"");if(i==="graphql"&&r){let v=Hr(r,o);w=`${w} (${v})`}else r&&(w=`${w} (${r})`);let R={},S=O.searchParams;return S&&typeof S.forEach=="function"&&S.forEach((v,A)=>{R[A]=v}),{protocol:E.replace(":",""),host:P,pathname:w,params:Object.keys(R).length>0?R:null,isSecure:N}}catch{return{protocol:"",host:t,pathname:"",params:null,isSecure:!1}}},l=Jl(()=>a(t),[t,i,r,o]),[p,c]=fr(!1);return G(u,{style:C.urlBreakdown,children:[G(u,{style:C.urlRow,children:[l.isSecure?T(Yl,{size:12,color:_r.semantic.success}):T(Ql,{size:12,color:_r.semantic.warning}),T(f,{style:C.urlDomain,children:l.host}),G(f,{style:C.urlProtocol,children:["(",l.protocol.toUpperCase(),")"]}),n?T(xi,{value:t,buttonStyle:C.copyButton}):T(D,{style:C.copyButton,onPress:s,activeOpacity:.7,children:T(ki,{size:14,color:q.color.textSecondary})})]}),T(u,{style:C.urlPathRow,children:G(f,{style:C.urlPath,numberOfLines:2,children:[l.pathname,l.params?G(f,{style:C.urlQueryString,children:["?",new URLSearchParams(l.params).toString()]}):null]})}),l.params?G(u,{style:C.queryParamsCollapsible,children:[G(D,{style:C.queryParamsToggle,onPress:()=>c(!p),activeOpacity:.7,children:[T(f,{style:C.queryParamsToggleText,children:"Query Parameters"}),T(f,{style:C.collapsibleCount,children:Object.keys(l.params).length}),p?T(Si,{size:14,color:q.color.textSecondary}):T(vi,{size:14,color:q.color.textSecondary})]}),p?T(pr,{title:"",data:l.params,showTypeFilter:!0,rawMode:!0,initialExpanded:!0}):null]}):null]})},Xo=Gl(function({event:e,ignoredPatterns:r=sd,onTogglePattern:o=ad,showBodies:i=!0}){let n=e.status?_o(e.status):null,s=!e.status&&!e.error,{isPro:a}=od(),[l,p]=fr(!1);hi(()=>{l&&a&&p(!1)},[l,a]);let c=mi(),x=e.requestData===void 0&&(e.requestBodyOmitted===!0||(e.requestSize??0)>0),O=e.responseData===void 0&&(e.responseBodyOmitted===!0||(e.responseSize??0)>0),E=e.headersOmitted===!0,[P,N]=fr(null),[w,R]=fr(!1);hi(()=>{if(N(null),!c||!x&&!O&&!E){R(!1);return}let m=!1;return R(!0),c(e.id).then(y=>{m||N(y)}).catch(()=>{}).finally(()=>{m||R(!1)}),()=>{m=!0}},[e.id,c,x,O,E]);let S=e.requestData??P?.requestData??void 0,v=e.responseData??P?.responseData??void 0,A=(E?P?.requestHeaders:void 0)??e.requestHeaders,H=(E?P?.responseHeaders:void 0)??e.responseHeaders,L=()=>{let m={method:e.method,url:e.url,status:e.status,statusText:e.statusText,timestamp:new Date(e.timestamp).toISOString(),duration:e.duration?`${e.duration}ms`:"N/A",requestHeaders:A,requestData:S,responseHeaders:H,responseData:v,requestSize:e.requestSize?Xe(e.requestSize):"N/A",responseSize:e.responseSize?Xe(e.responseSize):"N/A",error:e.error,client:e.requestClient};return`# Network Request Details
|
|
11
|
+
|
|
12
|
+
## Request
|
|
13
|
+
- **Method:** ${m.method}
|
|
14
|
+
- **URL:** ${m.url}
|
|
15
|
+
- **Client:** ${m.client||"N/A"}
|
|
16
|
+
- **Timestamp:** ${m.timestamp}
|
|
17
|
+
|
|
18
|
+
## Response
|
|
19
|
+
- **Status:** ${m.status||"Pending"}${m.statusText?` (${m.statusText})`:""}
|
|
20
|
+
- **Duration:** ${m.duration}
|
|
21
|
+
- **Request Size:** ${m.requestSize}
|
|
22
|
+
- **Response Size:** ${m.responseSize}
|
|
23
|
+
${m.error?`- **Error:** ${m.error}`:""}
|
|
24
|
+
|
|
25
|
+
## Request Headers
|
|
26
|
+
\`\`\`json
|
|
27
|
+
${JSON.stringify(m.requestHeaders,null,2)}
|
|
28
|
+
\`\`\`
|
|
29
|
+
|
|
30
|
+
## Request Data
|
|
31
|
+
\`\`\`json
|
|
32
|
+
${JSON.stringify(m.requestData,null,2)}
|
|
33
|
+
\`\`\`
|
|
34
|
+
|
|
35
|
+
## Response Headers
|
|
36
|
+
\`\`\`json
|
|
37
|
+
${JSON.stringify(m.responseHeaders,null,2)}
|
|
38
|
+
\`\`\`
|
|
39
|
+
|
|
40
|
+
## Response Data
|
|
41
|
+
\`\`\`json
|
|
42
|
+
${JSON.stringify(m.responseData,null,2)}
|
|
43
|
+
\`\`\`
|
|
44
|
+
`};return G(jo,{children:[G(Ge,{testID:"buoy-network-detail-scroll",style:C.container,children:[G(u,{style:C.requestDetailsSection,children:[G(u,{style:C.httpHeader,children:[T(u,{style:C.httpMethodBadge,children:T(f,{style:C.httpMethod,children:e.method})}),e.status?T(u,{style:[C.httpStatusBadge,{backgroundColor:`${n?.color}20`}],children:G(f,{style:[C.httpStatusText,{color:n?.color}],children:[n?.text," ",n?.meaning]})}):s?G(u,{style:C.pendingBadge,children:[T(Uo,{size:10,color:q.color.warning}),T(f,{style:C.pendingBadgeText,children:"Pending"})]}):null,e.condition&&G(f,{style:{color:"#FFCC66"},children:["Conditions: ",e.condition.profile," (+",e.condition.delayMs," ms)"]}),e.duration?G(u,{style:C.httpDuration,children:[T(Uo,{size:10,color:q.color.textTertiary}),T(f,{style:C.httpDurationText,children:Jt(e.duration)})]}):null,e.override?G(u,{style:C.overrideBadge,children:[T(rd,{size:10,color:q.color.warning}),T(f,{style:C.overrideBadgeText,children:e.override.ruleName||"Overridden"})]}):null,a?T(xi,{value:L,buttonStyle:C.copyFullButton}):T(D,{style:C.copyFullButton,onPress:()=>p(!0),activeOpacity:.7,children:T(ki,{size:14,color:q.color.textSecondary})})]}),T(dd,{url:e.url,requestData:S,operationName:e.operationName,graphqlVariables:e.graphqlVariables,requestClient:e.requestClient,isPro:a,onUpgradePress:()=>p(!0)}),e.error?G(u,{style:C.errorBox,children:[T(Kl,{size:12,color:q.color.danger}),T(f,{style:C.errorText,children:e.error})]}):null]}),G(u,{style:C.timingSection,children:[G(u,{style:C.timingRow,children:[T(Uo,{size:12,color:q.color.textSecondary}),T(f,{style:C.timingLabel,children:"Started:"}),T(f,{style:C.timingValue,children:id(e.timestamp)}),G(f,{style:C.timingExact,children:["(",new Date(e.timestamp).toLocaleTimeString(),")"]}),e.requestSize||e.responseSize?G(u,{style:C.sizeRow,children:[e.requestSize!==void 0?G(u,{style:C.sizeItem,children:[T(yi,{size:10,color:q.color.info}),T(f,{style:C.sizeLabel,children:"Sent:"}),T(f,{style:C.sizeValue,children:Xe(e.requestSize)})]}):null,e.responseSize!==void 0?G(u,{style:C.sizeItem,children:[T(bi,{size:10,color:Fr}),T(f,{style:C.sizeLabel,children:"Received:"}),T(f,{style:C.sizeValue,children:Xe(e.responseSize)})]}):null]}):null]}),e.timings?G(jo,{children:[T(u,{style:C.phaseDivider}),T(ld,{timings:e.timings,total:e.duration??e.timings.ttfb+e.timings.download})]}):null]}),T(qt,{title:"Request Headers",icon:T(yi,{size:14,color:q.color.info}),defaultOpen:!1,count:Object.keys(A).length,children:Object.keys(A).length>0?T(u,{style:C.dataViewerContainer,children:T(pr,{title:"",data:A,showTypeFilter:!0,rawMode:!0,initialExpanded:!0,disableCopy:!a})}):T(f,{style:C.emptyText,children:"No request headers"})}),T(qt,{title:"Response Headers",icon:T(bi,{size:14,color:Fr}),defaultOpen:!1,count:Object.keys(H).length,children:Object.keys(H).length>0?T(u,{style:C.dataViewerContainer,children:T(pr,{title:"",data:H,showTypeFilter:!0,rawMode:!0,initialExpanded:!0,disableCopy:!a})}):T(f,{style:C.emptyText,children:"No response headers yet"})}),S!==void 0?T(qt,{title:"Request Body",icon:T(Vr,{size:14,color:q.color.accent}),defaultOpen:!1,children:T(u,{style:C.dataViewerContainer,children:i?T(pr,{title:"",data:S,showTypeFilter:!0,rawMode:!0,initialExpanded:!0,disableCopy:!a}):T(wi,{})})}):x?T(qt,{title:"Request Body",icon:T(Vr,{size:14,color:q.color.accent}),defaultOpen:!0,children:T(f,{style:C.emptyText,children:w?`Loading request body (${Xe(e.requestSize??0)})\u2026`:"Request body unavailable"})}):null,v!==void 0?T(qt,{title:"Response Body",icon:T(Vr,{size:14,color:Fr}),defaultOpen:!0,children:T(u,{style:C.dataViewerContainer,children:i?T(pr,{title:"",data:v,showTypeFilter:!0,rawMode:!0,initialExpanded:!0,disableCopy:!a}):T(wi,{})})}):O?T(qt,{title:"Response Body",icon:T(Vr,{size:14,color:Fr}),defaultOpen:!0,children:T(f,{style:C.emptyText,children:w?`Loading response body (${Xe(e.responseSize??0)})\u2026`:"Response body unavailable"})}):null,T(qt,{title:"Filter Options",icon:T(Zl,{size:14,color:q.color.warning}),defaultOpen:!1,children:T(u,{style:C.filterOptionsContainer,children:(()=>{let m="",y="";try{let b=new URL(e.url);m=b.hostname,y=b.pathname}catch{y=e.url}let k=r.has(m),d=r.has(y);return G(jo,{children:[G(D,{style:[C.filterOption,k&&C.filterOptionActive],onPress:()=>m&&o(m),children:[G(u,{style:C.filterOptionLeft,children:[T(ed,{size:16,color:k?q.color.warning:q.color.textTertiary}),G(u,{style:C.filterOptionContent,children:[T(f,{style:C.filterOptionLabel,children:"Ignore Domain"}),T(f,{style:C.filterOptionValue,children:m||"N/A"})]})]}),T(u,{style:[C.filterToggle,k&&C.filterToggleActive],children:T(f,{style:[C.filterToggleText,k&&C.filterToggleTextActive],children:k?"IGNORED":"IGNORE"})})]}),G(D,{style:[C.filterOption,d&&C.filterOptionActive],onPress:()=>y&&o(y),children:[G(u,{style:C.filterOptionLeft,children:[T(td,{size:16,color:d?q.color.warning:q.color.textTertiary}),G(u,{style:C.filterOptionContent,children:[T(f,{style:C.filterOptionLabel,children:"Ignore URL Pattern"}),T(f,{style:C.filterOptionValue,numberOfLines:1,children:y||"N/A"})]})]}),T(u,{style:[C.filterToggle,d&&C.filterToggleActive],children:T(f,{style:[C.filterToggleText,d&&C.filterToggleTextActive],children:d?"IGNORED":"IGNORE"})})]}),T(u,{style:C.filterInfoBox,children:T(f,{style:C.filterInfoText,children:"Ignored requests will be hidden from the network list. You can manage filters in the Filters tab."})})]})})()})})]}),T(nd,{visible:l,onClose:()=>p(!1),featureName:"Copy Request Details",description:"Copy network request details to share or debug issues.",benefits:["Copy full request details including headers and body","Export to JSON, Markdown, or plain text","Share request data with teammates","Feed data to AI assistants for debugging"]})]})}),C=K.create({container:{flex:1,backgroundColor:"transparent"},requestDetailsSection:{marginHorizontal:12,marginTop:12,backgroundColor:q.color.surface,borderRadius:8,borderWidth:1,borderColor:q.color.border,padding:12},httpHeader:{flexDirection:"row",alignItems:"center",gap:8,marginBottom:12,flexWrap:"nowrap"},httpMethodBadge:{backgroundColor:q.color.infoSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4},httpMethod:{color:q.color.info,fontSize:11,fontWeight:"700",letterSpacing:.5},httpStatusBadge:{paddingHorizontal:8,paddingVertical:4,borderRadius:4},httpStatusText:{fontSize:11,fontWeight:"600"},pendingBadge:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:q.color.warningSoft,paddingHorizontal:8,paddingVertical:4,borderRadius:4},pendingBadgeText:{color:q.color.warning,fontSize:11,fontWeight:"600"},httpDuration:{flexDirection:"row",alignItems:"center",gap:4},httpDurationText:{color:q.color.textSecondary,fontSize:11},overrideBadge:{flexDirection:"row",alignItems:"center",gap:4,paddingHorizontal:6,paddingVertical:3,borderRadius:4,backgroundColor:q.color.warningSoft},overrideBadgeText:{color:q.color.warning,fontSize:10,fontWeight:"700"},copyFullButton:{marginLeft:"auto",flexShrink:0,padding:4},urlBreakdown:{backgroundColor:q.color.bg,borderRadius:4,padding:8},urlRow:{flexDirection:"row",alignItems:"center",gap:6,marginBottom:4},urlDomain:{color:q.color.text,fontSize:12,fontWeight:"600",flex:1},urlProtocol:{color:q.color.textTertiary,fontSize:10},copyButton:{padding:4},urlPathRow:{paddingLeft:18},urlPath:{color:q.color.textSecondary,fontSize:11,fontFamily:Gt},urlQueryString:{color:q.color.info,fontSize:11,fontFamily:Gt},queryParamsCollapsible:{marginTop:8},queryParamsToggle:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingVertical:10,backgroundColor:q.color.surfaceElevated,borderRadius:8,borderWidth:1,borderColor:q.color.border,marginBottom:8},queryParamsToggleText:{flexGrow:0,color:q.color.text,fontSize:12,fontWeight:"600",letterSpacing:.3},timingSection:{marginHorizontal:12,marginTop:8,backgroundColor:q.color.surface,borderRadius:8,borderWidth:1,borderColor:q.color.border,padding:12},timingRow:{flexDirection:"row",alignItems:"center",gap:6,flexWrap:"wrap"},timingLabel:{color:q.color.textSecondary,fontSize:11},timingValue:{color:q.color.text,fontSize:11,fontWeight:"600"},timingExact:{color:q.color.textTertiary,fontSize:10,marginLeft:4},sizeRow:{flexDirection:"row",alignItems:"center",gap:16,marginLeft:"auto"},sizeItem:{flexDirection:"row",alignItems:"center",gap:4},sizeLabel:{color:q.color.textTertiary,fontSize:10},sizeValue:{color:q.color.info,fontSize:10,fontFamily:Gt,fontWeight:"600"},phaseDivider:{height:1,backgroundColor:q.color.border,marginTop:12,marginBottom:12},phaseList:{gap:8},phaseRow:{flexDirection:"row",alignItems:"center",gap:14},phaseLabelGroup:{width:150},phaseLabel:{fontSize:12,color:q.color.textSecondary},phaseHint:{fontSize:10,color:q.color.textTertiary},phaseTrack:{flex:1,height:7,borderRadius:4,backgroundColor:q.color.surfaceElevated,justifyContent:"center",overflow:"hidden"},phaseBar:{height:7,borderRadius:4},phaseValue:{width:72,textAlign:"right",fontSize:12,fontFamily:Gt,color:q.color.text},collapsibleSection:{marginHorizontal:12,marginTop:8,backgroundColor:q.color.surface,borderRadius:8,borderWidth:1,borderColor:q.color.border,overflow:"hidden"},collapsibleHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",padding:12,backgroundColor:q.color.surfaceElevated},collapsibleTitle:{flexDirection:"row",alignItems:"center",gap:8},collapsibleTitleText:{color:q.color.text,fontSize:13,fontWeight:"600"},collapsibleCount:{color:q.color.textTertiary,fontSize:11.5,fontFamily:Gt},collapsibleContent:{padding:12},dataViewerContainer:{marginTop:-12,marginHorizontal:-12,marginBottom:-12},bodyDeferred:{height:120},errorBox:{flexDirection:"row",alignItems:"center",gap:6,backgroundColor:q.color.dangerSoft,padding:8,borderRadius:4,marginTop:8},errorText:{color:q.color.danger,fontSize:11,flex:1},emptyText:{color:q.color.textTertiary,fontSize:12,fontStyle:"italic",textAlign:"center"},filterOptionsContainer:{gap:12},filterOption:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",backgroundColor:q.color.surfaceElevated,borderRadius:8,padding:12,borderWidth:1,borderColor:q.color.border},filterOptionActive:{backgroundColor:q.color.warningSoft,borderColor:q.color.warning+"33"},filterOptionLeft:{flexDirection:"row",alignItems:"center",gap:12,flex:1},filterOptionContent:{flex:1},filterOptionLabel:{color:q.color.textSecondary,fontSize:11,marginBottom:2,textTransform:"uppercase",letterSpacing:.5},filterOptionValue:{color:q.color.text,fontSize:13,fontFamily:Gt},filterToggle:{paddingHorizontal:10,paddingVertical:6,borderRadius:4,backgroundColor:q.color.bg,borderWidth:1,borderColor:q.color.border},filterToggleActive:{backgroundColor:q.color.warningSoft,borderColor:q.color.warning+"4D"},filterToggleText:{fontSize:10,fontWeight:"600",color:q.color.textTertiary,letterSpacing:.5},filterToggleTextActive:{color:q.color.warning},filterInfoBox:{backgroundColor:q.color.infoSoft,borderRadius:6,padding:10,borderWidth:1,borderColor:q.color.info+"33"},filterInfoText:{color:q.color.textSecondary,fontSize:11,lineHeight:16}});g();he();import{DynamicFilterView as Ri,macOSColors as Je,FileText as Ti,FileCode as Ci,Link as ud,Zap as cd,Settings as pd,Hash as fd,Eye as gd,ToolbarCopyButton as md,formatRelativeTime as hd,useFeatureGate as yd,ProFeatureBanner as bd,ExportPreview as wd,monoFont as Ei}from"@buoy-gg/shared-ui/web";import{DataViewer as vd}from"@buoy-gg/shared-ui/web/dataViewer";import{useCallback as et,useMemo as Mt,useState as Sd}from"react";import{Fragment as Cd,jsx as Fe,jsxs as Ni}from"react/jsx-runtime";var Oi={includeMethod:!0,includeStatus:!0,includeDuration:!0,includeTimestamp:!0,includeClient:!0,includeSizes:!0,includeErrors:!0,includeRequestHeaders:!0,includeResponseHeaders:!0,includeRequestBody:!0,includeResponseBody:!0,bodySizeThreshold:10,format:"markdown",filterMode:"all"},gr={urls:{includeMethod:!0,includeStatus:!1,includeDuration:!1,includeTimestamp:!1,includeClient:!1,includeSizes:!1,includeErrors:!1,includeRequestHeaders:!1,includeResponseHeaders:!1,includeRequestBody:!1,includeResponseBody:!1,bodySizeThreshold:10,format:"plaintext",filterMode:"all"},llm:{includeMethod:!0,includeStatus:!0,includeDuration:!0,includeTimestamp:!0,includeClient:!0,includeSizes:!0,includeErrors:!0,includeRequestHeaders:!0,includeResponseHeaders:!0,includeRequestBody:!0,includeResponseBody:!0,bodySizeThreshold:10,format:"markdown",filterMode:"all"},json:{includeMethod:!0,includeStatus:!0,includeDuration:!0,includeTimestamp:!0,includeClient:!0,includeSizes:!0,includeErrors:!0,includeRequestHeaders:!0,includeResponseHeaders:!0,includeRequestBody:!0,includeResponseBody:!0,bodySizeThreshold:-1,format:"json",filterMode:"all"},full:{includeMethod:!0,includeStatus:!0,includeDuration:!0,includeTimestamp:!0,includeClient:!0,includeSizes:!0,includeErrors:!0,includeRequestHeaders:!0,includeResponseHeaders:!0,includeRequestBody:!0,includeResponseBody:!0,bodySizeThreshold:-1,format:"markdown",filterMode:"all"}};function kd(t){for(let[e,r]of Object.entries(gr))if(Object.keys(r).every(i=>r[i]===t[i]))return e;return null}var xd=100*1024,Rd=500*1024;function Td(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ii({settings:t,onSettingsChange:e,events:r=[]}){let{isPro:o}=yd(),i=cr(),[n,s]=Sd(!1),a=r.length>0,l=Mt(()=>{if(!a)return null;let k=r.map(d=>typeof d.timestamp=="number"?d.timestamp:new Date(d.timestamp).getTime());return Math.max(...k)},[r,a]),p=Mt(()=>kd(t),[t]),c=et(()=>{e(gr.urls)},[e]),x=et(()=>{e(gr.llm)},[e]),O=et(()=>{e(gr.json)},[e]),E=et(()=>{e(gr.full)},[e]),P=et((k,d)=>{let[b,h]=k.split("::");if(b==="preset"){switch(h){case"urls":c();break;case"llm":x();break;case"json":O();break;case"full":E();break}return}if(b==="requestInfo"){e({...t,[h]:!t[h]});return}if(b==="headers"){e({...t,[h]:!t[h]});return}if(b==="body"){e(h==="bodySizeThreshold"?{...t,bodySizeThreshold:d}:{...t,[h]:!t[h]});return}if(b==="format"){e({...t,format:d});return}b==="filter"&&e({...t,filterMode:d})},[t,e,c,x,O,E]),N=Mt(()=>({method:"POST",url:"https://api.example.com/v1/users",status:201,duration:342,timestamp:new Date().toISOString(),requestHeaders:{"Content-Type":"application/json",Authorization:"Bearer ***"},responseHeaders:{"Content-Type":"application/json","X-Request-ID":"abc123"},requestBody:{name:"John Doe",email:"john@example.com"},responseBody:{id:"user_123",name:"John Doe",email:"john@example.com",createdAt:"2025-01-10T12:00:00Z"}}),[]),w=Mt(()=>a?r:[N],[a,r,N]),R=Mt(()=>{let k=a?r:[N],d=0;for(let b of k){if(t.includeMethod&&(d+=(b.url?.length||0)+10),t.includeStatus&&(d+=30),t.includeTimestamp&&(d+=30),t.includeRequestHeaders)try{d+=JSON.stringify(b.requestHeaders||{}).length}catch{d+=100}if(t.includeRequestBody){let h="requestBody"in b?b.requestBody:b.requestData;try{d+=JSON.stringify(h||{}).length}catch{d+=100}}if(t.includeResponseBody){let h="responseBody"in b?b.responseBody:b.responseData;try{d+=JSON.stringify(h||{}).length}catch{d+=100}}}return d},[a,r,N,t]),S=Mt(()=>R>=Rd?"danger":R>=xd?"warning":"none",[R]),v=et(()=>{let k=a?r:[N],{format:d,includeMethod:b,includeStatus:h,includeTimestamp:M,includeRequestHeaders:ae,includeRequestBody:pe,includeResponseBody:re}=t,X=Q=>{let z={};return b&&(z.method=Q.method,z.url=Q.url),h&&(z.status=Q.status,z.duration=Q.duration),M&&(z.timestamp=Q.timestamp),ae&&(z.requestHeaders=Q.requestHeaders),pe&&(z.requestBody="requestBody"in Q?Q.requestBody:Q.requestData),re&&(z.responseBody="responseBody"in Q?Q.responseBody:Q.responseData),z};if(d==="json"){let Q=k.map(X);return JSON.stringify(Q,null,2)}return d==="markdown"?k.map((z,Z)=>{let J=[];J.push(`# Request ${Z+1}`),b&&J.push(`
|
|
45
|
+
**${z.method}** ${z.url}`);let Pe=[];if(h&&(Pe.push(`**Status:** ${z.status}`),Pe.push(`**Duration:** ${z.duration}ms`)),M&&Pe.push(`**Timestamp:** ${z.timestamp}`),Pe.length>0&&J.push(`
|
|
46
|
+
`+Pe.join(`
|
|
47
|
+
`)),ae){let Ee=z.requestHeaders||{};J.push(`
|
|
48
|
+
## Request Headers
|
|
49
|
+
\`\`\`json
|
|
50
|
+
${JSON.stringify(Ee,null,2)}
|
|
51
|
+
\`\`\``)}if(pe){let Ee="requestBody"in z?z.requestBody:z.requestData;J.push(`
|
|
52
|
+
## Request Body
|
|
53
|
+
\`\`\`json
|
|
54
|
+
${JSON.stringify(Ee||{},null,2)}
|
|
55
|
+
\`\`\``)}if(re){let Ee="responseBody"in z?z.responseBody:z.responseData;J.push(`
|
|
56
|
+
## Response Body
|
|
57
|
+
\`\`\`json
|
|
58
|
+
${JSON.stringify(Ee||{},null,2)}
|
|
59
|
+
\`\`\``)}return J.join(`
|
|
60
|
+
`)}).join(`
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
`)||"No data included":k.map((Q,z)=>{let Z=[];if(Z.push(`Request ${z+1}:`),b&&Z.push(`${Q.method} ${Q.url}`),h&&(Z.push(`Status: ${Q.status}`),Z.push(`Duration: ${Q.duration}ms`)),M&&Z.push(`Timestamp: ${Q.timestamp}`),pe){let J="requestBody"in Q?Q.requestBody:Q.requestData;Z.push(`
|
|
65
|
+
Request:`),Z.push(JSON.stringify(J||{},null,2))}if(re){let J="responseBody"in Q?Q.responseBody:Q.responseData;Z.push(`
|
|
66
|
+
Response:`),Z.push(JSON.stringify(J||{},null,2))}return Z.join(`
|
|
67
|
+
`)}).join(`
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
`)||"No data included"},[a,r,N,t]),A=et(()=>{let k=a?r:[N],{format:d,includeMethod:b,includeStatus:h,includeTimestamp:M,includeRequestHeaders:ae,includeRequestBody:pe,includeResponseBody:re}=t,X=z=>{let Z={};return b&&(Z.method=z.method,Z.url=z.url),h&&(Z.status=z.status,Z.duration=z.duration),M&&(Z.timestamp=z.timestamp),ae&&(Z.requestHeaders=z.requestHeaders),pe&&(Z.requestBody="requestBody"in z?z.requestBody:z.requestData),re&&(Z.responseBody="responseBody"in z?z.responseBody:z.responseData),Z};if(d==="json"){let z=k.map(X);return Fe(vd,{data:z,title:"",showTypeFilter:!1})}if(d==="markdown"){let Z=k.map((J,Pe)=>{let Ee=[];Ee.push(`# Request ${Pe+1}`),b&&Ee.push(`
|
|
72
|
+
**${J.method}** ${J.url}`);let It=[];if(h&&(It.push(`**Status:** ${J.status}`),It.push(`**Duration:** ${J.duration}ms`)),M&&It.push(`**Timestamp:** ${J.timestamp}`),It.length>0&&Ee.push(`
|
|
73
|
+
`+It.join(`
|
|
74
|
+
`)),ae){let ze=J.requestHeaders||{};Ee.push(`
|
|
75
|
+
## Request Headers
|
|
76
|
+
\`\`\`json
|
|
77
|
+
${JSON.stringify(ze,null,2)}
|
|
78
|
+
\`\`\``)}if(pe){let ze="requestBody"in J?J.requestBody:J.requestData;Ee.push(`
|
|
79
|
+
## Request Body
|
|
80
|
+
\`\`\`json
|
|
81
|
+
${JSON.stringify(ze||{},null,2)}
|
|
82
|
+
\`\`\``)}if(re){let ze="responseBody"in J?J.responseBody:J.responseData;Ee.push(`
|
|
83
|
+
## Response Body
|
|
84
|
+
\`\`\`json
|
|
85
|
+
${JSON.stringify(ze||{},null,2)}
|
|
86
|
+
\`\`\``)}return Ee.join(`
|
|
87
|
+
`)}).join(`
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
`);return Fe(Ge,{style:Dt.previewScroll,nestedScrollEnabled:!0,children:Fe(f,{style:Dt.markdownText,selectable:o,children:Z||"No data included"})})}let Q=k.map((z,Z)=>{let J=[];if(J.push(`Request ${Z+1}:`),b&&J.push(`${z.method} ${z.url}`),h&&(J.push(`Status: ${z.status}`),J.push(`Duration: ${z.duration}ms`)),M&&J.push(`Timestamp: ${z.timestamp}`),pe){let Pe="requestBody"in z?z.requestBody:z.requestData;J.push(`
|
|
92
|
+
Request:`),J.push(JSON.stringify(Pe||{},null,2))}if(re){let Pe="responseBody"in z?z.responseBody:z.responseData;J.push(`
|
|
93
|
+
Response:`),J.push(JSON.stringify(Pe||{},null,2))}return J.join(`
|
|
94
|
+
`)}).join(`
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
`);return Fe(Ge,{style:Dt.previewScroll,nestedScrollEnabled:!0,children:Fe(f,{style:Dt.plaintextText,selectable:o,children:Q||"No data included"})})},[t,a,r,N,o]),H=et(()=>{let d=(a?r:[N]).length;return Fe(wd,{expanded:n,onExpandedChange:s,summary:`${d} request${d!==1?"s":""} \u2022 ~${Td(R)}`,warningLevel:S,warningText:{warning:"Large payload - preview may be slow",danger:"Very large payload - may cause performance issues"},renderBody:A})},[t,a,r,N,n,R,S,A]),L=et(()=>{let k=a&&l?`Live data \u2022 Updated ${hd(l,i)}`:"Mock data (no events captured)";return Ni(Cd,{children:[Fe(f,{style:Dt.statusLabel,children:k}),Fe(md,{value:v()})]})},[a,l,i,v]),m=et(()=>H(),[H]),y=Mt(()=>({sections:[{id:"presets",title:"Presets",type:"custom",data:[{id:"preset::urls",label:"URLs",icon:ud,color:Je.semantic.info,value:"urls",isActive:p==="urls"},{id:"preset::llm",label:"LLM",icon:cd,color:Je.semantic.success,value:"llm",isActive:p==="llm"},{id:"preset::json",label:"JSON",icon:Ci,color:Je.semantic.warning,value:"json",isActive:p==="json"},{id:"preset::full",label:"Full",icon:Ti,color:Je.semantic.info,value:"full",isActive:p==="full"},{id:"preset::custom",label:"Custom",icon:pd,color:Je.text.secondary,value:"custom",isActive:p===null}]},{id:"include",title:"Include",type:"custom",data:[{id:"requestInfo::includeMethod",label:"URL",value:"includeMethod",isActive:t.includeMethod},{id:"requestInfo::includeStatus",label:"Status",value:"includeStatus",isActive:t.includeStatus},{id:"requestInfo::includeTimestamp",label:"Time",value:"includeTimestamp",isActive:t.includeTimestamp},{id:"headers::includeRequestHeaders",label:"Headers",value:"includeRequestHeaders",isActive:t.includeRequestHeaders},{id:"body::includeRequestBody",label:"Req Body",value:"includeRequestBody",isActive:t.includeRequestBody},{id:"body::includeResponseBody",label:"Res Body",value:"includeResponseBody",isActive:t.includeResponseBody},{id:"requestInfo::includeErrors",label:"Errors",value:"includeErrors",isActive:t.includeErrors}]},{id:"format",title:"Format",type:"custom",data:[{id:"format::markdown",label:"Markdown",icon:Ti,color:Je.semantic.info,value:"markdown",isActive:t.format==="markdown"},{id:"format::json",label:"JSON",icon:Ci,color:Je.semantic.warning,value:"json",isActive:t.format==="json"},{id:"format::plaintext",label:"Text",icon:fd,color:Je.text.secondary,value:"plaintext",isActive:t.format==="plaintext"}]}],previewSection:{enabled:!0,title:"PREVIEW",icon:gd,content:m,headerActions:L},onFilterChange:P}),[t,P,m,L,p]);return o?Fe(Ri,{...y}):Ni(u,{style:Dt.gatedContainer,children:[Fe(bd,{featureName:"Network Export",description:"Export network requests to share with your team, debug APIs, or feed into AI tools.",benefits:["Export to JSON, Markdown, or plain text","Customizable copy presets (URLs only, LLM-ready, full data)","Share request details with teammates","Feed network data directly to AI assistants"]}),Fe(u,{style:Dt.gatedPreview,children:Fe(Ri,{...y})})]})}var Dt=K.create({previewScroll:{maxHeight:300},markdownText:{fontFamily:Ei,fontSize:11,color:Je.text.primary,lineHeight:18},plaintextText:{fontFamily:Ei,fontSize:11,color:Je.text.primary,lineHeight:18},statusLabel:{fontSize:11,fontWeight:"600",color:Je.text.muted,marginRight:8},gatedContainer:{flex:1,padding:12},gatedPreview:{flex:1}});g();he();import{Bookmark as Gi,CheckCircle as Ud,XCircle as jd,Clock as Xd,Copy as Jd,Pin as Gd,Trash2 as Kd,CopyButton as Yd,macOSColors as kt,night as se,useLimit as Qd,monoFont as Ji}from"@buoy-gg/shared-ui/web";g();import{getAccountAccess as Hi}from"@buoy-gg/shared-ui/web";import{BaseEventStore as Ld}from"@buoy-gg/shared-ui/web";g();function Jo(t){if(!t||typeof t!="object")return null;if("operationName"in t&&t.operationName){let e=t.operationName;if(typeof e=="string"&&e.trim().length>0)return e.trim()}if("query"in t&&typeof t.query=="string"){let r=t.query.match(/(?:query|mutation|subscription)\s+(\w+)/);if(r&&r[1])return r[1]}return null}g();import{devToolsStorageKeys as Pi,persistentStorage as Li}from"@buoy-gg/shared-ui/web";import{TIER_LIMITS as Ed}from"@buoy-gg/shared-ui/web";var Go=`${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`,mr=25,_e=50,Yo=Ed["network.saved"].free,St=16*1024,Bi=512*1024;function Ai(t){if(!t||typeof t!="object")return!1;let e=t;return typeof e.id=="string"&&typeof e.url=="string"}var Nd=800;function Kt(t,e){if(!e)return{pinned:!1,saved:!1};let r=t.pinnedLiveIds.has(e),o=t.savedLiveIds.has(e);if(r||o)return{pinned:r,saved:o};let i=t.records.find(n=>n.event.id===e);return i?{pinned:i.pinned,saved:i.saved}:{pinned:!1,saved:!1}}var Od={records:[],pinnedEvents:[],savedRecords:[],pinnedLiveIds:new Set,savedLiveIds:new Set};function qi(t){if(t==null)return{value:t,truncated:!1};if(typeof t=="string")return t.length<=St?{value:t,truncated:!1}:{value:`${t.slice(0,St)}
|
|
99
|
+
|
|
100
|
+
\u2026 truncated by Buoy (body exceeded ${St} bytes)`,truncated:!0};try{let e=JSON.stringify(t);return e===void 0?{value:void 0,truncated:!1}:e.length<=St?{value:t,truncated:!1}:{value:`${e.slice(0,St)}
|
|
101
|
+
|
|
102
|
+
\u2026 truncated by Buoy (body exceeded ${St} bytes)`,truncated:!0}}catch{return{value:"[unserializable body]",truncated:!0}}}function Mi(t){let e=qi(t.requestData),r=qi(t.responseData);return!e.truncated&&!r.truncated?{event:{...t},bodyTruncated:!1}:{event:{...t,requestData:e.value,responseData:r.value},bodyTruncated:!0}}function Di(t){let e=0;return t.requestData!=null&&(e+=Math.min(t.requestSize??0,St)),t.responseData!=null&&(e+=Math.min(t.responseSize??0,St)),e}function Id(t){let e=0;for(let n of t)e+=Di(n.event);if(e<=Bi)return t;let r=[...t].sort((n,s)=>n.pinned!==s.pinned?n.pinned?-1:1:s.savedAt-n.savedAt),o=new Set,i=0;for(let n of r){let s=Di(n.event);i+s<=Bi?i+=s:o.add(n.key)}return o.size===0?t:t.map(n=>o.has(n.key)?{...n,event:{...n.event,requestData:void 0,responseData:void 0},bodyTruncated:!0}:n)}function Pd(t){if(!Array.isArray(t))return[];let e=[];for(let r of t){if(!r||typeof r!="object")continue;let o=r;typeof o.key=="string"&&Ai(o.event)&&(!o.pinned&&!o.saved||e.push({key:o.key,event:{...o.event,id:`saved:${o.key}`},pinned:!!o.pinned,saved:!!o.saved,savedAt:typeof o.savedAt=="number"?o.savedAt:0,sessionId:typeof o.sessionId=="string"?o.sessionId:"unknown",liveId:typeof o.liveId=="string"?o.liveId:"",bodyTruncated:!!o.bodyTruncated}))}return e}var Ko=class{constructor(){this.records=[];this.listeners=new Set;this.loaded=!1;this.loadPromise=null;this.dirty=!1;this.keyCounter=0;this.trackedLiveIds=new Set;this.state=Od;this.remote=null;this.remoteEchoUntil=0}getState(){return this.state}enableRemoteMode(e){this.remote=e}disableRemoteMode(){this.remote=null}replaceRecords(e,r=!1){this.remote&&(!r&&Date.now()<this.remoteEchoUntil||(this.records=e,this.rebuild(),this.emit()))}sessionMatches(e){return this.remote!==null||e.sessionId===Go}getRecords(){return this.records}subscribe(e){return this.listeners.add(e),this.ensureLoaded(),()=>{this.listeners.delete(e)}}getEventById(e){for(let r of this.records)if(r.event.id===e)return r.event;return null}isPinned(e){return this.state.pinnedLiveIds.has(e)}isSaved(e){return this.state.savedLiveIds.has(e)}syncFromLive(e){if(this.trackedLiveIds.size===0||!this.trackedLiveIds.has(e.id))return;let r=this.records.findIndex(i=>this.sessionMatches(i)&&i.liveId===e.id);if(r===-1)return;let o=Mi(e);this.commit(this.records.map((i,n)=>n===r?{...i,event:o.event,bodyTruncated:o.bodyTruncated}:i))}togglePin(e){return this.setFlag(e,"pinned")}toggleSave(e){return this.setFlag(e,"saved")}remove(e){this.records.some(r=>r.key===e)&&(this.remote?.removeRecord(e),this.commit(this.records.filter(r=>r.key!==e)))}clearSaved(){this.records.some(e=>e.saved)&&(this.remote?.clearSaved(),this.commit(this.records.filter(e=>e.pinned).map(e=>({...e,saved:!1}))))}clearPinned(){this.records.some(e=>e.pinned)&&(this.remote?.clearPinned(),this.commit(this.records.filter(e=>e.saved).map(e=>({...e,pinned:!1}))))}setFlag(e,r){if(!Ai(e))return{ok:!1,reason:"invalid-event"};let o=this.findRecordFor(e);if(this.remote){let a=o?!o[r]:!0;r==="pinned"?this.remote.setPinned(e.id,a):this.remote.setSaved(e.id,a),this.remoteEchoUntil=Date.now()+Nd}if(o){let a=!o[r];if(a&&!this.hasRoomFor(r,o.key))return{ok:!1,reason:r==="pinned"?"pin-cap":"saved-cap"};let l={...o,[r]:a};return this.commit(l.pinned||l.saved?this.records.map(p=>p.key===o.key?l:p):this.records.filter(p=>p.key!==o.key)),{ok:!0,active:a}}if(!this.hasRoomFor(r,null))return{ok:!1,reason:r==="pinned"?"pin-cap":"saved-cap"};let i=Date.now(),n=Mi(e),s={key:`${Go}_${++this.keyCounter}`,event:n.event,pinned:r==="pinned",saved:r==="saved",savedAt:i,sessionId:Go,liveId:e.id,bodyTruncated:n.bodyTruncated};return this.commit(this.evictIfNeeded([s,...this.records])),{ok:!0,active:!0}}findRecordFor(e){return this.records.find(r=>r.event.id===e.id||this.sessionMatches(r)&&r.liveId===e.id)}hasRoomFor(e,r){let o=e==="pinned"?mr:_e;return this.records.filter(n=>n[e]&&n.key!==r).length<o}evictIfNeeded(e){let r=e.filter(n=>n.saved);if(r.length<=_e)return e;let o=r.filter(n=>!n.pinned).sort((n,s)=>n.savedAt-s.savedAt).slice(0,r.length-_e);if(o.length===0)return e;let i=new Set(o.map(n=>n.key));return e.filter(n=>!i.has(n.key))}ensureLoaded(){return this.remote||this.loaded?Promise.resolve():this.loadPromise?this.loadPromise:(this.loadPromise=(async()=>{try{let e=await Li.getItem(Pi.network.saved());e&&!this.dirty&&(this.records=Pd(JSON.parse(e)),this.rebuild())}catch{}finally{this.loaded=!0,this.emit()}})(),this.loadPromise)}persist(){this.remote||Li.setItem(Pi.network.saved(),JSON.stringify(this.records)).catch(()=>{})}commit(e){this.dirty=!0,this.records=Id(e),this.rebuild(),this.emit(),this.persist()}rebuild(){let e=[],r=[],o=new Set,i=new Set,n=new Set;for(let s of this.records)s.pinned&&e.push(s),s.saved&&r.push(s),!(!this.sessionMatches(s)||!s.liveId)&&(n.add(s.liveId),s.pinned&&o.add(s.liveId),s.saved&&i.add(s.liveId));this.trackedLiveIds=n,this.state={records:this.records,pinnedEvents:e.map(s=>s.event),savedRecords:r,pinnedLiveIds:o,savedLiveIds:i}}emit(){this.listeners.forEach(e=>e())}},ee=new Ko;var Bd=200,Qo=class extends Ld{constructor(){super({storeName:"network",maxEvents:500});this.pendingRequests=new Map;this.rawListenerUnsubscribe=null;this.bootBuffer=[];this.bootBufferUnsubscribe=null;this.mirrorMode=!1}startBootCapture(){if(Hi().status==="locked"||this.mirrorMode||this.bootBufferUnsubscribe||this.isCapturing())return;let r=ur();r.isActive||r.startListening(),this.bootBufferUnsubscribe=bt(o=>{this.bootBuffer.push(o),this.bootBuffer.length>Bd&&this.bootBuffer.shift()})}takeBootBuffer(){this.bootBufferUnsubscribe&&(this.bootBufferUnsubscribe(),this.bootBufferUnsubscribe=null);let r=this.bootBuffer;return this.bootBuffer=[],r}startCapturing(){let r=ur();r.isActive||r.startListening();for(let o of this.takeBootBuffer())this.processNetworkEvent(o);this.rawListenerUnsubscribe||(this.rawListenerUnsubscribe=bt(o=>{this.processNetworkEvent(o)}))}stopCapturing(){this.takeBootBuffer(),this.rawListenerUnsubscribe&&(this.rawListenerUnsubscribe(),this.rawListenerUnsubscribe=null),je()===0&&yt()}disableCapture(){this.mirrorMode=!0,this.takeBootBuffer(),je()===0&&yt(),super.disableCapture()}isCapturing(){return this.rawListenerUnsubscribe!==null}ensureInterception(){this.isCapturing()&&ur().startListening()}subscribeToEvents(r){let o=super.subscribeToEvents(r);return this.ensureInterception(),o}processNetworkEvent(r){if(Hi().status==="locked")return;let{request:o}=r;if(r.type==="request"){if(this.events.some(p=>p.id===o.id))return;let i=o.params?`?${new URLSearchParams(o.params).toString()}`:"",n=`${o.url}${i}`,s,a;o.client==="graphql"&&(s=Jo(o.data)||void 0,o.data&&typeof o.data=="object"&&"variables"in o.data&&o.data.variables&&typeof o.data.variables=="object"&&(a=o.data.variables));let l={id:o.id,method:o.method,url:n,host:this.extractHost(o.url),path:this.extractPath(o.url),query:i,timestamp:r.timestamp.getTime(),requestHeaders:o.headers||{},requestData:o.data,requestSize:this.getDataSize(o.data),responseHeaders:{},requestClient:o.client,operationName:s,graphqlVariables:a,override:r.override,condition:r.condition};this.pendingRequests.set(o.id,l),this.events=[l,...this.events].slice(0,this.maxEvents),this.notify(l),this.notifyArrayListeners()}else if(r.type==="request-body"){let i=this.events.find(s=>s.id===o.id);if(!i)return;let n={...i,requestData:o.data,requestSize:this.getDataSize(o.data)};if(o.client==="graphql"){n.operationName=Jo(o.data)||void 0;let s=o.data?.variables;s&&typeof s=="object"&&(n.graphqlVariables=s)}this.events=this.events.map(s=>s.id===o.id?n:s),this.pendingRequests.has(o.id)&&this.pendingRequests.set(o.id,n),ee.syncFromLive(n),this.notify(n),this.notifyArrayListeners()}else if(r.type==="response"||r.type==="error"){let i=this.events.findIndex(n=>n.id===o.id);if(i!==-1){let n={...this.events[i],duration:r.duration,timings:r.timings};r.response&&(n.status=r.response.status,n.statusText=r.response.statusText,n.responseHeaders=r.response.headers||{},n.responseData=r.response.body,n.responseSize=r.response.size||0,n.responseType=r.response.headers?.["content-type"]),r.error&&(n.error=r.error.message,n.status=n.status||0),r.override&&(n.override=r.override),this.events=this.events.map((s,a)=>a===i?n:s),this.pendingRequests.delete(o.id),ee.syncFromLive(n),this.notify(n),this.notifyArrayListeners()}}}extractHost(r){try{return new URL(r).hostname}catch{return""}}extractPath(r){try{return new URL(r).pathname}catch{return r}}getDataSize(r){if(!r)return 0;if(typeof r=="string")return r.length;try{return JSON.stringify(r).length}catch{return 0}}getEventById(r){return this.events.find(o=>o.id===r)}clearEvents(){super.clearEvents(),this.pendingRequests.clear()}onEvent(r,o=!0){let i=this.subscribe(r);if(o&&this.events.length>0){let n=[...this.events].reverse();for(let s of n)try{r(s)}catch{}}return i}getStats(){let r=this.events.length,o=this.events.filter(c=>c.status&&c.status>=200&&c.status<300).length,i=this.events.filter(c=>c.error||c.status&&c.status>=400).length,n=this.events.filter(c=>!c.status&&!c.error).length,s=this.events.filter(c=>c.duration).map(c=>c.duration),a=s.length>0?s.reduce((c,x)=>c+x,0)/s.length:0,l=this.events.reduce((c,x)=>c+(x.requestSize||0),0),p=this.events.reduce((c,x)=>c+(x.responseSize||0),0);return{totalRequests:r,successfulRequests:o,failedRequests:i,pendingRequests:n,totalDataSent:l,totalDataReceived:p,averageDuration:Math.round(a)}}filterEvents(r){let o=[...this.events];if(r.method&&(o=o.filter(i=>i.method===r.method)),r.status)switch(r.status){case"success":o=o.filter(i=>i.status&&i.status>=200&&i.status<300);break;case"error":o=o.filter(i=>i.error||i.status&&i.status>=400);break;case"pending":o=o.filter(i=>!i.status&&!i.error);break}if(r.searchText){let i=r.searchText.toLowerCase();o=o.filter(n=>n.url.toLowerCase().includes(i)||n.method.toLowerCase().includes(i)||n.error&&n.error.toLowerCase().includes(i))}return r.host&&(o=o.filter(i=>i.host===r.host)),o}},$=new Qo;g();import{useEffect as qd,useState as Md}from"react";var Dd=t=>ee.togglePin(t),Ad=t=>ee.toggleSave(t),Hd=t=>ee.remove(t),zd=()=>ee.clearSaved(),Vd=()=>ee.clearPinned();function tt(){let[t,e]=Md(()=>ee.getState());return qd(()=>ee.subscribe(()=>{e(ee.getState())}),[]),{...t,togglePin:Dd,toggleSave:Ad,remove:Hd,clearSaved:zd,clearPinned:Vd}}g();import{useSyncExternalStore as hr}from"react";g();var Fd=120,Zo=class{constructor(){this.ids=[];this.index=-1;this.selectedId=null;this.bodyId=null;this.renderedId=null;this.settleMs=120;this.settleTimer=null;this.subscribers=new Set;this.snapshot=this.buildSnapshot()}buildSnapshot(){return{ids:this.ids,index:this.index,selectedId:this.selectedId,bodyId:this.bodyId,renderedId:this.renderedId}}emit(){this.snapshot=this.buildSnapshot();for(let e of this.subscribers)e(this.snapshot)}getState(){return this.snapshot}subscribe(e){return this.subscribers.add(e),()=>{this.subscribers.delete(e)}}setIds(e){e.length===this.ids.length&&e.every((o,i)=>o===this.ids[i])||(this.ids=e,this.index=this.selectedId==null?-1:e.indexOf(this.selectedId),this.emit())}select(e){e!==this.selectedId&&(this.selectedId=e,this.index=e==null?-1:this.ids.indexOf(e),this.scheduleBody(e),this.emit())}clear(){this.select(null)}step(e){if(this.index<0)return null;let r=this.index+e;if(r<0||r>=this.ids.length)return null;let o=this.ids[r];return this.selectedId=o,this.index=r,this.scheduleBody(o),this.emit(),o}scheduleBody(e){if(this.settleTimer!=null&&(clearTimeout(this.settleTimer),this.settleTimer=null),e==null||this.bodyId==null||this.settleMs<=0){this.bodyId=e;return}this.settleTimer=setTimeout(()=>{this.settleTimer=null,this.bodyId!==this.selectedId&&(this.bodyId=this.selectedId,this.emit())},this.settleMs)}setSettleMs(e){this.settleMs=Math.max(0,e)}getSettleMs(){return this.settleMs}reportRendered(e){e!==this.renderedId&&(this.renderedId=e,this.emit())}reset(){this.settleTimer!=null&&clearTimeout(this.settleTimer),this.settleTimer=null,this.ids=[],this.index=-1,this.selectedId=null,this.bodyId=null,this.renderedId=null,this.emit()}},De=new Zo;function zi(t){return t.map(e=>e.id)}var yr=t=>De.subscribe(t),rt=()=>De.getState();function Vi(){return hr(yr,()=>rt().selectedId!=null,()=>rt().selectedId!=null)}function Yt(){return hr(yr,()=>rt().selectedId,()=>rt().selectedId)}function Fi(){return hr(yr,()=>rt().bodyId,()=>rt().bodyId)}function _i(){let t=hr(yr,()=>rt().index,()=>rt().index),e=hr(yr,()=>rt().ids.length,()=>rt().ids.length);return{index:t,total:e}}g();import{useEffect as Wi,useState as Wd}from"react";g();import{urlMatchesIgnoredPattern as _d}from"@buoy-gg/shared-ui/web";function lt(t,e){let r=e.searchText?e.searchText.toLowerCase():null,o=e.method&&e.method.length>0?new Set(e.method):null,i=e.contentType&&e.contentType.length>0?new Set(e.contentType):null,n=[...t];if(o&&(n=n.filter(s=>o.has(s.method))),e.status&&e.status!=="all")switch(e.status){case"success":n=n.filter(s=>s.status&&s.status>=200&&s.status<300);break;case"error":n=n.filter(s=>s.error||s.status&&s.status>=400);break;case"pending":n=n.filter(s=>!s.status&&!s.error);break}return r&&(n=n.filter(s=>s.url.toLowerCase().includes(r)||s.method.toLowerCase().includes(r)||s.path?.toLowerCase().includes(r)||s.host?.toLowerCase().includes(r)||s.error&&s.error.toLowerCase().includes(r)||s.operationName&&s.operationName.toLowerCase().includes(r)||zr(s.graphqlVariables,r))),e.host&&(n=n.filter(s=>s.host===e.host)),i&&(n=n.filter(s=>{let a=s.responseHeaders||s.requestHeaders,l=a?.["content-type"]||a?.["Content-Type"]||"";for(let p of i)switch(p){case"JSON":if(l.includes("json"))return!0;break;case"XML":if(l.includes("xml"))return!0;break;case"HTML":if(l.includes("html"))return!0;break;case"TEXT":if(l.includes("text"))return!0;break;case"IMAGE":if(l.includes("image"))return!0;break;case"VIDEO":if(l.includes("video"))return!0;break;case"AUDIO":if(l.includes("audio"))return!0;break;case"FORM":if(l.includes("form"))return!0;break;case"OTHER":if(!l||!l.includes("json")&&!l.includes("xml")&&!l.includes("html")&&!l.includes("text")&&!l.includes("image")&&!l.includes("video")&&!l.includes("audio")&&!l.includes("form"))return!0;break}return!1})),n}function dt(t,e){return e.length===0?t:t.filter(r=>!e.some(o=>_d(r.url,o)))}function $i(t,e){let r=0,o=0,i=0;for(let n of dt(t,e))n.status&&n.status>=200&&n.status<300?r++:n.error||n.status&&n.status>=400?o++:!n.status&&!n.error&&i++;return{successful:r,failed:o,pending:i,total:t.length}}function $d(t,e){return t.successful===e.successful&&t.failed===e.failed&&t.pending===e.pending&&t.total===e.total}function en(t){let{ignoredPatterns:e,paused:r}=t,[o,i]=Wd(()=>$i($.getEvents(),e));return Wi(()=>{if(r)return;let n=null,s=null,a=$.subscribeToEvents(l=>{s=l,n==null&&(n=requestAnimationFrame(()=>{if(n=null,!s)return;let p=$i(s,e);s=null,i(c=>$d(c,p)?c:p)}))});return()=>{a(),n!=null&&cancelAnimationFrame(n)}},[r,e]),Wi(()=>$.onClear(()=>{i({successful:0,failed:0,pending:0,total:0})}),[]),o}g();import{useEffect as Wr,useState as Ui}from"react";function ji(t){let{paused:e}=t,[r,o]=Ui(()=>$.getEvents().length>0);return Wr(()=>{if(!e)return $.subscribeToEvents(i=>{let n=i.length>0;o(s=>s===n?s:n)})},[e]),Wr(()=>$.onClear(()=>o(!1)),[]),r}function Xi(t){let{filter:e,ignoredPatterns:r,paused:o}=t,[i,n]=Ui(()=>lt(dt($.getEvents(),r),e).length>0);return Wr(()=>{if(!o)return $.subscribeToEvents(s=>{let a=lt(dt(s,r),e).length>0;n(l=>l===a?l:a)})},[o,e,r]),Wr(()=>$.onClear(()=>n(!1)),[]),i}g();function $r(t){if(t==null)return"N/A";if(t===0)return"0 B";let e=1024,r=["B","KB","MB","GB","TB"],o=Math.floor(Math.log(t)/Math.log(e));return`${(t/Math.pow(e,o)).toFixed(1)} ${r[o]}`}function Ur(t,e){if(e===-1||!t)return!0;try{return JSON.stringify(t).length<e*1024}catch{return!1}}function jr(t,e){let r=t;if(e.filterMode==="failed"?r=r.filter(n=>n.error||n.status&&n.status>=400):e.filterMode==="success"&&(r=r.filter(n=>n.status&&n.status>=200&&n.status<300)),r.length===0)return"No requests to copy";if(e.format==="plaintext")return r.map(n=>`${n.method} ${n.url}`).join(`
|
|
103
|
+
`);if(e.format==="json"){let n=r.map(s=>{let a={};return e.includeMethod&&(a.method=s.method,a.url=s.url),e.includeStatus&&(a.status=s.status,a.statusText=s.statusText),e.includeDuration&&(a.duration=s.duration),s.condition&&(a.condition=s.condition),e.includeTimestamp&&(a.timestamp=s.timestamp),e.includeClient&&(a.requestClient=s.requestClient),e.includeSizes&&(a.requestSize=s.requestSize,a.responseSize=s.responseSize),e.includeErrors&&s.error&&(a.error=s.error),e.includeRequestHeaders&&(a.requestHeaders=s.requestHeaders),e.includeResponseHeaders&&(a.responseHeaders=s.responseHeaders),e.includeRequestBody&&Ur(s.requestData,e.bodySizeThreshold)&&(a.requestData=s.requestData),e.includeResponseBody&&Ur(s.responseData,e.bodySizeThreshold)&&(a.responseData=s.responseData),a});return JSON.stringify(n,null,2)}let o=r.map((n,s)=>{let a=`# Request ${s+1}
|
|
104
|
+
|
|
105
|
+
`;if(e.includeMethod&&(a+=`**Method:** ${n.method}
|
|
106
|
+
`,a+=`**URL:** ${n.url}
|
|
107
|
+
`),e.includeStatus){let l=n.status||"Pending";a+=`**Status:** ${l}${n.statusText?` (${n.statusText})`:""}
|
|
108
|
+
`}if(e.includeClient&&n.requestClient&&(a+=`**Client:** ${n.requestClient}
|
|
109
|
+
`),n.condition&&(a+=`Conditions: ${n.condition.profile} (+${n.condition.delayMs} ms)
|
|
110
|
+
`),e.includeDuration&&n.duration&&(a+=`**Duration:** ${n.duration}ms
|
|
111
|
+
`),e.includeTimestamp&&(a+=`**Timestamp:** ${new Date(n.timestamp).toISOString()}
|
|
112
|
+
`),e.includeSizes){let l=n.requestSize?$r(n.requestSize):"N/A",p=n.responseSize?$r(n.responseSize):"N/A";a+=`**Request Size:** ${l}
|
|
113
|
+
`,a+=`**Response Size:** ${p}
|
|
114
|
+
`}if(e.includeErrors&&n.error&&(a+=`**Error:** ${n.error}
|
|
115
|
+
`),e.includeRequestHeaders&&Object.keys(n.requestHeaders).length>0&&(a+=`
|
|
116
|
+
## Request Headers
|
|
117
|
+
\`\`\`json
|
|
118
|
+
${JSON.stringify(n.requestHeaders,null,2)}
|
|
119
|
+
\`\`\`
|
|
120
|
+
`),e.includeRequestBody)if(a+=`
|
|
121
|
+
## Request Data
|
|
122
|
+
`,Ur(n.requestData,e.bodySizeThreshold))a+=`\`\`\`json
|
|
123
|
+
${JSON.stringify(n.requestData,null,2)}
|
|
124
|
+
\`\`\`
|
|
125
|
+
`;else{let l=n.requestSize?$r(n.requestSize):"Unknown size";a+=`_Payload omitted (${l}). Exceeds ${e.bodySizeThreshold}KB threshold._
|
|
126
|
+
`}if(e.includeResponseHeaders&&Object.keys(n.responseHeaders).length>0&&(a+=`
|
|
127
|
+
## Response Headers
|
|
128
|
+
\`\`\`json
|
|
129
|
+
${JSON.stringify(n.responseHeaders,null,2)}
|
|
130
|
+
\`\`\`
|
|
131
|
+
`),e.includeResponseBody)if(a+=`
|
|
132
|
+
## Response Data
|
|
133
|
+
`,Ur(n.responseData,e.bodySizeThreshold))a+=`\`\`\`json
|
|
134
|
+
${JSON.stringify(n.responseData,null,2)}
|
|
135
|
+
\`\`\`
|
|
136
|
+
`;else{let l=n.responseSize?$r(n.responseSize):"Unknown size";a+=`_Payload omitted (${l}). Exceeds ${e.bodySizeThreshold}KB threshold._
|
|
137
|
+
`}return a+=`
|
|
138
|
+
---
|
|
139
|
+
`,a}).join(`
|
|
140
|
+
`);return`# Network Requests (${r.length} total)
|
|
141
|
+
|
|
142
|
+
`+o}import{Fragment as eu,jsx as ye,jsxs as At}from"react/jsx-runtime";function Ki({activeStatus:t,onToggleStatus:e,ignoredPatterns:r,paused:o}){let i=en({ignoredPatterns:r,paused:o});return ye(Yi,{counts:i,activeStatus:t,onToggleStatus:e})}function Yi({counts:t,activeStatus:e,onToggleStatus:r}){return At(u,{style:ne.headerChipRow,children:[At(D,{style:[ne.headerChip,e==="success"&&ne.headerChipActive],onPress:()=>r("success"),children:[ye(Ud,{size:12,color:kt.semantic.success}),ye(f,{style:[ne.headerChipValue,{color:kt.semantic.success}],children:t.successful})]}),At(D,{style:[ne.headerChip,e==="error"&&ne.headerChipActive],onPress:()=>r("error"),children:[ye(jd,{size:12,color:kt.semantic.error}),ye(f,{style:[ne.headerChipValue,{color:kt.semantic.error}],children:t.failed})]}),At(D,{style:[ne.headerChip,e==="pending"&&ne.headerChipActive],onPress:()=>r("pending"),children:[ye(Xd,{size:12,color:kt.semantic.warning}),ye(f,{style:[ne.headerChipValue,{color:kt.semantic.warning}],children:t.pending})]})]})}function Qi({paused:t}){let e=ji({paused:t});return ye(D,{"sentry-label":"ignore clear events",testID:"buoy-network-clear",accessibilityLabel:"Clear network requests",accessibilityRole:"button",onPress:()=>$.clearEvents(),style:[ne.headerActionButton,!e&&ne.headerActionButtonDisabled],disabled:!e,children:ye(Kd,{size:14,color:e?se.color.textSecondary:se.color.textTertiary})})}function Zd({onPress:t}){let{savedRecords:e}=tt(),r=e.length;return At(D,{"sentry-label":"ignore open saved",onPress:t,accessibilityLabel:"Saved requests",style:ne.headerActionButton,children:[ye(Gi,{size:14,color:r>0?se.color.accent:se.color.textSecondary}),r>0?ye(u,{style:ne.savedBadge,children:ye(f,{style:ne.savedBadgeText,children:r>99?"99+":r})}):null]})}function tn({isPro:t,onUpgradePress:e}){let r=Yt(),o=tt(),{pinned:i,saved:n}=Kt(o,r),s=Qd("network.saved"),a=!i&&o.pinnedEvents.length>=mr,l=!n&&o.savedRecords.length>=s,p=()=>r?$.getEvents().find(O=>O.id===r)??ee.getEventById(r):null,c=()=>{let O=p();O&&o.togglePin(O)},x=()=>{if(l&&!t){e();return}let O=p();O&&o.toggleSave(O)};return At(eu,{children:[ye(D,{"sentry-label":"ignore pin request",onPress:c,disabled:a,testID:"buoy-network-pin",accessibilityRole:"button",accessibilityLabel:i?"Unpin request":"Pin request",accessibilityHint:a?`Pin limit reached (${mr})`:void 0,style:[ne.headerActionButton,i&&ne.headerActionButtonActive,a&&ne.headerActionButtonDisabled],children:ye(Gd,{size:14,active:i,color:i?se.color.accent:a?se.color.textTertiary:se.color.textSecondary})}),ye(D,{"sentry-label":"ignore save request",onPress:x,disabled:l&&t,testID:"buoy-network-save",accessibilityRole:"button",accessibilityLabel:n?"Remove from saved":"Save request",accessibilityHint:l&&t?`Saved limit reached (${_e})`:void 0,style:[ne.headerActionButton,n&&ne.headerActionButtonSaved,l&&t&&ne.headerActionButtonDisabled],children:ye(Gi,{size:14,color:n?se.color.accent:l&&t?se.color.textTertiary:se.color.textSecondary})})]})}function Zi({isPro:t,filter:e,ignoredPatterns:r,copySettings:o,paused:i,onUpgradePress:n,label:s}){let a=Xi({filter:e,ignoredPatterns:r,paused:i});return t?ye(Yd,{value:()=>jr(lt(dt($.getEvents(),r),e),o),size:14,label:s,buttonStyle:s?ne.copyMenuRow:ne.headerActionButton,labelStyle:ne.copyMenuLabel,colors:{idle:a?se.color.textSecondary:se.color.textTertiary,success:kt.semantic.success,error:kt.semantic.error},disabled:!a}):At(D,{"sentry-label":"ignore copy pro",onPress:n,style:[s?ne.copyMenuRow:ne.headerActionButton,!a&&ne.headerActionButtonDisabled],disabled:!a,children:[ye(Jd,{size:14,color:a?se.color.textSecondary:se.color.textTertiary}),s?ye(f,{style:ne.copyMenuLabel,children:s}):null]})}var ne=K.create({copyMenuRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:6,paddingVertical:11,justifyContent:"flex-start"},copyMenuLabel:{fontSize:13,fontWeight:"600",color:se.color.text},headerChipRow:{flexDirection:"row",alignItems:"center",gap:8},headerChip:{flexDirection:"row",alignItems:"center",gap:4,backgroundColor:se.color.buttonSurface,paddingHorizontal:10,paddingVertical:5,borderRadius:12,borderWidth:1,borderColor:se.color.border},headerChipActive:{backgroundColor:se.color.accentSoft,borderColor:se.color.accentBorderStrong},headerChipValue:{fontSize:12,fontWeight:"600",fontFamily:Ji},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:se.color.buttonSurface,borderWidth:1,borderColor:se.color.border,alignItems:"center",justifyContent:"center"},headerActionButtonDisabled:{opacity:.55},headerActionButtonActive:{backgroundColor:se.color.accentSoft,borderColor:se.color.accentBorderStrong},headerActionButtonSaved:{backgroundColor:se.color.accentSoft,borderColor:se.color.accentBorderStrong},savedBadge:{position:"absolute",top:-3,right:-3,minWidth:14,height:14,paddingHorizontal:3,borderRadius:7,backgroundColor:se.color.accent,alignItems:"center",justifyContent:"center"},savedBadgeText:{color:se.color.onAccent,fontSize:9,fontWeight:"700",fontFamily:Ji}});g();he();import{useCallback as Pu}from"react";import{FlaskConical as Lu,Pin as Bu,Power as qu,macOSColors as ve,ToolEmptyState as Mu,resolveListEmptyState as Du,EVENT_LIST_PRESET as Au,monoFont as Hu}from"@buoy-gg/shared-ui/web";g();he();import{memo as tu}from"react";import{ChevronRight as ru,Upload as ou,Download as nu,Clock as iu,AlertCircle as su,Bookmark as au,FlaskConical as lu,Pin as du,DevToolsCard as uu,MethodBadge as cu,TypeBadge as pu,night as Te,macOSColors as Qt,monoFont as rn}from"@buoy-gg/shared-ui/web";import{formatRelativeTime as fu}from"@buoy-gg/shared-ui/web";import{jsx as de,jsxs as ot}from"react/jsx-runtime";function gu(t,e){return e?Qt.semantic.error:t?t>=200&&t<300?Qt.semantic.success:t>=300&&t<400?Qt.semantic.info:t>=400?Qt.semantic.error:Qt.text.muted:Qt.semantic.warning}function mu(t){let e=t?.["content-type"]||t?.["Content-Type"]||"";return e.includes("json")?"JSON":e.includes("xml")?"XML":e.includes("html")?"HTML":e.includes("text")?"TEXT":e.includes("image")?"IMG":e.includes("video")?"VIDEO":e.includes("audio")?"AUDIO":e.includes("form")?"FORM":null}function es(t){switch(t){case"fetch":return{backgroundColor:"rgba(74, 144, 226, 0.15)",color:"#4A90E2"};case"graphql":return{backgroundColor:"rgba(229, 53, 171, 0.15)",color:"#E535AB"};case"grpc-web":return{backgroundColor:"rgba(16, 185, 129, 0.15)",color:"#10B981"};case"xhr":return{backgroundColor:"rgba(245, 158, 11, 0.15)",color:"#F59E0B"};default:return{backgroundColor:"rgba(147, 51, 234, 0.15)",color:"#9333EA"}}}function hu({event:t,isPending:e,statusColor:r}){return e?ot(u,{style:fe.pendingBadge,children:[de(iu,{size:10,color:Te.color.warning}),de(f,{style:fe.pendingText,children:"..."})]}):t.error?ot(u,{style:fe.errorBadge,children:[de(su,{size:10,color:Te.color.danger}),de(f,{style:fe.errorText,children:"ERR"})]}):de(u,{style:fe.statusBadge,children:de(f,{style:[fe.statusText,{color:r}],children:String(t.status)})})}function yu({requestSize:t,responseSize:e}){return!t&&!e?null:ot(u,{style:fe.sizeRow,children:[t?ot(u,{style:fe.sizeItem,children:[de(ou,{size:8,color:Te.color.info}),de(f,{style:fe.sizeText,children:Xe(t)})]}):null,e?ot(u,{style:fe.sizeItem,children:[de(nu,{size:8,color:Te.color.accent}),de(f,{style:fe.sizeText,children:Xe(e)})]}):null]})}function bu({timestamp:t,duration:e}){let r=cr(),o=fu(t,r);return e?ot(f,{style:fe.bottomRightText,children:[Jt(e)," ",o]}):de(f,{style:fe.bottomRightText,children:o})}var xt=tu(function({event:e,onPress:r,pinned:o=!1,saved:i=!1,overridden:n=!1,onLongPress:s}){let a=gu(e.status,e.error),l=!e.status&&!e.error,p=mu(e.responseHeaders),c=e.path||e.url.replace(/^https?:\/\/[^/]+/,"");return e.requestClient==="graphql"?e.operationName?c=Hr(e.operationName,e.graphqlVariables):c=c.replace(/\/graphql[^?]*/,"/graphql"):e.operationName&&(c=`${c}
|
|
143
|
+
(${e.operationName})`),ot(uu,{onPress:()=>r(e),onLongPress:s?()=>s(e):void 0,style:fe.cardWrapper,contentStyle:[fe.container,{borderLeftColor:a}],testID:`buoy-network-row-${e.id}`,accessibilityLabel:`${e.method} ${e.path||e.url}`,children:[ot(u,{style:fe.topRightContainer,children:[o?de(du,{size:10,active:!0,color:Te.color.info}):null,i?de(au,{size:10,color:Te.color.accent}):null,n||e.override?de(lu,{size:10,color:Te.color.warning}):null,de(hu,{event:e,isPending:l,statusColor:a}),e.requestClient?de(u,{style:[fe.topRightBadge,{backgroundColor:es(e.requestClient).backgroundColor}],children:de(f,{style:[fe.clientText,{color:es(e.requestClient).color}],children:e.requestClient==="graphql"?"GQL":e.requestClient==="grpc-web"?"gRPC":e.requestClient==="xhr"?"XHR":e.requestClient})}):null]}),ot(u,{style:fe.leftSection,children:[de(cu,{method:e.method,size:"small"}),de(yu,{requestSize:e.requestSize,responseSize:e.responseSize})]}),de(u,{style:fe.middleSection,children:de(f,{style:fe.urlText,numberOfLines:2,children:c})}),ot(u,{style:fe.rightSection,children:[p?de(pu,{type:p,size:"small"}):null,de(ru,{size:14,color:Te.color.textTertiary})]}),de(u,{style:fe.bottomRightContainer,children:de(bu,{timestamp:e.timestamp,duration:e.duration})})]})});xt.displayName="NetworkEventItemCompact";var fe=K.create({cardWrapper:{marginHorizontal:8},container:{flexDirection:"row",alignItems:"center",backgroundColor:"rgba(12, 12, 12, 0.9)",borderLeftWidth:3,borderLeftColor:"transparent",borderBottomWidth:1},leftSection:{marginRight:8,alignItems:"flex-start"},topRightContainer:{position:"absolute",top:1,right:1,flexDirection:"row",alignItems:"center",gap:4},topRightBadge:{paddingHorizontal:4,paddingVertical:2,borderRadius:4},middleSection:{flex:1,justifyContent:"center",paddingRight:8},urlText:{fontSize:12,color:Te.color.text,lineHeight:16,fontFamily:rn},rightSection:{flexDirection:"row",alignItems:"center",gap:6},bottomRightContainer:{position:"absolute",bottom:4,right:8},bottomRightText:{fontSize:9,color:Te.color.textTertiary,fontFamily:rn},statusBadge:{paddingHorizontal:4,paddingVertical:1,borderRadius:3},statusText:{fontSize:10,fontWeight:"600"},pendingBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:Te.color.warningSoft,borderRadius:3},pendingText:{fontSize:10,color:Te.color.warning,fontWeight:"600"},errorBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:Te.color.dangerSoft,borderRadius:3},errorText:{fontSize:10,color:Te.color.danger,fontWeight:"600"},durationText:{fontSize:9,color:Te.color.textSecondary},sizeRow:{flexDirection:"row",gap:4,marginTop:4},sizeItem:{flexDirection:"row",alignItems:"center",gap:2},sizeText:{fontSize:8,color:Te.color.textSecondary,fontFamily:rn},clientText:{fontSize:8,fontWeight:"700",letterSpacing:.3,textTransform:"uppercase"}});g();he();import{ProBadge as wu,Zap as vu,buoyColors as wr}from"@buoy-gg/shared-ui/web";import{jsx as Xr,jsxs as on}from"react/jsx-runtime";function Jr({title:t,subtitle:e,onPress:r}){return on(D,{style:br.banner,onPress:r,activeOpacity:.8,children:[on(u,{style:br.content,children:[on(u,{style:br.left,children:[Xr(vu,{size:16,color:wr.primary}),Xr(f,{style:br.title,children:t})]}),Xr(wu,{})]}),Xr(f,{style:br.subtitle,children:e})]})}var br=K.create({banner:{backgroundColor:wr.card,borderRadius:10,borderWidth:1,borderColor:wr.primary+"40",padding:12,marginHorizontal:12,marginTop:12,marginBottom:34},content:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",marginBottom:4},left:{flexDirection:"row",alignItems:"center",gap:8},title:{color:wr.text,fontSize:13,fontWeight:"600"},subtitle:{color:wr.textMuted,fontSize:11}});g();import{useEffect as ts,useMemo as Gr,useState as Su}from"react";import{useLimit as ku}from"@buoy-gg/shared-ui/web";function Rt(t){let{filter:e,ignoredPatterns:r,paused:o,visible:i=!0,isPro:n}=t,s=ku("network.requests"),a=n?1/0:s,[l,p]=Su(()=>$.getEvents());ts(()=>{if(!i)return;if(o){p($.getEvents());return}let N=null,w=null,R=$.subscribeToEvents(S=>{w=S,N==null&&(N=requestAnimationFrame(()=>{N=null,w&&p(w),w=null}))});return()=>{R(),N!=null&&cancelAnimationFrame(N)}},[o,i]),ts(()=>$.onClear(()=>{p([])}),[]);let c=Gr(()=>dt(l,r),[l,r]),x=Gr(()=>lt(c,e),[c,e]),O=Gr(()=>{let N=new Set;return l.slice(a).forEach(w=>{N.add(w.id)}),N},[l,a]),E=Gr(()=>O.size===0?x:x.filter(N=>!O.has(N.id)),[x,O]),P=x.length-E.length;return{events:x,visibleEvents:E,hasLockedEvents:P>0,lockedEventCount:P,totalEvents:c.length}}g();import{useCallback as Zt,useSyncExternalStore as Ou}from"react";g();import{devToolsStorageKeys as rs,persistentStorage as os}from"@buoy-gg/shared-ui/web";var xu=800,Ru=3,Tu=Object.freeze([]),Cu=250,Eu=["respond","fail","delay"];function Nu(t){if(!Array.isArray(t))return[];let e=[];for(let r of t){if(!r||typeof r!="object")continue;let o=r;if(typeof o.id!="string"||typeof o.urlPattern!="string"||!o.urlPattern)continue;let i=Eu.includes(o.kind)?o.kind:"respond";e.push({id:o.id,enabled:o.enabled!==!1,name:typeof o.name=="string"?o.name:void 0,urlPattern:o.urlPattern,methods:Array.isArray(o.methods)?o.methods.filter(n=>typeof n=="string"):void 0,kind:i,status:typeof o.status=="number"?Math.min(mt,Math.max(gt,o.status)):void 0,statusText:typeof o.statusText=="string"?o.statusText:void 0,headers:o.headers&&typeof o.headers=="object"?o.headers:void 0,body:typeof o.body=="string"?o.body:void 0,failKind:o.failKind==="timeout"?"timeout":void 0,delayMs:typeof o.delayMs=="number"?o.delayMs:void 0,times:typeof o.times=="number"?o.times:null,alternate:o.alternate===!0,hits:0,seen:0,createdAt:typeof o.createdAt=="number"?o.createdAt:0})}return e.slice(0,Ue)}var nn=class{constructor(){this.rules=[];this.enabled=!0;this.listeners=new Set;this.loaded=!1;this.loadPromise=null;this.dirty=!1;this.idCounter=0;this.state={enabled:!0,rules:[],autoPaused:!1};this.launchStreak=0;this.autoPaused=!1;this.keepAlive=null;this.hitEmitTimer=null;this.engineDisabled=!1;this.remote=null;this.remoteEchoUntil=0}enableRemoteMode(e){this.remote=e,this.disableEngine()}disableRemoteMode(){this.remote=null}replaceRules(e,r=!1){this.remote&&(!r&&Date.now()<this.remoteEchoUntil||(this.enabled=e.enabled,this.rules=e.rules,this.rebuild(),this.emit()))}markLocalEdit(){this.remote&&(this.remoteEchoUntil=Date.now()+xu)}disableEngine(){this.engineDisabled=!0,this.keepAlive&&(this.keepAlive(),this.keepAlive=null,je()===0&&yt())}getState(){return this.state}getRules(){return this.engineDisabled||!this.enabled?Tu:this.rules}async fetchRuleBody(e){let r=this.rules.find(o=>o.id===e);if(!r)return null;if(!r.bodyOmitted)return r.body??null;if(!this.remote?.getRuleBody)return null;try{return await this.remote.getRuleBody(e)}catch{return null}}activeCount(){return this.enabled?this.rules.filter(e=>e.enabled&&!dr(e)).length:0}subscribe(e){return this.listeners.add(e),this.ensureLoaded(),()=>{this.listeners.delete(e)}}setEnabled(e){this.enabled!==e&&(this.remote?.setEnabled(e),this.markLocalEdit(),this.markTouched(),this.enabled=e,this.commit(this.rules))}addRule(e){if(this.rules.length>=Ue)return null;let r={...e,id:`ovr_${Date.now().toString(36)}_${++this.idCounter}`,hits:0,seen:0,createdAt:Date.now()};return this.commit([r,...this.rules]),r}upsertRule(e){this.remote?.upsertRule(e),this.markLocalEdit(),this.markTouched();let{id:r,...o}=e;return r&&this.rules.some(i=>i.id===r)?(this.updateRule(r,o),this.rules.find(i=>i.id===r)??null):this.addRule(o)}updateRule(e,r){let o=this.rules.findIndex(n=>n.id===e);if(o===-1)return;let i=[...this.rules];i[o]={...i[o],...r,hits:0,seen:0},this.commit(i)}setRuleEnabled(e,r){let o=this.rules.findIndex(n=>n.id===e);if(o===-1||this.rules[o].enabled===r)return;this.remote?.setRuleEnabled(e,r),this.markLocalEdit(),this.markTouched();let i=[...this.rules];i[o]={...i[o],enabled:r,hits:r?0:i[o].hits,seen:r?0:i[o].seen},this.commit(i)}removeRule(e){let r=this.rules.filter(o=>o.id!==e);r.length!==this.rules.length&&(this.remote?.removeRule(e),this.markLocalEdit(),this.markTouched(),this.commit(r))}clearRules(){this.rules.length!==0&&(this.remote?.clearRules(),this.markLocalEdit(),this.markTouched(),this.commit([]))}recordMatch(e){let r=this.rules.findIndex(i=>i.id===e);if(r===-1)return;let o=[...this.rules];o[r]={...o[r],seen:o[r].seen+1},this.rules=o,this.rebuild()}recordHit(e){let r=this.rules.findIndex(a=>a.id===e);if(r===-1)return;let o=this.rules[r],i=o.hits+1,n=typeof o.times=="number"&&i>=o.times,s=[...this.rules];if(s[r]={...o,hits:i,enabled:n?!1:o.enabled},n){this.commit(s);return}this.rules=s,this.rebuild(),this.scheduleHitEmit()}ensureLoaded(){return this.remote||this.loaded?Promise.resolve():this.loadPromise?this.loadPromise:(this.loadPromise=(async()=>{try{let e=await os.getItem(rs.network.overrides());if(e&&!this.dirty){let r=JSON.parse(e);this.enabled=r?.enabled!==!1,this.rules=Nu(r?.rules),this.launchStreak=typeof r?.launchStreak=="number"?r.launchStreak:0,this.applyLaunchGuard(),this.rebuild()}}catch{}finally{this.loaded=!0,this.syncKeepAlive(),this.emit()}})(),this.loadPromise)}applyLaunchGuard(){if(!this.enabled||this.activeCount()===0){this.launchStreak=0;return}this.launchStreak+=1,this.launchStreak>=Ru&&(this.enabled=!1,this.autoPaused=!0,this.launchStreak=0),this.persist()}syncKeepAlive(){let e=!this.engineDisabled&&this.activeCount()>0;if(e&&!this.keepAlive){Pr(),this.keepAlive=bt(()=>{});return}!e&&this.keepAlive&&(this.keepAlive(),this.keepAlive=null,je()===0&&yt())}scheduleHitEmit(){this.hitEmitTimer===null&&(this.hitEmitTimer=setTimeout(()=>{this.hitEmitTimer=null,this.emit()},Cu))}commit(e){this.dirty=!0,this.rules=e.slice(0,Ue),this.rebuild(),this.syncKeepAlive(),this.emit(),this.persist()}rebuild(){this.state={enabled:this.enabled,rules:this.rules,autoPaused:this.autoPaused}}markTouched(){this.launchStreak=0,this.autoPaused=!1}noteHealthyLaunch(){this.launchStreak===0&&!this.autoPaused||(this.markTouched(),this.persist(),this.rebuild(),this.emit())}persist(){this.remote||os.setItem(rs.network.overrides(),JSON.stringify({enabled:this.enabled,rules:this.rules,launchStreak:this.launchStreak})).catch(()=>{})}emit(){this.listeners.forEach(e=>e())}},U=new nn;_n({getRules:()=>U.getRules(),recordHit:t=>U.recordHit(t),recordMatch:t=>U.recordMatch(t)});function Tt(){let t=Ou(Zt(s=>U.subscribe(s),[]),()=>U.getState(),()=>U.getState()),e=Zt(s=>U.setEnabled(s),[]),r=Zt(s=>U.upsertRule(s),[]),o=Zt((s,a)=>U.setRuleEnabled(s,a),[]),i=Zt(s=>U.removeRule(s),[]),n=Zt(()=>U.clearRules(),[]);return{enabled:t.enabled,rules:t.rules,autoPaused:t.autoPaused,activeCount:U.activeCount(),setEnabled:e,upsertRule:r,setRuleEnabled:o,removeRule:i,clearRules:n,isRuleSpent:dr}}g();function ns(t,e){if(e.length===0)return[];let r=new Set(e.map(i=>i.id)),o=new Set;for(let i of e){let n;for(let s of t){if(s.override&&r.has(s.override.ruleId)){o.add(s.id);continue}Ut(i,s.url,String(s.method||"GET"))&&(s.timestamp>=i.createdAt?o.add(s.id):(!n||s.timestamp>n.timestamp)&&(n=s))}n&&o.add(n.id)}return t.filter(i=>o.has(i.id))}g();var Iu=[];function vr(t,e,r){return e.length===0?{pinned:Iu,rest:t}:{pinned:e,rest:r.size===0?t:t.filter(o=>!r.has(o.id))}}import{jsx as ke,jsxs as Ht}from"react/jsx-runtime";var zu=t=>t.id;function Vu({events:t,onEventPress:e,onLongPress:r,savedLiveIds:o,onClearPinned:i}){return t.length===0?null:Ht(u,{style:Se.pinnedSection,children:[Ht(u,{style:Se.pinnedHeader,children:[ke(Bu,{size:11,active:!0,color:ve.semantic.info}),Ht(f,{style:Se.pinnedTitle,children:["PINNED \xB7 ",t.length]}),ke(D,{onPress:i,"sentry-label":"ignore unpin all",style:Se.pinnedClear,children:ke(f,{style:Se.pinnedClearText,children:"Unpin all"})})]}),t.map(n=>ke(xt,{event:n,onPress:e,onLongPress:r,pinned:!0,saved:o.has(n.id)},n.id))]})}function Fu({events:t,onEventPress:e,onLongPress:r,savedLiveIds:o,paused:i,onTogglePaused:n}){return t.length===0?null:Ht(u,{style:[Se.overriddenSection,i&&Se.overriddenSectionOff],children:[Ht(u,{style:Se.overriddenHeader,children:[ke(Lu,{size:11,color:i?ve.text.muted:ve.semantic.warning}),ke(f,{testID:"buoy-network-overridden-strip",style:[Se.overriddenTitle,i&&Se.overriddenTitleOff],children:i?`PAUSED \xB7 ${t.length}`:`OVERRIDDEN \xB7 ${t.length}`}),ke(D,{onPress:n,"sentry-label":"ignore pause overrides",style:Se.overriddenManage,children:ke(f,{style:[Se.overriddenManageText,i&&Se.overriddenTitleOff],children:i?"Resume":"Pause"})})]}),t.map(s=>ke(xt,{event:s,onPress:e,onLongPress:r,overridden:!0,saved:o.has(s.id)},s.id))]})}function is({visible:t,paused:e,filter:r,ignoredPatterns:o,isPro:i,searchText:n,onEventPress:s,onUpgradePress:a}){let{visibleEvents:l,hasLockedEvents:p,lockedEventCount:c,totalEvents:x}=Rt({filter:r,ignoredPatterns:o,paused:e,visible:t,isPro:i}),{pinnedEvents:O,pinnedLiveIds:E,savedLiveIds:P,togglePin:N,clearPinned:w}=tt(),{rules:R,enabled:S,setEnabled:v,isRuleSpent:A}=Tt(),H=Pu(X=>{N(X)},[N]);if(!t)return null;let{pinned:L,rest:m}=vr(l,O,E),y=R.filter(X=>X.enabled&&!A(X)),k=ns([...L,...m],y),d=new Set(k.map(X=>X.id)),b=L.filter(X=>!d.has(X.id)),h=d.size?m.filter(X=>!d.has(X.id)):m,M=!e,ae=({item:X})=>ke(xt,{event:X,onPress:s,onLongPress:H,saved:P.has(X.id)}),pe=()=>b.length>0||k.length>0?null:ke(Mu,{testID:"buoy-network-empty",...Du({subject:"requests",search:n,total:x,capturing:M,waiting:{otto:"fishing",title:"No network events",message:"Network requests will appear here"},paused:{title:"No network events",message:"Enable interception to start capturing"}})}),re=()=>{if(!p)return null;let X=n.length>0,ie=X?`${c} matching ${c===1?"request":"requests"} in locked history`:`${c} requests locked`;return ke(Jr,{title:ie,subtitle:X?"Upgrade to Pro to search your full request history":"Upgrade to Pro to unlock full request history",onPress:a})};return Ht(u,{style:Se.root,children:[M?null:Ht(u,{style:Se.disabledBanner,children:[ke(qu,{size:14,color:ve.semantic.warning}),ke(f,{style:Se.disabledText,children:"Network interception is disabled"})]}),ke(Fu,{events:k,onEventPress:s,onLongPress:H,savedLiveIds:P,paused:!S,onTogglePaused:()=>v(!S)}),ke(Vu,{events:b,onEventPress:s,onLongPress:H,savedLiveIds:P,onClearPinned:w}),h.length>0||p?ke(sr,{testID:"buoy-network-list",data:h,renderItem:ae,keyExtractor:zu,contentContainerStyle:Se.listContent,showsVerticalScrollIndicator:!0,onEndReachedThreshold:.8,scrollEnabled:!0,...Au,extraData:P,"sentry-label":"ignore network events list",ListFooterComponent:re}):pe()]})}var Se=K.create({root:{flex:1,minHeight:0},overriddenSection:{borderBottomWidth:1,borderBottomColor:ve.semantic.warning+"44",backgroundColor:ve.semantic.warningBackground},overriddenSectionOff:{borderBottomColor:ve.border.default,backgroundColor:ve.background.card},overriddenTitleOff:{color:ve.text.muted},overriddenHeader:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:12,paddingTop:8,paddingBottom:4},overriddenTitle:{flex:1,fontSize:10,fontWeight:"700",letterSpacing:.8,color:ve.semantic.warning},overriddenManage:{paddingHorizontal:6,paddingVertical:2},overriddenManageText:{fontSize:10,fontWeight:"600",color:ve.semantic.warning},pinnedSection:{borderBottomWidth:1,borderBottomColor:ve.border.default,paddingBottom:4},pinnedHeader:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:20,paddingTop:10,paddingBottom:6},pinnedTitle:{flex:1,color:ve.semantic.info,fontSize:10,fontWeight:"700",letterSpacing:.6,fontFamily:Hu},pinnedClear:{paddingHorizontal:6,paddingVertical:2},pinnedClearText:{color:ve.text.muted,fontSize:10},disabledBanner:{flexDirection:"row",alignItems:"center",gap:8,padding:10,marginHorizontal:12,marginTop:8,backgroundColor:ve.semantic.warningBackground,borderRadius:8,borderWidth:1,borderColor:ve.semantic.warning+"20"},disabledText:{color:ve.semantic.warning,fontSize:11,flex:1},listContent:{paddingTop:8}});g();he();import{useState as _u}from"react";import{Bookmark as Wu,CopyButton as $u,Search as Uu,macOSColors as We,useLimit as ju,ToolEmptyState as Xu,resolveListEmptyState as Ju,EVENT_LIST_PRESET as Gu,monoFont as Ku}from"@buoy-gg/shared-ui/web";g();function Kr(t,e,r){let o=t.slice(0,Math.min(e,_e)),i=o.map(n=>n.event);return{events:r?lt(i,{searchText:r}):i,lockedCount:t.length-o.length}}import{jsx as it,jsxs as Yr}from"react/jsx-runtime";var Yu=t=>t.id;function sn({visible:t,isPro:e,copySettings:r,search:o,onSearchChange:i,onEventPress:n,onUpgradePress:s}){let{savedRecords:a,pinnedLiveIds:l,toggleSave:p,clearSaved:c}=tt(),x=ju("network.saved"),[O,E]=_u(""),P=o!=null&&i!=null,N=P?o:O,w=P?i:E;if(!t)return null;let{events:R,lockedCount:S}=Kr(a,x,N),v=L=>{p(L)},A=({item:L})=>it(xt,{event:L,onPress:n,onLongPress:v,saved:!0,pinned:l.has(L.id)}),H=()=>S===0?null:it(Jr,{title:`${S} saved ${S===1?"request":"requests"} locked`,subtitle:`Your plan keeps ${x}. Upgrade to Pro to unlock the rest.`,onPress:s});return Yr(u,{style:nt.root,children:[Yr(u,{style:nt.toolbar,children:[it(Wu,{size:11,color:We.semantic.debug}),Yr(f,{style:nt.toolbarTitle,children:["SAVED \xB7 ",a.length,x>=_e?"":`/${x}`]}),e?it($u,{value:()=>jr(R,r),size:13,buttonStyle:nt.toolbarButton,colors:{idle:We.text.secondary,success:We.semantic.success,error:We.semantic.error},disabled:R.length===0}):null,it(D,{onPress:c,"sentry-label":"ignore clear saved",style:nt.toolbarClear,disabled:a.length===0,children:it(f,{style:[nt.toolbarClearText,a.length===0&&nt.toolbarClearTextDisabled],children:"Clear all"})})]}),a.length>0?Yr(u,{style:nt.searchRow,children:[it(Uu,{size:13,color:We.text.secondary}),it(ft,{style:nt.searchInput,placeholder:"Search saved requests\u2026",placeholderTextColor:We.text.muted,value:N,onChangeText:w,"sentry-label":"ignore saved search",accessibilityLabel:"Search saved requests",autoCapitalize:"none",autoCorrect:!1,returnKeyType:"search"})]}):null,a.length===0||N.trim().length>0&&R.length===0&&S===0?it(Xu,{testID:"buoy-network-saved-empty",...Ju({subject:"saved requests",verb:"kept",search:a.length===0?"":N,total:a.length,waiting:{otto:"empty",title:"No saved requests",message:"Open a request and tap the bookmark to keep it here \u2014 saved requests survive Clear and app restarts."}})}):it(sr,{data:R,renderItem:A,keyExtractor:Yu,contentContainerStyle:nt.listContent,showsVerticalScrollIndicator:!0,scrollEnabled:!0,...Gu,extraData:l,"sentry-label":"ignore saved requests list",ListFooterComponent:H})]})}var nt=K.create({root:{flex:1,minHeight:0},toolbar:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:20,paddingTop:10,paddingBottom:6},toolbarTitle:{flex:1,color:We.semantic.debug,fontSize:10,fontWeight:"700",letterSpacing:.6,fontFamily:Ku},toolbarButton:{width:26,height:26,borderRadius:6,alignItems:"center",justifyContent:"center"},toolbarClear:{paddingHorizontal:6,paddingVertical:2},toolbarClearText:{color:We.text.muted,fontSize:10},toolbarClearTextDisabled:{color:We.text.disabled},searchRow:{flexDirection:"row",alignItems:"center",gap:6,marginHorizontal:12,marginBottom:8,paddingHorizontal:10,paddingVertical:5,backgroundColor:We.background.input,borderRadius:10,borderWidth:1,borderColor:We.border.default},searchInput:{flex:1,color:We.text.primary,fontSize:13,paddingVertical:2},listContent:{paddingTop:4}});g();he();import{useCallback as hc,useEffect as no,useState as yc}from"react";import{AlertCircle as bc,AlertTriangle as wc,DevToolsCard as vc,EmptyState as Sc,MethodBadge as kc,Plus as xc,Trash2 as Rc,macOSColors as te,useLimit as Tc,monoFont as Cc}from"@buoy-gg/shared-ui/web";g();he();import{useMemo as cs,useState as oo}from"react";import{ChevronDown as dc,ChevronRight as uc,macOSColors as j,useSafeAreaInsets as cc,monoFont as pc}from"@buoy-gg/shared-ui/web";g();he();import{useState as Qr,useMemo as Zr,useCallback as xr,useRef as ln,useEffect as ec,memo as to}from"react";import{displayValue as tc,buoyColors as B,monoFont as Ae}from"@buoy-gg/shared-ui/web";import{CopyButton as rc}from"@buoy-gg/shared-ui/web";import{ChevronRight as oc,ChevronDown as nc,Trash as as}from"@buoy-gg/shared-ui/web";import{CyberpunkInput as ic}from"@buoy-gg/shared-ui/web/dataViewer";g();var Ct=(t,e,r)=>{if(e.length===0)return r;if(t instanceof Map){let o=new Map(t);if(e.length===1)return o.set(e[0],r),o;let[i,...n]=e,s=o.get(i);return o.set(i,Ct(s??null,n,r)),o}if(t instanceof Set){let o=Ct(Array.from(t),e,r);return new Set(Array.isArray(o)?o:[])}if(Array.isArray(t)){let o=[...t];if(e.length===1)return o[e[0]]=r,o;let[i,...n]=e;return o[i]=Ct(o[i],n,r),o}if(t instanceof Object){let o={...t};if(e.length===1)return o[e[0]]=r,o;let[i,...n]=e;return o[i]=Ct(o[i],n,r),o}return t};g();var Et=(t,e)=>{if(t instanceof Map){let r=new Map(t);if(e.length===1)return r.delete(e[0]),r;let[o,...i]=e;return r.set(o,Et(r.get(o),i)),r}if(t instanceof Set){let r=Et(Array.from(t),e);return new Set(r)}if(Array.isArray(t)){let r=[...t];if(e.length===1)return r.filter((n,s)=>s.toString()!==e[0]);let[o,...i]=e;return r[o]=Et(r[o],i),r}if(t instanceof Object){let r={...t};if(e.length===1)return delete r[e[0]],r;let[o,...i]=e;return r[o]=Et(r[o],i),r}return t};g();import{createContext as Qu,useContext as Zu}from"react";var an=Qu(null);function Sr(){return Zu(an)}import{Fragment as eo,jsx as Y,jsxs as Le}from"react/jsx-runtime";var kr=100,er={top:8,bottom:8,left:8,right:8},ss=12,sc=(t,e=kr)=>{if(e<1||t.length===0)return[];let r=[];for(let o=0;o<t.length;o+=e)r.push(t.slice(o,o+e));return r},dn=to(({expanded:t,isFocused:e=!1,isMain:r=!1})=>Y(u,{style:[_.expanderIcon,r&&_.expanderIconMain,t?_.expanded:_.collapsed],children:t?Y(nc,{size:r?14:ss,color:e?B.primary:r?B.text:B.textSecondary,strokeWidth:2.5}):Y(oc,{size:r?14:ss,color:e?B.primary:r?B.text:B.textSecondary,strokeWidth:2.5})}));dn.displayName="Expander";var ls=to(({value:t,isFocused:e=!1})=>Y(rc,{value:t,isFocused:e,buttonStyle:e?{..._.buttonStyle,..._.buttonStyleFocused}:_.buttonStyle}));ls.displayName="CopyButton";var un=to(({dataPath:t,isFocused:e=!1})=>{let r=Sr(),o=xr(()=>{r&&r.onChange(Et(r.root,t))},[r,t]);return r?Y(D,{"sentry-label":"ignore devtools explorer delete button",onPress:o,style:[_.deleteButton,e&&_.deleteButtonFocused],accessibilityLabel:"Delete item",hitSlop:er,activeOpacity:.7,children:Y(as,{size:14,strokeWidth:2,color:e?B.error:B.error+"CC"})}):null});un.displayName="DeleteItemButton";var ds=to(({dataPath:t,isFocused:e=!1})=>{let r=Sr(),o=xr(()=>{r&&r.onChange(Ct(r.root,t,[]))},[r,t]);return r?Y(D,{"sentry-label":"ignore devtools explorer clear button",style:[_.clearButton,e&&_.clearButtonFocused],"aria-label":"Remove all items",onPress:o,hitSlop:er,activeOpacity:.7,children:Y(f,{style:[_.clearButtonText,{color:e?B.warning:B.warning+"CC"}],children:"[]"})}):null});ds.displayName="ClearArrayButton";function ac({dataPath:t,value:e,itemsDeletable:r}){let o=Sr(),i=xr(()=>{if(!o)return;let l=typeof e=="boolean"?e:!1;o.onChange(Ct(o.root,t,!l))},[o,t,e]),n=xr(()=>{o&&o.onChange(Et(o.root,t))},[o,t]);if(!o)return null;let s=e?_.toggleBadgeTrue:_.toggleBadgeFalse,a=e?_.toggleTextTrue:_.toggleTextFalse;return Le(D,{"sentry-label":"ignore devtools explorer toggle button",style:_.modernToggleButton,onPress:i,hitSlop:er,activeOpacity:.8,children:[Y(u,{style:[_.toggleBadge,s],children:Y(f,{style:[_.toggleBadgeText,a],children:e?"TRUE":"FALSE"})}),r&&Y(D,{"sentry-label":"ignore devtools explorer delete button in toggle",onPress:n,style:_.deleteButtonInToggle,accessibilityLabel:"Delete item",hitSlop:er,activeOpacity:.7,children:Y(as,{size:14,strokeWidth:2,color:B.error+"CC"})})]})}function Rr({editable:t,label:e,value:r,defaultExpanded:o,dataPath:i,itemsDeletable:n,dataVersion:s=0}){let a=Sr(),[l,p]=Qr(!1),[c,x]=Qr("");ec(()=>{if(r!=null&&(typeof r=="string"||typeof r=="number")){let d=r.toString();x(d)}},[r,e,s]);let O=Zr(()=>{let d=e.toUpperCase();return["DATA","QUERY","QUERYKEY","TYPES","STATS","OPTIONS","OBSERVERS"].includes(d)},[e]),[E,P]=Qr((o||[]).includes(e)),N=()=>P(d=>!d),[w,R]=Qr([]),S=Zr(()=>r==null||typeof r!="object"?[]:Array.isArray(r)?(r.length>1e3?r.slice(0,1e3):r).map((h,M)=>({label:M.toString(),value:h})):r instanceof Map?Array.from(r.entries()).slice(0,1e3).map(([h,M])=>({label:h.toString(),value:M})):r instanceof Set?Array.from(r).slice(0,1e3).map((h,M)=>({label:M.toString(),value:h})):Object.entries(r).slice(0,1e3).map(([b,h])=>({label:b,value:h})),[r]),v=Zr(()=>Array.isArray(r)?"array":r===null||typeof r!="object"?typeof r:r instanceof Map||r instanceof Set?"Iterable":"object",[r]),A=Zr(()=>sc(S,kr),[S]),H=i??[],L=ln(a),m=ln(H),y=ln(v);L.current=a,m.current=H,y.current=v;let k=xr((d,b)=>{x(b);let h=L.current;if(!h||d&&isNaN(Number(b)))return;let M=y.current==="number"?Number(b):b;h.onChange(Ct(h.root,m.current,M))},[x]);return Y(u,{style:_.minWidthWrapper,children:Le(u,{style:_.fullWidthMarginRight,children:[A.length>0&&Le(eo,{children:[Le(u,{style:[_.flexRowItemsCenterGap,O&&_.flexRowItemsCenterGapMain],children:[Le(D,{"sentry-label":"ignore devtools explorer expander button",style:_.expanderButton,onPress:N,hitSlop:er,activeOpacity:.6,children:[Y(dn,{expanded:E,isFocused:l,isMain:O}),Y(f,{style:[_.labelText,l&&_.labelTextFocused,O&&_.labelTextMain],children:e}),Y(f,{style:_.textGray500,children:`${String(v).toLowerCase()==="iterable"?"(Iterable) ":""}${S.length} ${S.length>1?"items":"item"}`})]}),t&&Le(u,{style:_.flexRowGapItemsCenter,children:[Y(ls,{value:r,isFocused:l}),n&&a!==null&&Y(un,{dataPath:H,isFocused:l}),v==="array"&&a!==null&&Y(ds,{dataPath:H,isFocused:l})]})]}),E&&Le(eo,{children:[A.length===1&&Y(u,{style:[_.singleEntryContainer,O&&_.singleEntryContainerMain],children:S.map((d,b)=>Y(Rr,{defaultExpanded:o,label:d.label,value:d.value,editable:t,dataPath:[...H,d.label],itemsDeletable:v==="array"||v==="Iterable"||v==="object",dataVersion:s},d.label+b))}),A.length>1&&Y(u,{style:_.multiEntryContainer,children:A.map((d,b)=>Y(u,{children:Le(u,{style:_.relativeOutlineNone,children:[Le(D,{"sentry-label":"ignore devtools explorer page toggle",onPress:()=>R(h=>h.includes(b)?h.filter(M=>M!==b):[...h,b]),style:_.pageExpanderButton,hitSlop:er,children:[Y(dn,{expanded:w.includes(b)}),Le(f,{style:_.pageRangeText,children:["[",b*kr,"...",b*kr+kr-1,"]"]})]}),w.includes(b)&&Y(u,{style:_.entriesContainer,children:d.map(h=>Y(Rr,{defaultExpanded:o,label:h.label,value:h.value,editable:t,dataPath:[...H,h.label],dataVersion:s},h.label))})]})},b))})]})]}),A.length===0&&Le(u,{style:_.flexRowGapFullWidth,children:[t&&a!==null&&(v==="string"||v==="number"||v==="boolean")?Le(eo,{children:[t&&a&&(v==="string"||v==="number")&&Y(u,{style:_.nebulaInputWrapper,children:Y(ic,{label:e,accessibilityLabel:"Data input field for editing values",style:[v==="number"?_.textNumber:_.textString],keyboardType:v==="number"?"numeric":"default",value:c,onChangeText:d=>k(v==="number",d),onFocus:()=>p(!0),onBlur:()=>p(!1),showNumberControls:v==="number",onIncrement:()=>{let d=Number(c)||0;k(!0,String(d+1))},onDecrement:()=>{let d=Number(c)||0;k(!0,String(d-1))},showDeleteButton:n,onDelete:()=>{a.onChange(Et(a.root,H))}})}),v==="boolean"&&Le(u,{style:_.booleanRowContainer,children:[Y(f,{style:_.booleanLabel,children:e}),Y(u,{style:_.booleanToggleWrapper,children:Y(ac,{dataPath:H,value:r,itemsDeletable:n})})]})]}):Le(eo,{children:[Y(f,{style:_.text344054,children:e}),Y(f,{style:_.displayValueText,children:tc(r)})]}),t&&n&&a!==null&&v!=="string"&&v!=="number"&&v!=="boolean"&&Y(un,{dataPath:H,isFocused:l})]})]})})}var _=K.create({buttonStyle:{backgroundColor:B.card+"E6",borderWidth:1,borderColor:B.textSecondary+"33",borderRadius:6,flexDirection:"row",alignItems:"center",justifyContent:"center",width:28,height:28,position:"relative",shadowColor:"#000",shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2},buttonStyleFocused:{borderColor:B.primary+"CC",backgroundColor:B.primary+"26",shadowColor:B.primary,shadowOpacity:.3,shadowRadius:4},deleteButton:{backgroundColor:B.error+"1A",borderColor:B.error+"4D",borderWidth:1,borderRadius:6,padding:0,alignItems:"center",justifyContent:"center",width:28,height:28,position:"relative",shadowColor:B.error,shadowOffset:{width:0,height:0},shadowOpacity:.15,shadowRadius:3},deleteButtonFocused:{borderColor:B.error+"CC",backgroundColor:B.error+"33",shadowOpacity:.3,shadowRadius:5},deleteButtonInToggle:{backgroundColor:B.error+"1A",borderColor:B.error+"4D",borderWidth:1,borderRadius:6,padding:0,alignItems:"center",justifyContent:"center",width:28,height:28,shadowColor:B.error,shadowOffset:{width:0,height:0},shadowOpacity:.15,shadowRadius:3},clearButton:{backgroundColor:B.warning+"1A",borderWidth:1,borderColor:B.warning+"4D",borderRadius:6,flexDirection:"row",padding:0,alignItems:"center",justifyContent:"center",width:28,height:28,position:"relative",zIndex:10,shadowColor:B.warning,shadowOffset:{width:0,height:0},shadowOpacity:.15,shadowRadius:3},clearButtonFocused:{borderColor:B.warning+"CC",backgroundColor:B.warning+"33",shadowOpacity:.3,shadowRadius:5},clearButtonText:{fontSize:12,fontWeight:"700",fontFamily:Ae},expanderIcon:{width:18,height:18,alignItems:"center",justifyContent:"center",marginRight:1,backgroundColor:B.textSecondary+"14",borderRadius:3},expanderIconMain:{backgroundColor:B.textSecondary+"1A",width:20,height:20,borderRadius:4,borderWidth:.5,borderColor:B.textSecondary+"33"},expanded:{transform:[{rotate:"0deg"}]},collapsed:{transform:[{rotate:"0deg"}]},minWidthWrapper:{minWidth:180,fontSize:11,flexDirection:"row",flexWrap:"wrap",width:"100%",marginVertical:.5},fullWidthMarginRight:{position:"relative",width:"100%",marginRight:1},flexRowItemsCenterGap:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingVertical:3,paddingHorizontal:6,marginVertical:1,borderRadius:4,backgroundColor:B.card+"66",borderWidth:.5,borderColor:B.textSecondary+"1A"},flexRowItemsCenterGapMain:{backgroundColor:B.card+"E6",borderLeftWidth:2.5,borderLeftColor:B.textSecondary+"80",borderColor:B.textSecondary+"26",paddingVertical:5,paddingHorizontal:8,marginBottom:3,borderWidth:1,shadowColor:"#000",shadowOffset:{width:0,height:0},shadowOpacity:.08,shadowRadius:3},expanderButton:{flexDirection:"row",alignItems:"center",backgroundColor:"transparent",paddingVertical:1,paddingHorizontal:2,gap:6,borderWidth:0,minHeight:24,flex:1},labelText:{color:B.textSecondary,fontSize:10,fontWeight:"600",marginRight:4,fontFamily:Ae,letterSpacing:.4},labelTextFocused:{color:B.text},labelTextMain:{color:B.text,fontSize:11,fontWeight:"700",letterSpacing:.6},textGray500:{color:B.textMuted,fontSize:10,fontWeight:"400",fontFamily:Ae,opacity:.7},pageRangeText:{color:B.textSecondary,fontSize:10,fontWeight:"600",fontFamily:Ae},flexRowGapItemsCenter:{flexDirection:"row",alignItems:"center",gap:4,paddingLeft:2},singleEntryContainer:{marginLeft:2,marginTop:2,paddingLeft:8,borderLeftWidth:1.5,borderLeftColor:B.textSecondary+"40"},singleEntryContainerMain:{borderLeftColor:B.textSecondary+"4D",marginLeft:4,paddingLeft:10},multiEntryContainer:{marginLeft:2,marginTop:2,paddingLeft:8,borderLeftWidth:1.5,borderLeftColor:B.textSecondary+"40"},multiEntryContainerMain:{borderLeftColor:B.textSecondary+"4D",marginLeft:4,paddingLeft:10},relativeOutlineNone:{position:"relative"},pageExpanderButton:{flexDirection:"row",alignItems:"center",backgroundColor:B.card+"66",paddingVertical:3,paddingHorizontal:6,gap:6,borderRadius:4,borderWidth:.5,borderColor:B.textSecondary+"1A",marginBottom:2,minHeight:24},entriesContainer:{marginLeft:2,paddingLeft:8,marginTop:2,borderLeftWidth:1.5,borderLeftColor:B.textSecondary+"40"},textNumber:{color:B.text,fontWeight:"600",fontFamily:Ae},textString:{color:B.text,fontFamily:Ae},flexRowGapFullWidth:{flexDirection:"row",width:"100%",alignItems:"center",marginVertical:1,gap:6,paddingHorizontal:4,paddingVertical:2,borderRadius:3},text344054:{color:B.textSecondary,fontWeight:"600",fontSize:9,minWidth:50,fontFamily:Ae,letterSpacing:.4,opacity:.8},numberInputButtons:{position:"absolute",right:8,top:"50%",transform:[{translateY:-18}],flexDirection:"row",gap:4,zIndex:10},touchableButton:{width:32,height:32,borderRadius:6,backgroundColor:B.card+"E6",borderWidth:1,borderColor:B.textSecondary+"33",alignItems:"center",justifyContent:"center",marginLeft:2,shadowColor:"#000",shadowOffset:{width:0,height:1},shadowOpacity:.2,shadowRadius:2},touchableButtonFocused:{borderColor:B.primary+"CC",backgroundColor:B.primary+"26",shadowColor:B.primary,shadowOffset:{width:0,height:0},shadowOpacity:.3,shadowRadius:4,elevation:3},nebulaInputWrapper:{flex:1,width:"100%",position:"relative"},displayValueText:{flex:1,color:B.text,fontWeight:"400",fontFamily:Ae,fontSize:12,paddingVertical:6,paddingHorizontal:10,borderRadius:6,borderWidth:1,borderColor:B.textMuted+"66",minHeight:34},dataRow:{flexDirection:"row",alignItems:"center",paddingVertical:4,paddingHorizontal:8,minHeight:44,gap:12},dataLabel:{color:B.textSecondary,fontSize:13,fontWeight:"500",minWidth:80,flexShrink:0},dataValueContainer:{flex:1,flexDirection:"row",alignItems:"center"},inputWithActions:{flex:1,position:"relative"},numberControls:{position:"absolute",right:8,top:"50%",transform:[{translateY:-16}],flexDirection:"column",gap:2},numberButton:{width:32,height:16,borderRadius:4,alignItems:"center",justifyContent:"center",borderWidth:1,borderColor:B.primary+"0F"},readOnlyValue:{color:B.text,fontSize:13,fontFamily:Ae,paddingVertical:8,paddingHorizontal:12,borderRadius:6,borderWidth:1,borderColor:B.textMuted+"33",flex:1},actionButtons:{flexDirection:"row",gap:6,paddingLeft:8},booleanContainer:{flexDirection:"row",alignItems:"center",padding:8,borderRadius:6,borderWidth:1,borderColor:B.textMuted+"4D",flex:1},booleanText:{marginLeft:8,color:B.warning,fontWeight:"500",fontFamily:Ae},modernToggleButton:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",borderRadius:6,borderWidth:1,borderColor:B.textMuted+"99",paddingHorizontal:8,paddingVertical:6,marginVertical:2,minHeight:34,gap:8},toggleIconContainer:{marginRight:6},toggleIcon:{padding:8,borderRadius:8,alignItems:"center",justifyContent:"center",width:32,height:32},toggleIconSmall:{width:8,height:8,borderRadius:4},toggleContent:{flex:1,minWidth:0},toggleLabel:{color:"#E5E7EB",fontSize:11,fontWeight:"600",fontFamily:Ae,letterSpacing:.3},toggleStatus:{color:"#9CA3AF",fontSize:11},toggleBadge:{marginLeft:6,paddingHorizontal:6,paddingVertical:3,borderRadius:4,borderWidth:1},toggleBadgeText:{fontSize:9,fontWeight:"700",textTransform:"uppercase",letterSpacing:.8,fontFamily:Ae},toggleIconTrue:{backgroundColor:B.primary},toggleIconFalse:{backgroundColor:B.textMuted},toggleBadgeTrue:{backgroundColor:B.primary+"1A",borderColor:B.primary+"4D"},toggleBadgeFalse:{backgroundColor:B.textMuted+"1A",borderColor:B.textMuted+"4D"},toggleTextTrue:{color:B.primary,fontWeight:"600"},toggleTextFalse:{color:B.textSecondary,fontWeight:"500"},booleanRowContainer:{flexDirection:"row",alignItems:"center",width:"100%",gap:8,paddingVertical:2},booleanLabel:{color:B.textSecondary,fontSize:10,fontWeight:"600",fontFamily:Ae,letterSpacing:.4,minWidth:60,flexShrink:0},booleanToggleWrapper:{flex:1}});g();he();import{useState as lc}from"react";import{absoluteFill as us,macOSColors as Be}from"@buoy-gg/shared-ui/web";import{jsx as Nt,jsxs as cn}from"react/jsx-runtime";function ro({title:t,hint:e,value:r,placeholder:o="Number",min:i,max:n,onSubmit:s,onCancel:a}){let[l,p]=lc(r!=null?String(r):""),c=()=>{let x=l.trim();if(!x){s(null);return}let O=Number(x);if(!Number.isFinite(O)){s(null);return}let E=O;i!=null&&(E=Math.max(i,E)),n!=null&&(E=Math.min(n,E)),s(E)};return cn(u,{style:He.overlay,children:[Nt(D,{style:He.backdrop,activeOpacity:1,onPress:a,"sentry-label":"ignore dismiss number prompt"}),cn(u,{style:He.panel,children:[Nt(f,{style:He.title,children:t}),Nt(ft,{style:He.input,value:l,onChangeText:p,placeholder:o,placeholderTextColor:Be.text.muted,keyboardType:"number-pad",autoFocus:!0,selectTextOnFocus:!0,onSubmitEditing:c,returnKeyType:"done","sentry-label":"ignore number prompt input",accessibilityLabel:t}),e?Nt(f,{style:He.hint,children:e}):null,cn(u,{style:He.actions,children:[Nt(D,{onPress:a,"sentry-label":"ignore cancel number prompt",style:[He.button,He.cancelButton],children:Nt(f,{style:He.cancelText,children:"Cancel"})}),Nt(D,{onPress:c,"sentry-label":"ignore save number prompt",style:[He.button,He.saveButton],children:Nt(f,{style:He.saveText,children:"Set"})})]})]})]})}var He=K.create({overlay:{...us,zIndex:40},backdrop:{...us,backgroundColor:"rgba(0,0,0,0.6)"},panel:{marginHorizontal:12,marginTop:12,padding:14,borderRadius:10,borderWidth:1,borderColor:Be.border.hover,backgroundColor:Be.background.card,gap:10},title:{fontSize:13,fontWeight:"700",color:Be.text.primary},input:{backgroundColor:Be.background.input,borderWidth:1,borderColor:Be.border.input,borderRadius:6,paddingHorizontal:12,paddingVertical:10,fontSize:16,fontWeight:"700",color:Be.text.primary},hint:{fontSize:10,color:Be.text.muted},actions:{flexDirection:"row",gap:8},button:{flex:1,paddingVertical:10,borderRadius:6,alignItems:"center",borderWidth:1},cancelButton:{borderColor:Be.border.default,backgroundColor:Be.background.base},cancelText:{fontSize:12,fontWeight:"600",color:Be.text.secondary},saveButton:{borderColor:Be.semantic.info,backgroundColor:`${Be.semantic.info}22`},saveText:{fontSize:12,fontWeight:"700",color:Be.semantic.info}});import{Fragment as ms,jsx as W,jsxs as Ce}from"react/jsx-runtime";var fc=["GET","POST","PUT","PATCH","DELETE"],ps=[0,500,1e3,3e3,1e4],fs=[{id:"500",label:"Server error",code:"500",danger:!0,patch:{kind:"respond",status:500,statusText:"Internal Server Error"}},{id:"401",label:"Unauthorized",code:"401",danger:!0,patch:{kind:"respond",status:401,statusText:"Unauthorized"}},{id:"404",label:"Not found",code:"404",danger:!0,patch:{kind:"respond",status:404,statusText:"Not Found"}},{id:"403",label:"Forbidden",code:"403",danger:!0,patch:{kind:"respond",status:403,statusText:"Forbidden"}},{id:"429",label:"Rate limited",code:"429",danger:!0,patch:{kind:"respond",status:429,statusText:"Too Many Requests"}},{id:"503",label:"Unavailable",code:"503",danger:!0,patch:{kind:"respond",status:503,statusText:"Service Unavailable"}},{id:"400",label:"Bad request",code:"400",danger:!0,patch:{kind:"respond",status:400,statusText:"Bad Request"}},{id:"200",label:"Success",code:"200",patch:{kind:"respond",status:200,statusText:"OK"}},{id:"offline",label:"Offline",danger:!0,patch:{kind:"fail",failKind:"network"}},{id:"timeout",label:"Timeout",danger:!0,patch:{kind:"fail",failKind:"timeout"}},{id:"passthrough",label:"Real response",patch:{kind:"delay"}}];function gc(t){return t.kind==="delay"?"passthrough":t.kind==="fail"?t.failKind==="timeout"?"timeout":"offline":String(t.status??200)}function mc({outcome:t,active:e,onPress:r}){let o=t.danger?j.semantic.error:j.semantic.info;return Ce(D,{onPress:r,"sentry-label":"ignore override outcome",testID:`buoy-network-outcome-${t.label.toLowerCase().replace(/\s+/g,"-")}${t.code?`-${t.code}`:""}`,accessibilityRole:"button",accessibilityLabel:`${t.label}${t.code?` ${t.code}`:""}`,style:[V.outcome,e&&{borderColor:o,backgroundColor:`${o}1F`}],children:[W(f,{style:[V.outcomeLabel,e&&{color:o}],children:t.label}),t.code?W(f,{style:[V.outcomeCode,e&&{color:o}],children:t.code}):null]})}function gs({title:t,summary:e,open:r,onToggle:o,children:i}){return Ce(u,{style:V.disclosure,children:[Ce(D,{onPress:o,"sentry-label":"ignore override disclosure",testID:`buoy-network-disclosure-${t.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:t,style:V.disclosureHeader,children:[r?W(dc,{size:12,color:j.text.muted}):W(uc,{size:12,color:j.text.muted}),W(f,{style:V.disclosureTitle,children:t}),e&&!r?W(f,{style:V.disclosureSummary,numberOfLines:1,children:e}):null]}),r?W(u,{style:V.disclosureBody,children:i}):null]})}function tr({label:t,active:e,onPress:r}){return W(D,{onPress:r,"sentry-label":"ignore override chip",testID:`buoy-network-chip-${t.toLowerCase().replace(/\s+/g,"-")}`,accessibilityRole:"button",accessibilityLabel:t,style:[V.chip,e&&V.chipActive],children:W(f,{style:[V.chipText,e&&V.chipTextActive],children:t})})}function hs({draft:t,onChange:e,onSave:r,onCancel:o,saveLabel:i="Save",applySafeAreaInset:n=!1}){let s=cc({minBottom:16}),a=n?s.bottom:0,l=h=>e({...t,...h}),[p,c]=oo(!t.urlPattern.trim()),[x,O]=oo(!1),[E,P]=oo(null),[N,w]=oo(null),R=gc(t),S=t.kind==="respond"&&typeof t.status=="number"&&!fs.some(h=>h.code===String(t.status)),v=t.kind==="respond",A=t.methods?.[0],H=`${A??"Any"} ${t.urlPattern||"No URL yet"}`,L=cs(()=>{let h=(t.body??"").trim();if(!h)return"Empty";let M=h.split(`
|
|
144
|
+
`).length;return`${M} line${M===1?"":"s"}`},[t.body]),m=cs(()=>{let h=(t.body??"").trim();if(!h)return null;try{return JSON.parse(h)}catch{return null}},[t.body]),y=(t.body??"").trim().length>0&&!m,k=t.delayMs??0,d=k>0&&!ps.includes(k),b=!t.alternate&&typeof t.times=="number"&&t.times!==1;return Ce(u,{style:V.root,children:[Ce(Ge,{testID:"buoy-network-editor-scroll",style:V.scroll,contentContainerStyle:V.scrollContent,keyboardShouldPersistTaps:"handled",children:[Ce(gs,{title:"Applies to",summary:H,open:p,onToggle:()=>c(h=>!h),children:[W(ft,{style:V.input,value:t.urlPattern,onChangeText:h=>l({urlPattern:h}),testID:"buoy-network-override-pattern",accessibilityLabel:"Override URL pattern",placeholder:"https://api.example.com/v1/users*",placeholderTextColor:j.text.muted,autoCapitalize:"none",autoCorrect:!1,multiline:!0,"sentry-label":"ignore override url pattern"}),Ce(u,{style:V.chipRow,children:[W(tr,{label:"Any",active:!A,onPress:()=>l({methods:void 0})}),fc.map(h=>W(tr,{label:h,active:A===h,onPress:()=>l({methods:[h]})},h))]})]}),Ce(u,{style:V.outcomeGrid,children:[fs.map(h=>W(mc,{outcome:h,active:R===h.id,onPress:()=>l(h.patch)},h.id)),W(D,{onPress:()=>w("status"),"sentry-label":"ignore custom status",accessibilityLabel:"Custom status code",style:[V.customField,S&&V.customFieldActive],children:W(f,{style:[V.customValue,S&&V.customInputActive],children:S?String(t.status):"Custom"})})]}),v?W(gs,{title:"Response body",summary:L,open:x,onToggle:()=>O(h=>!h),children:E!==null?Ce(ms,{children:[W(ft,{style:[V.input,V.bodyInput],value:E,onChangeText:P,placeholder:"Paste a new body\u2026",placeholderTextColor:j.text.muted,autoCapitalize:"none",autoCorrect:!1,autoFocus:!0,multiline:!0,"sentry-label":"ignore override body paste"}),Ce(u,{style:V.inlineActions,children:[W(D,{onPress:()=>P(null),"sentry-label":"ignore cancel body paste",style:V.textButton,children:W(f,{style:V.textButtonMuted,children:"Cancel"})}),W(D,{onPress:()=>{let h=E.trim();try{l({body:JSON.stringify(JSON.parse(h),null,2)})}catch{l({body:h})}P(null)},disabled:!E.trim(),"sentry-label":"ignore apply body paste",style:V.textButton,children:W(f,{style:[V.textButtonLabel,!E.trim()&&V.textButtonDisabled],children:"Replace"})})]})]}):Ce(ms,{children:[m!==null?W(an.Provider,{value:{root:m,onChange:h=>l({body:JSON.stringify(h,null,2)})},children:W(Rr,{editable:!0,label:"",value:m,defaultExpanded:[""]})}):W(f,{style:V.emptyBody,children:y?"This body isn't JSON, so there's no tree to show.":"No body yet."}),W(D,{onPress:()=>P(""),"sentry-label":"ignore edit all body",style:V.textButton,children:W(f,{style:V.textButtonLabel,children:"Edit all"})})]})}):null,Ce(u,{style:V.field,children:[W(f,{style:V.subLabel,children:"Delay"}),Ce(u,{style:V.chipRow,children:[ps.map(h=>W(tr,{label:h===0?"None":`${h/1e3}s`,active:k===h,onPress:()=>l({delayMs:h})},h)),W(D,{onPress:()=>w("delay"),"sentry-label":"ignore custom delay",accessibilityLabel:"Custom delay in seconds",style:[V.customField,d&&V.customFieldActive],children:W(f,{style:[V.customValue,d&&V.customInputActive],children:d?`${k/1e3}s`:"Custom"})})]})]}),Ce(u,{style:V.field,children:[W(f,{style:V.subLabel,children:"Fires"}),W(f,{style:V.subHint,children:"A limited rule switches itself off once it's used up. Every other alternates forever \u2014 the first request through, the next overridden."}),Ce(u,{style:V.chipRow,children:[W(tr,{label:"Always",active:!t.alternate&&t.times==null,onPress:()=>l({alternate:!1,times:null})}),W(tr,{label:"Once",active:!t.alternate&&t.times===1,onPress:()=>l({alternate:!1,times:1})}),W(tr,{label:"Every other",active:t.alternate===!0,onPress:()=>l({alternate:!0,times:null})}),W(D,{onPress:()=>{l({alternate:!1}),w("times")},"sentry-label":"ignore custom times",accessibilityLabel:"Custom number of times",style:[V.customField,b&&V.customFieldActive],children:W(f,{style:[V.customValue,b&&V.customInputActive],children:b?`${t.times}\xD7`:"Custom"})})]})]})]}),N==="status"?W(ro,{title:"Custom status code",hint:`${gt}\u2013${mt}`,value:S?t.status:void 0,min:gt,max:mt,onSubmit:h=>{l({kind:"respond",status:h??void 0,statusText:void 0}),w(null)},onCancel:()=>w(null)}):null,N==="delay"?W(ro,{title:"Custom delay",hint:"Seconds",value:d?k/1e3:void 0,min:0,onSubmit:h=>{l({delayMs:h!=null?Math.round(h*1e3):0}),w(null)},onCancel:()=>w(null)}):null,N==="times"?W(ro,{title:"Fires how many times",hint:"Leave empty for always",value:b?t.times:void 0,min:1,onSubmit:h=>{l({alternate:!1,times:h&&h>0?h:null}),w(null)},onCancel:()=>w(null)}):null,Ce(u,{style:[V.footer,{paddingBottom:12+a}],children:[W(D,{onPress:o,"sentry-label":"ignore cancel override",testID:"buoy-network-editor-cancel",accessibilityRole:"button",accessibilityLabel:"Cancel",style:[V.footerButton,V.cancelButton],children:W(f,{style:V.cancelText,children:"Cancel"})}),W(D,{onPress:r,disabled:!t.urlPattern.trim(),"sentry-label":"ignore save override",testID:"buoy-network-editor-save",accessibilityRole:"button",accessibilityLabel:i,style:[V.footerButton,V.saveButton,!t.urlPattern.trim()&&V.saveButtonDisabled],children:W(f,{style:V.saveText,children:i})})]})]})}var V=K.create({root:{flex:1},scroll:{flex:1},scrollContent:{padding:12,paddingBottom:24,gap:4},field:{gap:8,paddingVertical:6},outcomeGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,paddingVertical:10},outcome:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:9,borderRadius:6,borderWidth:1,borderColor:j.border.default,backgroundColor:j.background.card},outcomeLabel:{fontSize:12,fontWeight:"600",color:j.text.primary},outcomeCode:{fontSize:10,fontWeight:"700",color:j.text.muted},disclosure:{borderRadius:6,borderWidth:1,borderColor:j.border.default,backgroundColor:j.background.card,overflow:"hidden"},disclosureHeader:{flexDirection:"row",alignItems:"center",gap:6,paddingHorizontal:10,paddingVertical:10},disclosureTitle:{fontSize:12,fontWeight:"600",color:j.text.primary},disclosureSummary:{flex:1,textAlign:"right",fontSize:11,color:j.text.muted},disclosureBody:{paddingHorizontal:10,paddingBottom:10,gap:8},input:{backgroundColor:j.background.input,borderWidth:1,borderColor:j.border.input,borderRadius:6,paddingHorizontal:10,paddingVertical:8,color:j.text.primary,fontSize:12,fontFamily:pc,minHeight:40},bodyInput:{minHeight:140,textAlignVertical:"top"},chipRow:{flexDirection:"row",flexWrap:"wrap",gap:6},chip:{paddingHorizontal:10,paddingVertical:6,borderRadius:5,borderWidth:1,borderColor:j.border.default,backgroundColor:j.background.base},chipActive:{borderColor:j.semantic.info,backgroundColor:`${j.semantic.info}1F`},chipText:{fontSize:11,fontWeight:"600",color:j.text.secondary},chipTextActive:{color:j.semantic.info},customField:{flexDirection:"row",alignItems:"center",paddingHorizontal:8,borderRadius:5,borderWidth:1,borderColor:j.border.default,backgroundColor:j.background.base},customFieldActive:{borderColor:j.semantic.info,backgroundColor:`${j.semantic.info}1F`},customValue:{paddingVertical:6,fontSize:11,fontWeight:"600",color:j.text.secondary},customInputActive:{color:j.semantic.info},subHint:{fontSize:10,lineHeight:14,color:j.text.muted,marginTop:-2},subLabel:{fontSize:10,fontWeight:"700",letterSpacing:.6,color:j.text.muted,textTransform:"uppercase"},textButton:{alignSelf:"flex-start",paddingVertical:4},textButtonLabel:{fontSize:11,fontWeight:"600",color:j.semantic.info},textButtonMuted:{fontSize:11,fontWeight:"600",color:j.text.secondary},textButtonDisabled:{opacity:.4},inlineActions:{flexDirection:"row",alignItems:"center",justifyContent:"space-between"},emptyBody:{fontSize:11,color:j.text.muted,paddingVertical:6},footer:{flexDirection:"row",gap:8,padding:12,borderTopWidth:1,borderTopColor:j.border.default,backgroundColor:j.background.base},footerButton:{flex:1,paddingVertical:11,borderRadius:6,alignItems:"center",borderWidth:1},cancelButton:{borderColor:j.border.default,backgroundColor:j.background.card},cancelText:{fontSize:12,fontWeight:"600",color:j.text.secondary},saveButton:{borderColor:j.semantic.info,backgroundColor:`${j.semantic.info}22`},saveButtonDisabled:{opacity:.4},saveText:{fontSize:12,fontWeight:"700",color:j.semantic.info}});import{jsx as me,jsxs as zt}from"react/jsx-runtime";function Ec(){return{enabled:!0,urlPattern:"",kind:"respond",status:500,body:"",times:null}}function Nc(t){let{id:e,hits:r,seen:o,createdAt:i,...n}=t;return n}function Oc(t){let e=t.urlPattern,r=e.indexOf("://");if(r===-1)return e;let o=e.indexOf("/",r+3);return o===-1?e.slice(r+3):e.slice(o)}function Ic(t){let e=[];return t.delayMs&&e.push(`${t.delayMs/1e3}s delay`),t.alternate?e.push("every other"):t.times===1?e.push("once"):typeof t.times=="number"&&e.push(`${t.times}\xD7`),e.join(" \xB7 ")}function Pc(t){if(t.kind==="fail")return te.semantic.error;if(t.kind==="delay")return te.semantic.info;let e=t.status??200;return e>=200&&e<300?te.semantic.success:e>=300&&e<400?te.semantic.info:te.semantic.error}function Lc({rule:t,spent:e,onEdit:r,onDelete:o}){let i=t.enabled&&!e,n=Pc(t),s=Ic(t),a=t.methods?.length?t.methods.join("/"):"ANY";return zt(vc,{onPress:r,style:ue.cardWrapper,contentStyle:[ue.card,{borderLeftColor:i?n:"transparent"}],children:[me(kc,{method:a,size:"small"}),zt(u,{style:ue.cardMiddle,children:[me(f,{style:[ue.urlText,!i&&ue.urlTextOff],numberOfLines:2,children:Oc(t)}),s?me(f,{style:ue.extrasText,children:s}):null]}),t.hits>0?me(f,{style:ue.rowHits,children:t.hits}):null,t.kind==="fail"?zt(u,{style:ue.failBadge,children:[me(bc,{size:10,color:te.semantic.error}),me(f,{style:ue.failText,children:t.failKind==="timeout"?"TIMEOUT":"OFFLINE"})]}):me(f,{style:[ue.statusText,{color:n}],children:t.kind==="delay"?"PASS":String(t.status??200)}),me(D,{onPress:o,"sentry-label":"ignore delete override rule",testID:"buoy-network-rule-delete",accessibilityRole:"button",accessibilityLabel:"Delete rule",hitSlop:{top:8,bottom:8,left:4,right:4},style:ue.rowDelete,children:me(Rc,{size:13,color:te.text.muted})})]})}function ys(t){return t.visible?me(Bc,{...t}):null}function Bc({isPro:t,onUpgradePress:e,pendingDraft:r,onPendingConsumed:o,backHandlerRef:i,applySafeAreaInset:n}){let s=Tc("network.overrideRules"),a=t?Ue:s,{enabled:l,autoPaused:p,rules:c,activeCount:x,setEnabled:O,upsertRule:E,setRuleEnabled:P,removeRule:N,isRuleSpent:w}=Tt(),[R,S]=yc(null);no(()=>{U.noteHealthyLaunch()},[]),no(()=>{if(i)return i.current=R?()=>(S(null),!0):null,()=>{i.current=null}},[i,R]);let v=hc(y=>{U.fetchRuleBody(y).then(k=>{k!=null&&S(d=>d?.id===y?{...d,draft:{...d.draft,body:k,bodyOmitted:void 0}}:d)})},[]);no(()=>{if(!r)return;let{id:y,...k}=r;S({id:y,draft:k}),y&&k.bodyOmitted&&v(y),o?.()},[r,o,v]),no(()=>{R?.id&&(c.some(y=>y.id===R.id)||S(null))},[R?.id,c]);let A=y=>{S({id:y.id,draft:Nc(y)}),y.bodyOmitted&&v(y.id)},H=y=>{c.filter(d=>d.enabled&&!w(d)).length<=a||c.filter(d=>d.enabled&&!w(d)&&d.id!==y).forEach(d=>P(d.id,!1))},L=()=>{if(!R)return;let y={...R.draft,enabled:!0,urlPattern:R.draft.urlPattern.trim()};if(!y.urlPattern)return;let k=E({...y,id:R.id});H(k?.id??R.id),O(!0),S(null)};if(R)return me(hs,{draft:R.draft,onChange:y=>S({...R,draft:y}),onSave:L,onCancel:()=>S(null),saveLabel:R.id?"Save":"Add",applySafeAreaInset:n});let m=c.length>0;return zt(u,{style:ue.root,children:[m?zt(u,{style:[ue.bar,l&&x>0&&ue.barOn],children:[l&&x>0?me(wc,{size:12,color:te.semantic.warning}):null,me(f,{style:[ue.barText,l&&x>0&&ue.barTextOn],numberOfLines:2,children:p?"Overrides paused \u2014 they'd been on for 3 launches":l&&x>0?`${x} override${x===1?" is":"s are"} on`:"Overrides are off"}),me(D,{onPress:()=>O(!(l&&x>0)),"sentry-label":"ignore toggle overrides master",testID:"buoy-network-overrides-master",accessibilityRole:"button",style:ue.barButton,children:me(f,{style:ue.barButtonText,children:l&&x>0?"Turn all off":p?"Turn back on":"Turn on"})})]}):null,zt(u,{style:ue.listHeader,children:[me(f,{style:ue.listHeaderText,children:m?`${c.length} rule${c.length===1?"":"s"}`:""}),me(D,{onPress:()=>S({draft:Ec()}),"sentry-label":"ignore new override rule",accessibilityLabel:"New override rule",style:ue.newButton,children:me(xc,{size:14,color:te.semantic.info})})]}),m?zt(Ge,{style:ue.list,contentContainerStyle:ue.listContent,keyboardShouldPersistTaps:"handled",children:[c.map(y=>me(Lc,{rule:y,spent:w(y),onEdit:()=>A(y),onDelete:()=>N(y.id)},y.id)),a<Ue?me(f,{style:ue.footNote,children:`Your plan: ${a} override at a time. Pro: up to ${Ue}.`}):null]}):me(u,{style:ue.emptyWrap,children:me(Sc,{otto:"empty",iconSize:32,title:"Nothing overridden",description:"Open any request and tap Override, or + to write a rule."})})]})}var ue=K.create({root:{flex:1},bar:{flexDirection:"row",alignItems:"center",gap:8,paddingHorizontal:12,paddingVertical:10,borderBottomWidth:1,borderBottomColor:te.border.default,backgroundColor:te.background.card},barOn:{borderBottomColor:te.semantic.warning+"44",backgroundColor:te.semantic.warningBackground},barText:{flex:1,fontSize:12,fontWeight:"600",color:te.text.secondary},barTextOn:{color:te.semantic.warning},barButton:{paddingHorizontal:10,paddingVertical:6,borderRadius:5,borderWidth:1,borderColor:te.border.hover,backgroundColor:te.background.base},barButtonText:{fontSize:11,fontWeight:"700",color:te.text.primary},listHeader:{flexDirection:"row",alignItems:"center",justifyContent:"space-between",paddingHorizontal:12,paddingTop:10,paddingBottom:4},listHeaderText:{fontSize:10,fontWeight:"700",letterSpacing:.6,color:te.text.muted,textTransform:"uppercase"},newButton:{padding:6,borderRadius:5,borderWidth:1,borderColor:te.border.default,backgroundColor:te.background.card},emptyWrap:{flex:1,justifyContent:"center"},list:{flex:1},listContent:{padding:10,gap:6},cardWrapper:{marginHorizontal:0,marginVertical:0},card:{flexDirection:"row",alignItems:"center",gap:8,borderLeftWidth:3,borderLeftColor:"transparent"},cardMiddle:{flex:1},urlText:{fontSize:12,color:te.text.primary,lineHeight:16,fontFamily:Cc},urlTextOff:{color:te.text.muted},extrasText:{fontSize:10,color:te.text.secondary,marginTop:2},statusText:{fontSize:11,fontWeight:"600"},failBadge:{flexDirection:"row",alignItems:"center",gap:2,paddingHorizontal:4,paddingVertical:1,backgroundColor:te.semantic.error+"26",borderRadius:3},failText:{fontSize:10,color:te.semantic.error,fontWeight:"600"},rowHits:{fontSize:11,fontWeight:"700",color:te.semantic.warning},rowDelete:{padding:5,borderRadius:5,borderWidth:1,borderColor:te.border.default,backgroundColor:te.background.base},footNote:{fontSize:10,lineHeight:14,color:te.text.muted,paddingHorizontal:4,paddingTop:8}});g();he();import{FlaskConical as qc,night as Vt}from"@buoy-gg/shared-ui/web";import{jsx as pn,jsxs as Mc}from"react/jsx-runtime";function bs({onPress:t}){let{activeCount:e}=Tt(),r=e>0;return Mc(D,{onPress:t,"sentry-label":"ignore open overrides",testID:"buoy-network-overrides",accessibilityRole:"button",style:[io.button,r&&io.buttonActive],accessibilityLabel:r?`Response overrides \u2014 ${e} active`:"Response overrides",children:[pn(qc,{size:14,color:r?Vt.color.warning:Vt.color.textSecondary}),r?pn(u,{style:io.badge,children:pn(f,{style:io.badgeText,children:e})}):null]})}var io=K.create({button:{width:32,height:32,borderRadius:8,alignItems:"center",justifyContent:"center",backgroundColor:Vt.color.buttonSurface,borderWidth:1,borderColor:Vt.color.border},buttonActive:{backgroundColor:Vt.color.warningSoft,borderColor:Vt.color.warning+"77"},badge:{position:"absolute",top:1,right:1,minWidth:12,height:12,borderRadius:6,paddingHorizontal:3,alignItems:"center",justifyContent:"center",backgroundColor:Vt.color.warning},badgeText:{fontSize:8,fontWeight:"800",color:"#000000"}});g();he();import{night as rr}from"@buoy-gg/shared-ui/web";g();function Dc(t){let e=t.indexOf("?");return e===-1?t:`${t.slice(0,e)}*`}function Ac(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return""}}function Tr(t){return{enabled:!0,name:void 0,urlPattern:Dc(t.url),methods:[String(t.method||"GET").toUpperCase()],kind:"respond",status:t.status&&t.status>=200?t.status:200,statusText:t.statusText,body:Ac(t.responseData),times:null}}import{jsx as ws}from"react/jsx-runtime";function vs({onOpen:t}){let e=Yt(),{rules:r,isRuleSpent:o}=Tt(),i=e?$.getEvents().find(l=>l.id===e)??ee.getEventById(e):null,n=i?r.find(l=>l.enabled&&!o(l)&&Ut(l,i.url,String(i.method||"GET")))??null:null,s=n!==null;return ws(D,{onPress:()=>{if(i){if(n){let{id:l,hits:p,seen:c,createdAt:x,...O}=n;t(O,l);return}t(Tr(i))}},"sentry-label":"ignore open overrides",testID:"buoy-network-override-request",accessibilityRole:"button",accessibilityLabel:s?"Edit the override on this request":"Override this request",style:[so.button,s&&so.buttonActive],children:ws(f,{style:[so.label,s&&so.labelActive],children:"Override"})})}var so=K.create({button:{paddingHorizontal:10,paddingVertical:6,borderRadius:8,borderWidth:1,borderColor:rr.color.border,backgroundColor:rr.color.buttonSurface},buttonActive:{borderColor:rr.color.warning+"77",backgroundColor:rr.color.warningSoft},label:{fontSize:11,fontWeight:"700",color:rr.color.accent},labelActive:{color:rr.color.warning}});g();he();import{absoluteFill as Ss,night as Ot}from"@buoy-gg/shared-ui/web";import{jsx as ut,jsxs as ao}from"react/jsx-runtime";function ks({onPress:t,isOpen:e,hasIndicator:r}){return ao(D,{onPress:t,"sentry-label":"ignore toggle header menu",testID:"buoy-network-menu",accessibilityRole:"button",accessibilityLabel:e?"Close menu":"More actions",style:[xe.button,e&&xe.buttonOpen],children:[ao(u,{style:xe.dots,children:[ut(u,{style:[xe.dot,e&&xe.dotOpen]}),ut(u,{style:[xe.dot,e&&xe.dotOpen]}),ut(u,{style:[xe.dot,e&&xe.dotOpen]})]}),r?ut(u,{style:xe.indicator}):null]})}function xs({onClose:t,children:e}){return ao(u,{style:xe.overlay,children:[ut(D,{style:xe.backdrop,activeOpacity:1,onPress:t,"sentry-label":"ignore dismiss header menu"}),ut(u,{style:xe.panel,children:e})]})}function lo({icon:t,label:e,detail:r,testID:o,onPress:i}){return ao(D,{onPress:i,"sentry-label":"ignore header menu item",testID:o,accessibilityRole:"button",accessibilityLabel:e,style:xe.item,children:[ut(u,{style:xe.itemIcon,children:t}),ut(f,{style:xe.itemLabel,children:e}),r?ut(f,{style:xe.itemDetail,children:r}):null]})}var xe=K.create({button:{width:32,height:32,borderRadius:8,alignItems:"center",justifyContent:"center"},buttonOpen:{backgroundColor:Ot.color.surfaceElevated},dots:{flexDirection:"column",gap:2.5,alignItems:"center"},dot:{width:3,height:3,borderRadius:2,backgroundColor:Ot.color.textSecondary},dotOpen:{backgroundColor:Ot.color.text},indicator:{position:"absolute",top:6,right:8,width:6,height:6,borderRadius:3,backgroundColor:Ot.color.accent},overlay:{...Ss,zIndex:50},backdrop:{...Ss,backgroundColor:"rgba(0,0,0,0.5)"},panel:{position:"absolute",top:6,right:8,minWidth:196,paddingVertical:4,borderRadius:10,borderWidth:1,borderColor:Ot.color.border,backgroundColor:Ot.color.surface},item:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:12,paddingVertical:11},itemIcon:{width:16,alignItems:"center"},itemLabel:{flex:1,fontSize:13,fontWeight:"600",color:Ot.color.text},itemDetail:{fontSize:11,color:Ot.color.textTertiary}});g();import{memo as Hc,useEffect as zc,useMemo as Vc}from"react";import{EventStepperFooter as Fc,useLimit as _c}from"@buoy-gg/shared-ui/web";import{jsx as Uc}from"react/jsx-runtime";var Wc=()=>De.step(-1),$c=()=>De.step(1),Rs=Hc(function({paused:e,filter:r,ignoredPatterns:o,isPro:i,fromSaved:n,savedSearch:s,applySafeAreaInset:a}){let{visibleEvents:l}=Rt({filter:r,ignoredPatterns:o,paused:e,isPro:i}),{pinnedEvents:p,pinnedLiveIds:c,savedRecords:x}=tt(),O=_c("network.saved"),E=Vc(()=>{if(n)return Kr(x,O,s).events;let{pinned:w,rest:R}=vr(l,p,c);return w.length===0?R:[...w,...R]},[n,x,s,i,l,p,c]);zc(()=>{De.setIds(zi(E))},[E]);let{index:P,total:N}=_i();return P<0?null:Uc(Fc,{currentIndex:P,totalItems:N,itemLabel:"Request",applySafeAreaInset:a,onPrevious:Wc,onNext:$c,variant:"night"})});g();import{useEffect as jc,useState as Xc}from"react";function Jc(t){return $.getEvents().find(e=>e.id===t)??ee.getEventById(t)}function fn(t,e={}){let{paused:r=!1}=e,[o,i]=Xc(null);return jc(()=>{if(!(!t||r))return $.subscribeToEvents(n=>{let s=n.find(a=>a.id===t);s&&i(a=>a&&a.id===t&&a.event===s?a:{id:t,event:s})})},[t,r]),t?o&&o.id===t?o.event:Jc(t):null}import{Fragment as pp,jsx as F,jsxs as $e}from"react/jsx-runtime";function ap({visible:t,paused:e,ignoredPatternValues:r,onTogglePattern:o,isPro:i,filter:n,ignoredPatterns:s,fromSaved:a,savedSearch:l,applySafeAreaInset:p}){let c=Yt(),x=Fi(),O=c!=null&&c===x,E=fn(c,{paused:e||!t});return Ft(()=>{t&&E&&O&&De.reportRendered(E.id)},[t,E,O]),t?$e(u,{style:_t.detailRoot,children:[E?F(Xo,{event:E,ignoredPatterns:r,onTogglePattern:o,showBodies:O}):F(u,{style:_t.detailBodyFallback}),F(Rs,{paused:e,filter:n,ignoredPatterns:s,isPro:i,fromSaved:a,savedSearch:l,applySafeAreaInset:p})]}):null}function lp({visible:t,paused:e,isPro:r,filter:o,onFilterChange:i,ignoredPatterns:n,onRemovePattern:s,onAddPattern:a,onTogglePatternMode:l}){let{events:p}=Rt({filter:o,ignoredPatterns:n,paused:e,visible:t,isPro:r});return t?F(fi,{events:p,filter:o,onFilterChange:i,ignoredPatterns:n,onRemovePattern:s,onAddPattern:a,onTogglePatternMode:l}):null}function dp({visible:t,paused:e,isPro:r,filter:o,ignoredPatterns:i,settings:n,onSettingsChange:s}){let{events:a}=Rt({filter:o,ignoredPatterns:i,paused:e,visible:t,isPro:r});return t?F(Ii,{settings:n,onSettingsChange:s,events:a}):null}function Cs({visible:t,onClose:e,onBack:r,onMinimize:o,enableSharedModalDimensions:i=!1,inline:n=!1,paused:s,onPausedChange:a,remoteConditions:l}){let{isPro:p}=rp(),[c,x]=Re(!1),O=s!=null&&a!=null,E=O?s:c,P=oe=>{let Ne=typeof oe=="function"?oe(E):oe;O?a(Ne):x(Ne)},[N,w]=Re({}),R=Vi(),[S,v]=Re(!1),[A,H]=Re(!1),[L,m]=Re(!1),[y,k]=Re(!1),[d,b]=Re(0),[h]=Re(ai);Ft(()=>{h.update(l)},[h,l]),Ft(()=>()=>h.update(void 0),[h]);let M=!0,[ae,pe]=Re(null),[re,X]=Re("filters"),[ie,Q]=Re(""),[z,Z]=Re(!1),J=uo(!1),[Pe,Ee]=Re(""),It=uo(null),{patterns:ze,values:Ms,add:Ds,remove:As,toggle:Hs,toggleMode:zs}=ip(),[nr,Rn]=Re(Oi),ho=uo(!1),[yo,bo]=Re(!1),[Wt,Vs]=Re("export"),ir=oe=>{Vs(oe),bo(!0)};Ft(()=>{yo&&p&&bo(!1)},[yo,p]),Ft(()=>{if(!t||ho.current)return;(async()=>{try{let Ne=await Ts.getItem(co.network.copyOptions());if(Ne){let Gs=JSON.parse(Ne);Rn(Gs)}}catch{}finally{ho.current=!0}})()},[t]),Ft(()=>{if(!ho.current)return;(async()=>{try{await Ts.setItem(co.network.copyOptions(),JSON.stringify(nr))}catch{}})()},[nr]);let Fs=()=>{De.clear()},Tn=gn(oe=>{De.select(oe.id)},[]),_s=gn((oe,Ne)=>{pe(Ne?{...oe,id:Ne}:oe),m(!0),De.clear()},[]),Ws=gn(()=>pe(null),[]),Cn=uo(null),En=oe=>{Q(oe),w(Ne=>({...Ne,searchText:oe}))},$s=oe=>{w(Ne=>({...Ne,status:Ne.status===oe?void 0:oe}))},[Nn,Us]=Re("bottomSheet"),js=oe=>{Us(oe)};Ft(()=>{z&&requestAnimationFrame(()=>{It.current?.focus()})},[z]);let On=()=>S?$e(be,{children:[F(be.Navigation,{onBack:()=>v(!1)}),F(be.Content,{title:"",noMargin:!0,children:F(tp,{size:"sm",tabs:[{key:"filters",label:"Filters"},{key:"copy",label:"Copy"}],activeKey:re,onChange:oe=>X(oe)})})]}):R?$e(be,{children:[F(be.Navigation,{onBack:Fs}),F(be.Content,{title:"Request Details",centered:!0}),$e(be.Actions,{children:[M?F(vs,{onOpen:_s}):null,F(tn,{isPro:p,onUpgradePress:()=>ir("saved")})]})]}):L&&M?$e(be,{children:[F(be.Navigation,{onBack:()=>{Cn.current?.()||(m(!1),pe(null))}}),F(be.Content,{title:"Response Overrides",centered:!0})]}):A?$e(be,{children:[F(be.Navigation,{onBack:()=>H(!1)}),F(be.Content,{title:"Saved Requests",centered:!0})]}):$e(be,{children:[r&&F(be.Navigation,{onBack:r}),F(be.Content,{title:"",children:z?F(be.Search,{value:ie,onChangeText:En,onCancel:()=>{En(""),Z(!1)},onDismiss:()=>Z(!1),dismissOnBlur:!0,clearOnlyWhenText:!0,placeholder:"Search URL, method, operation, error...",accessibilityLabel:"Search network requests",iconSize:14,testID:"buoy-network-search-input",clearTestID:"buoy-network-search-clear",inputProps:{"sentry-label":"ignore network search header"}}):F(Ki,{activeStatus:N.status,onToggleStatus:$s,ignoredPatterns:ze,paused:E})}),$e(be.Actions,{children:[F(D,{"sentry-label":"ignore open search",testID:"buoy-network-search-open",accessibilityLabel:"Open search",accessibilityRole:"button",onPress:()=>Z(!0),style:_t.headerActionButton,children:F(Gc,{size:14,color:ct.color.textSecondary})}),M?F(bs,{onPress:()=>m(!0)}):null,F(np,{isEnabled:!E,onToggle:()=>P(oe=>!oe),accessibilityLabel:E?"Resume network capture":"Pause network capture",testID:"buoy-network-power"}),F(Qi,{paused:E}),F(ks,{onPress:()=>k(oe=>!oe),isOpen:y,hasIndicator:wo})]})]}),wo=!!(N.status||N.method||N.contentType),Xs=i?co.modal.root():co.network.modal();if(!t)return null;let Js=R||!S,In=$e(pp,{children:[$e(u,{style:_t.container,children:[F(ap,{visible:R,paused:E,ignoredPatternValues:Ms,onTogglePattern:Hs,isPro:p,filter:N,ignoredPatterns:ze,fromSaved:A,savedSearch:Pe,applySafeAreaInset:!n&&Nn==="bottomSheet"}),F(lp,{visible:S&&re==="filters"&&!R,paused:E,isPro:p,filter:N,onFilterChange:w,ignoredPatterns:ze,onRemovePattern:As,onAddPattern:Ds,onTogglePatternMode:zs}),F(dp,{visible:S&&re==="copy"&&!R,paused:E,isPro:p,filter:N,ignoredPatterns:ze,settings:nr,onSettingsChange:Rn}),F(ys,{visible:M&&L&&!R&&!S,isPro:p,onUpgradePress:()=>ir("overrides"),pendingDraft:ae,onPendingConsumed:Ws,backHandlerRef:Cn,applySafeAreaInset:!n&&Nn==="bottomSheet"}),F(sn,{visible:A&&!R&&!S&&!(L&&M),isPro:p,copySettings:nr,search:Pe,onSearchChange:Ee,onEventPress:Tn,onUpgradePress:()=>ir("saved")}),F(is,{visible:!R&&!S&&!A&&!(L&&M),paused:E,filter:N,ignoredPatterns:ze,isPro:p,searchText:ie,onEventPress:Tn,onUpgradePress:()=>ir("export")})]}),y?$e(xs,{onClose:()=>k(!1),children:[F(lo,{icon:F(Kc,{size:14,color:ct.color.textSecondary}),label:"Network throttling",testID:"buoy-network-menu-throttling",onPress:()=>{k(!1),li(l?h:void 0),n||b(oe=>oe+1)}}),F(lo,{icon:F(Yc,{size:14,color:wo?ct.color.accent:ct.color.textSecondary}),label:"Filters",detail:wo?"Active":void 0,onPress:()=>{k(!1),X("filters"),v(!0)}}),F(lo,{icon:F(Qc,{size:14,color:ct.color.textSecondary}),label:"Saved requests",onPress:()=>{k(!1),H(!0)}}),F(u,{style:_t.menuCopyRow,children:F(Zi,{isPro:p,filter:N,ignoredPatterns:ze,copySettings:nr,paused:E,onUpgradePress:()=>{k(!1),ir("export")},label:"Copy requests"})})]}):null,F(op,{visible:yo,onClose:()=>bo(!1),featureName:Wt==="saved"?"Saved Requests":Wt==="overrides"?"Response Overrides":"Network Export",description:Wt==="saved"?"Keep the requests that matter. Saved requests survive Clear, app restarts, and the 500-request history cap.":Wt==="overrides"?"Force any endpoint to fail, stall or return something else \u2014 no backend changes, no code changes. Free keeps one active rule.":"Export network requests to share with your team, debug APIs, or feed into AI tools.",benefits:Wt==="overrides"?[`Run ${Ue} rules at once (free keeps ${Oo})`,"Force a 500, a 401 or an empty list in one tap","Simulate offline, timeouts and slow connections","Rules survive an app reload, so you can test the boot path"]:Wt==="saved"?[`Save up to ${_e} requests (free keeps ${Yo})`,"Failed requests stay put through a Clear","Snapshots survive an app restart","Export saved requests to teammates or AI assistants"]:["Export to JSON, Markdown, or plain text","Customizable copy presets (URLs only, LLM-ready, full data)","Share request details with teammates","Feed network data directly to AI assistants"]})]});return n?$e(u,{style:_t.inlineRoot,children:[F(u,{style:_t.inlineHeader,...sp,children:On()}),In]}):F(Zc,{visible:t,onClose:e,onMinimize:o,minimizeRequest:d,persistenceKey:Xs,variant:"night",header:{showToggleButton:!0,customContent:On()},onModeChange:js,enablePersistence:!0,initialMode:"bottomSheet",enableGlitchEffects:!0,disableScrollWrapper:Js,styles:{},children:In})}var _t=K.create({container:{flex:1,backgroundColor:"transparent"},detailRoot:{flex:1,minHeight:0},detailBodyFallback:{flex:1},inlineRoot:{flex:1,minHeight:0,backgroundColor:"transparent"},inlineHeader:{paddingHorizontal:12,paddingVertical:8,borderBottomWidth:1,borderBottomColor:ep.border.default,backgroundColor:"transparent"},menuCopyRow:{paddingHorizontal:6},headerActionButton:{width:32,height:32,borderRadius:8,backgroundColor:ct.color.buttonSurface,borderWidth:1,borderColor:ct.color.border,alignItems:"center",justifyContent:"center"},activeFilterButton:{backgroundColor:ct.color.accentSoft,borderColor:ct.color.accentBorderStrong}});function mn(t){return F(Ar,{children:F(Cs,{...t})})}function up(t={}){return F(Ar,{children:F(Cs,{...t,inline:!0,visible:!0,onClose:cp})})}var cp=()=>{};import{jsx as hp}from"react/jsx-runtime";var Es=typeof navigator<"u"&&navigator.product==="ReactNative";Es&&U.ensureLoaded();Es&&typeof I<"u"&&I&&$.startBootCapture();var Ns=gp({id:"network",name:"NET",description:"Network request logger",slot:"both",icon:({size:t})=>hp(ri,{size:t}),component:mn,props:{enableSharedModalDimensions:!1}}),mp=fp(Ns,t=>({enableSharedModalDimensions:t.enableSharedModalDimensions??!1}));g();function yp(){if(!(typeof navigator<"u"&&navigator.product==="ReactNative")&&(typeof window>"u"||typeof document>"u"))return()=>{};U.ensureLoaded();let e=$.subscribeToEvents(()=>{}),r=!1;return()=>{r||(r=!0,e())}}g();import{useState as hn,useEffect as bp,useCallback as po,useMemo as pt,useRef as wp}from"react";import{useLimit as vp,TIER_LIMITS as Sp}from"@buoy-gg/shared-ui/web";var Tw=Sp["network.requests"].free;function kp(t={}){let{isPro:e=!1}=t,r=vp("network.requests"),o=e?1/0:r,[i,n]=hn([]),[s,a]=hn({}),[l,p]=hn(!0),c=wp(null);bp(()=>(l&&(c.current=$.subscribeToEvents(n)),()=>{c.current&&(c.current(),c.current=null)}),[l]);let x=po(()=>{$.clearEvents(),n([])},[]),O=po(()=>{p(!1)},[]),E=po(()=>{p(!0)},[]),P=pt(()=>s.searchText?s.searchText.toLowerCase():null,[s.searchText]),N=pt(()=>s.method&&s.method.length>0?new Set(s.method):null,[s.method]),w=pt(()=>s.contentType&&s.contentType.length>0?new Set(s.contentType):null,[s.contentType]),R=pt(()=>{let d=[...i];if(N&&(d=d.filter(b=>N.has(b.method))),s.status&&s.status!=="all")switch(s.status){case"success":d=d.filter(b=>b.status&&b.status>=200&&b.status<300);break;case"error":d=d.filter(b=>b.error||b.status&&b.status>=400);break;case"pending":d=d.filter(b=>!b.status&&!b.error);break}return P&&(d=d.filter(b=>b.url.toLowerCase().includes(P)||b.method.toLowerCase().includes(P)||b.path?.toLowerCase().includes(P)||b.host?.toLowerCase().includes(P)||b.error&&b.error.toLowerCase().includes(P)||b.operationName&&b.operationName.toLowerCase().includes(P)||zr(b.graphqlVariables,P))),s.host&&(d=d.filter(b=>b.host===s.host)),w&&(d=d.filter(b=>{let h=b.responseHeaders||b.requestHeaders,M=h?.["content-type"]||h?.["Content-Type"]||"";for(let ae of w)switch(ae){case"JSON":if(M.includes("json"))return!0;break;case"XML":if(M.includes("xml"))return!0;break;case"HTML":if(M.includes("html"))return!0;break;case"TEXT":if(M.includes("text"))return!0;break;case"IMAGE":if(M.includes("image"))return!0;break;case"VIDEO":if(M.includes("video"))return!0;break;case"AUDIO":if(M.includes("audio"))return!0;break;case"FORM":if(M.includes("form"))return!0;break;case"OTHER":if(!M||!M.includes("json")&&!M.includes("xml")&&!M.includes("html")&&!M.includes("text")&&!M.includes("image")&&!M.includes("video")&&!M.includes("audio")&&!M.includes("form"))return!0;break}return!1})),d},[i,s,P,N,w]),S=pt(()=>{let d=new Set;return i.slice(o).forEach(b=>{d.add(b.id)}),d},[i,o]),v=pt(()=>R.filter(d=>S.has(d.id)),[R,S]),A=v.length>0,H=v.length,L=po(d=>S.has(d),[S]),m=pt(()=>{let d=0,b=0,h=0,M=0,ae=0,pe=0,re=0;for(let ie of i)ie.status&&ie.status>=200&&ie.status<300?d++:ie.error||ie.status&&ie.status>=400?b++:!ie.status&&!ie.error&&h++,M+=ie.requestSize||0,ae+=ie.responseSize||0,ie.duration&&(pe+=ie.duration,re++);let X=re>0?pe/re:0;return{totalRequests:i.length,successfulRequests:d,failedRequests:b,pendingRequests:h,totalDataSent:M,totalDataReceived:ae,averageDuration:Math.round(X)}},[i]),y=pt(()=>{let d=new Set;for(let b of i)b.host&&d.add(b.host);return Array.from(d)},[i]),k=pt(()=>{let d=new Set;for(let b of i)d.add(b.method);return Array.from(d)},[i]);return{events:R,allEvents:i,stats:m,filter:s,setFilter:a,clearEvents:x,isCapturing:l,pauseCapturing:O,resumeCapturing:E,hosts:y,methods:k,hasLockedEvents:A,lockedEventCount:H,isEventLocked:L,requestLimit:o,getSubscriberCounts:()=>$.getSubscriberCounts()}}import{useIgnoredPatterns as dv,ignoredPatternsStore as uv,urlMatchesIgnoredPattern as cv,isUrlIgnored as pv}from"@buoy-gg/shared-ui/web";g();import{approxJsonSize as Sn,isOverWireBudget as xp}from"@buoy-gg/shared-ui/web";import{expandKeyedArrays as Rp,patchFromPath as Tp,refusalText as Cp,shapeKind as Os,suggestedPatch as Ep,typedEditViolations as Np}from"@buoy-gg/shared-ui/web";var wn=16*1024,mo=1.25*1024*1024;function vn(t,e){return t===void 0?!1:(e??0)>wn?!0:xp(t,wn)}var Is=new WeakMap,Ps=new WeakMap;function kn(t){let e=Is.get(t);if(e)return e;let r;try{r=Ip(t)}catch{r=Op(t)}return Is.set(t,r),r}function Op(t){let e={...t,requestData:void 0,responseData:void 0,graphqlVariables:void 0,requestBodyOmitted:t.requestData!==void 0?!0:void 0,responseBodyOmitted:t.responseData!==void 0?!0:void 0},r=1024;try{r=Sn(e,mo).bytes}catch{}return{event:e,bytes:r}}function Ip(t){let e=vn(t.requestData,t.requestSize),r=vn(t.responseData,t.responseSize),o=Bs(t.graphqlVariables),i=Ls(t.requestHeaders),n=Ls(t.responseHeaders),s=e||r||o!==t.graphqlVariables||i!==t.requestHeaders||n!==t.responseHeaders,a=t;return s&&(a={...t},e&&(a.requestData=void 0,a.requestBodyOmitted=!0),r&&(a.responseData=void 0,a.responseBodyOmitted=!0),o!==t.graphqlVariables&&(a.graphqlVariables=o),i!==t.requestHeaders&&(a.requestHeaders=i,a.headersOmitted=!0),n!==t.responseHeaders&&(a.responseHeaders=n,a.headersOmitted=!0)),{event:a,bytes:Sn(a,mo).bytes}}function Pp(t){let e=Ps.get(t);if(e)return e;let{event:r}=kn(t),o={...r};o.requestData!==void 0&&(o.requestData=void 0,o.requestBodyOmitted=!0),o.responseData!==void 0&&(o.responseData=void 0,o.responseBodyOmitted=!0),o.graphqlVariables!==void 0&&(o.graphqlVariables=Bs(o.graphqlVariables,!0));let i={event:o,bytes:Sn(o,mo).bytes};return Ps.set(t,i),i}function Lp(t){let e=new Array(t.length),r=0;for(let o=0;o<t.length;o++){let i=kn(t[o]);if(r+i.bytes<=mo)e[o]=i.event,r+=i.bytes;else{let n=Pp(t[o]);e[o]=n.event,r+=n.bytes}}return e}function Bs(t,e=!1){if(!t||!e&&!vn(t,void 0))return t;let r={};for(let[o,i]of Object.entries(t))(typeof i=="string"&&i.length<=64||typeof i=="number"||typeof i=="boolean")&&(r[o]=i);return Object.keys(r).length>0?r:void 0}var yn=64;function Ls(t){if(!t)return t;let e=!1,r={};for(let[o,i]of Object.entries(t))typeof i=="string"&&(i.length<=yn?r[o]=i:(r[o]=`${i.slice(0,yn)}\u2026 [${i.length-yn} more]`,e=!0));return e?r:t}var Bp=t=>{let e=!1,r=t.rules.map(o=>!o.body||o.body.length<=wn?o:(e=!0,{...o,body:void 0,bodyOmitted:!0}));return e?{...t,rules:r}:t},go=t=>$.getEventById(t)??ee.getEventById(t),or=t=>t&&typeof t=="object"?t.id:void 0,fo=(t,e)=>!!(t&&typeof t=="object"&&t[e]),bn=()=>Lo()?{}:{active:!1,inactiveReason:Wn},qp=["respond","fail","delay"];function Mp(t,e){if(!t||typeof t!="object")return null;let r=t.rule??t;if(!r||typeof r!="object")return null;let o=r,i=typeof o.urlPattern=="string"&&o.urlPattern.trim()?o.urlPattern.trim():e?.urlPattern??"";if(!i)return null;let n=qp.includes(o.kind)?o.kind:e?.kind??"respond";return{id:typeof o.id=="string"?o.id:void 0,enabled:o.enabled!==!1,name:typeof o.name=="string"?o.name:e?.name,urlPattern:i,methods:Array.isArray(o.methods)?o.methods.filter(s=>typeof s=="string").map(s=>s.toUpperCase()):e?.methods,kind:n,status:typeof o.status=="number"?o.status:e?.status,statusText:typeof o.statusText=="string"?o.statusText:e?.statusText,headers:o.headers&&typeof o.headers=="object"?o.headers:e?.headers,body:Ap(o,e),failKind:o.failKind==="timeout"?"timeout":void 0,delayMs:typeof o.delayMs=="number"?o.delayMs:void 0,times:typeof o.times=="number"?o.times:null,alternate:o.alternate===!0}}var Cr=t=>!!t&&typeof t=="object"&&!Array.isArray(t);function qs(t,e,r="",o={shrunk:[],breaks:[]}){if(Array.isArray(t)&&Array.isArray(e))return e.length>0&&e.length<t.length&&o.shrunk.push({path:r||"(root)",have:t.length,sent:e.length}),e;if(!Cr(t)||!Cr(e))return e;let i={...t};for(let[n,s]of Object.entries(e)){let a=r?`${r}.${n}`:n;if(n in t){let l=Os(t[n]),p=Os(s);(l==="array"||l==="object")&&l!==p&&o.breaks.push({path:a,from:l,to:p}),i[n]=qs(t[n],s,a,o)}else i[n]=s}return i}function Dp(t,e){if(t.body!=null||!Cr(t.bodyPatch)||typeof e!="string")return[];try{return Np(JSON.parse(e),t.bodyPatch,{noun:"response body"})}catch{return[]}}function Ap(t,e){if(typeof t.body=="string")return t.body;if(t.body!=null)return JSON.stringify(t.body,null,2);let r=e?.body??(typeof t.id=="string"?U.getState().rules.find(o=>o.id===t.id)?.body:void 0);if(Cr(t.bodyPatch)&&typeof r=="string")try{return JSON.stringify(qs(JSON.parse(r),t.bodyPatch),null,2)}catch{return r}return r}function Hp(t){if(!t||typeof t!="object")return null;let e=t.rule??t;if(!e||typeof e!="object")return null;let r=e.id;if(typeof r!="string")return null;let o=U.getState().rules.find(i=>i.id===r);return o?{...o}:null}function zp(t){if(!t||typeof t!="object")return null;let e=t.rule??t;if(!e||typeof e!="object")return null;let r=e;if(r.bodyOmitted!==!0||typeof r.id!="string")return null;let o=U.getState().rules.find(i=>i.id===r.id);return o?{body:o.body}:null}function Vp(t){if(!t||typeof t!="object")return null;let e=t.fromRequestId;if(typeof e!="string"||!e)return null;let r=go(e);return r?Tr(r):null}var Fp={dispose:()=>{U.setEnabled(!1)},version:6,getSnapshot:()=>($.ensureInterception(),{conditions:{version:1,runtimeId:qr,profile:Ye(),available:at()},events:Lp($.getEvents()),overrides:Bp(U.getState()),saved:ee.getRecords().map(t=>({...t,event:kn(t.event).event}))}),subscribe:t=>{let e=$.subscribeToEvents(t),r=vt(t),o=ee.subscribe(t),i=U.subscribe(t);return()=>{r(),e(),o(),i()}},actions:{getNetworkConditions:()=>({runtimeId:qr,profile:Ye(),available:at()}),setNetworkConditions:t=>{let e=t&&typeof t=="object"?t.profile:void 0;return{runtimeId:qr,profile:Xt(e),available:at()}},clearEvents:()=>{$.clearEvents()},getEventBody:t=>{let e=or(t);if(!e)return null;let r=go(e);return r?{url:r.url??null,method:r.method??null,status:r.status??null,override:r.override??null,requestData:r.requestData??null,responseData:r.responseData??null,requestHeaders:r.requestHeaders??null,responseHeaders:r.responseHeaders??null}:null},setPinned:t=>{let e=or(t);if(!e)return null;let r=go(e);if(!r)return null;let o=fo(t,"pinned");return Kt(ee.getState(),e).pinned===o?{ok:!0}:ee.togglePin(r)},setSaved:t=>{let e=or(t);if(!e)return null;let r=go(e);if(!r)return null;let o=fo(t,"saved");return Kt(ee.getState(),e).saved===o?{ok:!0}:ee.toggleSave(r)},removeSavedRecord:t=>{let e=t&&typeof t=="object"?t.key:void 0;return e?(ee.remove(e),{ok:!0}):null},clearSavedRequests:()=>(ee.clearSaved(),{ok:!0}),clearPinnedRequests:()=>(ee.clearPinned(),{ok:!0}),setOverridesEnabled:t=>(U.setEnabled(fo(t,"enabled")),{ok:!0,enabled:U.getState().enabled,...bn()}),upsertOverrideRule:t=>{let e=Vp(t)??zp(t)??Hp(t),r=t?.rule??t;if(r&&typeof r.bodyPath=="string"&&r.body==null){let n=e?.body??(typeof r.id=="string"?U.getState().rules.find(l=>l.id===r.id)?.body:void 0);if(typeof n!="string")return{ok:!1,error:"bodyPath needs something to patch: send fromRequestId (the captured request whose real response it addresses) or the id of an existing rule."};if(r.bodyValue===void 0)return{ok:!1,error:`Refused: sent \`bodyPath\` without \`bodyValue\`. Say what to set "${r.bodyPath}" to.`};let s;try{s=JSON.parse(n)}catch{return{ok:!1,error:"The captured response body is not JSON, so it cannot be addressed by path. Send a whole `body` instead."}}let a=Tp(s,r.bodyPath,r.bodyValue);if(!a.ok)return{ok:!1,error:`Refused: ${a.error}`};r.bodyPatch=a.patch,delete r.bodyPath,delete r.bodyValue}if(r&&Cr(r.bodyPatch)&&r.body==null){let n=e?.body??(typeof r.id=="string"?U.getState().rules.find(s=>s.id===r.id)?.body:void 0);if(typeof n!="string")return{ok:!1,error:"bodyPatch needs something to patch: send fromRequestId (the captured request whose real response the patch is merged into) or the id of an existing rule."};if(r.force!==!0){let s;try{let l=Rp(JSON.parse(n),r.bodyPatch);s=l.error,l.notes.length&&(r.bodyPatch=l.patch)}catch{}if(s)return{ok:!1,error:`Refused: ${s}`};let a=Dp(r,n);if(a.length>0)return{ok:!1,error:Cp(a,"response body",Ep(r.bodyPatch,a)),violations:a}}}let o=Mp(t,e);if(!o){let n=t?.fromRequestId;return{ok:!1,error:n?`No captured request \`${n}\` \u2014 it may have been cleared. Send a urlPattern instead.`:"A rule needs a non-empty urlPattern."}}let i=U.upsertRule(o);return i?(i.enabled&&U.setEnabled(!0),{ok:!0,rule:{id:i.id,urlPattern:i.urlPattern,enabled:i.enabled,kind:i.kind,status:i.status,times:i.times,bodySize:i.body?i.body.length:0},...i.times===void 0||i.times===null?{lingers:`This rule has no \`times\` budget, so it overrides EVERY matching request until it is disabled or deleted (id \`${i.id}\`). If you meant only the next one, set times:1.`}:{},...bn()}):{ok:!1,error:"Override rule limit reached."}},setOverrideRuleEnabled:t=>{let e=or(t);return e?(U.setRuleEnabled(e,fo(t,"enabled")),{ok:!0,...bn()}):{ok:!1,error:"Missing rule id."}},deleteOverrideRule:t=>{let e=or(t);return e?(U.removeRule(e),{ok:!0}):{ok:!1,error:"Missing rule id."}},clearOverrideRules:()=>(U.clearRules(),{ok:!0}),listOverrideRules:()=>U.getState(),getOverrideRuleBody:t=>{let e=or(t);if(!e)return null;let r=U.getState().rules.find(o=>o.id===e);return r?{body:r.body??null}:null},getCaptureStatus:()=>{let t=$.getSubscriberCounts().total,e=null,r=null;try{e=Ao(),r=je()}catch{}let o=null;try{o=Zn()}catch{}return{capturing:t>0,subscribers:t,interceptorInstalled:e,interceptorLive:o,listenerCount:r,eventCount:$.getEvents().length}},debugOverrides:t=>{let e=(t&&typeof t=="object"?t.url:void 0)??"https://example.com/";return{interceptorInstalled:Ao(),listenerCount:je(),engine:$n(e,"GET"),store:{enabled:U.getState().enabled,ruleCount:U.getState().rules.length,rulesVisibleToEngine:U.getRules().length}}}}};g();var _p=new Set(["content-length","host","connection","accept-encoding"]);function xn(t){return`'${t.replace(/'/g,"'\\''")}'`}function Wp(t){if(t==null)return null;if(typeof t=="string")return t;try{return JSON.stringify(t)}catch{return null}}function $p(t){let e=(t.method||"GET").toUpperCase(),r=Wp(t.requestData),o=[];e!=="GET"&&!(e==="POST"&&r!==null)&&o.push(`-X ${e}`);for(let[n,s]of Object.entries(t.requestHeaders||{}))_p.has(n.toLowerCase())||o.push(`-H ${xn(`${n}: ${s}`)}`);r!==null&&o.push(`--data-raw ${xn(r)}`);let i=`curl ${xn(t.url)}`;return o.length===0?i:`${i} \\
|
|
145
|
+
${o.join(` \\
|
|
146
|
+
`)}`}export{Fd as DEFAULT_SETTLE_MS,Oo as FREE_TIER_OVERRIDE_LIMIT,Yo as FREE_TIER_SAVED_LIMIT,Ue as MAX_OVERRIDE_RULES,mr as MAX_PINNED,_e as MAX_SAVED,jt as NETWORK_CONDITIONS,jl as NetworkBodyResolverProvider,tn as NetworkDetailPinActions,Xo as NetworkEventDetailView,xt as NetworkEventItemCompact,Yi as NetworkHeaderBadgesView,mn as NetworkModal,Zd as NetworkSavedButton,sn as NetworkSavedScreen,up as NetworkToolView,mt as OVERRIDE_STATUS_MAX,gt as OVERRIDE_STATUS_MIN,Ar as TickProvider,bt as addNetworkListener,mp as createNetworkTool,Tr as draftFromEvent,Kt as flagsForEventId,Xe as formatBytes,Jt as formatDuration,_o as formatHttpStatus,$p as generateCurl,Ye as getNetworkCondition,uv as ignoredPatternsStore,pv as isUrlIgnored,$ as networkEventStore,ur as networkListener,ee as networkSavedStore,De as networkSelectionStore,Fp as networkSyncAdapter,Ns as networkToolPreset,U as overrideRulesStore,wl as removeAllNetworkListeners,Xt as setNetworkCondition,vr as splitPinned,yp as startNetworkCapture,vt as subscribeNetworkConditions,cv as urlMatchesIgnoredPattern,dv as useIgnoredPatterns,fn as useLiveNetworkEvent,en as useNetworkBadgeCounts,Rt as useNetworkEventList,kp as useNetworkEvents,tt as useNetworkSaved,cr as useTickEveryMinute};
|