rails-profiler 0.27.0 → 0.28.0

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,5 +1,22 @@
1
1
  "use strict";
2
2
  (() => {
3
+ var __typeError = (msg) => {
4
+ throw TypeError(msg);
5
+ };
6
+ var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
7
+ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
8
+ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
9
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
10
+ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
11
+ var __privateWrapper = (obj, member, setter, getter) => ({
12
+ set _(value) {
13
+ __privateSet(obj, member, value, setter);
14
+ },
15
+ get _() {
16
+ return __privateGet(obj, member, getter);
17
+ }
18
+ });
19
+
3
20
  // node_modules/preact/dist/preact.module.js
4
21
  var n;
5
22
  var l;
@@ -68,8 +85,8 @@
68
85
  }
69
86
  }
70
87
  function P(n2, l3, u4, t3, i3, r3, o3, e3, f4, c3, s3) {
71
- var a3, h3, y3, d3, w3, g2, _2, m3 = t3 && t3.__k || v, b = l3.length;
72
- for (f4 = A(u4, l3, m3, f4, b), a3 = 0; a3 < b; a3++) null != (y3 = u4.__k[a3]) && (h3 = -1 != y3.__i && m3[y3.__i] || p, y3.__i = a3, g2 = z(n2, y3, h3, i3, r3, o3, e3, f4, c3, s3), d3 = y3.__e, y3.ref && h3.ref != y3.ref && (h3.ref && D(h3.ref, null, y3), s3.push(y3.ref, y3.__c || d3, y3)), null == w3 && null != d3 && (w3 = d3), (_2 = !!(4 & y3.__u)) || h3.__k === y3.__k ? f4 = H(y3, f4, n2, _2) : "function" == typeof y3.type && void 0 !== g2 ? f4 = g2 : d3 && (f4 = d3.nextSibling), y3.__u &= -7);
88
+ var a3, h3, y3, d3, w3, g2, _3, m3 = t3 && t3.__k || v, b = l3.length;
89
+ for (f4 = A(u4, l3, m3, f4, b), a3 = 0; a3 < b; a3++) null != (y3 = u4.__k[a3]) && (h3 = -1 != y3.__i && m3[y3.__i] || p, y3.__i = a3, g2 = z(n2, y3, h3, i3, r3, o3, e3, f4, c3, s3), d3 = y3.__e, y3.ref && h3.ref != y3.ref && (h3.ref && D(h3.ref, null, y3), s3.push(y3.ref, y3.__c || d3, y3)), null == w3 && null != d3 && (w3 = d3), (_3 = !!(4 & y3.__u)) || h3.__k === y3.__k ? f4 = H(y3, f4, n2, _3) : "function" == typeof y3.type && void 0 !== g2 ? f4 = g2 : d3 && (f4 = d3.nextSibling), y3.__u &= -7);
73
90
  return u4.__e = w3, f4;
74
91
  }
75
92
  function A(n2, l3, u4, t3, i3) {
@@ -130,11 +147,11 @@
130
147
  };
131
148
  }
132
149
  function z(n2, u4, t3, i3, r3, o3, e3, f4, c3, s3) {
133
- var a3, h3, p3, y3, _2, m3, b, S2, C3, M2, $2, I2, A3, H2, L, T3 = u4.type;
150
+ var a3, h3, p3, y3, _3, m3, b, S2, C3, M2, $2, I2, A3, H2, L, T3 = u4.type;
134
151
  if (void 0 !== u4.constructor) return null;
135
152
  128 & t3.__u && (c3 = !!(32 & t3.__u), o3 = [f4 = u4.__e = t3.__e]), (a3 = l.__b) && a3(u4);
136
153
  n: if ("function" == typeof T3) try {
137
- if (S2 = u4.props, C3 = T3.prototype && T3.prototype.render, M2 = (a3 = T3.contextType) && i3[a3.__c], $2 = a3 ? M2 ? M2.props.value : a3.__ : i3, t3.__c ? b = (h3 = u4.__c = t3.__c).__ = h3.__E : (C3 ? u4.__c = h3 = new T3(S2, $2) : (u4.__c = h3 = new x(S2, $2), h3.constructor = T3, h3.render = G), M2 && M2.sub(h3), h3.state || (h3.state = {}), h3.__n = i3, p3 = h3.__d = true, h3.__h = [], h3._sb = []), C3 && null == h3.__s && (h3.__s = h3.state), C3 && null != T3.getDerivedStateFromProps && (h3.__s == h3.state && (h3.__s = w({}, h3.__s)), w(h3.__s, T3.getDerivedStateFromProps(S2, h3.__s))), y3 = h3.props, _2 = h3.state, h3.__v = u4, p3) C3 && null == T3.getDerivedStateFromProps && null != h3.componentWillMount && h3.componentWillMount(), C3 && null != h3.componentDidMount && h3.__h.push(h3.componentDidMount);
154
+ if (S2 = u4.props, C3 = T3.prototype && T3.prototype.render, M2 = (a3 = T3.contextType) && i3[a3.__c], $2 = a3 ? M2 ? M2.props.value : a3.__ : i3, t3.__c ? b = (h3 = u4.__c = t3.__c).__ = h3.__E : (C3 ? u4.__c = h3 = new T3(S2, $2) : (u4.__c = h3 = new x(S2, $2), h3.constructor = T3, h3.render = G), M2 && M2.sub(h3), h3.state || (h3.state = {}), h3.__n = i3, p3 = h3.__d = true, h3.__h = [], h3._sb = []), C3 && null == h3.__s && (h3.__s = h3.state), C3 && null != T3.getDerivedStateFromProps && (h3.__s == h3.state && (h3.__s = w({}, h3.__s)), w(h3.__s, T3.getDerivedStateFromProps(S2, h3.__s))), y3 = h3.props, _3 = h3.state, h3.__v = u4, p3) C3 && null == T3.getDerivedStateFromProps && null != h3.componentWillMount && h3.componentWillMount(), C3 && null != h3.componentDidMount && h3.__h.push(h3.componentDidMount);
138
155
  else {
139
156
  if (C3 && null == T3.getDerivedStateFromProps && S2 !== y3 && null != h3.componentWillReceiveProps && h3.componentWillReceiveProps(S2, $2), u4.__v == t3.__v || !h3.__e && null != h3.shouldComponentUpdate && false === h3.shouldComponentUpdate(S2, h3.__s, $2)) {
140
157
  u4.__v != t3.__v && (h3.props = S2, h3.state = h3.__s, h3.__d = false), u4.__e = t3.__e, u4.__k = t3.__k, u4.__k.some(function(n3) {
@@ -143,14 +160,14 @@
143
160
  break n;
144
161
  }
145
162
  null != h3.componentWillUpdate && h3.componentWillUpdate(S2, h3.__s, $2), C3 && null != h3.componentDidUpdate && h3.__h.push(function() {
146
- h3.componentDidUpdate(y3, _2, m3);
163
+ h3.componentDidUpdate(y3, _3, m3);
147
164
  });
148
165
  }
149
166
  if (h3.context = $2, h3.props = S2, h3.__P = n2, h3.__e = false, I2 = l.__r, A3 = 0, C3) h3.state = h3.__s, h3.__d = false, I2 && I2(u4), a3 = h3.render(h3.props, h3.state, h3.context), v.push.apply(h3.__h, h3._sb), h3._sb = [];
150
167
  else do {
151
168
  h3.__d = false, I2 && I2(u4), a3 = h3.render(h3.props, h3.state, h3.context), h3.state = h3.__s;
152
169
  } while (h3.__d && ++A3 < 25);
153
- h3.state = h3.__s, null != h3.getChildContext && (i3 = w(w({}, i3), h3.getChildContext())), C3 && !p3 && null != h3.getSnapshotBeforeUpdate && (m3 = h3.getSnapshotBeforeUpdate(y3, _2)), H2 = null != a3 && a3.type === k && null == a3.key ? q(a3.props.children) : a3, f4 = P(n2, d(H2) ? H2 : [H2], u4, t3, i3, r3, o3, e3, f4, c3, s3), h3.base = u4.__e, u4.__u &= -161, h3.__h.length && e3.push(h3), b && (h3.__E = h3.__ = null);
170
+ h3.state = h3.__s, null != h3.getChildContext && (i3 = w(w({}, i3), h3.getChildContext())), C3 && !p3 && null != h3.getSnapshotBeforeUpdate && (m3 = h3.getSnapshotBeforeUpdate(y3, _3)), H2 = null != a3 && a3.type === k && null == a3.key ? q(a3.props.children) : a3, f4 = P(n2, d(H2) ? H2 : [H2], u4, t3, i3, r3, o3, e3, f4, c3, s3), h3.base = u4.__e, u4.__u &= -161, h3.__h.length && e3.push(h3), b && (h3.__E = h3.__ = null);
154
171
  } catch (n3) {
155
172
  if (u4.__v = null, c3 || null != o3) if (n3.then) {
156
173
  for (u4.__u |= c3 ? 160 : 128; f4 && 8 == f4.nodeType && f4.nextSibling; ) f4 = f4.nextSibling;
@@ -184,25 +201,25 @@
184
201
  return "object" != typeof n2 || null == n2 || n2.__b > 0 ? n2 : d(n2) ? n2.map(q) : w({}, n2);
185
202
  }
186
203
  function B(u4, t3, i3, r3, o3, e3, f4, c3, s3) {
187
- var a3, h3, v3, y3, w3, _2, m3, b = i3.props || p, k3 = t3.props, x2 = t3.type;
188
- if ("svg" == x2 ? o3 = "http://www.w3.org/2000/svg" : "math" == x2 ? o3 = "http://www.w3.org/1998/Math/MathML" : o3 || (o3 = "http://www.w3.org/1999/xhtml"), null != e3) {
189
- for (a3 = 0; a3 < e3.length; a3++) if ((w3 = e3[a3]) && "setAttribute" in w3 == !!x2 && (x2 ? w3.localName == x2 : 3 == w3.nodeType)) {
204
+ var a3, h3, v3, y3, w3, _3, m3, b = i3.props || p, k3 = t3.props, x3 = t3.type;
205
+ if ("svg" == x3 ? o3 = "http://www.w3.org/2000/svg" : "math" == x3 ? o3 = "http://www.w3.org/1998/Math/MathML" : o3 || (o3 = "http://www.w3.org/1999/xhtml"), null != e3) {
206
+ for (a3 = 0; a3 < e3.length; a3++) if ((w3 = e3[a3]) && "setAttribute" in w3 == !!x3 && (x3 ? w3.localName == x3 : 3 == w3.nodeType)) {
190
207
  u4 = w3, e3[a3] = null;
191
208
  break;
192
209
  }
193
210
  }
194
211
  if (null == u4) {
195
- if (null == x2) return document.createTextNode(k3);
196
- u4 = document.createElementNS(o3, x2, k3.is && k3), c3 && (l.__m && l.__m(t3, e3), c3 = false), e3 = null;
212
+ if (null == x3) return document.createTextNode(k3);
213
+ u4 = document.createElementNS(o3, x3, k3.is && k3), c3 && (l.__m && l.__m(t3, e3), c3 = false), e3 = null;
197
214
  }
198
- if (null == x2) b === k3 || c3 && u4.data == k3 || (u4.data = k3);
215
+ if (null == x3) b === k3 || c3 && u4.data == k3 || (u4.data = k3);
199
216
  else {
200
217
  if (e3 = e3 && n.call(u4.childNodes), !c3 && null != e3) for (b = {}, a3 = 0; a3 < u4.attributes.length; a3++) b[(w3 = u4.attributes[a3]).name] = w3.value;
201
218
  for (a3 in b) w3 = b[a3], "dangerouslySetInnerHTML" == a3 ? v3 = w3 : "children" == a3 || a3 in k3 || "value" == a3 && "defaultValue" in k3 || "checked" == a3 && "defaultChecked" in k3 || F(u4, a3, null, w3, o3);
202
- for (a3 in k3) w3 = k3[a3], "children" == a3 ? y3 = w3 : "dangerouslySetInnerHTML" == a3 ? h3 = w3 : "value" == a3 ? _2 = w3 : "checked" == a3 ? m3 = w3 : c3 && "function" != typeof w3 || b[a3] === w3 || F(u4, a3, w3, b[a3], o3);
219
+ for (a3 in k3) w3 = k3[a3], "children" == a3 ? y3 = w3 : "dangerouslySetInnerHTML" == a3 ? h3 = w3 : "value" == a3 ? _3 = w3 : "checked" == a3 ? m3 = w3 : c3 && "function" != typeof w3 || b[a3] === w3 || F(u4, a3, w3, b[a3], o3);
203
220
  if (h3) c3 || v3 && (h3.__html == v3.__html || h3.__html == u4.innerHTML) || (u4.innerHTML = h3.__html), t3.__k = [];
204
- else if (v3 && (u4.innerHTML = ""), P("template" == t3.type ? u4.content : u4, d(y3) ? y3 : [y3], t3, i3, r3, "foreignObject" == x2 ? "http://www.w3.org/1999/xhtml" : o3, e3, f4, e3 ? e3[0] : i3.__k && S(i3, 0), c3, s3), null != e3) for (a3 = e3.length; a3--; ) g(e3[a3]);
205
- c3 || (a3 = "value", "progress" == x2 && null == _2 ? u4.removeAttribute("value") : null != _2 && (_2 !== u4[a3] || "progress" == x2 && !_2 || "option" == x2 && _2 != b[a3]) && F(u4, a3, _2, b[a3], o3), a3 = "checked", null != m3 && m3 != u4[a3] && F(u4, a3, m3, b[a3], o3));
221
+ else if (v3 && (u4.innerHTML = ""), P("template" == t3.type ? u4.content : u4, d(y3) ? y3 : [y3], t3, i3, r3, "foreignObject" == x3 ? "http://www.w3.org/1999/xhtml" : o3, e3, f4, e3 ? e3[0] : i3.__k && S(i3, 0), c3, s3), null != e3) for (a3 = e3.length; a3--; ) g(e3[a3]);
222
+ c3 || (a3 = "value", "progress" == x3 && null == _3 ? u4.removeAttribute("value") : null != _3 && (_3 !== u4[a3] || "progress" == x3 && !_3 || "option" == x3 && _3 != b[a3]) && F(u4, a3, _3, b[a3], o3), a3 = "checked", null != m3 && m3 != u4[a3] && F(u4, a3, m3, b[a3], o3));
206
223
  }
207
224
  return u4;
208
225
  }
@@ -236,6 +253,29 @@
236
253
  var r3, o3, e3, f4;
237
254
  t3 == document && (t3 = document.documentElement), l.__ && l.__(u4, t3), o3 = (r3 = "function" == typeof i3) ? null : i3 && i3.__k || t3.__k, e3 = [], f4 = [], z(t3, u4 = (!r3 && i3 || t3).__k = _(k, null, [u4]), o3 || p, p, t3.namespaceURI, !r3 && i3 ? [i3] : o3 ? null : t3.firstChild ? n.call(t3.childNodes) : null, e3, !r3 && i3 ? i3 : o3 ? o3.__e : t3.firstChild, r3, f4), V(e3, u4, f4);
238
255
  }
256
+ function R(n2) {
257
+ function l3(n3) {
258
+ var u4, t3;
259
+ return this.getChildContext || (u4 = /* @__PURE__ */ new Set(), (t3 = {})[l3.__c] = this, this.getChildContext = function() {
260
+ return t3;
261
+ }, this.componentWillUnmount = function() {
262
+ u4 = null;
263
+ }, this.shouldComponentUpdate = function(n4) {
264
+ this.props.value != n4.value && u4.forEach(function(n5) {
265
+ n5.__e = true, $(n5);
266
+ });
267
+ }, this.sub = function(n4) {
268
+ u4.add(n4);
269
+ var l4 = n4.componentWillUnmount;
270
+ n4.componentWillUnmount = function() {
271
+ u4 && u4.delete(n4), l4 && l4.call(n4);
272
+ };
273
+ }), n3.children;
274
+ }
275
+ return l3.__c = "__cC" + h++, l3.__ = n2, l3.Provider = l3.__l = (l3.Consumer = function(n3, l4) {
276
+ return n3.children(l4);
277
+ }).contextType = l3, l3;
278
+ }
239
279
  n = v.slice, l = { __e: function(n2, l3, u4, t3) {
240
280
  for (var i3, r3, o3; l3 = l3.__; ) if ((i3 = l3.__c) && !i3.__) try {
241
281
  if ((r3 = i3.constructor) && null != r3.getDerivedStateFromError && (i3.setState(r3.getDerivedStateFromError(n2)), o3 = i3.__d), null != i3.componentDidCatch && (i3.componentDidCatch(n2, t3 || {}), o3 = i3.__d), o3) return i3.__E = i3;
@@ -254,152 +294,3667 @@
254
294
  return n2.__v.__b - l3.__v.__b;
255
295
  }, I.__r = 0, f = /(PointerCapture)$|Capture$/i, c = 0, s = O(false), a = O(true), h = 0;
256
296
 
257
- // node_modules/preact/hooks/dist/hooks.module.js
258
- var t2;
259
- var r2;
260
- var u2;
261
- var i2;
262
- var o2 = 0;
263
- var f2 = [];
264
- var c2 = l;
265
- var e2 = c2.__b;
266
- var a2 = c2.__r;
267
- var v2 = c2.diffed;
268
- var l2 = c2.__c;
269
- var m2 = c2.unmount;
270
- var s2 = c2.__;
271
- function p2(n2, t3) {
272
- c2.__h && c2.__h(r2, n2, o2 || t3), o2 = 0;
273
- var u4 = r2.__H || (r2.__H = { __: [], __h: [] });
274
- return n2 >= u4.__.length && u4.__.push({}), u4.__[n2];
297
+ // node_modules/@tanstack/query-core/build/modern/subscribable.js
298
+ var Subscribable = class {
299
+ constructor() {
300
+ this.listeners = /* @__PURE__ */ new Set();
301
+ this.subscribe = this.subscribe.bind(this);
302
+ }
303
+ subscribe(listener) {
304
+ this.listeners.add(listener);
305
+ this.onSubscribe();
306
+ return () => {
307
+ this.listeners.delete(listener);
308
+ this.onUnsubscribe();
309
+ };
310
+ }
311
+ hasListeners() {
312
+ return this.listeners.size > 0;
313
+ }
314
+ onSubscribe() {
315
+ }
316
+ onUnsubscribe() {
317
+ }
318
+ };
319
+
320
+ // node_modules/@tanstack/query-core/build/modern/focusManager.js
321
+ var _focused, _cleanup, _setup, _a;
322
+ var FocusManager = (_a = class extends Subscribable {
323
+ constructor() {
324
+ super();
325
+ __privateAdd(this, _focused);
326
+ __privateAdd(this, _cleanup);
327
+ __privateAdd(this, _setup);
328
+ __privateSet(this, _setup, (onFocus) => {
329
+ if (typeof window !== "undefined" && window.addEventListener) {
330
+ const listener = () => onFocus();
331
+ window.addEventListener("visibilitychange", listener, false);
332
+ return () => {
333
+ window.removeEventListener("visibilitychange", listener);
334
+ };
335
+ }
336
+ return;
337
+ });
338
+ }
339
+ onSubscribe() {
340
+ if (!__privateGet(this, _cleanup)) {
341
+ this.setEventListener(__privateGet(this, _setup));
342
+ }
343
+ }
344
+ onUnsubscribe() {
345
+ var _a12;
346
+ if (!this.hasListeners()) {
347
+ (_a12 = __privateGet(this, _cleanup)) == null ? void 0 : _a12.call(this);
348
+ __privateSet(this, _cleanup, void 0);
349
+ }
350
+ }
351
+ setEventListener(setup) {
352
+ var _a12;
353
+ __privateSet(this, _setup, setup);
354
+ (_a12 = __privateGet(this, _cleanup)) == null ? void 0 : _a12.call(this);
355
+ __privateSet(this, _cleanup, setup((focused) => {
356
+ if (typeof focused === "boolean") {
357
+ this.setFocused(focused);
358
+ } else {
359
+ this.onFocus();
360
+ }
361
+ }));
362
+ }
363
+ setFocused(focused) {
364
+ const changed = __privateGet(this, _focused) !== focused;
365
+ if (changed) {
366
+ __privateSet(this, _focused, focused);
367
+ this.onFocus();
368
+ }
369
+ }
370
+ onFocus() {
371
+ const isFocused = this.isFocused();
372
+ this.listeners.forEach((listener) => {
373
+ listener(isFocused);
374
+ });
375
+ }
376
+ isFocused() {
377
+ if (typeof __privateGet(this, _focused) === "boolean") {
378
+ return __privateGet(this, _focused);
379
+ }
380
+ return globalThis.document?.visibilityState !== "hidden";
381
+ }
382
+ }, _focused = new WeakMap(), _cleanup = new WeakMap(), _setup = new WeakMap(), _a);
383
+ var focusManager = new FocusManager();
384
+
385
+ // node_modules/@tanstack/query-core/build/modern/timeoutManager.js
386
+ var defaultTimeoutProvider = {
387
+ // We need the wrapper function syntax below instead of direct references to
388
+ // global setTimeout etc.
389
+ //
390
+ // BAD: `setTimeout: setTimeout`
391
+ // GOOD: `setTimeout: (cb, delay) => setTimeout(cb, delay)`
392
+ //
393
+ // If we use direct references here, then anything that wants to spy on or
394
+ // replace the global setTimeout (like tests) won't work since we'll already
395
+ // have a hard reference to the original implementation at the time when this
396
+ // file was imported.
397
+ setTimeout: (callback, delay) => setTimeout(callback, delay),
398
+ clearTimeout: (timeoutId) => clearTimeout(timeoutId),
399
+ setInterval: (callback, delay) => setInterval(callback, delay),
400
+ clearInterval: (intervalId) => clearInterval(intervalId)
401
+ };
402
+ var _provider, _providerCalled, _a2;
403
+ var TimeoutManager = (_a2 = class {
404
+ constructor() {
405
+ // We cannot have TimeoutManager<T> as we must instantiate it with a concrete
406
+ // type at app boot; and if we leave that type, then any new timer provider
407
+ // would need to support the default provider's concrete timer ID, which is
408
+ // infeasible across environments.
409
+ //
410
+ // We settle for type safety for the TimeoutProvider type, and accept that
411
+ // this class is unsafe internally to allow for extension.
412
+ __privateAdd(this, _provider, defaultTimeoutProvider);
413
+ __privateAdd(this, _providerCalled, false);
414
+ }
415
+ setTimeoutProvider(provider) {
416
+ if (true) {
417
+ if (__privateGet(this, _providerCalled) && provider !== __privateGet(this, _provider)) {
418
+ console.error(
419
+ `[timeoutManager]: Switching provider after calls to previous provider might result in unexpected behavior.`,
420
+ { previous: __privateGet(this, _provider), provider }
421
+ );
422
+ }
423
+ }
424
+ __privateSet(this, _provider, provider);
425
+ if (true) {
426
+ __privateSet(this, _providerCalled, false);
427
+ }
428
+ }
429
+ setTimeout(callback, delay) {
430
+ if (true) {
431
+ __privateSet(this, _providerCalled, true);
432
+ }
433
+ return __privateGet(this, _provider).setTimeout(callback, delay);
434
+ }
435
+ clearTimeout(timeoutId) {
436
+ __privateGet(this, _provider).clearTimeout(timeoutId);
437
+ }
438
+ setInterval(callback, delay) {
439
+ if (true) {
440
+ __privateSet(this, _providerCalled, true);
441
+ }
442
+ return __privateGet(this, _provider).setInterval(callback, delay);
443
+ }
444
+ clearInterval(intervalId) {
445
+ __privateGet(this, _provider).clearInterval(intervalId);
446
+ }
447
+ }, _provider = new WeakMap(), _providerCalled = new WeakMap(), _a2);
448
+ var timeoutManager = new TimeoutManager();
449
+ function systemSetTimeoutZero(callback) {
450
+ setTimeout(callback, 0);
275
451
  }
276
- function d2(n2) {
277
- return o2 = 1, h2(D2, n2);
452
+
453
+ // node_modules/@tanstack/query-core/build/modern/utils.js
454
+ var isServer = typeof window === "undefined" || "Deno" in globalThis;
455
+ function noop() {
456
+ }
457
+ function functionalUpdate(updater, input) {
458
+ return typeof updater === "function" ? updater(input) : updater;
459
+ }
460
+ function isValidTimeout(value) {
461
+ return typeof value === "number" && value >= 0 && value !== Infinity;
462
+ }
463
+ function timeUntilStale(updatedAt, staleTime) {
464
+ return Math.max(updatedAt + (staleTime || 0) - Date.now(), 0);
465
+ }
466
+ function resolveStaleTime(staleTime, query) {
467
+ return typeof staleTime === "function" ? staleTime(query) : staleTime;
468
+ }
469
+ function resolveQueryBoolean(option, query) {
470
+ return typeof option === "function" ? option(query) : option;
471
+ }
472
+ function matchQuery(filters, query) {
473
+ const {
474
+ type = "all",
475
+ exact,
476
+ fetchStatus,
477
+ predicate,
478
+ queryKey,
479
+ stale
480
+ } = filters;
481
+ if (queryKey) {
482
+ if (exact) {
483
+ if (query.queryHash !== hashQueryKeyByOptions(queryKey, query.options)) {
484
+ return false;
485
+ }
486
+ } else if (!partialMatchKey(query.queryKey, queryKey)) {
487
+ return false;
488
+ }
489
+ }
490
+ if (type !== "all") {
491
+ const isActive = query.isActive();
492
+ if (type === "active" && !isActive) {
493
+ return false;
494
+ }
495
+ if (type === "inactive" && isActive) {
496
+ return false;
497
+ }
498
+ }
499
+ if (typeof stale === "boolean" && query.isStale() !== stale) {
500
+ return false;
501
+ }
502
+ if (fetchStatus && fetchStatus !== query.state.fetchStatus) {
503
+ return false;
504
+ }
505
+ if (predicate && !predicate(query)) {
506
+ return false;
507
+ }
508
+ return true;
278
509
  }
279
- function h2(n2, u4, i3) {
280
- var o3 = p2(t2++, 2);
281
- if (o3.t = n2, !o3.__c && (o3.__ = [i3 ? i3(u4) : D2(void 0, u4), function(n3) {
282
- var t3 = o3.__N ? o3.__N[0] : o3.__[0], r3 = o3.t(t3, n3);
283
- t3 !== r3 && (o3.__N = [r3, o3.__[1]], o3.__c.setState({}));
284
- }], o3.__c = r2, !r2.__f)) {
285
- var f4 = function(n3, t3, r3) {
286
- if (!o3.__c.__H) return true;
287
- var u5 = o3.__c.__H.__.filter(function(n4) {
288
- return n4.__c;
289
- });
290
- if (u5.every(function(n4) {
291
- return !n4.__N;
292
- })) return !c3 || c3.call(this, n3, t3, r3);
293
- var i4 = o3.__c.props !== n3;
294
- return u5.some(function(n4) {
295
- if (n4.__N) {
296
- var t4 = n4.__[0];
297
- n4.__ = n4.__N, n4.__N = void 0, t4 !== n4.__[0] && (i4 = true);
298
- }
299
- }), c3 && c3.call(this, n3, t3, r3) || i4;
300
- };
301
- r2.__f = true;
302
- var c3 = r2.shouldComponentUpdate, e3 = r2.componentWillUpdate;
303
- r2.componentWillUpdate = function(n3, t3, r3) {
304
- if (this.__e) {
305
- var u5 = c3;
306
- c3 = void 0, f4(n3, t3, r3), c3 = u5;
510
+ function matchMutation(filters, mutation) {
511
+ const { exact, status, predicate, mutationKey } = filters;
512
+ if (mutationKey) {
513
+ if (!mutation.options.mutationKey) {
514
+ return false;
515
+ }
516
+ if (exact) {
517
+ if (hashKey(mutation.options.mutationKey) !== hashKey(mutationKey)) {
518
+ return false;
307
519
  }
308
- e3 && e3.call(this, n3, t3, r3);
309
- }, r2.shouldComponentUpdate = f4;
520
+ } else if (!partialMatchKey(mutation.options.mutationKey, mutationKey)) {
521
+ return false;
522
+ }
310
523
  }
311
- return o3.__N || o3.__;
524
+ if (status && mutation.state.status !== status) {
525
+ return false;
526
+ }
527
+ if (predicate && !predicate(mutation)) {
528
+ return false;
529
+ }
530
+ return true;
312
531
  }
313
- function y2(n2, u4) {
314
- var i3 = p2(t2++, 3);
315
- !c2.__s && C2(i3.__H, u4) && (i3.__ = n2, i3.u = u4, r2.__H.__h.push(i3));
532
+ function hashQueryKeyByOptions(queryKey, options) {
533
+ const hashFn = options?.queryKeyHashFn || hashKey;
534
+ return hashFn(queryKey);
535
+ }
536
+ function hashKey(queryKey) {
537
+ return JSON.stringify(
538
+ queryKey,
539
+ (_3, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
540
+ result[key] = val[key];
541
+ return result;
542
+ }, {}) : val
543
+ );
316
544
  }
317
- function A2(n2) {
318
- return o2 = 5, T2(function() {
319
- return { current: n2 };
320
- }, []);
545
+ function partialMatchKey(a3, b) {
546
+ if (a3 === b) {
547
+ return true;
548
+ }
549
+ if (typeof a3 !== typeof b) {
550
+ return false;
551
+ }
552
+ if (a3 && b && typeof a3 === "object" && typeof b === "object") {
553
+ return Object.keys(b).every((key) => partialMatchKey(a3[key], b[key]));
554
+ }
555
+ return false;
321
556
  }
322
- function T2(n2, r3) {
323
- var u4 = p2(t2++, 7);
324
- return C2(u4.__H, r3) && (u4.__ = n2(), u4.__H = r3, u4.__h = n2), u4.__;
557
+ var hasOwn = Object.prototype.hasOwnProperty;
558
+ function replaceEqualDeep(a3, b, depth = 0) {
559
+ if (a3 === b) {
560
+ return a3;
561
+ }
562
+ if (depth > 500) return b;
563
+ const array = isPlainArray(a3) && isPlainArray(b);
564
+ if (!array && !(isPlainObject(a3) && isPlainObject(b))) return b;
565
+ const aItems = array ? a3 : Object.keys(a3);
566
+ const aSize = aItems.length;
567
+ const bItems = array ? b : Object.keys(b);
568
+ const bSize = bItems.length;
569
+ const copy = array ? new Array(bSize) : {};
570
+ let equalItems = 0;
571
+ for (let i3 = 0; i3 < bSize; i3++) {
572
+ const key = array ? i3 : bItems[i3];
573
+ const aItem = a3[key];
574
+ const bItem = b[key];
575
+ if (aItem === bItem) {
576
+ copy[key] = aItem;
577
+ if (array ? i3 < aSize : hasOwn.call(a3, key)) equalItems++;
578
+ continue;
579
+ }
580
+ if (aItem === null || bItem === null || typeof aItem !== "object" || typeof bItem !== "object") {
581
+ copy[key] = bItem;
582
+ continue;
583
+ }
584
+ const v3 = replaceEqualDeep(aItem, bItem, depth + 1);
585
+ copy[key] = v3;
586
+ if (v3 === aItem) equalItems++;
587
+ }
588
+ return aSize === bSize && equalItems === aSize ? a3 : copy;
325
589
  }
326
- function q2(n2, t3) {
327
- return o2 = 8, T2(function() {
328
- return n2;
329
- }, t3);
590
+ function shallowEqualObjects(a3, b) {
591
+ if (!b || Object.keys(a3).length !== Object.keys(b).length) {
592
+ return false;
593
+ }
594
+ for (const key in a3) {
595
+ if (a3[key] !== b[key]) {
596
+ return false;
597
+ }
598
+ }
599
+ return true;
330
600
  }
331
- function j2() {
332
- for (var n2; n2 = f2.shift(); ) {
333
- var t3 = n2.__H;
334
- if (n2.__P && t3) try {
335
- t3.__h.some(z2), t3.__h.some(B2), t3.__h = [];
336
- } catch (r3) {
337
- t3.__h = [], c2.__e(r3, n2.__v);
601
+ function isPlainArray(value) {
602
+ return Array.isArray(value) && value.length === Object.keys(value).length;
603
+ }
604
+ function isPlainObject(o3) {
605
+ if (!hasObjectPrototype(o3)) {
606
+ return false;
607
+ }
608
+ const ctor = o3.constructor;
609
+ if (ctor === void 0) {
610
+ return true;
611
+ }
612
+ const prot = ctor.prototype;
613
+ if (!hasObjectPrototype(prot)) {
614
+ return false;
615
+ }
616
+ if (!prot.hasOwnProperty("isPrototypeOf")) {
617
+ return false;
618
+ }
619
+ if (Object.getPrototypeOf(o3) !== Object.prototype) {
620
+ return false;
621
+ }
622
+ return true;
623
+ }
624
+ function hasObjectPrototype(o3) {
625
+ return Object.prototype.toString.call(o3) === "[object Object]";
626
+ }
627
+ function sleep(timeout) {
628
+ return new Promise((resolve) => {
629
+ timeoutManager.setTimeout(resolve, timeout);
630
+ });
631
+ }
632
+ function replaceData(prevData, data, options) {
633
+ if (typeof options.structuralSharing === "function") {
634
+ return options.structuralSharing(prevData, data);
635
+ } else if (options.structuralSharing !== false) {
636
+ if (true) {
637
+ try {
638
+ return replaceEqualDeep(prevData, data);
639
+ } catch (error) {
640
+ console.error(
641
+ `Structural sharing requires data to be JSON serializable. To fix this, turn off structuralSharing or return JSON-serializable data from your queryFn. [${options.queryHash}]: ${error}`
642
+ );
643
+ throw error;
644
+ }
645
+ }
646
+ return replaceEqualDeep(prevData, data);
647
+ }
648
+ return data;
649
+ }
650
+ function addToEnd(items, item, max = 0) {
651
+ const newItems = [...items, item];
652
+ return max && newItems.length > max ? newItems.slice(1) : newItems;
653
+ }
654
+ function addToStart(items, item, max = 0) {
655
+ const newItems = [item, ...items];
656
+ return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
657
+ }
658
+ var skipToken = /* @__PURE__ */ Symbol();
659
+ function ensureQueryFn(options, fetchOptions) {
660
+ if (true) {
661
+ if (options.queryFn === skipToken) {
662
+ console.error(
663
+ `Attempted to invoke queryFn when set to skipToken. This is likely a configuration error. Query hash: '${options.queryHash}'`
664
+ );
665
+ }
666
+ }
667
+ if (!options.queryFn && fetchOptions?.initialPromise) {
668
+ return () => fetchOptions.initialPromise;
669
+ }
670
+ if (!options.queryFn || options.queryFn === skipToken) {
671
+ return () => Promise.reject(new Error(`Missing queryFn: '${options.queryHash}'`));
672
+ }
673
+ return options.queryFn;
674
+ }
675
+ function shouldThrowError(throwOnError, params) {
676
+ if (typeof throwOnError === "function") {
677
+ return throwOnError(...params);
678
+ }
679
+ return !!throwOnError;
680
+ }
681
+ function addConsumeAwareSignal(object, getSignal, onCancelled) {
682
+ let consumed = false;
683
+ let signal;
684
+ Object.defineProperty(object, "signal", {
685
+ enumerable: true,
686
+ get: () => {
687
+ signal ?? (signal = getSignal());
688
+ if (consumed) {
689
+ return signal;
690
+ }
691
+ consumed = true;
692
+ if (signal.aborted) {
693
+ onCancelled();
694
+ } else {
695
+ signal.addEventListener("abort", onCancelled, { once: true });
696
+ }
697
+ return signal;
698
+ }
699
+ });
700
+ return object;
701
+ }
702
+
703
+ // node_modules/@tanstack/query-core/build/modern/environmentManager.js
704
+ var environmentManager = /* @__PURE__ */ (() => {
705
+ let isServerFn = () => isServer;
706
+ return {
707
+ /**
708
+ * Returns whether the current runtime should be treated as a server environment.
709
+ */
710
+ isServer() {
711
+ return isServerFn();
712
+ },
713
+ /**
714
+ * Overrides the server check globally.
715
+ */
716
+ setIsServer(isServerValue) {
717
+ isServerFn = isServerValue;
718
+ }
719
+ };
720
+ })();
721
+
722
+ // node_modules/@tanstack/query-core/build/modern/thenable.js
723
+ function pendingThenable() {
724
+ let resolve;
725
+ let reject;
726
+ const thenable = new Promise((_resolve, _reject) => {
727
+ resolve = _resolve;
728
+ reject = _reject;
729
+ });
730
+ thenable.status = "pending";
731
+ thenable.catch(() => {
732
+ });
733
+ function finalize(data) {
734
+ Object.assign(thenable, data);
735
+ delete thenable.resolve;
736
+ delete thenable.reject;
737
+ }
738
+ thenable.resolve = (value) => {
739
+ finalize({
740
+ status: "fulfilled",
741
+ value
742
+ });
743
+ resolve(value);
744
+ };
745
+ thenable.reject = (reason) => {
746
+ finalize({
747
+ status: "rejected",
748
+ reason
749
+ });
750
+ reject(reason);
751
+ };
752
+ return thenable;
753
+ }
754
+
755
+ // node_modules/@tanstack/query-core/build/modern/notifyManager.js
756
+ var defaultScheduler = systemSetTimeoutZero;
757
+ function createNotifyManager() {
758
+ let queue = [];
759
+ let transactions = 0;
760
+ let notifyFn = (callback) => {
761
+ callback();
762
+ };
763
+ let batchNotifyFn = (callback) => {
764
+ callback();
765
+ };
766
+ let scheduleFn = defaultScheduler;
767
+ const schedule = (callback) => {
768
+ if (transactions) {
769
+ queue.push(callback);
770
+ } else {
771
+ scheduleFn(() => {
772
+ notifyFn(callback);
773
+ });
774
+ }
775
+ };
776
+ const flush = () => {
777
+ const originalQueue = queue;
778
+ queue = [];
779
+ if (originalQueue.length) {
780
+ scheduleFn(() => {
781
+ batchNotifyFn(() => {
782
+ originalQueue.forEach((callback) => {
783
+ notifyFn(callback);
784
+ });
785
+ });
786
+ });
787
+ }
788
+ };
789
+ return {
790
+ batch: (callback) => {
791
+ let result;
792
+ transactions++;
793
+ try {
794
+ result = callback();
795
+ } finally {
796
+ transactions--;
797
+ if (!transactions) {
798
+ flush();
799
+ }
800
+ }
801
+ return result;
802
+ },
803
+ /**
804
+ * All calls to the wrapped function will be batched.
805
+ */
806
+ batchCalls: (callback) => {
807
+ return (...args) => {
808
+ schedule(() => {
809
+ callback(...args);
810
+ });
811
+ };
812
+ },
813
+ schedule,
814
+ /**
815
+ * Use this method to set a custom notify function.
816
+ * This can be used to for example wrap notifications with `React.act` while running tests.
817
+ */
818
+ setNotifyFunction: (fn) => {
819
+ notifyFn = fn;
820
+ },
821
+ /**
822
+ * Use this method to set a custom function to batch notifications together into a single tick.
823
+ * By default React Query will use the batch function provided by ReactDOM or React Native.
824
+ */
825
+ setBatchNotifyFunction: (fn) => {
826
+ batchNotifyFn = fn;
827
+ },
828
+ setScheduler: (fn) => {
829
+ scheduleFn = fn;
830
+ }
831
+ };
832
+ }
833
+ var notifyManager = createNotifyManager();
834
+
835
+ // node_modules/@tanstack/query-core/build/modern/onlineManager.js
836
+ var _online, _cleanup2, _setup2, _a3;
837
+ var OnlineManager = (_a3 = class extends Subscribable {
838
+ constructor() {
839
+ super();
840
+ __privateAdd(this, _online, true);
841
+ __privateAdd(this, _cleanup2);
842
+ __privateAdd(this, _setup2);
843
+ __privateSet(this, _setup2, (onOnline) => {
844
+ if (typeof window !== "undefined" && window.addEventListener) {
845
+ const onlineListener = () => onOnline(true);
846
+ const offlineListener = () => onOnline(false);
847
+ window.addEventListener("online", onlineListener, false);
848
+ window.addEventListener("offline", offlineListener, false);
849
+ return () => {
850
+ window.removeEventListener("online", onlineListener);
851
+ window.removeEventListener("offline", offlineListener);
852
+ };
853
+ }
854
+ return;
855
+ });
856
+ }
857
+ onSubscribe() {
858
+ if (!__privateGet(this, _cleanup2)) {
859
+ this.setEventListener(__privateGet(this, _setup2));
860
+ }
861
+ }
862
+ onUnsubscribe() {
863
+ var _a12;
864
+ if (!this.hasListeners()) {
865
+ (_a12 = __privateGet(this, _cleanup2)) == null ? void 0 : _a12.call(this);
866
+ __privateSet(this, _cleanup2, void 0);
867
+ }
868
+ }
869
+ setEventListener(setup) {
870
+ var _a12;
871
+ __privateSet(this, _setup2, setup);
872
+ (_a12 = __privateGet(this, _cleanup2)) == null ? void 0 : _a12.call(this);
873
+ __privateSet(this, _cleanup2, setup(this.setOnline.bind(this)));
874
+ }
875
+ setOnline(online) {
876
+ const changed = __privateGet(this, _online) !== online;
877
+ if (changed) {
878
+ __privateSet(this, _online, online);
879
+ this.listeners.forEach((listener) => {
880
+ listener(online);
881
+ });
882
+ }
883
+ }
884
+ isOnline() {
885
+ return __privateGet(this, _online);
886
+ }
887
+ }, _online = new WeakMap(), _cleanup2 = new WeakMap(), _setup2 = new WeakMap(), _a3);
888
+ var onlineManager = new OnlineManager();
889
+
890
+ // node_modules/@tanstack/query-core/build/modern/retryer.js
891
+ function defaultRetryDelay(failureCount) {
892
+ return Math.min(1e3 * 2 ** failureCount, 3e4);
893
+ }
894
+ function canFetch(networkMode) {
895
+ return (networkMode ?? "online") === "online" ? onlineManager.isOnline() : true;
896
+ }
897
+ var CancelledError = class extends Error {
898
+ constructor(options) {
899
+ super("CancelledError");
900
+ this.revert = options?.revert;
901
+ this.silent = options?.silent;
902
+ }
903
+ };
904
+ function createRetryer(config) {
905
+ let isRetryCancelled = false;
906
+ let failureCount = 0;
907
+ let continueFn;
908
+ const thenable = pendingThenable();
909
+ const isResolved = () => thenable.status !== "pending";
910
+ const cancel = (cancelOptions) => {
911
+ if (!isResolved()) {
912
+ const error = new CancelledError(cancelOptions);
913
+ reject(error);
914
+ config.onCancel?.(error);
915
+ }
916
+ };
917
+ const cancelRetry = () => {
918
+ isRetryCancelled = true;
919
+ };
920
+ const continueRetry = () => {
921
+ isRetryCancelled = false;
922
+ };
923
+ const canContinue = () => focusManager.isFocused() && (config.networkMode === "always" || onlineManager.isOnline()) && config.canRun();
924
+ const canStart = () => canFetch(config.networkMode) && config.canRun();
925
+ const resolve = (value) => {
926
+ if (!isResolved()) {
927
+ continueFn?.();
928
+ thenable.resolve(value);
929
+ }
930
+ };
931
+ const reject = (value) => {
932
+ if (!isResolved()) {
933
+ continueFn?.();
934
+ thenable.reject(value);
935
+ }
936
+ };
937
+ const pause = () => {
938
+ return new Promise((continueResolve) => {
939
+ continueFn = (value) => {
940
+ if (isResolved() || canContinue()) {
941
+ continueResolve(value);
942
+ }
943
+ };
944
+ config.onPause?.();
945
+ }).then(() => {
946
+ continueFn = void 0;
947
+ if (!isResolved()) {
948
+ config.onContinue?.();
949
+ }
950
+ });
951
+ };
952
+ const run = () => {
953
+ if (isResolved()) {
954
+ return;
955
+ }
956
+ let promiseOrValue;
957
+ const initialPromise = failureCount === 0 ? config.initialPromise : void 0;
958
+ try {
959
+ promiseOrValue = initialPromise ?? config.fn();
960
+ } catch (error) {
961
+ promiseOrValue = Promise.reject(error);
962
+ }
963
+ Promise.resolve(promiseOrValue).then(resolve).catch((error) => {
964
+ if (isResolved()) {
965
+ return;
966
+ }
967
+ const retry = config.retry ?? (environmentManager.isServer() ? 0 : 3);
968
+ const retryDelay = config.retryDelay ?? defaultRetryDelay;
969
+ const delay = typeof retryDelay === "function" ? retryDelay(failureCount, error) : retryDelay;
970
+ const shouldRetry = retry === true || typeof retry === "number" && failureCount < retry || typeof retry === "function" && retry(failureCount, error);
971
+ if (isRetryCancelled || !shouldRetry) {
972
+ reject(error);
973
+ return;
974
+ }
975
+ failureCount++;
976
+ config.onFail?.(failureCount, error);
977
+ sleep(delay).then(() => {
978
+ return canContinue() ? void 0 : pause();
979
+ }).then(() => {
980
+ if (isRetryCancelled) {
981
+ reject(error);
982
+ } else {
983
+ run();
984
+ }
985
+ });
986
+ });
987
+ };
988
+ return {
989
+ promise: thenable,
990
+ status: () => thenable.status,
991
+ cancel,
992
+ continue: () => {
993
+ continueFn?.();
994
+ return thenable;
995
+ },
996
+ cancelRetry,
997
+ continueRetry,
998
+ canStart,
999
+ start: () => {
1000
+ if (canStart()) {
1001
+ run();
1002
+ } else {
1003
+ pause().then(run);
1004
+ }
1005
+ return thenable;
1006
+ }
1007
+ };
1008
+ }
1009
+
1010
+ // node_modules/@tanstack/query-core/build/modern/removable.js
1011
+ var _gcTimeout, _a4;
1012
+ var Removable = (_a4 = class {
1013
+ constructor() {
1014
+ __privateAdd(this, _gcTimeout);
1015
+ }
1016
+ destroy() {
1017
+ this.clearGcTimeout();
1018
+ }
1019
+ scheduleGc() {
1020
+ this.clearGcTimeout();
1021
+ if (isValidTimeout(this.gcTime)) {
1022
+ __privateSet(this, _gcTimeout, timeoutManager.setTimeout(() => {
1023
+ this.optionalRemove();
1024
+ }, this.gcTime));
1025
+ }
1026
+ }
1027
+ updateGcTime(newGcTime) {
1028
+ this.gcTime = Math.max(
1029
+ this.gcTime || 0,
1030
+ newGcTime ?? (environmentManager.isServer() ? Infinity : 5 * 60 * 1e3)
1031
+ );
1032
+ }
1033
+ clearGcTimeout() {
1034
+ if (__privateGet(this, _gcTimeout) !== void 0) {
1035
+ timeoutManager.clearTimeout(__privateGet(this, _gcTimeout));
1036
+ __privateSet(this, _gcTimeout, void 0);
1037
+ }
1038
+ }
1039
+ }, _gcTimeout = new WeakMap(), _a4);
1040
+
1041
+ // node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
1042
+ function infiniteQueryBehavior(pages) {
1043
+ return {
1044
+ onFetch: (context, query) => {
1045
+ const options = context.options;
1046
+ const direction = context.fetchOptions?.meta?.fetchMore?.direction;
1047
+ const oldPages = context.state.data?.pages || [];
1048
+ const oldPageParams = context.state.data?.pageParams || [];
1049
+ let result = { pages: [], pageParams: [] };
1050
+ let currentPage = 0;
1051
+ const fetchFn = async () => {
1052
+ let cancelled = false;
1053
+ const addSignalProperty = (object) => {
1054
+ addConsumeAwareSignal(
1055
+ object,
1056
+ () => context.signal,
1057
+ () => cancelled = true
1058
+ );
1059
+ };
1060
+ const queryFn = ensureQueryFn(context.options, context.fetchOptions);
1061
+ const fetchPage = async (data, param, previous) => {
1062
+ if (cancelled) {
1063
+ return Promise.reject(context.signal.reason);
1064
+ }
1065
+ if (param == null && data.pages.length) {
1066
+ return Promise.resolve(data);
1067
+ }
1068
+ const createQueryFnContext = () => {
1069
+ const queryFnContext2 = {
1070
+ client: context.client,
1071
+ queryKey: context.queryKey,
1072
+ pageParam: param,
1073
+ direction: previous ? "backward" : "forward",
1074
+ meta: context.options.meta
1075
+ };
1076
+ addSignalProperty(queryFnContext2);
1077
+ return queryFnContext2;
1078
+ };
1079
+ const queryFnContext = createQueryFnContext();
1080
+ const page = await queryFn(queryFnContext);
1081
+ const { maxPages } = context.options;
1082
+ const addTo = previous ? addToStart : addToEnd;
1083
+ return {
1084
+ pages: addTo(data.pages, page, maxPages),
1085
+ pageParams: addTo(data.pageParams, param, maxPages)
1086
+ };
1087
+ };
1088
+ if (direction && oldPages.length) {
1089
+ const previous = direction === "backward";
1090
+ const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
1091
+ const oldData = {
1092
+ pages: oldPages,
1093
+ pageParams: oldPageParams
1094
+ };
1095
+ const param = pageParamFn(options, oldData);
1096
+ result = await fetchPage(oldData, param, previous);
1097
+ } else {
1098
+ const remainingPages = pages ?? oldPages.length;
1099
+ do {
1100
+ const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result);
1101
+ if (currentPage > 0 && param == null) {
1102
+ break;
1103
+ }
1104
+ result = await fetchPage(result, param);
1105
+ currentPage++;
1106
+ } while (currentPage < remainingPages);
1107
+ }
1108
+ return result;
1109
+ };
1110
+ if (context.options.persister) {
1111
+ context.fetchFn = () => {
1112
+ return context.options.persister?.(
1113
+ fetchFn,
1114
+ {
1115
+ client: context.client,
1116
+ queryKey: context.queryKey,
1117
+ meta: context.options.meta,
1118
+ signal: context.signal
1119
+ },
1120
+ query
1121
+ );
1122
+ };
1123
+ } else {
1124
+ context.fetchFn = fetchFn;
1125
+ }
1126
+ }
1127
+ };
1128
+ }
1129
+ function getNextPageParam(options, { pages, pageParams }) {
1130
+ const lastIndex = pages.length - 1;
1131
+ return pages.length > 0 ? options.getNextPageParam(
1132
+ pages[lastIndex],
1133
+ pages,
1134
+ pageParams[lastIndex],
1135
+ pageParams
1136
+ ) : void 0;
1137
+ }
1138
+ function getPreviousPageParam(options, { pages, pageParams }) {
1139
+ return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : void 0;
1140
+ }
1141
+ function hasNextPage(options, data) {
1142
+ if (!data) return false;
1143
+ return getNextPageParam(options, data) != null;
1144
+ }
1145
+ function hasPreviousPage(options, data) {
1146
+ if (!data || !options.getPreviousPageParam) return false;
1147
+ return getPreviousPageParam(options, data) != null;
1148
+ }
1149
+
1150
+ // node_modules/@tanstack/query-core/build/modern/query.js
1151
+ var _queryType, _initialState, _revertState, _cache, _client, _retryer, _defaultOptions, _abortSignalConsumed, _Query_instances, isInitialPausedFetch_fn, dispatch_fn, _a5;
1152
+ var Query = (_a5 = class extends Removable {
1153
+ constructor(config) {
1154
+ super();
1155
+ __privateAdd(this, _Query_instances);
1156
+ __privateAdd(this, _queryType);
1157
+ __privateAdd(this, _initialState);
1158
+ __privateAdd(this, _revertState);
1159
+ __privateAdd(this, _cache);
1160
+ __privateAdd(this, _client);
1161
+ __privateAdd(this, _retryer);
1162
+ __privateAdd(this, _defaultOptions);
1163
+ __privateAdd(this, _abortSignalConsumed);
1164
+ __privateSet(this, _abortSignalConsumed, false);
1165
+ __privateSet(this, _defaultOptions, config.defaultOptions);
1166
+ this.setOptions(config.options);
1167
+ this.observers = [];
1168
+ __privateSet(this, _client, config.client);
1169
+ __privateSet(this, _cache, __privateGet(this, _client).getQueryCache());
1170
+ this.queryKey = config.queryKey;
1171
+ this.queryHash = config.queryHash;
1172
+ __privateSet(this, _initialState, getDefaultState(this.options));
1173
+ this.state = config.state ?? __privateGet(this, _initialState);
1174
+ this.scheduleGc();
1175
+ }
1176
+ get meta() {
1177
+ return this.options.meta;
1178
+ }
1179
+ get queryType() {
1180
+ return __privateGet(this, _queryType);
1181
+ }
1182
+ get promise() {
1183
+ return __privateGet(this, _retryer)?.promise;
1184
+ }
1185
+ setOptions(options) {
1186
+ this.options = { ...__privateGet(this, _defaultOptions), ...options };
1187
+ if (options?._type) {
1188
+ __privateSet(this, _queryType, options._type);
1189
+ }
1190
+ this.updateGcTime(this.options.gcTime);
1191
+ if (this.state && this.state.data === void 0) {
1192
+ const defaultState = getDefaultState(this.options);
1193
+ if (defaultState.data !== void 0) {
1194
+ this.setState(
1195
+ successState(defaultState.data, defaultState.dataUpdatedAt)
1196
+ );
1197
+ __privateSet(this, _initialState, defaultState);
1198
+ }
1199
+ }
1200
+ }
1201
+ optionalRemove() {
1202
+ if (!this.observers.length && this.state.fetchStatus === "idle") {
1203
+ __privateGet(this, _cache).remove(this);
1204
+ }
1205
+ }
1206
+ setData(newData, options) {
1207
+ const data = replaceData(this.state.data, newData, this.options);
1208
+ __privateMethod(this, _Query_instances, dispatch_fn).call(this, {
1209
+ data,
1210
+ type: "success",
1211
+ dataUpdatedAt: options?.updatedAt,
1212
+ manual: options?.manual
1213
+ });
1214
+ return data;
1215
+ }
1216
+ setState(state) {
1217
+ __privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "setState", state });
1218
+ }
1219
+ cancel(options) {
1220
+ const promise = __privateGet(this, _retryer)?.promise;
1221
+ __privateGet(this, _retryer)?.cancel(options);
1222
+ return promise ? promise.then(noop).catch(noop) : Promise.resolve();
1223
+ }
1224
+ destroy() {
1225
+ super.destroy();
1226
+ this.cancel({ silent: true });
1227
+ }
1228
+ get resetState() {
1229
+ return __privateGet(this, _initialState);
1230
+ }
1231
+ reset() {
1232
+ this.destroy();
1233
+ this.setState(this.resetState);
1234
+ }
1235
+ isActive() {
1236
+ return this.observers.some(
1237
+ (observer) => resolveQueryBoolean(observer.options.enabled, this) !== false
1238
+ );
1239
+ }
1240
+ isDisabled() {
1241
+ if (this.getObserversCount() > 0) {
1242
+ return !this.isActive();
1243
+ }
1244
+ return this.options.queryFn === skipToken || !this.isFetched();
1245
+ }
1246
+ isFetched() {
1247
+ return this.state.dataUpdateCount + this.state.errorUpdateCount > 0;
1248
+ }
1249
+ isStatic() {
1250
+ if (this.getObserversCount() > 0) {
1251
+ return this.observers.some(
1252
+ (observer) => resolveStaleTime(observer.options.staleTime, this) === "static"
1253
+ );
1254
+ }
1255
+ return false;
1256
+ }
1257
+ isStale() {
1258
+ if (this.getObserversCount() > 0) {
1259
+ return this.observers.some(
1260
+ (observer) => observer.getCurrentResult().isStale
1261
+ );
1262
+ }
1263
+ return this.state.data === void 0 || this.state.isInvalidated;
1264
+ }
1265
+ isStaleByTime(staleTime = 0) {
1266
+ if (this.state.data === void 0) {
1267
+ return true;
1268
+ }
1269
+ if (staleTime === "static") {
1270
+ return false;
1271
+ }
1272
+ if (this.state.isInvalidated) {
1273
+ return true;
1274
+ }
1275
+ return !timeUntilStale(this.state.dataUpdatedAt, staleTime);
1276
+ }
1277
+ onFocus() {
1278
+ const observer = this.observers.find((x3) => x3.shouldFetchOnWindowFocus());
1279
+ observer?.refetch({ cancelRefetch: false });
1280
+ __privateGet(this, _retryer)?.continue();
1281
+ }
1282
+ onOnline() {
1283
+ const observer = this.observers.find((x3) => x3.shouldFetchOnReconnect());
1284
+ observer?.refetch({ cancelRefetch: false });
1285
+ __privateGet(this, _retryer)?.continue();
1286
+ }
1287
+ addObserver(observer) {
1288
+ if (!this.observers.includes(observer)) {
1289
+ this.observers.push(observer);
1290
+ this.clearGcTimeout();
1291
+ __privateGet(this, _cache).notify({ type: "observerAdded", query: this, observer });
1292
+ }
1293
+ }
1294
+ removeObserver(observer) {
1295
+ if (this.observers.includes(observer)) {
1296
+ this.observers = this.observers.filter((x3) => x3 !== observer);
1297
+ if (!this.observers.length) {
1298
+ if (__privateGet(this, _retryer)) {
1299
+ if (__privateGet(this, _abortSignalConsumed) || __privateMethod(this, _Query_instances, isInitialPausedFetch_fn).call(this)) {
1300
+ __privateGet(this, _retryer).cancel({ revert: true });
1301
+ } else {
1302
+ __privateGet(this, _retryer).cancelRetry();
1303
+ }
1304
+ }
1305
+ this.scheduleGc();
1306
+ }
1307
+ __privateGet(this, _cache).notify({ type: "observerRemoved", query: this, observer });
1308
+ }
1309
+ }
1310
+ getObserversCount() {
1311
+ return this.observers.length;
1312
+ }
1313
+ invalidate() {
1314
+ if (!this.state.isInvalidated) {
1315
+ __privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "invalidate" });
1316
+ }
1317
+ }
1318
+ async fetch(options, fetchOptions) {
1319
+ if (this.state.fetchStatus !== "idle" && // If the promise in the retryer is already rejected, we have to definitely
1320
+ // re-start the fetch; there is a chance that the query is still in a
1321
+ // pending state when that happens
1322
+ __privateGet(this, _retryer)?.status() !== "rejected") {
1323
+ if (this.state.data !== void 0 && fetchOptions?.cancelRefetch) {
1324
+ this.cancel({ silent: true });
1325
+ } else if (__privateGet(this, _retryer)) {
1326
+ __privateGet(this, _retryer).continueRetry();
1327
+ return __privateGet(this, _retryer).promise;
1328
+ }
1329
+ }
1330
+ if (options) {
1331
+ this.setOptions(options);
1332
+ }
1333
+ if (!this.options.queryFn) {
1334
+ const observer = this.observers.find((x3) => x3.options.queryFn);
1335
+ if (observer) {
1336
+ this.setOptions(observer.options);
1337
+ }
1338
+ }
1339
+ if (true) {
1340
+ if (!Array.isArray(this.options.queryKey)) {
1341
+ console.error(
1342
+ `As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']`
1343
+ );
1344
+ }
1345
+ }
1346
+ const abortController = new AbortController();
1347
+ const addSignalProperty = (object) => {
1348
+ Object.defineProperty(object, "signal", {
1349
+ enumerable: true,
1350
+ get: () => {
1351
+ __privateSet(this, _abortSignalConsumed, true);
1352
+ return abortController.signal;
1353
+ }
1354
+ });
1355
+ };
1356
+ const fetchFn = () => {
1357
+ const queryFn = ensureQueryFn(this.options, fetchOptions);
1358
+ const createQueryFnContext = () => {
1359
+ const queryFnContext2 = {
1360
+ client: __privateGet(this, _client),
1361
+ queryKey: this.queryKey,
1362
+ meta: this.meta
1363
+ };
1364
+ addSignalProperty(queryFnContext2);
1365
+ return queryFnContext2;
1366
+ };
1367
+ const queryFnContext = createQueryFnContext();
1368
+ __privateSet(this, _abortSignalConsumed, false);
1369
+ if (this.options.persister) {
1370
+ return this.options.persister(
1371
+ queryFn,
1372
+ queryFnContext,
1373
+ this
1374
+ );
1375
+ }
1376
+ return queryFn(queryFnContext);
1377
+ };
1378
+ const createFetchContext = () => {
1379
+ const context2 = {
1380
+ fetchOptions,
1381
+ options: this.options,
1382
+ queryKey: this.queryKey,
1383
+ client: __privateGet(this, _client),
1384
+ state: this.state,
1385
+ fetchFn
1386
+ };
1387
+ addSignalProperty(context2);
1388
+ return context2;
1389
+ };
1390
+ const context = createFetchContext();
1391
+ const behavior = __privateGet(this, _queryType) === "infinite" ? infiniteQueryBehavior(
1392
+ this.options.pages
1393
+ ) : this.options.behavior;
1394
+ behavior?.onFetch(context, this);
1395
+ __privateSet(this, _revertState, this.state);
1396
+ if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) {
1397
+ __privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "fetch", meta: context.fetchOptions?.meta });
1398
+ }
1399
+ __privateSet(this, _retryer, createRetryer({
1400
+ initialPromise: fetchOptions?.initialPromise,
1401
+ fn: context.fetchFn,
1402
+ onCancel: (error) => {
1403
+ if (error instanceof CancelledError && error.revert) {
1404
+ this.setState({
1405
+ ...__privateGet(this, _revertState),
1406
+ fetchStatus: "idle"
1407
+ });
1408
+ }
1409
+ abortController.abort();
1410
+ },
1411
+ onFail: (failureCount, error) => {
1412
+ __privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "failed", failureCount, error });
1413
+ },
1414
+ onPause: () => {
1415
+ __privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "pause" });
1416
+ },
1417
+ onContinue: () => {
1418
+ __privateMethod(this, _Query_instances, dispatch_fn).call(this, { type: "continue" });
1419
+ },
1420
+ retry: context.options.retry,
1421
+ retryDelay: context.options.retryDelay,
1422
+ networkMode: context.options.networkMode,
1423
+ canRun: () => true
1424
+ }));
1425
+ try {
1426
+ const data = await __privateGet(this, _retryer).start();
1427
+ if (data === void 0) {
1428
+ if (true) {
1429
+ console.error(
1430
+ `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
1431
+ );
1432
+ }
1433
+ throw new Error(`${this.queryHash} data is undefined`);
1434
+ }
1435
+ this.setData(data);
1436
+ __privateGet(this, _cache).config.onSuccess?.(data, this);
1437
+ __privateGet(this, _cache).config.onSettled?.(
1438
+ data,
1439
+ this.state.error,
1440
+ this
1441
+ );
1442
+ return data;
1443
+ } catch (error) {
1444
+ if (error instanceof CancelledError) {
1445
+ if (error.silent) {
1446
+ return __privateGet(this, _retryer).promise;
1447
+ } else if (error.revert) {
1448
+ if (this.state.data === void 0) {
1449
+ throw error;
1450
+ }
1451
+ return this.state.data;
1452
+ }
1453
+ }
1454
+ __privateMethod(this, _Query_instances, dispatch_fn).call(this, {
1455
+ type: "error",
1456
+ error
1457
+ });
1458
+ __privateGet(this, _cache).config.onError?.(
1459
+ error,
1460
+ this
1461
+ );
1462
+ __privateGet(this, _cache).config.onSettled?.(
1463
+ this.state.data,
1464
+ error,
1465
+ this
1466
+ );
1467
+ throw error;
1468
+ } finally {
1469
+ this.scheduleGc();
1470
+ }
1471
+ }
1472
+ }, _queryType = new WeakMap(), _initialState = new WeakMap(), _revertState = new WeakMap(), _cache = new WeakMap(), _client = new WeakMap(), _retryer = new WeakMap(), _defaultOptions = new WeakMap(), _abortSignalConsumed = new WeakMap(), _Query_instances = new WeakSet(), isInitialPausedFetch_fn = function() {
1473
+ return this.state.fetchStatus === "paused" && this.state.status === "pending";
1474
+ }, dispatch_fn = function(action) {
1475
+ const reducer = (state) => {
1476
+ switch (action.type) {
1477
+ case "failed":
1478
+ return {
1479
+ ...state,
1480
+ fetchFailureCount: action.failureCount,
1481
+ fetchFailureReason: action.error
1482
+ };
1483
+ case "pause":
1484
+ return {
1485
+ ...state,
1486
+ fetchStatus: "paused"
1487
+ };
1488
+ case "continue":
1489
+ return {
1490
+ ...state,
1491
+ fetchStatus: "fetching"
1492
+ };
1493
+ case "fetch":
1494
+ return {
1495
+ ...state,
1496
+ ...fetchState(state.data, this.options),
1497
+ fetchMeta: action.meta ?? null
1498
+ };
1499
+ case "success":
1500
+ const newState = {
1501
+ ...state,
1502
+ ...successState(action.data, action.dataUpdatedAt),
1503
+ dataUpdateCount: state.dataUpdateCount + 1,
1504
+ ...!action.manual && {
1505
+ fetchStatus: "idle",
1506
+ fetchFailureCount: 0,
1507
+ fetchFailureReason: null
1508
+ }
1509
+ };
1510
+ __privateSet(this, _revertState, action.manual ? newState : void 0);
1511
+ return newState;
1512
+ case "error":
1513
+ const error = action.error;
1514
+ return {
1515
+ ...state,
1516
+ error,
1517
+ errorUpdateCount: state.errorUpdateCount + 1,
1518
+ errorUpdatedAt: Date.now(),
1519
+ fetchFailureCount: state.fetchFailureCount + 1,
1520
+ fetchFailureReason: error,
1521
+ fetchStatus: "idle",
1522
+ status: "error",
1523
+ // flag existing data as invalidated if we get a background error
1524
+ // note that "no data" always means stale so we can set unconditionally here
1525
+ isInvalidated: true
1526
+ };
1527
+ case "invalidate":
1528
+ return {
1529
+ ...state,
1530
+ isInvalidated: true
1531
+ };
1532
+ case "setState":
1533
+ return {
1534
+ ...state,
1535
+ ...action.state
1536
+ };
1537
+ }
1538
+ };
1539
+ this.state = reducer(this.state);
1540
+ notifyManager.batch(() => {
1541
+ this.observers.forEach((observer) => {
1542
+ observer.onQueryUpdate();
1543
+ });
1544
+ __privateGet(this, _cache).notify({ query: this, type: "updated", action });
1545
+ });
1546
+ }, _a5);
1547
+ function fetchState(data, options) {
1548
+ return {
1549
+ fetchFailureCount: 0,
1550
+ fetchFailureReason: null,
1551
+ fetchStatus: canFetch(options.networkMode) ? "fetching" : "paused",
1552
+ ...data === void 0 && {
1553
+ error: null,
1554
+ status: "pending"
1555
+ }
1556
+ };
1557
+ }
1558
+ function successState(data, dataUpdatedAt) {
1559
+ return {
1560
+ data,
1561
+ dataUpdatedAt: dataUpdatedAt ?? Date.now(),
1562
+ error: null,
1563
+ isInvalidated: false,
1564
+ status: "success"
1565
+ };
1566
+ }
1567
+ function getDefaultState(options) {
1568
+ const data = typeof options.initialData === "function" ? options.initialData() : options.initialData;
1569
+ const hasData = data !== void 0;
1570
+ const initialDataUpdatedAt = hasData ? typeof options.initialDataUpdatedAt === "function" ? options.initialDataUpdatedAt() : options.initialDataUpdatedAt : 0;
1571
+ return {
1572
+ data,
1573
+ dataUpdateCount: 0,
1574
+ dataUpdatedAt: hasData ? initialDataUpdatedAt ?? Date.now() : 0,
1575
+ error: null,
1576
+ errorUpdateCount: 0,
1577
+ errorUpdatedAt: 0,
1578
+ fetchFailureCount: 0,
1579
+ fetchFailureReason: null,
1580
+ fetchMeta: null,
1581
+ isInvalidated: false,
1582
+ status: hasData ? "success" : "pending",
1583
+ fetchStatus: "idle"
1584
+ };
1585
+ }
1586
+
1587
+ // node_modules/@tanstack/query-core/build/modern/queryObserver.js
1588
+ var _client2, _currentQuery, _currentQueryInitialState, _currentResult, _currentResultState, _currentResultOptions, _currentThenable, _selectError, _selectFn, _selectResult, _lastQueryWithDefinedData, _staleTimeoutId, _refetchIntervalId, _currentRefetchInterval, _trackedProps, _QueryObserver_instances, executeFetch_fn, updateStaleTimeout_fn, computeRefetchInterval_fn, updateRefetchInterval_fn, updateTimers_fn, clearStaleTimeout_fn, clearRefetchInterval_fn, updateQuery_fn, notify_fn, _a6;
1589
+ var QueryObserver = (_a6 = class extends Subscribable {
1590
+ constructor(client, options) {
1591
+ super();
1592
+ __privateAdd(this, _QueryObserver_instances);
1593
+ __privateAdd(this, _client2);
1594
+ __privateAdd(this, _currentQuery);
1595
+ __privateAdd(this, _currentQueryInitialState);
1596
+ __privateAdd(this, _currentResult);
1597
+ __privateAdd(this, _currentResultState);
1598
+ __privateAdd(this, _currentResultOptions);
1599
+ __privateAdd(this, _currentThenable);
1600
+ __privateAdd(this, _selectError);
1601
+ __privateAdd(this, _selectFn);
1602
+ __privateAdd(this, _selectResult);
1603
+ // This property keeps track of the last query with defined data.
1604
+ // It will be used to pass the previous data and query to the placeholder function between renders.
1605
+ __privateAdd(this, _lastQueryWithDefinedData);
1606
+ __privateAdd(this, _staleTimeoutId);
1607
+ __privateAdd(this, _refetchIntervalId);
1608
+ __privateAdd(this, _currentRefetchInterval);
1609
+ __privateAdd(this, _trackedProps, /* @__PURE__ */ new Set());
1610
+ this.options = options;
1611
+ __privateSet(this, _client2, client);
1612
+ __privateSet(this, _selectError, null);
1613
+ __privateSet(this, _currentThenable, pendingThenable());
1614
+ this.bindMethods();
1615
+ this.setOptions(options);
1616
+ }
1617
+ bindMethods() {
1618
+ this.refetch = this.refetch.bind(this);
1619
+ }
1620
+ onSubscribe() {
1621
+ if (this.listeners.size === 1) {
1622
+ __privateGet(this, _currentQuery).addObserver(this);
1623
+ if (shouldFetchOnMount(__privateGet(this, _currentQuery), this.options)) {
1624
+ __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
1625
+ } else {
1626
+ this.updateResult();
1627
+ }
1628
+ __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
1629
+ }
1630
+ }
1631
+ onUnsubscribe() {
1632
+ if (!this.hasListeners()) {
1633
+ this.destroy();
1634
+ }
1635
+ }
1636
+ shouldFetchOnReconnect() {
1637
+ return shouldFetchOn(
1638
+ __privateGet(this, _currentQuery),
1639
+ this.options,
1640
+ this.options.refetchOnReconnect
1641
+ );
1642
+ }
1643
+ shouldFetchOnWindowFocus() {
1644
+ return shouldFetchOn(
1645
+ __privateGet(this, _currentQuery),
1646
+ this.options,
1647
+ this.options.refetchOnWindowFocus
1648
+ );
1649
+ }
1650
+ destroy() {
1651
+ this.listeners = /* @__PURE__ */ new Set();
1652
+ __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
1653
+ __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
1654
+ __privateGet(this, _currentQuery).removeObserver(this);
1655
+ }
1656
+ setOptions(options) {
1657
+ const prevOptions = this.options;
1658
+ const prevQuery = __privateGet(this, _currentQuery);
1659
+ this.options = __privateGet(this, _client2).defaultQueryOptions(options);
1660
+ if (this.options.enabled !== void 0 && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryBoolean(this.options.enabled, __privateGet(this, _currentQuery)) !== "boolean") {
1661
+ throw new Error(
1662
+ "Expected enabled to be a boolean or a callback that returns a boolean"
1663
+ );
1664
+ }
1665
+ __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
1666
+ __privateGet(this, _currentQuery).setOptions(this.options);
1667
+ if (prevOptions._defaulted && !shallowEqualObjects(this.options, prevOptions)) {
1668
+ __privateGet(this, _client2).getQueryCache().notify({
1669
+ type: "observerOptionsUpdated",
1670
+ query: __privateGet(this, _currentQuery),
1671
+ observer: this
1672
+ });
1673
+ }
1674
+ const mounted = this.hasListeners();
1675
+ if (mounted && shouldFetchOptionally(
1676
+ __privateGet(this, _currentQuery),
1677
+ prevQuery,
1678
+ this.options,
1679
+ prevOptions
1680
+ )) {
1681
+ __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
1682
+ }
1683
+ this.updateResult();
1684
+ if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveQueryBoolean(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveQueryBoolean(prevOptions.enabled, __privateGet(this, _currentQuery)) || resolveStaleTime(this.options.staleTime, __privateGet(this, _currentQuery)) !== resolveStaleTime(prevOptions.staleTime, __privateGet(this, _currentQuery)))) {
1685
+ __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
1686
+ }
1687
+ const nextRefetchInterval = __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this);
1688
+ if (mounted && (__privateGet(this, _currentQuery) !== prevQuery || resolveQueryBoolean(this.options.enabled, __privateGet(this, _currentQuery)) !== resolveQueryBoolean(prevOptions.enabled, __privateGet(this, _currentQuery)) || nextRefetchInterval !== __privateGet(this, _currentRefetchInterval))) {
1689
+ __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, nextRefetchInterval);
1690
+ }
1691
+ }
1692
+ getOptimisticResult(options) {
1693
+ const query = __privateGet(this, _client2).getQueryCache().build(__privateGet(this, _client2), options);
1694
+ const result = this.createResult(query, options);
1695
+ if (shouldAssignObserverCurrentProperties(this, result)) {
1696
+ __privateSet(this, _currentResult, result);
1697
+ __privateSet(this, _currentResultOptions, this.options);
1698
+ __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
1699
+ }
1700
+ return result;
1701
+ }
1702
+ getCurrentResult() {
1703
+ return __privateGet(this, _currentResult);
1704
+ }
1705
+ trackResult(result, onPropTracked) {
1706
+ return new Proxy(result, {
1707
+ get: (target, key) => {
1708
+ this.trackProp(key);
1709
+ onPropTracked?.(key);
1710
+ if (key === "promise") {
1711
+ this.trackProp("data");
1712
+ if (!this.options.experimental_prefetchInRender && __privateGet(this, _currentThenable).status === "pending") {
1713
+ __privateGet(this, _currentThenable).reject(
1714
+ new Error(
1715
+ "experimental_prefetchInRender feature flag is not enabled"
1716
+ )
1717
+ );
1718
+ }
1719
+ }
1720
+ return Reflect.get(target, key);
1721
+ }
1722
+ });
1723
+ }
1724
+ trackProp(key) {
1725
+ __privateGet(this, _trackedProps).add(key);
1726
+ }
1727
+ getCurrentQuery() {
1728
+ return __privateGet(this, _currentQuery);
1729
+ }
1730
+ refetch({ ...options } = {}) {
1731
+ return this.fetch({
1732
+ ...options
1733
+ });
1734
+ }
1735
+ fetchOptimistic(options) {
1736
+ const defaultedOptions = __privateGet(this, _client2).defaultQueryOptions(options);
1737
+ const query = __privateGet(this, _client2).getQueryCache().build(__privateGet(this, _client2), defaultedOptions);
1738
+ return query.fetch().then(() => this.createResult(query, defaultedOptions));
1739
+ }
1740
+ fetch(fetchOptions) {
1741
+ return __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this, {
1742
+ ...fetchOptions,
1743
+ cancelRefetch: fetchOptions.cancelRefetch ?? true
1744
+ }).then(() => {
1745
+ this.updateResult();
1746
+ return __privateGet(this, _currentResult);
1747
+ });
1748
+ }
1749
+ createResult(query, options) {
1750
+ const prevQuery = __privateGet(this, _currentQuery);
1751
+ const prevOptions = this.options;
1752
+ const prevResult = __privateGet(this, _currentResult);
1753
+ const prevResultState = __privateGet(this, _currentResultState);
1754
+ const prevResultOptions = __privateGet(this, _currentResultOptions);
1755
+ const queryChange = query !== prevQuery;
1756
+ const queryInitialState = queryChange ? query.state : __privateGet(this, _currentQueryInitialState);
1757
+ const { state } = query;
1758
+ let newState = { ...state };
1759
+ let isPlaceholderData = false;
1760
+ let data;
1761
+ if (options._optimisticResults) {
1762
+ const mounted = this.hasListeners();
1763
+ const fetchOnMount = !mounted && shouldFetchOnMount(query, options);
1764
+ const fetchOptionally = mounted && shouldFetchOptionally(query, prevQuery, options, prevOptions);
1765
+ if (fetchOnMount || fetchOptionally) {
1766
+ newState = {
1767
+ ...newState,
1768
+ ...fetchState(state.data, query.options)
1769
+ };
1770
+ }
1771
+ if (options._optimisticResults === "isRestoring") {
1772
+ newState.fetchStatus = "idle";
1773
+ }
1774
+ }
1775
+ let { error, errorUpdatedAt, status } = newState;
1776
+ data = newState.data;
1777
+ let skipSelect = false;
1778
+ if (options.placeholderData !== void 0 && data === void 0 && status === "pending") {
1779
+ let placeholderData;
1780
+ if (prevResult?.isPlaceholderData && options.placeholderData === prevResultOptions?.placeholderData) {
1781
+ placeholderData = prevResult.data;
1782
+ skipSelect = true;
1783
+ } else {
1784
+ placeholderData = typeof options.placeholderData === "function" ? options.placeholderData(
1785
+ __privateGet(this, _lastQueryWithDefinedData)?.state.data,
1786
+ __privateGet(this, _lastQueryWithDefinedData)
1787
+ ) : options.placeholderData;
1788
+ }
1789
+ if (placeholderData !== void 0) {
1790
+ status = "success";
1791
+ data = replaceData(
1792
+ prevResult?.data,
1793
+ placeholderData,
1794
+ options
1795
+ );
1796
+ isPlaceholderData = true;
1797
+ }
1798
+ }
1799
+ if (options.select && data !== void 0 && !skipSelect) {
1800
+ if (prevResult && data === prevResultState?.data && options.select === __privateGet(this, _selectFn)) {
1801
+ data = __privateGet(this, _selectResult);
1802
+ } else {
1803
+ try {
1804
+ __privateSet(this, _selectFn, options.select);
1805
+ data = options.select(data);
1806
+ data = replaceData(prevResult?.data, data, options);
1807
+ __privateSet(this, _selectResult, data);
1808
+ __privateSet(this, _selectError, null);
1809
+ } catch (selectError) {
1810
+ __privateSet(this, _selectError, selectError);
1811
+ }
1812
+ }
1813
+ }
1814
+ if (__privateGet(this, _selectError)) {
1815
+ error = __privateGet(this, _selectError);
1816
+ data = __privateGet(this, _selectResult);
1817
+ errorUpdatedAt = Date.now();
1818
+ status = "error";
1819
+ }
1820
+ const isFetching = newState.fetchStatus === "fetching";
1821
+ const isPending = status === "pending";
1822
+ const isError = status === "error";
1823
+ const isLoading = isPending && isFetching;
1824
+ const hasData = data !== void 0;
1825
+ const result = {
1826
+ status,
1827
+ fetchStatus: newState.fetchStatus,
1828
+ isPending,
1829
+ isSuccess: status === "success",
1830
+ isError,
1831
+ isInitialLoading: isLoading,
1832
+ isLoading,
1833
+ data,
1834
+ dataUpdatedAt: newState.dataUpdatedAt,
1835
+ error,
1836
+ errorUpdatedAt,
1837
+ failureCount: newState.fetchFailureCount,
1838
+ failureReason: newState.fetchFailureReason,
1839
+ errorUpdateCount: newState.errorUpdateCount,
1840
+ isFetched: query.isFetched(),
1841
+ isFetchedAfterMount: newState.dataUpdateCount > queryInitialState.dataUpdateCount || newState.errorUpdateCount > queryInitialState.errorUpdateCount,
1842
+ isFetching,
1843
+ isRefetching: isFetching && !isPending,
1844
+ isLoadingError: isError && !hasData,
1845
+ isPaused: newState.fetchStatus === "paused",
1846
+ isPlaceholderData,
1847
+ isRefetchError: isError && hasData,
1848
+ isStale: isStale(query, options),
1849
+ refetch: this.refetch,
1850
+ promise: __privateGet(this, _currentThenable),
1851
+ isEnabled: resolveQueryBoolean(options.enabled, query) !== false
1852
+ };
1853
+ const nextResult = result;
1854
+ if (this.options.experimental_prefetchInRender) {
1855
+ const hasResultData = nextResult.data !== void 0;
1856
+ const isErrorWithoutData = nextResult.status === "error" && !hasResultData;
1857
+ const finalizeThenableIfPossible = (thenable) => {
1858
+ if (isErrorWithoutData) {
1859
+ thenable.reject(nextResult.error);
1860
+ } else if (hasResultData) {
1861
+ thenable.resolve(nextResult.data);
1862
+ }
1863
+ };
1864
+ const recreateThenable = () => {
1865
+ const pending = __privateSet(this, _currentThenable, nextResult.promise = pendingThenable());
1866
+ finalizeThenableIfPossible(pending);
1867
+ };
1868
+ const prevThenable = __privateGet(this, _currentThenable);
1869
+ switch (prevThenable.status) {
1870
+ case "pending":
1871
+ if (query.queryHash === prevQuery.queryHash) {
1872
+ finalizeThenableIfPossible(prevThenable);
1873
+ }
1874
+ break;
1875
+ case "fulfilled":
1876
+ if (isErrorWithoutData || nextResult.data !== prevThenable.value) {
1877
+ recreateThenable();
1878
+ }
1879
+ break;
1880
+ case "rejected":
1881
+ if (!isErrorWithoutData || nextResult.error !== prevThenable.reason) {
1882
+ recreateThenable();
1883
+ }
1884
+ break;
1885
+ }
1886
+ }
1887
+ return nextResult;
1888
+ }
1889
+ updateResult() {
1890
+ const prevResult = __privateGet(this, _currentResult);
1891
+ const nextResult = this.createResult(__privateGet(this, _currentQuery), this.options);
1892
+ __privateSet(this, _currentResultState, __privateGet(this, _currentQuery).state);
1893
+ __privateSet(this, _currentResultOptions, this.options);
1894
+ if (__privateGet(this, _currentResultState).data !== void 0) {
1895
+ __privateSet(this, _lastQueryWithDefinedData, __privateGet(this, _currentQuery));
1896
+ }
1897
+ if (shallowEqualObjects(nextResult, prevResult)) {
1898
+ return;
1899
+ }
1900
+ __privateSet(this, _currentResult, nextResult);
1901
+ const shouldNotifyListeners = () => {
1902
+ if (!prevResult) {
1903
+ return true;
1904
+ }
1905
+ const { notifyOnChangeProps } = this.options;
1906
+ const notifyOnChangePropsValue = typeof notifyOnChangeProps === "function" ? notifyOnChangeProps() : notifyOnChangeProps;
1907
+ if (notifyOnChangePropsValue === "all" || !notifyOnChangePropsValue && !__privateGet(this, _trackedProps).size) {
1908
+ return true;
1909
+ }
1910
+ const includedProps = new Set(
1911
+ notifyOnChangePropsValue ?? __privateGet(this, _trackedProps)
1912
+ );
1913
+ if (this.options.throwOnError) {
1914
+ includedProps.add("error");
1915
+ }
1916
+ return Object.keys(__privateGet(this, _currentResult)).some((key) => {
1917
+ const typedKey = key;
1918
+ const changed = __privateGet(this, _currentResult)[typedKey] !== prevResult[typedKey];
1919
+ return changed && includedProps.has(typedKey);
1920
+ });
1921
+ };
1922
+ __privateMethod(this, _QueryObserver_instances, notify_fn).call(this, { listeners: shouldNotifyListeners() });
1923
+ }
1924
+ onQueryUpdate() {
1925
+ this.updateResult();
1926
+ if (this.hasListeners()) {
1927
+ __privateMethod(this, _QueryObserver_instances, updateTimers_fn).call(this);
1928
+ }
1929
+ }
1930
+ }, _client2 = new WeakMap(), _currentQuery = new WeakMap(), _currentQueryInitialState = new WeakMap(), _currentResult = new WeakMap(), _currentResultState = new WeakMap(), _currentResultOptions = new WeakMap(), _currentThenable = new WeakMap(), _selectError = new WeakMap(), _selectFn = new WeakMap(), _selectResult = new WeakMap(), _lastQueryWithDefinedData = new WeakMap(), _staleTimeoutId = new WeakMap(), _refetchIntervalId = new WeakMap(), _currentRefetchInterval = new WeakMap(), _trackedProps = new WeakMap(), _QueryObserver_instances = new WeakSet(), executeFetch_fn = function(fetchOptions) {
1931
+ __privateMethod(this, _QueryObserver_instances, updateQuery_fn).call(this);
1932
+ let promise = __privateGet(this, _currentQuery).fetch(
1933
+ this.options,
1934
+ fetchOptions
1935
+ );
1936
+ if (!fetchOptions?.throwOnError) {
1937
+ promise = promise.catch(noop);
1938
+ }
1939
+ return promise;
1940
+ }, updateStaleTimeout_fn = function() {
1941
+ __privateMethod(this, _QueryObserver_instances, clearStaleTimeout_fn).call(this);
1942
+ const staleTime = resolveStaleTime(
1943
+ this.options.staleTime,
1944
+ __privateGet(this, _currentQuery)
1945
+ );
1946
+ if (environmentManager.isServer() || __privateGet(this, _currentResult).isStale || !isValidTimeout(staleTime)) {
1947
+ return;
1948
+ }
1949
+ const time = timeUntilStale(__privateGet(this, _currentResult).dataUpdatedAt, staleTime);
1950
+ const timeout = time + 1;
1951
+ __privateSet(this, _staleTimeoutId, timeoutManager.setTimeout(() => {
1952
+ if (!__privateGet(this, _currentResult).isStale) {
1953
+ this.updateResult();
1954
+ }
1955
+ }, timeout));
1956
+ }, computeRefetchInterval_fn = function() {
1957
+ return (typeof this.options.refetchInterval === "function" ? this.options.refetchInterval(__privateGet(this, _currentQuery)) : this.options.refetchInterval) ?? false;
1958
+ }, updateRefetchInterval_fn = function(nextInterval) {
1959
+ __privateMethod(this, _QueryObserver_instances, clearRefetchInterval_fn).call(this);
1960
+ __privateSet(this, _currentRefetchInterval, nextInterval);
1961
+ if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, __privateGet(this, _currentQuery)) === false || !isValidTimeout(__privateGet(this, _currentRefetchInterval)) || __privateGet(this, _currentRefetchInterval) === 0) {
1962
+ return;
1963
+ }
1964
+ __privateSet(this, _refetchIntervalId, timeoutManager.setInterval(() => {
1965
+ if (this.options.refetchIntervalInBackground || focusManager.isFocused()) {
1966
+ __privateMethod(this, _QueryObserver_instances, executeFetch_fn).call(this);
1967
+ }
1968
+ }, __privateGet(this, _currentRefetchInterval)));
1969
+ }, updateTimers_fn = function() {
1970
+ __privateMethod(this, _QueryObserver_instances, updateStaleTimeout_fn).call(this);
1971
+ __privateMethod(this, _QueryObserver_instances, updateRefetchInterval_fn).call(this, __privateMethod(this, _QueryObserver_instances, computeRefetchInterval_fn).call(this));
1972
+ }, clearStaleTimeout_fn = function() {
1973
+ if (__privateGet(this, _staleTimeoutId) !== void 0) {
1974
+ timeoutManager.clearTimeout(__privateGet(this, _staleTimeoutId));
1975
+ __privateSet(this, _staleTimeoutId, void 0);
1976
+ }
1977
+ }, clearRefetchInterval_fn = function() {
1978
+ if (__privateGet(this, _refetchIntervalId) !== void 0) {
1979
+ timeoutManager.clearInterval(__privateGet(this, _refetchIntervalId));
1980
+ __privateSet(this, _refetchIntervalId, void 0);
1981
+ }
1982
+ }, updateQuery_fn = function() {
1983
+ const query = __privateGet(this, _client2).getQueryCache().build(__privateGet(this, _client2), this.options);
1984
+ if (query === __privateGet(this, _currentQuery)) {
1985
+ return;
1986
+ }
1987
+ const prevQuery = __privateGet(this, _currentQuery);
1988
+ __privateSet(this, _currentQuery, query);
1989
+ __privateSet(this, _currentQueryInitialState, query.state);
1990
+ if (this.hasListeners()) {
1991
+ prevQuery?.removeObserver(this);
1992
+ query.addObserver(this);
1993
+ }
1994
+ }, notify_fn = function(notifyOptions) {
1995
+ notifyManager.batch(() => {
1996
+ if (notifyOptions.listeners) {
1997
+ this.listeners.forEach((listener) => {
1998
+ listener(__privateGet(this, _currentResult));
1999
+ });
2000
+ }
2001
+ __privateGet(this, _client2).getQueryCache().notify({
2002
+ query: __privateGet(this, _currentQuery),
2003
+ type: "observerResultsUpdated"
2004
+ });
2005
+ });
2006
+ }, _a6);
2007
+ function shouldLoadOnMount(query, options) {
2008
+ return resolveQueryBoolean(options.enabled, query) !== false && query.state.data === void 0 && !(query.state.status === "error" && resolveQueryBoolean(options.retryOnMount, query) === false);
2009
+ }
2010
+ function shouldFetchOnMount(query, options) {
2011
+ return shouldLoadOnMount(query, options) || query.state.data !== void 0 && shouldFetchOn(query, options, options.refetchOnMount);
2012
+ }
2013
+ function shouldFetchOn(query, options, field) {
2014
+ if (resolveQueryBoolean(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
2015
+ const value = typeof field === "function" ? field(query) : field;
2016
+ return value === "always" || value !== false && isStale(query, options);
2017
+ }
2018
+ return false;
2019
+ }
2020
+ function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
2021
+ return (query !== prevQuery || resolveQueryBoolean(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
2022
+ }
2023
+ function isStale(query, options) {
2024
+ return resolveQueryBoolean(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
2025
+ }
2026
+ function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
2027
+ if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
2028
+ return true;
2029
+ }
2030
+ return false;
2031
+ }
2032
+
2033
+ // node_modules/@tanstack/query-core/build/modern/infiniteQueryObserver.js
2034
+ var InfiniteQueryObserver = class extends QueryObserver {
2035
+ constructor(client, options) {
2036
+ super(client, options);
2037
+ }
2038
+ bindMethods() {
2039
+ super.bindMethods();
2040
+ this.fetchNextPage = this.fetchNextPage.bind(this);
2041
+ this.fetchPreviousPage = this.fetchPreviousPage.bind(this);
2042
+ }
2043
+ setOptions(options) {
2044
+ options._type = "infinite";
2045
+ super.setOptions(options);
2046
+ }
2047
+ getOptimisticResult(options) {
2048
+ options._type = "infinite";
2049
+ return super.getOptimisticResult(options);
2050
+ }
2051
+ fetchNextPage(options) {
2052
+ return this.fetch({
2053
+ ...options,
2054
+ meta: {
2055
+ fetchMore: { direction: "forward" }
2056
+ }
2057
+ });
2058
+ }
2059
+ fetchPreviousPage(options) {
2060
+ return this.fetch({
2061
+ ...options,
2062
+ meta: {
2063
+ fetchMore: { direction: "backward" }
2064
+ }
2065
+ });
2066
+ }
2067
+ createResult(query, options) {
2068
+ const { state } = query;
2069
+ const parentResult = super.createResult(query, options);
2070
+ const { isFetching, isRefetching, isError, isRefetchError } = parentResult;
2071
+ const fetchDirection = state.fetchMeta?.fetchMore?.direction;
2072
+ const isFetchNextPageError = isError && fetchDirection === "forward";
2073
+ const isFetchingNextPage = isFetching && fetchDirection === "forward";
2074
+ const isFetchPreviousPageError = isError && fetchDirection === "backward";
2075
+ const isFetchingPreviousPage = isFetching && fetchDirection === "backward";
2076
+ const result = {
2077
+ ...parentResult,
2078
+ fetchNextPage: this.fetchNextPage,
2079
+ fetchPreviousPage: this.fetchPreviousPage,
2080
+ hasNextPage: hasNextPage(options, state.data),
2081
+ hasPreviousPage: hasPreviousPage(options, state.data),
2082
+ isFetchNextPageError,
2083
+ isFetchingNextPage,
2084
+ isFetchPreviousPageError,
2085
+ isFetchingPreviousPage,
2086
+ isRefetchError: isRefetchError && !isFetchNextPageError && !isFetchPreviousPageError,
2087
+ isRefetching: isRefetching && !isFetchingNextPage && !isFetchingPreviousPage
2088
+ };
2089
+ return result;
2090
+ }
2091
+ };
2092
+
2093
+ // node_modules/@tanstack/query-core/build/modern/mutation.js
2094
+ var _client3, _observers, _mutationCache, _retryer2, _Mutation_instances, dispatch_fn2, _a7;
2095
+ var Mutation = (_a7 = class extends Removable {
2096
+ constructor(config) {
2097
+ super();
2098
+ __privateAdd(this, _Mutation_instances);
2099
+ __privateAdd(this, _client3);
2100
+ __privateAdd(this, _observers);
2101
+ __privateAdd(this, _mutationCache);
2102
+ __privateAdd(this, _retryer2);
2103
+ __privateSet(this, _client3, config.client);
2104
+ this.mutationId = config.mutationId;
2105
+ __privateSet(this, _mutationCache, config.mutationCache);
2106
+ __privateSet(this, _observers, []);
2107
+ this.state = config.state || getDefaultState2();
2108
+ this.setOptions(config.options);
2109
+ this.scheduleGc();
2110
+ }
2111
+ setOptions(options) {
2112
+ this.options = options;
2113
+ this.updateGcTime(this.options.gcTime);
2114
+ }
2115
+ get meta() {
2116
+ return this.options.meta;
2117
+ }
2118
+ addObserver(observer) {
2119
+ if (!__privateGet(this, _observers).includes(observer)) {
2120
+ __privateGet(this, _observers).push(observer);
2121
+ this.clearGcTimeout();
2122
+ __privateGet(this, _mutationCache).notify({
2123
+ type: "observerAdded",
2124
+ mutation: this,
2125
+ observer
2126
+ });
2127
+ }
2128
+ }
2129
+ removeObserver(observer) {
2130
+ __privateSet(this, _observers, __privateGet(this, _observers).filter((x3) => x3 !== observer));
2131
+ this.scheduleGc();
2132
+ __privateGet(this, _mutationCache).notify({
2133
+ type: "observerRemoved",
2134
+ mutation: this,
2135
+ observer
2136
+ });
2137
+ }
2138
+ optionalRemove() {
2139
+ if (!__privateGet(this, _observers).length) {
2140
+ if (this.state.status === "pending") {
2141
+ this.scheduleGc();
2142
+ } else {
2143
+ __privateGet(this, _mutationCache).remove(this);
2144
+ }
2145
+ }
2146
+ }
2147
+ continue() {
2148
+ return __privateGet(this, _retryer2)?.continue() ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
2149
+ this.execute(this.state.variables);
2150
+ }
2151
+ async execute(variables) {
2152
+ const onContinue = () => {
2153
+ __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "continue" });
2154
+ };
2155
+ const mutationFnContext = {
2156
+ client: __privateGet(this, _client3),
2157
+ meta: this.options.meta,
2158
+ mutationKey: this.options.mutationKey
2159
+ };
2160
+ __privateSet(this, _retryer2, createRetryer({
2161
+ fn: () => {
2162
+ if (!this.options.mutationFn) {
2163
+ return Promise.reject(new Error("No mutationFn found"));
2164
+ }
2165
+ return this.options.mutationFn(variables, mutationFnContext);
2166
+ },
2167
+ onFail: (failureCount, error) => {
2168
+ __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "failed", failureCount, error });
2169
+ },
2170
+ onPause: () => {
2171
+ __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "pause" });
2172
+ },
2173
+ onContinue,
2174
+ retry: this.options.retry ?? 0,
2175
+ retryDelay: this.options.retryDelay,
2176
+ networkMode: this.options.networkMode,
2177
+ canRun: () => __privateGet(this, _mutationCache).canRun(this)
2178
+ }));
2179
+ const restored = this.state.status === "pending";
2180
+ const isPaused = !__privateGet(this, _retryer2).canStart();
2181
+ try {
2182
+ if (restored) {
2183
+ onContinue();
2184
+ } else {
2185
+ __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "pending", variables, isPaused });
2186
+ if (__privateGet(this, _mutationCache).config.onMutate) {
2187
+ await __privateGet(this, _mutationCache).config.onMutate(
2188
+ variables,
2189
+ this,
2190
+ mutationFnContext
2191
+ );
2192
+ }
2193
+ const context = await this.options.onMutate?.(
2194
+ variables,
2195
+ mutationFnContext
2196
+ );
2197
+ if (context !== this.state.context) {
2198
+ __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, {
2199
+ type: "pending",
2200
+ context,
2201
+ variables,
2202
+ isPaused
2203
+ });
2204
+ }
2205
+ }
2206
+ const data = await __privateGet(this, _retryer2).start();
2207
+ await __privateGet(this, _mutationCache).config.onSuccess?.(
2208
+ data,
2209
+ variables,
2210
+ this.state.context,
2211
+ this,
2212
+ mutationFnContext
2213
+ );
2214
+ await this.options.onSuccess?.(
2215
+ data,
2216
+ variables,
2217
+ this.state.context,
2218
+ mutationFnContext
2219
+ );
2220
+ await __privateGet(this, _mutationCache).config.onSettled?.(
2221
+ data,
2222
+ null,
2223
+ this.state.variables,
2224
+ this.state.context,
2225
+ this,
2226
+ mutationFnContext
2227
+ );
2228
+ await this.options.onSettled?.(
2229
+ data,
2230
+ null,
2231
+ variables,
2232
+ this.state.context,
2233
+ mutationFnContext
2234
+ );
2235
+ __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "success", data });
2236
+ return data;
2237
+ } catch (error) {
2238
+ try {
2239
+ await __privateGet(this, _mutationCache).config.onError?.(
2240
+ error,
2241
+ variables,
2242
+ this.state.context,
2243
+ this,
2244
+ mutationFnContext
2245
+ );
2246
+ } catch (e3) {
2247
+ void Promise.reject(e3);
2248
+ }
2249
+ try {
2250
+ await this.options.onError?.(
2251
+ error,
2252
+ variables,
2253
+ this.state.context,
2254
+ mutationFnContext
2255
+ );
2256
+ } catch (e3) {
2257
+ void Promise.reject(e3);
2258
+ }
2259
+ try {
2260
+ await __privateGet(this, _mutationCache).config.onSettled?.(
2261
+ void 0,
2262
+ error,
2263
+ this.state.variables,
2264
+ this.state.context,
2265
+ this,
2266
+ mutationFnContext
2267
+ );
2268
+ } catch (e3) {
2269
+ void Promise.reject(e3);
2270
+ }
2271
+ try {
2272
+ await this.options.onSettled?.(
2273
+ void 0,
2274
+ error,
2275
+ variables,
2276
+ this.state.context,
2277
+ mutationFnContext
2278
+ );
2279
+ } catch (e3) {
2280
+ void Promise.reject(e3);
2281
+ }
2282
+ __privateMethod(this, _Mutation_instances, dispatch_fn2).call(this, { type: "error", error });
2283
+ throw error;
2284
+ } finally {
2285
+ __privateGet(this, _mutationCache).runNext(this);
2286
+ }
2287
+ }
2288
+ }, _client3 = new WeakMap(), _observers = new WeakMap(), _mutationCache = new WeakMap(), _retryer2 = new WeakMap(), _Mutation_instances = new WeakSet(), dispatch_fn2 = function(action) {
2289
+ const reducer = (state) => {
2290
+ switch (action.type) {
2291
+ case "failed":
2292
+ return {
2293
+ ...state,
2294
+ failureCount: action.failureCount,
2295
+ failureReason: action.error
2296
+ };
2297
+ case "pause":
2298
+ return {
2299
+ ...state,
2300
+ isPaused: true
2301
+ };
2302
+ case "continue":
2303
+ return {
2304
+ ...state,
2305
+ isPaused: false
2306
+ };
2307
+ case "pending":
2308
+ return {
2309
+ ...state,
2310
+ context: action.context,
2311
+ data: void 0,
2312
+ failureCount: 0,
2313
+ failureReason: null,
2314
+ error: null,
2315
+ isPaused: action.isPaused,
2316
+ status: "pending",
2317
+ variables: action.variables,
2318
+ submittedAt: Date.now()
2319
+ };
2320
+ case "success":
2321
+ return {
2322
+ ...state,
2323
+ data: action.data,
2324
+ failureCount: 0,
2325
+ failureReason: null,
2326
+ error: null,
2327
+ status: "success",
2328
+ isPaused: false
2329
+ };
2330
+ case "error":
2331
+ return {
2332
+ ...state,
2333
+ data: void 0,
2334
+ error: action.error,
2335
+ failureCount: state.failureCount + 1,
2336
+ failureReason: action.error,
2337
+ isPaused: false,
2338
+ status: "error"
2339
+ };
2340
+ }
2341
+ };
2342
+ this.state = reducer(this.state);
2343
+ notifyManager.batch(() => {
2344
+ __privateGet(this, _observers).forEach((observer) => {
2345
+ observer.onMutationUpdate(action);
2346
+ });
2347
+ __privateGet(this, _mutationCache).notify({
2348
+ mutation: this,
2349
+ type: "updated",
2350
+ action
2351
+ });
2352
+ });
2353
+ }, _a7);
2354
+ function getDefaultState2() {
2355
+ return {
2356
+ context: void 0,
2357
+ data: void 0,
2358
+ error: null,
2359
+ failureCount: 0,
2360
+ failureReason: null,
2361
+ isPaused: false,
2362
+ status: "idle",
2363
+ variables: void 0,
2364
+ submittedAt: 0
2365
+ };
2366
+ }
2367
+
2368
+ // node_modules/@tanstack/query-core/build/modern/mutationCache.js
2369
+ var _mutations, _scopes, _mutationId, _a8;
2370
+ var MutationCache = (_a8 = class extends Subscribable {
2371
+ constructor(config = {}) {
2372
+ super();
2373
+ __privateAdd(this, _mutations);
2374
+ __privateAdd(this, _scopes);
2375
+ __privateAdd(this, _mutationId);
2376
+ this.config = config;
2377
+ __privateSet(this, _mutations, /* @__PURE__ */ new Set());
2378
+ __privateSet(this, _scopes, /* @__PURE__ */ new Map());
2379
+ __privateSet(this, _mutationId, 0);
2380
+ }
2381
+ build(client, options, state) {
2382
+ const mutation = new Mutation({
2383
+ client,
2384
+ mutationCache: this,
2385
+ mutationId: ++__privateWrapper(this, _mutationId)._,
2386
+ options: client.defaultMutationOptions(options),
2387
+ state
2388
+ });
2389
+ this.add(mutation);
2390
+ return mutation;
2391
+ }
2392
+ add(mutation) {
2393
+ __privateGet(this, _mutations).add(mutation);
2394
+ const scope = scopeFor(mutation);
2395
+ if (typeof scope === "string") {
2396
+ const scopedMutations = __privateGet(this, _scopes).get(scope);
2397
+ if (scopedMutations) {
2398
+ scopedMutations.push(mutation);
2399
+ } else {
2400
+ __privateGet(this, _scopes).set(scope, [mutation]);
2401
+ }
2402
+ }
2403
+ this.notify({ type: "added", mutation });
2404
+ }
2405
+ remove(mutation) {
2406
+ if (__privateGet(this, _mutations).delete(mutation)) {
2407
+ const scope = scopeFor(mutation);
2408
+ if (typeof scope === "string") {
2409
+ const scopedMutations = __privateGet(this, _scopes).get(scope);
2410
+ if (scopedMutations) {
2411
+ if (scopedMutations.length > 1) {
2412
+ const index = scopedMutations.indexOf(mutation);
2413
+ if (index !== -1) {
2414
+ scopedMutations.splice(index, 1);
2415
+ }
2416
+ } else if (scopedMutations[0] === mutation) {
2417
+ __privateGet(this, _scopes).delete(scope);
2418
+ }
2419
+ }
2420
+ }
2421
+ }
2422
+ this.notify({ type: "removed", mutation });
2423
+ }
2424
+ canRun(mutation) {
2425
+ const scope = scopeFor(mutation);
2426
+ if (typeof scope === "string") {
2427
+ const mutationsWithSameScope = __privateGet(this, _scopes).get(scope);
2428
+ const firstPendingMutation = mutationsWithSameScope?.find(
2429
+ (m3) => m3.state.status === "pending"
2430
+ );
2431
+ return !firstPendingMutation || firstPendingMutation === mutation;
2432
+ } else {
2433
+ return true;
2434
+ }
2435
+ }
2436
+ runNext(mutation) {
2437
+ const scope = scopeFor(mutation);
2438
+ if (typeof scope === "string") {
2439
+ const foundMutation = __privateGet(this, _scopes).get(scope)?.find((m3) => m3 !== mutation && m3.state.isPaused);
2440
+ return foundMutation?.continue() ?? Promise.resolve();
2441
+ } else {
2442
+ return Promise.resolve();
2443
+ }
2444
+ }
2445
+ clear() {
2446
+ notifyManager.batch(() => {
2447
+ __privateGet(this, _mutations).forEach((mutation) => {
2448
+ this.notify({ type: "removed", mutation });
2449
+ });
2450
+ __privateGet(this, _mutations).clear();
2451
+ __privateGet(this, _scopes).clear();
2452
+ });
2453
+ }
2454
+ getAll() {
2455
+ return Array.from(__privateGet(this, _mutations));
2456
+ }
2457
+ find(filters) {
2458
+ const defaultedFilters = { exact: true, ...filters };
2459
+ return this.getAll().find(
2460
+ (mutation) => matchMutation(defaultedFilters, mutation)
2461
+ );
2462
+ }
2463
+ findAll(filters = {}) {
2464
+ return this.getAll().filter((mutation) => matchMutation(filters, mutation));
2465
+ }
2466
+ notify(event) {
2467
+ notifyManager.batch(() => {
2468
+ this.listeners.forEach((listener) => {
2469
+ listener(event);
2470
+ });
2471
+ });
2472
+ }
2473
+ resumePausedMutations() {
2474
+ const pausedMutations = this.getAll().filter((x3) => x3.state.isPaused);
2475
+ return notifyManager.batch(
2476
+ () => Promise.all(
2477
+ pausedMutations.map((mutation) => mutation.continue().catch(noop))
2478
+ )
2479
+ );
2480
+ }
2481
+ }, _mutations = new WeakMap(), _scopes = new WeakMap(), _mutationId = new WeakMap(), _a8);
2482
+ function scopeFor(mutation) {
2483
+ return mutation.options.scope?.id;
2484
+ }
2485
+
2486
+ // node_modules/@tanstack/query-core/build/modern/mutationObserver.js
2487
+ var _client4, _currentResult2, _currentMutation, _mutateOptions, _MutationObserver_instances, updateResult_fn, notify_fn2, _a9;
2488
+ var MutationObserver = (_a9 = class extends Subscribable {
2489
+ constructor(client, options) {
2490
+ super();
2491
+ __privateAdd(this, _MutationObserver_instances);
2492
+ __privateAdd(this, _client4);
2493
+ __privateAdd(this, _currentResult2);
2494
+ __privateAdd(this, _currentMutation);
2495
+ __privateAdd(this, _mutateOptions);
2496
+ __privateSet(this, _client4, client);
2497
+ this.setOptions(options);
2498
+ this.bindMethods();
2499
+ __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
2500
+ }
2501
+ bindMethods() {
2502
+ this.mutate = this.mutate.bind(this);
2503
+ this.reset = this.reset.bind(this);
2504
+ }
2505
+ setOptions(options) {
2506
+ const prevOptions = this.options;
2507
+ this.options = __privateGet(this, _client4).defaultMutationOptions(options);
2508
+ if (!shallowEqualObjects(this.options, prevOptions)) {
2509
+ __privateGet(this, _client4).getMutationCache().notify({
2510
+ type: "observerOptionsUpdated",
2511
+ mutation: __privateGet(this, _currentMutation),
2512
+ observer: this
2513
+ });
2514
+ }
2515
+ if (prevOptions?.mutationKey && this.options.mutationKey && hashKey(prevOptions.mutationKey) !== hashKey(this.options.mutationKey)) {
2516
+ this.reset();
2517
+ } else if (__privateGet(this, _currentMutation)?.state.status === "pending") {
2518
+ __privateGet(this, _currentMutation).setOptions(this.options);
2519
+ }
2520
+ }
2521
+ onUnsubscribe() {
2522
+ if (!this.hasListeners()) {
2523
+ __privateGet(this, _currentMutation)?.removeObserver(this);
2524
+ }
2525
+ }
2526
+ onMutationUpdate(action) {
2527
+ __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
2528
+ __privateMethod(this, _MutationObserver_instances, notify_fn2).call(this, action);
2529
+ }
2530
+ getCurrentResult() {
2531
+ return __privateGet(this, _currentResult2);
2532
+ }
2533
+ reset() {
2534
+ __privateGet(this, _currentMutation)?.removeObserver(this);
2535
+ __privateSet(this, _currentMutation, void 0);
2536
+ __privateMethod(this, _MutationObserver_instances, updateResult_fn).call(this);
2537
+ __privateMethod(this, _MutationObserver_instances, notify_fn2).call(this);
2538
+ }
2539
+ mutate(variables, options) {
2540
+ __privateSet(this, _mutateOptions, options);
2541
+ __privateGet(this, _currentMutation)?.removeObserver(this);
2542
+ __privateSet(this, _currentMutation, __privateGet(this, _client4).getMutationCache().build(__privateGet(this, _client4), this.options));
2543
+ __privateGet(this, _currentMutation).addObserver(this);
2544
+ return __privateGet(this, _currentMutation).execute(variables);
2545
+ }
2546
+ }, _client4 = new WeakMap(), _currentResult2 = new WeakMap(), _currentMutation = new WeakMap(), _mutateOptions = new WeakMap(), _MutationObserver_instances = new WeakSet(), updateResult_fn = function() {
2547
+ const state = __privateGet(this, _currentMutation)?.state ?? getDefaultState2();
2548
+ __privateSet(this, _currentResult2, {
2549
+ ...state,
2550
+ isPending: state.status === "pending",
2551
+ isSuccess: state.status === "success",
2552
+ isError: state.status === "error",
2553
+ isIdle: state.status === "idle",
2554
+ mutate: this.mutate,
2555
+ reset: this.reset
2556
+ });
2557
+ }, notify_fn2 = function(action) {
2558
+ notifyManager.batch(() => {
2559
+ if (__privateGet(this, _mutateOptions) && this.hasListeners()) {
2560
+ const variables = __privateGet(this, _currentResult2).variables;
2561
+ const onMutateResult = __privateGet(this, _currentResult2).context;
2562
+ const context = {
2563
+ client: __privateGet(this, _client4),
2564
+ meta: this.options.meta,
2565
+ mutationKey: this.options.mutationKey
2566
+ };
2567
+ if (action?.type === "success") {
2568
+ try {
2569
+ __privateGet(this, _mutateOptions).onSuccess?.(
2570
+ action.data,
2571
+ variables,
2572
+ onMutateResult,
2573
+ context
2574
+ );
2575
+ } catch (e3) {
2576
+ void Promise.reject(e3);
2577
+ }
2578
+ try {
2579
+ __privateGet(this, _mutateOptions).onSettled?.(
2580
+ action.data,
2581
+ null,
2582
+ variables,
2583
+ onMutateResult,
2584
+ context
2585
+ );
2586
+ } catch (e3) {
2587
+ void Promise.reject(e3);
2588
+ }
2589
+ } else if (action?.type === "error") {
2590
+ try {
2591
+ __privateGet(this, _mutateOptions).onError?.(
2592
+ action.error,
2593
+ variables,
2594
+ onMutateResult,
2595
+ context
2596
+ );
2597
+ } catch (e3) {
2598
+ void Promise.reject(e3);
2599
+ }
2600
+ try {
2601
+ __privateGet(this, _mutateOptions).onSettled?.(
2602
+ void 0,
2603
+ action.error,
2604
+ variables,
2605
+ onMutateResult,
2606
+ context
2607
+ );
2608
+ } catch (e3) {
2609
+ void Promise.reject(e3);
2610
+ }
2611
+ }
2612
+ }
2613
+ this.listeners.forEach((listener) => {
2614
+ listener(__privateGet(this, _currentResult2));
2615
+ });
2616
+ });
2617
+ }, _a9);
2618
+
2619
+ // node_modules/@tanstack/query-core/build/modern/queryCache.js
2620
+ var _queries, _a10;
2621
+ var QueryCache = (_a10 = class extends Subscribable {
2622
+ constructor(config = {}) {
2623
+ super();
2624
+ __privateAdd(this, _queries);
2625
+ this.config = config;
2626
+ __privateSet(this, _queries, /* @__PURE__ */ new Map());
2627
+ }
2628
+ build(client, options, state) {
2629
+ const queryKey = options.queryKey;
2630
+ const queryHash = options.queryHash ?? hashQueryKeyByOptions(queryKey, options);
2631
+ let query = this.get(queryHash);
2632
+ if (!query) {
2633
+ query = new Query({
2634
+ client,
2635
+ queryKey,
2636
+ queryHash,
2637
+ options: client.defaultQueryOptions(options),
2638
+ state,
2639
+ defaultOptions: client.getQueryDefaults(queryKey)
2640
+ });
2641
+ this.add(query);
2642
+ }
2643
+ return query;
2644
+ }
2645
+ add(query) {
2646
+ if (!__privateGet(this, _queries).has(query.queryHash)) {
2647
+ __privateGet(this, _queries).set(query.queryHash, query);
2648
+ this.notify({
2649
+ type: "added",
2650
+ query
2651
+ });
2652
+ }
2653
+ }
2654
+ remove(query) {
2655
+ const queryInMap = __privateGet(this, _queries).get(query.queryHash);
2656
+ if (queryInMap) {
2657
+ query.destroy();
2658
+ if (queryInMap === query) {
2659
+ __privateGet(this, _queries).delete(query.queryHash);
2660
+ }
2661
+ this.notify({ type: "removed", query });
2662
+ }
2663
+ }
2664
+ clear() {
2665
+ notifyManager.batch(() => {
2666
+ this.getAll().forEach((query) => {
2667
+ this.remove(query);
2668
+ });
2669
+ });
2670
+ }
2671
+ get(queryHash) {
2672
+ return __privateGet(this, _queries).get(queryHash);
2673
+ }
2674
+ getAll() {
2675
+ return [...__privateGet(this, _queries).values()];
2676
+ }
2677
+ find(filters) {
2678
+ const defaultedFilters = { exact: true, ...filters };
2679
+ return this.getAll().find(
2680
+ (query) => matchQuery(defaultedFilters, query)
2681
+ );
2682
+ }
2683
+ findAll(filters = {}) {
2684
+ const queries = this.getAll();
2685
+ return Object.keys(filters).length > 0 ? queries.filter((query) => matchQuery(filters, query)) : queries;
2686
+ }
2687
+ notify(event) {
2688
+ notifyManager.batch(() => {
2689
+ this.listeners.forEach((listener) => {
2690
+ listener(event);
2691
+ });
2692
+ });
2693
+ }
2694
+ onFocus() {
2695
+ notifyManager.batch(() => {
2696
+ this.getAll().forEach((query) => {
2697
+ query.onFocus();
2698
+ });
2699
+ });
2700
+ }
2701
+ onOnline() {
2702
+ notifyManager.batch(() => {
2703
+ this.getAll().forEach((query) => {
2704
+ query.onOnline();
2705
+ });
2706
+ });
2707
+ }
2708
+ }, _queries = new WeakMap(), _a10);
2709
+
2710
+ // node_modules/@tanstack/query-core/build/modern/queryClient.js
2711
+ var _queryCache, _mutationCache2, _defaultOptions2, _queryDefaults, _mutationDefaults, _mountCount, _unsubscribeFocus, _unsubscribeOnline, _a11;
2712
+ var QueryClient = (_a11 = class {
2713
+ constructor(config = {}) {
2714
+ __privateAdd(this, _queryCache);
2715
+ __privateAdd(this, _mutationCache2);
2716
+ __privateAdd(this, _defaultOptions2);
2717
+ __privateAdd(this, _queryDefaults);
2718
+ __privateAdd(this, _mutationDefaults);
2719
+ __privateAdd(this, _mountCount);
2720
+ __privateAdd(this, _unsubscribeFocus);
2721
+ __privateAdd(this, _unsubscribeOnline);
2722
+ __privateSet(this, _queryCache, config.queryCache || new QueryCache());
2723
+ __privateSet(this, _mutationCache2, config.mutationCache || new MutationCache());
2724
+ __privateSet(this, _defaultOptions2, config.defaultOptions || {});
2725
+ __privateSet(this, _queryDefaults, /* @__PURE__ */ new Map());
2726
+ __privateSet(this, _mutationDefaults, /* @__PURE__ */ new Map());
2727
+ __privateSet(this, _mountCount, 0);
2728
+ }
2729
+ mount() {
2730
+ __privateWrapper(this, _mountCount)._++;
2731
+ if (__privateGet(this, _mountCount) !== 1) return;
2732
+ __privateSet(this, _unsubscribeFocus, focusManager.subscribe(async (focused) => {
2733
+ if (focused) {
2734
+ await this.resumePausedMutations();
2735
+ __privateGet(this, _queryCache).onFocus();
2736
+ }
2737
+ }));
2738
+ __privateSet(this, _unsubscribeOnline, onlineManager.subscribe(async (online) => {
2739
+ if (online) {
2740
+ await this.resumePausedMutations();
2741
+ __privateGet(this, _queryCache).onOnline();
2742
+ }
2743
+ }));
2744
+ }
2745
+ unmount() {
2746
+ var _a12, _b;
2747
+ __privateWrapper(this, _mountCount)._--;
2748
+ if (__privateGet(this, _mountCount) !== 0) return;
2749
+ (_a12 = __privateGet(this, _unsubscribeFocus)) == null ? void 0 : _a12.call(this);
2750
+ __privateSet(this, _unsubscribeFocus, void 0);
2751
+ (_b = __privateGet(this, _unsubscribeOnline)) == null ? void 0 : _b.call(this);
2752
+ __privateSet(this, _unsubscribeOnline, void 0);
2753
+ }
2754
+ isFetching(filters) {
2755
+ return __privateGet(this, _queryCache).findAll({ ...filters, fetchStatus: "fetching" }).length;
2756
+ }
2757
+ isMutating(filters) {
2758
+ return __privateGet(this, _mutationCache2).findAll({ ...filters, status: "pending" }).length;
2759
+ }
2760
+ /**
2761
+ * Imperative (non-reactive) way to retrieve data for a QueryKey.
2762
+ * Should only be used in callbacks or functions where reading the latest data is necessary, e.g. for optimistic updates.
2763
+ *
2764
+ * Hint: Do not use this function inside a component, because it won't receive updates.
2765
+ * Use `useQuery` to create a `QueryObserver` that subscribes to changes.
2766
+ */
2767
+ getQueryData(queryKey) {
2768
+ const options = this.defaultQueryOptions({ queryKey });
2769
+ return __privateGet(this, _queryCache).get(options.queryHash)?.state.data;
2770
+ }
2771
+ ensureQueryData(options) {
2772
+ const defaultedOptions = this.defaultQueryOptions(options);
2773
+ const query = __privateGet(this, _queryCache).build(this, defaultedOptions);
2774
+ const cachedData = query.state.data;
2775
+ if (cachedData === void 0) {
2776
+ return this.fetchQuery(options);
2777
+ }
2778
+ if (options.revalidateIfStale && query.isStaleByTime(resolveStaleTime(defaultedOptions.staleTime, query))) {
2779
+ void this.prefetchQuery(defaultedOptions);
2780
+ }
2781
+ return Promise.resolve(cachedData);
2782
+ }
2783
+ getQueriesData(filters) {
2784
+ return __privateGet(this, _queryCache).findAll(filters).map(({ queryKey, state }) => {
2785
+ const data = state.data;
2786
+ return [queryKey, data];
2787
+ });
2788
+ }
2789
+ setQueryData(queryKey, updater, options) {
2790
+ const defaultedOptions = this.defaultQueryOptions({ queryKey });
2791
+ const query = __privateGet(this, _queryCache).get(
2792
+ defaultedOptions.queryHash
2793
+ );
2794
+ const prevData = query?.state.data;
2795
+ const data = functionalUpdate(updater, prevData);
2796
+ if (data === void 0) {
2797
+ return void 0;
2798
+ }
2799
+ return __privateGet(this, _queryCache).build(this, defaultedOptions).setData(data, { ...options, manual: true });
2800
+ }
2801
+ setQueriesData(filters, updater, options) {
2802
+ return notifyManager.batch(
2803
+ () => __privateGet(this, _queryCache).findAll(filters).map(({ queryKey }) => [
2804
+ queryKey,
2805
+ this.setQueryData(queryKey, updater, options)
2806
+ ])
2807
+ );
2808
+ }
2809
+ getQueryState(queryKey) {
2810
+ const options = this.defaultQueryOptions({ queryKey });
2811
+ return __privateGet(this, _queryCache).get(
2812
+ options.queryHash
2813
+ )?.state;
2814
+ }
2815
+ removeQueries(filters) {
2816
+ const queryCache = __privateGet(this, _queryCache);
2817
+ notifyManager.batch(() => {
2818
+ queryCache.findAll(filters).forEach((query) => {
2819
+ queryCache.remove(query);
2820
+ });
2821
+ });
2822
+ }
2823
+ resetQueries(filters, options) {
2824
+ const queryCache = __privateGet(this, _queryCache);
2825
+ return notifyManager.batch(() => {
2826
+ queryCache.findAll(filters).forEach((query) => {
2827
+ query.reset();
2828
+ });
2829
+ return this.refetchQueries(
2830
+ {
2831
+ type: "active",
2832
+ ...filters
2833
+ },
2834
+ options
2835
+ );
2836
+ });
2837
+ }
2838
+ cancelQueries(filters, cancelOptions = {}) {
2839
+ const defaultedCancelOptions = { revert: true, ...cancelOptions };
2840
+ const promises = notifyManager.batch(
2841
+ () => __privateGet(this, _queryCache).findAll(filters).map((query) => query.cancel(defaultedCancelOptions))
2842
+ );
2843
+ return Promise.all(promises).then(noop).catch(noop);
2844
+ }
2845
+ invalidateQueries(filters, options = {}) {
2846
+ return notifyManager.batch(() => {
2847
+ __privateGet(this, _queryCache).findAll(filters).forEach((query) => {
2848
+ query.invalidate();
2849
+ });
2850
+ if (filters?.refetchType === "none") {
2851
+ return Promise.resolve();
2852
+ }
2853
+ return this.refetchQueries(
2854
+ {
2855
+ ...filters,
2856
+ type: filters?.refetchType ?? filters?.type ?? "active"
2857
+ },
2858
+ options
2859
+ );
2860
+ });
2861
+ }
2862
+ refetchQueries(filters, options = {}) {
2863
+ const fetchOptions = {
2864
+ ...options,
2865
+ cancelRefetch: options.cancelRefetch ?? true
2866
+ };
2867
+ const promises = notifyManager.batch(
2868
+ () => __privateGet(this, _queryCache).findAll(filters).filter((query) => !query.isDisabled() && !query.isStatic()).map((query) => {
2869
+ let promise = query.fetch(void 0, fetchOptions);
2870
+ if (!fetchOptions.throwOnError) {
2871
+ promise = promise.catch(noop);
2872
+ }
2873
+ return query.state.fetchStatus === "paused" ? Promise.resolve() : promise;
2874
+ })
2875
+ );
2876
+ return Promise.all(promises).then(noop);
2877
+ }
2878
+ fetchQuery(options) {
2879
+ const defaultedOptions = this.defaultQueryOptions(options);
2880
+ if (defaultedOptions.retry === void 0) {
2881
+ defaultedOptions.retry = false;
2882
+ }
2883
+ const query = __privateGet(this, _queryCache).build(this, defaultedOptions);
2884
+ return query.isStaleByTime(
2885
+ resolveStaleTime(defaultedOptions.staleTime, query)
2886
+ ) ? query.fetch(defaultedOptions) : Promise.resolve(query.state.data);
2887
+ }
2888
+ prefetchQuery(options) {
2889
+ return this.fetchQuery(options).then(noop).catch(noop);
2890
+ }
2891
+ fetchInfiniteQuery(options) {
2892
+ options._type = "infinite";
2893
+ return this.fetchQuery(options);
2894
+ }
2895
+ prefetchInfiniteQuery(options) {
2896
+ return this.fetchInfiniteQuery(options).then(noop).catch(noop);
2897
+ }
2898
+ ensureInfiniteQueryData(options) {
2899
+ options._type = "infinite";
2900
+ return this.ensureQueryData(options);
2901
+ }
2902
+ resumePausedMutations() {
2903
+ if (onlineManager.isOnline()) {
2904
+ return __privateGet(this, _mutationCache2).resumePausedMutations();
2905
+ }
2906
+ return Promise.resolve();
2907
+ }
2908
+ getQueryCache() {
2909
+ return __privateGet(this, _queryCache);
2910
+ }
2911
+ getMutationCache() {
2912
+ return __privateGet(this, _mutationCache2);
2913
+ }
2914
+ getDefaultOptions() {
2915
+ return __privateGet(this, _defaultOptions2);
2916
+ }
2917
+ setDefaultOptions(options) {
2918
+ __privateSet(this, _defaultOptions2, options);
2919
+ }
2920
+ setQueryDefaults(queryKey, options) {
2921
+ __privateGet(this, _queryDefaults).set(hashKey(queryKey), {
2922
+ queryKey,
2923
+ defaultOptions: options
2924
+ });
2925
+ }
2926
+ getQueryDefaults(queryKey) {
2927
+ const defaults = [...__privateGet(this, _queryDefaults).values()];
2928
+ const result = {};
2929
+ defaults.forEach((queryDefault) => {
2930
+ if (partialMatchKey(queryKey, queryDefault.queryKey)) {
2931
+ Object.assign(result, queryDefault.defaultOptions);
2932
+ }
2933
+ });
2934
+ return result;
2935
+ }
2936
+ setMutationDefaults(mutationKey, options) {
2937
+ __privateGet(this, _mutationDefaults).set(hashKey(mutationKey), {
2938
+ mutationKey,
2939
+ defaultOptions: options
2940
+ });
2941
+ }
2942
+ getMutationDefaults(mutationKey) {
2943
+ const defaults = [...__privateGet(this, _mutationDefaults).values()];
2944
+ const result = {};
2945
+ defaults.forEach((queryDefault) => {
2946
+ if (partialMatchKey(mutationKey, queryDefault.mutationKey)) {
2947
+ Object.assign(result, queryDefault.defaultOptions);
2948
+ }
2949
+ });
2950
+ return result;
2951
+ }
2952
+ defaultQueryOptions(options) {
2953
+ if (options._defaulted) {
2954
+ return options;
2955
+ }
2956
+ const defaultedOptions = {
2957
+ ...__privateGet(this, _defaultOptions2).queries,
2958
+ ...this.getQueryDefaults(options.queryKey),
2959
+ ...options,
2960
+ _defaulted: true
2961
+ };
2962
+ if (!defaultedOptions.queryHash) {
2963
+ defaultedOptions.queryHash = hashQueryKeyByOptions(
2964
+ defaultedOptions.queryKey,
2965
+ defaultedOptions
2966
+ );
2967
+ }
2968
+ if (defaultedOptions.refetchOnReconnect === void 0) {
2969
+ defaultedOptions.refetchOnReconnect = defaultedOptions.networkMode !== "always";
2970
+ }
2971
+ if (defaultedOptions.throwOnError === void 0) {
2972
+ defaultedOptions.throwOnError = !!defaultedOptions.suspense;
2973
+ }
2974
+ if (!defaultedOptions.networkMode && defaultedOptions.persister) {
2975
+ defaultedOptions.networkMode = "offlineFirst";
2976
+ }
2977
+ if (defaultedOptions.queryFn === skipToken) {
2978
+ defaultedOptions.enabled = false;
2979
+ }
2980
+ return defaultedOptions;
2981
+ }
2982
+ defaultMutationOptions(options) {
2983
+ if (options?._defaulted) {
2984
+ return options;
2985
+ }
2986
+ return {
2987
+ ...__privateGet(this, _defaultOptions2).mutations,
2988
+ ...options?.mutationKey && this.getMutationDefaults(options.mutationKey),
2989
+ ...options,
2990
+ _defaulted: true
2991
+ };
2992
+ }
2993
+ clear() {
2994
+ __privateGet(this, _queryCache).clear();
2995
+ __privateGet(this, _mutationCache2).clear();
2996
+ }
2997
+ }, _queryCache = new WeakMap(), _mutationCache2 = new WeakMap(), _defaultOptions2 = new WeakMap(), _queryDefaults = new WeakMap(), _mutationDefaults = new WeakMap(), _mountCount = new WeakMap(), _unsubscribeFocus = new WeakMap(), _unsubscribeOnline = new WeakMap(), _a11);
2998
+
2999
+ // node_modules/preact/hooks/dist/hooks.module.js
3000
+ var t2;
3001
+ var r2;
3002
+ var u2;
3003
+ var i2;
3004
+ var o2 = 0;
3005
+ var f2 = [];
3006
+ var c2 = l;
3007
+ var e2 = c2.__b;
3008
+ var a2 = c2.__r;
3009
+ var v2 = c2.diffed;
3010
+ var l2 = c2.__c;
3011
+ var m2 = c2.unmount;
3012
+ var s2 = c2.__;
3013
+ function p2(n2, t3) {
3014
+ c2.__h && c2.__h(r2, n2, o2 || t3), o2 = 0;
3015
+ var u4 = r2.__H || (r2.__H = { __: [], __h: [] });
3016
+ return n2 >= u4.__.length && u4.__.push({}), u4.__[n2];
3017
+ }
3018
+ function d2(n2) {
3019
+ return o2 = 1, h2(D2, n2);
3020
+ }
3021
+ function h2(n2, u4, i3) {
3022
+ var o3 = p2(t2++, 2);
3023
+ if (o3.t = n2, !o3.__c && (o3.__ = [i3 ? i3(u4) : D2(void 0, u4), function(n3) {
3024
+ var t3 = o3.__N ? o3.__N[0] : o3.__[0], r3 = o3.t(t3, n3);
3025
+ t3 !== r3 && (o3.__N = [r3, o3.__[1]], o3.__c.setState({}));
3026
+ }], o3.__c = r2, !r2.__f)) {
3027
+ var f4 = function(n3, t3, r3) {
3028
+ if (!o3.__c.__H) return true;
3029
+ var u5 = o3.__c.__H.__.filter(function(n4) {
3030
+ return n4.__c;
3031
+ });
3032
+ if (u5.every(function(n4) {
3033
+ return !n4.__N;
3034
+ })) return !c3 || c3.call(this, n3, t3, r3);
3035
+ var i4 = o3.__c.props !== n3;
3036
+ return u5.some(function(n4) {
3037
+ if (n4.__N) {
3038
+ var t4 = n4.__[0];
3039
+ n4.__ = n4.__N, n4.__N = void 0, t4 !== n4.__[0] && (i4 = true);
3040
+ }
3041
+ }), c3 && c3.call(this, n3, t3, r3) || i4;
3042
+ };
3043
+ r2.__f = true;
3044
+ var c3 = r2.shouldComponentUpdate, e3 = r2.componentWillUpdate;
3045
+ r2.componentWillUpdate = function(n3, t3, r3) {
3046
+ if (this.__e) {
3047
+ var u5 = c3;
3048
+ c3 = void 0, f4(n3, t3, r3), c3 = u5;
3049
+ }
3050
+ e3 && e3.call(this, n3, t3, r3);
3051
+ }, r2.shouldComponentUpdate = f4;
3052
+ }
3053
+ return o3.__N || o3.__;
3054
+ }
3055
+ function y2(n2, u4) {
3056
+ var i3 = p2(t2++, 3);
3057
+ !c2.__s && C2(i3.__H, u4) && (i3.__ = n2, i3.u = u4, r2.__H.__h.push(i3));
3058
+ }
3059
+ function _2(n2, u4) {
3060
+ var i3 = p2(t2++, 4);
3061
+ !c2.__s && C2(i3.__H, u4) && (i3.__ = n2, i3.u = u4, r2.__h.push(i3));
3062
+ }
3063
+ function A2(n2) {
3064
+ return o2 = 5, T2(function() {
3065
+ return { current: n2 };
3066
+ }, []);
3067
+ }
3068
+ function T2(n2, r3) {
3069
+ var u4 = p2(t2++, 7);
3070
+ return C2(u4.__H, r3) && (u4.__ = n2(), u4.__H = r3, u4.__h = n2), u4.__;
3071
+ }
3072
+ function q2(n2, t3) {
3073
+ return o2 = 8, T2(function() {
3074
+ return n2;
3075
+ }, t3);
3076
+ }
3077
+ function x2(n2) {
3078
+ var u4 = r2.context[n2.__c], i3 = p2(t2++, 9);
3079
+ return i3.c = n2, u4 ? (null == i3.__ && (i3.__ = true, u4.sub(r2)), u4.props.value) : n2.__;
3080
+ }
3081
+ function j2() {
3082
+ for (var n2; n2 = f2.shift(); ) {
3083
+ var t3 = n2.__H;
3084
+ if (n2.__P && t3) try {
3085
+ t3.__h.some(z2), t3.__h.some(B2), t3.__h = [];
3086
+ } catch (r3) {
3087
+ t3.__h = [], c2.__e(r3, n2.__v);
3088
+ }
3089
+ }
3090
+ }
3091
+ c2.__b = function(n2) {
3092
+ r2 = null, e2 && e2(n2);
3093
+ }, c2.__ = function(n2, t3) {
3094
+ n2 && t3.__k && t3.__k.__m && (n2.__m = t3.__k.__m), s2 && s2(n2, t3);
3095
+ }, c2.__r = function(n2) {
3096
+ a2 && a2(n2), t2 = 0;
3097
+ var i3 = (r2 = n2.__c).__H;
3098
+ i3 && (u2 === r2 ? (i3.__h = [], r2.__h = [], i3.__.some(function(n3) {
3099
+ n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = void 0;
3100
+ })) : (i3.__h.some(z2), i3.__h.some(B2), i3.__h = [], t2 = 0)), u2 = r2;
3101
+ }, c2.diffed = function(n2) {
3102
+ v2 && v2(n2);
3103
+ var t3 = n2.__c;
3104
+ t3 && t3.__H && (t3.__H.__h.length && (1 !== f2.push(t3) && i2 === c2.requestAnimationFrame || ((i2 = c2.requestAnimationFrame) || w2)(j2)), t3.__H.__.some(function(n3) {
3105
+ n3.u && (n3.__H = n3.u), n3.u = void 0;
3106
+ })), u2 = r2 = null;
3107
+ }, c2.__c = function(n2, t3) {
3108
+ t3.some(function(n3) {
3109
+ try {
3110
+ n3.__h.some(z2), n3.__h = n3.__h.filter(function(n4) {
3111
+ return !n4.__ || B2(n4);
3112
+ });
3113
+ } catch (r3) {
3114
+ t3.some(function(n4) {
3115
+ n4.__h && (n4.__h = []);
3116
+ }), t3 = [], c2.__e(r3, n3.__v);
3117
+ }
3118
+ }), l2 && l2(n2, t3);
3119
+ }, c2.unmount = function(n2) {
3120
+ m2 && m2(n2);
3121
+ var t3, r3 = n2.__c;
3122
+ r3 && r3.__H && (r3.__H.__.some(function(n3) {
3123
+ try {
3124
+ z2(n3);
3125
+ } catch (n4) {
3126
+ t3 = n4;
3127
+ }
3128
+ }), r3.__H = void 0, t3 && c2.__e(t3, r3.__v));
3129
+ };
3130
+ var k2 = "function" == typeof requestAnimationFrame;
3131
+ function w2(n2) {
3132
+ var t3, r3 = function() {
3133
+ clearTimeout(u4), k2 && cancelAnimationFrame(t3), setTimeout(n2);
3134
+ }, u4 = setTimeout(r3, 35);
3135
+ k2 && (t3 = requestAnimationFrame(r3));
3136
+ }
3137
+ function z2(n2) {
3138
+ var t3 = r2, u4 = n2.__c;
3139
+ "function" == typeof u4 && (n2.__c = void 0, u4()), r2 = t3;
3140
+ }
3141
+ function B2(n2) {
3142
+ var t3 = r2;
3143
+ n2.__c = n2.__(), r2 = t3;
3144
+ }
3145
+ function C2(n2, t3) {
3146
+ return !n2 || n2.length !== t3.length || t3.some(function(t4, r3) {
3147
+ return t4 !== n2[r3];
3148
+ });
3149
+ }
3150
+ function D2(n2, t3) {
3151
+ return "function" == typeof t3 ? t3(n2) : t3;
3152
+ }
3153
+
3154
+ // node_modules/@tanstack/preact-query/build/modern/IsRestoringProvider.js
3155
+ var IsRestoringContext = R(false);
3156
+ var useIsRestoring = () => x2(IsRestoringContext);
3157
+ var IsRestoringProvider = IsRestoringContext.Provider;
3158
+
3159
+ // node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
3160
+ var f3 = 0;
3161
+ function u3(e3, t3, n2, o3, i3, u4) {
3162
+ t3 || (t3 = {});
3163
+ var a3, c3, p3 = t3;
3164
+ if ("ref" in p3) for (c3 in p3 = {}, t3) "ref" == c3 ? a3 = t3[c3] : p3[c3] = t3[c3];
3165
+ var l3 = { type: e3, props: p3, key: n2, ref: a3, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --f3, __i: -1, __u: 0, __source: i3, __self: u4 };
3166
+ if ("function" == typeof e3 && (a3 = e3.defaultProps)) for (c3 in a3) void 0 === p3[c3] && (p3[c3] = a3[c3]);
3167
+ return l.vnode && l.vnode(l3), l3;
3168
+ }
3169
+
3170
+ // node_modules/@tanstack/preact-query/build/modern/QueryClientProvider.js
3171
+ var QueryClientContext = R(
3172
+ void 0
3173
+ );
3174
+ var useQueryClient = (queryClient2) => {
3175
+ const client = x2(QueryClientContext);
3176
+ if (queryClient2) {
3177
+ return queryClient2;
3178
+ }
3179
+ if (!client) {
3180
+ throw new Error("No QueryClient set, use QueryClientProvider to set one");
3181
+ }
3182
+ return client;
3183
+ };
3184
+ var QueryClientProvider = ({
3185
+ client,
3186
+ children
3187
+ }) => {
3188
+ y2(() => {
3189
+ client.mount();
3190
+ return () => {
3191
+ client.unmount();
3192
+ };
3193
+ }, [client]);
3194
+ return /* @__PURE__ */ u3(QueryClientContext.Provider, { value: client, children });
3195
+ };
3196
+
3197
+ // node_modules/@tanstack/preact-query/build/modern/QueryErrorResetBoundary.js
3198
+ function createValue() {
3199
+ let isReset = false;
3200
+ return {
3201
+ clearReset: () => {
3202
+ isReset = false;
3203
+ },
3204
+ reset: () => {
3205
+ isReset = true;
3206
+ },
3207
+ isReset: () => {
3208
+ return isReset;
3209
+ }
3210
+ };
3211
+ }
3212
+ var QueryErrorResetBoundaryContext = R(createValue());
3213
+ var useQueryErrorResetBoundary = () => x2(QueryErrorResetBoundaryContext);
3214
+
3215
+ // node_modules/@tanstack/preact-query/build/modern/errorBoundaryUtils.js
3216
+ var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary) => {
3217
+ if (options.suspense || options.throwOnError || options.experimental_prefetchInRender) {
3218
+ if (!errorResetBoundary.isReset()) {
3219
+ options.retryOnMount = false;
3220
+ }
3221
+ }
3222
+ };
3223
+ var useClearResetErrorBoundary = (errorResetBoundary) => {
3224
+ y2(() => {
3225
+ errorResetBoundary.clearReset();
3226
+ }, [errorResetBoundary]);
3227
+ };
3228
+ var getHasError = ({
3229
+ result,
3230
+ errorResetBoundary,
3231
+ throwOnError,
3232
+ query,
3233
+ suspense
3234
+ }) => {
3235
+ return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === void 0 || shouldThrowError(throwOnError, [result.error, query]));
3236
+ };
3237
+
3238
+ // node_modules/@tanstack/preact-query/build/modern/suspense.js
3239
+ var ensureSuspenseTimers = (defaultedOptions) => {
3240
+ if (defaultedOptions.suspense) {
3241
+ const MIN_SUSPENSE_TIME_MS = 1e3;
3242
+ const clamp = (value) => value === "static" ? value : Math.max(value ?? MIN_SUSPENSE_TIME_MS, MIN_SUSPENSE_TIME_MS);
3243
+ const originalStaleTime = defaultedOptions.staleTime;
3244
+ defaultedOptions.staleTime = typeof originalStaleTime === "function" ? (...args) => clamp(originalStaleTime(...args)) : clamp(originalStaleTime);
3245
+ if (typeof defaultedOptions.gcTime === "number") {
3246
+ defaultedOptions.gcTime = Math.max(
3247
+ defaultedOptions.gcTime,
3248
+ MIN_SUSPENSE_TIME_MS
3249
+ );
3250
+ }
3251
+ }
3252
+ };
3253
+ var willFetch = (result, isRestoring) => result.isLoading && result.isFetching && !isRestoring;
3254
+ var shouldSuspend = (defaultedOptions, result) => defaultedOptions?.suspense && result.isPending;
3255
+ var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observer.fetchOptimistic(defaultedOptions).catch(() => {
3256
+ errorResetBoundary.clearReset();
3257
+ });
3258
+
3259
+ // node_modules/@tanstack/preact-query/build/modern/utils.js
3260
+ function useSyncExternalStore(subscribe, getSnapshot) {
3261
+ const value = getSnapshot();
3262
+ const [{ _instance }, forceUpdate] = d2({
3263
+ _instance: { _value: value, _getSnapshot: getSnapshot }
3264
+ });
3265
+ _2(() => {
3266
+ _instance._value = value;
3267
+ _instance._getSnapshot = getSnapshot;
3268
+ if (didSnapshotChange(_instance)) {
3269
+ forceUpdate({ _instance });
3270
+ }
3271
+ }, [subscribe, value, getSnapshot]);
3272
+ y2(() => {
3273
+ if (didSnapshotChange(_instance)) {
3274
+ forceUpdate({ _instance });
3275
+ }
3276
+ return subscribe(() => {
3277
+ if (didSnapshotChange(_instance)) {
3278
+ forceUpdate({ _instance });
3279
+ }
3280
+ });
3281
+ }, [subscribe]);
3282
+ return value;
3283
+ }
3284
+ function didSnapshotChange(inst) {
3285
+ const latestGetSnapshot = inst._getSnapshot;
3286
+ const prevValue = inst._value;
3287
+ try {
3288
+ const nextValue = latestGetSnapshot();
3289
+ return !Object.is(prevValue, nextValue);
3290
+ } catch (_error) {
3291
+ return true;
3292
+ }
3293
+ }
3294
+
3295
+ // node_modules/@tanstack/preact-query/build/modern/useBaseQuery.js
3296
+ function useBaseQuery(options, Observer, queryClient2) {
3297
+ if (true) {
3298
+ if (typeof options !== "object" || Array.isArray(options)) {
3299
+ throw new Error(
3300
+ 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
3301
+ );
3302
+ }
3303
+ }
3304
+ const isRestoring = useIsRestoring();
3305
+ const errorResetBoundary = useQueryErrorResetBoundary();
3306
+ const client = useQueryClient(queryClient2);
3307
+ const defaultedOptions = client.defaultQueryOptions(options);
3308
+ client.getDefaultOptions().queries?._experimental_beforeQuery?.(
3309
+ defaultedOptions
3310
+ );
3311
+ if (true) {
3312
+ if (!defaultedOptions.queryFn) {
3313
+ console.error(
3314
+ `[${defaultedOptions.queryHash}]: No queryFn was passed as an option, and no default queryFn was found. The queryFn parameter is only optional when using a default queryFn. More info here: https://tanstack.com/query/latest/docs/framework/react/guides/default-query-function`
3315
+ );
3316
+ }
3317
+ }
3318
+ defaultedOptions._optimisticResults = isRestoring ? "isRestoring" : "optimistic";
3319
+ ensureSuspenseTimers(defaultedOptions);
3320
+ ensurePreventErrorBoundaryRetry(defaultedOptions, errorResetBoundary);
3321
+ useClearResetErrorBoundary(errorResetBoundary);
3322
+ const isNewCacheEntry = !client.getQueryCache().get(defaultedOptions.queryHash);
3323
+ const [observer] = d2(
3324
+ () => new Observer(
3325
+ client,
3326
+ defaultedOptions
3327
+ )
3328
+ );
3329
+ const result = observer.getOptimisticResult(defaultedOptions);
3330
+ const shouldSubscribe = !isRestoring && options.subscribed !== false;
3331
+ useSyncExternalStore(
3332
+ q2(
3333
+ (onStoreChange) => {
3334
+ const unsubscribe = shouldSubscribe ? observer.subscribe(notifyManager.batchCalls(onStoreChange)) : noop;
3335
+ observer.updateResult();
3336
+ return unsubscribe;
3337
+ },
3338
+ [observer, shouldSubscribe]
3339
+ ),
3340
+ () => observer.getCurrentResult()
3341
+ );
3342
+ y2(() => {
3343
+ observer.setOptions(defaultedOptions);
3344
+ }, [defaultedOptions, observer]);
3345
+ if (shouldSuspend(defaultedOptions, result)) {
3346
+ throw fetchOptimistic(defaultedOptions, observer, errorResetBoundary);
3347
+ }
3348
+ if (getHasError({
3349
+ result,
3350
+ errorResetBoundary,
3351
+ throwOnError: defaultedOptions.throwOnError,
3352
+ query: client.getQueryCache().get(defaultedOptions.queryHash),
3353
+ suspense: defaultedOptions.suspense
3354
+ })) {
3355
+ throw result.error;
3356
+ }
3357
+ ;
3358
+ client.getDefaultOptions().queries?._experimental_afterQuery?.(
3359
+ defaultedOptions,
3360
+ result
3361
+ );
3362
+ if (defaultedOptions.experimental_prefetchInRender && !environmentManager.isServer() && willFetch(result, isRestoring)) {
3363
+ const promise = isNewCacheEntry ? (
3364
+ // Fetch immediately on render in order to ensure `.promise` is resolved even if the component is unmounted
3365
+ fetchOptimistic(defaultedOptions, observer, errorResetBoundary)
3366
+ ) : (
3367
+ // subscribe to the "cache promise" so that we can finalize the currentThenable once data comes in
3368
+ client.getQueryCache().get(defaultedOptions.queryHash)?.promise
3369
+ );
3370
+ promise?.catch(noop).finally(() => {
3371
+ observer.updateResult();
3372
+ });
3373
+ }
3374
+ return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
3375
+ }
3376
+
3377
+ // node_modules/@tanstack/preact-query/build/modern/useQuery.js
3378
+ function useQuery(options, queryClient2) {
3379
+ return useBaseQuery(options, QueryObserver, queryClient2);
3380
+ }
3381
+
3382
+ // node_modules/@tanstack/preact-query/build/modern/useMutation.js
3383
+ function useMutation(options, queryClient2) {
3384
+ const client = useQueryClient(queryClient2);
3385
+ const [observer] = d2(
3386
+ () => new MutationObserver(
3387
+ client,
3388
+ options
3389
+ )
3390
+ );
3391
+ y2(() => {
3392
+ observer.setOptions(options);
3393
+ }, [observer, options]);
3394
+ const result = useSyncExternalStore(
3395
+ q2(
3396
+ (onStoreChange) => observer.subscribe(notifyManager.batchCalls(onStoreChange)),
3397
+ [observer]
3398
+ ),
3399
+ () => observer.getCurrentResult()
3400
+ );
3401
+ const mutate = q2(
3402
+ (variables, mutateOptions) => {
3403
+ observer.mutate(variables, mutateOptions).catch(noop);
3404
+ },
3405
+ [observer]
3406
+ );
3407
+ if (result.error && shouldThrowError(observer.options.throwOnError, [result.error])) {
3408
+ throw result.error;
3409
+ }
3410
+ return { ...result, mutate, mutateAsync: result.mutate };
3411
+ }
3412
+
3413
+ // node_modules/@tanstack/preact-query/build/modern/useInfiniteQuery.js
3414
+ function useInfiniteQuery(options, queryClient2) {
3415
+ return useBaseQuery(
3416
+ options,
3417
+ InfiniteQueryObserver,
3418
+ queryClient2
3419
+ );
3420
+ }
3421
+
3422
+ // app/assets/typescript/profiler/api-fetcher.ts
3423
+ async function apiFetch(config) {
3424
+ const { url, method, params, data, headers = {}, signal } = config;
3425
+ const qs = params ? "?" + new URLSearchParams(Object.entries(params).map(([k3, v3]) => [k3, String(v3)])).toString() : "";
3426
+ const res = await fetch(url + qs, {
3427
+ method,
3428
+ signal,
3429
+ headers: data !== void 0 ? { "Content-Type": "application/json", ...headers } : headers,
3430
+ body: data !== void 0 ? JSON.stringify(data) : void 0
3431
+ });
3432
+ if (res.status === 204) return {};
3433
+ const json = await res.json();
3434
+ if (!res.ok) {
3435
+ throw Object.assign(new Error(json?.error ?? `HTTP ${res.status}`), { status: res.status, data: json });
3436
+ }
3437
+ return json;
3438
+ }
3439
+
3440
+ // app/assets/typescript/profiler/generated/api.ts
3441
+ var listConsoles = (params, signal) => {
3442
+ return apiFetch(
3443
+ {
3444
+ url: `/_profiler/api/console`,
3445
+ method: "GET",
3446
+ params,
3447
+ signal
3448
+ }
3449
+ );
3450
+ };
3451
+ var getListConsolesInfiniteQueryKey = (params) => {
3452
+ return [
3453
+ "infinite",
3454
+ `/_profiler/api/console`,
3455
+ ...params ? [params] : []
3456
+ ];
3457
+ };
3458
+ var getListConsolesInfiniteQueryOptions = (params, options) => {
3459
+ const { query: queryOptions } = options ?? {};
3460
+ const queryKey = queryOptions?.queryKey ?? getListConsolesInfiniteQueryKey(params);
3461
+ const queryFn = ({ signal }) => listConsoles(params, signal);
3462
+ return { queryKey, queryFn, ...queryOptions };
3463
+ };
3464
+ function useListConsolesInfinite(params, options) {
3465
+ const queryOptions = getListConsolesInfiniteQueryOptions(params, options);
3466
+ const query = useInfiniteQuery(queryOptions);
3467
+ query.queryKey = queryOptions.queryKey;
3468
+ return query;
3469
+ }
3470
+ var deleteConsole = (id) => {
3471
+ return apiFetch(
3472
+ {
3473
+ url: `/_profiler/api/console/${id}`,
3474
+ method: "DELETE"
3475
+ }
3476
+ );
3477
+ };
3478
+ var getDeleteConsoleMutationOptions = (options) => {
3479
+ const mutationKey = ["deleteConsole"];
3480
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3481
+ const mutationFn = (props) => {
3482
+ const { id } = props ?? {};
3483
+ return deleteConsole(id);
3484
+ };
3485
+ return { mutationFn, ...mutationOptions };
3486
+ };
3487
+ var useDeleteConsole = (options) => {
3488
+ const mutationOptions = getDeleteConsoleMutationOptions(options);
3489
+ return useMutation(mutationOptions);
3490
+ };
3491
+ var clearConsoles = () => {
3492
+ return apiFetch(
3493
+ {
3494
+ url: `/_profiler/api/console/clear`,
3495
+ method: "DELETE"
3496
+ }
3497
+ );
3498
+ };
3499
+ var getClearConsolesMutationOptions = (options) => {
3500
+ const mutationKey = ["clearConsoles"];
3501
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3502
+ const mutationFn = () => {
3503
+ return clearConsoles();
3504
+ };
3505
+ return { mutationFn, ...mutationOptions };
3506
+ };
3507
+ var useClearConsoles = (options) => {
3508
+ const mutationOptions = getClearConsolesMutationOptions(options);
3509
+ return useMutation(mutationOptions);
3510
+ };
3511
+ var getEnvVars = (signal) => {
3512
+ return apiFetch(
3513
+ {
3514
+ url: `/_profiler/api/env_vars`,
3515
+ method: "GET",
3516
+ signal
3517
+ }
3518
+ );
3519
+ };
3520
+ var getGetEnvVarsQueryKey = () => {
3521
+ return [
3522
+ `/_profiler/api/env_vars`
3523
+ ];
3524
+ };
3525
+ var getGetEnvVarsQueryOptions = (options) => {
3526
+ const { query: queryOptions } = options ?? {};
3527
+ const queryKey = queryOptions?.queryKey ?? getGetEnvVarsQueryKey();
3528
+ const queryFn = ({ signal }) => getEnvVars(signal);
3529
+ return { queryKey, queryFn, ...queryOptions };
3530
+ };
3531
+ function useGetEnvVars(options) {
3532
+ const queryOptions = getGetEnvVarsQueryOptions(options);
3533
+ const query = useQuery(queryOptions);
3534
+ query.queryKey = queryOptions.queryKey;
3535
+ return query;
3536
+ }
3537
+ var updateEnvVar = (updateEnvVarBody) => {
3538
+ return apiFetch(
3539
+ {
3540
+ url: `/_profiler/api/env_vars`,
3541
+ method: "PATCH",
3542
+ headers: { "Content-Type": "application/json" },
3543
+ data: updateEnvVarBody
3544
+ }
3545
+ );
3546
+ };
3547
+ var getUpdateEnvVarMutationOptions = (options) => {
3548
+ const mutationKey = ["updateEnvVar"];
3549
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3550
+ const mutationFn = (props) => {
3551
+ const { data } = props ?? {};
3552
+ return updateEnvVar(data);
3553
+ };
3554
+ return { mutationFn, ...mutationOptions };
3555
+ };
3556
+ var useUpdateEnvVar = (options) => {
3557
+ const mutationOptions = getUpdateEnvVarMutationOptions(options);
3558
+ return useMutation(mutationOptions);
3559
+ };
3560
+ var resetEnvVar = (params) => {
3561
+ return apiFetch(
3562
+ {
3563
+ url: `/_profiler/api/env_vars/reset`,
3564
+ method: "DELETE",
3565
+ params
3566
+ }
3567
+ );
3568
+ };
3569
+ var getResetEnvVarMutationOptions = (options) => {
3570
+ const mutationKey = ["resetEnvVar"];
3571
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3572
+ const mutationFn = (props) => {
3573
+ const { params } = props ?? {};
3574
+ return resetEnvVar(params);
3575
+ };
3576
+ return { mutationFn, ...mutationOptions };
3577
+ };
3578
+ var useResetEnvVar = (options) => {
3579
+ const mutationOptions = getResetEnvVarMutationOptions(options);
3580
+ return useMutation(mutationOptions);
3581
+ };
3582
+ var resetAllEnvVars = () => {
3583
+ return apiFetch(
3584
+ {
3585
+ url: `/_profiler/api/env_vars/reset_all`,
3586
+ method: "DELETE"
3587
+ }
3588
+ );
3589
+ };
3590
+ var getResetAllEnvVarsMutationOptions = (options) => {
3591
+ const mutationKey = ["resetAllEnvVars"];
3592
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3593
+ const mutationFn = () => {
3594
+ return resetAllEnvVars();
3595
+ };
3596
+ return { mutationFn, ...mutationOptions };
3597
+ };
3598
+ var useResetAllEnvVars = (options) => {
3599
+ const mutationOptions = getResetAllEnvVarsMutationOptions(options);
3600
+ return useMutation(mutationOptions);
3601
+ };
3602
+ var explainQuery = (explainQueryBody, signal) => {
3603
+ return apiFetch(
3604
+ {
3605
+ url: `/_profiler/api/explain`,
3606
+ method: "POST",
3607
+ headers: { "Content-Type": "application/json" },
3608
+ data: explainQueryBody,
3609
+ signal
338
3610
  }
339
- }
340
- }
341
- c2.__b = function(n2) {
342
- r2 = null, e2 && e2(n2);
343
- }, c2.__ = function(n2, t3) {
344
- n2 && t3.__k && t3.__k.__m && (n2.__m = t3.__k.__m), s2 && s2(n2, t3);
345
- }, c2.__r = function(n2) {
346
- a2 && a2(n2), t2 = 0;
347
- var i3 = (r2 = n2.__c).__H;
348
- i3 && (u2 === r2 ? (i3.__h = [], r2.__h = [], i3.__.some(function(n3) {
349
- n3.__N && (n3.__ = n3.__N), n3.u = n3.__N = void 0;
350
- })) : (i3.__h.some(z2), i3.__h.some(B2), i3.__h = [], t2 = 0)), u2 = r2;
351
- }, c2.diffed = function(n2) {
352
- v2 && v2(n2);
353
- var t3 = n2.__c;
354
- t3 && t3.__H && (t3.__H.__h.length && (1 !== f2.push(t3) && i2 === c2.requestAnimationFrame || ((i2 = c2.requestAnimationFrame) || w2)(j2)), t3.__H.__.some(function(n3) {
355
- n3.u && (n3.__H = n3.u), n3.u = void 0;
356
- })), u2 = r2 = null;
357
- }, c2.__c = function(n2, t3) {
358
- t3.some(function(n3) {
359
- try {
360
- n3.__h.some(z2), n3.__h = n3.__h.filter(function(n4) {
361
- return !n4.__ || B2(n4);
362
- });
363
- } catch (r3) {
364
- t3.some(function(n4) {
365
- n4.__h && (n4.__h = []);
366
- }), t3 = [], c2.__e(r3, n3.__v);
3611
+ );
3612
+ };
3613
+ var getExplainQueryMutationOptions = (options) => {
3614
+ const mutationKey = ["explainQuery"];
3615
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3616
+ const mutationFn = (props) => {
3617
+ const { data } = props ?? {};
3618
+ return explainQuery(data);
3619
+ };
3620
+ return { mutationFn, ...mutationOptions };
3621
+ };
3622
+ var useExplainQuery = (options) => {
3623
+ const mutationOptions = getExplainQueryMutationOptions(options);
3624
+ return useMutation(mutationOptions);
3625
+ };
3626
+ var updateFunctionProfiling = (updateFunctionProfilingBody) => {
3627
+ return apiFetch(
3628
+ {
3629
+ url: `/_profiler/api/function_profiling`,
3630
+ method: "PATCH",
3631
+ headers: { "Content-Type": "application/json" },
3632
+ data: updateFunctionProfilingBody
367
3633
  }
368
- }), l2 && l2(n2, t3);
369
- }, c2.unmount = function(n2) {
370
- m2 && m2(n2);
371
- var t3, r3 = n2.__c;
372
- r3 && r3.__H && (r3.__H.__.some(function(n3) {
373
- try {
374
- z2(n3);
375
- } catch (n4) {
376
- t3 = n4;
3634
+ );
3635
+ };
3636
+ var getUpdateFunctionProfilingMutationOptions = (options) => {
3637
+ const mutationKey = ["updateFunctionProfiling"];
3638
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3639
+ const mutationFn = (props) => {
3640
+ const { data } = props ?? {};
3641
+ return updateFunctionProfiling(data);
3642
+ };
3643
+ return { mutationFn, ...mutationOptions };
3644
+ };
3645
+ var useUpdateFunctionProfiling = (options) => {
3646
+ const mutationOptions = getUpdateFunctionProfilingMutationOptions(options);
3647
+ return useMutation(mutationOptions);
3648
+ };
3649
+ var listJobs = (params, signal) => {
3650
+ return apiFetch(
3651
+ {
3652
+ url: `/_profiler/api/jobs`,
3653
+ method: "GET",
3654
+ params,
3655
+ signal
377
3656
  }
378
- }), r3.__H = void 0, t3 && c2.__e(t3, r3.__v));
3657
+ );
3658
+ };
3659
+ var getListJobsInfiniteQueryKey = (params) => {
3660
+ return [
3661
+ "infinite",
3662
+ `/_profiler/api/jobs`,
3663
+ ...params ? [params] : []
3664
+ ];
3665
+ };
3666
+ var getListJobsInfiniteQueryOptions = (params, options) => {
3667
+ const { query: queryOptions } = options ?? {};
3668
+ const queryKey = queryOptions?.queryKey ?? getListJobsInfiniteQueryKey(params);
3669
+ const queryFn = ({ signal }) => listJobs(params, signal);
3670
+ return { queryKey, queryFn, ...queryOptions };
3671
+ };
3672
+ function useListJobsInfinite(params, options) {
3673
+ const queryOptions = getListJobsInfiniteQueryOptions(params, options);
3674
+ const query = useInfiniteQuery(queryOptions);
3675
+ query.queryKey = queryOptions.queryKey;
3676
+ return query;
3677
+ }
3678
+ var deleteJob = (id) => {
3679
+ return apiFetch(
3680
+ {
3681
+ url: `/_profiler/api/jobs/${id}`,
3682
+ method: "DELETE"
3683
+ }
3684
+ );
3685
+ };
3686
+ var getDeleteJobMutationOptions = (options) => {
3687
+ const mutationKey = ["deleteJob"];
3688
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3689
+ const mutationFn = (props) => {
3690
+ const { id } = props ?? {};
3691
+ return deleteJob(id);
3692
+ };
3693
+ return { mutationFn, ...mutationOptions };
3694
+ };
3695
+ var useDeleteJob = (options) => {
3696
+ const mutationOptions = getDeleteJobMutationOptions(options);
3697
+ return useMutation(mutationOptions);
3698
+ };
3699
+ var clearJobs = () => {
3700
+ return apiFetch(
3701
+ {
3702
+ url: `/_profiler/api/jobs/clear`,
3703
+ method: "DELETE"
3704
+ }
3705
+ );
3706
+ };
3707
+ var getClearJobsMutationOptions = (options) => {
3708
+ const mutationKey = ["clearJobs"];
3709
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3710
+ const mutationFn = () => {
3711
+ return clearJobs();
3712
+ };
3713
+ return { mutationFn, ...mutationOptions };
3714
+ };
3715
+ var useClearJobs = (options) => {
3716
+ const mutationOptions = getClearJobsMutationOptions(options);
3717
+ return useMutation(mutationOptions);
3718
+ };
3719
+ var listOutboundRequests = (signal) => {
3720
+ return apiFetch(
3721
+ {
3722
+ url: `/_profiler/api/outbound_http`,
3723
+ method: "GET",
3724
+ signal
3725
+ }
3726
+ );
3727
+ };
3728
+ var getListOutboundRequestsQueryKey = () => {
3729
+ return [
3730
+ `/_profiler/api/outbound_http`
3731
+ ];
3732
+ };
3733
+ var getListOutboundRequestsQueryOptions = (options) => {
3734
+ const { query: queryOptions } = options ?? {};
3735
+ const queryKey = queryOptions?.queryKey ?? getListOutboundRequestsQueryKey();
3736
+ const queryFn = ({ signal }) => listOutboundRequests(signal);
3737
+ return { queryKey, queryFn, ...queryOptions };
3738
+ };
3739
+ function useListOutboundRequests(options) {
3740
+ const queryOptions = getListOutboundRequestsQueryOptions(options);
3741
+ const query = useQuery(queryOptions);
3742
+ query.queryKey = queryOptions.queryKey;
3743
+ return query;
3744
+ }
3745
+ var listProfiles = (params, signal) => {
3746
+ return apiFetch(
3747
+ {
3748
+ url: `/_profiler/api/profiles`,
3749
+ method: "GET",
3750
+ params,
3751
+ signal
3752
+ }
3753
+ );
3754
+ };
3755
+ var getListProfilesInfiniteQueryKey = (params) => {
3756
+ return [
3757
+ "infinite",
3758
+ `/_profiler/api/profiles`,
3759
+ ...params ? [params] : []
3760
+ ];
3761
+ };
3762
+ var getListProfilesInfiniteQueryOptions = (params, options) => {
3763
+ const { query: queryOptions } = options ?? {};
3764
+ const queryKey = queryOptions?.queryKey ?? getListProfilesInfiniteQueryKey(params);
3765
+ const queryFn = ({ signal }) => listProfiles(params, signal);
3766
+ return { queryKey, queryFn, ...queryOptions };
3767
+ };
3768
+ function useListProfilesInfinite(params, options) {
3769
+ const queryOptions = getListProfilesInfiniteQueryOptions(params, options);
3770
+ const query = useInfiniteQuery(queryOptions);
3771
+ query.queryKey = queryOptions.queryKey;
3772
+ return query;
3773
+ }
3774
+ var deleteProfile = (id) => {
3775
+ return apiFetch(
3776
+ {
3777
+ url: `/_profiler/api/profiles/${id}`,
3778
+ method: "DELETE"
3779
+ }
3780
+ );
3781
+ };
3782
+ var getDeleteProfileMutationOptions = (options) => {
3783
+ const mutationKey = ["deleteProfile"];
3784
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3785
+ const mutationFn = (props) => {
3786
+ const { id } = props ?? {};
3787
+ return deleteProfile(id);
3788
+ };
3789
+ return { mutationFn, ...mutationOptions };
3790
+ };
3791
+ var useDeleteProfile = (options) => {
3792
+ const mutationOptions = getDeleteProfileMutationOptions(options);
3793
+ return useMutation(mutationOptions);
3794
+ };
3795
+ var clearProfiles = () => {
3796
+ return apiFetch(
3797
+ {
3798
+ url: `/_profiler/api/profiles/clear`,
3799
+ method: "DELETE"
3800
+ }
3801
+ );
3802
+ };
3803
+ var getClearProfilesMutationOptions = (options) => {
3804
+ const mutationKey = ["clearProfiles"];
3805
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3806
+ const mutationFn = () => {
3807
+ return clearProfiles();
3808
+ };
3809
+ return { mutationFn, ...mutationOptions };
3810
+ };
3811
+ var useClearProfiles = (options) => {
3812
+ const mutationOptions = getClearProfilesMutationOptions(options);
3813
+ return useMutation(mutationOptions);
3814
+ };
3815
+ var getTestRunnerFiles = (params, signal) => {
3816
+ return apiFetch(
3817
+ {
3818
+ url: `/_profiler/api/test_runner/files`,
3819
+ method: "GET",
3820
+ params,
3821
+ signal
3822
+ }
3823
+ );
3824
+ };
3825
+ var getGetTestRunnerFilesQueryKey = (params) => {
3826
+ return [
3827
+ `/_profiler/api/test_runner/files`,
3828
+ ...params ? [params] : []
3829
+ ];
3830
+ };
3831
+ var getGetTestRunnerFilesQueryOptions = (params, options) => {
3832
+ const { query: queryOptions } = options ?? {};
3833
+ const queryKey = queryOptions?.queryKey ?? getGetTestRunnerFilesQueryKey(params);
3834
+ const queryFn = ({ signal }) => getTestRunnerFiles(params, signal);
3835
+ return { queryKey, queryFn, ...queryOptions };
3836
+ };
3837
+ function useGetTestRunnerFiles(params, options) {
3838
+ const queryOptions = getGetTestRunnerFilesQueryOptions(params, options);
3839
+ const query = useQuery(queryOptions);
3840
+ query.queryKey = queryOptions.queryKey;
3841
+ return query;
3842
+ }
3843
+ var createTestRun = (createTestRunBody, signal) => {
3844
+ return apiFetch(
3845
+ {
3846
+ url: `/_profiler/api/test_runner/runs`,
3847
+ method: "POST",
3848
+ headers: { "Content-Type": "application/json" },
3849
+ data: createTestRunBody,
3850
+ signal
3851
+ }
3852
+ );
3853
+ };
3854
+ var getCreateTestRunMutationOptions = (options) => {
3855
+ const mutationKey = ["createTestRun"];
3856
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3857
+ const mutationFn = (props) => {
3858
+ const { data } = props ?? {};
3859
+ return createTestRun(data);
3860
+ };
3861
+ return { mutationFn, ...mutationOptions };
3862
+ };
3863
+ var useCreateTestRun = (options) => {
3864
+ const mutationOptions = getCreateTestRunMutationOptions(options);
3865
+ return useMutation(mutationOptions);
3866
+ };
3867
+ var deleteTestRun = (id) => {
3868
+ return apiFetch(
3869
+ {
3870
+ url: `/_profiler/api/test_runner/runs/${id}`,
3871
+ method: "DELETE"
3872
+ }
3873
+ );
3874
+ };
3875
+ var getDeleteTestRunMutationOptions = (options) => {
3876
+ const mutationKey = ["deleteTestRun"];
3877
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3878
+ const mutationFn = (props) => {
3879
+ const { id } = props ?? {};
3880
+ return deleteTestRun(id);
3881
+ };
3882
+ return { mutationFn, ...mutationOptions };
3883
+ };
3884
+ var useDeleteTestRun = (options) => {
3885
+ const mutationOptions = getDeleteTestRunMutationOptions(options);
3886
+ return useMutation(mutationOptions);
3887
+ };
3888
+ var listTests = (params, signal) => {
3889
+ return apiFetch(
3890
+ {
3891
+ url: `/_profiler/api/tests`,
3892
+ method: "GET",
3893
+ params,
3894
+ signal
3895
+ }
3896
+ );
3897
+ };
3898
+ var getListTestsInfiniteQueryKey = (params) => {
3899
+ return [
3900
+ "infinite",
3901
+ `/_profiler/api/tests`,
3902
+ ...params ? [params] : []
3903
+ ];
3904
+ };
3905
+ var getListTestsInfiniteQueryOptions = (params, options) => {
3906
+ const { query: queryOptions } = options ?? {};
3907
+ const queryKey = queryOptions?.queryKey ?? getListTestsInfiniteQueryKey(params);
3908
+ const queryFn = ({ signal }) => listTests(params, signal);
3909
+ return { queryKey, queryFn, ...queryOptions };
3910
+ };
3911
+ function useListTestsInfinite(params, options) {
3912
+ const queryOptions = getListTestsInfiniteQueryOptions(params, options);
3913
+ const query = useInfiniteQuery(queryOptions);
3914
+ query.queryKey = queryOptions.queryKey;
3915
+ return query;
3916
+ }
3917
+ var deleteTest = (id) => {
3918
+ return apiFetch(
3919
+ {
3920
+ url: `/_profiler/api/tests/${id}`,
3921
+ method: "DELETE"
3922
+ }
3923
+ );
3924
+ };
3925
+ var getDeleteTestMutationOptions = (options) => {
3926
+ const mutationKey = ["deleteTest"];
3927
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3928
+ const mutationFn = (props) => {
3929
+ const { id } = props ?? {};
3930
+ return deleteTest(id);
3931
+ };
3932
+ return { mutationFn, ...mutationOptions };
3933
+ };
3934
+ var useDeleteTest = (options) => {
3935
+ const mutationOptions = getDeleteTestMutationOptions(options);
3936
+ return useMutation(mutationOptions);
3937
+ };
3938
+ var clearTests = () => {
3939
+ return apiFetch(
3940
+ {
3941
+ url: `/_profiler/api/tests/clear`,
3942
+ method: "DELETE"
3943
+ }
3944
+ );
3945
+ };
3946
+ var getClearTestsMutationOptions = (options) => {
3947
+ const mutationKey = ["clearTests"];
3948
+ const { mutation: mutationOptions } = options ? options.mutation && "mutationKey" in options.mutation && options.mutation.mutationKey ? options : { ...options, mutation: { ...options.mutation, mutationKey } } : { mutation: { mutationKey } };
3949
+ const mutationFn = () => {
3950
+ return clearTests();
3951
+ };
3952
+ return { mutationFn, ...mutationOptions };
3953
+ };
3954
+ var useClearTests = (options) => {
3955
+ const mutationOptions = getClearTestsMutationOptions(options);
3956
+ return useMutation(mutationOptions);
379
3957
  };
380
- var k2 = "function" == typeof requestAnimationFrame;
381
- function w2(n2) {
382
- var t3, r3 = function() {
383
- clearTimeout(u4), k2 && cancelAnimationFrame(t3), setTimeout(n2);
384
- }, u4 = setTimeout(r3, 35);
385
- k2 && (t3 = requestAnimationFrame(r3));
386
- }
387
- function z2(n2) {
388
- var t3 = r2, u4 = n2.__c;
389
- "function" == typeof u4 && (n2.__c = void 0, u4()), r2 = t3;
390
- }
391
- function B2(n2) {
392
- var t3 = r2;
393
- n2.__c = n2.__(), r2 = t3;
394
- }
395
- function C2(n2, t3) {
396
- return !n2 || n2.length !== t3.length || t3.some(function(t4, r3) {
397
- return t4 !== n2[r3];
398
- });
399
- }
400
- function D2(n2, t3) {
401
- return "function" == typeof t3 ? t3(n2) : t3;
402
- }
403
3958
 
404
3959
  // app/assets/typescript/profiler/dashboard/utils.ts
405
3960
  function getGemVersion() {
@@ -424,17 +3979,6 @@
424
3979
  return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
425
3980
  }
426
3981
 
427
- // node_modules/preact/jsx-runtime/dist/jsxRuntime.module.js
428
- var f3 = 0;
429
- function u3(e3, t3, n2, o3, i3, u4) {
430
- t3 || (t3 = {});
431
- var a3, c3, p3 = t3;
432
- if ("ref" in p3) for (c3 in p3 = {}, t3) "ref" == c3 ? a3 = t3[c3] : p3[c3] = t3[c3];
433
- var l3 = { type: e3, props: p3, key: n2, ref: a3, __k: null, __: null, __b: 0, __e: null, __c: null, constructor: void 0, __v: --f3, __i: -1, __u: 0, __source: i3, __self: u4 };
434
- if ("function" == typeof e3 && (a3 = e3.defaultProps)) for (c3 in a3) void 0 === p3[c3] && (p3[c3] = a3[c3]);
435
- return l.vnode && l.vnode(l3), l3;
436
- }
437
-
438
3982
  // app/assets/typescript/profiler/components/dashboard/tabs/shared/HttpComponents.tsx
439
3983
  function CopyButton({ text }) {
440
3984
  const [copied, setCopied] = d2(false);
@@ -989,32 +4533,6 @@
989
4533
  if (/^\d+(\.\d+)?$/.test(value)) return false;
990
4534
  return true;
991
4535
  }
992
- async function patchEnvVar(key, value) {
993
- const res = await fetch("/_profiler/api/env_vars", {
994
- method: "PATCH",
995
- headers: { "Content-Type": "application/json" },
996
- body: JSON.stringify({ key, value })
997
- });
998
- if (!res.ok) {
999
- const body = await res.json().catch(() => ({}));
1000
- throw new Error(body.error ?? `Request failed (${res.status})`);
1001
- }
1002
- return res.json();
1003
- }
1004
- async function resetEnvVar(key) {
1005
- const res = await fetch(`/_profiler/api/env_vars/reset?key=${encodeURIComponent(key)}`, {
1006
- method: "DELETE"
1007
- });
1008
- if (!res.ok) {
1009
- const body = await res.json().catch(() => ({}));
1010
- throw new Error(body.error ?? `Request failed (${res.status})`);
1011
- }
1012
- return res.json();
1013
- }
1014
- async function resetAllEnvVars() {
1015
- const res = await fetch("/_profiler/api/env_vars/reset_all", { method: "DELETE" });
1016
- if (!res.ok) throw new Error(`Request failed (${res.status})`);
1017
- }
1018
4536
  function EnvTab({ envData, readOnly: forceReadOnly = false }) {
1019
4537
  const [initial, setInitial] = d2(() => ({ ...envData?.variables ?? {} }));
1020
4538
  const [variables, setVariables] = d2(initial);
@@ -1035,6 +4553,9 @@
1035
4553
  const [showImport, setShowImport] = d2(false);
1036
4554
  const [importContent, setImportContent] = d2("");
1037
4555
  const editInputRef = A2(null);
4556
+ const { mutateAsync: patchEnvVar } = useUpdateEnvVar();
4557
+ const { mutateAsync: resetEnvVar2 } = useResetEnvVar();
4558
+ const { mutateAsync: resetAllEnvVars2 } = useResetAllEnvVars();
1038
4559
  y2(() => {
1039
4560
  if (editingKey !== null) editInputRef.current?.focus();
1040
4561
  }, [editingKey]);
@@ -1074,9 +4595,7 @@
1074
4595
  const refresh = async () => {
1075
4596
  setRefreshing(true);
1076
4597
  try {
1077
- const res = await fetch("/_profiler/api/env_vars");
1078
- if (!res.ok) throw new Error(`Request failed (${res.status})`);
1079
- const data = await res.json();
4598
+ const data = await getEnvVars();
1080
4599
  setVariables(data.variables);
1081
4600
  setTotal(data.total);
1082
4601
  setOverrides(data.overrides ?? {});
@@ -1107,7 +4626,7 @@
1107
4626
  if (!entries.length) return;
1108
4627
  setSaving(true);
1109
4628
  try {
1110
- await Promise.all(entries.map(([k3, v3]) => patchEnvVar(k3, v3)));
4629
+ await Promise.all(entries.map(([k3, v3]) => patchEnvVar({ key: k3, value: v3 })));
1111
4630
  setVariables((prev) => ({ ...prev, ...importPreview }));
1112
4631
  setImportContent("");
1113
4632
  setShowImport(false);
@@ -1135,7 +4654,7 @@
1135
4654
  }
1136
4655
  setSaving(true);
1137
4656
  try {
1138
- const data = await patchEnvVar(key, editValue);
4657
+ const data = await patchEnvVar({ key, value: editValue });
1139
4658
  setVariables((prev) => ({ ...prev, [key]: editValue }));
1140
4659
  setOverrides((prev) => {
1141
4660
  const n2 = { ...prev };
@@ -1157,7 +4676,7 @@
1157
4676
  const deleteVar = async (key) => {
1158
4677
  setSaving(true);
1159
4678
  try {
1160
- const data = await patchEnvVar(key, null);
4679
+ const data = await patchEnvVar({ key, value: null });
1161
4680
  setVariables((prev) => {
1162
4681
  const n2 = { ...prev };
1163
4682
  delete n2[key];
@@ -1189,7 +4708,7 @@
1189
4708
  const next = /^(true|yes)$/i.test(current) ? "false" : "true";
1190
4709
  setSaving(true);
1191
4710
  try {
1192
- const data = await patchEnvVar(key, next);
4711
+ const data = await patchEnvVar({ key, value: next });
1193
4712
  setVariables((prev) => ({ ...prev, [key]: next }));
1194
4713
  setOverrides((prev) => {
1195
4714
  const n2 = { ...prev };
@@ -1211,7 +4730,7 @@
1211
4730
  if (!key) return;
1212
4731
  setSaving(true);
1213
4732
  try {
1214
- const data = await patchEnvVar(key, newValue);
4733
+ const data = await patchEnvVar({ key, value: newValue });
1215
4734
  setVariables((prev) => ({ ...prev, [key]: newValue }));
1216
4735
  setOverrides((prev) => {
1217
4736
  const n2 = { ...prev };
@@ -1238,7 +4757,7 @@
1238
4757
  const resetVar = async (key) => {
1239
4758
  setSaving(true);
1240
4759
  try {
1241
- const data = await resetEnvVar(key);
4760
+ const data = await resetEnvVar2({ key });
1242
4761
  setOverrides((prev) => {
1243
4762
  const n2 = { ...prev };
1244
4763
  delete n2[key];
@@ -1265,7 +4784,7 @@
1265
4784
  const doResetAll = async () => {
1266
4785
  setSaving(true);
1267
4786
  try {
1268
- await resetAllEnvVars();
4787
+ await resetAllEnvVars2({});
1269
4788
  setOverrides({});
1270
4789
  const data = await refresh();
1271
4790
  if (data) setInitial(data.variables);
@@ -1793,40 +5312,27 @@
1793
5312
  var BASE = "/_profiler";
1794
5313
  function TestRunnerContent() {
1795
5314
  const [framework, setFramework] = d2("");
1796
- const [frameworks, setFrameworks] = d2([]);
1797
- const [tree, setTree] = d2([]);
1798
5315
  const [selected, setSelected] = d2(/* @__PURE__ */ new Set());
1799
- const [loading, setLoading] = d2(true);
1800
5316
  const [currentRun, setCurrentRun] = d2(null);
1801
5317
  const [isRunning, setIsRunning] = d2(false);
1802
5318
  const [error, setError] = d2(null);
1803
- const loadFiles = q2((fw) => {
1804
- setLoading(true);
1805
- fetch(`${BASE}/api/test_runner/files?framework=${fw}`).then((r3) => r3.json()).then((data) => {
1806
- setFrameworks(data.frameworks || []);
1807
- setTree(data.tree || []);
1808
- setSelected(/* @__PURE__ */ new Set());
1809
- setLoading(false);
1810
- }).catch(() => {
1811
- setError("Failed to load test files");
1812
- setLoading(false);
1813
- });
1814
- }, []);
5319
+ const { data: filesData, isLoading: loading, refetch: refetchFiles } = useGetTestRunnerFiles(
5320
+ framework ? { framework } : {},
5321
+ { query: { refetchOnWindowFocus: false } }
5322
+ );
5323
+ const { mutateAsync: startTestRun } = useCreateTestRun();
5324
+ const { mutateAsync: killTestRun } = useDeleteTestRun();
5325
+ const frameworks = filesData?.frameworks ?? [];
5326
+ const tree = filesData?.tree ?? [];
1815
5327
  y2(() => {
1816
- fetch(`${BASE}/api/test_runner/files`).then((r3) => r3.json()).then((data) => {
1817
- const fws = (data.frameworks || []).map(String);
1818
- setFrameworks(fws);
1819
- const defaultFw = fws[0] || "minitest";
1820
- setFramework(defaultFw);
1821
- return fetch(`${BASE}/api/test_runner/files?framework=${defaultFw}`);
1822
- }).then((r3) => r3.json()).then((data) => {
1823
- setTree(data.tree || []);
1824
- setLoading(false);
1825
- }).catch(() => {
1826
- setError("Failed to load test files");
1827
- setLoading(false);
1828
- });
1829
- }, []);
5328
+ if (!framework && frameworks.length > 0) {
5329
+ setFramework(frameworks[0]);
5330
+ }
5331
+ }, [frameworks]);
5332
+ const loadFiles = q2((fw) => {
5333
+ setSelected(/* @__PURE__ */ new Set());
5334
+ refetchFiles();
5335
+ }, [refetchFiles]);
1830
5336
  y2(() => {
1831
5337
  if (!currentRun || !isRunning) return;
1832
5338
  if (["passed", "failed", "killed", "error"].includes(currentRun.status)) {
@@ -1887,25 +5393,25 @@
1887
5393
  setSelected(new Set(all));
1888
5394
  };
1889
5395
  const selectNone = () => setSelected(/* @__PURE__ */ new Set());
1890
- const runTests = () => {
5396
+ const runTests = async () => {
1891
5397
  if (selected.size === 0 || isRunning) return;
1892
5398
  setError(null);
1893
- fetch(`${BASE}/api/test_runner/runs`, {
1894
- method: "POST",
1895
- headers: { "Content-Type": "application/json" },
1896
- body: JSON.stringify({ files: Array.from(selected), framework })
1897
- }).then((r3) => r3.json()).then((data) => {
5399
+ try {
5400
+ const data = await startTestRun({ files: Array.from(selected), framework });
1898
5401
  setCurrentRun(data);
1899
5402
  setIsRunning(true);
1900
- }).catch(() => setError("Failed to start test run"));
5403
+ } catch {
5404
+ setError("Failed to start test run");
5405
+ }
1901
5406
  };
1902
- const stopRun = () => {
5407
+ const stopRun = async () => {
1903
5408
  if (!currentRun) return;
1904
- fetch(`${BASE}/api/test_runner/runs/${currentRun.id}`, { method: "DELETE" }).then(() => {
5409
+ try {
5410
+ await killTestRun({ id: currentRun.id });
1905
5411
  setIsRunning(false);
1906
5412
  setCurrentRun((prev) => prev ? { ...prev, status: "killed" } : prev);
1907
- }).catch(() => {
1908
- });
5413
+ } catch {
5414
+ }
1909
5415
  };
1910
5416
  const totalFiles = tree.reduce((n2, d3) => n2 + d3.files.length, 0);
1911
5417
  return /* @__PURE__ */ u3("div", { children: [
@@ -1968,7 +5474,7 @@
1968
5474
  // app/assets/typescript/profiler/components/ProfileList.tsx
1969
5475
  var BASE2 = "/_profiler";
1970
5476
  function TableSkeleton({ cols, rows = 6 }) {
1971
- return /* @__PURE__ */ u3("div", { children: Array.from({ length: rows }).map((_2, i3) => /* @__PURE__ */ u3("div", { class: "profiler-skeleton__row", children: cols.map((size, j3) => /* @__PURE__ */ u3("div", { class: `profiler-skeleton__cell profiler-skeleton__cell--${size}` }, j3)) }, i3)) });
5477
+ return /* @__PURE__ */ u3("div", { children: Array.from({ length: rows }).map((_3, i3) => /* @__PURE__ */ u3("div", { class: "profiler-skeleton__row", children: cols.map((size, j3) => /* @__PURE__ */ u3("div", { class: `profiler-skeleton__cell profiler-skeleton__cell--${size}` }, j3)) }, i3)) });
1972
5478
  }
1973
5479
  function methodClass(method) {
1974
5480
  const map = { GET: "badge-info", POST: "badge-success", PUT: "badge-warning", PATCH: "badge-warning", DELETE: "badge-error" };
@@ -2015,37 +5521,54 @@
2015
5521
  };
2016
5522
  };
2017
5523
  const [section, setSection] = d2(initialSection);
2018
- const [profiles, setProfiles] = d2([]);
2019
- const [httpOffset, setHttpOffset] = d2(0);
2020
- const [httpHasMore, setHttpHasMore] = d2(false);
2021
- const [httpLoadingMore, setHttpLoadingMore] = d2(false);
2022
- const [jobs, setJobs] = d2([]);
2023
- const [jobOffset, setJobOffset] = d2(0);
2024
- const [jobHasMore, setJobHasMore] = d2(false);
2025
- const [jobLoadingMore, setJobLoadingMore] = d2(false);
2026
- const [consoles, setConsoles] = d2([]);
2027
- const [consoleOffset, setConsoleOffset] = d2(0);
2028
- const [consoleHasMore, setConsoleHasMore] = d2(false);
2029
- const [consoleLoadingMore, setConsoleLoadingMore] = d2(false);
2030
- const [tests, setTests] = d2([]);
2031
- const [testOffset, setTestOffset] = d2(0);
2032
- const [testHasMore, setTestHasMore] = d2(false);
2033
- const [testLoadingMore, setTestLoadingMore] = d2(false);
2034
- const [loadingTests, setLoadingTests] = d2(initialSection() === "tests");
2035
- const [testsLoaded, setTestsLoaded] = d2(false);
2036
- const [testsError, setTestsError] = d2(null);
2037
- const [outboundRequests, setOutboundRequests] = d2([]);
2038
- const [loadingHttp, setLoadingHttp] = d2(initialSection() === "http");
2039
- const [loadingJobs, setLoadingJobs] = d2(initialSection() === "jobs");
2040
- const [loadingConsole, setLoadingConsole] = d2(initialSection() === "console");
2041
- const [loadingOutbound, setLoadingOutbound] = d2(initialSection() === "outbound");
2042
- const [error, setError] = d2(null);
2043
- const [jobsError, setJobsError] = d2(null);
2044
- const [consoleError, setConsoleError] = d2(null);
2045
- const [outboundError, setOutboundError] = d2(null);
2046
- const [envData, setEnvData] = d2(void 0);
2047
- const [loadingEnv, setLoadingEnv] = d2(initialSection() === "env");
2048
- const [envError, setEnvError] = d2(null);
5524
+ const infiniteOpts = (key) => ({
5525
+ query: {
5526
+ enabled: section === key,
5527
+ getNextPageParam: (lastPage) => lastPage.has_more ? lastPage.offset + lastPage.limit : void 0,
5528
+ initialPageParam: 0,
5529
+ refetchOnWindowFocus: false
5530
+ }
5531
+ });
5532
+ const httpQuery = useListProfilesInfinite({ limit: 50 }, infiniteOpts("http"));
5533
+ const jobsQuery = useListJobsInfinite({ limit: 50 }, infiniteOpts("jobs"));
5534
+ const consolesQuery = useListConsolesInfinite({ limit: 50 }, infiniteOpts("console"));
5535
+ const testsQuery = useListTestsInfinite({ limit: 50 }, infiniteOpts("tests"));
5536
+ const outboundQuery = useListOutboundRequests({ query: { enabled: section === "outbound", refetchOnWindowFocus: false } });
5537
+ const envQuery = useGetEnvVars({ query: { enabled: section === "env", refetchOnWindowFocus: false } });
5538
+ const { mutateAsync: deleteProfileMutation } = useDeleteProfile();
5539
+ const { mutateAsync: clearProfilesMutation } = useClearProfiles();
5540
+ const { mutateAsync: deleteJobMutation } = useDeleteJob();
5541
+ const { mutateAsync: clearJobsMutation } = useClearJobs();
5542
+ const { mutateAsync: deleteConsoleMutation } = useDeleteConsole();
5543
+ const { mutateAsync: clearConsolesMutation } = useClearConsoles();
5544
+ const { mutateAsync: deleteTestMutation } = useDeleteTest();
5545
+ const { mutateAsync: clearTestsMutation } = useClearTests();
5546
+ const profiles = httpQuery.data?.pages.flatMap((p3) => p3.profiles) ?? [];
5547
+ const jobs = jobsQuery.data?.pages.flatMap((p3) => p3.profiles) ?? [];
5548
+ const consoles = consolesQuery.data?.pages.flatMap((p3) => p3.profiles) ?? [];
5549
+ const tests = testsQuery.data?.pages.flatMap((p3) => p3.profiles) ?? [];
5550
+ const outboundRequests = outboundQuery.data ?? [];
5551
+ const envData = envQuery.data;
5552
+ const loadingHttp = httpQuery.isLoading;
5553
+ const loadingJobs = jobsQuery.isLoading;
5554
+ const loadingConsole = consolesQuery.isLoading;
5555
+ const loadingTests = testsQuery.isLoading;
5556
+ const loadingOutbound = outboundQuery.isLoading;
5557
+ const loadingEnv = envQuery.isLoading;
5558
+ const error = httpQuery.error?.message ?? null;
5559
+ const jobsError = jobsQuery.error?.message ?? null;
5560
+ const consoleError = consolesQuery.error?.message ?? null;
5561
+ const testsError = testsQuery.error?.message ?? null;
5562
+ const outboundError = outboundQuery.error?.message ?? null;
5563
+ const envError = envQuery.error?.message ?? null;
5564
+ const httpHasMore = !!httpQuery.hasNextPage;
5565
+ const jobHasMore = !!jobsQuery.hasNextPage;
5566
+ const consoleHasMore = !!consolesQuery.hasNextPage;
5567
+ const testHasMore = !!testsQuery.hasNextPage;
5568
+ const httpLoadingMore = httpQuery.isFetchingNextPage;
5569
+ const jobLoadingMore = jobsQuery.isFetchingNextPage;
5570
+ const consoleLoadingMore = consolesQuery.isFetchingNextPage;
5571
+ const testLoadingMore = testsQuery.isFetchingNextPage;
2049
5572
  const [copiedToken, setCopiedToken] = d2(null);
2050
5573
  const [httpSearch, setHttpSearch] = d2("");
2051
5574
  const [httpMethod, setHttpMethod] = d2("");
@@ -2069,9 +5592,6 @@
2069
5592
  const [outboundSearch, setOutboundSearch] = d2("");
2070
5593
  const [outboundMethod, setOutboundMethod] = d2("");
2071
5594
  const [outboundStatus, setOutboundStatus] = d2("");
2072
- y2(() => {
2073
- refreshSection(section);
2074
- }, []);
2075
5595
  y2(() => {
2076
5596
  const url = new URL(window.location.href);
2077
5597
  if (httpSort.col) {
@@ -2101,71 +5621,27 @@
2101
5621
  const togglePreset = (key) => {
2102
5622
  setHttpPreset((prev) => prev === key ? "" : key);
2103
5623
  };
2104
- const loadMoreHttp = () => {
2105
- setHttpLoadingMore(true);
2106
- fetch(`${BASE2}/api/profiles?limit=50&offset=${httpOffset}`).then((res) => res.json()).then((data) => {
2107
- setProfiles((prev) => [...prev, ...data.profiles]);
2108
- setHttpOffset((prev) => prev + data.profiles.length);
2109
- setHttpHasMore(data.has_more);
2110
- setHttpLoadingMore(false);
2111
- }).catch(() => setHttpLoadingMore(false));
2112
- };
2113
- const loadMoreJobs = () => {
2114
- setJobLoadingMore(true);
2115
- fetch(`${BASE2}/api/jobs?limit=50&offset=${jobOffset}`).then((res) => res.json()).then((data) => {
2116
- setJobs((prev) => [...prev, ...data.profiles]);
2117
- setJobOffset((prev) => prev + data.profiles.length);
2118
- setJobHasMore(data.has_more);
2119
- setJobLoadingMore(false);
2120
- }).catch(() => setJobLoadingMore(false));
2121
- };
2122
- const loadMoreConsole = () => {
2123
- setConsoleLoadingMore(true);
2124
- fetch(`${BASE2}/api/console?limit=50&offset=${consoleOffset}`).then((res) => res.json()).then((data) => {
2125
- setConsoles((prev) => [...prev, ...data.profiles]);
2126
- setConsoleOffset((prev) => prev + data.profiles.length);
2127
- setConsoleHasMore(data.has_more);
2128
- setConsoleLoadingMore(false);
2129
- }).catch(() => setConsoleLoadingMore(false));
2130
- };
2131
- const loadTests = () => {
2132
- if (testsLoaded) return;
2133
- setLoadingTests(true);
2134
- fetch(`${BASE2}/api/tests?limit=50&offset=0`).then((res) => res.json()).then((data) => {
2135
- setTests(data.profiles);
2136
- setTestOffset(data.profiles.length);
2137
- setTestHasMore(data.has_more);
2138
- setLoadingTests(false);
2139
- setTestsLoaded(true);
2140
- }).catch(() => {
2141
- setTestsError("Failed to load test profiles");
2142
- setLoadingTests(false);
2143
- setTestsLoaded(true);
2144
- });
2145
- };
2146
- const loadMoreTests = () => {
2147
- setTestLoadingMore(true);
2148
- fetch(`${BASE2}/api/tests?limit=50&offset=${testOffset}`).then((res) => res.json()).then((data) => {
2149
- setTests((prev) => [...prev, ...data.profiles]);
2150
- setTestOffset((prev) => prev + data.profiles.length);
2151
- setTestHasMore(data.has_more);
2152
- setTestLoadingMore(false);
2153
- }).catch(() => setTestLoadingMore(false));
5624
+ const loadMoreHttp = () => httpQuery.fetchNextPage();
5625
+ const loadMoreJobs = () => jobsQuery.fetchNextPage();
5626
+ const loadMoreConsole = () => consolesQuery.fetchNextPage();
5627
+ const loadMoreTests = () => testsQuery.fetchNextPage();
5628
+ const refetchSection = (s3) => {
5629
+ if (s3 === "http") httpQuery.refetch();
5630
+ else if (s3 === "jobs") jobsQuery.refetch();
5631
+ else if (s3 === "console") consolesQuery.refetch();
5632
+ else if (s3 === "tests") testsQuery.refetch();
5633
+ else if (s3 === "outbound") outboundQuery.refetch();
5634
+ else if (s3 === "env") envQuery.refetch();
2154
5635
  };
2155
5636
  const handleSectionChange = (s3) => {
2156
5637
  if (s3 === section) {
2157
- refreshSection(s3);
5638
+ refetchSection(s3);
2158
5639
  return;
2159
5640
  }
2160
5641
  setSection(s3);
2161
5642
  const url = new URL(window.location.href);
2162
5643
  url.searchParams.set("section", s3);
2163
5644
  history.pushState(null, "", url.toString());
2164
- if (s3 === "tests") {
2165
- loadTests();
2166
- } else {
2167
- refreshSection(s3);
2168
- }
2169
5645
  setHttpSearch("");
2170
5646
  setHttpMethod("");
2171
5647
  setHttpStatus("");
@@ -2192,131 +5668,39 @@
2192
5668
  setTimeout(() => setCopiedToken(null), 1500);
2193
5669
  });
2194
5670
  };
2195
- const deleteProfile = (token) => {
2196
- fetch(`${BASE2}/api/profiles/${token}`, { method: "DELETE" }).then(() => {
2197
- setProfiles((prev) => prev.filter((p3) => p3.token !== token));
2198
- });
2199
- };
2200
- const deleteJob = (token) => {
2201
- fetch(`${BASE2}/api/jobs/${token}`, { method: "DELETE" }).then(() => {
2202
- setJobs((prev) => prev.filter((p3) => p3.token !== token));
2203
- });
2204
- };
2205
- const deleteConsole = (token) => {
2206
- fetch(`${BASE2}/api/console/${token}`, { method: "DELETE" }).then(() => {
2207
- setConsoles((prev) => prev.filter((p3) => p3.token !== token));
2208
- });
2209
- };
2210
- const deleteTest = (token) => {
2211
- fetch(`${BASE2}/api/tests/${token}`, { method: "DELETE" }).then(() => {
2212
- setTests((prev) => prev.filter((p3) => p3.token !== token));
2213
- });
2214
- };
2215
- const clearProfiles = () => {
5671
+ const deleteProfile2 = (token) => deleteProfileMutation({ id: token }).then(() => httpQuery.refetch());
5672
+ const deleteJob2 = (token) => deleteJobMutation({ id: token }).then(() => jobsQuery.refetch());
5673
+ const deleteConsole2 = (token) => deleteConsoleMutation({ id: token }).then(() => consolesQuery.refetch());
5674
+ const deleteTest2 = (token) => deleteTestMutation({ id: token }).then(() => testsQuery.refetch());
5675
+ const clearProfiles2 = () => {
2216
5676
  if (!window.confirm("Delete all HTTP profiles?")) return;
2217
- fetch(`${BASE2}/api/profiles/clear`, { method: "DELETE" }).then(() => {
2218
- setProfiles([]);
2219
- });
5677
+ clearProfilesMutation().then(() => httpQuery.refetch());
2220
5678
  };
2221
- const clearJobs = () => {
5679
+ const clearJobs2 = () => {
2222
5680
  if (!window.confirm("Delete all job profiles?")) return;
2223
- fetch(`${BASE2}/api/jobs/clear`, { method: "DELETE" }).then(() => {
2224
- setJobs([]);
2225
- });
5681
+ clearJobsMutation().then(() => jobsQuery.refetch());
2226
5682
  };
2227
5683
  const clearConsole = () => {
2228
5684
  if (!window.confirm("Delete all console profiles?")) return;
2229
- fetch(`${BASE2}/api/console/clear`, { method: "DELETE" }).then(() => {
2230
- setConsoles([]);
2231
- });
5685
+ clearConsolesMutation().then(() => consolesQuery.refetch());
2232
5686
  };
2233
- const clearTests = () => {
5687
+ const clearTests2 = () => {
2234
5688
  if (!window.confirm("Delete all test profiles?")) return;
2235
- fetch(`${BASE2}/api/tests/clear`, { method: "DELETE" }).then(() => {
2236
- setTests([]);
2237
- });
5689
+ clearTestsMutation().then(() => testsQuery.refetch());
2238
5690
  };
2239
5691
  const clearAll = () => {
2240
5692
  if (!window.confirm("Delete all HTTP, job and console profiles?")) return;
2241
5693
  Promise.all([
2242
- fetch(`${BASE2}/api/profiles/clear`, { method: "DELETE" }),
2243
- fetch(`${BASE2}/api/jobs/clear`, { method: "DELETE" }),
2244
- fetch(`${BASE2}/api/console/clear`, { method: "DELETE" })
5694
+ clearProfilesMutation(),
5695
+ clearJobsMutation(),
5696
+ clearConsolesMutation()
2245
5697
  ]).then(() => {
2246
- setProfiles([]);
2247
- setJobs([]);
2248
- setConsoles([]);
5698
+ httpQuery.refetch();
5699
+ jobsQuery.refetch();
5700
+ consolesQuery.refetch();
2249
5701
  });
2250
5702
  };
2251
- const refreshSection = (s3) => {
2252
- if (s3 === "http") {
2253
- setLoadingHttp(true);
2254
- fetch(`${BASE2}/api/profiles?limit=50&offset=0`).then((res) => res.json()).then((data) => {
2255
- setProfiles(data.profiles);
2256
- setHttpOffset(data.profiles.length);
2257
- setHttpHasMore(data.has_more);
2258
- setLoadingHttp(false);
2259
- }).catch(() => {
2260
- setError("Failed to load profiles");
2261
- setLoadingHttp(false);
2262
- });
2263
- } else if (s3 === "jobs") {
2264
- setLoadingJobs(true);
2265
- fetch(`${BASE2}/api/jobs?limit=50&offset=0`).then((res) => res.json()).then((data) => {
2266
- setJobs(data.profiles);
2267
- setJobOffset(data.profiles.length);
2268
- setJobHasMore(data.has_more);
2269
- setLoadingJobs(false);
2270
- }).catch(() => {
2271
- setJobsError("Failed to load job profiles");
2272
- setLoadingJobs(false);
2273
- });
2274
- } else if (s3 === "console") {
2275
- setLoadingConsole(true);
2276
- fetch(`${BASE2}/api/console?limit=50&offset=0`).then((res) => res.json()).then((data) => {
2277
- setConsoles(data.profiles);
2278
- setConsoleOffset(data.profiles.length);
2279
- setConsoleHasMore(data.has_more);
2280
- setLoadingConsole(false);
2281
- }).catch(() => {
2282
- setConsoleError("Failed to load console profiles");
2283
- setLoadingConsole(false);
2284
- });
2285
- } else if (s3 === "tests") {
2286
- setLoadingTests(true);
2287
- setTestsLoaded(false);
2288
- fetch(`${BASE2}/api/tests?limit=50&offset=0`).then((res) => res.json()).then((data) => {
2289
- setTests(data.profiles);
2290
- setTestOffset(data.profiles.length);
2291
- setTestHasMore(data.has_more);
2292
- setLoadingTests(false);
2293
- setTestsLoaded(true);
2294
- }).catch(() => {
2295
- setTestsError("Failed to load test profiles");
2296
- setLoadingTests(false);
2297
- setTestsLoaded(true);
2298
- });
2299
- } else if (s3 === "outbound") {
2300
- setLoadingOutbound(true);
2301
- fetch(`${BASE2}/api/outbound_http`).then((res) => res.json()).then((data) => {
2302
- setOutboundRequests(data);
2303
- setLoadingOutbound(false);
2304
- }).catch(() => {
2305
- setOutboundError("Failed to load outbound HTTP requests");
2306
- setLoadingOutbound(false);
2307
- });
2308
- } else if (s3 === "env") {
2309
- setLoadingEnv(true);
2310
- fetch(`${BASE2}/api/env_vars`).then((res) => res.json()).then((data) => {
2311
- setEnvData(data);
2312
- setLoadingEnv(false);
2313
- }).catch(() => {
2314
- setEnvError("Failed to load environment variables");
2315
- setLoadingEnv(false);
2316
- });
2317
- }
2318
- };
2319
- const refresh = () => refreshSection(section);
5703
+ const refresh = () => refetchSection(section);
2320
5704
  const toggleConsoleSort = (col) => {
2321
5705
  setConsoleSort(
2322
5706
  (prev) => prev.col === col ? { col, dir: prev.dir === "asc" ? "desc" : "asc" } : { col, dir: "asc" }
@@ -2577,7 +5961,7 @@
2577
5961
  profiles.length
2578
5962
  ] }),
2579
5963
  /* @__PURE__ */ u3("button", { class: `btn-refresh${loadingHttp ? " btn-refresh--spinning" : ""}`, onClick: refresh, disabled: loadingHttp, title: "Refresh", children: "\u21BA" }),
2580
- /* @__PURE__ */ u3("button", { class: "btn btn-danger btn-sm", onClick: clearProfiles, title: "Delete HTTP profiles", children: "Clear" }),
5964
+ /* @__PURE__ */ u3("button", { class: "btn btn-danger btn-sm", onClick: clearProfiles2, title: "Delete HTTP profiles", children: "Clear" }),
2581
5965
  /* @__PURE__ */ u3("button", { class: "btn btn-danger btn-sm", onClick: clearAll, title: "Delete all HTTP and job profiles", children: "Clear All" })
2582
5966
  ] })
2583
5967
  ] }),
@@ -2623,7 +6007,7 @@
2623
6007
  /* @__PURE__ */ u3("td", { children: formatMemory(p3.memory) }),
2624
6008
  /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("span", { class: statusClass(p3.status), children: p3.status }) }),
2625
6009
  /* @__PURE__ */ u3("td", { class: "profiler-text--xs profiler-text--mono profiler-text--muted", children: /* @__PURE__ */ u3("button", { class: "token-copy", onClick: () => copyToken(p3.token), title: "Copy full token", children: copiedToken === p3.token ? "\u2713" : p3.token.substring(0, 8) + "\u2026" }) }),
2626
- /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("button", { class: "btn-row-delete", onClick: () => deleteProfile(p3.token), title: "Delete", children: "\xD7" }) })
6010
+ /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("button", { class: "btn-row-delete", onClick: () => deleteProfile2(p3.token), title: "Delete", children: "\xD7" }) })
2627
6011
  ] }, p3.token)) })
2628
6012
  ] }),
2629
6013
  httpHasMore && !httpFiltersActive && /* @__PURE__ */ u3("div", { class: "profiler-load-more", children: /* @__PURE__ */ u3("button", { class: "btn btn-secondary", onClick: loadMoreHttp, disabled: httpLoadingMore, children: httpLoadingMore ? "Loading\u2026" : "Load more" }) })
@@ -2663,7 +6047,7 @@
2663
6047
  jobs.length
2664
6048
  ] }),
2665
6049
  /* @__PURE__ */ u3("button", { class: `btn-refresh${loadingJobs ? " btn-refresh--spinning" : ""}`, onClick: refresh, disabled: loadingJobs, title: "Refresh", children: "\u21BA" }),
2666
- /* @__PURE__ */ u3("button", { class: "btn btn-danger btn-sm", onClick: clearJobs, title: "Delete job profiles", children: "Clear" }),
6050
+ /* @__PURE__ */ u3("button", { class: "btn btn-danger btn-sm", onClick: clearJobs2, title: "Delete job profiles", children: "Clear" }),
2667
6051
  /* @__PURE__ */ u3("button", { class: "btn btn-danger btn-sm", onClick: clearAll, title: "Delete all HTTP and job profiles", children: "Clear All" })
2668
6052
  ] })
2669
6053
  ] }),
@@ -2704,7 +6088,7 @@
2704
6088
  /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("span", { class: isFailed ? "badge-error" : "badge-success", children: isFailed ? "\u2717 Failed" : "\u2713 Completed" }) }),
2705
6089
  /* @__PURE__ */ u3("td", { children: jobData?.executions ?? "-" }),
2706
6090
  /* @__PURE__ */ u3("td", { class: "profiler-text--xs profiler-text--mono profiler-text--muted", children: /* @__PURE__ */ u3("button", { class: "token-copy", onClick: () => copyToken(p3.token), title: "Copy full token", children: copiedToken === p3.token ? "\u2713" : p3.token.substring(0, 8) + "\u2026" }) }),
2707
- /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("button", { class: "btn-row-delete", onClick: () => deleteJob(p3.token), title: "Delete", children: "\xD7" }) })
6091
+ /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("button", { class: "btn-row-delete", onClick: () => deleteJob2(p3.token), title: "Delete", children: "\xD7" }) })
2708
6092
  ] }, p3.token);
2709
6093
  }) })
2710
6094
  ] }),
@@ -2781,7 +6165,7 @@
2781
6165
  /* @__PURE__ */ u3("td", { children: p3.collectors_data?.database?.total_queries ?? "\u2014" }),
2782
6166
  /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("span", { class: isError ? "badge-error" : "badge-success", children: isError ? "\u2717 Error" : "\u2713 OK" }) }),
2783
6167
  /* @__PURE__ */ u3("td", { class: "profiler-text--xs profiler-text--mono profiler-text--muted", children: /* @__PURE__ */ u3("button", { class: "token-copy", onClick: () => copyToken(p3.token), title: "Copy full token", children: copiedToken === p3.token ? "\u2713" : p3.token.substring(0, 8) + "\u2026" }) }),
2784
- /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("button", { class: "btn-row-delete", onClick: () => deleteConsole(p3.token), title: "Delete", children: "\xD7" }) })
6168
+ /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("button", { class: "btn-row-delete", onClick: () => deleteConsole2(p3.token), title: "Delete", children: "\xD7" }) })
2785
6169
  ] }, p3.token);
2786
6170
  }) })
2787
6171
  ] }),
@@ -2826,7 +6210,7 @@
2826
6210
  tests.length
2827
6211
  ] }),
2828
6212
  /* @__PURE__ */ u3("button", { class: `btn-refresh${loadingTests ? " btn-refresh--spinning" : ""}`, onClick: refresh, disabled: loadingTests, title: "Refresh", children: "\u21BA" }),
2829
- /* @__PURE__ */ u3("button", { class: "btn btn-danger btn-sm", onClick: clearTests, title: "Delete test profiles", children: "Clear All" })
6213
+ /* @__PURE__ */ u3("button", { class: "btn btn-danger btn-sm", onClick: clearTests2, title: "Delete test profiles", children: "Clear All" })
2830
6214
  ] })
2831
6215
  ] }),
2832
6216
  filteredTests.length === 0 ? /* @__PURE__ */ u3("div", { class: "profiler-empty", children: /* @__PURE__ */ u3("div", { class: "profiler-empty__title", children: "No results match filters" }) }) : /* @__PURE__ */ u3("table", { children: [
@@ -2864,7 +6248,7 @@
2864
6248
  /* @__PURE__ */ u3("td", { children: p3.collectors_data?.database?.total_queries ?? "\u2014" }),
2865
6249
  /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("span", { class: status === "failed" ? "badge-error" : status === "pending" ? "badge-warning" : "badge-success", children: status === "failed" ? "\u2717 Failed" : status === "pending" ? "\u23F8 Pending" : "\u2713 Passed" }) }),
2866
6250
  /* @__PURE__ */ u3("td", { class: "profiler-text--xs profiler-text--mono profiler-text--muted", children: /* @__PURE__ */ u3("button", { class: "token-copy", onClick: () => copyToken(p3.token), title: "Copy full token", children: copiedToken === p3.token ? "\u2713" : p3.token.substring(0, 8) + "\u2026" }) }),
2867
- /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("button", { class: "btn-row-delete", onClick: () => deleteTest(p3.token), title: "Delete", children: "\xD7" }) })
6251
+ /* @__PURE__ */ u3("td", { children: /* @__PURE__ */ u3("button", { class: "btn-row-delete", onClick: () => deleteTest2(p3.token), title: "Delete", children: "\xD7" }) })
2868
6252
  ] }, p3.token);
2869
6253
  }) })
2870
6254
  ] }),
@@ -3125,6 +6509,7 @@
3125
6509
  adapter: "",
3126
6510
  error: null
3127
6511
  });
6512
+ const { mutateAsync: runExplainMutation } = useExplainQuery();
3128
6513
  if (!dbData?.queries) {
3129
6514
  return /* @__PURE__ */ u3("div", { class: "profiler-empty", children: /* @__PURE__ */ u3("p", { class: "profiler-empty__description", children: "No database queries recorded" }) });
3130
6515
  }
@@ -3140,17 +6525,7 @@
3140
6525
  const runExplain = async (queryIndex) => {
3141
6526
  setExplainState({ open: true, loading: true, result: null, format: "text", adapter: "", error: null });
3142
6527
  try {
3143
- const res = await fetch("/_profiler/api/explain", {
3144
- method: "POST",
3145
- headers: { "Content-Type": "application/json" },
3146
- body: JSON.stringify({ token, query_index: queryIndex })
3147
- });
3148
- if (!res.ok) {
3149
- const body = await res.json().catch(() => ({}));
3150
- setExplainState((s3) => ({ ...s3, loading: false, error: body.error ?? `HTTP ${res.status}` }));
3151
- return;
3152
- }
3153
- const data = await res.json();
6528
+ const data = await runExplainMutation({ token, query_index: queryIndex });
3154
6529
  setExplainState((s3) => ({
3155
6530
  ...s3,
3156
6531
  loading: false,
@@ -3415,10 +6790,10 @@
3415
6790
  const vpRange = this.viewport.end - this.viewport.start;
3416
6791
  for (let i3 = this.frames.length - 1; i3 >= 0; i3--) {
3417
6792
  const f4 = this.frames[i3];
3418
- const x2 = (f4.absStart - this.viewport.start) / vpRange * w3;
6793
+ const x3 = (f4.absStart - this.viewport.start) / vpRange * w3;
3419
6794
  const fw = (f4.absEnd - f4.absStart) / vpRange * w3;
3420
6795
  const y3 = f4.depth * ROW_HEIGHT;
3421
- if (mx >= x2 && mx <= x2 + fw && my >= y3 && my <= y3 + FRAME_HEIGHT) {
6796
+ if (mx >= x3 && mx <= x3 + fw && my >= y3 && my <= y3 + FRAME_HEIGHT) {
3422
6797
  return f4;
3423
6798
  }
3424
6799
  }
@@ -3584,34 +6959,34 @@
3584
6959
  this.callbacks.onSearchResults(matchCount, this.frames.length);
3585
6960
  }
3586
6961
  for (const frame of this.frames) {
3587
- const x2 = (frame.absStart - this.viewport.start) / vpRange * w3;
6962
+ const x3 = (frame.absStart - this.viewport.start) / vpRange * w3;
3588
6963
  const fw = (frame.absEnd - frame.absStart) / vpRange * w3;
3589
6964
  const y3 = frame.depth * ROW_HEIGHT;
3590
- if (x2 + fw < 0 || x2 > w3 || fw < 0.5) continue;
6965
+ if (x3 + fw < 0 || x3 > w3 || fw < 0.5) continue;
3591
6966
  const color = CATEGORY_COLORS[frame.node.category] || "#a78bfa";
3592
6967
  const isHovered = frame === this.hoveredFrame;
3593
6968
  const isHighlighted = !!this.highlightName && frame.node.name === this.highlightName;
3594
6969
  const isMatch = !hasSearch || frame.node.name.toLowerCase().includes(searchLower);
3595
6970
  ctx.fillStyle = isHovered || isHighlighted ? this.lightenColor(color, 0.2) : color;
3596
6971
  ctx.globalAlpha = hasSearch && !isMatch ? 0.2 : isHovered || isHighlighted ? 1 : 0.85;
3597
- this.roundRect(ctx, x2, y3, fw, FRAME_HEIGHT, 3);
6972
+ this.roundRect(ctx, x3, y3, fw, FRAME_HEIGHT, 3);
3598
6973
  ctx.fill();
3599
6974
  ctx.globalAlpha = 1;
3600
6975
  if (isHovered) {
3601
6976
  ctx.strokeStyle = "#ffffff";
3602
6977
  ctx.lineWidth = 1.5;
3603
- this.roundRect(ctx, x2, y3, fw, FRAME_HEIGHT, 3);
6978
+ this.roundRect(ctx, x3, y3, fw, FRAME_HEIGHT, 3);
3604
6979
  ctx.stroke();
3605
6980
  } else if (isHighlighted) {
3606
6981
  ctx.strokeStyle = "#fbbf24";
3607
6982
  ctx.lineWidth = 2;
3608
- this.roundRect(ctx, x2, y3, fw, FRAME_HEIGHT, 3);
6983
+ this.roundRect(ctx, x3, y3, fw, FRAME_HEIGHT, 3);
3609
6984
  ctx.stroke();
3610
6985
  } else if (hasSearch && isMatch) {
3611
6986
  ctx.strokeStyle = "#ffffff";
3612
6987
  ctx.lineWidth = 1;
3613
6988
  ctx.globalAlpha = 0.5;
3614
- this.roundRect(ctx, x2, y3, fw, FRAME_HEIGHT, 3);
6989
+ this.roundRect(ctx, x3, y3, fw, FRAME_HEIGHT, 3);
3615
6990
  ctx.stroke();
3616
6991
  ctx.globalAlpha = 1;
3617
6992
  }
@@ -3625,26 +7000,26 @@
3625
7000
  const durationWidth = ctx.measureText(duration).width;
3626
7001
  if (maxTextWidth > durationWidth + 20) {
3627
7002
  const nameMaxWidth = maxTextWidth - durationWidth - 8;
3628
- ctx.fillText(this.truncateText(ctx, label, nameMaxWidth), x2 + 4, y3 + FRAME_HEIGHT / 2);
7003
+ ctx.fillText(this.truncateText(ctx, label, nameMaxWidth), x3 + 4, y3 + FRAME_HEIGHT / 2);
3629
7004
  ctx.fillStyle = isHovered ? textColor : textMuted;
3630
- ctx.fillText(duration, x2 + fw - durationWidth - 4, y3 + FRAME_HEIGHT / 2);
7005
+ ctx.fillText(duration, x3 + fw - durationWidth - 4, y3 + FRAME_HEIGHT / 2);
3631
7006
  } else {
3632
- ctx.fillText(this.truncateText(ctx, label, maxTextWidth), x2 + 4, y3 + FRAME_HEIGHT / 2);
7007
+ ctx.fillText(this.truncateText(ctx, label, maxTextWidth), x3 + 4, y3 + FRAME_HEIGHT / 2);
3633
7008
  }
3634
7009
  }
3635
7010
  }
3636
7011
  }
3637
- roundRect(ctx, x2, y3, w3, h3, r3) {
7012
+ roundRect(ctx, x3, y3, w3, h3, r3) {
3638
7013
  ctx.beginPath();
3639
- ctx.moveTo(x2 + r3, y3);
3640
- ctx.lineTo(x2 + w3 - r3, y3);
3641
- ctx.quadraticCurveTo(x2 + w3, y3, x2 + w3, y3 + r3);
3642
- ctx.lineTo(x2 + w3, y3 + h3 - r3);
3643
- ctx.quadraticCurveTo(x2 + w3, y3 + h3, x2 + w3 - r3, y3 + h3);
3644
- ctx.lineTo(x2 + r3, y3 + h3);
3645
- ctx.quadraticCurveTo(x2, y3 + h3, x2, y3 + h3 - r3);
3646
- ctx.lineTo(x2, y3 + r3);
3647
- ctx.quadraticCurveTo(x2, y3, x2 + r3, y3);
7014
+ ctx.moveTo(x3 + r3, y3);
7015
+ ctx.lineTo(x3 + w3 - r3, y3);
7016
+ ctx.quadraticCurveTo(x3 + w3, y3, x3 + w3, y3 + r3);
7017
+ ctx.lineTo(x3 + w3, y3 + h3 - r3);
7018
+ ctx.quadraticCurveTo(x3 + w3, y3 + h3, x3 + w3 - r3, y3 + h3);
7019
+ ctx.lineTo(x3 + r3, y3 + h3);
7020
+ ctx.quadraticCurveTo(x3, y3 + h3, x3, y3 + h3 - r3);
7021
+ ctx.lineTo(x3, y3 + r3);
7022
+ ctx.quadraticCurveTo(x3, y3, x3 + r3, y3);
3648
7023
  ctx.closePath();
3649
7024
  }
3650
7025
  truncateText(ctx, text, maxWidth) {
@@ -3714,7 +7089,7 @@
3714
7089
  this.el.className = "profiler-flamegraph__tooltip";
3715
7090
  container.appendChild(this.el);
3716
7091
  }
3717
- show(frame, x2, y3) {
7092
+ show(frame, x3, y3) {
3718
7093
  const node = frame.node;
3719
7094
  const category = node.category;
3720
7095
  const color = CATEGORY_COLORS2[category] || "#a78bfa";
@@ -3796,10 +7171,10 @@
3796
7171
  this.el.appendChild(payloadDiv);
3797
7172
  }
3798
7173
  }
3799
- let left = x2 + 12;
7174
+ let left = x3 + 12;
3800
7175
  let top = y3 - 8;
3801
7176
  const tipRect = this.el.getBoundingClientRect();
3802
- if (left + tipRect.width > window.innerWidth) left = x2 - tipRect.width - 12;
7177
+ if (left + tipRect.width > window.innerWidth) left = x3 - tipRect.width - 12;
3803
7178
  if (top + tipRect.height > window.innerHeight) top = y3 - tipRect.height - 8;
3804
7179
  if (top < 0) top = 4;
3805
7180
  this.el.style.left = `${left}px`;
@@ -3904,14 +7279,7 @@
3904
7279
  const [fnMaxFramesUpdating, setFnMaxFramesUpdating] = d2(false);
3905
7280
  const [fnModeUpdating, setFnModeUpdating] = d2(false);
3906
7281
  const [fnClockUpdating, setFnClockUpdating] = d2(false);
3907
- const patchFunctionProfiling = async (patch) => {
3908
- const res = await fetch("/_profiler/api/function_profiling", {
3909
- method: "PATCH",
3910
- headers: { "Content-Type": "application/json" },
3911
- body: JSON.stringify(patch)
3912
- });
3913
- return res.json();
3914
- };
7282
+ const { mutateAsync: patchFunctionProfiling } = useUpdateFunctionProfiling();
3915
7283
  const toggleFunctionProfiling = async () => {
3916
7284
  setFnToggling(true);
3917
7285
  try {
@@ -3967,9 +7335,9 @@
3967
7335
  breadcrumbsRef.current = breadcrumbs;
3968
7336
  container.insertBefore(breadcrumbs["el"], canvas);
3969
7337
  const renderer = new FlameGraphRenderer(canvas, data.root_events, {
3970
- onHover: (frame, x2, y3) => {
7338
+ onHover: (frame, x3, y3) => {
3971
7339
  if (frame) {
3972
- tooltip.show(frame, x2, y3);
7340
+ tooltip.show(frame, x3, y3);
3973
7341
  } else {
3974
7342
  tooltip.hide();
3975
7343
  }
@@ -4533,9 +7901,9 @@
4533
7901
  });
4534
7902
  container.insertBefore(breadcrumbs["el"], canvas);
4535
7903
  const renderer = new FlameGraphRenderer(canvas, rootCalls, {
4536
- onHover: (frame, x2, y3) => {
7904
+ onHover: (frame, x3, y3) => {
4537
7905
  if (frame) {
4538
- tooltip.show(frame, x2, y3);
7906
+ tooltip.show(frame, x3, y3);
4539
7907
  onHoverNameRef.current?.(frame.node.name);
4540
7908
  } else {
4541
7909
  tooltip.hide();
@@ -5360,14 +8728,14 @@
5360
8728
  // app/assets/typescript/profiler/components/dashboard/ProfileDashboard.tsx
5361
8729
  function ProfileDashboard({ profile, initialTab, embedded }) {
5362
8730
  const cd = profile.collectors_data || {};
5363
- const hasAjax = cd["ajax"]?.total_requests > 0;
5364
- const hasHttp = cd["http"]?.total_requests > 0;
5365
- const hasException = !!cd["exception"]?.exception_class;
5366
- const hasLogs = (cd["logs"]?.count ?? 0) > 0;
5367
- const hasRoutes = (cd["routes"]?.total ?? 0) > 0;
5368
- const hasI18n = (cd["i18n"]?.total ?? 0) > 0;
8731
+ const hasAjax = (cd.ajax?.total_requests ?? 0) > 0;
8732
+ const hasHttp = (cd.http?.total_requests ?? 0) > 0;
8733
+ const hasException = !!cd.exception?.exception_class;
8734
+ const hasLogs = (cd.logs?.count ?? 0) > 0;
8735
+ const hasRoutes = (cd.routes?.total ?? 0) > 0;
8736
+ const hasI18n = (cd.i18n?.total ?? 0) > 0;
5369
8737
  const hasJobs = (profile.child_jobs?.length ?? 0) > 0;
5370
- const hasMailers = (cd["mailer"]?.total ?? 0) > 0;
8738
+ const hasMailers = (cd.mailer?.total ?? 0) > 0;
5371
8739
  const [activeTab, setActiveTab] = d2(hasException ? "exception" : initialTab);
5372
8740
  const handleTabClick = (tab) => (e3) => {
5373
8741
  e3.preventDefault();
@@ -5443,21 +8811,21 @@
5443
8811
  /* @__PURE__ */ u3("a", { href: "#", class: tabClass("env"), onClick: handleTabClick("env"), children: "Env" })
5444
8812
  ] }),
5445
8813
  /* @__PURE__ */ u3("div", { class: "profiler-p-4 tab-content active", children: [
5446
- activeTab === "exception" && /* @__PURE__ */ u3(ExceptionTab, { exceptionData: cd["exception"] }),
8814
+ activeTab === "exception" && /* @__PURE__ */ u3(ExceptionTab, { exceptionData: cd.exception }),
5447
8815
  activeTab === "request" && /* @__PURE__ */ u3(RequestTab, { profile }),
5448
- activeTab === "dump" && /* @__PURE__ */ u3(DumpsTab, { dumpData: cd["dump"] }),
5449
- activeTab === "database" && /* @__PURE__ */ u3(DatabaseTab, { dbData: cd["database"], token: profile.token }),
5450
- activeTab === "ajax" && /* @__PURE__ */ u3(AjaxTab, { ajaxData: cd["ajax"] }),
5451
- activeTab === "http" && /* @__PURE__ */ u3(HttpTab, { httpData: cd["http"] }),
5452
- activeTab === "timeline" && /* @__PURE__ */ u3(FlameGraphTab, { flamegraphData: cd["flamegraph"], perfData: cd["performance"], functionProfileData: cd["function_profile"] }),
5453
- activeTab === "views" && /* @__PURE__ */ u3(ViewsTab, { viewData: cd["view"] }),
5454
- activeTab === "cache" && /* @__PURE__ */ u3(CacheTab, { cacheData: cd["cache"] }),
5455
- activeTab === "logs" && /* @__PURE__ */ u3(LogsTab, { logData: cd["logs"] }),
5456
- activeTab === "routes" && /* @__PURE__ */ u3(RoutesTab, { routesData: cd["routes"] }),
5457
- activeTab === "i18n" && /* @__PURE__ */ u3(I18nTab, { i18nData: cd["i18n"] }),
8816
+ activeTab === "dump" && /* @__PURE__ */ u3(DumpsTab, { dumpData: cd.dump }),
8817
+ activeTab === "database" && /* @__PURE__ */ u3(DatabaseTab, { dbData: cd.database, token: profile.token }),
8818
+ activeTab === "ajax" && /* @__PURE__ */ u3(AjaxTab, { ajaxData: cd.ajax }),
8819
+ activeTab === "http" && /* @__PURE__ */ u3(HttpTab, { httpData: cd.http }),
8820
+ activeTab === "timeline" && /* @__PURE__ */ u3(FlameGraphTab, { flamegraphData: cd.flamegraph, perfData: cd.performance, functionProfileData: cd.function_profile }),
8821
+ activeTab === "views" && /* @__PURE__ */ u3(ViewsTab, { viewData: cd.view }),
8822
+ activeTab === "cache" && /* @__PURE__ */ u3(CacheTab, { cacheData: cd.cache }),
8823
+ activeTab === "logs" && /* @__PURE__ */ u3(LogsTab, { logData: cd.logs }),
8824
+ activeTab === "routes" && /* @__PURE__ */ u3(RoutesTab, { routesData: cd.routes }),
8825
+ activeTab === "i18n" && /* @__PURE__ */ u3(I18nTab, { i18nData: cd.i18n }),
5458
8826
  activeTab === "jobs" && /* @__PURE__ */ u3(JobsTab, { jobs: profile.child_jobs }),
5459
- activeTab === "mailer" && /* @__PURE__ */ u3(MailerTab, { mailerData: cd["mailer"] }),
5460
- activeTab === "env" && /* @__PURE__ */ u3(EnvTab, { envData: cd["env"], readOnly: true })
8827
+ activeTab === "mailer" && /* @__PURE__ */ u3(MailerTab, { mailerData: cd.mailer }),
8828
+ activeTab === "env" && /* @__PURE__ */ u3(EnvTab, { envData: cd.env, readOnly: true })
5461
8829
  ] })
5462
8830
  ] }),
5463
8831
  !embedded && /* @__PURE__ */ u3("div", { class: "profiler-mt-6", children: /* @__PURE__ */ u3("a", { href: "/_profiler", style: "color: var(--profiler-accent);", children: "\u2190 Back to profiles" }) })
@@ -5926,10 +9294,10 @@
5926
9294
  const scale = (width - 100) / timeRange;
5927
9295
  events.forEach((event, index) => {
5928
9296
  const y3 = index * 40 + 20;
5929
- const x2 = (event.started_at - minTime) * scale + 50;
9297
+ const x3 = (event.started_at - minTime) * scale + 50;
5930
9298
  const eventWidth = event.duration * scale;
5931
9299
  const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
5932
- rect.setAttribute("x", x2.toString());
9300
+ rect.setAttribute("x", x3.toString());
5933
9301
  rect.setAttribute("y", y3.toString());
5934
9302
  rect.setAttribute("width", Math.max(eventWidth, 2).toString());
5935
9303
  rect.setAttribute("height", "20");
@@ -6135,10 +9503,16 @@ Duration: ${event.duration.toFixed(2)}ms`;
6135
9503
  }
6136
9504
 
6137
9505
  // app/assets/typescript/profiler/main.tsx
9506
+ var queryClient = new QueryClient({
9507
+ defaultOptions: { queries: { staleTime: 3e4, retry: 1 } }
9508
+ });
6138
9509
  document.addEventListener("DOMContentLoaded", () => {
6139
9510
  const indexEl = document.getElementById("profiler-index");
6140
9511
  if (indexEl) {
6141
- J(/* @__PURE__ */ u3(ProfileList, {}), indexEl);
9512
+ J(
9513
+ /* @__PURE__ */ u3(QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ u3(ProfileList, {}) }),
9514
+ indexEl
9515
+ );
6142
9516
  }
6143
9517
  const showEl = document.getElementById("profiler-show");
6144
9518
  if (showEl) {