{"version":3,"sources":["../../src/hooks/useSaveDelay.ts"],"sourcesContent":["import { useEffect, useState } from 'react'\n\nexport function useSaveDelay(setNotificationStatus: (isShowing: boolean) => void, delay: number) {\n  const [updateTimer, setUpdateTimer] = useState<NodeJS.Timeout | undefined>(undefined)\n  const [notificationTimer, setNotificationTimer] = useState<NodeJS.Timeout | undefined>(undefined)\n\n  const restartTimer = (onSave: () => void) => {\n    clearTimeout(updateTimer)\n    setUpdateTimer(setTimeout(() => {\n      onSave()\n      setNotificationStatus(true)\n      // Show Saved Notification for fade animation duration\n      clearTimeout(notificationTimer)\n      setNotificationTimer(setTimeout(() => {\n        setNotificationStatus(false)\n        clearTimeout(notificationTimer)\n      }, delay))\n      clearTimeout(updateTimer)\n    }, delay))\n  }\n\n  const clearUpdateTimer = (hasSaved = true) => {\n    clearTimeout(updateTimer)\n    if (hasSaved) {\n      setNotificationStatus(true)\n      clearTimeout(notificationTimer)\n      setNotificationTimer(setTimeout(() => {\n        setNotificationStatus(false)\n        clearTimeout(notificationTimer)\n      }, delay))\n    } else {\n      setNotificationStatus(false)\n    }\n  }\n\n  useEffect(() => {\n    return () => {\n      clearTimeout(updateTimer)\n      clearTimeout(notificationTimer)\n    }\n  }, []) // eslint-disable-line react-hooks/exhaustive-deps\n\n  return { restartTimer, clearUpdateTimer }\n}"],"mappings":";AAAA,SAAS,WAAW,gBAAgB;AAE7B,SAAS,aAAa,uBAAqD,OAAe;AAC/F,QAAM,CAAC,aAAa,cAAc,IAAI,SAAqC,MAAS;AACpF,QAAM,CAAC,mBAAmB,oBAAoB,IAAI,SAAqC,MAAS;AAEhG,QAAM,eAAe,CAAC,WAAuB;AAC3C,iBAAa,WAAW;AACxB,mBAAe,WAAW,MAAM;AAC9B,aAAO;AACP,4BAAsB,IAAI;AAE1B,mBAAa,iBAAiB;AAC9B,2BAAqB,WAAW,MAAM;AACpC,8BAAsB,KAAK;AAC3B,qBAAa,iBAAiB;AAAA,MAChC,GAAG,KAAK,CAAC;AACT,mBAAa,WAAW;AAAA,IAC1B,GAAG,KAAK,CAAC;AAAA,EACX;AAEA,QAAM,mBAAmB,CAAC,WAAW,SAAS;AAC5C,iBAAa,WAAW;AACxB,QAAI,UAAU;AACZ,4BAAsB,IAAI;AAC1B,mBAAa,iBAAiB;AAC9B,2BAAqB,WAAW,MAAM;AACpC,8BAAsB,KAAK;AAC3B,qBAAa,iBAAiB;AAAA,MAChC,GAAG,KAAK,CAAC;AAAA,IACX,OAAO;AACL,4BAAsB,KAAK;AAAA,IAC7B;AAAA,EACF;AAEA,YAAU,MAAM;AACd,WAAO,MAAM;AACX,mBAAa,WAAW;AACxB,mBAAa,iBAAiB;AAAA,IAChC;AAAA,EACF,GAAG,CAAC,CAAC;AAEL,SAAO,EAAE,cAAc,iBAAiB;AAC1C;","names":[]}