pih-appointment-widget 0.0.8 → 0.0.11

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.
@@ -8,6 +8,20 @@ var _react = _interopRequireWildcard(require("react"));
8
8
  var _appointmentService = require("../services/appointmentService");
9
9
  var _apiConfig = require("../constants/apiConfig");
10
10
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
11
+ // Decode JWT payload (no verification; for display only). Returns {} on invalid/missing.
12
+ function getJwtPayload(token) {
13
+ if (!token || typeof token !== "string") return {};
14
+ try {
15
+ const parts = token.split(".");
16
+ if (parts.length !== 3) return {};
17
+ const base64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
18
+ const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
19
+ return JSON.parse(atob(padded));
20
+ } catch (_unused) {
21
+ return {};
22
+ }
23
+ }
24
+
11
25
  // SDK Component - accepts configuration from parent app
12
26
  const AppointmentPage = _ref => {
13
27
  let {
@@ -17,7 +31,10 @@ const AppointmentPage = _ref => {
17
31
  const apiBaseUrl = config.apiBaseUrl || _apiConfig.API_BASE_URL;
18
32
  const hospitalId = config.hospitalId || _apiConfig.DEFAULT_PARAMS.hospitalId;
19
33
  const doctorId = config.doctorId || _apiConfig.DEFAULT_PARAMS.doctorId;
20
- const joinCallUrl = config.joinCallUrl || _apiConfig.JOIN_CALL_URL;
34
+ const joinCallUrl = (config.joinCallUrl || _apiConfig.JOIN_CALL_URL) + config.token;
35
+ const token = config.token;
36
+ const jwtPayload = getJwtPayload(token);
37
+ const userName = jwtPayload.name || jwtPayload.sub || "User";
21
38
  // Helper function to get today's date in YYYY-MM-DD format
22
39
  const getTodayDate = () => {
23
40
  const today = new Date();
@@ -208,7 +225,8 @@ const AppointmentPage = _ref => {
208
225
  const serviceConfig = {
209
226
  apiBaseUrl,
210
227
  hospitalId,
211
- doctorId
228
+ doctorId,
229
+ token
212
230
  };
213
231
 
214
232
  // Fetch all appointments (no pagination params to BE)
@@ -587,7 +605,7 @@ const AppointmentPage = _ref => {
587
605
  style: {
588
606
  color: "#1a1a1a"
589
607
  }
590
- }, "Sameera")), /*#__PURE__*/_react.default.createElement("img", {
608
+ }, userName)), /*#__PURE__*/_react.default.createElement("img", {
591
609
  src: "https://w7.pngwing.com/pngs/340/946/png-transparent-avatar-user-computer-icons-software-developer-avatar-child-face-heroes-thumbnail.png",
592
610
  alt: "User",
593
611
  style: {
@@ -29,4 +29,4 @@ const DEFAULT_PARAMS = exports.DEFAULT_PARAMS = {
29
29
  const REQUEST_TIMEOUT = exports.REQUEST_TIMEOUT = 10000;
30
30
 
31
31
  // Join call URL (will be dynamic from auth API later)
32
- const JOIN_CALL_URL = exports.JOIN_CALL_URL = "https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6InVzZXItcm9sZTpkb2N0b3IiLCJuYW1lIjoiRHIuIE1hZ2VkIEZhaG15IiwidmlkZW8iOnsicm9vbUpvaW4iOnRydWUsInJvb20iOiIxMzUwMDgiLCJjYW5QdWJsaXNoIjp0cnVlLCJjYW5TdWJzY3JpYmUiOnRydWUsImNhblB1Ymxpc2hEYXRhIjp0cnVlfSwiaXNzIjoiQVBJa2JTTDg5Y0hxVlhZIiwiZXhwIjoxNzcxMzQxNjYyLCJuYmYiOjAsInN1YiI6ImhpbmF2aW5tYXRoQGdtYWlsLmNvbSJ9.3iJCdselxCHZ6IPzzgG3fGrIwInSszgqLeSgo3EX5bs";
32
+ const JOIN_CALL_URL = exports.JOIN_CALL_URL = "https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/";
@@ -1,32 +1,41 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom'), require('axios')) :
3
- typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom', 'axios'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MyPackage = {}, global.React, global.ReactDOM, global.axios));
5
- })(this, (function (exports, React, ReactDOM, axios) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react-dom')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', 'react', 'react-dom'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.MyPackage = {}, global.React, global.ReactDOM));
5
+ })(this, (function (exports, React, ReactDOM) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
- function _interopNamespace(e) {
10
- if (e && e.__esModule) return e;
11
- var n = Object.create(null);
12
- if (e) {
13
- Object.keys(e).forEach(function (k) {
14
- if (k !== 'default') {
15
- var d = Object.getOwnPropertyDescriptor(e, k);
16
- Object.defineProperty(n, k, d.get ? d : {
17
- enumerable: true,
18
- get: function () { return e[k]; }
19
- });
20
- }
21
- });
22
- }
23
- n["default"] = e;
24
- return Object.freeze(n);
25
- }
26
-
27
9
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
28
10
  var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
29
- var axios__namespace = /*#__PURE__*/_interopNamespace(axios);
11
+
12
+ const getApi = async function (url) {
13
+ let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
14
+ let token = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
15
+ const urlWithParams = new URL(url);
16
+ urlWithParams.search = new URLSearchParams(params).toString();
17
+ const options = {
18
+ method: "GET",
19
+ headers: {
20
+ "Content-Type": "application/json",
21
+ "Authorization": "Bearer ".concat(token)
22
+ // "X-CLIENT-APP": header,
23
+ }
24
+ };
25
+ return fetch(urlWithParams, options).then(response => {
26
+ if (!response.ok) {
27
+ return {
28
+ err: "Something went wrong!"
29
+ };
30
+ }
31
+ return response.json();
32
+ }).catch(error => {
33
+ console.error("Fetch error:", error);
34
+ return {
35
+ err: error
36
+ };
37
+ });
38
+ };
30
39
 
31
40
  // API Configuration Constants
32
41
  // All values are hardcoded defaults
@@ -49,47 +58,8 @@
49
58
  doctorId: 6694
50
59
  };
51
60
 
52
- // Request timeout (milliseconds)
53
- const REQUEST_TIMEOUT = 10000;
54
-
55
61
  // Join call URL (will be dynamic from auth API later)
56
- const JOIN_CALL_URL = "https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6InVzZXItcm9sZTpkb2N0b3IiLCJuYW1lIjoiRHIuIE1hZ2VkIEZhaG15IiwidmlkZW8iOnsicm9vbUpvaW4iOnRydWUsInJvb20iOiIxMzUwMDgiLCJjYW5QdWJsaXNoIjp0cnVlLCJjYW5TdWJzY3JpYmUiOnRydWUsImNhblB1Ymxpc2hEYXRhIjp0cnVlfSwiaXNzIjoiQVBJa2JTTDg5Y0hxVlhZIiwiZXhwIjoxNzcxMzQxNjYyLCJuYmYiOjAsInN1YiI6ImhpbmF2aW5tYXRoQGdtYWlsLmNvbSJ9.3iJCdselxCHZ6IPzzgG3fGrIwInSszgqLeSgo3EX5bs";
57
-
58
- // Create axios instance factory - allows dynamic configuration for SDK usage
59
- const createApiClient = baseURL => {
60
- const client = axios__namespace.create({
61
- baseURL,
62
- headers: {
63
- "Content-Type": "application/json"
64
- },
65
- timeout: REQUEST_TIMEOUT
66
- });
67
-
68
- // Request interceptor to add auth token
69
- client.interceptors.request.use(config => {
70
- const token = localStorage.getItem("authToken");
71
- if (token) {
72
- config.headers.Authorization = "Bearer ".concat(token);
73
- }
74
- return config;
75
- }, error => {
76
- return Promise.reject(error);
77
- });
78
-
79
- // Response interceptor for error handling
80
- client.interceptors.response.use(response => response, error => {
81
- var _error$response;
82
- if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
83
- // Handle unauthorized access
84
- console.error("Unauthorized access - redirecting to login");
85
- }
86
- return Promise.reject(error);
87
- });
88
- return client;
89
- };
90
-
91
- // Default client for backward compatibility
92
- const apiClient = createApiClient();
62
+ const JOIN_CALL_URL = "https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/";
93
63
 
94
64
  /**
95
65
  * Fetch appointments by status
@@ -111,25 +81,48 @@
111
81
  }
112
82
 
113
83
  // Use provided config or fall back to defaults from apiConfig.js
114
- const client = config.apiBaseUrl ? createApiClient(config.apiBaseUrl) : apiClient;
84
+ const baseURL = config.apiBaseUrl || API_BASE_URL;
115
85
  const hospitalId = config.hospitalId || DEFAULT_PARAMS.hospitalId;
116
86
  const doctorId = config.doctorId || DEFAULT_PARAMS.doctorId;
117
- const response = await client.get(API_PATHS.APPOINTMENTS, {
118
- params: {
119
- hospitalId,
120
- doctorId,
121
- fromDate: fromDate,
122
- toDate: toDate,
123
- statuses: apiStatus
124
- }
125
- });
126
- return response.data;
87
+ const token = config.token || '';
88
+ // Build query params
89
+ const params = {
90
+ hospitalId,
91
+ doctorId,
92
+ fromDate,
93
+ toDate,
94
+ statuses: apiStatus
95
+ };
96
+
97
+ // Build full URL
98
+ const url = "".concat(baseURL).concat(API_PATHS.APPOINTMENTS);
99
+
100
+ // Use httpService getApi
101
+ const response = await getApi(url, params, "PIH-Appointment-Widget", token);
102
+ if (response.err) {
103
+ throw new Error(response.err);
104
+ }
105
+ return response;
127
106
  } catch (error) {
128
107
  console.error("Error fetching ".concat(status, " appointments:"), error);
129
108
  throw error;
130
109
  }
131
110
  };
132
111
 
112
+ // Decode JWT payload (no verification; for display only). Returns {} on invalid/missing.
113
+ function getJwtPayload(token) {
114
+ if (!token || typeof token !== "string") return {};
115
+ try {
116
+ const parts = token.split(".");
117
+ if (parts.length !== 3) return {};
118
+ const base64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
119
+ const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
120
+ return JSON.parse(atob(padded));
121
+ } catch (_unused) {
122
+ return {};
123
+ }
124
+ }
125
+
133
126
  // SDK Component - accepts configuration from parent app
134
127
  const AppointmentPage = _ref => {
135
128
  let {
@@ -139,7 +132,10 @@
139
132
  const apiBaseUrl = config.apiBaseUrl || API_BASE_URL;
140
133
  const hospitalId = config.hospitalId || DEFAULT_PARAMS.hospitalId;
141
134
  const doctorId = config.doctorId || DEFAULT_PARAMS.doctorId;
142
- const joinCallUrl = config.joinCallUrl || JOIN_CALL_URL;
135
+ const joinCallUrl = (config.joinCallUrl || JOIN_CALL_URL) + config.token;
136
+ const token = config.token;
137
+ const jwtPayload = getJwtPayload(token);
138
+ const userName = jwtPayload.name || jwtPayload.sub || "User";
143
139
  // Helper function to get today's date in YYYY-MM-DD format
144
140
  const getTodayDate = () => {
145
141
  const today = new Date();
@@ -330,7 +326,8 @@
330
326
  const serviceConfig = {
331
327
  apiBaseUrl,
332
328
  hospitalId,
333
- doctorId
329
+ doctorId,
330
+ token
334
331
  };
335
332
 
336
333
  // Fetch all appointments (no pagination params to BE)
@@ -709,7 +706,7 @@
709
706
  style: {
710
707
  color: "#1a1a1a"
711
708
  }
712
- }, "Sameera")), /*#__PURE__*/React__default["default"].createElement("img", {
709
+ }, userName)), /*#__PURE__*/React__default["default"].createElement("img", {
713
710
  src: "https://w7.pngwing.com/pngs/340/946/png-transparent-avatar-user-computer-icons-software-developer-avatar-child-face-heroes-thumbnail.png",
714
711
  alt: "User",
715
712
  style: {
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom"),require("axios")):"function"==typeof define&&define.amd?define(["exports","react","react-dom","axios"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MyPackage={},e.React,e.ReactDOM,e.axios)}(this,function(e,t,n,a){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function i(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach(function(n){if("default"!==n){var a=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,a.get?a:{enumerable:!0,get:function(){return e[n]}})}}),t.default=e,Object.freeze(t)}var l=o(t),r=o(n),d=i(a);const p="/appointment/V1/consultant/all-appointments",s="dMtEGhak",c=6694,u=e=>{const t=d.create({baseURL:e,headers:{"Content-Type":"application/json"},timeout:1e4});return t.interceptors.request.use(e=>{const t=localStorage.getItem("authToken");return t&&(e.headers.Authorization="Bearer ".concat(t)),e},e=>Promise.reject(e)),t.interceptors.response.use(e=>e,e=>{var t;return 401===(null===(t=e.response)||void 0===t?void 0:t.status)&&console.error("Unauthorized access - redirecting to login"),Promise.reject(e)}),t},x=u(),f=e=>{let{config:n={}}=e;const a=n.apiBaseUrl||"https://afiyaapiqa.powermindinc.com",o=n.hospitalId||s,i=n.doctorId||c,r=n.joinCallUrl||"https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6InVzZXItcm9sZTpkb2N0b3IiLCJuYW1lIjoiRHIuIE1hZ2VkIEZhaG15IiwidmlkZW8iOnsicm9vbUpvaW4iOnRydWUsInJvb20iOiIxMzUwMDgiLCJjYW5QdWJsaXNoIjp0cnVlLCJjYW5TdWJzY3JpYmUiOnRydWUsImNhblB1Ymxpc2hEYXRhIjp0cnVlfSwiaXNzIjoiQVBJa2JTTDg5Y0hxVlhZIiwiZXhwIjoxNzcxMzQxNjYyLCJuYmYiOjAsInN1YiI6ImhpbmF2aW5tYXRoQGdtYWlsLmNvbSJ9.3iJCdselxCHZ6IPzzgG3fGrIwInSszgqLeSgo3EX5bs",d=()=>(new Date).toISOString().split("T")[0],[f,m]=t.useState("upcoming"),[g,h]=t.useState([]),[y,E]=t.useState(null),[b,F]=t.useState(!1),[w,v]=t.useState(null),[C,S]=t.useState(window.innerWidth<768),[k,z]=t.useState("today"),[D,I]=t.useState("today"),[W,M]=t.useState(!1),[j,R]=t.useState("asc"),[A,B]=t.useState(""),[N,T]=t.useState(!1),[Y,L]=t.useState(!1),[H,O]=t.useState(!1),[J,X]=t.useState({x:window.innerWidth-550,y:80}),[P,U]=t.useState({width:550,height:450}),[V,Z]=t.useState(!1),[G,q]=t.useState({x:0,y:0}),[_,Q]=t.useState(!1),[K,$]=t.useState(null),[ee,te]=t.useState({x:0,y:0,width:0,height:0}),[ne,ae]=t.useState(1),oe=g.filter(e=>{if(!A.trim())return!0;const t=A.toLowerCase(),n=(e.patientName||"").toLowerCase(),a=String(e.patientId||"").toLowerCase();return n.includes(t)||a.includes(t)}),ie=20*(ne-1),le=ie+20,re=oe.slice(ie,le),de=Math.ceil(oe.length/20),pe=oe.length,[se,ce]=t.useState(d()),[ue,xe]=t.useState(d()),[fe,me]=t.useState(),[ge,he]=t.useState(),ye=e=>(null==e?void 0:e.id)||(null==e?void 0:e._id)||(null==e?void 0:e.appointmentId)||(null==e?void 0:e.patientId)||JSON.stringify(e),Ee=e=>null!=e&&e.image?e.image:null,be=e=>e?e.charAt(0).toUpperCase():"?",Fe=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},we=t.useCallback(async()=>{F(!0),v(null);try{const e={apiBaseUrl:a,hospitalId:o,doctorId:i},t=await async function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};try{let o=(e||"").toUpperCase();"INPROGRESS"===o&&(o="IN_PROGRESS");const i=a.apiBaseUrl?u(a.apiBaseUrl):x,l=a.hospitalId||s,r=a.doctorId||c;return(await i.get(p,{params:{hospitalId:l,doctorId:r,fromDate:t,toDate:n,statuses:o}})).data}catch(t){throw console.error("Error fetching ".concat(e," appointments:"),t),t}}(f,se,ue,e),n=t.data||t.appointments||t||[];h(n),n.length>0?E(n[0]):E(null)}catch(e){console.error("Error fetching appointments:",e),v(e.message||"Failed to fetch appointments")}finally{F(!1)}},[f,se,ue,a,o,i]),ve=e=>{E(e)},Ce=t.useCallback(e=>{if(!H)if(V){const t=e.clientX-G.x,n=e.clientY-G.y,a=window.innerWidth-P.width,o=window.innerHeight-P.height;X({x:Math.max(0,Math.min(t,a)),y:Math.max(0,Math.min(n,o))})}else if(_){const t=e.clientX-ee.x,n=e.clientY-ee.y;let a=ee.width,o=ee.height,i=ee.posX,l=ee.posY;const r=300,d=250,p=window.innerWidth-40,s=window.innerHeight-100;if("right"===K)a=Math.min(Math.max(ee.width+t,r),p),i+a>window.innerWidth&&(a=window.innerWidth-i);else if("left"===K){const e=Math.min(Math.max(ee.width-t,r),p),n=e-ee.width;a=e,i=Math.max(0,ee.posX-n),0===i&&(a=ee.posX+ee.width)}else if("bottom"===K)o=Math.min(Math.max(ee.height+n,d),s),l+o>window.innerHeight&&(o=window.innerHeight-l);else if("top"===K){const e=Math.min(Math.max(ee.height-n,d),s),t=e-ee.height;o=e,l=Math.max(0,ee.posY-t),0===l&&(o=ee.posY+ee.height)}U({width:a,height:o}),X({x:i,y:l})}},[V,_,G,K,ee,J,P,H]),Se=()=>{Z(!1),Q(!1),$(null)},ke=(e,t)=>{t.preventDefault(),t.stopPropagation(),Q(!0),$(e),te({x:t.clientX,y:t.clientY,width:P.width,height:P.height,posX:J.x,posY:J.y})};t.useEffect(()=>{if(V||_)return window.addEventListener("mousemove",Ce),window.addEventListener("mouseup",Se),()=>{window.removeEventListener("mousemove",Ce),window.removeEventListener("mouseup",Se)}},[V,_,Ce]),t.useEffect(()=>{if(!N||H)return;const e=()=>{if(!(window.innerWidth<768)){const e=Y?350:P.width,t=Y?60:P.height,n=window.innerWidth-40,a=window.innerHeight-100,o=Math.min(e,n),i=Math.min(t,a);o===P.width&&i===P.height||U({width:o,height:i});const l=window.innerWidth-o-20,r=window.innerHeight-i-20;X(e=>({x:Math.min(e.x,l),y:Math.min(e.y,r)}))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[N,Y,H,P]),t.useEffect(()=>{ae(1)},[f,k,se,ue,A]),t.useEffect(()=>{we()},[we]),t.useEffect(()=>{const e=document.createElement("link");e.href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap",e.rel="stylesheet",document.head.appendChild(e);const t=document.createElement("style");t.innerHTML="\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n \n @media (max-width: 768px) {\n .appointments-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .appointments-header-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .hide-on-mobile {\n display: none !important;\n }\n }\n @media (max-width: 480px) {\n .appointments-header-grid {\n font-size: 10px !important;\n }\n .appointments-grid {\n font-size: 11px !important;\n }\n }\n ",document.head.appendChild(t);const n=()=>{S(window.innerWidth<768)};return window.addEventListener("resize",n),()=>{document.head.removeChild(e),document.head.removeChild(t),window.removeEventListener("resize",n)}},[]),t.useEffect(()=>{const e=e=>{!W||e.target.closest("button")||e.target.closest('input[type="date"]')||M(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[W]);let ze='"Nunito", serif';return l.default.createElement("div",{style:{fontFamily:ze,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"}},l.default.createElement("div",{style:{background:"#FFFFFF",padding:C?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:C?"8px":"0"}},l.default.createElement("div",{style:{position:"relative",width:C?"calc(100% - 90px)":"480px",maxWidth:C?"none":"480px"}},l.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:A,onChange:e=>B(e.target.value),style:{width:"100%",padding:C?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:C?"12px":"13px",fontFamily:ze,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),A&&l.default.createElement("button",{onClick:()=>B(""),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:"#999",fontSize:"16px"},title:"Clear search"},"✕")),l.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:C?"10px":"16px"}},l.default.createElement("div",{style:{position:"relative",cursor:"pointer"}},l.default.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#555",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},l.default.createElement("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),l.default.createElement("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})),l.default.createElement("span",{style:{position:"absolute",top:"-5px",right:"-5px",background:"#1CC3CE",color:"white",borderRadius:"50%",width:"16px",height:"16px",fontSize:"10px",fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center"}},"1")),l.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},!C&&l.default.createElement("span",{style:{fontSize:"13px",color:"#555"}},"Hello, ",l.default.createElement("strong",{style:{color:"#1a1a1a"}},"Sameera")),l.default.createElement("img",{src:"https://w7.pngwing.com/pngs/340/946/png-transparent-avatar-user-computer-icons-software-developer-avatar-child-face-heroes-thumbnail.png",alt:"User",style:{width:"32px",height:"32px",borderRadius:"50%",objectFit:"cover"}})))),l.default.createElement("div",{style:{padding:C?"12px":"16px 24px",flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}},l.default.createElement("div",{style:{marginBottom:C?"10px":"14px"}},l.default.createElement("h1",{style:{fontSize:C?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),l.default.createElement("p",{style:{fontSize:C?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:C?"flex-start":"center",marginBottom:C?"10px":"14px",flexDirection:C?"column":"row",gap:C?"12px":"0"}},l.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:C?"100%":"auto"}},l.default.createElement("button",{onClick:()=>m("upcoming"),style:{background:"upcoming"===f?"#4C4DDC":"#FFFFFF",padding:C?"8px 10px":"9px 16px",border:"upcoming"===f?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:C?"10px":"13px",color:"upcoming"===f?"white":"#555555",fontWeight:600,fontFamily:ze,cursor:"pointer",flex:C?"1 1 auto":"none",minWidth:C?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),l.default.createElement("button",{onClick:()=>m("completed"),style:{background:"completed"===f?"#4C4DDC":"#FFFFFF",padding:C?"8px 10px":"9px 16px",border:"completed"===f?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:C?"10px":"13px",color:"completed"===f?"white":"#555555",fontWeight:600,fontFamily:ze,cursor:"pointer",flex:C?"1 1 auto":"none",minWidth:C?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),l.default.createElement("button",{onClick:()=>m("cancelled"),style:{background:"cancelled"===f?"#4C4DDC":"#FFFFFF",padding:C?"8px 10px":"9px 16px",border:"cancelled"===f?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:C?"10px":"13px",color:"cancelled"===f?"white":"#555555",fontWeight:600,fontFamily:ze,cursor:"pointer",flex:C?"1 1 auto":"none",minWidth:C?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Cancelled Appointments")),l.default.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"auto",position:"relative",justifyContent:C?"flex-start":"flex-end"}},l.default.createElement("button",{onClick:()=>{W||(me(se),he(ue),I(k)),M(!W)},style:{padding:"8px 12px",fontFamily:ze,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:C?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:C?"4px":"6px",cursor:"pointer",flex:"none",minWidth:C?"100px":"auto",justifyContent:"center"}},l.default.createElement("svg",{width:C?"12":"14",height:C?"12":"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},l.default.createElement("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),l.default.createElement("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),l.default.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),l.default.createElement("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),l.default.createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},(()=>{switch(k){case"today":default:return"Today";case"tomorrow":return"Tomorrow";case"currentWeek":return"Current Week";case"thisMonth":return"This Month";case"currentYear":return"Current Year";case"custom":return C?"Custom":"".concat(se," to ").concat(ue)}})()),l.default.createElement("svg",{width:C?"8":"10",height:C?"8":"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},l.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),W&&l.default.createElement("div",{style:{position:"absolute",top:"100%",right:C?"auto":0,left:C?0:"auto",marginTop:"4px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",padding:"8px",zIndex:1e3,minWidth:C?"280px":"240px",width:C?"calc(100vw - 24px)":"auto",maxWidth:C?"calc(100vw - 24px)":"280px"}},l.default.createElement("div",{style:{marginBottom:"custom"===D?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map(e=>l.default.createElement("button",{key:e,onClick:()=>{if(I(e),"custom"!==e){const t=(e=>{const t=new Date;let n,a;switch(e){case"today":default:n=a=d();break;case"tomorrow":const e=new Date(t);e.setDate(e.getDate()+1),n=a=e.toISOString().split("T")[0];break;case"currentWeek":const o=new Date(t),i=new Date(t),l=t.getDay(),r=0===l?-6:1-l;o.setDate(t.getDate()+r),i.setDate(o.getDate()+6),n=o.toISOString().split("T")[0],a=i.toISOString().split("T")[0];break;case"thisMonth":const p=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);n=p.toISOString().split("T")[0],a=s.toISOString().split("T")[0];break;case"currentYear":n="".concat(t.getFullYear(),"-01-01"),a="".concat(t.getFullYear(),"-12-31")}return{from:n,to:a}})(e);z(e),ce(t.from),xe(t.to),me(t.from),he(t.to),M(!1)}else me(""),he("")},style:{width:"100%",padding:"10px 12px",background:D===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:ze,cursor:"pointer",textAlign:"left",fontWeight:D===e?600:400,color:D===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{D!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{D!==e&&(t.target.style.background="#FFFFFF")}},l.default.createElement("span",null,{thisMonth:"This Month",today:"Today",tomorrow:"Tomorrow",currentWeek:"Current Week",currentYear:"Current Year",custom:"Custom"}[e]),D===e&&l.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓")))),"custom"===D&&l.default.createElement("div",{style:{paddingTop:"8px",borderTop:"1px solid #E5E5E5"}},l.default.createElement("div",{style:{marginBottom:"8px"}},l.default.createElement("input",{type:"date",value:fe,onChange:e=>me(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:ze,boxSizing:"border-box",cursor:"pointer"}})),l.default.createElement("div",{style:{marginBottom:"12px"}},l.default.createElement("input",{type:"date",value:ge,onChange:e=>he(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:ze,boxSizing:"border-box",cursor:"pointer"}})),l.default.createElement("div",{style:{display:"flex",gap:"8px"}},l.default.createElement("button",{onClick:()=>{I(k),me(se),he(ue),M(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:ze,fontWeight:600,cursor:"pointer"}},"Cancel"),l.default.createElement("button",{onClick:()=>{fe&&ge&&(z("custom"),ce(fe),xe(ge),M(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:ze,fontWeight:600,cursor:"pointer"}},"Submit")))))),l.default.createElement("div",{style:{display:"flex",flexDirection:C?"column":"row",gap:C?"12px":"14px",flex:1,minHeight:0,overflow:C?"auto":"hidden"}},l.default.createElement("div",{style:{flex:C?"none":"1 1 65%",width:C?"100%":"auto",display:"flex",flexDirection:"column",minHeight:C?"400px":"auto"}},l.default.createElement("div",{style:{background:"#FFFFFF",borderRadius:"8px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden",display:"flex",flexDirection:"column",height:C?"auto":"100%"}},l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:C?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},l.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:C?"6px":"8px"}},l.default.createElement("span",{style:{fontSize:C?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),l.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:C?"10px":"11px",fontWeight:600,padding:C?"2px 7px":"3px 8px",borderRadius:"12px"}},pe))),l.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:C?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:C?"8px":"12px",padding:C?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:C?"10px":"12px",fontWeight:600,color:"#666"}},l.default.createElement("div",null,"Patients name"),!C&&l.default.createElement("div",null,"Patient ID"),l.default.createElement("div",{onClick:()=>{const e="asc"===j?"desc":"asc";R(e);const t=[...g].sort((t,n)=>{const a=new Date(t.appointmentDate||t.date||0),o=new Date(n.appointmentDate||n.date||0);return"asc"===e?a-o:o-a});h(t),ae(1),t.length>0&&E(t[0])},style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",l.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===j?"▲":"▼")),!C&&l.default.createElement("div",null,"Slot"),!C&&l.default.createElement("div",null,"Doctor")),l.default.createElement("div",{style:{overflow:"auto",flex:1}},b?l.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},l.default.createElement("div",{style:{textAlign:"center"}},l.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Loading appointments...")):w?l.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#FF0000"}},l.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"⚠️ Error"),l.default.createElement("div",{style:{fontSize:"13px"}},w),l.default.createElement("button",{onClick:we,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:ze}},"Retry")):0===re.length?l.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#888"}},l.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),l.default.createElement("div",{style:{fontSize:"13px"}},A?'No appointments found for "'.concat(A,'"'):"No appointments found"),A&&l.default.createElement("button",{onClick:()=>B(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:ze}},"Clear Search")):re.map(e=>l.default.createElement("div",{key:ye(e),role:"button",tabIndex:0,onClick:()=>ve(e),onKeyDown:t=>"Enter"===t.key&&ve(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:C?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:C?"8px":"12px",padding:C?"10px 12px":"12px 18px",background:ye(y)===ye(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:C?"11px":"13px"}},l.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:C?"8px":"10px"}},Ee(e)?l.default.createElement("img",{src:e.image,alt:"",style:{width:C?"32px":"36px",height:C?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):l.default.createElement("div",{style:{width:C?"32px":"36px",height:C?"32px":"36px",borderRadius:"50%",background:Fe(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:C?"14px":"16px"}},be(e.patientName)),l.default.createElement("div",null,l.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:C?"11px":"13px"}},e.patientName),l.default.createElement("div",{style:{fontSize:C?"9px":"11px",color:"#888"}},e.email))),!C&&l.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),l.default.createElement("div",{style:{color:"#555",fontSize:C?"10px":"12px"}},(()=>{const t=e.appointmentDate||"",n=t.match(/\s(\d{1,2}:\d{2}(?:\s*(?:AM|PM))?)$/i);return n?l.default.createElement(l.default.Fragment,null,l.default.createElement("div",null,t.slice(0,n.index).trim()),l.default.createElement("div",{style:{fontSize:C?"9px":"11px",color:"#888"}},n[1].trim())):l.default.createElement("div",null,t)})()),!C&&l.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!C&&l.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-")))),!b&&!w&&re.length>0&&l.default.createElement("div",{style:{padding:C?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:C?"wrap":"nowrap",gap:C?"10px":"0"}},l.default.createElement("div",{style:{fontSize:C?"11px":"12px",color:"#666"}},"Showing page ",ne," of ",de," (",pe," total)"),l.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},l.default.createElement("button",{onClick:()=>ae(e=>Math.max(1,e-1)),disabled:1===ne,style:{padding:C?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===ne?"#F5F5F5":"#FFFFFF",color:1===ne?"#999":"#1a1a1a",fontSize:C?"11px":"12px",fontFamily:ze,fontWeight:600,cursor:1===ne?"not-allowed":"pointer",opacity:1===ne?.5:1}},"Previous"),l.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,de))].map((e,t)=>{let n;return n=de<=5||ne<=3?t+1:ne>=de-2?de-4+t:ne-2+t,l.default.createElement("button",{key:n,onClick:()=>ae(n),style:{padding:C?"6px 10px":"6px 12px",border:ne===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:ne===n?"#4C4DDC":"#FFFFFF",color:ne===n?"#FFFFFF":"#1a1a1a",fontSize:C?"11px":"12px",fontFamily:ze,fontWeight:600,cursor:"pointer",minWidth:C?"32px":"36px"}},n)})),l.default.createElement("button",{onClick:()=>ae(e=>Math.min(de,e+1)),disabled:ne===de,style:{padding:C?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:ne===de?"#F5F5F5":"#FFFFFF",color:ne===de?"#999":"#1a1a1a",fontSize:C?"11px":"12px",fontFamily:ze,fontWeight:600,cursor:ne===de?"not-allowed":"pointer",opacity:ne===de?.5:1}},"Next"))))),l.default.createElement("div",{style:{flex:C?"none":"1 1 35%",width:C?"100%":"auto",display:y||!C?"flex":"none",flexDirection:"column",minHeight:"auto"}},l.default.createElement("div",{style:{border:"1px solid #E5E5E5",borderRadius:"8px",overflow:"hidden",background:"#FFFFFF",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",flexDirection:"column",height:C?"auto":"100%"}},y?l.default.createElement(l.default.Fragment,null,l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:C?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},l.default.createElement("div",null,l.default.createElement("div",{style:{color:"#002668",fontSize:C?"14px":"16px",fontWeight:"700"}},y.patientName||"N/A"),l.default.createElement("div",{style:{color:"#002668",fontSize:C?"11px":"13px"}},y.patientId||y.mrn||"N/A")),l.default.createElement("div",null,Ee(y)?l.default.createElement("img",{style:{width:C?"36px":"44px",height:C?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:y.image,alt:y.patientName}):l.default.createElement("div",{style:{width:C?"36px":"44px",height:C?"36px":"44px",borderRadius:"50%",background:Fe(y.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:C?"16px":"20px"}},be(y.patientName)))),l.default.createElement("div",{style:{padding:C?"12px 14px":"14px 18px",gap:C?"10px":"12px",display:"flex",flexDirection:"column",background:"white",overflow:"auto",flex:1,position:"relative"}},l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},l.default.createElement("div",{style:{textAlign:"left"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.specialisation)||(null==y?void 0:y.speciality)||"N/A")),l.default.createElement("div",{style:{textAlign:"right"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.type)||(null==y?void 0:y.appointmentType)||"Online"))),l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},l.default.createElement("div",{style:{textAlign:"left"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.date)||(null==y?void 0:y.appointmentDate)||"N/A")),l.default.createElement("div",{style:{textAlign:"right"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.time)||(null==y?void 0:y.appointmentTime)||"N/A"))),l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},l.default.createElement("div",{style:{textAlign:"left"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.doctor)||(null==y?void 0:y.doctorName)||"N/A"))),l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},l.default.createElement("div",{style:{textAlign:"left"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),l.default.createElement("div",{style:{fontWeight:"700",fontSize:C?"12px":"13px"}},(null==y?void 0:y.hospital)||(null==y?void 0:y.hospitalName)||"N/A"))),l.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},l.default.createElement("div",{style:{textAlign:"left"}},l.default.createElement("div",{style:{fontSize:C?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),l.default.createElement("div",{style:{fontWeight:"600",fontSize:C?"11px":"12px",lineHeight:"1.4"}},(null==y?void 0:y.reason)||(null==y?void 0:y.reasonForAppointment)||"No reason provided"))),l.default.createElement("div",{style:{display:"flex",flexDirection:C?"column":"row",gap:"6px",marginTop:"10px"}},l.default.createElement("button",{onClick:()=>{y&&(r?(T(!0),L(!1),O(!1)):alert("Call link not available"))},style:{flex:1,background:"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:C?"10px 8px":"8px 6px",fontFamily:ze,fontWeight:600,fontSize:C?"11px":"12px",cursor:"pointer"}},"Join Call >")))):l.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"40px",color:"#888",textAlign:"center"}},l.default.createElement("div",null,l.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),l.default.createElement("div",{style:{fontSize:"13px"}},"Select an appointment to view details"))))))),N&&l.default.createElement("div",{style:{position:"fixed",left:H?"0":C?"10px":"".concat(J.x,"px"),top:H?"0":C?"70px":"".concat(J.y,"px"),right:H?"0":C?"10px":"auto",bottom:H?"0":"auto",width:H?"100vw":C?"calc(100vw - 20px)":Y?"350px":"".concat(P.width,"px"),height:H?"100vh":Y?"auto":C?"300px":"".concat(P.height,"px"),background:"#FFFFFF",borderRadius:H?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:V||_?"none":"all 0.3s ease"}},l.default.createElement("div",{onMouseDown:C||H?void 0:e=>{Z(!0);const t=e.currentTarget.getBoundingClientRect();q({x:e.clientX-t.left,y:e.clientY-t.top})},style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:C?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:!C&&!H&&(V?"grabbing":"grab"),userSelect:"none"}},l.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:C?"6px":"8px",flex:1,minWidth:0}},l.default.createElement("div",{style:{width:C?"6px":"8px",height:C?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),l.default.createElement("span",{style:{fontSize:C?"11px":"13px",fontWeight:600,fontFamily:ze,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",(null==y?void 0:y.patientName)||"Patient")),l.default.createElement("div",{style:{display:"flex",gap:C?"4px":"6px",alignItems:"center",flexShrink:0}},!H&&l.default.createElement("button",{onClick:()=>{H&&O(!1),L(!Y)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:C?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:C?"28px":"32px",height:C?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:Y?"Restore":"Minimize"},Y?l.default.createElement("svg",{width:C?"14":"16",height:C?"14":"16",viewBox:"0 0 16 16",fill:"none"},l.default.createElement("rect",{x:"3",y:"3",width:"10",height:"10",stroke:"white",strokeWidth:"1.8",fill:"none"})):l.default.createElement("svg",{width:C?"14":"16",height:C?"14":"16",viewBox:"0 0 16 16",fill:"none"},l.default.createElement("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round"}))),l.default.createElement("button",{onClick:()=>{Y&&L(!1),O(!H)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:C?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:C?"28px":"32px",height:C?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:H?"Exit Fullscreen":"Fullscreen"},H?l.default.createElement("svg",{width:C?"14":"16",height:C?"14":"16",viewBox:"0 0 16 16",fill:"none"},l.default.createElement("path",{d:"M10 3H13V6M6 13H3V10M13 10V13H10M3 6V3H6",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})):l.default.createElement("svg",{width:C?"14":"16",height:C?"14":"16",viewBox:"0 0 16 16",fill:"none"},l.default.createElement("path",{d:"M3 6V3H6M13 10V13H10M10 3H13V6M6 13H3V10",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))),l.default.createElement("button",{onClick:()=>{T(!1),L(!1),O(!1)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:C?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:C?"28px":"32px",height:C?"28px":"32px",fontWeight:"bold",fontSize:C?"18px":"22px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:"Close"},"×"))),!Y&&l.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},l.default.createElement("iframe",{src:r,style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!C&&!H&&!Y&&l.default.createElement(l.default.Fragment,null,l.default.createElement("div",{onMouseDown:e=>ke("left",e),style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),l.default.createElement("div",{onMouseDown:e=>ke("right",e),style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),l.default.createElement("div",{onMouseDown:e=>ke("top",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",top:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),l.default.createElement("div",{onMouseDown:e=>ke("bottom",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),l.default.createElement("div",{style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"0 2px 2px 0",opacity:_&&"left"===K?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}}),l.default.createElement("div",{style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"2px 0 0 2px",opacity:_&&"right"===K?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}})),l.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n ")))};let m=null;const g={showWidget:(e,t)=>{m||(m=document.createElement("div"),document.body.appendChild(m));const n=()=>l.default.createElement(l.default.Fragment,null,l.default.createElement(f,{config:e}));r.default.render(l.default.createElement(n,null),m)},closePopup:()=>{m&&(r.default.unmountComponentAtNode(m),m=null)}};window.BookingSDK=g,e.AppointmentPage=f,e.default=g,Object.defineProperty(e,"__esModule",{value:!0})});
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("react-dom")):"function"==typeof define&&define.amd?define(["exports","react","react-dom"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).MyPackage={},e.React,e.ReactDOM)}(this,function(e,t,n){"use strict";function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=a(t),i=a(n);const l="https://afiyaapiqa.powermindinc.com",r="/appointment/V1/consultant/all-appointments",d="dMtEGhak",p=6694,s=async function(e,t,n){let a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};try{let o=(e||"").toUpperCase();"INPROGRESS"===o&&(o="IN_PROGRESS");const i=a.apiBaseUrl||l,s=a.hospitalId||d,c=a.doctorId||p,u=a.token||"",x={hospitalId:s,doctorId:c,fromDate:t,toDate:n,statuses:o},f="".concat(i).concat(r),m=await async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"";const a=new URL(e);a.search=new URLSearchParams(t).toString();const o={method:"GET",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(n)}};return fetch(a,o).then(e=>e.ok?e.json():{err:"Something went wrong!"}).catch(e=>(console.error("Fetch error:",e),{err:e}))}(f,x,"PIH-Appointment-Widget",u);if(m.err)throw new Error(m.err);return m}catch(t){throw console.error("Error fetching ".concat(e," appointments:"),t),t}};const c=e=>{let{config:n={}}=e;const a=n.apiBaseUrl||l,i=n.hospitalId||d,r=n.doctorId||p,c=(n.joinCallUrl||"https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/")+n.token,u=n.token,x=function(e){if(!e||"string"!=typeof e)return{};try{const t=e.split(".");if(3!==t.length)return{};const n=t[1].replace(/-/g,"+").replace(/_/g,"/"),a=n.padEnd(n.length+(4-n.length%4)%4,"=");return JSON.parse(atob(a))}catch(e){return{}}}(u),f=x.name||x.sub||"User",m=()=>(new Date).toISOString().split("T")[0],[g,h]=t.useState("upcoming"),[y,E]=t.useState([]),[F,b]=t.useState(null),[w,v]=t.useState(!1),[S,C]=t.useState(null),[k,D]=t.useState(window.innerWidth<768),[z,W]=t.useState("today"),[M,I]=t.useState("today"),[R,A]=t.useState(!1),[j,B]=t.useState("asc"),[T,L]=t.useState(""),[N,H]=t.useState(!1),[Y,O]=t.useState(!1),[P,U]=t.useState(!1),[V,X]=t.useState({x:window.innerWidth-550,y:80}),[_,G]=t.useState({width:550,height:450}),[q,J]=t.useState(!1),[K,$]=t.useState({x:0,y:0}),[Q,Z]=t.useState(!1),[ee,te]=t.useState(null),[ne,ae]=t.useState({x:0,y:0,width:0,height:0}),[oe,ie]=t.useState(1),le=y.filter(e=>{if(!T.trim())return!0;const t=T.toLowerCase(),n=(e.patientName||"").toLowerCase(),a=String(e.patientId||"").toLowerCase();return n.includes(t)||a.includes(t)}),re=20*(oe-1),de=re+20,pe=le.slice(re,de),se=Math.ceil(le.length/20),ce=le.length,[ue,xe]=t.useState(m()),[fe,me]=t.useState(m()),[ge,he]=t.useState(),[ye,Ee]=t.useState(),Fe=e=>(null==e?void 0:e.id)||(null==e?void 0:e._id)||(null==e?void 0:e.appointmentId)||(null==e?void 0:e.patientId)||JSON.stringify(e),be=e=>null!=e&&e.image?e.image:null,we=e=>e?e.charAt(0).toUpperCase():"?",ve=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},Se=t.useCallback(async()=>{v(!0),C(null);try{const e={apiBaseUrl:a,hospitalId:i,doctorId:r,token:u},t=await s(g,ue,fe,e),n=t.data||t.appointments||t||[];E(n),n.length>0?b(n[0]):b(null)}catch(e){console.error("Error fetching appointments:",e),C(e.message||"Failed to fetch appointments")}finally{v(!1)}},[g,ue,fe,a,i,r]),Ce=e=>{b(e)},ke=t.useCallback(e=>{if(!P)if(q){const t=e.clientX-K.x,n=e.clientY-K.y,a=window.innerWidth-_.width,o=window.innerHeight-_.height;X({x:Math.max(0,Math.min(t,a)),y:Math.max(0,Math.min(n,o))})}else if(Q){const t=e.clientX-ne.x,n=e.clientY-ne.y;let a=ne.width,o=ne.height,i=ne.posX,l=ne.posY;const r=300,d=250,p=window.innerWidth-40,s=window.innerHeight-100;if("right"===ee)a=Math.min(Math.max(ne.width+t,r),p),i+a>window.innerWidth&&(a=window.innerWidth-i);else if("left"===ee){const e=Math.min(Math.max(ne.width-t,r),p),n=e-ne.width;a=e,i=Math.max(0,ne.posX-n),0===i&&(a=ne.posX+ne.width)}else if("bottom"===ee)o=Math.min(Math.max(ne.height+n,d),s),l+o>window.innerHeight&&(o=window.innerHeight-l);else if("top"===ee){const e=Math.min(Math.max(ne.height-n,d),s),t=e-ne.height;o=e,l=Math.max(0,ne.posY-t),0===l&&(o=ne.posY+ne.height)}G({width:a,height:o}),X({x:i,y:l})}},[q,Q,K,ee,ne,V,_,P]),De=()=>{J(!1),Z(!1),te(null)},ze=(e,t)=>{t.preventDefault(),t.stopPropagation(),Z(!0),te(e),ae({x:t.clientX,y:t.clientY,width:_.width,height:_.height,posX:V.x,posY:V.y})};t.useEffect(()=>{if(q||Q)return window.addEventListener("mousemove",ke),window.addEventListener("mouseup",De),()=>{window.removeEventListener("mousemove",ke),window.removeEventListener("mouseup",De)}},[q,Q,ke]),t.useEffect(()=>{if(!N||P)return;const e=()=>{if(!(window.innerWidth<768)){const e=Y?350:_.width,t=Y?60:_.height,n=window.innerWidth-40,a=window.innerHeight-100,o=Math.min(e,n),i=Math.min(t,a);o===_.width&&i===_.height||G({width:o,height:i});const l=window.innerWidth-o-20,r=window.innerHeight-i-20;X(e=>({x:Math.min(e.x,l),y:Math.min(e.y,r)}))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[N,Y,P,_]),t.useEffect(()=>{ie(1)},[g,z,ue,fe,T]),t.useEffect(()=>{Se()},[Se]),t.useEffect(()=>{const e=document.createElement("link");e.href="https://fonts.googleapis.com/css2?family=Nunito:ital,wght@0,200..1000;1,200..1000&display=swap",e.rel="stylesheet",document.head.appendChild(e);const t=document.createElement("style");t.innerHTML="\n @keyframes spin {\n 0% { transform: rotate(0deg); }\n 100% { transform: rotate(360deg); }\n }\n \n @media (max-width: 768px) {\n .appointments-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .appointments-header-grid {\n grid-template-columns: 1.5fr 1fr 0.8fr !important;\n }\n .hide-on-mobile {\n display: none !important;\n }\n }\n @media (max-width: 480px) {\n .appointments-header-grid {\n font-size: 10px !important;\n }\n .appointments-grid {\n font-size: 11px !important;\n }\n }\n ",document.head.appendChild(t);const n=()=>{D(window.innerWidth<768)};return window.addEventListener("resize",n),()=>{document.head.removeChild(e),document.head.removeChild(t),window.removeEventListener("resize",n)}},[]),t.useEffect(()=>{const e=e=>{!R||e.target.closest("button")||e.target.closest('input[type="date"]')||A(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[R]);let We='"Nunito", serif';return o.default.createElement("div",{style:{fontFamily:We,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"}},o.default.createElement("div",{style:{background:"#FFFFFF",padding:k?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:k?"8px":"0"}},o.default.createElement("div",{style:{position:"relative",width:k?"calc(100% - 90px)":"480px",maxWidth:k?"none":"480px"}},o.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:T,onChange:e=>L(e.target.value),style:{width:"100%",padding:k?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:k?"12px":"13px",fontFamily:We,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),T&&o.default.createElement("button",{onClick:()=>L(""),style:{position:"absolute",right:"8px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",padding:"4px",display:"flex",alignItems:"center",justifyContent:"center",color:"#999",fontSize:"16px"},title:"Clear search"},"✕")),o.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:k?"10px":"16px"}},o.default.createElement("div",{style:{position:"relative",cursor:"pointer"}},o.default.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#555",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},o.default.createElement("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),o.default.createElement("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})),o.default.createElement("span",{style:{position:"absolute",top:"-5px",right:"-5px",background:"#1CC3CE",color:"white",borderRadius:"50%",width:"16px",height:"16px",fontSize:"10px",fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center"}},"1")),o.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},!k&&o.default.createElement("span",{style:{fontSize:"13px",color:"#555"}},"Hello, ",o.default.createElement("strong",{style:{color:"#1a1a1a"}},f)),o.default.createElement("img",{src:"https://w7.pngwing.com/pngs/340/946/png-transparent-avatar-user-computer-icons-software-developer-avatar-child-face-heroes-thumbnail.png",alt:"User",style:{width:"32px",height:"32px",borderRadius:"50%",objectFit:"cover"}})))),o.default.createElement("div",{style:{padding:k?"12px":"16px 24px",flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}},o.default.createElement("div",{style:{marginBottom:k?"10px":"14px"}},o.default.createElement("h1",{style:{fontSize:k?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),o.default.createElement("p",{style:{fontSize:k?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:k?"flex-start":"center",marginBottom:k?"10px":"14px",flexDirection:k?"column":"row",gap:k?"12px":"0"}},o.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:k?"100%":"auto"}},o.default.createElement("button",{onClick:()=>h("upcoming"),style:{background:"upcoming"===g?"#4C4DDC":"#FFFFFF",padding:k?"8px 10px":"9px 16px",border:"upcoming"===g?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:k?"10px":"13px",color:"upcoming"===g?"white":"#555555",fontWeight:600,fontFamily:We,cursor:"pointer",flex:k?"1 1 auto":"none",minWidth:k?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),o.default.createElement("button",{onClick:()=>h("completed"),style:{background:"completed"===g?"#4C4DDC":"#FFFFFF",padding:k?"8px 10px":"9px 16px",border:"completed"===g?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:k?"10px":"13px",color:"completed"===g?"white":"#555555",fontWeight:600,fontFamily:We,cursor:"pointer",flex:k?"1 1 auto":"none",minWidth:k?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),o.default.createElement("button",{onClick:()=>h("cancelled"),style:{background:"cancelled"===g?"#4C4DDC":"#FFFFFF",padding:k?"8px 10px":"9px 16px",border:"cancelled"===g?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:k?"10px":"13px",color:"cancelled"===g?"white":"#555555",fontWeight:600,fontFamily:We,cursor:"pointer",flex:k?"1 1 auto":"none",minWidth:k?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Cancelled Appointments")),o.default.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"auto",position:"relative",justifyContent:k?"flex-start":"flex-end"}},o.default.createElement("button",{onClick:()=>{R||(he(ue),Ee(fe),I(z)),A(!R)},style:{padding:"8px 12px",fontFamily:We,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:k?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:k?"4px":"6px",cursor:"pointer",flex:"none",minWidth:k?"100px":"auto",justifyContent:"center"}},o.default.createElement("svg",{width:k?"12":"14",height:k?"12":"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},o.default.createElement("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),o.default.createElement("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),o.default.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),o.default.createElement("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),o.default.createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},(()=>{switch(z){case"today":default:return"Today";case"tomorrow":return"Tomorrow";case"currentWeek":return"Current Week";case"thisMonth":return"This Month";case"currentYear":return"Current Year";case"custom":return k?"Custom":"".concat(ue," to ").concat(fe)}})()),o.default.createElement("svg",{width:k?"8":"10",height:k?"8":"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},o.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),R&&o.default.createElement("div",{style:{position:"absolute",top:"100%",right:k?"auto":0,left:k?0:"auto",marginTop:"4px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.15)",padding:"8px",zIndex:1e3,minWidth:k?"280px":"240px",width:k?"calc(100vw - 24px)":"auto",maxWidth:k?"calc(100vw - 24px)":"280px"}},o.default.createElement("div",{style:{marginBottom:"custom"===M?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map(e=>o.default.createElement("button",{key:e,onClick:()=>{if(I(e),"custom"!==e){const t=(e=>{const t=new Date;let n,a;switch(e){case"today":default:n=a=m();break;case"tomorrow":const e=new Date(t);e.setDate(e.getDate()+1),n=a=e.toISOString().split("T")[0];break;case"currentWeek":const o=new Date(t),i=new Date(t),l=t.getDay(),r=0===l?-6:1-l;o.setDate(t.getDate()+r),i.setDate(o.getDate()+6),n=o.toISOString().split("T")[0],a=i.toISOString().split("T")[0];break;case"thisMonth":const d=new Date(t.getFullYear(),t.getMonth(),1),p=new Date(t.getFullYear(),t.getMonth()+1,0);n=d.toISOString().split("T")[0],a=p.toISOString().split("T")[0];break;case"currentYear":n="".concat(t.getFullYear(),"-01-01"),a="".concat(t.getFullYear(),"-12-31")}return{from:n,to:a}})(e);W(e),xe(t.from),me(t.to),he(t.from),Ee(t.to),A(!1)}else he(""),Ee("")},style:{width:"100%",padding:"10px 12px",background:M===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:We,cursor:"pointer",textAlign:"left",fontWeight:M===e?600:400,color:M===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{M!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{M!==e&&(t.target.style.background="#FFFFFF")}},o.default.createElement("span",null,{thisMonth:"This Month",today:"Today",tomorrow:"Tomorrow",currentWeek:"Current Week",currentYear:"Current Year",custom:"Custom"}[e]),M===e&&o.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓")))),"custom"===M&&o.default.createElement("div",{style:{paddingTop:"8px",borderTop:"1px solid #E5E5E5"}},o.default.createElement("div",{style:{marginBottom:"8px"}},o.default.createElement("input",{type:"date",value:ge,onChange:e=>he(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:We,boxSizing:"border-box",cursor:"pointer"}})),o.default.createElement("div",{style:{marginBottom:"12px"}},o.default.createElement("input",{type:"date",value:ye,onChange:e=>Ee(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:We,boxSizing:"border-box",cursor:"pointer"}})),o.default.createElement("div",{style:{display:"flex",gap:"8px"}},o.default.createElement("button",{onClick:()=>{I(z),he(ue),Ee(fe),A(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:We,fontWeight:600,cursor:"pointer"}},"Cancel"),o.default.createElement("button",{onClick:()=>{ge&&ye&&(W("custom"),xe(ge),me(ye),A(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:We,fontWeight:600,cursor:"pointer"}},"Submit")))))),o.default.createElement("div",{style:{display:"flex",flexDirection:k?"column":"row",gap:k?"12px":"14px",flex:1,minHeight:0,overflow:k?"auto":"hidden"}},o.default.createElement("div",{style:{flex:k?"none":"1 1 65%",width:k?"100%":"auto",display:"flex",flexDirection:"column",minHeight:k?"400px":"auto"}},o.default.createElement("div",{style:{background:"#FFFFFF",borderRadius:"8px",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",overflow:"hidden",display:"flex",flexDirection:"column",height:k?"auto":"100%"}},o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:k?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},o.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:k?"6px":"8px"}},o.default.createElement("span",{style:{fontSize:k?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),o.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:k?"10px":"11px",fontWeight:600,padding:k?"2px 7px":"3px 8px",borderRadius:"12px"}},ce))),o.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:k?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:k?"8px":"12px",padding:k?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:k?"10px":"12px",fontWeight:600,color:"#666"}},o.default.createElement("div",null,"Patients name"),!k&&o.default.createElement("div",null,"Patient ID"),o.default.createElement("div",{onClick:()=>{const e="asc"===j?"desc":"asc";B(e);const t=[...y].sort((t,n)=>{const a=new Date(t.appointmentDate||t.date||0),o=new Date(n.appointmentDate||n.date||0);return"asc"===e?a-o:o-a});E(t),ie(1),t.length>0&&b(t[0])},style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",o.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===j?"▲":"▼")),!k&&o.default.createElement("div",null,"Slot"),!k&&o.default.createElement("div",null,"Doctor")),o.default.createElement("div",{style:{overflow:"auto",flex:1}},w?o.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},o.default.createElement("div",{style:{textAlign:"center"}},o.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",margin:"0 auto 10px"}}),"Loading appointments...")):S?o.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#FF0000"}},o.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"⚠️ Error"),o.default.createElement("div",{style:{fontSize:"13px"}},S),o.default.createElement("button",{onClick:Se,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:We}},"Retry")):0===pe.length?o.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#888"}},o.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),o.default.createElement("div",{style:{fontSize:"13px"}},T?'No appointments found for "'.concat(T,'"'):"No appointments found"),T&&o.default.createElement("button",{onClick:()=>L(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:We}},"Clear Search")):pe.map(e=>o.default.createElement("div",{key:Fe(e),role:"button",tabIndex:0,onClick:()=>Ce(e),onKeyDown:t=>"Enter"===t.key&&Ce(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:k?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:k?"8px":"12px",padding:k?"10px 12px":"12px 18px",background:Fe(F)===Fe(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:k?"11px":"13px"}},o.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:k?"8px":"10px"}},be(e)?o.default.createElement("img",{src:e.image,alt:"",style:{width:k?"32px":"36px",height:k?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):o.default.createElement("div",{style:{width:k?"32px":"36px",height:k?"32px":"36px",borderRadius:"50%",background:ve(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:k?"14px":"16px"}},we(e.patientName)),o.default.createElement("div",null,o.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:k?"11px":"13px"}},e.patientName),o.default.createElement("div",{style:{fontSize:k?"9px":"11px",color:"#888"}},e.email))),!k&&o.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),o.default.createElement("div",{style:{color:"#555",fontSize:k?"10px":"12px"}},(()=>{const t=e.appointmentDate||"",n=t.match(/\s(\d{1,2}:\d{2}(?:\s*(?:AM|PM))?)$/i);return n?o.default.createElement(o.default.Fragment,null,o.default.createElement("div",null,t.slice(0,n.index).trim()),o.default.createElement("div",{style:{fontSize:k?"9px":"11px",color:"#888"}},n[1].trim())):o.default.createElement("div",null,t)})()),!k&&o.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!k&&o.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-")))),!w&&!S&&pe.length>0&&o.default.createElement("div",{style:{padding:k?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:k?"wrap":"nowrap",gap:k?"10px":"0"}},o.default.createElement("div",{style:{fontSize:k?"11px":"12px",color:"#666"}},"Showing page ",oe," of ",se," (",ce," total)"),o.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},o.default.createElement("button",{onClick:()=>ie(e=>Math.max(1,e-1)),disabled:1===oe,style:{padding:k?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===oe?"#F5F5F5":"#FFFFFF",color:1===oe?"#999":"#1a1a1a",fontSize:k?"11px":"12px",fontFamily:We,fontWeight:600,cursor:1===oe?"not-allowed":"pointer",opacity:1===oe?.5:1}},"Previous"),o.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,se))].map((e,t)=>{let n;return n=se<=5||oe<=3?t+1:oe>=se-2?se-4+t:oe-2+t,o.default.createElement("button",{key:n,onClick:()=>ie(n),style:{padding:k?"6px 10px":"6px 12px",border:oe===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:oe===n?"#4C4DDC":"#FFFFFF",color:oe===n?"#FFFFFF":"#1a1a1a",fontSize:k?"11px":"12px",fontFamily:We,fontWeight:600,cursor:"pointer",minWidth:k?"32px":"36px"}},n)})),o.default.createElement("button",{onClick:()=>ie(e=>Math.min(se,e+1)),disabled:oe===se,style:{padding:k?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:oe===se?"#F5F5F5":"#FFFFFF",color:oe===se?"#999":"#1a1a1a",fontSize:k?"11px":"12px",fontFamily:We,fontWeight:600,cursor:oe===se?"not-allowed":"pointer",opacity:oe===se?.5:1}},"Next"))))),o.default.createElement("div",{style:{flex:k?"none":"1 1 35%",width:k?"100%":"auto",display:F||!k?"flex":"none",flexDirection:"column",minHeight:"auto"}},o.default.createElement("div",{style:{border:"1px solid #E5E5E5",borderRadius:"8px",overflow:"hidden",background:"#FFFFFF",boxShadow:"0 1px 4px rgba(0,0,0,0.08)",display:"flex",flexDirection:"column",height:k?"auto":"100%"}},F?o.default.createElement(o.default.Fragment,null,o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:k?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},o.default.createElement("div",null,o.default.createElement("div",{style:{color:"#002668",fontSize:k?"14px":"16px",fontWeight:"700"}},F.patientName||"N/A"),o.default.createElement("div",{style:{color:"#002668",fontSize:k?"11px":"13px"}},F.patientId||F.mrn||"N/A")),o.default.createElement("div",null,be(F)?o.default.createElement("img",{style:{width:k?"36px":"44px",height:k?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:F.image,alt:F.patientName}):o.default.createElement("div",{style:{width:k?"36px":"44px",height:k?"36px":"44px",borderRadius:"50%",background:ve(F.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:k?"16px":"20px"}},we(F.patientName)))),o.default.createElement("div",{style:{padding:k?"12px 14px":"14px 18px",gap:k?"10px":"12px",display:"flex",flexDirection:"column",background:"white",overflow:"auto",flex:1,position:"relative"}},o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o.default.createElement("div",{style:{textAlign:"left"}},o.default.createElement("div",{style:{fontSize:k?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:k?"12px":"13px"}},(null==F?void 0:F.specialisation)||(null==F?void 0:F.speciality)||"N/A")),o.default.createElement("div",{style:{textAlign:"right"}},o.default.createElement("div",{style:{fontSize:k?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:k?"12px":"13px"}},(null==F?void 0:F.type)||(null==F?void 0:F.appointmentType)||"Online"))),o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o.default.createElement("div",{style:{textAlign:"left"}},o.default.createElement("div",{style:{fontSize:k?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:k?"12px":"13px"}},(null==F?void 0:F.date)||(null==F?void 0:F.appointmentDate)||"N/A")),o.default.createElement("div",{style:{textAlign:"right"}},o.default.createElement("div",{style:{fontSize:k?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:k?"12px":"13px"}},(null==F?void 0:F.time)||(null==F?void 0:F.appointmentTime)||"N/A"))),o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o.default.createElement("div",{style:{textAlign:"left"}},o.default.createElement("div",{style:{fontSize:k?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:k?"12px":"13px"}},(null==F?void 0:F.doctor)||(null==F?void 0:F.doctorName)||"N/A"))),o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o.default.createElement("div",{style:{textAlign:"left"}},o.default.createElement("div",{style:{fontSize:k?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),o.default.createElement("div",{style:{fontWeight:"700",fontSize:k?"12px":"13px"}},(null==F?void 0:F.hospital)||(null==F?void 0:F.hospitalName)||"N/A"))),o.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},o.default.createElement("div",{style:{textAlign:"left"}},o.default.createElement("div",{style:{fontSize:k?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),o.default.createElement("div",{style:{fontWeight:"600",fontSize:k?"11px":"12px",lineHeight:"1.4"}},(null==F?void 0:F.reason)||(null==F?void 0:F.reasonForAppointment)||"No reason provided"))),o.default.createElement("div",{style:{display:"flex",flexDirection:k?"column":"row",gap:"6px",marginTop:"10px"}},o.default.createElement("button",{onClick:()=>{F&&(c?(H(!0),O(!1),U(!1)):alert("Call link not available"))},style:{flex:1,background:"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:k?"10px 8px":"8px 6px",fontFamily:We,fontWeight:600,fontSize:k?"11px":"12px",cursor:"pointer"}},"Join Call >")))):o.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"40px",color:"#888",textAlign:"center"}},o.default.createElement("div",null,o.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),o.default.createElement("div",{style:{fontSize:"13px"}},"Select an appointment to view details"))))))),N&&o.default.createElement("div",{style:{position:"fixed",left:P?"0":k?"10px":"".concat(V.x,"px"),top:P?"0":k?"70px":"".concat(V.y,"px"),right:P?"0":k?"10px":"auto",bottom:P?"0":"auto",width:P?"100vw":k?"calc(100vw - 20px)":Y?"350px":"".concat(_.width,"px"),height:P?"100vh":Y?"auto":k?"300px":"".concat(_.height,"px"),background:"#FFFFFF",borderRadius:P?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:q||Q?"none":"all 0.3s ease"}},o.default.createElement("div",{onMouseDown:k||P?void 0:e=>{J(!0);const t=e.currentTarget.getBoundingClientRect();$({x:e.clientX-t.left,y:e.clientY-t.top})},style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:k?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:!k&&!P&&(q?"grabbing":"grab"),userSelect:"none"}},o.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:k?"6px":"8px",flex:1,minWidth:0}},o.default.createElement("div",{style:{width:k?"6px":"8px",height:k?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),o.default.createElement("span",{style:{fontSize:k?"11px":"13px",fontWeight:600,fontFamily:We,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",(null==F?void 0:F.patientName)||"Patient")),o.default.createElement("div",{style:{display:"flex",gap:k?"4px":"6px",alignItems:"center",flexShrink:0}},!P&&o.default.createElement("button",{onClick:()=>{P&&U(!1),O(!Y)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:k?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:k?"28px":"32px",height:k?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:Y?"Restore":"Minimize"},Y?o.default.createElement("svg",{width:k?"14":"16",height:k?"14":"16",viewBox:"0 0 16 16",fill:"none"},o.default.createElement("rect",{x:"3",y:"3",width:"10",height:"10",stroke:"white",strokeWidth:"1.8",fill:"none"})):o.default.createElement("svg",{width:k?"14":"16",height:k?"14":"16",viewBox:"0 0 16 16",fill:"none"},o.default.createElement("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round"}))),o.default.createElement("button",{onClick:()=>{Y&&O(!1),U(!P)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:k?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:k?"28px":"32px",height:k?"28px":"32px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:P?"Exit Fullscreen":"Fullscreen"},P?o.default.createElement("svg",{width:k?"14":"16",height:k?"14":"16",viewBox:"0 0 16 16",fill:"none"},o.default.createElement("path",{d:"M10 3H13V6M6 13H3V10M13 10V13H10M3 6V3H6",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})):o.default.createElement("svg",{width:k?"14":"16",height:k?"14":"16",viewBox:"0 0 16 16",fill:"none"},o.default.createElement("path",{d:"M3 6V3H6M13 10V13H10M10 3H13V6M6 13H3V10",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))),o.default.createElement("button",{onClick:()=>{H(!1),O(!1),U(!1)},style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:k?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:k?"28px":"32px",height:k?"28px":"32px",fontWeight:"bold",fontSize:k?"18px":"22px",transition:"background 0.2s ease"},onMouseEnter:e=>e.target.style.background="rgba(255, 255, 255, 0.3)",onMouseLeave:e=>e.target.style.background="rgba(255, 255, 255, 0.2)",title:"Close"},"×"))),!Y&&o.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},o.default.createElement("iframe",{src:c,style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!k&&!P&&!Y&&o.default.createElement(o.default.Fragment,null,o.default.createElement("div",{onMouseDown:e=>ze("left",e),style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),o.default.createElement("div",{onMouseDown:e=>ze("right",e),style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),o.default.createElement("div",{onMouseDown:e=>ze("top",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",top:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),o.default.createElement("div",{onMouseDown:e=>ze("bottom",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),o.default.createElement("div",{style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"0 2px 2px 0",opacity:Q&&"left"===ee?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}}),o.default.createElement("div",{style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"4px",height:"30px",background:"rgba(76, 77, 220, 0.6)",borderRadius:"2px 0 0 2px",opacity:Q&&"right"===ee?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}})),o.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n ")))};let u=null;const x={showWidget:(e,t)=>{u||(u=document.createElement("div"),document.body.appendChild(u));const n=()=>o.default.createElement(o.default.Fragment,null,o.default.createElement(c,{config:e}));i.default.render(o.default.createElement(n,null),u)},closePopup:()=>{u&&(i.default.unmountComponentAtNode(u),u=null)}};window.BookingSDK=x,e.AppointmentPage=c,e.default=x,Object.defineProperty(e,"__esModule",{value:!0})});
@@ -3,46 +3,9 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.joinAppointmentCall = exports.getAppointmentsByStatus = exports.getAppointmentDetails = exports.default = void 0;
7
- var axios = _interopRequireWildcard(require("axios"));
6
+ exports.joinAppointmentCall = exports.getAppointmentsByStatus = exports.getAppointmentDetails = void 0;
7
+ var _httpService = require("./httpService");
8
8
  var _apiConfig = require("../constants/apiConfig");
9
- function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
10
- // Create axios instance factory - allows dynamic configuration for SDK usage
11
- const createApiClient = baseURL => {
12
- const client = axios.create({
13
- baseURL,
14
- headers: {
15
- "Content-Type": "application/json"
16
- },
17
- timeout: _apiConfig.REQUEST_TIMEOUT
18
- });
19
-
20
- // Request interceptor to add auth token
21
- client.interceptors.request.use(config => {
22
- const token = localStorage.getItem("authToken");
23
- if (token) {
24
- config.headers.Authorization = "Bearer ".concat(token);
25
- }
26
- return config;
27
- }, error => {
28
- return Promise.reject(error);
29
- });
30
-
31
- // Response interceptor for error handling
32
- client.interceptors.response.use(response => response, error => {
33
- var _error$response;
34
- if (((_error$response = error.response) === null || _error$response === void 0 ? void 0 : _error$response.status) === 401) {
35
- // Handle unauthorized access
36
- console.error("Unauthorized access - redirecting to login");
37
- }
38
- return Promise.reject(error);
39
- });
40
- return client;
41
- };
42
-
43
- // Default client for backward compatibility
44
- const apiClient = createApiClient();
45
-
46
9
  /**
47
10
  * Fetch appointments by status
48
11
  * @param {string} status - Appointment status (inprogress, completed, cancelled, upcoming)
@@ -63,19 +26,28 @@ const getAppointmentsByStatus = async function (status, fromDate, toDate) {
63
26
  }
64
27
 
65
28
  // Use provided config or fall back to defaults from apiConfig.js
66
- const client = config.apiBaseUrl ? createApiClient(config.apiBaseUrl) : apiClient;
29
+ const baseURL = config.apiBaseUrl || _apiConfig.API_BASE_URL;
67
30
  const hospitalId = config.hospitalId || _apiConfig.DEFAULT_PARAMS.hospitalId;
68
31
  const doctorId = config.doctorId || _apiConfig.DEFAULT_PARAMS.doctorId;
69
- const response = await client.get(_apiConfig.API_PATHS.APPOINTMENTS, {
70
- params: {
71
- hospitalId,
72
- doctorId,
73
- fromDate: fromDate,
74
- toDate: toDate,
75
- statuses: apiStatus
76
- }
77
- });
78
- return response.data;
32
+ const token = config.token || '';
33
+ // Build query params
34
+ const params = {
35
+ hospitalId,
36
+ doctorId,
37
+ fromDate,
38
+ toDate,
39
+ statuses: apiStatus
40
+ };
41
+
42
+ // Build full URL
43
+ const url = "".concat(baseURL).concat(_apiConfig.API_PATHS.APPOINTMENTS);
44
+
45
+ // Use httpService getApi
46
+ const response = await (0, _httpService.getApi)(url, params, "PIH-Appointment-Widget", token);
47
+ if (response.err) {
48
+ throw new Error(response.err);
49
+ }
50
+ return response;
79
51
  } catch (error) {
80
52
  console.error("Error fetching ".concat(status, " appointments:"), error);
81
53
  throw error;
@@ -85,13 +57,20 @@ const getAppointmentsByStatus = async function (status, fromDate, toDate) {
85
57
  /**
86
58
  * Fetch appointment details by ID
87
59
  * @param {string|number} appointmentId - The appointment ID
60
+ * @param {object} config - Optional configuration { apiBaseUrl }
88
61
  * @returns {Promise} Appointment details
89
62
  */
90
63
  exports.getAppointmentsByStatus = getAppointmentsByStatus;
91
- const getAppointmentDetails = async appointmentId => {
64
+ const getAppointmentDetails = async function (appointmentId) {
65
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
92
66
  try {
93
- const response = await apiClient.get("".concat(_apiConfig.API_PATHS.APPOINTMENT_DETAILS, "/").concat(appointmentId));
94
- return response.data;
67
+ const baseURL = config.apiBaseUrl || _apiConfig.API_BASE_URL;
68
+ const url = "".concat(baseURL).concat(_apiConfig.API_PATHS.APPOINTMENT_DETAILS, "/").concat(appointmentId);
69
+ const response = await (0, _httpService.getApi)(url, {}, "PIH-Appointment-Widget");
70
+ if (response.err) {
71
+ throw new Error(response.err);
72
+ }
73
+ return response;
95
74
  } catch (error) {
96
75
  console.error("Error fetching appointment details:", error);
97
76
  throw error;
@@ -101,17 +80,24 @@ const getAppointmentDetails = async appointmentId => {
101
80
  /**
102
81
  * Join appointment call
103
82
  * @param {string|number} appointmentId - The appointment ID
83
+ * @param {object} config - Optional configuration { apiBaseUrl }
104
84
  * @returns {Promise} Call details/link
105
85
  */
106
86
  exports.getAppointmentDetails = getAppointmentDetails;
107
- const joinAppointmentCall = async appointmentId => {
87
+ const joinAppointmentCall = async function (appointmentId) {
88
+ let config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
108
89
  try {
109
- const response = await apiClient.post("".concat(_apiConfig.API_PATHS.JOIN_CALL, "/").concat(appointmentId, "/join"));
110
- return response.data;
90
+ const baseURL = config.apiBaseUrl || _apiConfig.API_BASE_URL;
91
+ const url = "".concat(baseURL).concat(_apiConfig.API_PATHS.JOIN_CALL, "/").concat(appointmentId, "/join");
92
+ const token = localStorage.getItem("authToken") || "";
93
+ const response = await (0, _httpService.postApi)(url, {}, "PIH-Appointment-Widget", {}, token);
94
+ if (response.err) {
95
+ throw new Error(response.err);
96
+ }
97
+ return response;
111
98
  } catch (error) {
112
99
  console.error("Error joining appointment call:", error);
113
100
  throw error;
114
101
  }
115
102
  };
116
- exports.joinAppointmentCall = joinAppointmentCall;
117
- var _default = exports.default = apiClient;
103
+ exports.joinAppointmentCall = joinAppointmentCall;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.postApi = exports.getApi = void 0;
7
+ const getApi = async function (url) {
8
+ let params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
9
+ let header = arguments.length > 2 ? arguments[2] : undefined;
10
+ let token = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '';
11
+ const urlWithParams = new URL(url);
12
+ urlWithParams.search = new URLSearchParams(params).toString();
13
+ const options = {
14
+ method: "GET",
15
+ headers: {
16
+ "Content-Type": "application/json",
17
+ "Authorization": "Bearer ".concat(token)
18
+ // "X-CLIENT-APP": header,
19
+ }
20
+ };
21
+ return fetch(urlWithParams, options).then(response => {
22
+ if (!response.ok) {
23
+ return {
24
+ err: "Something went wrong!"
25
+ };
26
+ }
27
+ return response.json();
28
+ }).catch(error => {
29
+ console.error("Fetch error:", error);
30
+ return {
31
+ err: error
32
+ };
33
+ });
34
+ };
35
+ exports.getApi = getApi;
36
+ const postApi = async function (url) {
37
+ let body = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
38
+ let header = arguments.length > 2 ? arguments[2] : undefined;
39
+ let params = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
40
+ let token = arguments.length > 4 ? arguments[4] : undefined;
41
+ const urlWithParams = new URL(url);
42
+ Object.keys(params).forEach(key => {
43
+ urlWithParams.searchParams.append(key, params[key]);
44
+ });
45
+ const options = {
46
+ method: "POST",
47
+ headers: {
48
+ "Content-Type": "application/json"
49
+ // Authorization: `Bearer ${token}`,
50
+ },
51
+ body: JSON.stringify(body)
52
+ };
53
+ return fetch(urlWithParams.toString(), options).then(response => {
54
+ if (!response.ok) {
55
+ return response.json().then(errorData => {
56
+ var _errorData$resultInfo;
57
+ const errorMessage = (errorData === null || errorData === void 0 || (_errorData$resultInfo = errorData.resultInfo) === null || _errorData$resultInfo === void 0 ? void 0 : _errorData$resultInfo.message) || "Something went wrong!";
58
+ return {
59
+ err: errorMessage
60
+ };
61
+ });
62
+ }
63
+ return response.json();
64
+ }).catch(error => {
65
+ console.error("Fetch error:", error);
66
+ return {
67
+ err: error.message || "Network error"
68
+ };
69
+ });
70
+ };
71
+ exports.postApi = postApi;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pih-appointment-widget",
3
- "version": "0.0.8",
3
+ "version": "0.0.11",
4
4
  "main": "dist/App.js",
5
5
  "module": "dist/App.js",
6
6
  "exports": {
@@ -4,13 +4,30 @@ import {
4
4
  } from "../services/appointmentService";
5
5
  import { API_BASE_URL, JOIN_CALL_URL, DEFAULT_PARAMS } from "../constants/apiConfig";
6
6
 
7
+ // Decode JWT payload (no verification; for display only). Returns {} on invalid/missing.
8
+ function getJwtPayload(token) {
9
+ if (!token || typeof token !== "string") return {};
10
+ try {
11
+ const parts = token.split(".");
12
+ if (parts.length !== 3) return {};
13
+ const base64 = parts[1].replace(/-/g, "+").replace(/_/g, "/");
14
+ const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
15
+ return JSON.parse(atob(padded));
16
+ } catch {
17
+ return {};
18
+ }
19
+ }
20
+
7
21
  // SDK Component - accepts configuration from parent app
8
22
  const AppointmentPage = ({ config = {} }) => {
9
23
  // Extract config with fallbacks to hardcoded defaults from apiConfig.js
10
24
  const apiBaseUrl = config.apiBaseUrl || API_BASE_URL;
11
25
  const hospitalId = config.hospitalId || DEFAULT_PARAMS.hospitalId;
12
26
  const doctorId = config.doctorId || DEFAULT_PARAMS.doctorId;
13
- const joinCallUrl = config.joinCallUrl || JOIN_CALL_URL;
27
+ const joinCallUrl = (config.joinCallUrl || JOIN_CALL_URL) + config.token;
28
+ const token = config.token;
29
+ const jwtPayload = getJwtPayload(token);
30
+ const userName = jwtPayload.name || jwtPayload.sub || "User";
14
31
  // Helper function to get today's date in YYYY-MM-DD format
15
32
  const getTodayDate = () => {
16
33
  const today = new Date();
@@ -185,7 +202,8 @@ const AppointmentPage = ({ config = {} }) => {
185
202
  const serviceConfig = {
186
203
  apiBaseUrl,
187
204
  hospitalId,
188
- doctorId
205
+ doctorId,
206
+ token
189
207
  };
190
208
 
191
209
  // Fetch all appointments (no pagination params to BE)
@@ -589,7 +607,7 @@ const AppointmentPage = ({ config = {} }) => {
589
607
  <div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
590
608
  {!isMobile && (
591
609
  <span style={{ fontSize: "13px", color: "#555" }}>
592
- Hello, <strong style={{ color: "#1a1a1a" }}>Sameera</strong>
610
+ Hello, <strong style={{ color: "#1a1a1a" }}>{userName}</strong>
593
611
  </span>
594
612
  )}
595
613
  <img
@@ -23,4 +23,4 @@ export const DEFAULT_PARAMS = {
23
23
  export const REQUEST_TIMEOUT = 10000;
24
24
 
25
25
  // Join call URL (will be dynamic from auth API later)
26
- export const JOIN_CALL_URL = "https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/eyJhbGciOiJIUzI1NiJ9.eyJtZXRhZGF0YSI6InVzZXItcm9sZTpkb2N0b3IiLCJuYW1lIjoiRHIuIE1hZ2VkIEZhaG15IiwidmlkZW8iOnsicm9vbUpvaW4iOnRydWUsInJvb20iOiIxMzUwMDgiLCJjYW5QdWJsaXNoIjp0cnVlLCJjYW5TdWJzY3JpYmUiOnRydWUsImNhblB1Ymxpc2hEYXRhIjp0cnVlfSwiaXNzIjoiQVBJa2JTTDg5Y0hxVlhZIiwiZXhwIjoxNzcxMzQxNjYyLCJuYmYiOjAsInN1YiI6ImhpbmF2aW5tYXRoQGdtYWlsLmNvbSJ9.3iJCdselxCHZ6IPzzgG3fGrIwInSszgqLeSgo3EX5bs";
26
+ export const JOIN_CALL_URL = "https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/";
@@ -1,52 +1,10 @@
1
- import * as axios from "axios";
1
+ import { getApi, postApi } from "./httpService";
2
2
  import {
3
+ API_BASE_URL,
3
4
  API_PATHS,
4
- DEFAULT_PARAMS,
5
- REQUEST_TIMEOUT,
5
+ DEFAULT_PARAMS,
6
6
  } from "../constants/apiConfig";
7
7
 
8
- // Create axios instance factory - allows dynamic configuration for SDK usage
9
- const createApiClient = (baseURL) => {
10
- const client = axios.create({
11
- baseURL,
12
- headers: {
13
- "Content-Type": "application/json",
14
- },
15
- timeout: REQUEST_TIMEOUT,
16
- });
17
-
18
- // Request interceptor to add auth token
19
- client.interceptors.request.use(
20
- (config) => {
21
- const token = localStorage.getItem("authToken");
22
- if (token) {
23
- config.headers.Authorization = `Bearer ${token}`;
24
- }
25
- return config;
26
- },
27
- (error) => {
28
- return Promise.reject(error);
29
- }
30
- );
31
-
32
- // Response interceptor for error handling
33
- client.interceptors.response.use(
34
- (response) => response,
35
- (error) => {
36
- if (error.response?.status === 401) {
37
- // Handle unauthorized access
38
- console.error("Unauthorized access - redirecting to login");
39
- }
40
- return Promise.reject(error);
41
- }
42
- );
43
-
44
- return client;
45
- };
46
-
47
- // Default client for backward compatibility
48
- const apiClient = createApiClient();
49
-
50
8
  /**
51
9
  * Fetch appointments by status
52
10
  * @param {string} status - Appointment status (inprogress, completed, cancelled, upcoming)
@@ -66,20 +24,30 @@ export const getAppointmentsByStatus = async (status, fromDate, toDate, config =
66
24
  }
67
25
 
68
26
  // Use provided config or fall back to defaults from apiConfig.js
69
- const client = config.apiBaseUrl ? createApiClient(config.apiBaseUrl) : apiClient;
27
+ const baseURL = config.apiBaseUrl || API_BASE_URL;
70
28
  const hospitalId = config.hospitalId || DEFAULT_PARAMS.hospitalId;
71
29
  const doctorId = config.doctorId || DEFAULT_PARAMS.doctorId;
30
+ const token = config.token || '';
31
+ // Build query params
32
+ const params = {
33
+ hospitalId,
34
+ doctorId,
35
+ fromDate,
36
+ toDate,
37
+ statuses: apiStatus,
38
+ };
39
+
40
+ // Build full URL
41
+ const url = `${baseURL}${API_PATHS.APPOINTMENTS}`;
72
42
 
73
- const response = await client.get(API_PATHS.APPOINTMENTS, {
74
- params: {
75
- hospitalId,
76
- doctorId,
77
- fromDate: fromDate,
78
- toDate: toDate,
79
- statuses: apiStatus,
80
- },
81
- });
82
- return response.data;
43
+ // Use httpService getApi
44
+ const response = await getApi(url, params, "PIH-Appointment-Widget", token);
45
+
46
+ if (response.err) {
47
+ throw new Error(response.err);
48
+ }
49
+
50
+ return response;
83
51
  } catch (error) {
84
52
  console.error(`Error fetching ${status} appointments:`, error);
85
53
  throw error;
@@ -89,12 +57,21 @@ export const getAppointmentsByStatus = async (status, fromDate, toDate, config =
89
57
  /**
90
58
  * Fetch appointment details by ID
91
59
  * @param {string|number} appointmentId - The appointment ID
60
+ * @param {object} config - Optional configuration { apiBaseUrl }
92
61
  * @returns {Promise} Appointment details
93
62
  */
94
- export const getAppointmentDetails = async (appointmentId) => {
63
+ export const getAppointmentDetails = async (appointmentId, config = {}) => {
95
64
  try {
96
- const response = await apiClient.get(`${API_PATHS.APPOINTMENT_DETAILS}/${appointmentId}`);
97
- return response.data;
65
+ const baseURL = config.apiBaseUrl || API_BASE_URL;
66
+ const url = `${baseURL}${API_PATHS.APPOINTMENT_DETAILS}/${appointmentId}`;
67
+
68
+ const response = await getApi(url, {}, "PIH-Appointment-Widget");
69
+
70
+ if (response.err) {
71
+ throw new Error(response.err);
72
+ }
73
+
74
+ return response;
98
75
  } catch (error) {
99
76
  console.error("Error fetching appointment details:", error);
100
77
  throw error;
@@ -104,16 +81,24 @@ export const getAppointmentDetails = async (appointmentId) => {
104
81
  /**
105
82
  * Join appointment call
106
83
  * @param {string|number} appointmentId - The appointment ID
84
+ * @param {object} config - Optional configuration { apiBaseUrl }
107
85
  * @returns {Promise} Call details/link
108
86
  */
109
- export const joinAppointmentCall = async (appointmentId) => {
87
+ export const joinAppointmentCall = async (appointmentId, config = {}) => {
110
88
  try {
111
- const response = await apiClient.post(`${API_PATHS.JOIN_CALL}/${appointmentId}/join`);
112
- return response.data;
89
+ const baseURL = config.apiBaseUrl || API_BASE_URL;
90
+ const url = `${baseURL}${API_PATHS.JOIN_CALL}/${appointmentId}/join`;
91
+ const token = localStorage.getItem("authToken") || "";
92
+
93
+ const response = await postApi(url, {}, "PIH-Appointment-Widget", {}, token);
94
+
95
+ if (response.err) {
96
+ throw new Error(response.err);
97
+ }
98
+
99
+ return response;
113
100
  } catch (error) {
114
101
  console.error("Error joining appointment call:", error);
115
102
  throw error;
116
103
  }
117
104
  };
118
-
119
- export default apiClient;
@@ -0,0 +1,56 @@
1
+ export const getApi = async (url, params = {}, header, token = '') => {
2
+ const urlWithParams = new URL(url);
3
+ urlWithParams.search = new URLSearchParams(params).toString();
4
+
5
+ const options = {
6
+ method: "GET",
7
+ headers: {
8
+ "Content-Type": "application/json",
9
+ "Authorization": `Bearer ${token}`,
10
+ // "X-CLIENT-APP": header,
11
+ },
12
+ };
13
+
14
+ return fetch(urlWithParams, options)
15
+ .then((response) => {
16
+ if (!response.ok) {
17
+ return { err: "Something went wrong!" };
18
+ }
19
+ return response.json();
20
+ })
21
+ .catch((error) => {
22
+ console.error("Fetch error:", error);
23
+ return { err: error };
24
+ });
25
+ };
26
+ export const postApi = async (url, body = {}, header, params = {}, token) => {
27
+ const urlWithParams = new URL(url);
28
+ Object.keys(params).forEach((key) => {
29
+ urlWithParams.searchParams.append(key, params[key]);
30
+ });
31
+
32
+ const options = {
33
+ method: "POST",
34
+ headers: {
35
+ "Content-Type": "application/json",
36
+ // Authorization: `Bearer ${token}`,
37
+ },
38
+ body: JSON.stringify(body),
39
+ };
40
+
41
+ return fetch(urlWithParams.toString(), options)
42
+ .then((response) => {
43
+ if (!response.ok) {
44
+ return response.json().then((errorData) => {
45
+ const errorMessage =
46
+ errorData?.resultInfo?.message || "Something went wrong!";
47
+ return { err: errorMessage };
48
+ });
49
+ }
50
+ return response.json();
51
+ })
52
+ .catch((error) => {
53
+ console.error("Fetch error:", error);
54
+ return { err: error.message || "Network error" };
55
+ });
56
+ };