import{s as b}from"./chunk-DZLz74EQ.js";import{t as y}from"./react-BcIddLXZ.js";import{n as h}from"./jsx-runtime-DvsdsEjx.js";import{t as E}from"./useEventListener-C5BS4xuN.js";var I=b(h(),1),u=b(y(),1);function S(n,p){let t=(0,I.c)(11),{delayMs:l,whenVisible:e,disabled:v}=p,i=v===void 0?!1:v,r=(0,u.useRef)(void 0),o,s;t[0]===n?(o=t[1],s=t[2]):(o=()=>{r.current=n},s=[n],t[0]=n,t[1]=o,t[2]=s),(0,u.useEffect)(o,s);let a,c;t[3]!==l||t[4]!==i||t[5]!==e?(a=()=>{if(l===null||i)return;let m=setInterval(()=>{var d;e&&document.visibilityState!=="visible"||((d=r.current)==null||d.call(r))},l);return()=>clearInterval(m)},c=[l,e,i],t[3]=l,t[4]=i,t[5]=e,t[6]=a,t[7]=c):(a=t[6],c=t[7]),(0,u.useEffect)(a,c);let f;return t[8]!==i||t[9]!==e?(f=()=>{var m;document.visibilityState==="visible"&&e&&!i&&((m=r.current)==null||m.call(r))},t[8]=i,t[9]=e,t[10]=f):f=t[10],E(document,"visibilitychange",f),null}export{S as t};
