{"version":3,"file":"Countdown.js","names":["defineDs","m","MithrilRedrawEverySecond","Countdown","controller","args","days","prop","hours","minutes","seconds","calculateTimeLeft","difference","Date","endTime","countdownTime","Math","floor","setInterval","start","formatTime","time","timeStr","toString","split","map","digit","index","key","className","concat","simple","large","view","_ref","_ref2","textAfter"],"sources":["DanskeSpil/Domain/Feature.LoyaltyClub/Components/Countdown/Countdown.js"],"sourcesContent":["defineDs('DanskeSpil/Domain/Feature.LoyaltyClub/Components/Countdown/Countdown', [\r\n 'Shared/Framework/Mithril/Scripts/Core/Mithril',\r\n 'Shared/Framework/Mithril/Scripts/Helpers/MithrilRedrawEverySecond'\r\n],\r\nfunction (m, MithrilRedrawEverySecond) {\r\n const Countdown = {\r\n controller: function (args) {\r\n\r\n const days = m.prop(0);\r\n const hours = m.prop(0);\r\n const minutes = m.prop(0);\r\n const seconds = m.prop(0);\r\n\r\n const calculateTimeLeft = () => {\r\n let difference = +new Date(args.endTime) - +new Date();\r\n return difference > 0 ? difference / 1000 : 0;\r\n };\r\n\r\n const countdownTime = m.prop(calculateTimeLeft());\r\n\r\n days(Math.floor(countdownTime() / (60 * 60 * 24)));\r\n hours(Math.floor((countdownTime() % (60 * 60 * 24)) / (60 * 60)));\r\n minutes(Math.floor((countdownTime() % (60 * 60)) / 60));\r\n seconds(Math.floor(countdownTime() % 60));\r\n\r\n setInterval(() => {\r\n countdownTime(calculateTimeLeft());\r\n\r\n days(Math.floor(countdownTime() / (60 * 60 * 24)));\r\n hours(Math.floor((countdownTime() % (60 * 60 * 24)) / (60 * 60)));\r\n minutes(Math.floor((countdownTime() % (60 * 60)) / 60));\r\n seconds(Math.floor(countdownTime() % 60));\r\n }, 1000);\r\n\r\n MithrilRedrawEverySecond.start();\r\n\r\n const formatTime = (time) => {\r\n const timeStr = time < 10 ? '0' + time : time.toString();\r\n return timeStr.split('').map((digit, index) => (\r\n \r\n {digit}\r\n \r\n ));\r\n };\r\n\r\n return {\r\n days, hours, minutes, seconds, formatTime\r\n };\r\n },\r\n view: function ({ days, hours, minutes, seconds, formatTime }, { simple, textAfter, large }) {\r\n if (days() > 0) {\r\n return (\r\n
\r\n {formatTime(days())}\r\n {textAfter}\r\n
\r\n );\r\n } else {\r\n return (\r\n
\r\n {formatTime(hours())}\r\n :\r\n {formatTime(minutes())}\r\n :\r\n {formatTime(seconds())}\r\n
\r\n );\r\n }\r\n }\r\n };\r\n\r\n return Countdown;\r\n});"],"mappings":"AAAAA,QAAQ,CAAC,sEAAsE,EAAE,CAC/E,+CAA+C,EAC/C,mEAAmE,CACpE,EACD,UAAUC,CAAC,EAAEC,wBAAwB,EAAE;EACrC,IAAMC,SAAS,GAAG;IAChBC,UAAU,EAAE,SAAAA,CAAUC,IAAI,EAAE;MAE1B,IAAMC,IAAI,GAAGL,CAAC,CAACM,IAAI,CAAC,CAAC,CAAC;MACtB,IAAMC,KAAK,GAAGP,CAAC,CAACM,IAAI,CAAC,CAAC,CAAC;MACvB,IAAME,OAAO,GAAGR,CAAC,CAACM,IAAI,CAAC,CAAC,CAAC;MACzB,IAAMG,OAAO,GAAGT,CAAC,CAACM,IAAI,CAAC,CAAC,CAAC;MAEzB,IAAMI,iBAAiB,GAAGA,CAAA,KAAM;QAC9B,IAAIC,UAAU,GAAG,CAAC,IAAIC,IAAI,CAACR,IAAI,CAACS,OAAO,CAAC,GAAG,CAAC,IAAID,IAAI,CAAC,CAAC;QACtD,OAAOD,UAAU,GAAG,CAAC,GAAGA,UAAU,GAAG,IAAI,GAAG,CAAC;MAC/C,CAAC;MAED,IAAMG,aAAa,GAAGd,CAAC,CAACM,IAAI,CAACI,iBAAiB,CAAC,CAAC,CAAC;MAEjDL,IAAI,CAACU,IAAI,CAACC,KAAK,CAACF,aAAa,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;MAClDP,KAAK,CAACQ,IAAI,CAACC,KAAK,CAAEF,aAAa,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,E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