@buoy-gg/react-query 7.0.68 → 7.0.70

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createReactQuerySyncAdapter=createReactQuerySyncAdapter;var _sharedUi=require("@buoy-gg/shared-ui");var _reactQuery=require("@tanstack/react-query");var _dehydrate=require("./dehydrate");var _getQueryStatusLabel=require("../utils/getQueryStatusLabel");function touchesList(r,s){let t=r;for(const e of s.split(".")){if(!t||typeof t!=="object"||Array.isArray(t))return false;if(!(e in t))return false;t=t[e]}return Array.isArray(t)?t.length>0:!!t&&typeof t==="object"}const isPlainObject=r=>!!r&&typeof r==="object"&&!Array.isArray(r);function shapeKind(r){if(Array.isArray(r))return"array";if(r===null)return"null";if(typeof r==="object")return"object";return typeof r}function deepMerge(r,s,t="",e={shrunk:[],breaks:[]}){if(Array.isArray(r)&&Array.isArray(s)){if(s.length>0&&s.length<r.length){e.shrunk.push({path:t||"(root)",have:r.length,sent:s.length})}return s}if(!isPlainObject(r)||!isPlainObject(s))return s;const a={...r};for(const[n,u]of Object.entries(s)){const c=t?`${t}.${n}`:n;if(n in r){const d=shapeKind(r[n]);const h=shapeKind(u);if((d==="array"||d==="object")&&d!==h){e.breaks.push({path:c,from:d,to:h})}a[n]=deepMerge(r[n],u,c,e)}else{a[n]=u}}return a}function looseKeyParts(r){const s=r.trim();try{const t=JSON.parse(s);if(Array.isArray(t)){return t.map(e=>typeof e==="object"&&e!==null?JSON.stringify(e):String(e))}}catch{}if(s.includes(",")&&!s.startsWith("[")){return s.split(",").map(t=>t.trim().replace(/^["']|["']$/g,""))}return null}function refetchIntervalOf(r){let s;for(const t of r.observers??[]){const e=t.options?.refetchInterval;let a=e;if(typeof e==="function"){try{a=e(r)}catch{a=void 0}}if(typeof a==="number"&&a>0)s=s===void 0?a:Math.min(s,a)}return s}function createReactQuerySyncAdapter(r){const s=t=>{const{queryHash:e}=t;const a=r.getQueryCache();let n=e?a.get(e):void 0;if(!n&&typeof e==="string"){const u=looseKeyParts(e);if(u){n=a.getAll().find(c=>{const d=c.queryKey.map(h=>typeof h==="object"?JSON.stringify(h):String(h));return d.length===u.length&&d.every((h,f)=>h===u[f])})}}if(!n){throw new Error(`Query with hash "${e}" not found`)}return n};return{version:2,getSnapshot:()=>({dehydratedState:(0,_dehydrate.dehydrateQueryClient)(r),isOnlineManagerOnline:_reactQuery.onlineManager.isOnline()}),subscribe:t=>{const e=r.getQueryCache().subscribe(t);const a=r.getMutationCache().subscribe(t);const n=_reactQuery.onlineManager.subscribe(t);return()=>{e();a();n()}},actions:{getQueryData:t=>{const{queryHash:e,path:a}=t??{};if(!e)return{found:false,reason:"missing queryHash"};const n=r.getQueryCache().get(e);if(!n)return{found:false,reason:"unknown queryHash"};if(a){const c=(0,_sharedUi.readPath)(n.state.data,a);if(!c.ok)return{found:false,reason:c.error};return{found:true,queryHash:e,path:a,shape:(0,_sharedUi.shapeSummary)(c.value),data:c.value}}if(n.state.data===void 0){const c=n.state.status;const d=n.state.error;return{found:true,queryHash:e,hasData:false,status:c,fetchStatus:n.state.fetchStatus,...d?{error:d instanceof Error?d.message:String(d)}:{},reason:c==="error"?"This query has no data because it FAILED. Report the error, not an empty result.":n.state.fetchStatus==="fetching"?"No data yet \u2014 this query is still fetching.":"This query has never resolved (it may be disabled, or never enabled). It is not empty \u2014 it has nothing."}}const u=(0,_sharedUi.shapeSummary)(n.state.data);return{found:true,queryHash:e,hasData:true,...u?{shape:u}:{},data:(0,_dehydrate.capQueryDetail)(n.state.data)}},listQueries:t=>{const{includeData:e=false,staleOnly:a=false,limit:n}=t??{};const u=r.getQueryCache().getAll();const c=a?u.filter(o=>o.isStale()):u;const d=[...c].sort((o,y)=>{const g=Number(y.getObserversCount()>0)-Number(o.getObserversCount()>0);return g!==0?g:(y.state.dataUpdatedAt??0)-(o.state.dataUpdatedAt??0)});const h=typeof n==="number"&&n>0?d.slice(0,n):d;const f=h.map(o=>{const y=o.state.error;const g=refetchIntervalOf(o);return{queryHash:o.queryHash,queryKey:o.queryKey,status:(0,_getQueryStatusLabel.getQueryStatusLabel)(o),fetchStatus:o.state.fetchStatus,isStale:o.isStale(),observers:o.getObserversCount(),updatedAt:o.state.dataUpdatedAt,...g?{refetchEveryMs:g}:{},error:y?y.message??String(y):void 0,...e?{data:o.state.data}:{},...(0,_sharedUi.shapeSummary)(o.state.data)?{shape:(0,_sharedUi.shapeSummary)(o.state.data)}:{}}});return{queries:f,total:u.length,returned:f.length,includedData:e}},refetch:t=>{const e=s(t);return e.fetch().catch(()=>void 0)},invalidate:t=>r.invalidateQueries(s(t)),reset:t=>r.resetQueries(s(t)),remove:t=>{const e=s(t);const a=r.getQueryCache().findAll(e).some(n=>n.getObserversCount()>0);r.removeQueries(e);return{ok:true,...a?{note:"Removed \u2014 but a screen is still watching this query, and React Query leaves that screen rendering its LAST value (including anything written into the cache before this) until something refetches. Nothing on screen will change on its own. Use `reset` instead when you want the screen to go back to loading and fetch again."}:{}}},setQueryData:t=>{const{data:e,merge:a,force:n,path:u,value:c}=t;const{queryKey:d,queryHash:h}=t;let f=d;if(f===void 0&&typeof h==="string"){const i=r.getQueryCache().get(h);if(!i){return{ok:false,error:`Refused: no query with hash ${h} is in the cache. Read listQueries for the current hashes \u2014 a query that has been removed or whose key includes changing params (a search term, a cart payload) will not match an older hash.`}}f=i.queryKey}if(f===void 0){return{ok:false,error:`Refused: no query was named. Send \`queryKey\` (the array from listQueries) or \`queryHash\` (its string form).`}}const o=r.getQueryData(f);const y=r.getQueryCache().find({queryKey:f,exact:true});if(o===void 0&&y&&(e!==void 0||u!==void 0)){const i=y;const l=i?.state.status;const m=l==="error"?`it FAILED${i?.state.error?` (${i.state.error instanceof Error?i.state.error.message:String(i.state.error)})`:""}`:l==="pending"?"it has never resolved (it may be disabled, or still loading)":"it holds no data";return{ok:false,error:`Refused: this query has no data to edit \u2014 ${m}. There is nothing to merge into. Fix the cause first (restoreError, or let it fetch), or send force:true with the COMPLETE value if you mean to seed the cache from nothing.`,status:l}}if(e===void 0&&u===void 0){return{ok:false,error:`Refused: no change was described. Send \`data\` (with merge:true for a partial edit), or \`path\` and \`value\` to set one value.`}}let g=e;if(u!==void 0){if(c===void 0){return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${u}" to; if you mean to clear it, send value:null and the field must already be nullable.`}}const i=(0,_sharedUi.patchFromPath)(o,u,c);if(!i.ok)return{ok:false,error:`Refused: ${i.error}`};g=i.patch}if(a||u!==void 0){const i=n?{patch:g,notes:[],error:void 0}:(0,_sharedUi.expandKeyedArrays)(o,g);if(i.error){return{ok:false,error:`Refused: ${i.error}`}}const l=i.patch;if(!n){const p=(0,_sharedUi.typedEditViolations)(o,l,{noun:"data"});if(p.length>0){const b=(0,_sharedUi.suggestedPatch)(l,p);return{ok:false,error:(0,_sharedUi.refusalText)(p,"data",b),violations:p,...b?{suggestedData:b}:{}}}}const m=deepMerge(o,l);const v=(0,_sharedUi.unshapedLists)(o).filter(p=>touchesList(l,p));r.setQueryData(f,m,{updatedAt:Date.now()});return{ok:true,mode:"merge",...u!==void 0?{path:u}:{},changedKeys:isPlainObject(l)?Object.keys(l):void 0,...i.notes.length?{keyed:i.notes}:{},...v.length?{unchecked:v.map(p=>`\`${p}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the screen renders a field you left out, it will render undefined \u2014 read the query back and compare against how the screen uses it.`)}:{}}}if(!n&&isPlainObject(o)&&isPlainObject(e)){const i=Object.keys(o).filter(l=>!(l in e));if(i.length>0){return{ok:false,error:`Refused: the new value drops ${i.length} top-level field(s) the cached value has (${i.slice(0,8).join(", ")}${i.length>8?", \u2026":""}). A screen rendering those fields would crash. To change some fields, send merge:true with ONLY the fields that change. To really replace the whole value, send force:true.`,missingKeys:i}}}r.setQueryData(f,e,{updatedAt:Date.now()});return{ok:true,mode:"replace"}},triggerError:t=>{const e=s(t);const a=e.options;e.setState({status:"error",error:new Error("Unknown error from devtools"),fetchMeta:{...e.state.fetchMeta,__previousQueryOptions:a}})},restoreError:t=>r.resetQueries(s(t)),triggerLoading:t=>{const e=s(t);const a=e.options;e.fetch({...a,queryFn:()=>new Promise(()=>{}),gcTime:-1}).catch(()=>void 0);e.setState({data:void 0,status:"pending",fetchMeta:{...e.state.fetchMeta,__previousQueryOptions:a}})},restoreLoading:t=>{const e=s(t);const a=e.state;const n=e.state.fetchMeta?e.state.fetchMeta.__previousQueryOptions:null;e.cancel({silent:true});e.setState({...a,fetchStatus:"idle",fetchMeta:null});if(n){e.fetch(n).catch(()=>void 0)}},clearQueryCache:()=>{const t=r.getQueryCache().getAll().filter(e=>e.getObserversCount()>0).length;r.getQueryCache().clear();return{ok:true,cleared:true,...t?{note:`Cleared \u2014 but ${t} quer${t===1?"y is":"ies are"} still being watched by a screen, and React Query leaves those screens rendering their LAST value until something refetches. The cache is empty; the app on screen is not. Use \`reset\` on a query when you want its screen to reload.`}:{}}},clearMutationCache:()=>{r.getMutationCache().clear()},setOnline:t=>{const{online:e}=t;_reactQuery.onlineManager.setOnline(e)}}}}
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.createReactQuerySyncAdapter=createReactQuerySyncAdapter;var _sharedUi=require("@buoy-gg/shared-ui");var _reactQuery=require("@tanstack/react-query");var _dehydrate=require("./dehydrate");var _getQueryStatusLabel=require("../utils/getQueryStatusLabel");function touchesList(r,s){let t=r;for(const e of s.split(".")){if(!t||typeof t!=="object"||Array.isArray(t))return false;if(!(e in t))return false;t=t[e]}return Array.isArray(t)?t.length>0:!!t&&typeof t==="object"}const isPlainObject=r=>!!r&&typeof r==="object"&&!Array.isArray(r);function shapeKind(r){if(Array.isArray(r))return"array";if(r===null)return"null";if(typeof r==="object")return"object";return typeof r}function deepMerge(r,s,t="",e={shrunk:[],breaks:[]}){if(Array.isArray(r)&&Array.isArray(s)){if(s.length>0&&s.length<r.length){e.shrunk.push({path:t||"(root)",have:r.length,sent:s.length})}return s}if(!isPlainObject(r)||!isPlainObject(s))return s;const a={...r};for(const[n,u]of Object.entries(s)){const c=t?`${t}.${n}`:n;if(n in r){const d=shapeKind(r[n]);const h=shapeKind(u);if((d==="array"||d==="object")&&d!==h){e.breaks.push({path:c,from:d,to:h})}a[n]=deepMerge(r[n],u,c,e)}else{a[n]=u}}return a}function looseKeyParts(r){const s=r.trim();try{const t=JSON.parse(s);if(Array.isArray(t)){return t.map(e=>typeof e==="object"&&e!==null?JSON.stringify(e):String(e))}}catch{}if(s.includes(",")&&!s.startsWith("[")){return s.split(",").map(t=>t.trim().replace(/^["']|["']$/g,""))}return null}function refetchIntervalOf(r){let s;for(const t of r.observers??[]){const e=t.options?.refetchInterval;let a=e;if(typeof e==="function"){try{a=e(r)}catch{a=void 0}}if(typeof a==="number"&&a>0)s=s===void 0?a:Math.min(s,a)}return s}function createReactQuerySyncAdapter(r){const s=t=>{const{queryHash:e}=t;const a=r.getQueryCache();let n=e?a.get(e):void 0;if(!n&&typeof e==="string"){const u=looseKeyParts(e);if(u){n=a.getAll().find(c=>{const d=c.queryKey.map(h=>typeof h==="object"?JSON.stringify(h):String(h));return d.length===u.length&&d.every((h,f)=>h===u[f])})}}if(!n){throw new Error(`Query with hash "${e}" not found`)}return n};return{version:2,getSnapshot:()=>({dehydratedState:(0,_dehydrate.dehydrateQueryClient)(r),isOnlineManagerOnline:_reactQuery.onlineManager.isOnline()}),subscribe:t=>{const e=r.getQueryCache().subscribe(t);const a=r.getMutationCache().subscribe(t);const n=_reactQuery.onlineManager.subscribe(t);return()=>{e();a();n()}},actions:{getQueryData:t=>{const{queryHash:e,path:a}=t??{};if(!e)return{found:false,reason:"missing queryHash"};const n=r.getQueryCache().get(e);if(!n)return{found:false,reason:"unknown queryHash"};if(a){const c=(0,_sharedUi.readPath)(n.state.data,a);if(!c.ok)return{found:false,reason:c.error};return{found:true,queryHash:e,path:a,shape:(0,_sharedUi.shapeSummary)(c.value),data:c.value}}if(n.state.data===void 0){const c=n.state.status;const d=n.state.error;return{found:true,queryHash:e,hasData:false,status:c,fetchStatus:n.state.fetchStatus,...d?{error:d instanceof Error?d.message:String(d)}:{},reason:c==="error"?"This query has no data because it FAILED. Report the error, not an empty result.":n.state.fetchStatus==="fetching"?"No data yet \u2014 this query is still fetching.":"This query has never resolved (it may be disabled, or never enabled). It is not empty \u2014 it has nothing."}}const u=(0,_sharedUi.shapeSummary)(n.state.data);return{found:true,queryHash:e,hasData:true,...u?{shape:u}:{},data:(0,_dehydrate.capQueryDetail)(n.state.data)}},listQueries:t=>{const{includeData:e=false,staleOnly:a=false,limit:n}=t??{};const u=r.getQueryCache().getAll();const c=a?u.filter(o=>o.isStale()):u;const d=[...c].sort((o,y)=>{const g=Number(y.getObserversCount()>0)-Number(o.getObserversCount()>0);return g!==0?g:(y.state.dataUpdatedAt??0)-(o.state.dataUpdatedAt??0)});const h=typeof n==="number"&&n>0?d.slice(0,n):d;const f=h.map(o=>{const y=o.state.error;const g=refetchIntervalOf(o);return{queryHash:o.queryHash,queryKey:o.queryKey,status:(0,_getQueryStatusLabel.getQueryStatusLabel)(o),fetchStatus:o.state.fetchStatus,isStale:o.isStale(),observers:o.getObserversCount(),updatedAt:o.state.dataUpdatedAt,...g?{refetchEveryMs:g}:{},error:y?y.message??String(y):void 0,...e?{data:o.state.data}:{},...(0,_sharedUi.shapeSummary)(o.state.data)?{shape:(0,_sharedUi.shapeSummary)(o.state.data)}:{}}});return{queries:f,total:u.length,returned:f.length,includedData:e}},refetch:t=>{const e=s(t);return e.fetch().catch(()=>void 0)},invalidate:t=>r.invalidateQueries(s(t)),reset:t=>r.resetQueries(s(t)),remove:t=>{const e=s(t);const a=r.getQueryCache().findAll(e).some(n=>n.getObserversCount()>0);r.removeQueries(e);return{ok:true,...a?{note:"Removed \u2014 but a screen is still watching this query, and React Query leaves that screen rendering its LAST value (including anything written into the cache before this) until something refetches. Nothing on screen will change on its own. Use `reset` instead when you want the screen to go back to loading and fetch again."}:{}}},setQueryData:t=>{const{data:e,merge:a,force:n,path:u,value:c}=t;const{queryKey:d,queryHash:h}=t;let f=d;if(f===void 0&&typeof h==="string"){const i=r.getQueryCache().get(h);if(!i){return{ok:false,error:`Refused: no query with hash ${h} is in the cache. Read listQueries for the current hashes \u2014 a query that has been removed or whose key includes changing params (a search term, a cart payload) will not match an older hash.`}}f=i.queryKey}if(f===void 0){return{ok:false,error:`Refused: no query was named. Send \`queryKey\` (the array from listQueries) or \`queryHash\` (its string form).`}}const o=r.getQueryData(f);const y=r.getQueryCache().find({queryKey:f,exact:true});if(o===void 0&&y&&(e!==void 0||u!==void 0)){const i=y;const l=i?.state.status;const m=l==="error"?`it FAILED${i?.state.error?` (${i.state.error instanceof Error?i.state.error.message:String(i.state.error)})`:""}`:l==="pending"?"it has never resolved (it may be disabled, or still loading)":"it holds no data";return{ok:false,error:`Refused: this query has no data to edit \u2014 ${m}. There is nothing to merge into. Fix the cause first (restoreError, or let it fetch), or send force:true with the COMPLETE value if you mean to seed the cache from nothing.`,status:l}}if(e===void 0&&u===void 0){return{ok:false,error:`Refused: no change was described. Send \`data\` (with merge:true for a partial edit), or \`path\` and \`value\` to set one value.`}}let g=e;if(u!==void 0){if(c===void 0){return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${u}" to; if you mean to clear it, send value:null and the field must already be nullable.`}}const i=(0,_sharedUi.patchFromPath)(o,u,c);if(!i.ok)return{ok:false,error:`Refused: ${i.error}`};g=i.patch}if(a||u!==void 0){const i=n?{patch:g,notes:[],error:void 0}:(0,_sharedUi.expandKeyedArrays)(o,g);if(i.error){return{ok:false,error:`Refused: ${i.error}`}}const l=i.patch;if(!n){const p=(0,_sharedUi.typedEditViolations)(o,l,{noun:"data"});if(p.length>0){const b=(0,_sharedUi.suggestedPatch)(l,p);return{ok:false,error:(0,_sharedUi.refusalText)(p,"data",b),violations:p,...b?{suggestedData:b}:{}}}}const m=deepMerge(o,l);const v=(0,_sharedUi.unshapedLists)(o).filter(p=>touchesList(l,p));r.setQueryData(f,m,{updatedAt:Date.now()});return{ok:true,mode:"merge",...u!==void 0?{path:u}:{},changedKeys:isPlainObject(l)?Object.keys(l):void 0,...i.notes.length?{keyed:i.notes}:{},...v.length?{unchecked:v.map(p=>`\`${p}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the screen renders a field you left out, it will render undefined \u2014 read the query back and compare against how the screen uses it.`)}:{}}}if(!n&&isPlainObject(o)&&isPlainObject(e)){const i=Object.keys(o).filter(l=>!(l in e));if(i.length>0){return{ok:false,error:`Refused: the new value drops ${i.length} top-level field(s) the cached value has (${i.slice(0,8).join(", ")}${i.length>8?", \u2026":""}). A screen rendering those fields would crash. To change some fields, send merge:true with ONLY the fields that change. To really replace the whole value, send force:true.`,missingKeys:i}}}r.setQueryData(f,e,{updatedAt:Date.now()});return{ok:true,mode:"replace"}},triggerError:t=>{const e=s(t);const a=e.options;e.setState({status:"error",error:new Error("Unknown error from devtools"),fetchMeta:{...e.state.fetchMeta,__previousQueryOptions:a}})},restoreError:t=>{void r.resetQueries(s(t)).catch(()=>void 0);return{restored:true}},triggerLoading:t=>{const e=s(t);const a=e.options;e.fetch({...a,queryFn:()=>new Promise(()=>{}),gcTime:-1}).catch(()=>void 0);e.setState({data:void 0,status:"pending",fetchMeta:{...e.state.fetchMeta,__previousQueryOptions:a}})},restoreLoading:t=>{const e=s(t);const a=e.state;const n=e.state.fetchMeta?e.state.fetchMeta.__previousQueryOptions:null;e.cancel({silent:true});e.setState({...a,fetchStatus:"idle",fetchMeta:null});if(n){e.fetch(n).catch(()=>void 0)}},clearQueryCache:()=>{const t=r.getQueryCache().getAll().filter(e=>e.getObserversCount()>0).length;r.getQueryCache().clear();return{ok:true,cleared:true,...t?{note:`Cleared \u2014 but ${t} quer${t===1?"y is":"ies are"} still being watched by a screen, and React Query leaves those screens rendering their LAST value until something refetches. The cache is empty; the app on screen is not. Use \`reset\` on a query when you want its screen to reload.`}:{}}},clearMutationCache:()=>{r.getMutationCache().clear()},setOnline:t=>{const{online:e}=t;_reactQuery.onlineManager.setOnline(e)}}}}
@@ -1 +1 @@
1
- "use strict";import{expandKeyedArrays as O,patchFromPath as M,readPath as $,refusalText as D,shapeSummary as b,suggestedPatch as K,typedEditViolations as R,unshapedLists as j}from"@buoy-gg/shared-ui";import{onlineManager as Q}from"@tanstack/react-query";import{capQueryDetail as E,dehydrateQueryClient as T}from"./dehydrate";import{getQueryStatusLabel as L}from"../utils/getQueryStatusLabel";function N(r,a){let t=r;for(const e of a.split(".")){if(!t||typeof t!=="object"||Array.isArray(t))return false;if(!(e in t))return false;t=t[e]}return Array.isArray(t)?t.length>0:!!t&&typeof t==="object"}const m=r=>!!r&&typeof r==="object"&&!Array.isArray(r);function S(r){if(Array.isArray(r))return"array";if(r===null)return"null";if(typeof r==="object")return"object";return typeof r}function k(r,a,t="",e={shrunk:[],breaks:[]}){if(Array.isArray(r)&&Array.isArray(a)){if(a.length>0&&a.length<r.length){e.shrunk.push({path:t||"(root)",have:r.length,sent:a.length})}return a}if(!m(r)||!m(a))return a;const s={...r};for(const[n,u]of Object.entries(a)){const c=t?`${t}.${n}`:n;if(n in r){const d=S(r[n]);const f=S(u);if((d==="array"||d==="object")&&d!==f){e.breaks.push({path:c,from:d,to:f})}s[n]=k(r[n],u,c,e)}else{s[n]=u}}return s}function x(r){const a=r.trim();try{const t=JSON.parse(a);if(Array.isArray(t)){return t.map(e=>typeof e==="object"&&e!==null?JSON.stringify(e):String(e))}}catch{}if(a.includes(",")&&!a.startsWith("[")){return a.split(",").map(t=>t.trim().replace(/^["']|["']$/g,""))}return null}function H(r){let a;for(const t of r.observers??[]){const e=t.options?.refetchInterval;let s=e;if(typeof e==="function"){try{s=e(r)}catch{s=void 0}}if(typeof s==="number"&&s>0)a=a===void 0?s:Math.min(a,s)}return a}export function createReactQuerySyncAdapter(r){const a=t=>{const{queryHash:e}=t;const s=r.getQueryCache();let n=e?s.get(e):void 0;if(!n&&typeof e==="string"){const u=x(e);if(u){n=s.getAll().find(c=>{const d=c.queryKey.map(f=>typeof f==="object"?JSON.stringify(f):String(f));return d.length===u.length&&d.every((f,h)=>f===u[h])})}}if(!n){throw new Error(`Query with hash "${e}" not found`)}return n};return{version:2,getSnapshot:()=>({dehydratedState:T(r),isOnlineManagerOnline:Q.isOnline()}),subscribe:t=>{const e=r.getQueryCache().subscribe(t);const s=r.getMutationCache().subscribe(t);const n=Q.subscribe(t);return()=>{e();s();n()}},actions:{getQueryData:t=>{const{queryHash:e,path:s}=t??{};if(!e)return{found:false,reason:"missing queryHash"};const n=r.getQueryCache().get(e);if(!n)return{found:false,reason:"unknown queryHash"};if(s){const c=$(n.state.data,s);if(!c.ok)return{found:false,reason:c.error};return{found:true,queryHash:e,path:s,shape:b(c.value),data:c.value}}if(n.state.data===void 0){const c=n.state.status;const d=n.state.error;return{found:true,queryHash:e,hasData:false,status:c,fetchStatus:n.state.fetchStatus,...d?{error:d instanceof Error?d.message:String(d)}:{},reason:c==="error"?"This query has no data because it FAILED. Report the error, not an empty result.":n.state.fetchStatus==="fetching"?"No data yet \u2014 this query is still fetching.":"This query has never resolved (it may be disabled, or never enabled). It is not empty \u2014 it has nothing."}}const u=b(n.state.data);return{found:true,queryHash:e,hasData:true,...u?{shape:u}:{},data:E(n.state.data)}},listQueries:t=>{const{includeData:e=false,staleOnly:s=false,limit:n}=t??{};const u=r.getQueryCache().getAll();const c=s?u.filter(o=>o.isStale()):u;const d=[...c].sort((o,y)=>{const g=Number(y.getObserversCount()>0)-Number(o.getObserversCount()>0);return g!==0?g:(y.state.dataUpdatedAt??0)-(o.state.dataUpdatedAt??0)});const f=typeof n==="number"&&n>0?d.slice(0,n):d;const h=f.map(o=>{const y=o.state.error;const g=H(o);return{queryHash:o.queryHash,queryKey:o.queryKey,status:L(o),fetchStatus:o.state.fetchStatus,isStale:o.isStale(),observers:o.getObserversCount(),updatedAt:o.state.dataUpdatedAt,...g?{refetchEveryMs:g}:{},error:y?y.message??String(y):void 0,...e?{data:o.state.data}:{},...b(o.state.data)?{shape:b(o.state.data)}:{}}});return{queries:h,total:u.length,returned:h.length,includedData:e}},refetch:t=>{const e=a(t);return e.fetch().catch(()=>void 0)},invalidate:t=>r.invalidateQueries(a(t)),reset:t=>r.resetQueries(a(t)),remove:t=>{const e=a(t);const s=r.getQueryCache().findAll(e).some(n=>n.getObserversCount()>0);r.removeQueries(e);return{ok:true,...s?{note:"Removed \u2014 but a screen is still watching this query, and React Query leaves that screen rendering its LAST value (including anything written into the cache before this) until something refetches. Nothing on screen will change on its own. Use `reset` instead when you want the screen to go back to loading and fetch again."}:{}}},setQueryData:t=>{const{data:e,merge:s,force:n,path:u,value:c}=t;const{queryKey:d,queryHash:f}=t;let h=d;if(h===void 0&&typeof f==="string"){const i=r.getQueryCache().get(f);if(!i){return{ok:false,error:`Refused: no query with hash ${f} is in the cache. Read listQueries for the current hashes \u2014 a query that has been removed or whose key includes changing params (a search term, a cart payload) will not match an older hash.`}}h=i.queryKey}if(h===void 0){return{ok:false,error:`Refused: no query was named. Send \`queryKey\` (the array from listQueries) or \`queryHash\` (its string form).`}}const o=r.getQueryData(h);const y=r.getQueryCache().find({queryKey:h,exact:true});if(o===void 0&&y&&(e!==void 0||u!==void 0)){const i=y;const l=i?.state.status;const v=l==="error"?`it FAILED${i?.state.error?` (${i.state.error instanceof Error?i.state.error.message:String(i.state.error)})`:""}`:l==="pending"?"it has never resolved (it may be disabled, or still loading)":"it holds no data";return{ok:false,error:`Refused: this query has no data to edit \u2014 ${v}. There is nothing to merge into. Fix the cause first (restoreError, or let it fetch), or send force:true with the COMPLETE value if you mean to seed the cache from nothing.`,status:l}}if(e===void 0&&u===void 0){return{ok:false,error:`Refused: no change was described. Send \`data\` (with merge:true for a partial edit), or \`path\` and \`value\` to set one value.`}}let g=e;if(u!==void 0){if(c===void 0){return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${u}" to; if you mean to clear it, send value:null and the field must already be nullable.`}}const i=M(o,u,c);if(!i.ok)return{ok:false,error:`Refused: ${i.error}`};g=i.patch}if(s||u!==void 0){const i=n?{patch:g,notes:[],error:void 0}:O(o,g);if(i.error){return{ok:false,error:`Refused: ${i.error}`}}const l=i.patch;if(!n){const p=R(o,l,{noun:"data"});if(p.length>0){const w=K(l,p);return{ok:false,error:D(p,"data",w),violations:p,...w?{suggestedData:w}:{}}}}const v=k(o,l);const A=j(o).filter(p=>N(l,p));r.setQueryData(h,v,{updatedAt:Date.now()});return{ok:true,mode:"merge",...u!==void 0?{path:u}:{},changedKeys:m(l)?Object.keys(l):void 0,...i.notes.length?{keyed:i.notes}:{},...A.length?{unchecked:A.map(p=>`\`${p}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the screen renders a field you left out, it will render undefined \u2014 read the query back and compare against how the screen uses it.`)}:{}}}if(!n&&m(o)&&m(e)){const i=Object.keys(o).filter(l=>!(l in e));if(i.length>0){return{ok:false,error:`Refused: the new value drops ${i.length} top-level field(s) the cached value has (${i.slice(0,8).join(", ")}${i.length>8?", \u2026":""}). A screen rendering those fields would crash. To change some fields, send merge:true with ONLY the fields that change. To really replace the whole value, send force:true.`,missingKeys:i}}}r.setQueryData(h,e,{updatedAt:Date.now()});return{ok:true,mode:"replace"}},triggerError:t=>{const e=a(t);const s=e.options;e.setState({status:"error",error:new Error("Unknown error from devtools"),fetchMeta:{...e.state.fetchMeta,__previousQueryOptions:s}})},restoreError:t=>r.resetQueries(a(t)),triggerLoading:t=>{const e=a(t);const s=e.options;e.fetch({...s,queryFn:()=>new Promise(()=>{}),gcTime:-1}).catch(()=>void 0);e.setState({data:void 0,status:"pending",fetchMeta:{...e.state.fetchMeta,__previousQueryOptions:s}})},restoreLoading:t=>{const e=a(t);const s=e.state;const n=e.state.fetchMeta?e.state.fetchMeta.__previousQueryOptions:null;e.cancel({silent:true});e.setState({...s,fetchStatus:"idle",fetchMeta:null});if(n){e.fetch(n).catch(()=>void 0)}},clearQueryCache:()=>{const t=r.getQueryCache().getAll().filter(e=>e.getObserversCount()>0).length;r.getQueryCache().clear();return{ok:true,cleared:true,...t?{note:`Cleared \u2014 but ${t} quer${t===1?"y is":"ies are"} still being watched by a screen, and React Query leaves those screens rendering their LAST value until something refetches. The cache is empty; the app on screen is not. Use \`reset\` on a query when you want its screen to reload.`}:{}}},clearMutationCache:()=>{r.getMutationCache().clear()},setOnline:t=>{const{online:e}=t;Q.setOnline(e)}}}}
1
+ "use strict";import{expandKeyedArrays as O,patchFromPath as M,readPath as $,refusalText as D,shapeSummary as b,suggestedPatch as K,typedEditViolations as R,unshapedLists as j}from"@buoy-gg/shared-ui";import{onlineManager as Q}from"@tanstack/react-query";import{capQueryDetail as E,dehydrateQueryClient as T}from"./dehydrate";import{getQueryStatusLabel as L}from"../utils/getQueryStatusLabel";function N(r,a){let t=r;for(const e of a.split(".")){if(!t||typeof t!=="object"||Array.isArray(t))return false;if(!(e in t))return false;t=t[e]}return Array.isArray(t)?t.length>0:!!t&&typeof t==="object"}const m=r=>!!r&&typeof r==="object"&&!Array.isArray(r);function S(r){if(Array.isArray(r))return"array";if(r===null)return"null";if(typeof r==="object")return"object";return typeof r}function k(r,a,t="",e={shrunk:[],breaks:[]}){if(Array.isArray(r)&&Array.isArray(a)){if(a.length>0&&a.length<r.length){e.shrunk.push({path:t||"(root)",have:r.length,sent:a.length})}return a}if(!m(r)||!m(a))return a;const s={...r};for(const[n,u]of Object.entries(a)){const c=t?`${t}.${n}`:n;if(n in r){const d=S(r[n]);const f=S(u);if((d==="array"||d==="object")&&d!==f){e.breaks.push({path:c,from:d,to:f})}s[n]=k(r[n],u,c,e)}else{s[n]=u}}return s}function x(r){const a=r.trim();try{const t=JSON.parse(a);if(Array.isArray(t)){return t.map(e=>typeof e==="object"&&e!==null?JSON.stringify(e):String(e))}}catch{}if(a.includes(",")&&!a.startsWith("[")){return a.split(",").map(t=>t.trim().replace(/^["']|["']$/g,""))}return null}function H(r){let a;for(const t of r.observers??[]){const e=t.options?.refetchInterval;let s=e;if(typeof e==="function"){try{s=e(r)}catch{s=void 0}}if(typeof s==="number"&&s>0)a=a===void 0?s:Math.min(a,s)}return a}export function createReactQuerySyncAdapter(r){const a=t=>{const{queryHash:e}=t;const s=r.getQueryCache();let n=e?s.get(e):void 0;if(!n&&typeof e==="string"){const u=x(e);if(u){n=s.getAll().find(c=>{const d=c.queryKey.map(f=>typeof f==="object"?JSON.stringify(f):String(f));return d.length===u.length&&d.every((f,h)=>f===u[h])})}}if(!n){throw new Error(`Query with hash "${e}" not found`)}return n};return{version:2,getSnapshot:()=>({dehydratedState:T(r),isOnlineManagerOnline:Q.isOnline()}),subscribe:t=>{const e=r.getQueryCache().subscribe(t);const s=r.getMutationCache().subscribe(t);const n=Q.subscribe(t);return()=>{e();s();n()}},actions:{getQueryData:t=>{const{queryHash:e,path:s}=t??{};if(!e)return{found:false,reason:"missing queryHash"};const n=r.getQueryCache().get(e);if(!n)return{found:false,reason:"unknown queryHash"};if(s){const c=$(n.state.data,s);if(!c.ok)return{found:false,reason:c.error};return{found:true,queryHash:e,path:s,shape:b(c.value),data:c.value}}if(n.state.data===void 0){const c=n.state.status;const d=n.state.error;return{found:true,queryHash:e,hasData:false,status:c,fetchStatus:n.state.fetchStatus,...d?{error:d instanceof Error?d.message:String(d)}:{},reason:c==="error"?"This query has no data because it FAILED. Report the error, not an empty result.":n.state.fetchStatus==="fetching"?"No data yet \u2014 this query is still fetching.":"This query has never resolved (it may be disabled, or never enabled). It is not empty \u2014 it has nothing."}}const u=b(n.state.data);return{found:true,queryHash:e,hasData:true,...u?{shape:u}:{},data:E(n.state.data)}},listQueries:t=>{const{includeData:e=false,staleOnly:s=false,limit:n}=t??{};const u=r.getQueryCache().getAll();const c=s?u.filter(o=>o.isStale()):u;const d=[...c].sort((o,y)=>{const g=Number(y.getObserversCount()>0)-Number(o.getObserversCount()>0);return g!==0?g:(y.state.dataUpdatedAt??0)-(o.state.dataUpdatedAt??0)});const f=typeof n==="number"&&n>0?d.slice(0,n):d;const h=f.map(o=>{const y=o.state.error;const g=H(o);return{queryHash:o.queryHash,queryKey:o.queryKey,status:L(o),fetchStatus:o.state.fetchStatus,isStale:o.isStale(),observers:o.getObserversCount(),updatedAt:o.state.dataUpdatedAt,...g?{refetchEveryMs:g}:{},error:y?y.message??String(y):void 0,...e?{data:o.state.data}:{},...b(o.state.data)?{shape:b(o.state.data)}:{}}});return{queries:h,total:u.length,returned:h.length,includedData:e}},refetch:t=>{const e=a(t);return e.fetch().catch(()=>void 0)},invalidate:t=>r.invalidateQueries(a(t)),reset:t=>r.resetQueries(a(t)),remove:t=>{const e=a(t);const s=r.getQueryCache().findAll(e).some(n=>n.getObserversCount()>0);r.removeQueries(e);return{ok:true,...s?{note:"Removed \u2014 but a screen is still watching this query, and React Query leaves that screen rendering its LAST value (including anything written into the cache before this) until something refetches. Nothing on screen will change on its own. Use `reset` instead when you want the screen to go back to loading and fetch again."}:{}}},setQueryData:t=>{const{data:e,merge:s,force:n,path:u,value:c}=t;const{queryKey:d,queryHash:f}=t;let h=d;if(h===void 0&&typeof f==="string"){const i=r.getQueryCache().get(f);if(!i){return{ok:false,error:`Refused: no query with hash ${f} is in the cache. Read listQueries for the current hashes \u2014 a query that has been removed or whose key includes changing params (a search term, a cart payload) will not match an older hash.`}}h=i.queryKey}if(h===void 0){return{ok:false,error:`Refused: no query was named. Send \`queryKey\` (the array from listQueries) or \`queryHash\` (its string form).`}}const o=r.getQueryData(h);const y=r.getQueryCache().find({queryKey:h,exact:true});if(o===void 0&&y&&(e!==void 0||u!==void 0)){const i=y;const l=i?.state.status;const v=l==="error"?`it FAILED${i?.state.error?` (${i.state.error instanceof Error?i.state.error.message:String(i.state.error)})`:""}`:l==="pending"?"it has never resolved (it may be disabled, or still loading)":"it holds no data";return{ok:false,error:`Refused: this query has no data to edit \u2014 ${v}. There is nothing to merge into. Fix the cause first (restoreError, or let it fetch), or send force:true with the COMPLETE value if you mean to seed the cache from nothing.`,status:l}}if(e===void 0&&u===void 0){return{ok:false,error:`Refused: no change was described. Send \`data\` (with merge:true for a partial edit), or \`path\` and \`value\` to set one value.`}}let g=e;if(u!==void 0){if(c===void 0){return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${u}" to; if you mean to clear it, send value:null and the field must already be nullable.`}}const i=M(o,u,c);if(!i.ok)return{ok:false,error:`Refused: ${i.error}`};g=i.patch}if(s||u!==void 0){const i=n?{patch:g,notes:[],error:void 0}:O(o,g);if(i.error){return{ok:false,error:`Refused: ${i.error}`}}const l=i.patch;if(!n){const p=R(o,l,{noun:"data"});if(p.length>0){const w=K(l,p);return{ok:false,error:D(p,"data",w),violations:p,...w?{suggestedData:w}:{}}}}const v=k(o,l);const A=j(o).filter(p=>N(l,p));r.setQueryData(h,v,{updatedAt:Date.now()});return{ok:true,mode:"merge",...u!==void 0?{path:u}:{},changedKeys:m(l)?Object.keys(l):void 0,...i.notes.length?{keyed:i.notes}:{},...A.length?{unchecked:A.map(p=>`\`${p}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the screen renders a field you left out, it will render undefined \u2014 read the query back and compare against how the screen uses it.`)}:{}}}if(!n&&m(o)&&m(e)){const i=Object.keys(o).filter(l=>!(l in e));if(i.length>0){return{ok:false,error:`Refused: the new value drops ${i.length} top-level field(s) the cached value has (${i.slice(0,8).join(", ")}${i.length>8?", \u2026":""}). A screen rendering those fields would crash. To change some fields, send merge:true with ONLY the fields that change. To really replace the whole value, send force:true.`,missingKeys:i}}}r.setQueryData(h,e,{updatedAt:Date.now()});return{ok:true,mode:"replace"}},triggerError:t=>{const e=a(t);const s=e.options;e.setState({status:"error",error:new Error("Unknown error from devtools"),fetchMeta:{...e.state.fetchMeta,__previousQueryOptions:s}})},restoreError:t=>{void r.resetQueries(a(t)).catch(()=>void 0);return{restored:true}},triggerLoading:t=>{const e=a(t);const s=e.options;e.fetch({...s,queryFn:()=>new Promise(()=>{}),gcTime:-1}).catch(()=>void 0);e.setState({data:void 0,status:"pending",fetchMeta:{...e.state.fetchMeta,__previousQueryOptions:s}})},restoreLoading:t=>{const e=a(t);const s=e.state;const n=e.state.fetchMeta?e.state.fetchMeta.__previousQueryOptions:null;e.cancel({silent:true});e.setState({...s,fetchStatus:"idle",fetchMeta:null});if(n){e.fetch(n).catch(()=>void 0)}},clearQueryCache:()=>{const t=r.getQueryCache().getAll().filter(e=>e.getObserversCount()>0).length;r.getQueryCache().clear();return{ok:true,cleared:true,...t?{note:`Cleared \u2014 but ${t} quer${t===1?"y is":"ies are"} still being watched by a screen, and React Query leaves those screens rendering their LAST value until something refetches. The cache is empty; the app on screen is not. Use \`reset\` on a query when you want its screen to reload.`}:{}}},clearMutationCache:()=>{r.getMutationCache().clear()},setOnline:t=>{const{online:e}=t;Q.setOnline(e)}}}}
@@ -146,7 +146,9 @@ export declare function createReactQuerySyncAdapter(queryClient: QueryClient): {
146
146
  missingKeys?: undefined;
147
147
  };
148
148
  triggerError: (params: unknown) => void;
149
- restoreError: (params: unknown) => Promise<void>;
149
+ restoreError: (params: unknown) => {
150
+ restored: boolean;
151
+ };
150
152
  triggerLoading: (params: unknown) => void;
151
153
  restoreLoading: (params: unknown) => void;
152
154
  clearQueryCache: () => {
package/lib/web/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  To see queries here:
4
4
  \u2022 Make API calls using useQuery
5
5
  \u2022 Ensure queries are within QueryClientProvider
6
- \u2022 Check console for debugging info`}}),contentContainerStyle:zo.queryListContent})]})}var zo=T.create({queryListContainer:{flex:1,backgroundColor:"transparent"},queryListContent:{padding:8,backgroundColor:"transparent",flexGrow:1}});import{ToolFooter as yl,useSafeAreaInsets as hl}from"@buoy-gg/shared-ui/web";import{jsx as ir}from"react/jsx-runtime";function Lo({activeFilter:e,onFilterChange:t,isFloatingMode:r=true,size:o="default"}){let a=hl({minBottom:16});return ir(yl,{floating:r,safeArea:false,paddingBottom:r?0:a.bottom,style:Bo.filterFooter,children:ir(h,{style:Bo.filterContainer,children:ir(fo,{activeFilter:e,onFilterChange:t,size:o})})})}var Bo=T.create({filterFooter:{paddingTop:8,paddingHorizontal:0},filterContainer:{minHeight:32,justifyContent:"center"}});import{useCallback as fl,useMemo as lt}from"react";import{DynamicFilterView as ml,buoyColors as Ae,monoFont as pl,night as sr}from"@buoy-gg/shared-ui/web";import{XCircle as Ho,Clock as lr,RefreshCw as gl,Globe as bl,Zap as vl,Filter as Sl,Eye as Cl}from"@buoy-gg/shared-ui/web";import{jsx as ur}from"react/jsx-runtime";var xl=()=>false;function wl({queries:e,activeFilter:t,onFilterChange:r,ignoredPatterns:o,onPatternToggle:a,includedPatterns:n,onIncludedPatternToggle:s,isTeamPattern:u=xl}){let l=fl(y=>u(y)?ur(h,{accessibilityLabel:"Set by your team on buoy.gg",style:[Wo.teamBadge,{borderColor:`${sr.color.accent}60`,backgroundColor:`${sr.color.accent}15`}],children:ur(v,{style:[Wo.teamBadgeText,{color:sr.color.accent}],children:"TEAM"})}):null,[u]),c=lt(()=>{let y={all:e.length,disabled:0,fresh:0,stale:0,fetching:0,paused:0,inactive:0,error:0};return e.forEach(m=>{let g=se(m);g==="disabled"?y.disabled++:g==="error"?y.error++:g==="fresh"?y.fresh++:g==="stale"?y.stale++:g==="fetching"?y.fetching++:g==="paused"?y.paused++:g==="inactive"&&y.inactive++}),y},[e]),i=lt(()=>{let y=new Set;return e.forEach(m=>{if(!m?.queryKey)return;(Array.isArray(m.queryKey)?m.queryKey:[m.queryKey]).forEach(g=>{if(g!=null){let p=String(g);/^\d+$/.test(p)||y.add(p)}})}),Array.from(y).sort().slice(0,50)},[e]),d=lt(()=>i,[i]),f=lt(()=>{let y=e;return n.size>0&&(y=y.filter(m=>{if(!m?.queryKey)return false;let g=(Array.isArray(m.queryKey)?m.queryKey:[m.queryKey]).filter(p=>p!=null).map(p=>String(p)).join(" ").toLowerCase();return Array.from(n).some(p=>g.includes(p.toLowerCase()))})),o.size>0&&(y=y.filter(m=>{if(!m?.queryKey)return true;let g=(Array.isArray(m.queryKey)?m.queryKey:[m.queryKey]).filter(p=>p!=null).map(p=>String(p)).join(" ").toLowerCase();return!Array.from(o).some(p=>g.includes(p.toLowerCase()))})),y.length},[e,n,o]),b=lt(()=>({filterSummarySection:{enabled:true,totalCount:e.length,filteredCount:f,includePatterns:n,excludePatterns:o},sections:[{id:"status",title:"Status",type:"status",data:[{id:"status::all",label:"All",count:c.all,icon:bl,color:Ae.primary,isActive:!t||t==="all"},{id:"status::disabled",label:"Disabled",count:c.disabled,icon:Ho,color:Ae.textMuted,isActive:t==="disabled"},{id:"status::fresh",label:"Fresh",count:c.fresh,icon:vl,color:Ae.success,isActive:t==="fresh"},{id:"status::stale",label:"Stale",count:c.stale,icon:lr,color:Ae.warning,isActive:t==="stale"},{id:"status::fetching",label:"Fetching",count:c.fetching,icon:gl,color:Ae.primary,isActive:t==="fetching"},{id:"status::paused",label:"Paused",count:c.paused,icon:lr,color:Ae.textMuted,isActive:t==="paused"},{id:"status::inactive",label:"Inactive",count:c.inactive,icon:lr,color:Ae.textSecondary,isActive:t==="inactive"},{id:"status::error",label:"Error",count:c.error,icon:Ho,color:Ae.error,isActive:t==="error"}]}],addFilterSection:{enabled:true,placeholder:"Enter pattern to exclude...",title:"EXCLUDE FILTERS",icon:Sl},includeOnlySection:{enabled:true,title:"INCLUDE ONLY FILTERS",description:"Show ONLY queries matching these patterns. All non-matching queries will be hidden.",placeholder:"Enter pattern to include...",icon:Cl,patterns:n,onPatternToggle:s,onPatternAdd:s,renderPatternMeta:l},availableItemsSection:{enabled:true,title:"AVAILABLE QUERY KEYS",emptyMessage:"No queries found. Query keys will appear here once queries are active.",items:d},howItWorksSection:{enabled:true,title:"HOW QUERY FILTERS WORK",description:"There are two types of query key filters:",examples:["","INCLUDE ONLY (green):","\u2022 Shows ONLY queries matching the pattern","\u2022 Example: 'rewards' \u2192 shows only reward queries","\u2022 When active, non-matching queries are hidden","","EXCLUDE (blue):","\u2022 Hides queries matching the pattern","\u2022 Example: 'analytics' \u2192 hides analytics queries","","Filters are case-insensitive and match partial keys."]},activePatterns:o,renderPatternMeta:l}),[c,t,o,n,d,s,e.length,f,l]);return ur(ml,{...b,onFilterChange:y=>{let[m,g]=y.split("::");m==="status"?r(g==="all"||t===g?null:g):m==="suggestion"&&a(g)},onPatternToggle:a,onPatternAdd:a})}var Wo=T.create({teamBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1},teamBadgeText:{fontSize:9,fontFamily:pl,fontWeight:"700",letterSpacing:.5}});import{useState as ut,useCallback as ct,useEffect as At,useMemo as jo,useRef as Vo}from"react";import{devToolsStorageKeys as Ee,persistentStorage as Et,useTeamList as $o}from"@buoy-gg/shared-ui/web";import{jsx as pe,jsxs as ql}from"react/jsx-runtime";function No({visible:e,selectedQueryKey:t,onQuerySelect:r,onClose:o,onMinimize:a,activeFilter:n,onFilterChange:s,enableSharedModalDimensions:u=false,onTabChange:l,searchText:c="",onSearchChange:i}){let d=cn(),f=Mr(t),b=St(),y=ct(()=>{d.getQueryCache().clear()},[d]),[m,g]=ut(null),p=n??m,S=s??g,[w,C]=ut(false),[q,A]=ut(new Set),[j,Qe]=ut(new Set),M=Vo(null),ae=Vo(null);At(()=>{(async()=>{try{let x=await Et.getItem(Ee.reactQuery.ignoredPatterns());if(x){let R=JSON.parse(x);Array.isArray(R)&&(M.current=JSON.stringify(Array.from(new Set(R))),A(new Set(R)))}}catch(x){console.error("[Buoy]","Failed to load ignored patterns:",x)}finally{M.current??(M.current="[]")}})()},[]),At(()=>{(async()=>{try{let x=await Et.getItem(Ee.reactQuery.includedPatterns());if(x){let R=JSON.parse(x);Array.isArray(R)&&(ae.current=JSON.stringify(Array.from(new Set(R))),Qe(new Set(R)))}}catch(x){console.error("[Buoy]","Failed to load included patterns:",x)}finally{ae.current??(ae.current="[]")}})()},[]),At(()=>{let x=JSON.stringify(Array.from(q));if(M.current===null||M.current===x)return;M.current=x,(async()=>{try{await Et.setItem(Ee.reactQuery.ignoredPatterns(),x)}catch(R){console.error("[Buoy]","Failed to save ignored patterns:",R)}})()},[q]),At(()=>{let x=JSON.stringify(Array.from(j));if(ae.current===null||ae.current===x)return;ae.current=x,(async()=>{try{await Et.setItem(Ee.reactQuery.includedPatterns(),x)}catch(R){console.error("[Buoy]","Failed to save included patterns:",R)}})()},[j]);let ye=$o(Ee.reactQuery.ignoredPatterns()),he=$o(Ee.reactQuery.includedPatterns()),ne=jo(()=>ye.length?new Set([...q,...ye]):q,[q,ye]),ie=jo(()=>he.length?new Set([...j,...he]):j,[j,he]),ht=ct(x=>ye.includes(x)&&!q.has(x)||he.includes(x)&&!j.has(x),[ye,he,q,j]),ft=ct(x=>{A(R=>{if(!R.has(x)&&ye.includes(x))return R;let fe=new Set(R);return fe.has(x)?fe.delete(x):fe.add(x),fe})},[ye]),Lt=ct(x=>{Qe(R=>{if(!R.has(x)&&he.includes(x))return R;let fe=new Set(R);return fe.has(x)?fe.delete(x):fe.add(x),fe})},[he]),[mt,Ua]=ut("bottomSheet"),_a=u?Ee.reactQuery.modal():Ee.reactQuery.browserModal(),Ja=ct(x=>{Ua(x)},[]),Ga=yn({minBottom:16}),Ya=mt==="floating"?56:48+Ga.bottom;if(!e)return null;let Xa=()=>{if(w){let x=[{key:"filters",label:"Filters"}];return ql(Bt,{children:[pe(Bt.Navigation,{onBack:()=>C(false)}),pe(Bt.Content,{title:"",noMargin:true,children:pe(hn,{tabs:x,activeTab:"filters",testIDPrefix:"buoy-rq-filterview-tab",onTabChange:()=>{}})})]})}return pe(tt,{selectedQuery:f,activeTab:"queries",onTabChange:l,onBack:()=>r(void 0),searchText:c,onSearchChange:i,onFilterPress:()=>C(true),hasActiveFilters:p!==null||ne.size>0||ie.size>0,onClearCache:y})},Za=pe(Lo,{activeFilter:p,onFilterChange:S,isFloatingMode:mt==="floating"});return pe(dn,{visible:e,onClose:o,onMinimize:a,persistenceKey:_a,header:{customContent:Xa(),showToggleButton:true},onModeChange:Ja,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:!w,styles:{},footer:w?void 0:Za,footerHeight:w?void 0:Ya,children:pe(h,{style:Ml.container,children:w?pe(wl,{queries:b,activeFilter:p,onFilterChange:S,ignoredPatterns:ne,onPatternToggle:ft,includedPatterns:ie,onIncludedPatternToggle:Lt,isTeamPattern:ht}):pe(Ko,{selectedQuery:f,onQuerySelect:r,activeFilter:p,searchText:c,ignoredPatterns:ne,includedPatterns:ie,onFilterPress:()=>C(true)})})})}var Ml=T.create({container:{flex:1,backgroundColor:"transparent"}});import{JsModal as Tl,devToolsStorageKeys as Uo,useSafeAreaInsets as Al}from"@buoy-gg/shared-ui/web";import{useQueryClient as _o}from"@tanstack/react-query";import{useSafeAreaInsets as Jo,night as K,monoFont as Go}from"@buoy-gg/shared-ui/web";import{useMemo as El}from"react";function cr(e,t,r){return El(()=>{let o=e.state.status;return[{label:"Refetch",variant:"refetch",disabled:se(e)==="fetching",onPress:()=>Yt({query:e})},{label:e.state.fetchStatus==="fetching"?"Restore Loading":"Trigger Loading",variant:"triggerLoading",disabled:false,onPress:()=>Gt({query:e})},{label:o==="error"?"Restore Error":"Trigger Error",variant:"triggerError",disabled:o==="pending",onPress:()=>Xt({query:e,queryClient:t})}]},[e,t,r])}import{DataViewer as Dl}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as Rl,jsx as k,jsxs as _e}from"react/jsx-runtime";function Yo({selectedQuery:e,isFloatingMode:t,disableInternalFooter:r=false,queryVersion:o}){let a=Jo({minBottom:16}),n=_o(),s=cr(e,n,o);return _e(Rl,{children:[_e(be,{testID:"buoy-rq-detail-scroll",accessibilityLabel:"Data editor mode",accessibilityHint:"View data editor mode","sentry-label":"ignore data editor mode",style:I.explorerScrollContainer,contentContainerStyle:[I.explorerScrollContent,!r&&{paddingBottom:72}],children:[_e(h,{style:I.section,children:[k(Il,{visible:!!e.state.data,selectedQuery:e,queryVersion:o}),k(Ql,{visible:!e.state.data,selectedQuery:e})]}),k(h,{style:I.section,children:k(_t,{query:e})}),k(h,{style:I.section,children:_e(h,{style:I.queryExplorerContainer,children:[k(v,{testID:"buoy-rq-query-explorer-header",style:I.queryExplorerHeader,children:"Query Explorer"}),k(h,{style:I.queryExplorerContent,children:k(Dl,{title:"",data:e,maxDepth:10,rawMode:true,showTypeFilter:true,initialExpanded:false})})]})})]}),!r&&k(h,{style:[I.actionFooter,{paddingBottom:t?0:a.bottom+8}],children:k(h,{style:I.actionsRow,children:s.map((u,l)=>k(ue,{testID:`buoy-rq-action-${u.variant}`,onClick:u.onPress,text:u.label,variant:u.variant,disabled:u.disabled},l))})})]})}function kl({selectedQuery:e,isFloatingMode:t,queryVersion:r}){let o=Jo({minBottom:16}),a=_o(),n=cr(e,a,r);return k(h,{style:[I.actionFooter,{paddingBottom:t?0:o.bottom+8}],children:k(h,{style:I.actionsRow,children:n.map((s,u)=>k(ue,{testID:`buoy-rq-action-${s.variant}`,onClick:s.onPress,text:s.label,variant:s.variant,disabled:s.disabled},u))})})}function Il({visible:e,selectedQuery:t,queryVersion:r=0}){return e?_e(h,{style:I.dataContainer,children:[k(v,{testID:"buoy-rq-data-header",style:I.dataHeader,children:"Data Editor"}),k(h,{style:I.dataContent,children:k(me,{editable:true,label:"Data",value:t.state.data,defaultExpanded:["Data"],activeQuery:t,dataVersion:r})})]}):null}function Ql({visible:e,selectedQuery:t}){if(!e)return null;let r=()=>t.isDisabled()?{title:"Query Disabled",description:"This query is disabled and won't automatically fetch. Enable the query or manually trigger a fetch to load data."}:t.state.status==="pending"||se(t)==="fetching"?{title:t.state.status==="pending"?"Loading...":"Refetching...",description:"Please wait while the query is being executed."}:t.state.status==="error"?{title:"Query Error",description:t.state.error?.message||"An error occurred while fetching data."}:{title:"No Data Available",description:"This query has no data to edit. Try refetching the query first."},{title:o,description:a}=r();return _e(h,{style:I.emptyState,children:[k(v,{testID:"buoy-rq-detail-empty-title",style:I.emptyTitle,children:o}),k(v,{testID:"buoy-rq-detail-empty-description",style:I.emptyDescription,children:a})]})}var I=T.create({explorerScrollContainer:{flex:1},explorerScrollContent:{paddingBottom:16,paddingHorizontal:8,flexGrow:1},section:{marginBottom:16},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:K.color.text,fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},emptyDescription:{color:K.color.textSecondary,fontSize:14,textAlign:"center",lineHeight:20,maxWidth:280},actionFooter:{borderTopWidth:1,borderTopColor:K.color.border,paddingTop:8,paddingHorizontal:12,backgroundColor:"transparent",borderBottomLeftRadius:14,borderBottomRightRadius:14},actionsRow:{flexDirection:"row",alignItems:"center",gap:8},queryExplorerContainer:{minWidth:200,backgroundColor:K.color.surface,borderRadius:6,borderWidth:1,borderColor:K.color.accent+"4D",overflow:"hidden",shadowColor:K.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},queryExplorerHeader:{backgroundColor:K.color.accent+"1A",paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:K.color.accent,borderBottomWidth:1,borderBottomColor:K.color.accent+"33",letterSpacing:.5,textTransform:"uppercase",fontFamily:Go},queryExplorerContent:{padding:8},dataContainer:{minWidth:200,backgroundColor:K.color.surface,borderRadius:6,borderWidth:1,borderColor:K.color.accent+"4D",overflow:"hidden",shadowColor:K.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6,marginTop:8},dataHeader:{backgroundColor:K.color.accent+"1A",paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:K.color.accent,borderBottomWidth:1,borderBottomColor:K.color.accent+"33",letterSpacing:.5,textTransform:"uppercase",fontFamily:Go},dataContent:{padding:8}});import{useState as Fl,useCallback as Pl,useEffect as Ol,useRef as Kl}from"react";import{jsx as Dt}from"react/jsx-runtime";function Xo({visible:e,selectedQueryKey:t,onQuerySelect:r,onClose:o,onMinimize:a,enableSharedModalDimensions:n=false,onTabChange:s}){let{query:u,version:l}=Ht(t),[c,i]=Fl("bottomSheet"),d=t?JSON.stringify(t):void 0,f=Kl(void 0);Ol(()=>{if(u){f.current=d;return}e&&f.current!==void 0&&f.current===d&&(f.current=void 0,r(void 0))},[e,u,d,r]);let b=Pl(w=>{i(w)},[]),y=Al({minBottom:16}),m=c==="floating"?72:80+y.bottom,g=()=>Dt(tt,{selectedQuery:u,activeTab:"queries",onTabChange:s,onBack:()=>r(void 0)}),p=n?Uo.reactQuery.modal():`${Uo.reactQuery.modal()}_data_editor`;if(!e||!u)return null;let S=Dt(kl,{selectedQuery:u,isFloatingMode:c==="floating",queryVersion:l},`footer-${l}`);return Dt(Tl,{visible:e,onClose:o,onMinimize:a,persistenceKey:p,header:{customContent:g(),showToggleButton:true},onModeChange:b,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:S,footerHeight:m,children:Dt(Yo,{selectedQuery:u,isFloatingMode:c==="floating",disableInternalFooter:true,queryVersion:l})})}import{useQueryClient as zl}from"@tanstack/react-query";import{useCallback as dr,useState as Zo,useRef as ea}from"react";import{useEffect as Ll,useState as Bl}from"react";import{useQueryClient as Hl}from"@tanstack/react-query";function yr(e){let t=Hl(),[r,o]=Bl(void 0);return Ll(()=>{let a=()=>{if(e!==void 0){let s=t.getMutationCache().getAll().find(u=>u.mutationId===e);o(s)}else o(void 0)};setTimeout(a,0);let n=t.getMutationCache().subscribe(a);return()=>n()},[t,e]),r}import{jsx as ta}from"react/jsx-runtime";function ra({selectedMutation:e,onMutationSelect:t,activeFilter:r,searchText:o=""}){let a=n=>{t(typeof n=="function"?n(e):n)};return ta(h,{style:oa.mutationListContainer,children:ta(Mo,{selectedMutation:e,setSelectedMutation:a,activeFilter:r,searchText:o,hideInfoPanel:true,contentContainerStyle:oa.mutationListContent})})}var oa=T.create({mutationListContainer:{flex:1,backgroundColor:"transparent"},mutationListContent:{padding:8,backgroundColor:"transparent"}});import{ToolFooter as Wl,useSafeAreaInsets as jl}from"@buoy-gg/shared-ui/web";import{useMemo as Vl}from"react";import{jsx as hr}from"react/jsx-runtime";function aa({activeFilter:e,onFilterChange:t,modalMode:r,size:o="default"}){let a=r==="floating",n=jl({minBottom:16}),s=Vl(()=>a?0:n.bottom,[a,n.bottom]);return hr(Wl,{floating:a,safeArea:false,paddingBottom:s,style:na.filterFooter,children:hr(h,{style:na.filterContainer,children:hr(To,{activeFilter:e,onFilterChange:t,size:o})})},`footer-${a?"floating":"docked"}`)}var na=T.create({filterFooter:{paddingTop:8,paddingHorizontal:0},filterContainer:{minHeight:32,justifyContent:"center"}});import{JsModal as $l,useSafeAreaInsets as Nl}from"@buoy-gg/shared-ui/web";import{absoluteFill as Ul}from"@buoy-gg/shared-ui/web";import{useMemo as W}from"react";import{ChevronLeft as _l,ChevronRight as Jl,night as Rt}from"@buoy-gg/shared-ui/web";import{jsx as Je,jsxs as Gl}from"react/jsx-runtime";var He=32,ia=6,sa=He,Yl=120,kt=.95,la=1.15;function ua({translationX:e,maxTranslation:t=Yl,canSwipeLeft:r=true,canSwipeRight:o=true}){let a=W(()=>e.interpolate({inputRange:[0,t],outputRange:[0,1],extrapolate:"clamp"}),[e,t]),n=W(()=>a.interpolate({inputRange:[0,1],outputRange:[ia,sa]}),[a]),s=W(()=>a.interpolate({inputRange:[0,kt,1],outputRange:[1,1,la]}),[a]),u=W(()=>a.interpolate({inputRange:[0,.99,1],outputRange:[0,0,16]}),[a]),l=W(()=>a.interpolate({inputRange:[0,.01],outputRange:[0,1],extrapolate:"clamp"}),[a]),c=W(()=>a.interpolate({inputRange:[0,.5,1],outputRange:[0,0,1],extrapolate:"clamp"}),[a]),i=W(()=>a.interpolate({inputRange:[0,.5,kt,1],outputRange:[.8,.8,1,1.2]}),[a]),d=W(()=>e.interpolate({inputRange:[-t,0],outputRange:[1,0],extrapolate:"clamp"}),[e,t]),f=W(()=>d.interpolate({inputRange:[0,1],outputRange:[ia,sa]}),[d]),b=W(()=>d.interpolate({inputRange:[0,kt,1],outputRange:[1,1,la]}),[d]),y=W(()=>d.interpolate({inputRange:[0,.99,1],outputRange:[0,0,-16]}),[d]),m=W(()=>d.interpolate({inputRange:[0,.01],outputRange:[0,1],extrapolate:"clamp"}),[d]),g=W(()=>d.interpolate({inputRange:[0,.5,1],outputRange:[0,0,1],extrapolate:"clamp"}),[d]),p=W(()=>d.interpolate({inputRange:[0,.5,kt,1],outputRange:[.8,.8,1,1.2]}),[d]);return Gl(h,{style:fr.container,pointerEvents:"none",children:[o&&Je(Z.View,{style:[fr.leftWrapper,{width:n,height:He,borderRadius:He/2,backgroundColor:Rt.color.text+"E6",justifyContent:"center",alignItems:"center",opacity:l,transform:[{scale:s},{translateX:u}]}],children:Je(Z.View,{style:{opacity:c,transform:[{scale:i}]},children:Je(_l,{size:He*.6,color:Rt.color.accent,strokeWidth:3})})}),r&&Je(Z.View,{style:[fr.rightWrapper,{width:f,height:He,borderRadius:He/2,backgroundColor:Rt.color.text+"E6",justifyContent:"center",alignItems:"center",opacity:m,transform:[{scale:b},{translateX:y}]}],children:Je(Z.View,{style:{opacity:g,transform:[{scale:p}]},children:Je(Jl,{size:He*.6,color:Rt.color.accent,strokeWidth:3})})})]})}var fr=T.create({container:{...Ul,zIndex:1e3,justifyContent:"center",alignItems:"center"},leftWrapper:{position:"absolute",left:16},rightWrapper:{position:"absolute",right:16}});import{devToolsStorageKeys as ca}from"@buoy-gg/shared-ui/web";import{jsx as Ge,jsxs as Xl}from"react/jsx-runtime";function da({visible:e,selectedMutationId:t,onMutationSelect:r,onClose:o,onMinimize:a,activeFilter:n,onFilterChange:s,onTabChange:u,enableSharedModalDimensions:l=false,searchText:c="",onSearchChange:i}){let d=zl(),f=yr(t),[b,y]=Zo(null),m=n??b,g=s??y,p=dr(()=>{d.getMutationCache().clear(),r(void 0)},[d,r]),[S,w]=Zo("bottomSheet"),C=l?ca.reactQuery.modal():ca.reactQuery.mutationModal(),q=ea(new Z.Value(0)).current,A=dr(ne=>{ne==="right"&&u("queries")},[u]),j=dr(ne=>{w(ne)},[]),Qe=Nl({minBottom:16}),M=S==="floating"?56:48+Qe.bottom,ae=ea(Wt.create({onStartShouldSetPanResponder:()=>false,onMoveShouldSetPanResponder:(ne,ie)=>Math.abs(ie.dx)>5&&Math.abs(ie.dy)<10,onPanResponderMove:(ne,ie)=>{q.setValue(ie.dx)},onPanResponderRelease:(ne,ie)=>{let{dx:ht,vx:ft}=ie,Lt=80,mt=.5;Z.spring(q,{toValue:0,useNativeDriver:true}).start(),(Math.abs(ht)>Lt||Math.abs(ft)>mt)&&(ht>0||ft>0?A("right"):A("left"))},onPanResponderTerminate:()=>{Z.spring(q,{toValue:0,useNativeDriver:true}).start()}})).current;if(!e)return null;let ye=()=>Ge(tt,{selectedMutation:f,activeTab:"mutations",onTabChange:u,onBack:()=>r(void 0),searchText:c,onSearchChange:i,onClearCache:p}),he=Ge(aa,{activeFilter:m,onFilterChange:g,modalMode:S});return Ge($l,{visible:e,onClose:o,onMinimize:a,persistenceKey:C,header:{customContent:ye(),showToggleButton:true},onModeChange:j,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:he,footerHeight:M,children:Ge(h,{style:{flex:1},children:Xl(h,{...ae.panHandlers,style:{flex:1},children:[Ge(ua,{translationX:q,canSwipeLeft:false,canSwipeRight:true}),Ge(ra,{selectedMutation:f,onMutationSelect:r,activeFilter:m,searchText:c})]})})})}import{JsModal as Zl,useSafeAreaInsets as eu,devToolsStorageKeys as ya}from"@buoy-gg/shared-ui/web";import{useSafeAreaInsets as tu,night as z,monoFont as ha}from"@buoy-gg/shared-ui/web";import{useMemo as ru}from"react";import{useQueryClient as ou}from"@tanstack/react-query";function fa(e){let t=ou();return ru(()=>[{label:"Remove",variant:"remove",disabled:false,onPress:()=>t.getMutationCache().remove(e)}],[e,t])}import{DataViewer as au}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as nu,jsx as Q,jsxs as Ye}from"react/jsx-runtime";function ma({selectedMutation:e,isFloatingMode:t,disableInternalFooter:r=false}){return Ye(nu,{children:[Ye(be,{testID:"buoy-rq-mutation-detail-scroll",accessibilityLabel:"Mutation editor mode",accessibilityHint:"View mutation editor mode","sentry-label":"ignore mutation editor mode",style:P.explorerScrollContainer,contentContainerStyle:P.explorerScrollContent,children:[Ye(h,{style:P.section,children:[Q(iu,{visible:!!e.state.data,selectedMutation:e}),Q(su,{visible:!e.state.data,selectedMutation:e})]}),Q(h,{style:P.section,children:Q(ar,{selectedMutation:e})}),Q(h,{style:P.section,children:Ye(h,{style:P.mutationExplorerContainer,children:[Q(v,{style:P.mutationExplorerHeader,children:"Mutation Explorer"}),Q(h,{style:P.mutationExplorerContent,children:Q(au,{title:"",data:e,maxDepth:10,rawMode:true,showTypeFilter:true,initialExpanded:false})})]})})]}),!r&&Q(pa,{selectedMutation:e,isFloatingMode:t})]})}function pa({selectedMutation:e,isFloatingMode:t}){let r=tu({minBottom:16}),o=fa(e);return Q(h,{style:[P.actionFooter,{paddingBottom:t?0:r.bottom+8}],children:Q(h,{style:P.actionsGrid,children:o.map((a,n)=>Q(ue,{testID:`buoy-rq-action-${a.variant}`,onClick:a.onPress,text:a.label,variant:a.variant,disabled:a.disabled},n))})})}function iu({visible:e,selectedMutation:t}){return e?Ye(h,{style:P.dataContainer,children:[Q(v,{style:P.dataHeader,children:"Data Editor"}),Q(h,{style:P.dataContent,children:Q(me,{editable:true,label:"Data",value:t.state.data,defaultExpanded:["Data"]},t.mutationId)})]}):null}function su({visible:e,selectedMutation:t}){if(!e)return null;let r=()=>t.state.status==="pending"?{title:"Pending...",description:"The mutation is in progress."}:t.state.status==="error"?{title:"Mutation Error",description:t.state.error?.message||"An error occurred."}:{title:"No Data Available",description:"This mutation has no data."},{title:o,description:a}=r();return Ye(h,{style:P.emptyState,children:[Q(v,{testID:"buoy-rq-mutation-detail-empty-title",style:P.emptyTitle,children:o}),Q(v,{testID:"buoy-rq-mutation-detail-empty-description",style:P.emptyDescription,children:a})]})}var P=T.create({explorerScrollContainer:{flex:1},explorerScrollContent:{paddingBottom:16,paddingHorizontal:8,flexGrow:1},section:{marginBottom:16},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:z.color.text,fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},emptyDescription:{color:z.color.textSecondary,fontSize:14,textAlign:"center",lineHeight:20,maxWidth:280},actionFooter:{borderTopWidth:1,borderTopColor:z.color.border,paddingVertical:8,paddingHorizontal:12,backgroundColor:"transparent",borderBottomLeftRadius:14,borderBottomRightRadius:14},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,justifyContent:"space-between"},mutationExplorerContainer:{minWidth:200,backgroundColor:z.color.surface,borderRadius:6,borderWidth:1,borderColor:z.color.accent+"4D",overflow:"hidden",shadowColor:z.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},mutationExplorerHeader:{backgroundColor:z.color.accent+"1A",paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:z.color.accent,borderBottomWidth:1,borderBottomColor:z.color.accent+"33",letterSpacing:.5,textTransform:"uppercase",fontFamily:ha},mutationExplorerContent:{padding:8},dataContainer:{minWidth:200,backgroundColor:z.color.surface,borderRadius:6,borderWidth:1,borderColor:z.color.accent+"4D",overflow:"hidden",shadowColor:z.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},dataHeader:{backgroundColor:z.color.accent+"1A",paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:z.color.accent,borderBottomWidth:1,borderBottomColor:z.color.accent+"33",letterSpacing:.5,textTransform:"uppercase",fontFamily:ha},dataContent:{padding:8}});import{useState as lu,useCallback as uu,useEffect as cu,useRef as du}from"react";import{jsx as It}from"react/jsx-runtime";function ga({visible:e,selectedMutationId:t,onMutationSelect:r,onClose:o,onMinimize:a,onTabChange:n,enableSharedModalDimensions:s=false}){let u=yr(t),[l,c]=lu("bottomSheet"),i=du(void 0);cu(()=>{if(u){i.current=u.mutationId;return}e&&i.current!==void 0&&i.current===t&&(i.current=void 0,r(void 0))},[e,u,t,r]);let d=uu(p=>{c(p)},[]),f=eu({minBottom:16}),b=l==="floating"?72:80+f.bottom,y=()=>It(tt,{selectedMutation:u,activeTab:"mutations",onTabChange:n,onBack:()=>r(void 0)}),m=s?ya.reactQuery.modal():ya.reactQuery.mutationModal();if(!e||!u)return null;let g=It(pa,{selectedMutation:u,isFloatingMode:l==="floating"});return It(Zl,{visible:e,onClose:o,onMinimize:a,persistenceKey:m,header:{customContent:y(),showToggleButton:true},onModeChange:d,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:g,footerHeight:b,children:It(ma,{selectedMutation:u,isFloatingMode:l==="floating",disableInternalFooter:true})})}import{Fragment as yu,jsx as Qt,jsxs as hu}from"react/jsx-runtime";function ba({visible:e,selectedQueryKey:t,selectedMutationId:r,onQuerySelect:o,onMutationSelect:a,onClose:n,onMinimize:s,activeFilter:u,onFilterChange:l,activeTab:c,onTabChange:i,enableSharedModalDimensions:d=false,searchText:f="",onSearchChange:b}){let y=!!t||!!r,m=c==="queries",g=c==="mutations",p={onClose:n,onMinimize:s,activeFilter:u,onFilterChange:l,enableSharedModalDimensions:d},S=e&&!y&&m,w=e&&!y&&g,C=e&&y&&m&&!!t,q=e&&y&&g&&!!r;return hu(yu,{children:[Qt(No,{visible:S,selectedQueryKey:t,onQuerySelect:o,onTabChange:i,searchText:f,onSearchChange:b,...p}),Qt(da,{visible:w,selectedMutationId:r,onMutationSelect:a,onTabChange:i,searchText:f,onSearchChange:b,...p}),Qt(Xo,{visible:C,selectedQueryKey:t,onQuerySelect:o,onTabChange:i,...p}),Qt(ga,{visible:q,selectedMutationId:r,onMutationSelect:a,onTabChange:i,...p})]})}import{ChangeLog as fu}from"@buoy-gg/shared-ui/web";var mu=0;function De(){return`rq-${Date.now()}-${++mu}`}var pu=class extends fu{constructor(){super({max:200});this.queryClient=null;this.queryUnsubscribe=null;this.mutationUnsubscribe=null;this.fetchStartTimes=new Map;this.mutationStartTimes=new Map;this.lastQueryStates=new Map;this.lastMutationStates=new Map}setQueryClient(e){this.disconnect(),this.queryClient=e,this.queryUnsubscribe=e.getQueryCache().subscribe(t=>{t.type==="updated"&&t.query&&this.handleQueryUpdate(t.query)}),this.mutationUnsubscribe=e.getMutationCache().subscribe(t=>{t.type==="updated"&&t.mutation&&this.handleMutationUpdate(t.mutation)})}disconnect(){this.queryUnsubscribe&&(this.queryUnsubscribe(),this.queryUnsubscribe=null),this.mutationUnsubscribe&&(this.mutationUnsubscribe(),this.mutationUnsubscribe=null),this.queryClient=null,this.lastQueryStates.clear(),this.lastMutationStates.clear(),this.fetchStartTimes.clear(),this.mutationStartTimes.clear()}handleQueryUpdate(e){if(Se(e.queryKey))return;let t=e.queryHash,r={fetchStatus:e.state.fetchStatus,status:e.state.status},o=this.lastQueryStates.get(t);if(!o)r.fetchStatus==="fetching"&&(this.fetchStartTimes.set(t,Date.now()),this.addEvent({id:De(),type:"query-fetch-start",timestamp:Date.now(),queryKey:e.queryKey,queryHash:t,query:e}));else{let a=o.fetchStatus==="fetching",n=r.fetchStatus==="fetching";if(!a&&n&&(this.fetchStartTimes.set(t,Date.now()),this.addEvent({id:De(),type:"query-fetch-start",timestamp:Date.now(),queryKey:e.queryKey,queryHash:t,query:e})),a&&!n){let s=this.fetchStartTimes.get(t),u=s?Date.now()-s:void 0;this.fetchStartTimes.delete(t),r.status==="error"?this.addEvent({id:De(),type:"query-fetch-error",timestamp:Date.now(),queryKey:e.queryKey,queryHash:t,queryError:e.state.error,duration:u,query:e}):this.addEvent({id:De(),type:"query-fetch-success",timestamp:Date.now(),queryKey:e.queryKey,queryHash:t,queryData:e.state.data,duration:u,query:e})}!o.status&&e.state.isInvalidated&&this.addEvent({id:De(),type:"query-invalidated",timestamp:Date.now(),queryKey:e.queryKey,queryHash:t,query:e})}this.lastQueryStates.set(t,r)}handleMutationUpdate(e){let t=e.mutationId,r=e.state.status,o=this.lastMutationStates.get(t);if(o!==r){if(r==="pending"&&o!=="pending")this.mutationStartTimes.set(t,Date.now()),this.addEvent({id:De(),type:"mutation-start",timestamp:Date.now(),mutationId:t,mutationKey:e.options.mutationKey,mutationVariables:e.state.variables,mutation:e});else if(r==="success"&&o==="pending"){let a=this.mutationStartTimes.get(t),n=a?Date.now()-a:void 0;this.mutationStartTimes.delete(t),this.addEvent({id:De(),type:"mutation-success",timestamp:Date.now(),mutationId:t,mutationKey:e.options.mutationKey,mutationVariables:e.state.variables,mutationData:e.state.data,duration:n,mutation:e})}else if(r==="error"&&o==="pending"){let a=this.mutationStartTimes.get(t),n=a?Date.now()-a:void 0;this.mutationStartTimes.delete(t),this.addEvent({id:De(),type:"mutation-error",timestamp:Date.now(),mutationId:t,mutationKey:e.options.mutationKey,mutationVariables:e.state.variables,mutationError:e.state.error,duration:n,mutation:e})}}this.lastMutationStates.set(t,r)}addEvent(e){this.record(e)}getEvents(){return this.items}subscribe(e){let t=super.subscribe(e);return e(this.items),t}clearEvents(){this.clear()}isConnected(){return this.queryClient!==null}},We=new pu,gu=e=>We.setQueryClient(e),bu=()=>We.disconnect();import{jsx as va}from"react/jsx-runtime";function mr({visible:e,onClose:t,onMinimize:r,enableSharedModalDimensions:o=true}){let a=ln();sn(()=>{We.isConnected()||We.setQueryClient(a)},[a]);let[n,s]=Ze(void 0),[u,l]=Ze(void 0),[c,i]=Ze(null),[d,f]=Ze("queries"),[b,y]=Ze(""),m=Fe(()=>{s(void 0),l(void 0),i(null),f("queries"),y("")},[]),g=Fe(()=>{m(),t()},[t,m]),p=Fe(A=>{s(A?.queryKey)},[]),S=Fe(A=>{l(A?.mutationId)},[]),w=Fe(A=>{i(A)},[]),C=Fe(A=>{f(A),i(null),s(void 0),l(void 0),y("")},[]),q=Fe(A=>{y(A)},[]);return e?va(un,{children:va(ba,{visible:e,selectedQueryKey:n,selectedMutationId:u,onQuerySelect:p,onMutationSelect:S,onClose:g,onMinimize:r,activeFilter:c,onFilterChange:w,activeTab:d,onTabChange:C,searchText:b,onSearchChange:q,enableSharedModalDimensions:o})}):null}import{onlineManager as ge}from"@tanstack/react-query";import{devToolsStorageKeys as Sa,persistentStorage as Ca}from"@buoy-gg/shared-ui/web";import{useState as xa,useEffect as wa}from"react";import{jsx as Ft}from"react/jsx-runtime";var qa=()=>null,Ma=async e=>{try{await Ca.setItem(Sa.settings.wifiEnabled(),e.toString())}catch{}},vu=async()=>{try{let e=await Ca.getItem(Sa.settings.wifiEnabled());e!==null&&ge.setOnline(e==="true")}catch{}};vu();function Su({size:e}){let[t,r]=xa(()=>ge.isOnline());return wa(()=>ge.subscribe(o=>{r(o)}),[]),Ft(qr,{size:e,color:t?"#10B981":"#DC2626"})}var Cu={id:"query",name:"QUERY",description:"React Query inspector",slot:"both",icon:({size:e})=>Ft(wr,{size:e}),component:mr,props:{enableSharedModalDimensions:false}};function xu(e){return{id:e?.id||"query",name:e?.name||"QUERY",description:e?.description||"React Query inspector",slot:"both",icon:({size:t})=>Ft(wr,{size:t}),component:mr,props:{enableSharedModalDimensions:e?.enableSharedModalDimensions!==void 0?e.enableSharedModalDimensions:false}}}var wu={id:"query-wifi-toggle",name:"WIFI",description:"Toggle React Query online/offline state",slot:"row",icon:Su,component:qa,props:{},launchMode:"toggle-only",onPress:()=>{let e=!ge.isOnline();ge.setOnline(e),Ma(e)}};function qu(e){let t=e?.onColor||"#10B981",r=e?.offColor||"#DC2626",o=({size:a})=>{let[n,s]=xa(()=>ge.isOnline());return wa(()=>ge.subscribe(u=>{s(u)}),[]),Ft(qr,{size:a,color:n?t:r})};return{id:e?.id||"query-wifi-toggle",name:e?.name||"WIFI",description:e?.description||"Toggle React Query online/offline state",slot:"row",icon:o,component:qa,props:{},launchMode:"toggle-only",onPress:()=>{let a=!ge.isOnline();ge.setOnline(a),Ma(a)}}}import{expandKeyedArrays as Mu,patchFromPath as Tu,readPath as Au,refusalText as Eu,shapeSummary as Pt,suggestedPatch as Du,typedEditViolations as Ru,unshapedLists as ku}from"@buoy-gg/shared-ui/web";import{onlineManager as pr}from"@tanstack/react-query";import{isJsonSerializable as Ta,isOverWireBudget as Aa}from"@buoy-gg/shared-ui/web";var Iu=Object.freeze({__buoyDataOnDevice:true,note:"Query data stays on the device \u2014 fetched on demand via getQueryData."}),Ea=Object.freeze({__buoyUnserializable:true,note:"Query data is not JSON-serializable (circular or bigint) and stayed on the device."}),Qu=16*1024,Da=8*1024*1024;function Fu(e){return!!e&&typeof e=="object"&&e.__buoyDataOnDevice===true}function Pu(e){return!!e&&typeof e=="object"&&e.__buoyUnserializable===true}function Ra(e){return Fu(e)||Pu(e)}function Re(e){if(e!==void 0)return Aa(e,Qu)?Ta(e)?Iu:Ea:e}function Ot(e){if(e==null)return e;if(typeof e=="object"){let t=e,r=typeof t.name=="string"?t.name:void 0,o=typeof t.message=="string"?t.message:void 0;if(r!==void 0||o!==void 0)return Re({...r!==void 0?{name:r}:{},...o!==void 0?{message:o}:{}})}return Re(e)}function Ou(e){return Aa(e,Da)?Ta(e)?{__buoyTruncated:true,note:`Exceeds the ${Da/(1024*1024)}MB detail limit \u2014 inspect it on-device.`}:Ea:e}function Ku(e){let t=e.getMutationCache().getAll().map(o=>zu(o)),r=e.getQueryCache().getAll().map(o=>Bu(o));return{mutations:t,queries:r}}function zu(e){let t=e.state;return{mutationId:e.mutationId,mutationKey:e.options.mutationKey,state:{...t,data:Re(t.data),variables:Re(t.variables),error:Ot(t.error),failureReason:Ot(t.failureReason)},...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:Re(e.meta)}}}function Lu(e){let{queryFn:t,select:r,persister:o,initialData:a,placeholderData:n,...s}=e;return{...s,queryFn:void 0,...e.meta?{meta:Re(e.meta)}:{}}}function Bu(e){let t=e.observers.map(r=>({queryHash:e.queryHash,options:Lu(r.options)}));return{state:{...e.state,...e.state.data!==void 0&&{data:Re(e.state.data)},error:Ot(e.state.error),fetchFailureReason:Ot(e.state.fetchFailureReason)},queryKey:e.queryKey,queryHash:e.queryHash,...e.meta&&{meta:Re(e.meta)},observers:t}}function Hu(e,t){let r=e;for(let o of t.split(".")){if(!r||typeof r!="object"||Array.isArray(r)||!(o in r))return false;r=r[o]}return Array.isArray(r)?r.length>0:!!r&&typeof r=="object"}var dt=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function ka(e){return Array.isArray(e)?"array":e===null?"null":typeof e=="object"?"object":typeof e}function Ia(e,t,r="",o={shrunk:[],breaks:[]}){if(Array.isArray(e)&&Array.isArray(t))return t.length>0&&t.length<e.length&&o.shrunk.push({path:r||"(root)",have:e.length,sent:t.length}),t;if(!dt(e)||!dt(t))return t;let a={...e};for(let[n,s]of Object.entries(t)){let u=r?`${r}.${n}`:n;if(n in e){let l=ka(e[n]),c=ka(s);(l==="array"||l==="object")&&l!==c&&o.breaks.push({path:u,from:l,to:c}),a[n]=Ia(e[n],s,u,o)}else a[n]=s}return a}function Wu(e){let t=e.trim();try{let r=JSON.parse(t);if(Array.isArray(r))return r.map(o=>typeof o=="object"&&o!==null?JSON.stringify(o):String(o))}catch{}return t.includes(",")&&!t.startsWith("[")?t.split(",").map(r=>r.trim().replace(/^["']|["']$/g,"")):null}function ju(e){let t;for(let r of e.observers??[]){let o=r.options?.refetchInterval,a=o;if(typeof o=="function")try{a=o(e)}catch{a=void 0}typeof a=="number"&&a>0&&(t=t===void 0?a:Math.min(t,a))}return t}function Qa(e){let t=r=>{let{queryHash:o}=r,a=e.getQueryCache(),n=o?a.get(o):void 0;if(!n&&typeof o=="string"){let s=Wu(o);s&&(n=a.getAll().find(u=>{let l=u.queryKey.map(c=>typeof c=="object"?JSON.stringify(c):String(c));return l.length===s.length&&l.every((c,i)=>c===s[i])}))}if(!n)throw new Error(`Query with hash "${o}" not found`);return n};return{version:2,getSnapshot:()=>({dehydratedState:Ku(e),isOnlineManagerOnline:pr.isOnline()}),subscribe:r=>{let o=e.getQueryCache().subscribe(r),a=e.getMutationCache().subscribe(r),n=pr.subscribe(r);return()=>{o(),a(),n()}},actions:{getQueryData:r=>{let{queryHash:o,path:a}=r??{};if(!o)return{found:false,reason:"missing queryHash"};let n=e.getQueryCache().get(o);if(!n)return{found:false,reason:"unknown queryHash"};if(a){let u=Au(n.state.data,a);return u.ok?{found:true,queryHash:o,path:a,shape:Pt(u.value),data:u.value}:{found:false,reason:u.error}}if(n.state.data===void 0){let u=n.state.status,l=n.state.error;return{found:true,queryHash:o,hasData:false,status:u,fetchStatus:n.state.fetchStatus,...l?{error:l instanceof Error?l.message:String(l)}:{},reason:u==="error"?"This query has no data because it FAILED. Report the error, not an empty result.":n.state.fetchStatus==="fetching"?"No data yet \u2014 this query is still fetching.":"This query has never resolved (it may be disabled, or never enabled). It is not empty \u2014 it has nothing."}}let s=Pt(n.state.data);return{found:true,queryHash:o,hasData:true,...s?{shape:s}:{},data:Ou(n.state.data)}},listQueries:r=>{let{includeData:o=false,staleOnly:a=false,limit:n}=r??{},s=e.getQueryCache().getAll(),u=[...a?s.filter(c=>c.isStale()):s].sort((c,i)=>{let d=+(i.getObserversCount()>0)-+(c.getObserversCount()>0);return d!==0?d:(i.state.dataUpdatedAt??0)-(c.state.dataUpdatedAt??0)}),l=(typeof n=="number"&&n>0?u.slice(0,n):u).map(c=>{let i=c.state.error,d=ju(c);return{queryHash:c.queryHash,queryKey:c.queryKey,status:se(c),fetchStatus:c.state.fetchStatus,isStale:c.isStale(),observers:c.getObserversCount(),updatedAt:c.state.dataUpdatedAt,...d?{refetchEveryMs:d}:{},error:i?i.message??String(i):void 0,...o?{data:c.state.data}:{},...Pt(c.state.data)?{shape:Pt(c.state.data)}:{}}});return{queries:l,total:s.length,returned:l.length,includedData:o}},refetch:r=>t(r).fetch().catch(()=>{}),invalidate:r=>e.invalidateQueries(t(r)),reset:r=>e.resetQueries(t(r)),remove:r=>{let o=t(r),a=e.getQueryCache().findAll(o).some(n=>n.getObserversCount()>0);return e.removeQueries(o),{ok:true,...a?{note:"Removed \u2014 but a screen is still watching this query, and React Query leaves that screen rendering its LAST value (including anything written into the cache before this) until something refetches. Nothing on screen will change on its own. Use `reset` instead when you want the screen to go back to loading and fetch again."}:{}}},setQueryData:r=>{let{data:o,merge:a,force:n,path:s,value:u}=r,{queryKey:l,queryHash:c}=r,i=l;if(i===void 0&&typeof c=="string"){let y=e.getQueryCache().get(c);if(!y)return{ok:false,error:`Refused: no query with hash ${c} is in the cache. Read listQueries for the current hashes \u2014 a query that has been removed or whose key includes changing params (a search term, a cart payload) will not match an older hash.`};i=y.queryKey}if(i===void 0)return{ok:false,error:"Refused: no query was named. Send `queryKey` (the array from listQueries) or `queryHash` (its string form)."};let d=e.getQueryData(i),f=e.getQueryCache().find({queryKey:i,exact:true});if(d===void 0&&f&&(o!==void 0||s!==void 0)){let y=f,m=y?.state.status;return{ok:false,error:`Refused: this query has no data to edit \u2014 ${m==="error"?`it FAILED${y?.state.error?` (${y.state.error instanceof Error?y.state.error.message:String(y.state.error)})`:""}`:m==="pending"?"it has never resolved (it may be disabled, or still loading)":"it holds no data"}. There is nothing to merge into. Fix the cause first (restoreError, or let it fetch), or send force:true with the COMPLETE value if you mean to seed the cache from nothing.`,status:m}}if(o===void 0&&s===void 0)return{ok:false,error:"Refused: no change was described. Send `data` (with merge:true for a partial edit), or `path` and `value` to set one value."};let b=o;if(s!==void 0){if(u===void 0)return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${s}" to; if you mean to clear it, send value:null and the field must already be nullable.`};let y=Tu(d,s,u);if(!y.ok)return{ok:false,error:`Refused: ${y.error}`};b=y.patch}if(a||s!==void 0){let y=n?{patch:b,notes:[],error:void 0}:Mu(d,b);if(y.error)return{ok:false,error:`Refused: ${y.error}`};let m=y.patch;if(!n){let S=Ru(d,m,{noun:"data"});if(S.length>0){let w=Du(m,S);return{ok:false,error:Eu(S,"data",w),violations:S,...w?{suggestedData:w}:{}}}}let g=Ia(d,m),p=ku(d).filter(S=>Hu(m,S));return e.setQueryData(i,g,{updatedAt:Date.now()}),{ok:true,mode:"merge",...s!==void 0?{path:s}:{},changedKeys:dt(m)?Object.keys(m):void 0,...y.notes.length?{keyed:y.notes}:{},...p.length?{unchecked:p.map(S=>`\`${S}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the screen renders a field you left out, it will render undefined \u2014 read the query back and compare against how the screen uses it.`)}:{}}}if(!n&&dt(d)&&dt(o)){let y=Object.keys(d).filter(m=>!(m in o));if(y.length>0)return{ok:false,error:`Refused: the new value drops ${y.length} top-level field(s) the cached value has (${y.slice(0,8).join(", ")}${y.length>8?", \u2026":""}). A screen rendering those fields would crash. To change some fields, send merge:true with ONLY the fields that change. To really replace the whole value, send force:true.`,missingKeys:y}}return e.setQueryData(i,o,{updatedAt:Date.now()}),{ok:true,mode:"replace"}},triggerError:r=>{let o=t(r),a=o.options;o.setState({status:"error",error:new Error("Unknown error from devtools"),fetchMeta:{...o.state.fetchMeta,__previousQueryOptions:a}})},restoreError:r=>e.resetQueries(t(r)),triggerLoading:r=>{let o=t(r),a=o.options;o.fetch({...a,queryFn:()=>new Promise(()=>{}),gcTime:-1}).catch(()=>{}),o.setState({data:void 0,status:"pending",fetchMeta:{...o.state.fetchMeta,__previousQueryOptions:a}})},restoreLoading:r=>{let o=t(r),a=o.state,n=o.state.fetchMeta?o.state.fetchMeta.__previousQueryOptions:null;o.cancel({silent:true}),o.setState({...a,fetchStatus:"idle",fetchMeta:null}),n&&o.fetch(n).catch(()=>{})},clearQueryCache:()=>{let r=e.getQueryCache().getAll().filter(o=>o.getObserversCount()>0).length;return e.getQueryCache().clear(),{ok:true,cleared:true,...r?{note:`Cleared \u2014 but ${r} quer${r===1?"y is":"ies are"} still being watched by a screen, and React Query leaves those screens rendering their LAST value until something refetches. The cache is empty; the app on screen is not. Use \`reset\` on a query when you want its screen to reload.`}:{}}},clearMutationCache:()=>{e.getMutationCache().clear()},setOnline:r=>{let{online:o}=r;pr.setOnline(o)}}}}import{useEffect as Vu,useMemo as $u}from"react";import{useQueryClient as Nu}from"@tanstack/react-query";import{classifyPreviewItem as Uu,createRestoreScope as _u,emptyRestoreResult as Ju,failedRestore as Gu,registerStateSnapshotProvider as Yu,superJsonSerialize as Xu}from"@buoy-gg/shared-ui/web";function Fa(e){return{...e,fetchStatus:"idle",fetchMeta:null}}function gr(e){return{status:e.state.status,error:e.state.error??null,data:e.state.data}}function br(e,t){try{let r=JSON.stringify(e);return r.length>60?`${r.slice(0,57)}\u2026`:r}catch{return t}}function Pa(e){if(e==null)return e??null;if(typeof e=="object"){let t=e,r=typeof t.name=="string"?t.name:void 0,o=typeof t.message=="string"?t.message:void 0;if(r!==void 0||o!==void 0)return{...r!==void 0?{name:r}:{},...o!==void 0?{message:o}:{}}}return e}function Oa(e){if(e===void 0)return true;try{return Xu(e),true}catch{return false}}function Ka(e){let t=[],r=[];for(let o of e.getQueryCache().getAll()){let a=br(o.queryKey,o.queryHash);if(!Oa(o.state.data)){t.push(`query ${a}: data can't be serialized (circular reference?) \u2014 not captured`);continue}r.push({queryKey:o.queryKey,queryHash:o.queryHash,...o.meta&&Oa(o.meta)?{meta:o.meta}:{},state:Fa({...o.state,error:Pa(o.state.error),fetchFailureReason:Pa(o.state.fetchFailureReason)})})}return{queries:r,warnings:t}}function Zu(e){return{id:"query",label:"React Query",status:()=>({canCapture:true,canRestore:true}),async capture(){let{queries:t,warnings:r}=Ka(e),o=e.getMutationCache().getAll().length;return o>0&&r.push(`${o} mutation(s) not captured (mutation functions cannot be restored)`),{data:{queries:t},warnings:r}},async restore(t,r){let o=t,a=_u(r),n=Ju();if(!o?.queries)return Gu("empty query snapshot");let s=e.getQueryCache(),u=new Set(o.queries.map(i=>i.queryHash));for(let i of o.queries)if(a.allows(i.queryHash)){if(Ra(i.state.data)){n.skipped.push({id:i.queryHash,reason:"captured as an on-device placeholder by an older Buoy \u2014 re-capture this restore point"});continue}try{let d=Fa(i.state),f=s.get(i.queryHash);f?f.setState(d):s.build(e,{queryKey:i.queryKey,queryHash:i.queryHash,...i.meta&&{meta:i.meta}},d),n.applied+=1}catch(d){n.skipped.push({id:i.queryHash,reason:String(d)}),n.ok=false}}for(let i of s.getAll().slice())if(a.allows(i.queryHash)&&!u.has(i.queryHash))try{s.remove(i),n.applied+=1}catch(d){n.skipped.push({id:i.queryHash,reason:String(d)})}let l=e.getMutationCache().getAll().length;l>0&&(e.getMutationCache().clear(),n.warnings.push(`mutation cache cleared (${l} mutation(s))`));let c=a.excludedWarning("quer(y/ies)");return c&&n.warnings.push(c),n},async previewItems(t,r){let o=t?.queries??[],a=r===void 0,n=a?Ka(e).queries:r?.queries??[],s=new Map(n.map(i=>[i.queryHash,i])),u=new Map(o.map(i=>[i.queryHash,i])),l=[],c=[];for(let i of o){let d=br(i.queryKey,i.queryHash);if(Ra(i.state.data)){l.push({key:i.queryHash,label:d,verdict:"wont-apply",reason:"data stayed on the device when this was captured (older Buoy) \u2014 re-capture this restore point"});continue}let f=s.get(i.queryHash);l.push(Uu({key:i.queryHash,label:d,oldValue:f?gr(f):void 0,newValue:gr(i),inOld:f!==void 0,inNew:true},{tooLargeReason:"query data too large to render a diff \u2014 restore still applies it"}))}for(let i of n)u.has(i.queryHash)||l.push({key:i.queryHash,label:br(i.queryKey,i.queryHash),verdict:"removed",oldValue:gr(i)});if(a){let i=e.getMutationCache().getAll().length;i>0&&c.push(`${i} in-memory mutation record(s) will be cleared`)}return{items:l,notes:c}}}}function ec(e){return Yu(Zu(e))}function tc(){let e;try{e=Nu()}catch{e=null}return Vu(()=>{if(e)return ec(e)},[e]),$u(()=>e?Qa(e):null,[e])}function za({queryState:e,observerCount:t,isStale:r}){return e.fetchStatus==="fetching"?"blue":e.status==="error"?"red":t?e.fetchStatus==="paused"?"purple":r?"yellow":"green":"gray"}import{useQueryClient as rc}from"@tanstack/react-query";import{jsx as Kt,jsxs as ke}from"react/jsx-runtime";function La(){try{let e=rc(),t=e.getQueryCache().getAll(),r=e.getMutationCache().getAll();return ke(h,{style:Y.container,children:[Kt(v,{style:Y.title,children:"Debug Info"}),Kt(v,{style:Y.info,children:"QueryClient: \u2705 Available"}),ke(v,{style:Y.info,children:["Queries: ",t.length]}),ke(v,{style:Y.info,children:["Mutations: ",r.length]}),t.length>0&&ke(h,{style:Y.queriesList,children:[Kt(v,{style:Y.subtitle,children:"Query Keys:"}),t.slice(0,3).map((o,a)=>ke(v,{style:Y.queryKey,children:["\u2022"," ",Array.isArray(o.queryKey)?o.queryKey.join(" - "):String(o.queryKey)]},a)),t.length>3&&ke(v,{style:Y.more,children:["... and ",t.length-3," more"]})]})]})}catch(e){return ke(h,{style:Y.container,children:[Kt(v,{style:Y.title,children:"Debug Info"}),ke(v,{style:Y.error,children:["\u274C QueryClient Error: ",String(e)]})]})}}var Y=T.create({container:{padding:16,backgroundColor:"rgba(0, 0, 0, 0.3)",borderRadius:8,margin:16,borderWidth:1,borderColor:"rgba(255, 255, 255, 0.1)"},title:{color:"#FFFFFF",fontSize:14,fontWeight:"600",marginBottom:8},subtitle:{color:"#E5E7EB",fontSize:12,fontWeight:"500",marginTop:8,marginBottom:4},info:{color:"#9CA3AF",fontSize:12,marginBottom:4},error:{color:"#EF4444",fontSize:12,marginBottom:4},queriesList:{marginTop:4},queryKey:{color:"#60A5FA",fontSize:11,marginLeft:8,marginBottom:2},more:{color:"#9CA3AF",fontSize:11,fontStyle:"italic",marginLeft:8}});import{jsx as Ie,jsxs as Xe}from"react/jsx-runtime";function oc({queries:e,selectedQuery:t,isOpen:r,onClose:o,onSelect:a}){let n=s=>Array.isArray(s.queryKey)?s.queryKey.join(" - "):String(s.queryKey);return Ie(Pr,{accessibilityLabel:"Query selector",accessibilityHint:"View query selector","sentry-label":"ignore query selector",visible:r,transparent:true,animationType:"fade",onRequestClose:o,children:Ie(Qr,{accessibilityLabel:"Query selector overlay",accessibilityHint:"View query selector overlay","sentry-label":"ignore query selector overlay",style:L.modalOverlay,onPress:o,children:Xe(h,{accessibilityLabel:"Query selector content",accessibilityHint:"View query selector content","sentry-label":"ignore query selector content",style:L.modalContent,children:[Xe(h,{style:L.modalHeader,children:[Ie(v,{style:L.modalTitle,children:"Select Query"}),Xe(v,{style:L.modalSubtitle,children:[e.length," ",e.length===1?"query":"queries"," ","available"]})]}),Ie(be,{accessibilityLabel:"Query selector scroll view",accessibilityHint:"View query selector scroll view","sentry-label":"ignore query selector scroll view",style:L.scrollView,contentContainerStyle:L.scrollViewContent,showsVerticalScrollIndicator:true,children:e.length===0?Xe(h,{style:L.emptyState,children:[Ie(v,{style:L.emptyTitle,children:"No Queries Found"}),Xe(v,{style:L.emptyDescription,children:["No React Query queries are currently active.",`
6
+ \u2022 Check console for debugging info`}}),contentContainerStyle:zo.queryListContent})]})}var zo=T.create({queryListContainer:{flex:1,backgroundColor:"transparent"},queryListContent:{padding:8,backgroundColor:"transparent",flexGrow:1}});import{ToolFooter as yl,useSafeAreaInsets as hl}from"@buoy-gg/shared-ui/web";import{jsx as ir}from"react/jsx-runtime";function Lo({activeFilter:e,onFilterChange:t,isFloatingMode:r=true,size:o="default"}){let a=hl({minBottom:16});return ir(yl,{floating:r,safeArea:false,paddingBottom:r?0:a.bottom,style:Bo.filterFooter,children:ir(h,{style:Bo.filterContainer,children:ir(fo,{activeFilter:e,onFilterChange:t,size:o})})})}var Bo=T.create({filterFooter:{paddingTop:8,paddingHorizontal:0},filterContainer:{minHeight:32,justifyContent:"center"}});import{useCallback as fl,useMemo as lt}from"react";import{DynamicFilterView as ml,buoyColors as Ae,monoFont as pl,night as sr}from"@buoy-gg/shared-ui/web";import{XCircle as Ho,Clock as lr,RefreshCw as gl,Globe as bl,Zap as vl,Filter as Sl,Eye as Cl}from"@buoy-gg/shared-ui/web";import{jsx as ur}from"react/jsx-runtime";var xl=()=>false;function wl({queries:e,activeFilter:t,onFilterChange:r,ignoredPatterns:o,onPatternToggle:a,includedPatterns:n,onIncludedPatternToggle:s,isTeamPattern:u=xl}){let l=fl(y=>u(y)?ur(h,{accessibilityLabel:"Set by your team on buoy.gg",style:[Wo.teamBadge,{borderColor:`${sr.color.accent}60`,backgroundColor:`${sr.color.accent}15`}],children:ur(v,{style:[Wo.teamBadgeText,{color:sr.color.accent}],children:"TEAM"})}):null,[u]),c=lt(()=>{let y={all:e.length,disabled:0,fresh:0,stale:0,fetching:0,paused:0,inactive:0,error:0};return e.forEach(m=>{let g=se(m);g==="disabled"?y.disabled++:g==="error"?y.error++:g==="fresh"?y.fresh++:g==="stale"?y.stale++:g==="fetching"?y.fetching++:g==="paused"?y.paused++:g==="inactive"&&y.inactive++}),y},[e]),i=lt(()=>{let y=new Set;return e.forEach(m=>{if(!m?.queryKey)return;(Array.isArray(m.queryKey)?m.queryKey:[m.queryKey]).forEach(g=>{if(g!=null){let p=String(g);/^\d+$/.test(p)||y.add(p)}})}),Array.from(y).sort().slice(0,50)},[e]),d=lt(()=>i,[i]),f=lt(()=>{let y=e;return n.size>0&&(y=y.filter(m=>{if(!m?.queryKey)return false;let g=(Array.isArray(m.queryKey)?m.queryKey:[m.queryKey]).filter(p=>p!=null).map(p=>String(p)).join(" ").toLowerCase();return Array.from(n).some(p=>g.includes(p.toLowerCase()))})),o.size>0&&(y=y.filter(m=>{if(!m?.queryKey)return true;let g=(Array.isArray(m.queryKey)?m.queryKey:[m.queryKey]).filter(p=>p!=null).map(p=>String(p)).join(" ").toLowerCase();return!Array.from(o).some(p=>g.includes(p.toLowerCase()))})),y.length},[e,n,o]),b=lt(()=>({filterSummarySection:{enabled:true,totalCount:e.length,filteredCount:f,includePatterns:n,excludePatterns:o},sections:[{id:"status",title:"Status",type:"status",data:[{id:"status::all",label:"All",count:c.all,icon:bl,color:Ae.primary,isActive:!t||t==="all"},{id:"status::disabled",label:"Disabled",count:c.disabled,icon:Ho,color:Ae.textMuted,isActive:t==="disabled"},{id:"status::fresh",label:"Fresh",count:c.fresh,icon:vl,color:Ae.success,isActive:t==="fresh"},{id:"status::stale",label:"Stale",count:c.stale,icon:lr,color:Ae.warning,isActive:t==="stale"},{id:"status::fetching",label:"Fetching",count:c.fetching,icon:gl,color:Ae.primary,isActive:t==="fetching"},{id:"status::paused",label:"Paused",count:c.paused,icon:lr,color:Ae.textMuted,isActive:t==="paused"},{id:"status::inactive",label:"Inactive",count:c.inactive,icon:lr,color:Ae.textSecondary,isActive:t==="inactive"},{id:"status::error",label:"Error",count:c.error,icon:Ho,color:Ae.error,isActive:t==="error"}]}],addFilterSection:{enabled:true,placeholder:"Enter pattern to exclude...",title:"EXCLUDE FILTERS",icon:Sl},includeOnlySection:{enabled:true,title:"INCLUDE ONLY FILTERS",description:"Show ONLY queries matching these patterns. All non-matching queries will be hidden.",placeholder:"Enter pattern to include...",icon:Cl,patterns:n,onPatternToggle:s,onPatternAdd:s,renderPatternMeta:l},availableItemsSection:{enabled:true,title:"AVAILABLE QUERY KEYS",emptyMessage:"No queries found. Query keys will appear here once queries are active.",items:d},howItWorksSection:{enabled:true,title:"HOW QUERY FILTERS WORK",description:"There are two types of query key filters:",examples:["","INCLUDE ONLY (green):","\u2022 Shows ONLY queries matching the pattern","\u2022 Example: 'rewards' \u2192 shows only reward queries","\u2022 When active, non-matching queries are hidden","","EXCLUDE (blue):","\u2022 Hides queries matching the pattern","\u2022 Example: 'analytics' \u2192 hides analytics queries","","Filters are case-insensitive and match partial keys."]},activePatterns:o,renderPatternMeta:l}),[c,t,o,n,d,s,e.length,f,l]);return ur(ml,{...b,onFilterChange:y=>{let[m,g]=y.split("::");m==="status"?r(g==="all"||t===g?null:g):m==="suggestion"&&a(g)},onPatternToggle:a,onPatternAdd:a})}var Wo=T.create({teamBadge:{paddingHorizontal:8,paddingVertical:3,borderRadius:6,borderWidth:1},teamBadgeText:{fontSize:9,fontFamily:pl,fontWeight:"700",letterSpacing:.5}});import{useState as ut,useCallback as ct,useEffect as At,useMemo as jo,useRef as Vo}from"react";import{devToolsStorageKeys as Ee,persistentStorage as Et,useTeamList as $o}from"@buoy-gg/shared-ui/web";import{jsx as pe,jsxs as ql}from"react/jsx-runtime";function No({visible:e,selectedQueryKey:t,onQuerySelect:r,onClose:o,onMinimize:a,activeFilter:n,onFilterChange:s,enableSharedModalDimensions:u=false,onTabChange:l,searchText:c="",onSearchChange:i}){let d=cn(),f=Mr(t),b=St(),y=ct(()=>{d.getQueryCache().clear()},[d]),[m,g]=ut(null),p=n??m,S=s??g,[w,C]=ut(false),[q,A]=ut(new Set),[j,Qe]=ut(new Set),M=Vo(null),ae=Vo(null);At(()=>{(async()=>{try{let x=await Et.getItem(Ee.reactQuery.ignoredPatterns());if(x){let R=JSON.parse(x);Array.isArray(R)&&(M.current=JSON.stringify(Array.from(new Set(R))),A(new Set(R)))}}catch(x){console.error("[Buoy]","Failed to load ignored patterns:",x)}finally{M.current??(M.current="[]")}})()},[]),At(()=>{(async()=>{try{let x=await Et.getItem(Ee.reactQuery.includedPatterns());if(x){let R=JSON.parse(x);Array.isArray(R)&&(ae.current=JSON.stringify(Array.from(new Set(R))),Qe(new Set(R)))}}catch(x){console.error("[Buoy]","Failed to load included patterns:",x)}finally{ae.current??(ae.current="[]")}})()},[]),At(()=>{let x=JSON.stringify(Array.from(q));if(M.current===null||M.current===x)return;M.current=x,(async()=>{try{await Et.setItem(Ee.reactQuery.ignoredPatterns(),x)}catch(R){console.error("[Buoy]","Failed to save ignored patterns:",R)}})()},[q]),At(()=>{let x=JSON.stringify(Array.from(j));if(ae.current===null||ae.current===x)return;ae.current=x,(async()=>{try{await Et.setItem(Ee.reactQuery.includedPatterns(),x)}catch(R){console.error("[Buoy]","Failed to save included patterns:",R)}})()},[j]);let ye=$o(Ee.reactQuery.ignoredPatterns()),he=$o(Ee.reactQuery.includedPatterns()),ne=jo(()=>ye.length?new Set([...q,...ye]):q,[q,ye]),ie=jo(()=>he.length?new Set([...j,...he]):j,[j,he]),ht=ct(x=>ye.includes(x)&&!q.has(x)||he.includes(x)&&!j.has(x),[ye,he,q,j]),ft=ct(x=>{A(R=>{if(!R.has(x)&&ye.includes(x))return R;let fe=new Set(R);return fe.has(x)?fe.delete(x):fe.add(x),fe})},[ye]),Lt=ct(x=>{Qe(R=>{if(!R.has(x)&&he.includes(x))return R;let fe=new Set(R);return fe.has(x)?fe.delete(x):fe.add(x),fe})},[he]),[mt,Ua]=ut("bottomSheet"),_a=u?Ee.reactQuery.modal():Ee.reactQuery.browserModal(),Ja=ct(x=>{Ua(x)},[]),Ga=yn({minBottom:16}),Ya=mt==="floating"?56:48+Ga.bottom;if(!e)return null;let Xa=()=>{if(w){let x=[{key:"filters",label:"Filters"}];return ql(Bt,{children:[pe(Bt.Navigation,{onBack:()=>C(false)}),pe(Bt.Content,{title:"",noMargin:true,children:pe(hn,{tabs:x,activeTab:"filters",testIDPrefix:"buoy-rq-filterview-tab",onTabChange:()=>{}})})]})}return pe(tt,{selectedQuery:f,activeTab:"queries",onTabChange:l,onBack:()=>r(void 0),searchText:c,onSearchChange:i,onFilterPress:()=>C(true),hasActiveFilters:p!==null||ne.size>0||ie.size>0,onClearCache:y})},Za=pe(Lo,{activeFilter:p,onFilterChange:S,isFloatingMode:mt==="floating"});return pe(dn,{visible:e,onClose:o,onMinimize:a,persistenceKey:_a,header:{customContent:Xa(),showToggleButton:true},onModeChange:Ja,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,disableScrollWrapper:!w,styles:{},footer:w?void 0:Za,footerHeight:w?void 0:Ya,children:pe(h,{style:Ml.container,children:w?pe(wl,{queries:b,activeFilter:p,onFilterChange:S,ignoredPatterns:ne,onPatternToggle:ft,includedPatterns:ie,onIncludedPatternToggle:Lt,isTeamPattern:ht}):pe(Ko,{selectedQuery:f,onQuerySelect:r,activeFilter:p,searchText:c,ignoredPatterns:ne,includedPatterns:ie,onFilterPress:()=>C(true)})})})}var Ml=T.create({container:{flex:1,backgroundColor:"transparent"}});import{JsModal as Tl,devToolsStorageKeys as Uo,useSafeAreaInsets as Al}from"@buoy-gg/shared-ui/web";import{useQueryClient as _o}from"@tanstack/react-query";import{useSafeAreaInsets as Jo,night as K,monoFont as Go}from"@buoy-gg/shared-ui/web";import{useMemo as El}from"react";function cr(e,t,r){return El(()=>{let o=e.state.status;return[{label:"Refetch",variant:"refetch",disabled:se(e)==="fetching",onPress:()=>Yt({query:e})},{label:e.state.fetchStatus==="fetching"?"Restore Loading":"Trigger Loading",variant:"triggerLoading",disabled:false,onPress:()=>Gt({query:e})},{label:o==="error"?"Restore Error":"Trigger Error",variant:"triggerError",disabled:o==="pending",onPress:()=>Xt({query:e,queryClient:t})}]},[e,t,r])}import{DataViewer as Dl}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as Rl,jsx as k,jsxs as _e}from"react/jsx-runtime";function Yo({selectedQuery:e,isFloatingMode:t,disableInternalFooter:r=false,queryVersion:o}){let a=Jo({minBottom:16}),n=_o(),s=cr(e,n,o);return _e(Rl,{children:[_e(be,{testID:"buoy-rq-detail-scroll",accessibilityLabel:"Data editor mode",accessibilityHint:"View data editor mode","sentry-label":"ignore data editor mode",style:I.explorerScrollContainer,contentContainerStyle:[I.explorerScrollContent,!r&&{paddingBottom:72}],children:[_e(h,{style:I.section,children:[k(Il,{visible:!!e.state.data,selectedQuery:e,queryVersion:o}),k(Ql,{visible:!e.state.data,selectedQuery:e})]}),k(h,{style:I.section,children:k(_t,{query:e})}),k(h,{style:I.section,children:_e(h,{style:I.queryExplorerContainer,children:[k(v,{testID:"buoy-rq-query-explorer-header",style:I.queryExplorerHeader,children:"Query Explorer"}),k(h,{style:I.queryExplorerContent,children:k(Dl,{title:"",data:e,maxDepth:10,rawMode:true,showTypeFilter:true,initialExpanded:false})})]})})]}),!r&&k(h,{style:[I.actionFooter,{paddingBottom:t?0:a.bottom+8}],children:k(h,{style:I.actionsRow,children:s.map((u,l)=>k(ue,{testID:`buoy-rq-action-${u.variant}`,onClick:u.onPress,text:u.label,variant:u.variant,disabled:u.disabled},l))})})]})}function kl({selectedQuery:e,isFloatingMode:t,queryVersion:r}){let o=Jo({minBottom:16}),a=_o(),n=cr(e,a,r);return k(h,{style:[I.actionFooter,{paddingBottom:t?0:o.bottom+8}],children:k(h,{style:I.actionsRow,children:n.map((s,u)=>k(ue,{testID:`buoy-rq-action-${s.variant}`,onClick:s.onPress,text:s.label,variant:s.variant,disabled:s.disabled},u))})})}function Il({visible:e,selectedQuery:t,queryVersion:r=0}){return e?_e(h,{style:I.dataContainer,children:[k(v,{testID:"buoy-rq-data-header",style:I.dataHeader,children:"Data Editor"}),k(h,{style:I.dataContent,children:k(me,{editable:true,label:"Data",value:t.state.data,defaultExpanded:["Data"],activeQuery:t,dataVersion:r})})]}):null}function Ql({visible:e,selectedQuery:t}){if(!e)return null;let r=()=>t.isDisabled()?{title:"Query Disabled",description:"This query is disabled and won't automatically fetch. Enable the query or manually trigger a fetch to load data."}:t.state.status==="pending"||se(t)==="fetching"?{title:t.state.status==="pending"?"Loading...":"Refetching...",description:"Please wait while the query is being executed."}:t.state.status==="error"?{title:"Query Error",description:t.state.error?.message||"An error occurred while fetching data."}:{title:"No Data Available",description:"This query has no data to edit. Try refetching the query first."},{title:o,description:a}=r();return _e(h,{style:I.emptyState,children:[k(v,{testID:"buoy-rq-detail-empty-title",style:I.emptyTitle,children:o}),k(v,{testID:"buoy-rq-detail-empty-description",style:I.emptyDescription,children:a})]})}var I=T.create({explorerScrollContainer:{flex:1},explorerScrollContent:{paddingBottom:16,paddingHorizontal:8,flexGrow:1},section:{marginBottom:16},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:K.color.text,fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},emptyDescription:{color:K.color.textSecondary,fontSize:14,textAlign:"center",lineHeight:20,maxWidth:280},actionFooter:{borderTopWidth:1,borderTopColor:K.color.border,paddingTop:8,paddingHorizontal:12,backgroundColor:"transparent",borderBottomLeftRadius:14,borderBottomRightRadius:14},actionsRow:{flexDirection:"row",alignItems:"center",gap:8},queryExplorerContainer:{minWidth:200,backgroundColor:K.color.surface,borderRadius:6,borderWidth:1,borderColor:K.color.accent+"4D",overflow:"hidden",shadowColor:K.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},queryExplorerHeader:{backgroundColor:K.color.accent+"1A",paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:K.color.accent,borderBottomWidth:1,borderBottomColor:K.color.accent+"33",letterSpacing:.5,textTransform:"uppercase",fontFamily:Go},queryExplorerContent:{padding:8},dataContainer:{minWidth:200,backgroundColor:K.color.surface,borderRadius:6,borderWidth:1,borderColor:K.color.accent+"4D",overflow:"hidden",shadowColor:K.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6,marginTop:8},dataHeader:{backgroundColor:K.color.accent+"1A",paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:K.color.accent,borderBottomWidth:1,borderBottomColor:K.color.accent+"33",letterSpacing:.5,textTransform:"uppercase",fontFamily:Go},dataContent:{padding:8}});import{useState as Fl,useCallback as Pl,useEffect as Ol,useRef as Kl}from"react";import{jsx as Dt}from"react/jsx-runtime";function Xo({visible:e,selectedQueryKey:t,onQuerySelect:r,onClose:o,onMinimize:a,enableSharedModalDimensions:n=false,onTabChange:s}){let{query:u,version:l}=Ht(t),[c,i]=Fl("bottomSheet"),d=t?JSON.stringify(t):void 0,f=Kl(void 0);Ol(()=>{if(u){f.current=d;return}e&&f.current!==void 0&&f.current===d&&(f.current=void 0,r(void 0))},[e,u,d,r]);let b=Pl(w=>{i(w)},[]),y=Al({minBottom:16}),m=c==="floating"?72:80+y.bottom,g=()=>Dt(tt,{selectedQuery:u,activeTab:"queries",onTabChange:s,onBack:()=>r(void 0)}),p=n?Uo.reactQuery.modal():`${Uo.reactQuery.modal()}_data_editor`;if(!e||!u)return null;let S=Dt(kl,{selectedQuery:u,isFloatingMode:c==="floating",queryVersion:l},`footer-${l}`);return Dt(Tl,{visible:e,onClose:o,onMinimize:a,persistenceKey:p,header:{customContent:g(),showToggleButton:true},onModeChange:b,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:S,footerHeight:m,children:Dt(Yo,{selectedQuery:u,isFloatingMode:c==="floating",disableInternalFooter:true,queryVersion:l})})}import{useQueryClient as zl}from"@tanstack/react-query";import{useCallback as dr,useState as Zo,useRef as ea}from"react";import{useEffect as Ll,useState as Bl}from"react";import{useQueryClient as Hl}from"@tanstack/react-query";function yr(e){let t=Hl(),[r,o]=Bl(void 0);return Ll(()=>{let a=()=>{if(e!==void 0){let s=t.getMutationCache().getAll().find(u=>u.mutationId===e);o(s)}else o(void 0)};setTimeout(a,0);let n=t.getMutationCache().subscribe(a);return()=>n()},[t,e]),r}import{jsx as ta}from"react/jsx-runtime";function ra({selectedMutation:e,onMutationSelect:t,activeFilter:r,searchText:o=""}){let a=n=>{t(typeof n=="function"?n(e):n)};return ta(h,{style:oa.mutationListContainer,children:ta(Mo,{selectedMutation:e,setSelectedMutation:a,activeFilter:r,searchText:o,hideInfoPanel:true,contentContainerStyle:oa.mutationListContent})})}var oa=T.create({mutationListContainer:{flex:1,backgroundColor:"transparent"},mutationListContent:{padding:8,backgroundColor:"transparent"}});import{ToolFooter as Wl,useSafeAreaInsets as jl}from"@buoy-gg/shared-ui/web";import{useMemo as Vl}from"react";import{jsx as hr}from"react/jsx-runtime";function aa({activeFilter:e,onFilterChange:t,modalMode:r,size:o="default"}){let a=r==="floating",n=jl({minBottom:16}),s=Vl(()=>a?0:n.bottom,[a,n.bottom]);return hr(Wl,{floating:a,safeArea:false,paddingBottom:s,style:na.filterFooter,children:hr(h,{style:na.filterContainer,children:hr(To,{activeFilter:e,onFilterChange:t,size:o})})},`footer-${a?"floating":"docked"}`)}var na=T.create({filterFooter:{paddingTop:8,paddingHorizontal:0},filterContainer:{minHeight:32,justifyContent:"center"}});import{JsModal as $l,useSafeAreaInsets as Nl}from"@buoy-gg/shared-ui/web";import{absoluteFill as Ul}from"@buoy-gg/shared-ui/web";import{useMemo as W}from"react";import{ChevronLeft as _l,ChevronRight as Jl,night as Rt}from"@buoy-gg/shared-ui/web";import{jsx as Je,jsxs as Gl}from"react/jsx-runtime";var He=32,ia=6,sa=He,Yl=120,kt=.95,la=1.15;function ua({translationX:e,maxTranslation:t=Yl,canSwipeLeft:r=true,canSwipeRight:o=true}){let a=W(()=>e.interpolate({inputRange:[0,t],outputRange:[0,1],extrapolate:"clamp"}),[e,t]),n=W(()=>a.interpolate({inputRange:[0,1],outputRange:[ia,sa]}),[a]),s=W(()=>a.interpolate({inputRange:[0,kt,1],outputRange:[1,1,la]}),[a]),u=W(()=>a.interpolate({inputRange:[0,.99,1],outputRange:[0,0,16]}),[a]),l=W(()=>a.interpolate({inputRange:[0,.01],outputRange:[0,1],extrapolate:"clamp"}),[a]),c=W(()=>a.interpolate({inputRange:[0,.5,1],outputRange:[0,0,1],extrapolate:"clamp"}),[a]),i=W(()=>a.interpolate({inputRange:[0,.5,kt,1],outputRange:[.8,.8,1,1.2]}),[a]),d=W(()=>e.interpolate({inputRange:[-t,0],outputRange:[1,0],extrapolate:"clamp"}),[e,t]),f=W(()=>d.interpolate({inputRange:[0,1],outputRange:[ia,sa]}),[d]),b=W(()=>d.interpolate({inputRange:[0,kt,1],outputRange:[1,1,la]}),[d]),y=W(()=>d.interpolate({inputRange:[0,.99,1],outputRange:[0,0,-16]}),[d]),m=W(()=>d.interpolate({inputRange:[0,.01],outputRange:[0,1],extrapolate:"clamp"}),[d]),g=W(()=>d.interpolate({inputRange:[0,.5,1],outputRange:[0,0,1],extrapolate:"clamp"}),[d]),p=W(()=>d.interpolate({inputRange:[0,.5,kt,1],outputRange:[.8,.8,1,1.2]}),[d]);return Gl(h,{style:fr.container,pointerEvents:"none",children:[o&&Je(Z.View,{style:[fr.leftWrapper,{width:n,height:He,borderRadius:He/2,backgroundColor:Rt.color.text+"E6",justifyContent:"center",alignItems:"center",opacity:l,transform:[{scale:s},{translateX:u}]}],children:Je(Z.View,{style:{opacity:c,transform:[{scale:i}]},children:Je(_l,{size:He*.6,color:Rt.color.accent,strokeWidth:3})})}),r&&Je(Z.View,{style:[fr.rightWrapper,{width:f,height:He,borderRadius:He/2,backgroundColor:Rt.color.text+"E6",justifyContent:"center",alignItems:"center",opacity:m,transform:[{scale:b},{translateX:y}]}],children:Je(Z.View,{style:{opacity:g,transform:[{scale:p}]},children:Je(Jl,{size:He*.6,color:Rt.color.accent,strokeWidth:3})})})]})}var fr=T.create({container:{...Ul,zIndex:1e3,justifyContent:"center",alignItems:"center"},leftWrapper:{position:"absolute",left:16},rightWrapper:{position:"absolute",right:16}});import{devToolsStorageKeys as ca}from"@buoy-gg/shared-ui/web";import{jsx as Ge,jsxs as Xl}from"react/jsx-runtime";function da({visible:e,selectedMutationId:t,onMutationSelect:r,onClose:o,onMinimize:a,activeFilter:n,onFilterChange:s,onTabChange:u,enableSharedModalDimensions:l=false,searchText:c="",onSearchChange:i}){let d=zl(),f=yr(t),[b,y]=Zo(null),m=n??b,g=s??y,p=dr(()=>{d.getMutationCache().clear(),r(void 0)},[d,r]),[S,w]=Zo("bottomSheet"),C=l?ca.reactQuery.modal():ca.reactQuery.mutationModal(),q=ea(new Z.Value(0)).current,A=dr(ne=>{ne==="right"&&u("queries")},[u]),j=dr(ne=>{w(ne)},[]),Qe=Nl({minBottom:16}),M=S==="floating"?56:48+Qe.bottom,ae=ea(Wt.create({onStartShouldSetPanResponder:()=>false,onMoveShouldSetPanResponder:(ne,ie)=>Math.abs(ie.dx)>5&&Math.abs(ie.dy)<10,onPanResponderMove:(ne,ie)=>{q.setValue(ie.dx)},onPanResponderRelease:(ne,ie)=>{let{dx:ht,vx:ft}=ie,Lt=80,mt=.5;Z.spring(q,{toValue:0,useNativeDriver:true}).start(),(Math.abs(ht)>Lt||Math.abs(ft)>mt)&&(ht>0||ft>0?A("right"):A("left"))},onPanResponderTerminate:()=>{Z.spring(q,{toValue:0,useNativeDriver:true}).start()}})).current;if(!e)return null;let ye=()=>Ge(tt,{selectedMutation:f,activeTab:"mutations",onTabChange:u,onBack:()=>r(void 0),searchText:c,onSearchChange:i,onClearCache:p}),he=Ge(aa,{activeFilter:m,onFilterChange:g,modalMode:S});return Ge($l,{visible:e,onClose:o,onMinimize:a,persistenceKey:C,header:{customContent:ye(),showToggleButton:true},onModeChange:j,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:he,footerHeight:M,children:Ge(h,{style:{flex:1},children:Xl(h,{...ae.panHandlers,style:{flex:1},children:[Ge(ua,{translationX:q,canSwipeLeft:false,canSwipeRight:true}),Ge(ra,{selectedMutation:f,onMutationSelect:r,activeFilter:m,searchText:c})]})})})}import{JsModal as Zl,useSafeAreaInsets as eu,devToolsStorageKeys as ya}from"@buoy-gg/shared-ui/web";import{useSafeAreaInsets as tu,night as z,monoFont as ha}from"@buoy-gg/shared-ui/web";import{useMemo as ru}from"react";import{useQueryClient as ou}from"@tanstack/react-query";function fa(e){let t=ou();return ru(()=>[{label:"Remove",variant:"remove",disabled:false,onPress:()=>t.getMutationCache().remove(e)}],[e,t])}import{DataViewer as au}from"@buoy-gg/shared-ui/web/dataViewer";import{Fragment as nu,jsx as Q,jsxs as Ye}from"react/jsx-runtime";function ma({selectedMutation:e,isFloatingMode:t,disableInternalFooter:r=false}){return Ye(nu,{children:[Ye(be,{testID:"buoy-rq-mutation-detail-scroll",accessibilityLabel:"Mutation editor mode",accessibilityHint:"View mutation editor mode","sentry-label":"ignore mutation editor mode",style:P.explorerScrollContainer,contentContainerStyle:P.explorerScrollContent,children:[Ye(h,{style:P.section,children:[Q(iu,{visible:!!e.state.data,selectedMutation:e}),Q(su,{visible:!e.state.data,selectedMutation:e})]}),Q(h,{style:P.section,children:Q(ar,{selectedMutation:e})}),Q(h,{style:P.section,children:Ye(h,{style:P.mutationExplorerContainer,children:[Q(v,{style:P.mutationExplorerHeader,children:"Mutation Explorer"}),Q(h,{style:P.mutationExplorerContent,children:Q(au,{title:"",data:e,maxDepth:10,rawMode:true,showTypeFilter:true,initialExpanded:false})})]})})]}),!r&&Q(pa,{selectedMutation:e,isFloatingMode:t})]})}function pa({selectedMutation:e,isFloatingMode:t}){let r=tu({minBottom:16}),o=fa(e);return Q(h,{style:[P.actionFooter,{paddingBottom:t?0:r.bottom+8}],children:Q(h,{style:P.actionsGrid,children:o.map((a,n)=>Q(ue,{testID:`buoy-rq-action-${a.variant}`,onClick:a.onPress,text:a.label,variant:a.variant,disabled:a.disabled},n))})})}function iu({visible:e,selectedMutation:t}){return e?Ye(h,{style:P.dataContainer,children:[Q(v,{style:P.dataHeader,children:"Data Editor"}),Q(h,{style:P.dataContent,children:Q(me,{editable:true,label:"Data",value:t.state.data,defaultExpanded:["Data"]},t.mutationId)})]}):null}function su({visible:e,selectedMutation:t}){if(!e)return null;let r=()=>t.state.status==="pending"?{title:"Pending...",description:"The mutation is in progress."}:t.state.status==="error"?{title:"Mutation Error",description:t.state.error?.message||"An error occurred."}:{title:"No Data Available",description:"This mutation has no data."},{title:o,description:a}=r();return Ye(h,{style:P.emptyState,children:[Q(v,{testID:"buoy-rq-mutation-detail-empty-title",style:P.emptyTitle,children:o}),Q(v,{testID:"buoy-rq-mutation-detail-empty-description",style:P.emptyDescription,children:a})]})}var P=T.create({explorerScrollContainer:{flex:1},explorerScrollContent:{paddingBottom:16,paddingHorizontal:8,flexGrow:1},section:{marginBottom:16},emptyState:{flex:1,justifyContent:"center",alignItems:"center",padding:32},emptyTitle:{color:z.color.text,fontSize:18,fontWeight:"600",marginBottom:8,textAlign:"center"},emptyDescription:{color:z.color.textSecondary,fontSize:14,textAlign:"center",lineHeight:20,maxWidth:280},actionFooter:{borderTopWidth:1,borderTopColor:z.color.border,paddingVertical:8,paddingHorizontal:12,backgroundColor:"transparent",borderBottomLeftRadius:14,borderBottomRightRadius:14},actionsGrid:{flexDirection:"row",flexWrap:"wrap",gap:6,justifyContent:"space-between"},mutationExplorerContainer:{minWidth:200,backgroundColor:z.color.surface,borderRadius:6,borderWidth:1,borderColor:z.color.accent+"4D",overflow:"hidden",shadowColor:z.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},mutationExplorerHeader:{backgroundColor:z.color.accent+"1A",paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:z.color.accent,borderBottomWidth:1,borderBottomColor:z.color.accent+"33",letterSpacing:.5,textTransform:"uppercase",fontFamily:ha},mutationExplorerContent:{padding:8},dataContainer:{minWidth:200,backgroundColor:z.color.surface,borderRadius:6,borderWidth:1,borderColor:z.color.accent+"4D",overflow:"hidden",shadowColor:z.color.accent,shadowOffset:{width:0,height:0},shadowOpacity:.1,shadowRadius:6},dataHeader:{backgroundColor:z.color.accent+"1A",paddingHorizontal:12,paddingVertical:10,fontWeight:"600",fontSize:12,color:z.color.accent,borderBottomWidth:1,borderBottomColor:z.color.accent+"33",letterSpacing:.5,textTransform:"uppercase",fontFamily:ha},dataContent:{padding:8}});import{useState as lu,useCallback as uu,useEffect as cu,useRef as du}from"react";import{jsx as It}from"react/jsx-runtime";function ga({visible:e,selectedMutationId:t,onMutationSelect:r,onClose:o,onMinimize:a,onTabChange:n,enableSharedModalDimensions:s=false}){let u=yr(t),[l,c]=lu("bottomSheet"),i=du(void 0);cu(()=>{if(u){i.current=u.mutationId;return}e&&i.current!==void 0&&i.current===t&&(i.current=void 0,r(void 0))},[e,u,t,r]);let d=uu(p=>{c(p)},[]),f=eu({minBottom:16}),b=l==="floating"?72:80+f.bottom,y=()=>It(tt,{selectedMutation:u,activeTab:"mutations",onTabChange:n,onBack:()=>r(void 0)}),m=s?ya.reactQuery.modal():ya.reactQuery.mutationModal();if(!e||!u)return null;let g=It(pa,{selectedMutation:u,isFloatingMode:l==="floating"});return It(Zl,{visible:e,onClose:o,onMinimize:a,persistenceKey:m,header:{customContent:y(),showToggleButton:true},onModeChange:d,enablePersistence:true,initialMode:"bottomSheet",enableGlitchEffects:true,styles:{},footer:g,footerHeight:b,children:It(ma,{selectedMutation:u,isFloatingMode:l==="floating",disableInternalFooter:true})})}import{Fragment as yu,jsx as Qt,jsxs as hu}from"react/jsx-runtime";function ba({visible:e,selectedQueryKey:t,selectedMutationId:r,onQuerySelect:o,onMutationSelect:a,onClose:n,onMinimize:s,activeFilter:u,onFilterChange:l,activeTab:c,onTabChange:i,enableSharedModalDimensions:d=false,searchText:f="",onSearchChange:b}){let y=!!t||!!r,m=c==="queries",g=c==="mutations",p={onClose:n,onMinimize:s,activeFilter:u,onFilterChange:l,enableSharedModalDimensions:d},S=e&&!y&&m,w=e&&!y&&g,C=e&&y&&m&&!!t,q=e&&y&&g&&!!r;return hu(yu,{children:[Qt(No,{visible:S,selectedQueryKey:t,onQuerySelect:o,onTabChange:i,searchText:f,onSearchChange:b,...p}),Qt(da,{visible:w,selectedMutationId:r,onMutationSelect:a,onTabChange:i,searchText:f,onSearchChange:b,...p}),Qt(Xo,{visible:C,selectedQueryKey:t,onQuerySelect:o,onTabChange:i,...p}),Qt(ga,{visible:q,selectedMutationId:r,onMutationSelect:a,onTabChange:i,...p})]})}import{ChangeLog as fu}from"@buoy-gg/shared-ui/web";var mu=0;function De(){return`rq-${Date.now()}-${++mu}`}var pu=class extends fu{constructor(){super({max:200});this.queryClient=null;this.queryUnsubscribe=null;this.mutationUnsubscribe=null;this.fetchStartTimes=new Map;this.mutationStartTimes=new Map;this.lastQueryStates=new Map;this.lastMutationStates=new Map}setQueryClient(e){this.disconnect(),this.queryClient=e,this.queryUnsubscribe=e.getQueryCache().subscribe(t=>{t.type==="updated"&&t.query&&this.handleQueryUpdate(t.query)}),this.mutationUnsubscribe=e.getMutationCache().subscribe(t=>{t.type==="updated"&&t.mutation&&this.handleMutationUpdate(t.mutation)})}disconnect(){this.queryUnsubscribe&&(this.queryUnsubscribe(),this.queryUnsubscribe=null),this.mutationUnsubscribe&&(this.mutationUnsubscribe(),this.mutationUnsubscribe=null),this.queryClient=null,this.lastQueryStates.clear(),this.lastMutationStates.clear(),this.fetchStartTimes.clear(),this.mutationStartTimes.clear()}handleQueryUpdate(e){if(Se(e.queryKey))return;let t=e.queryHash,r={fetchStatus:e.state.fetchStatus,status:e.state.status},o=this.lastQueryStates.get(t);if(!o)r.fetchStatus==="fetching"&&(this.fetchStartTimes.set(t,Date.now()),this.addEvent({id:De(),type:"query-fetch-start",timestamp:Date.now(),queryKey:e.queryKey,queryHash:t,query:e}));else{let a=o.fetchStatus==="fetching",n=r.fetchStatus==="fetching";if(!a&&n&&(this.fetchStartTimes.set(t,Date.now()),this.addEvent({id:De(),type:"query-fetch-start",timestamp:Date.now(),queryKey:e.queryKey,queryHash:t,query:e})),a&&!n){let s=this.fetchStartTimes.get(t),u=s?Date.now()-s:void 0;this.fetchStartTimes.delete(t),r.status==="error"?this.addEvent({id:De(),type:"query-fetch-error",timestamp:Date.now(),queryKey:e.queryKey,queryHash:t,queryError:e.state.error,duration:u,query:e}):this.addEvent({id:De(),type:"query-fetch-success",timestamp:Date.now(),queryKey:e.queryKey,queryHash:t,queryData:e.state.data,duration:u,query:e})}!o.status&&e.state.isInvalidated&&this.addEvent({id:De(),type:"query-invalidated",timestamp:Date.now(),queryKey:e.queryKey,queryHash:t,query:e})}this.lastQueryStates.set(t,r)}handleMutationUpdate(e){let t=e.mutationId,r=e.state.status,o=this.lastMutationStates.get(t);if(o!==r){if(r==="pending"&&o!=="pending")this.mutationStartTimes.set(t,Date.now()),this.addEvent({id:De(),type:"mutation-start",timestamp:Date.now(),mutationId:t,mutationKey:e.options.mutationKey,mutationVariables:e.state.variables,mutation:e});else if(r==="success"&&o==="pending"){let a=this.mutationStartTimes.get(t),n=a?Date.now()-a:void 0;this.mutationStartTimes.delete(t),this.addEvent({id:De(),type:"mutation-success",timestamp:Date.now(),mutationId:t,mutationKey:e.options.mutationKey,mutationVariables:e.state.variables,mutationData:e.state.data,duration:n,mutation:e})}else if(r==="error"&&o==="pending"){let a=this.mutationStartTimes.get(t),n=a?Date.now()-a:void 0;this.mutationStartTimes.delete(t),this.addEvent({id:De(),type:"mutation-error",timestamp:Date.now(),mutationId:t,mutationKey:e.options.mutationKey,mutationVariables:e.state.variables,mutationError:e.state.error,duration:n,mutation:e})}}this.lastMutationStates.set(t,r)}addEvent(e){this.record(e)}getEvents(){return this.items}subscribe(e){let t=super.subscribe(e);return e(this.items),t}clearEvents(){this.clear()}isConnected(){return this.queryClient!==null}},We=new pu,gu=e=>We.setQueryClient(e),bu=()=>We.disconnect();import{jsx as va}from"react/jsx-runtime";function mr({visible:e,onClose:t,onMinimize:r,enableSharedModalDimensions:o=true}){let a=ln();sn(()=>{We.isConnected()||We.setQueryClient(a)},[a]);let[n,s]=Ze(void 0),[u,l]=Ze(void 0),[c,i]=Ze(null),[d,f]=Ze("queries"),[b,y]=Ze(""),m=Fe(()=>{s(void 0),l(void 0),i(null),f("queries"),y("")},[]),g=Fe(()=>{m(),t()},[t,m]),p=Fe(A=>{s(A?.queryKey)},[]),S=Fe(A=>{l(A?.mutationId)},[]),w=Fe(A=>{i(A)},[]),C=Fe(A=>{f(A),i(null),s(void 0),l(void 0),y("")},[]),q=Fe(A=>{y(A)},[]);return e?va(un,{children:va(ba,{visible:e,selectedQueryKey:n,selectedMutationId:u,onQuerySelect:p,onMutationSelect:S,onClose:g,onMinimize:r,activeFilter:c,onFilterChange:w,activeTab:d,onTabChange:C,searchText:b,onSearchChange:q,enableSharedModalDimensions:o})}):null}import{onlineManager as ge}from"@tanstack/react-query";import{devToolsStorageKeys as Sa,persistentStorage as Ca}from"@buoy-gg/shared-ui/web";import{useState as xa,useEffect as wa}from"react";import{jsx as Ft}from"react/jsx-runtime";var qa=()=>null,Ma=async e=>{try{await Ca.setItem(Sa.settings.wifiEnabled(),e.toString())}catch{}},vu=async()=>{try{let e=await Ca.getItem(Sa.settings.wifiEnabled());e!==null&&ge.setOnline(e==="true")}catch{}};vu();function Su({size:e}){let[t,r]=xa(()=>ge.isOnline());return wa(()=>ge.subscribe(o=>{r(o)}),[]),Ft(qr,{size:e,color:t?"#10B981":"#DC2626"})}var Cu={id:"query",name:"QUERY",description:"React Query inspector",slot:"both",icon:({size:e})=>Ft(wr,{size:e}),component:mr,props:{enableSharedModalDimensions:false}};function xu(e){return{id:e?.id||"query",name:e?.name||"QUERY",description:e?.description||"React Query inspector",slot:"both",icon:({size:t})=>Ft(wr,{size:t}),component:mr,props:{enableSharedModalDimensions:e?.enableSharedModalDimensions!==void 0?e.enableSharedModalDimensions:false}}}var wu={id:"query-wifi-toggle",name:"WIFI",description:"Toggle React Query online/offline state",slot:"row",icon:Su,component:qa,props:{},launchMode:"toggle-only",onPress:()=>{let e=!ge.isOnline();ge.setOnline(e),Ma(e)}};function qu(e){let t=e?.onColor||"#10B981",r=e?.offColor||"#DC2626",o=({size:a})=>{let[n,s]=xa(()=>ge.isOnline());return wa(()=>ge.subscribe(u=>{s(u)}),[]),Ft(qr,{size:a,color:n?t:r})};return{id:e?.id||"query-wifi-toggle",name:e?.name||"WIFI",description:e?.description||"Toggle React Query online/offline state",slot:"row",icon:o,component:qa,props:{},launchMode:"toggle-only",onPress:()=>{let a=!ge.isOnline();ge.setOnline(a),Ma(a)}}}import{expandKeyedArrays as Mu,patchFromPath as Tu,readPath as Au,refusalText as Eu,shapeSummary as Pt,suggestedPatch as Du,typedEditViolations as Ru,unshapedLists as ku}from"@buoy-gg/shared-ui/web";import{onlineManager as pr}from"@tanstack/react-query";import{isJsonSerializable as Ta,isOverWireBudget as Aa}from"@buoy-gg/shared-ui/web";var Iu=Object.freeze({__buoyDataOnDevice:true,note:"Query data stays on the device \u2014 fetched on demand via getQueryData."}),Ea=Object.freeze({__buoyUnserializable:true,note:"Query data is not JSON-serializable (circular or bigint) and stayed on the device."}),Qu=16*1024,Da=8*1024*1024;function Fu(e){return!!e&&typeof e=="object"&&e.__buoyDataOnDevice===true}function Pu(e){return!!e&&typeof e=="object"&&e.__buoyUnserializable===true}function Ra(e){return Fu(e)||Pu(e)}function Re(e){if(e!==void 0)return Aa(e,Qu)?Ta(e)?Iu:Ea:e}function Ot(e){if(e==null)return e;if(typeof e=="object"){let t=e,r=typeof t.name=="string"?t.name:void 0,o=typeof t.message=="string"?t.message:void 0;if(r!==void 0||o!==void 0)return Re({...r!==void 0?{name:r}:{},...o!==void 0?{message:o}:{}})}return Re(e)}function Ou(e){return Aa(e,Da)?Ta(e)?{__buoyTruncated:true,note:`Exceeds the ${Da/(1024*1024)}MB detail limit \u2014 inspect it on-device.`}:Ea:e}function Ku(e){let t=e.getMutationCache().getAll().map(o=>zu(o)),r=e.getQueryCache().getAll().map(o=>Bu(o));return{mutations:t,queries:r}}function zu(e){let t=e.state;return{mutationId:e.mutationId,mutationKey:e.options.mutationKey,state:{...t,data:Re(t.data),variables:Re(t.variables),error:Ot(t.error),failureReason:Ot(t.failureReason)},...e.options.scope&&{scope:e.options.scope},...e.meta&&{meta:Re(e.meta)}}}function Lu(e){let{queryFn:t,select:r,persister:o,initialData:a,placeholderData:n,...s}=e;return{...s,queryFn:void 0,...e.meta?{meta:Re(e.meta)}:{}}}function Bu(e){let t=e.observers.map(r=>({queryHash:e.queryHash,options:Lu(r.options)}));return{state:{...e.state,...e.state.data!==void 0&&{data:Re(e.state.data)},error:Ot(e.state.error),fetchFailureReason:Ot(e.state.fetchFailureReason)},queryKey:e.queryKey,queryHash:e.queryHash,...e.meta&&{meta:Re(e.meta)},observers:t}}function Hu(e,t){let r=e;for(let o of t.split(".")){if(!r||typeof r!="object"||Array.isArray(r)||!(o in r))return false;r=r[o]}return Array.isArray(r)?r.length>0:!!r&&typeof r=="object"}var dt=e=>!!e&&typeof e=="object"&&!Array.isArray(e);function ka(e){return Array.isArray(e)?"array":e===null?"null":typeof e=="object"?"object":typeof e}function Ia(e,t,r="",o={shrunk:[],breaks:[]}){if(Array.isArray(e)&&Array.isArray(t))return t.length>0&&t.length<e.length&&o.shrunk.push({path:r||"(root)",have:e.length,sent:t.length}),t;if(!dt(e)||!dt(t))return t;let a={...e};for(let[n,s]of Object.entries(t)){let u=r?`${r}.${n}`:n;if(n in e){let l=ka(e[n]),c=ka(s);(l==="array"||l==="object")&&l!==c&&o.breaks.push({path:u,from:l,to:c}),a[n]=Ia(e[n],s,u,o)}else a[n]=s}return a}function Wu(e){let t=e.trim();try{let r=JSON.parse(t);if(Array.isArray(r))return r.map(o=>typeof o=="object"&&o!==null?JSON.stringify(o):String(o))}catch{}return t.includes(",")&&!t.startsWith("[")?t.split(",").map(r=>r.trim().replace(/^["']|["']$/g,"")):null}function ju(e){let t;for(let r of e.observers??[]){let o=r.options?.refetchInterval,a=o;if(typeof o=="function")try{a=o(e)}catch{a=void 0}typeof a=="number"&&a>0&&(t=t===void 0?a:Math.min(t,a))}return t}function Qa(e){let t=r=>{let{queryHash:o}=r,a=e.getQueryCache(),n=o?a.get(o):void 0;if(!n&&typeof o=="string"){let s=Wu(o);s&&(n=a.getAll().find(u=>{let l=u.queryKey.map(c=>typeof c=="object"?JSON.stringify(c):String(c));return l.length===s.length&&l.every((c,i)=>c===s[i])}))}if(!n)throw new Error(`Query with hash "${o}" not found`);return n};return{version:2,getSnapshot:()=>({dehydratedState:Ku(e),isOnlineManagerOnline:pr.isOnline()}),subscribe:r=>{let o=e.getQueryCache().subscribe(r),a=e.getMutationCache().subscribe(r),n=pr.subscribe(r);return()=>{o(),a(),n()}},actions:{getQueryData:r=>{let{queryHash:o,path:a}=r??{};if(!o)return{found:false,reason:"missing queryHash"};let n=e.getQueryCache().get(o);if(!n)return{found:false,reason:"unknown queryHash"};if(a){let u=Au(n.state.data,a);return u.ok?{found:true,queryHash:o,path:a,shape:Pt(u.value),data:u.value}:{found:false,reason:u.error}}if(n.state.data===void 0){let u=n.state.status,l=n.state.error;return{found:true,queryHash:o,hasData:false,status:u,fetchStatus:n.state.fetchStatus,...l?{error:l instanceof Error?l.message:String(l)}:{},reason:u==="error"?"This query has no data because it FAILED. Report the error, not an empty result.":n.state.fetchStatus==="fetching"?"No data yet \u2014 this query is still fetching.":"This query has never resolved (it may be disabled, or never enabled). It is not empty \u2014 it has nothing."}}let s=Pt(n.state.data);return{found:true,queryHash:o,hasData:true,...s?{shape:s}:{},data:Ou(n.state.data)}},listQueries:r=>{let{includeData:o=false,staleOnly:a=false,limit:n}=r??{},s=e.getQueryCache().getAll(),u=[...a?s.filter(c=>c.isStale()):s].sort((c,i)=>{let d=+(i.getObserversCount()>0)-+(c.getObserversCount()>0);return d!==0?d:(i.state.dataUpdatedAt??0)-(c.state.dataUpdatedAt??0)}),l=(typeof n=="number"&&n>0?u.slice(0,n):u).map(c=>{let i=c.state.error,d=ju(c);return{queryHash:c.queryHash,queryKey:c.queryKey,status:se(c),fetchStatus:c.state.fetchStatus,isStale:c.isStale(),observers:c.getObserversCount(),updatedAt:c.state.dataUpdatedAt,...d?{refetchEveryMs:d}:{},error:i?i.message??String(i):void 0,...o?{data:c.state.data}:{},...Pt(c.state.data)?{shape:Pt(c.state.data)}:{}}});return{queries:l,total:s.length,returned:l.length,includedData:o}},refetch:r=>t(r).fetch().catch(()=>{}),invalidate:r=>e.invalidateQueries(t(r)),reset:r=>e.resetQueries(t(r)),remove:r=>{let o=t(r),a=e.getQueryCache().findAll(o).some(n=>n.getObserversCount()>0);return e.removeQueries(o),{ok:true,...a?{note:"Removed \u2014 but a screen is still watching this query, and React Query leaves that screen rendering its LAST value (including anything written into the cache before this) until something refetches. Nothing on screen will change on its own. Use `reset` instead when you want the screen to go back to loading and fetch again."}:{}}},setQueryData:r=>{let{data:o,merge:a,force:n,path:s,value:u}=r,{queryKey:l,queryHash:c}=r,i=l;if(i===void 0&&typeof c=="string"){let y=e.getQueryCache().get(c);if(!y)return{ok:false,error:`Refused: no query with hash ${c} is in the cache. Read listQueries for the current hashes \u2014 a query that has been removed or whose key includes changing params (a search term, a cart payload) will not match an older hash.`};i=y.queryKey}if(i===void 0)return{ok:false,error:"Refused: no query was named. Send `queryKey` (the array from listQueries) or `queryHash` (its string form)."};let d=e.getQueryData(i),f=e.getQueryCache().find({queryKey:i,exact:true});if(d===void 0&&f&&(o!==void 0||s!==void 0)){let y=f,m=y?.state.status;return{ok:false,error:`Refused: this query has no data to edit \u2014 ${m==="error"?`it FAILED${y?.state.error?` (${y.state.error instanceof Error?y.state.error.message:String(y.state.error)})`:""}`:m==="pending"?"it has never resolved (it may be disabled, or still loading)":"it holds no data"}. There is nothing to merge into. Fix the cause first (restoreError, or let it fetch), or send force:true with the COMPLETE value if you mean to seed the cache from nothing.`,status:m}}if(o===void 0&&s===void 0)return{ok:false,error:"Refused: no change was described. Send `data` (with merge:true for a partial edit), or `path` and `value` to set one value."};let b=o;if(s!==void 0){if(u===void 0)return{ok:false,error:`Refused: sent \`path\` without \`value\`. Say what to set "${s}" to; if you mean to clear it, send value:null and the field must already be nullable.`};let y=Tu(d,s,u);if(!y.ok)return{ok:false,error:`Refused: ${y.error}`};b=y.patch}if(a||s!==void 0){let y=n?{patch:b,notes:[],error:void 0}:Mu(d,b);if(y.error)return{ok:false,error:`Refused: ${y.error}`};let m=y.patch;if(!n){let S=Ru(d,m,{noun:"data"});if(S.length>0){let w=Du(m,S);return{ok:false,error:Eu(S,"data",w),violations:S,...w?{suggestedData:w}:{}}}}let g=Ia(d,m),p=ku(d).filter(S=>Hu(m,S));return e.setQueryData(i,g,{updatedAt:Date.now()}),{ok:true,mode:"merge",...s!==void 0?{path:s}:{},changedKeys:dt(m)?Object.keys(m):void 0,...y.notes.length?{keyed:y.notes}:{},...p.length?{unchecked:p.map(S=>`\`${S}\` was empty, so nothing in the app knows what its items look like and the shape of what you added was NOT checked. If the screen renders a field you left out, it will render undefined \u2014 read the query back and compare against how the screen uses it.`)}:{}}}if(!n&&dt(d)&&dt(o)){let y=Object.keys(d).filter(m=>!(m in o));if(y.length>0)return{ok:false,error:`Refused: the new value drops ${y.length} top-level field(s) the cached value has (${y.slice(0,8).join(", ")}${y.length>8?", \u2026":""}). A screen rendering those fields would crash. To change some fields, send merge:true with ONLY the fields that change. To really replace the whole value, send force:true.`,missingKeys:y}}return e.setQueryData(i,o,{updatedAt:Date.now()}),{ok:true,mode:"replace"}},triggerError:r=>{let o=t(r),a=o.options;o.setState({status:"error",error:new Error("Unknown error from devtools"),fetchMeta:{...o.state.fetchMeta,__previousQueryOptions:a}})},restoreError:r=>(e.resetQueries(t(r)).catch(()=>{}),{restored:true}),triggerLoading:r=>{let o=t(r),a=o.options;o.fetch({...a,queryFn:()=>new Promise(()=>{}),gcTime:-1}).catch(()=>{}),o.setState({data:void 0,status:"pending",fetchMeta:{...o.state.fetchMeta,__previousQueryOptions:a}})},restoreLoading:r=>{let o=t(r),a=o.state,n=o.state.fetchMeta?o.state.fetchMeta.__previousQueryOptions:null;o.cancel({silent:true}),o.setState({...a,fetchStatus:"idle",fetchMeta:null}),n&&o.fetch(n).catch(()=>{})},clearQueryCache:()=>{let r=e.getQueryCache().getAll().filter(o=>o.getObserversCount()>0).length;return e.getQueryCache().clear(),{ok:true,cleared:true,...r?{note:`Cleared \u2014 but ${r} quer${r===1?"y is":"ies are"} still being watched by a screen, and React Query leaves those screens rendering their LAST value until something refetches. The cache is empty; the app on screen is not. Use \`reset\` on a query when you want its screen to reload.`}:{}}},clearMutationCache:()=>{e.getMutationCache().clear()},setOnline:r=>{let{online:o}=r;pr.setOnline(o)}}}}import{useEffect as Vu,useMemo as $u}from"react";import{useQueryClient as Nu}from"@tanstack/react-query";import{classifyPreviewItem as Uu,createRestoreScope as _u,emptyRestoreResult as Ju,failedRestore as Gu,registerStateSnapshotProvider as Yu,superJsonSerialize as Xu}from"@buoy-gg/shared-ui/web";function Fa(e){return{...e,fetchStatus:"idle",fetchMeta:null}}function gr(e){return{status:e.state.status,error:e.state.error??null,data:e.state.data}}function br(e,t){try{let r=JSON.stringify(e);return r.length>60?`${r.slice(0,57)}\u2026`:r}catch{return t}}function Pa(e){if(e==null)return e??null;if(typeof e=="object"){let t=e,r=typeof t.name=="string"?t.name:void 0,o=typeof t.message=="string"?t.message:void 0;if(r!==void 0||o!==void 0)return{...r!==void 0?{name:r}:{},...o!==void 0?{message:o}:{}}}return e}function Oa(e){if(e===void 0)return true;try{return Xu(e),true}catch{return false}}function Ka(e){let t=[],r=[];for(let o of e.getQueryCache().getAll()){let a=br(o.queryKey,o.queryHash);if(!Oa(o.state.data)){t.push(`query ${a}: data can't be serialized (circular reference?) \u2014 not captured`);continue}r.push({queryKey:o.queryKey,queryHash:o.queryHash,...o.meta&&Oa(o.meta)?{meta:o.meta}:{},state:Fa({...o.state,error:Pa(o.state.error),fetchFailureReason:Pa(o.state.fetchFailureReason)})})}return{queries:r,warnings:t}}function Zu(e){return{id:"query",label:"React Query",status:()=>({canCapture:true,canRestore:true}),async capture(){let{queries:t,warnings:r}=Ka(e),o=e.getMutationCache().getAll().length;return o>0&&r.push(`${o} mutation(s) not captured (mutation functions cannot be restored)`),{data:{queries:t},warnings:r}},async restore(t,r){let o=t,a=_u(r),n=Ju();if(!o?.queries)return Gu("empty query snapshot");let s=e.getQueryCache(),u=new Set(o.queries.map(i=>i.queryHash));for(let i of o.queries)if(a.allows(i.queryHash)){if(Ra(i.state.data)){n.skipped.push({id:i.queryHash,reason:"captured as an on-device placeholder by an older Buoy \u2014 re-capture this restore point"});continue}try{let d=Fa(i.state),f=s.get(i.queryHash);f?f.setState(d):s.build(e,{queryKey:i.queryKey,queryHash:i.queryHash,...i.meta&&{meta:i.meta}},d),n.applied+=1}catch(d){n.skipped.push({id:i.queryHash,reason:String(d)}),n.ok=false}}for(let i of s.getAll().slice())if(a.allows(i.queryHash)&&!u.has(i.queryHash))try{s.remove(i),n.applied+=1}catch(d){n.skipped.push({id:i.queryHash,reason:String(d)})}let l=e.getMutationCache().getAll().length;l>0&&(e.getMutationCache().clear(),n.warnings.push(`mutation cache cleared (${l} mutation(s))`));let c=a.excludedWarning("quer(y/ies)");return c&&n.warnings.push(c),n},async previewItems(t,r){let o=t?.queries??[],a=r===void 0,n=a?Ka(e).queries:r?.queries??[],s=new Map(n.map(i=>[i.queryHash,i])),u=new Map(o.map(i=>[i.queryHash,i])),l=[],c=[];for(let i of o){let d=br(i.queryKey,i.queryHash);if(Ra(i.state.data)){l.push({key:i.queryHash,label:d,verdict:"wont-apply",reason:"data stayed on the device when this was captured (older Buoy) \u2014 re-capture this restore point"});continue}let f=s.get(i.queryHash);l.push(Uu({key:i.queryHash,label:d,oldValue:f?gr(f):void 0,newValue:gr(i),inOld:f!==void 0,inNew:true},{tooLargeReason:"query data too large to render a diff \u2014 restore still applies it"}))}for(let i of n)u.has(i.queryHash)||l.push({key:i.queryHash,label:br(i.queryKey,i.queryHash),verdict:"removed",oldValue:gr(i)});if(a){let i=e.getMutationCache().getAll().length;i>0&&c.push(`${i} in-memory mutation record(s) will be cleared`)}return{items:l,notes:c}}}}function ec(e){return Yu(Zu(e))}function tc(){let e;try{e=Nu()}catch{e=null}return Vu(()=>{if(e)return ec(e)},[e]),$u(()=>e?Qa(e):null,[e])}function za({queryState:e,observerCount:t,isStale:r}){return e.fetchStatus==="fetching"?"blue":e.status==="error"?"red":t?e.fetchStatus==="paused"?"purple":r?"yellow":"green":"gray"}import{useQueryClient as rc}from"@tanstack/react-query";import{jsx as Kt,jsxs as ke}from"react/jsx-runtime";function La(){try{let e=rc(),t=e.getQueryCache().getAll(),r=e.getMutationCache().getAll();return ke(h,{style:Y.container,children:[Kt(v,{style:Y.title,children:"Debug Info"}),Kt(v,{style:Y.info,children:"QueryClient: \u2705 Available"}),ke(v,{style:Y.info,children:["Queries: ",t.length]}),ke(v,{style:Y.info,children:["Mutations: ",r.length]}),t.length>0&&ke(h,{style:Y.queriesList,children:[Kt(v,{style:Y.subtitle,children:"Query Keys:"}),t.slice(0,3).map((o,a)=>ke(v,{style:Y.queryKey,children:["\u2022"," ",Array.isArray(o.queryKey)?o.queryKey.join(" - "):String(o.queryKey)]},a)),t.length>3&&ke(v,{style:Y.more,children:["... and ",t.length-3," more"]})]})]})}catch(e){return ke(h,{style:Y.container,children:[Kt(v,{style:Y.title,children:"Debug Info"}),ke(v,{style:Y.error,children:["\u274C QueryClient Error: ",String(e)]})]})}}var Y=T.create({container:{padding:16,backgroundColor:"rgba(0, 0, 0, 0.3)",borderRadius:8,margin:16,borderWidth:1,borderColor:"rgba(255, 255, 255, 0.1)"},title:{color:"#FFFFFF",fontSize:14,fontWeight:"600",marginBottom:8},subtitle:{color:"#E5E7EB",fontSize:12,fontWeight:"500",marginTop:8,marginBottom:4},info:{color:"#9CA3AF",fontSize:12,marginBottom:4},error:{color:"#EF4444",fontSize:12,marginBottom:4},queriesList:{marginTop:4},queryKey:{color:"#60A5FA",fontSize:11,marginLeft:8,marginBottom:2},more:{color:"#9CA3AF",fontSize:11,fontStyle:"italic",marginLeft:8}});import{jsx as Ie,jsxs as Xe}from"react/jsx-runtime";function oc({queries:e,selectedQuery:t,isOpen:r,onClose:o,onSelect:a}){let n=s=>Array.isArray(s.queryKey)?s.queryKey.join(" - "):String(s.queryKey);return Ie(Pr,{accessibilityLabel:"Query selector",accessibilityHint:"View query selector","sentry-label":"ignore query selector",visible:r,transparent:true,animationType:"fade",onRequestClose:o,children:Ie(Qr,{accessibilityLabel:"Query selector overlay",accessibilityHint:"View query selector overlay","sentry-label":"ignore query selector overlay",style:L.modalOverlay,onPress:o,children:Xe(h,{accessibilityLabel:"Query selector content",accessibilityHint:"View query selector content","sentry-label":"ignore query selector content",style:L.modalContent,children:[Xe(h,{style:L.modalHeader,children:[Ie(v,{style:L.modalTitle,children:"Select Query"}),Xe(v,{style:L.modalSubtitle,children:[e.length," ",e.length===1?"query":"queries"," ","available"]})]}),Ie(be,{accessibilityLabel:"Query selector scroll view",accessibilityHint:"View query selector scroll view","sentry-label":"ignore query selector scroll view",style:L.scrollView,contentContainerStyle:L.scrollViewContent,showsVerticalScrollIndicator:true,children:e.length===0?Xe(h,{style:L.emptyState,children:[Ie(v,{style:L.emptyTitle,children:"No Queries Found"}),Xe(v,{style:L.emptyDescription,children:["No React Query queries are currently active.",`
7
7
 
8
8
  `,"To see queries here:",`
9
9
  `,"\u2022 Make API calls using useQuery",`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/react-query",
3
- "version": "7.0.68",
3
+ "version": "7.0.70",
4
4
  "description": "TanStack Query devtools inside your React Native app — cache inspection, refetch & invalidate, offline toggle. Part of Buoy devtools.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -39,8 +39,8 @@
39
39
  "**/checkPeer.*"
40
40
  ],
41
41
  "dependencies": {
42
- "@buoy-gg/floating-tools-core": "^7.0.68",
43
- "@buoy-gg/shared-ui": "^7.0.68"
42
+ "@buoy-gg/floating-tools-core": "^7.0.70",
43
+ "@buoy-gg/shared-ui": "^7.0.70"
44
44
  },
45
45
  "peerDependencies": {
46
46
  "@tanstack/react-query": ">=5.0.0",