railwatch 0.9.2 → 0.9.4
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 +4 -4
- data/CHANGELOG.md +25 -0
- data/app/frontend/entrypoints/inertia.tsx +5 -8
- data/app/frontend/lib/mount.ts +23 -0
- data/app/frontend/lib/railwatch.ts +10 -1
- data/docs/configuration.md +22 -5
- data/lib/railwatch/buffer.rb +9 -0
- data/lib/railwatch/reporter.rb +89 -2
- data/lib/railwatch/sampler.rb +10 -2
- data/lib/railwatch/version.rb +1 -1
- data/lib/railwatch.rb +4 -2
- data/public/railwatch/assets/{app-layout-CpEbDy93.js → app-layout-by7G3sa1.js} +1 -1
- data/public/railwatch/assets/{arrow-up-DAODKT5N.js → arrow-up-DCZ7emux.js} +1 -1
- data/public/railwatch/assets/{braces-DgB4bqp0.js → braces-CykT5_5u.js} +1 -1
- data/public/railwatch/assets/{card-C4EFUWG1.js → card-C-PPSA0g.js} +1 -1
- data/public/railwatch/assets/{chart-CD6EHDjG.js → chart-Cov79YC5.js} +1 -1
- data/public/railwatch/assets/{chart-hover-B5cFOZ24.js → chart-hover-DdK4E-2h.js} +1 -1
- data/public/railwatch/assets/{chart-panel-XD8qJDmg.js → chart-panel-BPaYRXJB.js} +1 -1
- data/public/railwatch/assets/{code-CuTKEYtT.js → code-BYjC4YZ_.js} +1 -1
- data/public/railwatch/assets/{copy-id-COM9oXfT.js → copy-id-LPfoj9cC.js} +1 -1
- data/public/railwatch/assets/{cursor-load-more-CleS4nD4.js → cursor-load-more-DSdhgpGl.js} +1 -1
- data/public/railwatch/assets/{data-table-Bzj8zcao.js → data-table-CQ_YRWQs.js} +1 -1
- data/public/railwatch/assets/{env-layout-Dic4A8Kn.js → env-layout-CdMWbUkm.js} +1 -1
- data/public/railwatch/assets/{execution-path-C7Up9w4e.js → execution-path-7MYt-Qbn.js} +1 -1
- data/public/railwatch/assets/{filter-bar-B5wbix1y.js → filter-bar-CrzpQ_vD.js} +1 -1
- data/public/railwatch/assets/{flamegraph-Dve4TVkl.js → flamegraph-BIFEdTAg.js} +1 -1
- data/public/railwatch/assets/{frames-CkDFkUhi.js → frames-C5t-x4f0.js} +1 -1
- data/public/railwatch/assets/{index-Dj03Gham.js → index--NQ7us-L.js} +1 -1
- data/public/railwatch/assets/{index-DKwz3gSX.js → index-2kgYe_99.js} +1 -1
- data/public/railwatch/assets/{index-CgoVIV-m.js → index-4YEPHxtO.js} +1 -1
- data/public/railwatch/assets/{index-7fYWYI1v.js → index-AOCC1GDJ.js} +1 -1
- data/public/railwatch/assets/{index-wH-xxmJK.js → index-BEo-u0eO.js} +1 -1
- data/public/railwatch/assets/{index-CXSEiNWw.js → index-BJ1V3w2N.js} +1 -1
- data/public/railwatch/assets/{index-DJZkxYZf.js → index-BPoHsBKb.js} +1 -1
- data/public/railwatch/assets/{index-BheGBdI9.js → index-BZzyGUM3.js} +1 -1
- data/public/railwatch/assets/{index-B51WiPQg.js → index-BgVq7yKL.js} +1 -1
- data/public/railwatch/assets/{index-BxSwNl8H.js → index-BqFGEZvW.js} +1 -1
- data/public/railwatch/assets/{index-BA3nScnV.js → index-ByuHJ1CH.js} +1 -1
- data/public/railwatch/assets/{index-DwGETVLb.js → index-C2j50AL2.js} +1 -1
- data/public/railwatch/assets/{index-D7t5pSOT.js → index-CLEdTkvW.js} +1 -1
- data/public/railwatch/assets/{index-Dx7oNB2j.js → index-CWgq8qBu.js} +1 -1
- data/public/railwatch/assets/{index-YqmR-RY4.js → index-CXQ7_oVj.js} +1 -1
- data/public/railwatch/assets/{index-CEcv5bba.js → index-CmyYrjS2.js} +1 -1
- data/public/railwatch/assets/{index-B2hTf0w6.js → index-Cn9_HjDo.js} +1 -1
- data/public/railwatch/assets/{index-CG7VCShP.js → index-CsMAm9UK.js} +1 -1
- data/public/railwatch/assets/{index-Kxpc-Jju.js → index-D0Kk_oGY.js} +1 -1
- data/public/railwatch/assets/{index-DTLmaJha.js → index-DC9ZptJh.js} +1 -1
- data/public/railwatch/assets/{index-DqeNWrJc.js → index-DNzg7jmV.js} +1 -1
- data/public/railwatch/assets/{index-0glo-UpF.js → index-DQ8uJO5f.js} +1 -1
- data/public/railwatch/assets/{index-kX9K5M8z.js → index-Deq14BxB.js} +1 -1
- data/public/railwatch/assets/{index-C_3JsXHv.js → index-IaV3Blzp.js} +1 -1
- data/public/railwatch/assets/{index-6t2RLBwA.js → index-TYNWcJQs.js} +1 -1
- data/public/railwatch/assets/{index-x18ma-AF.js → index-WonH2fcZ.js} +1 -1
- data/public/railwatch/assets/{index-CnlT_aCL.js → index-WxWUaH_d.js} +1 -1
- data/public/railwatch/assets/{index-D_dUD6LY.js → index-mUNrl4ky.js} +1 -1
- data/public/railwatch/assets/{inertia-b7M33AzA.js → inertia-DfNRARuA.js} +13 -13
- data/public/railwatch/assets/{json-viewer-C0RZwcC2.js → json-viewer-DMsF5glp.js} +1 -1
- data/public/railwatch/assets/{klass-BT-gRTuY.js → klass-CmHYk5rz.js} +1 -1
- data/public/railwatch/assets/{origin-identity-ouOEvOlq.js → origin-identity-1R3bqa3R.js} +1 -1
- data/public/railwatch/assets/{percentile-picker-BYFo11OE.js → percentile-picker-73z5PAps.js} +1 -1
- data/public/railwatch/assets/{relative-time-CJX4HXBB.js → relative-time-Dsc_cCdX.js} +1 -1
- data/public/railwatch/assets/{release-health-CIxeXQ_e.js → release-health-BV5OaOWd.js} +1 -1
- data/public/railwatch/assets/{route-eUFnanVO.js → route-CWh58C7K.js} +1 -1
- data/public/railwatch/assets/{segmented-CJq8WOHZ.js → segmented-DB4zh-Am.js} +1 -1
- data/public/railwatch/assets/{select-vYjStP1q.js → select-DBKjFlOX.js} +1 -1
- data/public/railwatch/assets/{series-chart-FBOfRLhK.js → series-chart-BaiDG795.js} +1 -1
- data/public/railwatch/assets/{show-zaB17ZGC.js → show-B4ICCFGh.js} +1 -1
- data/public/railwatch/assets/{show-BJcTlqdU.js → show-B5lOU9Gv.js} +1 -1
- data/public/railwatch/assets/{show-DGPuUSHE.js → show-BYPB74t4.js} +1 -1
- data/public/railwatch/assets/{show-DNY79oEl.js → show-C7A0m2M8.js} +1 -1
- data/public/railwatch/assets/{show-D7fBqLw0.js → show-DT5X1zqE.js} +1 -1
- data/public/railwatch/assets/{show-C7w8Tnt2.js → show-D_NBdXsn.js} +1 -1
- data/public/railwatch/assets/{show-BBNCHyV9.js → show-DgPCnRg8.js} +1 -1
- data/public/railwatch/assets/{show-C5SMVt6Z.js → show-Yl69HF0x.js} +1 -1
- data/public/railwatch/assets/{show-daCAn8qV.js → show-_QxuUQCm.js} +1 -1
- data/public/railwatch/assets/{show-DeTnRall.js → show-g__jnN36.js} +1 -1
- data/public/railwatch/assets/{show-Bq4w9YtT.js → show-l4ztfjl9.js} +1 -1
- data/public/railwatch/assets/{sort-header-dslBMND2.js → sort-header-BcG8ulEH.js} +1 -1
- data/public/railwatch/assets/{sparkline-cell-C7fhjJby.js → sparkline-cell-B47ipscB.js} +1 -1
- data/public/railwatch/assets/{stat-nY8iS5q9.js → stat-DT2hhsqS.js} +1 -1
- data/public/railwatch/assets/{status-badge-D40D8TiV.js → status-badge-CmbRKlY7.js} +1 -1
- data/public/railwatch/assets/{tenant-path-UhieazCc.js → tenant-path-C4rNGauE.js} +1 -1
- data/public/railwatch/assets/{use-clipboard-T9kCBcs8.js → use-clipboard-oTNeP4ax.js} +1 -1
- data/public/railwatch/assets/{use-live-rp6jfGac.js → use-live-CLZZj245.js} +1 -1
- data/public/railwatch/manifest.json +611 -611
- metadata +75 -74
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as w,j as h,o as C,c as k,u as M}from"./inertia-
|
|
1
|
+
import{r as w,j as h,o as C,c as k,u as M}from"./inertia-DfNRARuA.js";import{a as D}from"./use-live-CLZZj245.js";import{A as I,a as O}from"./arrow-up-DCZ7emux.js";const T=300,F="cubic-bezier(.22, 1, .36, 1)",Y=2e3,$="inline-block h-[1.15em] overflow-hidden leading-[1.15em] align-top",U="inline-block h-[1.15em] overflow-visible leading-[1.15em] align-top text-center",P="block will-change-transform",E="block h-[1.15em] leading-[1.15em]",z="inline-block h-[1.15em] leading-[1.15em]";function N(o){const t=document.createElement("span");return t.className=o,t}function V(o){let t=o.length;for(;t>0&&!/[0-9]/.test(o[t-1]);)t--;return{digits:o.slice(0,t),suffix:o.slice(t)}}function q(o){const t=N(o?U:$);if(o)return{separator:!0,el:t,char:null};const u=N(P),s=N(E),i=N(E);return u.append(s,i),t.append(u),{separator:!1,el:t,strip:u,top:s,bottom:i,animation:null,char:null}}function G(o,{durationMs:t,easing:u}){const s=new Map;let i="";function d(e,r){e.animation?.cancel(),e.animation=null,e.top.textContent=r,e.bottom.textContent="",e.char=r}function R(e,r,m){if(typeof e.strip.animate!="function"){d(e,r);return}e.animation?.cancel();const a=e.char??r;m>0?(e.top.textContent=a,e.bottom.textContent=r):(e.top.textContent=r,e.bottom.textContent=a);const c=m>0?[{transform:"translateY(0)"},{transform:"translateY(-50%)"}]:[{transform:"translateY(-50%)"},{transform:"translateY(0)"}],n=e.strip.animate(c,{duration:t,easing:u,fill:"forwards"});e.animation=n,e.char=r,n.onfinish=()=>{e.animation===n&&d(e,r)}}function g(e){typeof e.el.animate=="function"&&e.el.animate([{opacity:0,transform:"translateY(0.35em)"},{opacity:1,transform:"none"}],{duration:t,easing:u})}return{paint(e,r){const{digits:m,suffix:a}=V(e),c=m.split(""),n=c.map((p,l)=>({key:c.length-1-l,char:p})),x=`${n.map(p=>p.key).join(",")}|${a}`,b=i==="";if(x!==i){const p=document.createDocumentFragment(),l=new Set;for(const{key:f,char:y}of n){l.add(f);const S=!/[0-9]/.test(y);let v=s.get(f);v?.separator!==S&&(v=q(S),s.set(f,v),!b&&r!==0&&g(v)),p.append(v.el)}for(const f of[...s.keys()])l.has(f)||s.delete(f);if(o.replaceChildren(p),a){const f=N(z);f.textContent=a,o.append(f)}i=x}for(const{key:p,char:l}of n){const f=s.get(p);!f||f.char===l||(f.separator?(f.el.textContent=l,f.char=l):f.char===null||r===0?d(f,l):R(f,l,r))}},destroy(){for(const e of s.values())e.separator||e.animation?.cancel()}}}function Q({value:o,format:t,className:u,durationMs:s=T,easing:i=F,minIntervalMs:d=Y}){const R=w.useRef(null),g=w.useRef(null),e=w.useRef(o),r=w.useRef(null),m=w.useRef(0),a=w.useRef(void 0),c=w.useRef({format:t,durationMs:s,easing:i,minIntervalMs:d});return w.useEffect(()=>{c.current={format:t,durationMs:s,easing:i,minIntervalMs:d}}),w.useEffect(()=>{const n=R.current;if(!n)return;const{format:x,durationMs:b,easing:p}=c.current,l=G(n,{durationMs:b,easing:p});return g.current=l,l.paint(x(e.current),0),()=>{clearTimeout(a.current),a.current=void 0,r.current=null,g.current=null,l.destroy()}},[]),w.useEffect(()=>{const n=g.current;if(!n||o===e.current)return;const x=l=>{m.current=Date.now(),n.paint(c.current.format(l),l>=e.current?1:-1),e.current=l},b=Date.now()-m.current,p=c.current.minIntervalMs-b;if(p<=0){x(o);return}r.current=o,a.current??=window.setTimeout(()=>{a.current=void 0;const l=r.current;r.current=null,l!==null&&l!==e.current&&x(l)},p)},[o]),h.jsx("span",{ref:R,className:C(u)})}const A="(prefers-reduced-motion: reduce)";function X(o){const t=window.matchMedia(A);return t.addEventListener("change",o),()=>{t.removeEventListener("change",o)}}function B(){return window.matchMedia(A).matches}function H(){return w.useSyncExternalStore(X,B,J)}function J(){return!0}function K(o){const t=k.c(15),{current:u,previous:s,goodDirection:i,caption:d}=o;if(!s)return null;const R=(u-s)/s*100;if(R===0)return null;const g=R>0?"up":"down",e=g===i,r=g==="up"?I:O,m=e?"text-live":"text-destructive";let a;t[0]!==m?(a=C("inline-flex items-center gap-0.5 font-mono text-xs tabular-nums",m),t[0]=m,t[1]=a):a=t[1];let c;t[2]!==r?(c=h.jsx(r,{className:"size-3"}),t[2]=r,t[3]=c):c=t[3];let n;t[4]!==R?(n=Math.abs(R).toFixed(1),t[4]=R,t[5]=n):n=t[5];let x;t[6]!==a||t[7]!==c||t[8]!==n?(x=h.jsxs("span",{className:a,children:[c,n,"%"]}),t[6]=a,t[7]=c,t[8]=n,t[9]=x):x=t[9];let b;t[10]!==d?(b=d&&h.jsx("span",{className:"text-muted-foreground text-[11px]",children:d}),t[10]=d,t[11]=b):b=t[11];let p;return t[12]!==x||t[13]!==b?(p=h.jsxs(h.Fragment,{children:[x,b]}),t[12]=x,t[13]=b,t[14]=p):p=t[14],p}function W(o){const t=k.c(16),{value:u,format:s}=o,{url:i}=M(),d=D(),R=H();let g;t[0]!==s||t[1]!==u?(g=s(u),t[0]=s,t[1]=u,t[2]=g):g=t[2];const e=g,r=d&&!R;let m;t[3]!==r||t[4]!==s||t[5]!==e||t[6]!==i||t[7]!==u?(m=r?h.jsx(Q,{value:u,format:s},i):e,t[3]=r,t[4]=s,t[5]=e,t[6]=i,t[7]=u,t[8]=m):m=t[8];let a;t[9]!==m?(a=h.jsx("span",{"aria-hidden":"true",children:m}),t[9]=m,t[10]=a):a=t[10];let c;t[11]!==e?(c=h.jsx("span",{className:"sr-only",children:e}),t[11]=e,t[12]=c):c=t[12];let n;return t[13]!==a||t[14]!==c?(n=h.jsxs(h.Fragment,{children:[a,c]}),t[13]=a,t[14]=c,t[15]=n):n=t[15],n}function nt(o){const t=k.c(28),{label:u,value:s,roll:i,hint:d,tone:R,delta:g,deltaCaption:e,card:r,className:m}=o,c=(r===void 0?!1:r)&&"bg-card rounded-lg border";let n;t[0]!==m||t[1]!==c?(n=C("flex min-w-0 flex-col gap-1 px-4 py-3",c,m),t[0]=m,t[1]=c,t[2]=n):n=t[2];let x;t[3]!==u?(x=h.jsx("div",{className:"label-caps truncate",children:u}),t[3]=u,t[4]=x):x=t[4];const b=R==="destructive"&&"text-destructive",p=R==="warning"&&"text-warning",l=R==="success"&&"text-live";let f;t[5]!==b||t[6]!==p||t[7]!==l?(f=C("text-xl font-semibold tracking-tight tabular-nums sm:text-2xl",b,p,l),t[5]=b,t[6]=p,t[7]=l,t[8]=f):f=t[8];let y;t[9]!==i||t[10]!==s?(y=i?h.jsx(W,{...i}):s,t[9]=i,t[10]=s,t[11]=y):y=t[11];let S;t[12]!==f||t[13]!==y?(S=h.jsx("div",{className:f,children:y}),t[12]=f,t[13]=y,t[14]=S):S=t[14];let v;t[15]!==g||t[16]!==e?(v=g&&h.jsx(K,{...g,caption:e}),t[15]=g,t[16]=e,t[17]=v):v=t[17];let j;t[18]!==S||t[19]!==v?(j=h.jsxs("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[S,v]}),t[18]=S,t[19]=v,t[20]=j):j=t[20];let L;t[21]!==d?(L=d&&h.jsx("div",{className:"text-muted-foreground truncate font-mono text-[11px]",children:d}),t[21]=d,t[22]=L):L=t[22];let _;return t[23]!==j||t[24]!==L||t[25]!==n||t[26]!==x?(_=h.jsxs("div",{className:n,children:[x,j,L]}),t[23]=j,t[24]=L,t[25]=n,t[26]=x,t[27]=_):_=t[27],_}function st(o){const t=k.c(5),{children:u,className:s}=o;let i;t[0]!==s?(i=C("bg-card divide-border grid grid-cols-2 divide-y overflow-hidden rounded-lg border sm:divide-x sm:divide-y-0","[&>*:nth-child(odd)]:border-r sm:[&>*:nth-child(odd)]:border-r-0","[&>*:nth-child(odd):last-child]:col-span-2 [&>*:nth-child(odd):last-child]:border-r-0 sm:[&>*:nth-child(odd):last-child]:col-span-1","sm:auto-cols-fr sm:grid-flow-col",s),t[0]=s,t[1]=i):i=t[1];let d;return t[2]!==u||t[3]!==i?(d=h.jsx("div",{className:i,children:u}),t[2]=u,t[3]=i,t[4]=d):d=t[4],d}export{nt as S,st as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as u,o as d,j as m}from"./inertia-
|
|
1
|
+
import{c as u,o as d,j as m}from"./inertia-DfNRARuA.js";import{B as g}from"./app-layout-by7G3sa1.js";import{s as x}from"./format-B9SDkrWj.js";const f={success:"border-live/30 bg-live/10 text-live",warning:"border-warning/40 bg-warning/10 text-warning",destructive:"border-danger/40 bg-danger/10 text-danger",muted:"border-border bg-muted text-muted-foreground"},v="rounded-sm px-1.5 font-mono text-[10px] tracking-wider uppercase";function j(c){const t=u.c(5),{status:e,outcome:i,label:o}=c,n=x(e,i),s=f[n];let r;t[0]!==s?(r=d(v,"tabular-nums",s),t[0]=s,t[1]=r):r=t[1];const a=o??i??e??"–";let l;return t[2]!==r||t[3]!==a?(l=m.jsx(g,{variant:"outline",className:r,children:a}),t[2]=r,t[3]=a,t[4]=l):l=t[4],l}function B(c){const t=u.c(5),{level:e}=c,o=f[e==="error"||e==="fatal"?"destructive":e==="warn"?"warning":e==="event"?"success":"muted"];let n;t[0]!==o?(n=d(v,o),t[0]=o,t[1]=n):n=t[1];let s;return t[2]!==e||t[3]!==n?(s=m.jsx(g,{variant:"outline",className:n,children:e}),t[2]=e,t[3]=n,t[4]=s):s=t[4],s}function N(c){const t=u.c(5),{status:e}=c,o=f[e==="open"?"destructive":e==="resolved"?"success":"muted"];let n;t[0]!==o?(n=d(v,o),t[0]=o,t[1]=n):n=t[1];let s;return t[2]!==e||t[3]!==n?(s=m.jsx(g,{variant:"outline",className:n,children:e}),t[2]=e,t[3]=n,t[4]=s):s=t[4],s}function h(c){const t=u.c(6),{children:e,tone:i,className:o}=c,s=f[i===void 0?"muted":i];let r;t[0]!==o||t[1]!==s?(r=d(v,s,o),t[0]=o,t[1]=s,t[2]=r):r=t[2];let a;return t[3]!==e||t[4]!==r?(a=m.jsx(g,{variant:"outline",className:r,children:e}),t[3]=e,t[4]=r,t[5]=a):a=t[5],a}export{N as I,h as K,B as L,j as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{am as p}from"./inertia-
|
|
1
|
+
import{am as p}from"./inertia-DfNRARuA.js";function s(n,a,r,e){const o=String(p(n,a,r,e)),[i,t]=o.split("?");return`${i.replace(/\./g,"%2E")}${t?`?${t}`:""}`}export{s as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{x as i,c as l,r as p}from"./inertia-
|
|
1
|
+
import{x as i,c as l,r as p}from"./inertia-DfNRARuA.js";const u=[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],f=i("copy",u);function x(){const e=l.c(3),[o,c]=p.useState(null);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=async a=>{if(!navigator?.clipboard)return console.warn("Clipboard not supported"),!1;try{return await navigator.clipboard.writeText(a),c(a),!0}catch(s){return console.warn("Copy failed",s),c(null),!1}},e[0]=t):t=e[0];const n=t;let r;return e[1]!==o?(r=[o,n],e[1]=o,e[2]=r):r=e[2],r}export{f as C,x as u};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,c as rt,d as L}from"./inertia-b7M33AzA.js";var T={logger:typeof console<"u"?console:void 0,WebSocket:typeof WebSocket<"u"?WebSocket:void 0},i={log(...n){this.enabled&&(n.push(Date.now()),T.logger.log("[ActionCable]",...n))}};const g=()=>new Date().getTime(),C=n=>(g()-n)/1e3;class N{constructor(t){this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=t,this.reconnectAttempts=0}start(){this.isRunning()||(this.startedAt=g(),delete this.stoppedAt,this.startPolling(),addEventListener("visibilitychange",this.visibilityDidChange),i.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`))}stop(){this.isRunning()&&(this.stoppedAt=g(),this.stopPolling(),removeEventListener("visibilitychange",this.visibilityDidChange),i.log("ConnectionMonitor stopped"))}isRunning(){return this.startedAt&&!this.stoppedAt}recordMessage(){this.pingedAt=g()}recordConnect(){this.reconnectAttempts=0,delete this.disconnectedAt,i.log("ConnectionMonitor recorded connect")}recordDisconnect(){this.disconnectedAt=g(),i.log("ConnectionMonitor recorded disconnect")}startPolling(){this.stopPolling(),this.poll()}stopPolling(){clearTimeout(this.pollTimeout)}poll(){this.pollTimeout=setTimeout((()=>{this.reconnectIfStale(),this.poll()}),this.getPollInterval())}getPollInterval(){const{staleThreshold:t,reconnectionBackoffRate:e}=this.constructor,s=Math.pow(1+e,Math.min(this.reconnectAttempts,10)),r=(this.reconnectAttempts===0?1:e)*Math.random();return t*1e3*s*(1+r)}reconnectIfStale(){this.connectionIsStale()&&(i.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${C(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`),this.reconnectAttempts++,this.disconnectedRecently()?i.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${C(this.disconnectedAt)} s`):(i.log("ConnectionMonitor reopening"),this.connection.reopen()))}get refreshedAt(){return this.pingedAt?this.pingedAt:this.startedAt}connectionIsStale(){return C(this.refreshedAt)>this.constructor.staleThreshold}disconnectedRecently(){return this.disconnectedAt&&C(this.disconnectedAt)<this.constructor.staleThreshold}visibilityDidChange(){document.visibilityState==="visible"&&setTimeout((()=>{(this.connectionIsStale()||!this.connection.isOpen())&&(i.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`),this.connection.reopen())}),200)}}N.staleThreshold=6;N.reconnectionBackoffRate=.15;var z={message_types:{welcome:"welcome",disconnect:"disconnect",ping:"ping",confirmation:"confirm_subscription",rejection:"reject_subscription"},default_mount_path:"/cable",protocols:["actioncable-v1-json","actioncable-unsupported"]};const{message_types:p,protocols:x}=z,ct=x.slice(0,x.length-1),V=[].indexOf;class I{constructor(t){this.open=this.open.bind(this),this.consumer=t,this.subscriptions=this.consumer.subscriptions,this.monitor=new N(this),this.disconnected=!0}send(t){return this.isOpen()?(this.webSocket.send(JSON.stringify(t)),!0):!1}open(){if(this.isActive())return i.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`),!1;{const t=[...x,...this.consumer.subprotocols||[]];return i.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${t}`),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new T.WebSocket(this.consumer.url,t),this.installEventHandlers(),this.monitor.start(),!0}}close({allowReconnect:t}={allowReconnect:!0}){if(t||this.monitor.stop(),this.isOpen())return this.webSocket.close()}reopen(){if(i.log(`Reopening WebSocket, current state is ${this.getState()}`),this.isActive())try{return this.close()}catch(t){i.log("Failed to reopen WebSocket",t)}finally{i.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`),setTimeout(this.open,this.constructor.reopenDelay)}else return this.open()}getProtocol(){if(this.webSocket)return this.webSocket.protocol}isOpen(){return this.isState("open")}isActive(){return this.isState("open","connecting")}triedToReconnect(){return this.monitor.reconnectAttempts>0}isProtocolSupported(){return V.call(ct,this.getProtocol())>=0}isState(...t){return V.call(t,this.getState())>=0}getState(){if(this.webSocket){for(let t in T.WebSocket)if(T.WebSocket[t]===this.webSocket.readyState)return t.toLowerCase()}return null}installEventHandlers(){for(let t in this.events){const e=this.events[t].bind(this);this.webSocket[`on${t}`]=e}}uninstallEventHandlers(){for(let t in this.events)this.webSocket[`on${t}`]=function(){}}}I.reopenDelay=500;I.prototype.events={message(n){if(!this.isProtocolSupported())return;const{identifier:t,message:e,reason:s,reconnect:o,type:r}=JSON.parse(n.data);switch(this.monitor.recordMessage(),r){case p.welcome:return this.triedToReconnect()&&(this.reconnectAttempted=!0),this.monitor.recordConnect(),this.subscriptions.reload();case p.disconnect:return i.log(`Disconnecting. Reason: ${s}`),this.close({allowReconnect:o});case p.ping:return null;case p.confirmation:return this.subscriptions.confirmSubscription(t),this.reconnectAttempted?(this.reconnectAttempted=!1,this.subscriptions.notify(t,"connected",{reconnected:!0})):this.subscriptions.notify(t,"connected",{reconnected:!1});case p.rejection:return this.subscriptions.reject(t);default:return this.subscriptions.notify(t,"received",e)}},open(){if(i.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`),this.disconnected=!1,!this.isProtocolSupported())return i.log("Protocol is unsupported. Stopping monitor and disconnecting."),this.close({allowReconnect:!1})},close(n){if(i.log("WebSocket onclose event"),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll("disconnected",{willAttemptReconnect:this.monitor.isRunning()})},error(){i.log("WebSocket onerror event")}};const lt=function(n,t){if(t!=null)for(let e in t){const s=t[e];n[e]=s}return n};class at{constructor(t,e={},s){this.consumer=t,this.identifier=JSON.stringify(e),lt(this,s)}perform(t,e={}){return e.action=t,this.send(e)}send(t){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(t)})}unsubscribe(){return this.consumer.subscriptions.remove(this)}}class ut{constructor(t){this.subscriptions=t,this.pendingSubscriptions=[]}guarantee(t){this.pendingSubscriptions.indexOf(t)==-1?(i.log(`SubscriptionGuarantor guaranteeing ${t.identifier}`),this.pendingSubscriptions.push(t)):i.log(`SubscriptionGuarantor already guaranteeing ${t.identifier}`),this.startGuaranteeing()}forget(t){i.log(`SubscriptionGuarantor forgetting ${t.identifier}`),this.pendingSubscriptions=this.pendingSubscriptions.filter((e=>e!==t))}startGuaranteeing(){this.stopGuaranteeing(),this.retrySubscribing()}stopGuaranteeing(){clearTimeout(this.retryTimeout)}retrySubscribing(){this.retryTimeout=setTimeout((()=>{this.subscriptions&&typeof this.subscriptions.subscribe=="function"&&this.pendingSubscriptions.map((t=>{i.log(`SubscriptionGuarantor resubscribing ${t.identifier}`),this.subscriptions.subscribe(t)}))}),500)}}class ht{constructor(t){this.consumer=t,this.guarantor=new ut(this),this.subscriptions=[]}create(t,e){const s=t,o=typeof s=="object"?s:{channel:s},r=new at(this.consumer,o,e);return this.add(r)}add(t){return this.subscriptions.push(t),this.consumer.ensureActiveConnection(),this.notify(t,"initialized"),this.subscribe(t),t}remove(t){return this.forget(t),this.findAll(t.identifier).length||this.sendCommand(t,"unsubscribe"),t}reject(t){return this.findAll(t).map((e=>(this.forget(e),this.notify(e,"rejected"),e)))}forget(t){return this.guarantor.forget(t),this.subscriptions=this.subscriptions.filter((e=>e!==t)),t}findAll(t){return this.subscriptions.filter((e=>e.identifier===t))}reload(){return this.subscriptions.map((t=>this.subscribe(t)))}notifyAll(t,...e){return this.subscriptions.map((s=>this.notify(s,t,...e)))}notify(t,e,...s){let o;return typeof t=="string"?o=this.findAll(t):o=[t],o.map((r=>typeof r[e]=="function"?r[e](...s):void 0))}subscribe(t){this.sendCommand(t,"subscribe")&&this.guarantor.guarantee(t)}confirmSubscription(t){i.log(`Subscription confirmed ${t}`),this.findAll(t).map((e=>this.guarantor.forget(e)))}sendCommand(t,e){const{identifier:s}=t;return this.consumer.send({command:e,identifier:s})}}class dt{constructor(t){this._url=t,this.subscriptions=new ht(this),this.connection=new I(this),this.subprotocols=[]}get url(){return ft(this._url)}send(t){return this.connection.send(t)}connect(){return this.connection.open()}disconnect(){return this.connection.close({allowReconnect:!1})}ensureActiveConnection(){if(!this.connection.isActive())return this.connection.open()}addSubProtocol(t){this.subprotocols=[...this.subprotocols,t]}}function ft(n){if(typeof n=="function"&&(n=n()),n&&!/^wss?:/i.test(n)){const t=document.createElement("a");return t.href=n,t.href=t.href,t.protocol=t.protocol.replace("http","ws"),t.href}else return n}function pt(n=gt("url")||z.default_mount_path){return new dt(n)}function gt(n){const t=document.head.querySelector(`meta[name='action-cable-${n}']`);if(t)return t.getAttribute("content")}let q;function mt(){return q??=pt(),q}const bt=5e3,K="railwatch:live-paused";let j=!1;const G=new Set;function Y(n){if(j!==n){j=n;for(const t of G)t()}}function St(n){return G.add(n),()=>{G.delete(n)}}function Tt(){return c.useSyncExternalStore(St,vt,yt)}function yt(){return!1}function vt(){return j}function Et(n,t){const e=rt.c(19);let s;e[0]!==t?(s={},e[0]=t,e[1]=s):s=e[1];const{only:o,onEvent:r}=s,[h,E]=c.useState(!1),[_,H]=c.useState(null),[$,F]=c.useState(null),[Q,X]=c.useState(n);Q!==n&&(X(n),E(!1),H(null),F(null));const[l,Z]=c.useState(kt),J=c.useRef(o),B=c.useRef(r),P=c.useRef(l);let m;e[2]!==r||e[3]!==o||e[4]!==l?(m=()=>{J.current=o,B.current=r,P.current=l},e[2]=r,e[3]=o,e[4]=l,e[5]=m):m=e[5],c.useEffect(m);const D=c.useRef(Rt);let b,S;e[6]!==h||e[7]!==l?(b=()=>(Y(h&&!l),wt),S=[h,l],e[6]=h,e[7]=l,e[8]=b,e[9]=S):(b=e[8],S=e[9]),c.useEffect(b,S);let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=function(u){P.current=u,localStorage.setItem(K,u?"1":"0"),Z(u),D.current()},e[10]=y):y=e[10];const tt=y;let v,A;e[11]!==n?(v=()=>{let d=!1,u=!1,M=!1,O=!1,W=-1/0,R,k;const et=function(){u=!1,M=!0,W=Date.now(),L.reload({only:J.current,onCancelToken:ot=>{k=()=>ot.cancel()},onSuccess:()=>{d||F(Date.now())},onFinish:()=>{k=void 0,M=!1,f()}})};function f(){if(clearTimeout(R),R=void 0,d||!u||M||O||P.current||document.visibilityState!=="visible")return;const a=bt-(Date.now()-W);a>0?R=setTimeout(f,a):et()}const U=function(){f()},nt=L.on("start",a=>{a.detail.visit.async||(O=!0,u=!1,W=Date.now(),k?.())}),it=L.on("finish",a=>{a.detail.visit.async||(O=!1,f())});document.addEventListener("visibilitychange",U),D.current=f;const st=mt().subscriptions.create({channel:"EnvironmentChannel",id:n},{connected:()=>{d||E(!0)},disconnected:()=>{d||E(!1)},received:a=>{d||(H(Date.now()),B.current?.(a),u=!0,f())}});return()=>{d=!0,k?.(),clearTimeout(R),nt(),it(),D.current=At,document.removeEventListener("visibilitychange",U),st.unsubscribe()}},A=[n],e[11]=n,e[12]=v,e[13]=A):(v=e[12],A=e[13]),c.useEffect(v,A);let w;return e[14]!==h||e[15]!==_||e[16]!==$||e[17]!==l?(w={connected:h,lastEventAt:_,lastRefreshedAt:$,paused:l,setPaused:tt},e[14]=h,e[15]=_,e[16]=$,e[17]=l,e[18]=w):w=e[18],w}function At(){}function wt(){return Y(!1)}function Rt(){}function kt(){return typeof window>"u"?!1:localStorage.getItem(K)==="1"}export{Tt as a,Et as u};
|
|
1
|
+
import{r as c,c as rt,d as L}from"./inertia-DfNRARuA.js";var T={logger:typeof console<"u"?console:void 0,WebSocket:typeof WebSocket<"u"?WebSocket:void 0},i={log(...n){this.enabled&&(n.push(Date.now()),T.logger.log("[ActionCable]",...n))}};const g=()=>new Date().getTime(),C=n=>(g()-n)/1e3;class N{constructor(t){this.visibilityDidChange=this.visibilityDidChange.bind(this),this.connection=t,this.reconnectAttempts=0}start(){this.isRunning()||(this.startedAt=g(),delete this.stoppedAt,this.startPolling(),addEventListener("visibilitychange",this.visibilityDidChange),i.log(`ConnectionMonitor started. stale threshold = ${this.constructor.staleThreshold} s`))}stop(){this.isRunning()&&(this.stoppedAt=g(),this.stopPolling(),removeEventListener("visibilitychange",this.visibilityDidChange),i.log("ConnectionMonitor stopped"))}isRunning(){return this.startedAt&&!this.stoppedAt}recordMessage(){this.pingedAt=g()}recordConnect(){this.reconnectAttempts=0,delete this.disconnectedAt,i.log("ConnectionMonitor recorded connect")}recordDisconnect(){this.disconnectedAt=g(),i.log("ConnectionMonitor recorded disconnect")}startPolling(){this.stopPolling(),this.poll()}stopPolling(){clearTimeout(this.pollTimeout)}poll(){this.pollTimeout=setTimeout((()=>{this.reconnectIfStale(),this.poll()}),this.getPollInterval())}getPollInterval(){const{staleThreshold:t,reconnectionBackoffRate:e}=this.constructor,s=Math.pow(1+e,Math.min(this.reconnectAttempts,10)),r=(this.reconnectAttempts===0?1:e)*Math.random();return t*1e3*s*(1+r)}reconnectIfStale(){this.connectionIsStale()&&(i.log(`ConnectionMonitor detected stale connection. reconnectAttempts = ${this.reconnectAttempts}, time stale = ${C(this.refreshedAt)} s, stale threshold = ${this.constructor.staleThreshold} s`),this.reconnectAttempts++,this.disconnectedRecently()?i.log(`ConnectionMonitor skipping reopening recent disconnect. time disconnected = ${C(this.disconnectedAt)} s`):(i.log("ConnectionMonitor reopening"),this.connection.reopen()))}get refreshedAt(){return this.pingedAt?this.pingedAt:this.startedAt}connectionIsStale(){return C(this.refreshedAt)>this.constructor.staleThreshold}disconnectedRecently(){return this.disconnectedAt&&C(this.disconnectedAt)<this.constructor.staleThreshold}visibilityDidChange(){document.visibilityState==="visible"&&setTimeout((()=>{(this.connectionIsStale()||!this.connection.isOpen())&&(i.log(`ConnectionMonitor reopening stale connection on visibilitychange. visibilityState = ${document.visibilityState}`),this.connection.reopen())}),200)}}N.staleThreshold=6;N.reconnectionBackoffRate=.15;var z={message_types:{welcome:"welcome",disconnect:"disconnect",ping:"ping",confirmation:"confirm_subscription",rejection:"reject_subscription"},default_mount_path:"/cable",protocols:["actioncable-v1-json","actioncable-unsupported"]};const{message_types:p,protocols:x}=z,ct=x.slice(0,x.length-1),V=[].indexOf;class I{constructor(t){this.open=this.open.bind(this),this.consumer=t,this.subscriptions=this.consumer.subscriptions,this.monitor=new N(this),this.disconnected=!0}send(t){return this.isOpen()?(this.webSocket.send(JSON.stringify(t)),!0):!1}open(){if(this.isActive())return i.log(`Attempted to open WebSocket, but existing socket is ${this.getState()}`),!1;{const t=[...x,...this.consumer.subprotocols||[]];return i.log(`Opening WebSocket, current state is ${this.getState()}, subprotocols: ${t}`),this.webSocket&&this.uninstallEventHandlers(),this.webSocket=new T.WebSocket(this.consumer.url,t),this.installEventHandlers(),this.monitor.start(),!0}}close({allowReconnect:t}={allowReconnect:!0}){if(t||this.monitor.stop(),this.isOpen())return this.webSocket.close()}reopen(){if(i.log(`Reopening WebSocket, current state is ${this.getState()}`),this.isActive())try{return this.close()}catch(t){i.log("Failed to reopen WebSocket",t)}finally{i.log(`Reopening WebSocket in ${this.constructor.reopenDelay}ms`),setTimeout(this.open,this.constructor.reopenDelay)}else return this.open()}getProtocol(){if(this.webSocket)return this.webSocket.protocol}isOpen(){return this.isState("open")}isActive(){return this.isState("open","connecting")}triedToReconnect(){return this.monitor.reconnectAttempts>0}isProtocolSupported(){return V.call(ct,this.getProtocol())>=0}isState(...t){return V.call(t,this.getState())>=0}getState(){if(this.webSocket){for(let t in T.WebSocket)if(T.WebSocket[t]===this.webSocket.readyState)return t.toLowerCase()}return null}installEventHandlers(){for(let t in this.events){const e=this.events[t].bind(this);this.webSocket[`on${t}`]=e}}uninstallEventHandlers(){for(let t in this.events)this.webSocket[`on${t}`]=function(){}}}I.reopenDelay=500;I.prototype.events={message(n){if(!this.isProtocolSupported())return;const{identifier:t,message:e,reason:s,reconnect:o,type:r}=JSON.parse(n.data);switch(this.monitor.recordMessage(),r){case p.welcome:return this.triedToReconnect()&&(this.reconnectAttempted=!0),this.monitor.recordConnect(),this.subscriptions.reload();case p.disconnect:return i.log(`Disconnecting. Reason: ${s}`),this.close({allowReconnect:o});case p.ping:return null;case p.confirmation:return this.subscriptions.confirmSubscription(t),this.reconnectAttempted?(this.reconnectAttempted=!1,this.subscriptions.notify(t,"connected",{reconnected:!0})):this.subscriptions.notify(t,"connected",{reconnected:!1});case p.rejection:return this.subscriptions.reject(t);default:return this.subscriptions.notify(t,"received",e)}},open(){if(i.log(`WebSocket onopen event, using '${this.getProtocol()}' subprotocol`),this.disconnected=!1,!this.isProtocolSupported())return i.log("Protocol is unsupported. Stopping monitor and disconnecting."),this.close({allowReconnect:!1})},close(n){if(i.log("WebSocket onclose event"),!this.disconnected)return this.disconnected=!0,this.monitor.recordDisconnect(),this.subscriptions.notifyAll("disconnected",{willAttemptReconnect:this.monitor.isRunning()})},error(){i.log("WebSocket onerror event")}};const lt=function(n,t){if(t!=null)for(let e in t){const s=t[e];n[e]=s}return n};class at{constructor(t,e={},s){this.consumer=t,this.identifier=JSON.stringify(e),lt(this,s)}perform(t,e={}){return e.action=t,this.send(e)}send(t){return this.consumer.send({command:"message",identifier:this.identifier,data:JSON.stringify(t)})}unsubscribe(){return this.consumer.subscriptions.remove(this)}}class ut{constructor(t){this.subscriptions=t,this.pendingSubscriptions=[]}guarantee(t){this.pendingSubscriptions.indexOf(t)==-1?(i.log(`SubscriptionGuarantor guaranteeing ${t.identifier}`),this.pendingSubscriptions.push(t)):i.log(`SubscriptionGuarantor already guaranteeing ${t.identifier}`),this.startGuaranteeing()}forget(t){i.log(`SubscriptionGuarantor forgetting ${t.identifier}`),this.pendingSubscriptions=this.pendingSubscriptions.filter((e=>e!==t))}startGuaranteeing(){this.stopGuaranteeing(),this.retrySubscribing()}stopGuaranteeing(){clearTimeout(this.retryTimeout)}retrySubscribing(){this.retryTimeout=setTimeout((()=>{this.subscriptions&&typeof this.subscriptions.subscribe=="function"&&this.pendingSubscriptions.map((t=>{i.log(`SubscriptionGuarantor resubscribing ${t.identifier}`),this.subscriptions.subscribe(t)}))}),500)}}class ht{constructor(t){this.consumer=t,this.guarantor=new ut(this),this.subscriptions=[]}create(t,e){const s=t,o=typeof s=="object"?s:{channel:s},r=new at(this.consumer,o,e);return this.add(r)}add(t){return this.subscriptions.push(t),this.consumer.ensureActiveConnection(),this.notify(t,"initialized"),this.subscribe(t),t}remove(t){return this.forget(t),this.findAll(t.identifier).length||this.sendCommand(t,"unsubscribe"),t}reject(t){return this.findAll(t).map((e=>(this.forget(e),this.notify(e,"rejected"),e)))}forget(t){return this.guarantor.forget(t),this.subscriptions=this.subscriptions.filter((e=>e!==t)),t}findAll(t){return this.subscriptions.filter((e=>e.identifier===t))}reload(){return this.subscriptions.map((t=>this.subscribe(t)))}notifyAll(t,...e){return this.subscriptions.map((s=>this.notify(s,t,...e)))}notify(t,e,...s){let o;return typeof t=="string"?o=this.findAll(t):o=[t],o.map((r=>typeof r[e]=="function"?r[e](...s):void 0))}subscribe(t){this.sendCommand(t,"subscribe")&&this.guarantor.guarantee(t)}confirmSubscription(t){i.log(`Subscription confirmed ${t}`),this.findAll(t).map((e=>this.guarantor.forget(e)))}sendCommand(t,e){const{identifier:s}=t;return this.consumer.send({command:e,identifier:s})}}class dt{constructor(t){this._url=t,this.subscriptions=new ht(this),this.connection=new I(this),this.subprotocols=[]}get url(){return ft(this._url)}send(t){return this.connection.send(t)}connect(){return this.connection.open()}disconnect(){return this.connection.close({allowReconnect:!1})}ensureActiveConnection(){if(!this.connection.isActive())return this.connection.open()}addSubProtocol(t){this.subprotocols=[...this.subprotocols,t]}}function ft(n){if(typeof n=="function"&&(n=n()),n&&!/^wss?:/i.test(n)){const t=document.createElement("a");return t.href=n,t.href=t.href,t.protocol=t.protocol.replace("http","ws"),t.href}else return n}function pt(n=gt("url")||z.default_mount_path){return new dt(n)}function gt(n){const t=document.head.querySelector(`meta[name='action-cable-${n}']`);if(t)return t.getAttribute("content")}let q;function mt(){return q??=pt(),q}const bt=5e3,K="railwatch:live-paused";let j=!1;const G=new Set;function Y(n){if(j!==n){j=n;for(const t of G)t()}}function St(n){return G.add(n),()=>{G.delete(n)}}function Tt(){return c.useSyncExternalStore(St,vt,yt)}function yt(){return!1}function vt(){return j}function Et(n,t){const e=rt.c(19);let s;e[0]!==t?(s={},e[0]=t,e[1]=s):s=e[1];const{only:o,onEvent:r}=s,[h,E]=c.useState(!1),[_,H]=c.useState(null),[$,F]=c.useState(null),[Q,X]=c.useState(n);Q!==n&&(X(n),E(!1),H(null),F(null));const[l,Z]=c.useState(kt),J=c.useRef(o),B=c.useRef(r),P=c.useRef(l);let m;e[2]!==r||e[3]!==o||e[4]!==l?(m=()=>{J.current=o,B.current=r,P.current=l},e[2]=r,e[3]=o,e[4]=l,e[5]=m):m=e[5],c.useEffect(m);const D=c.useRef(Rt);let b,S;e[6]!==h||e[7]!==l?(b=()=>(Y(h&&!l),wt),S=[h,l],e[6]=h,e[7]=l,e[8]=b,e[9]=S):(b=e[8],S=e[9]),c.useEffect(b,S);let y;e[10]===Symbol.for("react.memo_cache_sentinel")?(y=function(u){P.current=u,localStorage.setItem(K,u?"1":"0"),Z(u),D.current()},e[10]=y):y=e[10];const tt=y;let v,A;e[11]!==n?(v=()=>{let d=!1,u=!1,M=!1,O=!1,W=-1/0,R,k;const et=function(){u=!1,M=!0,W=Date.now(),L.reload({only:J.current,onCancelToken:ot=>{k=()=>ot.cancel()},onSuccess:()=>{d||F(Date.now())},onFinish:()=>{k=void 0,M=!1,f()}})};function f(){if(clearTimeout(R),R=void 0,d||!u||M||O||P.current||document.visibilityState!=="visible")return;const a=bt-(Date.now()-W);a>0?R=setTimeout(f,a):et()}const U=function(){f()},nt=L.on("start",a=>{a.detail.visit.async||(O=!0,u=!1,W=Date.now(),k?.())}),it=L.on("finish",a=>{a.detail.visit.async||(O=!1,f())});document.addEventListener("visibilitychange",U),D.current=f;const st=mt().subscriptions.create({channel:"EnvironmentChannel",id:n},{connected:()=>{d||E(!0)},disconnected:()=>{d||E(!1)},received:a=>{d||(H(Date.now()),B.current?.(a),u=!0,f())}});return()=>{d=!0,k?.(),clearTimeout(R),nt(),it(),D.current=At,document.removeEventListener("visibilitychange",U),st.unsubscribe()}},A=[n],e[11]=n,e[12]=v,e[13]=A):(v=e[12],A=e[13]),c.useEffect(v,A);let w;return e[14]!==h||e[15]!==_||e[16]!==$||e[17]!==l?(w={connected:h,lastEventAt:_,lastRefreshedAt:$,paused:l,setPaused:tt},e[14]=h,e[15]=_,e[16]=$,e[17]=l,e[18]=w):w=e[18],w}function At(){}function wt(){return Y(!1)}function Rt(){}function kt(){return typeof window>"u"?!1:localStorage.getItem(K)==="1"}export{Tt as a,Et as u};
|