🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →

react-idle-timer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-idle-timer - npm Package Compare versions

Comparing version

to
5.4.1

@@ -1,1 +0,1 @@

var It=Object.create,ie=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty;var Ue=t=>ie(t,"__esModule",{value:!0});var yt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Lt=(t,e)=>{for(var r in e)ie(t,r,{get:e[r],enumerable:!0})},kt=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of bt(e))!wt.call(t,n)&&n!=="default"&&ie(t,n,{get:()=>e[n],enumerable:!(r=Et(e,n))||r.enumerable});return t},$=t=>kt(Ue(ie(t!=null?It(gt(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var Ve=yt((ae,Be)=>{(function(t,e){typeof ae=="object"&&typeof Be!="undefined"?e(ae):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t.fastUniqueNumbers={}))})(ae,function(t){"use strict";var e=function(f){return function(h){var o=f(h);return h.add(o),o}},r=function(f){return function(h,o){return f.set(h,o),o}},n=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,l=536870912,c=l*2,E=function(f,h){return function(o){var k=h.get(o),x=k===void 0?o.size:k<c?k+1:0;if(!o.has(x))return f(o,x);if(o.size<l){for(;o.has(x);)x=Math.floor(Math.random()*c);return f(o,x)}if(o.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;o.has(x);)x=Math.floor(Math.random()*n);return f(o,x)}},F=new WeakMap,ee=r(F),d=E(ee,F),m=e(d);t.addUniqueNumber=m,t.generateUniqueNumber=d,Object.defineProperty(t,"__esModule",{value:!0})})});Ue(exports);Lt(exports,{DEFAULT_EVENTS:()=>ce,IdleTimerConsumer:()=>st,IdleTimerContext:()=>Z,IdleTimerProvider:()=>it,createMocks:()=>Qe,useIdleTimer:()=>G,useIdleTimerContext:()=>at,withIdleTimer:()=>We,workerTimers:()=>Ke});var se=$(require("react"));function We(t){return(0,se.forwardRef)(function(r,n){let l={...r};!l.onPrompt&&t.prototype.onPrompt&&(l.onPrompt=()=>{t.prototype.onPrompt()}),!l.onIdle&&t.prototype.onIdle&&(l.onIdle=()=>{t.prototype.onIdle()}),!l.onActive&&t.prototype.onActive&&(l.onActive=E=>{t.prototype.onActive(E)}),!l.onAction&&t.prototype.onAction&&(l.onAction=E=>{t.prototype.onAction(E)});let c=G(l);return typeof n=="function"?n(c):n&&(n.current=c),se.default.createElement(t,{...r,...c})})}var i=$(require("react"));var K=$(Ve());var He=t=>t.method!==void 0&&t.method==="call";var Ge=t=>t.error===null&&typeof t.id=="number";var qe=t=>{let e=new Map([[0,()=>{}]]),r=new Map([[0,()=>{}]]),n=new Map,l=new Worker(t);return l.addEventListener("message",({data:d})=>{if(He(d)){let{params:{timerId:m,timerType:p}}=d;if(p==="interval"){let f=e.get(m);if(typeof f=="number"){let h=n.get(f);if(h===void 0||h.timerId!==m||h.timerType!==p)throw new Error("The timer is in an undefined state.")}else if(typeof f!="undefined")f();else throw new Error("The timer is in an undefined state.")}else if(p==="timeout"){let f=r.get(m);if(typeof f=="number"){let h=n.get(f);if(h===void 0||h.timerId!==m||h.timerType!==p)throw new Error("The timer is in an undefined state.")}else if(typeof f!="undefined")f(),r.delete(m);else throw new Error("The timer is in an undefined state.")}}else if(Ge(d)){let{id:m}=d,p=n.get(m);if(p===void 0)throw new Error("The timer is in an undefined state.");let{timerId:f,timerType:h}=p;n.delete(m),h==="interval"?e.delete(f):r.delete(f)}else{let{error:{message:m}}=d;throw new Error(m)}}),{clearInterval:d=>{let m=(0,K.generateUniqueNumber)(n);n.set(m,{timerId:d,timerType:"interval"}),e.set(d,m),l.postMessage({id:m,method:"clear",params:{timerId:d,timerType:"interval"}})},clearTimeout:d=>{let m=(0,K.generateUniqueNumber)(n);n.set(m,{timerId:d,timerType:"timeout"}),r.set(d,m),l.postMessage({id:m,method:"clear",params:{timerId:d,timerType:"timeout"}})},setInterval:(d,m)=>{let p=(0,K.generateUniqueNumber)(e);return e.set(p,()=>{d(),typeof e.get(p)=="function"&&l.postMessage({id:null,method:"set",params:{delay:m,now:performance.now(),timerId:p,timerType:"interval"}})}),l.postMessage({id:null,method:"set",params:{delay:m,now:performance.now(),timerId:p,timerType:"interval"}}),p},setTimeout:(d,m)=>{let p=(0,K.generateUniqueNumber)(r);return r.set(p,d),l.postMessage({id:null,method:"set",params:{delay:m,now:performance.now(),timerId:p,timerType:"timeout"}}),p}}};var Q=null,je=(t,e)=>()=>{if(Q!==null)return Q;let r=new Blob([e],{type:"application/javascript; charset=utf-8"}),n=URL.createObjectURL(r);return Q=t(n),Q.setTimeout(()=>URL.revokeObjectURL(n),0),Q};var Ye=`(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id "'.concat(t,'".'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error('The given type "'.concat(i,'" is not supported'));(e=>{const r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error('The given method "'.concat(s.method,'" is not supported'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error('The given type "'.concat(d,'" is not supported'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();`;var le=je(qe,Ye),Je=t=>le().clearInterval(t),ze=t=>le().clearTimeout(t),Xe=(t,e)=>le().setInterval(t,e),$e=(t,e)=>le().setTimeout(t,e);var g=(typeof window=="undefined"?"undefined":typeof window)=="object";var T={setTimeout:g?setTimeout.bind(window):setTimeout,clearTimeout:g?clearTimeout.bind(window):clearTimeout,setInterval:g?setInterval.bind(window):setInterval,clearInterval:g?clearInterval.bind(window):clearInterval},Ke={setTimeout:$e,clearTimeout:ze,setInterval:Xe,clearInterval:Je};function Qe(){T.setTimeout=setTimeout,T.clearTimeout=clearTimeout,T.setInterval=setInterval,T.clearInterval=clearInterval}function Ze(t){T.setTimeout=t.setTimeout,T.clearTimeout=t.clearTimeout,T.setInterval=t.setInterval,T.clearInterval=t.clearInterval}var q={},et=class{constructor(e){this.closed=!1;this.mc=new MessageChannel;this.name=e,q[e]=q[e]||[],q[e].push(this),this.mc.port1.start(),this.mc.port2.start(),this.onStorage=this.onStorage.bind(this),window.addEventListener("storage",this.onStorage)}onStorage(e){if(e.storageArea!==window.localStorage||e.key.substring(0,this.name.length)!==this.name||e.newValue===null)return;let r=JSON.parse(e.newValue);this.mc.port2.postMessage(r)}postMessage(e){if(this.closed)throw new Error("InvalidStateError");let r=JSON.stringify(e),n=`${this.name}:${String(Date.now())}${String(Math.random())}`;window.localStorage.setItem(n,r),T.setTimeout(()=>{window.localStorage.removeItem(n)},500),q[this.name].forEach(l=>{l!==this&&l.mc.port2.postMessage(JSON.parse(r))})}close(){if(this.closed)return;this.closed=!0,this.mc.port1.close(),this.mc.port2.close(),window.removeEventListener("storage",this.onStorage);let e=q[this.name].indexOf(this);q[this.name].splice(e,1)}get onmessage(){return this.mc.port1.onmessage}set onmessage(e){this.mc.port1.onmessage=e}get onmessageerror(){return this.mc.port1.onmessageerror}set onmessageerror(e){this.mc.port1.onmessageerror=e}addEventListener(e,r){return this.mc.port1.addEventListener(e,r)}removeEventListener(e,r){return this.mc.port1.removeEventListener(e,r)}dispatchEvent(e){return this.mc.port1.dispatchEvent(e)}},tt=typeof window=="undefined"?void 0:typeof window.BroadcastChannel=="function"?window.BroadcastChannel:et;function rt(t=0){return new Promise(e=>T.setTimeout(e,t))}function ue(){return Math.random().toString(36).substring(2)}var u;(function(o){o[o.APPLY=0]="APPLY",o[o.TELL=1]="TELL",o[o.CLOSE=2]="CLOSE",o[o.REGISTER=3]="REGISTER",o[o.DEREGISTER=4]="DEREGISTER",o[o.IDLE=5]="IDLE",o[o.ACTIVE=6]="ACTIVE",o[o.PROMPT=7]="PROMPT",o[o.START=8]="START",o[o.RESET=9]="RESET",o[o.ACTIVATE=10]="ACTIVATE",o[o.PAUSE=11]="PAUSE",o[o.RESUME=12]="RESUME",o[o.MESSAGE=13]="MESSAGE"})(u||(u={}));var ge=class{constructor(e,r){this.token=ue();this.isLeader=!1;this.isDead=!1;this.isApplying=!1;this.reApply=!1;this.intervals=[];this.listeners=[];this.channel=e,this.options=r,this.apply=this.apply.bind(this),this.awaitLeadership=this.awaitLeadership.bind(this),this.sendAction=this.sendAction.bind(this)}async apply(){if(this.isLeader||this.isDead)return!1;if(this.isApplying)return this.reApply=!0,!1;this.isApplying=!0;let e=!1,r=n=>{let{token:l,action:c}=n.data;l!==this.token&&(c===u.APPLY&&l>this.token&&(e=!0),c===u.TELL&&(e=!0))};this.channel.addEventListener("message",r);try{return this.sendAction(u.APPLY),await rt(this.options.responseTime),this.channel.removeEventListener("message",r),this.isApplying=!1,e?this.reApply?this.apply():!1:(this.assumeLead(),!0)}catch{return!1}}awaitLeadership(){if(this.isLeader)return Promise.resolve();let e=!1,r=null;return new Promise(n=>{let l=()=>{if(e)return;e=!0,T.clearInterval(r);let E=this.intervals.indexOf(r);this.intervals.splice(E,1),this.channel.removeEventListener("message",c),n()};r=T.setInterval(()=>{this.apply().then(()=>{this.isLeader&&l()})},this.options.fallbackInterval),this.intervals.push(r);let c=E=>{let{action:F}=E.data;F===u.CLOSE&&this.apply().then(()=>{this.isLeader&&l()})};this.channel.addEventListener("message",c)})}sendAction(e){this.channel.postMessage({action:e,token:this.token})}assumeLead(){this.isLeader=!0;let e=r=>{let{action:n}=r.data;n===u.APPLY&&this.sendAction(u.TELL)};return this.channel.addEventListener("message",e),this.listeners.push(e),this.sendAction(u.TELL)}waitForLeadership(){return this.deferred?this.deferred:(this.deferred=this.awaitLeadership(),this.deferred)}close(){this.isDead||(this.isDead=!0,this.isLeader=!1,this.sendAction(u.CLOSE),this.listeners.forEach(e=>this.channel.removeEventListener("message",e)),this.intervals.forEach(e=>T.clearInterval(e)))}};var L;(function(n){n[n.PROMPTED=0]="PROMPTED",n[n.ACTIVE=1]="ACTIVE",n[n.IDLE=2]="IDLE"})(L||(L={}));var we=class{constructor(e){this.token=ue();this.registry=new Map;this.allIdle=!1;let{channelName:r}=e;if(this.options=e,this.channel=new tt(r),this.registry.set(this.token,1),e.leaderElection){let n={fallbackInterval:2e3,responseTime:100};this.elector=new ge(this.channel,n),this.elector.waitForLeadership()}this.channel.addEventListener("message",n=>{let{action:l,token:c,data:E}=n.data;switch(l){case u.REGISTER:this.registry.set(c,2);break;case u.DEREGISTER:this.registry.delete(c);break;case u.IDLE:this.idle(c);break;case u.ACTIVE:this.active(c);break;case u.PROMPT:this.prompt(c);break;case u.START:this.start(c);break;case u.RESET:this.reset(c);break;case u.ACTIVATE:this.activate(c);break;case u.PAUSE:this.pause(c);break;case u.RESUME:this.resume(c);break;case u.MESSAGE:this.options.onMessage(E);break}}),this.send(u.REGISTER)}get isLeader(){if(!this.elector)throw new Error('\u274C Leader election is not enabled. To Enable it set the "leaderElection" property to true.');return this.elector.isLeader}prompt(e=this.token){this.registry.set(e,0);let r=[...this.registry.values()].every(n=>n===0);e===this.token&&this.send(u.PROMPT),r&&this.options.onPrompt()}idle(e=this.token){this.registry.set(e,2);let r=[...this.registry.values()].every(n=>n===2);e===this.token&&this.send(u.IDLE),!this.allIdle&&r&&(this.allIdle=!0,this.options.onIdle())}active(e=this.token){this.allIdle=!1,this.registry.set(e,1);let r=[...this.registry.values()].some(n=>n===1);e===this.token&&this.send(u.ACTIVE),r&&this.options.onActive()}start(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(u.START):this.options.start(!0)}reset(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(u.RESET):this.options.reset(!0)}activate(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(u.ACTIVATE):this.options.activate(!0)}pause(e=this.token){e===this.token?this.send(u.PAUSE):this.options.pause(!0)}resume(e=this.token){e===this.token?this.send(u.RESUME):this.options.resume(!0)}message(e){try{this.channel.postMessage({action:u.MESSAGE,token:this.token,data:e})}catch{}}send(e){try{this.channel.postMessage({action:e,token:this.token})}catch{}}close(){this.options.leaderElection&&this.elector.close(),this.send(u.DEREGISTER),this.channel.close()}};var nt=g?document:null,ce=["mousemove","keydown","wheel","DOMMouseScroll","mousewheel","mousedown","touchstart","touchmove","MSPointerDown","MSPointerMove","visibilitychange"];var me=$(require("react"));function _(t){let e=(0,me.useRef)(t);return(0,me.useEffect)(()=>{e.current=t},[t]),e}function ot(t,e){let r;function n(...l){r&&clearTimeout(r),r=setTimeout(()=>{t(...l),r=null},e)}return n.cancel=function(){clearTimeout(r)},n}function de(t,e){let r=0;return function(...n){let l=new Date().getTime();if(!(l-r<e))return r=l,t(...n)}}var I=()=>g?performance.now():Date.now();function G({timeout:t=1e3*60*20,promptTimeout:e=0,element:r=nt,events:n=ce,timers:l=void 0,immediateEvents:c=[],onPrompt:E=()=>{},onIdle:F=()=>{},onActive:ee=()=>{},onAction:d=()=>{},onMessage:m=()=>{},debounce:p=0,throttle:f=0,eventsThrottle:h=200,startOnMount:o=!0,startManually:k=!1,stopOnIdle:x=!1,crossTab:V=!1,name:ye="idle-timer",syncTimers:Y=0,leaderElection:Le=!1}={}){let J=(0,i.useRef)(I()),ke=(0,i.useRef)(Date.now()),te=(0,i.useRef)(I()),C=(0,i.useRef)(null),D=(0,i.useRef)(null),z=(0,i.useRef)(0),v=(0,i.useRef)(!0),S=(0,i.useRef)(!1),U=(0,i.useRef)(!0),X=(0,i.useRef)(!1),b=(0,i.useRef)(!1),w=(0,i.useRef)(0),A=(0,i.useRef)(0),R=(0,i.useRef)(null),a=(0,i.useRef)(null),O=_(t),re=_(e),lt=_(x),xe=(0,i.useRef)(c),pe=(0,i.useRef)(r),fe=(0,i.useRef)([...new Set([...n,...c]).values()]),Me=_(F),he=_(ee),Pe=_(E),ne=_(m),y=(0,i.useRef)();(0,i.useEffect)(()=>{y.current&&y.current.cancel&&y.current.cancel(),p>0?y.current=ot(d,p):f>0?y.current=de(d,f):y.current=d},[d,f,p]);let Se=(0,i.useRef)();(0,i.useEffect)(()=>{V&&Y&&(Se.current=de(()=>{a.current.active()},Y))},[V,Y]);let M=()=>{R.current!==null&&(T.clearTimeout(R.current),R.current=null)},W=(s,P=!0)=>{M(),R.current=T.setTimeout(Te,s||O.current),P&&(D.current=I())},Ae=s=>{w.current=0,A.current=I(),b.current=!0,W(re.current,!1),Pe.current(s)},Re=()=>{M(),v.current=!0,C.current=I(),lt.current?B():b.current&&(A.current=0,b.current=!1),Me.current()},ve=s=>{M(),b.current=!1,A.current=0,v.current=!1,z.current+=I()-C.current,N(),W(),he.current(s)},Te=s=>{if(!v.current){if(y.current.cancel&&y.current.cancel(),re.current>0&&!b.current){a.current?a.current.prompt():Ae(s);return}a.current?a.current.idle():Re();return}a.current?a.current.active():ve(s)},Oe=s=>{if(y.current(s),b.current)return;if(M(),!v.current&&xe.current.includes(s.type)){Te(s);return}let P=I()-D.current;if(v.current&&!x||!v.current&&P>O.current){Te(s);return}S.current=!1,w.current=0,A.current=0,W(),V&&Y&&Se.current()},oe=(0,i.useRef)();(0,i.useEffect)(()=>{let s=X.current;s&&B(),h>0?oe.current=de(Oe,h):oe.current=Oe,s&&N()},[h,V,Y]);let N=()=>{!g||X.current||(fe.current.forEach(s=>{pe.current.addEventListener(s,oe.current,{capture:!0,passive:!0})}),X.current=!0)},B=(s=!1)=>{!g||(X.current||s)&&(fe.current.forEach(P=>{pe.current.removeEventListener(P,oe.current,{capture:!0})}),X.current=!1)},H=(0,i.useCallback)(s=>{M(),N(),v.current=!1,b.current=!1,S.current=!1,w.current=0,A.current=0,a.current&&!s&&a.current.start(),W()},[R,v,O,a]),Ie=(0,i.useCallback)(s=>{M(),N(),v.current=!1,b.current=!1,S.current=!1,w.current=0,A.current=0,te.current=I(),a.current&&!s&&a.current.reset(),k||W()},[R,v,O,k,a]),Ce=(0,i.useCallback)(s=>{M(),N(),(v.current||b.current)&&ve(),v.current=!1,b.current=!1,S.current=!1,w.current=0,A.current=0,te.current=I(),a.current&&!s&&a.current.activate(),W()},[R,v,O,a]),Ee=(0,i.useCallback)((s=!1)=>S.current?!1:(w.current=De(),S.current=!0,B(),M(),a.current&&!s&&a.current.pause(),!0),[R,a]),be=(0,i.useCallback)((s=!1)=>S.current?(S.current=!1,b.current||N(),v.current||W(w.current),A.current&&(A.current=I()),a.current&&!s&&a.current.resume(),!0):!1,[R,O,w,a]),ut=(0,i.useCallback)((s,P)=>{a.current?(P&&ne.current(s),a.current.message(s)):P&&ne.current(s)},[m]),ct=(0,i.useCallback)(()=>v.current,[v]),mt=(0,i.useCallback)(()=>b.current,[b]),dt=(0,i.useCallback)(()=>{if(!a.current)throw new Error('\u274C Cross Tab feature is not enabled. To enable it set the "crossTab" property to true.');return a.current.isLeader},[a]),pt=(0,i.useCallback)(()=>{if(!a.current)throw new Error('\u274C Cross Tab feature is not enabled. To enable it set the "crossTab" property to true.');return a.current.token},[a]),De=(0,i.useCallback)(()=>{if(S.current)return w.current;let s=w.current?w.current:re.current+O.current,P=D.current?I()-D.current:0,Fe=Math.ceil(s-P);return Fe<0?0:Math.abs(Fe)},[O,re,b,w,D]),ft=(0,i.useCallback)(()=>Math.round(I()-te.current),[te]),Ne=(0,i.useCallback)(()=>Math.round(I()-J.current),[J]),ht=(0,i.useCallback)(()=>C.current?new Date(ke.current-J.current+C.current):null,[C]),vt=(0,i.useCallback)(()=>D.current?new Date(ke.current-J.current+D.current):null,[D]),_e=(0,i.useCallback)(()=>v.current?Math.round(I()-C.current+z.current):Math.round(z.current),[C,z]),Tt=(0,i.useCallback)(()=>{let s=Math.round(Ne()-_e());return s>=0?s:0},[J,C,z]);return(0,i.useEffect)(()=>{if(p>0&&f>0)throw new Error("\u274C onAction can either be throttled or debounced, not both.");l&&Ze(l);let s=()=>{a.current&&a.current.close(),y.current.cancel&&y.current.cancel(),M(),B(!0)};return g&&window.addEventListener("beforeunload",s),()=>{g&&window.removeEventListener("beforeunload",s),a.current&&a.current.close(),y.current.cancel&&y.current.cancel(),M(),B(!0)}},[]),(0,i.useEffect)(()=>{a.current&&a.current.close(),V?a.current=new we({channelName:ye,leaderElection:Le,onPrompt:()=>{Ae()},onIdle:()=>{Re()},onActive:()=>{ve()},onMessage:ne.current,start:H,reset:Ie,activate:Ce,pause:Ee,resume:be}):a.current=null},[V,ye,Le,Pe,Me,he,ne,H,Ie,Ee,be]),(0,i.useEffect)(()=>{M(),B(!0),U.current||(S.current=!0,v.current=!0,w.current=0),!k&&(o?H():N())},[k,o,U]),(0,i.useEffect)(()=>{if(!U.current){let s=[...new Set([...n,...c]).values()];if(B(),fe.current=s,pe.current=r,xe.current=c,k)return;o?H():N()}},[r,JSON.stringify(n),JSON.stringify(c),U,k,o]),(0,i.useEffect)(()=>{if(U.current)U.current=!1;else{if(O.current=t,k)return;v.current&&(he.current(),a.current&&a.current.active()),H()}},[t,a,k,U,v]),{message:ut,start:H,reset:Ie,activate:Ce,pause:Ee,resume:be,isIdle:ct,isPrompted:mt,isLeader:dt,getTabId:pt,getRemainingTime:De,getElapsedTime:ft,getTotalElapsedTime:Ne,getLastIdleTime:ht,getLastActiveTime:vt,getTotalIdleTime:_e,getTotalActiveTime:Tt}}var j=$(require("react"));var Z=(0,j.createContext)(null);function it(t){let e=G(t);return j.default.createElement(Z.Provider,{value:e},t.children)}var st=Z.Consumer;function at(){return(0,j.useContext)(Z)}
var It=Object.create,se=Object.defineProperty;var Et=Object.getOwnPropertyDescriptor;var bt=Object.getOwnPropertyNames;var gt=Object.getPrototypeOf,wt=Object.prototype.hasOwnProperty;var We=t=>se(t,"__esModule",{value:!0});var yt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Lt=(t,e)=>{for(var r in e)se(t,r,{get:e[r],enumerable:!0})},kt=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of bt(e))!wt.call(t,n)&&n!=="default"&&se(t,n,{get:()=>e[n],enumerable:!(r=Et(e,n))||r.enumerable});return t},K=t=>kt(We(se(t!=null?It(gt(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var He=yt((le,Ve)=>{(function(t,e){typeof le=="object"&&typeof Ve!="undefined"?e(le):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t.fastUniqueNumbers={}))})(le,function(t){"use strict";var e=function(f){return function(h){var o=f(h);return h.add(o),o}},r=function(f){return function(h,o){return f.set(h,o),o}},n=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,l=536870912,c=l*2,E=function(f,h){return function(o){var k=h.get(o),x=k===void 0?o.size:k<c?k+1:0;if(!o.has(x))return f(o,x);if(o.size<l){for(;o.has(x);)x=Math.floor(Math.random()*c);return f(o,x)}if(o.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;o.has(x);)x=Math.floor(Math.random()*n);return f(o,x)}},F=new WeakMap,te=r(F),d=E(te,F),m=e(d);t.addUniqueNumber=m,t.generateUniqueNumber=d,Object.defineProperty(t,"__esModule",{value:!0})})});We(exports);Lt(exports,{DEFAULT_EVENTS:()=>me,IdleTimerConsumer:()=>st,IdleTimerContext:()=>ee,IdleTimerProvider:()=>it,createMocks:()=>Qe,useIdleTimer:()=>q,useIdleTimerContext:()=>at,withIdleTimer:()=>Be,workerTimers:()=>j});var ae=K(require("react"));function Be(t){return(0,ae.forwardRef)(function(r,n){let l={...r};!l.onPrompt&&t.prototype.onPrompt&&(l.onPrompt=()=>{t.prototype.onPrompt()}),!l.onIdle&&t.prototype.onIdle&&(l.onIdle=()=>{t.prototype.onIdle()}),!l.onActive&&t.prototype.onActive&&(l.onActive=E=>{t.prototype.onActive(E)}),!l.onAction&&t.prototype.onAction&&(l.onAction=E=>{t.prototype.onAction(E)});let c=q(l);return typeof n=="function"?n(c):n&&(n.current=c),ae.default.createElement(t,{...r,...c})})}var i=K(require("react"));var Q=K(He());var Ge=t=>t.method!==void 0&&t.method==="call";var qe=t=>t.error===null&&typeof t.id=="number";var je=t=>{let e=new Map([[0,()=>{}]]),r=new Map([[0,()=>{}]]),n=new Map,l=new Worker(t);return l.addEventListener("message",({data:d})=>{if(Ge(d)){let{params:{timerId:m,timerType:p}}=d;if(p==="interval"){let f=e.get(m);if(typeof f=="number"){let h=n.get(f);if(h===void 0||h.timerId!==m||h.timerType!==p)throw new Error("The timer is in an undefined state.")}else if(typeof f!="undefined")f();else throw new Error("The timer is in an undefined state.")}else if(p==="timeout"){let f=r.get(m);if(typeof f=="number"){let h=n.get(f);if(h===void 0||h.timerId!==m||h.timerType!==p)throw new Error("The timer is in an undefined state.")}else if(typeof f!="undefined")f(),r.delete(m);else throw new Error("The timer is in an undefined state.")}}else if(qe(d)){let{id:m}=d,p=n.get(m);if(p===void 0)throw new Error("The timer is in an undefined state.");let{timerId:f,timerType:h}=p;n.delete(m),h==="interval"?e.delete(f):r.delete(f)}else{let{error:{message:m}}=d;throw new Error(m)}}),{clearInterval:d=>{let m=(0,Q.generateUniqueNumber)(n);n.set(m,{timerId:d,timerType:"interval"}),e.set(d,m),l.postMessage({id:m,method:"clear",params:{timerId:d,timerType:"interval"}})},clearTimeout:d=>{let m=(0,Q.generateUniqueNumber)(n);n.set(m,{timerId:d,timerType:"timeout"}),r.set(d,m),l.postMessage({id:m,method:"clear",params:{timerId:d,timerType:"timeout"}})},setInterval:(d,m)=>{let p=(0,Q.generateUniqueNumber)(e);return e.set(p,()=>{d(),typeof e.get(p)=="function"&&l.postMessage({id:null,method:"set",params:{delay:m,now:performance.now(),timerId:p,timerType:"interval"}})}),l.postMessage({id:null,method:"set",params:{delay:m,now:performance.now(),timerId:p,timerType:"interval"}}),p},setTimeout:(d,m)=>{let p=(0,Q.generateUniqueNumber)(r);return r.set(p,d),l.postMessage({id:null,method:"set",params:{delay:m,now:performance.now(),timerId:p,timerType:"timeout"}}),p}}};var Z=null,Ye=(t,e)=>()=>{if(Z!==null)return Z;let r=new Blob([e],{type:"application/javascript; charset=utf-8"}),n=URL.createObjectURL(r);return Z=t(n),Z.setTimeout(()=>URL.revokeObjectURL(n),0),Z};var Je=`(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id "'.concat(t,'".'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error('The given type "'.concat(i,'" is not supported'));(e=>{const r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error('The given method "'.concat(s.method,'" is not supported'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error('The given type "'.concat(d,'" is not supported'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();`;var ue=Ye(je,Je),ze=t=>ue().clearInterval(t),Xe=t=>ue().clearTimeout(t),$e=(t,e)=>ue().setInterval(t,e),Ke=(t,e)=>ue().setTimeout(t,e);var g=(typeof window=="undefined"?"undefined":typeof window)=="object";var T={setTimeout:g?setTimeout.bind(window):setTimeout,clearTimeout:g?clearTimeout.bind(window):clearTimeout,setInterval:g?setInterval.bind(window):setInterval,clearInterval:g?clearInterval.bind(window):clearInterval},j={setTimeout:Ke,clearTimeout:Xe,setInterval:$e,clearInterval:ze};function Qe(){T.setTimeout=setTimeout,T.clearTimeout=clearTimeout,T.setInterval=setInterval,T.clearInterval=clearInterval,j.setTimeout=setTimeout,j.clearTimeout=clearTimeout,j.setInterval=setInterval,j.clearInterval=clearInterval}function Ze(t){T.setTimeout=t.setTimeout,T.clearTimeout=t.clearTimeout,T.setInterval=t.setInterval,T.clearInterval=t.clearInterval}var Y={},et=class{constructor(e){this.closed=!1;this.mc=new MessageChannel;this.name=e,Y[e]=Y[e]||[],Y[e].push(this),this.mc.port1.start(),this.mc.port2.start(),this.onStorage=this.onStorage.bind(this),window.addEventListener("storage",this.onStorage)}onStorage(e){if(e.storageArea!==window.localStorage||e.key.substring(0,this.name.length)!==this.name||e.newValue===null)return;let r=JSON.parse(e.newValue);this.mc.port2.postMessage(r)}postMessage(e){if(this.closed)throw new Error("InvalidStateError");let r=JSON.stringify(e),n=`${this.name}:${String(Date.now())}${String(Math.random())}`;window.localStorage.setItem(n,r),T.setTimeout(()=>{window.localStorage.removeItem(n)},500),Y[this.name].forEach(l=>{l!==this&&l.mc.port2.postMessage(JSON.parse(r))})}close(){if(this.closed)return;this.closed=!0,this.mc.port1.close(),this.mc.port2.close(),window.removeEventListener("storage",this.onStorage);let e=Y[this.name].indexOf(this);Y[this.name].splice(e,1)}get onmessage(){return this.mc.port1.onmessage}set onmessage(e){this.mc.port1.onmessage=e}get onmessageerror(){return this.mc.port1.onmessageerror}set onmessageerror(e){this.mc.port1.onmessageerror=e}addEventListener(e,r){return this.mc.port1.addEventListener(e,r)}removeEventListener(e,r){return this.mc.port1.removeEventListener(e,r)}dispatchEvent(e){return this.mc.port1.dispatchEvent(e)}},tt=typeof window=="undefined"?void 0:typeof window.BroadcastChannel=="function"?window.BroadcastChannel:et;function rt(t=0){return new Promise(e=>T.setTimeout(e,t))}function ce(){return Math.random().toString(36).substring(2)}var u;(function(o){o[o.APPLY=0]="APPLY",o[o.TELL=1]="TELL",o[o.CLOSE=2]="CLOSE",o[o.REGISTER=3]="REGISTER",o[o.DEREGISTER=4]="DEREGISTER",o[o.IDLE=5]="IDLE",o[o.ACTIVE=6]="ACTIVE",o[o.PROMPT=7]="PROMPT",o[o.START=8]="START",o[o.RESET=9]="RESET",o[o.ACTIVATE=10]="ACTIVATE",o[o.PAUSE=11]="PAUSE",o[o.RESUME=12]="RESUME",o[o.MESSAGE=13]="MESSAGE"})(u||(u={}));var we=class{constructor(e,r){this.token=ce();this.isLeader=!1;this.isDead=!1;this.isApplying=!1;this.reApply=!1;this.intervals=[];this.listeners=[];this.channel=e,this.options=r,this.apply=this.apply.bind(this),this.awaitLeadership=this.awaitLeadership.bind(this),this.sendAction=this.sendAction.bind(this)}async apply(){if(this.isLeader||this.isDead)return!1;if(this.isApplying)return this.reApply=!0,!1;this.isApplying=!0;let e=!1,r=n=>{let{token:l,action:c}=n.data;l!==this.token&&(c===u.APPLY&&l>this.token&&(e=!0),c===u.TELL&&(e=!0))};this.channel.addEventListener("message",r);try{return this.sendAction(u.APPLY),await rt(this.options.responseTime),this.channel.removeEventListener("message",r),this.isApplying=!1,e?this.reApply?this.apply():!1:(this.assumeLead(),!0)}catch{return!1}}awaitLeadership(){if(this.isLeader)return Promise.resolve();let e=!1,r=null;return new Promise(n=>{let l=()=>{if(e)return;e=!0,T.clearInterval(r);let E=this.intervals.indexOf(r);this.intervals.splice(E,1),this.channel.removeEventListener("message",c),n()};r=T.setInterval(()=>{this.apply().then(()=>{this.isLeader&&l()})},this.options.fallbackInterval),this.intervals.push(r);let c=E=>{let{action:F}=E.data;F===u.CLOSE&&this.apply().then(()=>{this.isLeader&&l()})};this.channel.addEventListener("message",c)})}sendAction(e){this.channel.postMessage({action:e,token:this.token})}assumeLead(){this.isLeader=!0;let e=r=>{let{action:n}=r.data;n===u.APPLY&&this.sendAction(u.TELL)};return this.channel.addEventListener("message",e),this.listeners.push(e),this.sendAction(u.TELL)}waitForLeadership(){return this.deferred?this.deferred:(this.deferred=this.awaitLeadership(),this.deferred)}close(){this.isDead||(this.isDead=!0,this.isLeader=!1,this.sendAction(u.CLOSE),this.listeners.forEach(e=>this.channel.removeEventListener("message",e)),this.intervals.forEach(e=>T.clearInterval(e)))}};var L;(function(n){n[n.PROMPTED=0]="PROMPTED",n[n.ACTIVE=1]="ACTIVE",n[n.IDLE=2]="IDLE"})(L||(L={}));var ye=class{constructor(e){this.token=ce();this.registry=new Map;this.allIdle=!1;let{channelName:r}=e;if(this.options=e,this.channel=new tt(r),this.registry.set(this.token,1),e.leaderElection){let n={fallbackInterval:2e3,responseTime:100};this.elector=new we(this.channel,n),this.elector.waitForLeadership()}this.channel.addEventListener("message",n=>{let{action:l,token:c,data:E}=n.data;switch(l){case u.REGISTER:this.registry.set(c,2);break;case u.DEREGISTER:this.registry.delete(c);break;case u.IDLE:this.idle(c);break;case u.ACTIVE:this.active(c);break;case u.PROMPT:this.prompt(c);break;case u.START:this.start(c);break;case u.RESET:this.reset(c);break;case u.ACTIVATE:this.activate(c);break;case u.PAUSE:this.pause(c);break;case u.RESUME:this.resume(c);break;case u.MESSAGE:this.options.onMessage(E);break}}),this.send(u.REGISTER)}get isLeader(){if(!this.elector)throw new Error('\u274C Leader election is not enabled. To Enable it set the "leaderElection" property to true.');return this.elector.isLeader}prompt(e=this.token){this.registry.set(e,0);let r=[...this.registry.values()].every(n=>n===0);e===this.token&&this.send(u.PROMPT),r&&this.options.onPrompt()}idle(e=this.token){this.registry.set(e,2);let r=[...this.registry.values()].every(n=>n===2);e===this.token&&this.send(u.IDLE),!this.allIdle&&r&&(this.allIdle=!0,this.options.onIdle())}active(e=this.token){this.allIdle=!1,this.registry.set(e,1);let r=[...this.registry.values()].some(n=>n===1);e===this.token&&this.send(u.ACTIVE),r&&this.options.onActive()}start(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(u.START):this.options.start(!0)}reset(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(u.RESET):this.options.reset(!0)}activate(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(u.ACTIVATE):this.options.activate(!0)}pause(e=this.token){e===this.token?this.send(u.PAUSE):this.options.pause(!0)}resume(e=this.token){e===this.token?this.send(u.RESUME):this.options.resume(!0)}message(e){try{this.channel.postMessage({action:u.MESSAGE,token:this.token,data:e})}catch{}}send(e){try{this.channel.postMessage({action:e,token:this.token})}catch{}}close(){this.options.leaderElection&&this.elector.close(),this.send(u.DEREGISTER),this.channel.close()}};var nt=g?document:null,me=["mousemove","keydown","wheel","DOMMouseScroll","mousewheel","mousedown","touchstart","touchmove","MSPointerDown","MSPointerMove","visibilitychange"];var de=K(require("react"));function _(t){let e=(0,de.useRef)(t);return(0,de.useEffect)(()=>{e.current=t},[t]),e}function ot(t,e){let r;function n(...l){r&&clearTimeout(r),r=setTimeout(()=>{t(...l),r=null},e)}return n.cancel=function(){clearTimeout(r)},n}function pe(t,e){let r=0;return function(...n){let l=new Date().getTime();if(!(l-r<e))return r=l,t(...n)}}var I=()=>g?performance.now():Date.now();function q({timeout:t=1e3*60*20,promptTimeout:e=0,element:r=nt,events:n=me,timers:l=void 0,immediateEvents:c=[],onPrompt:E=()=>{},onIdle:F=()=>{},onActive:te=()=>{},onAction:d=()=>{},onMessage:m=()=>{},debounce:p=0,throttle:f=0,eventsThrottle:h=200,startOnMount:o=!0,startManually:k=!1,stopOnIdle:x=!1,crossTab:V=!1,name:Le="idle-timer",syncTimers:z=0,leaderElection:ke=!1}={}){let H=(0,i.useRef)(I()),xe=(0,i.useRef)(Date.now()),re=(0,i.useRef)(I()),C=(0,i.useRef)(null),D=(0,i.useRef)(null),X=(0,i.useRef)(0),v=(0,i.useRef)(!0),S=(0,i.useRef)(!1),U=(0,i.useRef)(!0),$=(0,i.useRef)(!1),b=(0,i.useRef)(!1),w=(0,i.useRef)(0),A=(0,i.useRef)(0),R=(0,i.useRef)(null),a=(0,i.useRef)(null),O=_(t),ne=_(e),lt=_(x),Me=(0,i.useRef)(c),fe=(0,i.useRef)(r),he=(0,i.useRef)([...new Set([...n,...c]).values()]),Pe=_(F),ve=_(te),Se=_(E),oe=_(m),y=(0,i.useRef)();(0,i.useEffect)(()=>{y.current&&y.current.cancel&&y.current.cancel(),p>0?y.current=ot(d,p):f>0?y.current=pe(d,f):y.current=d},[d,f,p]);let Ae=(0,i.useRef)();(0,i.useEffect)(()=>{V&&z&&(Ae.current=pe(()=>{a.current.active()},z))},[V,z]);let M=()=>{R.current!==null&&(T.clearTimeout(R.current),R.current=null)},W=(s,P=!0)=>{M(),R.current=T.setTimeout(Ie,s||O.current),P&&(D.current=I())},Re=s=>{w.current=0,A.current=I(),b.current=!0,W(ne.current,!1),Se.current(s)},Oe=()=>{M(),v.current=!0,C.current=I(),lt.current?B():b.current&&(A.current=0,b.current=!1),Pe.current()},Te=s=>{M(),b.current=!1,A.current=0,v.current=!1,X.current+=I()-C.current,N(),W(),ve.current(s)},Ie=s=>{if(!v.current){if(y.current.cancel&&y.current.cancel(),ne.current>0&&!b.current){a.current?a.current.prompt():Re(s);return}a.current?a.current.idle():Oe();return}a.current?a.current.active():Te(s)},Ce=s=>{if(y.current(s),b.current)return;if(M(),!v.current&&Me.current.includes(s.type)){Ie(s);return}let P=I()-D.current;if(v.current&&!x||!v.current&&P>O.current){Ie(s);return}S.current=!1,w.current=0,A.current=0,W(),V&&z&&Ae.current()},ie=(0,i.useRef)();(0,i.useEffect)(()=>{let s=$.current;s&&B(),h>0?ie.current=pe(Ce,h):ie.current=Ce,s&&N()},[h,V,z]);let N=()=>{!g||$.current||(he.current.forEach(s=>{fe.current.addEventListener(s,ie.current,{capture:!0,passive:!0})}),$.current=!0)},B=(s=!1)=>{!g||($.current||s)&&(he.current.forEach(P=>{fe.current.removeEventListener(P,ie.current,{capture:!0})}),$.current=!1)},G=(0,i.useCallback)(s=>{M(),N(),v.current=!1,b.current=!1,S.current=!1,w.current=0,A.current=0,a.current&&!s&&a.current.start(),W()},[R,v,O,a]),Ee=(0,i.useCallback)(s=>{M(),N(),v.current=!1,b.current=!1,S.current=!1,w.current=0,A.current=0,H.current=I(),re.current=I(),a.current&&!s&&a.current.reset(),k||W()},[R,v,O,k,a]),De=(0,i.useCallback)(s=>{M(),N(),(v.current||b.current)&&Te(),v.current=!1,b.current=!1,S.current=!1,w.current=0,A.current=0,re.current=I(),a.current&&!s&&a.current.activate(),W()},[R,v,O,a]),be=(0,i.useCallback)((s=!1)=>S.current?!1:(w.current=Ne(),S.current=!0,B(),M(),a.current&&!s&&a.current.pause(),!0),[R,a]),ge=(0,i.useCallback)((s=!1)=>S.current?(S.current=!1,b.current||N(),v.current||W(w.current),A.current&&(A.current=I()),a.current&&!s&&a.current.resume(),!0):!1,[R,O,w,a]),ut=(0,i.useCallback)((s,P)=>{a.current?(P&&oe.current(s),a.current.message(s)):P&&oe.current(s)},[m]),ct=(0,i.useCallback)(()=>v.current,[v]),mt=(0,i.useCallback)(()=>b.current,[b]),dt=(0,i.useCallback)(()=>{if(!a.current)throw new Error('\u274C Cross Tab feature is not enabled. To enable it set the "crossTab" property to true.');return a.current.isLeader},[a]),pt=(0,i.useCallback)(()=>{if(!a.current)throw new Error('\u274C Cross Tab feature is not enabled. To enable it set the "crossTab" property to true.');return a.current.token},[a]),Ne=(0,i.useCallback)(()=>{if(S.current)return w.current;let s=w.current?w.current:ne.current+O.current,P=D.current?I()-D.current:0,Ue=Math.ceil(s-P);return Ue<0?0:Math.abs(Ue)},[O,ne,b,w,D]),ft=(0,i.useCallback)(()=>Math.round(I()-re.current),[re]),_e=(0,i.useCallback)(()=>Math.round(I()-H.current),[H]),ht=(0,i.useCallback)(()=>C.current?new Date(xe.current-H.current+C.current):null,[C]),vt=(0,i.useCallback)(()=>D.current?new Date(xe.current-H.current+D.current):null,[D]),Fe=(0,i.useCallback)(()=>v.current?Math.round(I()-C.current+X.current):Math.round(X.current),[C,X]),Tt=(0,i.useCallback)(()=>{let s=Math.round(_e()-Fe());return s>=0?s:0},[H,C,X]);return(0,i.useEffect)(()=>{if(p>0&&f>0)throw new Error("\u274C onAction can either be throttled or debounced, not both.");l&&Ze(l);let s=()=>{a.current&&a.current.close(),y.current.cancel&&y.current.cancel(),M(),B(!0)};return g&&window.addEventListener("beforeunload",s),()=>{g&&window.removeEventListener("beforeunload",s),a.current&&a.current.close(),y.current.cancel&&y.current.cancel(),M(),B(!0)}},[]),(0,i.useEffect)(()=>{a.current&&a.current.close(),V?a.current=new ye({channelName:Le,leaderElection:ke,onPrompt:()=>{Re()},onIdle:()=>{Oe()},onActive:()=>{Te()},onMessage:oe.current,start:G,reset:Ee,activate:De,pause:be,resume:ge}):a.current=null},[V,Le,ke,Se,Pe,ve,oe,G,Ee,be,ge]),(0,i.useEffect)(()=>{M(),B(!0),U.current||(S.current=!0,v.current=!0,w.current=0),!k&&(o?G():N())},[k,o,U]),(0,i.useEffect)(()=>{if(!U.current){let s=[...new Set([...n,...c]).values()];if(B(),he.current=s,fe.current=r,Me.current=c,k)return;o?G():N()}},[r,JSON.stringify(n),JSON.stringify(c),U,k,o]),(0,i.useEffect)(()=>{if(U.current)U.current=!1;else{if(O.current=t,k)return;v.current&&(ve.current(),a.current&&a.current.active()),G()}},[t,a,k,U,v]),{message:ut,start:G,reset:Ee,activate:De,pause:be,resume:ge,isIdle:ct,isPrompted:mt,isLeader:dt,getTabId:pt,getRemainingTime:Ne,getElapsedTime:ft,getTotalElapsedTime:_e,getLastIdleTime:ht,getLastActiveTime:vt,getTotalIdleTime:Fe,getTotalActiveTime:Tt}}var J=K(require("react"));var ee=(0,J.createContext)(null);function it(t){let e=q(t);return J.default.createElement(ee.Provider,{value:e},t.children)}var st=ee.Consumer;function at(){return(0,J.useContext)(ee)}

@@ -1,1 +0,1 @@

var ut=Object.create,Te=Object.defineProperty;var ct=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var dt=Object.getPrototypeOf,pt=Object.prototype.hasOwnProperty;var ft=t=>Te(t,"__esModule",{value:!0});var ht=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var vt=(t,e,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of mt(e))!pt.call(t,r)&&r!=="default"&&Te(t,r,{get:()=>e[r],enumerable:!(n=ct(e,r))||n.enumerable});return t},Tt=t=>vt(ft(Te(t!=null?ut(dt(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var Fe=ht((oe,_e)=>{(function(t,e){typeof oe=="object"&&typeof _e!="undefined"?e(oe):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t.fastUniqueNumbers={}))})(oe,function(t){"use strict";var e=function(p){return function(h){var o=p(h);return h.add(o),o}},n=function(p){return function(h,o){return p.set(h,o),o}},r=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,a=536870912,u=a*2,b=function(p,h){return function(o){var x=h.get(o),M=x===void 0?o.size:x<u?x+1:0;if(!o.has(M))return p(o,M);if(o.size<a){for(;o.has(M);)M=Math.floor(Math.random()*u);return p(o,M)}if(o.size>r)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;o.has(M);)M=Math.floor(Math.random()*r);return p(o,M)}},W=new WeakMap,Z=n(W),m=b(Z,W),c=e(m);t.addUniqueNumber=c,t.generateUniqueNumber=m,Object.defineProperty(t,"__esModule",{value:!0})})});import It,{forwardRef as Et}from"react";function bt(t){return Et(function(n,r){let a={...n};!a.onPrompt&&t.prototype.onPrompt&&(a.onPrompt=()=>{t.prototype.onPrompt()}),!a.onIdle&&t.prototype.onIdle&&(a.onIdle=()=>{t.prototype.onIdle()}),!a.onActive&&t.prototype.onActive&&(a.onActive=b=>{t.prototype.onActive(b)}),!a.onAction&&t.prototype.onAction&&(a.onAction=b=>{t.prototype.onAction(b)});let u=$(a);return typeof r=="function"?r(u):r&&(r.current=u),It.createElement(t,{...n,...u})})}import{useEffect as U,useRef as f,useCallback as I}from"react";var K=Tt(Fe());var Ue=t=>t.method!==void 0&&t.method==="call";var We=t=>t.error===null&&typeof t.id=="number";var Be=t=>{let e=new Map([[0,()=>{}]]),n=new Map([[0,()=>{}]]),r=new Map,a=new Worker(t);return a.addEventListener("message",({data:m})=>{if(Ue(m)){let{params:{timerId:c,timerType:d}}=m;if(d==="interval"){let p=e.get(c);if(typeof p=="number"){let h=r.get(p);if(h===void 0||h.timerId!==c||h.timerType!==d)throw new Error("The timer is in an undefined state.")}else if(typeof p!="undefined")p();else throw new Error("The timer is in an undefined state.")}else if(d==="timeout"){let p=n.get(c);if(typeof p=="number"){let h=r.get(p);if(h===void 0||h.timerId!==c||h.timerType!==d)throw new Error("The timer is in an undefined state.")}else if(typeof p!="undefined")p(),n.delete(c);else throw new Error("The timer is in an undefined state.")}}else if(We(m)){let{id:c}=m,d=r.get(c);if(d===void 0)throw new Error("The timer is in an undefined state.");let{timerId:p,timerType:h}=d;r.delete(c),h==="interval"?e.delete(p):n.delete(p)}else{let{error:{message:c}}=m;throw new Error(c)}}),{clearInterval:m=>{let c=(0,K.generateUniqueNumber)(r);r.set(c,{timerId:m,timerType:"interval"}),e.set(m,c),a.postMessage({id:c,method:"clear",params:{timerId:m,timerType:"interval"}})},clearTimeout:m=>{let c=(0,K.generateUniqueNumber)(r);r.set(c,{timerId:m,timerType:"timeout"}),n.set(m,c),a.postMessage({id:c,method:"clear",params:{timerId:m,timerType:"timeout"}})},setInterval:(m,c)=>{let d=(0,K.generateUniqueNumber)(e);return e.set(d,()=>{m(),typeof e.get(d)=="function"&&a.postMessage({id:null,method:"set",params:{delay:c,now:performance.now(),timerId:d,timerType:"interval"}})}),a.postMessage({id:null,method:"set",params:{delay:c,now:performance.now(),timerId:d,timerType:"interval"}}),d},setTimeout:(m,c)=>{let d=(0,K.generateUniqueNumber)(n);return n.set(d,m),a.postMessage({id:null,method:"set",params:{delay:c,now:performance.now(),timerId:d,timerType:"timeout"}}),d}}};var Q=null,Ve=(t,e)=>()=>{if(Q!==null)return Q;let n=new Blob([e],{type:"application/javascript; charset=utf-8"}),r=URL.createObjectURL(n);return Q=t(r),Q.setTimeout(()=>URL.revokeObjectURL(r),0),Q};var He=`(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id "'.concat(t,'".'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error('The given type "'.concat(i,'" is not supported'));(e=>{const r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error('The given method "'.concat(s.method,'" is not supported'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error('The given type "'.concat(d,'" is not supported'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();`;var ie=Ve(Be,He),Ge=t=>ie().clearInterval(t),qe=t=>ie().clearTimeout(t),je=(t,e)=>ie().setInterval(t,e),Ye=(t,e)=>ie().setTimeout(t,e);var w=(typeof window=="undefined"?"undefined":typeof window)=="object";var T={setTimeout:w?setTimeout.bind(window):setTimeout,clearTimeout:w?clearTimeout.bind(window):clearTimeout,setInterval:w?setInterval.bind(window):setInterval,clearInterval:w?clearInterval.bind(window):clearInterval},gt={setTimeout:Ye,clearTimeout:qe,setInterval:je,clearInterval:Ge};function wt(){T.setTimeout=setTimeout,T.clearTimeout=clearTimeout,T.setInterval=setInterval,T.clearInterval=clearInterval}function Je(t){T.setTimeout=t.setTimeout,T.clearTimeout=t.clearTimeout,T.setInterval=t.setInterval,T.clearInterval=t.clearInterval}var j={},ze=class{constructor(e){this.closed=!1;this.mc=new MessageChannel;this.name=e,j[e]=j[e]||[],j[e].push(this),this.mc.port1.start(),this.mc.port2.start(),this.onStorage=this.onStorage.bind(this),window.addEventListener("storage",this.onStorage)}onStorage(e){if(e.storageArea!==window.localStorage||e.key.substring(0,this.name.length)!==this.name||e.newValue===null)return;let n=JSON.parse(e.newValue);this.mc.port2.postMessage(n)}postMessage(e){if(this.closed)throw new Error("InvalidStateError");let n=JSON.stringify(e),r=`${this.name}:${String(Date.now())}${String(Math.random())}`;window.localStorage.setItem(r,n),T.setTimeout(()=>{window.localStorage.removeItem(r)},500),j[this.name].forEach(a=>{a!==this&&a.mc.port2.postMessage(JSON.parse(n))})}close(){if(this.closed)return;this.closed=!0,this.mc.port1.close(),this.mc.port2.close(),window.removeEventListener("storage",this.onStorage);let e=j[this.name].indexOf(this);j[this.name].splice(e,1)}get onmessage(){return this.mc.port1.onmessage}set onmessage(e){this.mc.port1.onmessage=e}get onmessageerror(){return this.mc.port1.onmessageerror}set onmessageerror(e){this.mc.port1.onmessageerror=e}addEventListener(e,n){return this.mc.port1.addEventListener(e,n)}removeEventListener(e,n){return this.mc.port1.removeEventListener(e,n)}dispatchEvent(e){return this.mc.port1.dispatchEvent(e)}},Xe=typeof window=="undefined"?void 0:typeof window.BroadcastChannel=="function"?window.BroadcastChannel:ze;function $e(t=0){return new Promise(e=>T.setTimeout(e,t))}function se(){return Math.random().toString(36).substring(2)}var l;(function(o){o[o.APPLY=0]="APPLY",o[o.TELL=1]="TELL",o[o.CLOSE=2]="CLOSE",o[o.REGISTER=3]="REGISTER",o[o.DEREGISTER=4]="DEREGISTER",o[o.IDLE=5]="IDLE",o[o.ACTIVE=6]="ACTIVE",o[o.PROMPT=7]="PROMPT",o[o.START=8]="START",o[o.RESET=9]="RESET",o[o.ACTIVATE=10]="ACTIVATE",o[o.PAUSE=11]="PAUSE",o[o.RESUME=12]="RESUME",o[o.MESSAGE=13]="MESSAGE"})(l||(l={}));var Ie=class{constructor(e,n){this.token=se();this.isLeader=!1;this.isDead=!1;this.isApplying=!1;this.reApply=!1;this.intervals=[];this.listeners=[];this.channel=e,this.options=n,this.apply=this.apply.bind(this),this.awaitLeadership=this.awaitLeadership.bind(this),this.sendAction=this.sendAction.bind(this)}async apply(){if(this.isLeader||this.isDead)return!1;if(this.isApplying)return this.reApply=!0,!1;this.isApplying=!0;let e=!1,n=r=>{let{token:a,action:u}=r.data;a!==this.token&&(u===l.APPLY&&a>this.token&&(e=!0),u===l.TELL&&(e=!0))};this.channel.addEventListener("message",n);try{return this.sendAction(l.APPLY),await $e(this.options.responseTime),this.channel.removeEventListener("message",n),this.isApplying=!1,e?this.reApply?this.apply():!1:(this.assumeLead(),!0)}catch{return!1}}awaitLeadership(){if(this.isLeader)return Promise.resolve();let e=!1,n=null;return new Promise(r=>{let a=()=>{if(e)return;e=!0,T.clearInterval(n);let b=this.intervals.indexOf(n);this.intervals.splice(b,1),this.channel.removeEventListener("message",u),r()};n=T.setInterval(()=>{this.apply().then(()=>{this.isLeader&&a()})},this.options.fallbackInterval),this.intervals.push(n);let u=b=>{let{action:W}=b.data;W===l.CLOSE&&this.apply().then(()=>{this.isLeader&&a()})};this.channel.addEventListener("message",u)})}sendAction(e){this.channel.postMessage({action:e,token:this.token})}assumeLead(){this.isLeader=!0;let e=n=>{let{action:r}=n.data;r===l.APPLY&&this.sendAction(l.TELL)};return this.channel.addEventListener("message",e),this.listeners.push(e),this.sendAction(l.TELL)}waitForLeadership(){return this.deferred?this.deferred:(this.deferred=this.awaitLeadership(),this.deferred)}close(){this.isDead||(this.isDead=!0,this.isLeader=!1,this.sendAction(l.CLOSE),this.listeners.forEach(e=>this.channel.removeEventListener("message",e)),this.intervals.forEach(e=>T.clearInterval(e)))}};var k;(function(r){r[r.PROMPTED=0]="PROMPTED",r[r.ACTIVE=1]="ACTIVE",r[r.IDLE=2]="IDLE"})(k||(k={}));var Ee=class{constructor(e){this.token=se();this.registry=new Map;this.allIdle=!1;let{channelName:n}=e;if(this.options=e,this.channel=new Xe(n),this.registry.set(this.token,1),e.leaderElection){let r={fallbackInterval:2e3,responseTime:100};this.elector=new Ie(this.channel,r),this.elector.waitForLeadership()}this.channel.addEventListener("message",r=>{let{action:a,token:u,data:b}=r.data;switch(a){case l.REGISTER:this.registry.set(u,2);break;case l.DEREGISTER:this.registry.delete(u);break;case l.IDLE:this.idle(u);break;case l.ACTIVE:this.active(u);break;case l.PROMPT:this.prompt(u);break;case l.START:this.start(u);break;case l.RESET:this.reset(u);break;case l.ACTIVATE:this.activate(u);break;case l.PAUSE:this.pause(u);break;case l.RESUME:this.resume(u);break;case l.MESSAGE:this.options.onMessage(b);break}}),this.send(l.REGISTER)}get isLeader(){if(!this.elector)throw new Error('\u274C Leader election is not enabled. To Enable it set the "leaderElection" property to true.');return this.elector.isLeader}prompt(e=this.token){this.registry.set(e,0);let n=[...this.registry.values()].every(r=>r===0);e===this.token&&this.send(l.PROMPT),n&&this.options.onPrompt()}idle(e=this.token){this.registry.set(e,2);let n=[...this.registry.values()].every(r=>r===2);e===this.token&&this.send(l.IDLE),!this.allIdle&&n&&(this.allIdle=!0,this.options.onIdle())}active(e=this.token){this.allIdle=!1,this.registry.set(e,1);let n=[...this.registry.values()].some(r=>r===1);e===this.token&&this.send(l.ACTIVE),n&&this.options.onActive()}start(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(l.START):this.options.start(!0)}reset(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(l.RESET):this.options.reset(!0)}activate(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(l.ACTIVATE):this.options.activate(!0)}pause(e=this.token){e===this.token?this.send(l.PAUSE):this.options.pause(!0)}resume(e=this.token){e===this.token?this.send(l.RESUME):this.options.resume(!0)}message(e){try{this.channel.postMessage({action:l.MESSAGE,token:this.token,data:e})}catch{}}send(e){try{this.channel.postMessage({action:e,token:this.token})}catch{}}close(){this.options.leaderElection&&this.elector.close(),this.send(l.DEREGISTER),this.channel.close()}};var Ke=w?document:null,be=["mousemove","keydown","wheel","DOMMouseScroll","mousewheel","mousedown","touchstart","touchmove","MSPointerDown","MSPointerMove","visibilitychange"];import{useRef as yt,useEffect as Lt}from"react";function F(t){let e=yt(t);return Lt(()=>{e.current=t},[t]),e}function Qe(t,e){let n;function r(...a){n&&clearTimeout(n),n=setTimeout(()=>{t(...a),n=null},e)}return r.cancel=function(){clearTimeout(n)},r}function ae(t,e){let n=0;return function(...r){let a=new Date().getTime();if(!(a-n<e))return n=a,t(...r)}}var E=()=>w?performance.now():Date.now();function $({timeout:t=1e3*60*20,promptTimeout:e=0,element:n=Ke,events:r=be,timers:a=void 0,immediateEvents:u=[],onPrompt:b=()=>{},onIdle:W=()=>{},onActive:Z=()=>{},onAction:m=()=>{},onMessage:c=()=>{},debounce:d=0,throttle:p=0,eventsThrottle:h=200,startOnMount:o=!0,startManually:x=!1,stopOnIdle:M=!1,crossTab:G=!1,name:ge="idle-timer",syncTimers:Y=0,leaderElection:we=!1}={}){let J=f(E()),ye=f(Date.now()),ee=f(E()),D=f(null),N=f(null),z=f(0),v=f(!0),A=f(!1),B=f(!0),X=f(!1),g=f(!1),y=f(0),R=f(0),O=f(null),s=f(null),C=F(t),te=F(e),Ze=F(M),Le=f(u),ue=f(n),ce=f([...new Set([...r,...u]).values()]),ke=F(W),me=F(Z),xe=F(b),re=F(c),L=f();U(()=>{L.current&&L.current.cancel&&L.current.cancel(),d>0?L.current=Qe(m,d):p>0?L.current=ae(m,p):L.current=m},[m,p,d]);let Me=f();U(()=>{G&&Y&&(Me.current=ae(()=>{s.current.active()},Y))},[G,Y]);let P=()=>{O.current!==null&&(T.clearTimeout(O.current),O.current=null)},V=(i,S=!0)=>{P(),O.current=T.setTimeout(pe,i||C.current),S&&(N.current=E())},Pe=i=>{y.current=0,R.current=E(),g.current=!0,V(te.current,!1),xe.current(i)},Se=()=>{P(),v.current=!0,D.current=E(),Ze.current?H():g.current&&(R.current=0,g.current=!1),ke.current()},de=i=>{P(),g.current=!1,R.current=0,v.current=!1,z.current+=E()-D.current,_(),V(),me.current(i)},pe=i=>{if(!v.current){if(L.current.cancel&&L.current.cancel(),te.current>0&&!g.current){s.current?s.current.prompt():Pe(i);return}s.current?s.current.idle():Se();return}s.current?s.current.active():de(i)},Ae=i=>{if(L.current(i),g.current)return;if(P(),!v.current&&Le.current.includes(i.type)){pe(i);return}let S=E()-N.current;if(v.current&&!M||!v.current&&S>C.current){pe(i);return}A.current=!1,y.current=0,R.current=0,V(),G&&Y&&Me.current()},ne=f();U(()=>{let i=X.current;i&&H(),h>0?ne.current=ae(Ae,h):ne.current=Ae,i&&_()},[h,G,Y]);let _=()=>{!w||X.current||(ce.current.forEach(i=>{ue.current.addEventListener(i,ne.current,{capture:!0,passive:!0})}),X.current=!0)},H=(i=!1)=>{!w||(X.current||i)&&(ce.current.forEach(S=>{ue.current.removeEventListener(S,ne.current,{capture:!0})}),X.current=!1)},q=I(i=>{P(),_(),v.current=!1,g.current=!1,A.current=!1,y.current=0,R.current=0,s.current&&!i&&s.current.start(),V()},[O,v,C,s]),fe=I(i=>{P(),_(),v.current=!1,g.current=!1,A.current=!1,y.current=0,R.current=0,ee.current=E(),s.current&&!i&&s.current.reset(),x||V()},[O,v,C,x,s]),Re=I(i=>{P(),_(),(v.current||g.current)&&de(),v.current=!1,g.current=!1,A.current=!1,y.current=0,R.current=0,ee.current=E(),s.current&&!i&&s.current.activate(),V()},[O,v,C,s]),he=I((i=!1)=>A.current?!1:(y.current=Oe(),A.current=!0,H(),P(),s.current&&!i&&s.current.pause(),!0),[O,s]),ve=I((i=!1)=>A.current?(A.current=!1,g.current||_(),v.current||V(y.current),R.current&&(R.current=E()),s.current&&!i&&s.current.resume(),!0):!1,[O,C,y,s]),et=I((i,S)=>{s.current?(S&&re.current(i),s.current.message(i)):S&&re.current(i)},[c]),tt=I(()=>v.current,[v]),rt=I(()=>g.current,[g]),nt=I(()=>{if(!s.current)throw new Error('\u274C Cross Tab feature is not enabled. To enable it set the "crossTab" property to true.');return s.current.isLeader},[s]),ot=I(()=>{if(!s.current)throw new Error('\u274C Cross Tab feature is not enabled. To enable it set the "crossTab" property to true.');return s.current.token},[s]),Oe=I(()=>{if(A.current)return y.current;let i=y.current?y.current:te.current+C.current,S=N.current?E()-N.current:0,Ne=Math.ceil(i-S);return Ne<0?0:Math.abs(Ne)},[C,te,g,y,N]),it=I(()=>Math.round(E()-ee.current),[ee]),Ce=I(()=>Math.round(E()-J.current),[J]),st=I(()=>D.current?new Date(ye.current-J.current+D.current):null,[D]),at=I(()=>N.current?new Date(ye.current-J.current+N.current):null,[N]),De=I(()=>v.current?Math.round(E()-D.current+z.current):Math.round(z.current),[D,z]),lt=I(()=>{let i=Math.round(Ce()-De());return i>=0?i:0},[J,D,z]);return U(()=>{if(d>0&&p>0)throw new Error("\u274C onAction can either be throttled or debounced, not both.");a&&Je(a);let i=()=>{s.current&&s.current.close(),L.current.cancel&&L.current.cancel(),P(),H(!0)};return w&&window.addEventListener("beforeunload",i),()=>{w&&window.removeEventListener("beforeunload",i),s.current&&s.current.close(),L.current.cancel&&L.current.cancel(),P(),H(!0)}},[]),U(()=>{s.current&&s.current.close(),G?s.current=new Ee({channelName:ge,leaderElection:we,onPrompt:()=>{Pe()},onIdle:()=>{Se()},onActive:()=>{de()},onMessage:re.current,start:q,reset:fe,activate:Re,pause:he,resume:ve}):s.current=null},[G,ge,we,xe,ke,me,re,q,fe,he,ve]),U(()=>{P(),H(!0),B.current||(A.current=!0,v.current=!0,y.current=0),!x&&(o?q():_())},[x,o,B]),U(()=>{if(!B.current){let i=[...new Set([...r,...u]).values()];if(H(),ce.current=i,ue.current=n,Le.current=u,x)return;o?q():_()}},[n,JSON.stringify(r),JSON.stringify(u),B,x,o]),U(()=>{if(B.current)B.current=!1;else{if(C.current=t,x)return;v.current&&(me.current(),s.current&&s.current.active()),q()}},[t,s,x,B,v]),{message:et,start:q,reset:fe,activate:Re,pause:he,resume:ve,isIdle:tt,isPrompted:rt,isLeader:nt,getTabId:ot,getRemainingTime:Oe,getElapsedTime:it,getTotalElapsedTime:Ce,getLastIdleTime:st,getLastActiveTime:at,getTotalIdleTime:De,getTotalActiveTime:lt}}import kt,{createContext as xt,useContext as Mt}from"react";var le=xt(null);function Pt(t){let e=$(t);return kt.createElement(le.Provider,{value:e},t.children)}var St=le.Consumer;function At(){return Mt(le)}export{be as DEFAULT_EVENTS,St as IdleTimerConsumer,le as IdleTimerContext,Pt as IdleTimerProvider,wt as createMocks,$ as useIdleTimer,At as useIdleTimerContext,bt as withIdleTimer,gt as workerTimers};
var ct=Object.create,Ie=Object.defineProperty;var mt=Object.getOwnPropertyDescriptor;var dt=Object.getOwnPropertyNames;var pt=Object.getPrototypeOf,ft=Object.prototype.hasOwnProperty;var ht=t=>Ie(t,"__esModule",{value:!0});var vt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Tt=(t,e,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of dt(e))!ft.call(t,r)&&r!=="default"&&Ie(t,r,{get:()=>e[r],enumerable:!(n=mt(e,r))||n.enumerable});return t},It=t=>Tt(ht(Ie(t!=null?ct(pt(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var Ue=vt((ie,Fe)=>{(function(t,e){typeof ie=="object"&&typeof Fe!="undefined"?e(ie):typeof define=="function"&&define.amd?define(["exports"],e):(t=typeof globalThis!="undefined"?globalThis:t||self,e(t.fastUniqueNumbers={}))})(ie,function(t){"use strict";var e=function(p){return function(h){var o=p(h);return h.add(o),o}},n=function(p){return function(h,o){return p.set(h,o),o}},r=Number.MAX_SAFE_INTEGER===void 0?9007199254740991:Number.MAX_SAFE_INTEGER,a=536870912,u=a*2,b=function(p,h){return function(o){var x=h.get(o),M=x===void 0?o.size:x<u?x+1:0;if(!o.has(M))return p(o,M);if(o.size<a){for(;o.has(M);)M=Math.floor(Math.random()*u);return p(o,M)}if(o.size>r)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;o.has(M);)M=Math.floor(Math.random()*r);return p(o,M)}},W=new WeakMap,ee=n(W),m=b(ee,W),c=e(m);t.addUniqueNumber=c,t.generateUniqueNumber=m,Object.defineProperty(t,"__esModule",{value:!0})})});import Et,{forwardRef as bt}from"react";function gt(t){return bt(function(n,r){let a={...n};!a.onPrompt&&t.prototype.onPrompt&&(a.onPrompt=()=>{t.prototype.onPrompt()}),!a.onIdle&&t.prototype.onIdle&&(a.onIdle=()=>{t.prototype.onIdle()}),!a.onActive&&t.prototype.onActive&&(a.onActive=b=>{t.prototype.onActive(b)}),!a.onAction&&t.prototype.onAction&&(a.onAction=b=>{t.prototype.onAction(b)});let u=$(a);return typeof r=="function"?r(u):r&&(r.current=u),Et.createElement(t,{...n,...u})})}import{useEffect as U,useRef as f,useCallback as I}from"react";var K=It(Ue());var We=t=>t.method!==void 0&&t.method==="call";var Be=t=>t.error===null&&typeof t.id=="number";var Ve=t=>{let e=new Map([[0,()=>{}]]),n=new Map([[0,()=>{}]]),r=new Map,a=new Worker(t);return a.addEventListener("message",({data:m})=>{if(We(m)){let{params:{timerId:c,timerType:d}}=m;if(d==="interval"){let p=e.get(c);if(typeof p=="number"){let h=r.get(p);if(h===void 0||h.timerId!==c||h.timerType!==d)throw new Error("The timer is in an undefined state.")}else if(typeof p!="undefined")p();else throw new Error("The timer is in an undefined state.")}else if(d==="timeout"){let p=n.get(c);if(typeof p=="number"){let h=r.get(p);if(h===void 0||h.timerId!==c||h.timerType!==d)throw new Error("The timer is in an undefined state.")}else if(typeof p!="undefined")p(),n.delete(c);else throw new Error("The timer is in an undefined state.")}}else if(Be(m)){let{id:c}=m,d=r.get(c);if(d===void 0)throw new Error("The timer is in an undefined state.");let{timerId:p,timerType:h}=d;r.delete(c),h==="interval"?e.delete(p):n.delete(p)}else{let{error:{message:c}}=m;throw new Error(c)}}),{clearInterval:m=>{let c=(0,K.generateUniqueNumber)(r);r.set(c,{timerId:m,timerType:"interval"}),e.set(m,c),a.postMessage({id:c,method:"clear",params:{timerId:m,timerType:"interval"}})},clearTimeout:m=>{let c=(0,K.generateUniqueNumber)(r);r.set(c,{timerId:m,timerType:"timeout"}),n.set(m,c),a.postMessage({id:c,method:"clear",params:{timerId:m,timerType:"timeout"}})},setInterval:(m,c)=>{let d=(0,K.generateUniqueNumber)(e);return e.set(d,()=>{m(),typeof e.get(d)=="function"&&a.postMessage({id:null,method:"set",params:{delay:c,now:performance.now(),timerId:d,timerType:"interval"}})}),a.postMessage({id:null,method:"set",params:{delay:c,now:performance.now(),timerId:d,timerType:"interval"}}),d},setTimeout:(m,c)=>{let d=(0,K.generateUniqueNumber)(n);return n.set(d,m),a.postMessage({id:null,method:"set",params:{delay:c,now:performance.now(),timerId:d,timerType:"timeout"}}),d}}};var Q=null,He=(t,e)=>()=>{if(Q!==null)return Q;let n=new Blob([e],{type:"application/javascript; charset=utf-8"}),r=URL.createObjectURL(n);return Q=t(r),Q.setTimeout(()=>URL.revokeObjectURL(r),0),Q};var Ge=`(()=>{"use strict";const e=new Map,t=new Map,r=(e,t)=>{let r,o;const i=performance.now();r=i,o=e-Math.max(0,i-t);return{expected:r+o,remainingDelay:o}},o=(e,t,r,i)=>{const s=performance.now();s>r?postMessage({id:null,method:"call",params:{timerId:t,timerType:i}}):e.set(t,setTimeout(o,r-s,e,t,r,i))};addEventListener("message",(i=>{let{data:s}=i;try{if("clear"===s.method){const{id:r,params:{timerId:o,timerType:i}}=s;if("interval"===i)(t=>{const r=e.get(t);if(void 0===r)throw new Error('There is no interval scheduled with the given id "'.concat(t,'".'));clearTimeout(r),e.delete(t)})(o),postMessage({error:null,id:r});else{if("timeout"!==i)throw new Error('The given type "'.concat(i,'" is not supported'));(e=>{const r=t.get(e);if(void 0===r)throw new Error('There is no timeout scheduled with the given id "'.concat(e,'".'));clearTimeout(r),t.delete(e)})(o),postMessage({error:null,id:r})}}else{if("set"!==s.method)throw new Error('The given method "'.concat(s.method,'" is not supported'));{const{params:{delay:i,now:n,timerId:a,timerType:d}}=s;if("interval"===d)((t,i,s)=>{const{expected:n,remainingDelay:a}=r(t,s);e.set(i,setTimeout(o,a,e,i,n,"interval"))})(i,a,n);else{if("timeout"!==d)throw new Error('The given type "'.concat(d,'" is not supported'));((e,i,s)=>{const{expected:n,remainingDelay:a}=r(e,s);t.set(i,setTimeout(o,a,t,i,n,"timeout"))})(i,a,n)}}}}catch(e){postMessage({error:{message:e.message},id:s.id,result:null})}}))})();`;var se=He(Ve,Ge),qe=t=>se().clearInterval(t),je=t=>se().clearTimeout(t),Ye=(t,e)=>se().setInterval(t,e),Je=(t,e)=>se().setTimeout(t,e);var w=(typeof window=="undefined"?"undefined":typeof window)=="object";var T={setTimeout:w?setTimeout.bind(window):setTimeout,clearTimeout:w?clearTimeout.bind(window):clearTimeout,setInterval:w?setInterval.bind(window):setInterval,clearInterval:w?clearInterval.bind(window):clearInterval},Z={setTimeout:Je,clearTimeout:je,setInterval:Ye,clearInterval:qe};function wt(){T.setTimeout=setTimeout,T.clearTimeout=clearTimeout,T.setInterval=setInterval,T.clearInterval=clearInterval,Z.setTimeout=setTimeout,Z.clearTimeout=clearTimeout,Z.setInterval=setInterval,Z.clearInterval=clearInterval}function ze(t){T.setTimeout=t.setTimeout,T.clearTimeout=t.clearTimeout,T.setInterval=t.setInterval,T.clearInterval=t.clearInterval}var Y={},Xe=class{constructor(e){this.closed=!1;this.mc=new MessageChannel;this.name=e,Y[e]=Y[e]||[],Y[e].push(this),this.mc.port1.start(),this.mc.port2.start(),this.onStorage=this.onStorage.bind(this),window.addEventListener("storage",this.onStorage)}onStorage(e){if(e.storageArea!==window.localStorage||e.key.substring(0,this.name.length)!==this.name||e.newValue===null)return;let n=JSON.parse(e.newValue);this.mc.port2.postMessage(n)}postMessage(e){if(this.closed)throw new Error("InvalidStateError");let n=JSON.stringify(e),r=`${this.name}:${String(Date.now())}${String(Math.random())}`;window.localStorage.setItem(r,n),T.setTimeout(()=>{window.localStorage.removeItem(r)},500),Y[this.name].forEach(a=>{a!==this&&a.mc.port2.postMessage(JSON.parse(n))})}close(){if(this.closed)return;this.closed=!0,this.mc.port1.close(),this.mc.port2.close(),window.removeEventListener("storage",this.onStorage);let e=Y[this.name].indexOf(this);Y[this.name].splice(e,1)}get onmessage(){return this.mc.port1.onmessage}set onmessage(e){this.mc.port1.onmessage=e}get onmessageerror(){return this.mc.port1.onmessageerror}set onmessageerror(e){this.mc.port1.onmessageerror=e}addEventListener(e,n){return this.mc.port1.addEventListener(e,n)}removeEventListener(e,n){return this.mc.port1.removeEventListener(e,n)}dispatchEvent(e){return this.mc.port1.dispatchEvent(e)}},$e=typeof window=="undefined"?void 0:typeof window.BroadcastChannel=="function"?window.BroadcastChannel:Xe;function Ke(t=0){return new Promise(e=>T.setTimeout(e,t))}function ae(){return Math.random().toString(36).substring(2)}var l;(function(o){o[o.APPLY=0]="APPLY",o[o.TELL=1]="TELL",o[o.CLOSE=2]="CLOSE",o[o.REGISTER=3]="REGISTER",o[o.DEREGISTER=4]="DEREGISTER",o[o.IDLE=5]="IDLE",o[o.ACTIVE=6]="ACTIVE",o[o.PROMPT=7]="PROMPT",o[o.START=8]="START",o[o.RESET=9]="RESET",o[o.ACTIVATE=10]="ACTIVATE",o[o.PAUSE=11]="PAUSE",o[o.RESUME=12]="RESUME",o[o.MESSAGE=13]="MESSAGE"})(l||(l={}));var Ee=class{constructor(e,n){this.token=ae();this.isLeader=!1;this.isDead=!1;this.isApplying=!1;this.reApply=!1;this.intervals=[];this.listeners=[];this.channel=e,this.options=n,this.apply=this.apply.bind(this),this.awaitLeadership=this.awaitLeadership.bind(this),this.sendAction=this.sendAction.bind(this)}async apply(){if(this.isLeader||this.isDead)return!1;if(this.isApplying)return this.reApply=!0,!1;this.isApplying=!0;let e=!1,n=r=>{let{token:a,action:u}=r.data;a!==this.token&&(u===l.APPLY&&a>this.token&&(e=!0),u===l.TELL&&(e=!0))};this.channel.addEventListener("message",n);try{return this.sendAction(l.APPLY),await Ke(this.options.responseTime),this.channel.removeEventListener("message",n),this.isApplying=!1,e?this.reApply?this.apply():!1:(this.assumeLead(),!0)}catch{return!1}}awaitLeadership(){if(this.isLeader)return Promise.resolve();let e=!1,n=null;return new Promise(r=>{let a=()=>{if(e)return;e=!0,T.clearInterval(n);let b=this.intervals.indexOf(n);this.intervals.splice(b,1),this.channel.removeEventListener("message",u),r()};n=T.setInterval(()=>{this.apply().then(()=>{this.isLeader&&a()})},this.options.fallbackInterval),this.intervals.push(n);let u=b=>{let{action:W}=b.data;W===l.CLOSE&&this.apply().then(()=>{this.isLeader&&a()})};this.channel.addEventListener("message",u)})}sendAction(e){this.channel.postMessage({action:e,token:this.token})}assumeLead(){this.isLeader=!0;let e=n=>{let{action:r}=n.data;r===l.APPLY&&this.sendAction(l.TELL)};return this.channel.addEventListener("message",e),this.listeners.push(e),this.sendAction(l.TELL)}waitForLeadership(){return this.deferred?this.deferred:(this.deferred=this.awaitLeadership(),this.deferred)}close(){this.isDead||(this.isDead=!0,this.isLeader=!1,this.sendAction(l.CLOSE),this.listeners.forEach(e=>this.channel.removeEventListener("message",e)),this.intervals.forEach(e=>T.clearInterval(e)))}};var k;(function(r){r[r.PROMPTED=0]="PROMPTED",r[r.ACTIVE=1]="ACTIVE",r[r.IDLE=2]="IDLE"})(k||(k={}));var be=class{constructor(e){this.token=ae();this.registry=new Map;this.allIdle=!1;let{channelName:n}=e;if(this.options=e,this.channel=new $e(n),this.registry.set(this.token,1),e.leaderElection){let r={fallbackInterval:2e3,responseTime:100};this.elector=new Ee(this.channel,r),this.elector.waitForLeadership()}this.channel.addEventListener("message",r=>{let{action:a,token:u,data:b}=r.data;switch(a){case l.REGISTER:this.registry.set(u,2);break;case l.DEREGISTER:this.registry.delete(u);break;case l.IDLE:this.idle(u);break;case l.ACTIVE:this.active(u);break;case l.PROMPT:this.prompt(u);break;case l.START:this.start(u);break;case l.RESET:this.reset(u);break;case l.ACTIVATE:this.activate(u);break;case l.PAUSE:this.pause(u);break;case l.RESUME:this.resume(u);break;case l.MESSAGE:this.options.onMessage(b);break}}),this.send(l.REGISTER)}get isLeader(){if(!this.elector)throw new Error('\u274C Leader election is not enabled. To Enable it set the "leaderElection" property to true.');return this.elector.isLeader}prompt(e=this.token){this.registry.set(e,0);let n=[...this.registry.values()].every(r=>r===0);e===this.token&&this.send(l.PROMPT),n&&this.options.onPrompt()}idle(e=this.token){this.registry.set(e,2);let n=[...this.registry.values()].every(r=>r===2);e===this.token&&this.send(l.IDLE),!this.allIdle&&n&&(this.allIdle=!0,this.options.onIdle())}active(e=this.token){this.allIdle=!1,this.registry.set(e,1);let n=[...this.registry.values()].some(r=>r===1);e===this.token&&this.send(l.ACTIVE),n&&this.options.onActive()}start(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(l.START):this.options.start(!0)}reset(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(l.RESET):this.options.reset(!0)}activate(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(l.ACTIVATE):this.options.activate(!0)}pause(e=this.token){e===this.token?this.send(l.PAUSE):this.options.pause(!0)}resume(e=this.token){e===this.token?this.send(l.RESUME):this.options.resume(!0)}message(e){try{this.channel.postMessage({action:l.MESSAGE,token:this.token,data:e})}catch{}}send(e){try{this.channel.postMessage({action:e,token:this.token})}catch{}}close(){this.options.leaderElection&&this.elector.close(),this.send(l.DEREGISTER),this.channel.close()}};var Qe=w?document:null,ge=["mousemove","keydown","wheel","DOMMouseScroll","mousewheel","mousedown","touchstart","touchmove","MSPointerDown","MSPointerMove","visibilitychange"];import{useRef as yt,useEffect as Lt}from"react";function F(t){let e=yt(t);return Lt(()=>{e.current=t},[t]),e}function Ze(t,e){let n;function r(...a){n&&clearTimeout(n),n=setTimeout(()=>{t(...a),n=null},e)}return r.cancel=function(){clearTimeout(n)},r}function le(t,e){let n=0;return function(...r){let a=new Date().getTime();if(!(a-n<e))return n=a,t(...r)}}var E=()=>w?performance.now():Date.now();function $({timeout:t=1e3*60*20,promptTimeout:e=0,element:n=Qe,events:r=ge,timers:a=void 0,immediateEvents:u=[],onPrompt:b=()=>{},onIdle:W=()=>{},onActive:ee=()=>{},onAction:m=()=>{},onMessage:c=()=>{},debounce:d=0,throttle:p=0,eventsThrottle:h=200,startOnMount:o=!0,startManually:x=!1,stopOnIdle:M=!1,crossTab:G=!1,name:we="idle-timer",syncTimers:J=0,leaderElection:ye=!1}={}){let q=f(E()),Le=f(Date.now()),te=f(E()),D=f(null),N=f(null),z=f(0),v=f(!0),A=f(!1),B=f(!0),X=f(!1),g=f(!1),y=f(0),R=f(0),O=f(null),s=f(null),C=F(t),re=F(e),et=F(M),ke=f(u),ce=f(n),me=f([...new Set([...r,...u]).values()]),xe=F(W),de=F(ee),Me=F(b),ne=F(c),L=f();U(()=>{L.current&&L.current.cancel&&L.current.cancel(),d>0?L.current=Ze(m,d):p>0?L.current=le(m,p):L.current=m},[m,p,d]);let Pe=f();U(()=>{G&&J&&(Pe.current=le(()=>{s.current.active()},J))},[G,J]);let P=()=>{O.current!==null&&(T.clearTimeout(O.current),O.current=null)},V=(i,S=!0)=>{P(),O.current=T.setTimeout(fe,i||C.current),S&&(N.current=E())},Se=i=>{y.current=0,R.current=E(),g.current=!0,V(re.current,!1),Me.current(i)},Ae=()=>{P(),v.current=!0,D.current=E(),et.current?H():g.current&&(R.current=0,g.current=!1),xe.current()},pe=i=>{P(),g.current=!1,R.current=0,v.current=!1,z.current+=E()-D.current,_(),V(),de.current(i)},fe=i=>{if(!v.current){if(L.current.cancel&&L.current.cancel(),re.current>0&&!g.current){s.current?s.current.prompt():Se(i);return}s.current?s.current.idle():Ae();return}s.current?s.current.active():pe(i)},Re=i=>{if(L.current(i),g.current)return;if(P(),!v.current&&ke.current.includes(i.type)){fe(i);return}let S=E()-N.current;if(v.current&&!M||!v.current&&S>C.current){fe(i);return}A.current=!1,y.current=0,R.current=0,V(),G&&J&&Pe.current()},oe=f();U(()=>{let i=X.current;i&&H(),h>0?oe.current=le(Re,h):oe.current=Re,i&&_()},[h,G,J]);let _=()=>{!w||X.current||(me.current.forEach(i=>{ce.current.addEventListener(i,oe.current,{capture:!0,passive:!0})}),X.current=!0)},H=(i=!1)=>{!w||(X.current||i)&&(me.current.forEach(S=>{ce.current.removeEventListener(S,oe.current,{capture:!0})}),X.current=!1)},j=I(i=>{P(),_(),v.current=!1,g.current=!1,A.current=!1,y.current=0,R.current=0,s.current&&!i&&s.current.start(),V()},[O,v,C,s]),he=I(i=>{P(),_(),v.current=!1,g.current=!1,A.current=!1,y.current=0,R.current=0,q.current=E(),te.current=E(),s.current&&!i&&s.current.reset(),x||V()},[O,v,C,x,s]),Oe=I(i=>{P(),_(),(v.current||g.current)&&pe(),v.current=!1,g.current=!1,A.current=!1,y.current=0,R.current=0,te.current=E(),s.current&&!i&&s.current.activate(),V()},[O,v,C,s]),ve=I((i=!1)=>A.current?!1:(y.current=Ce(),A.current=!0,H(),P(),s.current&&!i&&s.current.pause(),!0),[O,s]),Te=I((i=!1)=>A.current?(A.current=!1,g.current||_(),v.current||V(y.current),R.current&&(R.current=E()),s.current&&!i&&s.current.resume(),!0):!1,[O,C,y,s]),tt=I((i,S)=>{s.current?(S&&ne.current(i),s.current.message(i)):S&&ne.current(i)},[c]),rt=I(()=>v.current,[v]),nt=I(()=>g.current,[g]),ot=I(()=>{if(!s.current)throw new Error('\u274C Cross Tab feature is not enabled. To enable it set the "crossTab" property to true.');return s.current.isLeader},[s]),it=I(()=>{if(!s.current)throw new Error('\u274C Cross Tab feature is not enabled. To enable it set the "crossTab" property to true.');return s.current.token},[s]),Ce=I(()=>{if(A.current)return y.current;let i=y.current?y.current:re.current+C.current,S=N.current?E()-N.current:0,_e=Math.ceil(i-S);return _e<0?0:Math.abs(_e)},[C,re,g,y,N]),st=I(()=>Math.round(E()-te.current),[te]),De=I(()=>Math.round(E()-q.current),[q]),at=I(()=>D.current?new Date(Le.current-q.current+D.current):null,[D]),lt=I(()=>N.current?new Date(Le.current-q.current+N.current):null,[N]),Ne=I(()=>v.current?Math.round(E()-D.current+z.current):Math.round(z.current),[D,z]),ut=I(()=>{let i=Math.round(De()-Ne());return i>=0?i:0},[q,D,z]);return U(()=>{if(d>0&&p>0)throw new Error("\u274C onAction can either be throttled or debounced, not both.");a&&ze(a);let i=()=>{s.current&&s.current.close(),L.current.cancel&&L.current.cancel(),P(),H(!0)};return w&&window.addEventListener("beforeunload",i),()=>{w&&window.removeEventListener("beforeunload",i),s.current&&s.current.close(),L.current.cancel&&L.current.cancel(),P(),H(!0)}},[]),U(()=>{s.current&&s.current.close(),G?s.current=new be({channelName:we,leaderElection:ye,onPrompt:()=>{Se()},onIdle:()=>{Ae()},onActive:()=>{pe()},onMessage:ne.current,start:j,reset:he,activate:Oe,pause:ve,resume:Te}):s.current=null},[G,we,ye,Me,xe,de,ne,j,he,ve,Te]),U(()=>{P(),H(!0),B.current||(A.current=!0,v.current=!0,y.current=0),!x&&(o?j():_())},[x,o,B]),U(()=>{if(!B.current){let i=[...new Set([...r,...u]).values()];if(H(),me.current=i,ce.current=n,ke.current=u,x)return;o?j():_()}},[n,JSON.stringify(r),JSON.stringify(u),B,x,o]),U(()=>{if(B.current)B.current=!1;else{if(C.current=t,x)return;v.current&&(de.current(),s.current&&s.current.active()),j()}},[t,s,x,B,v]),{message:tt,start:j,reset:he,activate:Oe,pause:ve,resume:Te,isIdle:rt,isPrompted:nt,isLeader:ot,getTabId:it,getRemainingTime:Ce,getElapsedTime:st,getTotalElapsedTime:De,getLastIdleTime:at,getLastActiveTime:lt,getTotalIdleTime:Ne,getTotalActiveTime:ut}}import kt,{createContext as xt,useContext as Mt}from"react";var ue=xt(null);function Pt(t){let e=$(t);return kt.createElement(ue.Provider,{value:e},t.children)}var St=ue.Consumer;function At(){return Mt(ue)}export{ge as DEFAULT_EVENTS,St as IdleTimerConsumer,ue as IdleTimerContext,Pt as IdleTimerProvider,wt as createMocks,$ as useIdleTimer,At as useIdleTimerContext,gt as withIdleTimer,Z as workerTimers};
{
"name": "react-idle-timer",
"version": "5.4.0",
"version": "5.4.1",
"description": "Activity detection for React.js",

@@ -5,0 +5,0 @@ "main": "./dist/index.cjs.js",