"use strict";const e=require("react/jsx-runtime"),n=require("react"),N=require("../global.module.cjs"),S=require("../tools/icons.cjs"),r=require("../tools/tools.cjs"),m=require("../lite.cjs"),O=new Date,Q=[new Date,new Date],u=b=>b.toString().padStart(2,"0"),_=function(B){const{as:T="div",className:D,dropOldClass:M,locale:p,onDateClick:x,selectedDate:l,style:f,variables:k,...Y}=B,o=l&&l.length>0?l:Q,[i,W]=n.useState(O.getFullYear()),[d,E]=n.useState(O.getMonth()),[F,w]=n.useState(r.generateCalendar(i,d,[],6,1,void 0,l,p)),[h,H]=n.useState(o.map(t=>u(t.getHours()))),[g,P]=n.useState(o.map(t=>u(t.getMinutes()))),[v,R]=n.useState(o.map(t=>u(t.getSeconds()))),[C,q]=n.useState(null),K=n.useMemo(()=>{const t=r.classx(!M&&"card card-body border-0 p-0",D),a=r.stylex((s,c)=>({tKey:r.convertBsKeyToVar(c)}),k,f);return{className:t,style:a}},[D,M,f,k]),I=n.useCallback(t=>{const a=new Date(i,d+t);W(a.getFullYear()),E(a.getMonth())},[d,i]),L=n.useCallback(t=>{const s=((y,j)=>{const z=parseInt(h[j],10)||0,G=parseInt(g[j],10)||0,J=parseInt(v[j],10)||0;return m.setSeconds(m.setMinutes(m.setHours(y,z),G),J)})(t.date,C?1:0),c={...t,active:!0,date:s};w(y=>r.updateCalendarActiveState(c,y)),C?(x==null||x({date:r.sortDates(C,c.date)}),q(null)):q(c.date)},[h,g,x,v,C]),$=(t,a)=>{const s=[...h];s[a]=t.target.value.trim(),H(s)},A=(t,a)=>{const s=[...g];s[a]=t.target.value.trim(),P(s)},V=(t,a)=>{const s=[...v];s[a]=t.target.value.trim(),R(s)};return n.useEffect(()=>{w(r.generateCalendar(i,d,[],6,1,void 0,l,p)),H(o.map(t=>u(t.getHours()))),P(o.map(t=>u(t.getMinutes()))),R(o.map(t=>u(t.getSeconds())))},[d,i,o,p,l]),e.jsxs(T,{...Y,...K,children:[e.jsxs("div",{className:"list-group border-0 row-gap-1 px-3",children:[e.jsxs("div",{className:"row align-items-center position-relative text-center mb-2",children:[e.jsx("div",{className:"col px-1",onClick:()=>I(-1),children:e.jsx("div",{className:r.classxWithOptions(null,"user-select-none list-group-item list-group-item-action border-0 px-0 py-1 rounded text-secondary",N.treeStyles.brlCursorPointer),children:e.jsx(S.BiChevronLeft,{})})}),e.jsx("div",{className:"col px-1"}),e.jsx("div",{className:"col px-1"}),e.jsx("div",{className:"col px-1"}),e.jsx("div",{className:"col px-1"}),e.jsx("div",{className:"col px-1"}),e.jsx("div",{className:"col px-1",onClick:()=>I(1),children:e.jsx("div",{className:r.classxWithOptions(null,"user-select-none list-group-item list-group-item-action border-0 px-0 py-1 rounded text-secondary",N.treeStyles.brlCursorPointer),children:e.jsx(S.BiChevronRight,{})})}),e.jsx("div",{className:"position-absolute top-50 start-50 translate-middle w-auto text-nowrap",children:m.format(new Date(i,d),"MMMM yyyy",{locale:p})})]}),F.rows.map((t,a)=>e.jsx("div",{className:"row text-center",children:t.map((s,c)=>a===0?e.jsx("div",{className:"col px-1",children:e.jsx("div",{className:"list-group-item border-0 px-0 py-1 rounded text-body-secondary",children:s.value})},`${s.value}${c}`):e.jsx("div",{className:"col px-1",onClick:()=>L(s),children:e.jsx("div",{className:r.classxWithOptions(null,"list-group-item list-group-item-action px-0 py-1 rounded",N.treeStyles.brlCursorPointer,!s.isCurrentMonth&&!s.active&&"text-body-tertiary",s.active&&"active",s.isToday?"border-secondary-subtle":"border-0"),children:m.format(s.date,"d",{locale:p})})},s.date.toISOString()))},a))]}),e.jsx("div",{className:"d-flex flex-column gap-2 mt-4 mb-1",children:["Start","End"].map((t,a)=>e.jsxs("div",{className:"input-group",children:[e.jsxs("span",{className:"input-group-text text-primary-emphasis",children:[e.jsx(S.BiClock,{}),e.jsxs("span",{className:"ps-1",children:[t,"Time"]})]}),e.jsx("input",{className:"form-control",onChange:s=>$(s,a),placeholder:"HH",type:"text",value:h[a]}),e.jsx("span",{className:"input-group-text text-secondary",children:":"}),e.jsx("input",{className:"form-control",onChange:s=>A(s,a),placeholder:"MM",type:"text",value:g[a]}),e.jsx("span",{className:"input-group-text text-secondary",children:":"}),e.jsx("input",{className:"form-control",onChange:s=>V(s,a),placeholder:"SS",type:"text",value:v[a]})]},a))})]})};_.displayName="BRL.DateRangePickerDatetime";exports.DateRangePickerDatetime=_;
//# sourceMappingURL=date-range-picker-datetime.cjs.map
