import{U as u,j as t,Z as D,bb as l,a1 as y,I as g}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf10.js";import{a as $}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf4.js";import{o as z,ar as N}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf23.js";import{u as M}from"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf19.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf18.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf6.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf8.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf5.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf7.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf9.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf2.js";import"./v_7_4_2_9_8cb79d4f-81e0-49c1-b597-7f2344477fbf3.js";function f(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 G(){var p;const{language:i}=M(),{close:s}=z(),r=u.dayDate(),n=u.timeDate(),[e,c]=$.useState({title:(p=document.getElementById("chatName"))==null?void 0:p.innerHTML,init_date:r.year+"-"+r.month+"-"+r.day,init_hora:n.hours+":"+n.minutes,fim_date:"",fim_hora:"",location:"",descricao:""}),o=(a,h)=>{c({...e,[a]:h})},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 N("googleCalendario")===!0)return;g({type:"Success",message:i.eventoGoogleCalendarioCriado,position:"top-right"});let m="https://calendar.google.com/calendar/render?action=TEMPLATE",_=`&text=${encodeURIComponent(e.title)}`,v=f(e.init_date,e.init_hora),j=f(e.fim_date,e.fim_hora),C=`&dates=${v.replace(new RegExp("[-:+]","g"),"")}/${j.replace(new RegExp("[-:+]","g"),"")}`,w=`&details=${encodeURIComponent(e.descricao)}`,T=`&location=${encodeURIComponent(e.location)}`;m=m+_+C+w+T,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(D,{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(y,{funcao:d,name:i.modal_schedulingCallendar_saveButton})})]})}export{G as default};
