1 line
19 KiB
JavaScript
1 line
19 KiB
JavaScript
"use strict";exports.id=753,exports.ids=[753],exports.modules={90753:(e,t,r)=>{let n,s,i,o;r.d(t,{Yp:()=>O});var a=r(17577);r(10326);var u=Object.create,c=Object.defineProperty,l=Object.getOwnPropertyDescriptor,h=Object.getOwnPropertyNames,d=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,p=(n=(e,t)=>{!function(n,s){"object"==typeof e&&"u">typeof t?s(e):"function"==typeof define&&r.amdO?define(["exports"],s):s((n="u">typeof globalThis?globalThis:n||self).fastUniqueNumbers={})}(e,function(e){var t,r=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,n=new WeakMap,s=(t=function(e,t){return n.set(e,t),t},function(e){var s=n.get(e),i=void 0===s?e.size:s<1073741824?s+1:0;if(!e.has(i))return t(e,i);if(e.size<536870912){for(;e.has(i);)i=Math.floor(1073741824*Math.random());return t(e,i)}if(e.size>r)throw Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;e.has(i);)i=Math.floor(Math.random()*r);return t(e,i)});e.addUniqueNumber=function(e){var t=s(e);return e.add(t),t},e.generateUniqueNumber=s})},()=>(s||n((s={exports:{}}).exports,s),s.exports));a.Component;var f=(o=null!=(i=p())?u(d(i)):{},((e,t,r,n)=>{if(t&&"object"==typeof t||"function"==typeof t)for(let r of h(t))m.call(e,r)||void 0===r||c(e,r,{get:()=>t[r],enumerable:!(n=l(t,r))||n.enumerable});return e})(i&&i.__esModule?o:c(o,"default",{value:i,enumerable:!0}),i)),v=e=>void 0!==e.method&&"call"===e.method,g=e=>null===e.error&&"number"==typeof e.id,w=(((e,t)=>{let r=null;return()=>{if(null!==r)return r;let n=new Blob([t],{type:"application/javascript; charset=utf-8"}),s=URL.createObjectURL(n);return r=e(s),setTimeout(()=>URL.revokeObjectURL(s)),r}})(e=>{let t=new Map([[0,()=>{}]]),r=new Map([[0,()=>{}]]),n=new Map,s=new Worker(e);return s.addEventListener("message",({data:e})=>{if(v(e)){let{params:{timerId:s,timerType:i}}=e;if("interval"===i){let e=t.get(s);if("number"==typeof e){let t=n.get(e);if(void 0===t||t.timerId!==s||t.timerType!==i)throw Error("The timer is in an undefined state.")}else if("u">typeof e)e();else throw Error("The timer is in an undefined state.")}else if("timeout"===i){let e=r.get(s);if("number"==typeof e){let t=n.get(e);if(void 0===t||t.timerId!==s||t.timerType!==i)throw Error("The timer is in an undefined state.")}else if("u">typeof e)e(),r.delete(s);else throw Error("The timer is in an undefined state.")}}else if(g(e)){let{id:s}=e,i=n.get(s);if(void 0===i)throw Error("The timer is in an undefined state.");let{timerId:o,timerType:a}=i;n.delete(s),"interval"===a?t.delete(o):r.delete(o)}else{let{error:{message:t}}=e;throw Error(t)}}),{clearInterval:e=>{let r=(0,f.generateUniqueNumber)(n);n.set(r,{timerId:e,timerType:"interval"}),t.set(e,r),s.postMessage({id:r,method:"clear",params:{timerId:e,timerType:"interval"}})},clearTimeout:e=>{let t=(0,f.generateUniqueNumber)(n);n.set(t,{timerId:e,timerType:"timeout"}),r.set(e,t),s.postMessage({id:t,method:"clear",params:{timerId:e,timerType:"timeout"}})},setInterval:(e,r)=>{let n=(0,f.generateUniqueNumber)(t);return t.set(n,()=>{e(),"function"==typeof t.get(n)&&s.postMessage({id:null,method:"set",params:{delay:r,now:performance.now(),timerId:n,timerType:"interval"}})}),s.postMessage({id:null,method:"set",params:{delay:r,now:performance.now(),timerId:n,timerType:"interval"}}),n},setTimeout:(e,t)=>{let n=(0,f.generateUniqueNumber)(r);return r.set(n,e),s.postMessage({id:null,method:"set",params:{delay:t,now:performance.now(),timerId:n,timerType:"timeout"}}),n}}},'(()=>{"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})}}))})();'),(typeof window>"u"?"undefined":typeof window)=="object"),y={setTimeout:w?setTimeout.bind(window):setTimeout,clearTimeout:w?clearTimeout.bind(window):clearTimeout,setInterval:w?setInterval.bind(window):setInterval,clearInterval:w?clearInterval.bind(window):clearInterval},b={},T=class{name;closed=!1;mc=new MessageChannel;constructor(e){this.name=e,b[e]=b[e]||[],b[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||null===e.newValue)return;let t=JSON.parse(e.newValue);this.mc.port2.postMessage(t)}postMessage(e){if(this.closed)throw Error("InvalidStateError");let t=JSON.stringify(e),r=`${this.name}:${String(Date.now())}${String(Math.random())}`;window.localStorage.setItem(r,t),y.setTimeout(()=>{window.localStorage.removeItem(r)},500),b[this.name].forEach(e=>{e!==this&&e.mc.port2.postMessage(JSON.parse(t))})}close(){if(this.closed)return;this.closed=!0,this.mc.port1.close(),this.mc.port2.close(),window.removeEventListener("storage",this.onStorage);let e=b[this.name].indexOf(this);b[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,t){return this.mc.port1.addEventListener(e,t)}removeEventListener(e,t){return this.mc.port1.removeEventListener(e,t)}dispatchEvent(e){return this.mc.port1.dispatchEvent(e)}},E=typeof window>"u"?void 0:"function"==typeof window.BroadcastChannel?window.BroadcastChannel:T;function k(){return Math.random().toString(36).substring(2)}var I=class{options;channel;token=k();isLeader=!1;isDead=!1;isApplying=!1;reApply=!1;intervals=[];listeners=[];deferred;constructor(e,t){this.channel=e,this.options=t,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,t=t=>{let{token:r,action:n}=t.data;r!==this.token&&(0===n&&r>this.token&&(e=!0),1===n&&(e=!0))};this.channel.addEventListener("message",t);try{return this.sendAction(0),await function(e=0){return new Promise(t=>y.setTimeout(t,e))}(this.options.responseTime),this.channel.removeEventListener("message",t),this.isApplying=!1,e?!!this.reApply&&this.apply():(this.assumeLead(),!0)}catch{return!1}}awaitLeadership(){if(this.isLeader)return Promise.resolve();let e=!1,t=null;return new Promise(r=>{let n=()=>{if(e)return;e=!0;try{y.clearInterval(t)}catch{}let n=this.intervals.indexOf(t);n>=0&&this.intervals.splice(n,1),this.channel.removeEventListener("message",s),r()};t=y.setInterval(()=>{this.apply().then(()=>{this.isLeader&&n()})},this.options.fallbackInterval),this.intervals.push(t);let s=e=>{let{action:t}=e.data;2===t&&this.apply().then(()=>{this.isLeader&&n()})};this.channel.addEventListener("message",s)})}sendAction(e){this.channel.postMessage({action:e,token:this.token})}assumeLead(){this.isLeader=!0;let e=e=>{let{action:t}=e.data;0===t&&this.sendAction(1)};return this.channel.addEventListener("message",e),this.listeners.push(e),this.sendAction(1)}waitForLeadership(){return this.deferred||(this.deferred=this.awaitLeadership()),this.deferred}close(){if(!this.isDead){this.isDead=!0,this.isLeader=!1,this.sendAction(2);try{this.listeners.forEach(e=>this.channel.removeEventListener("message",e)),this.intervals.forEach(e=>y.clearInterval(e))}catch{}}}},M=class{channel;options;elector;token=k();registry=new Map;allIdle=!1;isLastActive=!1;constructor(e){let{channelName:t}=e;this.options=e,this.channel=new E(t),this.registry.set(this.token,1),e.leaderElection&&(this.elector=new I(this.channel,{fallbackInterval:2e3,responseTime:100}),this.elector.waitForLeadership()),this.channel.addEventListener("message",e=>{let{action:t,token:r,data:n}=e.data;switch(t){case 3:this.registry.set(r,2);break;case 4:this.registry.delete(r);break;case 5:this.idle(r);break;case 6:this.active(r);break;case 7:this.prompt(r);break;case 8:this.start(r);break;case 9:this.reset(r);break;case 10:this.activate(r);break;case 11:this.pause(r);break;case 12:this.resume(r);break;case 13:this.options.onMessage(n)}}),this.send(3)}get isLeader(){if(!this.elector)throw Error('❌ 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 t=[...this.registry.values()].every(e=>0===e);e===this.token&&this.send(7),t&&this.options.onPrompt()}idle(e=this.token){this.registry.set(e,2);let t=[...this.registry.values()].every(e=>2===e);e===this.token&&this.send(5),!this.allIdle&&t&&(this.allIdle=!0,this.options.onIdle())}active(e=this.token){this.allIdle=!1,this.registry.set(e,1);let t=[...this.registry.values()].some(e=>1===e);e===this.token&&this.send(6),t&&this.options.onActive(),this.isLastActive=e===this.token}start(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(8):this.options.start(!0),this.isLastActive=e===this.token}reset(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(9):this.options.reset(!0),this.isLastActive=e===this.token}activate(e=this.token){this.allIdle=!1,this.registry.set(e,1),e===this.token?this.send(10):this.options.activate(!0),this.isLastActive=e===this.token}pause(e=this.token){e===this.token?this.send(11):this.options.pause(!0)}resume(e=this.token){e===this.token?this.send(12):this.options.resume(!0)}message(e){try{this.channel.postMessage({action:13,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(4),this.channel.close()}},L=w?document:null,R=["mousemove","keydown","wheel","DOMMouseScroll","mousewheel","mousedown","touchstart","touchmove","MSPointerDown","MSPointerMove","visibilitychange","focus"];function A(e,t){let r=0;return function(...n){let s=new Date().getTime();if(!(s-r<t))return r=s,e(...n)}}var C=()=>Date.now();function O({timeout:e=12e5,promptTimeout:t=0,promptBeforeIdle:r=0,element:n=L,events:s=R,timers:i,immediateEvents:o=[],onPresenceChange:u=()=>{},onPrompt:c=()=>{},onIdle:l=()=>{},onActive:h=()=>{},onAction:d=()=>{},onMessage:m=()=>{},debounce:p=0,throttle:f=0,eventsThrottle:v=200,startOnMount:g=!0,startManually:b=!1,stopOnIdle:T=!1,crossTab:E=!1,name:k="idle-timer",syncTimers:I=0,leaderElection:O=!1,disabled:S=!1}={}){let N=(0,a.useRef)(C()),P=(0,a.useRef)(C()),x=(0,a.useRef)(null),D=(0,a.useRef)(null),j=(0,a.useRef)(0),U=(0,a.useRef)(0),B=(0,a.useRef)(0),q=(0,a.useRef)(0),_=(0,a.useRef)(!1),J=(0,a.useRef)(!1),F=(0,a.useRef)(!1),$=(0,a.useRef)(!0),z=(0,a.useRef)(!1),G=(0,a.useRef)(null),V=(0,a.useRef)(null),W=(0,a.useRef)(e),X=(0,a.useRef)(0);(0,a.useEffect)(()=>{if(t&&console.warn("⚠️ IdleTimer -- The `promptTimeout` property has been deprecated in favor of `promptBeforeIdle`. It will be removed in the next major release."),r&&t)throw Error("❌ Both promptTimeout and promptBeforeIdle can not be set. The promptTimeout property will be deprecated in a future version.");if(e>=2147483647)throw Error(`\u274C The value for the timeout property must fit in a 32 bit signed integer, 2147483647.`);if(t>=2147483647)throw Error(`\u274C The value for the promptTimeout property must fit in a 32 bit signed integer, 2147483647.`);if(r>=2147483647)throw Error(`\u274C The value for the promptBeforeIdle property must fit in a 32 bit signed integer, 2147483647.`);if(r>=e)throw Error(`\u274C The value for the promptBeforeIdle property must be less than the timeout property, ${e}.`);if(r?(W.current=e-r,X.current=r):(W.current=e,X.current=t),!$.current){if(b||S)return;_.current&&(en.current(null,eB),V.current&&V.current.active()),ew()}},[e,t,r,b,S]);let Y=(0,a.useRef)(T);(0,a.useEffect)(()=>{Y.current=T},[T]);let H=(0,a.useRef)(o),K=(0,a.useRef)(n),Q=(0,a.useRef)([...new Set([...s,...o]).values()]),Z=(0,a.useRef)(S);(0,a.useEffect)(()=>{Z.current=S,!$.current&&(S?eT():b||ew())},[S]);let ee=(0,a.useRef)(u);(0,a.useEffect)(()=>{ee.current=u},[u]);let et=(0,a.useRef)(c);(0,a.useEffect)(()=>{et.current=c},[c]);let er=(0,a.useRef)(l);(0,a.useEffect)(()=>{er.current=l},[l]);let en=(0,a.useRef)(h);(0,a.useEffect)(()=>{en.current=h},[h]);let es=(0,a.useRef)(d);(0,a.useEffect)(()=>{es.current=d},[d]);let ei=(0,a.useRef)(m);(0,a.useEffect)(()=>{ei.current=m},[m]);let eo=(0,a.useMemo)(()=>{let e=(e,t)=>es.current(e,t);return p>0?function(e,t){let r;function n(...s){r&&clearTimeout(r),r=setTimeout(()=>{e(...s),r=null},t)}return n.cancel=function(){clearTimeout(r)},n}(e,p):f>0?A(e,f):e},[f,p]),ea=(0,a.useRef)();(0,a.useEffect)(()=>{E&&I&&(ea.current=A(()=>{V.current.active()},I))},[E,I]);let eu=()=>{null!==G.current&&(y.clearTimeout(G.current),G.current=null)},ec=(e,t=!0)=>{eu(),G.current=y.setTimeout(em,e||W.current),t&&(D.current=C())},el=e=>{J.current||_.current||(et.current(e,eB),ee.current({type:"active",prompted:!0},eB)),q.current=0,B.current=C(),J.current=!0,ec(X.current,!1)},eh=()=>{eu(),_.current||(er.current(null,eB),ee.current({type:"idle"},eB)),_.current=!0,x.current=C(),Y.current?eg():J.current&&(B.current=0,J.current=!1)},ed=e=>{eu(),(_.current||J.current)&&(en.current(e,eB),ee.current({type:"active",prompted:!1},eB)),J.current=!1,B.current=0,_.current=!1,j.current+=C()-x.current,U.current+=C()-x.current,ev(),ec()},em=e=>{if(!_.current){eo.cancel&&eo.cancel();let t=C()-D.current;if(!(W.current+X.current<t)&&X.current>0&&!J.current){V.current?V.current.prompt():el(e);return}V.current?V.current.idle():eh();return}V.current?V.current.active():ed(e)},ep=e=>{if(g||D.current||(D.current=C(),en.current(null,eB)),eo(e,eB),J.current)return;if(eu(),!_.current&&H.current.includes(e.type)){em(e);return}let t=C()-D.current;if(_.current&&!T||!_.current&&t>=W.current){em(e);return}F.current=!1,q.current=0,B.current=0,ec(),E&&I&&ea.current()},ef=(0,a.useRef)(ep);(0,a.useEffect)(()=>{let e=z.current;e&&eg(),v>0?ef.current=A(ep,v):ef.current=ep,e&&ev()},[v,f,p,es,E,I]);let ev=()=>{w&&K.current&&(z.current||(Q.current.forEach(e=>{K.current.addEventListener(e,ef.current,{capture:!0,passive:!0})}),z.current=!0))},eg=(e=!1)=>{w&&K.current&&(z.current||e)&&(Q.current.forEach(e=>{K.current.removeEventListener(e,ef.current,{capture:!0})}),z.current=!1)},ew=(0,a.useCallback)(e=>!Z.current&&(eu(),ev(),_.current=!1,J.current=!1,F.current=!1,q.current=0,B.current=0,V.current&&!e&&V.current.start(),ec(),!0),[G,_,Z,W,V]),ey=(0,a.useCallback)(e=>!Z.current&&(eu(),ev(),P.current=C(),j.current+=C()-x.current,U.current+=C()-x.current,j.current=0,_.current=!1,J.current=!1,F.current=!1,q.current=0,B.current=0,V.current&&!e&&V.current.reset(),b||ec(),!0),[G,_,W,b,Z,V]),eb=(0,a.useCallback)(e=>!Z.current&&(eu(),ev(),(_.current||J.current)&&ed(),_.current=!1,J.current=!1,F.current=!1,q.current=0,B.current=0,P.current=C(),V.current&&!e&&V.current.activate(),ec(),!0),[G,_,J,Z,W,V]),eT=(0,a.useCallback)((e=!1)=>!Z.current&&!F.current&&(q.current=eC(),F.current=!0,eg(),eu(),V.current&&!e&&V.current.pause(),!0),[G,Z,V]),eE=(0,a.useCallback)((e=!1)=>!Z.current&&!!F.current&&(F.current=!1,J.current||ev(),_.current||ec(q.current),B.current&&(B.current=C()),V.current&&!e&&V.current.resume(),!0),[G,W,Z,q,V]),ek=(0,a.useCallback)((e,t)=>(V.current?(t&&ei.current(e,eB),V.current.message(e)):t&&ei.current(e,eB),!0),[m]),eI=(0,a.useCallback)(()=>_.current,[_]),eM=(0,a.useCallback)(()=>J.current,[J]),eL=(0,a.useCallback)(()=>V.current?V.current.isLeader:null,[V]),eR=(0,a.useCallback)(()=>V.current?V.current.isLastActive:null,[V]),eA=(0,a.useCallback)(()=>V.current?V.current.token:null,[V]),eC=(0,a.useCallback)(()=>{if(F.current)return q.current;let e=Math.floor((q.current?q.current:X.current+W.current)-(D.current?C()-D.current:0));return e<0?0:Math.abs(e)},[W,X,J,q,D]),eO=(0,a.useCallback)(()=>Math.round(C()-P.current),[P]),eS=(0,a.useCallback)(()=>Math.round(C()-N.current),[N]),eN=(0,a.useCallback)(()=>x.current?new Date(x.current):null,[x]),eP=(0,a.useCallback)(()=>D.current?new Date(D.current):null,[D]),ex=(0,a.useCallback)(()=>_.current?Math.round(C()-x.current+j.current):Math.round(j.current),[x,j]),eD=(0,a.useCallback)(()=>_.current?Math.round(C()-x.current+U.current):Math.round(U.current),[x,U]),ej=(0,a.useCallback)(()=>{let e=Math.round(eO()-ex());return e>=0?e:0},[x,j]),eU=(0,a.useCallback)(()=>{let e=Math.round(eS()-eD());return e>=0?e:0},[x,j]);(0,a.useEffect)(()=>{if(p>0&&f>0)throw Error("❌ onAction can either be throttled or debounced, not both.");i&&(y.setTimeout=i.setTimeout,y.clearTimeout=i.clearTimeout,y.setInterval=i.setInterval,y.clearInterval=i.clearInterval);let e=()=>{V.current&&V.current.close(),eo.cancel&&eo.cancel(),eu(),eg(!0)};return w&&window.addEventListener("beforeunload",e),()=>{w&&window.removeEventListener("beforeunload",e),V.current&&V.current.close(),eo.cancel&&eo.cancel(),eu(),eg(!0)}},[]),(0,a.useEffect)(()=>{V.current&&V.current.close(),E?V.current=new M({channelName:k,leaderElection:O,onPrompt:()=>{el()},onIdle:()=>{eh()},onActive:()=>{ed()},onMessage:e=>{ei.current(e,eB)},start:ew,reset:ey,activate:eb,pause:eT,resume:eE}):V.current=null},[E,k,O,et,er,en,ei,ew,ey,eT,eE]),(0,a.useEffect)(()=>{$.current||(eu(),eg(!0)),b||S||(g?ew():ev())},[b,g,S,$]),(0,a.useEffect)(()=>{if(!$.current){let e=[...new Set([...s,...o]).values()];eg(),Q.current=e,K.current=n,H.current=o,b||S||(g?ew():ev())}},[n,JSON.stringify(s),JSON.stringify(o),$,S,b,g]),(0,a.useEffect)(()=>{$.current&&($.current=!1)},[$]);let eB={message:ek,start:ew,reset:ey,activate:eb,pause:eT,resume:eE,isIdle:eI,isPrompted:eM,isLeader:eL,isLastActiveTab:eR,getTabId:eA,getRemainingTime:eC,getElapsedTime:eO,getTotalElapsedTime:eS,getLastIdleTime:eN,getLastActiveTime:eP,getIdleTime:ex,getTotalIdleTime:eD,getActiveTime:ej,getTotalActiveTime:eU,setOnPresenceChange:e=>{u=e,ee.current=e},setOnPrompt:e=>{c=e,et.current=e},setOnIdle:e=>{l=e,er.current=e},setOnActive:e=>{h=e,en.current=e},setOnAction:e=>{d=e,es.current=e},setOnMessage:e=>{m=e,ei.current=e}};return eB}(0,a.createContext)(null).Consumer}}; |