"use strict";(self.webpackChunkui=self.webpackChunkui||[]).push([[31],{49(e,n,t){t.d(n,{a:()=>c,b:()=>l});var r=t(12),o="undefined"!=typeof window?r.useLayoutEffect:r.useEffect;function a(e,n,t,a){const c=(0,r.useRef)(n);o((()=>{c.current=n}),[n]),(0,r.useEffect)((()=>{const n=(null==t?void 0:t.current)??window;if(!n||!n.addEventListener)return;const r=e=>{c.current(e)};return n.addEventListener(e,r,a),()=>{n.removeEventListener(e,r,a)}}),[e,t,a])}function c({countStart:e,countStop:n=0,intervalMs:t=1e3,isIncrement:a=!1}){const{count:c,increment:s,decrement:u,reset:l}=function(e){const[n,t]=(0,r.useState)(e??0);return{count:n,increment:(0,r.useCallback)((()=>{t((e=>e+1))}),[]),decrement:(0,r.useCallback)((()=>{t((e=>e-1))}),[]),reset:(0,r.useCallback)((()=>{t(e??0)}),[e]),setCount:t}}(e),{value:i,setTrue:f,setFalse:d}=function(e=!1){if("boolean"!=typeof e)throw new Error("defaultValue must be `true` or `false`");const[n,t]=(0,r.useState)(e),o=(0,r.useCallback)((()=>{t(!0)}),[]),a=(0,r.useCallback)((()=>{t(!1)}),[]),c=(0,r.useCallback)((()=>{t((e=>!e))}),[]);return{value:n,setValue:t,setTrue:o,setFalse:a,toggle:c}}(!1),w=(0,r.useCallback)((()=>{d(),l()}),[d,l]);return function(e,n){const t=(0,r.useRef)(e);o((()=>{t.current=e}),[e]),(0,r.useEffect)((()=>{if(null===n)return;const e=setInterval((()=>{t.current()}),n);return()=>{clearInterval(e)}}),[n])}((0,r.useCallback)((()=>{c!==n?a?s():u():d()}),[c,n,u,s,a,d]),i?t:null),[c,{startCountdown:f,stopCountdown:d,resetCountdown:w}]}function s(e){const n=(0,r.useRef)((()=>{throw new Error("Cannot call an event handler while rendering.")}));return o((()=>{n.current=e}),[e]),(0,r.useCallback)(((...e)=>{var t;return null==(t=n.current)?void 0:t.call(n,...e)}),[n])}var u="undefined"==typeof window;function l(e,n,t={}){const{initializeWithValue:o=!0}=t,c=(0,r.useCallback)((e=>t.serializer?t.serializer(e):JSON.stringify(e)),[t]),l=(0,r.useCallback)((e=>{if(t.deserializer)return t.deserializer(e);if("undefined"===e)return;const r=n instanceof Function?n():n;let o;try{o=JSON.parse(e)}catch(e){return console.error("Error parsing JSON:",e),r}return o}),[t,n]),i=(0,r.useCallback)((()=>{const t=n instanceof Function?n():n;if(u)return t;try{const n=window.localStorage.getItem(e);return n?l(n):t}catch(n){return console.warn(`Error reading localStorage key “${e}”:`,n),t}}),[n,e,l]),[f,d]=(0,r.useState)((()=>o?i():n instanceof Function?n():n)),w=s((n=>{u&&console.warn(`Tried setting localStorage key “${e}” even though environment is not a client`);try{const t=n instanceof Function?n(i()):n;window.localStorage.setItem(e,c(t)),d(t),window.dispatchEvent(new StorageEvent("local-storage",{key:e}))}catch(n){console.warn(`Error setting localStorage key “${e}”:`,n)}})),g=s((()=>{u&&console.warn(`Tried removing localStorage key “${e}” even though environment is not a client`);const t=n instanceof Function?n():n;window.localStorage.removeItem(e),d(t),window.dispatchEvent(new StorageEvent("local-storage",{key:e}))}));(0,r.useEffect)((()=>{d(i())}),[e]);const k=(0,r.useCallback)((n=>{n.key&&n.key!==e||d(i())}),[e,i]);return a("storage",k),a("local-storage",k),[f,w,g]}}}]);