rails-profiler 0.36.2 → 0.37.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 425d3e2d7c0c01fc34672541d20f519bf260bd32e19c7ea9100fa5c5d6e43a81
4
- data.tar.gz: a56c7fb60987d17569b6dfaad5d37068c516e39ed8f73fe260f4ad651c0dcb36
3
+ metadata.gz: 0f5418db9e2953cf84f81a2da0fd935969cf5b3664c2b3add867f690f191d21c
4
+ data.tar.gz: a8be67b4983c084ae25a9c5fa08a510cb13a460d9d9cc5c3882521bf1c176fbc
5
5
  SHA512:
6
- metadata.gz: 1102b3922c690c15f2247343fb6afd9b1ef2d5e5fbe7d79b88affad0b01ae288586f0df29f9049ee8b65385ccf12138365963ca5dbbe1032158dd259f3538d14
7
- data.tar.gz: 06e26f6bd030fc17d8da158d5e6205d0cbaf426b0545b26ea2bd4cddcf3d4e1e685ab2bd668149cddc63aa4e052bcf25bbde7a120168ba8599f1bd22e7e18cbd
6
+ metadata.gz: f1cafbad567a766daa50fcafd2cd1807f8de1e4762656fb77f5ea6598b9c59ec259ec2431c83ace4a12c64ec73bd73be4907c1f0afa742c327c8c963c0f92c5b
7
+ data.tar.gz: 18b53980ec70b59cd5022f8692d9af03eb44db380633572284e253bb4ee578062ce748c30ddcfc0e4829f6ef73877709487489e76c727a4d74958277b50e47c9
data/CHANGELOG.md CHANGED
@@ -19,6 +19,20 @@ every commit of every tag interval is accounted for one way or the other.
19
19
 
20
20
  ## [Unreleased]
21
21
 
22
+ ## [0.37.0] - 2026-10-18
23
+
24
+ <!-- stamped -->
25
+
26
+ ### Added
27
+
28
+ - **Collectors:** a collector whose `subscribe` or `collect` raises `collector_circuit_breaker_threshold` times in a row (`3` by default) is no longer run: its circuit opens and the profiles leave it out. After 60 seconds one request tries it again; a success closes the circuit, a failure opens it for another 60 seconds. `collector_circuit_breaker_enabled = false` turns the counting and the blocking off.
29
+ - **API:** `GET /_profiler/health` (a page, or JSON with `/_profiler/health.json`) shows the circuit state (`closed`, `open`, `half_open`) and the consecutive failures of each configured collector. It always answers `200`.
30
+ - **Toolbar:** a `Health` link next to the `Profiler` link opens that page.
31
+
32
+ ### Fixed
33
+
34
+ - **Collectors:** a collector whose `subscribe` raises no longer stops the profiler for the whole request, job, console expression or test: only that collector is left out and the others keep profiling.
35
+
22
36
  ## [0.36.2] - 2026-10-18
23
37
 
24
38
  <!-- stamped -->
@@ -1,2 +1,2 @@
1
1
  "use strict";(()=>{var br=t=>{throw TypeError(t)};var Kt=(t,e,r)=>e.has(t)||br("Cannot "+r);var a=(t,e,r)=>(Kt(t,e,"read from private field"),r?r.call(t):e.get(t)),_=(t,e,r)=>e.has(t)?br("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(t):e.set(t,r),h=(t,e,r,o)=>(Kt(t,e,"write to private field"),o?o.call(t,r):e.set(t,r),r),E=(t,e,r)=>(Kt(t,e,"access private method"),r);var Ye=(t,e,r,o)=>({set _(i){h(t,e,i,r)},get _(){return a(t,e,o)}});var vt,P,Cr,fo,ue,Rr,Pr,Ar,Or,Lt,Ft,St,Qr,mt={},Tt=[],yo=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,gt=Array.isArray;function oe(t,e){for(var r in e)t[r]=e[r];return t}function It(t){t&&t.parentNode&&t.parentNode.removeChild(t)}function ho(t,e,r){var o,i,s,u={};for(s in e)s=="key"?o=e[s]:s=="ref"?i=e[s]:u[s]=e[s];if(arguments.length>2&&(u.children=arguments.length>3?vt.call(arguments,2):r),typeof t=="function"&&t.defaultProps!=null)for(s in t.defaultProps)u[s]===void 0&&(u[s]=t.defaultProps[s]);return ht(t,u,o,i,null)}function ht(t,e,r,o,i){var s={type:t,props:e,key:r,ref:o,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:i??++Cr,__i:-1,__u:0};return i==null&&P.vnode!=null&&P.vnode(s),s}function b(t){return t.children}function Me(t,e){this.props=t,this.context=e}function De(t,e){if(e==null)return t.__?De(t.__,t.__i+1):null;for(var r;e<t.__k.length;e++)if((r=t.__k[e])!=null&&r.__e!=null)return r.__e;return typeof t.type=="function"?De(t):null}function mo(t){if(t.__P&&t.__d){var e=t.__v,r=e.__e,o=[],i=[],s=oe({},e);s.__v=e.__v+1,P.vnode&&P.vnode(s),Vt(t.__P,s,e,t.__n,t.__P.namespaceURI,32&e.__u?[r]:null,o,r??De(e),!!(32&e.__u),i),s.__v=e.__v,s.__.__k[s.__i]=s,Kr(o,s,i),e.__e=e.__=null,s.__e!=r&&qr(s)}}function qr(t){if((t=t.__)!=null&&t.__c!=null)return t.__e=t.__c.base=null,t.__k.some(function(e){if(e!=null&&e.__e!=null)return t.__e=t.__c.base=e.__e}),qr(t)}function Ut(t){(!t.__d&&(t.__d=!0)&&ue.push(t)&&!_t.__r++||Rr!=P.debounceRendering)&&((Rr=P.debounceRendering)||Pr)(_t)}function _t(){try{for(var t,e=1;ue.length;)ue.length>e&&ue.sort(Ar),t=ue.shift(),e=ue.length,mo(t)}finally{ue.length=_t.__r=0}}function Mr(t,e,r,o,i,s,u,p,f,c,y){var l,m,d,T,x,v,g,R=o&&o.__k||Tt,q=e.length;for(f=To(r,e,R,f,q),l=0;l<q;l++)(d=r.__k[l])!=null&&(m=d.__i!=-1&&R[d.__i]||mt,d.__i=l,v=Vt(t,d,m,i,s,u,p,f,c,y),T=d.__e,d.ref&&m.ref!=d.ref&&(m.ref&&Nt(m.ref,null,d),y.push(d.ref,d.__c||T,d)),x==null&&T!=null&&(x=T),(g=!!(4&d.__u))||m.__k===d.__k?f=Dr(d,f,t,g):typeof d.type=="function"&&v!==void 0?f=v:T&&(f=T.nextSibling),d.__u&=-7);return r.__e=x,f}function To(t,e,r,o,i){var s,u,p,f,c,y=r.length,l=y,m=0;for(t.__k=new Array(i),s=0;s<i;s++)(u=e[s])!=null&&typeof u!="boolean"&&typeof u!="function"?(typeof u=="string"||typeof u=="number"||typeof u=="bigint"||u.constructor==String?u=t.__k[s]=ht(null,u,null,null,null):gt(u)?u=t.__k[s]=ht(b,{children:u},null,null,null):u.constructor===void 0&&u.__b>0?u=t.__k[s]=ht(u.type,u.props,u.key,u.ref?u.ref:null,u.__v):t.__k[s]=u,f=s+m,u.__=t,u.__b=t.__b+1,p=null,(c=u.__i=_o(u,r,f,l))!=-1&&(l--,(p=r[c])&&(p.__u|=2)),p==null||p.__v==null?(c==-1&&(i>y?m--:i<y&&m++),typeof u.type!="function"&&(u.__u|=4)):c!=f&&(c==f-1?m--:c==f+1?m++:(c>f?m--:m++,u.__u|=4))):t.__k[s]=null;if(l)for(s=0;s<y;s++)(p=r[s])!=null&&(2&p.__u)==0&&(p.__e==o&&(o=De(p)),Sr(p,p));return o}function Dr(t,e,r,o){var i,s;if(typeof t.type=="function"){for(i=t.__k,s=0;i&&s<i.length;s++)i[s]&&(i[s].__=t,e=Dr(i[s],e,r,o));return e}t.__e!=e&&(o&&(e&&t.type&&!e.parentNode&&(e=De(t)),r.insertBefore(t.__e,e||null)),e=t.__e);do e=e&&e.nextSibling;while(e!=null&&e.nodeType==8);return e}function _o(t,e,r,o){var i,s,u,p=t.key,f=t.type,c=e[r],y=c!=null&&(2&c.__u)==0;if(c===null&&p==null||y&&p==c.key&&f==c.type)return r;if(o>(y?1:0)){for(i=r-1,s=r+1;i>=0||s<e.length;)if((c=e[u=i>=0?i--:s++])!=null&&(2&c.__u)==0&&p==c.key&&f==c.type)return u}return-1}function Er(t,e,r){e[0]=="-"?t.setProperty(e,r??""):t[e]=r==null?"":typeof r!="number"||yo.test(e)?r:r+"px"}function dt(t,e,r,o,i){var s,u;e:if(e=="style")if(typeof r=="string")t.style.cssText=r;else{if(typeof o=="string"&&(t.style.cssText=o=""),o)for(e in o)r&&e in r||Er(t.style,e,"");if(r)for(e in r)o&&r[e]==o[e]||Er(t.style,e,r[e])}else if(e[0]=="o"&&e[1]=="n")s=e!=(e=e.replace(Or,"$1")),u=e.toLowerCase(),e=u in t||e=="onFocusOut"||e=="onFocusIn"?u.slice(2):e.slice(2),t.l||(t.l={}),t.l[e+s]=r,r?o?r.u=o.u:(r.u=Lt,t.addEventListener(e,s?St:Ft,s)):t.removeEventListener(e,s?St:Ft,s);else{if(i=="http://www.w3.org/2000/svg")e=e.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if(e!="width"&&e!="height"&&e!="href"&&e!="list"&&e!="form"&&e!="tabIndex"&&e!="download"&&e!="rowSpan"&&e!="colSpan"&&e!="role"&&e!="popover"&&e in t)try{t[e]=r??"";break e}catch{}typeof r=="function"||(r==null||r===!1&&e[4]!="-"?t.removeAttribute(e):t.setAttribute(e,e=="popover"&&r==1?"":r))}}function wr(t){return function(e){if(this.l){var r=this.l[e.type+t];if(e.t==null)e.t=Lt++;else if(e.t<r.u)return;return r(P.event?P.event(e):e)}}}function Vt(t,e,r,o,i,s,u,p,f,c){var y,l,m,d,T,x,v,g,R,q,F,L,W,G,H,Q=e.type;if(e.constructor!==void 0)return null;128&r.__u&&(f=!!(32&r.__u),s=[p=e.__e=r.__e]),(y=P.__b)&&y(e);e:if(typeof Q=="function")try{if(g=e.props,R=Q.prototype&&Q.prototype.render,q=(y=Q.contextType)&&o[y.__c],F=y?q?q.props.value:y.__:o,r.__c?v=(l=e.__c=r.__c).__=l.__E:(R?e.__c=l=new Q(g,F):(e.__c=l=new Me(g,F),l.constructor=Q,l.render=go),q&&q.sub(l),l.state||(l.state={}),l.__n=o,m=l.__d=!0,l.__h=[],l._sb=[]),R&&l.__s==null&&(l.__s=l.state),R&&Q.getDerivedStateFromProps!=null&&(l.__s==l.state&&(l.__s=oe({},l.__s)),oe(l.__s,Q.getDerivedStateFromProps(g,l.__s))),d=l.props,T=l.state,l.__v=e,m)R&&Q.getDerivedStateFromProps==null&&l.componentWillMount!=null&&l.componentWillMount(),R&&l.componentDidMount!=null&&l.__h.push(l.componentDidMount);else{if(R&&Q.getDerivedStateFromProps==null&&g!==d&&l.componentWillReceiveProps!=null&&l.componentWillReceiveProps(g,F),e.__v==r.__v||!l.__e&&l.shouldComponentUpdate!=null&&l.shouldComponentUpdate(g,l.__s,F)===!1){e.__v!=r.__v&&(l.props=g,l.state=l.__s,l.__d=!1),e.__e=r.__e,e.__k=r.__k,e.__k.some(function(B){B&&(B.__=e)}),Tt.push.apply(l.__h,l._sb),l._sb=[],l.__h.length&&u.push(l);break e}l.componentWillUpdate!=null&&l.componentWillUpdate(g,l.__s,F),R&&l.componentDidUpdate!=null&&l.__h.push(function(){l.componentDidUpdate(d,T,x)})}if(l.context=F,l.props=g,l.__P=t,l.__e=!1,L=P.__r,W=0,R)l.state=l.__s,l.__d=!1,L&&L(e),y=l.render(l.props,l.state,l.context),Tt.push.apply(l.__h,l._sb),l._sb=[];else do l.__d=!1,L&&L(e),y=l.render(l.props,l.state,l.context),l.state=l.__s;while(l.__d&&++W<25);l.state=l.__s,l.getChildContext!=null&&(o=oe(oe({},o),l.getChildContext())),R&&!m&&l.getSnapshotBeforeUpdate!=null&&(x=l.getSnapshotBeforeUpdate(d,T)),G=y!=null&&y.type===b&&y.key==null?Fr(y.props.children):y,p=Mr(t,gt(G)?G:[G],e,r,o,i,s,u,p,f,c),l.base=e.__e,e.__u&=-161,l.__h.length&&u.push(l),v&&(l.__E=l.__=null)}catch(B){if(e.__v=null,f||s!=null)if(B.then){for(e.__u|=f?160:128;p&&p.nodeType==8&&p.nextSibling;)p=p.nextSibling;s[s.indexOf(p)]=null,e.__e=p}else{for(H=s.length;H--;)It(s[H]);kt(e)}else e.__e=r.__e,e.__k=r.__k,B.then||kt(e);P.__e(B,e,r)}else s==null&&e.__v==r.__v?(e.__k=r.__k,e.__e=r.__e):p=e.__e=vo(r.__e,e,r,o,i,s,u,f,c);return(y=P.diffed)&&y(e),128&e.__u?void 0:p}function kt(t){t&&(t.__c&&(t.__c.__e=!0),t.__k&&t.__k.some(kt))}function Kr(t,e,r){for(var o=0;o<r.length;o++)Nt(r[o],r[++o],r[++o]);P.__c&&P.__c(e,t),t.some(function(i){try{t=i.__h,i.__h=[],t.some(function(s){s.call(i)})}catch(s){P.__e(s,i.__v)}})}function Fr(t){return typeof t!="object"||t==null||t.__b>0?t:gt(t)?t.map(Fr):oe({},t)}function vo(t,e,r,o,i,s,u,p,f){var c,y,l,m,d,T,x,v=r.props||mt,g=e.props,R=e.type;if(R=="svg"?i="http://www.w3.org/2000/svg":R=="math"?i="http://www.w3.org/1998/Math/MathML":i||(i="http://www.w3.org/1999/xhtml"),s!=null){for(c=0;c<s.length;c++)if((d=s[c])&&"setAttribute"in d==!!R&&(R?d.localName==R:d.nodeType==3)){t=d,s[c]=null;break}}if(t==null){if(R==null)return document.createTextNode(g);t=document.createElementNS(i,R,g.is&&g),p&&(P.__m&&P.__m(e,s),p=!1),s=null}if(R==null)v===g||p&&t.data==g||(t.data=g);else{if(s=s&&vt.call(t.childNodes),!p&&s!=null)for(v={},c=0;c<t.attributes.length;c++)v[(d=t.attributes[c]).name]=d.value;for(c in v)d=v[c],c=="dangerouslySetInnerHTML"?l=d:c=="children"||c in g||c=="value"&&"defaultValue"in g||c=="checked"&&"defaultChecked"in g||dt(t,c,null,d,i);for(c in g)d=g[c],c=="children"?m=d:c=="dangerouslySetInnerHTML"?y=d:c=="value"?T=d:c=="checked"?x=d:p&&typeof d!="function"||v[c]===d||dt(t,c,d,v[c],i);if(y)p||l&&(y.__html==l.__html||y.__html==t.innerHTML)||(t.innerHTML=y.__html),e.__k=[];else if(l&&(t.innerHTML=""),Mr(e.type=="template"?t.content:t,gt(m)?m:[m],e,r,o,R=="foreignObject"?"http://www.w3.org/1999/xhtml":i,s,u,s?s[0]:r.__k&&De(r,0),p,f),s!=null)for(c=s.length;c--;)It(s[c]);p||(c="value",R=="progress"&&T==null?t.removeAttribute("value"):T!=null&&(T!==t[c]||R=="progress"&&!T||R=="option"&&T!=v[c])&&dt(t,c,T,v[c],i),c="checked",x!=null&&x!=t[c]&&dt(t,c,x,v[c],i))}return t}function Nt(t,e,r){try{if(typeof t=="function"){var o=typeof t.__u=="function";o&&t.__u(),o&&e==null||(t.__u=t(e))}else t.current=e}catch(i){P.__e(i,r)}}function Sr(t,e,r){var o,i;if(P.unmount&&P.unmount(t),(o=t.ref)&&(o.current&&o.current!=t.__e||Nt(o,null,e)),(o=t.__c)!=null){if(o.componentWillUnmount)try{o.componentWillUnmount()}catch(s){P.__e(s,e)}o.base=o.__P=null}if(o=t.__k)for(i=0;i<o.length;i++)o[i]&&Sr(o[i],e,r||typeof t.type!="function");r||It(t.__e),t.__c=t.__=t.__e=void 0}function go(t,e,r){return this.constructor(t,r)}function Gt(t,e,r){var o,i,s,u;e==document&&(e=document.documentElement),P.__&&P.__(t,e),i=(o=typeof r=="function")?null:r&&r.__k||e.__k,s=[],u=[],Vt(e,t=(!o&&r||e).__k=ho(b,null,[t]),i||mt,mt,e.namespaceURI,!o&&r?[r]:i?null:e.firstChild?vt.call(e.childNodes):null,s,!o&&r?r:i?i.__e:e.firstChild,o,u),Kr(s,t,u)}function Ke(t){function e(r){var o,i;return this.getChildContext||(o=new Set,(i={})[e.__c]=this,this.getChildContext=function(){return i},this.componentWillUnmount=function(){o=null},this.shouldComponentUpdate=function(s){this.props.value!=s.value&&o.forEach(function(u){u.__e=!0,Ut(u)})},this.sub=function(s){o.add(s);var u=s.componentWillUnmount;s.componentWillUnmount=function(){o&&o.delete(s),u&&u.call(s)}}),r.children}return e.__c="__cC"+Qr++,e.__=t,e.Provider=e.__l=(e.Consumer=function(r,o){return r.children(o)}).contextType=e,e}vt=Tt.slice,P={__e:function(t,e,r,o){for(var i,s,u;e=e.__;)if((i=e.__c)&&!i.__)try{if((s=i.constructor)&&s.getDerivedStateFromError!=null&&(i.setState(s.getDerivedStateFromError(t)),u=i.__d),i.componentDidCatch!=null&&(i.componentDidCatch(t,o||{}),u=i.__d),u)return i.__E=i}catch(p){t=p}throw t}},Cr=0,fo=function(t){return t!=null&&t.constructor===void 0},Me.prototype.setState=function(t,e){var r;r=this.__s!=null&&this.__s!=this.state?this.__s:this.__s=oe({},this.state),typeof t=="function"&&(t=t(oe({},r),this.props)),t&&oe(r,t),t!=null&&this.__v&&(e&&this._sb.push(e),Ut(this))},Me.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Ut(this))},Me.prototype.render=b,ue=[],Pr=typeof Promise=="function"?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Ar=function(t,e){return t.__v.__b-e.__v.__b},_t.__r=0,Or=/(PointerCapture)$|Capture$/i,Lt=0,Ft=wr(!1),St=wr(!0),Qr=0;var Y=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(t){return this.listeners.add(t),this.onSubscribe(),()=>{this.listeners.delete(t),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}};var _e,le,Fe,Ur,xo=(Ur=class extends Y{constructor(){super();_(this,_e);_(this,le);_(this,Fe);h(this,Fe,e=>{if(typeof window<"u"&&window.addEventListener){let r=()=>e();return window.addEventListener("visibilitychange",r,!1),()=>{window.removeEventListener("visibilitychange",r)}}})}onSubscribe(){a(this,le)||this.setEventListener(a(this,Fe))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,le))==null||e.call(this),h(this,le,void 0))}setEventListener(e){var r;h(this,Fe,e),(r=a(this,le))==null||r.call(this),h(this,le,e(o=>{typeof o=="boolean"?this.setFocused(o):this.onFocus()}))}setFocused(e){a(this,_e)!==e&&(h(this,_e,e),this.onFocus())}onFocus(){let e=this.isFocused();this.listeners.forEach(r=>{r(e)})}isFocused(){return typeof a(this,_e)=="boolean"?a(this,_e):globalThis.document?.visibilityState!=="hidden"}},_e=new WeakMap,le=new WeakMap,Fe=new WeakMap,Ur),Se=new xo;var bo={setTimeout:(t,e)=>setTimeout(t,e),clearTimeout:t=>clearTimeout(t),setInterval:(t,e)=>setInterval(t,e),clearInterval:t=>clearInterval(t)},pe,jt,kr,Ro=(kr=class{constructor(){_(this,pe,bo);_(this,jt,!1)}setTimeoutProvider(t){h(this,pe,t)}setTimeout(t,e){return a(this,pe).setTimeout(t,e)}clearTimeout(t){a(this,pe).clearTimeout(t)}setInterval(t,e){return a(this,pe).setInterval(t,e)}clearInterval(t){a(this,pe).clearInterval(t)}},pe=new WeakMap,jt=new WeakMap,kr),Z=new Ro;function Lr(t){setTimeout(t,0)}var Bt=typeof window>"u"||"Deno"in globalThis;function K(){}function Nr(t,e){return typeof t=="function"?t(e):t}function Ze(t){return typeof t=="number"&&t>=0&&t!==1/0}function xt(t,e){return Math.max(t+(e||0)-Date.now(),0)}function z(t,e){return typeof t=="function"?t(e):t}function I(t,e){return typeof t=="function"?t(e):t}function bt(t,e){let{type:r="all",exact:o,fetchStatus:i,predicate:s,queryKey:u,stale:p}=t;if(u){if(o){if(e.queryHash!==et(u,e.options))return!1}else if(!ge(e.queryKey,u))return!1}if(r!=="all"){let f=e.isActive();if(r==="active"&&!f||r==="inactive"&&f)return!1}return!(typeof p=="boolean"&&e.isStale()!==p||i&&i!==e.state.fetchStatus||s&&!s(e))}function Rt(t,e){let{exact:r,status:o,predicate:i,mutationKey:s}=t;if(s){if(!e.options.mutationKey)return!1;if(r){if(ve(e.options.mutationKey)!==ve(s))return!1}else if(!ge(e.options.mutationKey,s))return!1}return!(o&&e.state.status!==o||i&&!i(e))}function et(t,e){return(e?.queryKeyHashFn||ve)(t)}function ve(t){return JSON.stringify(t,(e,r)=>Ht(r)?Object.keys(r).sort().reduce((o,i)=>(o[i]=r[i],o),{}):r)}function ge(t,e){return t===e?!0:typeof t!=typeof e?!1:t&&e&&typeof t=="object"&&typeof e=="object"?Object.keys(e).every(r=>ge(t[r],e[r])):!1}var Eo=Object.prototype.hasOwnProperty;function Jt(t,e,r=0){if(t===e)return t;if(r>500)return e;let o=Ir(t)&&Ir(e);if(!o&&!(Ht(t)&&Ht(e)))return e;let s=(o?t:Object.keys(t)).length,u=o?e:Object.keys(e),p=u.length,f=o?new Array(p):{},c=0;for(let y=0;y<p;y++){let l=o?y:u[y],m=t[l],d=e[l];if(m===d){f[l]=m,(o?y<s:Eo.call(t,l))&&c++;continue}if(m===null||d===null||typeof m!="object"||typeof d!="object"){f[l]=d;continue}let T=Jt(m,d,r+1);f[l]=T,T===m&&c++}return s===p&&c===s?t:f}function Et(t,e){if(!e||Object.keys(t).length!==Object.keys(e).length)return!1;for(let r in t)if(t[r]!==e[r])return!1;return!0}function Ir(t){return Array.isArray(t)&&t.length===Object.keys(t).length}function Ht(t){if(!Vr(t))return!1;let e=t.constructor;if(e===void 0)return!0;let r=e.prototype;return!(!Vr(r)||!r.hasOwnProperty("isPrototypeOf")||Object.getPrototypeOf(t)!==Object.prototype)}function Vr(t){return Object.prototype.toString.call(t)==="[object Object]"}function Gr(t){return new Promise(e=>{Z.setTimeout(e,t)})}function tt(t,e,r){return typeof r.structuralSharing=="function"?r.structuralSharing(t,e):r.structuralSharing!==!1?Jt(t,e):e}function jr(t,e,r=0){let o=[...t,e];return r&&o.length>r?o.slice(1):o}function Hr(t,e,r=0){let o=[e,...t];return r&&o.length>r?o.slice(0,-1):o}var Ue=Symbol();function wt(t,e){return!t.queryFn&&e?.initialPromise?()=>e.initialPromise:!t.queryFn||t.queryFn===Ue?()=>Promise.reject(new Error(`Missing queryFn: '${t.queryHash}'`)):t.queryFn}function $t(t,e){return typeof t=="function"?t(...e):!!t}function Br(t,e,r){let o=!1,i;return Object.defineProperty(t,"signal",{enumerable:!0,get:()=>(i??(i=e()),o||(o=!0,i.aborted?r():i.addEventListener("abort",r,{once:!0})),i)}),t}var ee=(()=>{let t=()=>Bt;return{isServer(){return t()},setIsServer(e){t=e}}})();function rt(){let t,e,r=new Promise((i,s)=>{t=i,e=s});r.status="pending",r.catch(()=>{});function o(i){Object.assign(r,i),delete r.resolve,delete r.reject}return r.resolve=i=>{o({status:"fulfilled",value:i}),t(i)},r.reject=i=>{o({status:"rejected",reason:i}),e(i)},r}var Jr=Lr;function wo(){let t=[],e=0,r=p=>{p()},o=p=>{p()},i=Jr,s=p=>{e?t.push(p):i(()=>{r(p)})},u=()=>{let p=t;t=[],p.length&&i(()=>{o(()=>{p.forEach(f=>{r(f)})})})};return{batch:p=>{let f;e++;try{f=p()}finally{e--,e||u()}return f},batchCalls:p=>(...f)=>{s(()=>{p(...f)})},schedule:s,setNotifyFunction:p=>{r=p},setBatchNotifyFunction:p=>{o=p},setScheduler:p=>{i=p}}}var A=wo();var ke,ce,Le,$r,Co=($r=class extends Y{constructor(){super();_(this,ke,!0);_(this,ce);_(this,Le);h(this,Le,e=>{if(typeof window<"u"&&window.addEventListener){let r=()=>e(!0),o=()=>e(!1);return window.addEventListener("online",r,!1),window.addEventListener("offline",o,!1),()=>{window.removeEventListener("online",r),window.removeEventListener("offline",o)}}})}onSubscribe(){a(this,ce)||this.setEventListener(a(this,Le))}onUnsubscribe(){var e;this.hasListeners()||((e=a(this,ce))==null||e.call(this),h(this,ce,void 0))}setEventListener(e){var r;h(this,Le,e),(r=a(this,ce))==null||r.call(this),h(this,ce,e(this.setOnline.bind(this)))}setOnline(e){a(this,ke)!==e&&(h(this,ke,e),this.listeners.forEach(o=>{o(e)}))}isOnline(){return a(this,ke)}},ke=new WeakMap,ce=new WeakMap,Le=new WeakMap,$r),Ie=new Co;function Po(t){return Math.min(1e3*2**t,3e4)}function Wt(t){return(t??"online")==="online"?Ie.isOnline():!0}var Ct=class extends Error{constructor(t){super("CancelledError"),this.revert=t?.revert,this.silent=t?.silent}};function Pt(t){let e=!1,r=0,o,i=rt(),s=()=>i.status!=="pending",u=x=>{if(!s()){let v=new Ct(x);m(v),t.onCancel?.(v)}},p=()=>{e=!0},f=()=>{e=!1},c=()=>Se.isFocused()&&(t.networkMode==="always"||Ie.isOnline())&&t.canRun(),y=()=>Wt(t.networkMode)&&t.canRun(),l=x=>{s()||(o?.(),i.resolve(x))},m=x=>{s()||(o?.(),i.reject(x))},d=()=>new Promise(x=>{o=v=>{(s()||c())&&x(v)},t.onPause?.()}).then(()=>{o=void 0,s()||t.onContinue?.()}),T=()=>{if(s())return;let x,v=r===0?t.initialPromise:void 0;try{x=v??t.fn()}catch(g){x=Promise.reject(g)}Promise.resolve(x).then(l).catch(g=>{if(s())return;let R=t.retry??(ee.isServer()?0:3),q=t.retryDelay??Po,F=typeof q=="function"?q(r,g):q,L=R===!0||typeof R=="number"&&r<R||typeof R=="function"&&R(r,g);if(e||!L){m(g);return}r++,t.onFail?.(r,g),Gr(F).then(()=>c()?void 0:d()).then(()=>{e?m(g):T()})})};return{promise:i,status:()=>i.status,cancel:u,continue:()=>(o?.(),i),cancelRetry:p,continueRetry:f,canStart:y,start:()=>(y()?T():d().then(T),i)}}var xe,Wr,At=(Wr=class{constructor(){_(this,xe)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),Ze(this.gcTime)&&h(this,xe,Z.setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(t){this.gcTime=Math.max(this.gcTime||0,t??(ee.isServer()?1/0:300*1e3))}clearGcTimeout(){a(this,xe)!==void 0&&(Z.clearTimeout(a(this,xe)),h(this,xe,void 0))}},xe=new WeakMap,Wr);function Xr(t){return{onFetch:(e,r)=>{let o=e.options,i=e.fetchOptions?.meta?.fetchMore?.direction,s=e.state.data?.pages||[],u=e.state.data?.pageParams||[],p={pages:[],pageParams:[]},f=0,c=async()=>{let y=!1,l=T=>{Br(T,()=>e.signal,()=>y=!0)},m=wt(e.options,e.fetchOptions),d=async(T,x,v)=>{if(y)return Promise.reject(e.signal.reason);if(x==null&&T.pages.length)return Promise.resolve(T);let R=(()=>{let W={client:e.client,queryKey:e.queryKey,pageParam:x,direction:v?"backward":"forward",meta:e.options.meta};return l(W),W})(),q=await m(R),{maxPages:F}=e.options,L=v?Hr:jr;return{pages:L(T.pages,q,F),pageParams:L(T.pageParams,x,F)}};if(i&&s.length){let T=i==="backward",x=T?Ao:zr,v={pages:s,pageParams:u},g=x(o,v);p=await d(v,g,T)}else{let T=t??s.length;do{let x=f===0?u[0]??o.initialPageParam:zr(o,p);if(f>0&&x==null)break;p=await d(p,x),f++}while(f<T)}return p};e.options.persister?e.fetchFn=()=>e.options.persister?.(c,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},r):e.fetchFn=c}}}function zr(t,{pages:e,pageParams:r}){let o=e.length-1;return e.length>0?t.getNextPageParam(e[o],e,r[o],r):void 0}function Ao(t,{pages:e,pageParams:r}){return e.length>0?t.getPreviousPageParam?.(e[0],e,r[0],r):void 0}var Ve,be,Ne,J,Re,S,nt,Ee,j,rn,se,en,tn=(en=class extends At{constructor(e){super();_(this,j);_(this,Ve);_(this,be);_(this,Ne);_(this,J);_(this,Re);_(this,S);_(this,nt);_(this,Ee);h(this,Ee,!1),h(this,nt,e.defaultOptions),this.setOptions(e.options),this.observers=[],h(this,Re,e.client),h(this,J,a(this,Re).getQueryCache()),this.queryKey=e.queryKey,this.queryHash=e.queryHash,h(this,be,Zr(this.options)),this.state=e.state??a(this,be),this.scheduleGc()}get meta(){return this.options.meta}get queryType(){return a(this,Ve)}get promise(){return a(this,S)?.promise}setOptions(e){if(this.options={...a(this,nt),...e},e?._type&&h(this,Ve,e._type),this.updateGcTime(this.options.gcTime),this.state&&this.state.data===void 0){let r=Zr(this.options);r.data!==void 0&&(this.setState(Yr(r.data,r.dataUpdatedAt)),h(this,be,r))}}optionalRemove(){!this.observers.length&&this.state.fetchStatus==="idle"&&a(this,J).remove(this)}setData(e,r){let o=tt(this.state.data,e,this.options);return E(this,j,se).call(this,{data:o,type:"success",dataUpdatedAt:r?.updatedAt,manual:r?.manual}),o}setState(e){E(this,j,se).call(this,{type:"setState",state:e})}cancel(e){let r=a(this,S)?.promise;return a(this,S)?.cancel(e),r?r.then(K).catch(K):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}get resetState(){return a(this,be)}reset(){this.destroy(),this.setState(this.resetState)}isActive(){return this.observers.some(e=>I(e.options.enabled,this)!==!1)}isDisabled(){return this.getObserversCount()>0?!this.isActive():this.options.queryFn===Ue||!this.isFetched()}isFetched(){return this.state.dataUpdateCount+this.state.errorUpdateCount>0}isStatic(){return this.getObserversCount()>0?this.observers.some(e=>z(e.options.staleTime,this)==="static"):!1}isStale(){return this.getObserversCount()>0?this.observers.some(e=>e.getCurrentResult().isStale):this.state.data===void 0||this.state.isInvalidated}isStaleByTime(e=0){return this.state.data===void 0?!0:e==="static"?!1:this.state.isInvalidated?!0:!xt(this.state.dataUpdatedAt,e)}onFocus(){this.observers.find(r=>r.shouldFetchOnWindowFocus())?.refetch({cancelRefetch:!1}),a(this,S)?.continue()}onOnline(){this.observers.find(r=>r.shouldFetchOnReconnect())?.refetch({cancelRefetch:!1}),a(this,S)?.continue()}addObserver(e){this.observers.includes(e)||(this.observers.push(e),this.clearGcTimeout(),a(this,J).notify({type:"observerAdded",query:this,observer:e}))}removeObserver(e){this.observers.includes(e)&&(this.observers=this.observers.filter(r=>r!==e),this.observers.length||(a(this,S)&&(a(this,Ee)||E(this,j,rn).call(this)?a(this,S).cancel({revert:!0}):a(this,S).cancelRetry()),this.scheduleGc()),a(this,J).notify({type:"observerRemoved",query:this,observer:e}))}getObserversCount(){return this.observers.length}invalidate(){this.state.isInvalidated||E(this,j,se).call(this,{type:"invalidate"})}async fetch(e,r){if(this.state.fetchStatus!=="idle"&&a(this,S)?.status()!=="rejected"){if(this.state.data!==void 0&&r?.cancelRefetch)this.cancel({silent:!0});else if(a(this,S))return a(this,S).continueRetry(),a(this,S).promise}if(e&&this.setOptions(e),!this.options.queryFn){let c=this.observers.find(y=>y.options.queryFn);c&&this.setOptions(c.options)}let o=new AbortController,i=c=>{Object.defineProperty(c,"signal",{enumerable:!0,get:()=>(h(this,Ee,!0),o.signal)})},s=()=>{let c=wt(this.options,r),l=(()=>{let m={client:a(this,Re),queryKey:this.queryKey,meta:this.meta};return i(m),m})();return h(this,Ee,!1),this.options.persister?this.options.persister(c,l,this):c(l)},p=(()=>{let c={fetchOptions:r,options:this.options,queryKey:this.queryKey,client:a(this,Re),state:this.state,fetchFn:s};return i(c),c})();(a(this,Ve)==="infinite"?Xr(this.options.pages):this.options.behavior)?.onFetch(p,this),h(this,Ne,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==p.fetchOptions?.meta)&&E(this,j,se).call(this,{type:"fetch",meta:p.fetchOptions?.meta}),h(this,S,Pt({initialPromise:r?.initialPromise,fn:p.fetchFn,onCancel:c=>{c instanceof Ct&&c.revert&&this.setState({...a(this,Ne),fetchStatus:"idle"}),o.abort()},onFail:(c,y)=>{E(this,j,se).call(this,{type:"failed",failureCount:c,error:y})},onPause:()=>{E(this,j,se).call(this,{type:"pause"})},onContinue:()=>{E(this,j,se).call(this,{type:"continue"})},retry:p.options.retry,retryDelay:p.options.retryDelay,networkMode:p.options.networkMode,canRun:()=>!0}));try{let c=await a(this,S).start();if(c===void 0)throw new Error(`${this.queryHash} data is undefined`);return this.setData(c),a(this,J).config.onSuccess?.(c,this),a(this,J).config.onSettled?.(c,this.state.error,this),c}catch(c){if(c instanceof Ct){if(c.silent)return a(this,S).promise;if(c.revert){if(this.state.data===void 0)throw c;return this.state.data}}throw E(this,j,se).call(this,{type:"error",error:c}),a(this,J).config.onError?.(c,this),a(this,J).config.onSettled?.(this.state.data,c,this),c}finally{this.scheduleGc()}}},Ve=new WeakMap,be=new WeakMap,Ne=new WeakMap,J=new WeakMap,Re=new WeakMap,S=new WeakMap,nt=new WeakMap,Ee=new WeakMap,j=new WeakSet,rn=function(){return this.state.fetchStatus==="paused"&&this.state.status==="pending"},se=function(e){let r=o=>{switch(e.type){case"failed":return{...o,fetchFailureCount:e.failureCount,fetchFailureReason:e.error};case"pause":return{...o,fetchStatus:"paused"};case"continue":return{...o,fetchStatus:"fetching"};case"fetch":return{...o,...zt(o.data,this.options),fetchMeta:e.meta??null};case"success":let i={...o,...Yr(e.data,e.dataUpdatedAt),dataUpdateCount:o.dataUpdateCount+1,...!e.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};return h(this,Ne,e.manual?i:void 0),i;case"error":let s=e.error;return{...o,error:s,errorUpdateCount:o.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:o.fetchFailureCount+1,fetchFailureReason:s,fetchStatus:"idle",status:"error",isInvalidated:!0};case"invalidate":return{...o,isInvalidated:!0};case"setState":return{...o,...e.state}}};this.state=r(this.state),A.batch(()=>{this.observers.forEach(o=>{o.onQueryUpdate()}),a(this,J).notify({query:this,type:"updated",action:e})})},en);function zt(t,e){return{fetchFailureCount:0,fetchFailureReason:null,fetchStatus:Wt(e.networkMode)?"fetching":"paused",...t===void 0&&{error:null,status:"pending"}}}function Yr(t,e){return{data:t,dataUpdatedAt:e??Date.now(),error:null,isInvalidated:!1,status:"success"}}function Zr(t){let e=typeof t.initialData=="function"?t.initialData():t.initialData,r=e!==void 0,o=r?typeof t.initialDataUpdatedAt=="function"?t.initialDataUpdatedAt():t.initialDataUpdatedAt:0;return{data:e,dataUpdateCount:0,dataUpdatedAt:r?o??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:r?"success":"pending",fetchStatus:"idle"}}var N,w,st,V,we,Ge,ie,fe,it,je,He,Ce,Pe,ye,Be,C,ot,Xt,Yt,Zt,er,tr,rr,nr,an,sn,sr=(sn=class extends Y{constructor(e,r){super();_(this,C);_(this,N);_(this,w);_(this,st);_(this,V);_(this,we);_(this,Ge);_(this,ie);_(this,fe);_(this,it);_(this,je);_(this,He);_(this,Ce);_(this,Pe);_(this,ye);_(this,Be,new Set);this.options=r,h(this,N,e),h(this,fe,null),h(this,ie,rt()),this.bindMethods(),this.setOptions(r)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(a(this,w).addObserver(this),nn(a(this,w),this.options)?E(this,C,ot).call(this):this.updateResult(),E(this,C,er).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return or(a(this,w),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return or(a(this,w),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,E(this,C,tr).call(this),E(this,C,rr).call(this),a(this,w).removeObserver(this)}setOptions(e){let r=this.options,o=a(this,w);if(this.options=a(this,N).defaultQueryOptions(e),this.options.enabled!==void 0&&typeof this.options.enabled!="boolean"&&typeof this.options.enabled!="function"&&typeof I(this.options.enabled,a(this,w))!="boolean")throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");E(this,C,nr).call(this),a(this,w).setOptions(this.options),r._defaulted&&!Et(this.options,r)&&a(this,N).getQueryCache().notify({type:"observerOptionsUpdated",query:a(this,w),observer:this});let i=this.hasListeners();i&&on(a(this,w),o,this.options,r)&&E(this,C,ot).call(this),this.updateResult(),i&&(a(this,w)!==o||I(this.options.enabled,a(this,w))!==I(r.enabled,a(this,w))||z(this.options.staleTime,a(this,w))!==z(r.staleTime,a(this,w)))&&E(this,C,Xt).call(this);let s=E(this,C,Yt).call(this);i&&(a(this,w)!==o||I(this.options.enabled,a(this,w))!==I(r.enabled,a(this,w))||s!==a(this,ye))&&E(this,C,Zt).call(this,s)}getOptimisticResult(e){let r=a(this,N).getQueryCache().build(a(this,N),e),o=this.createResult(r,e);return Qo(this,o)&&(h(this,V,o),h(this,Ge,this.options),h(this,we,a(this,w).state)),o}getCurrentResult(){return a(this,V)}trackResult(e,r){return new Proxy(e,{get:(o,i)=>(this.trackProp(i),r?.(i),i==="promise"&&(this.trackProp("data"),!this.options.experimental_prefetchInRender&&a(this,ie).status==="pending"&&a(this,ie).reject(new Error("experimental_prefetchInRender feature flag is not enabled"))),Reflect.get(o,i))})}trackProp(e){a(this,Be).add(e)}getCurrentQuery(){return a(this,w)}refetch({...e}={}){return this.fetch({...e})}fetchOptimistic(e){let r=a(this,N).defaultQueryOptions(e),o=a(this,N).getQueryCache().build(a(this,N),r);return o.fetch().then(()=>this.createResult(o,r))}fetch(e){return E(this,C,ot).call(this,{...e,cancelRefetch:e.cancelRefetch??!0}).then(()=>(this.updateResult(),a(this,V)))}createResult(e,r){let o=a(this,w),i=this.options,s=a(this,V),u=a(this,we),p=a(this,Ge),c=e!==o?e.state:a(this,st),{state:y}=e,l={...y},m=!1,d;if(r._optimisticResults){let Q=this.hasListeners(),B=!Q&&nn(e,r),ct=Q&&on(e,o,r,i);(B||ct)&&(l={...l,...zt(y.data,e.options)}),r._optimisticResults==="isRestoring"&&(l.fetchStatus="idle")}let{error:T,errorUpdatedAt:x,status:v}=l;d=l.data;let g=!1;if(r.placeholderData!==void 0&&d===void 0&&v==="pending"){let Q;s?.isPlaceholderData&&r.placeholderData===p?.placeholderData?(Q=s.data,g=!0):Q=typeof r.placeholderData=="function"?r.placeholderData(a(this,He)?.state.data,a(this,He)):r.placeholderData,Q!==void 0&&(v="success",d=tt(s?.data,Q,r),m=!0)}if(r.select&&d!==void 0&&!g)if(s&&d===u?.data&&r.select===a(this,it))d=a(this,je);else try{h(this,it,r.select),d=r.select(d),d=tt(s?.data,d,r),h(this,je,d),h(this,fe,null)}catch(Q){h(this,fe,Q)}a(this,fe)&&(T=a(this,fe),d=a(this,je),x=Date.now(),v="error");let R=l.fetchStatus==="fetching",q=v==="pending",F=v==="error",L=q&&R,W=d!==void 0,H={status:v,fetchStatus:l.fetchStatus,isPending:q,isSuccess:v==="success",isError:F,isInitialLoading:L,isLoading:L,data:d,dataUpdatedAt:l.dataUpdatedAt,error:T,errorUpdatedAt:x,failureCount:l.fetchFailureCount,failureReason:l.fetchFailureReason,errorUpdateCount:l.errorUpdateCount,isFetched:e.isFetched(),isFetchedAfterMount:l.dataUpdateCount>c.dataUpdateCount||l.errorUpdateCount>c.errorUpdateCount,isFetching:R,isRefetching:R&&!q,isLoadingError:F&&!W,isPaused:l.fetchStatus==="paused",isPlaceholderData:m,isRefetchError:F&&W,isStale:ir(e,r),refetch:this.refetch,promise:a(this,ie),isEnabled:I(r.enabled,e)!==!1};if(this.options.experimental_prefetchInRender){let Q=H.data!==void 0,B=H.status==="error"&&!Q,ct=yt=>{B?yt.reject(H.error):Q&&yt.resolve(H.data)},xr=()=>{let yt=h(this,ie,H.promise=rt());ct(yt)},ft=a(this,ie);switch(ft.status){case"pending":e.queryHash===o.queryHash&&ct(ft);break;case"fulfilled":(B||H.data!==ft.value)&&xr();break;case"rejected":(!B||H.error!==ft.reason)&&xr();break}}return H}updateResult(){let e=a(this,V),r=this.createResult(a(this,w),this.options);if(h(this,we,a(this,w).state),h(this,Ge,this.options),a(this,we).data!==void 0&&h(this,He,a(this,w)),Et(r,e))return;h(this,V,r);let o=()=>{if(!e)return!0;let{notifyOnChangeProps:i}=this.options,s=typeof i=="function"?i():i;if(s==="all"||!s&&!a(this,Be).size)return!0;let u=new Set(s??a(this,Be));return this.options.throwOnError&&u.add("error"),Object.keys(a(this,V)).some(p=>{let f=p;return a(this,V)[f]!==e[f]&&u.has(f)})};E(this,C,an).call(this,{listeners:o()})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&E(this,C,er).call(this)}},N=new WeakMap,w=new WeakMap,st=new WeakMap,V=new WeakMap,we=new WeakMap,Ge=new WeakMap,ie=new WeakMap,fe=new WeakMap,it=new WeakMap,je=new WeakMap,He=new WeakMap,Ce=new WeakMap,Pe=new WeakMap,ye=new WeakMap,Be=new WeakMap,C=new WeakSet,ot=function(e){E(this,C,nr).call(this);let r=a(this,w).fetch(this.options,e);return e?.throwOnError||(r=r.catch(K)),r},Xt=function(){E(this,C,tr).call(this);let e=z(this.options.staleTime,a(this,w));if(ee.isServer()||a(this,V).isStale||!Ze(e))return;let o=xt(a(this,V).dataUpdatedAt,e)+1;h(this,Ce,Z.setTimeout(()=>{a(this,V).isStale||this.updateResult()},o))},Yt=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(a(this,w)):this.options.refetchInterval)??!1},Zt=function(e){E(this,C,rr).call(this),h(this,ye,e),!(ee.isServer()||I(this.options.enabled,a(this,w))===!1||!Ze(a(this,ye))||a(this,ye)===0)&&h(this,Pe,Z.setInterval(()=>{(this.options.refetchIntervalInBackground||Se.isFocused())&&E(this,C,ot).call(this)},a(this,ye)))},er=function(){E(this,C,Xt).call(this),E(this,C,Zt).call(this,E(this,C,Yt).call(this))},tr=function(){a(this,Ce)!==void 0&&(Z.clearTimeout(a(this,Ce)),h(this,Ce,void 0))},rr=function(){a(this,Pe)!==void 0&&(Z.clearInterval(a(this,Pe)),h(this,Pe,void 0))},nr=function(){let e=a(this,N).getQueryCache().build(a(this,N),this.options);if(e===a(this,w))return;let r=a(this,w);h(this,w,e),h(this,st,e.state),this.hasListeners()&&(r?.removeObserver(this),e.addObserver(this))},an=function(e){A.batch(()=>{e.listeners&&this.listeners.forEach(r=>{r(a(this,V))}),a(this,N).getQueryCache().notify({query:a(this,w),type:"observerResultsUpdated"})})},sn);function Oo(t,e){return I(e.enabled,t)!==!1&&t.state.data===void 0&&!(t.state.status==="error"&&I(e.retryOnMount,t)===!1)}function nn(t,e){return Oo(t,e)||t.state.data!==void 0&&or(t,e,e.refetchOnMount)}function or(t,e,r){if(I(e.enabled,t)!==!1&&z(e.staleTime,t)!=="static"){let o=typeof r=="function"?r(t):r;return o==="always"||o!==!1&&ir(t,e)}return!1}function on(t,e,r,o){return(t!==e||I(o.enabled,t)===!1)&&(!r.suspense||t.state.status!=="error")&&ir(t,r)}function ir(t,e){return I(e.enabled,t)!==!1&&t.isStaleByTime(z(e.staleTime,t))}function Qo(t,e){return!Et(t.getCurrentResult(),e)}var at,te,k,Ae,re,de,un,ln=(un=class extends At{constructor(e){super();_(this,re);_(this,at);_(this,te);_(this,k);_(this,Ae);h(this,at,e.client),this.mutationId=e.mutationId,h(this,k,e.mutationCache),h(this,te,[]),this.state=e.state||qo(),this.setOptions(e.options),this.scheduleGc()}setOptions(e){this.options=e,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(e){a(this,te).includes(e)||(a(this,te).push(e),this.clearGcTimeout(),a(this,k).notify({type:"observerAdded",mutation:this,observer:e}))}removeObserver(e){h(this,te,a(this,te).filter(r=>r!==e)),this.scheduleGc(),a(this,k).notify({type:"observerRemoved",mutation:this,observer:e})}optionalRemove(){a(this,te).length||(this.state.status==="pending"?this.scheduleGc():a(this,k).remove(this))}continue(){return a(this,Ae)?.continue()??this.execute(this.state.variables)}async execute(e){let r=()=>{E(this,re,de).call(this,{type:"continue"})},o={client:a(this,at),meta:this.options.meta,mutationKey:this.options.mutationKey};h(this,Ae,Pt({fn:()=>this.options.mutationFn?this.options.mutationFn(e,o):Promise.reject(new Error("No mutationFn found")),onFail:(u,p)=>{E(this,re,de).call(this,{type:"failed",failureCount:u,error:p})},onPause:()=>{E(this,re,de).call(this,{type:"pause"})},onContinue:r,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>a(this,k).canRun(this)}));let i=this.state.status==="pending",s=!a(this,Ae).canStart();try{if(i)r();else{E(this,re,de).call(this,{type:"pending",variables:e,isPaused:s}),a(this,k).config.onMutate&&await a(this,k).config.onMutate(e,this,o);let p=await this.options.onMutate?.(e,o);p!==this.state.context&&E(this,re,de).call(this,{type:"pending",context:p,variables:e,isPaused:s})}let u=await a(this,Ae).start();return await a(this,k).config.onSuccess?.(u,e,this.state.context,this,o),await this.options.onSuccess?.(u,e,this.state.context,o),await a(this,k).config.onSettled?.(u,null,this.state.variables,this.state.context,this,o),await this.options.onSettled?.(u,null,e,this.state.context,o),E(this,re,de).call(this,{type:"success",data:u}),u}catch(u){try{await a(this,k).config.onError?.(u,e,this.state.context,this,o)}catch(p){Promise.reject(p)}try{await this.options.onError?.(u,e,this.state.context,o)}catch(p){Promise.reject(p)}try{await a(this,k).config.onSettled?.(void 0,u,this.state.variables,this.state.context,this,o)}catch(p){Promise.reject(p)}try{await this.options.onSettled?.(void 0,u,e,this.state.context,o)}catch(p){Promise.reject(p)}throw E(this,re,de).call(this,{type:"error",error:u}),u}finally{a(this,k).runNext(this)}}},at=new WeakMap,te=new WeakMap,k=new WeakMap,Ae=new WeakMap,re=new WeakSet,de=function(e){let r=o=>{switch(e.type){case"failed":return{...o,failureCount:e.failureCount,failureReason:e.error};case"pause":return{...o,isPaused:!0};case"continue":return{...o,isPaused:!1};case"pending":return{...o,context:e.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:e.isPaused,status:"pending",variables:e.variables,submittedAt:Date.now()};case"success":return{...o,data:e.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...o,data:void 0,error:e.error,failureCount:o.failureCount+1,failureReason:e.error,isPaused:!1,status:"error"}}};this.state=r(this.state),A.batch(()=>{a(this,te).forEach(o=>{o.onMutationUpdate(e)}),a(this,k).notify({mutation:this,type:"updated",action:e})})},un);function qo(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var ae,X,ut,pn,cn=(pn=class extends Y{constructor(e={}){super();_(this,ae);_(this,X);_(this,ut);this.config=e,h(this,ae,new Set),h(this,X,new Map),h(this,ut,0)}build(e,r,o){let i=new ln({client:e,mutationCache:this,mutationId:++Ye(this,ut)._,options:e.defaultMutationOptions(r),state:o});return this.add(i),i}add(e){a(this,ae).add(e);let r=Ot(e);if(typeof r=="string"){let o=a(this,X).get(r);o?o.push(e):a(this,X).set(r,[e])}this.notify({type:"added",mutation:e})}remove(e){if(a(this,ae).delete(e)){let r=Ot(e);if(typeof r=="string"){let o=a(this,X).get(r);if(o)if(o.length>1){let i=o.indexOf(e);i!==-1&&o.splice(i,1)}else o[0]===e&&a(this,X).delete(r)}}this.notify({type:"removed",mutation:e})}canRun(e){let r=Ot(e);if(typeof r=="string"){let i=a(this,X).get(r)?.find(s=>s.state.status==="pending");return!i||i===e}else return!0}runNext(e){let r=Ot(e);return typeof r=="string"?a(this,X).get(r)?.find(i=>i!==e&&i.state.isPaused)?.continue()??Promise.resolve():Promise.resolve()}clear(){A.batch(()=>{a(this,ae).forEach(e=>{this.notify({type:"removed",mutation:e})}),a(this,ae).clear(),a(this,X).clear()})}getAll(){return Array.from(a(this,ae))}find(e){let r={exact:!0,...e};return this.getAll().find(o=>Rt(r,o))}findAll(e={}){return this.getAll().filter(r=>Rt(e,r))}notify(e){A.batch(()=>{this.listeners.forEach(r=>{r(e)})})}resumePausedMutations(){let e=this.getAll().filter(r=>r.state.isPaused);return A.batch(()=>Promise.all(e.map(r=>r.continue().catch(K))))}},ae=new WeakMap,X=new WeakMap,ut=new WeakMap,pn);function Ot(t){return t.options.scope?.id}var ne,fn,yn=(fn=class extends Y{constructor(e={}){super();_(this,ne);this.config=e,h(this,ne,new Map)}build(e,r,o){let i=r.queryKey,s=r.queryHash??et(i,r),u=this.get(s);return u||(u=new tn({client:e,queryKey:i,queryHash:s,options:e.defaultQueryOptions(r),state:o,defaultOptions:e.getQueryDefaults(i)}),this.add(u)),u}add(e){a(this,ne).has(e.queryHash)||(a(this,ne).set(e.queryHash,e),this.notify({type:"added",query:e}))}remove(e){let r=a(this,ne).get(e.queryHash);r&&(e.destroy(),r===e&&a(this,ne).delete(e.queryHash),this.notify({type:"removed",query:e}))}clear(){A.batch(()=>{this.getAll().forEach(e=>{this.remove(e)})})}get(e){return a(this,ne).get(e)}getAll(){return[...a(this,ne).values()]}find(e){let r={exact:!0,...e};return this.getAll().find(o=>bt(r,o))}findAll(e={}){let r=this.getAll();return Object.keys(e).length>0?r.filter(o=>bt(e,o)):r}notify(e){A.batch(()=>{this.listeners.forEach(r=>{r(e)})})}onFocus(){A.batch(()=>{this.getAll().forEach(e=>{e.onFocus()})})}onOnline(){A.batch(()=>{this.getAll().forEach(e=>{e.onOnline()})})}},ne=new WeakMap,fn);var M,he,me,Je,$e,Te,We,ze,dn,ar=(dn=class{constructor(t={}){_(this,M);_(this,he);_(this,me);_(this,Je);_(this,$e);_(this,Te);_(this,We);_(this,ze);h(this,M,t.queryCache||new yn),h(this,he,t.mutationCache||new cn),h(this,me,t.defaultOptions||{}),h(this,Je,new Map),h(this,$e,new Map),h(this,Te,0)}mount(){Ye(this,Te)._++,a(this,Te)===1&&(h(this,We,Se.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,M).onFocus())})),h(this,ze,Ie.subscribe(async t=>{t&&(await this.resumePausedMutations(),a(this,M).onOnline())})))}unmount(){var t,e;Ye(this,Te)._--,a(this,Te)===0&&((t=a(this,We))==null||t.call(this),h(this,We,void 0),(e=a(this,ze))==null||e.call(this),h(this,ze,void 0))}isFetching(t){return a(this,M).findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return a(this,he).findAll({...t,status:"pending"}).length}getQueryData(t){let e=this.defaultQueryOptions({queryKey:t});return a(this,M).get(e.queryHash)?.state.data}ensureQueryData(t){let e=this.defaultQueryOptions(t),r=a(this,M).build(this,e),o=r.state.data;return o===void 0?this.fetchQuery(t):(t.revalidateIfStale&&r.isStaleByTime(z(e.staleTime,r))&&this.prefetchQuery(e),Promise.resolve(o))}getQueriesData(t){return a(this,M).findAll(t).map(({queryKey:e,state:r})=>{let o=r.data;return[e,o]})}setQueryData(t,e,r){let o=this.defaultQueryOptions({queryKey:t}),s=a(this,M).get(o.queryHash)?.state.data,u=Nr(e,s);if(u!==void 0)return a(this,M).build(this,o).setData(u,{...r,manual:!0})}setQueriesData(t,e,r){return A.batch(()=>a(this,M).findAll(t).map(({queryKey:o})=>[o,this.setQueryData(o,e,r)]))}getQueryState(t){let e=this.defaultQueryOptions({queryKey:t});return a(this,M).get(e.queryHash)?.state}removeQueries(t){let e=a(this,M);A.batch(()=>{e.findAll(t).forEach(r=>{e.remove(r)})})}resetQueries(t,e){let r=a(this,M);return A.batch(()=>(r.findAll(t).forEach(o=>{o.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){let r={revert:!0,...e},o=A.batch(()=>a(this,M).findAll(t).map(i=>i.cancel(r)));return Promise.all(o).then(K).catch(K)}invalidateQueries(t,e={}){return A.batch(()=>(a(this,M).findAll(t).forEach(r=>{r.invalidate()}),t?.refetchType==="none"?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){let r={...e,cancelRefetch:e.cancelRefetch??!0},o=A.batch(()=>a(this,M).findAll(t).filter(i=>!i.isDisabled()&&!i.isStatic()).map(i=>{let s=i.fetch(void 0,r);return r.throwOnError||(s=s.catch(K)),i.state.fetchStatus==="paused"?Promise.resolve():s}));return Promise.all(o).then(K)}fetchQuery(t){let e=this.defaultQueryOptions(t);e.retry===void 0&&(e.retry=!1);let r=a(this,M).build(this,e);return r.isStaleByTime(z(e.staleTime,r))?r.fetch(e):Promise.resolve(r.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(K).catch(K)}fetchInfiniteQuery(t){return t._type="infinite",this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(K).catch(K)}ensureInfiniteQueryData(t){return t._type="infinite",this.ensureQueryData(t)}resumePausedMutations(){return Ie.isOnline()?a(this,he).resumePausedMutations():Promise.resolve()}getQueryCache(){return a(this,M)}getMutationCache(){return a(this,he)}getDefaultOptions(){return a(this,me)}setDefaultOptions(t){h(this,me,t)}setQueryDefaults(t,e){a(this,Je).set(ve(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){let e=[...a(this,Je).values()],r={};return e.forEach(o=>{ge(t,o.queryKey)&&Object.assign(r,o.defaultOptions)}),r}setMutationDefaults(t,e){a(this,$e).set(ve(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){let e=[...a(this,$e).values()],r={};return e.forEach(o=>{ge(t,o.mutationKey)&&Object.assign(r,o.defaultOptions)}),r}defaultQueryOptions(t){if(t._defaulted)return t;let e={...a(this,me).queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=et(e.queryKey,e)),e.refetchOnReconnect===void 0&&(e.refetchOnReconnect=e.networkMode!=="always"),e.throwOnError===void 0&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===Ue&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...a(this,me).mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){a(this,M).clear(),a(this,he).clear()}},M=new WeakMap,he=new WeakMap,me=new WeakMap,Je=new WeakMap,$e=new WeakMap,Te=new WeakMap,We=new WeakMap,ze=new WeakMap,dn);var Oe,O,ur,hn,lt=0,Rn=[],D=P,mn=D.__b,Tn=D.__r,_n=D.diffed,vn=D.__c,gn=D.unmount,xn=D.__;function pt(t,e){D.__h&&D.__h(O,t,lt||e),lt=0;var r=O.__H||(O.__H={__:[],__h:[]});return t>=r.__.length&&r.__.push({}),r.__[t]}function Qe(t){return lt=1,Mo(Cn,t)}function Mo(t,e,r){var o=pt(Oe++,2);if(o.t=t,!o.__c&&(o.__=[r?r(e):Cn(void 0,e),function(p){var f=o.__N?o.__N[0]:o.__[0],c=o.t(f,p);f!==c&&(o.__N=[c,o.__[1]],o.__c.setState({}))}],o.__c=O,!O.__f)){var i=function(p,f,c){if(!o.__c.__H)return!0;var y=o.__c.__H.__.filter(function(m){return m.__c});if(y.every(function(m){return!m.__N}))return!s||s.call(this,p,f,c);var l=o.__c.props!==p;return y.some(function(m){if(m.__N){var d=m.__[0];m.__=m.__N,m.__N=void 0,d!==m.__[0]&&(l=!0)}}),s&&s.call(this,p,f,c)||l};O.__f=!0;var s=O.shouldComponentUpdate,u=O.componentWillUpdate;O.componentWillUpdate=function(p,f,c){if(this.__e){var y=s;s=void 0,i(p,f,c),s=y}u&&u.call(this,p,f,c)},O.shouldComponentUpdate=i}return o.__N||o.__}function $(t,e){var r=pt(Oe++,3);!D.__s&&pr(r.__H,e)&&(r.__=t,r.u=e,O.__H.__h.push(r))}function qt(t,e){var r=pt(Oe++,4);!D.__s&&pr(r.__H,e)&&(r.__=t,r.u=e,O.__h.push(r))}function qe(t){return lt=5,En(function(){return{current:t}},[])}function En(t,e){var r=pt(Oe++,7);return pr(r.__H,e)&&(r.__=t(),r.__H=e,r.__h=t),r.__}function wn(t,e){return lt=8,En(function(){return t},e)}function Xe(t){var e=O.context[t.__c],r=pt(Oe++,9);return r.c=t,e?(r.__==null&&(r.__=!0,e.sub(O)),e.props.value):t.__}function Do(){for(var t;t=Rn.shift();){var e=t.__H;if(t.__P&&e)try{e.__h.some(Qt),e.__h.some(lr),e.__h=[]}catch(r){e.__h=[],D.__e(r,t.__v)}}}D.__b=function(t){O=null,mn&&mn(t)},D.__=function(t,e){t&&e.__k&&e.__k.__m&&(t.__m=e.__k.__m),xn&&xn(t,e)},D.__r=function(t){Tn&&Tn(t),Oe=0;var e=(O=t.__c).__H;e&&(ur===O?(e.__h=[],O.__h=[],e.__.some(function(r){r.__N&&(r.__=r.__N),r.u=r.__N=void 0})):(e.__h.some(Qt),e.__h.some(lr),e.__h=[],Oe=0)),ur=O},D.diffed=function(t){_n&&_n(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(Rn.push(e)!==1&&hn===D.requestAnimationFrame||((hn=D.requestAnimationFrame)||Ko)(Do)),e.__H.__.some(function(r){r.u&&(r.__H=r.u),r.u=void 0})),ur=O=null},D.__c=function(t,e){e.some(function(r){try{r.__h.some(Qt),r.__h=r.__h.filter(function(o){return!o.__||lr(o)})}catch(o){e.some(function(i){i.__h&&(i.__h=[])}),e=[],D.__e(o,r.__v)}}),vn&&vn(t,e)},D.unmount=function(t){gn&&gn(t);var e,r=t.__c;r&&r.__H&&(r.__H.__.some(function(o){try{Qt(o)}catch(i){e=i}}),r.__H=void 0,e&&D.__e(e,r.__v))};var bn=typeof requestAnimationFrame=="function";function Ko(t){var e,r=function(){clearTimeout(o),bn&&cancelAnimationFrame(e),setTimeout(t)},o=setTimeout(r,35);bn&&(e=requestAnimationFrame(r))}function Qt(t){var e=O,r=t.__c;typeof r=="function"&&(t.__c=void 0,r()),O=e}function lr(t){var e=O;t.__c=t.__(),O=e}function pr(t,e){return!t||t.length!==e.length||e.some(function(r,o){return r!==t[o]})}function Cn(t,e){return typeof e=="function"?e(t):e}var Pn=Ke(!1),An=()=>Xe(Pn),$i=Pn.Provider;var Fo=0;function n(t,e,r,o,i,s){e||(e={});var u,p,f=e;if("ref"in f)for(p in f={},e)p=="ref"?u=e[p]:f[p]=e[p];var c={type:t,props:f,key:r,ref:u,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:--Fo,__i:-1,__u:0,__source:i,__self:s};if(typeof t=="function"&&(u=t.defaultProps))for(p in u)f[p]===void 0&&(f[p]=u[p]);return P.vnode&&P.vnode(c),c}var cr=Ke(void 0),fr=t=>{let e=Xe(cr);if(t)return t;if(!e)throw new Error("No QueryClient set, use QueryClientProvider to set one");return e},yr=({client:t,children:e})=>($(()=>(t.mount(),()=>{t.unmount()}),[t]),n(cr.Provider,{value:t,children:e}));function So(){let t=!1;return{clearReset:()=>{t=!1},reset:()=>{t=!0},isReset:()=>t}}var Uo=Ke(So()),On=()=>Xe(Uo);var Qn=(t,e)=>{(t.suspense||t.throwOnError||t.experimental_prefetchInRender)&&(e.isReset()||(t.retryOnMount=!1))},qn=t=>{$(()=>{t.clearReset()},[t])},Mn=({result:t,errorResetBoundary:e,throwOnError:r,query:o,suspense:i})=>t.isError&&!e.isReset()&&!t.isFetching&&o&&(i&&t.data===void 0||$t(r,[t.error,o]));var Dn=t=>{if(t.suspense){let r=i=>i==="static"?i:Math.max(i??1e3,1e3),o=t.staleTime;t.staleTime=typeof o=="function"?(...i)=>r(o(...i)):r(o),typeof t.gcTime=="number"&&(t.gcTime=Math.max(t.gcTime,1e3))}},Kn=(t,e)=>t.isLoading&&t.isFetching&&!e,Fn=(t,e)=>t?.suspense&&e.isPending,dr=(t,e,r)=>e.fetchOptimistic(t).catch(()=>{r.clearReset()});function Sn(t,e){let r=e(),[{_instance:o},i]=Qe({_instance:{_value:r,_getSnapshot:e}});return qt(()=>{o._value=r,o._getSnapshot=e,hr(o)&&i({_instance:o})},[t,r,e]),$(()=>(hr(o)&&i({_instance:o}),t(()=>{hr(o)&&i({_instance:o})})),[t]),r}function hr(t){let e=t._getSnapshot,r=t._value;try{let o=e();return!Object.is(r,o)}catch{return!0}}function Un(t,e,r){let o=An(),i=On(),s=fr(r),u=s.defaultQueryOptions(t);s.getDefaultOptions().queries?._experimental_beforeQuery?.(u),u._optimisticResults=o?"isRestoring":"optimistic",Dn(u),Qn(u,i),qn(i);let p=!s.getQueryCache().get(u.queryHash),[f]=Qe(()=>new e(s,u)),c=f.getOptimisticResult(u),y=!o&&t.subscribed!==!1;if(Sn(wn(l=>{let m=y?f.subscribe(A.batchCalls(l)):K;return f.updateResult(),m},[f,y]),()=>f.getCurrentResult()),$(()=>{f.setOptions(u)},[u,f]),Fn(u,c))throw dr(u,f,i);if(Mn({result:c,errorResetBoundary:i,throwOnError:u.throwOnError,query:s.getQueryCache().get(u.queryHash),suspense:u.suspense}))throw c.error;return s.getDefaultOptions().queries?._experimental_afterQuery?.(u,c),u.experimental_prefetchInRender&&!ee.isServer()&&Kn(c,o)&&(p?dr(u,f,i):s.getQueryCache().get(u.queryHash)?.promise)?.catch(K).finally(()=>{f.updateResult()}),u.notifyOnChangeProps?c:f.trackResult(c)}function mr(t,e){return Un(t,sr,e)}function U({children:t,panel:e,href:r,className:o,panelLarge:i}){let[s,u]=Qe(!1),p=qe(null),f=qe(null),c=qe(null),y=()=>{c.current&&(clearTimeout(c.current),c.current=null),f.current=setTimeout(()=>u(!0),100)},l=()=>{f.current&&(clearTimeout(f.current),f.current=null),c.current=setTimeout(()=>u(!1),150)};qt(()=>{if(s&&p.current){let T=p.current;T.style.left="50%",T.style.right="auto",T.style.transform="translateX(-50%)";let x=T.getBoundingClientRect();x.left<8?(T.style.left="0",T.style.transform="none"):x.right>window.innerWidth-8&&(T.style.left="auto",T.style.right="0",T.style.transform="none")}},[s]);let m=["profiler-toolbar-item",e?"profiler-toolbar-hoverable":"",o||""].filter(Boolean).join(" "),d=e?n("div",{ref:p,class:`profiler-toolbar-panel${i?" profiler-toolbar-panel-large":""}${s?" is-visible":""}`,onMouseEnter:y,onMouseLeave:l,children:e}):null;return r?n("a",{href:r,class:m,onMouseEnter:y,onMouseLeave:l,children:[t,d]}):n("span",{class:m,onMouseEnter:y,onMouseLeave:l,children:[t,d]})}function ko(t){return t>=200&&t<300?"profiler-text--success":t>=300&&t<400?"profiler-text--warning":t>=400?"profiler-text--error":""}function kn({profile:t,requestData:e}){let r=ko(t.status),o=e.controller_action,i=e.route_name,s=e.route_pattern,u=e.route_params;return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Request & Response",n("span",{class:"profiler-float-right",children:t.path})]}),n("div",{class:"profiler-toolbar-panel-content",children:[n("div",{class:"profiler-section__header",children:"Request"}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Method"}),n("strong",{class:"profiler-text--accent",children:t.method})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Path"}),n("strong",{children:t.path})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Status"}),n("strong",{class:r,children:t.status})]}),o&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Controller#Action"}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:o})]}),i&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Route Name"}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:i})]}),s&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Route Pattern"}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:s})]}),u&&Object.keys(u).length>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Route Params"}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:Object.entries(u).map(([p,f])=>`${p}: ${f}`).join(", ")})]}),t.params&&Object.keys(t.params).length>0&&n(b,{children:[n("div",{class:"profiler-section__header profiler-mt-3",children:"Parameters"}),Object.entries(t.params).map(([p,f])=>n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{class:"profiler-text--xs profiler-text--mono",children:p}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:String(f).substring(0,40)})]},p))]})]})]})}function Ln({dbData:t}){return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Database",n("span",{class:"profiler-float-right",children:[t.total_queries," queries \xB7 ",t.total_duration.toFixed(2)," ms"]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[t.queries.slice(0,10).map((e,r)=>n("div",{class:`profiler-toolbar-panel-query${e.slow?" profiler-toolbar-panel-query-slow":""}`,children:[n("div",{class:"profiler-flex profiler-flex--between profiler-mb-1",children:[n("span",{class:"profiler-text--xs profiler-text--muted",children:["#",r+1," ",e.name]}),n("span",{class:`${e.slow?"profiler-text--error":"profiler-text--success"} profiler-text--xs`,children:[e.duration.toFixed(2)," ms"]})]}),n("code",{children:e.sql})]},r)),t.total_queries>10&&n("div",{class:"profiler-more",children:["+ ",t.total_queries-10," more queries"]})]})]})}function Lo(t){return{GET:"badge-info",POST:"badge-success",PUT:"badge-warning",PATCH:"badge-warning",DELETE:"badge-error"}[t]||""}var Io={frame:"Turbo Frame request",stream:"Turbo Stream response"};function In({ajaxData:t}){return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["AJAX",n("span",{class:"profiler-float-right",children:[t.total_requests," requests \xB7 ",t.total_duration.toFixed(2)," ms"]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[t.requests.slice(0,10).map((e,r)=>{let o=e.status>=200&&e.status<300?"profiler-ajax-card--success":"profiler-ajax-card--error";return n("div",{class:`profiler-ajax-card ${o}`,children:n("div",{class:"profiler-ajax-card__row",children:[n("div",{class:"profiler-flex profiler-flex--gap-2",children:[n("span",{class:`badge ${Lo(e.method)}`,children:e.method}),e.turbo&&n("span",{class:"badge badge-default",title:Io[e.turbo],children:e.turbo.toUpperCase()}),n("span",{class:"profiler-text--xs profiler-text--truncate",children:e.path})]}),n("div",{class:"profiler-flex profiler-flex--gap-2",children:[n("span",{class:`profiler-text--xs ${e.status>=200&&e.status<300?"profiler-text--success":"profiler-text--error"}`,children:e.status}),n("span",{class:"profiler-text--xs profiler-text--muted",children:[e.duration.toFixed(2)," ms"]})]})]})},r)}),t.total_requests>10&&n("div",{class:"profiler-more",children:["+ ",t.total_requests-10," more"]})]})]})}function Vn({perfData:t}){return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:"Events"}),n("div",{class:"profiler-toolbar-panel-content",children:t.events.slice(0,8).map((e,r)=>n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{class:"profiler-text--xs",children:e.name}),n("strong",{class:"profiler-text--accent",children:[e.duration.toFixed(2)," ms"]})]},r))})]})}function Nn({viewData:t}){return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Views",n("span",{class:"profiler-float-right",children:[t.total_duration.toFixed(2)," ms"]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[t.views&&t.views.length>0&&n(b,{children:[n("div",{class:"profiler-section__header",children:"Templates"}),t.views.map((e,r)=>n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{class:"profiler-text--xs",children:e.identifier}),n("strong",{class:"profiler-text--success",children:[e.duration.toFixed(2)," ms"]})]},r))]}),t.partials&&t.partials.length>0&&n(b,{children:[n("div",{class:"profiler-section__header profiler-mt-3",children:"Partials"}),t.partials.map((e,r)=>n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{class:"profiler-text--xs",children:e.identifier}),n("strong",{class:"profiler-text--success",children:[e.duration.toFixed(2)," ms"]})]},r))]})]})]})}function Gn({cacheData:t}){return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Cache",n("span",{class:"profiler-float-right",children:["Hit rate: ",t.hit_rate,"%"]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Reads"}),n("strong",{children:t.total_reads})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Writes"}),n("strong",{children:t.total_writes})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Hits"}),n("strong",{class:"profiler-text--success",children:t.hits})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Misses"}),n("strong",{class:"profiler-text--error",children:t.misses})]})]})]})}function jn({dumpData:t}){return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Dumps (",t.count,")"]}),n("div",{class:"profiler-toolbar-panel-content",children:[t.dumps.slice(0,5).map((e,r)=>n("div",{class:"profiler-dump-card",children:[n("div",{class:"profiler-dump-card__header",children:[n("span",{class:"profiler-text--xs profiler-text--muted",children:["#",r+1,e.label&&n(b,{children:[" \xB7 ",n("strong",{class:"profiler-text--warning",children:e.label})]})]}),n("span",{class:"profiler-text--xs profiler-text--muted",children:[e.file.split("/").pop(),":",e.line]})]}),n("pre",{class:"profiler-text--xs profiler-text--truncate profiler-text--warning",style:{margin:0,background:"none",border:"none",padding:0},children:(e.formatted.split(`
2
- `)[0]||e.formatted).trim()})]},r)),t.count>5&&n("div",{class:"profiler-more",children:["+ ",t.count-5," more dumps"]})]})]})}function Vo(t){return{GET:"badge-info",POST:"badge-success",PUT:"badge-warning",PATCH:"badge-warning",DELETE:"badge-error"}[t]||""}function Hn({httpData:t}){return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Outbound HTTP",n("span",{class:"profiler-float-right",children:[t.total_requests," requests \xB7 ",t.total_duration.toFixed(2)," ms"]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[t.requests.slice(0,10).map((r,o)=>{let i=r.status>=400||r.status===0,s=r.duration>=500,u=i?"profiler-ajax-card--error":s?"profiler-ajax-card--warning":"profiler-ajax-card--success",p=(()=>{try{return new URL(r.url).host}catch{return r.url}})();return n("div",{class:`profiler-ajax-card ${u}`,children:n("div",{class:"profiler-ajax-card__row",children:[n("div",{class:"profiler-flex profiler-flex--gap-2",children:[n("span",{class:`badge ${Vo(r.method)}`,children:r.method}),n("span",{class:"profiler-text--xs profiler-text--truncate",children:p})]}),n("div",{class:"profiler-flex profiler-flex--gap-2",children:[n("span",{class:`profiler-text--xs ${i?"profiler-text--error":"profiler-text--success"}`,children:r.status===0?"ERR":r.status}),n("span",{class:`profiler-text--xs ${s?"profiler-text--error":"profiler-text--muted"}`,children:[r.duration.toFixed(2)," ms"]})]})]})},o)}),t.total_requests>10&&n("div",{class:"profiler-more",children:["+ ",t.total_requests-10," more"]})]})]})}function No(t){switch(t){case"ERROR":case"FATAL":return"var(--profiler-error, #ef4444)";case"WARN":return"var(--profiler-warning, #f59e0b)";case"INFO":return"var(--profiler-success, #22c55e)";default:return"var(--profiler-muted, #6b7280)"}}function Bn({logData:t}){let e=t.logs.slice(-5).reverse();return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Logs (",t.count,")",t.errors>0&&n("span",{style:"color:var(--profiler-error,#ef4444);margin-left:8px;",children:[t.errors," error",t.errors!==1?"s":""]}),t.warnings>0&&t.errors===0&&n("span",{style:"color:var(--profiler-warning,#f59e0b);margin-left:8px;",children:[t.warnings," warning",t.warnings!==1?"s":""]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[e.map((r,o)=>n("div",{class:"profiler-toolbar-panel-row",style:"align-items:flex-start;gap:6px;",children:[n("span",{class:"profiler-text--xs",style:`color:${No(r.level)};font-weight:600;min-width:40px;`,children:r.level}),n("span",{class:"profiler-text--xs profiler-text--truncate",style:"flex:1;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",children:r.message})]},o)),t.count>5&&n("div",{class:"profiler-more",children:["+ ",t.count-5," more messages"]})]})]})}function Jn({exceptionData:t}){let e=t.backtrace?.find(r=>r.app_frame);return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",style:"color:var(--profiler-error,#ef4444);",children:["\u{1F4A5} ",t.exception_class]}),n("div",{class:"profiler-toolbar-panel-content",children:n("div",{class:"profiler-toolbar-panel-row",style:"flex-direction:column;align-items:flex-start;gap:4px;",children:[n("span",{class:"profiler-text--xs",style:"max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",children:t.message}),e&&n("span",{class:"profiler-text--xs profiler-text--muted",style:"max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",children:e.location})]})})]})}function $n({routesData:t}){let{total:e,matched:r}=t;return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Routes",n("span",{class:"profiler-float-right",children:[e," routes"]})]}),n("div",{class:"profiler-toolbar-panel-content",children:r?n(b,{children:[n("div",{class:"profiler-section__header",children:"Matched Route"}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Pattern"}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:r.pattern})]}),r.name&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Name"}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:[r.name,"_path"]})]}),r.controller_action&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Controller#Action"}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:r.controller_action})]})]}):n("div",{class:"profiler-toolbar-panel-row",children:n("span",{class:"profiler-text--muted",children:"No route matched"})})})]})}function Wn({i18nData:t}){let e=t.lookups.filter(s=>s.missing),r=t.lookups.filter(s=>!s.missing),o=[...e,...r].slice(0,5),i=t.total-5;return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["I18n",n("span",{style:"margin-left:6px;font-weight:400;color:var(--profiler-muted,#6b7280);",children:["[",t.locale,"]"]}),t.missing_count>0&&n("span",{style:"color:var(--profiler-error,#ef4444);margin-left:8px;",children:[t.missing_count," missing"]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[o.map((s,u)=>n("div",{class:"profiler-toolbar-panel-row",style:"align-items:flex-start;gap:6px;",children:[n("span",{class:"profiler-text--xs profiler-text--truncate",style:`flex:1;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;${s.missing?"color:var(--profiler-error,#ef4444);":""}`,children:s.key}),s.missing&&n("span",{class:"profiler-text--xs",style:"color:var(--profiler-error,#ef4444);font-weight:600;",children:"\u26A0"})]},u)),i>0&&n("div",{class:"profiler-more",children:["+ ",i," more keys"]})]})]})}function Go({job:t}){if(t.status==="running")return n("strong",{class:"profiler-text--xs profiler-text--mono profiler-text--info",children:[n("span",{class:"profiler-spinner","aria-hidden":"true",children:"\u25D0"})," running"]});let e=t.status==="failed";return n("strong",{class:`profiler-text--xs profiler-text--mono ${e?"profiler-text--error":"profiler-text--success"}`,children:[e?"\u2717":"\u2713"," ",t.duration?.toFixed(0),"ms"]})}function zn({jobs:t}){let e=t.filter(u=>u.status==="running").length,r=t.filter(u=>u.status==="completed").length,o=t.filter(u=>u.status==="failed").length,i=t.slice(0,5),s=t.length-5;return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Background Jobs",n("span",{class:"profiler-float-right",children:[t.length," job",t.length!==1?"s":""]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[n("div",{class:"profiler-section__header",children:"Summary"}),e>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Running"}),n("strong",{class:"profiler-text--info",children:e})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Completed"}),n("strong",{class:r>0?"profiler-text--success":"profiler-text--muted",children:r})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Failed"}),n("strong",{class:o>0?"profiler-text--error":"profiler-text--muted",children:o})]}),n("div",{class:"profiler-section__header profiler-mt-3",children:"Last jobs"}),i.map((u,p)=>n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{class:"profiler-text--xs profiler-text--mono",children:u.job_class}),n(Go,{job:u})]},p)),s>0&&n("div",{class:"profiler-more",children:["+ ",s," more"]})]})]})}function Xn({envData:t}){return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:"Environment"}),n("div",{class:"profiler-toolbar-panel-content",children:n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Variables"}),n("strong",{children:t.total})]})})]})}function Yn({mailerData:t}){let e=t.failed>0||t.loop_warnings.length>0;return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Mailers",n("span",{class:"profiler-float-right",children:[t.total," email",t.total!==1?"s":""]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[t.deliver_now>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"deliver_now"}),n("strong",{children:t.deliver_now})]}),t.deliver_later>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"deliver_later"}),n("strong",{children:t.deliver_later})]}),(t.queued_count??0)>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Queued"}),n("strong",{children:t.queued_count})]}),t.multi_part_count>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Multi-part"}),n("strong",{children:t.multi_part_count})]}),t.failed>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Errors"}),n("strong",{class:"profiler-text--error",children:t.failed})]}),t.loop_warnings.length>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{class:"profiler-text--warning",children:"\u26A0\uFE0F Loop detected"}),n("strong",{class:"profiler-text--warning",children:t.loop_warnings.length})]}),[...t.emails,...t.errors].slice(0,3).map((r,o)=>n("div",{class:"profiler-toolbar-panel-row profiler-text--sm",children:[n("span",{class:"profiler-text--muted",children:[r.mailer_class,"#",r.action]}),n("span",{class:r.error?"profiler-text--error":"profiler-text--success",children:r.error?"\u274C":"\u2705"})]},o)),t.total>3&&n("div",{class:"profiler-toolbar-panel-row profiler-text--muted profiler-text--xs",children:["+",t.total-3," more\u2026"]})]})]})}function Tr(t){return t.allocated_objects!=null?t.allocated_objects:t.memory!=null?Math.round(t.memory/40):null}function Zn(t){return t==null?"-":`${t.toLocaleString("en")} objects`}var eo="Objects allocated by the whole process while this ran: on a multi-threaded server, it includes what other threads allocated meanwhile.";function jo(t){return t>=200&&t<300?"profiler-text--success":t>=300&&t<400?"profiler-text--warning":t>=400?"profiler-text--error":""}function Ho(t){return t<100?"profiler-text--success":t<500?"profiler-text--warning":"profiler-text--error"}function Bo(t){return new Date(t).toLocaleTimeString("en",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function to({profile:t,token:e}){let r=t.collectors_data||{},o=r.request,i=r.database,s=r.ajax,u=r.performance,p=r.view,f=r.cache,c=r.dump,y=r.http,l=r.logs,m=r.exception,d=r.routes,T=r.i18n,x=r.env,v=r.mailer,g=t.child_jobs??[],R=jo(t.status),q=Ho(t.duration),F=(i?.slow_queries??0)>0?"profiler-text--error":"profiler-text--success",L=(s?.total_requests??0)>20?"profiler-text--error":"profiler-text--success",W=(f?.hit_rate??0)>80?"profiler-text--success":"profiler-text--warning";return n(b,{children:n("div",{class:"profiler-toolbar-container",children:[o&&n(b,{children:[n(U,{href:`/_profiler/profiles/${e}?tab=request`,className:R,panelLarge:!0,panel:n(kn,{profile:t,requestData:o}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:t.method}),n("span",{children:t.status})]}),n(U,{href:`/_profiler/profiles/${e}?tab=request`,className:q,panel:n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:"Performance"}),n("div",{class:"profiler-toolbar-panel-content",children:[n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Duration"}),n("strong",{class:q,children:[t.duration.toFixed(2)," ms"]})]}),Tr(t)!=null&&n("div",{class:"profiler-toolbar-panel-row",title:eo,children:[n("span",{children:"Allocations"}),n("strong",{children:Zn(Tr(t))})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Started"}),n("strong",{children:Bo(t.started_at)})]})]})]}),children:[n("span",{class:q,children:t.duration.toFixed(2)}),n("span",{class:"profiler-text--muted profiler-text--xs",children:"ms"})]})]}),i?.total_queries!==void 0&&n(U,{href:`/_profiler/profiles/${e}?tab=database`,className:F,panelLarge:!0,panel:n(Ln,{dbData:i}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"DB"}),n("span",{children:i.total_queries}),(i.slow_queries??0)>0&&n("span",{class:"profiler-text--error profiler-text--xs",children:["\u25B2 ",i.slow_queries]}),n("span",{class:"profiler-text--muted profiler-text--xs",children:[i.total_duration.toFixed(1),"ms"]})]}),s&&s.total_requests>0&&n(U,{href:`/_profiler/profiles/${e}?tab=ajax`,className:L,panelLarge:!0,panel:n(In,{ajaxData:s}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"XHR"}),n("span",{children:s.total_requests}),n("span",{class:"profiler-text--muted profiler-text--xs",children:[s.total_duration.toFixed(1),"ms"]})]}),u?.events&&u.total_events>0&&n(U,{href:`/_profiler/profiles/${e}?tab=timeline`,panel:n(Vn,{perfData:u}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"EVT"}),n("span",{children:u.total_events})]}),p?.total_views!==void 0&&n(U,{href:`/_profiler/profiles/${e}?tab=views`,panel:n(Nn,{viewData:p}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"VIEW"}),n("span",{children:p.total_views}),p.total_partials>0&&n("span",{class:"profiler-text--muted profiler-text--xs",children:["+",p.total_partials,"p"]})]}),f&&f.total_reads>0&&n(U,{href:`/_profiler/profiles/${e}?tab=cache`,className:W,panel:n(Gn,{cacheData:f}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"CACHE"}),n("span",{class:W,children:[f.hit_rate,"%"]})]}),y&&y.total_requests>0&&n(U,{href:`/_profiler/profiles/${e}?tab=http`,className:y.error_requests>0||y.slow_requests>0?"profiler-text--error":"profiler-text--success",panelLarge:!0,panel:n(Hn,{httpData:y}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"HTTP"}),n("span",{children:y.total_requests}),y.slow_requests>0&&n("span",{class:"profiler-text--error profiler-text--xs",children:["\u25B2 ",y.slow_requests]}),n("span",{class:"profiler-text--muted profiler-text--xs",children:[y.total_duration.toFixed(1),"ms"]})]}),c&&c.count>0&&n(U,{href:`/_profiler/profiles/${e}?tab=dump`,className:"profiler-text--warning",panelLarge:!0,panel:n(jn,{dumpData:c}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"DUMP"}),n("span",{class:"profiler-text--warning",children:c.count})]}),l&&l.count>0&&n(U,{href:`/_profiler/profiles/${e}?tab=logs`,className:l.errors>0?"profiler-text--error":l.warnings>0?"profiler-text--warning":"profiler-text--muted",panelLarge:!0,panel:n(Bn,{logData:l}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"LOG"}),n("span",{class:l.errors>0?"profiler-text--error":l.warnings>0?"profiler-text--warning":"",children:l.errors>0?l.errors:l.warnings>0?l.warnings:l.count})]}),m&&m.exception_class&&n(U,{href:`/_profiler/profiles/${e}?tab=exception`,className:"profiler-text--error",panelLarge:!0,panel:n(Jn,{exceptionData:m}),children:[n("span",{class:"profiler-text--error profiler-text--xs",children:"\u{1F4A5}"}),n("span",{class:"profiler-text--error profiler-text--xs",children:m.exception_class.split("::").pop()})]}),d&&d.total>0&&n(U,{href:`/_profiler/profiles/${e}?tab=routes`,panelLarge:!0,panel:n($n,{routesData:d}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"ROUTE"}),n("span",{class:"profiler-text--xs profiler-text--mono",children:d.matched?.pattern??"-"})]}),T&&T.total>0&&n(U,{href:`/_profiler/profiles/${e}?tab=i18n`,className:T.missing_count>0?"profiler-text--error":"profiler-text--muted",panel:n(Wn,{i18nData:T}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"I18N"}),n("span",{class:"profiler-text--xs profiler-text--mono",children:T.locale}),T.missing_count>0&&n("span",{class:"profiler-text--error profiler-text--xs",children:["\u26A0 ",T.missing_count]})]}),g.length>0&&n(U,{href:`/_profiler/profiles/${e}?tab=jobs`,className:g.some(G=>G.status==="failed")?"profiler-text--error":g.some(G=>G.status==="running")?"profiler-text--info":"profiler-text--success",panelLarge:!0,panel:n(zn,{jobs:g}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"JOB"}),n("span",{children:g.length}),g.some(G=>G.status==="failed")&&n("span",{class:"profiler-text--error profiler-text--xs",children:"\u2717"}),g.some(G=>G.status==="running")&&n("span",{class:"profiler-spinner profiler-text--info profiler-text--xs","aria-hidden":"true",children:"\u25D0"})]}),v&&(v.total>0||(v.queued_count??0)>0)&&n(U,{href:`/_profiler/profiles/${e}?tab=mailer`,className:v.failed>0?"profiler-text--error":"profiler-text--success",panelLarge:!0,panel:n(Yn,{mailerData:v}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"MAIL"}),v.total>0&&n("span",{children:v.total}),v.total===0&&(v.queued_count??0)>0&&n("span",{class:"profiler-text--muted",children:[v.queued_count,"q"]}),v.total>0&&(v.queued_count??0)>0&&n("span",{class:"profiler-text--muted profiler-text--xs",children:["+",v.queued_count,"q"]}),v.failed>0&&n("span",{class:"profiler-text--error profiler-text--xs",children:["\u25B2 ",v.failed]})]}),x&&x.total>0&&n(U,{href:`/_profiler/profiles/${e}?tab=env`,panel:n(Xn,{envData:x}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"ENV"}),n("span",{class:"profiler-text--muted",children:x.total})]}),n("a",{href:"/_profiler",class:"profiler-toolbar-item profiler-toolbar-logo",children:"\u2B21 Profiler"})]})})}var Jo="profiler-active-slave",$o=(()=>{try{let t=sessionStorage.getItem(Jo);return t?`/slaves/${t}`:""}catch{return""}})();function ro(){return $o}var Wo="/_profiler/api/cluster/";async function Mt(t){let e=t.url.startsWith(Wo)?"":ro(),r=e?t.url.replace("/_profiler/api",`/_profiler/api${e}`):t.url,{method:o,params:i,data:s,headers:u={},signal:p}=t,f=r,c=i?"?"+new URLSearchParams(Object.entries(i).map(([d,T])=>[d,String(T)])).toString():"",y={"X-Profiler-Request":"1",...u},l=await fetch(f+c,{method:o,signal:p,headers:s!==void 0?{"Content-Type":"application/json",...y}:y,body:s!==void 0?JSON.stringify(s):void 0});if(l.status===204)return{};let m=await l.json();if(!l.ok)throw Object.assign(new Error(m?.error??`HTTP ${l.status}`),{status:l.status,data:m});return m}var zo=(t,e)=>{let r={queryKey:e};for(let o of Object.keys(t))o!=="queryKey"&&Object.defineProperty(r,o,{enumerable:!0,configurable:!0,get:()=>t[o]});return r};var Xo=(t,e)=>Mt({url:`/_profiler/api/toolbar/${t}`,method:"GET",signal:e}),Yo=t=>[`/_profiler/api/toolbar/${t}`],Zo=(t,e)=>{let{query:r}=e??{};return{queryKey:r?.queryKey??Yo(t),queryFn:({signal:s})=>Xo(t,s),enabled:t!=null,...r}};function no(t,e){let r=Zo(t,e),o=mr(r);return zo(o,r.queryKey)}var oo=[1e3,1e3,2e3,2e3,4e3,4e3,8e3,8e3,15e3,15e3],es=3e4,ts=10*6e4;function rs(t){return typeof t=="object"&&t!==null&&Number.isFinite(t.cursor)}function so(t){let e=t.now??(()=>Date.now()),r=t.setTimer??((T,x)=>setTimeout(T,x)),o=t.clearTimer??(T=>clearTimeout(T)),i=t.cursor,s=0,u=e(),p=null,f=!1,c=!1,y=!1,l=()=>{p!==null&&(o(p),p=null)},m=()=>{if(l(),c||f||e()-u>=ts)return;let T=s<oo.length?oo[s]:es;s+=1,p=r(()=>{p=null,d()},T)},d=async()=>{if(!(c||y)){y=!0;try{let T=await t.check(i);if(c)return;rs(T)&&(i=Math.max(i,T.cursor),T.updated===!0&&(s=0,u=e(),t.onUpdate()))}catch{}finally{y=!1}m()}};return m(),{pause(){f=!0,l()},resume(){c||(f=!1,l(),d())},stop(){c=!0,l()}}}var ns="/_profiler";function io(t,e,r){let o=qe(r);o.current=r,$(()=>{if(!t||e===void 0)return;let s=so({cursor:e,check:p=>Mt({url:`${ns}/api/events/${encodeURIComponent(t)}`,method:"GET",params:{since:p}}),onUpdate:()=>o.current()}),u=()=>{document.hidden?s.pause():s.resume()};return document.addEventListener("visibilitychange",u),document.hidden&&s.pause(),()=>{document.removeEventListener("visibilitychange",u),s.stop()}},[t,e!==void 0])}function ao({token:t}){let{data:e,refetch:r,isError:o,isFetching:i}=no(t,{query:{refetchOnWindowFocus:!1}});$(()=>{window.__PROFILER_REFRESH_TOOLBAR__=()=>{r()}},[r]),io(t,e?.events_cursor,()=>{r()});let s=e?.profile??null;return s?n(to,{profile:s,token:t}):o?n("div",{class:"profiler-toolbar-container",children:n("span",{class:"profiler-toolbar-error",role:"alert",children:[n("span",{class:"profiler-text--error",children:"Profiler data could not be loaded."}),n("button",{type:"button",class:"profiler-toolbar-retry",disabled:i,onClick:()=>{r()},children:i?"Retrying...":"Retry"})]})}):null}var Dt=class extends Me{constructor(){super(...arguments);this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(r){console.error("[Profiler] The toolbar failed to render:",r)}render(){return this.state.failed?n("div",{class:"profiler-toolbar-container",children:n("span",{class:"profiler-toolbar-error",role:"alert",children:[n("span",{class:"profiler-text--error",children:"Profiler toolbar error."}),n("button",{type:"button",class:"profiler-toolbar-retry",onClick:()=>this.setState({failed:!1}),children:"Retry"})]})}):this.props.children}};function uo(t){return t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey&&t.code==="KeyP"}var _r=new Map;function vr(t){try{return localStorage.getItem(t)}catch{return _r.has(t)?_r.get(t):null}}function lo(t,e){_r.set(t,e);try{localStorage.setItem(t,e)}catch{}}var gr=280;function po(t){let e=vr("profiler-theme"),r=e==="light"?"light":e==="dark"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";t.forEach(o=>o.setAttribute("data-theme",r))}var os=new ar({defaultOptions:{queries:{staleTime:3e4,retry:1}}});function co(){let t=document.getElementById("profiler-toolbar"),e=document.getElementById("profiler-toolbar-toggle");if(!t||!e)return;let r=t.dataset.token;if(!r)return;window.__PROFILER_TOOLBAR_TEARDOWN__?.();let o=new AbortController,{signal:i}=o,s=()=>{o.abort(),Gt(null,t),window.__PROFILER_TOOLBAR_TEARDOWN__===s&&delete window.__PROFILER_TOOLBAR_TEARDOWN__};window.__PROFILER_TOOLBAR_TEARDOWN__=s,document.addEventListener("turbo:load",()=>{t.isConnected||s()},{signal:i});let u=[t,e];po(u),window.addEventListener("storage",c=>{c.key==="profiler-theme"&&po(u)},{signal:i}),window.addEventListener("profiler:theme-change",(c=>{c.detail?.theme&&u.forEach(y=>y.setAttribute("data-theme",c.detail.theme))}),{signal:i});let p=vr("profiler-toolbar-collapsed")==="true";e.dataset.collapsed=String(p),p&&!t.style.transform&&(t.style.animation="none",t.style.transform="translateX(calc(100% + 44px))"),p||setTimeout(()=>{t.style.animation="none"},400);function f(){let c=!p;p=c,lo("profiler-toolbar-collapsed",String(c)),e.dataset.collapsed=String(c),c?(t.style.transition=`transform ${gr}ms cubic-bezier(0.4,0,0.2,1)`,t.style.transform="translateX(calc(100% + 44px))"):(t.style.transition="none",t.style.transform="translateX(calc(100% + 44px))",t.offsetWidth,t.style.transition=`transform ${gr}ms cubic-bezier(0.4,0,0.2,1)`,t.style.transform="translateX(0)",setTimeout(()=>{t.style.transform="",t.style.transition=""},gr+50))}e.addEventListener("click",f,{signal:i}),document.addEventListener("keydown",c=>{uo(c)&&(c.preventDefault(),f())},{signal:i}),Gt(n(yr,{client:os,children:n(Dt,{children:n(ao,{token:r})})}),t)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",co):co();})();
2
+ `)[0]||e.formatted).trim()})]},r)),t.count>5&&n("div",{class:"profiler-more",children:["+ ",t.count-5," more dumps"]})]})]})}function Vo(t){return{GET:"badge-info",POST:"badge-success",PUT:"badge-warning",PATCH:"badge-warning",DELETE:"badge-error"}[t]||""}function Hn({httpData:t}){return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Outbound HTTP",n("span",{class:"profiler-float-right",children:[t.total_requests," requests \xB7 ",t.total_duration.toFixed(2)," ms"]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[t.requests.slice(0,10).map((r,o)=>{let i=r.status>=400||r.status===0,s=r.duration>=500,u=i?"profiler-ajax-card--error":s?"profiler-ajax-card--warning":"profiler-ajax-card--success",p=(()=>{try{return new URL(r.url).host}catch{return r.url}})();return n("div",{class:`profiler-ajax-card ${u}`,children:n("div",{class:"profiler-ajax-card__row",children:[n("div",{class:"profiler-flex profiler-flex--gap-2",children:[n("span",{class:`badge ${Vo(r.method)}`,children:r.method}),n("span",{class:"profiler-text--xs profiler-text--truncate",children:p})]}),n("div",{class:"profiler-flex profiler-flex--gap-2",children:[n("span",{class:`profiler-text--xs ${i?"profiler-text--error":"profiler-text--success"}`,children:r.status===0?"ERR":r.status}),n("span",{class:`profiler-text--xs ${s?"profiler-text--error":"profiler-text--muted"}`,children:[r.duration.toFixed(2)," ms"]})]})]})},o)}),t.total_requests>10&&n("div",{class:"profiler-more",children:["+ ",t.total_requests-10," more"]})]})]})}function No(t){switch(t){case"ERROR":case"FATAL":return"var(--profiler-error, #ef4444)";case"WARN":return"var(--profiler-warning, #f59e0b)";case"INFO":return"var(--profiler-success, #22c55e)";default:return"var(--profiler-muted, #6b7280)"}}function Bn({logData:t}){let e=t.logs.slice(-5).reverse();return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Logs (",t.count,")",t.errors>0&&n("span",{style:"color:var(--profiler-error,#ef4444);margin-left:8px;",children:[t.errors," error",t.errors!==1?"s":""]}),t.warnings>0&&t.errors===0&&n("span",{style:"color:var(--profiler-warning,#f59e0b);margin-left:8px;",children:[t.warnings," warning",t.warnings!==1?"s":""]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[e.map((r,o)=>n("div",{class:"profiler-toolbar-panel-row",style:"align-items:flex-start;gap:6px;",children:[n("span",{class:"profiler-text--xs",style:`color:${No(r.level)};font-weight:600;min-width:40px;`,children:r.level}),n("span",{class:"profiler-text--xs profiler-text--truncate",style:"flex:1;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",children:r.message})]},o)),t.count>5&&n("div",{class:"profiler-more",children:["+ ",t.count-5," more messages"]})]})]})}function Jn({exceptionData:t}){let e=t.backtrace?.find(r=>r.app_frame);return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",style:"color:var(--profiler-error,#ef4444);",children:["\u{1F4A5} ",t.exception_class]}),n("div",{class:"profiler-toolbar-panel-content",children:n("div",{class:"profiler-toolbar-panel-row",style:"flex-direction:column;align-items:flex-start;gap:4px;",children:[n("span",{class:"profiler-text--xs",style:"max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",children:t.message}),e&&n("span",{class:"profiler-text--xs profiler-text--muted",style:"max-width:260px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;",children:e.location})]})})]})}function $n({routesData:t}){let{total:e,matched:r}=t;return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Routes",n("span",{class:"profiler-float-right",children:[e," routes"]})]}),n("div",{class:"profiler-toolbar-panel-content",children:r?n(b,{children:[n("div",{class:"profiler-section__header",children:"Matched Route"}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Pattern"}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:r.pattern})]}),r.name&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Name"}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:[r.name,"_path"]})]}),r.controller_action&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Controller#Action"}),n("strong",{class:"profiler-text--xs profiler-text--mono",children:r.controller_action})]})]}):n("div",{class:"profiler-toolbar-panel-row",children:n("span",{class:"profiler-text--muted",children:"No route matched"})})})]})}function Wn({i18nData:t}){let e=t.lookups.filter(s=>s.missing),r=t.lookups.filter(s=>!s.missing),o=[...e,...r].slice(0,5),i=t.total-5;return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["I18n",n("span",{style:"margin-left:6px;font-weight:400;color:var(--profiler-muted,#6b7280);",children:["[",t.locale,"]"]}),t.missing_count>0&&n("span",{style:"color:var(--profiler-error,#ef4444);margin-left:8px;",children:[t.missing_count," missing"]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[o.map((s,u)=>n("div",{class:"profiler-toolbar-panel-row",style:"align-items:flex-start;gap:6px;",children:[n("span",{class:"profiler-text--xs profiler-text--truncate",style:`flex:1;max-width:220px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;${s.missing?"color:var(--profiler-error,#ef4444);":""}`,children:s.key}),s.missing&&n("span",{class:"profiler-text--xs",style:"color:var(--profiler-error,#ef4444);font-weight:600;",children:"\u26A0"})]},u)),i>0&&n("div",{class:"profiler-more",children:["+ ",i," more keys"]})]})]})}function Go({job:t}){if(t.status==="running")return n("strong",{class:"profiler-text--xs profiler-text--mono profiler-text--info",children:[n("span",{class:"profiler-spinner","aria-hidden":"true",children:"\u25D0"})," running"]});let e=t.status==="failed";return n("strong",{class:`profiler-text--xs profiler-text--mono ${e?"profiler-text--error":"profiler-text--success"}`,children:[e?"\u2717":"\u2713"," ",t.duration?.toFixed(0),"ms"]})}function zn({jobs:t}){let e=t.filter(u=>u.status==="running").length,r=t.filter(u=>u.status==="completed").length,o=t.filter(u=>u.status==="failed").length,i=t.slice(0,5),s=t.length-5;return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Background Jobs",n("span",{class:"profiler-float-right",children:[t.length," job",t.length!==1?"s":""]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[n("div",{class:"profiler-section__header",children:"Summary"}),e>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Running"}),n("strong",{class:"profiler-text--info",children:e})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Completed"}),n("strong",{class:r>0?"profiler-text--success":"profiler-text--muted",children:r})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Failed"}),n("strong",{class:o>0?"profiler-text--error":"profiler-text--muted",children:o})]}),n("div",{class:"profiler-section__header profiler-mt-3",children:"Last jobs"}),i.map((u,p)=>n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{class:"profiler-text--xs profiler-text--mono",children:u.job_class}),n(Go,{job:u})]},p)),s>0&&n("div",{class:"profiler-more",children:["+ ",s," more"]})]})]})}function Xn({envData:t}){return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:"Environment"}),n("div",{class:"profiler-toolbar-panel-content",children:n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Variables"}),n("strong",{children:t.total})]})})]})}function Yn({mailerData:t}){let e=t.failed>0||t.loop_warnings.length>0;return n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:["Mailers",n("span",{class:"profiler-float-right",children:[t.total," email",t.total!==1?"s":""]})]}),n("div",{class:"profiler-toolbar-panel-content",children:[t.deliver_now>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"deliver_now"}),n("strong",{children:t.deliver_now})]}),t.deliver_later>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"deliver_later"}),n("strong",{children:t.deliver_later})]}),(t.queued_count??0)>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Queued"}),n("strong",{children:t.queued_count})]}),t.multi_part_count>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Multi-part"}),n("strong",{children:t.multi_part_count})]}),t.failed>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Errors"}),n("strong",{class:"profiler-text--error",children:t.failed})]}),t.loop_warnings.length>0&&n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{class:"profiler-text--warning",children:"\u26A0\uFE0F Loop detected"}),n("strong",{class:"profiler-text--warning",children:t.loop_warnings.length})]}),[...t.emails,...t.errors].slice(0,3).map((r,o)=>n("div",{class:"profiler-toolbar-panel-row profiler-text--sm",children:[n("span",{class:"profiler-text--muted",children:[r.mailer_class,"#",r.action]}),n("span",{class:r.error?"profiler-text--error":"profiler-text--success",children:r.error?"\u274C":"\u2705"})]},o)),t.total>3&&n("div",{class:"profiler-toolbar-panel-row profiler-text--muted profiler-text--xs",children:["+",t.total-3," more\u2026"]})]})]})}function Tr(t){return t.allocated_objects!=null?t.allocated_objects:t.memory!=null?Math.round(t.memory/40):null}function Zn(t){return t==null?"-":`${t.toLocaleString("en")} objects`}var eo="Objects allocated by the whole process while this ran: on a multi-threaded server, it includes what other threads allocated meanwhile.";function jo(t){return t>=200&&t<300?"profiler-text--success":t>=300&&t<400?"profiler-text--warning":t>=400?"profiler-text--error":""}function Ho(t){return t<100?"profiler-text--success":t<500?"profiler-text--warning":"profiler-text--error"}function Bo(t){return new Date(t).toLocaleTimeString("en",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit"})}function to({profile:t,token:e}){let r=t.collectors_data||{},o=r.request,i=r.database,s=r.ajax,u=r.performance,p=r.view,f=r.cache,c=r.dump,y=r.http,l=r.logs,m=r.exception,d=r.routes,T=r.i18n,x=r.env,v=r.mailer,g=t.child_jobs??[],R=jo(t.status),q=Ho(t.duration),F=(i?.slow_queries??0)>0?"profiler-text--error":"profiler-text--success",L=(s?.total_requests??0)>20?"profiler-text--error":"profiler-text--success",W=(f?.hit_rate??0)>80?"profiler-text--success":"profiler-text--warning";return n(b,{children:n("div",{class:"profiler-toolbar-container",children:[o&&n(b,{children:[n(U,{href:`/_profiler/profiles/${e}?tab=request`,className:R,panelLarge:!0,panel:n(kn,{profile:t,requestData:o}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:t.method}),n("span",{children:t.status})]}),n(U,{href:`/_profiler/profiles/${e}?tab=request`,className:q,panel:n(b,{children:[n("div",{class:"profiler-toolbar-panel-header",children:"Performance"}),n("div",{class:"profiler-toolbar-panel-content",children:[n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Duration"}),n("strong",{class:q,children:[t.duration.toFixed(2)," ms"]})]}),Tr(t)!=null&&n("div",{class:"profiler-toolbar-panel-row",title:eo,children:[n("span",{children:"Allocations"}),n("strong",{children:Zn(Tr(t))})]}),n("div",{class:"profiler-toolbar-panel-row",children:[n("span",{children:"Started"}),n("strong",{children:Bo(t.started_at)})]})]})]}),children:[n("span",{class:q,children:t.duration.toFixed(2)}),n("span",{class:"profiler-text--muted profiler-text--xs",children:"ms"})]})]}),i?.total_queries!==void 0&&n(U,{href:`/_profiler/profiles/${e}?tab=database`,className:F,panelLarge:!0,panel:n(Ln,{dbData:i}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"DB"}),n("span",{children:i.total_queries}),(i.slow_queries??0)>0&&n("span",{class:"profiler-text--error profiler-text--xs",children:["\u25B2 ",i.slow_queries]}),n("span",{class:"profiler-text--muted profiler-text--xs",children:[i.total_duration.toFixed(1),"ms"]})]}),s&&s.total_requests>0&&n(U,{href:`/_profiler/profiles/${e}?tab=ajax`,className:L,panelLarge:!0,panel:n(In,{ajaxData:s}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"XHR"}),n("span",{children:s.total_requests}),n("span",{class:"profiler-text--muted profiler-text--xs",children:[s.total_duration.toFixed(1),"ms"]})]}),u?.events&&u.total_events>0&&n(U,{href:`/_profiler/profiles/${e}?tab=timeline`,panel:n(Vn,{perfData:u}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"EVT"}),n("span",{children:u.total_events})]}),p?.total_views!==void 0&&n(U,{href:`/_profiler/profiles/${e}?tab=views`,panel:n(Nn,{viewData:p}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"VIEW"}),n("span",{children:p.total_views}),p.total_partials>0&&n("span",{class:"profiler-text--muted profiler-text--xs",children:["+",p.total_partials,"p"]})]}),f&&f.total_reads>0&&n(U,{href:`/_profiler/profiles/${e}?tab=cache`,className:W,panel:n(Gn,{cacheData:f}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"CACHE"}),n("span",{class:W,children:[f.hit_rate,"%"]})]}),y&&y.total_requests>0&&n(U,{href:`/_profiler/profiles/${e}?tab=http`,className:y.error_requests>0||y.slow_requests>0?"profiler-text--error":"profiler-text--success",panelLarge:!0,panel:n(Hn,{httpData:y}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"HTTP"}),n("span",{children:y.total_requests}),y.slow_requests>0&&n("span",{class:"profiler-text--error profiler-text--xs",children:["\u25B2 ",y.slow_requests]}),n("span",{class:"profiler-text--muted profiler-text--xs",children:[y.total_duration.toFixed(1),"ms"]})]}),c&&c.count>0&&n(U,{href:`/_profiler/profiles/${e}?tab=dump`,className:"profiler-text--warning",panelLarge:!0,panel:n(jn,{dumpData:c}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"DUMP"}),n("span",{class:"profiler-text--warning",children:c.count})]}),l&&l.count>0&&n(U,{href:`/_profiler/profiles/${e}?tab=logs`,className:l.errors>0?"profiler-text--error":l.warnings>0?"profiler-text--warning":"profiler-text--muted",panelLarge:!0,panel:n(Bn,{logData:l}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"LOG"}),n("span",{class:l.errors>0?"profiler-text--error":l.warnings>0?"profiler-text--warning":"",children:l.errors>0?l.errors:l.warnings>0?l.warnings:l.count})]}),m&&m.exception_class&&n(U,{href:`/_profiler/profiles/${e}?tab=exception`,className:"profiler-text--error",panelLarge:!0,panel:n(Jn,{exceptionData:m}),children:[n("span",{class:"profiler-text--error profiler-text--xs",children:"\u{1F4A5}"}),n("span",{class:"profiler-text--error profiler-text--xs",children:m.exception_class.split("::").pop()})]}),d&&d.total>0&&n(U,{href:`/_profiler/profiles/${e}?tab=routes`,panelLarge:!0,panel:n($n,{routesData:d}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"ROUTE"}),n("span",{class:"profiler-text--xs profiler-text--mono",children:d.matched?.pattern??"-"})]}),T&&T.total>0&&n(U,{href:`/_profiler/profiles/${e}?tab=i18n`,className:T.missing_count>0?"profiler-text--error":"profiler-text--muted",panel:n(Wn,{i18nData:T}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"I18N"}),n("span",{class:"profiler-text--xs profiler-text--mono",children:T.locale}),T.missing_count>0&&n("span",{class:"profiler-text--error profiler-text--xs",children:["\u26A0 ",T.missing_count]})]}),g.length>0&&n(U,{href:`/_profiler/profiles/${e}?tab=jobs`,className:g.some(G=>G.status==="failed")?"profiler-text--error":g.some(G=>G.status==="running")?"profiler-text--info":"profiler-text--success",panelLarge:!0,panel:n(zn,{jobs:g}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"JOB"}),n("span",{children:g.length}),g.some(G=>G.status==="failed")&&n("span",{class:"profiler-text--error profiler-text--xs",children:"\u2717"}),g.some(G=>G.status==="running")&&n("span",{class:"profiler-spinner profiler-text--info profiler-text--xs","aria-hidden":"true",children:"\u25D0"})]}),v&&(v.total>0||(v.queued_count??0)>0)&&n(U,{href:`/_profiler/profiles/${e}?tab=mailer`,className:v.failed>0?"profiler-text--error":"profiler-text--success",panelLarge:!0,panel:n(Yn,{mailerData:v}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"MAIL"}),v.total>0&&n("span",{children:v.total}),v.total===0&&(v.queued_count??0)>0&&n("span",{class:"profiler-text--muted",children:[v.queued_count,"q"]}),v.total>0&&(v.queued_count??0)>0&&n("span",{class:"profiler-text--muted profiler-text--xs",children:["+",v.queued_count,"q"]}),v.failed>0&&n("span",{class:"profiler-text--error profiler-text--xs",children:["\u25B2 ",v.failed]})]}),x&&x.total>0&&n(U,{href:`/_profiler/profiles/${e}?tab=env`,panel:n(Xn,{envData:x}),children:[n("span",{class:"profiler-text--muted profiler-text--xs",children:"ENV"}),n("span",{class:"profiler-text--muted",children:x.total})]}),n("a",{href:"/_profiler/health",class:"profiler-toolbar-item",children:"Health"}),n("a",{href:"/_profiler",class:"profiler-toolbar-item profiler-toolbar-logo",children:"\u2B21 Profiler"})]})})}var Jo="profiler-active-slave",$o=(()=>{try{let t=sessionStorage.getItem(Jo);return t?`/slaves/${t}`:""}catch{return""}})();function ro(){return $o}var Wo="/_profiler/api/cluster/";async function Mt(t){let e=t.url.startsWith(Wo)?"":ro(),r=e?t.url.replace("/_profiler/api",`/_profiler/api${e}`):t.url,{method:o,params:i,data:s,headers:u={},signal:p}=t,f=r,c=i?"?"+new URLSearchParams(Object.entries(i).map(([d,T])=>[d,String(T)])).toString():"",y={"X-Profiler-Request":"1",...u},l=await fetch(f+c,{method:o,signal:p,headers:s!==void 0?{"Content-Type":"application/json",...y}:y,body:s!==void 0?JSON.stringify(s):void 0});if(l.status===204)return{};let m=await l.json();if(!l.ok)throw Object.assign(new Error(m?.error??`HTTP ${l.status}`),{status:l.status,data:m});return m}var zo=(t,e)=>{let r={queryKey:e};for(let o of Object.keys(t))o!=="queryKey"&&Object.defineProperty(r,o,{enumerable:!0,configurable:!0,get:()=>t[o]});return r};var Xo=(t,e)=>Mt({url:`/_profiler/api/toolbar/${t}`,method:"GET",signal:e}),Yo=t=>[`/_profiler/api/toolbar/${t}`],Zo=(t,e)=>{let{query:r}=e??{};return{queryKey:r?.queryKey??Yo(t),queryFn:({signal:s})=>Xo(t,s),enabled:t!=null,...r}};function no(t,e){let r=Zo(t,e),o=mr(r);return zo(o,r.queryKey)}var oo=[1e3,1e3,2e3,2e3,4e3,4e3,8e3,8e3,15e3,15e3],es=3e4,ts=10*6e4;function rs(t){return typeof t=="object"&&t!==null&&Number.isFinite(t.cursor)}function so(t){let e=t.now??(()=>Date.now()),r=t.setTimer??((T,x)=>setTimeout(T,x)),o=t.clearTimer??(T=>clearTimeout(T)),i=t.cursor,s=0,u=e(),p=null,f=!1,c=!1,y=!1,l=()=>{p!==null&&(o(p),p=null)},m=()=>{if(l(),c||f||e()-u>=ts)return;let T=s<oo.length?oo[s]:es;s+=1,p=r(()=>{p=null,d()},T)},d=async()=>{if(!(c||y)){y=!0;try{let T=await t.check(i);if(c)return;rs(T)&&(i=Math.max(i,T.cursor),T.updated===!0&&(s=0,u=e(),t.onUpdate()))}catch{}finally{y=!1}m()}};return m(),{pause(){f=!0,l()},resume(){c||(f=!1,l(),d())},stop(){c=!0,l()}}}var ns="/_profiler";function io(t,e,r){let o=qe(r);o.current=r,$(()=>{if(!t||e===void 0)return;let s=so({cursor:e,check:p=>Mt({url:`${ns}/api/events/${encodeURIComponent(t)}`,method:"GET",params:{since:p}}),onUpdate:()=>o.current()}),u=()=>{document.hidden?s.pause():s.resume()};return document.addEventListener("visibilitychange",u),document.hidden&&s.pause(),()=>{document.removeEventListener("visibilitychange",u),s.stop()}},[t,e!==void 0])}function ao({token:t}){let{data:e,refetch:r,isError:o,isFetching:i}=no(t,{query:{refetchOnWindowFocus:!1}});$(()=>{window.__PROFILER_REFRESH_TOOLBAR__=()=>{r()}},[r]),io(t,e?.events_cursor,()=>{r()});let s=e?.profile??null;return s?n(to,{profile:s,token:t}):o?n("div",{class:"profiler-toolbar-container",children:n("span",{class:"profiler-toolbar-error",role:"alert",children:[n("span",{class:"profiler-text--error",children:"Profiler data could not be loaded."}),n("button",{type:"button",class:"profiler-toolbar-retry",disabled:i,onClick:()=>{r()},children:i?"Retrying...":"Retry"})]})}):null}var Dt=class extends Me{constructor(){super(...arguments);this.state={failed:!1}}static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(r){console.error("[Profiler] The toolbar failed to render:",r)}render(){return this.state.failed?n("div",{class:"profiler-toolbar-container",children:n("span",{class:"profiler-toolbar-error",role:"alert",children:[n("span",{class:"profiler-text--error",children:"Profiler toolbar error."}),n("button",{type:"button",class:"profiler-toolbar-retry",onClick:()=>this.setState({failed:!1}),children:"Retry"})]})}):this.props.children}};function uo(t){return t.altKey&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey&&t.code==="KeyP"}var _r=new Map;function vr(t){try{return localStorage.getItem(t)}catch{return _r.has(t)?_r.get(t):null}}function lo(t,e){_r.set(t,e);try{localStorage.setItem(t,e)}catch{}}var gr=280;function po(t){let e=vr("profiler-theme"),r=e==="light"?"light":e==="dark"?"dark":window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";t.forEach(o=>o.setAttribute("data-theme",r))}var os=new ar({defaultOptions:{queries:{staleTime:3e4,retry:1}}});function co(){let t=document.getElementById("profiler-toolbar"),e=document.getElementById("profiler-toolbar-toggle");if(!t||!e)return;let r=t.dataset.token;if(!r)return;window.__PROFILER_TOOLBAR_TEARDOWN__?.();let o=new AbortController,{signal:i}=o,s=()=>{o.abort(),Gt(null,t),window.__PROFILER_TOOLBAR_TEARDOWN__===s&&delete window.__PROFILER_TOOLBAR_TEARDOWN__};window.__PROFILER_TOOLBAR_TEARDOWN__=s,document.addEventListener("turbo:load",()=>{t.isConnected||s()},{signal:i});let u=[t,e];po(u),window.addEventListener("storage",c=>{c.key==="profiler-theme"&&po(u)},{signal:i}),window.addEventListener("profiler:theme-change",(c=>{c.detail?.theme&&u.forEach(y=>y.setAttribute("data-theme",c.detail.theme))}),{signal:i});let p=vr("profiler-toolbar-collapsed")==="true";e.dataset.collapsed=String(p),p&&!t.style.transform&&(t.style.animation="none",t.style.transform="translateX(calc(100% + 44px))"),p||setTimeout(()=>{t.style.animation="none"},400);function f(){let c=!p;p=c,lo("profiler-toolbar-collapsed",String(c)),e.dataset.collapsed=String(c),c?(t.style.transition=`transform ${gr}ms cubic-bezier(0.4,0,0.2,1)`,t.style.transform="translateX(calc(100% + 44px))"):(t.style.transition="none",t.style.transform="translateX(calc(100% + 44px))",t.offsetWidth,t.style.transition=`transform ${gr}ms cubic-bezier(0.4,0,0.2,1)`,t.style.transform="translateX(0)",setTimeout(()=>{t.style.transform="",t.style.transition=""},gr+50))}e.addEventListener("click",f,{signal:i}),document.addEventListener("keydown",c=>{uo(c)&&(c.preventDefault(),f())},{signal:i}),Gt(n(yr,{client:os,children:n(Dt,{children:n(ao,{token:r})})}),t)}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",co):co();})();
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Profiler
4
+ # GET /_profiler/health: the state of the circuit of each collector (see
5
+ # Profiler::Collectors::CircuitBreaker), as a page or, with a .json suffix or an Accept
6
+ # header, as JSON. Always 200: an open circuit means a collector is left out of the profiles,
7
+ # not that the profiler or the application is down, and a 503 would trip any probe pointed at it.
8
+ class HealthController < ApplicationController
9
+ def show
10
+ @enabled = Profiler.configuration.collector_circuit_breaker_enabled ? true : false
11
+ @threshold = Profiler.configuration.collector_circuit_breaker_threshold
12
+ @collectors = Profiler.configuration.collectors.map do |collector_class|
13
+ Collectors::CircuitBreaker.status(collector_class).merge(name: collector_class.name.to_s)
14
+ end
15
+
16
+ respond_to do |format|
17
+ format.html
18
+ format.json do
19
+ render json: {
20
+ circuit_breaker: { enabled: @enabled, threshold: @threshold },
21
+ collectors: @collectors
22
+ }
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ <div style="max-width: 900px; margin: 24px auto; padding: 0 16px; font-family: system-ui, sans-serif;">
2
+ <p><a href="<%= profiler.root_path %>">&larr; Profiler</a></p>
3
+ <h1>Collector health</h1>
4
+ <p>
5
+ Circuit breaker: <strong><%= @enabled ? "enabled" : "disabled" %></strong>,
6
+ opens after <strong><%= @threshold %></strong> consecutive failures.
7
+ </p>
8
+ <table style="border-collapse: collapse; width: 100%;">
9
+ <thead>
10
+ <tr>
11
+ <th style="text-align: left; border-bottom: 1px solid #888; padding: 6px;">Collector</th>
12
+ <th style="text-align: left; border-bottom: 1px solid #888; padding: 6px;">State</th>
13
+ <th style="text-align: right; border-bottom: 1px solid #888; padding: 6px;">Consecutive failures</th>
14
+ </tr>
15
+ </thead>
16
+ <tbody>
17
+ <% @collectors.each do |collector| %>
18
+ <tr>
19
+ <td style="padding: 6px;"><%= collector[:name] %></td>
20
+ <td style="padding: 6px; font-weight: bold; color: <%= { closed: "#2e7d32", open: "#c62828", half_open: "#ef6c00" }[collector[:state]] %>;"><%= collector[:state] %></td>
21
+ <td style="padding: 6px; text-align: right;"><%= collector[:failures] %></td>
22
+ </tr>
23
+ <% end %>
24
+ </tbody>
25
+ </table>
26
+ </div>
data/config/routes.rb CHANGED
@@ -29,6 +29,7 @@ Profiler::Engine.routes.draw do
29
29
  get "assets/icon.png", to: "assets#icon"
30
30
 
31
31
  get "test_runner", to: "test_runner#index"
32
+ get "health", to: "health#show"
32
33
 
33
34
  namespace :api do
34
35
  resources :profiles, only: [:index, :show, :destroy] do
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Profiler
4
+ module Collectors
5
+ # One circuit per collector class, shared by the threads and requests of the process. A
6
+ # class that fails config.collector_circuit_breaker_threshold times in a row (a subscribe or
7
+ # a collect that raises) is no longer instantiated: its circuit is open. After RECOVERY_SECONDS
8
+ # a single request tries it again (half open): a success closes the circuit, a failure
9
+ # opens it again for another RECOVERY_SECONDS. With the option off, nothing is counted and
10
+ # nothing is blocked.
11
+ module CircuitBreaker
12
+ RECOVERY_SECONDS = 60
13
+
14
+ # state: :closed, :open or :half_open. +since+ is when the circuit opened, or when the
15
+ # trial of a half open one was granted.
16
+ Circuit = Struct.new(:failures, :state, :since)
17
+
18
+ LOCK = Mutex.new
19
+ CIRCUITS = {}
20
+ private_constant :LOCK, :CIRCUITS
21
+
22
+ module_function
23
+
24
+ def enabled?
25
+ Profiler.configuration.collector_circuit_breaker_enabled ? true : false
26
+ end
27
+
28
+ # Whether a collector of this class is to be created for the next profile. An open circuit
29
+ # whose delay has passed answers true once, and becomes half open; a half open one answers
30
+ # false while its trial is under way, unless that trial never reported for RECOVERY_SECONDS.
31
+ def allow?(collector_class)
32
+ return true unless enabled?
33
+
34
+ LOCK.synchronize do
35
+ circuit = CIRCUITS[collector_class]
36
+ return true unless circuit
37
+
38
+ case circuit.state
39
+ when :closed then true
40
+ else
41
+ return false if now - circuit.since < RECOVERY_SECONDS
42
+
43
+ circuit.state = :half_open
44
+ circuit.since = now
45
+ true
46
+ end
47
+ end
48
+ end
49
+
50
+ def record_failure(collector_class)
51
+ return unless enabled?
52
+
53
+ LOCK.synchronize do
54
+ circuit = (CIRCUITS[collector_class] ||= Circuit.new(0, :closed, nil))
55
+ circuit.failures += 1
56
+ if circuit.state == :half_open || circuit.failures >= Profiler.configuration.collector_circuit_breaker_threshold
57
+ circuit.state = :open
58
+ circuit.since = now
59
+ end
60
+ end
61
+ end
62
+
63
+ def record_success(collector_class)
64
+ return unless enabled?
65
+
66
+ LOCK.synchronize do
67
+ circuit = CIRCUITS[collector_class]
68
+ return unless circuit
69
+
70
+ # A late success of a request that started before the circuit opened does not close it.
71
+ return if circuit.state == :open
72
+
73
+ CIRCUITS.delete(collector_class)
74
+ end
75
+ end
76
+
77
+ # { state:, failures: } for one class, without changing anything. An open circuit whose
78
+ # delay has passed is reported half open: the next request will try it.
79
+ def status(collector_class)
80
+ return { state: :closed, failures: 0 } unless enabled?
81
+
82
+ LOCK.synchronize do
83
+ circuit = CIRCUITS[collector_class]
84
+ return { state: :closed, failures: 0 } unless circuit
85
+
86
+ state = circuit.state
87
+ state = :half_open if state == :open && now - circuit.since >= RECOVERY_SECONDS
88
+ { state: state, failures: circuit.failures }
89
+ end
90
+ end
91
+
92
+ def reset!
93
+ LOCK.synchronize { CIRCUITS.clear }
94
+ end
95
+
96
+ # Monotonic seconds; a spec replaces it to move time.
97
+ def now
98
+ Process.clock_gettime(Process::CLOCK_MONOTONIC)
99
+ end
100
+ end
101
+ end
102
+ end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative "circuit_breaker"
4
+
3
5
  module Profiler
4
6
  module Collectors
5
7
  # Subscribes and releases the collectors of one profile, for every entry point that runs
@@ -7,14 +9,26 @@ module Profiler
7
9
  module Lifecycle
8
10
  module_function
9
11
 
10
- # Subscribes each collector in turn. When one fails, releases them all, the ones that
11
- # never subscribed included, and returns false: the caller then runs the work unprofiled.
12
+ # Subscribes each collector in turn. A collector whose subscribe raises is released and
13
+ # taken out of +collectors+ (the array is changed in place, so that the caller only collects
14
+ # the ones that subscribed); the others keep profiling. Returns false, with every collector
15
+ # released, only when none could subscribe: the caller then runs the work unprofiled.
12
16
  def subscribe_all(collectors, label)
13
- collectors.each { |collector| collector.subscribe if collector.respond_to?(:subscribe) }
17
+ return true if collectors.empty?
18
+
19
+ collectors.reject! { |collector| !subscribe_one(collector, label) }
20
+ !collectors.empty?
21
+ end
22
+
23
+ # Runs the block that collects from one collector. A failure is logged and counted against
24
+ # the collector's class (CircuitBreaker), a success clears that count; the others carry on.
25
+ def guard(collector, label)
26
+ yield
27
+ CircuitBreaker.record_success(collector.class)
14
28
  true
15
29
  rescue => e
16
- Profiler.log_error("#{label}: collector subscribe failed", e)
17
- release_all(collectors)
30
+ Profiler.log_error("#{label}: collector #{collector.class} failed", e)
31
+ CircuitBreaker.record_failure(collector.class)
18
32
  false
19
33
  end
20
34
 
@@ -26,6 +40,17 @@ module Profiler
26
40
  Profiler.log_error("collector #{collector.class} release failed", e)
27
41
  end
28
42
  end
43
+
44
+ def subscribe_one(collector, label)
45
+ collector.subscribe if collector.respond_to?(:subscribe)
46
+ true
47
+ rescue => e
48
+ Profiler.log_error("#{label}: collector #{collector.class} subscribe failed", e)
49
+ CircuitBreaker.record_failure(collector.class)
50
+ release_all([collector])
51
+ false
52
+ end
53
+ private_class_method :subscribe_one
29
54
  end
30
55
  end
31
56
  end
@@ -57,7 +57,8 @@ module Profiler
57
57
  :name, :master_url, :self_url,
58
58
  :cluster_heartbeat_interval, :cluster_offline_threshold,
59
59
  :cluster_master, :cluster_secret, :cluster_require_secret,
60
- :cluster_allow_insecure_http, :logger
60
+ :cluster_allow_insecure_http, :logger,
61
+ :collector_circuit_breaker_enabled
61
62
 
62
63
  attr_reader :authorize_block, :enabled, :track_tests, :max_profiles
63
64
 
@@ -156,6 +157,23 @@ module Profiler
156
157
  # Where the profiler's own errors go (Profiler.log): Rails.logger when nil, or $stderr when
157
158
  # there is none.
158
159
  @logger = nil
160
+ # A collector that fails this many times in a row is no longer run (see
161
+ # Profiler::Collectors::CircuitBreaker); false never stops one.
162
+ @collector_circuit_breaker_enabled = true
163
+ @collector_circuit_breaker_threshold = 3
164
+ end
165
+
166
+ attr_reader :collector_circuit_breaker_threshold
167
+
168
+ # A positive Integer. Anything else is left out with a warning, the previous value kept: the
169
+ # gem is loaded in production too, where a mistake here must not stop the application booting.
170
+ def collector_circuit_breaker_threshold=(value)
171
+ if value.is_a?(Integer) && value.positive?
172
+ @collector_circuit_breaker_threshold = value
173
+ else
174
+ Profiler.log_warn("config.collector_circuit_breaker_threshold: #{value.inspect} is not a positive " \
175
+ "Integer; keeping #{@collector_circuit_breaker_threshold}")
176
+ end
159
177
  end
160
178
 
161
179
  # Always a Pathname, whether set from a String or left to its default.
@@ -72,11 +72,9 @@ module Profiler
72
72
  profile.finish(console_status == "completed" ? 200 : 500)
73
73
 
74
74
  collectors.each do |collector|
75
- begin
75
+ Collectors::Lifecycle.guard(collector, "ConsoleProfiler") do
76
76
  collector.collect if collector.respond_to?(:collect)
77
77
  profile.add_collector_metadata(collector)
78
- rescue => e
79
- Profiler.log_error("ConsoleProfiler: collector #{collector.class} failed", e)
80
78
  end
81
79
  end
82
80
 
@@ -102,11 +102,9 @@ module Profiler
102
102
  profile.finish(job_status == "completed" ? 200 : 500)
103
103
 
104
104
  collectors.each do |collector|
105
- begin
105
+ Collectors::Lifecycle.guard(collector, "JobProfiler") do
106
106
  collector.collect if collector.respond_to?(:collect)
107
107
  profile.add_collector_metadata(collector)
108
- rescue => e
109
- Profiler.log_error("JobProfiler: collector #{collector.class} failed", e)
110
108
  end
111
109
  end
112
110
 
@@ -153,10 +153,10 @@ module Profiler
153
153
  # A Rack 3 streaming body (call without each) writes to the socket itself: nothing to relay.
154
154
  unless body.respond_to?(:each)
155
155
  kept.each do |collector|
156
- collector.collect if collector.respond_to?(:collect)
157
- profile.refresh_collector_metadata(collector)
158
- rescue => e
159
- Profiler.log_error("ProfilerMiddleware: collector #{collector.class} failed", e)
156
+ Collectors::Lifecycle.guard(collector, "ProfilerMiddleware") do
157
+ collector.collect if collector.respond_to?(:collect)
158
+ profile.refresh_collector_metadata(collector)
159
+ end
160
160
  end
161
161
  record_response(env, profile, request_body, status, profiled_headers, "", nil, false)
162
162
  # Saved before the headers leave: a profile that is not there gets no token.
@@ -199,10 +199,10 @@ module Profiler
199
199
  next unless collector.is_a?(Collectors::RequestCollector) ||
200
200
  (error && collector.respond_to?(:capture) && !collect_from_any_thread?(collector))
201
201
 
202
- collector.collect
203
- profile.refresh_collector_metadata(collector)
204
- rescue => e
205
- Profiler.log_error("ProfilerMiddleware: collector #{collector.class} failed", e)
202
+ Collectors::Lifecycle.guard(collector, "ProfilerMiddleware") do
203
+ collector.collect
204
+ profile.refresh_collector_metadata(collector)
205
+ end
206
206
  end
207
207
 
208
208
  Profiler.save_profile(profile, from: "ProfilerMiddleware")
@@ -261,11 +261,9 @@ module Profiler
261
261
 
262
262
  def collect_all(profile, collectors)
263
263
  collectors.each do |collector|
264
- begin
264
+ Collectors::Lifecycle.guard(collector, "ProfilerMiddleware") do
265
265
  collector.collect if collector.respond_to?(:collect)
266
266
  profile.add_collector_metadata(collector)
267
- rescue => e
268
- Profiler.log_error("ProfilerMiddleware: collector #{collector.class} failed", e)
269
267
  end
270
268
  end
271
269
  end
@@ -303,7 +301,9 @@ module Profiler
303
301
  # Builds the collectors without subscribing them: Lifecycle.subscribe_all does, so that
304
302
  # a failure part way leaves every collector reachable for release.
305
303
  def create_collectors(profile)
306
- Profiler.configuration.collectors.map { |collector_class| collector_class.new(profile) }
304
+ Profiler.configuration.collectors
305
+ .select { |collector_class| Collectors::CircuitBreaker.allow?(collector_class) }
306
+ .map { |collector_class| collector_class.new(profile) }
307
307
  end
308
308
 
309
309
  def html_response?(headers)
@@ -82,10 +82,10 @@ module Profiler
82
82
  @released = true
83
83
  @profile.collectors_released_after_seconds = after_seconds if after_seconds
84
84
  @collectors.each do |collector|
85
- collector.collect if collector.respond_to?(:collect)
86
- @profile.refresh_collector_metadata(collector)
87
- rescue => e
88
- Profiler.log_error("ProfilerMiddleware: collector #{collector.class} failed", e)
85
+ Collectors::Lifecycle.guard(collector, "ProfilerMiddleware") do
86
+ collector.collect if collector.respond_to?(:collect)
87
+ @profile.refresh_collector_metadata(collector)
88
+ end
89
89
  end
90
90
  Collectors::Lifecycle.release_all(@collectors)
91
91
  end
@@ -101,11 +101,9 @@ module Profiler
101
101
  profile.finish(test_status == "passed" ? 200 : 500)
102
102
 
103
103
  collectors.each do |collector|
104
- begin
104
+ Collectors::Lifecycle.guard(collector, "TestProfiler") do
105
105
  collector.collect if collector.respond_to?(:collect)
106
106
  profile.add_collector_metadata(collector)
107
- rescue => e
108
- Profiler.log_error("TestProfiler: collector #{collector.class} failed", e)
109
107
  end
110
108
  end
111
109
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Profiler
4
- VERSION = "0.36.2"
4
+ VERSION = "0.37.0"
5
5
 
6
6
  GEM_ROOT = File.expand_path("../..", __dir__)
7
7
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-profiler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.2
4
+ version: 0.37.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sébastien Duplessy
@@ -133,10 +133,12 @@ files:
133
133
  - app/controllers/profiler/api/toolbar_controller.rb
134
134
  - app/controllers/profiler/application_controller.rb
135
135
  - app/controllers/profiler/assets_controller.rb
136
+ - app/controllers/profiler/health_controller.rb
136
137
  - app/controllers/profiler/profiles_controller.rb
137
138
  - app/controllers/profiler/test_runner_controller.rb
138
139
  - app/views/layouts/profiler/application.html.erb
139
140
  - app/views/layouts/profiler/embedded.html.erb
141
+ - app/views/profiler/health/show.html.erb
140
142
  - app/views/profiler/profiles/index.html.erb
141
143
  - app/views/profiler/profiles/show.html.erb
142
144
  - app/views/profiler/test_runner/index.html.erb
@@ -156,6 +158,7 @@ files:
156
158
  - lib/profiler/collectors/ajax_collector.rb
157
159
  - lib/profiler/collectors/base_collector.rb
158
160
  - lib/profiler/collectors/cache_collector.rb
161
+ - lib/profiler/collectors/circuit_breaker.rb
159
162
  - lib/profiler/collectors/console_collector.rb
160
163
  - lib/profiler/collectors/database_collector.rb
161
164
  - lib/profiler/collectors/dump_collector.rb