'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 u,getTextFrontClasses as p,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:q,labelTypography:D,numTypography:H,enableLabelTextStyle:L}=T??{},{weekLabel:W,dayLabel:z,hourLabel:A,minuteLabel:B,secondLabel:G,enableWeek:I,enableDay:J,enableHour:K,enableMinute:M,enableSecond:O,redirectUrl:P,autoHideWhenTimeout:Q}=w??{},R=i(),{week:S,day:U,hour:V,minute:X,second:Y,timeLeft:Z,ref:$}=v(w,b),_=!!P?.link&&"edit"!==R,ee=l({...d()});if(w?.autoHideWhenTimeout&&Z<=0)return"edit"!==R?null:e("div",{className:ee,children:e("span",{children:"Countdown is run out of time (this only visible in the editor)"})});let et=r({...a({uid:b?.uid||""})}),es=m({...g(T)}),eo=l({...c(E?.cssClass)}),ei=l({...u({isLiquid:!1,autoHideWhenTimeout:Q})}),el=m({...x(T)}),er=m({...j(T)}),em=e=>l({...y(e)}),en=l({...p(T)}),ea=m({...N(T)}),ed=m({...k(T)}),ec=e=>l({...f(T,e)}),eu=l({...h()}),ep=(i,l)=>{let r=s(i);return t("div",{style:er,className:em(l),children:[e(o,{styles:{typography:H,typo:q},setting:{htmlTag:"div",text:r,excludeFlex:!0},className:en,style:ea,disableEdit:!0}),n(!!L,e(o,{styles:{typography:D,typo:F},setting:{text:l,htmlTag:"p",excludeFlex:!0},style:ed,className:ec(l),disableEdit:!0}))]})};return e("div",{ref:$,...et,className:eo,style:es,children:t("div",{className:ei,style:el,children:[n(_,e("a",{href:P?.link,target:P?.target,"aria-label":"Countdown link",className:eu,children:" "})),n(I,ep(S,W)),n(J,ep(U,z)),n(K,ep(V,A)),n(M,ep(X,B)),n(O,ep(Y,G))]})})};export{Countdown as default};
