@ampproject/amp-date-countdown
Advanced tools
Comparing version 1.2109032350.0 to 1.2109072113.0
; | ||
var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__markAsModule=function(e){return __defProp(e,"__esModule",{value:!0})},__export=function(e,t){for(var r in __markAsModule(e),t)__defProp(e,r,{get:t[r],enumerable:!0})},__reExport=function(e,t,r){if(t&&"object"==typeof t||"function"==typeof t)for(var n,o=__getOwnPropNames(t),a=0,i=o.length;a<i;a++)n=o[a],__hasOwnProp.call(e,n)||"default"===n||__defProp(e,n,{get:function(e){return t[e]}.bind(null,n),enumerable:!(r=__getOwnPropDesc(t,n))||r.enumerable});return e},__toModule=function(e){return __reExport(__markAsModule(__defProp(null!=e?__create(__getProtoOf(e)):{},"default",e&&e.__esModule&&"default"in e?{get:function(){return e.default},enumerable:!0}:{value:e,enumerable:!0})),e)};function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,u=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function isString(e){return"string"==typeof e}function parseDate(e){if(!e)return null;if("now"===e.toLowerCase())return Date.now();var t=Date.parse(e);return isNaN(t)?null:t}function getDate(e){return e?"number"==typeof e?e:isString(e)?parseDate(e):(e=e).getTime():null}__export(exports,{DateCountdown:function(){return DateCountdown}});var _Object$prototype=Object.prototype,hasOwn_=_Object$prototype.hasOwnProperty,toString_=_Object$prototype.toString;function dict(e){return e||{}}var preact=__toModule(require("preact")),preactDOM=__toModule(require("preact")),hooks=__toModule(require("preact/hooks"));function createElement2(e,t,r){return preact.createElement.apply(void 0,arguments)}function createContext2(e){return preact.createContext(e,void 0)}function useState2(e){return hooks.useState(e)}function useRef2(e){return hooks.useRef(e)}function useEffect2(e,t){hooks.useEffect(e,t)}function useLayoutEffect2(e,t){hooks.useLayoutEffect(e,t)}function useContext2(e){return hooks.useContext(e)}function useMemo2(e,t){return hooks.useMemo(e,t)}var compat=__toModule(require("preact/compat"));function forwardRef2(e){return compat.forwardRef(e)}var _excluded=["as","children","class","contentAs","contentClassName","contentProps","contentRef","contentStyle","layout","paint","size","style","wrapperClassName","wrapperStyle"],CONTAIN=[null,"paint","layout","content","size","size paint","size layout","strict"],SIZE_CONTENT_STYLE={"position":"relative","width":"100%","height":"100%"};function ContainWrapperWithRef(e,t){var r=e.as,n=void 0===r?"div":r,o=e.children,a=e.class,i=e.contentAs,u=void 0===i?"div":i,c=e.contentClassName,s=e.contentProps,l=e.contentRef,p=e.contentStyle,f=e.layout,_=void 0!==f&&f,d=e.paint,y=void 0!==d&&d,S=e.size,m=void 0!==S&&S,E=e.style,L=e.wrapperClassName,O=e.wrapperStyle,D=(m?4:0)+(_?2:0)+(y?1:0);return createElement2(n,_objectSpread2(_objectSpread2({},_objectWithoutPropertiesLoose(e,_excluded)),{},{ref:t,class:"".concat(a||""," ").concat(L||"").trim()||null,style:_objectSpread2(_objectSpread2(_objectSpread2({},E),O),{},{contain:CONTAIN[D]})}),createElement2(u,_objectSpread2(_objectSpread2({},s),{},{ref:l,class:c,style:_objectSpread2(_objectSpread2({},m&&SIZE_CONTENT_STYLE),{},{"overflow":y?"hidden":"visible"},p)}),o))}var ContainWrapper=forwardRef2(ContainWrapperWithRef),_excluded2=["as","children","class","style","wrapperClassName","wrapperStyle"];function WrapperWithRef(e,t){var r=e.as,n=void 0===r?"div":r,o=e.children,a=e.class,i=e.style,u=e.wrapperClassName,c=e.wrapperStyle;return createElement2(n,_objectSpread2(_objectSpread2({},_objectWithoutPropertiesLoose(e,_excluded2)),{},{ref:t,class:"".concat(a||""," ").concat(u||"").trim()||null,style:_objectSpread2(_objectSpread2({},i),c)}),o)}var _MAP,Wrapper=forwardRef2(WrapperWithRef);function useRenderer(e,t){var r=_slicedToArray(useState2(null),2),n=r[0],o=r[1];return useLayoutEffect2((function(){var r=e&&e(t)||null;if(r&&"function"==typeof r.then){var n=!1;return r.then((function(e){n||o(e)})),function(){n=!0}}o(r)}),[e,t]),n}var context,Loading={AUTO:"auto",LAZY:"lazy",EAGER:"eager",UNLOAD:"unload"},ORDER=[Loading.AUTO,Loading.LAZY,Loading.EAGER,Loading.UNLOAD],MAP=(_defineProperty(_MAP={},Loading.AUTO,0),_defineProperty(_MAP,Loading.LAZY,1),_defineProperty(_MAP,Loading.EAGER,2),_defineProperty(_MAP,Loading.UNLOAD,3),_MAP);function getAmpContext(){return context||(context=createContext2({renderable:!0,playable:!0,loading:Loading.AUTO}))}function useAmpContext(){return useContext2(getAmpContext())}function useResourcesNotify(){var e=useAmpContext().notify;useLayoutEffect2((function(){e&&e()}))}function getLocaleStrings(e){return LOCALE_WORD[e]}var LOCALE_WORD={"de":["Jahren","Monaten","Tagen","Stunden","Minuten","Sekunden"],"en":["Years","Months","Days","Hours","Minutes","Seconds"],"es":["años","meses","días","horas","minutos","segundos"],"fr":["ans","mois","jours","heures","minutes","secondes"],"id":["tahun","bulan","hari","jam","menit","detik"],"it":["anni","mesi","giorni","ore","minuti","secondi"],"ja":["年","ヶ月","日","時間","分","秒"],"ko":["년","달","일","시간","분","초"],"nl":["jaar","maanden","dagen","uur","minuten","seconden"],"pt":["anos","meses","dias","horas","minutos","segundos"],"ru":["год","месяц","день","час","минута","секунда"],"th":["ปี","เดือน","วัน","ชั่วโมง","นาที","วินาที"],"tr":["yıl","ay","gün","saat","dakika","saniye"],"vi":["năm","tháng","ngày","giờ","phút","giây"],"zh-cn":["年","月","天","小时","分钟","秒"],"zh-tw":["年","月","天","小時","分鐘","秒"]},_excluded3=["datetime","whenEnded","locale","biggestUnit","countUp","render"],NAME="DateCountdown",MILLISECONDS_IN_DAY=864e5,MILLISECONDS_IN_HOUR=36e5,MILLISECONDS_IN_MINUTE=6e4,MILLISECONDS_IN_SECOND=1e3,DELAY=1e3,TimeUnit={DAYS:1,HOURS:2,MINUTES:3,SECONDS:4},DEFAULT_LOCALE="en",DEFAULT_WHEN_ENDED="stop",DEFAULT_BIGGEST_UNIT="DAYS",DEFAULT_COUNT_UP=!1,DEFAULT_RENDER=function(e){return"".concat(e.days," ").concat(e.dd,", ")+"".concat(e.hours," ").concat(e.hh,", ")+"".concat(e.minutes," ").concat(e.mm,", ")+"".concat(e.seconds," ").concat(e.ss)};function DateCountdown(e){var t=e.datetime,r=e.whenEnded,n=void 0===r?DEFAULT_WHEN_ENDED:r,o=e.locale,a=void 0===o?DEFAULT_LOCALE:o,i=e.biggestUnit,u=void 0===i?DEFAULT_BIGGEST_UNIT:i,c=e.countUp,s=void 0===c?DEFAULT_COUNT_UP:c,l=e.render,p=void 0===l?DEFAULT_RENDER:l,f=_objectWithoutPropertiesLoose(e,_excluded3);useResourcesNotify();var _=useAmpContext().playable,d=useMemo2((function(){return getDate(t)}),[t]),y=useMemo2((function(){return getLocaleWord(a)}),[a]),S=_slicedToArray(useState2(d-Date.now()+DELAY),2),m=S[0],E=S[1],L=useMemo2((function(){return getDataForTemplate(m,u,y,s)}),[m,u,y,s]),O=useRef2(null);useEffect2((function(){if(_&&O.current){var e=O.current.ownerDocument.defaultView,t=e.setInterval((function(){var r=d-Date.now()+DELAY;E(r),n===DEFAULT_WHEN_ENDED&&r<1e3&&e.clearInterval(t)}),DELAY);return function(){return e.clearInterval(t)}}}),[_,d,n]);var D=useRenderer(p,L),b=D&&"object"==_typeof(D)&&"__html"in D;return createElement2(Wrapper,_objectSpread2(_objectSpread2({},f),{},{ref:O,dangerouslySetInnerHTML:b?D:null}),b?null:D)}function getDataForTemplate(e,t,r,n){return _objectSpread2(_objectSpread2({},getYDHMSFromMs(e,t,n)),r)}function getLocaleWord(e){void 0===getLocaleStrings(e)&&(displayWarning("Invalid locale ".concat(e,", defaulting to ").concat(DEFAULT_LOCALE,". ").concat(NAME)),e=DEFAULT_LOCALE);var t=getLocaleStrings(e);return dict({"years":t[0],"months":t[1],"days":t[2],"hours":t[3],"minutes":t[4],"seconds":t[5]})}function getYDHMSFromMs(e,t,r){r&&(e*=-1);var n=TimeUnit[t]==TimeUnit.DAYS?supportBackDate(Math.floor(e/MILLISECONDS_IN_DAY)):0,o=TimeUnit[t]==TimeUnit.HOURS?supportBackDate(Math.floor(e/MILLISECONDS_IN_HOUR)):TimeUnit[t]<TimeUnit.HOURS?supportBackDate(Math.floor(e%MILLISECONDS_IN_DAY/MILLISECONDS_IN_HOUR)):0,a=TimeUnit[t]==TimeUnit.MINUTES?supportBackDate(Math.floor(e/MILLISECONDS_IN_MINUTE)):TimeUnit[t]<TimeUnit.MINUTES?supportBackDate(Math.floor(e%MILLISECONDS_IN_HOUR/MILLISECONDS_IN_MINUTE)):0,i=TimeUnit[t]==TimeUnit.SECONDS?supportBackDate(Math.floor(e/MILLISECONDS_IN_SECOND)):supportBackDate(Math.floor(e%MILLISECONDS_IN_MINUTE/MILLISECONDS_IN_SECOND));return dict({"d":n,"dd":padStart(n),"h":o,"hh":padStart(o),"m":a,"mm":padStart(a),"s":i,"ss":padStart(i)})}function padStart(e){return e<-9||e>9?String(e):e>=-9&&e<0?"-0"+-e:"0"+e}function supportBackDate(e){return e<0?e+1:e}function displayWarning(e){console.warn(e)} | ||
var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__markAsModule=function(e){return __defProp(e,"__esModule",{value:!0})},__export=function(e,t){for(var r in __markAsModule(e),t)__defProp(e,r,{get:t[r],enumerable:!0})},__reExport=function(e,t,r){if(t&&"object"==typeof t||"function"==typeof t)for(var n,o=__getOwnPropNames(t),a=0,i=o.length;a<i;a++)n=o[a],__hasOwnProp.call(e,n)||"default"===n||__defProp(e,n,{get:function(e){return t[e]}.bind(null,n),enumerable:!(r=__getOwnPropDesc(t,n))||r.enumerable});return e},__toModule=function(e){return __reExport(__markAsModule(__defProp(null!=e?__create(__getProtoOf(e)):{},"default",e&&e.__esModule&&"default"in e?{get:function(){return e.default},enumerable:!0}:{value:e,enumerable:!0})),e)};function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,u=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function isString(e){return"string"==typeof e}function parseDate(e){if(!e)return null;if("now"===e.toLowerCase())return Date.now();var t=Date.parse(e);return isNaN(t)?null:t}function getDate(e){return e?"number"==typeof e?e:isString(e)?parseDate(e):(e=e).getTime():null}__export(exports,{BentoDateCountdown:function(){return BentoDateCountdown}});var _Object$prototype=Object.prototype,hasOwn_=_Object$prototype.hasOwnProperty,toString_=_Object$prototype.toString;function dict(e){return e||{}}var preact=__toModule(require("preact")),preactDOM=__toModule(require("preact")),hooks=__toModule(require("preact/hooks"));function createElement2(e,t,r){return preact.createElement.apply(void 0,arguments)}function createContext2(e){return preact.createContext(e,void 0)}function useState2(e){return hooks.useState(e)}function useRef2(e){return hooks.useRef(e)}function useEffect2(e,t){hooks.useEffect(e,t)}function useLayoutEffect2(e,t){hooks.useLayoutEffect(e,t)}function useContext2(e){return hooks.useContext(e)}function useMemo2(e,t){return hooks.useMemo(e,t)}var compat=__toModule(require("preact/compat"));function forwardRef2(e){return compat.forwardRef(e)}var _excluded=["as","children","class","contentAs","contentClassName","contentProps","contentRef","contentStyle","layout","paint","size","style","wrapperClassName","wrapperStyle"],CONTAIN=[null,"paint","layout","content","size","size paint","size layout","strict"],SIZE_CONTENT_STYLE={"position":"relative","width":"100%","height":"100%"};function ContainWrapperWithRef(e,t){var r=e.as,n=void 0===r?"div":r,o=e.children,a=e.class,i=e.contentAs,u=void 0===i?"div":i,c=e.contentClassName,s=e.contentProps,l=e.contentRef,p=e.contentStyle,f=e.layout,_=void 0!==f&&f,d=e.paint,y=void 0!==d&&d,S=e.size,m=void 0!==S&&S,E=e.style,L=e.wrapperClassName,O=e.wrapperStyle,D=(m?4:0)+(_?2:0)+(y?1:0);return createElement2(n,_objectSpread2(_objectSpread2({},_objectWithoutPropertiesLoose(e,_excluded)),{},{ref:t,class:"".concat(a||""," ").concat(L||"").trim()||null,style:_objectSpread2(_objectSpread2(_objectSpread2({},E),O),{},{contain:CONTAIN[D]})}),createElement2(u,_objectSpread2(_objectSpread2({},s),{},{ref:l,class:c,style:_objectSpread2(_objectSpread2({},m&&SIZE_CONTENT_STYLE),{},{"overflow":y?"hidden":"visible"},p)}),o))}var ContainWrapper=forwardRef2(ContainWrapperWithRef),_excluded2=["as","children","class","style","wrapperClassName","wrapperStyle"];function WrapperWithRef(e,t){var r=e.as,n=void 0===r?"div":r,o=e.children,a=e.class,i=e.style,u=e.wrapperClassName,c=e.wrapperStyle;return createElement2(n,_objectSpread2(_objectSpread2({},_objectWithoutPropertiesLoose(e,_excluded2)),{},{ref:t,class:"".concat(a||""," ").concat(u||"").trim()||null,style:_objectSpread2(_objectSpread2({},i),c)}),o)}var _MAP,Wrapper=forwardRef2(WrapperWithRef);function useRenderer(e,t){var r=_slicedToArray(useState2(null),2),n=r[0],o=r[1];return useLayoutEffect2((function(){var r=e&&e(t)||null;if(r&&"function"==typeof r.then){var n=!1;return r.then((function(e){n||o(e)})),function(){n=!0}}o(r)}),[e,t]),n}var context,Loading={AUTO:"auto",LAZY:"lazy",EAGER:"eager",UNLOAD:"unload"},ORDER=[Loading.AUTO,Loading.LAZY,Loading.EAGER,Loading.UNLOAD],MAP=(_defineProperty(_MAP={},Loading.AUTO,0),_defineProperty(_MAP,Loading.LAZY,1),_defineProperty(_MAP,Loading.EAGER,2),_defineProperty(_MAP,Loading.UNLOAD,3),_MAP);function getAmpContext(){return context||(context=createContext2({renderable:!0,playable:!0,loading:Loading.AUTO}))}function useAmpContext(){return useContext2(getAmpContext())}function useResourcesNotify(){var e=useAmpContext().notify;useLayoutEffect2((function(){e&&e()}))}function getLocaleStrings(e){return LOCALE_WORD[e]}var LOCALE_WORD={"de":["Jahren","Monaten","Tagen","Stunden","Minuten","Sekunden"],"en":["Years","Months","Days","Hours","Minutes","Seconds"],"es":["años","meses","días","horas","minutos","segundos"],"fr":["ans","mois","jours","heures","minutes","secondes"],"id":["tahun","bulan","hari","jam","menit","detik"],"it":["anni","mesi","giorni","ore","minuti","secondi"],"ja":["年","ヶ月","日","時間","分","秒"],"ko":["년","달","일","시간","분","초"],"nl":["jaar","maanden","dagen","uur","minuten","seconden"],"pt":["anos","meses","dias","horas","minutos","segundos"],"ru":["год","месяц","день","час","минута","секунда"],"th":["ปี","เดือน","วัน","ชั่วโมง","นาที","วินาที"],"tr":["yıl","ay","gün","saat","dakika","saniye"],"vi":["năm","tháng","ngày","giờ","phút","giây"],"zh-cn":["年","月","天","小时","分钟","秒"],"zh-tw":["年","月","天","小時","分鐘","秒"]},_excluded3=["datetime","whenEnded","locale","biggestUnit","countUp","render"],NAME="DateCountdown",MILLISECONDS_IN_DAY=864e5,MILLISECONDS_IN_HOUR=36e5,MILLISECONDS_IN_MINUTE=6e4,MILLISECONDS_IN_SECOND=1e3,DELAY=1e3,TimeUnit={DAYS:1,HOURS:2,MINUTES:3,SECONDS:4},DEFAULT_LOCALE="en",DEFAULT_WHEN_ENDED="stop",DEFAULT_BIGGEST_UNIT="DAYS",DEFAULT_COUNT_UP=!1,DEFAULT_RENDER=function(e){return"".concat(e.days," ").concat(e.dd,", ")+"".concat(e.hours," ").concat(e.hh,", ")+"".concat(e.minutes," ").concat(e.mm,", ")+"".concat(e.seconds," ").concat(e.ss)};function BentoDateCountdown(e){var t=e.datetime,r=e.whenEnded,n=void 0===r?DEFAULT_WHEN_ENDED:r,o=e.locale,a=void 0===o?DEFAULT_LOCALE:o,i=e.biggestUnit,u=void 0===i?DEFAULT_BIGGEST_UNIT:i,c=e.countUp,s=void 0===c?DEFAULT_COUNT_UP:c,l=e.render,p=void 0===l?DEFAULT_RENDER:l,f=_objectWithoutPropertiesLoose(e,_excluded3);useResourcesNotify();var _=useAmpContext().playable,d=useMemo2((function(){return getDate(t)}),[t]),y=useMemo2((function(){return getLocaleWord(a)}),[a]),S=_slicedToArray(useState2(d-Date.now()+DELAY),2),m=S[0],E=S[1],L=useMemo2((function(){return getDataForTemplate(m,u,y,s)}),[m,u,y,s]),O=useRef2(null);useEffect2((function(){if(_&&O.current){var e=O.current.ownerDocument.defaultView,t=e.setInterval((function(){var r=d-Date.now()+DELAY;E(r),n===DEFAULT_WHEN_ENDED&&r<1e3&&e.clearInterval(t)}),DELAY);return function(){return e.clearInterval(t)}}}),[_,d,n]);var D=useRenderer(p,L),b=D&&"object"==_typeof(D)&&"__html"in D;return createElement2(Wrapper,_objectSpread2(_objectSpread2({},f),{},{ref:O,dangerouslySetInnerHTML:b?D:null}),b?null:D)}function getDataForTemplate(e,t,r,n){return _objectSpread2(_objectSpread2({},getYDHMSFromMs(e,t,n)),r)}function getLocaleWord(e){void 0===getLocaleStrings(e)&&(displayWarning("Invalid locale ".concat(e,", defaulting to ").concat(DEFAULT_LOCALE,". ").concat(NAME)),e=DEFAULT_LOCALE);var t=getLocaleStrings(e);return dict({"years":t[0],"months":t[1],"days":t[2],"hours":t[3],"minutes":t[4],"seconds":t[5]})}function getYDHMSFromMs(e,t,r){r&&(e*=-1);var n=TimeUnit[t]==TimeUnit.DAYS?supportBackDate(Math.floor(e/MILLISECONDS_IN_DAY)):0,o=TimeUnit[t]==TimeUnit.HOURS?supportBackDate(Math.floor(e/MILLISECONDS_IN_HOUR)):TimeUnit[t]<TimeUnit.HOURS?supportBackDate(Math.floor(e%MILLISECONDS_IN_DAY/MILLISECONDS_IN_HOUR)):0,a=TimeUnit[t]==TimeUnit.MINUTES?supportBackDate(Math.floor(e/MILLISECONDS_IN_MINUTE)):TimeUnit[t]<TimeUnit.MINUTES?supportBackDate(Math.floor(e%MILLISECONDS_IN_HOUR/MILLISECONDS_IN_MINUTE)):0,i=TimeUnit[t]==TimeUnit.SECONDS?supportBackDate(Math.floor(e/MILLISECONDS_IN_SECOND)):supportBackDate(Math.floor(e%MILLISECONDS_IN_MINUTE/MILLISECONDS_IN_SECOND));return dict({"d":n,"dd":padStart(n),"h":o,"hh":padStart(o),"m":a,"mm":padStart(a),"s":i,"ss":padStart(i)})}function padStart(e){return e<-9||e>9?String(e):e>=-9&&e<0?"-0"+-e:"0"+e}function supportBackDate(e){return e<0?e+1:e}function displayWarning(e){console.warn(e)} |
@@ -34,4 +34,4 @@ var __create = Object.create; | ||
__export(exports, { | ||
DateCountdown: function() { | ||
return DateCountdown; | ||
BentoDateCountdown: function() { | ||
return BentoDateCountdown; | ||
} | ||
@@ -346,3 +346,3 @@ }); | ||
}; | ||
function DateCountdown(_ref) { | ||
function BentoDateCountdown(_ref) { | ||
var datetime = _ref.datetime, _ref$whenEnded = _ref.whenEnded, whenEnded = _ref$whenEnded === void 0 ? DEFAULT_WHEN_ENDED : _ref$whenEnded, _ref$locale = _ref.locale, locale = _ref$locale === void 0 ? DEFAULT_LOCALE : _ref$locale, _ref$biggestUnit = _ref.biggestUnit, biggestUnit = _ref$biggestUnit === void 0 ? DEFAULT_BIGGEST_UNIT : _ref$biggestUnit, _ref$countUp = _ref.countUp, countUp = _ref$countUp === void 0 ? DEFAULT_COUNT_UP : _ref$countUp, _ref$render = _ref.render, render2 = _ref$render === void 0 ? DEFAULT_RENDER : _ref$render, rest = _objectWithoutPropertiesLoose3(_ref, _excluded3); | ||
@@ -349,0 +349,0 @@ useResourcesNotify(); |
@@ -355,3 +355,3 @@ // src/core/types/string/index.js | ||
var DEFAULT_RENDER = (data) => `${data["days"]} ${data["dd"]}, ${data["hours"]} ${data["hh"]}, ${data["minutes"]} ${data["mm"]}, ${data["seconds"]} ${data["ss"]}`; | ||
function DateCountdown(_ref) { | ||
function BentoDateCountdown(_ref) { | ||
let { | ||
@@ -450,4 +450,4 @@ datetime, | ||
export { | ||
DateCountdown | ||
BentoDateCountdown | ||
}; | ||
//# sourceMappingURL=component-preact.max.module.js.map |
; | ||
function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function n(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function t(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){e(t,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function r(e,n){if(null==e)return{};var t,r,o={},s=Object.keys(e);for(r=0;r<s.length;r++)t=s[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}var{hasOwnProperty:o,toString:s}=Object.prototype;function a(e){return e||{}}import{cloneElement as i,createContext as l,createElement as u,createRef as c}from"preact";import{hydrate as f,render as p}from"preact";import{useCallback as d,useContext as y,useEffect as m,useImperativeHandle as h,useLayoutEffect as g,useMemo as w,useRef as b,useState as O}from"preact/hooks";function S(e,n,t){return u.apply(void 0,arguments)}function v(e){return O(e)}function j(e,n){g(e,n)}function D(e,n){return w(e,n)}import{Children as M,createPortal as $,forwardRef as N}from"preact/compat";function P(e){return N(e)}var C=["as","children","class","contentAs","contentClassName","contentProps","contentRef","contentStyle","layout","paint","size","style","wrapperClassName","wrapperStyle"],U=[null,"paint","layout","content","size","size paint","size layout","strict"],E={"position":"relative","width":"100%","height":"100%"};P((function(e,n){let{as:o="div",children:s,"class":a,contentAs:i="div",contentClassName:l,contentProps:u,contentRef:c,contentStyle:f,layout:p=!1,paint:d=!1,size:y=!1,"style":m,wrapperClassName:h,wrapperStyle:g}=e;const w=(y?4:0)+(p?2:0)+(d?1:0);return S(o,t(t({},r(e,C)),{},{ref:n,class:`${a||""} ${h||""}`.trim()||null,style:t(t(t({},m),g),{},{contain:U[w]})}),S(i,t(t({},u),{},{ref:c,class:l,style:t(t({},y&&E),{},{"overflow":d?"hidden":"visible"},f)}),s))}));var k,I=["as","children","class","style","wrapperClassName","wrapperStyle"],z=P((function(e,n){let{as:o="div",children:s,"class":a,"style":i,wrapperClassName:l,wrapperStyle:u}=e;return S(o,t(t({},r(e,I)),{},{ref:n,class:`${a||""} ${l||""}`.trim()||null,style:t(t({},i),u)}),s)}));function T(){const e=k||(k=l({renderable:!0,playable:!0,loading:"auto"},void 0));return y(e)}function A(e){return H[e]}var H={"de":["Jahren","Monaten","Tagen","Stunden","Minuten","Sekunden"],"en":["Years","Months","Days","Hours","Minutes","Seconds"],"es":["años","meses","días","horas","minutos","segundos"],"fr":["ans","mois","jours","heures","minutes","secondes"],"id":["tahun","bulan","hari","jam","menit","detik"],"it":["anni","mesi","giorni","ore","minuti","secondi"],"ja":["年","ヶ月","日","時間","分","秒"],"ko":["년","달","일","시간","분","초"],"nl":["jaar","maanden","dagen","uur","minuten","seconden"],"pt":["anos","meses","dias","horas","minutos","segundos"],"ru":["год","месяц","день","час","минута","секунда"],"th":["ปี","เดือน","วัน","ชั่วโมง","นาที","วินาที"],"tr":["yıl","ay","gün","saat","dakika","saniye"],"vi":["năm","tháng","ngày","giờ","phút","giây"],"zh-cn":["年","月","天","小时","分钟","秒"],"zh-tw":["年","月","天","小時","分鐘","秒"]},R=["datetime","whenEnded","locale","biggestUnit","countUp","render"],Y={DAYS:1,HOURS:2,MINUTES:3,SECONDS:4},x="en",L="stop",_="DAYS",J=!1,V=e=>`${e.days} ${e.dd}, ${e.hours} ${e.hh}, ${e.minutes} ${e.mm}, ${e.seconds} ${e.ss}`;function q(e){let{datetime:n,whenEnded:o=L,locale:s=x,biggestUnit:i=_,countUp:l=J,render:u=V}=e,c=r(e,R);!function(){const{notify:e}=T();j((()=>{e&&e()}))}();const{playable:f}=T(),p=D((()=>{return(e=n)?"number"==typeof e?e:"string"==typeof e?function(e){if(!e)return null;if("now"===e.toLowerCase())return Date.now();const n=Date.parse(e);return isNaN(n)?null:n}(e):(e=e).getTime():null;var e}),[n]),d=D((()=>function(e){var n;void 0===A(e)&&(n=`Invalid locale ${e}, defaulting to ${x}. DateCountdown`,console.warn(n),e=x);const t=A(e);return a({"years":t[0],"months":t[1],"days":t[2],"hours":t[3],"minutes":t[4],"seconds":t[5]})}(s)),[s]),[y,h]=v(p-Date.now()+1e3),g=D((()=>function(e,n,r,o){return t(t({},function(e,n,t){t&&(e*=-1);const r=Y[n]==Y.DAYS?F(Math.floor(e/864e5)):0,o=Y[n]==Y.HOURS?F(Math.floor(e/36e5)):Y[n]<Y.HOURS?F(Math.floor(e%864e5/36e5)):0,s=Y[n]==Y.MINUTES?F(Math.floor(e/6e4)):Y[n]<Y.MINUTES?F(Math.floor(e%36e5/6e4)):0,i=F(Y[n]==Y.SECONDS?Math.floor(e/1e3):Math.floor(e%6e4/1e3));return a({"d":r,"dd":B(r),"h":o,"hh":B(o),"m":s,"mm":B(s),"s":i,"ss":B(i)})}(e,n,o)),r)}(y,i,d,l)),[y,i,d,l]),w=b(null);m((()=>{if(!f||!w.current)return;const e=w.current.ownerDocument.defaultView,n=e.setInterval((()=>{const t=p-Date.now()+1e3;h(t),o===L&&t<1e3&&e.clearInterval(n)}),1e3);return()=>e.clearInterval(n)}),[f,p,o]);const O=function(e,n){const[t,r]=v(null);return j((()=>{const t=e&&e(n)||null;if(t&&"function"==typeof t.then){let e=!1;return t.then((n=>{e||r(n)})),()=>{e=!0}}r(t)}),[e,n]),t}(u,g),M=O&&"object"==typeof O&&"__html"in O;return S(z,t(t({},c),{},{ref:w,dangerouslySetInnerHTML:M?O:null}),M?null:O)}function B(e){return e<-9||e>9?String(e):e>=-9&&e<0?"-0"+-e:"0"+e}function F(e){return e<0?e+1:e}export{q as DateCountdown}; | ||
function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function n(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function t(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){e(t,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function r(e,n){if(null==e)return{};var t,r,o={},s=Object.keys(e);for(r=0;r<s.length;r++)t=s[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}var{hasOwnProperty:o,toString:s}=Object.prototype;function a(e){return e||{}}import{cloneElement as i,createContext as l,createElement as u,createRef as c}from"preact";import{hydrate as f,render as p}from"preact";import{useCallback as d,useContext as y,useEffect as m,useImperativeHandle as h,useLayoutEffect as g,useMemo as w,useRef as b,useState as O}from"preact/hooks";function S(e,n,t){return u.apply(void 0,arguments)}function v(e){return O(e)}function j(e,n){g(e,n)}function D(e,n){return w(e,n)}import{Children as M,createPortal as $,forwardRef as N}from"preact/compat";function P(e){return N(e)}var C=["as","children","class","contentAs","contentClassName","contentProps","contentRef","contentStyle","layout","paint","size","style","wrapperClassName","wrapperStyle"],U=[null,"paint","layout","content","size","size paint","size layout","strict"],E={"position":"relative","width":"100%","height":"100%"};P((function(e,n){let{as:o="div",children:s,"class":a,contentAs:i="div",contentClassName:l,contentProps:u,contentRef:c,contentStyle:f,layout:p=!1,paint:d=!1,size:y=!1,"style":m,wrapperClassName:h,wrapperStyle:g}=e;const w=(y?4:0)+(p?2:0)+(d?1:0);return S(o,t(t({},r(e,C)),{},{ref:n,class:`${a||""} ${h||""}`.trim()||null,style:t(t(t({},m),g),{},{contain:U[w]})}),S(i,t(t({},u),{},{ref:c,class:l,style:t(t({},y&&E),{},{"overflow":d?"hidden":"visible"},f)}),s))}));var k,I=["as","children","class","style","wrapperClassName","wrapperStyle"],z=P((function(e,n){let{as:o="div",children:s,"class":a,"style":i,wrapperClassName:l,wrapperStyle:u}=e;return S(o,t(t({},r(e,I)),{},{ref:n,class:`${a||""} ${l||""}`.trim()||null,style:t(t({},i),u)}),s)}));function T(){const e=k||(k=l({renderable:!0,playable:!0,loading:"auto"},void 0));return y(e)}function A(e){return H[e]}var H={"de":["Jahren","Monaten","Tagen","Stunden","Minuten","Sekunden"],"en":["Years","Months","Days","Hours","Minutes","Seconds"],"es":["años","meses","días","horas","minutos","segundos"],"fr":["ans","mois","jours","heures","minutes","secondes"],"id":["tahun","bulan","hari","jam","menit","detik"],"it":["anni","mesi","giorni","ore","minuti","secondi"],"ja":["年","ヶ月","日","時間","分","秒"],"ko":["년","달","일","시간","분","초"],"nl":["jaar","maanden","dagen","uur","minuten","seconden"],"pt":["anos","meses","dias","horas","minutos","segundos"],"ru":["год","месяц","день","час","минута","секунда"],"th":["ปี","เดือน","วัน","ชั่วโมง","นาที","วินาที"],"tr":["yıl","ay","gün","saat","dakika","saniye"],"vi":["năm","tháng","ngày","giờ","phút","giây"],"zh-cn":["年","月","天","小时","分钟","秒"],"zh-tw":["年","月","天","小時","分鐘","秒"]},R=["datetime","whenEnded","locale","biggestUnit","countUp","render"],Y={DAYS:1,HOURS:2,MINUTES:3,SECONDS:4},x="en",L="stop",_="DAYS",J=!1,V=e=>`${e.days} ${e.dd}, ${e.hours} ${e.hh}, ${e.minutes} ${e.mm}, ${e.seconds} ${e.ss}`;function q(e){let{datetime:n,whenEnded:o=L,locale:s=x,biggestUnit:i=_,countUp:l=J,render:u=V}=e,c=r(e,R);!function(){const{notify:e}=T();j((()=>{e&&e()}))}();const{playable:f}=T(),p=D((()=>{return(e=n)?"number"==typeof e?e:"string"==typeof e?function(e){if(!e)return null;if("now"===e.toLowerCase())return Date.now();const n=Date.parse(e);return isNaN(n)?null:n}(e):(e=e).getTime():null;var e}),[n]),d=D((()=>function(e){var n;void 0===A(e)&&(n=`Invalid locale ${e}, defaulting to ${x}. DateCountdown`,console.warn(n),e=x);const t=A(e);return a({"years":t[0],"months":t[1],"days":t[2],"hours":t[3],"minutes":t[4],"seconds":t[5]})}(s)),[s]),[y,h]=v(p-Date.now()+1e3),g=D((()=>function(e,n,r,o){return t(t({},function(e,n,t){t&&(e*=-1);const r=Y[n]==Y.DAYS?F(Math.floor(e/864e5)):0,o=Y[n]==Y.HOURS?F(Math.floor(e/36e5)):Y[n]<Y.HOURS?F(Math.floor(e%864e5/36e5)):0,s=Y[n]==Y.MINUTES?F(Math.floor(e/6e4)):Y[n]<Y.MINUTES?F(Math.floor(e%36e5/6e4)):0,i=F(Y[n]==Y.SECONDS?Math.floor(e/1e3):Math.floor(e%6e4/1e3));return a({"d":r,"dd":B(r),"h":o,"hh":B(o),"m":s,"mm":B(s),"s":i,"ss":B(i)})}(e,n,o)),r)}(y,i,d,l)),[y,i,d,l]),w=b(null);m((()=>{if(!f||!w.current)return;const e=w.current.ownerDocument.defaultView,n=e.setInterval((()=>{const t=p-Date.now()+1e3;h(t),o===L&&t<1e3&&e.clearInterval(n)}),1e3);return()=>e.clearInterval(n)}),[f,p,o]);const O=function(e,n){const[t,r]=v(null);return j((()=>{const t=e&&e(n)||null;if(t&&"function"==typeof t.then){let e=!1;return t.then((n=>{e||r(n)})),()=>{e=!0}}r(t)}),[e,n]),t}(u,g),M=O&&"object"==typeof O&&"__html"in O;return S(z,t(t({},c),{},{ref:w,dangerouslySetInnerHTML:M?O:null}),M?null:O)}function B(e){return e<-9||e>9?String(e):e>=-9&&e<0?"-0"+-e:"0"+e}function F(e){return e<0?e+1:e}export{q as BentoDateCountdown}; |
; | ||
var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__markAsModule=function(e){return __defProp(e,"__esModule",{value:!0})},__export=function(e,t){for(var r in __markAsModule(e),t)__defProp(e,r,{get:t[r],enumerable:!0})},__reExport=function(e,t,r){if(t&&"object"==typeof t||"function"==typeof t)for(var n,o=__getOwnPropNames(t),a=0,i=o.length;a<i;a++)n=o[a],__hasOwnProp.call(e,n)||"default"===n||__defProp(e,n,{get:function(e){return t[e]}.bind(null,n),enumerable:!(r=__getOwnPropDesc(t,n))||r.enumerable});return e},__toModule=function(e){return __reExport(__markAsModule(__defProp(null!=e?__create(__getProtoOf(e)):{},"default",e&&e.__esModule&&"default"in e?{get:function(){return e.default},enumerable:!0}:{value:e,enumerable:!0})),e)};function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,u=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function isString(e){return"string"==typeof e}function parseDate(e){if(!e)return null;if("now"===e.toLowerCase())return Date.now();var t=Date.parse(e);return isNaN(t)?null:t}function getDate(e){return e?"number"==typeof e?e:isString(e)?parseDate(e):(e=e).getTime():null}__export(exports,{DateCountdown:function(){return DateCountdown}});var _Object$prototype=Object.prototype,hasOwn_=_Object$prototype.hasOwnProperty,toString_=_Object$prototype.toString;function dict(e){return e||{}}var preact=__toModule(require("react")),preactDOM=__toModule(require("react-dom")),hooks=__toModule(require("react"));function createElement2(e,t,r){return preact.createElement.apply(void 0,arguments)}function createContext2(e){return preact.createContext(e,void 0)}function useState2(e){return hooks.useState(e)}function useRef2(e){return hooks.useRef(e)}function useEffect2(e,t){hooks.useEffect(e,t)}function useLayoutEffect2(e,t){hooks.useLayoutEffect(e,t)}function useContext2(e){return hooks.useContext(e)}function useMemo2(e,t){return hooks.useMemo(e,t)}var compat=__toModule(require("react"));function forwardRef2(e){return compat.forwardRef(e)}var _excluded=["as","children","class","contentAs","contentClassName","contentProps","contentRef","contentStyle","layout","paint","size","style","wrapperClassName","wrapperStyle"],CONTAIN=[null,"paint","layout","content","size","size paint","size layout","strict"],SIZE_CONTENT_STYLE={"position":"relative","width":"100%","height":"100%"};function ContainWrapperWithRef(e,t){var r=e.as,n=void 0===r?"div":r,o=e.children,a=e.class,i=e.contentAs,u=void 0===i?"div":i,c=e.contentClassName,s=e.contentProps,l=e.contentRef,p=e.contentStyle,f=e.layout,_=void 0!==f&&f,d=e.paint,y=void 0!==d&&d,S=e.size,m=void 0!==S&&S,E=e.style,L=e.wrapperClassName,O=e.wrapperStyle,D=(m?4:0)+(_?2:0)+(y?1:0);return createElement2(n,_objectSpread2(_objectSpread2({},_objectWithoutPropertiesLoose(e,_excluded)),{},{ref:t,class:"".concat(a||""," ").concat(L||"").trim()||null,style:_objectSpread2(_objectSpread2(_objectSpread2({},E),O),{},{contain:CONTAIN[D]})}),createElement2(u,_objectSpread2(_objectSpread2({},s),{},{ref:l,class:c,style:_objectSpread2(_objectSpread2({},m&&SIZE_CONTENT_STYLE),{},{"overflow":y?"hidden":"visible"},p)}),o))}var ContainWrapper=forwardRef2(ContainWrapperWithRef),_excluded2=["as","children","class","style","wrapperClassName","wrapperStyle"];function WrapperWithRef(e,t){var r=e.as,n=void 0===r?"div":r,o=e.children,a=e.class,i=e.style,u=e.wrapperClassName,c=e.wrapperStyle;return createElement2(n,_objectSpread2(_objectSpread2({},_objectWithoutPropertiesLoose(e,_excluded2)),{},{ref:t,class:"".concat(a||""," ").concat(u||"").trim()||null,style:_objectSpread2(_objectSpread2({},i),c)}),o)}var _MAP,Wrapper=forwardRef2(WrapperWithRef);function useRenderer(e,t){var r=_slicedToArray(useState2(null),2),n=r[0],o=r[1];return useLayoutEffect2((function(){var r=e&&e(t)||null;if(r&&"function"==typeof r.then){var n=!1;return r.then((function(e){n||o(e)})),function(){n=!0}}o(r)}),[e,t]),n}var context,Loading={AUTO:"auto",LAZY:"lazy",EAGER:"eager",UNLOAD:"unload"},ORDER=[Loading.AUTO,Loading.LAZY,Loading.EAGER,Loading.UNLOAD],MAP=(_defineProperty(_MAP={},Loading.AUTO,0),_defineProperty(_MAP,Loading.LAZY,1),_defineProperty(_MAP,Loading.EAGER,2),_defineProperty(_MAP,Loading.UNLOAD,3),_MAP);function getAmpContext(){return context||(context=createContext2({renderable:!0,playable:!0,loading:Loading.AUTO}))}function useAmpContext(){return useContext2(getAmpContext())}function useResourcesNotify(){var e=useAmpContext().notify;useLayoutEffect2((function(){e&&e()}))}function getLocaleStrings(e){return LOCALE_WORD[e]}var LOCALE_WORD={"de":["Jahren","Monaten","Tagen","Stunden","Minuten","Sekunden"],"en":["Years","Months","Days","Hours","Minutes","Seconds"],"es":["años","meses","días","horas","minutos","segundos"],"fr":["ans","mois","jours","heures","minutes","secondes"],"id":["tahun","bulan","hari","jam","menit","detik"],"it":["anni","mesi","giorni","ore","minuti","secondi"],"ja":["年","ヶ月","日","時間","分","秒"],"ko":["년","달","일","시간","분","초"],"nl":["jaar","maanden","dagen","uur","minuten","seconden"],"pt":["anos","meses","dias","horas","minutos","segundos"],"ru":["год","месяц","день","час","минута","секунда"],"th":["ปี","เดือน","วัน","ชั่วโมง","นาที","วินาที"],"tr":["yıl","ay","gün","saat","dakika","saniye"],"vi":["năm","tháng","ngày","giờ","phút","giây"],"zh-cn":["年","月","天","小时","分钟","秒"],"zh-tw":["年","月","天","小時","分鐘","秒"]},_excluded3=["datetime","whenEnded","locale","biggestUnit","countUp","render"],NAME="DateCountdown",MILLISECONDS_IN_DAY=864e5,MILLISECONDS_IN_HOUR=36e5,MILLISECONDS_IN_MINUTE=6e4,MILLISECONDS_IN_SECOND=1e3,DELAY=1e3,TimeUnit={DAYS:1,HOURS:2,MINUTES:3,SECONDS:4},DEFAULT_LOCALE="en",DEFAULT_WHEN_ENDED="stop",DEFAULT_BIGGEST_UNIT="DAYS",DEFAULT_COUNT_UP=!1,DEFAULT_RENDER=function(e){return"".concat(e.days," ").concat(e.dd,", ")+"".concat(e.hours," ").concat(e.hh,", ")+"".concat(e.minutes," ").concat(e.mm,", ")+"".concat(e.seconds," ").concat(e.ss)};function DateCountdown(e){var t=e.datetime,r=e.whenEnded,n=void 0===r?DEFAULT_WHEN_ENDED:r,o=e.locale,a=void 0===o?DEFAULT_LOCALE:o,i=e.biggestUnit,u=void 0===i?DEFAULT_BIGGEST_UNIT:i,c=e.countUp,s=void 0===c?DEFAULT_COUNT_UP:c,l=e.render,p=void 0===l?DEFAULT_RENDER:l,f=_objectWithoutPropertiesLoose(e,_excluded3);useResourcesNotify();var _=useAmpContext().playable,d=useMemo2((function(){return getDate(t)}),[t]),y=useMemo2((function(){return getLocaleWord(a)}),[a]),S=_slicedToArray(useState2(d-Date.now()+DELAY),2),m=S[0],E=S[1],L=useMemo2((function(){return getDataForTemplate(m,u,y,s)}),[m,u,y,s]),O=useRef2(null);useEffect2((function(){if(_&&O.current){var e=O.current.ownerDocument.defaultView,t=e.setInterval((function(){var r=d-Date.now()+DELAY;E(r),n===DEFAULT_WHEN_ENDED&&r<1e3&&e.clearInterval(t)}),DELAY);return function(){return e.clearInterval(t)}}}),[_,d,n]);var D=useRenderer(p,L),b=D&&"object"==_typeof(D)&&"__html"in D;return createElement2(Wrapper,_objectSpread2(_objectSpread2({},f),{},{ref:O,dangerouslySetInnerHTML:b?D:null}),b?null:D)}function getDataForTemplate(e,t,r,n){return _objectSpread2(_objectSpread2({},getYDHMSFromMs(e,t,n)),r)}function getLocaleWord(e){void 0===getLocaleStrings(e)&&(displayWarning("Invalid locale ".concat(e,", defaulting to ").concat(DEFAULT_LOCALE,". ").concat(NAME)),e=DEFAULT_LOCALE);var t=getLocaleStrings(e);return dict({"years":t[0],"months":t[1],"days":t[2],"hours":t[3],"minutes":t[4],"seconds":t[5]})}function getYDHMSFromMs(e,t,r){r&&(e*=-1);var n=TimeUnit[t]==TimeUnit.DAYS?supportBackDate(Math.floor(e/MILLISECONDS_IN_DAY)):0,o=TimeUnit[t]==TimeUnit.HOURS?supportBackDate(Math.floor(e/MILLISECONDS_IN_HOUR)):TimeUnit[t]<TimeUnit.HOURS?supportBackDate(Math.floor(e%MILLISECONDS_IN_DAY/MILLISECONDS_IN_HOUR)):0,a=TimeUnit[t]==TimeUnit.MINUTES?supportBackDate(Math.floor(e/MILLISECONDS_IN_MINUTE)):TimeUnit[t]<TimeUnit.MINUTES?supportBackDate(Math.floor(e%MILLISECONDS_IN_HOUR/MILLISECONDS_IN_MINUTE)):0,i=TimeUnit[t]==TimeUnit.SECONDS?supportBackDate(Math.floor(e/MILLISECONDS_IN_SECOND)):supportBackDate(Math.floor(e%MILLISECONDS_IN_MINUTE/MILLISECONDS_IN_SECOND));return dict({"d":n,"dd":padStart(n),"h":o,"hh":padStart(o),"m":a,"mm":padStart(a),"s":i,"ss":padStart(i)})}function padStart(e){return e<-9||e>9?String(e):e>=-9&&e<0?"-0"+-e:"0"+e}function supportBackDate(e){return e<0?e+1:e}function displayWarning(e){console.warn(e)} | ||
var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__markAsModule=function(e){return __defProp(e,"__esModule",{value:!0})},__export=function(e,t){for(var r in __markAsModule(e),t)__defProp(e,r,{get:t[r],enumerable:!0})},__reExport=function(e,t,r){if(t&&"object"==typeof t||"function"==typeof t)for(var n,o=__getOwnPropNames(t),a=0,i=o.length;a<i;a++)n=o[a],__hasOwnProp.call(e,n)||"default"===n||__defProp(e,n,{get:function(e){return t[e]}.bind(null,n),enumerable:!(r=__getOwnPropDesc(t,n))||r.enumerable});return e},__toModule=function(e){return __reExport(__markAsModule(__defProp(null!=e?__create(__getProtoOf(e)):{},"default",e&&e.__esModule&&"default"in e?{get:function(){return e.default},enumerable:!0}:{value:e,enumerable:!0})),e)};function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function _objectSpread2(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach((function(t){_defineProperty(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function _arrayWithHoles(e){if(Array.isArray(e))return e}function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var n,o,a=[],i=!0,u=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(e){u=!0,o=e}finally{try{i||null==r.return||r.return()}finally{if(u)throw o}}return a}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(e,t):void 0}}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _slicedToArray(e,t){return _arrayWithHoles(e)||_iterableToArrayLimit(e,t)||_unsupportedIterableToArray(e,t)||_nonIterableRest()}function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var r,n,o={},a=Object.keys(e);for(n=0;n<a.length;n++)r=a[n],t.indexOf(r)>=0||(o[r]=e[r]);return o}function isString(e){return"string"==typeof e}function parseDate(e){if(!e)return null;if("now"===e.toLowerCase())return Date.now();var t=Date.parse(e);return isNaN(t)?null:t}function getDate(e){return e?"number"==typeof e?e:isString(e)?parseDate(e):(e=e).getTime():null}__export(exports,{BentoDateCountdown:function(){return BentoDateCountdown}});var _Object$prototype=Object.prototype,hasOwn_=_Object$prototype.hasOwnProperty,toString_=_Object$prototype.toString;function dict(e){return e||{}}var preact=__toModule(require("react")),preactDOM=__toModule(require("react-dom")),hooks=__toModule(require("react"));function createElement2(e,t,r){return preact.createElement.apply(void 0,arguments)}function createContext2(e){return preact.createContext(e,void 0)}function useState2(e){return hooks.useState(e)}function useRef2(e){return hooks.useRef(e)}function useEffect2(e,t){hooks.useEffect(e,t)}function useLayoutEffect2(e,t){hooks.useLayoutEffect(e,t)}function useContext2(e){return hooks.useContext(e)}function useMemo2(e,t){return hooks.useMemo(e,t)}var compat=__toModule(require("react"));function forwardRef2(e){return compat.forwardRef(e)}var _excluded=["as","children","class","contentAs","contentClassName","contentProps","contentRef","contentStyle","layout","paint","size","style","wrapperClassName","wrapperStyle"],CONTAIN=[null,"paint","layout","content","size","size paint","size layout","strict"],SIZE_CONTENT_STYLE={"position":"relative","width":"100%","height":"100%"};function ContainWrapperWithRef(e,t){var r=e.as,n=void 0===r?"div":r,o=e.children,a=e.class,i=e.contentAs,u=void 0===i?"div":i,c=e.contentClassName,s=e.contentProps,l=e.contentRef,p=e.contentStyle,f=e.layout,_=void 0!==f&&f,d=e.paint,y=void 0!==d&&d,S=e.size,m=void 0!==S&&S,E=e.style,L=e.wrapperClassName,O=e.wrapperStyle,D=(m?4:0)+(_?2:0)+(y?1:0);return createElement2(n,_objectSpread2(_objectSpread2({},_objectWithoutPropertiesLoose(e,_excluded)),{},{ref:t,class:"".concat(a||""," ").concat(L||"").trim()||null,style:_objectSpread2(_objectSpread2(_objectSpread2({},E),O),{},{contain:CONTAIN[D]})}),createElement2(u,_objectSpread2(_objectSpread2({},s),{},{ref:l,class:c,style:_objectSpread2(_objectSpread2({},m&&SIZE_CONTENT_STYLE),{},{"overflow":y?"hidden":"visible"},p)}),o))}var ContainWrapper=forwardRef2(ContainWrapperWithRef),_excluded2=["as","children","class","style","wrapperClassName","wrapperStyle"];function WrapperWithRef(e,t){var r=e.as,n=void 0===r?"div":r,o=e.children,a=e.class,i=e.style,u=e.wrapperClassName,c=e.wrapperStyle;return createElement2(n,_objectSpread2(_objectSpread2({},_objectWithoutPropertiesLoose(e,_excluded2)),{},{ref:t,class:"".concat(a||""," ").concat(u||"").trim()||null,style:_objectSpread2(_objectSpread2({},i),c)}),o)}var _MAP,Wrapper=forwardRef2(WrapperWithRef);function useRenderer(e,t){var r=_slicedToArray(useState2(null),2),n=r[0],o=r[1];return useLayoutEffect2((function(){var r=e&&e(t)||null;if(r&&"function"==typeof r.then){var n=!1;return r.then((function(e){n||o(e)})),function(){n=!0}}o(r)}),[e,t]),n}var context,Loading={AUTO:"auto",LAZY:"lazy",EAGER:"eager",UNLOAD:"unload"},ORDER=[Loading.AUTO,Loading.LAZY,Loading.EAGER,Loading.UNLOAD],MAP=(_defineProperty(_MAP={},Loading.AUTO,0),_defineProperty(_MAP,Loading.LAZY,1),_defineProperty(_MAP,Loading.EAGER,2),_defineProperty(_MAP,Loading.UNLOAD,3),_MAP);function getAmpContext(){return context||(context=createContext2({renderable:!0,playable:!0,loading:Loading.AUTO}))}function useAmpContext(){return useContext2(getAmpContext())}function useResourcesNotify(){var e=useAmpContext().notify;useLayoutEffect2((function(){e&&e()}))}function getLocaleStrings(e){return LOCALE_WORD[e]}var LOCALE_WORD={"de":["Jahren","Monaten","Tagen","Stunden","Minuten","Sekunden"],"en":["Years","Months","Days","Hours","Minutes","Seconds"],"es":["años","meses","días","horas","minutos","segundos"],"fr":["ans","mois","jours","heures","minutes","secondes"],"id":["tahun","bulan","hari","jam","menit","detik"],"it":["anni","mesi","giorni","ore","minuti","secondi"],"ja":["年","ヶ月","日","時間","分","秒"],"ko":["년","달","일","시간","분","초"],"nl":["jaar","maanden","dagen","uur","minuten","seconden"],"pt":["anos","meses","dias","horas","minutos","segundos"],"ru":["год","месяц","день","час","минута","секунда"],"th":["ปี","เดือน","วัน","ชั่วโมง","นาที","วินาที"],"tr":["yıl","ay","gün","saat","dakika","saniye"],"vi":["năm","tháng","ngày","giờ","phút","giây"],"zh-cn":["年","月","天","小时","分钟","秒"],"zh-tw":["年","月","天","小時","分鐘","秒"]},_excluded3=["datetime","whenEnded","locale","biggestUnit","countUp","render"],NAME="DateCountdown",MILLISECONDS_IN_DAY=864e5,MILLISECONDS_IN_HOUR=36e5,MILLISECONDS_IN_MINUTE=6e4,MILLISECONDS_IN_SECOND=1e3,DELAY=1e3,TimeUnit={DAYS:1,HOURS:2,MINUTES:3,SECONDS:4},DEFAULT_LOCALE="en",DEFAULT_WHEN_ENDED="stop",DEFAULT_BIGGEST_UNIT="DAYS",DEFAULT_COUNT_UP=!1,DEFAULT_RENDER=function(e){return"".concat(e.days," ").concat(e.dd,", ")+"".concat(e.hours," ").concat(e.hh,", ")+"".concat(e.minutes," ").concat(e.mm,", ")+"".concat(e.seconds," ").concat(e.ss)};function BentoDateCountdown(e){var t=e.datetime,r=e.whenEnded,n=void 0===r?DEFAULT_WHEN_ENDED:r,o=e.locale,a=void 0===o?DEFAULT_LOCALE:o,i=e.biggestUnit,u=void 0===i?DEFAULT_BIGGEST_UNIT:i,c=e.countUp,s=void 0===c?DEFAULT_COUNT_UP:c,l=e.render,p=void 0===l?DEFAULT_RENDER:l,f=_objectWithoutPropertiesLoose(e,_excluded3);useResourcesNotify();var _=useAmpContext().playable,d=useMemo2((function(){return getDate(t)}),[t]),y=useMemo2((function(){return getLocaleWord(a)}),[a]),S=_slicedToArray(useState2(d-Date.now()+DELAY),2),m=S[0],E=S[1],L=useMemo2((function(){return getDataForTemplate(m,u,y,s)}),[m,u,y,s]),O=useRef2(null);useEffect2((function(){if(_&&O.current){var e=O.current.ownerDocument.defaultView,t=e.setInterval((function(){var r=d-Date.now()+DELAY;E(r),n===DEFAULT_WHEN_ENDED&&r<1e3&&e.clearInterval(t)}),DELAY);return function(){return e.clearInterval(t)}}}),[_,d,n]);var D=useRenderer(p,L),b=D&&"object"==_typeof(D)&&"__html"in D;return createElement2(Wrapper,_objectSpread2(_objectSpread2({},f),{},{ref:O,dangerouslySetInnerHTML:b?D:null}),b?null:D)}function getDataForTemplate(e,t,r,n){return _objectSpread2(_objectSpread2({},getYDHMSFromMs(e,t,n)),r)}function getLocaleWord(e){void 0===getLocaleStrings(e)&&(displayWarning("Invalid locale ".concat(e,", defaulting to ").concat(DEFAULT_LOCALE,". ").concat(NAME)),e=DEFAULT_LOCALE);var t=getLocaleStrings(e);return dict({"years":t[0],"months":t[1],"days":t[2],"hours":t[3],"minutes":t[4],"seconds":t[5]})}function getYDHMSFromMs(e,t,r){r&&(e*=-1);var n=TimeUnit[t]==TimeUnit.DAYS?supportBackDate(Math.floor(e/MILLISECONDS_IN_DAY)):0,o=TimeUnit[t]==TimeUnit.HOURS?supportBackDate(Math.floor(e/MILLISECONDS_IN_HOUR)):TimeUnit[t]<TimeUnit.HOURS?supportBackDate(Math.floor(e%MILLISECONDS_IN_DAY/MILLISECONDS_IN_HOUR)):0,a=TimeUnit[t]==TimeUnit.MINUTES?supportBackDate(Math.floor(e/MILLISECONDS_IN_MINUTE)):TimeUnit[t]<TimeUnit.MINUTES?supportBackDate(Math.floor(e%MILLISECONDS_IN_HOUR/MILLISECONDS_IN_MINUTE)):0,i=TimeUnit[t]==TimeUnit.SECONDS?supportBackDate(Math.floor(e/MILLISECONDS_IN_SECOND)):supportBackDate(Math.floor(e%MILLISECONDS_IN_MINUTE/MILLISECONDS_IN_SECOND));return dict({"d":n,"dd":padStart(n),"h":o,"hh":padStart(o),"m":a,"mm":padStart(a),"s":i,"ss":padStart(i)})}function padStart(e){return e<-9||e>9?String(e):e>=-9&&e<0?"-0"+-e:"0"+e}function supportBackDate(e){return e<0?e+1:e}function displayWarning(e){console.warn(e)} |
@@ -34,4 +34,4 @@ var __create = Object.create; | ||
__export(exports, { | ||
DateCountdown: function() { | ||
return DateCountdown; | ||
BentoDateCountdown: function() { | ||
return BentoDateCountdown; | ||
} | ||
@@ -346,3 +346,3 @@ }); | ||
}; | ||
function DateCountdown(_ref) { | ||
function BentoDateCountdown(_ref) { | ||
var datetime = _ref.datetime, _ref$whenEnded = _ref.whenEnded, whenEnded = _ref$whenEnded === void 0 ? DEFAULT_WHEN_ENDED : _ref$whenEnded, _ref$locale = _ref.locale, locale = _ref$locale === void 0 ? DEFAULT_LOCALE : _ref$locale, _ref$biggestUnit = _ref.biggestUnit, biggestUnit = _ref$biggestUnit === void 0 ? DEFAULT_BIGGEST_UNIT : _ref$biggestUnit, _ref$countUp = _ref.countUp, countUp = _ref$countUp === void 0 ? DEFAULT_COUNT_UP : _ref$countUp, _ref$render = _ref.render, render2 = _ref$render === void 0 ? DEFAULT_RENDER : _ref$render, rest = _objectWithoutPropertiesLoose3(_ref, _excluded3); | ||
@@ -349,0 +349,0 @@ useResourcesNotify(); |
@@ -355,3 +355,3 @@ // src/core/types/string/index.js | ||
var DEFAULT_RENDER = (data) => `${data["days"]} ${data["dd"]}, ${data["hours"]} ${data["hh"]}, ${data["minutes"]} ${data["mm"]}, ${data["seconds"]} ${data["ss"]}`; | ||
function DateCountdown(_ref) { | ||
function BentoDateCountdown(_ref) { | ||
let { | ||
@@ -450,4 +450,4 @@ datetime, | ||
export { | ||
DateCountdown | ||
BentoDateCountdown | ||
}; | ||
//# sourceMappingURL=component-react.max.module.js.map |
; | ||
function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function n(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function t(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){e(t,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function r(e,n){if(null==e)return{};var t,r,o={},s=Object.keys(e);for(r=0;r<s.length;r++)t=s[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}var{hasOwnProperty:o,toString:s}=Object.prototype;function a(e){return e||{}}import{cloneElement as i,createContext as l,createElement as u,createRef as c}from"react";import{hydrate as f,render as p}from"react-dom";import{useCallback as d,useContext as y,useEffect as m,useImperativeHandle as h,useLayoutEffect as g,useMemo as w,useRef as b,useState as O}from"react";function S(e,n,t){return u.apply(void 0,arguments)}function v(e){return O(e)}function j(e,n){g(e,n)}function D(e,n){return w(e,n)}import{Children as M,createPortal as $,forwardRef as N}from"react";function P(e){return N(e)}var C=["as","children","class","contentAs","contentClassName","contentProps","contentRef","contentStyle","layout","paint","size","style","wrapperClassName","wrapperStyle"],U=[null,"paint","layout","content","size","size paint","size layout","strict"],E={"position":"relative","width":"100%","height":"100%"};P((function(e,n){let{as:o="div",children:s,"class":a,contentAs:i="div",contentClassName:l,contentProps:u,contentRef:c,contentStyle:f,layout:p=!1,paint:d=!1,size:y=!1,"style":m,wrapperClassName:h,wrapperStyle:g}=e;const w=(y?4:0)+(p?2:0)+(d?1:0);return S(o,t(t({},r(e,C)),{},{ref:n,class:`${a||""} ${h||""}`.trim()||null,style:t(t(t({},m),g),{},{contain:U[w]})}),S(i,t(t({},u),{},{ref:c,class:l,style:t(t({},y&&E),{},{"overflow":d?"hidden":"visible"},f)}),s))}));var I,k=["as","children","class","style","wrapperClassName","wrapperStyle"],z=P((function(e,n){let{as:o="div",children:s,"class":a,"style":i,wrapperClassName:l,wrapperStyle:u}=e;return S(o,t(t({},r(e,k)),{},{ref:n,class:`${a||""} ${l||""}`.trim()||null,style:t(t({},i),u)}),s)}));function T(){const e=I||(I=l({renderable:!0,playable:!0,loading:"auto"},void 0));return y(e)}function A(e){return H[e]}var H={"de":["Jahren","Monaten","Tagen","Stunden","Minuten","Sekunden"],"en":["Years","Months","Days","Hours","Minutes","Seconds"],"es":["años","meses","días","horas","minutos","segundos"],"fr":["ans","mois","jours","heures","minutes","secondes"],"id":["tahun","bulan","hari","jam","menit","detik"],"it":["anni","mesi","giorni","ore","minuti","secondi"],"ja":["年","ヶ月","日","時間","分","秒"],"ko":["년","달","일","시간","분","초"],"nl":["jaar","maanden","dagen","uur","minuten","seconden"],"pt":["anos","meses","dias","horas","minutos","segundos"],"ru":["год","месяц","день","час","минута","секунда"],"th":["ปี","เดือน","วัน","ชั่วโมง","นาที","วินาที"],"tr":["yıl","ay","gün","saat","dakika","saniye"],"vi":["năm","tháng","ngày","giờ","phút","giây"],"zh-cn":["年","月","天","小时","分钟","秒"],"zh-tw":["年","月","天","小時","分鐘","秒"]},R=["datetime","whenEnded","locale","biggestUnit","countUp","render"],Y={DAYS:1,HOURS:2,MINUTES:3,SECONDS:4},x="en",L="stop",_="DAYS",J=!1,V=e=>`${e.days} ${e.dd}, ${e.hours} ${e.hh}, ${e.minutes} ${e.mm}, ${e.seconds} ${e.ss}`;function q(e){let{datetime:n,whenEnded:o=L,locale:s=x,biggestUnit:i=_,countUp:l=J,render:u=V}=e,c=r(e,R);!function(){const{notify:e}=T();j((()=>{e&&e()}))}();const{playable:f}=T(),p=D((()=>{return(e=n)?"number"==typeof e?e:"string"==typeof e?function(e){if(!e)return null;if("now"===e.toLowerCase())return Date.now();const n=Date.parse(e);return isNaN(n)?null:n}(e):(e=e).getTime():null;var e}),[n]),d=D((()=>function(e){var n;void 0===A(e)&&(n=`Invalid locale ${e}, defaulting to ${x}. DateCountdown`,console.warn(n),e=x);const t=A(e);return a({"years":t[0],"months":t[1],"days":t[2],"hours":t[3],"minutes":t[4],"seconds":t[5]})}(s)),[s]),[y,h]=v(p-Date.now()+1e3),g=D((()=>function(e,n,r,o){return t(t({},function(e,n,t){t&&(e*=-1);const r=Y[n]==Y.DAYS?F(Math.floor(e/864e5)):0,o=Y[n]==Y.HOURS?F(Math.floor(e/36e5)):Y[n]<Y.HOURS?F(Math.floor(e%864e5/36e5)):0,s=Y[n]==Y.MINUTES?F(Math.floor(e/6e4)):Y[n]<Y.MINUTES?F(Math.floor(e%36e5/6e4)):0,i=F(Y[n]==Y.SECONDS?Math.floor(e/1e3):Math.floor(e%6e4/1e3));return a({"d":r,"dd":B(r),"h":o,"hh":B(o),"m":s,"mm":B(s),"s":i,"ss":B(i)})}(e,n,o)),r)}(y,i,d,l)),[y,i,d,l]),w=b(null);m((()=>{if(!f||!w.current)return;const e=w.current.ownerDocument.defaultView,n=e.setInterval((()=>{const t=p-Date.now()+1e3;h(t),o===L&&t<1e3&&e.clearInterval(n)}),1e3);return()=>e.clearInterval(n)}),[f,p,o]);const O=function(e,n){const[t,r]=v(null);return j((()=>{const t=e&&e(n)||null;if(t&&"function"==typeof t.then){let e=!1;return t.then((n=>{e||r(n)})),()=>{e=!0}}r(t)}),[e,n]),t}(u,g),M=O&&"object"==typeof O&&"__html"in O;return S(z,t(t({},c),{},{ref:w,dangerouslySetInnerHTML:M?O:null}),M?null:O)}function B(e){return e<-9||e>9?String(e):e>=-9&&e<0?"-0"+-e:"0"+e}function F(e){return e<0?e+1:e}export{q as DateCountdown}; | ||
function e(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function n(e,n){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n&&(r=r.filter((function(n){return Object.getOwnPropertyDescriptor(e,n).enumerable}))),t.push.apply(t,r)}return t}function t(t){for(var r=1;r<arguments.length;r++){var o=null!=arguments[r]?arguments[r]:{};r%2?n(Object(o),!0).forEach((function(n){e(t,n,o[n])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(o,e))}))}return t}function r(e,n){if(null==e)return{};var t,r,o={},s=Object.keys(e);for(r=0;r<s.length;r++)t=s[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}var{hasOwnProperty:o,toString:s}=Object.prototype;function a(e){return e||{}}import{cloneElement as i,createContext as l,createElement as u,createRef as c}from"react";import{hydrate as f,render as p}from"react-dom";import{useCallback as d,useContext as y,useEffect as m,useImperativeHandle as h,useLayoutEffect as g,useMemo as w,useRef as b,useState as O}from"react";function S(e,n,t){return u.apply(void 0,arguments)}function v(e){return O(e)}function j(e,n){g(e,n)}function D(e,n){return w(e,n)}import{Children as M,createPortal as $,forwardRef as N}from"react";function P(e){return N(e)}var C=["as","children","class","contentAs","contentClassName","contentProps","contentRef","contentStyle","layout","paint","size","style","wrapperClassName","wrapperStyle"],U=[null,"paint","layout","content","size","size paint","size layout","strict"],E={"position":"relative","width":"100%","height":"100%"};P((function(e,n){let{as:o="div",children:s,"class":a,contentAs:i="div",contentClassName:l,contentProps:u,contentRef:c,contentStyle:f,layout:p=!1,paint:d=!1,size:y=!1,"style":m,wrapperClassName:h,wrapperStyle:g}=e;const w=(y?4:0)+(p?2:0)+(d?1:0);return S(o,t(t({},r(e,C)),{},{ref:n,class:`${a||""} ${h||""}`.trim()||null,style:t(t(t({},m),g),{},{contain:U[w]})}),S(i,t(t({},u),{},{ref:c,class:l,style:t(t({},y&&E),{},{"overflow":d?"hidden":"visible"},f)}),s))}));var I,k=["as","children","class","style","wrapperClassName","wrapperStyle"],z=P((function(e,n){let{as:o="div",children:s,"class":a,"style":i,wrapperClassName:l,wrapperStyle:u}=e;return S(o,t(t({},r(e,k)),{},{ref:n,class:`${a||""} ${l||""}`.trim()||null,style:t(t({},i),u)}),s)}));function T(){const e=I||(I=l({renderable:!0,playable:!0,loading:"auto"},void 0));return y(e)}function A(e){return H[e]}var H={"de":["Jahren","Monaten","Tagen","Stunden","Minuten","Sekunden"],"en":["Years","Months","Days","Hours","Minutes","Seconds"],"es":["años","meses","días","horas","minutos","segundos"],"fr":["ans","mois","jours","heures","minutes","secondes"],"id":["tahun","bulan","hari","jam","menit","detik"],"it":["anni","mesi","giorni","ore","minuti","secondi"],"ja":["年","ヶ月","日","時間","分","秒"],"ko":["년","달","일","시간","분","초"],"nl":["jaar","maanden","dagen","uur","minuten","seconden"],"pt":["anos","meses","dias","horas","minutos","segundos"],"ru":["год","месяц","день","час","минута","секунда"],"th":["ปี","เดือน","วัน","ชั่วโมง","นาที","วินาที"],"tr":["yıl","ay","gün","saat","dakika","saniye"],"vi":["năm","tháng","ngày","giờ","phút","giây"],"zh-cn":["年","月","天","小时","分钟","秒"],"zh-tw":["年","月","天","小時","分鐘","秒"]},R=["datetime","whenEnded","locale","biggestUnit","countUp","render"],Y={DAYS:1,HOURS:2,MINUTES:3,SECONDS:4},x="en",L="stop",_="DAYS",J=!1,V=e=>`${e.days} ${e.dd}, ${e.hours} ${e.hh}, ${e.minutes} ${e.mm}, ${e.seconds} ${e.ss}`;function q(e){let{datetime:n,whenEnded:o=L,locale:s=x,biggestUnit:i=_,countUp:l=J,render:u=V}=e,c=r(e,R);!function(){const{notify:e}=T();j((()=>{e&&e()}))}();const{playable:f}=T(),p=D((()=>{return(e=n)?"number"==typeof e?e:"string"==typeof e?function(e){if(!e)return null;if("now"===e.toLowerCase())return Date.now();const n=Date.parse(e);return isNaN(n)?null:n}(e):(e=e).getTime():null;var e}),[n]),d=D((()=>function(e){var n;void 0===A(e)&&(n=`Invalid locale ${e}, defaulting to ${x}. DateCountdown`,console.warn(n),e=x);const t=A(e);return a({"years":t[0],"months":t[1],"days":t[2],"hours":t[3],"minutes":t[4],"seconds":t[5]})}(s)),[s]),[y,h]=v(p-Date.now()+1e3),g=D((()=>function(e,n,r,o){return t(t({},function(e,n,t){t&&(e*=-1);const r=Y[n]==Y.DAYS?F(Math.floor(e/864e5)):0,o=Y[n]==Y.HOURS?F(Math.floor(e/36e5)):Y[n]<Y.HOURS?F(Math.floor(e%864e5/36e5)):0,s=Y[n]==Y.MINUTES?F(Math.floor(e/6e4)):Y[n]<Y.MINUTES?F(Math.floor(e%36e5/6e4)):0,i=F(Y[n]==Y.SECONDS?Math.floor(e/1e3):Math.floor(e%6e4/1e3));return a({"d":r,"dd":B(r),"h":o,"hh":B(o),"m":s,"mm":B(s),"s":i,"ss":B(i)})}(e,n,o)),r)}(y,i,d,l)),[y,i,d,l]),w=b(null);m((()=>{if(!f||!w.current)return;const e=w.current.ownerDocument.defaultView,n=e.setInterval((()=>{const t=p-Date.now()+1e3;h(t),o===L&&t<1e3&&e.clearInterval(n)}),1e3);return()=>e.clearInterval(n)}),[f,p,o]);const O=function(e,n){const[t,r]=v(null);return j((()=>{const t=e&&e(n)||null;if(t&&"function"==typeof t.then){let e=!1;return t.then((n=>{e||r(n)})),()=>{e=!0}}r(t)}),[e,n]),t}(u,g),M=O&&"object"==typeof O&&"__html"in O;return S(z,t(t({},c),{},{ref:w,dangerouslySetInnerHTML:M?O:null}),M?null:O)}function B(e){return e<-9||e>9?String(e):e>=-9&&e<0?"-0"+-e:"0"+e}function F(e){return e<0?e+1:e}export{q as BentoDateCountdown}; |
{ | ||
"name": "@ampproject/amp-date-countdown", | ||
"version": "1.2109032350.0", | ||
"version": "1.2109072113.0", | ||
"description": "AMP HTML amp-date-countdown Component", | ||
@@ -5,0 +5,0 @@ "author": "The AMP HTML Authors", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
299915