@mediquo/elements 0.8.0 → 0.8.1
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.
- package/README.md +61 -5
- package/dist/chunks/action-unavailable-message-BIgsXk9u.js +1 -0
- package/dist/chunks/api-chat-client-pGZWREjK.js +1 -0
- package/dist/chunks/api-client-context-V1UAGtKW.js +1 -0
- package/dist/chunks/{apple-pay-outcomes-BpcbdGfO.js → apple-pay-outcomes-BONpT54d.js} +1 -1
- package/dist/chunks/appointment-action-unavailable-dialog-BYse3uIa.d.ts +54 -0
- package/dist/chunks/{appointment-card-skeleton-B7dKtGv0.d.ts → appointment-card-skeleton-C3mV8Ky1.d.ts} +5 -3
- package/dist/chunks/appointment-card-skeleton-CAQmlCTm.js +1 -0
- package/dist/chunks/appointment-details-DXLBQnPN.js +1 -0
- package/dist/chunks/chunk-6CCJWPGL-TiaqZaPV.js +1 -0
- package/dist/chunks/{chunk-BUV4MGML-Bn3JWCAv.js → chunk-BUV4MGML-CkhBbfUu.js} +1 -1
- package/dist/chunks/chunk-HN62IQ7S-xbkIy7k_.js +1 -0
- package/dist/chunks/chunk-Y4EKUX25-QqMl3eiq.js +1 -0
- package/dist/chunks/consume-CovVqBjI.js +1 -0
- package/dist/chunks/{chunk-6CCJWPGL-DlOpbEYH.js → context-consumer-ESdICVAb.js} +1 -1
- package/dist/chunks/documentation-view-GZI-DC3e.js +1 -0
- package/dist/chunks/{get-appointment-query-lJe75hGS.js → get-appointment-query-C-gTTuiQ.js} +1 -1
- package/dist/chunks/{get-organization-setup-query-DxHNY0w8.js → get-organization-setup-query-Dr1cXnHl.js} +1 -1
- package/dist/chunks/{get-patient-documents-query-D1SfC_k_.js → get-patient-documents-query-NC9xCa_N.js} +1 -1
- package/dist/chunks/{get-patient-profile-query-DiU2f_QH.js → get-patient-profile-query-4AO6xvVn.js} +1 -1
- package/dist/chunks/{get-schedule-services-query-Ckvz9Fqh.js → get-schedule-services-query-Fzvb9ug9.js} +1 -1
- package/dist/chunks/index-6gxzoTLM.js +1 -0
- package/dist/chunks/{index-Ca-l41nB.js → index-CXb3gOFA.js} +1 -1
- package/dist/chunks/index-CoZKmhwT.js +1 -0
- package/dist/chunks/{index-63zQSBy4.js → index-CyteNROM.js} +1 -1
- package/dist/chunks/{index-czcKClL3.d.ts → index-KhJ8hC0H.d.ts} +8 -0
- package/dist/chunks/index-PGYfkbm6.js +1 -0
- package/dist/chunks/index.d-Bl682CAX.d.ts +2977 -0
- package/dist/chunks/login-token-task-Yib__6a9.js +1 -0
- package/dist/chunks/{mq-chat-room-CRPruRJD.d.ts → mq-chat-room-t3j3Tq4o.d.ts} +12 -227
- package/dist/chunks/mq-layout-D1j50tKd.d.ts +51 -0
- package/dist/chunks/mq-layout-L3TlCxI0.js +1 -0
- package/dist/chunks/provide-BwI4DDGF.js +1 -0
- package/dist/chunks/query-controller-BlO1Ax65.js +1 -0
- package/dist/chunks/refund-cancel-policy-CcsJ-pMx.js +1 -0
- package/dist/chunks/{schemas.d-D7bCe24u.d.ts → schemas.d-b6_AekBb.d.ts} +12 -1
- package/dist/chunks/telemetry-client-CoWay8es.js +1 -0
- package/dist/env.js +1 -1
- package/dist/i18n.js +1 -1
- package/dist/mq-api-client-provider.d.ts +39 -0
- package/dist/mq-api-client-provider.js +1 -0
- package/dist/mq-apple-pay-checkout.d.ts +12 -0
- package/dist/mq-apple-pay-checkout.js +1 -1
- package/dist/mq-appointment-checkout.d.ts +3 -1
- package/dist/mq-appointment-checkout.js +1 -1
- package/dist/mq-appointment-documentation.d.ts +13 -5
- package/dist/mq-appointment-documentation.js +1 -1
- package/dist/mq-chat-room.d.ts +5 -2
- package/dist/mq-chat-room.js +1 -1
- package/dist/mq-checkout.d.ts +21 -1
- package/dist/mq-checkout.js +1 -1
- package/dist/mq-dashboard.d.ts +22 -122
- package/dist/mq-dashboard.js +1 -1
- package/dist/mq-documents.d.ts +14 -4
- package/dist/mq-documents.js +1 -1
- package/dist/mq-google-pay-checkout.d.ts +12 -0
- package/dist/mq-google-pay-checkout.js +1 -1
- package/dist/mq-immediate-videocall-checkout.d.ts +3 -0
- package/dist/mq-immediate-videocall-checkout.js +1 -1
- package/dist/mq-my-appointments.d.ts +11 -7
- package/dist/mq-my-appointments.js +1 -1
- package/dist/mq-next-appointments.d.ts +15 -5
- package/dist/mq-next-appointments.js +1 -1
- package/dist/mq-payment-poller.d.ts +11 -0
- package/dist/mq-payment-poller.js +1 -1
- package/dist/mq-professional-presence-sync.d.ts +1 -0
- package/dist/mq-professional-presence-sync.js +1 -1
- package/dist/mq-query-client-provider.d.ts +4 -1
- package/dist/mq-query-client-provider.js +1 -1
- package/dist/mq-recent-documents.d.ts +10 -25
- package/dist/mq-recent-documents.js +1 -1
- package/dist/mq-schedule-success.d.ts +12 -2
- package/dist/mq-schedule-success.js +2 -2
- package/dist/mq-schedule.d.ts +25 -221
- package/dist/mq-schedule.js +1 -1
- package/dist/mq-session-provider.d.ts +1 -1
- package/dist/mq-session-provider.js +1 -1
- package/dist/mq-socket-provider.js +1 -1
- package/dist/mq-support-chat.d.ts +13 -3
- package/dist/mq-support-chat.js +1 -1
- package/dist/mq-terms-and-conditions.d.ts +5 -1
- package/dist/mq-terms-and-conditions.js +1 -1
- package/dist/mq-unread-count-sync.d.ts +1 -0
- package/dist/mq-unread-count-sync.js +1 -1
- package/dist/mq-videocall.d.ts +13 -4
- package/dist/mq-videocall.js +1 -1
- package/dist/react/mq-api-client-provider.d.ts +26 -0
- package/dist/react/mq-api-client-provider.js +2 -0
- package/dist/react/mq-apple-pay-checkout.d.ts +4 -1
- package/dist/react/mq-apple-pay-checkout.js +1 -1
- package/dist/react/mq-appointment-checkout.d.ts +3 -1
- package/dist/react/mq-appointment-checkout.js +1 -1
- package/dist/react/mq-appointment-documentation.d.ts +6 -5
- package/dist/react/mq-appointment-documentation.js +1 -1
- package/dist/react/mq-chat-room.d.ts +5 -2
- package/dist/react/mq-chat-room.js +1 -1
- package/dist/react/mq-checkout.d.ts +4 -1
- package/dist/react/mq-checkout.js +1 -1
- package/dist/react/mq-dashboard.d.ts +11 -11
- package/dist/react/mq-dashboard.js +1 -1
- package/dist/react/mq-documents-page.d.ts +5 -4
- package/dist/react/mq-documents-page.js +1 -1
- package/dist/react/mq-documents.d.ts +5 -4
- package/dist/react/mq-documents.js +1 -1
- package/dist/react/mq-google-pay-checkout.d.ts +4 -1
- package/dist/react/mq-google-pay-checkout.js +1 -1
- package/dist/react/mq-immediate-videocall-checkout.d.ts +3 -0
- package/dist/react/mq-immediate-videocall-checkout.js +1 -1
- package/dist/react/mq-my-appointments.d.ts +10 -8
- package/dist/react/mq-my-appointments.js +1 -1
- package/dist/react/mq-next-appointments.d.ts +10 -7
- package/dist/react/mq-next-appointments.js +1 -1
- package/dist/react/mq-payment-poller.d.ts +4 -0
- package/dist/react/mq-payment-poller.js +1 -1
- package/dist/react/mq-professional-presence-sync.js +1 -1
- package/dist/react/mq-query-client-provider.d.ts +1 -0
- package/dist/react/mq-query-client-provider.js +1 -1
- package/dist/react/mq-recent-documents.d.ts +4 -3
- package/dist/react/mq-recent-documents.js +1 -1
- package/dist/react/mq-schedule-success.d.ts +5 -2
- package/dist/react/mq-schedule-success.js +1 -1
- package/dist/react/mq-schedule.d.ts +4 -2
- package/dist/react/mq-schedule.js +1 -1
- package/dist/react/mq-session-provider.d.ts +1 -1
- package/dist/react/mq-session-provider.js +1 -1
- package/dist/react/mq-socket-provider.js +1 -1
- package/dist/react/mq-support-chat.d.ts +5 -2
- package/dist/react/mq-support-chat.js +1 -1
- package/dist/react/mq-terms-and-conditions.d.ts +5 -1
- package/dist/react/mq-terms-and-conditions.js +1 -1
- package/dist/react/mq-toast-container.js +1 -1
- package/dist/react/mq-unread-count-sync.js +1 -1
- package/dist/react/mq-videocall.d.ts +6 -5
- package/dist/react/mq-videocall.js +1 -1
- package/dist/theme.js +1 -1
- package/dist/ui/mq-calendar.js +1 -1
- package/dist/ui/mq-clamped-text.js +1 -1
- package/package.json +5 -1
- package/dist/chunks/action-unavailable-message-CRLimFj5.js +0 -1
- package/dist/chunks/api-chat-client-BiiYnU-b.js +0 -1
- package/dist/chunks/appointment-action-unavailable-dialog-Da2IATYj.d.ts +0 -321
- package/dist/chunks/appointment-card-skeleton-ZfTAElLq.js +0 -1
- package/dist/chunks/appointment-details-Bm3Uuw2g.js +0 -1
- package/dist/chunks/chunk-Y4EKUX25-CqL3lLdx.js +0 -1
- package/dist/chunks/consume-BhoQNO_8.js +0 -1
- package/dist/chunks/context-provider--AKuwfs9.js +0 -1
- package/dist/chunks/document.model.d-DIzMiOmd.d.ts +0 -6
- package/dist/chunks/documentation-view-CTnpWIxq.js +0 -1
- package/dist/chunks/i18n-formats-EgnwLxKt.js +0 -1
- package/dist/chunks/index-CSJzkkRA.d.ts +0 -28
- package/dist/chunks/index-CZ9HtP96.js +0 -1
- package/dist/chunks/index-DMiowcMQ.js +0 -1
- package/dist/chunks/index-DZjrAnPq.js +0 -1
- package/dist/chunks/login-token-task-BI-L2zSV.js +0 -1
- package/dist/chunks/mq-layout-BndHxkbb.js +0 -1
- package/dist/chunks/mq-layout-D8Mak16a.d.ts +0 -21
- package/dist/chunks/provide-D2fnEhT2.js +0 -1
- package/dist/chunks/query-controller-D7jBX4X7.js +0 -1
- package/dist/chunks/refund-cancel-policy-DV6bzqcu.js +0 -1
- package/dist/chunks/schemas.d-Bss7CeCZ.d.ts +0 -53
- package/dist/chunks/telemetry-client-Bkbn48Dd.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getLocale as t,isValidLocale as e,setLocale as i,initLocalization as n}from"./i18n.js";import{_ as o,c as a}from"./chunks/custom-element-D2ziPxYE.js";import{c as s}from"./chunks/consume-BhoQNO_8.js";import{m as r,s as p}from"./chunks/runtime-Bg1WXVCx.js";import{l as c}from"./chunks/localized-decorator-BlOuLhym.js";import{Q as l}from"./chunks/query-controller-D7jBX4X7.js";import{l as m}from"./chunks/chunk-S5RWG6G2-DPesx3Od.js";import{A as h,c as d,a as u,i as g}from"./chunks/api-chat-client-BiiYnU-b.js";import{a as v,g as f}from"./chunks/action-unavailable-message-CRLimFj5.js";import{g as y}from"./chunks/get-organization-setup-query-DxHNY0w8.js";import{g as b,a as k}from"./chunks/i18n-formats-EgnwLxKt.js";import{g as x}from"./chunks/get-patient-profile-query-DiU2f_QH.js";import{c as $}from"./chunks/refund-cancel-policy-DV6bzqcu.js";import{i as j,a as w,E as C,x as O}from"./chunks/lit-element-DiWJYFwC.js";import{n as q}from"./chunks/property-scuRaFcM.js";import{setEnv as M}from"./env.js";import{MqAppointmentJoinVideocallEvent as z,MqAppointmentRescheduleEvent as S,MqViewAppointmentsEvent as U}from"./events.js";import"./chunks/index-DZjrAnPq.js";import"./ui/mq-skeleton.js";import{t as I,g as E,i as A,c as D,e as T}from"./chunks/telemetry-client-Bkbn48Dd.js";import{r as _}from"./chunks/state-LQivXIgA.js";import{calendarIcon as N}from"./ui/icons/calendar-icon.js";import{dotsHorizontalIcon as R}from"./ui/icons/dots-horizontal-icon.js";import{messageBubbleIcon as H}from"./ui/icons/message-bubble-icon.js";import{phoneIcon as Q}from"./ui/icons/phone-icon.js";import{videoIcon as P}from"./ui/icons/video-icon.js";import"./mq-chat-room.js";import"./chunks/professional-overview-C4H_znIJ.js";import"./ui/mq-button.js";import"./ui/mq-floating-bubble.js";import{toast as L}from"./ui/mq-toast.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/external-CJj32K_p.js";import"./chunks/chunk-6CCJWPGL-DlOpbEYH.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/mutation-controller-CR2qcqhH.js";import"./chunks/price-DU3YLTpk.js";import"./ui/mq-dialog.js";import"./ui/icons/x-icon.js";import"./ui/icons/types.js";import"./ui/icons/file-icon.js";import"./ui/icons/arrow-right-icon.js";import"./chunks/if-defined-BYeVdwgd.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/provide-D2fnEhT2.js";import"./chunks/context-provider--AKuwfs9.js";import"./theme.js";import"./ui/mq-avatar.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/chunk-BUV4MGML-Bn3JWCAv.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./chunks/chunk-Y4EKUX25-CqL3lLdx.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import"./ui/icons/chevron-down-icon.js";import"./ui/mq-text-button.js";const B=j`:host{display:flex;flex-direction:column;justify-content:space-between;gap:var(--sp-6);flex:1;width:100%;min-width:0;box-sizing:border-box;color:var(--color-text-icons--primary,#0a0a22)}professional-overview{--avatar-size-lg:66px;display:block}.details{display:flex;flex-direction:column;align-items:flex-start;gap:var(--sp-3)}.detail-row{display:inline-flex;align-items:center;gap:var(--sp-2);font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;font-weight:var(--font-weight-normal)}.detail-row svg{flex-shrink:0}.detail-row span::first-letter{text-transform:uppercase}.footer{display:flex;flex-direction:column;gap:var(--sp-4)}.reminder{font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;font-weight:var(--font-weight-normal);color:var(--color-text-icons--secondary,#6d658b);margin:0}.actions{--button-height-md:2.75rem;display:flex;align-items:stretch;gap:10px}.actions>mq-button{flex:1;min-width:0}.overflow{position:relative;flex:0 0 auto}@media (max-width:767px){.actions{flex-wrap:wrap}.actions>mq-button.join{order:1;flex:1 0 100%}}.menu{position:absolute;right:0;bottom:calc(100% + var(--sp-2));z-index:2;display:flex;flex-direction:column;min-width:176px;padding:var(--sp-1);background-color:var(--color-card,#fff);border:1px solid var(--color-border-subtle,#edecf1);border-radius:var(--border-radius-lg);box-shadow:var(--shadow-lg)}.menu-item{display:block;width:100%;background:0 0;border:none;border-radius:var(--border-radius-sm);padding:var(--sp-2) var(--sp-3);cursor:pointer;text-align:left;font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;color:var(--color-text-icons--primary,#0a0a22)}.menu-item:hover{background-color:var(--color-muted)}.menu-item.negative{color:var(--color-negative)}`;let V=class NextAppointmentCard extends w{constructor(){super(...arguments),this.specialtyName="",this.token="",this.patientHash="",this.hasChatSupport=!1,this.isExpired=!1,this.isModifyUnavailable=!1,this.isCancelUnavailable=!1,this.modifyUnavailableMessage="",this.cancelUnavailableMessage="",this.isChatOpen=!1,this.isMenuOpen=!1,this.isCancelDialogOpen=!1,this.openDialog=null,this.closeMenuOnOutsideClick=t=>{t.composedPath().includes(this)||(this.isMenuOpen=!1)},this.closeMenuOnEscape=t=>{"Escape"===t.key&&(this.isMenuOpen=!1)},this.handleJoinVideocall=()=>{I.track(E(this.patientHash,this.appointmentId)),this.dispatchEvent(new z({appointmentId:this.appointmentId}))},this.handleToggleChat=()=>{this.isChatOpen=!this.isChatOpen,this.isChatOpen&&I.track(A(this.patientHash,this.appointmentId))},this.handleModify=()=>{this.isMenuOpen=!1,this.isModifyUnavailable?this.openDialog="modify":(I.track(D(this.patientHash,this.appointmentId)),this.dispatchEvent(new S({appointmentId:this.appointmentId})))},this.handleCancel=()=>{this.isMenuOpen=!1,this.isCancelUnavailable?this.openDialog="cancel":(I.track(T(this.patientHash,this.appointmentId)),this.isCancelDialogOpen=!0)}}static{this.styles=B}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.closeMenuOnOutsideClick),document.addEventListener("keydown",this.closeMenuOnEscape)}disconnectedCallback(){document.removeEventListener("click",this.closeMenuOnOutsideClick),document.removeEventListener("keydown",this.closeMenuOnEscape),super.disconnectedCallback()}get appointmentId(){return this.appointmentResource.appointment.id??""}get channel(){return this.appointmentResource.appointment.channel}channelIcon(){switch(this.channel){case h.videocall:return P({size:20});case h.phonecall:return Q({size:20});default:return H({size:20})}}channelLabel(){switch(this.channel){case h.videocall:return r("Videoconsulta");case h.phonecall:return r("Consulta telefónica");default:return r("Chat")}}formatWhen(){const e=t().replace("_","-"),i=this.timezone?{timeZone:this.timezone}:{},n=new Date(this.appointmentResource.appointment.starts_at);if(Number.isNaN(n.getTime()))return"";const o=new Intl.DateTimeFormat(e,{weekday:"long",day:"numeric",month:"long",year:"numeric",...i}).format(n),a=new Intl.DateTimeFormat(e,{timeStyle:"short",...i}).format(n);return r(p`${o}, ${a} h`)}renderActions(){const t=this.channel===h.videocall;return O`<div class="actions">${this.hasChatSupport?O`<mq-button variant="outline" @click="${this.handleToggleChat}">${r("Ir a chat")}</mq-button>`:C} ${t?O`<mq-button class="join" variant="primary" @click="${this.handleJoinVideocall}">${r("Unirse a la videoconsulta")}</mq-button>`:C}<div class="overflow"><mq-button variant="outline" size="icon-lg" aria-label="${r("Más opciones")}" aria-haspopup="menu" aria-expanded="${this.isMenuOpen}" @click="${()=>{this.isMenuOpen=!this.isMenuOpen}}">${R({size:16})}</mq-button>${this.isMenuOpen?O`<div class="menu" role="menu"><button class="menu-item" type="button" role="menuitem" @click="${this.handleModify}">${r("Modificar cita")}</button> <button class="menu-item negative" type="button" role="menuitem" @click="${this.handleCancel}">${r("Anular cita")}</button></div>`:C}</div></div>`}render(){const{professional:t}=this.appointmentResource,e=this.formatWhen();return O`<professional-overview .name="${t.name}" .specialtyName="${this.specialtyName}" .collegiateNumber="${t.collegiate_number??void 0}" .description="${t.description??""}" .languages="${t.languages??[]}" .avatar="${t.avatar??""}"></professional-overview><div class="details">${e?O`<div class="detail-row">${N({size:20})} <span>${e}</span></div>`:C}<div class="detail-row">${this.channelIcon()} <span>${this.channelLabel()}</span></div></div><div class="footer"><p class="reminder">${r("Recibirás un recordatorio 15 minutos antes de la consulta")}</p>${this.renderActions()}</div><mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" hideCloseButton @mq-close="${()=>{this.isChatOpen=!1}}">${this.isChatOpen?O`<mq-chat-room slot="content" .consultationId="${this.appointmentResource.appointment.id}" consultation-type="appointment" token="${this.token}" .roomId="${this.appointmentResource.room.id}" .professionalHash="${t.hash}" ?readonly="${this.isExpired}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}"></mq-chat-room>`:C}</mq-floating-bubble><appointment-action-unavailable-dialog .open="${"modify"===this.openDialog}" .heading="${r("Modificar cita")}" .message="${this.modifyUnavailableMessage}" @close="${()=>{this.openDialog=null}}"></appointment-action-unavailable-dialog><appointment-action-unavailable-dialog .open="${"cancel"===this.openDialog}" .heading="${r("Anular cita")}" .message="${this.cancelUnavailableMessage}" @close="${()=>{this.openDialog=null}}"></appointment-action-unavailable-dialog><cancel-appointment-confirmation-dialog .appointmentId="${this.appointmentResource.appointment.id}" .price="${this.appointmentResource.price??void 0}" .open="${this.isCancelDialogOpen}" @cancel="${()=>{this.isCancelDialogOpen=!1}}" @success="${()=>{this.isCancelDialogOpen=!1,L.success(r("Consulta anulada correctamente")),this.dispatchEvent(new CustomEvent("appointment-cancel-confirmed",{bubbles:!0,composed:!0,detail:{id:this.appointmentId}}))}}"></cancel-appointment-confirmation-dialog>`}};o([q({type:Object})],V.prototype,"appointmentResource",void 0),o([q({type:String})],V.prototype,"specialtyName",void 0),o([q({type:String})],V.prototype,"token",void 0),o([q({type:String})],V.prototype,"patientHash",void 0),o([q({type:String})],V.prototype,"timezone",void 0),o([q({type:Boolean})],V.prototype,"hasChatSupport",void 0),o([q({type:Boolean})],V.prototype,"isExpired",void 0),o([q({type:Boolean})],V.prototype,"isModifyUnavailable",void 0),o([q({type:Boolean})],V.prototype,"isCancelUnavailable",void 0),o([q({type:String})],V.prototype,"modifyUnavailableMessage",void 0),o([q({type:String})],V.prototype,"cancelUnavailableMessage",void 0),o([_()],V.prototype,"isChatOpen",void 0),o([_()],V.prototype,"isMenuOpen",void 0),o([_()],V.prototype,"isCancelDialogOpen",void 0),o([_()],V.prototype,"openDialog",void 0),V=o([c(),a("next-appointment-card")],V);const G=[d.pending,d.accepted],K=j`:host{display:flex;flex-direction:column;gap:var(--sp-4);width:100%;min-width:0;box-sizing:border-box}:host([empty]){align-self:start}:host([empty]) .card{flex:0 0 auto}.card{display:flex;flex-direction:column;flex:1;min-width:0;box-sizing:border-box;background-color:var(--color-card,#fff);border:1px solid var(--color-border-subtle,#edecf1);border-radius:var(--mq-next-appointments-radius,12px);padding:var(--mq-next-appointments-padding,var(--sp-6))}`;let F=class MqNextAppointments extends w{constructor(){super(...arguments),this.getPatientProfileQuery=new l(this,()=>x(u,{enabled:!this.loginToken})),this.getAppointmentsQuery=new l(this,()=>v(u,{status:G,order:{field:"starts_at",direction:"asc"},page:1,per_page:1})),this.getOrganizationSetupQuery=new l(this,()=>y(u)),this.getOrganizationSpecialtiesQuery=new l(this,()=>b(u)),this.handleViewAll=()=>{this.dispatchEvent(new U({tab:"next"}))}}static{this.styles=K}willUpdate(t){t.has("env")&&this.env&&M(this.env),t.has("apiKey")&&this.apiKey&&u.setApiKey(this.apiKey),t.has("token")&&this.token&&u.setAuthToken(this.token),t.has("locale")&&this.locale&&e(this.locale)&&(i(this.locale),u.setLanguage(this.locale))}get patientHash(){return this.loginToken?.patient.hash??this.getPatientProfileQuery.result?.data?.hash??""}get accessToken(){return this.token||this.loginToken?.access_token||""}get patientTimezone(){return this.timezone??this.loginToken?.patient.timezone}get isEmpty(){const t=this.getAppointmentsQuery.result;return!0===t?.isSuccess&&!t.data?.data?.[0]}updated(){this.toggleAttribute("empty",this.isEmpty)}renderAppointment(){return this.getAppointmentsQuery.render({complete:e=>{const i=e.data?.[0];if(!i)return O`<home-widget-empty-state icon="calendar" heading="${r("No tienes próximas citas")}" description="${r("Cuando agendes una cita, aparecerá aquí para que puedas consultarla, modificarla o cancelarla.")}"></home-widget-empty-state>`;const n=this.getOrganizationSetupQuery.result?.data,o=n?.appointments?.seconds_before_start_to_refund_on_cancel,a=$({startsAtIso:i.appointment.starts_at,refundPolicySeconds:o}),s=g(i.appointment.expires_at),p=0===i.slots.length,c=this.getOrganizationSpecialtiesQuery.result?.data?.find(t=>t.id===i.speciality.id);return O`<next-appointment-card .appointmentResource="${i}" .specialtyName="${k(c?.code??"",t(),c?.name??i.speciality.name)}" .token="${this.accessToken}" .patientHash="${this.patientHash}" .timezone="${this.patientTimezone}" .hasChatSupport="${!0===n?.appointments?.has_chat_in_appointment}" .isExpired="${s}" .isModifyUnavailable="${s||p||!a}" .isCancelUnavailable="${s||!a}" .modifyUnavailableMessage="${f({action:"modify",refundPolicySeconds:o})}" .cancelUnavailableMessage="${f({action:"cancel",refundPolicySeconds:o})}"></next-appointment-card>`},pending:()=>O`<mq-skeleton height="257px"></mq-skeleton>`,error:()=>O`<home-widget-empty-state icon="calendar" heading="${r("No hemos podido cargar tu próxima cita")}" description="${r("Vuelve a intentarlo en unos minutos.")}"></home-widget-empty-state>`})}render(){return O`<section-header heading="${r("Próxima cita")}" action-label="${r("Ver todas")}" @section-action="${this.handleViewAll}"></section-header><div class="card">${this.renderAppointment()}</div>`}};o([q({type:String,attribute:"api-key"})],F.prototype,"apiKey",void 0),o([q({type:String,attribute:"token"})],F.prototype,"token",void 0),o([q({type:String,attribute:"locale"})],F.prototype,"locale",void 0),o([q({type:String,attribute:"env"})],F.prototype,"env",void 0),o([q({type:String,attribute:"timezone"})],F.prototype,"timezone",void 0),o([s({context:m,subscribe:!0})],F.prototype,"loginToken",void 0),F=o([c(),a("mq-next-appointments")],F),n();export{z as MqAppointmentJoinVideocallEvent,S as MqAppointmentRescheduleEvent,F as MqNextAppointments,U as MqViewAppointmentsEvent};
|
|
1
|
+
import{getLocale as t,isValidLocale as e,setLocale as i,initLocalization as n}from"./i18n.js";import{_ as o,c as a}from"./chunks/custom-element-D2ziPxYE.js";import{e as s}from"./chunks/provide-BwI4DDGF.js";import{c as r}from"./chunks/consume-CovVqBjI.js";import{m as p,s as c}from"./chunks/runtime-Bg1WXVCx.js";import{l}from"./chunks/localized-decorator-BlOuLhym.js";import{Q as m}from"./chunks/query-controller-BlO1Ax65.js";import{A as h}from"./chunks/api-client-context-V1UAGtKW.js";import{l as d}from"./chunks/chunk-S5RWG6G2-DPesx3Od.js";import{A as u,a as g,c as v,n as f,i as y}from"./chunks/api-chat-client-pGZWREjK.js";import{a as b,g as k}from"./chunks/action-unavailable-message-BIgsXk9u.js";import{g as x}from"./chunks/get-organization-setup-query-Dr1cXnHl.js";import{t as j,j as $,l as C,f as w,h as O,g as M,a as q}from"./chunks/telemetry-client-CoWay8es.js";import{g as z}from"./chunks/get-patient-profile-query-4AO6xvVn.js";import{c as S}from"./chunks/refund-cancel-policy-CcsJ-pMx.js";import{i as I,a as E,E as U,x as A}from"./chunks/lit-element-DiWJYFwC.js";import{n as D}from"./chunks/property-scuRaFcM.js";import{r as T}from"./chunks/state-LQivXIgA.js";import{setEnv as _}from"./env.js";import{MqAppointmentJoinVideocallEvent as N,MqAppointmentRescheduleEvent as R,MqViewAppointmentsEvent as Q}from"./events.js";import"./chunks/index-CoZKmhwT.js";import"./ui/mq-skeleton.js";import{calendarIcon as H}from"./ui/icons/calendar-icon.js";import{dotsHorizontalIcon as P}from"./ui/icons/dots-horizontal-icon.js";import{messageBubbleIcon as V}from"./ui/icons/message-bubble-icon.js";import{phoneIcon as B}from"./ui/icons/phone-icon.js";import{videoIcon as L}from"./ui/icons/video-icon.js";import"./mq-chat-room.js";import"./chunks/professional-overview-C4H_znIJ.js";import"./ui/mq-button.js";import"./ui/mq-floating-bubble.js";import{toast as F}from"./ui/mq-toast.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-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import"./chunks/mutation-controller-CR2qcqhH.js";import"./chunks/price-DU3YLTpk.js";import"./ui/mq-dialog.js";import"./ui/icons/x-icon.js";import"./ui/icons/types.js";import"./ui/icons/file-icon.js";import"./ui/icons/arrow-right-icon.js";import"./chunks/if-defined-BYeVdwgd.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";import"./theme.js";import"./ui/mq-avatar.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.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"./ui/icons/chevron-down-icon.js";import"./ui/mq-text-button.js";const G=I`:host{display:flex;flex-direction:column;justify-content:space-between;gap:var(--sp-6);flex:1;width:100%;min-width:0;box-sizing:border-box;color:var(--color-text-icons--primary,#0a0a22)}professional-overview{--avatar-size-lg:66px;display:block}.details{display:flex;flex-direction:column;align-items:flex-start;gap:var(--sp-3)}.detail-row{display:inline-flex;align-items:center;gap:var(--sp-2);font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;font-weight:var(--font-weight-normal)}.detail-row svg{flex-shrink:0}.detail-row span::first-letter{text-transform:uppercase}.footer{display:flex;flex-direction:column;gap:var(--sp-4)}.reminder{font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;font-weight:var(--font-weight-normal);color:var(--color-text-icons--secondary,#6d658b);margin:0}.actions{--button-height-md:2.75rem;display:flex;align-items:stretch;gap:10px}.actions>mq-button{flex:1;min-width:0}.overflow{position:relative;flex:0 0 auto}@media (max-width:767px){.actions{flex-wrap:wrap}.actions>mq-button.join{order:1;flex:1 0 100%}}.menu{position:absolute;right:0;bottom:calc(100% + var(--sp-2));z-index:2;display:flex;flex-direction:column;min-width:176px;padding:var(--sp-1);background-color:var(--color-card,#fff);border:1px solid var(--color-border-subtle,#edecf1);border-radius:var(--border-radius-lg);box-shadow:var(--shadow-lg)}.menu-item{display:block;width:100%;background:0 0;border:none;border-radius:var(--border-radius-sm);padding:var(--sp-2) var(--sp-3);cursor:pointer;text-align:left;font-family:var(--font-body);font-size:var(--text-sm);line-height:1.35;color:var(--color-text-icons--primary,#0a0a22)}.menu-item:hover{background-color:var(--color-muted)}.menu-item.negative{color:var(--color-negative)}`;let J=class NextAppointmentCard extends E{constructor(){super(...arguments),this.specialtyName="",this.token="",this.patientHash="",this.hasChatSupport=!1,this.isExpired=!1,this.isModifyUnavailable=!1,this.isCancelUnavailable=!1,this.modifyUnavailableMessage="",this.cancelUnavailableMessage="",this.isChatOpen=!1,this.isMenuOpen=!1,this.isCancelDialogOpen=!1,this.openDialog=null,this.closeMenuOnOutsideClick=t=>{t.composedPath().includes(this)||(this.isMenuOpen=!1)},this.closeMenuOnEscape=t=>{"Escape"===t.key&&(this.isMenuOpen=!1)},this.handleJoinVideocall=()=>{j.track($(this.patientHash,this.appointmentId)),this.dispatchEvent(new N({appointmentId:this.appointmentId}))},this.handleToggleChat=()=>{this.isChatOpen=!this.isChatOpen,this.isChatOpen&&j.track(C(this.patientHash,this.appointmentId))},this.handleModify=()=>{this.isMenuOpen=!1,this.isModifyUnavailable?this.openDialog="modify":(j.track(w(this.patientHash,this.appointmentId)),this.dispatchEvent(new R({appointmentId:this.appointmentId})))},this.handleCancel=()=>{this.isMenuOpen=!1,this.isCancelUnavailable?this.openDialog="cancel":(j.track(O(this.patientHash,this.appointmentId)),this.isCancelDialogOpen=!0)}}static{this.styles=G}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.closeMenuOnOutsideClick),document.addEventListener("keydown",this.closeMenuOnEscape)}disconnectedCallback(){document.removeEventListener("click",this.closeMenuOnOutsideClick),document.removeEventListener("keydown",this.closeMenuOnEscape),super.disconnectedCallback()}get appointmentId(){return this.appointmentResource.appointment.id??""}get channel(){return this.appointmentResource.appointment.channel}channelIcon(){switch(this.channel){case u.videocall:return L({size:20});case u.phonecall:return B({size:20});default:return V({size:20})}}channelLabel(){switch(this.channel){case u.videocall:return p("Videoconsulta");case u.phonecall:return p("Consulta telefónica");default:return p("Chat")}}formatWhen(){const e=t().replace("_","-"),i=this.timezone?{timeZone:this.timezone}:{},n=new Date(this.appointmentResource.appointment.starts_at);if(Number.isNaN(n.getTime()))return"";const o=new Intl.DateTimeFormat(e,{weekday:"long",day:"numeric",month:"long",year:"numeric",...i}).format(n),a=new Intl.DateTimeFormat(e,{timeStyle:"short",...i}).format(n);return p(c`${o}, ${a} h`)}renderActions(){const t=this.channel===u.videocall;return A`<div class="actions">${this.hasChatSupport?A`<mq-button variant="outline" @click="${this.handleToggleChat}">${p("Ir a chat")}</mq-button>`:U} ${t?A`<mq-button class="join" variant="primary" @click="${this.handleJoinVideocall}">${p("Unirse a la videoconsulta")}</mq-button>`:U}<div class="overflow"><mq-button variant="outline" size="icon-lg" aria-label="${p("Más opciones")}" aria-haspopup="menu" aria-expanded="${this.isMenuOpen}" @click="${()=>{this.isMenuOpen=!this.isMenuOpen}}">${P({size:16})}</mq-button>${this.isMenuOpen?A`<div class="menu" role="menu"><button class="menu-item" type="button" role="menuitem" @click="${this.handleModify}">${p("Modificar cita")}</button> <button class="menu-item negative" type="button" role="menuitem" @click="${this.handleCancel}">${p("Anular cita")}</button></div>`:U}</div></div>`}render(){const{professional:t}=this.appointmentResource,e=this.formatWhen();return A`<professional-overview .name="${t.name}" .specialtyName="${this.specialtyName}" .collegiateNumber="${t.collegiate_number??void 0}" .description="${t.description??""}" .languages="${t.languages??[]}" .avatar="${t.avatar??""}"></professional-overview><div class="details">${e?A`<div class="detail-row">${H({size:20})} <span>${e}</span></div>`:U}<div class="detail-row">${this.channelIcon()} <span>${this.channelLabel()}</span></div></div><div class="footer"><p class="reminder">${p("Recibirás un recordatorio 15 minutos antes de la consulta")}</p>${this.renderActions()}</div><mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" hideCloseButton @mq-close="${()=>{this.isChatOpen=!1}}">${this.isChatOpen?A`<mq-chat-room slot="content" .consultationId="${this.appointmentResource.appointment.id}" consultation-type="appointment" token="${this.token}" .roomId="${this.appointmentResource.room.id}" .professionalHash="${t.hash}" ?readonly="${this.isExpired}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}"></mq-chat-room>`:U}</mq-floating-bubble><appointment-action-unavailable-dialog .open="${"modify"===this.openDialog}" .heading="${p("Modificar cita")}" .message="${this.modifyUnavailableMessage}" @close="${()=>{this.openDialog=null}}"></appointment-action-unavailable-dialog><appointment-action-unavailable-dialog .open="${"cancel"===this.openDialog}" .heading="${p("Anular cita")}" .message="${this.cancelUnavailableMessage}" @close="${()=>{this.openDialog=null}}"></appointment-action-unavailable-dialog><cancel-appointment-confirmation-dialog .appointmentId="${this.appointmentResource.appointment.id}" .price="${this.appointmentResource.price??void 0}" .open="${this.isCancelDialogOpen}" @cancel="${()=>{this.isCancelDialogOpen=!1}}" @success="${()=>{this.isCancelDialogOpen=!1,F.success(p("Consulta anulada correctamente")),this.dispatchEvent(new CustomEvent("appointment-cancel-confirmed",{bubbles:!0,composed:!0,detail:{id:this.appointmentId}}))}}"></cancel-appointment-confirmation-dialog>`}};o([D({type:Object})],J.prototype,"appointmentResource",void 0),o([D({type:String})],J.prototype,"specialtyName",void 0),o([D({type:String})],J.prototype,"token",void 0),o([D({type:String})],J.prototype,"patientHash",void 0),o([D({type:String})],J.prototype,"timezone",void 0),o([D({type:Boolean})],J.prototype,"hasChatSupport",void 0),o([D({type:Boolean})],J.prototype,"isExpired",void 0),o([D({type:Boolean})],J.prototype,"isModifyUnavailable",void 0),o([D({type:Boolean})],J.prototype,"isCancelUnavailable",void 0),o([D({type:String})],J.prototype,"modifyUnavailableMessage",void 0),o([D({type:String})],J.prototype,"cancelUnavailableMessage",void 0),o([T()],J.prototype,"isChatOpen",void 0),o([T()],J.prototype,"isMenuOpen",void 0),o([T()],J.prototype,"isCancelDialogOpen",void 0),o([T()],J.prototype,"openDialog",void 0),J=o([l(),a("next-appointment-card")],J);const K=[g.pending,g.accepted],W=I`:host{display:flex;flex-direction:column;gap:var(--sp-4);width:100%;min-width:0;box-sizing:border-box}:host([empty]){align-self:start}:host([empty]) .card{flex:0 0 auto}.card{display:flex;flex-direction:column;flex:1;min-width:0;box-sizing:border-box;background-color:var(--color-card,#fff);border:1px solid var(--color-border-subtle,#edecf1);border-radius:var(--mq-next-appointments-radius,12px);padding:var(--mq-next-appointments-padding,var(--sp-6))}`;let X=class MqNextAppointments extends E{constructor(){super(...arguments),this.apiClient=v(),this.getPatientProfileQuery=new m(this,()=>z(this.apiClient,{enabled:!this.loginToken})),this.getAppointmentsQuery=new m(this,()=>b(this.apiClient,{status:K,order:{field:"starts_at",direction:"asc"},page:1,per_page:1})),this.getOrganizationSetupQuery=new m(this,()=>x(this.apiClient)),this.getOrganizationSpecialtiesQuery=new m(this,()=>M(this.apiClient)),this.handleViewAll=()=>{this.dispatchEvent(new Q({tab:"next"}))}}static{this.styles=W}willUpdate(t){t.has("env")&&this.env&&_(this.env),t.has("locale")&&this.locale&&e(this.locale)&&i(this.locale);const n=f(t,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale},this.inheritedApiClient);n&&(this.apiClient=n)}get patientHash(){return this.loginToken?.patient.hash??this.getPatientProfileQuery.result?.data?.hash??""}get accessToken(){return this.token||this.loginToken?.access_token||""}get patientTimezone(){return this.timezone??this.loginToken?.patient.timezone}get isEmpty(){const t=this.getAppointmentsQuery.result;return!0===t?.isSuccess&&!t.data?.data?.[0]}updated(){this.toggleAttribute("empty",this.isEmpty)}renderAppointment(){return this.getAppointmentsQuery.render({complete:e=>{const i=e.data?.[0];if(!i)return A`<home-widget-empty-state icon="calendar" heading="${p("No tienes próximas citas")}" description="${p("Cuando agendes una cita, aparecerá aquí para que puedas consultarla, modificarla o cancelarla.")}"></home-widget-empty-state>`;const n=this.getOrganizationSetupQuery.result?.data,o=n?.appointments?.seconds_before_start_to_refund_on_cancel,a=S({startsAtIso:i.appointment.starts_at,refundPolicySeconds:o}),s=y(i.appointment.expires_at),r=0===i.slots.length,c=this.getOrganizationSpecialtiesQuery.result?.data?.find(t=>t.id===i.speciality.id);return A`<next-appointment-card .appointmentResource="${i}" .specialtyName="${q(c?.code??"",t(),c?.name??i.speciality.name)}" .token="${this.accessToken}" .patientHash="${this.patientHash}" .timezone="${this.patientTimezone}" .hasChatSupport="${!0===n?.appointments?.has_chat_in_appointment}" .isExpired="${s}" .isModifyUnavailable="${s||r||!a}" .isCancelUnavailable="${s||!a}" .modifyUnavailableMessage="${k({action:"modify",refundPolicySeconds:o})}" .cancelUnavailableMessage="${k({action:"cancel",refundPolicySeconds:o})}"></next-appointment-card>`},pending:()=>A`<mq-skeleton height="257px"></mq-skeleton>`,error:()=>A`<home-widget-empty-state icon="calendar" heading="${p("No hemos podido cargar tu próxima cita")}" description="${p("Vuelve a intentarlo en unos minutos.")}"></home-widget-empty-state>`})}render(){return A`<section-header heading="${p("Próxima cita")}" action-label="${p("Ver todas")}" @section-action="${this.handleViewAll}"></section-header><div class="card">${this.renderAppointment()}</div>`}};o([D({type:String,attribute:"api-key"})],X.prototype,"apiKey",void 0),o([D({type:String,attribute:"token"})],X.prototype,"token",void 0),o([D({type:String,attribute:"locale"})],X.prototype,"locale",void 0),o([D({type:String,attribute:"env"})],X.prototype,"env",void 0),o([D({type:String,attribute:"timezone"})],X.prototype,"timezone",void 0),o([r({context:d,subscribe:!0})],X.prototype,"loginToken",void 0),o([r({context:h,subscribe:!0}),T()],X.prototype,"inheritedApiClient",void 0),o([s({context:h}),T()],X.prototype,"apiClient",void 0),X=o([l(),a("mq-next-appointments")],X),n();export{N as MqAppointmentJoinVideocallEvent,R as MqAppointmentRescheduleEvent,X as MqNextAppointments,Q as MqViewAppointmentsEvent};
|
|
@@ -1,9 +1,13 @@
|
|
|
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
5
|
import { Env } from './env.js';
|
|
5
6
|
import './ui/mq-button.js';
|
|
6
7
|
export { MqPaymentSucceededEvent } from './events.js';
|
|
8
|
+
import 'axios';
|
|
9
|
+
import 'zod';
|
|
10
|
+
import './chunks/schemas.d-b6_AekBb.js';
|
|
7
11
|
|
|
8
12
|
/**
|
|
9
13
|
* Resolves a payment session started elsewhere, on a screen of its own.
|
|
@@ -45,6 +49,13 @@ declare class MqPaymentPoller extends LitElement {
|
|
|
45
49
|
private _intervalId?;
|
|
46
50
|
private _deadline;
|
|
47
51
|
private _settled;
|
|
52
|
+
/** The organization scope this element was mounted under, if any. */
|
|
53
|
+
private inheritedApiClient?;
|
|
54
|
+
/**
|
|
55
|
+
* This element's own transport, bound to its `api-key` and provided to every
|
|
56
|
+
* descendant. Never shared with another element.
|
|
57
|
+
*/
|
|
58
|
+
apiClient: MediquoApiChatClient;
|
|
48
59
|
protected willUpdate(changed: PropertyValues<this>): void;
|
|
49
60
|
protected updated(changed: PropertyValues<this>): void;
|
|
50
61
|
disconnectedCallback(): void;
|
|
@@ -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{
|
|
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{m as a}from"./chunks/runtime-Bg1WXVCx.js";import{l}from"./chunks/localized-decorator-BlOuLhym.js";import{c,n as d,P as p}from"./chunks/api-chat-client-pGZWREjK.js";import{A as h}from"./chunks/api-client-context-V1UAGtKW.js";import{i as m,a as u,x as v}from"./chunks/lit-element-DiWJYFwC.js";import{n as f}from"./chunks/property-scuRaFcM.js";import{r as g}from"./chunks/state-LQivXIgA.js";import{setEnv as y}from"./env.js";import{MqBackEvent as _,MqPaymentSucceededEvent as x}from"./events.js";import{spinnerIcon as k}from"./ui/icons/spinner-icon.js";import"./ui/mq-button.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-HN62IQ7S-xbkIy7k_.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/create-context-DqP79qjF.js";import"./ui/icons/types.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/if-defined-BYeVdwgd.js";const b="support@mediquo.com",j=m`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;min-height:320px;padding:var(--sp-6);box-sizing:border-box}.card{width:100%;max-width:460px;box-sizing:border-box;padding:var(--sp-10);background:var(--color-card);border-radius:var(--border-radius-lg);box-shadow:var(--shadow-lg)}.verifying{display:flex;flex-direction:column;align-items:center;gap:var(--sp-4);text-align:center}.outcome{display:flex;flex-direction:column;gap:var(--sp-4)}.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-negative);margin:0}.verifying .title{font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-semibold);color:var(--color-neutrals-text-default)}.message{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-subtle);margin:0}.support a{color:var(--color-primary-text-link);font-weight:var(--font-weight-medium);text-decoration:none}.support a:hover{text-decoration:underline}.actions{display:flex;flex-direction:column;gap:var(--sp-3);margin-top:var(--sp-2)}`;let w=class MqPaymentPoller extends u{constructor(){super(...arguments),this.timeoutMs=9e4,this._view="verifying",this._deadline=0,this._settled=!1,this.apiClient=c(),this._onRetry=()=>{this._restart()},this._onBack=()=>{this.dispatchEvent(new _({source:"payment-poller"}))}}static{this.styles=j}willUpdate(i){i.has("env")&&this.env&&y(this.env),i.has("locale")&&this.locale&&t(this.locale)&&e(this.locale);const s=d(i,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale},this.inheritedApiClient);s&&(this.apiClient=s)}updated(t){t.has("sessionId")&&this._restart()}disconnectedCallback(){this._stop(),super.disconnectedCallback()}_restart(){this._stop(),this._settled=!1,this._view="verifying",this.sessionId&&(this._deadline=Date.now()+this.timeoutMs,this._pollOnce(),this._intervalId=setInterval(()=>{this._pollOnce()},2e3))}_stop(){void 0!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0)}_settle(t){this._stop(),this._settled=!0,this._view=t}async _pollOnce(){const t=this.sessionId;if(this._settled||!t)return;if(Date.now()>=this._deadline)return void this._settle("timeout");let e;try{e=await this.apiClient.payments.getPaymentSession(t)}catch{return}return this._settled||t!==this.sessionId?void 0:e.status===p.Paid?(this._stop(),this._settled=!0,void this.dispatchEvent(new x({appointmentId:e.consultation_id,consultationType:e.consultation_type}))):void(e.status===p.Denied&&this._settle("denied"))}_renderVerifying(){return v`<div class="card"><div class="verifying" role="status" aria-live="polite">${k({size:28,color:"var(--color-primary)"})}<p class="title">${a("Confirmando tu pago")}</p><p class="message">${a("No cierres, vuelvas atrás ni actualices la ventana; esto puede tardar unos momentos.")}</p></div></div>`}_renderDenied(){return v`<div class="card"><div class="outcome" role="alert"><p class="title">${a("Tu pago no se ha completado")}</p><p class="message">${a("El pago ha sido rechazado y no hemos creado la cita. No se te ha cobrado nada: vuelve a intentarlo con otro método de pago.")}</p><div class="actions"><mq-button variant="primary" size="lg" fullwidth @click="${this._onBack}">${a("Volver")}</mq-button></div></div></div>`}_renderTimeout(){return v`<div class="card"><div class="outcome" role="alert"><p class="title">${a("Ha ocurrido un error")}</p><p class="message">${a("No hemos podido confirmar tu pago. Por favor, inténtalo de nuevo más tarde.")}</p><p class="message support">${a("Si se te ha cobrado sin una cita confirmada, contacta con nuestro equipo en")} <a href="mailto:${b}">${b}</a></p><div class="actions"><mq-button variant="primary" size="lg" fullwidth @click="${this._onRetry}">${a("Reintentar verificación")}</mq-button><mq-button variant="secondary" size="lg" fullwidth @click="${this._onBack}">${a("Volver")}</mq-button></div></div></div>`}render(){switch(this._view){case"denied":return this._renderDenied();case"timeout":return this._renderTimeout();default:return this._renderVerifying()}}};s([f({type:String,attribute:"session-id"})],w.prototype,"sessionId",void 0),s([f({type:String,attribute:"api-key"})],w.prototype,"apiKey",void 0),s([f({type:String,attribute:"token"})],w.prototype,"token",void 0),s([f({type:String,attribute:"locale"})],w.prototype,"locale",void 0),s([f({type:String,attribute:"env"})],w.prototype,"env",void 0),s([f({type:Number,attribute:"timeout-ms"})],w.prototype,"timeoutMs",void 0),s([g()],w.prototype,"_view",void 0),s([n({context:h,subscribe:!0}),g()],w.prototype,"inheritedApiClient",void 0),s([r({context:h}),g()],w.prototype,"apiClient",void 0),w=s([l(),o("mq-payment-poller")],w),i();export{w as MqPaymentPoller,x as MqPaymentSucceededEvent};
|
|
@@ -16,6 +16,7 @@ declare class ProfessionalPresenceSyncController implements ReactiveController {
|
|
|
16
16
|
private readonly host;
|
|
17
17
|
private socket;
|
|
18
18
|
private queryClient;
|
|
19
|
+
private apiClient;
|
|
19
20
|
private readonly clearTimers;
|
|
20
21
|
constructor(host: ReactiveControllerHost);
|
|
21
22
|
private _queryKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as e,c as s}from"./chunks/custom-element-D2ziPxYE.js";import{a as t,E as n}from"./chunks/lit-element-DiWJYFwC.js";import{
|
|
1
|
+
import{_ as e,c as s}from"./chunks/custom-element-D2ziPxYE.js";import{a as t,E as n}from"./chunks/lit-element-DiWJYFwC.js";import{s as c}from"./chunks/context-consumer-ESdICVAb.js";import{Q as r}from"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import{A as i}from"./chunks/api-client-context-V1UAGtKW.js";import{S as o,a}from"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import{g as h}from"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import{a as l}from"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/external-CJj32K_p.js";import"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./chunks/format-CRFiCNHw.js";class ProfessionalPresenceSyncController{constructor(e){this.host=e,this.clearTimers=new Map,this._onAbsenceCreated=e=>{if(!e?.professional_hash||!e.finishes_at)return;const{professional_hash:s,id:t,finishes_at:n}=e;this._setActiveAbsence(s,{id:t,finishes_at:n}),this._clearTimer(s);const c=l(n).getTime()-Date.now();c>0&&c<2147483647&&this.clearTimers.set(s,setTimeout(()=>{this.clearTimers.delete(s),this._setActiveAbsence(s,null)},c))},this._onAbsenceCancelled=e=>{e?.professional_hash&&(this._clearTimer(e.professional_hash),this._setActiveAbsence(e.professional_hash,null))},new c(this.host,{context:o,subscribe:!0,callback:e=>{e&&e!==this.socket&&(this.socket=e,this.socket.on(a.absence_created,this._onAbsenceCreated),this.socket.on(a.absence_cancelled,this._onAbsenceCancelled))}}),new c(this.host,{context:r,subscribe:!0,callback:e=>{e&&(this.queryClient=e)}}),new c(this.host,{context:i,subscribe:!0,callback:e=>{this.apiClient=e}}),this.host.addController(this)}_queryKey(e){if(this.apiClient)return h(this.apiClient,{hash:e}).queryKey}_setActiveAbsence(e,s){const t=this._queryKey(e);t&&this.queryClient?.setQueryData(t,e=>e?{...e,active_absence:s}:void 0)}_clearTimer(e){const s=this.clearTimers.get(e);s&&(clearTimeout(s),this.clearTimers.delete(e))}hostConnected(){}hostDisconnected(){this.socket?.off(a.absence_created,this._onAbsenceCreated),this.socket?.off(a.absence_cancelled,this._onAbsenceCancelled);for(const e of this.clearTimers.values())clearTimeout(e);this.clearTimers.clear()}}let u=class MqProfessionalPresenceSync extends t{constructor(){super(...arguments),this._controller=new ProfessionalPresenceSyncController(this)}createRenderRoot(){return this}render(){return n}};u=e([s("mq-professional-presence-sync")],u);export{u as MqProfessionalPresenceSync,ProfessionalPresenceSyncController};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import * as lit_html from 'lit-html';
|
|
2
|
+
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
2
3
|
import { LitElement } from 'lit';
|
|
3
4
|
|
|
4
5
|
/** Variadic constructor signature used by Lit/TS mixins (`TS2545`). */
|
|
5
6
|
type Constructor<T = object> = new (...args: any[]) => T;
|
|
6
7
|
|
|
7
|
-
declare const QueryClientProvider_base: Constructor<{
|
|
8
|
+
declare const QueryClientProvider_base: Constructor<{
|
|
9
|
+
queryClient: _tanstack_query_core.QueryClient;
|
|
10
|
+
}> & typeof LitElement;
|
|
8
11
|
declare class QueryClientProvider extends QueryClientProvider_base {
|
|
9
12
|
render(): lit_html.TemplateResult<1>;
|
|
10
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{Q as s}from"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import{e as i}from"./chunks/provide-D2fnEhT2.js";import{h as a,j as r,k as n,R as o,l as u,g as h,S as c,m as l,n as d,o as f,Q as y,q as p,f as m,u as g,a as v,v as b,w as C,x as q,y as O}from"./chunks/query-Cjvi4_dT.js";import{x as P,a as w}from"./chunks/lit-element-DiWJYFwC.js";import{r as Q}from"./chunks/state-LQivXIgA.js";import{e as x}from"./chunks/ensure-context-root-DbdqwnKB.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/context-provider--AKuwfs9.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/property-scuRaFcM.js";var D=Object.defineProperty;function M(t){return{onFetch:(e,s)=>{const i=e.options,o=e.fetchOptions?.meta?.fetchMore?.direction,u=e.state.data?.pages||[],h=e.state.data?.pageParams||[];let c={pages:[],pageParams:[]},l=0;const d=async()=>{let s=!1;const d=a(e.options,e.fetchOptions),f=async(t,i,a)=>{if(s)return Promise.reject();if(null==i&&t.pages.length)return Promise.resolve(t);const o=(()=>{const t={client:e.client,queryKey:e.queryKey,pageParam:i,direction:a?"backward":"forward",meta:e.options.meta};var r;return r=t,Object.defineProperty(r,"signal",{enumerable:!0,get:()=>(e.signal.aborted?s=!0:e.signal.addEventListener("abort",()=>{s=!0}),e.signal)}),t})(),u=await d(o),{maxPages:h}=e.options,c=a?r:n;return{pages:c(t.pages,u,h),pageParams:c(t.pageParams,i,h)}};if(o&&u.length){const t="backward"===o,e={pages:u,pageParams:h},s=(t?A:k)(i,e);c=await f(e,s,t)}else{const e=t??u.length;do{const t=0===l?h[0]??i.initialPageParam:k(i,c);if(l>0&&null==t)break;c=await f(c,t),l++}while(l<e)}return c};e.options.persister?e.fetchFn=()=>e.options.persister?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s):e.fetchFn=d}}}function k(t,{pages:e,pageParams:s}){const i=e.length-1;return e.length>0?t.getNextPageParam(e[i],e,s[i],s):void 0}function A(t,{pages:e,pageParams:s}){return e.length>0?t.getPreviousPageParam?.(e[0],e,s[0],s):void 0}var j=class extends o{#t;#e;#s;constructor(t){super(),this.mutationId=t.mutationId,this.#e=t.mutationCache,this.#t=[],this.state=t.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||("pending"===this.state.status?this.scheduleGc():this.#e.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#i({type:"continue"})};this.#s=u({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(t,e)=>{this.#i({type:"failed",failureCount:t,error:e})},onPause:()=>{this.#i({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const s="pending"===this.state.status,i=!this.#s.canStart();try{if(s)e();else{this.#i({type:"pending",variables:t,isPaused:i}),await(this.#e.config.onMutate?.(t,this));const e=await(this.options.onMutate?.(t));e!==this.state.context&&this.#i({type:"pending",context:e,variables:t,isPaused:i})}const a=await this.#s.start();return await(this.#e.config.onSuccess?.(a,t,this.state.context,this)),await(this.options.onSuccess?.(a,t,this.state.context)),await(this.#e.config.onSettled?.(a,null,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(a,null,t,this.state.context)),this.#i({type:"success",data:a}),a}catch(e){try{throw await(this.#e.config.onError?.(e,t,this.state.context,this)),await(this.options.onError?.(e,t,this.state.context)),await(this.#e.config.onSettled?.(void 0,e,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(void 0,e,t,this.state.context)),e}finally{this.#i({type:"error",error:e})}}finally{this.#e.runNext(this)}}#i(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"pending":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}})(this.state),h.batch(()=>{this.#t.forEach(e=>{e.onMutationUpdate(t)}),this.#e.notify({mutation:this,type:"updated",action:t})})}};var E=class extends c{constructor(t={}){super(),this.config=t,this.#a=new Set,this.#r=new Map,this.#n=0}#a;#r;#n;build(t,e,s){const i=new j({mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:s});return this.add(i),i}add(t){this.#a.add(t);const e=K(t);if("string"==typeof e){const s=this.#r.get(e);s?s.push(t):this.#r.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#a.delete(t)){const e=K(t);if("string"==typeof e){const s=this.#r.get(e);if(s)if(s.length>1){const e=s.indexOf(t);-1!==e&&s.splice(e,1)}else s[0]===t&&this.#r.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=K(t);if("string"==typeof e){const s=this.#r.get(e),i=s?.find(t=>"pending"===t.state.status);return!i||i===t}return!0}runNext(t){const e=K(t);if("string"==typeof e){const s=this.#r.get(e)?.find(e=>e!==t&&e.state.isPaused);return s?.continue()??Promise.resolve()}return Promise.resolve()}clear(){h.batch(()=>{this.#a.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#a.clear(),this.#r.clear()})}getAll(){return Array.from(this.#a)}find(t){const e={exact:!0,...t};return this.getAll().find(t=>l(e,t))}findAll(t={}){return this.getAll().filter(e=>l(t,e))}notify(t){h.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(t=>t.state.isPaused);return h.batch(()=>Promise.all(t.map(t=>t.continue().catch(d))))}};function K(t){return t.options.scope?.id}var F=class extends c{constructor(t={}){super(),this.config=t,this.#o=new Map}#o;build(t,e,s){const i=e.queryKey,a=e.queryHash??f(i,e);let r=this.get(a);return r||(r=new y({client:t,queryKey:i,queryHash:a,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(i)}),this.add(r)),r}add(t){this.#o.has(t.queryHash)||(this.#o.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#o.get(t.queryHash);e&&(t.destroy(),e===t&&this.#o.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){h.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#o.get(t)}getAll(){return[...this.#o.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(t=>p(e,t))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(e=>p(t,e)):e}notify(t){h.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){h.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){h.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},R=class{#u;#e;#h;#c;#l;#d;#f;#y;constructor(t={}){this.#u=t.queryCache||new F,this.#e=t.mutationCache||new E,this.#h=t.defaultOptions||{},this.#c=new Map,this.#l=new Map,this.#d=0}mount(){this.#d++,1===this.#d&&(this.#f=m.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#u.onFocus())}),this.#y=g.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#u.onOnline())}))}unmount(){this.#d--,0===this.#d&&(this.#f?.(),this.#f=void 0,this.#y?.(),this.#y=void 0)}isFetching(t){return this.#u.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#u.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),s=this.#u.build(this,e),i=s.state.data;return void 0===i?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(v(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(t){return this.#u.findAll(t).map(({queryKey:t,state:e})=>[t,e.data])}setQueryData(t,e,s){const i=this.defaultQueryOptions({queryKey:t}),a=this.#u.get(i.queryHash),r=a?.state.data,n=b(e,r);if(void 0!==n)return this.#u.build(this,i).setData(n,{...s,manual:!0})}setQueriesData(t,e,s){return h.batch(()=>this.#u.findAll(t).map(({queryKey:t})=>[t,this.setQueryData(t,e,s)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#u.get(e.queryHash)?.state}removeQueries(t){const e=this.#u;h.batch(()=>{e.findAll(t).forEach(t=>{e.remove(t)})})}resetQueries(t,e){const s=this.#u;return h.batch(()=>(s.findAll(t).forEach(t=>{t.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const s={revert:!0,...e},i=h.batch(()=>this.#u.findAll(t).map(t=>t.cancel(s)));return Promise.all(i).then(d).catch(d)}invalidateQueries(t,e={}){return h.batch(()=>(this.#u.findAll(t).forEach(t=>{t.invalidate()}),"none"===t?.refetchType?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const s={...e,cancelRefetch:e.cancelRefetch??!0},i=h.batch(()=>this.#u.findAll(t).filter(t=>!t.isDisabled()&&!t.isStatic()).map(t=>{let e=t.fetch(void 0,s);return s.throwOnError||(e=e.catch(d)),"paused"===t.state.fetchStatus?Promise.resolve():e}));return Promise.all(i).then(d)}fetchQuery(t){const e=this.defaultQueryOptions(t);void 0===e.retry&&(e.retry=!1);const s=this.#u.build(this,e);return s.isStaleByTime(v(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(d).catch(d)}fetchInfiniteQuery(t){return t.behavior=M(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(d).catch(d)}ensureInfiniteQueryData(t){return t.behavior=M(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return g.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#u}getMutationCache(){return this.#e}getDefaultOptions(){return this.#h}setDefaultOptions(t){this.#h=t}setQueryDefaults(t,e){this.#c.set(C(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#c.values()],s={};return e.forEach(e=>{q(t,e.queryKey)&&Object.assign(s,e.defaultOptions)}),s}setMutationDefaults(t,e){this.#l.set(C(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#l.values()],s={};return e.forEach(e=>{q(t,e.mutationKey)&&Object.assign(s,e.defaultOptions)}),s}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#h.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=f(e.queryKey,e)),void 0===e.refetchOnReconnect&&(e.refetchOnReconnect="always"!==e.networkMode),void 0===e.throwOnError&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===O&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#h.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#u.clear(),this.#e.clear()}},S=t=>{class QueryClientMixinClass extends t{constructor(){super(...arguments),this.queryClient=new R({defaultOptions:{queries:{staleTime:6e4}}})}connectedCallback(){super.connectedCallback(),this.queryClient.mount()}disconnectedCallback(){super.disconnectedCallback(),this.queryClient.unmount()}}return((t,e,s)=>{for(var i,a=void 0,r=t.length-1;r>=0;r--)(i=t[r])&&(a=i(e,s,a)||a);a&&D(e,s,a)})([i({context:s}),Q()],QueryClientMixinClass.prototype,"queryClient"),QueryClientMixinClass};x();let I=class QueryClientProvider extends(S(w)){render(){return P`<slot></slot>`}};I=t([e("mq-query-client-provider")],I);export{I as QueryClientProvider};
|
|
1
|
+
import{_ as t,c as e}from"./chunks/custom-element-D2ziPxYE.js";import{Q as s}from"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import{e as i}from"./chunks/provide-BwI4DDGF.js";import{h as a,j as r,k as n,R as o,l as u,g as h,S as c,m as l,n as d,o as f,Q as y,q as p,f as m,u as g,a as v,v as b,w as C,x as q,y as O}from"./chunks/query-Cjvi4_dT.js";import{x as P,a as w}from"./chunks/lit-element-DiWJYFwC.js";import{r as Q}from"./chunks/state-LQivXIgA.js";import{e as x}from"./chunks/ensure-context-root-DbdqwnKB.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/property-scuRaFcM.js";var D=Object.defineProperty;function M(t){return{onFetch:(e,s)=>{const i=e.options,o=e.fetchOptions?.meta?.fetchMore?.direction,u=e.state.data?.pages||[],h=e.state.data?.pageParams||[];let c={pages:[],pageParams:[]},l=0;const d=async()=>{let s=!1;const d=a(e.options,e.fetchOptions),f=async(t,i,a)=>{if(s)return Promise.reject();if(null==i&&t.pages.length)return Promise.resolve(t);const o=(()=>{const t={client:e.client,queryKey:e.queryKey,pageParam:i,direction:a?"backward":"forward",meta:e.options.meta};var r;return r=t,Object.defineProperty(r,"signal",{enumerable:!0,get:()=>(e.signal.aborted?s=!0:e.signal.addEventListener("abort",()=>{s=!0}),e.signal)}),t})(),u=await d(o),{maxPages:h}=e.options,c=a?r:n;return{pages:c(t.pages,u,h),pageParams:c(t.pageParams,i,h)}};if(o&&u.length){const t="backward"===o,e={pages:u,pageParams:h},s=(t?A:k)(i,e);c=await f(e,s,t)}else{const e=t??u.length;do{const t=0===l?h[0]??i.initialPageParam:k(i,c);if(l>0&&null==t)break;c=await f(c,t),l++}while(l<e)}return c};e.options.persister?e.fetchFn=()=>e.options.persister?.(d,{client:e.client,queryKey:e.queryKey,meta:e.options.meta,signal:e.signal},s):e.fetchFn=d}}}function k(t,{pages:e,pageParams:s}){const i=e.length-1;return e.length>0?t.getNextPageParam(e[i],e,s[i],s):void 0}function A(t,{pages:e,pageParams:s}){return e.length>0?t.getPreviousPageParam?.(e[0],e,s[0],s):void 0}var E=class extends o{#t;#e;#s;constructor(t){super(),this.mutationId=t.mutationId,this.#e=t.mutationCache,this.#t=[],this.state=t.state||{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0},this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options=t,this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){this.#t.includes(t)||(this.#t.push(t),this.clearGcTimeout(),this.#e.notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){this.#t=this.#t.filter(e=>e!==t),this.scheduleGc(),this.#e.notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){this.#t.length||("pending"===this.state.status?this.scheduleGc():this.#e.remove(this))}continue(){return this.#s?.continue()??this.execute(this.state.variables)}async execute(t){const e=()=>{this.#i({type:"continue"})};this.#s=u({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(t,e)=>{this.#i({type:"failed",failureCount:t,error:e})},onPause:()=>{this.#i({type:"pause"})},onContinue:e,retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode,canRun:()=>this.#e.canRun(this)});const s="pending"===this.state.status,i=!this.#s.canStart();try{if(s)e();else{this.#i({type:"pending",variables:t,isPaused:i}),await(this.#e.config.onMutate?.(t,this));const e=await(this.options.onMutate?.(t));e!==this.state.context&&this.#i({type:"pending",context:e,variables:t,isPaused:i})}const a=await this.#s.start();return await(this.#e.config.onSuccess?.(a,t,this.state.context,this)),await(this.options.onSuccess?.(a,t,this.state.context)),await(this.#e.config.onSettled?.(a,null,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(a,null,t,this.state.context)),this.#i({type:"success",data:a}),a}catch(e){try{throw await(this.#e.config.onError?.(e,t,this.state.context,this)),await(this.options.onError?.(e,t,this.state.context)),await(this.#e.config.onSettled?.(void 0,e,this.state.variables,this.state.context,this)),await(this.options.onSettled?.(void 0,e,t,this.state.context)),e}finally{this.#i({type:"error",error:e})}}finally{this.#e.runNext(this)}}#i(t){this.state=(e=>{switch(t.type){case"failed":return{...e,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...e,isPaused:!0};case"continue":return{...e,isPaused:!1};case"pending":return{...e,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:t.isPaused,status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...e,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...e,data:void 0,error:t.error,failureCount:e.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}})(this.state),h.batch(()=>{this.#t.forEach(e=>{e.onMutationUpdate(t)}),this.#e.notify({mutation:this,type:"updated",action:t})})}};var K=class extends c{constructor(t={}){super(),this.config=t,this.#a=new Set,this.#r=new Map,this.#n=0}#a;#r;#n;build(t,e,s){const i=new E({mutationCache:this,mutationId:++this.#n,options:t.defaultMutationOptions(e),state:s});return this.add(i),i}add(t){this.#a.add(t);const e=j(t);if("string"==typeof e){const s=this.#r.get(e);s?s.push(t):this.#r.set(e,[t])}this.notify({type:"added",mutation:t})}remove(t){if(this.#a.delete(t)){const e=j(t);if("string"==typeof e){const s=this.#r.get(e);if(s)if(s.length>1){const e=s.indexOf(t);-1!==e&&s.splice(e,1)}else s[0]===t&&this.#r.delete(e)}}this.notify({type:"removed",mutation:t})}canRun(t){const e=j(t);if("string"==typeof e){const s=this.#r.get(e),i=s?.find(t=>"pending"===t.state.status);return!i||i===t}return!0}runNext(t){const e=j(t);if("string"==typeof e){const s=this.#r.get(e)?.find(e=>e!==t&&e.state.isPaused);return s?.continue()??Promise.resolve()}return Promise.resolve()}clear(){h.batch(()=>{this.#a.forEach(t=>{this.notify({type:"removed",mutation:t})}),this.#a.clear(),this.#r.clear()})}getAll(){return Array.from(this.#a)}find(t){const e={exact:!0,...t};return this.getAll().find(t=>l(e,t))}findAll(t={}){return this.getAll().filter(e=>l(t,e))}notify(t){h.batch(()=>{this.listeners.forEach(e=>{e(t)})})}resumePausedMutations(){const t=this.getAll().filter(t=>t.state.isPaused);return h.batch(()=>Promise.all(t.map(t=>t.continue().catch(d))))}};function j(t){return t.options.scope?.id}var F=class extends c{constructor(t={}){super(),this.config=t,this.#o=new Map}#o;build(t,e,s){const i=e.queryKey,a=e.queryHash??f(i,e);let r=this.get(a);return r||(r=new y({client:t,queryKey:i,queryHash:a,options:t.defaultQueryOptions(e),state:s,defaultOptions:t.getQueryDefaults(i)}),this.add(r)),r}add(t){this.#o.has(t.queryHash)||(this.#o.set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const e=this.#o.get(t.queryHash);e&&(t.destroy(),e===t&&this.#o.delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){h.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return this.#o.get(t)}getAll(){return[...this.#o.values()]}find(t){const e={exact:!0,...t};return this.getAll().find(t=>p(e,t))}findAll(t={}){const e=this.getAll();return Object.keys(t).length>0?e.filter(e=>p(t,e)):e}notify(t){h.batch(()=>{this.listeners.forEach(e=>{e(t)})})}onFocus(){h.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){h.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},R=class{#u;#e;#h;#c;#l;#d;#f;#y;constructor(t={}){this.#u=t.queryCache||new F,this.#e=t.mutationCache||new K,this.#h=t.defaultOptions||{},this.#c=new Map,this.#l=new Map,this.#d=0}mount(){this.#d++,1===this.#d&&(this.#f=m.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#u.onFocus())}),this.#y=g.subscribe(async t=>{t&&(await this.resumePausedMutations(),this.#u.onOnline())}))}unmount(){this.#d--,0===this.#d&&(this.#f?.(),this.#f=void 0,this.#y?.(),this.#y=void 0)}isFetching(t){return this.#u.findAll({...t,fetchStatus:"fetching"}).length}isMutating(t){return this.#e.findAll({...t,status:"pending"}).length}getQueryData(t){const e=this.defaultQueryOptions({queryKey:t});return this.#u.get(e.queryHash)?.state.data}ensureQueryData(t){const e=this.defaultQueryOptions(t),s=this.#u.build(this,e),i=s.state.data;return void 0===i?this.fetchQuery(t):(t.revalidateIfStale&&s.isStaleByTime(v(e.staleTime,s))&&this.prefetchQuery(e),Promise.resolve(i))}getQueriesData(t){return this.#u.findAll(t).map(({queryKey:t,state:e})=>[t,e.data])}setQueryData(t,e,s){const i=this.defaultQueryOptions({queryKey:t}),a=this.#u.get(i.queryHash),r=a?.state.data,n=b(e,r);if(void 0!==n)return this.#u.build(this,i).setData(n,{...s,manual:!0})}setQueriesData(t,e,s){return h.batch(()=>this.#u.findAll(t).map(({queryKey:t})=>[t,this.setQueryData(t,e,s)]))}getQueryState(t){const e=this.defaultQueryOptions({queryKey:t});return this.#u.get(e.queryHash)?.state}removeQueries(t){const e=this.#u;h.batch(()=>{e.findAll(t).forEach(t=>{e.remove(t)})})}resetQueries(t,e){const s=this.#u;return h.batch(()=>(s.findAll(t).forEach(t=>{t.reset()}),this.refetchQueries({type:"active",...t},e)))}cancelQueries(t,e={}){const s={revert:!0,...e},i=h.batch(()=>this.#u.findAll(t).map(t=>t.cancel(s)));return Promise.all(i).then(d).catch(d)}invalidateQueries(t,e={}){return h.batch(()=>(this.#u.findAll(t).forEach(t=>{t.invalidate()}),"none"===t?.refetchType?Promise.resolve():this.refetchQueries({...t,type:t?.refetchType??t?.type??"active"},e)))}refetchQueries(t,e={}){const s={...e,cancelRefetch:e.cancelRefetch??!0},i=h.batch(()=>this.#u.findAll(t).filter(t=>!t.isDisabled()&&!t.isStatic()).map(t=>{let e=t.fetch(void 0,s);return s.throwOnError||(e=e.catch(d)),"paused"===t.state.fetchStatus?Promise.resolve():e}));return Promise.all(i).then(d)}fetchQuery(t){const e=this.defaultQueryOptions(t);void 0===e.retry&&(e.retry=!1);const s=this.#u.build(this,e);return s.isStaleByTime(v(e.staleTime,s))?s.fetch(e):Promise.resolve(s.state.data)}prefetchQuery(t){return this.fetchQuery(t).then(d).catch(d)}fetchInfiniteQuery(t){return t.behavior=M(t.pages),this.fetchQuery(t)}prefetchInfiniteQuery(t){return this.fetchInfiniteQuery(t).then(d).catch(d)}ensureInfiniteQueryData(t){return t.behavior=M(t.pages),this.ensureQueryData(t)}resumePausedMutations(){return g.isOnline()?this.#e.resumePausedMutations():Promise.resolve()}getQueryCache(){return this.#u}getMutationCache(){return this.#e}getDefaultOptions(){return this.#h}setDefaultOptions(t){this.#h=t}setQueryDefaults(t,e){this.#c.set(C(t),{queryKey:t,defaultOptions:e})}getQueryDefaults(t){const e=[...this.#c.values()],s={};return e.forEach(e=>{q(t,e.queryKey)&&Object.assign(s,e.defaultOptions)}),s}setMutationDefaults(t,e){this.#l.set(C(t),{mutationKey:t,defaultOptions:e})}getMutationDefaults(t){const e=[...this.#l.values()],s={};return e.forEach(e=>{q(t,e.mutationKey)&&Object.assign(s,e.defaultOptions)}),s}defaultQueryOptions(t){if(t._defaulted)return t;const e={...this.#h.queries,...this.getQueryDefaults(t.queryKey),...t,_defaulted:!0};return e.queryHash||(e.queryHash=f(e.queryKey,e)),void 0===e.refetchOnReconnect&&(e.refetchOnReconnect="always"!==e.networkMode),void 0===e.throwOnError&&(e.throwOnError=!!e.suspense),!e.networkMode&&e.persister&&(e.networkMode="offlineFirst"),e.queryFn===O&&(e.enabled=!1),e}defaultMutationOptions(t){return t?._defaulted?t:{...this.#h.mutations,...t?.mutationKey&&this.getMutationDefaults(t.mutationKey),...t,_defaulted:!0}}clear(){this.#u.clear(),this.#e.clear()}},S=t=>{class QueryClientMixinClass extends t{constructor(){super(...arguments),this.queryClient=new R({defaultOptions:{queries:{staleTime:6e4}}})}connectedCallback(){super.connectedCallback(),this.queryClient.mount()}disconnectedCallback(){super.disconnectedCallback(),this.queryClient.unmount()}}return((t,e,s)=>{for(var i,a=void 0,r=t.length-1;r>=0;r--)(i=t[r])&&(a=i(e,s,a)||a);a&&D(e,s,a)})([i({context:s}),Q()],QueryClientMixinClass.prototype,"queryClient"),QueryClientMixinClass};x();let I=class QueryClientProvider extends(S(w)){render(){return P`<slot></slot>`}};I=t([e("mq-query-client-provider")],I);export{I as QueryClientProvider};
|
|
@@ -1,36 +1,14 @@
|
|
|
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
5
|
import { Env } from './env.js';
|
|
5
6
|
import './chunks/index-CDBk7hVW.js';
|
|
6
7
|
import './ui/mq-skeleton.js';
|
|
7
|
-
import { D as DocumentType } from './chunks/document.model.d-DIzMiOmd.js';
|
|
8
|
-
import './ui/mq-button.js';
|
|
9
8
|
export { DownloadFileEvent, MqViewDocumentsEvent } from './events.js';
|
|
9
|
+
import 'axios';
|
|
10
10
|
import 'zod';
|
|
11
|
-
|
|
12
|
-
declare class RecentDocumentRow extends LitElement {
|
|
13
|
-
static styles: lit.CSSResult;
|
|
14
|
-
documentId: string;
|
|
15
|
-
kind: DocumentType;
|
|
16
|
-
name: string;
|
|
17
|
-
specialty: string;
|
|
18
|
-
date: string;
|
|
19
|
-
downloadUrl: string;
|
|
20
|
-
patientHash: string;
|
|
21
|
-
private isDownloading;
|
|
22
|
-
private formatDate;
|
|
23
|
-
private formatKind;
|
|
24
|
-
private get kindClass();
|
|
25
|
-
private get metaLine();
|
|
26
|
-
private handleDownload;
|
|
27
|
-
render(): lit_html.TemplateResult<1>;
|
|
28
|
-
}
|
|
29
|
-
declare global {
|
|
30
|
-
interface HTMLElementTagNameMap {
|
|
31
|
-
"recent-document-row": RecentDocumentRow;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
11
|
+
import './chunks/schemas.d-b6_AekBb.js';
|
|
34
12
|
|
|
35
13
|
declare class MqRecentDocuments extends LitElement {
|
|
36
14
|
static styles: lit.CSSResult;
|
|
@@ -38,6 +16,13 @@ declare class MqRecentDocuments extends LitElement {
|
|
|
38
16
|
token?: string;
|
|
39
17
|
locale?: string;
|
|
40
18
|
env?: Env;
|
|
19
|
+
/** The organization scope this element was mounted under, if any. */
|
|
20
|
+
private inheritedApiClient?;
|
|
21
|
+
/**
|
|
22
|
+
* This element's own transport, bound to its `api-key` and provided to every
|
|
23
|
+
* descendant. Never shared with another element.
|
|
24
|
+
*/
|
|
25
|
+
apiClient: MediquoApiChatClient;
|
|
41
26
|
protected willUpdate(changed: PropertyValues<this>): void;
|
|
42
27
|
private loginToken?;
|
|
43
28
|
private getPatientProfileQuery;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{isValidLocale as t,setLocale as e,getLocale as i,initLocalization as s}from"./i18n.js";import{_ as o,c as n}from"./chunks/custom-element-D2ziPxYE.js";import{e as r}from"./chunks/provide-BwI4DDGF.js";import{c as a}from"./chunks/consume-CovVqBjI.js";import{m as c}from"./chunks/runtime-Bg1WXVCx.js";import{l as p}from"./chunks/localized-decorator-BlOuLhym.js";import{Q as m}from"./chunks/query-controller-BlO1Ax65.js";import{A as h}from"./chunks/api-client-context-V1UAGtKW.js";import{l as u}from"./chunks/chunk-S5RWG6G2-DPesx3Od.js";import{g as d,t as l,r as k,a as g}from"./chunks/telemetry-client-CoWay8es.js";import{g as f}from"./chunks/get-patient-documents-query-NC9xCa_N.js";import{g as y}from"./chunks/get-patient-profile-query-4AO6xvVn.js";import{i as j,a as v,x as b,E as x}from"./chunks/lit-element-DiWJYFwC.js";import{n as w}from"./chunks/property-scuRaFcM.js";import{r as $}from"./chunks/state-LQivXIgA.js";import{setEnv as q}from"./env.js";import{MqViewDocumentsEvent as C}from"./events.js";export{DownloadFileEvent}from"./events.js";import{c as D,n as S}from"./chunks/api-chat-client-pGZWREjK.js";import"./chunks/index-CoZKmhwT.js";import"./ui/mq-skeleton.js";import{D as A}from"./chunks/index-6gxzoTLM.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"./ui/icons/calendar-icon.js";import"./ui/icons/types.js";import"./ui/icons/file-icon.js";import"./ui/icons/arrow-right-icon.js";import"./chunks/if-defined-BYeVdwgd.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/blob-to-base64-CUL1trde.js";import"./ui/icons/download-icon.js";import"./ui/mq-button.js";import"./chunks/class-map-Co76I6aw.js";import"./ui/mq-toast.js";const Q=j`:host{display:flex;flex-direction:column;gap:var(--sp-4);width:100%;min-width:0;box-sizing:border-box}:host([empty]){align-self:start}:host([empty]) .card{flex:0 0 auto;justify-content:flex-start}.card{display:flex;flex-direction:column;justify-content:center;gap:var(--sp-3);flex:1;min-width:0;box-sizing:border-box;background-color:var(--color-card,#fff);border:1px solid var(--color-border-subtle,#edecf1);border-radius:var(--mq-recent-documents-radius,12px);padding:var(--mq-recent-documents-padding,var(--sp-6))}.divider{height:1px;width:100%;background-color:var(--color-border-subtle,#edecf1);flex-shrink:0}`;let H=class MqRecentDocuments extends v{constructor(){super(...arguments),this.apiClient=D(),this.getPatientProfileQuery=new m(this,()=>y(this.apiClient,{enabled:!this.loginToken})),this.getPatientDocumentsQuery=new m(this,()=>({...f(this.apiClient,{patient_hash:this.patientHash,page:1,per_page:3}),enabled:!!this.patientHash})),this.getOrganizationSpecialtiesQuery=new m(this,()=>d(this.apiClient)),this.handleViewAll=()=>{l.track(k(this.patientHash)),this.dispatchEvent(new C)}}static{this.styles=Q}willUpdate(i){i.has("env")&&this.env&&q(this.env),i.has("locale")&&this.locale&&t(this.locale)&&e(this.locale);const s=S(i,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale},this.inheritedApiClient);s&&(this.apiClient=s)}get patientHash(){return this.loginToken?.patient.hash??this.getPatientProfileQuery.result?.data?.hash??""}get isEmpty(){const t=this.getPatientDocumentsQuery.result;return!0===t?.isSuccess&&0===(t.data?.data?.length??0)}updated(){this.toggleAttribute("empty",this.isEmpty)}specialtyNameOf(t){const e=this.getOrganizationSpecialtiesQuery.result?.data?.find(e=>Number(e.id)===Number(t));return g(e?.code??"",i(),e?.name)}renderDocuments(){return this.getPatientDocumentsQuery.render({complete:t=>0===t.data.length?b`<home-widget-empty-state icon="document" heading="${c("No tienes documentación")}" description="${c("Aquí se mostrarán tus recetas e informes médicos.")}"></home-widget-empty-state>`:b`${t.data.map((e,i)=>b`<document-row documentId="${e.document_id}" kind="${e.document_type}" name="${e.name}" specialty="${this.specialtyNameOf(e.professional.speciality_id)}" date="${e.created_at}" downloadUrl="${e.url}" patientHash="${this.patientHash}"></document-row>${i<t.data.length-1?b`<div class="divider"></div>`:x}`)}`,pending:()=>b`${Array.from({length:3}).map((t,e)=>b`<mq-skeleton height="${A}"></mq-skeleton>${e<2?b`<div class="divider"></div>`:x}`)}`,error:()=>b`<home-widget-empty-state icon="document" heading="${c("No hemos podido cargar tu documentación")}" description="${c("Vuelve a intentarlo en unos minutos.")}"></home-widget-empty-state>`})}render(){return b`<section-header heading="${c("Documentos recientes")}" action-label="${c("Ver todas")}" @section-action="${this.handleViewAll}"></section-header><div class="card">${this.renderDocuments()}</div>`}};o([w({type:String,attribute:"api-key"})],H.prototype,"apiKey",void 0),o([w({type:String,attribute:"token"})],H.prototype,"token",void 0),o([w({type:String,attribute:"locale"})],H.prototype,"locale",void 0),o([w({type:String,attribute:"env"})],H.prototype,"env",void 0),o([a({context:h,subscribe:!0}),$()],H.prototype,"inheritedApiClient",void 0),o([r({context:h}),$()],H.prototype,"apiClient",void 0),o([a({context:u,subscribe:!0})],H.prototype,"loginToken",void 0),H=o([p(),n("mq-recent-documents")],H),s();export{H as MqRecentDocuments,C as MqViewDocumentsEvent};
|
|
@@ -1,21 +1,24 @@
|
|
|
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
5
|
import { Env } from './env.js';
|
|
5
6
|
import './ui/mq-callout.js';
|
|
6
7
|
import './ui/mq-button.js';
|
|
7
8
|
import './chunks/professional-overview-mO3tuMuH.js';
|
|
8
9
|
import './chunks/appointment-details-CVEDe_k0.js';
|
|
9
|
-
import './chunks/mq-chat-room-
|
|
10
|
+
import './chunks/mq-chat-room-t3j3Tq4o.js';
|
|
10
11
|
import './ui/mq-floating-bubble.js';
|
|
11
12
|
import './ui/mq-unread-badge.js';
|
|
12
13
|
import './ui/mq-skeleton.js';
|
|
13
14
|
import './ui/mq-card.js';
|
|
14
15
|
import { QueryClient } from '@tanstack/query-core';
|
|
16
|
+
import 'axios';
|
|
17
|
+
import 'zod';
|
|
18
|
+
import './chunks/schemas.d-b6_AekBb.js';
|
|
15
19
|
import './ui/mq-text-button.js';
|
|
16
20
|
import './ui/mq-avatar.js';
|
|
17
21
|
import './chunks/appointment.model.d-BWwBLaEL.js';
|
|
18
|
-
import 'zod';
|
|
19
22
|
|
|
20
23
|
declare class MqScheduleSuccessSkeleton extends LitElement {
|
|
21
24
|
static styles: lit.CSSResult;
|
|
@@ -69,6 +72,13 @@ declare class MqScheduleSuccess extends LitElement {
|
|
|
69
72
|
private get _accessToken();
|
|
70
73
|
private get _timezone();
|
|
71
74
|
private _trackedPageView;
|
|
75
|
+
/** The organization scope this element was mounted under, if any. */
|
|
76
|
+
private inheritedApiClient?;
|
|
77
|
+
/**
|
|
78
|
+
* This element's own transport, bound to its `api-key` and provided to every
|
|
79
|
+
* descendant. Never shared with another element.
|
|
80
|
+
*/
|
|
81
|
+
apiClient: MediquoApiChatClient;
|
|
72
82
|
protected willUpdate(changed: PropertyValues<this>): void;
|
|
73
83
|
private getPatientProfileQuery;
|
|
74
84
|
private getAppointmentQuery;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{isValidLocale as t,setLocale as e,getLocale as i,initLocalization as o}from"./i18n.js";import{_ as n,c as a}from"./chunks/custom-element-D2ziPxYE.js";import{m as s,s as r}from"./chunks/runtime-Bg1WXVCx.js";import{l as c}from"./chunks/localized-decorator-BlOuLhym.js";import{i as
|
|
1
|
+
import{isValidLocale as t,setLocale as e,getLocale as i,initLocalization as o}from"./i18n.js";import{_ as n,c as a}from"./chunks/custom-element-D2ziPxYE.js";import{m as s,s as r}from"./chunks/runtime-Bg1WXVCx.js";import{l as c}from"./chunks/localized-decorator-BlOuLhym.js";import{A as p}from"./chunks/api-client-context-V1UAGtKW.js";import{i as l,a as d,x as m,E as u}from"./chunks/lit-element-DiWJYFwC.js";import{n as h}from"./chunks/property-scuRaFcM.js";import{r as v}from"./chunks/state-LQivXIgA.js";import{setEnv as g}from"./env.js";import{MqViewAppointmentsEvent as f,MqHomeEvent as k}from"./events.js";import{c as b,A as y,n as x,C as j}from"./chunks/api-chat-client-pGZWREjK.js";import{checkIcon as w}from"./ui/icons/check-icon.js";import"./ui/mq-callout.js";import"./ui/mq-button.js";import{e as $}from"./chunks/provide-BwI4DDGF.js";import{c as q}from"./chunks/consume-CovVqBjI.js";import{l as C}from"./chunks/chunk-S5RWG6G2-DPesx3Od.js";import"./chunks/professional-overview-C4H_znIJ.js";import"./chunks/appointment-details-DXLBQnPN.js";import{Q as _}from"./chunks/query-controller-BlO1Ax65.js";import{s as S}from"./chunks/chunk-6CCJWPGL-TiaqZaPV.js";import{g as I}from"./chunks/get-appointment-query-C-gTTuiQ.js";import{g as z}from"./chunks/get-patient-profile-query-4AO6xvVn.js";import{g as A}from"./chunks/chunk-Y4EKUX25-QqMl3eiq.js";import{a as Q}from"./chunks/chunk-HN62IQ7S-xbkIy7k_.js";import{calendarIcon as O}from"./ui/icons/calendar-icon.js";import{chatbubbleIcon as T}from"./ui/icons/chat-bubble-icon.js";import{videoIcon as P}from"./ui/icons/video-icon.js";import"./mq-chat-room.js";import"./ui/mq-floating-bubble.js";import"./ui/mq-unread-badge.js";import{g as E,t as N,m as V,a as H,n as B,o as U,p as F}from"./chunks/telemetry-client-CoWay8es.js";import{f as G}from"./chunks/price-DU3YLTpk.js";import"./ui/mq-skeleton.js";import"./ui/mq-card.js";import{Q as M}from"./chunks/chunk-RCFIJTXZ-C6Ir0-sM.js";import{a as R}from"./chunks/addSeconds-ofMnxlgT.js";import"./chunks/chunk-4FFT6DC2-CVWibomC.js";import"./chunks/external-CJj32K_p.js";import"./chunks/create-context-DqP79qjF.js";import"./chunks/isBefore-CPpTogxo.js";import"./chunks/parseISO-Dj3qSTG8.js";import"./ui/icons/types.js";import"./ui/icons/info-circle-outine-icon.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./chunks/if-defined-BYeVdwgd.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-consumer-ESdICVAb.js";import"./ui/icons/chevron-down-icon.js";import"./ui/mq-text-button.js";import"./ui/mq-avatar.js";import"./ui/icons/briefcase-icon.js";import"./ui/icons/clock-icon.js";import"./ui/icons/message-bubble-icon.js";import"./ui/icons/phone-icon.js";import"./chunks/query-Cjvi4_dT.js";import"./chunks/format-CRFiCNHw.js";import"./theme.js";import"./ui/icons/x-icon.js";import"./chunks/chunk-BUV4MGML-CkhBbfUu.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./ui/icons/check-double-icon.js";import"./chunks/chunk-YTQUGGS3-DmCGIoFy.js";import"./chunks/mutation-controller-CR2qcqhH.js";import"./chunks/style-map-CIdqdn7C.js";const K=l`header{padding:var(--sp-6) var(--sp-4);display:flex;align-items:center;gap:var(--sp-2);max-width:var(--content-max-width);margin:0 auto}.summary{padding:var(--sp-6) var(--sp-4);background-color:var(--color-neutrals-background-weak);max-width:var(--content-max-width);margin:0 auto}.summary-content{display:flex;flex-direction:column;gap:var(--sp-4)}.manage-appointment{box-sizing:border-box;max-width:var(--content-max-width);margin:0 auto}`;let L=class MqScheduleSuccessSkeleton extends d{static{this.styles=K}render(){return m`<div><header><mq-skeleton width="220px" height="40px" border-radius="md"></mq-skeleton></header><div class="summary"><div class="summary-content"><mq-skeleton width="280px" height="32px" border-radius="md"></mq-skeleton><mq-skeleton width="100%" height="400px" border-radius="lg"></mq-skeleton><mq-skeleton width="100%" height="80px" border-radius="lg"></mq-skeleton></div></div><div class="manage-appointment"><mq-skeleton width="100%" height="313px" border-radius="lg"></mq-skeleton></div></div>`}};L=n([a("mq-schedule-success-skeleton")],L);const D=l`.success-title{display:flex;align-items:center;gap:var(--sp-2);margin-bottom:var(--sp-4)}header h1{font-family:var(--font-titles);font-size:var(--text-3xl);line-height:var(--text-3xl--line-height);font-weight:var(--font-weight-bold);margin:0}h2{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);margin:0;margin-bottom:var(--sp-6)}.summary{padding:var(--sp-6) var(--sp-4)}.professional-card{padding:var(--sp-4)}.appointment-summary{margin-bottom:var(--sp-2);display:flex;flex-direction:column;gap:var(--sp-4)}.add-to-calendar-container{padding-top:var(--sp-4);border-top:1px solid var(--color-neutrals-border-disabled)}.price-breakdown{display:flex;flex-direction:column;gap:var(--sp-2)}.price-row{display:flex;justify-content:space-between;gap:var(--sp-4);font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-default)}.price-row--total{font-weight:var(--font-weight-semibold)}.price-breakdown hr{width:100%;border:none;border-top:1px solid var(--color-neutrals-border-disabled);margin:var(--sp-1) 0}.floating-content{height:100%}.actions{display:flex;flex-direction:column;gap:var(--sp-4)}@media (min-width:768px){.actions{flex-direction:row}}.footer-cta{margin-top:var(--sp-4);padding:var(--sp-6) var(--sp-4)}.footer-cta h2{margin-bottom:var(--sp-2)}.footer-cta .description{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 0 var(--sp-6)}.footer-cta .actions{display:flex;flex-direction:column;gap:var(--sp-3)}`;class OpenVideocallEvent extends Event{static{this.eventName="open-videocall"}constructor(t){super(OpenVideocallEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}let W=class MqScheduleSuccess extends d{constructor(){super(...arguments),this.kind="schedule",this.showNavCtas=!1,this._trackedPageView=!1,this.apiClient=b(),this.getPatientProfileQuery=new _(this,()=>z(this.apiClient)),this.getAppointmentQuery=new _(this,()=>I(this.apiClient,{id:this.appointmentId})),this.getCouponQuery=new _(this,()=>{return t=this.apiClient,e={appointmentId:this.appointmentId},i={enabled:!!this.appointmentId},{queryKey:S(t,"appointment-consultation-coupon",e.appointmentId),queryFn:()=>t.payments.getAppointmentConsultationCoupon(e.appointmentId),retry:!1,...i};var t,e,i}),this.getOrganizationSpecialtiesQuery=new _(this,()=>E(this.apiClient)),this.isChatOpen=!1,this.unreadQuery=new _(this,()=>A(this.apiClient,{roomId:Number(this.getAppointmentQuery.result?.data?.room_id)},{enabled:!!this.getAppointmentQuery.result?.data?.room_id})),this._getCalloutText=t=>{switch(t.channel){case y.videocall:return s("Te enviaremos un enlace al email indicado cuando sea el momento de conectarte a la vídeoconsulta. Asegúrate de tener buena conexión a internet y un dispositivo con cámara y micrófono.");case y.phonecall:return s(r`El profesional te llamará al
|
|
2
2
|
${this.getPatientProfileQuery.result?.data?.profile.phone??""} en el horario
|
|
3
3
|
seleccionado. Asegúrate de tener buena cobertura y poder atender en
|
|
4
|
-
el horario elegido.`);case
|
|
4
|
+
el horario elegido.`);case y.chat:return s("El profesional te enviará un mensaje para que podamos coordinar la cita. Asegúrate de tener buena cobertura y poder atender en el horario elegido.");default:return u}}}static{this.styles=D}get _accessToken(){return this.token??this.loginToken?.access_token}get _timezone(){return this.timezone||Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}willUpdate(i){i.has("env")&&this.env&&g(this.env),i.has("locale")&&this.locale&&t(this.locale)&&e(this.locale);const o=x(i,{env:this.env,apiKey:this.apiKey,token:this.token,locale:this.locale},this.inheritedApiClient);o&&(this.apiClient=o)}get _patientHash(){return this.getPatientProfileQuery.result?.data?.hash??""}connectedCallback(){super.connectedCallback(),this.queryClientContext?.invalidateQueries()}updated(){!this._trackedPageView&&this._patientHash&&(this._trackedPageView=!0,N.track(V(this._patientHash,this.appointmentId)))}renderPriceBreakdown(t,e,i){const o=t.price;if(null==o||o<=0)return u;const n=t.currency??"EUR",a=t.discount_amount??0,r=a>0,c=o-a,p=this.getCouponQuery.result?.data,l=p?.name??p?.code,d=r?p?.percent_off??Math.round(a/o*100):0,h=l?`${s("Promoción")} ${l}`:s("Promoción");return m`<div class="price-breakdown"><div class="price-row"><span>${i}</span> <span>${G({amount:o,currency:n},e)}</span></div>${r?m`<div class="price-row"><span>${h} (-${d}%)</span> <span>${G({amount:-a,currency:n},e)}</span></div><hr><div class="price-row price-row--total"><span>${s("Total")}</span> <span>${G({amount:c,currency:n},e)}</span></div>`:u}</div>`}render(){return this.getAppointmentQuery.render({pending:()=>m`<mq-schedule-success-skeleton></mq-schedule-success-skeleton>`,complete:t=>{const e=i(),o=Q(t.start_date),n=R(o,t.duration),a=this.getOrganizationSpecialtiesQuery.result?.data?.find(e=>e.id===Number(t.speciality_id)),c=H(a?.code??"",e,a?.name),p=t.channel===y.videocall,l=t.channel===y.phonecall,d=!0===t.has_chat_in_appointment,h=(p||l)&&d,v=this._accessToken;return m`<div><header><div class="success-title">${w()}<h1>${"schedule"===this.kind?s("Cita confirmada"):s("Cita modificada")}</h1></div><h2>${s(r`Resumen de la cita para ${t?.to?.name??""}`)}</h2></header><mq-card class="summary" roundness="md"><div class="appointment-summary"><professional-overview .name="${t.from.name??""}" .specialtyName="${c}" .collegiateNumber="${t.from.collegiate_number??void 0}" .description="${t.from.description??""}" .languages="${t.from.languages??[]}" .avatar="${t.from.avatar??""}" always-expanded-on-desktop></professional-overview><appointment-details .startsAt="${o.toISOString()}" .duration="${t.duration}" .channel="${t.channel}" .timezone="${this._timezone}"></appointment-details>${this.renderPriceBreakdown(t,e,c||s("Consulta"))}<div class="add-to-calendar-container"><mq-text-button fontWeight="bold" size="sm" @click="${()=>{N.track(B(this._patientHash,this.appointmentId));const e=function({title:t,description:e,startsAt:i,endsAt:o}){const n=t=>t.toISOString().replace(/[-:]/g,"").replace(/\.\d{3}/,""),a=n(i),s=n(o);return`https://www.google.com/calendar/render?${new URLSearchParams({action:"TEMPLATE",text:t,dates:`${a}/${s}`,...e&&{details:e}}).toString()}`}({title:s(r`Cita agendada de ${t.from.speciality??""}`),startsAt:o,endsAt:n,description:p&&t.consultation_short_url?s(r`Enlace a la cita: ${t.consultation_short_url}`):void 0});window.open(e,"_blank")}}">${O({size:24})} ${s("Añadir al calendario")}</mq-text-button></div>${h||p?m`<div class="actions">${h?m`<mq-button variant="primary" fullwidth size="md" @click="${()=>{N.track(U(this._patientHash,this.appointmentId)),this.isChatOpen=!this.isChatOpen}}">${T({size:24})} ${s("Chatear con el profesional")} ${(this.unreadQuery.result?.data?.unread_count??0)>0?m`<mq-unread-badge></mq-unread-badge>`:u}</mq-button>`:u} ${p?m`<mq-button variant="outline" fullwidth size="md" @click="${()=>{N.track(F(this._patientHash,this.appointmentId)),this.dispatchEvent(new OpenVideocallEvent({appointmentId:this.appointmentId}))}}">${P({size:24})} ${s("Ir a videollamada")}</mq-button>`:u}</div>`:u}</div><mq-callout background="default" variant="info" ?noPadding="${!(h||p)}">${this._getCalloutText(t)}</mq-callout></mq-card>${this.showNavCtas?m`<mq-card class="footer-cta" roundness="md"><h2>${s("Tus citas")}</h2><p class="description">${s("Accede, modifica o anula tus citas.")}</p><div class="actions"><mq-button variant="primary" size="md" fullwidth @click="${()=>{this.dispatchEvent(new f({tab:"next"}))}}">${s("Ver mis citas")}</mq-button><mq-button variant="outline" size="md" fullwidth @click="${()=>{this.dispatchEvent(new k)}}">${s("Volver al inicio")}</mq-button></div></mq-card>`:u}</div><mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" @mq-close="${()=>{this.isChatOpen=!1}}" hideCloseButton>${this.isChatOpen&&v?m`<div slot="content" class="floating-content"><mq-chat-room .consultationId="${t.id}" .consultationType="${j.appointment}" .token="${v}" .roomId="${Number(t.room_id)}" .professionalHash="${t.from.hash}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}"></mq-chat-room></div>`:u}</mq-floating-bubble>`}})}};n([h({type:String})],W.prototype,"kind",void 0),n([h({type:String})],W.prototype,"appointmentId",void 0),n([h({type:String,attribute:"api-key"})],W.prototype,"apiKey",void 0),n([h({type:String,attribute:"token"})],W.prototype,"token",void 0),n([h({type:String,attribute:"timezone"})],W.prototype,"timezone",void 0),n([h({type:String,attribute:"locale"})],W.prototype,"locale",void 0),n([h({type:String,attribute:"env"})],W.prototype,"env",void 0),n([h({type:Boolean,attribute:"show-nav-ctas"})],W.prototype,"showNavCtas",void 0),n([q({context:M,subscribe:!0})],W.prototype,"queryClientContext",void 0),n([q({context:C})],W.prototype,"loginToken",void 0),n([q({context:p,subscribe:!0}),v()],W.prototype,"inheritedApiClient",void 0),n([$({context:p}),v()],W.prototype,"apiClient",void 0),n([v()],W.prototype,"isChatOpen",void 0),W=n([c(),a("mq-schedule-success")],W),o();export{W as MqScheduleSuccess,OpenVideocallEvent};
|