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