PageSourceSearch

https://salutaeuropa.web.app/static/js/1979.920c66c7.chunk.js

js salutaeuropa.web.app collected 2026-10-03 12:38:06 UTC 38,478 bytes, 1 lines download raw bytes

1(globalThis.webpackChunkreactsaluta=globalThis.webpackChunkreactsaluta||[]).push([[1979],{67132(e,a,t){"use strict";t.d(a,{DD:()=>l,Di:()=>g,Dv:()=>n,Ee:()=>x,KH:()=>u,Mm:()=>c,TL:()=>i,Tb:()=>o,UE:()=>m,fi:()=>p,lt:()=>d,pJ:()=>b,vP:()=>f,yn:()=>h});var s=t(96011),r=t.n(s);const l=e=>{switch(e){case"enable":return"DISPONIBLE";case"disable":return"AGENDADO";case"lock":return"BLOQUEADO";case"reserved":case"booked":return"RESERVADO";case"reagendamiento":return"REAGENDAMIENTO";default:return"DESCONOCIDO"}};async function n(e,a,t){try{return(await r().post(`${t}/schedule/generateAppointmentsSlots`,{uid:e},{headers:{Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}async function o(e,a,t,s){console.log("generateSpecificSchedulesSlots",e,a);try{return(await r().post(`${s}/schedule/generateSpecificSchedulesSlots`,{uid:e,schedules:a},{headers:{Authorization:`Bearer ${t}`}})).data}catch(l){throw l}}async function i(e,a,t){try{return(await r().post(`${t}/schedule/createSlot`,{...e},{headers:{Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}async function c(e,a,t){try{return(await r().post(`${t}/schedule/enableSlot`,{slotId:e},{headers:{Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}async function d(e,a,t){try{return(await r().post(`${t}/schedule/disableSlot`,{slotId:e},{headers:{Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}async function m(e,a,t){try{return(await r().post(`${t}/schedule/lockSlot`,{slotId:e},{headers:{Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}async function u(e,a,t){try{return(await r().post(`${t}/schedule/deleteSlot`,{slotId:e},{headers:{Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}async function x(e,a,t,s){try{return(await r().get(`${s}/schedule/getSlotsByProfessional/${e}/${a}`,{headers:{Authorization:`Bearer ${t}`}})).data}catch(l){throw l}}async function h(e,a){try{return(await r().post(`${a}/schedule/refreshAllProfessionalsSlots`,{},{headers:{Authorization:`Bearer ${e}`}})).data}catch(t){throw t}}async function p(e,a,t){try{return(await r().post(`${t}/schedule/deleteSlotsBulk`,{slotIds:e},{headers:{Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}async function g(e,a,t){try{return(await r().post(`${t}/schedule/lockSlotsBulk`,{slotIds:e},{headers:{Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}async function b(e,a,t){try{return(await r().post(`${t}/schedule/enableSlotsBulk`,{slotIds:e},{headers:{Authorization:`Bearer ${a}`}})).data}catch(s){throw s}}async function f(e,a,t,s){try{return(await r().post(`${s}/schedule/updateSlotsBulk`,{slotIds:e,updateData:a},{headers:{Authorization:`Bearer ${t}`}})).data}catch(l){throw l}}},10638(e,a,t){"use strict";t.r(a),t.d(a,{default:()=>U});var s=t(9950),r=t(73878),l=(t(96011),t(48525)),n=t(59051),o=(t(25045),t(4695)),i=t.n(o),c=t(81011),d=t(2043),m=t(71518),u=t(51826),x=t(66979),h=t(44876),p=t(74137),g=t(44414);const b=e=>{let{data:a}=e;const t=(0,s.useMemo)(()=>[{Header:"Usuario",accessor:"completeName",Cell:e=>{let{value:a,row:t}=e;return(0,g.jsxs)("div",{className:"flex items-center",children:[(0,g.jsx)("div",{className:"flex-shrink-0 w-10 h-10 bg-saluta-p_light rounded-full flex items-center justify-center text-saluta-p",children:(0,g.jsx)(m.A,{className:"w-6 h-6"})}),(0,g.jsxs)("div",{className:"ml-4",children:[(0,g.jsx)("div",{className:"text-sm font-medium text-gray-900",children:a||"Sin nombre"}),(0,g.jsx)("div",{className:"text-xs text-gray-500",children:t.original.uid})]})]})}},{Header:"Email",accessor:"email",Cell:e=>{let{value:a}=e;return(0,g.jsxs)("div",{className:"flex items-center text-sm text-gray-600",children:[(0,g.jsx)(u.A,{className:"w-4 h-4 mr-2 text-gray-400"}),a]})}},{Header:"RUT / DNI",accessor:"dni",Cell:e=>{let{value:a}=e;return(0,g.jsxs)("div",{className:"flex items-center text-sm text-gray-600",children:[(0,g.jsx)(x.A,{className:"w-4 h-4 mr-2 text-gray-400"}),a||"N/A"]})}}],[]),{getTableProps:r,getTableBodyProps:l,headerGroups:n,rows:o,prepareRow:i}=(0,d.useTable)({columns:t,data:a||[]},d.useSortBy,d.useRowSelect);return a&&0!==a.length?(0,g.jsx)("div",{className:"mt-8 overflow-hidden bg-white shadow-xl shadow-gray-100/50 rounded-2xl border border-gray-100",children:(0,g.jsx)("div",{className:"overflow-x-auto",children:(0,g.jsxs)("table",{...r(),className:"min-w-full divide-y divide-gray-200",children:[(0,g.jsx)("thead",{className:"bg-gray-50",children:n.map(e=>(0,g.jsx)("tr",{...e.getHeaderGroupProps(),children:e.headers.map(e=>(0,g.jsx)("th",{...e.getHeaderProps(e.getSortByToggleProps()),className:"px-6 py-4 text-left text-xs font-bold text-gray-500 uppercase tracking-wider select-none cursor-pointer hover:bg-gray-100 transition-colors duration-200",children:(0,g.jsxs)("div",{className:"flex items-center space-x-1",children:[(0,g.jsx)("span",{children:e.render("Header")}),(0,g.jsx)("span",{className:"text-gray-400",children:e.isSorted?e.isSortedDesc?(0,g.jsx)(h.A,{className:"w-4 h-4"}):(0,g.jsx)(p.A,{className:"w-4 h-4"}):null})]})}))}))}),(0,g.jsx)("tbody",{...l(),className:"bg-white divide-y divide-gray-100",children:o.map(e=>(i(e),(0,g.jsx)("tr",{...e.getRowProps(),className:"hover:bg-blue-50/30 transition-colors duration-150 ease-in-out",children:e.cells.map(e=>(0,g.jsx)("td",{...e.getCellProps(),className:"px-6 py-4 whitespace-nowrap",children:e.render("Cell")}))})))})]})})}):(0,g.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 p-12 text-center shadow-sm mt-6",children:[(0,g.jsx)("div",{className:"inline-flex items-center justify-center w-16 h-16 rounded-full bg-gray-50 mb-4 text-gray-400",children:(0,g.jsx)(m.A,{className:"w-8 h-8"})}),(0,g.jsx)("h3",{className:"text-lg font-semibold text-gray-900 mb-1 font-sans",children:"No hay datos"}),(0,g.jsx)("p",{className:"text-gray-500 text-sm max-w-xs mx-auto",children:"Realiza una b\xfasqueda por Email, UID o Excel para visualizar los usuarios aqu\xed."})]})};
1var f=t(62376),y=t(74849),j=t(51352),w=t(44515),v=t(57011),N=t(1379),S=t(5820),A=t(79970),k=t(58693),C=t(92084),D=t(81991),E=t(14414),z=t(38817),B=t(67714),I=t(64283),$=t(46243),P=t(67132);function O(){for(var e=arguments.length,a=new Array(e),t=0;t<e;t++)a[t]=arguments[t];return a.filter(Boolean).join(" ")}function T(e){let{title:a,desc:t,icon:s,color:r,onClick:l}=e;return(0,g.jsxs)("button",{onClick:l,className:O("group text-left p-8 rounded-3xl border transition-all duration-300 hover:shadow-xl hover:-translate-y-1 relative overflow-hidden",{red:"bg-red-50 text-red-600 border-red-100 hover:bg-red-100","saluta-p":"bg-blue-50 text-saluta-p border-blue-100 hover:bg-blue-100","saluta-s":"bg-emerald-50 text-saluta-s border-emerald-100 hover:bg-emerald-100"}[r]||"bg-gray-50 border-gray-100 text-gray-700"),children:[(0,g.jsxs)("div",{className:"flex flex-col h-full",children:[(0,g.jsx)("div",{className:"mb-4 inline-flex items-center justify-center p-3 rounded-2xl bg-white shadow-sm border border-inherit transition-transform group-hover:scale-110",children:(0,g.jsx)(s,{className:"w-6 h-6"})}),(0,g.jsx)("h3",{className:"text-lg font-extrabold mb-2 text-gray-900 group-hover:text-inherit transition-colors",children:a}),(0,g.jsx)("p",{className:"text-sm opacity-60 leading-relaxed font-medium",children:t})]}),(0,g.jsx)("div",{className:"absolute -right-4 -bottom-4 opacity-5 group-hover:opacity-10 transition-opacity",children:(0,g.jsx)(s,{className:"w-24 h-24"})})]})}const U=function(){var e,a;const{urlServer:t,db:o,storage:d,firebase:m}=(0,r.d4)(e=>e.company.companyInstance,(e,a)=>
1e===a),[u,x]=(0,s.useState)([]),[h,p]=(0,s.useState)(""),[U,R]=(0,s.useState)(""),[_,F]=(0,s.useState)(""),[L,M]=(0,s.useState)(!1),[G,J]=(0,s.useState)(null);function H(e){return new Promise((a,t)=>{o.collection("users").where("email","==",e.trim()).get().then(e=>{e.empty&&a(null),e.forEach(e=>{const t=e.data(),s=[t.nameFirst,t.nameSecond,t.lastNameFirst,t.lastnameSecond].filter(Boolean).join(" ");a({...t,completeName:s,uid:e.id})})}).catch(e=>t(e))})}const q={patient:[{action:"view",element:"news"}],psychologist:[{action:"view",element:"menu-doctor"},{action:"view",element:"news"},{action:"view",element:"medical-care"},{action:"view",element:"my-patients"},{action:"view",element:"all-patients"},{action:"option",element:"btn-medical-report"},{action:"option",element:"btn-send-attention-summary"}],doctor:[{action:"view",element:"menu-doctor"},{action:"view",element:"news"},{action:"view",element:"medical-care"},{action:"view",element:"my-patients"},{action:"view",element:"all-patients"},{action:"option",element:"btn-medical-report"},{action:"option",element:"btn-medical-license-report"},{action:"option",element:"generate-compin-record"},{action:"option",element:"btn-generate-prescription"},{action:"option",element:"btn-generate-order"},{action:"option",element:"btn-generate-procedure"},{action:"option",element:"btn-send-attention-summary"}]},V=async e=>{if(0===u.length)return(0,c.n7)("No hay usuarios seleccionados");M(!0);const a=q[e]||[];try{const t=u.map(e=>o.collection("users").doc(e.uid).update({permissions:a}));await Promise.all(t),(0,c.Sv)(`Actualizados a rol: ${e}`)}catch(t){(0,c.n7)("Error al actualizar roles masivos")}finally{M(!1)}};return(0,g.jsxs)("div",{className:"min-h-screen bg-gray-50/50 p-4 md:p-8 font-sans antialiased text-gray-900",children:[(0,g.jsx)("div",{className:"max-w-7xl mx-auto mb-8",children:(0,g.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,g.jsx)("div",{className:"p-3 bg-saluta-p text-white rounded-2xl shadow-lg shadow-saluta-p/20",children:(0,g.jsx)(y.A,{className:"w-8 h-8"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("h1",{className:"text-3xl font-extrabold tracking-tight text-gray-900",children:"Configuraci\xf3n Administrativa"}),(0,g.jsx)("p",{className:"text-gray-500 mt-1",children:"Gesti\xf3n de usuarios, permisos y roles de la plataforma"})]})]})}),(0,g.jsx)("div",{className:"max-w-7xl mx-auto",children:(0,g.jsxs)(f.o.Group,{children:[(0,g.jsx)(f.o.List,{className:"flex space-x-1 rounded-xl bg-gray-200/50 p-1 mb-8 max-w-3xl",children:[{name:"Comunidad & B\xfasqueda",icon:j.A},{name:"Gesti\xf3n de Permisos",icon:w.A},{name:"Inspecci\xf3n JSON",icon:v.A},{name:"Acciones R\xe1pidas",icon:N.A},{name:"Agenda & Slots",icon:S.A},{name:"Roles R\xe1pidos",icon:N.A}].map(e=>(0,g.jsxs)(f.o,{className:e=>{let{selected:a}=e;return O("w-full rounded-lg py-2.5 text-sm font-bold leading-5 transition-all duration-200 focus:outline-none flex items-center justify-center space-x-2",a?"bg-white text-saluta-p shadow-sm border border-gray-100":"text-gray-500 hover:bg-white/[0.12] hover:text-gray-700")},children:[(0,g.jsx)(e.icon,{className:"w-4 h-4"}),(0,g.jsx)("span",{className:"hidden sm:inline",children:e.name})]},e.name))}),(0,g.jsxs)(f.o.Panels,{children:[(0,g.jsx)(f.o.Panel,{className:"focus:outline-none animate-in fade-in slide-in-from-bottom-2 duration-300",children:(0,g.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[(0,g.jsxs)("div",{className:"lg:col-span-1 space-y-6",children:[(0,g.jsxs)("div",{className:"bg-white p-6 rounded-2xl shadow-sm border border-gray-100",children:[(0,g.jsxs)("h3",{className:"text-lg font-bold flex items-center mb-6",children:[(0,g.jsx)(A.A,{className:"w-5 h-5 mr-2 text-saluta-p"}),"B\xfasqueda de Usuario"]}),(0,g.jsxs)("div",{className:"space-y-4",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("label",{className:"block text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Por Email"}),(0,g.jsxs)("div",{className:"relative flex items-center",children:[(0,g.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,g.jsx)(k.A,{className:"w-5 h-5 text-gray-300","aria-hidden":"true"})}),(0,g.jsx)("input",{type:"email",value:h,onChange:e=>p(e.target.value),placeholder:"[email protected]",className:"block w-full pl-10 pr-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl focus:ring-2 focus:ring-saluta-p/40 focu
1s:border-saluta-p outline-none transition-all placeholder:text-gray-400/60"})]}),(0,g.jsxs)("button",{onClick:()=>{if(!h)return(0,c.n7)("Ingresa un email");M(!0),H(h).then(e=>{e?((0,c.Sv)("Usuario encontrado"),x([e]),R(e.uid)):(0,c.n7)("No se encontr\xf3 el usuario")}).catch(()=>(0,c.n7)("Error al buscar")).finally(()=>M(!1))},disabled:L,className:"w-full mt-3 py-2.5 bg-saluta-p hover:bg-saluta-p_dark text-white rounded-xl font-bold shadow-md shadow-saluta-p/10 transition-all flex items-center justify-center space-x-2 disabled:opacity-50 hover:shadow-lg active:scale-[0.98]",children:[(0,g.jsx)(A.A,{className:"w-4 h-4"}),(0,g.jsx)("span",{children:"Buscar por Email"})]})]}),(0,g.jsxs)("div",{className:"relative py-2",children:[(0,g.jsx)("div",{className:"absolute inset-0 flex items-center","aria-hidden":"true",children:(0,g.jsx)("div",{className:"w-full border-t border-gray-100"})}),(0,g.jsx)("div",{className:"relative flex justify-center text-[10px] uppercase font-black",children:(0,g.jsx)("span",{className:"bg-white px-3 text-gray-300 tracking-widest",children:"\xf3"})})]}),(0,g.jsxs)("div",{children:[(0,g.jsx)("label",{className:"block text-xs font-bold text-gray-400 uppercase tracking-wider mb-2",children:"Por UID"}),(0,g.jsxs)("div",{className:"relative flex items-center",children:[(0,g.jsx)("div",{className:"absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none",children:(0,g.jsx)(C.A,{className:"w-5 h-5 text-gray-300","aria-hidden":"true"})}),(0,g.jsx)("input",{type:"text",value:U,onChange:e=>R(e.target.value),placeholder:"UID de Firebase",className:"block w-full pl-10 pr-3 py-2.5 bg-gray-50 border border-gray-200 rounded-xl focus:ring-2 focus:ring-saluta-p/40 focus:border-saluta-p outline-none transition-all placeholder:text-gray-400/60"})]}),(0,g.jsxs)("button",{onClick:()=>{if(!U)return(0,c.n7)("Ingresa un UID");var e;M(!0),(e=U,new Promise((a,t)=>{o.collection("users").doc(e.trim()).get().then(e=>{if(e.exists){const t=e.data(),s=[t.nameFirst,t.nameSecond,t.lastNameFirst,t.lastnameSecond].filter(Boolean).join(" ");a({...t,completeName:s,uid:e.id})}else a(null)}).catch(e=>t(e))})).then(e=>{e?((0,c.Sv)("Usuario encontrado"),x([e])):(0,c.n7)("No se encontr\xf3 el usuario")}).catch(()=>(0,c.n7)("Error al buscar")).finally(()=>M(!1))},disabled:L,className:"w-full mt-3 py-2.5 bg-blue-700 hover:bg-blue-900 text-white rounded-xl font-bold shadow-md transition-all flex items-center justify-center space-x-2 disabled:opacity-50 hover:shadow-lg active:scale-[0.98]",children:[(0,g.jsx)(v.A,{className:"w-4 h-4"}),(0,g.jsx)("span",{children:"Buscar por UID"})]})]})]})]}),(0,g.jsxs)("div",{className:"bg-gradient-to-br from-green-500 to-emerald-600 p-6 rounded-2xl shadow-lg border border-white/10 text-white group cursor-pointer relative overflow-hidden transition-all hover:shadow-xl hover:scale-[1.02]",children:[(0,g.jsx)("div",{className:"absolute -right-4 -top-4 opacity-10 group-hover:opacity-20 transition-opacity",children:(0,g.jsx)(D.A,{className:"w-32 h-32"})}),(0,g.jsxs)("div",{className:"relative z-10",children:[(0,g.jsxs)("h3",{className:"text-lg font-bold flex items-center",children:[(0,g.jsx)(D.A,{className:"w-6 h-6 mr-2"}),"Carga Masiva"]}),(0,g.jsx)("p",{className:"text-white/80 text-sm mt-1 mb-4 leading-relaxed",children:"Selecciona un archivo Excel (.xlsx) con los correos de los usuarios."}),(0,g.jsxs)("label",{className:"inline-flex items-center px-4 py-2 bg-white/20 hover:bg-white/30 backdrop-blur-md rounded-xl font-bold transition-all cursor-pointer border border-white/20",children:[(0,g.jsx)("span",{children:"Cargar Documento"}),(0,g.jsx)("input",{type:"file",className:"hidden",onChange:e=>{return a=e.target.files[0],M(!0),void new Promise((e,t)=>{const s=new FileReader;s.readAsArrayBuffer(a),s.onload=a=>{const t=a.target.result,s=l.read(t,{type:"buffer"}),r=s.SheetNames[0],n=s.Sheets[r],o=l.utils.sheet_to_json(n);e(o)},s.onerror=e=>t(e)}).then(e=>{const a=e.map(e=>H(e.email));Promise.all(a).then(e=>{const a=e.filter(e=>null!==e);(0,c.Sv)("Se carg\xf3 el listado de usuarios"),x(a)}).catch(()=>(0,c.n7)("Error al cargar")).finally(()=>M(!1))});var a}})]})]})]})]}),(0,g.jsxs)("div",{className:"lg:col-span-2",children:[(0,g.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,g.jsx)("h2",{className:"text-xl font-bold text-gray-800",children:"Resultados de Comunidad"}),(0,g.jsxs)("span",{className:"text-xs font-bold text-gray-400 bg-gray-200/50 px-2.5 py-1 rounded-full",children:[u.length," Usuario(s)"]})]}),(0,g.jsx)(b,{data:u})]})]})}),(0,g.jsx)(f.o.Panel,{className:"focus:outline-none animate-in fade-in slide-in-from-bottom-2 duration-300",children:(0,g.jsxs)("div",{className:"bg-white rounded-3xl shadow-sm border border-gray-100 overflow-hidden",children:[(0,g.jsxs)("div",{className:"bg-gray-50 border-b border-gray-100 p-6 flex items-center justify-between flex-wrap gap-4",children:[(0,g.jsxs)("div",{className:"flex items-center",children:[(0,g.jsx)("div",{className:"w-10 h-10 rounded-xl bg-orange-100 text-orange-600 flex items-center justify-center mr-4",children:(0,g.jsx)(w.A,{className:"w-6 h-6"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("h3",{className:"font-bold text-gray-900",children:"Editor de Permisos JSON"}),(0,g.jsxs)("p",{className:"text-xs text-gray-500",children:["Usa este editor para definir permisos granulares para ",(null===(e=u[0])||void 0===e?void 0:e.completeName)||"el usuario seleccionado"]})]})]}),u.length>0&&(0,g.jsxs)("button",{onClick:()=>{var e;return(e=>{var a;if(!e)return(0,c.n7)("No hay permisos para descargar");const t=e.map(e=>JSON.stringify(e)).join("\n"),s=new Blob([t],{type:"application/json;charset=utf-8"}),r=URL.createObjectURL(s),l=document.createElement("a");l.href=r,l.download=`permissions_${(null===(a=u[0])||void 0===a?void 0:a.email)||"user"}.txt`,l.click(),URL.revokeObjectURL(r),(0,c.Sv)("Permisos descargados")})(null===(e=u[0])||void 0===e?void 0:e.permissions)},className:"px-4 py-2 bg-white border border-gray-200 hover:border-saluta-p text-gray-700 hover:text-saluta-p rounded-xl font-bold text-sm transition-all flex items-center space-x-2",children:[(0,g.jsx)(E.A,{className:"w-4 h-4"}),(0,g.jsx)("span",{children:"Exportar Actuales"})]})]}),(0,g.jsxs)("div",{className:"p-6 space-y-6",children:[(0,g.jsxs)("div",{className:"relative group",children:[(0,g.jsx)("div",{className:"absolute top-4 right-4 z-10 flex space-x-2 opacity-0 group-hover:opacity-100 transition-opacity",children:(0,g.jsx)("span",{className:"bg-gray-800 text-white px-2 py-1 rounded text-[10px] font-mono",children:"DEBUG MODE"})}
1),(0,g.jsx)("textarea",{rows:"12",value:_,onChange:e=>F(e.target.value),placeholder:'Ej: {"action": "view", "element": "news"}',className:"w-full p-6 bg-gray-900 text-green-400 font-mono text-sm leading-relaxed border-0 rounded-2xl focus:ring-4 focus:ring-saluta-p/5 outline-none transition-all shadow-inner placeholder:text-gray-700"})]}),(0,g.jsxs)("div",{className:"flex items-center justify-between",children:[(0,g.jsx)("div",{className:"flex items-center text-xs text-gray-400 space-x-4",children:(0,g.jsxs)("span",{className:"flex items-center",children:[(0,g.jsx)("span",{className:"w-2 h-2 rounded-full bg-green-500 mr-2"})," Cada l\xednea debe ser un objeto JSON v\xe1lido"]})}),(0,g.jsxs)("button",{onClick:async()=>{if(!U)return(0,c.n7)("Selecciona un usuario primero");try{const e=_.split("\n").filter(e=>""!==e.trim()).map(e=>JSON.parse(e));await o.collection("users").doc(U).update({permissions:e}),(0,c.Sv)("Permisos actualizados correctamente")}catch(e){console.error(e),(0,c.n7)("Error en el formato JSON o al actualizar")}},className:"px-8 py-3 bg-saluta-p hover:bg-saluta-p_dark text-white rounded-2xl font-extrabold shadow-lg shadow-saluta-p/20 transition-all flex items-center space-x-2 hover:-translate-y-0.5 active:translate-y-0",children:[(0,g.jsx)(N.A,{className:"w-5 h-5"}),(0,g.jsx)("span",{children:"Sincronizar Permisos"})]})]})]})]})}),(0,g.jsx)(f.o.Panel,{className:"focus:outline-none animate-in fade-in slide-in-from-bottom-2 duration-300",children:(0,g.jsxs)("div",{className:"bg-white rounded-3xl shadow-sm border border-gray-100 overflow-hidden",children:[(0,g.jsxs)("div",{className:"bg-gray-50 border-b border-gray-100 p-6 flex items-center justify-between",children:[(0,g.jsxs)("div",{className:"flex items-center",children:[(0,g.jsx)("div",{className:"w-10 h-10 rounded-xl bg-purple-100 text-purple-600 flex items-center justify-center mr-4",children:(0,g.jsx)(v.A,{className:"w-6 h-6"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("h3",{className:"font-bold text-gray-900",children:"Inspecci\xf3n Completa del Documento"}),(0,g.jsxs)("p",{className:"text-xs text-gray-500",children:["Visualizando todos los campos del documento de ",(null===(a=u[0])||void 0===a?void 0:a.completeName)||"usuario"]})]})]}),(0,g.jsx)("div",{className:"text-[10px] font-bold text-purple-500 uppercase bg-purple-50 px-2 py-1 rounded",children:"READ ONLY"})]}),(0,g.jsx)("div",{className:"p-6",children:u.length>0?(0,g.jsxs)(g.Fragment,{children:[("doctor"===u[0].typeUser||"doctor-perito"===u[0].typeUser||"psychologist"===u[0].typeUser||"perito"===u[0].typeUser)&&(0,g.jsxs)("div",{className:"mb-6 p-6 bg-white rounded-2xl border border-gray-100 flex items-center justify-between shadow-sm",children:[(0,g.jsxs)("div",{className:"flex items-center space-x-6",children:[(0,g.jsx)("div",{className:"w-48 h-24 bg-gray-50 rounded-xl border-2 border-dashed border-gray-100 flex items-center justify-center overflow-hidden group relative",children:u[0].signature?(0,g.jsx)("img",{src:u[0].signature,alt:"Firma Profesional",className:"max-h-full object-contain transition-transform duration-300 group-hover:scale-110"}):(0,g.jsxs)("div",{className:"flex flex-col items-center justify-center text-gray-400 space-y-1",children:[(0,g.jsx)(C.A,{className:"w-8 h-8 opacity-20"}),(0,g.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-widest text-center px-4",children:"Sin Firma"})]})}),(0,g.jsxs)("div",{children:[(0,g.jsxs)("h4",{className:"font-bold text-gray-900 flex items-center",children:["Firma Digital del Profesional",u[0].signature&&(0,g.jsx)("span",{className:"ml-2 w-2 h-2 rounded-full bg-green-500 animate-pulse"})]}),(0,g.jsx)("p",{className:"text-xs text-gray-500 max-w-xs mt-1 leading-relaxed",children:"Esta firma se adjuntar\xe1 autom\xe1ticamente a informes y certificados emitidos por el profesional."})]})]}),(0,g.jsxs)("label",{className:"px-6 py-2.5 bg-saluta-p hover:bg-saluta-p_dark text-white rounded-xl font-bold shadow-md shadow-saluta-p/10 transition-all cursor-pointer flex items-center space-x-2 active:scale-95",children:[(0,g.jsx)(D.A,{className:"w-4 h-4"}),(0,g.jsx)("span",{children:u[0].signature?"Actualizar Firma":"Cargar Firma"}),(0,g.jsx)("input",{type:"file",className:"hidden",onChange:e=>{const a=e.target.files[0],t=u[0];if(a&&t){d.child(`images/${t.dni}/signature`).put(a).then(function(e){e.ref.getDownloadURL().then(function(e){o.collection("users").doc(`${t.uid}`).update({signature:e}).then(()=>{const a=u.map(a=>a.uid===t.uid?{...a,signature:e}:a);x(a),(0,c.Sv)("Se actualiz\xf3 la firma del profesional correctamente")}).catch(e=>{console.error("Error updating signature: ",e),(0,c.n7)("Error al actualizar el registro de firma")})})}).catch(e=>{console.error("Error uploading file: ",e),(0,c.n7)("Error al subir el archivo a Storage")})}},accept:"image/*"})]})]}),(0,g.jsx)("div",{className:"bg-gray-900 rounded-2xl p-6 shadow-inner border border-gray-800",children:(0,g.jsx)("textarea",{readOnly:!0,rows:"20",value:JSON.stringify(u[0],null,4),className:"w-full bg-transparent text-blue-300 font-mono text-sm border-0 focus:ring-0 resize-none leading-relaxed"})})]}):(0,g.jsx)("div",{className:"py-12 text-center",children:(0,g.jsx)("p",{className:"text-gray-400 italic",children:"No hay ning\xfan usuario seleccionado para inspeccionar campos."})})})]})}),(0,g.jsx)(f.o.Panel,{className:"focus:outline-none animate-in fade-in slide-in-from-bottom-2 duration-300",children:(0,g.jsxs)("div",{className:"bg-white rounded-3xl shadow-sm border border-gray-100 overflow-hidden",children:[(0,g.jsx)("div",{className:"bg-gradient-to-r from-blue-600 to-indigo-700 p-8 text-white",children:(0,g.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,g.jsx)("div",{className:"w-16 h-16 rounded-2xl bg-white/20 backdrop-blur-md flex items-center justify-center border border-white/30 shadow-inner",children:(0,g.jsx)(S.A,{className:"w-10 h-10"})}),(0,g.jsxs)("div",{children:[(0,g.jsx)("h2",{className:"text-2xl font-black tracking-tight",children:"Mantenimiento de Agenda"}),(0,g.jsx)("p",{className:"text-blue-100 font-medium opacity-80",children:"Herramientas para resolver inconsistencias en la disponibilidad y citas."})]})]})}),(0,g.jsxs)("div",{className:"p-8 grid grid-cols-1 md:grid-cols-2 gap-8",children:[(0,g.jsxs)("div",{className:"bg-gray-50 rounded-3xl p-8 border border-gray-100 flex flex-col justify-between hover:shadow-md transition-shadow",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"w-12 h-12 rounded-xl bg-orange-100 text-orange-600 flex items-center justify-center mb-4",children:(0,g.jsx)(z.A,{className:"w-6 h-6"})}),(0,g.jsx)("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:"Sincronizaci\xf3n Manual (Frontend)"}),(0,g.jsxs)("p",{className:"text-sm text-gray-500 mb-6 leading-relaxed",children:["Escanea todas las citas agendadas en todos los pa\xedses y fuerza el cierre de los slots correspondientes si a\xfan aparecen como disponibles.",(0,g.jsx)("span",{className:"block mt-2 font-semibold text-orange-600",children:"Recomendado si hay errores persistentes de cupos duplicados."})]}),G&&(0,g.jsxs)("div",{className:"mb-6 p-4 bg-white rounded-2xl border border-orange-100 shadow-inner",children:[(0,g.jsxs)("div",{className:"flex justify-between items-center mb-2",children:[(0,g.jsx)("span",{className:"text-xs font-bold text-orange-600 uppercase tracking-widest",children:G.country}),(0,g.jsxs)("span",{className:"text-xs font-mono text-gray-400",children:[G.current," / ",G.total]})]}),(0,g.jsx)("div",{className:"w-full bg-gray-100 h-1.5 rounded-full overflow-hidden mb-3",children:(0,g.jsx)("div",{className:"bg-orange-500 h-full transition-all duration-300",style:{width:G.current/(G.total||1)*100+"%"}})}),(0,g.jsxs)("div",{className:"flex items-center text-[10px] font-bold text-gray-400",children:[(0,g.jsx)("div",{className:"w-2 h-2 rounded-full bg-green-500 mr-2 animate-pulse"}),"SLOTS CORREGIDOS: ",(0,g.jsx)("span",{className:"text-gray-900 ml-1",children:G.fixed})]})]})]}),(0,g.jsxs)("button",{onClick:async()=>{M(!0),J({country:"Iniciando...",current:0,total:0,fixed:0});try{const e=["Chile"];let a=0;const t=new Date,s=new Date;s.setDate(t.getDate()-30);for(const r of e){J(e=>({...e,country:r,current:0,total:0}));const e=`schedule_${r.replaceAll(" ","").toLowerCase()}`,t=(await o.collection(e).where(m.firestore.FieldPath.documentId(),">=",s.getTime().toString()).get()).docs;J(e=>({...e,total:t.length}));let l=0;for(const s of t){l++;const e=s.data(),t=s.ref;if(J(e=>({...e,current:l})),!e.timestamp||!e.professionalDNI)continue;const r=e.timeZone||"America/Santiago",i=new Date(e.timestamp),c=n(i).tz(r),d=`${e.professionalDNI}_${c.format("YYYY-MM-DD")}_${c.format("HH:mm")}`;e.slotId!==d&&await t.update({slotId:d});const m=["success","free","Aceptada","AUTHORIZED","pago_exitoso"].includes(e.payStatus),u="agendado"===e.scheduleStatus,x="finalizado"===e.scheduleStatus;let h="booked";(u||m||x)&&(h="disable"),"cancelado"!==e.scheduleStatus&&"anulado"!==e.scheduleStatus&&"reagendado"!==e.scheduleStatus||(h="enable");const p=o.collection("slots").doc(d);if("enable"===h){const e=await p.get();e.exists&&e.data().appointmentId===s.id&&await p.update({availabilityStatus:"enable",appointmentId:null,bookedAt:null,bookedBy:null,appointmentInfo:null,updatedBy:"deep_sync_tool_v2"})}else await p.set({availabilityStatus:h,appointmentId:s.id,bookedAt:e.createDate||new Date,bookedBy:e.patientDNI,appointmentInfo:{...e,slotId:d},updatedBy:"deep_sync_tool_v2"},{merge:!0});a++,J(e=>({...e,fixed:a}))}}(0,c.Sv)(`Sincronizaci\xf3n completada. Se corrigieron ${a} slots.`)}catch(e){console.error("Error en sincronizaci\xf3n:",e),(0,c.n7)("Error durante la sincronizaci\xf3n de slots")}finally{M(!1),setTimeout(()=>J(null),5e3)}},disabled:L,className:"w-full py-4 bg-orange-500 hover:bg-orange-600 text-white rounded-2xl font-black shadow-lg shadow-orange-500/20 transition-all flex items-center justify-center space-x-2 active:scale-95 disabled:opacity-50",children:[(0,g.jsx)(z.A,{className:"w-5 h-5 "+(L?"animate-spin":"")}),(0,g.jsx)("span",{children:"Ejecutar Sincronizaci\xf3n Global"})]})]}),(0,g.jsxs)("div",{className:"bg-gray-50 rounded-3xl p-8 border border-gray-100 flex flex-col justify-between hover:shadow-md transition-shadow",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"w-12 h-12 rounded-xl bg-blue-100 text-blue-600 flex items-center justify-center mb-4",children:(0,g.jsx)(N.A,{className:"w-6 h-6"})}),(0,g.jsx)("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:"Refrescar Cach\xe9 Servidor"}),(0,g.jsxs)("p",{className:"text-sm text-gray-500 mb-6 leading-relaxed",children:["Solicita al servidor que recalcule la disponibilidad total de todos los profesionales activos. Este proceso es m\xe1s r\xe1pido pero depende exclusivamente de la l\xf3gica del backend.",(0,g.jsx)("span",{className:"block mt-2 font-semibold text-blue-600",children:"\xdasalo como primera opci\xf3n antes de la sincronizaci\xf3n manual."})]})]}),(0,g.jsxs)("button",{onClick:async()=>{M(!0);try{const e=await m.auth().currentUser.getIdToken();await(0,P.yn)(e,t),(0,c.Sv)("Solicitud de refresco enviada al servidor correctamente")}catch(e){console.error(e),(0,c.n7)("Error al solicitar refresco al servidor")}finally{M(!1)}},disabled:L,className:"w-full py-4 bg-blue-600 hover:bg-blue-700 text-white rounded-2xl font-black shadow-lg shadow-blue-600/20 transition-all flex items-center justify-center space-x-2 active:scale-95 disabled:opacity-50",children:[(0,g.jsx)(B.A,{className:"w-5 h-5"}),(0,g.jsx)("span",{children:"Refrescar Todo el Backend"})]})]}),(0,g.jsxs)("div",{className:"bg-gray-50 rounded-3xl p-8 border border-gray-100 flex flex-col justify-between hover:shadow-md transition-shadow",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"w-12 h-12 rounded-xl bg-purple-100 text-purple-600 flex items-center justify-center mb-4",children:(0,g.jsx)(I.A,{className:"w-6 h-6"})}),(0,g.jsx)("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:"Sync Metadatos Atenci\xf3n"}),(0,g.jsxs)("p",{className:"text-sm text-gray-500 mb-6 leading-relaxed",children:["Recorre las atenciones registradas y sincroniza campos como Fonasa, Estado de Pago y C\xf3digos de Servicio desde la cita original.",(0,g.jsx)("span",{className:"block mt-2 font-semibold text-purple-600",children:'Corrige errores de "undefined" al ver historiales m\xe9dicos antiguos.'})]})]}),(0,g.jsxs)("button",{onClick:async()=>{M(!0),J({country:"Sincronizando Metadatos...",current:0,total:0,fixed:0});try{const e=["Chile"];let a=0;const t=n().clone().subtract(60,"days");for(const s of e){J(e=>({...e,country:`Metadatos ${s}`,current:0,total:0}));const e=`schedule_${s.replaceAll(" ","").toLowerCase()}`,r=(await o.collection(e).where("timestamp",">=",t.valueOf()).get()).docs;J(e=>({...e,total:r.length}));let l=0;for(const t of r){l++;const e=t.data();J(e=>({...e,current:l}));const r=o.collection("attention").doc(s.toLowerCase()).collection(e.patientDNI).doc(e.timestamp.toString());(await r.get()).exists&&(await r.update({...e,typeConsult:e.serviceName,typeConsultCode:e.serviceCode,typeConsultCodeAlternative:e.serviceCodeAlternative,typeConsultDuration:e.serviceDuration}),a++),J(e=>({...e,fixed:a}))}}(0,c.Sv)(`Sincronizaci\xf3n de metadatos completada: ${a} registros actualizados.`)}catch(e){console.error("Error en sync metadatos:",e),(0,c.n7)("Error al sincronizar metadatos de atenci\xf3n")}
1finally{M(!1),setTimeout(()=>J(null),5e3)}},disabled:L,className:"w-full py-4 bg-purple-600 hover:bg-purple-700 text-white rounded-2xl font-black shadow-lg shadow-purple-600/20 transition-all flex items-center justify-center space-x-2 active:scale-95 disabled:opacity-50",children:[(0,g.jsx)(z.A,{className:"w-5 h-5 "+(L?"animate-spin":"")}),(0,g.jsx)("span",{children:"Sincronizar Datos Cl\xednicos"})]})]}),(0,g.jsxs)("div",{className:"bg-gray-50 rounded-3xl p-8 border border-gray-100 flex flex-col justify-between hover:shadow-md transition-shadow",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"w-12 h-12 rounded-xl bg-green-100 text-green-600 flex items-center justify-center mb-4",children:(0,g.jsx)($.A,{className:"w-6 h-6"})}),(0,g.jsx)("h3",{className:"text-lg font-bold text-gray-900 mb-2",children:"Gestor de Documentos (JSON)"}),(0,g.jsxs)("p",{className:"text-sm text-gray-500 mb-6 leading-relaxed",children:["Consulta y edita el contenido actual de cualquier documento en Firestore. Puedes realizar modificaciones directas al JSON y guardarlas.",(0,g.jsx)("span",{className:"block mt-2 font-semibold text-red-600 text-xs",children:"Atenci\xf3n: Use con extremo cuidado, afecta directamente a la BD."})]})]}),(0,g.jsxs)("button",{onClick:async()=>{i().fire({title:"Gestor de Documentos",input:"text",inputLabel:"Ruta del Documento",inputPlaceholder:"Ej: attention/chile/DNI/TIMESTAMP",showCancelButton:!0,confirmButtonText:"Cargar Documento",cancelButtonText:"Cancelar"}).then(async e=>{if(e.isConfirmed&&e.value){const t=e.value;M(!0);try{const e=await o.doc(t).get();if(e.exists){const a=e.data(),s=e=>{if(Array.isArray(e))return e.map(e=>s(e));if(null!==e&&"object"===typeof e){if(void 0!==e.seconds&&void 0!==e.nanoseconds)return new Date(1e3*e.seconds).toISOString()+" (Timestamp)";const a={};for(let t in e)a[t]=s(e[t]);return a}return e},r=JSON.stringify(s(a),null,4);i().fire({title:"Editor de Datos Firestore",html:`\n                                <div class="text-left w-full px-2">\n                                    <div class="flex justify-between items-center mb-3">\n                                        <p class="text-[10px] text-gray-500 font-mono uppercase tracking-[0.2em]">${t}</p>\n                                    </div>\n                                    <textarea id="json-textarea" class="w-full h-[70vh] p-8 text-sm font-mono border-0 rounded-[32px] bg-[#050505] text-green-500 focus:outline-none scrollbar-thin scrollbar-thumb-gray-800 shadow-2xl selection:bg-green-500/30">${r}</textarea>\n                                </div>\n                            `,width:"95%",showCancelButton:!0,confirmButtonText:"Guardar Cambios",cancelButtonText:"Cerrar Visualizador",buttonsStyling:!1,customClass:{container:"z-[10000]",confirmButton:"mt-6 px-12 py-4 bg-saluta-p hover:bg-saluta-p_dark text-white rounded-2xl font-black transition-all shadow-xl active:scale-95 mr-4",cancelButton:"mt-6 px-12 py-4 bg-gray-900 text-white rounded-2xl font-black hover:bg-black transition-all shadow-xl active:scale-95"},preConfirm:()=>{const e=document.getElementById("json-textarea").value;try{return JSON.parse(e)}catch(a){return i().showValidationMessage("El JSON proporcionado no es v\xe1lido: "+a.message),!1}}}).then(async e=>{e.isConfirmed&&await(async(e,a)=>{M(!0);try{const t=e=>{if(Array.isArray(e))return e.map(e=>t(e));if(null!==e&&"object"===typeof e){const s={};for(let r in e){const l=e[r];if("string"===typeof l&&l.endsWith(" (Timestamp)"))try{const e=l.replace(" (Timestamp)","");s[r]=m.firestore.Timestamp.fromDate(new Date(e))}catch(a){s[r]=l}else s[r]=t(l)}return s}return e},s=t(a);await o.doc(e).set(s,{merge:!0}),(0,c.Sv)("Documento actualizado (Timestamps detectados y convertidos)")}catch(t){console.error(t),(0,c.n7)("Error en la actualizaci\xf3n: "+t.message)}finally{M(!1)}})(t,e.value)})}else(0,c.n7)("El documento no existe en esa ruta.")}catch(a){console.error(a),(0,c.n7)("Error al intentar leer el documento.")}finally{M(!1)}}})},disabled:L,className:"w-full py-4 bg-green-600 hover:bg-green-700 text-white rounded-2xl font-black shadow-lg shadow-green-600/20 transition-all flex items-center justify-center space-x-2 active:scale-95 disabled:opacity-50",children:[(0,g.jsx)($.A,{className:"w-5 h-5"}),(0,g.jsx)("span",{children:"Visualizar y Editar Documento"})]})]})]}),(0,g.jsx)("div",{className:"mx-8 mb-8 p-4 bg-yellow-50 border border-yellow-100 rounded-2xl",children:(0,g.jsxs)("div",{className:"flex items-start space-x-3",children:[(0,g.jsx)(y.A,{className:"w-5 h-5 text-yellow-600 mt-0.5"}),(0,g.jsxs)("div",{className:"text-xs text-yellow-800 leading-relaxed font-medium",children:[(0,g.jsx)("strong",{className:"block mb-1",children:"Nota importante:"}),'Ambos procesos son seguros y no eliminan citas existentes. Solo actualizan el estado de disponibilidad de los "slots" para que coincidan con la realidad de la agenda.']})]})})]})}),(0,g.jsxs)(f.o.Panel,{className:"focus:outline-none animate-in fade-in slide-in-from-bottom-2 duration-300",children:[(0,g.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6",children:[(0,g.jsx)(T,{title:"Pacientes",desc:"Permisos b\xe1sicos para clientes finales",icon:j.A,color:"red",onClick:()=>V("patient")}),(0,g.jsx)(T,{title:"M\xe9dicos / Doctores",desc:"Acceso completo a fichas y gesti\xf3n m\xe9dica",icon:N.A,color:"saluta-p",onClick:()=>V("doctor")}
1),(0,g.jsx)(T,{title:"Psic\xf3logos",desc:"Permisos especializados para salud mental",icon:j.A,color:"saluta-s",onClick:()=>V("psychologist")})]}),(0,g.jsxs)("div",{className:"mt-8 bg-blue-50/50 border border-blue-100 rounded-3xl p-8 flex items-center space-x-6",children:[(0,g.jsx)("div",{className:"hidden sm:flex w-20 h-20 rounded-full bg-blue-100 text-blue-600 items-center justify-center flex-shrink-0",children:(0,g.jsx)(N.A,{className:"w-10 h-10"})}),(0,g.jsxs)("div",{className:"flex-1",children:[(0,g.jsx)("h3",{className:"text-xl font-bold text-blue-900 mb-1",children:"Visualizaci\xf3n de Datos"}),(0,g.jsx)("p",{className:"text-blue-700/70 text-sm mb-4 leading-relaxed",children:"Verifica el estado actual de los objetos de usuario cargados en memoria."}),(0,g.jsx)("button",{onClick:()=>console.log(u),className:"px-6 py-2.5 bg-blue-600 hover:bg-blue-700 text-white font-bold rounded-xl transition-all shadow-md shadow-blue-600/20",children:"Log Usuarios en Consola"})]})]})]})]})]})})]})}},16251(){},67233(){},29800(){}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.