import{r as T,j as t}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b.js";import{p as D,aA as y}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b24.js";import{u as $}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b20.js";import{U as h,$ as z,bn as l,a2 as N,I as g}from"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b11.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b7.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b9.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b6.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b8.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b19.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b4.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b3.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b2.js";import"./v_7_4_2_25_48461181-0d14-4d2a-b9c3-5de50369a90b10.js";function u(i,s){const n=new Date(`${i}T${s}:00`).getTimezoneOffset(),e=Math.abs(Math.floor(n/60)),c=Math.abs(n%60),d=`${n>0?"-":"+"}${e.toString().padStart(2,"0")}:${c.toString().padStart(2,"0")}`;return`${i}T${s}:00${d}`}function F(){const{language:i}=$(),{close:s}=D(),r=h.dayDate(),n=h.timeDate(),[e,c]=T.useState({title:document.getElementById("chatName")?.innerHTML,init_date:r.year+"-"+r.month+"-"+r.day,init_hora:n.hours+":"+n.minutes,fim_date:"",fim_hora:"",location:"",descricao:""}),o=(a,p)=>{c({...e,[a]:p})},d=async()=>{if(e.init_date.length===0||e.init_hora.length===0||e.fim_date.length===0||e.fim_hora.length===0){g({type:"Error",message:i.preenchaTodosCamposDataHora,position:"top-right"});return}const a=new Date(e.init_date+" "+e.init_hora).getTime();if(new Date(e.fim_date+" "+e.fim_hora).getTime()<a){g({type:"Error",message:i.dataDeTerminoInferiorDataInicio,position:"top-right"});return}if(await y("googleCalendario")===!0)return;g({type:"Success",message:i.eventoGoogleCalendarioCriado,position:"top-right"});let m="https://calendar.google.com/calendar/render?action=TEMPLATE",x=`&text=${encodeURIComponent(e.title)}`,_=u(e.init_date,e.init_hora),v=u(e.fim_date,e.fim_hora),j=`&dates=${_.replace(new RegExp("[-:+]","g"),"")}/${v.replace(new RegExp("[-:+]","g"),"")}`,C=`&details=${encodeURIComponent(e.descricao)}`,w=`&location=${encodeURIComponent(e.location)}`;m=m+x+j+C+w,window.open(m,"_blank"),s()};return t.jsxs("div",{className:"w-[35rem] p-2 flex flex-col items-center",children:[t.jsx("header",{className:"w-full",children:t.jsx(z,{size:"22px",weight:"bold",children:i.modal_schedulingCallendar_title})}),t.jsxs("main",{className:"w-full flex flex-col gap-3 mt-2",children:[t.jsx(l,{size:"15px",title:i.modal_schedulingCallendar_placeTitle,type:"text",placeHolder:i.modal_schedulingCallendar_placeMessage,value:e.title,onchange:a=>o("title",a.target.value)}),t.jsxs("div",{className:"w-full flex flex-col gap-2",children:[t.jsxs("div",{className:"w-full gap-3 flex items-center",children:[t.jsx("div",{className:"w-3/6",children:t.jsx(l,{size:"12px",title:i.modal_schedulingCallendar_since,type:"date",value:e.init_date,onchange:a=>o("init_date",a.target.value)})}),t.jsx("div",{className:"w-3/6 self-end",children:t.jsx(l,{title:"",type:"time",value:e.init_hora,onchange:a=>o("init_hora",a.target.value)})})]}),t.jsxs("div",{className:"w-full gap-3 flex items-center",children:[t.jsx("div",{className:"w-3/6",children:t.jsx(l,{size:"12px",title:i.modal_schedulingCallendar_until,type:"date",value:e.fim_date,onchange:a=>o("fim_date",a.target.value)})}),t.jsx("div",{className:"w-3/6 self-end",children:t.jsx(l,{title:"",type:"time",value:e.fim_hora,onchange:a=>o("fim_hora",a.target.value)})})]})]}),t.jsx(l,{size:"15px",title:i.modal_schedulingCallendar_location,type:"text",placeHolder:i.inserirLocalizacao,value:e.location,onchange:a=>o("location",a.target.value)}),t.jsx(l,{size:"15px",title:i.modal_schedulingCallendar_description,type:"text",placeHolder:i.modal_schedulingCallendar_placeMessageAbout,value:e.descricao,onchange:a=>o("descricao",a.target.value)})]}),t.jsx("footer",{className:"mt-2",children:t.jsx(N,{funcao:d,name:i.modal_schedulingCallendar_saveButton})})]})}export{F as default};
