'use client';
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),helpers=require("../common/helpers.js"),Text=require("../../text/components/Text.js"),core=require("@gem-sdk/core"),system=require("@gem-sdk/system"),attrs=require("../common/attrs.js"),classes=require("../common/classes.js"),styles=require("../common/styles.js"),useCountDownTimer=require("../hooks/useCountDownTimer.js");const Countdown=e=>{let{setting:s,styles:t,builderProps:l,advanced:a}=e,{labelTypo:r,numTypo:i,labelTypography:m,numTypography:n,enableLabelTextStyle:y}=t??{},{weekLabel:c,dayLabel:o,hourLabel:u,minuteLabel:d,secondLabel:x,enableWeek:j,enableDay:C,enableHour:g,enableMinute:p,enableSecond:h,redirectUrl:f}=s??{},T=core.useEditorMode(),{week:S,day:k,hour:q,minute:R,second:v,timeLeft:w,ref:I}=useCountDownTimer.default(s,l),N=!!f?.link&&"edit"!==T,b=system.createClass({...classes.getTextExpireClasses()});if(s?.autoHideWhenTimeout&&w<=0)return"edit"!==T?null:jsxRuntime.jsx("div",{className:b,children:jsxRuntime.jsx("span",{children:"Countdown is run out of time (this only visible in the editor)"})});let D=system.createAttr({...attrs.getAttr({uid:l?.uid||""})}),E=system.createStyle({...styles.getWrapperStyle(t)}),F=system.createClass({...classes.getWrapperClasses(a?.cssClass)}),W=system.createClass({...classes.getContentClasses()}),A=system.createStyle({...styles.getContainStyle(t)}),B=system.createStyle({...styles.getDateStyle(t)}),M=e=>system.createClass({...classes.getDateClasses(e)}),_=system.createClass({...classes.getTextFrontClasses(t)}),H=system.createStyle({...styles.getTextFrontStyle(t)}),L=system.createStyle({...styles.getTextBackStyle(t)}),O=e=>system.createClass({...classes.getTextBackClasses(t,e)}),P=system.createClass({...classes.getLinkClasses()}),z=(e,s)=>{let t=helpers.formatTime(e);return jsxRuntime.jsxs("div",{style:B,className:M(s),children:[jsxRuntime.jsx(Text.default,{styles:{typography:n,typo:i},setting:{htmlTag:"div",text:t,excludeFlex:!0},className:_,style:H,disableEdit:!0}),system.If(!!y,jsxRuntime.jsx(Text.default,{styles:{typography:m,typo:r},setting:{text:s,htmlTag:"p",excludeFlex:!0},style:L,className:O(s),disableEdit:!0}))]})};return jsxRuntime.jsx("div",{ref:I,...D,className:F,style:E,children:jsxRuntime.jsxs("div",{className:W,style:A,children:[system.If(N,jsxRuntime.jsx("a",{href:f?.link,target:f?.target,"aria-label":"Countdown link",className:P,children:" "})),system.If(j,z(S,c)),system.If(C,z(k,o)),system.If(g,z(q,u)),system.If(p,z(R,d)),system.If(h,z(v,x))]})})};exports.default=Countdown;
