import{U as u,j as t,D,bj as l,J as y,I as g}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e10.js";import{a as $}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e4.js";import{n as z,_ as N}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e22.js";import{u as M}from"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e19.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e18.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e8.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e5.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e7.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e6.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e2.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e3.js";import"./v_7_4_0_1_4b8cc392-a410-45f6-b662-85abdad9c03e9.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};
