@mylikita/booking-widget 0.1.13 → 0.1.14
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @mylikita/booking-widget v0.1.
|
|
1
|
+
/*! @mylikita/booking-widget v0.1.14 | MIT */
|
|
2
2
|
var MyLikitaBookingWidget=(()=>{var Y=Object.defineProperty;var we=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var xe=Object.prototype.hasOwnProperty;var be=(i,e)=>{for(var t in e)Y(i,t,{get:e[t],enumerable:!0})},_e=(i,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ye(e))!xe.call(i,a)&&a!==t&&Y(i,a,{get:()=>e[a],enumerable:!(r=we(e,a))||r.enumerable});return i};var ve=i=>_e(Y({},"__esModule",{value:!0}),i);var Ae={};be(Ae,{DEFAULT_THEME:()=>O,MYLIKITA_MARK_DATA_URI:()=>G,STATUS_COPY:()=>N,TERMINAL_STATUSES:()=>ae,createBooking:()=>I,createBookingWidget:()=>le,createBrandHeader:()=>M,fetchProviders:()=>S,fetchStatus:()=>E,newExternalRef:()=>A,pollStatus:()=>T,resolveTheme:()=>P,statusCopy:()=>C});async function I({relayUrl:i,websiteKey:e,payload:t,signal:r}){let a=await fetch(`${q(i)}/v1/bookings`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify(t),signal:r}),o=await Z(a);if(a.status===409)return{ok:!0,duplicate:!0,booking_ref:o?.booking_ref,error:o?.message};if(!a.ok)throw K(a.status,o,"create");return{ok:!0,duplicate:!1,booking_ref:o?.booking_ref,status:o?.status||"pending_confirmation"}}async function S({relayUrl:i,websiteKey:e,signal:t}){let r=await fetch(`${q(i)}/v1/providers`,{headers:{Authorization:`Bearer ${e}`},signal:t}),a=await Z(r);if(!r.ok)throw K(r.status,a,"providers");return(Array.isArray(a?.providers)?a.providers:[]).map(d=>({external_id:d.external_id,name:d.name||d.external_id,specialty:d.specialty||null,module:d.module||"general"}))}async function E({relayUrl:i,websiteKey:e,bookingRef:t,signal:r}){let a=await fetch(`${q(i)}/v1/bookings/${encodeURIComponent(t)}`,{headers:{Authorization:`Bearer ${e}`},signal:r}),o=await Z(a);if(!a.ok)throw K(a.status,o,"status");return{booking_ref:o?.booking_ref,status:o?.status||"pending_confirmation",appt_ref:o?.appt_ref||null}}async function T(i,{intervalMs:e=5e3,maxTries:t=12,signal:r}={}){for(let a=0;a<t;a++){if(r?.aborted)return{status:"aborted",resolved:!1,data:null};let o=await i();if(o.status!=="pending_confirmation")return{status:o.status,resolved:!0,data:o};a<t-1&&await he(e,r)}return{status:"pending_confirmation",resolved:!1,data:null}}function A(){return`BK-${Date.now()}-${Math.random().toString(36).slice(2,6)}`}function q(i){return String(i||"").replace(/\/+$/,"")}function K(i,e,t){let r=new Error(e?.message||e?.error||`Relay ${t} failed (HTTP ${i})`);return r.code=e?.error||"http_error",r.status=i,r}async function Z(i){try{return await i.json()}catch{return null}}function he(i,e){return new Promise(t=>{if(e?.aborted)return t();let r=()=>{clearTimeout(a),t()},a=setTimeout(()=>{e?.removeEventListener("abort",r),t()},i);e?.addEventListener("abort",r,{once:!0})})}var N={pending_confirmation:{title:"Request received",message:"We've received your booking request \u2014 we'll confirm shortly.",kind:"info"},confirmed:{title:"Appointment confirmed",message:"Your appointment is confirmed. See you at the clinic!",kind:"success"},cancelled:{title:"Appointment cancelled",message:"This appointment was cancelled. Please contact the clinic if this was unexpected.",kind:"danger"},rescheduled:{title:"Appointment rescheduled",message:"This appointment was moved \u2014 the new time was sent to you.",kind:"info"},no_show:{title:"Missed appointment",message:"This appointment was marked as missed.",kind:"danger"},expired:{title:"Request expired",message:"This booking request expired \u2014 please call the clinic to book.",kind:"danger"},poll_error:{title:"Something went wrong",message:"We could not check your booking right now. Please try again shortly.",kind:"danger"}};function C(i){return N[i]||N.pending_confirmation}var ae=["confirmed","cancelled","rescheduled","no_show","expired"];var O={primary:"#0d6efd",primaryDark:"#0b5ed7",primaryText:"#ffffff",bg:"#ffffff",text:"#1e293b",muted:"#64748b",border:"#e2e8f0",danger:"#dc3545",success:"#15803d",radius:10,font:"system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif"};function P(i={}){let e={...O,...i||{}};return{"--mlw-primary":e.primary,"--mlw-primary-dark":e.primaryDark,"--mlw-primary-text":e.primaryText,"--mlw-bg":e.bg,"--mlw-text":e.text,"--mlw-muted":e.muted,"--mlw-border":e.border,"--mlw-danger":e.danger,"--mlw-success":e.success,"--mlw-radius":`${e.radius}px`,"--mlw-font":e.font}}var ne=`
|
|
3
3
|
.mylikita-widget {
|
|
4
4
|
--mlw-primary: #0d6efd;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mylikita/booking-widget",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.14",
|
|
4
4
|
"description": "Drop-in appointment booking widget for MyLikita hospital websites. Submits bookings through the MyLikita relay (POST /v1/bookings) and polls status (GET /v1/bookings/:ref). Themeable via CSS variables.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/mylikita-booking-widget.cjs",
|