@mediquo/elements 0.3.2 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. package/dist/chunks/{api-chat-client-BTBtu01T.js → api-chat-client-C8SqZtCa.js} +1 -1
  2. package/dist/chunks/{apple-pay-outcomes-BlytM6W-.js → apple-pay-outcomes-BNkcTbbM.js} +1 -1
  3. package/dist/chunks/create-component-BB-6Gu6l.js +1 -0
  4. package/dist/chunks/exports-G_7Ih_GH.js +1 -0
  5. package/dist/chunks/{index-B9iWdvW3.js → index-BJcdB5MT.js} +1 -1
  6. package/dist/chunks/index-DiqYAEHW.js +1 -0
  7. package/dist/chunks/{mq-layout-DpzeL9_i.js → mq-layout-CpIZTsV2.js} +1 -1
  8. package/dist/chunks/{price-Dtdjx70D.js → price-tImUmtpX.js} +1 -1
  9. package/dist/chunks/{refund-cancel-policy-Bm5djPds.js → refund-cancel-policy-CnbrIqH0.js} +1 -1
  10. package/dist/chunks/{telemetry-client-CKCb9Gnf.js → telemetry-client-BRVJU-fZ.js} +1 -1
  11. package/dist/env.js +1 -1
  12. package/dist/i18n.js +1 -1
  13. package/dist/mq-apple-pay-checkout.js +1 -1
  14. package/dist/mq-appointment-checkout.js +1 -1
  15. package/dist/mq-chat-room.js +1 -1
  16. package/dist/mq-checkout.js +1 -1
  17. package/dist/mq-google-pay-checkout.js +1 -1
  18. package/dist/mq-immediate-videocall-checkout.js +1 -1
  19. package/dist/mq-my-appointments.js +1 -1
  20. package/dist/mq-schedule-success.js +2 -2
  21. package/dist/mq-schedule.d.ts +2 -2
  22. package/dist/mq-schedule.js +1 -1
  23. package/dist/mq-socket-provider.js +1 -1
  24. package/dist/mq-support-chat.js +1 -1
  25. package/dist/mq-videocall.js +1 -1
  26. package/dist/react/mq-apple-pay-checkout.d.ts +15 -0
  27. package/dist/react/mq-apple-pay-checkout.js +2 -0
  28. package/dist/react/mq-appointment-checkout.d.ts +17 -0
  29. package/dist/react/mq-appointment-checkout.js +2 -0
  30. package/dist/react/mq-chat-room.d.ts +19 -0
  31. package/dist/react/mq-chat-room.js +2 -0
  32. package/dist/react/mq-checkout.d.ts +18 -0
  33. package/dist/react/mq-checkout.js +2 -0
  34. package/dist/react/mq-google-pay-checkout.d.ts +15 -0
  35. package/dist/react/mq-google-pay-checkout.js +2 -0
  36. package/dist/react/mq-immediate-videocall-checkout.d.ts +16 -0
  37. package/dist/react/mq-immediate-videocall-checkout.js +2 -0
  38. package/dist/react/mq-my-appointments.d.ts +29 -0
  39. package/dist/react/mq-my-appointments.js +2 -0
  40. package/dist/react/mq-query-client-provider.d.ts +8 -0
  41. package/dist/react/mq-query-client-provider.js +2 -0
  42. package/dist/react/mq-schedule-success.d.ts +26 -0
  43. package/dist/react/mq-schedule-success.js +2 -0
  44. package/dist/react/mq-schedule.d.ts +31 -0
  45. package/dist/react/mq-schedule.js +2 -0
  46. package/dist/react/mq-socket-provider.d.ts +9 -0
  47. package/dist/react/mq-socket-provider.js +2 -0
  48. package/dist/react/mq-support-chat.d.ts +15 -0
  49. package/dist/react/mq-support-chat.js +2 -0
  50. package/dist/react/mq-theme-provider.d.ts +8 -0
  51. package/dist/react/mq-theme-provider.js +2 -0
  52. package/dist/react/mq-videocall.d.ts +25 -0
  53. package/dist/react/mq-videocall.js +2 -0
  54. package/dist/ui/mq-calendar.js +1 -1
  55. package/dist/ui/mq-clamped-text.js +1 -1
  56. package/dist/ui/mq-toast.js +1 -1
  57. package/package.json +25 -4
  58. package/dist/chunks/exports-XZaVrMLd.js +0 -1
  59. package/dist/chunks/index-BYHKNPG2.js +0 -1
package/dist/env.js CHANGED
@@ -1 +1 @@
1
- const E="https://mediquo-landing.s3.eu-central-1.amazonaws.com/sdk-web/elements",o="production",e="0.3.2",n={development:{MODE:"development",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"47836441",ASSETS_BASE_URL:E},production:{MODE:"production",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"46655102",ASSETS_BASE_URL:E}};let t=o;const _=new Proxy({},{get:(E,o)=>n[t??"production"][o]});function S(E){t=E}export{E as ASSETS_BASE_URL,_ as env,S as setEnv};
1
+ const E="https://mediquo-landing.s3.eu-central-1.amazonaws.com/sdk-web/elements",o="production",e="0.4.0",n={development:{MODE:"development",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"47836441",ASSETS_BASE_URL:E},production:{MODE:"production",MQ_DEFAULT_ENV:o,MQ_ELEMENTS_VERSION:e,OPENTOK_API_KEY:"46655102",ASSETS_BASE_URL:E}};let t=o;const _=new Proxy({},{get:(E,o)=>n[t??"production"][o]});function S(E){t=E}export{E as ASSETS_BASE_URL,_ as env,S as setEnv};
package/dist/i18n.js CHANGED
@@ -1 +1 @@
1
- import{c as e}from"./chunks/runtime-Bg1WXVCx.js";import{z as t,l as n}from"./chunks/external-zAbuzxDj.js";const c=["ca_ES","de_DE","en_US","pt_PT"],s=t.enum(["en_US","pt_PT","de_DE","es_ES","ca_ES"]);function a(e){return s.safeParse(e).success}const o="__mqElementsLocalization__";function i(){const e=globalThis;return e[o]||(e[o]={initialized:!1}),e[o]}function r(){const t=i();if(!t.initialized){t.initialized=!0;try{const{setLocale:n,getLocale:s}=e({sourceLocale:"es_ES",targetLocales:c,loadLocale:async e=>{switch(e){case"en_US":default:return import("./chunks/en_US-BslWF9nj.js");case"pt_PT":return import("./chunks/pt_PT-CFbbWowX.js");case"de_DE":return import("./chunks/de_DE-CrwfSJnS.js");case"ca_ES":return import("./chunks/ca_ES-nttMFJzr.js")}}});t.setLocale=n,t.getLocale=s}catch(e){n.warn("Localization was already configured on this page.",e)}}}const u="Localization not initialized yet.";async function l(e){const{setLocale:t}=i();if(t)return t(e);n.warn(u)}function _(){const{getLocale:e}=i();return e?e():(n.warn(u),"es_ES")}export{_ as getLocale,r as initLocalization,a as isValidLocale,l as setLocale};
1
+ import{c as e}from"./chunks/runtime-Bg1WXVCx.js";import{z as t,l as n}from"./chunks/external-zAbuzxDj.js";const c=["ca_ES","de_DE","en_US","pt_PT"],a=t.enum(["en_US","pt_PT","de_DE","es_ES","ca_ES"]);function s(e){return a.safeParse(e).success}const o="__mqElementsLocalization__";function i(){const e=globalThis;return e[o]||(e[o]={initialized:!1}),e[o]}function r(){const t=i();if(!t.initialized){t.initialized=!0;try{const{setLocale:n,getLocale:a}=e({sourceLocale:"es_ES",targetLocales:c,loadLocale:async e=>{switch(e){case"en_US":default:return import("./chunks/en_US-BslWF9nj.js");case"pt_PT":return import("./chunks/pt_PT-CFbbWowX.js");case"de_DE":return import("./chunks/de_DE-CrwfSJnS.js");case"ca_ES":return import("./chunks/ca_ES-nttMFJzr.js")}}});t.setLocale=n,t.getLocale=a}catch(e){n.warn("Localization was already configured on this page.",e)}}}const u="Localization not initialized yet.";async function l(e){const{setLocale:t}=i();if(t)return t(e);n.warn(u)}function _(){const{getLocale:e}=i();return e?e():(n.warn(u),"es_ES")}export{_ as getLocale,r as initLocalization,s as isValidLocale,l as setLocale};
@@ -1 +1 @@
1
- import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{m as a}from"./chunks/runtime-Bg1WXVCx.js";import{l as s}from"./chunks/parseISO-jT42c8Ob.js";import{L as i}from"./chunks/login-token-task-BI-L2zSV.js";import{l as n}from"./chunks/external-zAbuzxDj.js";import{i as o,a as r,x as p}from"./chunks/lit-element-DiWJYFwC.js";import{n as l}from"./chunks/property-scuRaFcM.js";import{r as c}from"./chunks/state-LQivXIgA.js";import{setEnv as h}from"./env.js";import{initLocalization as u,isValidLocale as y,setLocale as d}from"./i18n.js";import{a as m}from"./chunks/api-chat-client-BTBtu01T.js";import{u as v,s as b,r as f}from"./chunks/apple-pay-outcomes-BlytM6W-.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";function k(){if("undefined"==typeof navigator)return!1;const e=navigator.userAgent;return/Safari/i.test(e)&&!/Chrome|Chromium|Edg|OPR|Firefox|FxiOS/i.test(e)}async function P(e){if("undefined"==typeof window||!window.isSecureContext)return{available:!1,reason:"unsupported"};if(!function(){if("undefined"==typeof window)return!1;const e="undefined"!=typeof ApplePaySession&&"function"==typeof ApplePaySession.canMakePayments,t="undefined"!=typeof customElements&&void 0!==customElements.get("apple-pay-button");return e&&t}())return{available:!1,reason:"sdk-missing"};if(!e.trim())return{available:!1,reason:"merchant-id-missing"};const t=ApplePaySession;if(function(e){return"function"==typeof e.applePayCapabilities}(t))try{return function(e){switch(e){case"applePayUnsupported":return{available:!1,reason:"unsupported"};case"paymentCredentialsUnavailable":case"paymentCredentialsAvailable":case"paymentCredentialStatusUnknown":return{available:!0,usesQrFlow:!k()}}}((await t.applePayCapabilities(e)).paymentCredentialStatus)}catch{return t.canMakePayments()?{available:!0,usesQrFlow:!k()}:{available:!1,reason:"unsupported"}}return t.canMakePayments()?{available:!0,usesQrFlow:!k()}:{available:!1,reason:"unsupported"}}const g={es_ES:"es-ES",en_US:"en-US",pt_PT:"pt-PT",de_DE:"de-DE",ca_ES:"ca-ES"};try{u()}catch{}const E=["visa","masterCard","amex"],_=["supports3DS"],S=o`:host{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:12px;width:100%;min-height:48px}.helper{margin:0;text-align:center;font-family:system-ui,sans-serif;font-size:13px;line-height:1.4;color:#6e6e73}.pay-row{display:block;width:100%}.pay-row--paying{opacity:.55;pointer-events:none}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:48px;--apple-pay-button-border-radius:10px;--apple-pay-button-padding:0;display:block;width:100%;min-height:48px;cursor:pointer}.state{text-align:center;font-family:system-ui,sans-serif;font-size:15px;color:#86868b;margin:0}`;class ApplePayCheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(ApplePayCheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(e){super(ApplePayCheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(e){super(ApplePayCheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}function A(e,t){n.warn(e,{error:t instanceof Error?t.message:String(t)})}let w=class MqApplePayCheckout extends r{constructor(){super(...arguments),this._availabilityPhase="checking",this._showQrHelper=!1,this._paying=!1,this._suppressCancelEvent=!1,this._availabilityGeneration=0,this._loginTokenTask=new i(this,m,{args:()=>[this.apiKey,this.token],onComplete:e=>{m.setAuthToken(e.access_token),this._refreshAvailability()},onError:()=>{this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"auth"}))}}),this._onPayClick=()=>{if(this._paying||"ready"!==this._availabilityPhase)return;let e;try{e=new ApplePaySession(3,this._buildPaymentRequest())}catch(e){return A("mq-apple-pay-checkout: failed to create ApplePaySession",e),void this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}this._paying=!0,this._suppressCancelEvent=!1,e.onvalidatemerchant=async t=>{try{const a=await m.payments.validateApplePayMerchant({order_id:this.sessionId,validation_url:t.validationURL});e.completeMerchantValidation(v(a))}catch(t){A("mq-apple-pay-checkout: validate-merchant failed",t),this._suppressCancelEvent=!0,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"merchant"})),e.abort(),this._paying=!1}},e.onpaymentauthorized=async t=>{try{const a=await m.payments.authorizeApplePay({order_id:this.sessionId,token:b(t.payment.token)}),{status:s,consultation_id:i}=a.data,n=f(s,i,this.sessionId);switch(n.kind){case"success":e.completePayment(ApplePaySession.STATUS_SUCCESS),this.dispatchEvent(new ApplePayCheckoutSuccessEvent({sessionId:n.sessionId,reference:n.reference}));break;case"denied":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutDeniedEvent({sessionId:n.sessionId}));break;case"error":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:n.reason}))}}catch(t){A("mq-apple-pay-checkout: authorize failed",t),e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"authorize"}))}finally{this._paying=!1}},e.oncancel=()=>{this._paying=!1,this._suppressCancelEvent?this._suppressCancelEvent=!1:this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"cancelled"}))};try{e.begin()}catch(e){A("mq-apple-pay-checkout: session.begin() failed",e),this._paying=!1,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}}}static{this.styles=S}willUpdate(e){if(e.has("env")&&this.env&&h(this.env),e.has("apiKey")&&m.setApiKey(this.apiKey),e.has("locale")){const e=y(this.locale)?this.locale:"es_ES";d(e),m.setLanguage(e)}e.has("merchantId")&&this._loginTokenTask.value&&this._refreshAvailability()}async _refreshAvailability(){const e=++this._availabilityGeneration;this._availabilityPhase="checking",this._showQrHelper=!1;const t=await P(this.merchantId??"");e===this._availabilityGeneration&&(t.available?(this._availabilityPhase="ready",this._showQrHelper=t.usesQrFlow):this._availabilityPhase="unavailable")}get _resolvedLocale(){return y(this.locale)?this.locale:"es_ES"}_buildPaymentRequest(){return{countryCode:this.country,currencyCode:this.currency,supportedNetworks:[...E],merchantCapabilities:[..._],total:{label:this.label,amount:this.amount}}}_renderUnavailable(){return this.merchantId?.trim()?"undefined"==typeof ApplePaySession?p`<p class="state">${a("No se ha podido cargar Apple Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`:p`<p class="state">${a("Apple Pay no está disponible")}</p>`:p`<p class="state">${a("Falta el identificador de comercio de Apple Pay")}</p>`}render(){return this._loginTokenTask.render({pending:()=>p`<p class="state">${a("Preparando Apple Pay…")}</p>`,error:()=>p`<p class="state">${a("No hemos podido iniciar el pago")}</p>`,complete:()=>{return"checking"===this._availabilityPhase?p`<p class="state">${a("Comprobando Apple Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():p`${this._showQrHelper?p`<p class="helper">${a("Para pagar con Apple Pay, escanea el código QR con tu iPhone (iOS 18 o posterior) y confirma el pago.")}</p>`:null}<div class="pay-row ${this._paying?"pay-row--paying":""}"><apple-pay-button buttonstyle="black" type="pay" locale="${e=this._resolvedLocale,g[e]??"es-ES"}" aria-label="${a("Pagar con Apple Pay")}" @click="${this._onPayClick}"></apple-pay-button></div>`;var e}})}};e([l({type:String,attribute:"env"})],w.prototype,"env",void 0),e([l({type:String,attribute:"api-key"})],w.prototype,"apiKey",void 0),e([l({type:String,attribute:"token"})],w.prototype,"token",void 0),e([l({type:String,attribute:"locale",reflect:!0})],w.prototype,"locale",void 0),e([l({type:String,attribute:"merchant-id"})],w.prototype,"merchantId",void 0),e([l({type:String,attribute:"session-id"})],w.prototype,"sessionId",void 0),e([l({type:String,attribute:"amount"})],w.prototype,"amount",void 0),e([l({type:String,attribute:"currency"})],w.prototype,"currency",void 0),e([l({type:String,attribute:"country"})],w.prototype,"country",void 0),e([l({type:String,attribute:"label"})],w.prototype,"label",void 0),e([c()],w.prototype,"_availabilityPhase",void 0),e([c()],w.prototype,"_showQrHelper",void 0),e([c()],w.prototype,"_paying",void 0),w=e([s(),t("mq-apple-pay-checkout")],w);export{ApplePayCheckoutDeniedEvent,ApplePayCheckoutErrorEvent,ApplePayCheckoutSuccessEvent,w as MqApplePayCheckout};
1
+ import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{m as a}from"./chunks/runtime-Bg1WXVCx.js";import{l as s}from"./chunks/parseISO-jT42c8Ob.js";import{L as i}from"./chunks/login-token-task-BI-L2zSV.js";import{l as n}from"./chunks/external-zAbuzxDj.js";import{i as o,a as r,x as p}from"./chunks/lit-element-DiWJYFwC.js";import{n as l}from"./chunks/property-scuRaFcM.js";import{r as c}from"./chunks/state-LQivXIgA.js";import{setEnv as h}from"./env.js";import{initLocalization as u,isValidLocale as y,setLocale as d}from"./i18n.js";import{b as m}from"./chunks/api-chat-client-C8SqZtCa.js";import{u as v,s as b,r as f}from"./chunks/apple-pay-outcomes-BNkcTbbM.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";function k(){if("undefined"==typeof navigator)return!1;const e=navigator.userAgent;return/Safari/i.test(e)&&!/Chrome|Chromium|Edg|OPR|Firefox|FxiOS/i.test(e)}async function P(e){if("undefined"==typeof window||!window.isSecureContext)return{available:!1,reason:"unsupported"};if(!function(){if("undefined"==typeof window)return!1;const e="undefined"!=typeof ApplePaySession&&"function"==typeof ApplePaySession.canMakePayments,t="undefined"!=typeof customElements&&void 0!==customElements.get("apple-pay-button");return e&&t}())return{available:!1,reason:"sdk-missing"};if(!e.trim())return{available:!1,reason:"merchant-id-missing"};const t=ApplePaySession;if(function(e){return"function"==typeof e.applePayCapabilities}(t))try{return function(e){switch(e){case"applePayUnsupported":return{available:!1,reason:"unsupported"};case"paymentCredentialsUnavailable":case"paymentCredentialsAvailable":case"paymentCredentialStatusUnknown":return{available:!0,usesQrFlow:!k()}}}((await t.applePayCapabilities(e)).paymentCredentialStatus)}catch{return t.canMakePayments()?{available:!0,usesQrFlow:!k()}:{available:!1,reason:"unsupported"}}return t.canMakePayments()?{available:!0,usesQrFlow:!k()}:{available:!1,reason:"unsupported"}}const g={es_ES:"es-ES",en_US:"en-US",pt_PT:"pt-PT",de_DE:"de-DE",ca_ES:"ca-ES"};try{u()}catch{}const E=["visa","masterCard","amex"],_=["supports3DS"],S=o`:host{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:12px;width:100%;min-height:48px}.helper{margin:0;text-align:center;font-family:system-ui,sans-serif;font-size:13px;line-height:1.4;color:#6e6e73}.pay-row{display:block;width:100%}.pay-row--paying{opacity:.55;pointer-events:none}apple-pay-button{--apple-pay-button-width:100%;--apple-pay-button-height:48px;--apple-pay-button-border-radius:10px;--apple-pay-button-padding:0;display:block;width:100%;min-height:48px;cursor:pointer}.state{text-align:center;font-family:system-ui,sans-serif;font-size:15px;color:#86868b;margin:0}`;class ApplePayCheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(ApplePayCheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(e){super(ApplePayCheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class ApplePayCheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(e){super(ApplePayCheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}function A(e,t){n.warn(e,{error:t instanceof Error?t.message:String(t)})}let w=class MqApplePayCheckout extends r{constructor(){super(...arguments),this._availabilityPhase="checking",this._showQrHelper=!1,this._paying=!1,this._suppressCancelEvent=!1,this._availabilityGeneration=0,this._loginTokenTask=new i(this,m,{args:()=>[this.apiKey,this.token],onComplete:e=>{m.setAuthToken(e.access_token),this._refreshAvailability()},onError:()=>{this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"auth"}))}}),this._onPayClick=()=>{if(this._paying||"ready"!==this._availabilityPhase)return;let e;try{e=new ApplePaySession(3,this._buildPaymentRequest())}catch(e){return A("mq-apple-pay-checkout: failed to create ApplePaySession",e),void this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}this._paying=!0,this._suppressCancelEvent=!1,e.onvalidatemerchant=async t=>{try{const a=await m.payments.validateApplePayMerchant({order_id:this.sessionId,validation_url:t.validationURL});e.completeMerchantValidation(v(a))}catch(t){A("mq-apple-pay-checkout: validate-merchant failed",t),this._suppressCancelEvent=!0,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"merchant"})),e.abort(),this._paying=!1}},e.onpaymentauthorized=async t=>{try{const a=await m.payments.authorizeApplePay({order_id:this.sessionId,token:b(t.payment.token)}),{status:s,consultation_id:i}=a.data,n=f(s,i,this.sessionId);switch(n.kind){case"success":e.completePayment(ApplePaySession.STATUS_SUCCESS),this.dispatchEvent(new ApplePayCheckoutSuccessEvent({sessionId:n.sessionId,reference:n.reference}));break;case"denied":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutDeniedEvent({sessionId:n.sessionId}));break;case"error":e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:n.reason}))}}catch(t){A("mq-apple-pay-checkout: authorize failed",t),e.completePayment(ApplePaySession.STATUS_FAILURE),this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"authorize"}))}finally{this._paying=!1}},e.oncancel=()=>{this._paying=!1,this._suppressCancelEvent?this._suppressCancelEvent=!1:this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"cancelled"}))};try{e.begin()}catch(e){A("mq-apple-pay-checkout: session.begin() failed",e),this._paying=!1,this.dispatchEvent(new ApplePayCheckoutErrorEvent({reason:"unsupported"}))}}}static{this.styles=S}willUpdate(e){if(e.has("env")&&this.env&&h(this.env),e.has("apiKey")&&m.setApiKey(this.apiKey),e.has("locale")){const e=y(this.locale)?this.locale:"es_ES";d(e),m.setLanguage(e)}e.has("merchantId")&&this._loginTokenTask.value&&this._refreshAvailability()}async _refreshAvailability(){const e=++this._availabilityGeneration;this._availabilityPhase="checking",this._showQrHelper=!1;const t=await P(this.merchantId??"");e===this._availabilityGeneration&&(t.available?(this._availabilityPhase="ready",this._showQrHelper=t.usesQrFlow):this._availabilityPhase="unavailable")}get _resolvedLocale(){return y(this.locale)?this.locale:"es_ES"}_buildPaymentRequest(){return{countryCode:this.country,currencyCode:this.currency,supportedNetworks:[...E],merchantCapabilities:[..._],total:{label:this.label,amount:this.amount}}}_renderUnavailable(){return this.merchantId?.trim()?"undefined"==typeof ApplePaySession?p`<p class="state">${a("No se ha podido cargar Apple Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`:p`<p class="state">${a("Apple Pay no está disponible")}</p>`:p`<p class="state">${a("Falta el identificador de comercio de Apple Pay")}</p>`}render(){return this._loginTokenTask.render({pending:()=>p`<p class="state">${a("Preparando Apple Pay…")}</p>`,error:()=>p`<p class="state">${a("No hemos podido iniciar el pago")}</p>`,complete:()=>{return"checking"===this._availabilityPhase?p`<p class="state">${a("Comprobando Apple Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():p`${this._showQrHelper?p`<p class="helper">${a("Para pagar con Apple Pay, escanea el código QR con tu iPhone (iOS 18 o posterior) y confirma el pago.")}</p>`:null}<div class="pay-row ${this._paying?"pay-row--paying":""}"><apple-pay-button buttonstyle="black" type="pay" locale="${e=this._resolvedLocale,g[e]??"es-ES"}" aria-label="${a("Pagar con Apple Pay")}" @click="${this._onPayClick}"></apple-pay-button></div>`;var e}})}};e([l({type:String,attribute:"env"})],w.prototype,"env",void 0),e([l({type:String,attribute:"api-key"})],w.prototype,"apiKey",void 0),e([l({type:String,attribute:"token"})],w.prototype,"token",void 0),e([l({type:String,attribute:"locale",reflect:!0})],w.prototype,"locale",void 0),e([l({type:String,attribute:"merchant-id"})],w.prototype,"merchantId",void 0),e([l({type:String,attribute:"session-id"})],w.prototype,"sessionId",void 0),e([l({type:String,attribute:"amount"})],w.prototype,"amount",void 0),e([l({type:String,attribute:"currency"})],w.prototype,"currency",void 0),e([l({type:String,attribute:"country"})],w.prototype,"country",void 0),e([l({type:String,attribute:"label"})],w.prototype,"label",void 0),e([c()],w.prototype,"_availabilityPhase",void 0),e([c()],w.prototype,"_showQrHelper",void 0),e([c()],w.prototype,"_paying",void 0),w=e([s(),t("mq-apple-pay-checkout")],w);export{ApplePayCheckoutDeniedEvent,ApplePayCheckoutErrorEvent,ApplePayCheckoutSuccessEvent,w as MqApplePayCheckout};
@@ -1 +1 @@
1
- import{_ as t,t as e}from"./chunks/custom-element-DA9Fxvxd.js";import{a as o,x as i}from"./chunks/lit-element-DiWJYFwC.js";import{n as s}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import{a as p}from"./chunks/api-chat-client-BTBtu01T.js";import"./mq-checkout.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/parseISO-jT42c8Ob.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/login-token-task-BI-L2zSV.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";class AppointmentPaidEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(AppointmentPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}let r=class MqAppointmentCheckout extends o{constructor(){super(...arguments),this._provideSession=async()=>{const t=await p.payments.createPaymentLink({slot_id:this.slotId,service_id:this.serviceId,specialty_id:this.specialtyId,consultation_reason:this.consultationReason,discount_code:this.discountCode,preconsultation_documents:this.preconsultationDocuments});return{sessionId:t.session_id,paymentUrl:t.payment_link}},this._onSuccess=t=>{t.stopPropagation(),this.dispatchEvent(new AppointmentPaidEvent({appointmentId:t.detail.reference}))}}render(){return i`<mq-checkout env="${n(this.env)}" api-key="${this.apiKey}" token="${this.token}" locale="${this.locale}" .provideSession="${this._provideSession}" @payment-success="${this._onSuccess}"></mq-checkout>`}};t([s({type:String,attribute:"env"})],r.prototype,"env",void 0),t([s({type:String,attribute:"api-key"})],r.prototype,"apiKey",void 0),t([s({type:String,attribute:"token"})],r.prototype,"token",void 0),t([s({type:String,attribute:"locale",reflect:!0})],r.prototype,"locale",void 0),t([s({type:String,attribute:"slot-id"})],r.prototype,"slotId",void 0),t([s({type:String,attribute:"service-id"})],r.prototype,"serviceId",void 0),t([s({type:String,attribute:"specialty-id"})],r.prototype,"specialtyId",void 0),t([s({type:String,attribute:"consultation-reason"})],r.prototype,"consultationReason",void 0),t([s({type:String,attribute:"discount-code"})],r.prototype,"discountCode",void 0),t([s({attribute:!1})],r.prototype,"preconsultationDocuments",void 0),r=t([e("mq-appointment-checkout")],r);export{AppointmentPaidEvent,r as MqAppointmentCheckout};
1
+ import{_ as t,t as e}from"./chunks/custom-element-DA9Fxvxd.js";import{a as i,x as o}from"./chunks/lit-element-DiWJYFwC.js";import{n as s}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import{b as p}from"./chunks/api-chat-client-C8SqZtCa.js";import"./mq-checkout.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/parseISO-jT42c8Ob.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/login-token-task-BI-L2zSV.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";class AppointmentPaidEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(AppointmentPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}let r=class MqAppointmentCheckout extends i{constructor(){super(...arguments),this._provideSession=async()=>{const t=await p.payments.createPaymentLink({slot_id:this.slotId,service_id:this.serviceId,specialty_id:this.specialtyId,consultation_reason:this.consultationReason,discount_code:this.discountCode,preconsultation_documents:this.preconsultationDocuments});return{sessionId:t.session_id,paymentUrl:t.payment_link}},this._onSuccess=t=>{t.stopPropagation(),this.dispatchEvent(new AppointmentPaidEvent({appointmentId:t.detail.reference}))}}render(){return o`<mq-checkout env="${n(this.env)}" api-key="${this.apiKey}" token="${this.token}" locale="${this.locale}" .provideSession="${this._provideSession}" @payment-success="${this._onSuccess}"></mq-checkout>`}};t([s({type:String,attribute:"env"})],r.prototype,"env",void 0),t([s({type:String,attribute:"api-key"})],r.prototype,"apiKey",void 0),t([s({type:String,attribute:"token"})],r.prototype,"token",void 0),t([s({type:String,attribute:"locale",reflect:!0})],r.prototype,"locale",void 0),t([s({type:String,attribute:"slot-id"})],r.prototype,"slotId",void 0),t([s({type:String,attribute:"service-id"})],r.prototype,"serviceId",void 0),t([s({type:String,attribute:"specialty-id"})],r.prototype,"specialtyId",void 0),t([s({type:String,attribute:"consultation-reason"})],r.prototype,"consultationReason",void 0),t([s({type:String,attribute:"discount-code"})],r.prototype,"discountCode",void 0),t([s({attribute:!1})],r.prototype,"preconsultationDocuments",void 0),r=t([e("mq-appointment-checkout")],r);export{AppointmentPaidEvent,r as MqAppointmentCheckout};
@@ -1 +1 @@
1
- export{M as MqChatRoom,b as MqChatRoomCloseEvent,c as MqChatRoomProfileEvent}from"./chunks/exports-XZaVrMLd.js";import"./chunks/custom-element-DA9Fxvxd.js";import"./chunks/provide-CfT7g_Zi.js";import"./chunks/context-provider-CiMFpvDA.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/mutation-controller-OVT8NEt6.js";import"./chunks/query-QJ1INUTG.js";import"./chunks/parseISO-jT42c8Ob.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/lit-element-DiWJYFwC.js";import"./chunks/property-scuRaFcM.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./chunks/api-chat-client-BTBtu01T.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./ui/icons/x-icon.js";import"./ui/icons/types.js";import"./ui/mq-avatar.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./ui/mq-button.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/if-defined-BYeVdwgd.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./events.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./i18n.js";import"./chunks/chunk-YTQUGGS3-DN-JZpgG.js";
1
+ export{M as MqChatRoom,b as MqChatRoomCloseEvent,c as MqChatRoomProfileEvent}from"./chunks/exports-G_7Ih_GH.js";import"./chunks/custom-element-DA9Fxvxd.js";import"./chunks/provide-CfT7g_Zi.js";import"./chunks/context-provider-CiMFpvDA.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/mutation-controller-OVT8NEt6.js";import"./chunks/query-QJ1INUTG.js";import"./chunks/parseISO-jT42c8Ob.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/lit-element-DiWJYFwC.js";import"./chunks/property-scuRaFcM.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./chunks/api-chat-client-C8SqZtCa.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./ui/icons/x-icon.js";import"./ui/icons/types.js";import"./ui/mq-avatar.js";import"./chunks/class-map-Co76I6aw.js";import"./chunks/directive-2EDmOukv.js";import"./ui/mq-button.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/if-defined-BYeVdwgd.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./events.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./i18n.js";import"./chunks/chunk-YTQUGGS3-DN-JZpgG.js";
@@ -1 +1 @@
1
- import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{m as s}from"./chunks/runtime-Bg1WXVCx.js";import{l as i}from"./chunks/parseISO-jT42c8Ob.js";import{h as o}from"./chunks/task-Bj8p7kJX.js";import{a as n,P as r}from"./chunks/api-chat-client-BTBtu01T.js";import{L as a}from"./chunks/login-token-task-BI-L2zSV.js";import{l as h}from"./chunks/external-zAbuzxDj.js";import{i as d,a as l,x as c}from"./chunks/lit-element-DiWJYFwC.js";import{n as p}from"./chunks/property-scuRaFcM.js";import{r as m}from"./chunks/state-LQivXIgA.js";import{setEnv as u}from"./env.js";import{tokens as v}from"./theme.js";import{initLocalization as _,isValidLocale as f,setLocale as y}from"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";var g=class{constructor(e,t){this.host=e,this.options=t,this._deadline=0,this._timedOut=!1,this.host.addController(this)}get timedOut(){return this._timedOut}hostConnected(){const e=this.options.intervalMs??1e3,t=void 0!==this.options.startDelayMs?this.options.startDelayMs:e;this._deadline=Date.now()+this.options.timeoutMs,this._timedOut=!1,this._startTimeoutId=setTimeout(()=>{this._startTimeoutId=void 0,this._poll(),this._intervalId=setInterval(()=>{this._poll()},e)},t)}hostDisconnected(){this._stop()}stop(){this._stop()}async _poll(){if(Date.now()>=this._deadline)return this._stop(),this._timedOut=!0,this.host.requestUpdate(),void this.options.onTimeout?.();try{const e=await this.options.refetchFn();this.options.shouldComplete(e)&&(this._stop(),this.options.onComplete?.(e))}catch{}}_stop(){void 0!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),void 0!==this._startTimeoutId&&(clearTimeout(this._startTimeoutId),this._startTimeoutId=void 0)}};try{_()}catch{}const k=d`:host{height:100%;min-height:0;display:flex;flex-direction:column;flex:1}.payment-frame{position:relative;width:100%;min-width:0;display:flex;flex-direction:column;flex:1;min-height:0}.payment-frame iframe:not(.loaded){position:absolute;width:1px;height:1px;opacity:0;pointer-events:none;border:none}.payment-frame iframe.loaded{flex:none;display:block;width:100%;border:none;min-height:1050px}.state{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;gap:var(--sp-4);padding:var(--sp-8);text-align:center}.state-title{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0}.state-message{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-default);margin:0}`,E="mediquo:payment:retry",b="mediquo:payment:resize";class CheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(CheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class CheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(e){super(CheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class CheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(e){super(CheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class CheckoutRetryEvent extends Event{static{this.eventName="payment-retry"}constructor(){super(CheckoutRetryEvent.eventName,{bubbles:!0,composed:!0})}}let w=class MqCheckout extends l{constructor(){super(...arguments),this._iframeLoaded=!1,this._iframeHeight=null,this._sessionEpoch=0,this._currentSessionId=null,this._paymentOrigin=null,this._loginTokenTask=new a(this,n,{args:()=>[this.apiKey,this.token],onComplete:e=>{n.setAuthToken(e.access_token),this._sessionTask.run()},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"auth"}))}}),this._sessionTask=new o(this,{task:async()=>{if("function"!=typeof this.provideSession)throw new Error("mq-checkout: `provideSession` property is required");return this.provideSession()},args:()=>[this._sessionEpoch],autoRun:!1,onComplete:e=>{this._currentSessionId=e.sessionId,this._iframeLoaded=!1,this._iframeHeight=null;try{this._paymentOrigin=new URL(e.paymentUrl).origin}catch{this._paymentOrigin=null,h.warn(`mq-checkout: invalid paymentUrl "${e.paymentUrl}"`)}},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"session"}))}}),this._paymentPoll=new g(this,{startDelayMs:5e3,intervalMs:3e3,timeoutMs:6e5,refetchFn:async()=>{if(!this._currentSessionId)throw new Error("mq-checkout: session not ready");const e=await n.payments.getPaymentSession(this._currentSessionId);return e.status===r.Denied&&(this._paymentPoll.stop(),this.dispatchEvent(new CheckoutDeniedEvent({sessionId:this._currentSessionId}))),e},shouldComplete:e=>e.status===r.Paid,onComplete:e=>{this.dispatchEvent(new CheckoutSuccessEvent({sessionId:this._currentSessionId??"",reference:e.consultation_id}))},onTimeout:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"timeout"}))}}),this._onMessage=e=>{if(!this._paymentOrigin||e.origin===this._paymentOrigin)switch(e.data?.type){case E:return this.dispatchEvent(new CheckoutRetryEvent),this._sessionEpoch+=1,void this._sessionTask.run();case b:return void("number"==typeof e.data.height&&(this._iframeHeight=e.data.height))}}}static{this.styles=[v,k]}get _timedOut(){return this._paymentPoll.timedOut}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this._onMessage)}disconnectedCallback(){window.removeEventListener("message",this._onMessage),super.disconnectedCallback()}willUpdate(e){if(e.has("env")&&this.env&&u(this.env),e.has("apiKey")&&n.setApiKey(this.apiKey),e.has("locale")){const e=f(this.locale)?this.locale:"es_ES";y(e),n.setLanguage(e)}}_onIframeLoad(){this._iframeLoaded=!0}_renderState(e,t){return c`<div class="state"><p class="state-title">${e}</p>${t?c`<p class="state-message">${t}</p>`:null}</div>`}_renderLoading(){return c`<div class="payment-frame"><mq-skeleton width="100%" height="600px" border-radius="md" role="status" aria-live="polite" aria-label="${s("Cargando portal de pago")}"></mq-skeleton></div>`}_renderFrame(e){return c`<div class="payment-frame">${this._iframeLoaded?null:this._renderLoading()}<iframe class="${this._iframeLoaded?"loaded":""}" src="${e}" title="${s("Portal de pago")}" style="${null!==this._iframeHeight?`min-height: ${this._iframeHeight}px; height: ${this._iframeHeight}px;`:""}" @load="${this._onIframeLoad}"></iframe></div>`}render(){return this._timedOut?this._renderState(s("No hemos podido confirmar tu pago"),s("Ha ocurrido un problema al verificar el estado de tu pago. Por favor, contacta con soporte si el cargo se ha realizado.")):this._loginTokenTask.render({pending:()=>this._renderLoading(),error:()=>this._renderState(s("No hemos podido iniciar el pago"),s("Por favor, inténtalo de nuevo más tarde.")),complete:()=>this._sessionTask.render({initial:()=>this._renderLoading(),pending:()=>this._renderLoading(),error:()=>this._renderState(s("No hemos podido iniciar el pago"),s("Por favor, inténtalo de nuevo más tarde.")),complete:e=>this._renderFrame(e.paymentUrl)})})}};e([p({type:String,attribute:"env"})],w.prototype,"env",void 0),e([p({type:String,attribute:"api-key"})],w.prototype,"apiKey",void 0),e([p({type:String,attribute:"token"})],w.prototype,"token",void 0),e([p({type:String,attribute:"locale",reflect:!0})],w.prototype,"locale",void 0),e([p({attribute:!1})],w.prototype,"provideSession",void 0),e([m()],w.prototype,"_iframeLoaded",void 0),e([m()],w.prototype,"_iframeHeight",void 0),e([m()],w.prototype,"_sessionEpoch",void 0),w=e([i(),t("mq-checkout")],w);export{CheckoutDeniedEvent,CheckoutErrorEvent,CheckoutRetryEvent,CheckoutSuccessEvent,w as MqCheckout};
1
+ import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{m as s}from"./chunks/runtime-Bg1WXVCx.js";import{l as i}from"./chunks/parseISO-jT42c8Ob.js";import{h as o}from"./chunks/task-Bj8p7kJX.js";import{b as n,P as r}from"./chunks/api-chat-client-C8SqZtCa.js";import{L as a}from"./chunks/login-token-task-BI-L2zSV.js";import{l as h}from"./chunks/external-zAbuzxDj.js";import{i as d,a as l,x as c}from"./chunks/lit-element-DiWJYFwC.js";import{n as p}from"./chunks/property-scuRaFcM.js";import{r as m}from"./chunks/state-LQivXIgA.js";import{setEnv as u}from"./env.js";import{tokens as v}from"./theme.js";import{initLocalization as _,isValidLocale as f,setLocale as y}from"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";var g=class{constructor(e,t){this.host=e,this.options=t,this._deadline=0,this._timedOut=!1,this.host.addController(this)}get timedOut(){return this._timedOut}hostConnected(){const e=this.options.intervalMs??1e3,t=void 0!==this.options.startDelayMs?this.options.startDelayMs:e;this._deadline=Date.now()+this.options.timeoutMs,this._timedOut=!1,this._startTimeoutId=setTimeout(()=>{this._startTimeoutId=void 0,this._poll(),this._intervalId=setInterval(()=>{this._poll()},e)},t)}hostDisconnected(){this._stop()}stop(){this._stop()}async _poll(){if(Date.now()>=this._deadline)return this._stop(),this._timedOut=!0,this.host.requestUpdate(),void this.options.onTimeout?.();try{const e=await this.options.refetchFn();this.options.shouldComplete(e)&&(this._stop(),this.options.onComplete?.(e))}catch{}}_stop(){void 0!==this._intervalId&&(clearInterval(this._intervalId),this._intervalId=void 0),void 0!==this._startTimeoutId&&(clearTimeout(this._startTimeoutId),this._startTimeoutId=void 0)}};try{_()}catch{}const k=d`:host{height:100%;min-height:0;display:flex;flex-direction:column;flex:1}.payment-frame{position:relative;width:100%;min-width:0;display:flex;flex-direction:column;flex:1;min-height:0}.payment-frame iframe:not(.loaded){position:absolute;width:1px;height:1px;opacity:0;pointer-events:none;border:none}.payment-frame iframe.loaded{flex:none;display:block;width:100%;border:none;min-height:1050px}.state{display:flex;flex-direction:column;align-items:center;justify-content:center;flex:1;gap:var(--sp-4);padding:var(--sp-8);text-align:center}.state-title{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0}.state-message{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);color:var(--color-neutrals-text-default);margin:0}`,E="mediquo:payment:retry",b="mediquo:payment:resize";class CheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(CheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class CheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(e){super(CheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class CheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(e){super(CheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}class CheckoutRetryEvent extends Event{static{this.eventName="payment-retry"}constructor(){super(CheckoutRetryEvent.eventName,{bubbles:!0,composed:!0})}}let w=class MqCheckout extends l{constructor(){super(...arguments),this._iframeLoaded=!1,this._iframeHeight=null,this._sessionEpoch=0,this._currentSessionId=null,this._paymentOrigin=null,this._loginTokenTask=new a(this,n,{args:()=>[this.apiKey,this.token],onComplete:e=>{n.setAuthToken(e.access_token),this._sessionTask.run()},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"auth"}))}}),this._sessionTask=new o(this,{task:async()=>{if("function"!=typeof this.provideSession)throw new Error("mq-checkout: `provideSession` property is required");return this.provideSession()},args:()=>[this._sessionEpoch],autoRun:!1,onComplete:e=>{this._currentSessionId=e.sessionId,this._iframeLoaded=!1,this._iframeHeight=null;try{this._paymentOrigin=new URL(e.paymentUrl).origin}catch{this._paymentOrigin=null,h.warn(`mq-checkout: invalid paymentUrl "${e.paymentUrl}"`)}},onError:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"session"}))}}),this._paymentPoll=new g(this,{startDelayMs:5e3,intervalMs:3e3,timeoutMs:6e5,refetchFn:async()=>{if(!this._currentSessionId)throw new Error("mq-checkout: session not ready");const e=await n.payments.getPaymentSession(this._currentSessionId);return e.status===r.Denied&&(this._paymentPoll.stop(),this.dispatchEvent(new CheckoutDeniedEvent({sessionId:this._currentSessionId}))),e},shouldComplete:e=>e.status===r.Paid,onComplete:e=>{this.dispatchEvent(new CheckoutSuccessEvent({sessionId:this._currentSessionId??"",reference:e.consultation_id}))},onTimeout:()=>{this.dispatchEvent(new CheckoutErrorEvent({reason:"timeout"}))}}),this._onMessage=e=>{if(!this._paymentOrigin||e.origin===this._paymentOrigin)switch(e.data?.type){case E:return this.dispatchEvent(new CheckoutRetryEvent),this._sessionEpoch+=1,void this._sessionTask.run();case b:return void("number"==typeof e.data.height&&(this._iframeHeight=e.data.height))}}}static{this.styles=[v,k]}get _timedOut(){return this._paymentPoll.timedOut}connectedCallback(){super.connectedCallback(),window.addEventListener("message",this._onMessage)}disconnectedCallback(){window.removeEventListener("message",this._onMessage),super.disconnectedCallback()}willUpdate(e){if(e.has("env")&&this.env&&u(this.env),e.has("apiKey")&&n.setApiKey(this.apiKey),e.has("locale")){const e=f(this.locale)?this.locale:"es_ES";y(e),n.setLanguage(e)}}_onIframeLoad(){this._iframeLoaded=!0}_renderState(e,t){return c`<div class="state"><p class="state-title">${e}</p>${t?c`<p class="state-message">${t}</p>`:null}</div>`}_renderLoading(){return c`<div class="payment-frame"><mq-skeleton width="100%" height="600px" border-radius="md" role="status" aria-live="polite" aria-label="${s("Cargando portal de pago")}"></mq-skeleton></div>`}_renderFrame(e){return c`<div class="payment-frame">${this._iframeLoaded?null:this._renderLoading()}<iframe class="${this._iframeLoaded?"loaded":""}" src="${e}" title="${s("Portal de pago")}" style="${null!==this._iframeHeight?`min-height: ${this._iframeHeight}px; height: ${this._iframeHeight}px;`:""}" @load="${this._onIframeLoad}"></iframe></div>`}render(){return this._timedOut?this._renderState(s("No hemos podido confirmar tu pago"),s("Ha ocurrido un problema al verificar el estado de tu pago. Por favor, contacta con soporte si el cargo se ha realizado.")):this._loginTokenTask.render({pending:()=>this._renderLoading(),error:()=>this._renderState(s("No hemos podido iniciar el pago"),s("Por favor, inténtalo de nuevo más tarde.")),complete:()=>this._sessionTask.render({initial:()=>this._renderLoading(),pending:()=>this._renderLoading(),error:()=>this._renderState(s("No hemos podido iniciar el pago"),s("Por favor, inténtalo de nuevo más tarde.")),complete:e=>this._renderFrame(e.paymentUrl)})})}};e([p({type:String,attribute:"env"})],w.prototype,"env",void 0),e([p({type:String,attribute:"api-key"})],w.prototype,"apiKey",void 0),e([p({type:String,attribute:"token"})],w.prototype,"token",void 0),e([p({type:String,attribute:"locale",reflect:!0})],w.prototype,"locale",void 0),e([p({attribute:!1})],w.prototype,"provideSession",void 0),e([m()],w.prototype,"_iframeLoaded",void 0),e([m()],w.prototype,"_iframeHeight",void 0),e([m()],w.prototype,"_sessionEpoch",void 0),w=e([i(),t("mq-checkout")],w);export{CheckoutDeniedEvent,CheckoutErrorEvent,CheckoutRetryEvent,CheckoutSuccessEvent,w as MqCheckout};
@@ -1 +1 @@
1
- import{_ as t,t as e}from"./chunks/custom-element-DA9Fxvxd.js";import{m as a}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/parseISO-jT42c8Ob.js";import{L as o}from"./chunks/login-token-task-BI-L2zSV.js";import{l as i}from"./chunks/external-zAbuzxDj.js";import{i as s,a as r,x as l}from"./chunks/lit-element-DiWJYFwC.js";import{n as c}from"./chunks/property-scuRaFcM.js";import{r as h}from"./chunks/state-LQivXIgA.js";import{setEnv as u}from"./env.js";import{initLocalization as p,isValidLocale as y,setLocale as d}from"./i18n.js";import{i as m,a as g}from"./chunks/api-chat-client-BTBtu01T.js";import{r as v}from"./chunks/apple-pay-outcomes-BlytM6W-.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";function b(){return"undefined"!=typeof google&&"function"==typeof google.payments?.api?.PaymentsClient}const _=["PAN_ONLY","CRYPTOGRAM_3DS"],k=["VISA","MASTERCARD","AMEX"];function f(t){return{type:"PAYMENT_GATEWAY",parameters:{gateway:"globalpayments",gatewayMerchantId:t}}}function C(t){return{type:"CARD",parameters:{allowedAuthMethods:[..._],allowedCardNetworks:[...k]},tokenizationSpecification:f(t)}}function w(t){return[C(t)]}function E(t,e){return"test"===e?"TEST":"production"===e?"PRODUCTION":"development"===t?"TEST":"PRODUCTION"}function P(t,e){return function(t,e){return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:w(t.gatewayMerchantId),merchantInfo:{merchantId:t.merchantId,merchantName:t.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPrice:e.amount,currencyCode:e.currencyCode,countryCode:e.countryCode}}}(t,e)}async function I(t,e,a,n={}){if("undefined"==typeof window||!window.isSecureContext)return i.warn("google-pay: unavailable outside a secure context"),{available:!1,reason:"unsupported"};if(!t.trim())return i.warn("google-pay: missing merchant id"),{available:!1,reason:"merchant-id-missing"};if(!e.trim())return i.warn("google-pay: missing gateway merchant id"),{available:!1,reason:"gateway-merchant-id-missing"};if(!await function(t=8e3,e){return b()?Promise.resolve(!0):t<=0||e?.aborted?Promise.resolve(!1):new Promise(a=>{const n=Date.now()+t,o=t=>{clearInterval(s),e?.removeEventListener("abort",i),a(t)},i=()=>o(!1),s=setInterval(()=>{b()?o(!0):Date.now()>=n&&o(!1)},100);e?.addEventListener("abort",i,{once:!0})})}(n.sdkWaitTimeoutMs,n.signal))return i.warn("google-pay: pay.js was not loaded by the host page"),{available:!1,reason:"sdk-missing"};const o=E(a,n.gatewayEnvironment);try{const t=new google.payments.api.PaymentsClient({environment:o}),a=await t.isReadyToPay(function(t){return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:w(t)}}(e));return a.result?{available:!0}:(i.warn("google-pay: isReadyToPay returned false",{environment:o}),{available:!1,reason:"unsupported"})}catch(t){return i.warn("google-pay: isReadyToPay threw",{environment:o,error:t instanceof Error?t.message:String(t)}),{available:!1,reason:"unsupported"}}}function G(t,e){return function(t){if(function(t){return"object"==typeof t&&null!==t&&"statusCode"in t&&"string"==typeof t.statusCode}(t)){const e=t.statusCode.toUpperCase();if("CANCELED"===e||"CANCELLED"===e)return!0}if(t instanceof Error){const e=t.message.toLowerCase();return e.includes("cancel")||e.includes("closed")||e.includes("abort")}return!1}(t)?{kind:"cancelled"}:m(t)&&400===t.response?.status?{kind:"denied",sessionId:e}:{kind:"authorize"}}function S(t){if(null!==t&&"object"==typeof t){const e=t.paymentMethodData?.tokenizationData,a=e?.token;if("string"==typeof a&&a.length>0)return a}throw new Error("Invalid Google Pay payment data: missing tokenizationData.token")}try{p()}catch{}const A=s`:host{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:12px;width:100%;min-height:48px}.pay-row{display:block;width:100%}.pay-row--paying{opacity:.55;pointer-events:none}::slotted([slot=google-pay-button]){display:block;width:100%;height:var(--mq-google-pay-button-height,48px)}.state{text-align:center;font-family:system-ui,sans-serif;font-size:15px;color:#86868b;margin:0}`;class GooglePayCheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(GooglePayCheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class GooglePayCheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(t){super(GooglePayCheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class GooglePayCheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(t){super(GooglePayCheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}const T=new Set(["sdk-missing","unsupported"]);function D(t,e){i.warn(t,{error:e instanceof Error?e.message:String(e)})}let N=class MqGooglePayCheckout extends r{constructor(){super(...arguments),this._availabilityPhase="checking",this._unavailableReason=null,this._paying=!1,this._paymentsClient=null,this._paymentsClientEnvironment=null,this._buttonHost=null,this._availabilityGeneration=0,this._availabilityAbortController=null,this._terminalErrorDispatched=!1,this._loginTokenTask=new o(this,g,{args:()=>[this.apiKey,this.token],onComplete:t=>{g.setAuthToken(t.access_token),this._refreshAvailability()},onError:()=>{this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"auth"}))}}),this._onPayClick=()=>{this._paying||"ready"!==this._availabilityPhase||this._processPayment()}}static{this.styles=A}willUpdate(t){if(t.has("env")&&(this.env&&u(this.env),this._resetPaymentsClient()),t.has("gatewayEnvironment")&&this._resetPaymentsClient(),t.has("apiKey")&&g.setApiKey(this.apiKey),t.has("locale")){const t=y(this.locale)?this.locale:"es_ES";d(t),g.setLanguage(t)}(t.has("merchantId")||t.has("gatewayMerchantId")||t.has("env")||t.has("gatewayEnvironment"))&&this._loginTokenTask.value&&this._refreshAvailability()}connectedCallback(){super.connectedCallback(),this._availabilityAbortController=new AbortController,this._terminalErrorDispatched=!1}disconnectedCallback(){this._availabilityAbortController?.abort(),this._availabilityAbortController=null,this._resetPaymentsClient(),super.disconnectedCallback()}_dispatchTerminalError(){this._terminalErrorDispatched||(this._terminalErrorDispatched=!0,this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"unsupported"})))}_resetPaymentsClient(){this._paymentsClient=null,this._paymentsClientEnvironment=null,this._removeButtonHost()}_getPaymentsClient(){const t=E(this.env,this.gatewayEnvironment);return this._paymentsClient&&this._paymentsClientEnvironment===t||(this._paymentsClient=new google.payments.api.PaymentsClient({environment:t}),this._paymentsClientEnvironment=t,this._buttonHost=null),this._paymentsClient}async _refreshAvailability(){const t=++this._availabilityGeneration;this._availabilityPhase="checking",this._unavailableReason=null,this._removeButtonHost();const e=await I(this.merchantId??"",this.gatewayMerchantId??"",this.env,{signal:this._availabilityAbortController?.signal,gatewayEnvironment:this.gatewayEnvironment});if(t===this._availabilityGeneration&&this.isConnected){if(!e.available)return this._availabilityPhase="unavailable",this._unavailableReason=e.reason,void(T.has(e.reason)&&this._dispatchTerminalError());this._availabilityPhase="ready",this._unavailableReason=null}}_ensureButtonHost(){const t=this.querySelector(':scope > [slot="google-pay-button"]');if(t)return t;const e=document.createElement("div");return e.slot="google-pay-button",this.appendChild(e),e}_removeButtonHost(){this.querySelector(':scope > [slot="google-pay-button"]')?.remove(),this._buttonHost=null}_mountGooglePayButton(){if(this._buttonHost||"ready"!==this._availabilityPhase)return;const t=this._ensureButtonHost();try{const e=this._getPaymentsClient().createButton({onClick:this._onPayClick,buttonColor:"black",buttonType:"pay",buttonSizeMode:"fill"});t.replaceChildren(e),this._buttonHost=t}catch(t){D("mq-google-pay-checkout: failed to create Google Pay button",t),this._removeButtonHost(),this._availabilityPhase="unavailable",this._unavailableReason="unsupported",this._dispatchTerminalError()}}updated(t){super.updated(t),"ready"===this._availabilityPhase&&this._mountGooglePayButton()}async _processPayment(){this._paying=!0;try{const t=await this._getPaymentsClient().loadPaymentData(P({merchantId:this.merchantId,gatewayMerchantId:this.gatewayMerchantId,merchantName:this.merchantName||this.label},{amount:this.amount,currencyCode:this.currency,countryCode:this.country})),e=await g.payments.authorizeGooglePay({order_id:this.sessionId,token:S(t)}),{status:a,consultation_id:n}=e.data,o=v(a,n,this.sessionId);switch(o.kind){case"success":this.dispatchEvent(new GooglePayCheckoutSuccessEvent({sessionId:o.sessionId,reference:o.reference}));break;case"denied":this.dispatchEvent(new GooglePayCheckoutDeniedEvent({sessionId:o.sessionId}));break;case"error":this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:o.reason}))}}catch(t){const e=G(t,this.sessionId);switch(e.kind){case"cancelled":this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"cancelled"}));break;case"denied":this.dispatchEvent(new GooglePayCheckoutDeniedEvent({sessionId:e.sessionId}));break;case"authorize":D("mq-google-pay-checkout: authorize failed",t),this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"authorize"}))}}finally{this._paying=!1}}_renderUnavailable(){switch(this._unavailableReason){case"merchant-id-missing":return l`<p class="state">${a("Falta el identificador de comercio de Google Pay")}</p>`;case"gateway-merchant-id-missing":return l`<p class="state">${a("Falta el identificador de pasarela de Google Pay")}</p>`;case"sdk-missing":return l`<p class="state">${a("No se ha podido cargar Google Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`;default:return l`<p class="state">${a("Google Pay no está disponible. Prueba con tarjeta u otro método de pago.")}</p>`}}render(){return this._loginTokenTask.render({pending:()=>l`<p class="state">${a("Preparando Google Pay…")}</p>`,error:()=>l`<p class="state">${a("No hemos podido iniciar el pago")}</p>`,complete:()=>"checking"===this._availabilityPhase?l`<p class="state">${a("Comprobando Google Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():l`<div class="pay-row ${this._paying?"pay-row--paying":""}"><slot name="google-pay-button"></slot></div>`})}};t([c({type:String,attribute:"env"})],N.prototype,"env",void 0),t([c({type:String,attribute:"gateway-environment"})],N.prototype,"gatewayEnvironment",void 0),t([c({type:String,attribute:"api-key"})],N.prototype,"apiKey",void 0),t([c({type:String,attribute:"token"})],N.prototype,"token",void 0),t([c({type:String,attribute:"locale",reflect:!0})],N.prototype,"locale",void 0),t([c({type:String,attribute:"merchant-id"})],N.prototype,"merchantId",void 0),t([c({type:String,attribute:"gateway-merchant-id"})],N.prototype,"gatewayMerchantId",void 0),t([c({type:String,attribute:"merchant-name"})],N.prototype,"merchantName",void 0),t([c({type:String,attribute:"session-id"})],N.prototype,"sessionId",void 0),t([c({type:String,attribute:"amount"})],N.prototype,"amount",void 0),t([c({type:String,attribute:"currency"})],N.prototype,"currency",void 0),t([c({type:String,attribute:"country"})],N.prototype,"country",void 0),t([c({type:String,attribute:"label"})],N.prototype,"label",void 0),t([h()],N.prototype,"_availabilityPhase",void 0),t([h()],N.prototype,"_unavailableReason",void 0),t([h()],N.prototype,"_paying",void 0),N=t([n(),e("mq-google-pay-checkout")],N);export{GooglePayCheckoutDeniedEvent,GooglePayCheckoutErrorEvent,GooglePayCheckoutSuccessEvent,N as MqGooglePayCheckout};
1
+ import{_ as t,t as e}from"./chunks/custom-element-DA9Fxvxd.js";import{m as a}from"./chunks/runtime-Bg1WXVCx.js";import{l as n}from"./chunks/parseISO-jT42c8Ob.js";import{L as o}from"./chunks/login-token-task-BI-L2zSV.js";import{l as i}from"./chunks/external-zAbuzxDj.js";import{i as s,a as r,x as l}from"./chunks/lit-element-DiWJYFwC.js";import{n as c}from"./chunks/property-scuRaFcM.js";import{r as h}from"./chunks/state-LQivXIgA.js";import{setEnv as u}from"./env.js";import{initLocalization as p,isValidLocale as y,setLocale as d}from"./i18n.js";import{i as m,b as g}from"./chunks/api-chat-client-C8SqZtCa.js";import{r as v}from"./chunks/apple-pay-outcomes-BNkcTbbM.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";function b(){return"undefined"!=typeof google&&"function"==typeof google.payments?.api?.PaymentsClient}const _=["PAN_ONLY","CRYPTOGRAM_3DS"],f=["VISA","MASTERCARD","AMEX"];function k(t){return{type:"PAYMENT_GATEWAY",parameters:{gateway:"globalpayments",gatewayMerchantId:t}}}function C(t){return{type:"CARD",parameters:{allowedAuthMethods:[..._],allowedCardNetworks:[...f]},tokenizationSpecification:k(t)}}function w(t){return[C(t)]}function E(t,e){return"test"===e?"TEST":"production"===e?"PRODUCTION":"development"===t?"TEST":"PRODUCTION"}function P(t,e){return function(t,e){return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:w(t.gatewayMerchantId),merchantInfo:{merchantId:t.merchantId,merchantName:t.merchantName},transactionInfo:{totalPriceStatus:"FINAL",totalPrice:e.amount,currencyCode:e.currencyCode,countryCode:e.countryCode}}}(t,e)}async function I(t,e,a,n={}){if("undefined"==typeof window||!window.isSecureContext)return i.warn("google-pay: unavailable outside a secure context"),{available:!1,reason:"unsupported"};if(!t.trim())return i.warn("google-pay: missing merchant id"),{available:!1,reason:"merchant-id-missing"};if(!e.trim())return i.warn("google-pay: missing gateway merchant id"),{available:!1,reason:"gateway-merchant-id-missing"};if(!await function(t=8e3,e){return b()?Promise.resolve(!0):t<=0||e?.aborted?Promise.resolve(!1):new Promise(a=>{const n=Date.now()+t,o=t=>{clearInterval(s),e?.removeEventListener("abort",i),a(t)},i=()=>o(!1),s=setInterval(()=>{b()?o(!0):Date.now()>=n&&o(!1)},100);e?.addEventListener("abort",i,{once:!0})})}(n.sdkWaitTimeoutMs,n.signal))return i.warn("google-pay: pay.js was not loaded by the host page"),{available:!1,reason:"sdk-missing"};const o=E(a,n.gatewayEnvironment);try{const t=new google.payments.api.PaymentsClient({environment:o}),a=await t.isReadyToPay(function(t){return{apiVersion:2,apiVersionMinor:0,allowedPaymentMethods:w(t)}}(e));return a.result?{available:!0}:(i.warn("google-pay: isReadyToPay returned false",{environment:o}),{available:!1,reason:"unsupported"})}catch(t){return i.warn("google-pay: isReadyToPay threw",{environment:o,error:t instanceof Error?t.message:String(t)}),{available:!1,reason:"unsupported"}}}function G(t,e){return function(t){if(function(t){return"object"==typeof t&&null!==t&&"statusCode"in t&&"string"==typeof t.statusCode}(t)){const e=t.statusCode.toUpperCase();if("CANCELED"===e||"CANCELLED"===e)return!0}if(t instanceof Error){const e=t.message.toLowerCase();return e.includes("cancel")||e.includes("closed")||e.includes("abort")}return!1}(t)?{kind:"cancelled"}:m(t)&&400===t.response?.status?{kind:"denied",sessionId:e}:{kind:"authorize"}}function S(t){if(null!==t&&"object"==typeof t){const e=t.paymentMethodData?.tokenizationData,a=e?.token;if("string"==typeof a&&a.length>0)return a}throw new Error("Invalid Google Pay payment data: missing tokenizationData.token")}try{p()}catch{}const A=s`:host{display:flex;flex-direction:column;align-items:stretch;justify-content:center;gap:12px;width:100%;min-height:48px}.pay-row{display:block;width:100%}.pay-row--paying{opacity:.55;pointer-events:none}::slotted([slot=google-pay-button]){display:block;width:100%;height:var(--mq-google-pay-button-height,48px)}.state{text-align:center;font-family:system-ui,sans-serif;font-size:15px;color:#86868b;margin:0}`;class GooglePayCheckoutSuccessEvent extends Event{static{this.eventName="payment-success"}constructor(t){super(GooglePayCheckoutSuccessEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class GooglePayCheckoutDeniedEvent extends Event{static{this.eventName="payment-denied"}constructor(t){super(GooglePayCheckoutDeniedEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}class GooglePayCheckoutErrorEvent extends Event{static{this.eventName="payment-error"}constructor(t){super(GooglePayCheckoutErrorEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}const T=new Set(["sdk-missing","unsupported"]);function D(t,e){i.warn(t,{error:e instanceof Error?e.message:String(e)})}let N=class MqGooglePayCheckout extends r{constructor(){super(...arguments),this._availabilityPhase="checking",this._unavailableReason=null,this._paying=!1,this._paymentsClient=null,this._paymentsClientEnvironment=null,this._buttonHost=null,this._availabilityGeneration=0,this._availabilityAbortController=null,this._terminalErrorDispatched=!1,this._loginTokenTask=new o(this,g,{args:()=>[this.apiKey,this.token],onComplete:t=>{g.setAuthToken(t.access_token),this._refreshAvailability()},onError:()=>{this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"auth"}))}}),this._onPayClick=()=>{this._paying||"ready"!==this._availabilityPhase||this._processPayment()}}static{this.styles=A}willUpdate(t){if(t.has("env")&&(this.env&&u(this.env),this._resetPaymentsClient()),t.has("gatewayEnvironment")&&this._resetPaymentsClient(),t.has("apiKey")&&g.setApiKey(this.apiKey),t.has("locale")){const t=y(this.locale)?this.locale:"es_ES";d(t),g.setLanguage(t)}(t.has("merchantId")||t.has("gatewayMerchantId")||t.has("env")||t.has("gatewayEnvironment"))&&this._loginTokenTask.value&&this._refreshAvailability()}connectedCallback(){super.connectedCallback(),this._availabilityAbortController=new AbortController,this._terminalErrorDispatched=!1}disconnectedCallback(){this._availabilityAbortController?.abort(),this._availabilityAbortController=null,this._resetPaymentsClient(),super.disconnectedCallback()}_dispatchTerminalError(){this._terminalErrorDispatched||(this._terminalErrorDispatched=!0,this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"unsupported"})))}_resetPaymentsClient(){this._paymentsClient=null,this._paymentsClientEnvironment=null,this._removeButtonHost()}_getPaymentsClient(){const t=E(this.env,this.gatewayEnvironment);return this._paymentsClient&&this._paymentsClientEnvironment===t||(this._paymentsClient=new google.payments.api.PaymentsClient({environment:t}),this._paymentsClientEnvironment=t,this._buttonHost=null),this._paymentsClient}async _refreshAvailability(){const t=++this._availabilityGeneration;this._availabilityPhase="checking",this._unavailableReason=null,this._removeButtonHost();const e=await I(this.merchantId??"",this.gatewayMerchantId??"",this.env,{signal:this._availabilityAbortController?.signal,gatewayEnvironment:this.gatewayEnvironment});if(t===this._availabilityGeneration&&this.isConnected){if(!e.available)return this._availabilityPhase="unavailable",this._unavailableReason=e.reason,void(T.has(e.reason)&&this._dispatchTerminalError());this._availabilityPhase="ready",this._unavailableReason=null}}_ensureButtonHost(){const t=this.querySelector(':scope > [slot="google-pay-button"]');if(t)return t;const e=document.createElement("div");return e.slot="google-pay-button",this.appendChild(e),e}_removeButtonHost(){this.querySelector(':scope > [slot="google-pay-button"]')?.remove(),this._buttonHost=null}_mountGooglePayButton(){if(this._buttonHost||"ready"!==this._availabilityPhase)return;const t=this._ensureButtonHost();try{const e=this._getPaymentsClient().createButton({onClick:this._onPayClick,buttonColor:"black",buttonType:"pay",buttonSizeMode:"fill"});t.replaceChildren(e),this._buttonHost=t}catch(t){D("mq-google-pay-checkout: failed to create Google Pay button",t),this._removeButtonHost(),this._availabilityPhase="unavailable",this._unavailableReason="unsupported",this._dispatchTerminalError()}}updated(t){super.updated(t),"ready"===this._availabilityPhase&&this._mountGooglePayButton()}async _processPayment(){this._paying=!0;try{const t=await this._getPaymentsClient().loadPaymentData(P({merchantId:this.merchantId,gatewayMerchantId:this.gatewayMerchantId,merchantName:this.merchantName||this.label},{amount:this.amount,currencyCode:this.currency,countryCode:this.country})),e=await g.payments.authorizeGooglePay({order_id:this.sessionId,token:S(t)}),{status:a,consultation_id:n}=e.data,o=v(a,n,this.sessionId);switch(o.kind){case"success":this.dispatchEvent(new GooglePayCheckoutSuccessEvent({sessionId:o.sessionId,reference:o.reference}));break;case"denied":this.dispatchEvent(new GooglePayCheckoutDeniedEvent({sessionId:o.sessionId}));break;case"error":this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:o.reason}))}}catch(t){const e=G(t,this.sessionId);switch(e.kind){case"cancelled":this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"cancelled"}));break;case"denied":this.dispatchEvent(new GooglePayCheckoutDeniedEvent({sessionId:e.sessionId}));break;case"authorize":D("mq-google-pay-checkout: authorize failed",t),this.dispatchEvent(new GooglePayCheckoutErrorEvent({reason:"authorize"}))}}finally{this._paying=!1}}_renderUnavailable(){switch(this._unavailableReason){case"merchant-id-missing":return l`<p class="state">${a("Falta el identificador de comercio de Google Pay")}</p>`;case"gateway-merchant-id-missing":return l`<p class="state">${a("Falta el identificador de pasarela de Google Pay")}</p>`;case"sdk-missing":return l`<p class="state">${a("No se ha podido cargar Google Pay. Comprueba la configuración del sitio e inténtalo de nuevo.")}</p>`;default:return l`<p class="state">${a("Google Pay no está disponible. Prueba con tarjeta u otro método de pago.")}</p>`}}render(){return this._loginTokenTask.render({pending:()=>l`<p class="state">${a("Preparando Google Pay…")}</p>`,error:()=>l`<p class="state">${a("No hemos podido iniciar el pago")}</p>`,complete:()=>"checking"===this._availabilityPhase?l`<p class="state">${a("Comprobando Google Pay…")}</p>`:"unavailable"===this._availabilityPhase?this._renderUnavailable():l`<div class="pay-row ${this._paying?"pay-row--paying":""}"><slot name="google-pay-button"></slot></div>`})}};t([c({type:String,attribute:"env"})],N.prototype,"env",void 0),t([c({type:String,attribute:"gateway-environment"})],N.prototype,"gatewayEnvironment",void 0),t([c({type:String,attribute:"api-key"})],N.prototype,"apiKey",void 0),t([c({type:String,attribute:"token"})],N.prototype,"token",void 0),t([c({type:String,attribute:"locale",reflect:!0})],N.prototype,"locale",void 0),t([c({type:String,attribute:"merchant-id"})],N.prototype,"merchantId",void 0),t([c({type:String,attribute:"gateway-merchant-id"})],N.prototype,"gatewayMerchantId",void 0),t([c({type:String,attribute:"merchant-name"})],N.prototype,"merchantName",void 0),t([c({type:String,attribute:"session-id"})],N.prototype,"sessionId",void 0),t([c({type:String,attribute:"amount"})],N.prototype,"amount",void 0),t([c({type:String,attribute:"currency"})],N.prototype,"currency",void 0),t([c({type:String,attribute:"country"})],N.prototype,"country",void 0),t([c({type:String,attribute:"label"})],N.prototype,"label",void 0),t([h()],N.prototype,"_availabilityPhase",void 0),t([h()],N.prototype,"_unavailableReason",void 0),t([h()],N.prototype,"_paying",void 0),N=t([n(),e("mq-google-pay-checkout")],N);export{GooglePayCheckoutDeniedEvent,GooglePayCheckoutErrorEvent,GooglePayCheckoutSuccessEvent,N as MqGooglePayCheckout};
@@ -1 +1 @@
1
- import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{a as i,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n as o}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import{a}from"./chunks/api-chat-client-BTBtu01T.js";import"./mq-checkout.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/parseISO-jT42c8Ob.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/login-token-task-BI-L2zSV.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";class ImmediateVideocallPaidEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(ImmediateVideocallPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}let r=class MqImmediateVideocallCheckout extends i{constructor(){super(...arguments),this._provideSession=async()=>{const e=await a.payments.createImmediateVideocallPaymentLink({video_call_schedule_id:this.videoCallScheduleId});return{sessionId:e.session_id,paymentUrl:e.payment_link}},this._onSuccess=e=>{e.stopPropagation(),this.dispatchEvent(new ImmediateVideocallPaidEvent({videoCallId:e.detail.reference}))}}render(){return s`<mq-checkout env="${n(this.env)}" api-key="${this.apiKey}" token="${this.token}" locale="${this.locale}" .provideSession="${this._provideSession}" @payment-success="${this._onSuccess}"></mq-checkout>`}};e([o({type:String,attribute:"env"})],r.prototype,"env",void 0),e([o({type:String,attribute:"api-key"})],r.prototype,"apiKey",void 0),e([o({type:String,attribute:"token"})],r.prototype,"token",void 0),e([o({type:String,attribute:"locale",reflect:!0})],r.prototype,"locale",void 0),e([o({type:String,attribute:"video-call-schedule-id"})],r.prototype,"videoCallScheduleId",void 0),r=e([t("mq-immediate-videocall-checkout")],r);export{ImmediateVideocallPaidEvent,r as MqImmediateVideocallCheckout};
1
+ import{_ as e,t}from"./chunks/custom-element-DA9Fxvxd.js";import{a as i,x as s}from"./chunks/lit-element-DiWJYFwC.js";import{n as o}from"./chunks/property-scuRaFcM.js";import{o as n}from"./chunks/if-defined-BYeVdwgd.js";import{b as r}from"./chunks/api-chat-client-C8SqZtCa.js";import"./mq-checkout.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/parseISO-jT42c8Ob.js";import"./chunks/runtime-Bg1WXVCx.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./chunks/task-Bj8p7kJX.js";import"./chunks/login-token-task-BI-L2zSV.js";import"./chunks/state-LQivXIgA.js";import"./theme.js";import"./i18n.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./chunks/directive-2EDmOukv.js";class ImmediateVideocallPaidEvent extends Event{static{this.eventName="payment-success"}constructor(e){super(ImmediateVideocallPaidEvent.eventName,{bubbles:!0,composed:!0}),this.detail=e}}let a=class MqImmediateVideocallCheckout extends i{constructor(){super(...arguments),this._provideSession=async()=>{const e=await r.payments.createImmediateVideocallPaymentLink({video_call_schedule_id:this.videoCallScheduleId});return{sessionId:e.session_id,paymentUrl:e.payment_link}},this._onSuccess=e=>{e.stopPropagation(),this.dispatchEvent(new ImmediateVideocallPaidEvent({videoCallId:e.detail.reference}))}}render(){return s`<mq-checkout env="${n(this.env)}" api-key="${this.apiKey}" token="${this.token}" locale="${this.locale}" .provideSession="${this._provideSession}" @payment-success="${this._onSuccess}"></mq-checkout>`}};e([o({type:String,attribute:"env"})],a.prototype,"env",void 0),e([o({type:String,attribute:"api-key"})],a.prototype,"apiKey",void 0),e([o({type:String,attribute:"token"})],a.prototype,"token",void 0),e([o({type:String,attribute:"locale",reflect:!0})],a.prototype,"locale",void 0),e([o({type:String,attribute:"video-call-schedule-id"})],a.prototype,"videoCallScheduleId",void 0),a=e([t("mq-immediate-videocall-checkout")],a);export{ImmediateVideocallPaidEvent,a as MqImmediateVideocallCheckout};
@@ -1 +1 @@
1
- import{h as t,f as e}from"./chunks/price-Dtdjx70D.js";export{A as AppointmentDetails}from"./chunks/price-Dtdjx70D.js";import{_ as i,t as n}from"./chunks/custom-element-DA9Fxvxd.js";import{M as a,c as o,Q as s}from"./chunks/mutation-controller-OVT8NEt6.js";import{m as r,s as p}from"./chunks/runtime-Bg1WXVCx.js";import{l}from"./chunks/parseISO-jT42c8Ob.js";import{l as c}from"./chunks/chunk-S5RWG6G2-oTcdgk2H.js";import{a as d,i as m,x as h,E as u}from"./chunks/lit-element-DiWJYFwC.js";import{n as v}from"./chunks/property-scuRaFcM.js";import{e as g}from"./chunks/external-zAbuzxDj.js";import{MqAppointmentRescheduleEvent as f,MqAppointmentBookEvent as b,MqAppointmentJoinVideocallEvent as y,MqAppointmentViewDocumentationEvent as x,MqHomeEvent as $}from"./events.js";import"./ui/mq-tabs.js";import{a as k,A as q,d as w,e as C}from"./chunks/api-chat-client-BTBtu01T.js";import{g as j}from"./chunks/get-organization-setup-query-BMbuRi6v.js";import{t as H,h as V,i as S,j as M,k as R,l as E,g as z,c as D,m as I}from"./chunks/telemetry-client-CKCb9Gnf.js";export{P as ProfessionalOverview}from"./chunks/telemetry-client-CKCb9Gnf.js";import{g as O,c as N}from"./chunks/refund-cancel-policy-Bm5djPds.js";import{a as _}from"./chunks/exports-XZaVrMLd.js";import{r as U}from"./chunks/state-LQivXIgA.js";import{getLocale as Q}from"./i18n.js";import"./ui/mq-card.js";import"./ui/mq-floating-bubble.js";import{Q as T}from"./chunks/query-QJ1INUTG.js";import"./ui/mq-button.js";import"./ui/mq-dialog.js";import{e as B}from"./chunks/class-map-Co76I6aw.js";import{messageBubbleIcon as Z}from"./ui/icons/message-bubble-icon.js";import{videoIcon as L}from"./ui/icons/video-icon.js";import"./ui/mq-unread-badge.js";import{toast as G}from"./ui/mq-toast.js";import"./ui/back-link.js";import"./ui/icons/briefcase-icon.js";import"./ui/icons/types.js";import"./ui/icons/calendar-icon.js";import"./ui/icons/clock-icon.js";import"./ui/icons/phone-icon.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-provider-CiMFpvDA.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./ui/icons/chevron-down-icon.js";import"./chunks/if-defined-BYeVdwgd.js";import"./ui/mq-text-button.js";import"./chunks/directive-2EDmOukv.js";import"./ui/mq-avatar.js";import"./chunks/provide-CfT7g_Zi.js";import"./theme.js";import"./ui/icons/x-icon.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./chunks/chunk-YTQUGGS3-DN-JZpgG.js";const F=g(["next","history"]).enum;class MqMyAppointmentsSelectEvent extends Event{static{this.eventName="ontabchange"}constructor(t){super(MqMyAppointmentsSelectEvent.eventName,{bubbles:!0,composed:!0}),this.value=t}}let W=class CancelAppointmentConfirmationDialog extends d{constructor(){super(...arguments),this.open=!1,this.cancelAppointmentMutation=new a(this,{mutationFn:async t=>k.appointments.cancelAppointment(t),onSuccess:()=>{this.queryClientContext?.invalidateQueries(),this.dispatchEvent(new CustomEvent("success",{bubbles:!0,composed:!0}))}}),this.handleClose=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))},this.handleDismissClick=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))},this.handleConfirmClick=()=>{this.cancelAppointmentMutation.run({id:this.appointmentId})}}static{this.styles=m`:host{display:contents}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}p{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);margin:0}.subheading-payable{font-size:var(--text-base);line-height:22px}.price-rows{display:flex;flex-direction:column;font-family:var(--font-body);font-size:var(--text-sm);font-weight:var(--font-weight-medium);line-height:var(--text-sm--line-height);color:var(--color-card-foreground);width:100%;margin-bottom:var(--sp-4)}.price-row{display:flex;align-items:center;justify-content:space-between;min-height:34px;gap:var(--sp-2)}.price-row span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.actions{display:flex;gap:var(--sp-3);margin-top:var(--sp-4);justify-content:flex-end;flex-wrap:wrap}`}render(){const i=Q(),n=this.price,a=t(n),o=this.cancelAppointmentMutation.isPending;if(a){const t=e(n,i),a=`-${t}`;return h`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${r("Confirmar cancelación")}</h2><p slot="subheading" class="subheading-payable">${r("¿Seguro que quieres cancelar esta cita? Se te devolverá el importe pagado en un plazo de 5-10 días hábiles.")}</p><div><div class="price-rows"><div class="price-row"><span>${r("Importe pagado")}</span> <span>${t}</span></div><div class="price-row"><span>${r("Importe a devolver")}</span> <span>${a}</span></div></div><div class="actions"><mq-button variant="outline" ?disabled="${o}" @click="${this.handleDismissClick}">${r("Volver")}</mq-button><mq-button variant="primary" ?disabled="${o}" @click="${this.handleConfirmClick}">${r("Confirmar")}</mq-button></div></div></mq-dialog>`}return h`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${r("Confirmar cancelación")}</h2><p slot="subheading">${r("¿Seguro que quieres cancelar esta cita?")}</p><div><div class="actions"><mq-button variant="outline" ?disabled="${o}" @click="${this.handleDismissClick}">${r("Cancelar")}</mq-button><mq-button variant="primary" ?disabled="${o}" @click="${this.handleConfirmClick}">${r("Confirmar")}</mq-button></div></div></mq-dialog>`}};i([v({type:Boolean,reflect:!0})],W.prototype,"open",void 0),i([o({context:T,subscribe:!0})],W.prototype,"queryClientContext",void 0),i([v({type:String})],W.prototype,"appointmentId",void 0),i([v({type:Object})],W.prototype,"price",void 0),W=i([l(),n("cancel-appointment-confirmation-dialog")],W);let K=class AppointmentActionUnavailableDialog extends d{constructor(){super(...arguments),this.open=!1,this.heading="",this.message="",this.handleClose=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}}static{this.styles=m`:host{display:contents}mq-dialog::part(dialog){max-width:343px;min-width: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}p{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);margin:0}.actions{display:flex;margin-top:var(--sp-4)}`}render(){return h`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${this.heading}</h2><p slot="subheading">${this.message}</p><div class="actions"><mq-button variant="primary" fullwidth @click="${this.handleClose}">${r("Volver")}</mq-button></div></mq-dialog>`}};i([v({type:Boolean,reflect:!0})],K.prototype,"open",void 0),i([v({type:String})],K.prototype,"heading",void 0),i([v({type:String})],K.prototype,"message",void 0),K=i([l(),n("appointment-action-unavailable-dialog")],K);let Y=class AppointmentCardActions extends d{constructor(){super(...arguments),this.variant="next",this.isVideocall=!1,this.hasChatSupport=!1,this.unreadCount=0,this.isModifyUnavailable=!1,this.isCancelUnavailable=!1,this.hasNoSlots=!1,this.modifyUnavailableMessage="",this.cancelUnavailableMessage="",this.repeatTarget=null,this.professionalHash="",this.openDialog=null,this.handleModifyClick=()=>{this.isModifyUnavailable?this.openDialog="modify":(H.track(V(this.patientHash,this.appointmentId)),this.dispatchEvent(new f({appointmentId:this.appointmentId})))},this.handleCancelClick=()=>{this.isCancelUnavailable?this.openDialog="cancel":(H.track(S(this.patientHash,this.appointmentId)),this.dispatchEvent(new CustomEvent("request-cancel",{bubbles:!0,composed:!0})))},this.handleRepeatClick=()=>{this.hasNoSlots?this.openDialog="repeat-no-slots":this.repeatTarget?(H.track(M(this.patientHash,this.appointmentId)),this.dispatchEvent(new b({specialty:this.repeatTarget.specialty,service:this.repeatTarget.service,professional:this.professionalHash}))):this.openDialog="repeat-error"},this.handleDialogClose=()=>{this.openDialog=null}}static{this.styles=m`:host{display:contents}.actions{display:flex;gap:var(--sp-3);margin-top:var(--sp-2)}.actions.next{flex-direction:column}.actions-secondary{display:flex;gap:var(--sp-3)}.actions mq-button{flex:1}`}get patientHash(){return this.loginToken.patient.hash}renderChatButton(){return h`<mq-button variant="primary" fullwidth noPadding @click="${()=>{this.dispatchEvent(new CustomEvent("toggle-chat",{bubbles:!0,composed:!0}))}}">${Z({size:24})} ${r("Chat")} ${this.unreadCount>0?h`<mq-unread-badge></mq-unread-badge>`:u}</mq-button>`}renderNextActions(){return h`${this.isVideocall?h`<mq-button variant="outline" fullwidth noPadding @click="${()=>{H.track(R(this.patientHash,this.appointmentId)),this.dispatchEvent(new y({appointmentId:this.appointmentId}))}}">${L({size:24})} ${r("Ir a videollamada")}</mq-button>`:u}<div class="actions-secondary">${this.hasChatSupport?this.renderChatButton():u}<mq-button variant="outline" fullwidth noPadding @click="${this.handleModifyClick}">${r("Modificar")}</mq-button><mq-button variant="outline-negative" fullwidth noPadding @click="${this.handleCancelClick}">${r("Cancelar")}</mq-button></div>`}renderHistoryActions(){return h`${this.hasChatSupport?this.renderChatButton():u}<mq-button variant="outline" fullwidth noPadding @click="${()=>{H.track(E(this.patientHash,this.appointmentId)),this.dispatchEvent(new x({appointmentId:this.appointmentId}))}}">${r("Documentos")}</mq-button><mq-button variant="outline" fullwidth noPadding @click="${this.handleRepeatClick}">${r("Repetir")}</mq-button>`}render(){return h`<div class="${B({actions:!0,next:"next"===this.variant})}">${"next"===this.variant?this.renderNextActions():this.renderHistoryActions()}</div><appointment-action-unavailable-dialog .open="${"modify"===this.openDialog}" .heading="${r("Modificar cita")}" .message="${this.modifyUnavailableMessage}" @close="${this.handleDialogClose}"></appointment-action-unavailable-dialog><appointment-action-unavailable-dialog .open="${"cancel"===this.openDialog}" .heading="${r("Anular cita")}" .message="${this.cancelUnavailableMessage}" @close="${this.handleDialogClose}"></appointment-action-unavailable-dialog><appointment-action-unavailable-dialog .open="${"repeat-no-slots"===this.openDialog}" .heading="${r("Repetir cita")}" .message="${r("Este profesional no tiene horarios disponibles")}" @close="${this.handleDialogClose}"></appointment-action-unavailable-dialog><appointment-action-unavailable-dialog .open="${"repeat-error"===this.openDialog}" .heading="${r("Repetir cita")}" .message="${r("Lo sentimos, no hemos podido repetir tu cita. Por favor, contacta con soporte.")}" @close="${this.handleDialogClose}"></appointment-action-unavailable-dialog>`}};function J(t){const{action:e,refundPolicySeconds:i}=t,n=null!=i&&i<3600,a=Math.ceil((i??0)/60),o=Math.ceil((i??0)/3600);return r(0===(n?a:o)?"modify"===e?"Esta cita ya ha pasado, por lo que no se puede modificar.":"Esta cita ya ha pasado, por lo que no se puede anular.":"modify"===e?n?p`Lo sentimos, como faltan menos de ${a} minutos para tu cita no podemos modificarla.`:p`Lo sentimos, como faltan menos de ${o} horas para tu cita no podemos modificarla.`:n?p`Lo sentimos, como faltan menos de ${a} minutos para tu cita no podemos anularla.`:p`Lo sentimos, como faltan menos de ${o} horas para tu cita no podemos anularla.`)}i([o({context:c})],Y.prototype,"loginToken",void 0),i([v({type:String})],Y.prototype,"variant",void 0),i([v({type:String})],Y.prototype,"appointmentId",void 0),i([v({type:Boolean})],Y.prototype,"isVideocall",void 0),i([v({type:Boolean})],Y.prototype,"hasChatSupport",void 0),i([v({type:Number})],Y.prototype,"unreadCount",void 0),i([v({type:Boolean})],Y.prototype,"isModifyUnavailable",void 0),i([v({type:Boolean})],Y.prototype,"isCancelUnavailable",void 0),i([v({type:Boolean})],Y.prototype,"hasNoSlots",void 0),i([v({type:String})],Y.prototype,"modifyUnavailableMessage",void 0),i([v({type:String})],Y.prototype,"cancelUnavailableMessage",void 0),i([v({type:Object})],Y.prototype,"repeatTarget",void 0),i([v({type:String})],Y.prototype,"professionalHash",void 0),i([U()],Y.prototype,"openDialog",void 0),Y=i([l(),n("appointment-card-actions")],Y);let X=class AppointmentCard extends d{constructor(){super(...arguments),this.variant="next",this.detailsVariant="wide",this.isChatOpen=!1,this.isCancelDialogOpen=!1,this.unreadQuery=new s(this,()=>_(k,{roomId:this.appointmentResource?.room?.id})),this.getOrganizationSpecialtiesQuery=new s(this,()=>z(k,{enabled:!!this.appointmentResource?.speciality?.id})),this.getOrganizationSetupQuery=new s(this,()=>j(k)),this.getScheduleServicesQuery=new s(this,()=>O(k))}static{this.styles=m`:host{display:flex}.card{width:100%;padding:var(--sp-6);display:flex;flex-direction:column;gap:var(--sp-4);justify-content:space-between}.card-top-content{display:flex;flex-direction:column;gap:var(--sp-6)}.see-details{color:var(--color-primary-link-default);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-bold)}.see-details:hover{text-decoration:underline}.chevron-down{width:16px;height:16px;transition:transform .2s ease}.appointment-details{display:flex;flex-direction:column;gap:12px}.clock-icon-wrapper{width:24px;height:24px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.clock-icon-wrapper svg{width:100%;height:100%}.appointment-type{display:flex;align-items:center;gap:12px;font-size:18px;color:#2c3e50}.actions{display:flex;gap:var(--sp-3);margin-top:var(--sp-2)}.actions.next{flex-direction:column}.actions-secondary{display:flex;gap:var(--sp-3)}.actions mq-button{flex:1}`}render(){const t=this.appointmentResource.appointment.channel===q.videocall,e=this.appointmentResource.appointment.channel===q.phonecall,i=!0===this.getOrganizationSetupQuery.result?.data?.appointments?.has_chat_in_appointment,n=(t||e)&&i,a=Q(),o=w(this.appointmentResource.appointment.expires_at),s=0===this.appointmentResource.slots.length,p=this.getOrganizationSetupQuery.result?.data?.appointments?.seconds_before_start_to_refund_on_cancel,l=N({startsAtIso:this.appointmentResource.appointment.starts_at,refundPolicySeconds:p}),c=o||s||!l,d=o||!l,m=J({action:"modify",refundPolicySeconds:p}),v=J({action:"cancel",refundPolicySeconds:p}),g=this.getOrganizationSpecialtiesQuery.result?.data?.find(t=>Number(t.id)===Number(this.appointmentResource.speciality.id)),f=D(g?.code??"",a,g?.name??this.appointmentResource.speciality.name),b=this.getScheduleServicesQuery.result?.data?.find(t=>t.id===this.appointmentResource.appointment.service_id)?.code,y=g?.code&&b?{specialty:g.code,service:b}:null;return h`<mq-card class="card" roundness="md"><div class="card-top-content"><professional-overview .specialtyName="${f??""}" .collegiateNumber="${this.appointmentResource.professional.collegiate_number??void 0}" .description="${this.appointmentResource.professional.description??""}" .languages="${this.appointmentResource.professional.languages}" .avatar="${this.appointmentResource.professional.avatar??""}" .name="${this.appointmentResource.professional.name}"></professional-overview><appointment-details .startsAt="${this.appointmentResource.appointment.starts_at}" .duration="${this.appointmentResource.appointment.duration}" .channel="${this.appointmentResource.appointment.channel}" .timezone="${this.loginToken?.patient?.timezone}" variant="${this.detailsVariant}"></appointment-details></div><appointment-card-actions .variant="${this.variant}" .appointmentId="${this.appointmentResource.appointment.id??""}" .isVideocall="${t}" .hasChatSupport="${n}" .unreadCount="${this.unreadQuery.result?.data?.unread_count??0}" .isModifyUnavailable="${c}" .isCancelUnavailable="${d}" .hasNoSlots="${s}" .modifyUnavailableMessage="${m}" .cancelUnavailableMessage="${v}" .repeatTarget="${y}" .professionalHash="${this.appointmentResource.professional.hash}" @toggle-chat="${()=>{this.isChatOpen=!this.isChatOpen,this.isChatOpen&&H.track(I(this.loginToken.patient.hash,this.appointmentResource.appointment.id??""))}}" @request-cancel="${()=>{this.isCancelDialogOpen=!0}}"></appointment-card-actions><mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" @mq-close="${()=>{this.isChatOpen=!1}}" hideCloseButton>${this.isChatOpen?h`<mq-chat-room slot="content" .consultationId="${this.appointmentResource.appointment.id}" consultation-type="appointment" token="${this.loginToken.access_token}" .roomId="${this.appointmentResource.room.id}" .professionalHash="${this.appointmentResource.professional.hash}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}" ?readonly="${o}"></mq-chat-room>`:u}</mq-floating-bubble><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,G.success(r("Consulta anulada correctamente")),this.dispatchEvent(new CustomEvent("appointment-cancel-confirmed",{bubbles:!0,composed:!0,detail:{id:this.appointmentResource.appointment.id}}))}}"></cancel-appointment-confirmation-dialog></mq-card>`}};i([v({type:Object})],X.prototype,"appointmentResource",void 0),i([v({type:Number})],X.prototype,"specialtyId",void 0),i([v({type:String})],X.prototype,"variant",void 0),i([v({type:String})],X.prototype,"detailsVariant",void 0),i([o({context:c})],X.prototype,"loginToken",void 0),i([U()],X.prototype,"isChatOpen",void 0),i([U()],X.prototype,"isCancelDialogOpen",void 0),X=i([l(),n("appointment-card")],X);let tt=class AppointmentCardSkeleton extends d{static{this.styles=m`div{border-radius:var(--border-radius-md);background:color-mix(in srgb,var(--color-neutrals-background-disabled) 50%,#fff 50%);height:337px;width:100%}`}render(){return h`<div></div>`}};tt=i([n("appointment-card-skeleton")],tt);let et=class EmptyState extends d{static{this.styles=m`.container{border-radius:var(--border-radius-md);background-color:var(--color-neutrals-background-weak);padding:var(--sp-10) var(--sp-6)}.card{border-radius:var(--border-radius-md);max-width:512px;margin:0 auto;background-color:var(--color-neutrals-background-extraWeak);padding:var(--sp-6);display:flex;flex-direction:column;align-items:center;gap:var(--sp-3)}.card>*{max-width:323px;margin:0 auto}.title{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0}.description{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal);text-align:center;color:var(--color-neutrals-text-default);margin:0}@media (min-width:768px){.container{padding:var(--sp-6)}mq-button{max-width:323px}}`}handleRequestAppointment(){this.dispatchEvent(new CustomEvent("request-appointment",{bubbles:!0,composed:!0}))}render(){return h`<div class="container"><div class="card">${function({color:t="currentColor"}){return h`<svg width="31" height="32" viewBox="0 0 31 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M29.6 2.4H23.2V0H21.6V2.4H18.4V0H16.8V2.4H13.6V0H12V2.4H8.8V0H7.2V2.4H0.8C0.587827 2.4 0.384344 2.48429 0.234315 2.63431C0.0842855 2.78434 0 2.98783 0 3.2V31.2C0 31.4122 0.0842855 31.6157 0.234315 31.7657C0.384344 31.9157 0.587827 32 0.8 32H29.6C29.8122 32 30.0157 31.9157 30.1657 31.7657C30.3157 31.6157 30.4 31.4122 30.4 31.2V3.2C30.4 2.98783 30.3157 2.78434 30.1657 2.63431C30.0157 2.48429 29.8122 2.4 29.6 2.4ZM28.8 30.4H1.6V10.4H27.2V8.8H1.6V4H7.2V7.2H8.8V4H12V7.2H13.6V4H16.8V7.2H18.4V4H21.6V7.2H23.2V4H28.8V30.4ZM3.2 19.2H9.6V12.8H3.2V19.2ZM4.8 14.4H8V17.6H4.8V14.4ZM20.8 19.2H27.2V12.8H20.8V19.2ZM22.4 14.4H25.6V17.6H22.4V14.4ZM12 19.2H18.4V12.8H12V19.2ZM13.6 14.4H16.8V17.6H13.6V14.4ZM3.2 28H9.6V21.6H3.2V28ZM4.8 23.2H8V26.4H4.8V23.2ZM20.8 28H27.2V21.6H20.8V28ZM22.4 23.2H25.6V26.4H22.4V23.2ZM12 28H18.4V21.6H12V28ZM13.6 23.2H16.8V26.4H13.6V23.2Z" fill="${t}"/></svg>`}({color:"var(--color-primary)"})}<p class="title">${this.title}</p><p class="description">${this.description}</p><mq-button variant="primary" size="md" fullwidth @click="${this.handleRequestAppointment}">${r("Pedir cita")}</mq-button></div></div>`}};function it(t,e){return{queryKey:["appointments",e],queryFn:()=>t.appointments.getAppointments(e)}}i([v({type:String})],et.prototype,"title",void 0),i([v({type:String})],et.prototype,"description",void 0),et=i([n("empty-state")],et);const nt=[C.pending,C.accepted],at=m`.appointments-list{display:grid;grid-template-columns:1fr;gap:var(--sp-6);margin-bottom:var(--sp-6)}@media (min-width:768px){.appointments-list{grid-template-columns:repeat(2,1fr)}}`;let ot=class NextAppointmentsTab extends d{constructor(){super(...arguments),this.getAppointmentsQuery=new s(this,()=>it(k,{status:nt,order:{field:"starts_at",direction:"asc"}}))}static{this.styles=at}render(){return this.getAppointmentsQuery.render({complete:t=>h`${t.data.length>0?h`<div class="appointments-list">${t.data.map(t=>h`<appointment-card .appointmentResource="${t}" .specialtyId="${t.speciality?.id}"></appointment-card>`)}</div>`:h`<empty-state title="${r("No tienes próximas citas")}" description="${r("Agenda una consulta médica cuando la necesites. Aquí verás todos los detalles y podrás gestionar tus próximas citas.")}"></empty-state>`}`,pending:()=>h`<div class="appointments-list"><appointment-card-skeleton></appointment-card-skeleton><appointment-card-skeleton></appointment-card-skeleton><appointment-card-skeleton></appointment-card-skeleton></div>`})}};ot=i([l(),n("next-appointments-tab")],ot);const st=[C.finished,C.reporting];let rt=class AppointmentsHistoryTab extends d{constructor(){super(...arguments),this.getAppointmentsQuery=new s(this,()=>it(k,{status:st,order:{field:"starts_at",direction:"desc"}}))}static{this.styles=m`.appointments-list{display:grid;grid-template-columns:1fr;gap:var(--sp-6);margin-bottom:var(--sp-6)}@media (min-width:768px){.appointments-list{grid-template-columns:repeat(2,1fr)}}`}render(){return this.getAppointmentsQuery.render({complete:t=>h`${t.data.length>0?h`<div class="appointments-list">${t.data.map(t=>h`<appointment-card .appointmentResource="${t}" .specialtyId="${t.speciality?.id}" variant="history"></appointment-card>`)}</div>`:h`<empty-state title="${r("No tienes citas en el historial")}" description="${r("Aquí verás todas las citas que has tenido. Puedes acceder a los documentos de cada consulta y reagendar una cita si es necesario.")}"></empty-state>`}`,pending:()=>h`<div class="appointments-list"><appointment-card-skeleton></appointment-card-skeleton><appointment-card-skeleton></appointment-card-skeleton><appointment-card-skeleton></appointment-card-skeleton></div>`})}};rt=i([l(),n("appointments-history-tab")],rt);const pt=m`.container{display:flex;flex-direction:column;gap:var(--size-3)}h1{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-neutral-link-dark);margin:0}p{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);font-weight:var(--font-weight-normal);color:var(--color-neutral-link-dark);margin:0}.user-info{display:flex;align-items:center;justify-content:space-between}@media (min-width:768px){h1{font-size:var(--text-3xl);line-height:var(--text-3xl--line-height)}mq-tabs-list{max-width:435px}}`;let lt=class MqMyAppointments extends d{constructor(){super(...arguments),this.tab=F.next}static{this.styles=pt}handleSelect(t){this.dispatchEvent(new MqMyAppointmentsSelectEvent(t.value))}render(){return h`<div class="container"><back-link @mq-back="${t=>{t.stopPropagation(),this.dispatchEvent(new $)}}">${r("Volver al inicio")}</back-link><h1>${r("Mis citas")}</h1><div class="user-info"><p>${r(p`Para: ${this.loginToken.patient.name}`)}</p></div><mq-tabs .value="${this.tab}" @onvaluechange="${this.handleSelect}"><mq-tabs-list><mq-tabs-trigger value="${F.next}">${r("Próximas citas")}</mq-tabs-trigger><mq-tabs-trigger value="${F.history}">${r("Histórico")}</mq-tabs-trigger></mq-tabs-list><mq-tabs-content value="${F.next}"><next-appointments-tab></next-appointments-tab></mq-tabs-content><mq-tabs-content value="${F.history}"><appointments-history-tab></appointments-history-tab></mq-tabs-content></mq-tabs></div>`}};i([o({context:c})],lt.prototype,"loginToken",void 0),i([v({type:String,reflect:!0})],lt.prototype,"tab",void 0),lt=i([l(),n("mq-my-appointments")],lt);const ct=m`:host{display:block}.request-appointment-cta{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:space-between;padding:var(--sp-12) var(--sp-4);background:var(--color-card);gap:var(--sp-4)}.title-body{display:flex;flex-direction:column;gap:var(--sp-2);flex:1}.title{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0;text-align:center}.subtitle{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);font-weight:var(--font-weight-normal);color:var(--color-neutrals-text-default);margin:0;display:none}mq-button{width:100%}.button-text-desktop{display:none}.button-text-mobile{display:inline}@media (min-width:768px){.request-appointment-cta{flex-direction:row;padding:var(--sp-12) var(--sp-20);gap:var(--sp-2)}.title-body{align-items:flex-start;flex:1;max-width:843px}.title{font-size:var(--text-3xl);line-height:var(--text-3xl--line-height);font-weight:var(--font-weight-extrabold);text-align:left}.subtitle{display:block}mq-button{width:auto;flex-shrink:0;--button-height-md:var(--button-height-lg);--text-sm:var(--text-base);--text-sm--line-height:var(--text-base--line-height)}.button-text-desktop{display:inline}.button-text-mobile{display:none}}`;class RequestAppointmentEvent extends Event{static{this.eventName="request-appointment"}constructor(){super(RequestAppointmentEvent.eventName,{bubbles:!0,composed:!0})}}let dt=class RequestAppointmentCta extends d{static{this.styles=ct}handleRequestAppointment(){this.dispatchEvent(new RequestAppointmentEvent)}render(){return h`<div class="request-appointment-cta"><div class="title-body"><h2 class="title">${r("Nueva cita de especialidades digitales")}</h2><p class="subtitle">${r("Realiza la búsqueda en tu cuadro médico digital")}</p></div><mq-button variant="primary" size="md" fullwidth @click="${this.handleRequestAppointment}"><span class="button-text-mobile">${r("Pedir cita")}</span> <span class="button-text-desktop">${r("Pedir una nueva cita")}</span></mq-button></div>`}};dt=i([l(),n("request-appointment-cta")],dt);export{lt as MqMyAppointments,MqMyAppointmentsSelectEvent,dt as RequestAppointmentCta,RequestAppointmentEvent};
1
+ import{h as t,f as e}from"./chunks/price-tImUmtpX.js";export{A as AppointmentDetails}from"./chunks/price-tImUmtpX.js";import{_ as i,t as n}from"./chunks/custom-element-DA9Fxvxd.js";import{M as a,c as o,Q as s}from"./chunks/mutation-controller-OVT8NEt6.js";import{m as r,s as p}from"./chunks/runtime-Bg1WXVCx.js";import{l}from"./chunks/parseISO-jT42c8Ob.js";import{l as c}from"./chunks/chunk-S5RWG6G2-oTcdgk2H.js";import{a as d,i as m,x as h,E as u}from"./chunks/lit-element-DiWJYFwC.js";import{n as v}from"./chunks/property-scuRaFcM.js";import{e as g}from"./chunks/external-zAbuzxDj.js";import{MqAppointmentRescheduleEvent as f,MqAppointmentBookEvent as b,MqAppointmentJoinVideocallEvent as y,MqAppointmentViewDocumentationEvent as x,MqHomeEvent as $}from"./events.js";import"./ui/mq-tabs.js";import{b as k,A as q,c as w,d as C}from"./chunks/api-chat-client-C8SqZtCa.js";import{g as j}from"./chunks/get-organization-setup-query-BMbuRi6v.js";import{t as H,h as V,i as S,j as M,k as R,l as E,g as z,c as D,m as I}from"./chunks/telemetry-client-BRVJU-fZ.js";export{P as ProfessionalOverview}from"./chunks/telemetry-client-BRVJU-fZ.js";import{g as O,c as N}from"./chunks/refund-cancel-policy-CnbrIqH0.js";import{g as _}from"./chunks/exports-G_7Ih_GH.js";import{r as U}from"./chunks/state-LQivXIgA.js";import{getLocale as Q}from"./i18n.js";import"./ui/mq-card.js";import"./ui/mq-floating-bubble.js";import{Q as T}from"./chunks/query-QJ1INUTG.js";import"./ui/mq-button.js";import"./ui/mq-dialog.js";import{e as Z}from"./chunks/class-map-Co76I6aw.js";import{messageBubbleIcon as B}from"./ui/icons/message-bubble-icon.js";import{videoIcon as L}from"./ui/icons/video-icon.js";import"./ui/mq-unread-badge.js";import{toast as G}from"./ui/mq-toast.js";import"./ui/back-link.js";import"./ui/icons/briefcase-icon.js";import"./ui/icons/types.js";import"./ui/icons/calendar-icon.js";import"./ui/icons/clock-icon.js";import"./ui/icons/phone-icon.js";import"./chunks/context-request-event-Dfydf1ub.js";import"./chunks/context-provider-CiMFpvDA.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.js";import"./env.js";import"./ui/icons/chevron-down-icon.js";import"./chunks/if-defined-BYeVdwgd.js";import"./ui/mq-text-button.js";import"./chunks/directive-2EDmOukv.js";import"./ui/mq-avatar.js";import"./chunks/provide-CfT7g_Zi.js";import"./theme.js";import"./ui/icons/x-icon.js";import"./ui/mq-skeleton.js";import"./chunks/style-map-CIdqdn7C.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./ui/icons/check-double-icon.js";import"./ui/icons/check-icon.js";import"./chunks/chunk-YTQUGGS3-DN-JZpgG.js";const F=g(["next","history"]).enum;class MqMyAppointmentsSelectEvent extends Event{static{this.eventName="ontabchange"}constructor(t){super(MqMyAppointmentsSelectEvent.eventName,{bubbles:!0,composed:!0}),this.value=t}}let W=class CancelAppointmentConfirmationDialog extends d{constructor(){super(...arguments),this.open=!1,this.cancelAppointmentMutation=new a(this,{mutationFn:async t=>k.appointments.cancelAppointment(t),onSuccess:()=>{this.queryClientContext?.invalidateQueries(),this.dispatchEvent(new CustomEvent("success",{bubbles:!0,composed:!0}))}}),this.handleClose=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))},this.handleDismissClick=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("cancel",{bubbles:!0,composed:!0}))},this.handleConfirmClick=()=>{this.cancelAppointmentMutation.run({id:this.appointmentId})}}static{this.styles=m`:host{display:contents}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}p{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);margin:0}.subheading-payable{font-size:var(--text-base);line-height:22px}.price-rows{display:flex;flex-direction:column;font-family:var(--font-body);font-size:var(--text-sm);font-weight:var(--font-weight-medium);line-height:var(--text-sm--line-height);color:var(--color-card-foreground);width:100%;margin-bottom:var(--sp-4)}.price-row{display:flex;align-items:center;justify-content:space-between;min-height:34px;gap:var(--sp-2)}.price-row span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.actions{display:flex;gap:var(--sp-3);margin-top:var(--sp-4);justify-content:flex-end;flex-wrap:wrap}`}render(){const i=Q(),n=this.price,a=t(n),o=this.cancelAppointmentMutation.isPending;if(a){const t=e(n,i),a=`-${t}`;return h`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${r("Confirmar cancelación")}</h2><p slot="subheading" class="subheading-payable">${r("¿Seguro que quieres cancelar esta cita? Se te devolverá el importe pagado en un plazo de 5-10 días hábiles.")}</p><div><div class="price-rows"><div class="price-row"><span>${r("Importe pagado")}</span> <span>${t}</span></div><div class="price-row"><span>${r("Importe a devolver")}</span> <span>${a}</span></div></div><div class="actions"><mq-button variant="outline" ?disabled="${o}" @click="${this.handleDismissClick}">${r("Volver")}</mq-button><mq-button variant="primary" ?disabled="${o}" @click="${this.handleConfirmClick}">${r("Confirmar")}</mq-button></div></div></mq-dialog>`}return h`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${r("Confirmar cancelación")}</h2><p slot="subheading">${r("¿Seguro que quieres cancelar esta cita?")}</p><div><div class="actions"><mq-button variant="outline" ?disabled="${o}" @click="${this.handleDismissClick}">${r("Cancelar")}</mq-button><mq-button variant="primary" ?disabled="${o}" @click="${this.handleConfirmClick}">${r("Confirmar")}</mq-button></div></div></mq-dialog>`}};i([v({type:Boolean,reflect:!0})],W.prototype,"open",void 0),i([o({context:T,subscribe:!0})],W.prototype,"queryClientContext",void 0),i([v({type:String})],W.prototype,"appointmentId",void 0),i([v({type:Object})],W.prototype,"price",void 0),W=i([l(),n("cancel-appointment-confirmation-dialog")],W);let K=class AppointmentActionUnavailableDialog extends d{constructor(){super(...arguments),this.open=!1,this.heading="",this.message="",this.handleClose=()=>{this.open=!1,this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}}static{this.styles=m`:host{display:contents}mq-dialog::part(dialog){max-width:343px;min-width: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}p{font-family:var(--font-body);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-normal);margin:0}.actions{display:flex;margin-top:var(--sp-4)}`}render(){return h`<mq-dialog .open="${this.open}" @mq-close="${this.handleClose}" dismissable><h2 slot="heading">${this.heading}</h2><p slot="subheading">${this.message}</p><div class="actions"><mq-button variant="primary" fullwidth @click="${this.handleClose}">${r("Volver")}</mq-button></div></mq-dialog>`}};i([v({type:Boolean,reflect:!0})],K.prototype,"open",void 0),i([v({type:String})],K.prototype,"heading",void 0),i([v({type:String})],K.prototype,"message",void 0),K=i([l(),n("appointment-action-unavailable-dialog")],K);let Y=class AppointmentCardActions extends d{constructor(){super(...arguments),this.variant="next",this.isVideocall=!1,this.hasChatSupport=!1,this.unreadCount=0,this.isModifyUnavailable=!1,this.isCancelUnavailable=!1,this.hasNoSlots=!1,this.modifyUnavailableMessage="",this.cancelUnavailableMessage="",this.repeatTarget=null,this.professionalHash="",this.openDialog=null,this.handleModifyClick=()=>{this.isModifyUnavailable?this.openDialog="modify":(H.track(V(this.patientHash,this.appointmentId)),this.dispatchEvent(new f({appointmentId:this.appointmentId})))},this.handleCancelClick=()=>{this.isCancelUnavailable?this.openDialog="cancel":(H.track(S(this.patientHash,this.appointmentId)),this.dispatchEvent(new CustomEvent("request-cancel",{bubbles:!0,composed:!0})))},this.handleRepeatClick=()=>{this.hasNoSlots?this.openDialog="repeat-no-slots":this.repeatTarget?(H.track(M(this.patientHash,this.appointmentId)),this.dispatchEvent(new b({specialty:this.repeatTarget.specialty,service:this.repeatTarget.service,professional:this.professionalHash}))):this.openDialog="repeat-error"},this.handleDialogClose=()=>{this.openDialog=null}}static{this.styles=m`:host{display:contents}.actions{display:flex;gap:var(--sp-3);margin-top:var(--sp-2)}.actions.next{flex-direction:column}.actions-secondary{display:flex;gap:var(--sp-3)}.actions mq-button{flex:1}`}get patientHash(){return this.loginToken.patient.hash}renderChatButton(){return h`<mq-button variant="primary" fullwidth noPadding @click="${()=>{this.dispatchEvent(new CustomEvent("toggle-chat",{bubbles:!0,composed:!0}))}}">${B({size:24})} ${r("Chat")} ${this.unreadCount>0?h`<mq-unread-badge></mq-unread-badge>`:u}</mq-button>`}renderNextActions(){return h`${this.isVideocall?h`<mq-button variant="outline" fullwidth noPadding @click="${()=>{H.track(R(this.patientHash,this.appointmentId)),this.dispatchEvent(new y({appointmentId:this.appointmentId}))}}">${L({size:24})} ${r("Ir a videollamada")}</mq-button>`:u}<div class="actions-secondary">${this.hasChatSupport?this.renderChatButton():u}<mq-button variant="outline" fullwidth noPadding @click="${this.handleModifyClick}">${r("Modificar")}</mq-button><mq-button variant="outline-negative" fullwidth noPadding @click="${this.handleCancelClick}">${r("Cancelar")}</mq-button></div>`}renderHistoryActions(){return h`${this.hasChatSupport?this.renderChatButton():u}<mq-button variant="outline" fullwidth noPadding @click="${()=>{H.track(E(this.patientHash,this.appointmentId)),this.dispatchEvent(new x({appointmentId:this.appointmentId}))}}">${r("Documentos")}</mq-button><mq-button variant="outline" fullwidth noPadding @click="${this.handleRepeatClick}">${r("Repetir")}</mq-button>`}render(){return h`<div class="${Z({actions:!0,next:"next"===this.variant})}">${"next"===this.variant?this.renderNextActions():this.renderHistoryActions()}</div><appointment-action-unavailable-dialog .open="${"modify"===this.openDialog}" .heading="${r("Modificar cita")}" .message="${this.modifyUnavailableMessage}" @close="${this.handleDialogClose}"></appointment-action-unavailable-dialog><appointment-action-unavailable-dialog .open="${"cancel"===this.openDialog}" .heading="${r("Anular cita")}" .message="${this.cancelUnavailableMessage}" @close="${this.handleDialogClose}"></appointment-action-unavailable-dialog><appointment-action-unavailable-dialog .open="${"repeat-no-slots"===this.openDialog}" .heading="${r("Repetir cita")}" .message="${r("Este profesional no tiene horarios disponibles")}" @close="${this.handleDialogClose}"></appointment-action-unavailable-dialog><appointment-action-unavailable-dialog .open="${"repeat-error"===this.openDialog}" .heading="${r("Repetir cita")}" .message="${r("Lo sentimos, no hemos podido repetir tu cita. Por favor, contacta con soporte.")}" @close="${this.handleDialogClose}"></appointment-action-unavailable-dialog>`}};function J(t){const{action:e,refundPolicySeconds:i}=t,n=null!=i&&i<3600,a=Math.ceil((i??0)/60),o=Math.ceil((i??0)/3600);return r(0===(n?a:o)?"modify"===e?"Esta cita ya ha pasado, por lo que no se puede modificar.":"Esta cita ya ha pasado, por lo que no se puede anular.":"modify"===e?n?p`Lo sentimos, como faltan menos de ${a} minutos para tu cita no podemos modificarla.`:p`Lo sentimos, como faltan menos de ${o} horas para tu cita no podemos modificarla.`:n?p`Lo sentimos, como faltan menos de ${a} minutos para tu cita no podemos anularla.`:p`Lo sentimos, como faltan menos de ${o} horas para tu cita no podemos anularla.`)}i([o({context:c})],Y.prototype,"loginToken",void 0),i([v({type:String})],Y.prototype,"variant",void 0),i([v({type:String})],Y.prototype,"appointmentId",void 0),i([v({type:Boolean})],Y.prototype,"isVideocall",void 0),i([v({type:Boolean})],Y.prototype,"hasChatSupport",void 0),i([v({type:Number})],Y.prototype,"unreadCount",void 0),i([v({type:Boolean})],Y.prototype,"isModifyUnavailable",void 0),i([v({type:Boolean})],Y.prototype,"isCancelUnavailable",void 0),i([v({type:Boolean})],Y.prototype,"hasNoSlots",void 0),i([v({type:String})],Y.prototype,"modifyUnavailableMessage",void 0),i([v({type:String})],Y.prototype,"cancelUnavailableMessage",void 0),i([v({type:Object})],Y.prototype,"repeatTarget",void 0),i([v({type:String})],Y.prototype,"professionalHash",void 0),i([U()],Y.prototype,"openDialog",void 0),Y=i([l(),n("appointment-card-actions")],Y);let X=class AppointmentCard extends d{constructor(){super(...arguments),this.variant="next",this.detailsVariant="wide",this.isChatOpen=!1,this.isCancelDialogOpen=!1,this.unreadQuery=new s(this,()=>_(k,{roomId:this.appointmentResource?.room?.id})),this.getOrganizationSpecialtiesQuery=new s(this,()=>z(k,{enabled:!!this.appointmentResource?.speciality?.id})),this.getOrganizationSetupQuery=new s(this,()=>j(k)),this.getScheduleServicesQuery=new s(this,()=>O(k))}static{this.styles=m`:host{display:flex}.card{width:100%;padding:var(--sp-6);display:flex;flex-direction:column;gap:var(--sp-4);justify-content:space-between}.card-top-content{display:flex;flex-direction:column;gap:var(--sp-6)}.see-details{color:var(--color-primary-link-default);font-size:var(--text-sm);line-height:var(--text-sm--line-height);font-weight:var(--font-weight-bold)}.see-details:hover{text-decoration:underline}.chevron-down{width:16px;height:16px;transition:transform .2s ease}.appointment-details{display:flex;flex-direction:column;gap:12px}.clock-icon-wrapper{width:24px;height:24px;display:flex;align-items:center;justify-content:center;flex-shrink:0}.clock-icon-wrapper svg{width:100%;height:100%}.appointment-type{display:flex;align-items:center;gap:12px;font-size:18px;color:#2c3e50}.actions{display:flex;gap:var(--sp-3);margin-top:var(--sp-2)}.actions.next{flex-direction:column}.actions-secondary{display:flex;gap:var(--sp-3)}.actions mq-button{flex:1}`}render(){const t=this.appointmentResource.appointment.channel===q.videocall,e=this.appointmentResource.appointment.channel===q.phonecall,i=!0===this.getOrganizationSetupQuery.result?.data?.appointments?.has_chat_in_appointment,n=(t||e)&&i,a=Q(),o=w(this.appointmentResource.appointment.expires_at),s=0===this.appointmentResource.slots.length,p=this.getOrganizationSetupQuery.result?.data?.appointments?.seconds_before_start_to_refund_on_cancel,l=N({startsAtIso:this.appointmentResource.appointment.starts_at,refundPolicySeconds:p}),c=o||s||!l,d=o||!l,m=J({action:"modify",refundPolicySeconds:p}),v=J({action:"cancel",refundPolicySeconds:p}),g=this.getOrganizationSpecialtiesQuery.result?.data?.find(t=>Number(t.id)===Number(this.appointmentResource.speciality.id)),f=D(g?.code??"",a,g?.name??this.appointmentResource.speciality.name),b=this.getScheduleServicesQuery.result?.data?.find(t=>t.id===this.appointmentResource.appointment.service_id)?.code,y=g?.code&&b?{specialty:g.code,service:b}:null;return h`<mq-card class="card" roundness="md"><div class="card-top-content"><professional-overview .specialtyName="${f??""}" .collegiateNumber="${this.appointmentResource.professional.collegiate_number??void 0}" .description="${this.appointmentResource.professional.description??""}" .languages="${this.appointmentResource.professional.languages}" .avatar="${this.appointmentResource.professional.avatar??""}" .name="${this.appointmentResource.professional.name}"></professional-overview><appointment-details .startsAt="${this.appointmentResource.appointment.starts_at}" .duration="${this.appointmentResource.appointment.duration}" .channel="${this.appointmentResource.appointment.channel}" .timezone="${this.loginToken?.patient?.timezone}" variant="${this.detailsVariant}"></appointment-details></div><appointment-card-actions .variant="${this.variant}" .appointmentId="${this.appointmentResource.appointment.id??""}" .isVideocall="${t}" .hasChatSupport="${n}" .unreadCount="${this.unreadQuery.result?.data?.unread_count??0}" .isModifyUnavailable="${c}" .isCancelUnavailable="${d}" .hasNoSlots="${s}" .modifyUnavailableMessage="${m}" .cancelUnavailableMessage="${v}" .repeatTarget="${y}" .professionalHash="${this.appointmentResource.professional.hash}" @toggle-chat="${()=>{this.isChatOpen=!this.isChatOpen,this.isChatOpen&&H.track(I(this.loginToken.patient.hash,this.appointmentResource.appointment.id??""))}}" @request-cancel="${()=>{this.isCancelDialogOpen=!0}}"></appointment-card-actions><mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" @mq-close="${()=>{this.isChatOpen=!1}}" hideCloseButton>${this.isChatOpen?h`<mq-chat-room slot="content" .consultationId="${this.appointmentResource.appointment.id}" consultation-type="appointment" token="${this.loginToken.access_token}" .roomId="${this.appointmentResource.room.id}" .professionalHash="${this.appointmentResource.professional.hash}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}" ?readonly="${o}"></mq-chat-room>`:u}</mq-floating-bubble><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,G.success(r("Consulta anulada correctamente")),this.dispatchEvent(new CustomEvent("appointment-cancel-confirmed",{bubbles:!0,composed:!0,detail:{id:this.appointmentResource.appointment.id}}))}}"></cancel-appointment-confirmation-dialog></mq-card>`}};i([v({type:Object})],X.prototype,"appointmentResource",void 0),i([v({type:Number})],X.prototype,"specialtyId",void 0),i([v({type:String})],X.prototype,"variant",void 0),i([v({type:String})],X.prototype,"detailsVariant",void 0),i([o({context:c})],X.prototype,"loginToken",void 0),i([U()],X.prototype,"isChatOpen",void 0),i([U()],X.prototype,"isCancelDialogOpen",void 0),X=i([l(),n("appointment-card")],X);let tt=class AppointmentCardSkeleton extends d{static{this.styles=m`div{border-radius:var(--border-radius-md);background:color-mix(in srgb,var(--color-neutrals-background-disabled) 50%,#fff 50%);height:337px;width:100%}`}render(){return h`<div></div>`}};tt=i([n("appointment-card-skeleton")],tt);let et=class EmptyState extends d{static{this.styles=m`.container{border-radius:var(--border-radius-md);background-color:var(--color-neutrals-background-weak);padding:var(--sp-10) var(--sp-6)}.card{border-radius:var(--border-radius-md);max-width:512px;margin:0 auto;background-color:var(--color-neutrals-background-extraWeak);padding:var(--sp-6);display:flex;flex-direction:column;align-items:center;gap:var(--sp-3)}.card>*{max-width:323px;margin:0 auto}.title{font-family:var(--font-body);font-size:var(--text-lg);line-height:var(--text-lg--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0}.description{font-family:var(--font-body);font-size:var(--text-xs);line-height:var(--text-xs--line-height);font-weight:var(--font-weight-normal);text-align:center;color:var(--color-neutrals-text-default);margin:0}@media (min-width:768px){.container{padding:var(--sp-6)}mq-button{max-width:323px}}`}handleRequestAppointment(){this.dispatchEvent(new CustomEvent("request-appointment",{bubbles:!0,composed:!0}))}render(){return h`<div class="container"><div class="card">${function({color:t="currentColor"}){return h`<svg width="31" height="32" viewBox="0 0 31 32" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M29.6 2.4H23.2V0H21.6V2.4H18.4V0H16.8V2.4H13.6V0H12V2.4H8.8V0H7.2V2.4H0.8C0.587827 2.4 0.384344 2.48429 0.234315 2.63431C0.0842855 2.78434 0 2.98783 0 3.2V31.2C0 31.4122 0.0842855 31.6157 0.234315 31.7657C0.384344 31.9157 0.587827 32 0.8 32H29.6C29.8122 32 30.0157 31.9157 30.1657 31.7657C30.3157 31.6157 30.4 31.4122 30.4 31.2V3.2C30.4 2.98783 30.3157 2.78434 30.1657 2.63431C30.0157 2.48429 29.8122 2.4 29.6 2.4ZM28.8 30.4H1.6V10.4H27.2V8.8H1.6V4H7.2V7.2H8.8V4H12V7.2H13.6V4H16.8V7.2H18.4V4H21.6V7.2H23.2V4H28.8V30.4ZM3.2 19.2H9.6V12.8H3.2V19.2ZM4.8 14.4H8V17.6H4.8V14.4ZM20.8 19.2H27.2V12.8H20.8V19.2ZM22.4 14.4H25.6V17.6H22.4V14.4ZM12 19.2H18.4V12.8H12V19.2ZM13.6 14.4H16.8V17.6H13.6V14.4ZM3.2 28H9.6V21.6H3.2V28ZM4.8 23.2H8V26.4H4.8V23.2ZM20.8 28H27.2V21.6H20.8V28ZM22.4 23.2H25.6V26.4H22.4V23.2ZM12 28H18.4V21.6H12V28ZM13.6 23.2H16.8V26.4H13.6V23.2Z" fill="${t}"/></svg>`}({color:"var(--color-primary)"})}<p class="title">${this.title}</p><p class="description">${this.description}</p><mq-button variant="primary" size="md" fullwidth @click="${this.handleRequestAppointment}">${r("Pedir cita")}</mq-button></div></div>`}};function it(t,e){return{queryKey:["appointments",e],queryFn:()=>t.appointments.getAppointments(e)}}i([v({type:String})],et.prototype,"title",void 0),i([v({type:String})],et.prototype,"description",void 0),et=i([n("empty-state")],et);const nt=[C.pending,C.accepted],at=m`.appointments-list{display:grid;grid-template-columns:1fr;gap:var(--sp-6);margin-bottom:var(--sp-6)}@media (min-width:768px){.appointments-list{grid-template-columns:repeat(2,1fr)}}`;let ot=class NextAppointmentsTab extends d{constructor(){super(...arguments),this.getAppointmentsQuery=new s(this,()=>it(k,{status:nt,order:{field:"starts_at",direction:"asc"}}))}static{this.styles=at}render(){return this.getAppointmentsQuery.render({complete:t=>h`${t.data.length>0?h`<div class="appointments-list">${t.data.map(t=>h`<appointment-card .appointmentResource="${t}" .specialtyId="${t.speciality?.id}"></appointment-card>`)}</div>`:h`<empty-state title="${r("No tienes próximas citas")}" description="${r("Agenda una consulta médica cuando la necesites. Aquí verás todos los detalles y podrás gestionar tus próximas citas.")}"></empty-state>`}`,pending:()=>h`<div class="appointments-list"><appointment-card-skeleton></appointment-card-skeleton><appointment-card-skeleton></appointment-card-skeleton><appointment-card-skeleton></appointment-card-skeleton></div>`})}};ot=i([l(),n("next-appointments-tab")],ot);const st=[C.finished,C.reporting];let rt=class AppointmentsHistoryTab extends d{constructor(){super(...arguments),this.getAppointmentsQuery=new s(this,()=>it(k,{status:st,order:{field:"starts_at",direction:"desc"}}))}static{this.styles=m`.appointments-list{display:grid;grid-template-columns:1fr;gap:var(--sp-6);margin-bottom:var(--sp-6)}@media (min-width:768px){.appointments-list{grid-template-columns:repeat(2,1fr)}}`}render(){return this.getAppointmentsQuery.render({complete:t=>h`${t.data.length>0?h`<div class="appointments-list">${t.data.map(t=>h`<appointment-card .appointmentResource="${t}" .specialtyId="${t.speciality?.id}" variant="history"></appointment-card>`)}</div>`:h`<empty-state title="${r("No tienes citas en el historial")}" description="${r("Aquí verás todas las citas que has tenido. Puedes acceder a los documentos de cada consulta y reagendar una cita si es necesario.")}"></empty-state>`}`,pending:()=>h`<div class="appointments-list"><appointment-card-skeleton></appointment-card-skeleton><appointment-card-skeleton></appointment-card-skeleton><appointment-card-skeleton></appointment-card-skeleton></div>`})}};rt=i([l(),n("appointments-history-tab")],rt);const pt=m`.container{display:flex;flex-direction:column;gap:var(--size-3)}h1{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-neutral-link-dark);margin:0}p{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);font-weight:var(--font-weight-normal);color:var(--color-neutral-link-dark);margin:0}.user-info{display:flex;align-items:center;justify-content:space-between}@media (min-width:768px){h1{font-size:var(--text-3xl);line-height:var(--text-3xl--line-height)}mq-tabs-list{max-width:435px}}`;let lt=class MqMyAppointments extends d{constructor(){super(...arguments),this.tab=F.next}static{this.styles=pt}handleSelect(t){this.dispatchEvent(new MqMyAppointmentsSelectEvent(t.value))}render(){return h`<div class="container"><back-link @mq-back="${t=>{t.stopPropagation(),this.dispatchEvent(new $)}}">${r("Volver al inicio")}</back-link><h1>${r("Mis citas")}</h1><div class="user-info"><p>${r(p`Para: ${this.loginToken.patient.name}`)}</p></div><mq-tabs .value="${this.tab}" @onvaluechange="${this.handleSelect}"><mq-tabs-list><mq-tabs-trigger value="${F.next}">${r("Próximas citas")}</mq-tabs-trigger><mq-tabs-trigger value="${F.history}">${r("Histórico")}</mq-tabs-trigger></mq-tabs-list><mq-tabs-content value="${F.next}"><next-appointments-tab></next-appointments-tab></mq-tabs-content><mq-tabs-content value="${F.history}"><appointments-history-tab></appointments-history-tab></mq-tabs-content></mq-tabs></div>`}};i([o({context:c})],lt.prototype,"loginToken",void 0),i([v({type:String,reflect:!0})],lt.prototype,"tab",void 0),lt=i([l(),n("mq-my-appointments")],lt);const ct=m`:host{display:block}.request-appointment-cta{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:space-between;padding:var(--sp-12) var(--sp-4);background:var(--color-card);gap:var(--sp-4)}.title-body{display:flex;flex-direction:column;gap:var(--sp-2);flex:1}.title{font-family:var(--font-titles);font-size:var(--text-2xl);line-height:var(--text-2xl--line-height);font-weight:var(--font-weight-bold);color:var(--color-neutrals-text-default);margin:0;text-align:center}.subtitle{font-family:var(--font-body);font-size:var(--text-base);line-height:var(--text-base--line-height);font-weight:var(--font-weight-normal);color:var(--color-neutrals-text-default);margin:0;display:none}mq-button{width:100%}.button-text-desktop{display:none}.button-text-mobile{display:inline}@media (min-width:768px){.request-appointment-cta{flex-direction:row;padding:var(--sp-12) var(--sp-20);gap:var(--sp-2)}.title-body{align-items:flex-start;flex:1;max-width:843px}.title{font-size:var(--text-3xl);line-height:var(--text-3xl--line-height);font-weight:var(--font-weight-extrabold);text-align:left}.subtitle{display:block}mq-button{width:auto;flex-shrink:0;--button-height-md:var(--button-height-lg);--text-sm:var(--text-base);--text-sm--line-height:var(--text-base--line-height)}.button-text-desktop{display:inline}.button-text-mobile{display:none}}`;class RequestAppointmentEvent extends Event{static{this.eventName="request-appointment"}constructor(){super(RequestAppointmentEvent.eventName,{bubbles:!0,composed:!0})}}let dt=class RequestAppointmentCta extends d{static{this.styles=ct}handleRequestAppointment(){this.dispatchEvent(new RequestAppointmentEvent)}render(){return h`<div class="request-appointment-cta"><div class="title-body"><h2 class="title">${r("Nueva cita de especialidades digitales")}</h2><p class="subtitle">${r("Realiza la búsqueda en tu cuadro médico digital")}</p></div><mq-button variant="primary" size="md" fullwidth @click="${this.handleRequestAppointment}"><span class="button-text-mobile">${r("Pedir cita")}</span> <span class="button-text-desktop">${r("Pedir una nueva cita")}</span></mq-button></div>`}};dt=i([l(),n("request-appointment-cta")],dt);export{lt as MqMyAppointments,MqMyAppointmentsSelectEvent,dt as RequestAppointmentCta,RequestAppointmentEvent};
@@ -1,4 +1,4 @@
1
- import{isValidLocale as t,setLocale as e,getLocale as i,initLocalization as n}from"./i18n.js";import{_ as o,t as a}from"./chunks/custom-element-DA9Fxvxd.js";import{m as s,s as r}from"./chunks/runtime-Bg1WXVCx.js";import{l as c}from"./chunks/parseISO-jT42c8Ob.js";import{i as p,a as l,x as d,E as m}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as h}from"./chunks/state-LQivXIgA.js";import{setEnv as g}from"./env.js";import{a as v,A as f,c as y,C as b}from"./chunks/api-chat-client-BTBtu01T.js";import{checkIcon as k}from"./ui/icons/check-icon.js";import"./ui/mq-callout.js";import"./ui/mq-button.js";import{Q as x,c as w}from"./chunks/mutation-controller-OVT8NEt6.js";import{l as j}from"./chunks/chunk-S5RWG6G2-oTcdgk2H.js";import{g as $,t as q,b as _,a as C,c as S,d as z,e as I,f as O}from"./chunks/telemetry-client-CKCb9Gnf.js";import{f as A}from"./chunks/price-Dtdjx70D.js";import{g as Q,a as P}from"./chunks/get-patient-profile-query-C8T8DJ7z.js";import{g as T}from"./chunks/get-organization-setup-query-BMbuRi6v.js";import{a as E}from"./chunks/exports-XZaVrMLd.js";import{calendarIcon as H}from"./ui/icons/calendar-icon.js";import{chatbubbleIcon as N}from"./ui/icons/chat-bubble-icon.js";import{videoIcon as V}from"./ui/icons/video-icon.js";import"./ui/mq-floating-bubble.js";import"./ui/mq-unread-badge.js";import"./ui/mq-skeleton.js";import"./ui/mq-card.js";import{Q as K}from"./chunks/query-QJ1INUTG.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.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/context-request-event-Dfydf1ub.js";import"./chunks/context-provider-CiMFpvDA.js";import"./ui/icons/chevron-down-icon.js";import"./chunks/if-defined-BYeVdwgd.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/provide-CfT7g_Zi.js";import"./theme.js";import"./ui/icons/x-icon.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./events.js";import"./ui/icons/check-double-icon.js";import"./chunks/chunk-YTQUGGS3-DN-JZpgG.js";import"./chunks/style-map-CIdqdn7C.js";const B=p`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 U=class MqScheduleSuccessSkeleton extends l{static{this.styles=B}render(){return d`<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>`}};U=o([a("mq-schedule-success-skeleton")],U);const G=p`.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}}`;class OpenVideocallEvent extends Event{static{this.eventName="open-videocall"}constructor(t){super(OpenVideocallEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}let M=class MqScheduleSuccess extends l{constructor(){super(...arguments),this.kind="schedule",this._trackedPageView=!1,this.getPatientProfileQuery=new x(this,()=>Q(v)),this.getAppointmentQuery=new x(this,()=>P(v,{id:this.appointmentId})),this.getCouponQuery=new x(this,()=>{return t=v,e={appointmentId:this.appointmentId},i={enabled:!!this.appointmentId},{queryKey:["appointment-consultation-coupon",e.appointmentId],queryFn:()=>t.payments.getAppointmentConsultationCoupon(e.appointmentId),retry:!1,...i};var t,e,i}),this.getOrganizationSpecialtiesQuery=new x(this,()=>$(v)),this.getOrganizationSetupQuery=new x(this,()=>T(v)),this.isChatOpen=!1,this.unreadQuery=new x(this,()=>E(v,{roomId:Number(this.getAppointmentQuery.result?.data?.room_id)},{enabled:!!this.getAppointmentQuery.result?.data?.room_id})),this._getCalloutText=t=>{switch(t.channel){case f.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 f.phonecall:return s(r`El profesional te llamará al
1
+ import{isValidLocale as t,setLocale as e,getLocale as i,initLocalization as n}from"./i18n.js";import{_ as o,t as a}from"./chunks/custom-element-DA9Fxvxd.js";import{m as s,s as r}from"./chunks/runtime-Bg1WXVCx.js";import{l as c}from"./chunks/parseISO-jT42c8Ob.js";import{i as p,a as l,x as d,E as m}from"./chunks/lit-element-DiWJYFwC.js";import{n as u}from"./chunks/property-scuRaFcM.js";import{r as h}from"./chunks/state-LQivXIgA.js";import{setEnv as g}from"./env.js";import{b as v,A as f,a as b,C as y}from"./chunks/api-chat-client-C8SqZtCa.js";import{checkIcon as k}from"./ui/icons/check-icon.js";import"./ui/mq-callout.js";import"./ui/mq-button.js";import{Q as x,c as w}from"./chunks/mutation-controller-OVT8NEt6.js";import{l as $}from"./chunks/chunk-S5RWG6G2-oTcdgk2H.js";import{g as j,t as q,b as _,a as C,c as S,d as z,e as I,f as O}from"./chunks/telemetry-client-BRVJU-fZ.js";import{f as Q}from"./chunks/price-tImUmtpX.js";import{g as A,a as P}from"./chunks/get-patient-profile-query-C8T8DJ7z.js";import{g as T}from"./chunks/get-organization-setup-query-BMbuRi6v.js";import{g as E}from"./chunks/exports-G_7Ih_GH.js";import{calendarIcon as H}from"./ui/icons/calendar-icon.js";import{chatbubbleIcon as N}from"./ui/icons/chat-bubble-icon.js";import{videoIcon as V}from"./ui/icons/video-icon.js";import"./ui/mq-floating-bubble.js";import"./ui/mq-unread-badge.js";import"./ui/mq-skeleton.js";import"./ui/mq-card.js";import{Q as K}from"./chunks/query-QJ1INUTG.js";import"./chunks/external-zAbuzxDj.js";import"./chunks/format-Cm3B1GMy.js";import"./chunks/isBefore-Cof0D841.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/context-request-event-Dfydf1ub.js";import"./chunks/context-provider-CiMFpvDA.js";import"./ui/icons/chevron-down-icon.js";import"./chunks/if-defined-BYeVdwgd.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/provide-CfT7g_Zi.js";import"./theme.js";import"./ui/icons/x-icon.js";import"./ui/icons/chevron-left-icon.js";import"./chunks/query-CeeutdfT.js";import"./events.js";import"./ui/icons/check-double-icon.js";import"./chunks/chunk-YTQUGGS3-DN-JZpgG.js";import"./chunks/style-map-CIdqdn7C.js";const U=p`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 B=class MqScheduleSuccessSkeleton extends l{static{this.styles=U}render(){return d`<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>`}};B=o([a("mq-schedule-success-skeleton")],B);const G=p`.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}}`;class OpenVideocallEvent extends Event{static{this.eventName="open-videocall"}constructor(t){super(OpenVideocallEvent.eventName,{bubbles:!0,composed:!0}),this.detail=t}}let M=class MqScheduleSuccess extends l{constructor(){super(...arguments),this.kind="schedule",this._trackedPageView=!1,this.getPatientProfileQuery=new x(this,()=>A(v)),this.getAppointmentQuery=new x(this,()=>P(v,{id:this.appointmentId})),this.getCouponQuery=new x(this,()=>{return t=v,e={appointmentId:this.appointmentId},i={enabled:!!this.appointmentId},{queryKey:["appointment-consultation-coupon",e.appointmentId],queryFn:()=>t.payments.getAppointmentConsultationCoupon(e.appointmentId),retry:!1,...i};var t,e,i}),this.getOrganizationSpecialtiesQuery=new x(this,()=>j(v)),this.getOrganizationSetupQuery=new x(this,()=>T(v)),this.isChatOpen=!1,this.unreadQuery=new x(this,()=>E(v,{roomId:Number(this.getAppointmentQuery.result?.data?.room_id)},{enabled:!!this.getAppointmentQuery.result?.data?.room_id})),this._getCalloutText=t=>{switch(t.channel){case f.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 f.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 f.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 m}}}static{this.styles=G}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("apiKey")&&this.apiKey&&v.setApiKey(this.apiKey),i.has("token")&&this.token&&v.setAuthToken(this.token),i.has("locale")&&this.locale&&t(this.locale)&&(e(this.locale),v.setLanguage(this.locale))}get _patientHash(){return this.getPatientProfileQuery.result?.data?.hash??""}connectedCallback(){super.connectedCallback(),this.queryClientContext?.invalidateQueries()}updated(){!this._trackedPageView&&this._patientHash&&(this._trackedPageView=!0,q.track(_(this._patientHash,this.appointmentId)))}renderPriceBreakdown(t,e,i){const n=t.price;if(null==n||n<=0)return m;const o=t.currency??"EUR",a=t.discount_amount??0,r=a>0,c=n-a,p=this.getCouponQuery.result?.data,l=p?.name??p?.code,u=r?p?.percent_off??Math.round(a/n*100):0,h=l?`${s("Promoción")} ${l}`:s("Promoción");return d`<div class="price-breakdown"><div class="price-row"><span>${i}</span> <span>${A({amount:n,currency:o},e)}</span></div>${r?d`<div class="price-row"><span>${h} (-${u}%)</span> <span>${A({amount:-a,currency:o},e)}</span></div><hr><div class="price-row price-row--total"><span>${s("Total")}</span> <span>${A({amount:c,currency:o},e)}</span></div>`:m}</div>`}render(){return this.getAppointmentQuery.render({pending:()=>d`<mq-schedule-success-skeleton></mq-schedule-success-skeleton>`,complete:t=>{const e=i(),n=y(t.start_date),o=C(n,t.duration),a=this.getOrganizationSpecialtiesQuery.result?.data?.find(e=>e.id===Number(t.speciality_id)),c=S(a?.code??"",e,a?.name),p=t.channel===f.videocall,l=t.channel===f.phonecall,u=!0===this.getOrganizationSetupQuery.result?.data?.appointments?.has_chat_in_appointment,h=(p||l)&&u,g=this._accessToken;return d`<div><header><div class="success-title">${k()}<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="${n.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="${()=>{q.track(z(this._patientHash,this.appointmentId));const e=function({title:t,description:e,startsAt:i,endsAt:n}){const o=t=>t.toISOString().replace(/[-:]/g,"").replace(/\.\d{3}/,""),a=o(i),s=o(n);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:n,endsAt:o,description:p&&t.consultation_short_url?s(r`Enlace a la cita: ${t.consultation_short_url}`):void 0});window.open(e,"_blank")}}">${H({size:24})} ${s("Añadir al calendario")}</mq-text-button></div>${h||p?d`<div class="actions">${h?d`<mq-button variant="primary" fullwidth size="md" @click="${()=>{q.track(I(this._patientHash,this.appointmentId)),this.isChatOpen=!this.isChatOpen}}">${N({size:24})} ${s("Chatear con el profesional")} ${(this.unreadQuery.result?.data?.unread_count??0)>0?d`<mq-unread-badge></mq-unread-badge>`:m}</mq-button>`:m} ${p?d`<mq-button variant="outline" fullwidth size="md" @click="${()=>{q.track(O(this._patientHash,this.appointmentId)),this.dispatchEvent(new OpenVideocallEvent({appointmentId:this.appointmentId}))}}">${V({size:24})} ${s("Ir a videollamada")}</mq-button>`:m}</div>`:m}</div><mq-callout background="default" variant="info" ?noPadding="${!(h||p)}">${this._getCalloutText(t)}</mq-callout></mq-card></div><mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" @mq-close="${()=>{this.isChatOpen=!1}}" hideCloseButton>${this.isChatOpen&&g?d`<div slot="content" class="floating-content"><mq-chat-room .consultationId="${t.id}" .consultationType="${b.appointment}" .token="${g}" .roomId="${Number(t.room_id)}" .professionalHash="${t.from.hash}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}"></mq-chat-room></div>`:m}</mq-floating-bubble>`}})}};o([u({type:String})],M.prototype,"kind",void 0),o([u({type:String})],M.prototype,"appointmentId",void 0),o([u({type:String,attribute:"api-key"})],M.prototype,"apiKey",void 0),o([u({type:String,attribute:"token"})],M.prototype,"token",void 0),o([u({type:String,attribute:"timezone"})],M.prototype,"timezone",void 0),o([u({type:String,attribute:"locale"})],M.prototype,"locale",void 0),o([u({type:String,attribute:"env"})],M.prototype,"env",void 0),o([w({context:K,subscribe:!0})],M.prototype,"queryClientContext",void 0),o([w({context:j})],M.prototype,"loginToken",void 0),o([h()],M.prototype,"isChatOpen",void 0),M=o([c(),a("mq-schedule-success")],M),n();export{M as MqScheduleSuccess,OpenVideocallEvent};
4
+ el horario elegido.`);case f.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 m}}}static{this.styles=G}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("apiKey")&&this.apiKey&&v.setApiKey(this.apiKey),i.has("token")&&this.token&&v.setAuthToken(this.token),i.has("locale")&&this.locale&&t(this.locale)&&(e(this.locale),v.setLanguage(this.locale))}get _patientHash(){return this.getPatientProfileQuery.result?.data?.hash??""}connectedCallback(){super.connectedCallback(),this.queryClientContext?.invalidateQueries()}updated(){!this._trackedPageView&&this._patientHash&&(this._trackedPageView=!0,q.track(_(this._patientHash,this.appointmentId)))}renderPriceBreakdown(t,e,i){const n=t.price;if(null==n||n<=0)return m;const o=t.currency??"EUR",a=t.discount_amount??0,r=a>0,c=n-a,p=this.getCouponQuery.result?.data,l=p?.name??p?.code,u=r?p?.percent_off??Math.round(a/n*100):0,h=l?`${s("Promoción")} ${l}`:s("Promoción");return d`<div class="price-breakdown"><div class="price-row"><span>${i}</span> <span>${Q({amount:n,currency:o},e)}</span></div>${r?d`<div class="price-row"><span>${h} (-${u}%)</span> <span>${Q({amount:-a,currency:o},e)}</span></div><hr><div class="price-row price-row--total"><span>${s("Total")}</span> <span>${Q({amount:c,currency:o},e)}</span></div>`:m}</div>`}render(){return this.getAppointmentQuery.render({pending:()=>d`<mq-schedule-success-skeleton></mq-schedule-success-skeleton>`,complete:t=>{const e=i(),n=b(t.start_date),o=C(n,t.duration),a=this.getOrganizationSpecialtiesQuery.result?.data?.find(e=>e.id===Number(t.speciality_id)),c=S(a?.code??"",e,a?.name),p=t.channel===f.videocall,l=t.channel===f.phonecall,u=!0===this.getOrganizationSetupQuery.result?.data?.appointments?.has_chat_in_appointment,h=(p||l)&&u,g=this._accessToken;return d`<div><header><div class="success-title">${k()}<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="${n.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="${()=>{q.track(z(this._patientHash,this.appointmentId));const e=function({title:t,description:e,startsAt:i,endsAt:n}){const o=t=>t.toISOString().replace(/[-:]/g,"").replace(/\.\d{3}/,""),a=o(i),s=o(n);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:n,endsAt:o,description:p&&t.consultation_short_url?s(r`Enlace a la cita: ${t.consultation_short_url}`):void 0});window.open(e,"_blank")}}">${H({size:24})} ${s("Añadir al calendario")}</mq-text-button></div>${h||p?d`<div class="actions">${h?d`<mq-button variant="primary" fullwidth size="md" @click="${()=>{q.track(I(this._patientHash,this.appointmentId)),this.isChatOpen=!this.isChatOpen}}">${N({size:24})} ${s("Chatear con el profesional")} ${(this.unreadQuery.result?.data?.unread_count??0)>0?d`<mq-unread-badge></mq-unread-badge>`:m}</mq-button>`:m} ${p?d`<mq-button variant="outline" fullwidth size="md" @click="${()=>{q.track(O(this._patientHash,this.appointmentId)),this.dispatchEvent(new OpenVideocallEvent({appointmentId:this.appointmentId}))}}">${V({size:24})} ${s("Ir a videollamada")}</mq-button>`:m}</div>`:m}</div><mq-callout background="default" variant="info" ?noPadding="${!(h||p)}">${this._getCalloutText(t)}</mq-callout></mq-card></div><mq-floating-bubble ?dismissable="${!1}" .open="${this.isChatOpen}" @mq-close="${()=>{this.isChatOpen=!1}}" hideCloseButton>${this.isChatOpen&&g?d`<div slot="content" class="floating-content"><mq-chat-room .consultationId="${t.id}" .consultationType="${y.appointment}" .token="${g}" .roomId="${Number(t.room_id)}" .professionalHash="${t.from.hash}" @mq-chat-room-close="${()=>{this.isChatOpen=!1}}"></mq-chat-room></div>`:m}</mq-floating-bubble>`}})}};o([u({type:String})],M.prototype,"kind",void 0),o([u({type:String})],M.prototype,"appointmentId",void 0),o([u({type:String,attribute:"api-key"})],M.prototype,"apiKey",void 0),o([u({type:String,attribute:"token"})],M.prototype,"token",void 0),o([u({type:String,attribute:"timezone"})],M.prototype,"timezone",void 0),o([u({type:String,attribute:"locale"})],M.prototype,"locale",void 0),o([u({type:String,attribute:"env"})],M.prototype,"env",void 0),o([w({context:K,subscribe:!0})],M.prototype,"queryClientContext",void 0),o([w({context:$})],M.prototype,"loginToken",void 0),o([h()],M.prototype,"isChatOpen",void 0),M=o([c(),a("mq-schedule-success")],M),n();export{M as MqScheduleSuccess,OpenVideocallEvent};
@@ -165,16 +165,16 @@ declare const CompleteProfileFormSchema: z.ZodObject<{
165
165
  birth_date: z.ZodString;
166
166
  tax_id: z.ZodString;
167
167
  }, "strip", z.ZodTypeAny, {
168
- email: string;
169
168
  first_name: string;
170
169
  last_name: string;
170
+ email: string;
171
171
  phone: string;
172
172
  birth_date: string;
173
173
  tax_id: string;
174
174
  }, {
175
- email: string;
176
175
  first_name: string;
177
176
  last_name: string;
177
+ email: string;
178
178
  phone: string;
179
179
  birth_date: string;
180
180
  tax_id: string;