@mediquo/elements 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/dist/chunks/api-chat-client-CJ1EGJe3.js +1 -0
  2. package/dist/chunks/{apple-pay-outcomes-BONpT54d.js → apple-pay-outcomes-B1LrUXHR.js} +1 -1
  3. package/dist/chunks/{appointment-action-unavailable-dialog-BYse3uIa.d.ts → appointment-action-unavailable-dialog-CTiL4nMo.d.ts} +1 -1
  4. package/dist/chunks/{appointment-card-skeleton-C3mV8Ky1.d.ts → appointment-card-skeleton-C2Sim4nR.d.ts} +3 -3
  5. package/dist/chunks/appointment-card-skeleton-D8gypuKh.js +1 -0
  6. package/dist/chunks/document.model.d-DIzMiOmd.d.ts +6 -0
  7. package/dist/chunks/{documentation-view-GZI-DC3e.js → documentation-view-BbMbGneD.js} +1 -1
  8. package/dist/chunks/index-Bw-MbGKw.js +1 -0
  9. package/dist/chunks/{index-PGYfkbm6.js → index-D6Hg-beW.js} +1 -1
  10. package/dist/chunks/{index-CDBk7hVW.d.ts → index-DTEtqjQF.d.ts} +0 -13
  11. package/dist/chunks/{index-KhJ8hC0H.d.ts → index-Dbbpnw8f.d.ts} +1 -1
  12. package/dist/chunks/index-DdkeWQrh.d.ts +53 -0
  13. package/dist/chunks/index-Nf3nZ9O3.d.ts +16 -0
  14. package/dist/chunks/index-iaTXVzFa.js +1 -0
  15. package/dist/chunks/index-uHvVQMNc.js +1 -0
  16. package/dist/chunks/{index.d-Bl682CAX.d.ts → index.d-XSe7Hy-Q.d.ts} +12 -0
  17. package/dist/chunks/{mq-chat-room-t3j3Tq4o.d.ts → mq-chat-room-jeDvIF1Z.d.ts} +1 -1
  18. package/dist/chunks/{mq-layout-L3TlCxI0.js → mq-layout-E5mKSz4A.js} +1 -1
  19. package/dist/chunks/{mq-layout-D1j50tKd.d.ts → mq-layout-TG2K4zRv.d.ts} +2 -5
  20. package/dist/chunks/{telemetry-client-CoWay8es.js → telemetry-client-7fvNqUSU.js} +1 -1
  21. package/dist/env.js +1 -1
  22. package/dist/mq-api-client-provider.d.ts +1 -1
  23. package/dist/mq-api-client-provider.js +1 -1
  24. package/dist/mq-apple-pay-checkout.d.ts +1 -1
  25. package/dist/mq-apple-pay-checkout.js +1 -1
  26. package/dist/mq-appointment-checkout.d.ts +1 -1
  27. package/dist/mq-appointment-checkout.js +1 -1
  28. package/dist/mq-appointment-documentation.d.ts +4 -3
  29. package/dist/mq-appointment-documentation.js +1 -1
  30. package/dist/mq-chat-room.d.ts +2 -2
  31. package/dist/mq-chat-room.js +1 -1
  32. package/dist/mq-checkout.d.ts +1 -1
  33. package/dist/mq-checkout.js +1 -1
  34. package/dist/mq-dashboard.d.ts +7 -6
  35. package/dist/mq-dashboard.js +1 -1
  36. package/dist/mq-documents.d.ts +9 -5
  37. package/dist/mq-documents.js +1 -1
  38. package/dist/mq-google-pay-checkout.d.ts +1 -1
  39. package/dist/mq-google-pay-checkout.js +1 -1
  40. package/dist/mq-immediate-videocall-checkout.d.ts +1 -1
  41. package/dist/mq-immediate-videocall-checkout.js +1 -1
  42. package/dist/mq-my-appointments.d.ts +4 -4
  43. package/dist/mq-my-appointments.js +1 -1
  44. package/dist/mq-next-appointments.d.ts +5 -4
  45. package/dist/mq-next-appointments.js +1 -1
  46. package/dist/mq-payment-poller.d.ts +1 -1
  47. package/dist/mq-payment-poller.js +1 -1
  48. package/dist/mq-recent-documents.d.ts +10 -6
  49. package/dist/mq-recent-documents.js +1 -1
  50. package/dist/mq-schedule-success.d.ts +2 -2
  51. package/dist/mq-schedule-success.js +1 -1
  52. package/dist/mq-schedule.d.ts +2 -2
  53. package/dist/mq-schedule.js +1 -1
  54. package/dist/mq-support-chat.d.ts +3 -3
  55. package/dist/mq-support-chat.js +1 -1
  56. package/dist/mq-terms-and-conditions.d.ts +2 -2
  57. package/dist/mq-terms-and-conditions.js +1 -1
  58. package/dist/mq-videocall.d.ts +4 -3
  59. package/dist/mq-videocall.js +1 -1
  60. package/dist/react/mq-api-client-provider.d.ts +1 -1
  61. package/dist/react/mq-api-client-provider.js +1 -1
  62. package/dist/react/mq-apple-pay-checkout.d.ts +1 -1
  63. package/dist/react/mq-apple-pay-checkout.js +1 -1
  64. package/dist/react/mq-appointment-checkout.d.ts +1 -1
  65. package/dist/react/mq-appointment-checkout.js +1 -1
  66. package/dist/react/mq-appointment-documentation.d.ts +4 -3
  67. package/dist/react/mq-appointment-documentation.js +1 -1
  68. package/dist/react/mq-chat-room.d.ts +2 -2
  69. package/dist/react/mq-chat-room.js +1 -1
  70. package/dist/react/mq-checkout.d.ts +1 -1
  71. package/dist/react/mq-checkout.js +1 -1
  72. package/dist/react/mq-dashboard.d.ts +6 -5
  73. package/dist/react/mq-dashboard.js +1 -1
  74. package/dist/react/mq-documents-page.d.ts +5 -2
  75. package/dist/react/mq-documents-page.js +1 -1
  76. package/dist/react/mq-documents.d.ts +5 -2
  77. package/dist/react/mq-documents.js +1 -1
  78. package/dist/react/mq-google-pay-checkout.d.ts +1 -1
  79. package/dist/react/mq-google-pay-checkout.js +1 -1
  80. package/dist/react/mq-immediate-videocall-checkout.d.ts +1 -1
  81. package/dist/react/mq-immediate-videocall-checkout.js +1 -1
  82. package/dist/react/mq-my-appointments.d.ts +4 -4
  83. package/dist/react/mq-my-appointments.js +1 -1
  84. package/dist/react/mq-next-appointments.d.ts +5 -4
  85. package/dist/react/mq-next-appointments.js +1 -1
  86. package/dist/react/mq-payment-poller.d.ts +1 -1
  87. package/dist/react/mq-payment-poller.js +1 -1
  88. package/dist/react/mq-recent-documents.d.ts +6 -2
  89. package/dist/react/mq-recent-documents.js +1 -1
  90. package/dist/react/mq-schedule-success.d.ts +2 -2
  91. package/dist/react/mq-schedule-success.js +1 -1
  92. package/dist/react/mq-schedule.d.ts +1 -1
  93. package/dist/react/mq-schedule.js +1 -1
  94. package/dist/react/mq-support-chat.d.ts +2 -2
  95. package/dist/react/mq-support-chat.js +1 -1
  96. package/dist/react/mq-terms-and-conditions.d.ts +2 -2
  97. package/dist/react/mq-terms-and-conditions.js +1 -1
  98. package/dist/react/mq-videocall.d.ts +4 -3
  99. package/dist/react/mq-videocall.js +1 -1
  100. package/dist/ui/icons/download-02-icon.d.ts +6 -0
  101. package/dist/ui/icons/download-02-icon.js +1 -0
  102. package/package.json +1 -1
  103. package/dist/chunks/api-chat-client-pGZWREjK.js +0 -1
  104. package/dist/chunks/appointment-card-skeleton-CAQmlCTm.js +0 -1
  105. package/dist/chunks/index-6gxzoTLM.js +0 -1
  106. package/dist/chunks/index-CoZKmhwT.js +0 -1
@@ -1 +1 @@
1
- import{s as t}from"./chunk-6CCJWPGL-TiaqZaPV.js";function e(e,n){return{queryKey:t(e,"organization-specialties"),queryFn:()=>e.organizations.getOrganizationSpecialties(),...n}}function n(t,e){return{action_type:"event",event_type:"access to videocall button click",patient_hash:t,id_appointment:e}}function i(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function a(t,e){return{action_type:"event",event_type:"modify appoinment button click",patient_hash:t,id_appointment:e}}function o(t,e){return{action_type:"event",event_type:"cancel appoinment button click",patient_hash:t,id_appointment:e}}function p(t,e){return{action_type:"event",event_type:"view appointment document list button click",patient_hash:t,id_appointment:e}}function s(t,e){return{action_type:"event",event_type:"repeat appointment button click",patient_hash:t,id_appointment:e}}function c(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function _(t,e){return{action_type:"event",event_type:"access to videocall button click",patient_hash:t,id_appointment:e}}function r(t,e){return{action_type:"event",event_type:"add to calendar button click",patient_hash:t,id_appointment:e}}function l(t,e){return{action_type:"pageview",event_type:"appointment success page view",patient_hash:t,id_appointment:e}}function u(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function d(t,e){return{action_type:"event",event_type:"update documentation",patient_hash:t,id_appointment:e}}function y(t,e){return{action_type:"pageview",event_type:"documentation page view",patient_hash:t,id_appointment:e}}function h(t){return{action_type:"event",event_type:"view documentation list button click",patient_hash:t}}function v(t,e){return{action_type:"event",event_type:"download document button click",patient_hash:t,id_document:e}}function g(t){return{action_type:"event",event_type:"make an appointment button click",patient_hash:t}}function m(t){return{action_type:"event",event_type:"view appointment list button click",patient_hash:t}}function f(t){return{action_type:"pageview",event_type:"home page view",patient_hash:t}}function E(t,e,n){return{action_type:"event",event_type:"find availability button click",patient_hash:t,speciality_id:e,service_id:n}}function S(t,e,n,i,a,o,p){return{action_type:"debug",event_type:"find availability result",patient_hash:t,speciality_id:e,service_id:n,first_slot_date:i,first_slot_professional_hash:a,total_professionals:o,total_slots:p}}function k(t,e,n,i,a){return{action_type:"event",event_type:"professional schedule slot button click",patient_hash:t,professional_hash:e,start_date:n,speciality_id:i,service_id:a}}function b(t,e,n,i){return{action_type:"event",event_type:"professional availability button click",patient_hash:t,professional_hash:e,speciality_id:n,service_id:i}}function T(t,e,n,i,a){return{action_type:"event",event_type:"confirm appointment button click",patient_hash:t,professional_hash:e,start_date:n,speciality_id:i,service_id:a}}function w(t){return{action_type:"pageview",event_type:"select professional step page view",patient_hash:t}}function P(t,e){return{action_type:"pageview",event_type:"not time yet pageview",patient_hash:t,id_appointment:e}}function C(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function D(t,e){return{action_type:"pageview",event_type:"waiting room pageview",patient_hash:t,id_appointment:e}}function q(t,e){return{action_type:"pageview",event_type:"videocall pageview",patient_hash:t,id_appointment:e}}var K={digestive_system:{de_DE:"Verdauungssystem",en_US:"Digestive System",es_ES:"Aparato Digestivo",ca_ES:"Aparell Digestiu",pt_PT:"Aparelho Digestivo"},orthopedic_surgery_traumatology:{de_DE:"Traumatologie und Orthopädische Chirurgie",en_US:"Traumatology and Orthopedic Surgery",es_ES:"Traumatología y Cirugía Ortopédica",ca_ES:"Traumatologia i Cirurgia Ortopèdica",pt_PT:"Traumatologia e Cirurgia Ortopédica"},gynecology:{de_DE:"Gynäkologie",en_US:"Gynecology",es_ES:"Ginecología",ca_ES:"Ginecologia",pt_PT:"Ginecologia"},endocrinology:{de_DE:"Endokrinologie",en_US:"Endocrinology",es_ES:"Endocrinología",ca_ES:"Endocrinologia",pt_PT:"Endocrinologia"},psychiatry:{de_DE:"Psychiatrie",en_US:"Psychiatry",es_ES:"Psiquiatría",ca_ES:"Psiquiatria",pt_PT:"Psiquiatria"}},O={videocall:{de_DE:"Videosprechstunde",en_US:"Videocall",es_ES:"Videoconsulta",ca_ES:"Videoconsulta",pt_PT:"Videoconsulta"},phonecall:{de_DE:"Telefonische Behandlung",en_US:"Phone consultation",es_ES:"Consulta telefónica",ca_ES:"Consulta telefònica",pt_PT:"Consulta telefónica"}},U={de_DE:"Konsultationspreis",en_US:"Consultation price",es_ES:"Precio de consulta",ca_ES:"Preu de consulta",pt_PT:"Preço da consulta"},G={videocall:"videocall",phonecall:"phonecall",adeslas_videocall:"videocall",adeslas_prod_videocall:"videocall",adeslas_phonecall:"phonecall",adeslas_prod_phonecall:"phonecall"};function A(t,e,n){if(!t)return n??"";const i=G[t];return i?O[i][e]:n??U[e]}var V={consulta_telefonica:"phonecall",videoconsulta:"videocall"},x={"aparato-digestivo":"digestive_system","cirugia-ortopedica-y-traumatologia":"orthopedic_surgery_traumatology",ginecologia:"gynecology",endocrinologia:"endocrinology",psiquiatria:"psychiatry"};function z(t,e,n){const i=n?.trim();if(i)return i;const a=K[t]?.[e];return void 0!==a?a:t}class HttpTransport{endpoint;apiKey;constructor(t,e){this.endpoint=t,this.apiKey=e}send(t){fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(t)}).catch(()=>{})}}class MediquoTelemetryClient{_apiKey=null;_transport=null;setApiKey(t){this._apiKey=t,this._buildTransport()}track(t){null!==this._transport&&this._transport.send(t)}_buildTransport(){null!==this._apiKey&&(this._transport=new HttpTransport("https://tracking.____.mediquo.com/sdk",this._apiKey))}}const j=new class AppTelemetryClient extends MediquoTelemetryClient{track(t){}};export{k as A,b as B,S as C,w as D,P as E,C as F,D as G,q as H,V as S,z as a,y as b,d as c,v as d,u as e,a as f,e as g,o as h,s as i,n as j,p as k,i as l,l as m,r as n,c as o,_ as p,g as q,h as r,f as s,j as t,x as u,m as v,A as w,T as x,E as y,K as z};
1
+ import{s as t}from"./chunk-6CCJWPGL-TiaqZaPV.js";function e(e,n){return{queryKey:t(e,"organization-specialties"),queryFn:()=>e.organizations.getOrganizationSpecialties(),...n}}function n(t,e){return{action_type:"event",event_type:"access to videocall button click",patient_hash:t,id_appointment:e}}function i(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function a(t,e){return{action_type:"event",event_type:"modify appoinment button click",patient_hash:t,id_appointment:e}}function o(t,e){return{action_type:"event",event_type:"cancel appoinment button click",patient_hash:t,id_appointment:e}}function p(t,e){return{action_type:"event",event_type:"view appointment document list button click",patient_hash:t,id_appointment:e}}function s(t,e){return{action_type:"event",event_type:"repeat appointment button click",patient_hash:t,id_appointment:e}}function c(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function _(t,e){return{action_type:"event",event_type:"access to videocall button click",patient_hash:t,id_appointment:e}}function r(t,e){return{action_type:"event",event_type:"add to calendar button click",patient_hash:t,id_appointment:e}}function l(t,e){return{action_type:"pageview",event_type:"appointment success page view",patient_hash:t,id_appointment:e}}function u(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function d(t,e){return{action_type:"event",event_type:"update documentation",patient_hash:t,id_appointment:e}}function y(t,e){return{action_type:"pageview",event_type:"documentation page view",patient_hash:t,id_appointment:e}}function h(t){return{action_type:"event",event_type:"view documentation list button click",patient_hash:t}}function v(t,e){return{action_type:"event",event_type:"download document button click",patient_hash:t,id_document:e}}function g(t){return{action_type:"event",event_type:"make an appointment button click",patient_hash:t}}function m(t){return{action_type:"event",event_type:"view appointment list button click",patient_hash:t}}function f(t){return{action_type:"pageview",event_type:"home page view",patient_hash:t}}function E(t,e,n){return{action_type:"event",event_type:"find availability button click",patient_hash:t,speciality_id:e,service_id:n}}function S(t,e,n,i,a,o,p){return{action_type:"debug",event_type:"find availability result",patient_hash:t,speciality_id:e,service_id:n,first_slot_date:i,first_slot_professional_hash:a,total_professionals:o,total_slots:p}}function k(t,e,n,i,a){return{action_type:"event",event_type:"professional schedule slot button click",patient_hash:t,professional_hash:e,start_date:n,speciality_id:i,service_id:a}}function b(t,e,n,i){return{action_type:"event",event_type:"professional availability button click",patient_hash:t,professional_hash:e,speciality_id:n,service_id:i}}function T(t,e,n,i,a){return{action_type:"event",event_type:"confirm appointment button click",patient_hash:t,professional_hash:e,start_date:n,speciality_id:i,service_id:a}}function w(t){return{action_type:"pageview",event_type:"select professional step page view",patient_hash:t}}function P(t,e){return{action_type:"pageview",event_type:"not time yet pageview",patient_hash:t,id_appointment:e}}function C(t,e){return{action_type:"event",event_type:"open chat button click",patient_hash:t,id_appointment:e}}function D(t,e){return{action_type:"pageview",event_type:"waiting room pageview",patient_hash:t,id_appointment:e}}function q(t,e){return{action_type:"pageview",event_type:"videocall pageview",patient_hash:t,id_appointment:e}}var K={digestive_system:{de_DE:"Verdauungssystem",en_US:"Digestive System",es_ES:"Aparato Digestivo",ca_ES:"Aparell Digestiu",pt_PT:"Aparelho Digestivo"},orthopedic_surgery_traumatology:{de_DE:"Traumatologie und Orthopädische Chirurgie",en_US:"Traumatology and Orthopedic Surgery",es_ES:"Traumatología y Cirugía Ortopédica",ca_ES:"Traumatologia i Cirurgia Ortopèdica",pt_PT:"Traumatologia e Cirurgia Ortopédica"},gynecology:{de_DE:"Gynäkologie",en_US:"Gynecology",es_ES:"Ginecología",ca_ES:"Ginecologia",pt_PT:"Ginecologia"},endocrinology:{de_DE:"Endokrinologie",en_US:"Endocrinology",es_ES:"Endocrinología",ca_ES:"Endocrinologia",pt_PT:"Endocrinologia"},psychiatry:{de_DE:"Psychiatrie",en_US:"Psychiatry",es_ES:"Psiquiatría",ca_ES:"Psiquiatria",pt_PT:"Psiquiatria"}},O={videocall:{de_DE:"Videosprechstunde",en_US:"Videocall",es_ES:"Videoconsulta",ca_ES:"Videoconsulta",pt_PT:"Videoconsulta"},phonecall:{de_DE:"Telefonische Behandlung",en_US:"Phone consultation",es_ES:"Consulta telefónica",ca_ES:"Consulta telefònica",pt_PT:"Consulta telefónica"}},U={de_DE:"Konsultationspreis",en_US:"Consultation price",es_ES:"Precio de consulta",ca_ES:"Preu de consulta",pt_PT:"Preço da consulta"},G={videocall:"videocall",phonecall:"phonecall",adeslas_videocall:"videocall",adeslas_prod_videocall:"videocall",adeslas_phonecall:"phonecall",adeslas_prod_phonecall:"phonecall"};function A(t,e,n){if(!t)return n??"";const i=G[t];return i?O[i][e]:n??U[e]}var V={consulta_telefonica:"phonecall",videoconsulta:"videocall"},x={"aparato-digestivo":"digestive_system","cirugia-ortopedica-y-traumatologia":"orthopedic_surgery_traumatology",ginecologia:"gynecology",endocrinologia:"endocrinology",psiquiatria:"psychiatry"};function z(t,e,n){const i=n?.trim();if(i)return i;const a=K[t]?.[e];return void 0!==a?a:t}class HttpTransport{endpoint;apiKey;constructor(t,e){this.endpoint=t,this.apiKey=e}send(t){fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":this.apiKey},body:JSON.stringify(t)}).catch(()=>{})}}class MediquoTelemetryClient{_apiKey=null;_transport=null;setApiKey(t){this._apiKey=t,this._buildTransport()}track(t){null!==this._transport&&this._transport.send(t)}_buildTransport(){null!==this._apiKey&&(this._transport=new HttpTransport("https://tracking.____.mediquo.com/sdk",this._apiKey))}}const j=new class AppTelemetryClient extends MediquoTelemetryClient{track(t){}};export{k as A,b as B,S as C,w as D,P as E,C as F,D as G,q as H,V as S,e as a,y as b,d as c,v as d,u as e,a as f,z as g,o as h,s as i,n as j,p as k,i as l,l as m,r as n,c as o,_ as p,g as q,h as r,f as s,j as t,x as u,m as v,A as w,T as x,E as y,K as z};
package/dist/env.js CHANGED
@@ -1 +1 @@
1
- const E="https://mediquo-landing.s3.eu-central-1.amazonaws.com/sdk-web/elements",o="production",e="0.8.1",n={development:{MODE:"development",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"47836441",ASSETS_BASE_URL:E},production:{MODE:"production",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"46655102",ASSETS_BASE_URL:E}};let t=o;const _=new Proxy({},{get:(E,o)=>n[t??"production"][o]});function S(E){t=E}export{E as ASSETS_BASE_URL,_ as env,S as setEnv};
1
+ const E="https://mediquo-landing.s3.eu-central-1.amazonaws.com/sdk-web/elements",o="production",e="0.8.2",n={development:{MODE:"development",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"47836441",ASSETS_BASE_URL:E},production:{MODE:"production",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"46655102",ASSETS_BASE_URL:E}};let t=o;const _=new Proxy({},{get:(E,o)=>n[t??"production"][o]});function S(E){t=E}export{E as ASSETS_BASE_URL,_ as env,S as setEnv};
@@ -1,5 +1,5 @@
1
1
  import * as lit_html from 'lit-html';
2
- import { M as MediquoApiChatClient } from './chunks/index.d-Bl682CAX.js';
2
+ import { M as MediquoApiChatClient } from './chunks/index.d-XSe7Hy-Q.js';
3
3
  import { LitElement, PropertyValues } from 'lit';
4
4
  import { Env } from './env.js';
5
5
  import 'axios';
@@ -1 +1 @@
1
- import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{e as o}from"./chunks/provide-BwI4DDGF.js";import{A as i}from"./chunks/api-client-context-V1UAGtKW.js";import{a as r,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n}from"./chunks/property-scuRaFcM.js";import{r as p}from"./chunks/state-LQivXIgA.js";import{setEnv as c}from"./env.js";import{c as a,n as m}from"./chunks/api-chat-client-pGZWREjK.js";import{e as h}from"./chunks/ensure-context-root-DbdqwnKB.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";h();let u=class MqApiClientProvider extends r{constructor(){super(...arguments),this.apiClient=a()}willUpdate(t){t.has("env")&&this.env&&c(this.env);const e=m(t,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale});e&&(this.apiClient=e)}render(){return s`<slot></slot>`}};t([n({type:String,attribute:"api-key"})],u.prototype,"apiKey",void 0),t([n({type:String,attribute:"token"})],u.prototype,"token",void 0),t([n({type:String,attribute:"locale"})],u.prototype,"locale",void 0),t([n({type:String,attribute:"env"})],u.prototype,"env",void 0),t([o({context:i}),p()],u.prototype,"apiClient",void 0),u=t([e("mq-api-client-provider")],u);export{u as MqApiClientProvider};
1
+ import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{e as o}from"./chunks/provide-BwI4DDGF.js";import{A as i}from"./chunks/api-client-context-V1UAGtKW.js";import{a as r,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n}from"./chunks/property-scuRaFcM.js";import{r as p}from"./chunks/state-LQivXIgA.js";import{setEnv as c}from"./env.js";import{c as a,n as m}from"./chunks/api-chat-client-CJ1EGJe3.js";import{e as h}from"./chunks/ensure-context-root-DbdqwnKB.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";h();let u=class MqApiClientProvider extends r{constructor(){super(...arguments),this.apiClient=a()}willUpdate(t){t.has("env")&&this.env&&c(this.env);const e=m(t,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale});e&&(this.apiClient=e)}render(){return s`<slot></slot>`}};t([n({type:String,attribute:"api-key"})],u.prototype,"apiKey",void 0),t([n({type:String,attribute:"token"})],u.prototype,"token",void 0),t([n({type:String,attribute:"locale"})],u.prototype,"locale",void 0),t([n({type:String,attribute:"env"})],u.prototype,"env",void 0),t([o({context:i}),p()],u.prototype,"apiClient",void 0),u=t([e("mq-api-client-provider")],u);export{u as MqApiClientProvider};
@@ -1,6 +1,6 @@
1
1
  import * as lit from 'lit';
2
2
  import { LitElement, PropertyValues } from 'lit';
3
- import { M as MediquoApiChatClient } from './chunks/index.d-Bl682CAX.js';
3
+ import { M as MediquoApiChatClient } from './chunks/index.d-XSe7Hy-Q.js';
4
4
  import { Env } from './env.js';
5
5
  import { Locale } from './i18n.js';
6
6
  import 'axios';
@@ -1 +1 @@
1
- import{_ as e,c as t}from"./chunks/custom-element-D2ziPxYE.js";import{e as a}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{m as s}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{A as o}from"./chunks/api-client-context-V1UAGtKW.js";import{L as r}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as l,a as c,x as h}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as y}from"./chunks/state-LQivXIgA.js";import{setEnv as d}from"./env.js";import{initLocalization as m,setLocale as v,isValidLocale as k}from"./i18n.js";import{c as b,n as f}from"./chunks/api-chat-client-pGZWREjK.js";import{u as P,s as _,r as E}from"./chunks/apple-pay-outcomes-BONpT54d.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/external-CJj32K_p.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";function g(){if("undefined"==typeof navigator)return!1;const e=navigator.userAgent;return/Safari/i.test(e)&&!/Chrome|Chromium|Edg|OPR|Firefox|FxiOS/i.test(e)}async function S(e){if("undefined"==typeof window||!window.isSecureContext)return{available:!1,reason:"unsupported"};if(!function(){if("undefined"==typeof window)return!1;const e="undefined"!=typeof ApplePaySession&&"function"==typeof ApplePaySession.canMakePayments,t="undefined"!=typeof customElements&&void 0!==customElements.get("apple-pay-button");return e&&t}())return{available:!1,reason:"sdk-missing"};if(!e.trim())return{available:!1,reason:"merchant-id-missing"};const t=ApplePaySession;if(function(e){return"function"==typeof e.applePayCapabilities}(t))try{return function(e){switch(e){case"applePayUnsupported":return{available:!1,reason:"unsupported"};case"paymentCredentialsUnavailable":case"paymentCredentialsAvailable":case"paymentCredentialStatusUnknown":return{available:!0,usesQrFlow:!g()}}}((await t.applePayCapabilities(e)).paymentCredentialStatus)}catch{return t.canMakePayments()?{available:!0,usesQrFlow:!g()}:{available:!1,reason:"unsupported"}}return t.canMakePayments()?{available:!0,usesQrFlow:!g()}:{available:!1,reason:"unsupported"}}const A={es_ES:"es-ES",en_US:"en-US",pt_PT:"pt-PT",de_DE:"de-DE",ca_ES:"ca-ES"};try{m()}catch{}const C=["visa","masterCard","amex"],w=["supports3DS"],x=l`:host{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:12px;width:100%;min-height:48px}.helper{margin:0;text-align:center;font-family:system-ui,sans-serif;font-size:13px;line-height:1.4;color:#6e6e73}.pay-row{display:block;width:100%}.pay-row--paying{opacity:.55;pointer-events:none}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:48px;--apple-pay-button-border-radius:10px;--apple-pay-button-padding:0;display:block;width:100%;min-height:48px;cursor:pointer}.state{text-align:center;font-family:system-ui,sans-serif;font-size:15px;color:#86868b;margin:0}`;class ApplePayCheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(ApplePayCheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(e){super(ApplePayCheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(e){super(ApplePayCheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}function j(e,t){p.warn(e,{error:t instanceof Error?t.message:String(t)})}let T=class MqApplePayCheckout extends c{constructor(){super(...arguments),this._availabilityPhase="checking",this._showQrHelper=!1,this._paying=!1,this._suppressCancelEvent=!1,this._availabilityGeneration=0,this.apiClient=b(),this._loginTokenTask=new r(this,()=>this.apiClient,{args:()=>[this.apiKey,this.token],onComplete:e=>{this._sessionToken=e.access_token,this.apiClient.setAuthToken(e.access_token),this._refreshAvailability()},onError:()=>{this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"auth"}))}}),this._onPayClick=()=>{if(this._paying||"ready"!==this._availabilityPhase)return;let e;try{e=new ApplePaySession(3,this._buildPaymentRequest())}catch(e){return j("mq-apple-pay-checkout: failed to create ApplePaySession",e),void this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}this._paying=!0,this._suppressCancelEvent=!1,e.onvalidatemerchant=async t=>{try{const a=await this.apiClient.payments.validateApplePayMerchant({order_id:this.sessionId,validation_url:t.validationURL});e.completeMerchantValidation(P(a))}catch(t){j("mq-apple-pay-checkout: validate-merchant failed",t),this._suppressCancelEvent=!0,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"merchant"})),e.abort(),this._paying=!1}},e.onpaymentauthorized=async t=>{try{const a=await this.apiClient.payments.authorizeApplePay({order_id:this.sessionId,token:_(t.payment.token)}),{status:i,consultation_id:s}=a.data,n=E(i,s,this.sessionId);switch(n.kind){case"success":e.completePayment(ApplePaySession.STATUS_SUCCESS),this.dispatchEvent(new ApplePayCheckoutSuccessEvent({sessionId:n.sessionId,reference:n.reference}));break;case"denied":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutDeniedEvent({sessionId:n.sessionId}));break;case"error":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:n.reason}))}}catch(t){j("mq-apple-pay-checkout: authorize failed",t),e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"authorize"}))}finally{this._paying=!1}},e.oncancel=()=>{this._paying=!1,this._suppressCancelEvent?this._suppressCancelEvent=!1:this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"cancelled"}))};try{e.begin()}catch(e){j("mq-apple-pay-checkout: session.begin() failed",e),this._paying=!1,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}}}static{this.styles=x}willUpdate(e){e.has("env")&&this.env&&d(this.env),e.has("locale")&&v(k(this.locale)?this.locale:"es_ES");const t=f(e,{env:this.env,apiKey:this.apiKey,token:this._sessionToken,locale:k(this.locale)?this.locale:"es_ES"},this.inheritedApiClient);t&&(this.apiClient=t),e.has("merchantId")&&this._loginTokenTask.value&&this._refreshAvailability()}async _refreshAvailability(){const e=++this._availabilityGeneration;this._availabilityPhase="checking",this._showQrHelper=!1;const t=await S(this.merchantId??"");e===this._availabilityGeneration&&(t.available?(this._availabilityPhase="ready",this._showQrHelper=t.usesQrFlow):this._availabilityPhase="unavailable")}get _resolvedLocale(){return k(this.locale)?this.locale:"es_ES"}_buildPaymentRequest(){return{countryCode:this.country,currencyCode:this.currency,supportedNetworks:[...C],merchantCapabilities:[...w],total:{label:this.label,amount:this.amount}}}_renderUnavailable(){return this.merchantId?.trim()?"undefined"==typeof ApplePaySession?h`<p class="state">${s("No se ha podido cargar Apple Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`:h`<p class="state">${s("Apple Pay no está disponible")}</p>`:h`<p class="state">${s("Falta el identificador de comercio de Apple Pay")}</p>`}render(){return this._loginTokenTask.render({pending:()=>h`<p class="state">${s("Preparando Apple Pay…")}</p>`,error:()=>h`<p class="state">${s("No hemos podido iniciar el pago")}</p>`,complete:()=>{return"checking"===this._availabilityPhase?h`<p class="state">${s("Comprobando Apple Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():h`${this._showQrHelper?h`<p class="helper">${s("Para pagar con Apple Pay, escanea el código QR con tu iPhone (iOS 18 o posterior) y confirma el pago.")}</p>`:null}<div class="pay-row ${this._paying?"pay-row--paying":""}"><apple-pay-button buttonstyle="black" type="pay" locale="${e=this._resolvedLocale,A[e]??"es-ES"}" aria-label="${s("Pagar con Apple Pay")}" @click="${this._onPayClick}"></apple-pay-button></div>`;var e}})}};e([u({type:String,attribute:"env"})],T.prototype,"env",void 0),e([u({type:String,attribute:"api-key"})],T.prototype,"apiKey",void 0),e([u({type:String,attribute:"token"})],T.prototype,"token",void 0),e([u({type:String,attribute:"locale",reflect:!0})],T.prototype,"locale",void 0),e([u({type:String,attribute:"merchant-id"})],T.prototype,"merchantId",void 0),e([u({type:String,attribute:"session-id"})],T.prototype,"sessionId",void 0),e([u({type:String,attribute:"amount"})],T.prototype,"amount",void 0),e([u({type:String,attribute:"currency"})],T.prototype,"currency",void 0),e([u({type:String,attribute:"country"})],T.prototype,"country",void 0),e([u({type:String,attribute:"label"})],T.prototype,"label",void 0),e([y()],T.prototype,"_availabilityPhase",void 0),e([y()],T.prototype,"_showQrHelper",void 0),e([y()],T.prototype,"_paying",void 0),e([i({context:o,subscribe:!0}),y()],T.prototype,"inheritedApiClient",void 0),e([a({context:o}),y()],T.prototype,"apiClient",void 0),T=e([n(),t("mq-apple-pay-checkout")],T);export{ApplePayCheckoutDeniedEvent,ApplePayCheckoutErrorEvent,ApplePayCheckoutSuccessEvent,T as MqApplePayCheckout};
1
+ import{_ as e,c as t}from"./chunks/custom-element-D2ziPxYE.js";import{e as a}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{m as s}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{A as o}from"./chunks/api-client-context-V1UAGtKW.js";import{L as r}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as l,a as c,x as h}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as y}from"./chunks/state-LQivXIgA.js";import{setEnv as d}from"./env.js";import{initLocalization as m,setLocale as v,isValidLocale as k}from"./i18n.js";import{c as b,n as f}from"./chunks/api-chat-client-CJ1EGJe3.js";import{u as P,s as _,r as E}from"./chunks/apple-pay-outcomes-B1LrUXHR.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/external-CJj32K_p.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";function g(){if("undefined"==typeof navigator)return!1;const e=navigator.userAgent;return/Safari/i.test(e)&&!/Chrome|Chromium|Edg|OPR|Firefox|FxiOS/i.test(e)}async function S(e){if("undefined"==typeof window||!window.isSecureContext)return{available:!1,reason:"unsupported"};if(!function(){if("undefined"==typeof window)return!1;const e="undefined"!=typeof ApplePaySession&&"function"==typeof ApplePaySession.canMakePayments,t="undefined"!=typeof customElements&&void 0!==customElements.get("apple-pay-button");return e&&t}())return{available:!1,reason:"sdk-missing"};if(!e.trim())return{available:!1,reason:"merchant-id-missing"};const t=ApplePaySession;if(function(e){return"function"==typeof e.applePayCapabilities}(t))try{return function(e){switch(e){case"applePayUnsupported":return{available:!1,reason:"unsupported"};case"paymentCredentialsUnavailable":case"paymentCredentialsAvailable":case"paymentCredentialStatusUnknown":return{available:!0,usesQrFlow:!g()}}}((await t.applePayCapabilities(e)).paymentCredentialStatus)}catch{return t.canMakePayments()?{available:!0,usesQrFlow:!g()}:{available:!1,reason:"unsupported"}}return t.canMakePayments()?{available:!0,usesQrFlow:!g()}:{available:!1,reason:"unsupported"}}const A={es_ES:"es-ES",en_US:"en-US",pt_PT:"pt-PT",de_DE:"de-DE",ca_ES:"ca-ES"};try{m()}catch{}const C=["visa","masterCard","amex"],w=["supports3DS"],x=l`:host{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:12px;width:100%;min-height:48px}.helper{margin:0;text-align:center;font-family:system-ui,sans-serif;font-size:13px;line-height:1.4;color:#6e6e73}.pay-row{display:block;width:100%}.pay-row--paying{opacity:.55;pointer-events:none}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:48px;--apple-pay-button-border-radius:10px;--apple-pay-button-padding:0;display:block;width:100%;min-height:48px;cursor:pointer}.state{text-align:center;font-family:system-ui,sans-serif;font-size:15px;color:#86868b;margin:0}`;class ApplePayCheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(ApplePayCheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(e){super(ApplePayCheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(e){super(ApplePayCheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}function j(e,t){p.warn(e,{error:t instanceof Error?t.message:String(t)})}let T=class MqApplePayCheckout extends c{constructor(){super(...arguments),this._availabilityPhase="checking",this._showQrHelper=!1,this._paying=!1,this._suppressCancelEvent=!1,this._availabilityGeneration=0,this.apiClient=b(),this._loginTokenTask=new r(this,()=>this.apiClient,{args:()=>[this.apiKey,this.token],onComplete:e=>{this._sessionToken=e.access_token,this.apiClient.setAuthToken(e.access_token),this._refreshAvailability()},onError:()=>{this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"auth"}))}}),this._onPayClick=()=>{if(this._paying||"ready"!==this._availabilityPhase)return;let e;try{e=new ApplePaySession(3,this._buildPaymentRequest())}catch(e){return j("mq-apple-pay-checkout: failed to create ApplePaySession",e),void this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}this._paying=!0,this._suppressCancelEvent=!1,e.onvalidatemerchant=async t=>{try{const a=await this.apiClient.payments.validateApplePayMerchant({order_id:this.sessionId,validation_url:t.validationURL});e.completeMerchantValidation(P(a))}catch(t){j("mq-apple-pay-checkout: validate-merchant failed",t),this._suppressCancelEvent=!0,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"merchant"})),e.abort(),this._paying=!1}},e.onpaymentauthorized=async t=>{try{const a=await this.apiClient.payments.authorizeApplePay({order_id:this.sessionId,token:_(t.payment.token)}),{status:i,consultation_id:s}=a.data,n=E(i,s,this.sessionId);switch(n.kind){case"success":e.completePayment(ApplePaySession.STATUS_SUCCESS),this.dispatchEvent(new ApplePayCheckoutSuccessEvent({sessionId:n.sessionId,reference:n.reference}));break;case"denied":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutDeniedEvent({sessionId:n.sessionId}));break;case"error":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:n.reason}))}}catch(t){j("mq-apple-pay-checkout: authorize failed",t),e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"authorize"}))}finally{this._paying=!1}},e.oncancel=()=>{this._paying=!1,this._suppressCancelEvent?this._suppressCancelEvent=!1:this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"cancelled"}))};try{e.begin()}catch(e){j("mq-apple-pay-checkout: session.begin() failed",e),this._paying=!1,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}}}static{this.styles=x}willUpdate(e){e.has("env")&&this.env&&d(this.env),e.has("locale")&&v(k(this.locale)?this.locale:"es_ES");const t=f(e,{env:this.env,apiKey:this.apiKey,token:this._sessionToken,locale:k(this.locale)?this.locale:"es_ES"},this.inheritedApiClient);t&&(this.apiClient=t),e.has("merchantId")&&this._loginTokenTask.value&&this._refreshAvailability()}async _refreshAvailability(){const e=++this._availabilityGeneration;this._availabilityPhase="checking",this._showQrHelper=!1;const t=await S(this.merchantId??"");e===this._availabilityGeneration&&(t.available?(this._availabilityPhase="ready",this._showQrHelper=t.usesQrFlow):this._availabilityPhase="unavailable")}get _resolvedLocale(){return k(this.locale)?this.locale:"es_ES"}_buildPaymentRequest(){return{countryCode:this.country,currencyCode:this.currency,supportedNetworks:[...C],merchantCapabilities:[...w],total:{label:this.label,amount:this.amount}}}_renderUnavailable(){return this.merchantId?.trim()?"undefined"==typeof ApplePaySession?h`<p class="state">${s("No se ha podido cargar Apple Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`:h`<p class="state">${s("Apple Pay no está disponible")}</p>`:h`<p class="state">${s("Falta el identificador de comercio de Apple Pay")}</p>`}render(){return this._loginTokenTask.render({pending:()=>h`<p class="state">${s("Preparando Apple Pay…")}</p>`,error:()=>h`<p class="state">${s("No hemos podido iniciar el pago")}</p>`,complete:()=>{return"checking"===this._availabilityPhase?h`<p class="state">${s("Comprobando Apple Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():h`${this._showQrHelper?h`<p class="helper">${s("Para pagar con Apple Pay, escanea el código QR con tu iPhone (iOS 18 o posterior) y confirma el pago.")}</p>`:null}<div class="pay-row ${this._paying?"pay-row--paying":""}"><apple-pay-button buttonstyle="black" type="pay" locale="${e=this._resolvedLocale,A[e]??"es-ES"}" aria-label="${s("Pagar con Apple Pay")}" @click="${this._onPayClick}"></apple-pay-button></div>`;var e}})}};e([u({type:String,attribute:"env"})],T.prototype,"env",void 0),e([u({type:String,attribute:"api-key"})],T.prototype,"apiKey",void 0),e([u({type:String,attribute:"token"})],T.prototype,"token",void 0),e([u({type:String,attribute:"locale",reflect:!0})],T.prototype,"locale",void 0),e([u({type:String,attribute:"merchant-id"})],T.prototype,"merchantId",void 0),e([u({type:String,attribute:"session-id"})],T.prototype,"sessionId",void 0),e([u({type:String,attribute:"amount"})],T.prototype,"amount",void 0),e([u({type:String,attribute:"currency"})],T.prototype,"currency",void 0),e([u({type:String,attribute:"country"})],T.prototype,"country",void 0),e([u({type:String,attribute:"label"})],T.prototype,"label",void 0),e([y()],T.prototype,"_availabilityPhase",void 0),e([y()],T.prototype,"_showQrHelper",void 0),e([y()],T.prototype,"_paying",void 0),e([i({context:o,subscribe:!0}),y()],T.prototype,"inheritedApiClient",void 0),e([a({context:o}),y()],T.prototype,"apiClient",void 0),T=e([n(),t("mq-apple-pay-checkout")],T);export{ApplePayCheckoutDeniedEvent,ApplePayCheckoutErrorEvent,ApplePayCheckoutSuccessEvent,T as MqApplePayCheckout};
@@ -1,5 +1,5 @@
1
1
  import * as lit_html from 'lit-html';
2
- import { C as CreatePaymentLinkRequest } from './chunks/index.d-Bl682CAX.js';
2
+ import { C as CreatePaymentLinkRequest } from './chunks/index.d-XSe7Hy-Q.js';
3
3
  import { LitElement } from 'lit';
4
4
  import { Env } from './env.js';
5
5
  import { Locale } from './i18n.js';
@@ -1 +1 @@
1
- import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{a as o,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n as i}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import"./mq-checkout.js";import"./chunks/provide-BwI4DDGF.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/consume-CovVqBjI.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/api-chat-client-pGZWREjK.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";import"./chunks/api-client-context-V1UAGtKW.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/login-token-task-Yib__6a9.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";class AppointmentPaidEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(AppointmentPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}let r=class MqAppointmentCheckout extends o{constructor(){super(...arguments),this._provideSession=async t=>{const e=await t.payments.createPaymentLink({slot_id:this.slotId,service_id:this.serviceId,specialty_id:this.specialtyId,consultation_reason:this.consultationReason,discount_code:this.discountCode,preconsultation_documents:this.preconsultationDocuments});return{sessionId:e.session_id,paymentUrl:e.payment_link}},this._onSuccess=t=>{t.stopPropagation(),this.dispatchEvent(new AppointmentPaidEvent({appointmentId:t.detail.reference}))}}render(){return s`<mq-checkout env="${n(this.env)}" api-key="${this.apiKey}" token="${this.token}" locale="${this.locale}" .provideSession="${this._provideSession}" @payment-success="${this._onSuccess}"></mq-checkout>`}};t([i({type:String,attribute:"env"})],r.prototype,"env",void 0),t([i({type:String,attribute:"api-key"})],r.prototype,"apiKey",void 0),t([i({type:String,attribute:"token"})],r.prototype,"token",void 0),t([i({type:String,attribute:"locale",reflect:!0})],r.prototype,"locale",void 0),t([i({type:String,attribute:"slot-id"})],r.prototype,"slotId",void 0),t([i({type:String,attribute:"service-id"})],r.prototype,"serviceId",void 0),t([i({type:String,attribute:"specialty-id"})],r.prototype,"specialtyId",void 0),t([i({type:String,attribute:"consultation-reason"})],r.prototype,"consultationReason",void 0),t([i({type:String,attribute:"discount-code"})],r.prototype,"discountCode",void 0),t([i({attribute:!1})],r.prototype,"preconsultationDocuments",void 0),r=t([e("mq-appointment-checkout")],r);export{AppointmentPaidEvent,r as MqAppointmentCheckout};
1
+ import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{a as o,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n as i}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import"./mq-checkout.js";import"./chunks/provide-BwI4DDGF.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/consume-CovVqBjI.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/api-chat-client-CJ1EGJe3.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";import"./chunks/api-client-context-V1UAGtKW.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/login-token-task-Yib__6a9.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";class AppointmentPaidEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(AppointmentPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}let r=class MqAppointmentCheckout extends o{constructor(){super(...arguments),this._provideSession=async t=>{const e=await t.payments.createPaymentLink({slot_id:this.slotId,service_id:this.serviceId,specialty_id:this.specialtyId,consultation_reason:this.consultationReason,discount_code:this.discountCode,preconsultation_documents:this.preconsultationDocuments});return{sessionId:e.session_id,paymentUrl:e.payment_link}},this._onSuccess=t=>{t.stopPropagation(),this.dispatchEvent(new AppointmentPaidEvent({appointmentId:t.detail.reference}))}}render(){return s`<mq-checkout env="${n(this.env)}" api-key="${this.apiKey}" token="${this.token}" locale="${this.locale}" .provideSession="${this._provideSession}" @payment-success="${this._onSuccess}"></mq-checkout>`}};t([i({type:String,attribute:"env"})],r.prototype,"env",void 0),t([i({type:String,attribute:"api-key"})],r.prototype,"apiKey",void 0),t([i({type:String,attribute:"token"})],r.prototype,"token",void 0),t([i({type:String,attribute:"locale",reflect:!0})],r.prototype,"locale",void 0),t([i({type:String,attribute:"slot-id"})],r.prototype,"slotId",void 0),t([i({type:String,attribute:"service-id"})],r.prototype,"serviceId",void 0),t([i({type:String,attribute:"specialty-id"})],r.prototype,"specialtyId",void 0),t([i({type:String,attribute:"consultation-reason"})],r.prototype,"consultationReason",void 0),t([i({type:String,attribute:"discount-code"})],r.prototype,"discountCode",void 0),t([i({attribute:!1})],r.prototype,"preconsultationDocuments",void 0),r=t([e("mq-appointment-checkout")],r);export{AppointmentPaidEvent,r as MqAppointmentCheckout};
@@ -1,14 +1,14 @@
1
1
  import * as lit_html from 'lit-html';
2
- import { M as MediquoApiChatClient } from './chunks/index.d-Bl682CAX.js';
2
+ import { M as MediquoApiChatClient } from './chunks/index.d-XSe7Hy-Q.js';
3
3
  import { LitElement, PropertyValues } from 'lit';
4
4
  import { Env } from './env.js';
5
5
  import './ui/mq-button.js';
6
- import './chunks/mq-chat-room-t3j3Tq4o.js';
6
+ import './chunks/mq-chat-room-jeDvIF1Z.js';
7
7
  import './ui/mq-floating-bubble.js';
8
8
  import './ui/mq-card.js';
9
9
  import './ui/mq-unread-badge.js';
10
10
  import './ui/mq-page-title.js';
11
- import './chunks/mq-layout-D1j50tKd.js';
11
+ import './chunks/mq-layout-TG2K4zRv.js';
12
12
  import 'axios';
13
13
  import 'zod';
14
14
  import './chunks/schemas.d-b6_AekBb.js';
@@ -16,6 +16,7 @@ import './ui/mq-avatar.js';
16
16
  import './ui/mq-skeleton.js';
17
17
  import './chunks/appointment.model.d-BWwBLaEL.js';
18
18
  import '@tanstack/query-core';
19
+ import './chunks/document.model.d-DIzMiOmd.js';
19
20
 
20
21
  /**
21
22
  * Standalone "appointment documentation" screen: fetches an appointment by id
@@ -1 +1 @@
1
- import{isValidLocale as t,setLocale as e,initLocalization as i}from"./i18n.js";import{_ as s,c as o}from"./chunks/custom-element-D2ziPxYE.js";import{e as r}from"./chunks/provide-BwI4DDGF.js";import{c as n}from"./chunks/consume-CovVqBjI.js";import{Q as a}from"./chunks/query-controller-BlO1Ax65.js";import{A as c}from"./chunks/api-client-context-V1UAGtKW.js";import{g as p}from"./chunks/get-appointment-query-C-gTTuiQ.js";import{a as d,i as m,x as l}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as k}from"./chunks/state-LQivXIgA.js";import{setEnv as h}from"./env.js";import{c as v,n as j}from"./chunks/api-chat-client-pGZWREjK.js";import"./chunks/documentation-view-GZI-DC3e.js";import"./ui/mq-card.js";import"./chunks/mq-layout-L3TlCxI0.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/external-CJj32K_p.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/addSeconds-ofMnxlgT.js";import"./ui/icons/calendar-icon.js";import"./ui/icons/types.js";import"./ui/icons/clock-icon.js";import"./ui/icons/info-circle-outine-icon.js";import"./ui/mq-button.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/if-defined-BYeVdwgd.js";import"./chunks/chunk-S5RWG6G2-DPesx3Od.js";import"./ui/icons/message-bubble-icon.js";import"./mq-chat-room.js";import"./theme.js";import"./ui/icons/x-icon.js";import"./ui/mq-avatar.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./events.js";import"./chunks/chunk-Y4EKUX25-QqMl3eiq.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import"./chunks/mutation-controller-CR2qcqhH.js";import"./ui/mq-floating-bubble.js";import"./ui/mq-unread-badge.js";import"./ui/mq-page-title.js";import"./ui/icons/arrow-narrow-left-icon.js";import"./chunks/telemetry-client-CoWay8es.js";import"./ui/icons/download-icon.js";import"./chunks/blob-to-base64-CUL1trde.js";let b=class DocumentationViewSkeleton extends d{static{this.styles=m`.skeleton{border-radius:var(--border-radius-md);background-color:#f0f0f0;animation:skeleton-pulse 1.5s infinite}.page-title-skeleton{display:flex;align-items:center;gap:var(--sp-3);margin-bottom:var(--size-3)}.back-button-skeleton{width:var(--size-10);height:var(--size-10);border-radius:var(--border-radius-full);flex-shrink:0}.title-bar-skeleton{width:120px;height:24px;border-radius:var(--border-radius-sm)}@media (min-width:768px){.page-title-skeleton{gap:var(--sp-6)}.title-bar-skeleton{width:200px;height:32px}}.description-skeleton{width:100%;height:16px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-2)}.description-skeleton:last-of-type{width:70%;margin-bottom:var(--size-5)}.professional-card{padding:var(--size-4);margin-bottom:var(--size-4)}.professional-name-skeleton{width:180px;height:24px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-1)}.professional-speciality-skeleton{width:140px;height:16px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-4)}.description-list{display:flex;flex-direction:column;gap:var(--size-4)}.description-list-item{display:flex;flex-direction:row;align-items:center;gap:var(--size-2);font-family:var(--font-body)}.icon-skeleton{width:20px;height:20px;border-radius:var(--border-radius-sm)}.text-skeleton{width:120px;height:16px;border-radius:var(--border-radius-sm)}.documents-card{padding:var(--size-4);margin-bottom:var(--size-6)}.documents-card .skeleton{background-color:var(--color-muted)}.documents-card-title-skeleton{width:150px;height:24px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-4)}.button-skeleton{width:100%;height:44px;border-radius:var(--border-radius-md);margin-top:var(--size-4)}@keyframes skeleton-pulse{0%{opacity:1}50%{opacity:.6}100%{opacity:1}}`}render(){return l`<div class="page-title-skeleton"><div class="skeleton back-button-skeleton"></div><div class="skeleton title-bar-skeleton"></div></div><div class="skeleton description-skeleton"></div><div class="skeleton description-skeleton"></div><mq-card class="professional-card" roundness="md"><div><div class="skeleton professional-name-skeleton"></div><div class="skeleton professional-speciality-skeleton"></div></div><dl class="description-list"><div class="description-list-item"><div class="skeleton icon-skeleton"></div><div class="skeleton text-skeleton"></div></div><div class="description-list-item"><div class="skeleton icon-skeleton"></div><div class="skeleton text-skeleton"></div></div></dl></mq-card><mq-card class="documents-card" roundness="md"><div class="skeleton documents-card-title-skeleton"></div><div class="skeleton button-skeleton"></div></mq-card>`}};b=s([o("documentation-view-skeleton")],b);let g=class MqAppointmentDocumentation extends d{constructor(){super(...arguments),this.getAppointmentQuery=new a(this,()=>p(this.apiClient,{id:this.appointmentId})),this.apiClient=v()}willUpdate(i){i.has("env")&&this.env&&h(this.env),i.has("locale")&&this.locale&&t(this.locale)&&e(this.locale);const s=j(i,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale},this.inheritedApiClient);s&&(this.apiClient=s)}render(){return l`<mq-layout background="transparent">${this.getAppointmentQuery.render({complete:t=>l`<documentation-view .token="${this.token}" .appointment="${t}"></documentation-view>`,error:()=>l``,pending:()=>l`<documentation-view-skeleton></documentation-view-skeleton>`})}</mq-layout>`}};s([u({type:String,attribute:"appointment-id"})],g.prototype,"appointmentId",void 0),s([u({type:String,attribute:"token"})],g.prototype,"token",void 0),s([u({type:String,attribute:"api-key"})],g.prototype,"apiKey",void 0),s([u({type:String,attribute:"locale"})],g.prototype,"locale",void 0),s([u({type:String,attribute:"env"})],g.prototype,"env",void 0),s([n({context:c,subscribe:!0}),k()],g.prototype,"inheritedApiClient",void 0),s([r({context:c}),k()],g.prototype,"apiClient",void 0),g=s([o("mq-appointment-documentation")],g),i();export{g as MqAppointmentDocumentation};
1
+ import{isValidLocale as t,setLocale as e,initLocalization as i}from"./i18n.js";import{_ as s,c as o}from"./chunks/custom-element-D2ziPxYE.js";import{e as r}from"./chunks/provide-BwI4DDGF.js";import{c as n}from"./chunks/consume-CovVqBjI.js";import{Q as a}from"./chunks/query-controller-BlO1Ax65.js";import{A as c}from"./chunks/api-client-context-V1UAGtKW.js";import{g as p}from"./chunks/get-appointment-query-C-gTTuiQ.js";import{a as d,i as m,x as l}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as k}from"./chunks/state-LQivXIgA.js";import{setEnv as h}from"./env.js";import{c as v,n as j}from"./chunks/api-chat-client-CJ1EGJe3.js";import"./chunks/documentation-view-BbMbGneD.js";import"./ui/mq-card.js";import"./chunks/mq-layout-E5mKSz4A.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/external-CJj32K_p.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/localized-decorator-BlOuLhym.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/addSeconds-ofMnxlgT.js";import"./ui/icons/calendar-icon.js";import"./ui/icons/types.js";import"./ui/icons/clock-icon.js";import"./ui/icons/info-circle-outine-icon.js";import"./ui/mq-button.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/if-defined-BYeVdwgd.js";import"./chunks/chunk-S5RWG6G2-DPesx3Od.js";import"./ui/icons/message-bubble-icon.js";import"./mq-chat-room.js";import"./theme.js";import"./ui/icons/x-icon.js";import"./ui/mq-avatar.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./events.js";import"./chunks/chunk-Y4EKUX25-QqMl3eiq.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import"./chunks/mutation-controller-CR2qcqhH.js";import"./ui/mq-floating-bubble.js";import"./ui/mq-unread-badge.js";import"./ui/mq-page-title.js";import"./ui/icons/arrow-narrow-left-icon.js";import"./chunks/telemetry-client-7fvNqUSU.js";import"./ui/icons/download-icon.js";import"./chunks/blob-to-base64-CUL1trde.js";let b=class DocumentationViewSkeleton extends d{static{this.styles=m`.skeleton{border-radius:var(--border-radius-md);background-color:#f0f0f0;animation:skeleton-pulse 1.5s infinite}.page-title-skeleton{display:flex;align-items:center;gap:var(--sp-3);margin-bottom:var(--size-3)}.back-button-skeleton{width:var(--size-10);height:var(--size-10);border-radius:var(--border-radius-full);flex-shrink:0}.title-bar-skeleton{width:120px;height:24px;border-radius:var(--border-radius-sm)}@media (min-width:768px){.page-title-skeleton{gap:var(--sp-6)}.title-bar-skeleton{width:200px;height:32px}}.description-skeleton{width:100%;height:16px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-2)}.description-skeleton:last-of-type{width:70%;margin-bottom:var(--size-5)}.professional-card{padding:var(--size-4);margin-bottom:var(--size-4)}.professional-name-skeleton{width:180px;height:24px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-1)}.professional-speciality-skeleton{width:140px;height:16px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-4)}.description-list{display:flex;flex-direction:column;gap:var(--size-4)}.description-list-item{display:flex;flex-direction:row;align-items:center;gap:var(--size-2);font-family:var(--font-body)}.icon-skeleton{width:20px;height:20px;border-radius:var(--border-radius-sm)}.text-skeleton{width:120px;height:16px;border-radius:var(--border-radius-sm)}.documents-card{padding:var(--size-4);margin-bottom:var(--size-6)}.documents-card .skeleton{background-color:var(--color-muted)}.documents-card-title-skeleton{width:150px;height:24px;border-radius:var(--border-radius-sm);margin-bottom:var(--size-4)}.button-skeleton{width:100%;height:44px;border-radius:var(--border-radius-md);margin-top:var(--size-4)}@keyframes skeleton-pulse{0%{opacity:1}50%{opacity:.6}100%{opacity:1}}`}render(){return l`<div class="page-title-skeleton"><div class="skeleton back-button-skeleton"></div><div class="skeleton title-bar-skeleton"></div></div><div class="skeleton description-skeleton"></div><div class="skeleton description-skeleton"></div><mq-card class="professional-card" roundness="md"><div><div class="skeleton professional-name-skeleton"></div><div class="skeleton professional-speciality-skeleton"></div></div><dl class="description-list"><div class="description-list-item"><div class="skeleton icon-skeleton"></div><div class="skeleton text-skeleton"></div></div><div class="description-list-item"><div class="skeleton icon-skeleton"></div><div class="skeleton text-skeleton"></div></div></dl></mq-card><mq-card class="documents-card" roundness="md"><div class="skeleton documents-card-title-skeleton"></div><div class="skeleton button-skeleton"></div></mq-card>`}};b=s([o("documentation-view-skeleton")],b);let g=class MqAppointmentDocumentation extends d{constructor(){super(...arguments),this.getAppointmentQuery=new a(this,()=>p(this.apiClient,{id:this.appointmentId})),this.apiClient=v()}willUpdate(i){i.has("env")&&this.env&&h(this.env),i.has("locale")&&this.locale&&t(this.locale)&&e(this.locale);const s=j(i,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale},this.inheritedApiClient);s&&(this.apiClient=s)}render(){return l`<mq-layout background="transparent">${this.getAppointmentQuery.render({complete:t=>l`<documentation-view .token="${this.token}" .appointment="${t}"></documentation-view>`,error:()=>l``,pending:()=>l`<documentation-view-skeleton></documentation-view-skeleton>`})}</mq-layout>`}};s([u({type:String,attribute:"appointment-id"})],g.prototype,"appointmentId",void 0),s([u({type:String,attribute:"token"})],g.prototype,"token",void 0),s([u({type:String,attribute:"api-key"})],g.prototype,"apiKey",void 0),s([u({type:String,attribute:"locale"})],g.prototype,"locale",void 0),s([u({type:String,attribute:"env"})],g.prototype,"env",void 0),s([n({context:c,subscribe:!0}),k()],g.prototype,"inheritedApiClient",void 0),s([r({context:c}),k()],g.prototype,"apiClient",void 0),g=s([o("mq-appointment-documentation")],g),i();export{g as MqAppointmentDocumentation};
@@ -1,7 +1,7 @@
1
- export { M as MqChatRoom } from './chunks/mq-chat-room-t3j3Tq4o.js';
1
+ export { M as MqChatRoom } from './chunks/mq-chat-room-jeDvIF1Z.js';
2
2
  import 'lit-html';
3
3
  import 'lit';
4
- import './chunks/index.d-Bl682CAX.js';
4
+ import './chunks/index.d-XSe7Hy-Q.js';
5
5
  import 'axios';
6
6
  import 'zod';
7
7
  import './chunks/schemas.d-b6_AekBb.js';
@@ -1 +1 @@
1
- import{_ as e,c as t}from"./chunks/custom-element-D2ziPxYE.js";import{e as s}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{l as o}from"./chunks/localized-decorator-BlOuLhym.js";import{m as a,s as r}from"./chunks/runtime-Bg1WXVCx.js";import{A as n}from"./chunks/api-client-context-V1UAGtKW.js";import{i as l,a as d,x as c,E as h}from"./chunks/lit-element-DiWJYFwC.js";import{n as m}from"./chunks/property-scuRaFcM.js";import{r as p}from"./chunks/state-LQivXIgA.js";import{n as g}from"./chunks/create-context-DqP79qjF.js";import{tokens as u}from"./theme.js";import{xIcon as v}from"./ui/icons/x-icon.js";import"./ui/mq-avatar.js";import"./ui/mq-button.js";import"./ui/mq-skeleton.js";import{Q as b}from"./chunks/query-controller-BlO1Ax65.js";import{g as y}from"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import{o as f}from"./chunks/if-defined-BYeVdwgd.js";import{chevronLeftIcon as w}from"./ui/icons/chevron-left-icon.js";import{e as k}from"./chunks/query-CeeutdfT.js";import{l as x}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{DownloadFileEvent as C}from"./events.js";import{M as $,c as I,n as z}from"./chunks/api-chat-client-pGZWREjK.js";import{S as T,g as D}from"./chunks/chunk-Y4EKUX25-QqMl3eiq.js";import{checkDoubleIcon as M}from"./ui/icons/check-double-icon.js";import{checkIcon as j}from"./ui/icons/check-icon.js";import{getLocale as q}from"./i18n.js";import{S,a as P}from"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import{s as A}from"./chunks/context-consumer-ESdICVAb.js";import{s as _}from"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import{Q as E}from"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import{e as R}from"./chunks/class-map-Co76I6aw.js";import{M as U}from"./chunks/mutation-controller-CR2qcqhH.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./ui/icons/types.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";const B=g("apiKey"),H=g("token"),N=g("professionalHash"),L=g("roomId"),K=g("consultationId"),F=g("consultationType");class MqChatRoomCloseEvent extends Event{static{this.eventName="mq-chat-room-close"}constructor(){super(MqChatRoomCloseEvent.eventName,{bubbles:!0,composed:!0})}}class MqChatRoomProfileEvent extends Event{static{this.eventName="mq-chat-room-profile"}constructor(){super(MqChatRoomProfileEvent.eventName,{bubbles:!0,composed:!0})}}const O=l`header{padding:var(--size-3) var(--size-4);background-color:var(--color-background-primary);display:flex;justify-content:space-between;gap:var(--size-1)}.left-side{display:flex;flex:1;min-width:0;align-items:center;gap:var(--size-3)}.left-side mq-avatar{flex-shrink:0}.info{min-width:0}.ghost-btn{text-align:left;background:0 0;border:none;padding:0;cursor:pointer}.right-side{display:flex;align-items:center}.name{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-bold);margin:0;color:var(--color-background);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.specialty{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);margin:0;color:var(--color-white);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.name-skeleton{margin-bottom:var(--size-1)}.profile-title{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-medium);margin:0;color:var(--color-white)}`;let Q=class ChatRoomHeader extends d{constructor(){super(...arguments),this.hideCloseButton=!1,this.getProfessionalQuery=new b(this,()=>y(this.apiClient,{hash:this.professionalHash}))}static{this.styles=O}handleClose(){this.dispatchEvent(new MqChatRoomCloseEvent)}handleClickProfile(){this.dispatchEvent(new MqChatRoomProfileEvent)}renderProfile(){return c`<div class="left-side"><mq-button type="button" size="icon-md" variant="ghost-inverted" @click="${()=>{this.dispatchEvent(new CustomEvent("goto-chat",{bubbles:!0,composed:!0}))}}">${w({size:24})}</mq-button><p class="profile-title">${a("Perfil de profesional")}</p></div>`}renderChat(){return c`${this.getProfessionalQuery.render({complete:e=>c`<button type="button" class="left-side ghost-btn" @click="${this.handleClickProfile}"><mq-avatar src="${f(e.avatar??void 0)}" alt="User Avatar" fallback="John Doe" size="sm"></mq-avatar><div class="info"><p class="name">${e.name}</p><p class="specialty">${e.title}</p></div></button>`,pending:()=>c`<div class="left-side"><mq-skeleton width="45px" height="45px" border-radius="full"></mq-skeleton><div><mq-skeleton class="name-skeleton" height="14px" width="120px"></mq-skeleton><mq-skeleton height="14px" width="100px"></mq-skeleton></div></div>`})}`}render(){return c`<header>${"profile"===this.view?this.renderProfile():this.renderChat()}<div class="right-side">${this.hideCloseButton?h:c`<mq-button type="button" size="icon-md" variant="ghost-inverted" @click="${this.handleClose}">${v({size:24})}</mq-button>`}</div></header>`}};e([i({context:n,subscribe:!0})],Q.prototype,"apiClient",void 0),e([m({type:String})],Q.prototype,"professionalHash",void 0),e([m({type:Boolean})],Q.prototype,"hideCloseButton",void 0),e([m({type:String})],Q.prototype,"view",void 0),Q=e([o(),t("chat-room-header")],Q);const V=/(https?:\/\/[^\s,;:!)\]}\]]+|www\.[^\s,;:!)\]}\]]+|[a-zA-Z0-9][-a-zA-Z0-9]*(?:\.[a-zA-Z0-9][-a-zA-Z0-9]*)+(?:\/[^\s,;:!)\]}\]]*|(?:\?|#|&)[^\s,;:!)\]}\]]*)?)/gi;function J(e){return e.split(V).map((e,t)=>{if(t%2==1){const t=e.startsWith("http")?e:`https://${e}`;return c`<a href="${t}" target="_blank" rel="noopener noreferrer" class="message-link">${e}</a>`}return e})}let Y=class TextMessageBubble extends d{static{this.styles=[l`:host{display:block}.message-bubble{padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);word-wrap:break-word;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal)}.message-bubble.received{background-color:var(--chat-received-message-background);color:var(--chat-received-message-foreground);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);color:var(--chat-sent-message-foreground);border-bottom-right-radius:0}.message-content{white-space:pre-wrap}.message-paragraph{margin:0 0 var(--size-3) 0}.message-paragraph:last-child{margin-bottom:0}.message-bubble.received .message-content a.message-link,.message-bubble.sent .message-content a.message-link{color:var(--color-primary-link-default);text-decoration:underline}.message-bubble.received .message-content a.message-link:hover,.message-bubble.sent .message-content a.message-link:hover{opacity:.8}`]}formatMessageContent(e){const t=e.split("\n\n").filter(e=>e.trim());if(t.length<=1)return c`<div class="message-content">${J(e)}</div>`;const s=t.map(e=>c`<div class="message-paragraph">${J(e.trim())}</div>`);return c`<div class="message-content">${s}</div>`}render(){return c`<div class="message-bubble ${this.kind}">${this.formatMessageContent(this.message.string)}</div>`}};e([m({type:Object})],Y.prototype,"message",void 0),e([m({type:String})],Y.prototype,"kind",void 0),Y=e([t("text-message-bubble")],Y);const Z=l`:host{display:block}.message-bubble{padding:var(--size-2);border-radius:var(--border-radius-lg);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);overflow:hidden}.message-bubble.received{background-color:var(--chat-received-message-background);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);border-bottom-right-radius:0}.image-content{display:block;width:229px;height:229px;object-fit:cover;border-radius:var(--border-radius-md)}.image-placeholder{display:flex;align-items:center;justify-content:center;width:100%;max-width:300px;height:200px;background-color:var(--color-gray-light);border-radius:var(--border-radius-md);color:var(--chat-sent-message-foreground);font-size:var(--text-sm)}.image-content{cursor:pointer;transition:opacity .2s ease}.image-content:hover{opacity:.9}.preview-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:var(--dialog-underlay);display:flex;align-items:center;justify-content:center;z-index:1000;cursor:pointer;opacity:0;transition:opacity var(--dialog-transition-duration) ease}.preview-overlay.open{opacity:1}.preview-image{position:fixed;z-index:1000;inset:var(--mq-safe-top,0) var(--mq-safe-right,0) var(--mq-safe-bottom,0) var(--mq-safe-left,0);max-width:calc(100% - var(--mq-safe-left,4px) - var(--mq-safe-right,4px));max-height:calc(100% - var(--mq-safe-top,4px) - var(--mq-safe-bottom,4px));margin:auto;object-fit:contain;cursor:default;box-shadow:var(--dialog-shadow);transform:scale(.95);transition:transform var(--dialog-transition-duration) ease}.preview-overlay.open .preview-image{transform:scale(1)}.preview-close{z-index:1001;display:inline-flex;align-items:center;justify-content:center;height:var(--size-10);width:var(--size-10);position:absolute;top:var(--mq-safe-top,4px);right:var(--mq-safe-right,4px);background:rgba(255,255,255,.3);border:none;color:var(--color-neutrals-text-default);font-size:var(--text-xl);padding:var(--size-2) var(--size-3);border-radius:var(--border-radius-md);cursor:pointer;transition:background var(--dialog-transition-duration) ease}.preview-close:hover{background:var(--dialog-close-hover-bg)}`;let G=class ImageMessageBubble extends d{constructor(){super(...arguments),this.showPreview=!1,this.isPreviewRendered=!1,this.isPreviewActive=!1,this.closeTimer=null}static{this.styles=Z}handleImageError(e){const t=e.target;t.style.display="none";const s=t.nextElementSibling;s&&(s.style.display="flex")}handleImageLoad(e){const t=e.target.nextElementSibling;t&&(t.style.display="none")}handleImageClick(){this.showPreview=!0,this.isPreviewRendered=!0,this.updateComplete.then(()=>{requestAnimationFrame(()=>{this.isPreviewActive=!0})})}handleImageKeyDown(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleImageClick())}handleClosePreview(e){e&&e.stopPropagation(),this.isPreviewActive=!1,this.closeTimer&&window.clearTimeout(this.closeTimer),this.closeTimer=window.setTimeout(()=>{this.isPreviewRendered=!1,this.showPreview=!1,this.closeTimer=null},200)}handleOverlayClick(e){e.target===e.currentTarget&&this.handleClosePreview()}handleOverlayKeyDown(e){"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),this.handleClosePreview())}handleKeyDown(e){"Escape"===e.key&&this.showPreview&&(e.preventDefault(),this.handleClosePreview())}handlePreviewImageKeyDown(e){e.stopPropagation()}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeyDown.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeyDown.bind(this)),this.closeTimer&&(window.clearTimeout(this.closeTimer),this.closeTimer=null)}render(){const e=this.message.attachment.signed_url??this.message.attachment.url;return c`<div class="message-bubble ${this.kind}"><img class="image-content" src="${e}" width="229" height="229" alt="Shared attachment" @error="${this.handleImageError}" @load="${this.handleImageLoad}" @click="${this.handleImageClick}" @keydown="${this.handleImageKeyDown}" tabindex="0"><div class="image-placeholder" style="display:none">Image unavailable</div></div>${this.showPreview&&this.isPreviewRendered?c`<div class="preview-overlay ${this.isPreviewActive?"open":""}" @click="${this.handleOverlayClick}" @keydown="${this.handleOverlayKeyDown}" tabindex="0"><button class="preview-close" @click="${this.handleClosePreview}" aria-label="Close preview">${v({size:24})}</button> <img class="preview-image" src="${e}" alt="Shared attachment preview" @click="${e=>e.stopPropagation()}" @keydown="${this.handlePreviewImageKeyDown}" tabindex="0"></div>`:""}`}};e([m({type:Object})],G.prototype,"message",void 0),e([m({type:String})],G.prototype,"kind",void 0),e([i({context:H})],G.prototype,"token",void 0),e([p()],G.prototype,"showPreview",void 0),e([p()],G.prototype,"isPreviewRendered",void 0),e([p()],G.prototype,"isPreviewActive",void 0),G=e([t("image-message-bubble")],G);const W=l`:host{background-color:var(--chat-system-message-background);color:var(--chat-system-message-foreground);display:block;padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal)}a.message-link{color:var(--color-primary-link-default);text-decoration:underline}a.message-link:hover{opacity:.8}`;let X=class SystemMessageBubble extends d{static{this.styles=W}render(){return c`<div class="system-message-bubble">${J(this.message.string)}</div>`}};e([m({type:Object})],X.prototype,"message",void 0),X=e([t("system-message-bubble")],X);const ee=l`:host{display:block}.message-bubble{display:inline-block;padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);word-wrap:break-word;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);text-decoration:underline;color:var(--color-primary-link-default);border:none;cursor:pointer;text-align:left}.message-bubble:hover:not(:disabled){opacity:.8}.message-bubble:disabled{opacity:.5;cursor:not-allowed}.message-bubble.received{background-color:var(--chat-received-message-background);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);border-bottom-right-radius:0}.message-content{white-space:pre-wrap}.message-paragraph{margin:0 0 var(--size-3) 0}.message-paragraph:last-child{margin-bottom:0}`;let te=class FileMessageBubble extends d{constructor(){super(...arguments),this.isDownloading=!1}static{this.styles=ee}formatMessageContent(e){const t=e.split("\n\n").filter(e=>e.trim());if(t.length<=1)return c`<div class="message-content">${e}</div>`;const s=t.map(e=>c`<div class="message-paragraph">${e.trim()}</div>`);return c`<div class="message-content">${s}</div>`}async handleDownload(){if(this.isDownloading)return;const e=this.message.attachment.url;try{this.isDownloading=!0;const t=await fetch(e,{headers:{Authorization:`Bearer ${this.token}`}});if(!t.ok)throw new Error(`Failed to fetch file: ${t.statusText}`);const s=await t.blob(),i=new FileReader;i.onloadend=()=>{const e=i.result,t=new C({url:e,filename:this.message.attachment.file_name});this.dispatchEvent(t),this.isDownloading=!1},i.onerror=()=>{x.error("Error reading file as data URL"),this.isDownloading=!1},i.readAsDataURL(s)}catch(e){x.error("Error downloading file:",e),this.isDownloading=!1}}render(){return c`<button type="button" @click="${this.handleDownload}" class="message-bubble ${this.kind}" ?disabled="${this.isDownloading}">${this.formatMessageContent(this.message.attachment.file_name)}</button>`}};e([m({type:Object})],te.prototype,"message",void 0),e([m({type:String})],te.prototype,"kind",void 0),e([i({context:H})],te.prototype,"token",void 0),e([p()],te.prototype,"isDownloading",void 0),te=e([t("file-message-bubble")],te);let se=class MessageBubble extends d{constructor(){super(...arguments),this.showTimestamp=!0}static{this.styles=[l`:host{display:block}.timestamp{font-family:var(--font-body);font-size:var(--text-xs);color:var(--color-gray-medium);font-weight:var(--font-weight-normal);text-align:left;display:flex;align-items:center;gap:var(--size-1)}.timestamp.sent{text-align:right;justify-content:flex-end}.status-icon{width:12px;height:12px}.status-icon.read{color:var(--color-primary)}`]}formatTimestamp(e){if(!e)return"";try{const t=new Date(e);return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(t)}catch{return e}}renderStatusIcon(){switch(this.message.status){case $.Sent:return j({size:12,color:"currentColor"});case $.Received:return M({size:12,color:"currentColor"});case $.Read:return M({size:12,color:"currentColor",className:"read"});default:return null}}renderBubbleContent(){switch(this.message.type){case"image":return c`<image-message-bubble .message="${this.message}" .kind="${this.kind}"></image-message-bubble>`;case"file":return c`<file-message-bubble .message="${this.message}" .kind="${this.kind}"></file-message-bubble>`;default:return c`<text-message-bubble .message="${this.message}" .kind="${this.kind}"></text-message-bubble>`}}render(){if(this.message.senderType===T.system)return c`<system-message-bubble .message="${this.message}"></system-message-bubble>`;const e=this.message.createdAt?new Date(this.message.createdAt):this.message.time?new Date(this.message.time):null;return c`${this.renderBubbleContent()} ${this.showTimestamp&&e?c`<div class="timestamp ${this.kind}">${this.formatTimestamp(e.toISOString())} ${"sent"===this.kind?c`<span class="status-icon ${this.message.status===$.Read?"read":""}">${this.renderStatusIcon()}</span>`:""}</div>`:""}`}};e([m({type:String})],se.prototype,"kind",void 0),e([m({type:Object})],se.prototype,"message",void 0),e([m({type:Boolean})],se.prototype,"showTimestamp",void 0),se=e([t("message-bubble")],se);let ie=class DateBanner extends d{constructor(){super(...arguments),this.date=""}static{this.styles=[u,l`:host{display:block;margin-bottom:var(--size-2)}.date-banner{display:flex;align-items:center;justify-content:center;position:relative}.date-text{background-color:var(--color-gray-light);color:var(--color-gray-darker);font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);padding:var(--size-1) var(--size-2);border-radius:var(--border-radius-2xl);white-space:nowrap}`]}formatDate(e){const t=q().replace("_","-"),s=new Date(e),i=new Date,o=new Date(i);o.setDate(o.getDate()-1);const r=new Date(s.getFullYear(),s.getMonth(),s.getDate()),n=new Date(i.getFullYear(),i.getMonth(),i.getDate()),l=new Date(o.getFullYear(),o.getMonth(),o.getDate());return r.getTime()===n.getTime()?a("Hoy"):r.getTime()===l.getTime()?a("Ayer"):s.toLocaleDateString(t,{dateStyle:"medium"})}render(){return c`<div class="date-banner"><span class="date-text">${this.formatDate(this.date)}</span></div>`}};function oe(e){return e.createdAt?new Date(e.createdAt):e.time?new Date(e.time):new Date}e([m({type:String})],ie.prototype,"date",void 0),ie=e([o(),t("date-banner")],ie);let ae=class MessagesList extends d{constructor(){super(...arguments),this.messages=[]}static{this.styles=[u,l`:host{display:block;width:100%;height:100%;overflow-y:auto;overflow-x:hidden}.messages-container{display:flex;flex-direction:column;padding:var(--size-4);gap:var(--size-1);background-color:var(--color-white);padding-bottom:var(--size-4)}.message-wrapper{display:flex;width:100%}.message-wrapper.received{justify-content:flex-start}.message-wrapper.sent{justify-content:flex-end}.message-wrapper.system{justify-content:center}message-bubble{max-width:70%}`]}scrollToBottom(){requestAnimationFrame(()=>{const e=this.messagesContainerEnd;e&&e.scrollIntoView({behavior:"instant",block:"end"})})}shouldShowMessageTimestamp(e,t){if(e.senderType===T.system)return!1;if(!t)return!0;if(t.senderType!==e.senderType)return!0;if(t.senderType===T.ordinary&&e.senderType===T.ordinary&&t.fromUserHash!==e.fromUserHash)return!0;return(oe(t).getTime()-oe(e).getTime())/6e4>1}groupMessagesByDate(e){const t=[];let s=null;return e.forEach((i,o)=>{const a=oe(i),r=a?.toDateString();r!==s&&(t.push({type:"date",data:a.toDateString()}),s=r??null);const n=e[o+1],l=this.shouldShowMessageTimestamp(i,n);t.push({type:"message",data:i,showTimestamp:l})}),t}firstUpdated(){this.scrollToBottom()}willUpdate(e){e.has("messages")&&this.scrollToBottom()}render(){const e=this.groupMessagesByDate(this.messages),t=e.map((t,s)=>{if("date"===t.type)return c`<date-banner .date="${t.data}"></date-banner>`;const i=this.professionalHash!==t.data.fromUserHash,o=t.data.senderType===T.system?"system":i?"sent":"received";return c`<div class="message-wrapper ${o}"><message-bubble .message="${t.data}" .kind="${o}" .showTimestamp="${t.showTimestamp||"date"===e[s+1]?.type}"></message-bubble></div>`});return c`<div class="messages-container">${t}<div class="messages-container-end"></div></div>`}};e([m({type:Array})],ae.prototype,"messages",void 0),e([m({type:String})],ae.prototype,"professionalHash",void 0),e([k(".messages-container-end")],ae.prototype,"messagesContainerEnd",void 0),ae=e([t("messages-list")],ae);let re=class MessageBubbleSkeleton extends d{constructor(){super(...arguments),this.variant="patient",this.height="md",this.showTimestamp=!0}static{this.styles=[l`:host{display:block}.message-bubble{padding:var(--size-4);border-radius:var(--border-radius-lg);margin-bottom:var(--size-1);position:relative;overflow:hidden}.message-bubble.doctor{background-color:var(--color-gray-light);border-bottom-left-radius:0}.message-bubble.patient{background-color:var(--color-background-primary-light);border-bottom-right-radius:0}:host([height=sm]) .message-bubble{height:var(--size-8)}:host([height=md]) .message-bubble{height:var(--size-12)}`]}render(){return c`<div class="message-bubble ${this.variant}"></div>${this.showTimestamp?c`<div class="timestamp-skeleton ${this.variant}"></div>`:""}`}};e([m({type:String})],re.prototype,"variant",void 0),e([m({type:String})],re.prototype,"height",void 0),e([m({type:Boolean})],re.prototype,"showTimestamp",void 0),re=e([t("message-bubble-skeleton")],re);let ne=class MessagesSkeleton extends d{constructor(){super(...arguments),this.messageCount=6}static{this.styles=[u,l`:host{display:block;width:100%;height:100%;overflow:hidden}.messages-container{display:flex;flex-direction:column;padding:var(--size-4);gap:var(--size-3);max-width:100%;height:100%;background-color:var(--color-white)}.message-wrapper{display:flex;width:100%}.message-wrapper.doctor{justify-content:flex-start}.message-wrapper.patient{justify-content:flex-end}message-bubble-skeleton{max-width:85%;min-width:60%;width:100%}`]}getSkeletonHeight(e){const t=["sm","md","sm","md","sm","md"];return t[e%t.length]}getSkeletonVariant(e){const t=["doctor","patient","doctor","doctor","patient","doctor","patient"];return t[e%t.length]}renderSkeletonMessages(){return Array.from({length:this.messageCount},(e,t)=>{const s=this.getSkeletonVariant(t),i=this.getSkeletonHeight(t);return c`<div class="message-wrapper ${s}"><message-bubble-skeleton variant="${s}" height="${i}" ?showTimestamp="${t===this.messageCount-1||Math.random()>.7}"></message-bubble-skeleton></div>`})}render(){return c`<div class="messages-container">${this.renderSkeletonMessages()}</div>`}};e([m({type:Number})],ne.prototype,"messageCount",void 0),ne=e([t("messages-skeleton")],ne);var le=class{constructor(e,t){this.host=e,this.listeners=[],this.host.addController(this),this.socketContext=new A(this.host,{context:S,subscribe:!0,callback:e=>{if(e&&(this.socket=e,t?.listeners)){this.listeners=t.listeners;for(const e of this.listeners)this.socket?.on(e.eventName,e.callback)}}})}hostConnected(){}hostDisconnected(){for(const e of this.listeners)this.socket?.off(e.eventName,e.callback)}};function de(e,t){return{queryKey:_(e,"rooms",t.roomId),queryFn:()=>e.rooms.getRoomMessages(t),staleTime:0}}class OptimisticUpdatesController{constructor(e){this.host=e,this.apiClientContext=new A(this.host,{context:n,subscribe:!0,callback:e=>{this.apiClient=e}}),this.queryClientContext=new A(this.host,{context:E,subscribe:!0,callback:e=>{e&&(this.queryClient=e)}}),this.host.addController(this)}hostConnected(){}appendMessageToRoom(e,t){if(!this.apiClient)return;const s=de(this.apiClient,{roomId:t}).queryKey;this.queryClient?.setQueriesData({queryKey:s,exact:!0},t=>[...t??[],e])}deleteMessage(e,t){if(!this.queryClient||!this.apiClient)return;const s=de(this.apiClient,{roomId:t}).queryKey;this.queryClient.setQueryData(s,t=>(t??[]).map(t=>t.messageId===e?{...t,deletedAt:(new Date).toISOString(),string:a("Este mensaje fue eliminado")}:t))}updateMessageStatus({messageId:e,status:t,roomId:s}){if(!this.queryClient||!this.apiClient)return;const i=de(this.apiClient,{roomId:s}).queryKey;this.queryClient.setQueryData(i,s=>(s??[]).map(s=>s.messageId===e?{...s,status:t}:s))}}let ce=class ChatRoomMessages extends d{constructor(){super(...arguments),this.getRoomMessagesQuery=new b(this,()=>de(this.apiClient,{roomId:this.roomId})),this.optimisticUpdatesController=new OptimisticUpdatesController(this),this.onMessageReceived=e=>{if(e.roomId!==this.roomId)return;const t=function(e){const t={roomId:"string"==typeof e.roomId?Number.parseInt(e.roomId,10):e.roomId,messageId:e.messageId,status:e.status,senderType:e.senderType,fromUserHash:e.fromUserHash,time:e.time,createdAt:e.time?new Date(e.time).toISOString():null,deletedAt:null};switch(e.type){case"string":return{...t,type:"string",string:e.string,auto:e.auto?1:0,attachment:null};case"image":return{...t,type:"image",string:e.fileName||"",auto:0,attachment:{file_name:e.fileName,file_size:e.fileSize,url:e.imageUrl,type:"uncategorized",meta:{duration:0},signed_url:e.imageUrl}};case"file":return{...t,type:"file",string:e.fileName||"",auto:0,attachment:{file_name:e.fileName,file_size:e.fileSize,url:e.fileUrl,type:"uncategorized",meta:{duration:0},signed_url:e.fileUrl}};default:return{...t,type:"string",string:"",auto:0,attachment:null}}}(e);this.optimisticUpdatesController.appendMessageToRoom(t,t.roomId),t.roomId===this.roomId&&e.fromUserHash===this.professionalHash&&this._socketController.socket?.emit(P.messageStatus,e.messageId,this.roomId,$.Read)},this.onMessageDeleted=e=>{e.room_id===this.roomId&&this.optimisticUpdatesController.deleteMessage(e.message_id,e.room_id)},this.onMessageStatusUpdated=e=>{e.roomId===this.roomId&&this.optimisticUpdatesController.updateMessageStatus({messageId:e.messageId,status:e.status,roomId:e.roomId})},this._socketController=new le(this,{listeners:[{eventName:P.message,callback:this.onMessageReceived},{eventName:P.message_deleted,callback:this.onMessageDeleted},{eventName:P.messageStatus,callback:this.onMessageStatusUpdated}]})}static{this.styles=[u,l`:host{display:block;width:100%;height:100%}`]}render(){return this.getRoomMessagesQuery.render({pending:()=>c`<messages-skeleton messageCount="8"></messages-skeleton>`,complete:e=>c`<messages-list .messages="${e}" .professionalHash="${this.professionalHash}"></messages-list>`})}};e([i({context:n,subscribe:!0})],ce.prototype,"apiClient",void 0),e([m({type:Number})],ce.prototype,"roomId",void 0),e([m({type:String})],ce.prototype,"professionalHash",void 0),ce=e([t("chat-room-messages")],ce);var he=class{constructor(e){this.string=e.string,this.roomId=e.roomId,this.messageId=e.messageId,this.type=e.type,this.fileName=e.fileName,this.autoMessage=e.autoMessage,this.senderType=e.senderType,this.attachmentType=e.attachmentType,this.consultationId=e.consultationId,this.consultationType=e.consultationType}toSocketMessage(){return[P.message,this.string,this.roomId,this.messageId,this.type,this.fileName,this.autoMessage,this.senderType,this.attachmentType,this.consultationId,this.consultationType]}},me=class extends he{constructor(e){super({roomId:e.roomId,messageId:e.messageId,string:e.string,type:"string",fileName:null,autoMessage:!1,senderType:T.ordinary,attachmentType:"uncategorized",consultationId:e.consultationId,consultationType:e.consultationType})}},pe=class extends he{constructor(e){super({roomId:e.roomId,messageId:e.messageId,string:e.base64Attachment,fileName:e.fileName,type:e.type,autoMessage:!1,senderType:T.ordinary,attachmentType:"uncategorized",consultationId:e.consultationId,consultationType:e.consultationType})}};async function ge(e){return await Promise.all(e.map(async e=>{const t=await function(e){return new Promise((t,s)=>{const i=new FileReader;i.onload=()=>{const o=i.result.split(",")[1];o?t(o):s(new Error(`Invalid data URL format for file: ${e.name}`))},i.onerror=()=>{s(new Error(`Failed to read file: ${e.name}`))},i.readAsDataURL(e)})}(e);return{name:e.name,size:e.size,type:e.type,base64:t}}))}const ue=l`:host{display:block;position:absolute;bottom:0;padding:var(--size-2) var(--size-2);background:#fff}.footer-container{display:flex;align-items:center;gap:var(--size-1);max-width:100%}.input-container{flex:1;position:relative;display:flex;align-items:center;border:1px solid var(--color-neutrals-border-disabled);border-radius:var(--border-radius-2xl);padding:0 var(--size-1);overflow:hidden}.input-container:focus-within{border-color:var(--color-primary)}.message-input{flex:1;border:none;outline:0;background:0 0;font-family:var(--font-body);font-size:var(--text-base);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-neutrals-text-default);padding-left:var(--sp-2)}.message-input::placeholder{color:var(--color-neutrals-text-medium)}.attachment-icon{width:var(--size-5);height:var(--size-5);color:var(--color-primary)}.send-icon{width:var(--size-5);height:var(--size-5);color:var(--color-primary)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.send-button{color:var(--color-neutrals-link-disabled);background:0 0;border:none;padding:var(--size-2);border-radius:var(--border-radius-md);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .2s ease}.send-button:hover:not(.disabled){background:var(--color-primary-light)}.send-button:active:not(.disabled){background-color:var(--color-neutrals-background-active)}.send-button.disabled{cursor:not-allowed;opacity:.4}.send-button.disabled .send-icon{color:var(--color-neutrals-text-disabled)}`;let ve=class ChatRoomFooter extends d{constructor(){super(...arguments),this.isTyping=!1,this.typingTimeoutId=null,this.inputValue="",this.socketController=new le(this)}static{this.styles=[ue]}handleInputChange(e){const t=e.target;this.inputValue=t.value,this.isTyping||(this.socketController.socket?.emit(P.typing,this.roomId),this.isTyping=!0),this.typingTimeoutId&&clearTimeout(this.typingTimeoutId),this.typingTimeoutId=setTimeout(()=>{this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.isTyping=!1)},1500)}handleKeyDown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSendMessage())}async handleAttachment(e){const t=e.target.files;if(!t||0===t.length)return;const s=t.item(0);if(s)try{const e=(await ge([s]))[0];if(!e)return void x.error("Error converting file to base64");const t=e?.type.includes("image")?"image":"file",i=crypto.randomUUID(),o=s.name,a=new pe({type:t,base64Attachment:e.base64,fileName:o,roomId:this.roomId,messageId:i,consultationId:this.consultationId,consultationType:this.consultationType});this.socketController.socket?.emit(...a.toSocketMessage())}catch(e){x.error("Error converting files to base64:",e)}}handleAttachmentClick(){this.attachmentInput.click()}handleSendMessage(){const e=this.inputValue.trim();if(!e)return;const t=crypto.randomUUID();this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.isTyping=!1,this.typingTimeoutId&&clearTimeout(this.typingTimeoutId));const s=new me({messageId:t,string:e,roomId:this.roomId,consultationId:this.consultationId,consultationType:this.consultationType});this.socketController.socket?.emit(...s.toSocketMessage()),this.inputValue=""}disconnectedCallback(){this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.typingTimeoutId&&clearTimeout(this.typingTimeoutId))}render(){const e=this.inputValue.trim().length>0;return c`<div class="footer-container"><div class="input-container"><input class="message-input" type="text" placeholder="${a("Escribe aquí...")}" .value="${this.inputValue}" @input="${this.handleInputChange}" @keydown="${this.handleKeyDown}"><div><input class="attachment-input sr-only" type="file" accept="image/jpeg,image/jpg,image/png,image/gif,image/bmp,image/tiff,application/pdf,text/*,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,audio/*,video/*" @change="${this.handleAttachment}"><mq-button variant="ghost" size="icon-sm" @click="${this.handleAttachmentClick}" title="${a("Adjuntar archivo")}">${c`<svg class="attachment-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`}</mq-button></div></div><button class="send-button ${e?"":"disabled"}" @click="${this.handleSendMessage}" ?disabled="${!e}" title="${a("Enviar mensaje")}">${c`<svg class="send-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 2L11 13"/><path d="M22 2L15 22L11 13L2 9L22 2z"/></svg>`}</button></div>`}};e([i({context:K})],ve.prototype,"consultationId",void 0),e([i({context:F})],ve.prototype,"consultationType",void 0),e([m({type:Number})],ve.prototype,"roomId",void 0),e([p()],ve.prototype,"inputValue",void 0),e([k(".attachment-input")],ve.prototype,"attachmentInput",void 0),ve=e([t("chat-room-footer")],ve);const be=e=>({all_week:!0,monday:1===e,tuesday:2===e,wednesday:3===e,thursday:4===e,friday:5===e,saturday:6===e,sunday:7===e,working_week:e>=1&&e<=5,weekend:0===e||6===e});function ye(e,t){const s=be(6===e?0:e+1);return t.some(e=>{const t=e.days_of_week;return!0===s[t]})}let fe=class AvailabilitySection extends d{constructor(){super(...arguments),this.gaps=[],this.selectedDay=function(){const e=(new Date).getDay();return 0===e?6:e-1}()}static{this.styles=l`:host{display:flex;flex-direction:column;gap:var(--size-3)}.availability-header{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-normal);color:var(--color-primary);text-align:center;margin:0;margin-bottom:var(--size-4) 0}.availability-days{display:flex;flex-direction:row;justify-content:center;gap:var(--size-1);overflow-x:auto;padding-bottom:var(--size-4)}.availability-button{outline:0;border:1px solid var(--color-gray-medium);background:0 0;color:var(--color-gray-medium);cursor:pointer;height:var(--size-9);width:var(--size-10);border-radius:var(--border-radius-sm);text-transform:capitalize;font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium)}.availability-button:hover{background-color:color-mix(in srgb,var(--color-gray-light) 50%,transparent)}.availability-button:focus{background-color:color-mix(in srgb,var(--color-gray-light) 50%,transparent)}.availability-button.active{background:var(--color-primary);color:var(--color-white);border:none}.availability-button:disabled{opacity:.5;cursor:not-allowed;background-color:var(--color-gray-light)}.time-title{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);color:var(--color-gray-dark);margin:0;margin-bottom:var(--size-1)}.time-entries{display:flex;flex-direction:column;gap:var(--size-1);margin-bottom:var(--size-6)}.time-entry{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal);color:var(--color-gray-medium);margin:0}`}updated(e){e.has("gaps")&&(void 0===this.selectedDay||ye(this.selectedDay,this.gaps)||(this.selectedDay=void 0))}render(){const e=[{shortLabel:a("Lu"),label:a("Lunes"),key:"monday",disabled:!ye(0,this.gaps)},{shortLabel:a("Ma"),label:a("Martes"),key:"tuesday",disabled:!ye(1,this.gaps)},{shortLabel:a("Mi"),label:a("Miércoles"),key:"wednesday",disabled:!ye(2,this.gaps)},{shortLabel:a("Ju"),label:a("Jueves"),key:"thursday",disabled:!ye(3,this.gaps)},{shortLabel:a("Vi"),label:a("Viernes"),key:"friday",disabled:!ye(4,this.gaps)},{shortLabel:a("Sa"),label:a("Sábado"),key:"saturday",disabled:!ye(5,this.gaps)},{shortLabel:a("Do"),label:a("Domingo"),key:"sunday",disabled:!ye(6,this.gaps)}];return c`<h2 class="availability-header">${a("Disponibilidad")}</h2><div class="availability-days">${e.map((e,t)=>c`<button type="button" class="availability-button ${R({active:this.selectedDay===t&&!e.disabled})}" ?disabled="${e.disabled}" @click="${()=>{e.disabled||(this.selectedDay=t)}}">${e.shortLabel}</button>`)}</div>${void 0===this.selectedDay||e[this.selectedDay]?.disabled?"":(()=>{const t=function(e,t){const s=be(6===e?0:e+1);return t.filter(e=>{const t=e.days_of_week;return!0===s[t]}).map(e=>({from_time:e.from_time,to_time:e.to_time}))}(this.selectedDay,this.gaps);return c`<div class="availability-time"><p class="time-title">${e[this.selectedDay]?.label}</p><div class="time-entries">${t.length>0?t.map(e=>c`<p class="time-entry">${a("De")} ${e.from_time} ${a("a")} ${e.to_time}</p>`):c`<p class="time-entry">${a("No hay horarios disponibles")}</p>`}</div></div>`})()}`}};e([m({type:Array})],fe.prototype,"gaps",void 0),e([p()],fe.prototype,"selectedDay",void 0),fe=e([o(),t("availability-section")],fe);const we=l`:host{display:flex;flex-direction:column;height:100%;overflow-y:auto;background-color:var(--color-white)}.profile-container{padding:var(--size-6);display:flex;flex-direction:column}.profile-header{display:flex;flex-direction:column;align-items:center;text-align:center;padding-bottom:var(--size-6);border-bottom:1px solid var(--color-gray-medium);margin-bottom:var(--size-6)}.profile-avatar{margin-bottom:var(--size-2)}.profile-name{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-medium);color:var(--color-text-primary);margin:var(--size-4) 0}.profile-specialty{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);color:var(--color-text-icons--secondary);margin:0;margin-bottom:var(--size-2);text-transform:uppercase}.profile-collegiate{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);color:var(--color-gray-medium);text-transform:uppercase;margin:0}.description-header{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-medium);color:var(--color-primary);margin:0;margin-bottom:var(--size-3)}.description-text{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);color:var(--color-foreground);margin:0}`;let ke=class ChatRoomProfile extends d{constructor(){super(...arguments),this.getProfessionalQuery=new b(this,()=>y(this.apiClient,{hash:this.professionalHash}))}static{this.styles=[u,we]}renderProfile(e){return c`<div class="profile-container"><div class="profile-header"><mq-avatar class="profile-avatar" src="${e.avatar||""}" fallback="${e.name}" alt="${e.name}'s profile picture" size="xl"></mq-avatar><div><h1 class="profile-name">${e.name}</h1>${e.title?c`<p class="profile-specialty">${e.title}</p>`:""} ${e.collegiate_number?c`<p class="profile-collegiate">${a(r`Nº COL. ${e.collegiate_number}`)}</p>`:""}</div></div>${e.chat_schedule&&e.chat_schedule.gaps.length>0?c`<availability-section .gaps="${e.chat_schedule.gaps}"></availability-section>`:h} ${e.description||e.overview?c`<div><h2 class="description-header">${a("Descripción")}</h2><p class="description-text">${e.description||e.overview}</p></div>`:""}</div>`}render(){return this.getProfessionalQuery.render({pending:()=>c``,complete:e=>this.renderProfile(e)})}};e([i({context:n,subscribe:!0})],ke.prototype,"apiClient",void 0),e([m({type:String})],ke.prototype,"professionalHash",void 0),ke=e([o(),t("chat-room-profile")],ke);const xe=l`.root{display:flex;flex-direction:column;height:100%;overflow:hidden}chat-room-header{flex-shrink:0}chat-room-messages{flex:1;overflow-y:auto;overflow-x:hidden}chat-room-footer{position:sticky;bottom:0;left:0;right:0;flex-shrink:0}`;let Ce=class MqChatRoom extends d{constructor(){super(...arguments),this.consultationId=void 0,this.consultationType=void 0,this.readonly=!1,this.hideCloseButton=!1,this.view="chat",this.socketController=new le(this),this.readAllMessagesMutation=new U(this,{mutationFn:()=>this.apiClient.professionals.readAllMessages({roomId:this.roomId}),onSuccess:()=>{this.queryClientContext?.invalidateQueries({queryKey:D(this.apiClient,{roomId:this.roomId}).queryKey})}}),this.apiClient=I()}static{this.styles=[u,xe]}willUpdate(e){const t=z(e,{apiKey:this.apiKey,token:this.token},this.inheritedApiClient);t&&(this.apiClient=t),e.has("roomId")&&(this.socketController.socket?.emit(P.joinRoom,this.roomId),this.readAllMessagesMutation.run(void 0))}render(){return c`<div class="root"><chat-room-header .professionalHash="${this.professionalHash}" .view="${this.view}" .hideCloseButton="${this.hideCloseButton}" @mq-chat-room-profile="${()=>{this.view="profile"}}" @goto-chat="${()=>{this.view="chat"}}"></chat-room-header>${"chat"===this.view?c`<chat-room-messages .roomId="${this.roomId}" .professionalHash="${this.professionalHash}"></chat-room-messages>${this.readonly?h:c`<chat-room-footer .roomId="${this.roomId}"></chat-room-footer>`}`:c`<chat-room-profile .professionalHash="${this.professionalHash}" @mq-chat-room-chat="${()=>{this.view="chat"}}"></chat-room-profile>`}</div>`}};e([s({context:B}),m({type:String,attribute:"api-key"})],Ce.prototype,"apiKey",void 0),e([s({context:H}),m({type:String,attribute:"token"})],Ce.prototype,"token",void 0),e([s({context:N}),m({type:String,attribute:"professional-hash"})],Ce.prototype,"professionalHash",void 0),e([s({context:L}),m({type:Number,attribute:"room-id"})],Ce.prototype,"roomId",void 0),e([s({context:K}),m({type:String,attribute:"consultation-id"})],Ce.prototype,"consultationId",void 0),e([s({context:F}),m({type:String,attribute:"consultation-type"})],Ce.prototype,"consultationType",void 0),e([m({type:Boolean,reflect:!0})],Ce.prototype,"readonly",void 0),e([m({type:Boolean,attribute:"hide-close-button"})],Ce.prototype,"hideCloseButton",void 0),e([p()],Ce.prototype,"view",void 0),e([i({context:E,subscribe:!0})],Ce.prototype,"queryClientContext",void 0),e([i({context:n,subscribe:!0}),p()],Ce.prototype,"inheritedApiClient",void 0),e([s({context:n}),p()],Ce.prototype,"apiClient",void 0),Ce=e([o(),t("mq-chat-room")],Ce);export{Ce as MqChatRoom,MqChatRoomCloseEvent,MqChatRoomProfileEvent};
1
+ import{_ as e,c as t}from"./chunks/custom-element-D2ziPxYE.js";import{e as s}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{l as o}from"./chunks/localized-decorator-BlOuLhym.js";import{m as a,s as r}from"./chunks/runtime-Bg1WXVCx.js";import{A as n}from"./chunks/api-client-context-V1UAGtKW.js";import{i as l,a as d,x as c,E as h}from"./chunks/lit-element-DiWJYFwC.js";import{n as m}from"./chunks/property-scuRaFcM.js";import{r as p}from"./chunks/state-LQivXIgA.js";import{n as g}from"./chunks/create-context-DqP79qjF.js";import{tokens as u}from"./theme.js";import{xIcon as v}from"./ui/icons/x-icon.js";import"./ui/mq-avatar.js";import"./ui/mq-button.js";import"./ui/mq-skeleton.js";import{Q as b}from"./chunks/query-controller-BlO1Ax65.js";import{g as y}from"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import{o as f}from"./chunks/if-defined-BYeVdwgd.js";import{chevronLeftIcon as w}from"./ui/icons/chevron-left-icon.js";import{e as k}from"./chunks/query-CeeutdfT.js";import{l as x}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{DownloadFileEvent as C}from"./events.js";import{M as $,c as I,n as z}from"./chunks/api-chat-client-CJ1EGJe3.js";import{S as T,g as D}from"./chunks/chunk-Y4EKUX25-QqMl3eiq.js";import{checkDoubleIcon as M}from"./ui/icons/check-double-icon.js";import{checkIcon as j}from"./ui/icons/check-icon.js";import{getLocale as q}from"./i18n.js";import{S,a as P}from"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import{s as A}from"./chunks/context-consumer-ESdICVAb.js";import{s as _}from"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import{Q as E}from"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import{e as R}from"./chunks/class-map-Co76I6aw.js";import{M as U}from"./chunks/mutation-controller-CR2qcqhH.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./ui/icons/types.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";import"./env.js";const B=g("apiKey"),H=g("token"),N=g("professionalHash"),L=g("roomId"),K=g("consultationId"),F=g("consultationType");class MqChatRoomCloseEvent extends Event{static{this.eventName="mq-chat-room-close"}constructor(){super(MqChatRoomCloseEvent.eventName,{bubbles:!0,composed:!0})}}class MqChatRoomProfileEvent extends Event{static{this.eventName="mq-chat-room-profile"}constructor(){super(MqChatRoomProfileEvent.eventName,{bubbles:!0,composed:!0})}}const O=l`header{padding:var(--size-3) var(--size-4);background-color:var(--color-background-primary);display:flex;justify-content:space-between;gap:var(--size-1)}.left-side{display:flex;flex:1;min-width:0;align-items:center;gap:var(--size-3)}.left-side mq-avatar{flex-shrink:0}.info{min-width:0}.ghost-btn{text-align:left;background:0 0;border:none;padding:0;cursor:pointer}.right-side{display:flex;align-items:center}.name{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-bold);margin:0;color:var(--color-background);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.specialty{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);margin:0;color:var(--color-white);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.name-skeleton{margin-bottom:var(--size-1)}.profile-title{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-medium);margin:0;color:var(--color-white)}`;let Q=class ChatRoomHeader extends d{constructor(){super(...arguments),this.hideCloseButton=!1,this.getProfessionalQuery=new b(this,()=>y(this.apiClient,{hash:this.professionalHash}))}static{this.styles=O}handleClose(){this.dispatchEvent(new MqChatRoomCloseEvent)}handleClickProfile(){this.dispatchEvent(new MqChatRoomProfileEvent)}renderProfile(){return c`<div class="left-side"><mq-button type="button" size="icon-md" variant="ghost-inverted" @click="${()=>{this.dispatchEvent(new CustomEvent("goto-chat",{bubbles:!0,composed:!0}))}}">${w({size:24})}</mq-button><p class="profile-title">${a("Perfil de profesional")}</p></div>`}renderChat(){return c`${this.getProfessionalQuery.render({complete:e=>c`<button type="button" class="left-side ghost-btn" @click="${this.handleClickProfile}"><mq-avatar src="${f(e.avatar??void 0)}" alt="User Avatar" fallback="John Doe" size="sm"></mq-avatar><div class="info"><p class="name">${e.name}</p><p class="specialty">${e.title}</p></div></button>`,pending:()=>c`<div class="left-side"><mq-skeleton width="45px" height="45px" border-radius="full"></mq-skeleton><div><mq-skeleton class="name-skeleton" height="14px" width="120px"></mq-skeleton><mq-skeleton height="14px" width="100px"></mq-skeleton></div></div>`})}`}render(){return c`<header>${"profile"===this.view?this.renderProfile():this.renderChat()}<div class="right-side">${this.hideCloseButton?h:c`<mq-button type="button" size="icon-md" variant="ghost-inverted" @click="${this.handleClose}">${v({size:24})}</mq-button>`}</div></header>`}};e([i({context:n,subscribe:!0})],Q.prototype,"apiClient",void 0),e([m({type:String})],Q.prototype,"professionalHash",void 0),e([m({type:Boolean})],Q.prototype,"hideCloseButton",void 0),e([m({type:String})],Q.prototype,"view",void 0),Q=e([o(),t("chat-room-header")],Q);const V=/(https?:\/\/[^\s,;:!)\]}\]]+|www\.[^\s,;:!)\]}\]]+|[a-zA-Z0-9][-a-zA-Z0-9]*(?:\.[a-zA-Z0-9][-a-zA-Z0-9]*)+(?:\/[^\s,;:!)\]}\]]*|(?:\?|#|&)[^\s,;:!)\]}\]]*)?)/gi;function J(e){return e.split(V).map((e,t)=>{if(t%2==1){const t=e.startsWith("http")?e:`https://${e}`;return c`<a href="${t}" target="_blank" rel="noopener noreferrer" class="message-link">${e}</a>`}return e})}let Y=class TextMessageBubble extends d{static{this.styles=[l`:host{display:block}.message-bubble{padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);word-wrap:break-word;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal)}.message-bubble.received{background-color:var(--chat-received-message-background);color:var(--chat-received-message-foreground);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);color:var(--chat-sent-message-foreground);border-bottom-right-radius:0}.message-content{white-space:pre-wrap}.message-paragraph{margin:0 0 var(--size-3) 0}.message-paragraph:last-child{margin-bottom:0}.message-bubble.received .message-content a.message-link,.message-bubble.sent .message-content a.message-link{color:var(--color-primary-link-default);text-decoration:underline}.message-bubble.received .message-content a.message-link:hover,.message-bubble.sent .message-content a.message-link:hover{opacity:.8}`]}formatMessageContent(e){const t=e.split("\n\n").filter(e=>e.trim());if(t.length<=1)return c`<div class="message-content">${J(e)}</div>`;const s=t.map(e=>c`<div class="message-paragraph">${J(e.trim())}</div>`);return c`<div class="message-content">${s}</div>`}render(){return c`<div class="message-bubble ${this.kind}">${this.formatMessageContent(this.message.string)}</div>`}};e([m({type:Object})],Y.prototype,"message",void 0),e([m({type:String})],Y.prototype,"kind",void 0),Y=e([t("text-message-bubble")],Y);const Z=l`:host{display:block}.message-bubble{padding:var(--size-2);border-radius:var(--border-radius-lg);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);overflow:hidden}.message-bubble.received{background-color:var(--chat-received-message-background);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);border-bottom-right-radius:0}.image-content{display:block;width:229px;height:229px;object-fit:cover;border-radius:var(--border-radius-md)}.image-placeholder{display:flex;align-items:center;justify-content:center;width:100%;max-width:300px;height:200px;background-color:var(--color-gray-light);border-radius:var(--border-radius-md);color:var(--chat-sent-message-foreground);font-size:var(--text-sm)}.image-content{cursor:pointer;transition:opacity .2s ease}.image-content:hover{opacity:.9}.preview-overlay{position:fixed;top:0;left:0;right:0;bottom:0;background:var(--dialog-underlay);display:flex;align-items:center;justify-content:center;z-index:1000;cursor:pointer;opacity:0;transition:opacity var(--dialog-transition-duration) ease}.preview-overlay.open{opacity:1}.preview-image{position:fixed;z-index:1000;inset:var(--mq-safe-top,0) var(--mq-safe-right,0) var(--mq-safe-bottom,0) var(--mq-safe-left,0);max-width:calc(100% - var(--mq-safe-left,4px) - var(--mq-safe-right,4px));max-height:calc(100% - var(--mq-safe-top,4px) - var(--mq-safe-bottom,4px));margin:auto;object-fit:contain;cursor:default;box-shadow:var(--dialog-shadow);transform:scale(.95);transition:transform var(--dialog-transition-duration) ease}.preview-overlay.open .preview-image{transform:scale(1)}.preview-close{z-index:1001;display:inline-flex;align-items:center;justify-content:center;height:var(--size-10);width:var(--size-10);position:absolute;top:var(--mq-safe-top,4px);right:var(--mq-safe-right,4px);background:rgba(255,255,255,.3);border:none;color:var(--color-neutrals-text-default);font-size:var(--text-xl);padding:var(--size-2) var(--size-3);border-radius:var(--border-radius-md);cursor:pointer;transition:background var(--dialog-transition-duration) ease}.preview-close:hover{background:var(--dialog-close-hover-bg)}`;let G=class ImageMessageBubble extends d{constructor(){super(...arguments),this.showPreview=!1,this.isPreviewRendered=!1,this.isPreviewActive=!1,this.closeTimer=null}static{this.styles=Z}handleImageError(e){const t=e.target;t.style.display="none";const s=t.nextElementSibling;s&&(s.style.display="flex")}handleImageLoad(e){const t=e.target.nextElementSibling;t&&(t.style.display="none")}handleImageClick(){this.showPreview=!0,this.isPreviewRendered=!0,this.updateComplete.then(()=>{requestAnimationFrame(()=>{this.isPreviewActive=!0})})}handleImageKeyDown(e){"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),this.handleImageClick())}handleClosePreview(e){e&&e.stopPropagation(),this.isPreviewActive=!1,this.closeTimer&&window.clearTimeout(this.closeTimer),this.closeTimer=window.setTimeout(()=>{this.isPreviewRendered=!1,this.showPreview=!1,this.closeTimer=null},200)}handleOverlayClick(e){e.target===e.currentTarget&&this.handleClosePreview()}handleOverlayKeyDown(e){"Enter"!==e.key&&" "!==e.key||e.target===e.currentTarget&&(e.preventDefault(),this.handleClosePreview())}handleKeyDown(e){"Escape"===e.key&&this.showPreview&&(e.preventDefault(),this.handleClosePreview())}handlePreviewImageKeyDown(e){e.stopPropagation()}connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeyDown.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeyDown.bind(this)),this.closeTimer&&(window.clearTimeout(this.closeTimer),this.closeTimer=null)}render(){const e=this.message.attachment.signed_url??this.message.attachment.url;return c`<div class="message-bubble ${this.kind}"><img class="image-content" src="${e}" width="229" height="229" alt="Shared attachment" @error="${this.handleImageError}" @load="${this.handleImageLoad}" @click="${this.handleImageClick}" @keydown="${this.handleImageKeyDown}" tabindex="0"><div class="image-placeholder" style="display:none">Image unavailable</div></div>${this.showPreview&&this.isPreviewRendered?c`<div class="preview-overlay ${this.isPreviewActive?"open":""}" @click="${this.handleOverlayClick}" @keydown="${this.handleOverlayKeyDown}" tabindex="0"><button class="preview-close" @click="${this.handleClosePreview}" aria-label="Close preview">${v({size:24})}</button> <img class="preview-image" src="${e}" alt="Shared attachment preview" @click="${e=>e.stopPropagation()}" @keydown="${this.handlePreviewImageKeyDown}" tabindex="0"></div>`:""}`}};e([m({type:Object})],G.prototype,"message",void 0),e([m({type:String})],G.prototype,"kind",void 0),e([i({context:H})],G.prototype,"token",void 0),e([p()],G.prototype,"showPreview",void 0),e([p()],G.prototype,"isPreviewRendered",void 0),e([p()],G.prototype,"isPreviewActive",void 0),G=e([t("image-message-bubble")],G);const W=l`:host{background-color:var(--chat-system-message-background);color:var(--chat-system-message-foreground);display:block;padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal)}a.message-link{color:var(--color-primary-link-default);text-decoration:underline}a.message-link:hover{opacity:.8}`;let X=class SystemMessageBubble extends d{static{this.styles=W}render(){return c`<div class="system-message-bubble">${J(this.message.string)}</div>`}};e([m({type:Object})],X.prototype,"message",void 0),X=e([t("system-message-bubble")],X);const ee=l`:host{display:block}.message-bubble{display:inline-block;padding:var(--size-2_5) var(--size-4);border-radius:var(--border-radius-lg);word-wrap:break-word;font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);text-decoration:underline;color:var(--color-primary-link-default);border:none;cursor:pointer;text-align:left}.message-bubble:hover:not(:disabled){opacity:.8}.message-bubble:disabled{opacity:.5;cursor:not-allowed}.message-bubble.received{background-color:var(--chat-received-message-background);border-bottom-left-radius:0}.message-bubble.sent{background-color:var(--chat-sent-message-background);border-bottom-right-radius:0}.message-content{white-space:pre-wrap}.message-paragraph{margin:0 0 var(--size-3) 0}.message-paragraph:last-child{margin-bottom:0}`;let te=class FileMessageBubble extends d{constructor(){super(...arguments),this.isDownloading=!1}static{this.styles=ee}formatMessageContent(e){const t=e.split("\n\n").filter(e=>e.trim());if(t.length<=1)return c`<div class="message-content">${e}</div>`;const s=t.map(e=>c`<div class="message-paragraph">${e.trim()}</div>`);return c`<div class="message-content">${s}</div>`}async handleDownload(){if(this.isDownloading)return;const e=this.message.attachment.url;try{this.isDownloading=!0;const t=await fetch(e,{headers:{Authorization:`Bearer ${this.token}`}});if(!t.ok)throw new Error(`Failed to fetch file: ${t.statusText}`);const s=await t.blob(),i=new FileReader;i.onloadend=()=>{const e=i.result,t=new C({url:e,filename:this.message.attachment.file_name});this.dispatchEvent(t),this.isDownloading=!1},i.onerror=()=>{x.error("Error reading file as data URL"),this.isDownloading=!1},i.readAsDataURL(s)}catch(e){x.error("Error downloading file:",e),this.isDownloading=!1}}render(){return c`<button type="button" @click="${this.handleDownload}" class="message-bubble ${this.kind}" ?disabled="${this.isDownloading}">${this.formatMessageContent(this.message.attachment.file_name)}</button>`}};e([m({type:Object})],te.prototype,"message",void 0),e([m({type:String})],te.prototype,"kind",void 0),e([i({context:H})],te.prototype,"token",void 0),e([p()],te.prototype,"isDownloading",void 0),te=e([t("file-message-bubble")],te);let se=class MessageBubble extends d{constructor(){super(...arguments),this.showTimestamp=!0}static{this.styles=[l`:host{display:block}.timestamp{font-family:var(--font-body);font-size:var(--text-xs);color:var(--color-gray-medium);font-weight:var(--font-weight-normal);text-align:left;display:flex;align-items:center;gap:var(--size-1)}.timestamp.sent{text-align:right;justify-content:flex-end}.status-icon{width:12px;height:12px}.status-icon.read{color:var(--color-primary)}`]}formatTimestamp(e){if(!e)return"";try{const t=new Date(e);return new Intl.DateTimeFormat(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1}).format(t)}catch{return e}}renderStatusIcon(){switch(this.message.status){case $.Sent:return j({size:12,color:"currentColor"});case $.Received:return M({size:12,color:"currentColor"});case $.Read:return M({size:12,color:"currentColor",className:"read"});default:return null}}renderBubbleContent(){switch(this.message.type){case"image":return c`<image-message-bubble .message="${this.message}" .kind="${this.kind}"></image-message-bubble>`;case"file":return c`<file-message-bubble .message="${this.message}" .kind="${this.kind}"></file-message-bubble>`;default:return c`<text-message-bubble .message="${this.message}" .kind="${this.kind}"></text-message-bubble>`}}render(){if(this.message.senderType===T.system)return c`<system-message-bubble .message="${this.message}"></system-message-bubble>`;const e=this.message.createdAt?new Date(this.message.createdAt):this.message.time?new Date(this.message.time):null;return c`${this.renderBubbleContent()} ${this.showTimestamp&&e?c`<div class="timestamp ${this.kind}">${this.formatTimestamp(e.toISOString())} ${"sent"===this.kind?c`<span class="status-icon ${this.message.status===$.Read?"read":""}">${this.renderStatusIcon()}</span>`:""}</div>`:""}`}};e([m({type:String})],se.prototype,"kind",void 0),e([m({type:Object})],se.prototype,"message",void 0),e([m({type:Boolean})],se.prototype,"showTimestamp",void 0),se=e([t("message-bubble")],se);let ie=class DateBanner extends d{constructor(){super(...arguments),this.date=""}static{this.styles=[u,l`:host{display:block;margin-bottom:var(--size-2)}.date-banner{display:flex;align-items:center;justify-content:center;position:relative}.date-text{background-color:var(--color-gray-light);color:var(--color-gray-darker);font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);padding:var(--size-1) var(--size-2);border-radius:var(--border-radius-2xl);white-space:nowrap}`]}formatDate(e){const t=q().replace("_","-"),s=new Date(e),i=new Date,o=new Date(i);o.setDate(o.getDate()-1);const r=new Date(s.getFullYear(),s.getMonth(),s.getDate()),n=new Date(i.getFullYear(),i.getMonth(),i.getDate()),l=new Date(o.getFullYear(),o.getMonth(),o.getDate());return r.getTime()===n.getTime()?a("Hoy"):r.getTime()===l.getTime()?a("Ayer"):s.toLocaleDateString(t,{dateStyle:"medium"})}render(){return c`<div class="date-banner"><span class="date-text">${this.formatDate(this.date)}</span></div>`}};function oe(e){return e.createdAt?new Date(e.createdAt):e.time?new Date(e.time):new Date}e([m({type:String})],ie.prototype,"date",void 0),ie=e([o(),t("date-banner")],ie);let ae=class MessagesList extends d{constructor(){super(...arguments),this.messages=[]}static{this.styles=[u,l`:host{display:block;width:100%;height:100%;overflow-y:auto;overflow-x:hidden}.messages-container{display:flex;flex-direction:column;padding:var(--size-4);gap:var(--size-1);background-color:var(--color-white);padding-bottom:var(--size-4)}.message-wrapper{display:flex;width:100%}.message-wrapper.received{justify-content:flex-start}.message-wrapper.sent{justify-content:flex-end}.message-wrapper.system{justify-content:center}message-bubble{max-width:70%}`]}scrollToBottom(){requestAnimationFrame(()=>{const e=this.messagesContainerEnd;e&&e.scrollIntoView({behavior:"instant",block:"end"})})}shouldShowMessageTimestamp(e,t){if(e.senderType===T.system)return!1;if(!t)return!0;if(t.senderType!==e.senderType)return!0;if(t.senderType===T.ordinary&&e.senderType===T.ordinary&&t.fromUserHash!==e.fromUserHash)return!0;return(oe(t).getTime()-oe(e).getTime())/6e4>1}groupMessagesByDate(e){const t=[];let s=null;return e.forEach((i,o)=>{const a=oe(i),r=a?.toDateString();r!==s&&(t.push({type:"date",data:a.toDateString()}),s=r??null);const n=e[o+1],l=this.shouldShowMessageTimestamp(i,n);t.push({type:"message",data:i,showTimestamp:l})}),t}firstUpdated(){this.scrollToBottom()}willUpdate(e){e.has("messages")&&this.scrollToBottom()}render(){const e=this.groupMessagesByDate(this.messages),t=e.map((t,s)=>{if("date"===t.type)return c`<date-banner .date="${t.data}"></date-banner>`;const i=this.professionalHash!==t.data.fromUserHash,o=t.data.senderType===T.system?"system":i?"sent":"received";return c`<div class="message-wrapper ${o}"><message-bubble .message="${t.data}" .kind="${o}" .showTimestamp="${t.showTimestamp||"date"===e[s+1]?.type}"></message-bubble></div>`});return c`<div class="messages-container">${t}<div class="messages-container-end"></div></div>`}};e([m({type:Array})],ae.prototype,"messages",void 0),e([m({type:String})],ae.prototype,"professionalHash",void 0),e([k(".messages-container-end")],ae.prototype,"messagesContainerEnd",void 0),ae=e([t("messages-list")],ae);let re=class MessageBubbleSkeleton extends d{constructor(){super(...arguments),this.variant="patient",this.height="md",this.showTimestamp=!0}static{this.styles=[l`:host{display:block}.message-bubble{padding:var(--size-4);border-radius:var(--border-radius-lg);margin-bottom:var(--size-1);position:relative;overflow:hidden}.message-bubble.doctor{background-color:var(--color-gray-light);border-bottom-left-radius:0}.message-bubble.patient{background-color:var(--color-background-primary-light);border-bottom-right-radius:0}:host([height=sm]) .message-bubble{height:var(--size-8)}:host([height=md]) .message-bubble{height:var(--size-12)}`]}render(){return c`<div class="message-bubble ${this.variant}"></div>${this.showTimestamp?c`<div class="timestamp-skeleton ${this.variant}"></div>`:""}`}};e([m({type:String})],re.prototype,"variant",void 0),e([m({type:String})],re.prototype,"height",void 0),e([m({type:Boolean})],re.prototype,"showTimestamp",void 0),re=e([t("message-bubble-skeleton")],re);let ne=class MessagesSkeleton extends d{constructor(){super(...arguments),this.messageCount=6}static{this.styles=[u,l`:host{display:block;width:100%;height:100%;overflow:hidden}.messages-container{display:flex;flex-direction:column;padding:var(--size-4);gap:var(--size-3);max-width:100%;height:100%;background-color:var(--color-white)}.message-wrapper{display:flex;width:100%}.message-wrapper.doctor{justify-content:flex-start}.message-wrapper.patient{justify-content:flex-end}message-bubble-skeleton{max-width:85%;min-width:60%;width:100%}`]}getSkeletonHeight(e){const t=["sm","md","sm","md","sm","md"];return t[e%t.length]}getSkeletonVariant(e){const t=["doctor","patient","doctor","doctor","patient","doctor","patient"];return t[e%t.length]}renderSkeletonMessages(){return Array.from({length:this.messageCount},(e,t)=>{const s=this.getSkeletonVariant(t),i=this.getSkeletonHeight(t);return c`<div class="message-wrapper ${s}"><message-bubble-skeleton variant="${s}" height="${i}" ?showTimestamp="${t===this.messageCount-1||Math.random()>.7}"></message-bubble-skeleton></div>`})}render(){return c`<div class="messages-container">${this.renderSkeletonMessages()}</div>`}};e([m({type:Number})],ne.prototype,"messageCount",void 0),ne=e([t("messages-skeleton")],ne);var le=class{constructor(e,t){this.host=e,this.listeners=[],this.host.addController(this),this.socketContext=new A(this.host,{context:S,subscribe:!0,callback:e=>{if(e&&(this.socket=e,t?.listeners)){this.listeners=t.listeners;for(const e of this.listeners)this.socket?.on(e.eventName,e.callback)}}})}hostConnected(){}hostDisconnected(){for(const e of this.listeners)this.socket?.off(e.eventName,e.callback)}};function de(e,t){return{queryKey:_(e,"rooms",t.roomId),queryFn:()=>e.rooms.getRoomMessages(t),staleTime:0}}class OptimisticUpdatesController{constructor(e){this.host=e,this.apiClientContext=new A(this.host,{context:n,subscribe:!0,callback:e=>{this.apiClient=e}}),this.queryClientContext=new A(this.host,{context:E,subscribe:!0,callback:e=>{e&&(this.queryClient=e)}}),this.host.addController(this)}hostConnected(){}appendMessageToRoom(e,t){if(!this.apiClient)return;const s=de(this.apiClient,{roomId:t}).queryKey;this.queryClient?.setQueriesData({queryKey:s,exact:!0},t=>[...t??[],e])}deleteMessage(e,t){if(!this.queryClient||!this.apiClient)return;const s=de(this.apiClient,{roomId:t}).queryKey;this.queryClient.setQueryData(s,t=>(t??[]).map(t=>t.messageId===e?{...t,deletedAt:(new Date).toISOString(),string:a("Este mensaje fue eliminado")}:t))}updateMessageStatus({messageId:e,status:t,roomId:s}){if(!this.queryClient||!this.apiClient)return;const i=de(this.apiClient,{roomId:s}).queryKey;this.queryClient.setQueryData(i,s=>(s??[]).map(s=>s.messageId===e?{...s,status:t}:s))}}let ce=class ChatRoomMessages extends d{constructor(){super(...arguments),this.getRoomMessagesQuery=new b(this,()=>de(this.apiClient,{roomId:this.roomId})),this.optimisticUpdatesController=new OptimisticUpdatesController(this),this.onMessageReceived=e=>{if(e.roomId!==this.roomId)return;const t=function(e){const t={roomId:"string"==typeof e.roomId?Number.parseInt(e.roomId,10):e.roomId,messageId:e.messageId,status:e.status,senderType:e.senderType,fromUserHash:e.fromUserHash,time:e.time,createdAt:e.time?new Date(e.time).toISOString():null,deletedAt:null};switch(e.type){case"string":return{...t,type:"string",string:e.string,auto:e.auto?1:0,attachment:null};case"image":return{...t,type:"image",string:e.fileName||"",auto:0,attachment:{file_name:e.fileName,file_size:e.fileSize,url:e.imageUrl,type:"uncategorized",meta:{duration:0},signed_url:e.imageUrl}};case"file":return{...t,type:"file",string:e.fileName||"",auto:0,attachment:{file_name:e.fileName,file_size:e.fileSize,url:e.fileUrl,type:"uncategorized",meta:{duration:0},signed_url:e.fileUrl}};default:return{...t,type:"string",string:"",auto:0,attachment:null}}}(e);this.optimisticUpdatesController.appendMessageToRoom(t,t.roomId),t.roomId===this.roomId&&e.fromUserHash===this.professionalHash&&this._socketController.socket?.emit(P.messageStatus,e.messageId,this.roomId,$.Read)},this.onMessageDeleted=e=>{e.room_id===this.roomId&&this.optimisticUpdatesController.deleteMessage(e.message_id,e.room_id)},this.onMessageStatusUpdated=e=>{e.roomId===this.roomId&&this.optimisticUpdatesController.updateMessageStatus({messageId:e.messageId,status:e.status,roomId:e.roomId})},this._socketController=new le(this,{listeners:[{eventName:P.message,callback:this.onMessageReceived},{eventName:P.message_deleted,callback:this.onMessageDeleted},{eventName:P.messageStatus,callback:this.onMessageStatusUpdated}]})}static{this.styles=[u,l`:host{display:block;width:100%;height:100%}`]}render(){return this.getRoomMessagesQuery.render({pending:()=>c`<messages-skeleton messageCount="8"></messages-skeleton>`,complete:e=>c`<messages-list .messages="${e}" .professionalHash="${this.professionalHash}"></messages-list>`})}};e([i({context:n,subscribe:!0})],ce.prototype,"apiClient",void 0),e([m({type:Number})],ce.prototype,"roomId",void 0),e([m({type:String})],ce.prototype,"professionalHash",void 0),ce=e([t("chat-room-messages")],ce);var he=class{constructor(e){this.string=e.string,this.roomId=e.roomId,this.messageId=e.messageId,this.type=e.type,this.fileName=e.fileName,this.autoMessage=e.autoMessage,this.senderType=e.senderType,this.attachmentType=e.attachmentType,this.consultationId=e.consultationId,this.consultationType=e.consultationType}toSocketMessage(){return[P.message,this.string,this.roomId,this.messageId,this.type,this.fileName,this.autoMessage,this.senderType,this.attachmentType,this.consultationId,this.consultationType]}},me=class extends he{constructor(e){super({roomId:e.roomId,messageId:e.messageId,string:e.string,type:"string",fileName:null,autoMessage:!1,senderType:T.ordinary,attachmentType:"uncategorized",consultationId:e.consultationId,consultationType:e.consultationType})}},pe=class extends he{constructor(e){super({roomId:e.roomId,messageId:e.messageId,string:e.base64Attachment,fileName:e.fileName,type:e.type,autoMessage:!1,senderType:T.ordinary,attachmentType:"uncategorized",consultationId:e.consultationId,consultationType:e.consultationType})}};async function ge(e){return await Promise.all(e.map(async e=>{const t=await function(e){return new Promise((t,s)=>{const i=new FileReader;i.onload=()=>{const o=i.result.split(",")[1];o?t(o):s(new Error(`Invalid data URL format for file: ${e.name}`))},i.onerror=()=>{s(new Error(`Failed to read file: ${e.name}`))},i.readAsDataURL(e)})}(e);return{name:e.name,size:e.size,type:e.type,base64:t}}))}const ue=l`:host{display:block;position:absolute;bottom:0;padding:var(--size-2) var(--size-2);background:#fff}.footer-container{display:flex;align-items:center;gap:var(--size-1);max-width:100%}.input-container{flex:1;position:relative;display:flex;align-items:center;border:1px solid var(--color-neutrals-border-disabled);border-radius:var(--border-radius-2xl);padding:0 var(--size-1);overflow:hidden}.input-container:focus-within{border-color:var(--color-primary)}.message-input{flex:1;border:none;outline:0;background:0 0;font-family:var(--font-body);font-size:var(--text-base);font-size:var(--text-sm);line-height:var(--text-sm--line-height);color:var(--color-neutrals-text-default);padding-left:var(--sp-2)}.message-input::placeholder{color:var(--color-neutrals-text-medium)}.attachment-icon{width:var(--size-5);height:var(--size-5);color:var(--color-primary)}.send-icon{width:var(--size-5);height:var(--size-5);color:var(--color-primary)}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border-width:0}.send-button{color:var(--color-neutrals-link-disabled);background:0 0;border:none;padding:var(--size-2);border-radius:var(--border-radius-md);cursor:pointer;display:flex;align-items:center;justify-content:center;transition:background-color .2s ease}.send-button:hover:not(.disabled){background:var(--color-primary-light)}.send-button:active:not(.disabled){background-color:var(--color-neutrals-background-active)}.send-button.disabled{cursor:not-allowed;opacity:.4}.send-button.disabled .send-icon{color:var(--color-neutrals-text-disabled)}`;let ve=class ChatRoomFooter extends d{constructor(){super(...arguments),this.isTyping=!1,this.typingTimeoutId=null,this.inputValue="",this.socketController=new le(this)}static{this.styles=[ue]}handleInputChange(e){const t=e.target;this.inputValue=t.value,this.isTyping||(this.socketController.socket?.emit(P.typing,this.roomId),this.isTyping=!0),this.typingTimeoutId&&clearTimeout(this.typingTimeoutId),this.typingTimeoutId=setTimeout(()=>{this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.isTyping=!1)},1500)}handleKeyDown(e){"Enter"!==e.key||e.shiftKey||(e.preventDefault(),this.handleSendMessage())}async handleAttachment(e){const t=e.target.files;if(!t||0===t.length)return;const s=t.item(0);if(s)try{const e=(await ge([s]))[0];if(!e)return void x.error("Error converting file to base64");const t=e?.type.includes("image")?"image":"file",i=crypto.randomUUID(),o=s.name,a=new pe({type:t,base64Attachment:e.base64,fileName:o,roomId:this.roomId,messageId:i,consultationId:this.consultationId,consultationType:this.consultationType});this.socketController.socket?.emit(...a.toSocketMessage())}catch(e){x.error("Error converting files to base64:",e)}}handleAttachmentClick(){this.attachmentInput.click()}handleSendMessage(){const e=this.inputValue.trim();if(!e)return;const t=crypto.randomUUID();this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.isTyping=!1,this.typingTimeoutId&&clearTimeout(this.typingTimeoutId));const s=new me({messageId:t,string:e,roomId:this.roomId,consultationId:this.consultationId,consultationType:this.consultationType});this.socketController.socket?.emit(...s.toSocketMessage()),this.inputValue=""}disconnectedCallback(){this.isTyping&&(this.socketController.socket?.emit(P.stop_typing,this.roomId),this.typingTimeoutId&&clearTimeout(this.typingTimeoutId))}render(){const e=this.inputValue.trim().length>0;return c`<div class="footer-container"><div class="input-container"><input class="message-input" type="text" placeholder="${a("Escribe aquí...")}" .value="${this.inputValue}" @input="${this.handleInputChange}" @keydown="${this.handleKeyDown}"><div><input class="attachment-input sr-only" type="file" accept="image/jpeg,image/jpg,image/png,image/gif,image/bmp,image/tiff,application/pdf,text/*,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-powerpoint,application/vnd.openxmlformats-officedocument.presentationml.presentation,audio/*,video/*" @change="${this.handleAttachment}"><mq-button variant="ghost" size="icon-sm" @click="${this.handleAttachmentClick}" title="${a("Adjuntar archivo")}">${c`<svg class="attachment-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"/></svg>`}</mq-button></div></div><button class="send-button ${e?"":"disabled"}" @click="${this.handleSendMessage}" ?disabled="${!e}" title="${a("Enviar mensaje")}">${c`<svg class="send-icon" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 2L11 13"/><path d="M22 2L15 22L11 13L2 9L22 2z"/></svg>`}</button></div>`}};e([i({context:K})],ve.prototype,"consultationId",void 0),e([i({context:F})],ve.prototype,"consultationType",void 0),e([m({type:Number})],ve.prototype,"roomId",void 0),e([p()],ve.prototype,"inputValue",void 0),e([k(".attachment-input")],ve.prototype,"attachmentInput",void 0),ve=e([t("chat-room-footer")],ve);const be=e=>({all_week:!0,monday:1===e,tuesday:2===e,wednesday:3===e,thursday:4===e,friday:5===e,saturday:6===e,sunday:7===e,working_week:e>=1&&e<=5,weekend:0===e||6===e});function ye(e,t){const s=be(6===e?0:e+1);return t.some(e=>{const t=e.days_of_week;return!0===s[t]})}let fe=class AvailabilitySection extends d{constructor(){super(...arguments),this.gaps=[],this.selectedDay=function(){const e=(new Date).getDay();return 0===e?6:e-1}()}static{this.styles=l`:host{display:flex;flex-direction:column;gap:var(--size-3)}.availability-header{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-normal);color:var(--color-primary);text-align:center;margin:0;margin-bottom:var(--size-4) 0}.availability-days{display:flex;flex-direction:row;justify-content:center;gap:var(--size-1);overflow-x:auto;padding-bottom:var(--size-4)}.availability-button{outline:0;border:1px solid var(--color-gray-medium);background:0 0;color:var(--color-gray-medium);cursor:pointer;height:var(--size-9);width:var(--size-10);border-radius:var(--border-radius-sm);text-transform:capitalize;font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium)}.availability-button:hover{background-color:color-mix(in srgb,var(--color-gray-light) 50%,transparent)}.availability-button:focus{background-color:color-mix(in srgb,var(--color-gray-light) 50%,transparent)}.availability-button.active{background:var(--color-primary);color:var(--color-white);border:none}.availability-button:disabled{opacity:.5;cursor:not-allowed;background-color:var(--color-gray-light)}.time-title{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);color:var(--color-gray-dark);margin:0;margin-bottom:var(--size-1)}.time-entries{display:flex;flex-direction:column;gap:var(--size-1);margin-bottom:var(--size-6)}.time-entry{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal);color:var(--color-gray-medium);margin:0}`}updated(e){e.has("gaps")&&(void 0===this.selectedDay||ye(this.selectedDay,this.gaps)||(this.selectedDay=void 0))}render(){const e=[{shortLabel:a("Lu"),label:a("Lunes"),key:"monday",disabled:!ye(0,this.gaps)},{shortLabel:a("Ma"),label:a("Martes"),key:"tuesday",disabled:!ye(1,this.gaps)},{shortLabel:a("Mi"),label:a("Miércoles"),key:"wednesday",disabled:!ye(2,this.gaps)},{shortLabel:a("Ju"),label:a("Jueves"),key:"thursday",disabled:!ye(3,this.gaps)},{shortLabel:a("Vi"),label:a("Viernes"),key:"friday",disabled:!ye(4,this.gaps)},{shortLabel:a("Sa"),label:a("Sábado"),key:"saturday",disabled:!ye(5,this.gaps)},{shortLabel:a("Do"),label:a("Domingo"),key:"sunday",disabled:!ye(6,this.gaps)}];return c`<h2 class="availability-header">${a("Disponibilidad")}</h2><div class="availability-days">${e.map((e,t)=>c`<button type="button" class="availability-button ${R({active:this.selectedDay===t&&!e.disabled})}" ?disabled="${e.disabled}" @click="${()=>{e.disabled||(this.selectedDay=t)}}">${e.shortLabel}</button>`)}</div>${void 0===this.selectedDay||e[this.selectedDay]?.disabled?"":(()=>{const t=function(e,t){const s=be(6===e?0:e+1);return t.filter(e=>{const t=e.days_of_week;return!0===s[t]}).map(e=>({from_time:e.from_time,to_time:e.to_time}))}(this.selectedDay,this.gaps);return c`<div class="availability-time"><p class="time-title">${e[this.selectedDay]?.label}</p><div class="time-entries">${t.length>0?t.map(e=>c`<p class="time-entry">${a("De")} ${e.from_time} ${a("a")} ${e.to_time}</p>`):c`<p class="time-entry">${a("No hay horarios disponibles")}</p>`}</div></div>`})()}`}};e([m({type:Array})],fe.prototype,"gaps",void 0),e([p()],fe.prototype,"selectedDay",void 0),fe=e([o(),t("availability-section")],fe);const we=l`:host{display:flex;flex-direction:column;height:100%;overflow-y:auto;background-color:var(--color-white)}.profile-container{padding:var(--size-6);display:flex;flex-direction:column}.profile-header{display:flex;flex-direction:column;align-items:center;text-align:center;padding-bottom:var(--size-6);border-bottom:1px solid var(--color-gray-medium);margin-bottom:var(--size-6)}.profile-avatar{margin-bottom:var(--size-2)}.profile-name{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-medium);color:var(--color-text-primary);margin:var(--size-4) 0}.profile-specialty{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-medium);color:var(--color-text-icons--secondary);margin:0;margin-bottom:var(--size-2);text-transform:uppercase}.profile-collegiate{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);color:var(--color-gray-medium);text-transform:uppercase;margin:0}.description-header{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-medium);color:var(--color-primary);margin:0;margin-bottom:var(--size-3)}.description-text{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);color:var(--color-foreground);margin:0}`;let ke=class ChatRoomProfile extends d{constructor(){super(...arguments),this.getProfessionalQuery=new b(this,()=>y(this.apiClient,{hash:this.professionalHash}))}static{this.styles=[u,we]}renderProfile(e){return c`<div class="profile-container"><div class="profile-header"><mq-avatar class="profile-avatar" src="${e.avatar||""}" fallback="${e.name}" alt="${e.name}'s profile picture" size="xl"></mq-avatar><div><h1 class="profile-name">${e.name}</h1>${e.title?c`<p class="profile-specialty">${e.title}</p>`:""} ${e.collegiate_number?c`<p class="profile-collegiate">${a(r`Nº COL. ${e.collegiate_number}`)}</p>`:""}</div></div>${e.chat_schedule&&e.chat_schedule.gaps.length>0?c`<availability-section .gaps="${e.chat_schedule.gaps}"></availability-section>`:h} ${e.description||e.overview?c`<div><h2 class="description-header">${a("Descripción")}</h2><p class="description-text">${e.description||e.overview}</p></div>`:""}</div>`}render(){return this.getProfessionalQuery.render({pending:()=>c``,complete:e=>this.renderProfile(e)})}};e([i({context:n,subscribe:!0})],ke.prototype,"apiClient",void 0),e([m({type:String})],ke.prototype,"professionalHash",void 0),ke=e([o(),t("chat-room-profile")],ke);const xe=l`.root{display:flex;flex-direction:column;height:100%;overflow:hidden}chat-room-header{flex-shrink:0}chat-room-messages{flex:1;overflow-y:auto;overflow-x:hidden}chat-room-footer{position:sticky;bottom:0;left:0;right:0;flex-shrink:0}`;let Ce=class MqChatRoom extends d{constructor(){super(...arguments),this.consultationId=void 0,this.consultationType=void 0,this.readonly=!1,this.hideCloseButton=!1,this.view="chat",this.socketController=new le(this),this.readAllMessagesMutation=new U(this,{mutationFn:()=>this.apiClient.professionals.readAllMessages({roomId:this.roomId}),onSuccess:()=>{this.queryClientContext?.invalidateQueries({queryKey:D(this.apiClient,{roomId:this.roomId}).queryKey})}}),this.apiClient=I()}static{this.styles=[u,xe]}willUpdate(e){const t=z(e,{apiKey:this.apiKey,token:this.token},this.inheritedApiClient);t&&(this.apiClient=t),e.has("roomId")&&(this.socketController.socket?.emit(P.joinRoom,this.roomId),this.readAllMessagesMutation.run(void 0))}render(){return c`<div class="root"><chat-room-header .professionalHash="${this.professionalHash}" .view="${this.view}" .hideCloseButton="${this.hideCloseButton}" @mq-chat-room-profile="${()=>{this.view="profile"}}" @goto-chat="${()=>{this.view="chat"}}"></chat-room-header>${"chat"===this.view?c`<chat-room-messages .roomId="${this.roomId}" .professionalHash="${this.professionalHash}"></chat-room-messages>${this.readonly?h:c`<chat-room-footer .roomId="${this.roomId}"></chat-room-footer>`}`:c`<chat-room-profile .professionalHash="${this.professionalHash}" @mq-chat-room-chat="${()=>{this.view="chat"}}"></chat-room-profile>`}</div>`}};e([s({context:B}),m({type:String,attribute:"api-key"})],Ce.prototype,"apiKey",void 0),e([s({context:H}),m({type:String,attribute:"token"})],Ce.prototype,"token",void 0),e([s({context:N}),m({type:String,attribute:"professional-hash"})],Ce.prototype,"professionalHash",void 0),e([s({context:L}),m({type:Number,attribute:"room-id"})],Ce.prototype,"roomId",void 0),e([s({context:K}),m({type:String,attribute:"consultation-id"})],Ce.prototype,"consultationId",void 0),e([s({context:F}),m({type:String,attribute:"consultation-type"})],Ce.prototype,"consultationType",void 0),e([m({type:Boolean,reflect:!0})],Ce.prototype,"readonly",void 0),e([m({type:Boolean,attribute:"hide-close-button"})],Ce.prototype,"hideCloseButton",void 0),e([p()],Ce.prototype,"view",void 0),e([i({context:E,subscribe:!0})],Ce.prototype,"queryClientContext",void 0),e([i({context:n,subscribe:!0}),p()],Ce.prototype,"inheritedApiClient",void 0),e([s({context:n}),p()],Ce.prototype,"apiClient",void 0),Ce=e([o(),t("mq-chat-room")],Ce);export{Ce as MqChatRoom,MqChatRoomCloseEvent,MqChatRoomProfileEvent};
@@ -1,7 +1,7 @@
1
1
  import * as lit_html from 'lit-html';
2
2
  import * as lit from 'lit';
3
3
  import { LitElement, PropertyValues } from 'lit';
4
- import { M as MediquoApiChatClient } from './chunks/index.d-Bl682CAX.js';
4
+ import { M as MediquoApiChatClient } from './chunks/index.d-XSe7Hy-Q.js';
5
5
  import { Env } from './env.js';
6
6
  import { Locale } from './i18n.js';
7
7
  import './ui/mq-skeleton.js';
@@ -1 +1 @@
1
- import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{e as s}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{m as o}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{h as r}from"./chunks/task-Bj8p7kJX.js";import{c as a,P as h,n as c}from"./chunks/api-chat-client-pGZWREjK.js";import{A as d}from"./chunks/api-client-context-V1UAGtKW.js";import{L as l}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as m,a as u,x as v}from"./chunks/lit-element-DiWJYFwC.js";import{n as _}from"./chunks/property-scuRaFcM.js";import{r as f}from"./chunks/state-LQivXIgA.js";import{setEnv as k}from"./env.js";import{tokens as y}from"./theme.js";import{initLocalization as g,setLocale as E,isValidLocale as C}from"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";var x=class{constructor(t,e){this.host=t,this.options=e,this._deadline=0,this._timedOut=!1,this.host.addController(this)}get timedOut(){return this._timedOut}hostConnected(){const t=this.options.intervalMs??1e3,e=void 0!==this.options.startDelayMs?this.options.startDelayMs:t;this._deadline=Date.now()+this.options.timeoutMs,this._timedOut=!1,this._startTimeoutId=setTimeout(()=>{this._startTimeoutId=void 0,this._poll(),this._intervalId=setInterval(()=>{this._poll()},t)},e)}hostDisconnected(){this._stop()}stop(){this._stop()}async _poll(){if(Date.now()>=this._deadline)return this._stop(),this._timedOut=!0,this.host.requestUpdate(),void this.options.onTimeout?.();try{const t=await this.options.refetchFn();this.options.shouldComplete(t)&&(this._stop(),this.options.onComplete?.(t))}catch{}}_stop(){void 0!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),void 0!==this._startTimeoutId&&(clearTimeout(this._startTimeoutId),this._startTimeoutId=void 0)}};try{g()}catch{}const b=m`:host{height:100%;min-height:0;display:flex;flex-direction:column;flex:1}.payment-frame{position:relative;width:100%;min-width:0;display:flex;flex-direction:column;flex:1;min-height:0}.payment-frame iframe:not(.loaded){position:absolute;width:1px;height:1px;opacity:0;pointer-events:none;border:none}.payment-frame iframe.loaded{flex:none;display:block;width:100%;border:none;min-height:1050px}.state{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;gap:var(--sp-4);padding:var(--sp-8);text-align:center}.state-title{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0}.state-message{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-default);margin:0}`,w="mediquo:payment:retry",j="mediquo:payment:resize";class CheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(CheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(t){super(CheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(t){super(CheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutRetryEvent extends Event{static{this.eventName="payment-retry"}constructor(){super(CheckoutRetryEvent.eventName,{bubbles:!0,composed:!0})}}let S=class MqCheckout extends u{constructor(){super(...arguments),this._iframeLoaded=!1,this._iframeHeight=null,this._sessionEpoch=0,this._currentSessionId=null,this._paymentOrigin=null,this.apiClient=a(),this._loginTokenTask=new l(this,()=>this.apiClient,{args:()=>[this.apiKey,this.token],onComplete:t=>{this._sessionToken=t.access_token,this.apiClient.setAuthToken(t.access_token),this._sessionTask.run()},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"auth"}))}}),this._sessionTask=new r(this,{task:async()=>{if("function"!=typeof this.provideSession)throw new Error("mq-checkout: `provideSession` property is required");return this.provideSession(this.apiClient)},args:()=>[this._sessionEpoch],autoRun:!1,onComplete:t=>{this._currentSessionId=t.sessionId,this._iframeLoaded=!1,this._iframeHeight=null;try{this._paymentOrigin=new URL(t.paymentUrl).origin}catch{this._paymentOrigin=null,p.warn(`mq-checkout: invalid paymentUrl "${t.paymentUrl}"`)}},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"session"}))}}),this._paymentPoll=new x(this,{startDelayMs:5e3,intervalMs:3e3,timeoutMs:6e5,refetchFn:async()=>{if(!this._currentSessionId)throw new Error("mq-checkout: session not ready");const t=await this.apiClient.payments.getPaymentSession(this._currentSessionId);return t.status===h.Denied&&(this._paymentPoll.stop(),this.dispatchEvent(new CheckoutDeniedEvent({sessionId:this._currentSessionId}))),t},shouldComplete:t=>t.status===h.Paid,onComplete:t=>{this.dispatchEvent(new CheckoutSuccessEvent({sessionId:this._currentSessionId??"",reference:t.consultation_id}))},onTimeout:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"timeout"}))}}),this._onMessage=t=>{if(!this._paymentOrigin||t.origin===this._paymentOrigin)switch(t.data?.type){case w:return this.dispatchEvent(new CheckoutRetryEvent),this._sessionEpoch+=1,void this._sessionTask.run();case j:return void("number"==typeof t.data.height&&(this._iframeHeight=t.data.height))}}}static{this.styles=[y,b]}get _timedOut(){return this._paymentPoll.timedOut}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this._onMessage)}disconnectedCallback(){window.removeEventListener("message",this._onMessage),super.disconnectedCallback()}willUpdate(t){t.has("env")&&this.env&&k(this.env),t.has("locale")&&E(C(this.locale)?this.locale:"es_ES");const e=c(t,{env:this.env,apiKey:this.apiKey,token:this._sessionToken,locale:C(this.locale)?this.locale:"es_ES"},this.inheritedApiClient);e&&(this.apiClient=e)}_onIframeLoad(){this._iframeLoaded=!0}_renderState(t,e){return v`<div class="state"><p class="state-title">${t}</p>${e?v`<p class="state-message">${e}</p>`:null}</div>`}_renderLoading(){return v`<div class="payment-frame"><mq-skeleton width="100%" height="600px" border-radius="md" role="status" aria-live="polite" aria-label="${o("Cargando portal de pago")}"></mq-skeleton></div>`}_renderFrame(t){return v`<div class="payment-frame">${this._iframeLoaded?null:this._renderLoading()}<iframe class="${this._iframeLoaded?"loaded":""}" src="${t}" title="${o("Portal de pago")}" style="${null!==this._iframeHeight?`min-height: ${this._iframeHeight}px; height: ${this._iframeHeight}px;`:""}" @load="${this._onIframeLoad}"></iframe></div>`}render(){return this._timedOut?this._renderState(o("No hemos podido confirmar tu pago"),o("Ha ocurrido un problema al verificar el estado de tu pago. Por favor, contacta con soporte si el cargo se ha realizado.")):this._loginTokenTask.render({pending:()=>this._renderLoading(),error:()=>this._renderState(o("No hemos podido iniciar el pago"),o("Por favor, inténtalo de nuevo más tarde.")),complete:()=>this._sessionTask.render({initial:()=>this._renderLoading(),pending:()=>this._renderLoading(),error:()=>this._renderState(o("No hemos podido iniciar el pago"),o("Por favor, inténtalo de nuevo más tarde.")),complete:t=>this._renderFrame(t.paymentUrl)})})}};t([_({type:String,attribute:"env"})],S.prototype,"env",void 0),t([_({type:String,attribute:"api-key"})],S.prototype,"apiKey",void 0),t([_({type:String,attribute:"token"})],S.prototype,"token",void 0),t([_({type:String,attribute:"locale",reflect:!0})],S.prototype,"locale",void 0),t([_({attribute:!1})],S.prototype,"provideSession",void 0),t([f()],S.prototype,"_iframeLoaded",void 0),t([f()],S.prototype,"_iframeHeight",void 0),t([f()],S.prototype,"_sessionEpoch",void 0),t([i({context:d,subscribe:!0}),f()],S.prototype,"inheritedApiClient",void 0),t([s({context:d}),f()],S.prototype,"apiClient",void 0),S=t([n(),e("mq-checkout")],S);export{CheckoutDeniedEvent,CheckoutErrorEvent,CheckoutRetryEvent,CheckoutSuccessEvent,S as MqCheckout};
1
+ import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{e as s}from"./chunks/provide-BwI4DDGF.js";import{c as i}from"./chunks/consume-CovVqBjI.js";import{m as o}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/localized-decorator-BlOuLhym.js";import{h as r}from"./chunks/task-Bj8p7kJX.js";import{c as a,P as h,n as c}from"./chunks/api-chat-client-CJ1EGJe3.js";import{A as d}from"./chunks/api-client-context-V1UAGtKW.js";import{L as l}from"./chunks/login-token-task-Yib__6a9.js";import{l as p}from"./chunks/chunk-4FFT6DC2-CVWibomC.js";import{i as m,a as u,x as v}from"./chunks/lit-element-DiWJYFwC.js";import{n as _}from"./chunks/property-scuRaFcM.js";import{r as f}from"./chunks/state-LQivXIgA.js";import{setEnv as k}from"./env.js";import{tokens as y}from"./theme.js";import{initLocalization as g,setLocale as E,isValidLocale as C}from"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/external-CJj32K_p.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";var x=class{constructor(t,e){this.host=t,this.options=e,this._deadline=0,this._timedOut=!1,this.host.addController(this)}get timedOut(){return this._timedOut}hostConnected(){const t=this.options.intervalMs??1e3,e=void 0!==this.options.startDelayMs?this.options.startDelayMs:t;this._deadline=Date.now()+this.options.timeoutMs,this._timedOut=!1,this._startTimeoutId=setTimeout(()=>{this._startTimeoutId=void 0,this._poll(),this._intervalId=setInterval(()=>{this._poll()},t)},e)}hostDisconnected(){this._stop()}stop(){this._stop()}async _poll(){if(Date.now()>=this._deadline)return this._stop(),this._timedOut=!0,this.host.requestUpdate(),void this.options.onTimeout?.();try{const t=await this.options.refetchFn();this.options.shouldComplete(t)&&(this._stop(),this.options.onComplete?.(t))}catch{}}_stop(){void 0!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),void 0!==this._startTimeoutId&&(clearTimeout(this._startTimeoutId),this._startTimeoutId=void 0)}};try{g()}catch{}const b=m`:host{height:100%;min-height:0;display:flex;flex-direction:column;flex:1}.payment-frame{position:relative;width:100%;min-width:0;display:flex;flex-direction:column;flex:1;min-height:0}.payment-frame iframe:not(.loaded){position:absolute;width:1px;height:1px;opacity:0;pointer-events:none;border:none}.payment-frame iframe.loaded{flex:none;display:block;width:100%;border:none;min-height:1050px}.state{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;gap:var(--sp-4);padding:var(--sp-8);text-align:center}.state-title{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0}.state-message{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-default);margin:0}`,w="mediquo:payment:retry",j="mediquo:payment:resize";class CheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(CheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(t){super(CheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(t){super(CheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class CheckoutRetryEvent extends Event{static{this.eventName="payment-retry"}constructor(){super(CheckoutRetryEvent.eventName,{bubbles:!0,composed:!0})}}let S=class MqCheckout extends u{constructor(){super(...arguments),this._iframeLoaded=!1,this._iframeHeight=null,this._sessionEpoch=0,this._currentSessionId=null,this._paymentOrigin=null,this.apiClient=a(),this._loginTokenTask=new l(this,()=>this.apiClient,{args:()=>[this.apiKey,this.token],onComplete:t=>{this._sessionToken=t.access_token,this.apiClient.setAuthToken(t.access_token),this._sessionTask.run()},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"auth"}))}}),this._sessionTask=new r(this,{task:async()=>{if("function"!=typeof this.provideSession)throw new Error("mq-checkout: `provideSession` property is required");return this.provideSession(this.apiClient)},args:()=>[this._sessionEpoch],autoRun:!1,onComplete:t=>{this._currentSessionId=t.sessionId,this._iframeLoaded=!1,this._iframeHeight=null;try{this._paymentOrigin=new URL(t.paymentUrl).origin}catch{this._paymentOrigin=null,p.warn(`mq-checkout: invalid paymentUrl "${t.paymentUrl}"`)}},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"session"}))}}),this._paymentPoll=new x(this,{startDelayMs:5e3,intervalMs:3e3,timeoutMs:6e5,refetchFn:async()=>{if(!this._currentSessionId)throw new Error("mq-checkout: session not ready");const t=await this.apiClient.payments.getPaymentSession(this._currentSessionId);return t.status===h.Denied&&(this._paymentPoll.stop(),this.dispatchEvent(new CheckoutDeniedEvent({sessionId:this._currentSessionId}))),t},shouldComplete:t=>t.status===h.Paid,onComplete:t=>{this.dispatchEvent(new CheckoutSuccessEvent({sessionId:this._currentSessionId??"",reference:t.consultation_id}))},onTimeout:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"timeout"}))}}),this._onMessage=t=>{if(!this._paymentOrigin||t.origin===this._paymentOrigin)switch(t.data?.type){case w:return this.dispatchEvent(new CheckoutRetryEvent),this._sessionEpoch+=1,void this._sessionTask.run();case j:return void("number"==typeof t.data.height&&(this._iframeHeight=t.data.height))}}}static{this.styles=[y,b]}get _timedOut(){return this._paymentPoll.timedOut}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this._onMessage)}disconnectedCallback(){window.removeEventListener("message",this._onMessage),super.disconnectedCallback()}willUpdate(t){t.has("env")&&this.env&&k(this.env),t.has("locale")&&E(C(this.locale)?this.locale:"es_ES");const e=c(t,{env:this.env,apiKey:this.apiKey,token:this._sessionToken,locale:C(this.locale)?this.locale:"es_ES"},this.inheritedApiClient);e&&(this.apiClient=e)}_onIframeLoad(){this._iframeLoaded=!0}_renderState(t,e){return v`<div class="state"><p class="state-title">${t}</p>${e?v`<p class="state-message">${e}</p>`:null}</div>`}_renderLoading(){return v`<div class="payment-frame"><mq-skeleton width="100%" height="600px" border-radius="md" role="status" aria-live="polite" aria-label="${o("Cargando portal de pago")}"></mq-skeleton></div>`}_renderFrame(t){return v`<div class="payment-frame">${this._iframeLoaded?null:this._renderLoading()}<iframe class="${this._iframeLoaded?"loaded":""}" src="${t}" title="${o("Portal de pago")}" style="${null!==this._iframeHeight?`min-height: ${this._iframeHeight}px; height: ${this._iframeHeight}px;`:""}" @load="${this._onIframeLoad}"></iframe></div>`}render(){return this._timedOut?this._renderState(o("No hemos podido confirmar tu pago"),o("Ha ocurrido un problema al verificar el estado de tu pago. Por favor, contacta con soporte si el cargo se ha realizado.")):this._loginTokenTask.render({pending:()=>this._renderLoading(),error:()=>this._renderState(o("No hemos podido iniciar el pago"),o("Por favor, inténtalo de nuevo más tarde.")),complete:()=>this._sessionTask.render({initial:()=>this._renderLoading(),pending:()=>this._renderLoading(),error:()=>this._renderState(o("No hemos podido iniciar el pago"),o("Por favor, inténtalo de nuevo más tarde.")),complete:t=>this._renderFrame(t.paymentUrl)})})}};t([_({type:String,attribute:"env"})],S.prototype,"env",void 0),t([_({type:String,attribute:"api-key"})],S.prototype,"apiKey",void 0),t([_({type:String,attribute:"token"})],S.prototype,"token",void 0),t([_({type:String,attribute:"locale",reflect:!0})],S.prototype,"locale",void 0),t([_({attribute:!1})],S.prototype,"provideSession",void 0),t([f()],S.prototype,"_iframeLoaded",void 0),t([f()],S.prototype,"_iframeHeight",void 0),t([f()],S.prototype,"_sessionEpoch",void 0),t([i({context:d,subscribe:!0}),f()],S.prototype,"inheritedApiClient",void 0),t([s({context:d}),f()],S.prototype,"apiClient",void 0),S=t([n(),e("mq-checkout")],S);export{CheckoutDeniedEvent,CheckoutErrorEvent,CheckoutRetryEvent,CheckoutSuccessEvent,S as MqCheckout};
@@ -1,26 +1,27 @@
1
1
  import * as lit_html from 'lit-html';
2
2
  import * as lit from 'lit';
3
3
  import { LitElement, nothing, PropertyValues } from 'lit';
4
- import { M as MediquoApiChatClient, b as GetOrganizationSetupResponse } from './chunks/index.d-Bl682CAX.js';
4
+ import { M as MediquoApiChatClient, b as GetOrganizationSetupResponse } from './chunks/index.d-XSe7Hy-Q.js';
5
5
  import { L as LoginTokenResponse } from './chunks/schemas.d-b6_AekBb.js';
6
6
  import { Env } from './env.js';
7
- import './chunks/mq-layout-D1j50tKd.js';
7
+ import './chunks/mq-layout-TG2K4zRv.js';
8
8
  import './ui/mq-skeleton.js';
9
9
  import './ui/mq-avatar.js';
10
10
  import './ui/mq-button.js';
11
11
  import './ui/mq-card.js';
12
- import './chunks/appointment-card-skeleton-C3mV8Ky1.js';
12
+ import './chunks/appointment-card-skeleton-C2Sim4nR.js';
13
13
  export { MqAppointmentBookEvent, MqAppointmentJoinVideocallEvent, MqAppointmentRescheduleEvent, MqAppointmentViewDocumentationEvent, MqViewAppointmentsEvent, MqViewDocumentsEvent } from './events.js';
14
14
  import 'axios';
15
15
  import 'zod';
16
+ import './chunks/document.model.d-DIzMiOmd.js';
16
17
  import './chunks/appointment-details-CVEDe_k0.js';
17
18
  import './chunks/appointment.model.d-BWwBLaEL.js';
18
19
  import './chunks/professional-overview-mO3tuMuH.js';
19
20
  import './ui/mq-text-button.js';
20
- import './chunks/mq-chat-room-t3j3Tq4o.js';
21
+ import './chunks/mq-chat-room-jeDvIF1Z.js';
21
22
  import '@tanstack/query-core';
22
23
  import './ui/mq-floating-bubble.js';
23
- import './chunks/appointment-action-unavailable-dialog-BYse3uIa.js';
24
+ import './chunks/appointment-action-unavailable-dialog-CTiL4nMo.js';
24
25
  import './chunks/price.d-CwLosdAN.js';
25
26
  import './ui/mq-dialog.js';
26
27
  import './ui/mq-unread-badge.js';
@@ -37,7 +38,7 @@ declare class SupportChatBanner extends LitElement {
37
38
  private get _hasUnread();
38
39
  private _toggleSupportChat;
39
40
  private _ctaIcon;
40
- render(): lit_html.TemplateResult<1> | typeof nothing | null;
41
+ render(): typeof nothing | lit_html.TemplateResult<1> | null;
41
42
  }
42
43
  declare global {
43
44
  interface HTMLElementTagNameMap {