pih-appointment-widget 0.0.14 → 0.0.15

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.
@@ -328,6 +328,9 @@ const AppointmentPage = _ref7 => {
328
328
  height: 0
329
329
  });
330
330
 
331
+ // Profile dropdown (logout)
332
+ const [showProfileDropdown, setShowProfileDropdown] = (0, _react.useState)(false);
333
+
331
334
  // Pagination state (Frontend only)
332
335
  const [currentPage, setCurrentPage] = (0, _react.useState)(1);
333
336
  const limit = 20;
@@ -454,6 +457,24 @@ const AppointmentPage = _ref7 => {
454
457
  setSelectedAppointment(appointment);
455
458
  };
456
459
 
460
+ // Logout: clear storage and redirect to login page
461
+ const handleLogout = () => {
462
+ try {
463
+ if (typeof localStorage !== "undefined") {
464
+ localStorage.removeItem(STORAGE_KEY_ID_TOKEN);
465
+ localStorage.removeItem(STORAGE_KEY_EMAIL);
466
+ localStorage.removeItem(STORAGE_KEY_APP_TOKEN);
467
+ localStorage.removeItem(STORAGE_KEY_DOCTOR_ID);
468
+ localStorage.removeItem(STORAGE_KEY_USER_NAME);
469
+ }
470
+ } catch (e) {}
471
+ setShowProfileDropdown(false);
472
+ const homeUrl = config.homeUrl || _apiConfig.WEB_URL || "";
473
+ if (homeUrl && typeof window !== "undefined") {
474
+ window.location.href = homeUrl;
475
+ }
476
+ };
477
+
457
478
  // Handle join call — call initiate API to get LiveKit token+url, then open PiP
458
479
  const handleJoinCall = async () => {
459
480
  if (!selectedAppointment || !appToken) return;
@@ -684,10 +705,15 @@ const AppointmentPage = _ref7 => {
684
705
  if (cancelled) return;
685
706
  const token = extractAppToken(response);
686
707
  if (response.status === 400) {
687
- // Login API returned 400 — redirect to home page
708
+ // Login API returned 400 — show error message then redirect to home
709
+ const message = response.err + " " + ' Redirecting to home...' || "Invalid user. Redirecting to home...";
710
+ setTokenError(message);
711
+ setTokenLoading(false);
688
712
  const homeUrl = config.homeUrl || _apiConfig.WEB_URL || "";
689
713
  if (homeUrl && typeof window !== "undefined") {
690
- window.location.href = homeUrl;
714
+ setTimeout(() => {
715
+ window.location.href = homeUrl;
716
+ }, 3000);
691
717
  }
692
718
  return;
693
719
  }
@@ -960,11 +986,24 @@ const AppointmentPage = _ref7 => {
960
986
  justifyContent: "center"
961
987
  }
962
988
  }, "1")), /*#__PURE__*/_react.default.createElement("div", {
989
+ style: {
990
+ position: "relative"
991
+ }
992
+ }, /*#__PURE__*/_react.default.createElement("button", {
993
+ type: "button",
994
+ onClick: () => setShowProfileDropdown(v => !v),
963
995
  style: {
964
996
  display: "flex",
965
997
  alignItems: "center",
966
- gap: "8px"
967
- }
998
+ gap: "8px",
999
+ background: "none",
1000
+ border: "none",
1001
+ cursor: "pointer",
1002
+ padding: "4px 0",
1003
+ fontFamily
1004
+ },
1005
+ "aria-expanded": showProfileDropdown,
1006
+ "aria-haspopup": "true"
968
1007
  }, !isMobile && /*#__PURE__*/_react.default.createElement("span", {
969
1008
  style: {
970
1009
  fontSize: "13px",
@@ -983,7 +1022,76 @@ const AppointmentPage = _ref7 => {
983
1022
  borderRadius: "50%",
984
1023
  objectFit: "cover"
985
1024
  }
986
- })))), /*#__PURE__*/_react.default.createElement("div", {
1025
+ }), /*#__PURE__*/_react.default.createElement("svg", {
1026
+ width: "12",
1027
+ height: "12",
1028
+ viewBox: "0 0 24 24",
1029
+ fill: "none",
1030
+ stroke: "currentColor",
1031
+ strokeWidth: "2",
1032
+ style: {
1033
+ flexShrink: 0,
1034
+ opacity: showProfileDropdown ? 0.8 : 0.5
1035
+ }
1036
+ }, /*#__PURE__*/_react.default.createElement("polyline", {
1037
+ points: "6 9 12 15 18 9"
1038
+ }))), showProfileDropdown && /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
1039
+ style: {
1040
+ position: "fixed",
1041
+ inset: 0,
1042
+ zIndex: 9998
1043
+ },
1044
+ onClick: () => setShowProfileDropdown(false),
1045
+ "aria-hidden": "true"
1046
+ }), /*#__PURE__*/_react.default.createElement("div", {
1047
+ style: {
1048
+ position: "absolute",
1049
+ right: 0,
1050
+ top: "100%",
1051
+ marginTop: "4px",
1052
+ minWidth: "140px",
1053
+ background: "#FFFFFF",
1054
+ border: "1px solid #E5E5E5",
1055
+ borderRadius: "8px",
1056
+ boxShadow: "0 4px 16px rgba(0,0,0,0.12)",
1057
+ zIndex: 9999,
1058
+ overflow: "hidden"
1059
+ }
1060
+ }, /*#__PURE__*/_react.default.createElement("button", {
1061
+ type: "button",
1062
+ onClick: handleLogout,
1063
+ style: {
1064
+ width: "100%",
1065
+ padding: "10px 14px",
1066
+ textAlign: "left",
1067
+ background: "none",
1068
+ border: "none",
1069
+ cursor: "pointer",
1070
+ fontSize: "13px",
1071
+ fontFamily,
1072
+ color: "#e53935",
1073
+ fontWeight: 500,
1074
+ display: "flex",
1075
+ alignItems: "center",
1076
+ gap: "8px"
1077
+ }
1078
+ }, /*#__PURE__*/_react.default.createElement("svg", {
1079
+ width: "16",
1080
+ height: "16",
1081
+ viewBox: "0 0 24 24",
1082
+ fill: "none",
1083
+ stroke: "currentColor",
1084
+ strokeWidth: "2"
1085
+ }, /*#__PURE__*/_react.default.createElement("path", {
1086
+ d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"
1087
+ }), /*#__PURE__*/_react.default.createElement("polyline", {
1088
+ points: "16 17 21 12 16 7"
1089
+ }), /*#__PURE__*/_react.default.createElement("line", {
1090
+ x1: "21",
1091
+ y1: "12",
1092
+ x2: "9",
1093
+ y2: "12"
1094
+ })), "Logout")))))), /*#__PURE__*/_react.default.createElement("div", {
987
1095
  style: {
988
1096
  padding: isMobile ? "12px" : "16px 24px",
989
1097
  flex: 1,
@@ -556,6 +556,9 @@
556
556
  height: 0
557
557
  });
558
558
 
559
+ // Profile dropdown (logout)
560
+ const [showProfileDropdown, setShowProfileDropdown] = React.useState(false);
561
+
559
562
  // Pagination state (Frontend only)
560
563
  const [currentPage, setCurrentPage] = React.useState(1);
561
564
  const limit = 20;
@@ -682,6 +685,24 @@
682
685
  setSelectedAppointment(appointment);
683
686
  };
684
687
 
688
+ // Logout: clear storage and redirect to login page
689
+ const handleLogout = () => {
690
+ try {
691
+ if (typeof localStorage !== "undefined") {
692
+ localStorage.removeItem(STORAGE_KEY_ID_TOKEN);
693
+ localStorage.removeItem(STORAGE_KEY_EMAIL);
694
+ localStorage.removeItem(STORAGE_KEY_APP_TOKEN);
695
+ localStorage.removeItem(STORAGE_KEY_DOCTOR_ID);
696
+ localStorage.removeItem(STORAGE_KEY_USER_NAME);
697
+ }
698
+ } catch (e) {}
699
+ setShowProfileDropdown(false);
700
+ const homeUrl = config.homeUrl || WEB_URL || "";
701
+ if (homeUrl && typeof window !== "undefined") {
702
+ window.location.href = homeUrl;
703
+ }
704
+ };
705
+
685
706
  // Handle join call — call initiate API to get LiveKit token+url, then open PiP
686
707
  const handleJoinCall = async () => {
687
708
  if (!selectedAppointment || !appToken) return;
@@ -912,10 +933,15 @@
912
933
  if (cancelled) return;
913
934
  const token = extractAppToken(response);
914
935
  if (response.status === 400) {
915
- // Login API returned 400 — redirect to home page
936
+ // Login API returned 400 — show error message then redirect to home
937
+ const message = response.err + " " + ' Redirecting to home...' || "Invalid user. Redirecting to home...";
938
+ setTokenError(message);
939
+ setTokenLoading(false);
916
940
  const homeUrl = config.homeUrl || WEB_URL || "";
917
941
  if (homeUrl && typeof window !== "undefined") {
918
- window.location.href = homeUrl;
942
+ setTimeout(() => {
943
+ window.location.href = homeUrl;
944
+ }, 3000);
919
945
  }
920
946
  return;
921
947
  }
@@ -1188,11 +1214,24 @@
1188
1214
  justifyContent: "center"
1189
1215
  }
1190
1216
  }, "1")), /*#__PURE__*/React__default["default"].createElement("div", {
1217
+ style: {
1218
+ position: "relative"
1219
+ }
1220
+ }, /*#__PURE__*/React__default["default"].createElement("button", {
1221
+ type: "button",
1222
+ onClick: () => setShowProfileDropdown(v => !v),
1191
1223
  style: {
1192
1224
  display: "flex",
1193
1225
  alignItems: "center",
1194
- gap: "8px"
1195
- }
1226
+ gap: "8px",
1227
+ background: "none",
1228
+ border: "none",
1229
+ cursor: "pointer",
1230
+ padding: "4px 0",
1231
+ fontFamily
1232
+ },
1233
+ "aria-expanded": showProfileDropdown,
1234
+ "aria-haspopup": "true"
1196
1235
  }, !isMobile && /*#__PURE__*/React__default["default"].createElement("span", {
1197
1236
  style: {
1198
1237
  fontSize: "13px",
@@ -1211,7 +1250,76 @@
1211
1250
  borderRadius: "50%",
1212
1251
  objectFit: "cover"
1213
1252
  }
1214
- })))), /*#__PURE__*/React__default["default"].createElement("div", {
1253
+ }), /*#__PURE__*/React__default["default"].createElement("svg", {
1254
+ width: "12",
1255
+ height: "12",
1256
+ viewBox: "0 0 24 24",
1257
+ fill: "none",
1258
+ stroke: "currentColor",
1259
+ strokeWidth: "2",
1260
+ style: {
1261
+ flexShrink: 0,
1262
+ opacity: showProfileDropdown ? 0.8 : 0.5
1263
+ }
1264
+ }, /*#__PURE__*/React__default["default"].createElement("polyline", {
1265
+ points: "6 9 12 15 18 9"
1266
+ }))), showProfileDropdown && /*#__PURE__*/React__default["default"].createElement(React__default["default"].Fragment, null, /*#__PURE__*/React__default["default"].createElement("div", {
1267
+ style: {
1268
+ position: "fixed",
1269
+ inset: 0,
1270
+ zIndex: 9998
1271
+ },
1272
+ onClick: () => setShowProfileDropdown(false),
1273
+ "aria-hidden": "true"
1274
+ }), /*#__PURE__*/React__default["default"].createElement("div", {
1275
+ style: {
1276
+ position: "absolute",
1277
+ right: 0,
1278
+ top: "100%",
1279
+ marginTop: "4px",
1280
+ minWidth: "140px",
1281
+ background: "#FFFFFF",
1282
+ border: "1px solid #E5E5E5",
1283
+ borderRadius: "8px",
1284
+ boxShadow: "0 4px 16px rgba(0,0,0,0.12)",
1285
+ zIndex: 9999,
1286
+ overflow: "hidden"
1287
+ }
1288
+ }, /*#__PURE__*/React__default["default"].createElement("button", {
1289
+ type: "button",
1290
+ onClick: handleLogout,
1291
+ style: {
1292
+ width: "100%",
1293
+ padding: "10px 14px",
1294
+ textAlign: "left",
1295
+ background: "none",
1296
+ border: "none",
1297
+ cursor: "pointer",
1298
+ fontSize: "13px",
1299
+ fontFamily,
1300
+ color: "#e53935",
1301
+ fontWeight: 500,
1302
+ display: "flex",
1303
+ alignItems: "center",
1304
+ gap: "8px"
1305
+ }
1306
+ }, /*#__PURE__*/React__default["default"].createElement("svg", {
1307
+ width: "16",
1308
+ height: "16",
1309
+ viewBox: "0 0 24 24",
1310
+ fill: "none",
1311
+ stroke: "currentColor",
1312
+ strokeWidth: "2"
1313
+ }, /*#__PURE__*/React__default["default"].createElement("path", {
1314
+ d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"
1315
+ }), /*#__PURE__*/React__default["default"].createElement("polyline", {
1316
+ points: "16 17 21 12 16 7"
1317
+ }), /*#__PURE__*/React__default["default"].createElement("line", {
1318
+ x1: "21",
1319
+ y1: "12",
1320
+ x2: "9",
1321
+ y2: "12"
1322
+ })), "Logout")))))), /*#__PURE__*/React__default["default"].createElement("div", {
1215
1323
  style: {
1216
1324
  padding: isMobile ? "12px" : "16px 24px",
1217
1325
  flex: 1,
@@ -1 +1 @@
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 o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t),l=o(n);function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r="https://afiyaapiqa.powermindinc.com",d="/appointment/V1/consultant/all-appointments",s="/notification/V1/consultation/online/initiate",p="dMtEGhak",c=6694,u="https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/",f=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=(e||"").toUpperCase();"INPROGRESS"===a&&(a="IN_PROGRESS");const l=o.apiBaseUrl||r,i=o.hospitalId||p,s=o.doctorId||c,u=o.token||"",f={hospitalId:i,doctorId:s,fromDate:t,toDate:n,statuses:a},m="".concat(l).concat(d),x=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 o=new URL(e);o.search=new URLSearchParams(t).toString();const a={method:"GET",headers:{"Content-Type":"application/json",Authorization:"".concat(n)}};return fetch(o,a).then(async e=>{const t=await e.json().catch(()=>({}));var n;return e.ok?t:{err:(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"Something went wrong!",status:e.status}}).catch(e=>(console.error("Fetch error:",e),{err:(null==e?void 0:e.message)||String(e)||"Network error"}))}(m,f,"PIH-Appointment-Widget",u);return x},m=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(t.apiBaseUrl||r).replace(/\/$/,""),o="".concat(n).concat(s),a=t.appToken||"";return async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4?arguments[4]:void 0;const a=new URL(e);Object.keys(n).forEach(e=>{a.searchParams.append(e,n[e])});const l={"Content-Type":"application/json"};o&&(l.Authorization=o);const i={method:"POST",headers:l,body:JSON.stringify(t)};return fetch(a.toString(),i).then(async e=>{const t=await e.json().catch(()=>({}));var n;return e.ok?t:{err:(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"Something went wrong!",status:e.status}}).catch(e=>(console.error("Fetch error:",e),{err:e.message||"Network error"}))}(o,{patientId:String(e.patientId||""),primaryPatientId:String(e.primaryPatientId||e.patientId||""),hospitalId:t.hospitalId||p,doctorId:String(t.doctor_id||c),patientName:e.patientName||e.name||"",doctorName:e.doctorName||t.doctorName,appointmentId:String(e.id||e.appointmentId||e._id||"")},"PIH-Appointment-Widget",{},a)};const x="pih_appointment_idToken",g="pih_appointment_email",h="pih_appointment_appToken",y="pih_appointment_doctorId",E="pih_appointment_userName";class v extends t.Component{constructor(){super(...arguments),i(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){"undefined"!=typeof console&&console.error&&console.error("Appointment widget error:",e,t)}render(){return this.state.hasError?a.default.createElement("div",{style:{fontFamily:'"Nunito", serif',background:"#F5F5F7",boxSizing:"border-box",minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",textAlign:"center"}},a.default.createElement("div",{style:{maxWidth:"400px"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"⚠️"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Something went wrong"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},"Please refresh the page or try again later."))):this.props.children}}const b=e=>{let{config:n={}}=e;const o=n.apiBaseUrl||r,l=n.hospitalId||p,[i,d]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(x):null}catch(e){return null}}),[s,b]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(g):null}catch(e){return null}}),F=n.idToken||n.token||i,w=n.email||s;t.useEffect(()=>{try{if("undefined"==typeof localStorage)return;const e=n.idToken||n.token;if(e&&String(e).trim()){localStorage.getItem(x)!==e&&(k(null),I(null),D(null),localStorage.removeItem(h),localStorage.removeItem(y),localStorage.removeItem(E)),localStorage.setItem(x,e),d(e)}n.email&&String(n.email).trim()&&(localStorage.setItem(g,n.email),b(n.email))}catch(e){}},[n.idToken,n.token,n.email]);const[S,k]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(h):null}catch(e){return null}}),[C,I]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(y):null}catch(e){return null}}),[z,D]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(E):null}catch(e){return null}}),[W,T]=t.useState(()=>{try{if("undefined"==typeof localStorage)return!1;const e=localStorage.getItem(h),t=localStorage.getItem(x),n=localStorage.getItem(g);return!e&&!(!t||!n)}catch(e){return!1}}),[M,A]=t.useState(null),[j,R]=t.useState(0);t.useEffect(()=>{S&&W&&T(!1)},[S,W]),t.useEffect(()=>{if(!W)return;const e=setTimeout(()=>{A("Request timed out. Please try again."),T(!1)},3e4);return()=>clearTimeout(e)},[W]);const N=n.joinCallUrl||u;S&&String(N||"").replace(/\/?$/,"/");const B=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,"/"),o=n.padEnd(n.length+(4-n.length%4)%4,"=");return JSON.parse(atob(o))}catch(e){return{}}}(F),L=z||B.name||B.sub||"User",H=()=>(new Date).toISOString().split("T")[0],[P,Y]=t.useState("upcoming"),[O,_]=t.useState([]),[U,V]=t.useState(null),[X,$]=t.useState(!1),[q,G]=t.useState(null),[J,K]=t.useState(window.innerWidth<768),[Q,Z]=t.useState("today"),[ee,te]=t.useState("today"),[ne,oe]=t.useState(!1),[ae,le]=t.useState("asc"),[ie,re]=t.useState(""),[de,se]=t.useState(!1),[pe,ce]=t.useState(!1),[ue,fe]=t.useState(!1),[me,xe]=t.useState(null),[ge,he]=t.useState(null),[ye,Ee]=t.useState(!1),[ve,be]=t.useState(null),[Fe,we]=t.useState({x:window.innerWidth-550,y:80}),[Se,ke]=t.useState({width:550,height:450}),[Ce,Ie]=t.useState(!1),[ze,De]=t.useState({x:0,y:0}),[We,Te]=t.useState(!1),[Me,Ae]=t.useState(null),[je,Re]=t.useState({x:0,y:0,width:0,height:0}),[Ne,Be]=t.useState(1),Le=O.filter(e=>{if(!ie.trim())return!0;const t=ie.toLowerCase(),n=(e.patientName||"").toLowerCase(),o=String(e.patientId||"").toLowerCase();return n.includes(t)||o.includes(t)}),He=20*(Ne-1),Pe=He+20,Ye=Le.slice(He,Pe),Oe=Math.ceil(Le.length/20),_e=Le.length,[Ue,Ve]=t.useState(H()),[Xe,$e]=t.useState(H()),[qe,Ge]=t.useState(),[Je,Ke]=t.useState(),Qe=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),Ze=e=>null!=e&&e.image?e.image:null,et=e=>e?e.charAt(0).toUpperCase():"?",tt=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},nt=()=>{const e="asc"===ae?"desc":"asc";le(e);const t=[...O].sort((t,n)=>{const o=new Date(t.appointmentDate||t.date||0),a=new Date(n.appointmentDate||n.date||0);return"asc"===e?o-a:a-o});_(t),Be(1),t.length>0&&V(t[0])},ot=t.useCallback(async()=>{if(!S)return;const e=C||c;$(!0),G(null);try{const t={apiBaseUrl:o,hospitalId:l,doctorId:e,token:S},n=await f(P,Ue,Xe,t);if(401===n.status||403===n.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(h),localStorage.removeItem(y),localStorage.removeItem(E))}catch(e){}return k(null),I(null),D(null),R(e=>e+1),void G("Session expired. Re-authenticating...")}if(n.err)return void G(String(n.err||"Failed to fetch appointments"));const a=n.data||n.appointments||n||[];_(Array.isArray(a)?a:[]),Array.isArray(a)&&a.length>0?V(a[0]):V(null)}catch(e){console.error("Error fetching appointments:",e),G(e.message||"Failed to fetch appointments")}finally{$(!1)}},[P,Ue,Xe,o,l,C,S]),at=e=>{V(e)},lt=async()=>{if(U&&S){Ee(!0),be(null);try{var e;const t={apiBaseUrl:o,hospitalId:l,doctorId:C||c,doctorName:z||L,appToken:S};console.log(U,"selectedAppointment"),console.log(t,"callConfig");const a=await m(U,t);if(401===a.status||403===a.status)return be("Session expired. Please try again."),void Ee(!1);if(a.err||null===(e=a.data)||void 0===e||!e.token)return be(String(a.err||"Failed to initiate call")),void Ee(!1);const i=n.joinCallUrl||u,r=a.data.token?String(i||"").replace(/\/?$/,"/")+a.data.token:"";console.log("joinCallUrl",r),xe(a.data.token),he(r||""),se(!0),ce(!1),fe(!1)}catch(e){be(e.message||"Failed to initiate call")}finally{Ee(!1)}}},it=()=>{se(!1),ce(!1),fe(!1),xe(null),he(null),be(null)},rt=()=>{ue&&fe(!1),ce(!pe)},dt=()=>{pe&&ce(!1),fe(!ue)},st=e=>{Ie(!0);const t=e.currentTarget.getBoundingClientRect();De({x:e.clientX-t.left,y:e.clientY-t.top})},pt=t.useCallback(e=>{if(!ue)if(Ce){const t=e.clientX-ze.x,n=e.clientY-ze.y,o=window.innerWidth-Se.width,a=window.innerHeight-Se.height;we({x:Math.max(0,Math.min(t,o)),y:Math.max(0,Math.min(n,a))})}else if(We){const t=e.clientX-je.x,n=e.clientY-je.y;let o=je.width,a=je.height,l=je.posX,i=je.posY;const r=300,d=250,s=window.innerWidth-40,p=window.innerHeight-100;if("right"===Me)o=Math.min(Math.max(je.width+t,r),s),l+o>window.innerWidth&&(o=window.innerWidth-l);else if("left"===Me){const e=Math.min(Math.max(je.width-t,r),s),n=e-je.width;o=e,l=Math.max(0,je.posX-n),0===l&&(o=je.posX+je.width)}else if("bottom"===Me)a=Math.min(Math.max(je.height+n,d),p),i+a>window.innerHeight&&(a=window.innerHeight-i);else if("top"===Me){const e=Math.min(Math.max(je.height-n,d),p),t=e-je.height;a=e,i=Math.max(0,je.posY-t),0===i&&(a=je.posY+je.height)}ke({width:o,height:a}),we({x:l,y:i})}},[Ce,We,ze,Me,je,Fe,Se,ue]),ct=()=>{Ie(!1),Te(!1),Ae(null)},ut=(e,t)=>{t.preventDefault(),t.stopPropagation(),Te(!0),Ae(e),Re({x:t.clientX,y:t.clientY,width:Se.width,height:Se.height,posX:Fe.x,posY:Fe.y})};t.useEffect(()=>{if(Ce||We)return window.addEventListener("mousemove",pt),window.addEventListener("mouseup",ct),()=>{window.removeEventListener("mousemove",pt),window.removeEventListener("mouseup",ct)}},[Ce,We,pt]),t.useEffect(()=>{if(!de||ue)return;const e=()=>{if(!(window.innerWidth<768)){const e=pe?350:Se.width,t=pe?60:Se.height,n=window.innerWidth-40,o=window.innerHeight-100,a=Math.min(e,n),l=Math.min(t,o);a===Se.width&&l===Se.height||ke({width:a,height:l});const i=window.innerWidth-a-20,r=window.innerHeight-l-20;we(e=>({x:Math.min(e.x,i),y:Math.min(e.y,r)}))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[de,pe,ue,Se]),t.useEffect(()=>{if(!(F&&w&&(!S||j>0)))return;let e=!1;return T(!0),A(null),(async(e,t,n,o)=>{const a=e.replace(/\/$/,""),l="".concat(a,"/um/user/V1/sso/login?hospitalId=").concat(encodeURIComponent(t)),i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:n,email:o})};return console.log("[getTokenFromSso] request",{url:l,body:{idToken:n?n.slice(0,50)+"...":null,email:o}}),fetch(l,i).then(e=>(console.log("[getTokenFromSso] response status",e.status,e.statusText),e.ok?e.json().then(e=>{var t;return console.log("[getTokenFromSso] success",{hasData:!!e,dataKeys:e?Object.keys(e):[],hasAccessToken:!(null==e||null===(t=e.data)||void 0===t||!t.access_token)}),e}):e.json().then(t=>{var n;const o=(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"SSO login failed";return console.log("[getTokenFromSso] error body",t),{err:o,status:e.status}}).catch(()=>({err:"Something went wrong!",status:e.status})))).catch(e=>(console.error("[getTokenFromSso] catch",e),{err:e.message||"Network error"}))})(o,l,F,w).then(t=>{if(e)return;const o=function(e){var t,n,o,a,l,i;return!e||e.err?null:null!==(t=null!==(n=null!==(o=null!==(a=null===(l=e.data)||void 0===l?void 0:l.access_token)&&void 0!==a?a:null===(i=e.data)||void 0===i?void 0:i.token)&&void 0!==o?o:e.token)&&void 0!==n?n:e.accessToken)&&void 0!==t?t:null}(t);if(400===t.status){const e=n.homeUrl||"https://wbaemrdevittisalwe01-fnapdpfme7bvduhh.westeurope-01.azurewebsites.net/";return void(e&&"undefined"!=typeof window&&(window.location.href=e))}if(t.err||!o){A(String(t.err||"Failed to get token")),k(null),I(null),D(null);try{"undefined"!=typeof localStorage&&(localStorage.removeItem(h),localStorage.removeItem(y),localStorage.removeItem(E))}catch(e){}}else{const e=function(e){var t,n;if(null==e||!e.data)return null;const o=null!==(t=null!==(n=e.data.doctor_id)&&void 0!==n?n:e.data.doctorId)&&void 0!==t?t:null;return null!=o?String(o):null}(t),n=function(e){var t,n,o;if(null==e||!e.data)return null;const a=null!==(t=null!==(n=null!==(o=e.data.name)&&void 0!==o?o:e.data.doctor_name)&&void 0!==n?n:e.data.userName)&&void 0!==t?t:null;return null!=a?String(a):null}(t);k(o),I(e),D(n),A(null);try{"undefined"!=typeof localStorage&&(localStorage.setItem(h,o),e&&localStorage.setItem(y,e),n&&localStorage.setItem(E,n))}catch(e){}}}).catch(()=>{}).finally(()=>{e||T(!1)}),()=>{e=!0}},[o,l,F,w,j]),t.useEffect(()=>{Be(1)},[P,Q,Ue,Xe,ie]),t.useEffect(()=>{!W&&S&&ot()},[ot,S,W]),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=()=>{K(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=>{!ne||e.target.closest("button")||e.target.closest('input[type="date"]')||oe(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[ne]);let ft,mt='"Nunito", serif';return ft=M?a.default.createElement("div",{style:{fontFamily:mt,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"24px",textAlign:"center"}},a.default.createElement("div",{style:{maxWidth:"400px",padding:"32px 24px",background:"#FFFFFF",borderRadius:"12px",boxShadow:"0 4px 20px rgba(0,0,0,0.08)"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"🔒"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Not authorised"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},M),a.default.createElement("p",{style:{fontSize:"13px",color:"#999",marginTop:"16px",marginBottom:0}},"You are not authorised to use this service. Please sign in again or contact support."))):W&&F&&w?a.default.createElement("div",{style:{fontFamily:mt,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"24px"}},a.default.createElement("style",null,"@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }"),a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"16px"}}),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0}},"Checking authorisation...")):a.default.createElement("div",{style:{fontFamily:mt,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"}},a.default.createElement("div",{style:{background:"#FFFFFF",padding:J?"10px 12px":"12px 24px",display:"flex",justifyContent:"space-between",alignItems:"center",borderBottom:"1px solid #E5E5E5",flexWrap:"nowrap",gap:J?"8px":"0"}},a.default.createElement("div",{style:{position:"relative",width:J?"calc(100% - 90px)":"480px",maxWidth:J?"none":"480px"}},a.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:ie,onChange:e=>re(e.target.value),style:{width:"100%",padding:J?"8px 32px 8px 10px":"8px 36px 8px 14px",border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:J?"12px":"13px",fontFamily:mt,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),ie&&a.default.createElement("button",{onClick:()=>re(""),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"},"✕")),a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:J?"10px":"16px"}},a.default.createElement("div",{style:{position:"relative",cursor:"pointer"}},a.default.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#555",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),a.default.createElement("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})),a.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")),a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:"8px"}},!J&&a.default.createElement("span",{style:{fontSize:"13px",color:"#555"}},"Hello, ",a.default.createElement("strong",{style:{color:"#1a1a1a"}},L)),a.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"}})))),a.default.createElement("div",{style:{padding:J?"12px":"16px 24px",flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}},a.default.createElement("div",{style:{marginBottom:J?"10px":"14px"}},a.default.createElement("h1",{style:{fontSize:J?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),a.default.createElement("p",{style:{fontSize:J?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:J?"flex-start":"center",marginBottom:J?"10px":"14px",flexDirection:J?"column":"row",gap:J?"12px":"0"}},a.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:J?"100%":"auto"}},a.default.createElement("button",{onClick:()=>Y("upcoming"),style:{background:"upcoming"===P?"#4C4DDC":"#FFFFFF",padding:J?"8px 10px":"9px 16px",border:"upcoming"===P?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:J?"10px":"13px",color:"upcoming"===P?"white":"#555555",fontWeight:600,fontFamily:mt,cursor:"pointer",flex:J?"1 1 auto":"none",minWidth:J?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),a.default.createElement("button",{onClick:()=>Y("completed"),style:{background:"completed"===P?"#4C4DDC":"#FFFFFF",padding:J?"8px 10px":"9px 16px",border:"completed"===P?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:J?"10px":"13px",color:"completed"===P?"white":"#555555",fontWeight:600,fontFamily:mt,cursor:"pointer",flex:J?"1 1 auto":"none",minWidth:J?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),a.default.createElement("button",{onClick:()=>Y("cancelled"),style:{background:"cancelled"===P?"#4C4DDC":"#FFFFFF",padding:J?"8px 10px":"9px 16px",border:"cancelled"===P?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:J?"10px":"13px",color:"cancelled"===P?"white":"#555555",fontWeight:600,fontFamily:mt,cursor:"pointer",flex:J?"1 1 auto":"none",minWidth:J?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Cancelled Appointments")),a.default.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"auto",position:"relative",justifyContent:J?"flex-start":"flex-end"}},a.default.createElement("button",{onClick:()=>{ne||(Ge(Ue),Ke(Xe),te(Q)),oe(!ne)},style:{padding:"8px 12px",fontFamily:mt,fontWeight:600,border:"1px solid #E5E5E5",borderRadius:"6px",fontSize:J?"11px":"13px",color:"#1a1a1a",background:"#FFFFFF",display:"flex",alignItems:"center",gap:J?"4px":"6px",cursor:"pointer",flex:"none",minWidth:J?"100px":"auto",justifyContent:"center"}},a.default.createElement("svg",{width:J?"12":"14",height:J?"12":"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),a.default.createElement("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.default.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),a.default.createElement("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),a.default.createElement("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},(()=>{switch(Q){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 J?"Custom":"".concat(Ue," to ").concat(Xe)}})()),a.default.createElement("svg",{width:J?"8":"10",height:J?"8":"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),ne&&a.default.createElement("div",{style:{position:"absolute",top:"100%",right:J?"auto":0,left:J?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:J?"280px":"240px",width:J?"calc(100vw - 24px)":"auto",maxWidth:J?"calc(100vw - 24px)":"280px"}},a.default.createElement("div",{style:{marginBottom:"custom"===ee?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map(e=>a.default.createElement("button",{key:e,onClick:()=>{if(te(e),"custom"!==e){const t=(e=>{const t=new Date;let n,o;switch(e){case"today":default:n=o=H();break;case"tomorrow":const e=new Date(t);e.setDate(e.getDate()+1),n=o=e.toISOString().split("T")[0];break;case"currentWeek":const a=new Date(t),l=new Date(t),i=t.getDay(),r=0===i?-6:1-i;a.setDate(t.getDate()+r),l.setDate(a.getDate()+6),n=a.toISOString().split("T")[0],o=l.toISOString().split("T")[0];break;case"thisMonth":const d=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);n=d.toISOString().split("T")[0],o=s.toISOString().split("T")[0];break;case"currentYear":n="".concat(t.getFullYear(),"-01-01"),o="".concat(t.getFullYear(),"-12-31")}return{from:n,to:o}})(e);Z(e),Ve(t.from),$e(t.to),Ge(t.from),Ke(t.to),oe(!1)}else Ge(""),Ke("")},style:{width:"100%",padding:"10px 12px",background:ee===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:mt,cursor:"pointer",textAlign:"left",fontWeight:ee===e?600:400,color:ee===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{ee!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{ee!==e&&(t.target.style.background="#FFFFFF")}},a.default.createElement("span",null,{thisMonth:"This Month",today:"Today",tomorrow:"Tomorrow",currentWeek:"Current Week",currentYear:"Current Year",custom:"Custom"}[e]),ee===e&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓")))),"custom"===ee&&a.default.createElement("div",{style:{paddingTop:"8px",borderTop:"1px solid #E5E5E5"}},a.default.createElement("div",{style:{marginBottom:"8px"}},a.default.createElement("input",{type:"date",value:qe,onChange:e=>Ge(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:mt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{marginBottom:"12px"}},a.default.createElement("input",{type:"date",value:Je,onChange:e=>Ke(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:mt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{display:"flex",gap:"8px"}},a.default.createElement("button",{onClick:()=>{te(Q),Ge(Ue),Ke(Xe),oe(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:mt,fontWeight:600,cursor:"pointer"}},"Cancel"),a.default.createElement("button",{onClick:()=>{qe&&Je&&(Z("custom"),Ve(qe),$e(Je),oe(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:mt,fontWeight:600,cursor:"pointer"}},"Submit")))))),a.default.createElement("div",{style:{display:"flex",flexDirection:J?"column":"row",gap:J?"12px":"14px",flex:1,minHeight:0,overflow:J?"auto":"hidden"}},a.default.createElement("div",{style:{flex:J?"none":"1 1 65%",width:J?"100%":"auto",display:"flex",flexDirection:"column",minHeight:J?"400px":"auto"}},a.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:J?"auto":"100%"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:J?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:J?"6px":"8px"}},a.default.createElement("span",{style:{fontSize:J?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),a.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:J?"10px":"11px",fontWeight:600,padding:J?"2px 7px":"3px 8px",borderRadius:"12px"}},_e))),a.default.createElement("div",{className:"appointments-header-grid",style:{display:"grid",gridTemplateColumns:J?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:J?"8px":"12px",padding:J?"8px 12px":"10px 18px",background:"#F5F5F5",fontSize:J?"10px":"12px",fontWeight:600,color:"#666"}},a.default.createElement("div",null,"Patients name"),!J&&a.default.createElement("div",null,"Patient ID"),a.default.createElement("div",{onClick:nt,style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",a.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===ae?"▲":"▼")),!J&&a.default.createElement("div",null,"Slot"),!J&&a.default.createElement("div",null,"Doctor")),a.default.createElement("div",{style:{overflow:"auto",flex:1}},W?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.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"}}),"Getting token...")):X?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.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...")):q?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#FF0000"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"⚠️ Error"),a.default.createElement("div",{style:{fontSize:"13px"}},q),a.default.createElement("button",{onClick:ot,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:mt}},"Retry")):0===Ye.length?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#888"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},ie?'No appointments found for "'.concat(ie,'"'):"No appointments found"),ie&&a.default.createElement("button",{onClick:()=>re(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:mt}},"Clear Search")):Ye.map(e=>a.default.createElement("div",{key:Qe(e),role:"button",tabIndex:0,onClick:()=>at(e),onKeyDown:t=>"Enter"===t.key&&at(e),className:"appointments-grid",style:{display:"grid",gridTemplateColumns:J?"1.5fr 1fr 0.8fr":"2.5fr 1fr 1.5fr 0.8fr 1.2fr",gap:J?"8px":"12px",padding:J?"10px 12px":"12px 18px",background:Qe(U)===Qe(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:J?"11px":"13px"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:J?"8px":"10px"}},Ze(e)?a.default.createElement("img",{src:e.image,alt:"",style:{width:J?"32px":"36px",height:J?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):a.default.createElement("div",{style:{width:J?"32px":"36px",height:J?"32px":"36px",borderRadius:"50%",background:tt(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:J?"14px":"16px"}},et(e.patientName)),a.default.createElement("div",null,a.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:J?"11px":"13px"}},e.patientName),a.default.createElement("div",{style:{fontSize:J?"9px":"11px",color:"#888"}},e.email))),!J&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),a.default.createElement("div",{style:{color:"#555",fontSize:J?"10px":"12px"}},(()=>{const t=e.appointmentDate||"",n=t.match(/\s(\d{1,2}:\d{2}(?:\s*(?:AM|PM))?)$/i);return n?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",null,t.slice(0,n.index).trim()),a.default.createElement("div",{style:{fontSize:J?"9px":"11px",color:"#888"}},n[1].trim())):a.default.createElement("div",null,t)})()),!J&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!J&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-")))),!X&&!q&&Ye.length>0&&a.default.createElement("div",{style:{padding:J?"12px 14px":"14px 18px",borderTop:"1px solid #F1F1F1",display:"flex",justifyContent:"space-between",alignItems:"center",background:"#FFFFFF",flexWrap:J?"wrap":"nowrap",gap:J?"10px":"0"}},a.default.createElement("div",{style:{fontSize:J?"11px":"12px",color:"#666"}},"Showing page ",Ne," of ",Oe," (",_e," total)"),a.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},a.default.createElement("button",{onClick:()=>Be(e=>Math.max(1,e-1)),disabled:1===Ne,style:{padding:J?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===Ne?"#F5F5F5":"#FFFFFF",color:1===Ne?"#999":"#1a1a1a",fontSize:J?"11px":"12px",fontFamily:mt,fontWeight:600,cursor:1===Ne?"not-allowed":"pointer",opacity:1===Ne?.5:1}},"Previous"),a.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,Oe))].map((e,t)=>{let n;return n=Oe<=5||Ne<=3?t+1:Ne>=Oe-2?Oe-4+t:Ne-2+t,a.default.createElement("button",{key:n,onClick:()=>Be(n),style:{padding:J?"6px 10px":"6px 12px",border:Ne===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:Ne===n?"#4C4DDC":"#FFFFFF",color:Ne===n?"#FFFFFF":"#1a1a1a",fontSize:J?"11px":"12px",fontFamily:mt,fontWeight:600,cursor:"pointer",minWidth:J?"32px":"36px"}},n)})),a.default.createElement("button",{onClick:()=>Be(e=>Math.min(Oe,e+1)),disabled:Ne===Oe,style:{padding:J?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:Ne===Oe?"#F5F5F5":"#FFFFFF",color:Ne===Oe?"#999":"#1a1a1a",fontSize:J?"11px":"12px",fontFamily:mt,fontWeight:600,cursor:Ne===Oe?"not-allowed":"pointer",opacity:Ne===Oe?.5:1}},"Next"))))),a.default.createElement("div",{style:{flex:J?"none":"1 1 35%",width:J?"100%":"auto",display:U||!J?"flex":"none",flexDirection:"column",minHeight:"auto"}},a.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:J?"auto":"100%"}},U?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:J?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},a.default.createElement("div",null,a.default.createElement("div",{style:{color:"#002668",fontSize:J?"14px":"16px",fontWeight:"700"}},U.patientName||"N/A"),a.default.createElement("div",{style:{color:"#002668",fontSize:J?"11px":"13px"}},U.patientId||U.mrn||"N/A")),a.default.createElement("div",null,Ze(U)?a.default.createElement("img",{style:{width:J?"36px":"44px",height:J?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:U.image,alt:U.patientName}):a.default.createElement("div",{style:{width:J?"36px":"44px",height:J?"36px":"44px",borderRadius:"50%",background:tt(U.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:J?"16px":"20px"}},et(U.patientName)))),a.default.createElement("div",{style:{padding:J?"12px 14px":"14px 18px",gap:J?"10px":"12px",display:"flex",flexDirection:"column",background:"white",overflow:"auto",flex:1,position:"relative"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:J?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:J?"12px":"13px"}},(null==U?void 0:U.specialisation)||(null==U?void 0:U.speciality)||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:J?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:J?"12px":"13px"}},(null==U?void 0:U.type)||(null==U?void 0:U.appointmentType)||"Online"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:J?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:J?"12px":"13px"}},(null==U?void 0:U.date)||(null==U?void 0:U.appointmentDate)||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:J?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:J?"12px":"13px"}},(null==U?void 0:U.time)||(null==U?void 0:U.appointmentTime)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:J?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:J?"12px":"13px"}},(null==U?void 0:U.doctor)||(null==U?void 0:U.doctorName)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:J?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:J?"12px":"13px"}},(null==U?void 0:U.hospital)||(null==U?void 0:U.hospitalName)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:J?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),a.default.createElement("div",{style:{fontWeight:"600",fontSize:J?"11px":"12px",lineHeight:"1.4"}},(null==U?void 0:U.reason)||(null==U?void 0:U.reasonForAppointment)||"No reason provided"))),a.default.createElement("div",{style:{display:"flex",flexDirection:J?"column":"row",gap:"6px",marginTop:"10px"}},a.default.createElement("button",{type:"button",onClick:lt,disabled:ye,style:{flex:1,background:ye?"#99e4e8":"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:J?"10px 8px":"8px 6px",fontFamily:mt,fontWeight:600,fontSize:J?"11px":"12px",cursor:ye?"not-allowed":"pointer"}},ye?"Connecting...":"Join Call >")),ve&&a.default.createElement("div",{style:{fontSize:"11px",color:"#e53935",marginTop:"6px",textAlign:"center",width:"100%"}},"⚠️ ",ve))):a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"40px",color:"#888",textAlign:"center"}},a.default.createElement("div",null,a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},"Select an appointment to view details"))))))),de&&a.default.createElement("div",{style:{position:"fixed",left:ue?"0":J?"10px":"".concat(Fe.x,"px"),top:ue?"0":J?"70px":"".concat(Fe.y,"px"),right:ue?"0":J?"10px":"auto",bottom:ue?"0":"auto",width:ue?"100vw":J?"calc(100vw - 20px)":pe?"350px":"".concat(Se.width,"px"),height:ue?"100vh":pe?"auto":J?"300px":"".concat(Se.height,"px"),background:"#FFFFFF",borderRadius:ue?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:Ce||We?"none":"all 0.3s ease"}},a.default.createElement("div",{onMouseDown:J||ue?void 0:st,style:{background:"linear-gradient(135deg, #4C4DDC 0%, #3A3BBD 100%)",color:"#FFFFFF",padding:J?"8px 10px":"10px 12px",display:"flex",justifyContent:"space-between",alignItems:"center",cursor:!J&&!ue&&(Ce?"grabbing":"grab"),userSelect:"none"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:J?"6px":"8px",flex:1,minWidth:0}},a.default.createElement("div",{style:{width:J?"6px":"8px",height:J?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),a.default.createElement("span",{style:{fontSize:J?"11px":"13px",fontWeight:600,fontFamily:mt,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",(null==U?void 0:U.patientName)||"Patient")),a.default.createElement("div",{style:{display:"flex",gap:J?"4px":"6px",alignItems:"center",flexShrink:0}},!ue&&a.default.createElement("button",{onClick:rt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:J?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:J?"28px":"32px",height:J?"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:pe?"Restore":"Minimize"},pe?a.default.createElement("svg",{width:J?"14":"16",height:J?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("rect",{x:"3",y:"3",width:"10",height:"10",stroke:"white",strokeWidth:"1.8",fill:"none"})):a.default.createElement("svg",{width:J?"14":"16",height:J?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round"}))),a.default.createElement("button",{onClick:dt,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:J?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:J?"28px":"32px",height:J?"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:ue?"Exit Fullscreen":"Fullscreen"},ue?a.default.createElement("svg",{width:J?"14":"16",height:J?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M10 3H13V6M6 13H3V10M13 10V13H10M3 6V3H6",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})):a.default.createElement("svg",{width:J?"14":"16",height:J?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M3 6V3H6M13 10V13H10M10 3H13V6M6 13H3V10",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))),a.default.createElement("button",{onClick:it,style:{background:"rgba(255, 255, 255, 0.2)",border:"1px solid rgba(255, 255, 255, 0.3)",borderRadius:"6px",color:"#FFFFFF",cursor:"pointer",padding:J?"5px 8px":"6px 10px",lineHeight:1,display:"flex",alignItems:"center",justifyContent:"center",minWidth:J?"28px":"32px",height:J?"28px":"32px",fontWeight:"bold",fontSize:J?"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"},"×"))),!pe&&a.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},a.default.createElement("iframe",{src:(()=>{if(!me)return"";const e=String(N||"").replace(/\/?$/,"/");return console.log("${base}token=${callToken}","".concat(e,"token=").concat(me)),"".concat(e,"token=").concat(me)})(),style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!J&&!ue&&!pe&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{onMouseDown:e=>ut("left",e),style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>ut("right",e),style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>ut("top",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",top:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>ut("bottom",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),a.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:We&&"left"===Me?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}}),a.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:We&&"right"===Me?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}})),a.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "))),a.default.createElement(v,null,ft)};let F=null;const w={showWidget:(e,t)=>{F||(F=document.createElement("div"),document.body.appendChild(F));const n=()=>a.default.createElement(a.default.Fragment,null,a.default.createElement(b,{config:e}));l.default.render(a.default.createElement(n,null),F)},closePopup:()=>{F&&(l.default.unmountComponentAtNode(F),F=null)}};window.BookingSDK=w,e.AppointmentPage=b,e.default=w,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 o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t),l=o(n);function i(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const r="https://afiyaapiqa.powermindinc.com",d="/appointment/V1/consultant/all-appointments",s="/notification/V1/consultation/online/initiate",p="dMtEGhak",c=6694,u="https://wbafedevittisalwe01-had2b3e0a7h6fyey.westeurope-01.azurewebsites.net/call/",f="https://wbaemrdevittisalwe01-fnapdpfme7bvduhh.westeurope-01.azurewebsites.net/",m=async function(e,t,n){let o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},a=(e||"").toUpperCase();"INPROGRESS"===a&&(a="IN_PROGRESS");const l=o.apiBaseUrl||r,i=o.hospitalId||p,s=o.doctorId||c,u=o.token||"",f={hospitalId:i,doctorId:s,fromDate:t,toDate:n,statuses:a},m="".concat(l).concat(d),x=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 o=new URL(e);o.search=new URLSearchParams(t).toString();const a={method:"GET",headers:{"Content-Type":"application/json",Authorization:"".concat(n)}};return fetch(o,a).then(async e=>{const t=await e.json().catch(()=>({}));var n;return e.ok?t:{err:(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"Something went wrong!",status:e.status}}).catch(e=>(console.error("Fetch error:",e),{err:(null==e?void 0:e.message)||String(e)||"Network error"}))}(m,f,"PIH-Appointment-Widget",u);return x},x=async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=(t.apiBaseUrl||r).replace(/\/$/,""),o="".concat(n).concat(s),a=t.appToken||"";return async function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=arguments.length>4?arguments[4]:void 0;const a=new URL(e);Object.keys(n).forEach(e=>{a.searchParams.append(e,n[e])});const l={"Content-Type":"application/json"};o&&(l.Authorization=o);const i={method:"POST",headers:l,body:JSON.stringify(t)};return fetch(a.toString(),i).then(async e=>{const t=await e.json().catch(()=>({}));var n;return e.ok?t:{err:(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"Something went wrong!",status:e.status}}).catch(e=>(console.error("Fetch error:",e),{err:e.message||"Network error"}))}(o,{patientId:String(e.patientId||""),primaryPatientId:String(e.primaryPatientId||e.patientId||""),hospitalId:t.hospitalId||p,doctorId:String(t.doctor_id||c),patientName:e.patientName||e.name||"",doctorName:e.doctorName||t.doctorName,appointmentId:String(e.id||e.appointmentId||e._id||"")},"PIH-Appointment-Widget",{},a)};const g="pih_appointment_idToken",h="pih_appointment_email",y="pih_appointment_appToken",E="pih_appointment_doctorId",v="pih_appointment_userName";class b extends t.Component{constructor(){super(...arguments),i(this,"state",{hasError:!1})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e,t){"undefined"!=typeof console&&console.error&&console.error("Appointment widget error:",e,t)}render(){return this.state.hasError?a.default.createElement("div",{style:{fontFamily:'"Nunito", serif',background:"#F5F5F7",boxSizing:"border-box",minHeight:"100vh",display:"flex",alignItems:"center",justifyContent:"center",padding:"24px",textAlign:"center"}},a.default.createElement("div",{style:{maxWidth:"400px"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"⚠️"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Something went wrong"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},"Please refresh the page or try again later."))):this.props.children}}const F=e=>{let{config:n={}}=e;const o=n.apiBaseUrl||r,l=n.hospitalId||p,[i,d]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(g):null}catch(e){return null}}),[s,F]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(h):null}catch(e){return null}}),w=n.idToken||n.token||i,S=n.email||s;t.useEffect(()=>{try{if("undefined"==typeof localStorage)return;const e=n.idToken||n.token;if(e&&String(e).trim()){localStorage.getItem(g)!==e&&(C(null),z(null),W(null),localStorage.removeItem(y),localStorage.removeItem(E),localStorage.removeItem(v)),localStorage.setItem(g,e),d(e)}n.email&&String(n.email).trim()&&(localStorage.setItem(h,n.email),F(n.email))}catch(e){}},[n.idToken,n.token,n.email]);const[k,C]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(y):null}catch(e){return null}}),[I,z]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(E):null}catch(e){return null}}),[D,W]=t.useState(()=>{try{return"undefined"!=typeof localStorage?localStorage.getItem(v):null}catch(e){return null}}),[T,M]=t.useState(()=>{try{if("undefined"==typeof localStorage)return!1;const e=localStorage.getItem(y),t=localStorage.getItem(g),n=localStorage.getItem(h);return!e&&!(!t||!n)}catch(e){return!1}}),[A,R]=t.useState(null),[j,N]=t.useState(0);t.useEffect(()=>{k&&T&&M(!1)},[k,T]),t.useEffect(()=>{if(!T)return;const e=setTimeout(()=>{R("Request timed out. Please try again."),M(!1)},3e4);return()=>clearTimeout(e)},[T]);const B=n.joinCallUrl||u;k&&String(B||"").replace(/\/?$/,"/");const L=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,"/"),o=n.padEnd(n.length+(4-n.length%4)%4,"=");return JSON.parse(atob(o))}catch(e){return{}}}(w),H=D||L.name||L.sub||"User",P=()=>(new Date).toISOString().split("T")[0],[Y,O]=t.useState("upcoming"),[_,U]=t.useState([]),[V,X]=t.useState(null),[$,q]=t.useState(!1),[G,J]=t.useState(null),[K,Q]=t.useState(window.innerWidth<768),[Z,ee]=t.useState("today"),[te,ne]=t.useState("today"),[oe,ae]=t.useState(!1),[le,ie]=t.useState("asc"),[re,de]=t.useState(""),[se,pe]=t.useState(!1),[ce,ue]=t.useState(!1),[fe,me]=t.useState(!1),[xe,ge]=t.useState(null),[he,ye]=t.useState(null),[Ee,ve]=t.useState(!1),[be,Fe]=t.useState(null),[we,Se]=t.useState({x:window.innerWidth-550,y:80}),[ke,Ce]=t.useState({width:550,height:450}),[Ie,ze]=t.useState(!1),[De,We]=t.useState({x:0,y:0}),[Te,Me]=t.useState(!1),[Ae,Re]=t.useState(null),[je,Ne]=t.useState({x:0,y:0,width:0,height:0}),[Be,Le]=t.useState(!1),[He,Pe]=t.useState(1),Ye=_.filter(e=>{if(!re.trim())return!0;const t=re.toLowerCase(),n=(e.patientName||"").toLowerCase(),o=String(e.patientId||"").toLowerCase();return n.includes(t)||o.includes(t)}),Oe=20*(He-1),_e=Oe+20,Ue=Ye.slice(Oe,_e),Ve=Math.ceil(Ye.length/20),Xe=Ye.length,[$e,qe]=t.useState(P()),[Ge,Je]=t.useState(P()),[Ke,Qe]=t.useState(),[Ze,et]=t.useState(),tt=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),nt=e=>null!=e&&e.image?e.image:null,ot=e=>e?e.charAt(0).toUpperCase():"?",at=e=>{if(!e)return"#4C4DDC";const t=["#4C4DDC","#1CC3CE","#FF6B6B","#4ECDC4","#45B7D1","#FFA07A","#98D8C8","#F7DC6F"];return t[e.charCodeAt(0)%t.length]},lt=()=>{const e="asc"===le?"desc":"asc";ie(e);const t=[..._].sort((t,n)=>{const o=new Date(t.appointmentDate||t.date||0),a=new Date(n.appointmentDate||n.date||0);return"asc"===e?o-a:a-o});U(t),Pe(1),t.length>0&&X(t[0])},it=t.useCallback(async()=>{if(!k)return;const e=I||c;q(!0),J(null);try{const t={apiBaseUrl:o,hospitalId:l,doctorId:e,token:k},n=await m(Y,$e,Ge,t);if(401===n.status||403===n.status){try{"undefined"!=typeof localStorage&&(localStorage.removeItem(y),localStorage.removeItem(E),localStorage.removeItem(v))}catch(e){}return C(null),z(null),W(null),N(e=>e+1),void J("Session expired. Re-authenticating...")}if(n.err)return void J(String(n.err||"Failed to fetch appointments"));const a=n.data||n.appointments||n||[];U(Array.isArray(a)?a:[]),Array.isArray(a)&&a.length>0?X(a[0]):X(null)}catch(e){console.error("Error fetching appointments:",e),J(e.message||"Failed to fetch appointments")}finally{q(!1)}},[Y,$e,Ge,o,l,I,k]),rt=e=>{X(e)},dt=()=>{try{"undefined"!=typeof localStorage&&(localStorage.removeItem(g),localStorage.removeItem(h),localStorage.removeItem(y),localStorage.removeItem(E),localStorage.removeItem(v))}catch(e){}Le(!1);const e=n.homeUrl||f||"";e&&"undefined"!=typeof window&&(window.location.href=e)},st=async()=>{if(V&&k){ve(!0),Fe(null);try{var e;const t={apiBaseUrl:o,hospitalId:l,doctorId:I||c,doctorName:D||H,appToken:k};console.log(V,"selectedAppointment"),console.log(t,"callConfig");const a=await x(V,t);if(401===a.status||403===a.status)return Fe("Session expired. Please try again."),void ve(!1);if(a.err||null===(e=a.data)||void 0===e||!e.token)return Fe(String(a.err||"Failed to initiate call")),void ve(!1);const i=n.joinCallUrl||u,r=a.data.token?String(i||"").replace(/\/?$/,"/")+a.data.token:"";console.log("joinCallUrl",r),ge(a.data.token),ye(r||""),pe(!0),ue(!1),me(!1)}catch(e){Fe(e.message||"Failed to initiate call")}finally{ve(!1)}}},pt=()=>{pe(!1),ue(!1),me(!1),ge(null),ye(null),Fe(null)},ct=()=>{fe&&me(!1),ue(!ce)},ut=()=>{ce&&ue(!1),me(!fe)},ft=e=>{ze(!0);const t=e.currentTarget.getBoundingClientRect();We({x:e.clientX-t.left,y:e.clientY-t.top})},mt=t.useCallback(e=>{if(!fe)if(Ie){const t=e.clientX-De.x,n=e.clientY-De.y,o=window.innerWidth-ke.width,a=window.innerHeight-ke.height;Se({x:Math.max(0,Math.min(t,o)),y:Math.max(0,Math.min(n,a))})}else if(Te){const t=e.clientX-je.x,n=e.clientY-je.y;let o=je.width,a=je.height,l=je.posX,i=je.posY;const r=300,d=250,s=window.innerWidth-40,p=window.innerHeight-100;if("right"===Ae)o=Math.min(Math.max(je.width+t,r),s),l+o>window.innerWidth&&(o=window.innerWidth-l);else if("left"===Ae){const e=Math.min(Math.max(je.width-t,r),s),n=e-je.width;o=e,l=Math.max(0,je.posX-n),0===l&&(o=je.posX+je.width)}else if("bottom"===Ae)a=Math.min(Math.max(je.height+n,d),p),i+a>window.innerHeight&&(a=window.innerHeight-i);else if("top"===Ae){const e=Math.min(Math.max(je.height-n,d),p),t=e-je.height;a=e,i=Math.max(0,je.posY-t),0===i&&(a=je.posY+je.height)}Ce({width:o,height:a}),Se({x:l,y:i})}},[Ie,Te,De,Ae,je,we,ke,fe]),xt=()=>{ze(!1),Me(!1),Re(null)},gt=(e,t)=>{t.preventDefault(),t.stopPropagation(),Me(!0),Re(e),Ne({x:t.clientX,y:t.clientY,width:ke.width,height:ke.height,posX:we.x,posY:we.y})};t.useEffect(()=>{if(Ie||Te)return window.addEventListener("mousemove",mt),window.addEventListener("mouseup",xt),()=>{window.removeEventListener("mousemove",mt),window.removeEventListener("mouseup",xt)}},[Ie,Te,mt]),t.useEffect(()=>{if(!se||fe)return;const e=()=>{if(!(window.innerWidth<768)){const e=ce?350:ke.width,t=ce?60:ke.height,n=window.innerWidth-40,o=window.innerHeight-100,a=Math.min(e,n),l=Math.min(t,o);a===ke.width&&l===ke.height||Ce({width:a,height:l});const i=window.innerWidth-a-20,r=window.innerHeight-l-20;Se(e=>({x:Math.min(e.x,i),y:Math.min(e.y,r)}))}};return window.addEventListener("resize",e),()=>window.removeEventListener("resize",e)},[se,ce,fe,ke]),t.useEffect(()=>{if(!(w&&S&&(!k||j>0)))return;let e=!1;return M(!0),R(null),(async(e,t,n,o)=>{const a=e.replace(/\/$/,""),l="".concat(a,"/um/user/V1/sso/login?hospitalId=").concat(encodeURIComponent(t)),i={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({idToken:n,email:o})};return console.log("[getTokenFromSso] request",{url:l,body:{idToken:n?n.slice(0,50)+"...":null,email:o}}),fetch(l,i).then(e=>(console.log("[getTokenFromSso] response status",e.status,e.statusText),e.ok?e.json().then(e=>{var t;return console.log("[getTokenFromSso] success",{hasData:!!e,dataKeys:e?Object.keys(e):[],hasAccessToken:!(null==e||null===(t=e.data)||void 0===t||!t.access_token)}),e}):e.json().then(t=>{var n;const o=(null==t||null===(n=t.resultInfo)||void 0===n?void 0:n.message)||"SSO login failed";return console.log("[getTokenFromSso] error body",t),{err:o,status:e.status}}).catch(()=>({err:"Something went wrong!",status:e.status})))).catch(e=>(console.error("[getTokenFromSso] catch",e),{err:e.message||"Network error"}))})(o,l,w,S).then(t=>{if(e)return;const o=function(e){var t,n,o,a,l,i;return!e||e.err?null:null!==(t=null!==(n=null!==(o=null!==(a=null===(l=e.data)||void 0===l?void 0:l.access_token)&&void 0!==a?a:null===(i=e.data)||void 0===i?void 0:i.token)&&void 0!==o?o:e.token)&&void 0!==n?n:e.accessToken)&&void 0!==t?t:null}(t);if(400===t.status){const e=t.err+" Redirecting to home..."||"Invalid user. Redirecting to home...";R(e),M(!1);const o=n.homeUrl||f||"";return void(o&&"undefined"!=typeof window&&setTimeout(()=>{window.location.href=o},3e3))}if(t.err||!o){R(String(t.err||"Failed to get token")),C(null),z(null),W(null);try{"undefined"!=typeof localStorage&&(localStorage.removeItem(y),localStorage.removeItem(E),localStorage.removeItem(v))}catch(e){}}else{const e=function(e){var t,n;if(null==e||!e.data)return null;const o=null!==(t=null!==(n=e.data.doctor_id)&&void 0!==n?n:e.data.doctorId)&&void 0!==t?t:null;return null!=o?String(o):null}(t),n=function(e){var t,n,o;if(null==e||!e.data)return null;const a=null!==(t=null!==(n=null!==(o=e.data.name)&&void 0!==o?o:e.data.doctor_name)&&void 0!==n?n:e.data.userName)&&void 0!==t?t:null;return null!=a?String(a):null}(t);C(o),z(e),W(n),R(null);try{"undefined"!=typeof localStorage&&(localStorage.setItem(y,o),e&&localStorage.setItem(E,e),n&&localStorage.setItem(v,n))}catch(e){}}}).catch(()=>{}).finally(()=>{e||M(!1)}),()=>{e=!0}},[o,l,w,S,j]),t.useEffect(()=>{Pe(1)},[Y,Z,$e,Ge,re]),t.useEffect(()=>{!T&&k&&it()},[it,k,T]),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=()=>{Q(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=>{!oe||e.target.closest("button")||e.target.closest('input[type="date"]')||ae(!1)};return document.addEventListener("click",e),()=>{document.removeEventListener("click",e)}},[oe]);let ht,yt='"Nunito", serif';return ht=A?a.default.createElement("div",{style:{fontFamily:yt,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"24px",textAlign:"center"}},a.default.createElement("div",{style:{maxWidth:"400px",padding:"32px 24px",background:"#FFFFFF",borderRadius:"12px",boxShadow:"0 4px 20px rgba(0,0,0,0.08)"}},a.default.createElement("div",{style:{fontSize:"48px",marginBottom:"16px"}},"🔒"),a.default.createElement("h2",{style:{fontSize:"20px",fontWeight:700,color:"#1a1a1a",margin:"0 0 8px 0"}},"Not authorised"),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0,lineHeight:1.5}},A),a.default.createElement("p",{style:{fontSize:"13px",color:"#999",marginTop:"16px",marginBottom:0}},"You are not authorised to use this service. Please sign in again or contact support."))):T&&w&&S?a.default.createElement("div",{style:{fontFamily:yt,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",padding:"24px"}},a.default.createElement("style",null,"@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }"),a.default.createElement("div",{style:{width:"40px",height:"40px",border:"3px solid #f3f3f3",borderTop:"3px solid #4C4DDC",borderRadius:"50%",animation:"spin 1s linear infinite",marginBottom:"16px"}}),a.default.createElement("p",{style:{fontSize:"14px",color:"#666",margin:0}},"Checking authorisation...")):a.default.createElement("div",{style:{fontFamily:yt,background:"#F5F5F7",boxSizing:"border-box",height:"100vh",display:"flex",flexDirection:"column",overflow:"hidden"}},a.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"}},a.default.createElement("div",{style:{position:"relative",width:K?"calc(100% - 90px)":"480px",maxWidth:K?"none":"480px"}},a.default.createElement("input",{type:"text",placeholder:"Search by patient name or ID",value:re,onChange:e=>de(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:yt,background:"#FFFFFF",outline:"none",boxSizing:"border-box"}}),re&&a.default.createElement("button",{onClick:()=>de(""),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"},"✕")),a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:K?"10px":"16px"}},a.default.createElement("div",{style:{position:"relative",cursor:"pointer"}},a.default.createElement("svg",{width:"20",height:"20",viewBox:"0 0 24 24",fill:"none",stroke:"#555",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},a.default.createElement("path",{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"}),a.default.createElement("path",{d:"M13.73 21a2 2 0 0 1-3.46 0"})),a.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")),a.default.createElement("div",{style:{position:"relative"}},a.default.createElement("button",{type:"button",onClick:()=>Le(e=>!e),style:{display:"flex",alignItems:"center",gap:"8px",background:"none",border:"none",cursor:"pointer",padding:"4px 0",fontFamily:yt},"aria-expanded":Be,"aria-haspopup":"true"},!K&&a.default.createElement("span",{style:{fontSize:"13px",color:"#555"}},"Hello, ",a.default.createElement("strong",{style:{color:"#1a1a1a"}},H)),a.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"}}),a.default.createElement("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",style:{flexShrink:0,opacity:Be?.8:.5}},a.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),Be&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{position:"fixed",inset:0,zIndex:9998},onClick:()=>Le(!1),"aria-hidden":"true"}),a.default.createElement("div",{style:{position:"absolute",right:0,top:"100%",marginTop:"4px",minWidth:"140px",background:"#FFFFFF",border:"1px solid #E5E5E5",borderRadius:"8px",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",zIndex:9999,overflow:"hidden"}},a.default.createElement("button",{type:"button",onClick:dt,style:{width:"100%",padding:"10px 14px",textAlign:"left",background:"none",border:"none",cursor:"pointer",fontSize:"13px",fontFamily:yt,color:"#e53935",fontWeight:500,display:"flex",alignItems:"center",gap:"8px"}},a.default.createElement("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2"},a.default.createElement("path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"}),a.default.createElement("polyline",{points:"16 17 21 12 16 7"}),a.default.createElement("line",{x1:"21",y1:"12",x2:"9",y2:"12"})),"Logout")))))),a.default.createElement("div",{style:{padding:K?"12px":"16px 24px",flex:1,overflow:"hidden",display:"flex",flexDirection:"column"}},a.default.createElement("div",{style:{marginBottom:K?"10px":"14px"}},a.default.createElement("h1",{style:{fontSize:K?"18px":"22px",fontWeight:700,color:"#1a1a1a",margin:"0 0 2px 0"}},"Tele Consultation"),a.default.createElement("p",{style:{fontSize:K?"11px":"12px",color:"#999",margin:0}},"Displaying All Tele Consultation Appointments")),a.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"}},a.default.createElement("div",{style:{display:"flex",gap:"6px",flexWrap:"wrap",width:K?"100%":"auto"}},a.default.createElement("button",{onClick:()=>O("upcoming"),style:{background:"upcoming"===Y?"#4C4DDC":"#FFFFFF",padding:K?"8px 10px":"9px 16px",border:"upcoming"===Y?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:K?"10px":"13px",color:"upcoming"===Y?"white":"#555555",fontWeight:600,fontFamily:yt,cursor:"pointer",flex:K?"1 1 auto":"none",minWidth:K?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Upcoming Appointments"),a.default.createElement("button",{onClick:()=>O("completed"),style:{background:"completed"===Y?"#4C4DDC":"#FFFFFF",padding:K?"8px 10px":"9px 16px",border:"completed"===Y?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:K?"10px":"13px",color:"completed"===Y?"white":"#555555",fontWeight:600,fontFamily:yt,cursor:"pointer",flex:K?"1 1 auto":"none",minWidth:K?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Completed Appointments"),a.default.createElement("button",{onClick:()=>O("cancelled"),style:{background:"cancelled"===Y?"#4C4DDC":"#FFFFFF",padding:K?"8px 10px":"9px 16px",border:"cancelled"===Y?"none":"1px solid #E5E5E5",borderRadius:"6px",fontSize:K?"10px":"13px",color:"cancelled"===Y?"white":"#555555",fontWeight:600,fontFamily:yt,cursor:"pointer",flex:K?"1 1 auto":"none",minWidth:K?"0":"auto",transition:"all 0.3s ease",whiteSpace:"nowrap"}},"Cancelled Appointments")),a.default.createElement("div",{style:{display:"flex",gap:"8px",alignItems:"center",width:"auto",position:"relative",justifyContent:K?"flex-start":"flex-end"}},a.default.createElement("button",{onClick:()=>{oe||(Qe($e),et(Ge),ne(Z)),ae(!oe)},style:{padding:"8px 12px",fontFamily:yt,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"}},a.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"},a.default.createElement("rect",{x:"3",y:"4",width:"18",height:"18",rx:"2",ry:"2"}),a.default.createElement("line",{x1:"16",y1:"2",x2:"16",y2:"6"}),a.default.createElement("line",{x1:"8",y1:"2",x2:"8",y2:"6"}),a.default.createElement("line",{x1:"3",y1:"10",x2:"21",y2:"10"})),a.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($e," to ").concat(Ge)}})()),a.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"},a.default.createElement("polyline",{points:"6 9 12 15 18 9"}))),oe&&a.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"}},a.default.createElement("div",{style:{marginBottom:"custom"===te?"12px":"0"}},["thisMonth","today","tomorrow","currentWeek","currentYear","custom"].map(e=>a.default.createElement("button",{key:e,onClick:()=>{if(ne(e),"custom"!==e){const t=(e=>{const t=new Date;let n,o;switch(e){case"today":default:n=o=P();break;case"tomorrow":const e=new Date(t);e.setDate(e.getDate()+1),n=o=e.toISOString().split("T")[0];break;case"currentWeek":const a=new Date(t),l=new Date(t),i=t.getDay(),r=0===i?-6:1-i;a.setDate(t.getDate()+r),l.setDate(a.getDate()+6),n=a.toISOString().split("T")[0],o=l.toISOString().split("T")[0];break;case"thisMonth":const d=new Date(t.getFullYear(),t.getMonth(),1),s=new Date(t.getFullYear(),t.getMonth()+1,0);n=d.toISOString().split("T")[0],o=s.toISOString().split("T")[0];break;case"currentYear":n="".concat(t.getFullYear(),"-01-01"),o="".concat(t.getFullYear(),"-12-31")}return{from:n,to:o}})(e);ee(e),qe(t.from),Je(t.to),Qe(t.from),et(t.to),ae(!1)}else Qe(""),et("")},style:{width:"100%",padding:"10px 12px",background:te===e?"#E8EEF4":"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:yt,cursor:"pointer",textAlign:"left",fontWeight:te===e?600:400,color:te===e?"#4C4DDC":"#1a1a1a",marginBottom:"4px",display:"flex",justifyContent:"space-between",alignItems:"center",transition:"all 0.2s ease"},onMouseEnter:t=>{te!==e&&(t.target.style.background="#F5F5F5")},onMouseLeave:t=>{te!==e&&(t.target.style.background="#FFFFFF")}},a.default.createElement("span",null,{thisMonth:"This Month",today:"Today",tomorrow:"Tomorrow",currentWeek:"Current Week",currentYear:"Current Year",custom:"Custom"}[e]),te===e&&a.default.createElement("span",{style:{color:"#4C4DDC",fontSize:"16px"}},"✓")))),"custom"===te&&a.default.createElement("div",{style:{paddingTop:"8px",borderTop:"1px solid #E5E5E5"}},a.default.createElement("div",{style:{marginBottom:"8px"}},a.default.createElement("input",{type:"date",value:Ke,onChange:e=>Qe(e.target.value),placeholder:"Start Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:yt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{marginBottom:"12px"}},a.default.createElement("input",{type:"date",value:Ze,onChange:e=>et(e.target.value),placeholder:"End Date",style:{width:"100%",padding:"10px 8px",border:"1px solid #E5E5E5",borderRadius:"4px",fontSize:"13px",fontFamily:yt,boxSizing:"border-box",cursor:"pointer"}})),a.default.createElement("div",{style:{display:"flex",gap:"8px"}},a.default.createElement("button",{onClick:()=>{ne(Z),Qe($e),et(Ge),ae(!1)},style:{flex:1,padding:"10px 12px",background:"#FFFFFF",color:"#4C4DDC",border:"1px solid #4C4DDC",borderRadius:"4px",fontSize:"13px",fontFamily:yt,fontWeight:600,cursor:"pointer"}},"Cancel"),a.default.createElement("button",{onClick:()=>{Ke&&Ze&&(ee("custom"),qe(Ke),Je(Ze),ae(!1))},style:{flex:1,padding:"10px 12px",background:"#4C4DDC",color:"#FFFFFF",border:"none",borderRadius:"4px",fontSize:"13px",fontFamily:yt,fontWeight:600,cursor:"pointer"}},"Submit")))))),a.default.createElement("div",{style:{display:"flex",flexDirection:K?"column":"row",gap:K?"12px":"14px",flex:1,minHeight:0,overflow:K?"auto":"hidden"}},a.default.createElement("div",{style:{flex:K?"none":"1 1 65%",width:K?"100%":"auto",display:"flex",flexDirection:"column",minHeight:K?"400px":"auto"}},a.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%"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:K?"12px 14px":"14px 18px",borderBottom:"1px solid #F1F1F1"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:K?"6px":"8px"}},a.default.createElement("span",{style:{fontSize:K?"14px":"15px",fontWeight:700,color:"#1a1a1a"}},"Appointments"),a.default.createElement("span",{style:{background:"#4C4DDC",color:"#fff",fontSize:K?"10px":"11px",fontWeight:600,padding:K?"2px 7px":"3px 8px",borderRadius:"12px"}},Xe))),a.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"}},a.default.createElement("div",null,"Patients name"),!K&&a.default.createElement("div",null,"Patient ID"),a.default.createElement("div",{onClick:lt,style:{display:"flex",alignItems:"center",gap:"3px",cursor:"pointer",userSelect:"none"}},"Date",a.default.createElement("span",{style:{opacity:.7,fontSize:"10px"}},"asc"===le?"▲":"▼")),!K&&a.default.createElement("div",null,"Slot"),!K&&a.default.createElement("div",null,"Doctor")),a.default.createElement("div",{style:{overflow:"auto",flex:1}},T?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.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"}}),"Getting token...")):$?a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",padding:"40px",color:"#888"}},a.default.createElement("div",{style:{textAlign:"center"}},a.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...")):G?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#FF0000"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"⚠️ Error"),a.default.createElement("div",{style:{fontSize:"13px"}},G),a.default.createElement("button",{onClick:it,style:{marginTop:"16px",padding:"8px 16px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"6px",cursor:"pointer",fontFamily:yt}},"Retry")):0===Ue.length?a.default.createElement("div",{style:{padding:"40px",textAlign:"center",color:"#888"}},a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},re?'No appointments found for "'.concat(re,'"'):"No appointments found"),re&&a.default.createElement("button",{onClick:()=>de(""),style:{marginTop:"12px",padding:"6px 12px",background:"#4C4DDC",color:"white",border:"none",borderRadius:"4px",cursor:"pointer",fontSize:"12px",fontFamily:yt}},"Clear Search")):Ue.map(e=>a.default.createElement("div",{key:tt(e),role:"button",tabIndex:0,onClick:()=>rt(e),onKeyDown:t=>"Enter"===t.key&&rt(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:tt(V)===tt(e)?"#E8EEF4":"#FFFFFF",borderTop:"1px solid #F1F1F1",alignItems:"center",cursor:"pointer",fontSize:K?"11px":"13px"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:K?"8px":"10px"}},nt(e)?a.default.createElement("img",{src:e.image,alt:"",style:{width:K?"32px":"36px",height:K?"32px":"36px",borderRadius:"50%",objectFit:"cover"}}):a.default.createElement("div",{style:{width:K?"32px":"36px",height:K?"32px":"36px",borderRadius:"50%",background:at(e.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:600,fontSize:K?"14px":"16px"}},ot(e.patientName)),a.default.createElement("div",null,a.default.createElement("div",{style:{fontWeight:600,color:"#1a1a1a",fontSize:K?"11px":"13px"}},e.patientName),a.default.createElement("div",{style:{fontSize:K?"9px":"11px",color:"#888"}},e.email))),!K&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.patientId),a.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?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",null,t.slice(0,n.index).trim()),a.default.createElement("div",{style:{fontSize:K?"9px":"11px",color:"#888"}},n[1].trim())):a.default.createElement("div",null,t)})()),!K&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.appointmentTime||"-"),!K&&a.default.createElement("div",{style:{color:"#555",fontSize:"12px"}},e.doctorName||e.doctor||"-")))),!$&&!G&&Ue.length>0&&a.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"}},a.default.createElement("div",{style:{fontSize:K?"11px":"12px",color:"#666"}},"Showing page ",He," of ",Ve," (",Xe," total)"),a.default.createElement("div",{style:{display:"flex",gap:"6px",alignItems:"center"}},a.default.createElement("button",{onClick:()=>Pe(e=>Math.max(1,e-1)),disabled:1===He,style:{padding:K?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:1===He?"#F5F5F5":"#FFFFFF",color:1===He?"#999":"#1a1a1a",fontSize:K?"11px":"12px",fontFamily:yt,fontWeight:600,cursor:1===He?"not-allowed":"pointer",opacity:1===He?.5:1}},"Previous"),a.default.createElement("div",{style:{display:"flex",gap:"4px"}},[...Array(Math.min(5,Ve))].map((e,t)=>{let n;return n=Ve<=5||He<=3?t+1:He>=Ve-2?Ve-4+t:He-2+t,a.default.createElement("button",{key:n,onClick:()=>Pe(n),style:{padding:K?"6px 10px":"6px 12px",border:He===n?"none":"1px solid #E5E5E5",borderRadius:"4px",background:He===n?"#4C4DDC":"#FFFFFF",color:He===n?"#FFFFFF":"#1a1a1a",fontSize:K?"11px":"12px",fontFamily:yt,fontWeight:600,cursor:"pointer",minWidth:K?"32px":"36px"}},n)})),a.default.createElement("button",{onClick:()=>Pe(e=>Math.min(Ve,e+1)),disabled:He===Ve,style:{padding:K?"6px 10px":"6px 12px",border:"1px solid #E5E5E5",borderRadius:"4px",background:He===Ve?"#F5F5F5":"#FFFFFF",color:He===Ve?"#999":"#1a1a1a",fontSize:K?"11px":"12px",fontFamily:yt,fontWeight:600,cursor:He===Ve?"not-allowed":"pointer",opacity:He===Ve?.5:1}},"Next"))))),a.default.createElement("div",{style:{flex:K?"none":"1 1 35%",width:K?"100%":"auto",display:V||!K?"flex":"none",flexDirection:"column",minHeight:"auto"}},a.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%"}},V?a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:K?"12px 14px":"16px 18px",background:"#E8EEF4",borderBottom:"1px solid #E5E5E5"}},a.default.createElement("div",null,a.default.createElement("div",{style:{color:"#002668",fontSize:K?"14px":"16px",fontWeight:"700"}},V.patientName||"N/A"),a.default.createElement("div",{style:{color:"#002668",fontSize:K?"11px":"13px"}},V.patientId||V.mrn||"N/A")),a.default.createElement("div",null,nt(V)?a.default.createElement("img",{style:{width:K?"36px":"44px",height:K?"36px":"44px",borderRadius:"50%",objectFit:"cover"},src:V.image,alt:V.patientName}):a.default.createElement("div",{style:{width:K?"36px":"44px",height:K?"36px":"44px",borderRadius:"50%",background:at(V.patientName),display:"flex",alignItems:"center",justifyContent:"center",color:"#FFFFFF",fontWeight:700,fontSize:K?"16px":"20px"}},ot(V.patientName)))),a.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"}},a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Speciality"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.specialisation)||(null==V?void 0:V.speciality)||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Type"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.type)||(null==V?void 0:V.appointmentType)||"Online"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Date"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.date)||(null==V?void 0:V.appointmentDate)||"N/A")),a.default.createElement("div",{style:{textAlign:"right"}},a.default.createElement("div",{style:{fontSize:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Appointment Time"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.time)||(null==V?void 0:V.appointmentTime)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Doctor"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.doctor)||(null==V?void 0:V.doctorName)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Hospital"),a.default.createElement("div",{style:{fontWeight:"700",fontSize:K?"12px":"13px"}},(null==V?void 0:V.hospital)||(null==V?void 0:V.hospitalName)||"N/A"))),a.default.createElement("div",{style:{display:"flex",justifyContent:"space-between"}},a.default.createElement("div",{style:{textAlign:"left"}},a.default.createElement("div",{style:{fontSize:K?"10px":"11px",color:"#888",marginBottom:"3px"}},"Reason for Appointment"),a.default.createElement("div",{style:{fontWeight:"600",fontSize:K?"11px":"12px",lineHeight:"1.4"}},(null==V?void 0:V.reason)||(null==V?void 0:V.reasonForAppointment)||"No reason provided"))),a.default.createElement("div",{style:{display:"flex",flexDirection:K?"column":"row",gap:"6px",marginTop:"10px"}},a.default.createElement("button",{type:"button",onClick:st,disabled:Ee,style:{flex:1,background:Ee?"#99e4e8":"#1CC3CE",color:"#FFFFFF",border:"1px solid #1CC3CE",borderRadius:"6px",padding:K?"10px 8px":"8px 6px",fontFamily:yt,fontWeight:600,fontSize:K?"11px":"12px",cursor:Ee?"not-allowed":"pointer"}},Ee?"Connecting...":"Join Call >")),be&&a.default.createElement("div",{style:{fontSize:"11px",color:"#e53935",marginTop:"6px",textAlign:"center",width:"100%"}},"⚠️ ",be))):a.default.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",height:"100%",padding:"40px",color:"#888",textAlign:"center"}},a.default.createElement("div",null,a.default.createElement("div",{style:{fontSize:"16px",marginBottom:"8px"}},"📋"),a.default.createElement("div",{style:{fontSize:"13px"}},"Select an appointment to view details"))))))),se&&a.default.createElement("div",{style:{position:"fixed",left:fe?"0":K?"10px":"".concat(we.x,"px"),top:fe?"0":K?"70px":"".concat(we.y,"px"),right:fe?"0":K?"10px":"auto",bottom:fe?"0":"auto",width:fe?"100vw":K?"calc(100vw - 20px)":ce?"350px":"".concat(ke.width,"px"),height:fe?"100vh":ce?"auto":K?"300px":"".concat(ke.height,"px"),background:"#FFFFFF",borderRadius:fe?"0":"8px",boxShadow:"0 8px 24px rgba(0, 0, 0, 0.3)",zIndex:1e4,overflow:"hidden",display:"flex",flexDirection:"column",transition:Ie||Te?"none":"all 0.3s ease"}},a.default.createElement("div",{onMouseDown:K||fe?void 0:ft,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&&!fe&&(Ie?"grabbing":"grab"),userSelect:"none"}},a.default.createElement("div",{style:{display:"flex",alignItems:"center",gap:K?"6px":"8px",flex:1,minWidth:0}},a.default.createElement("div",{style:{width:K?"6px":"8px",height:K?"6px":"8px",borderRadius:"50%",background:"#FF4444",animation:"pulse 2s infinite",flexShrink:0}}),a.default.createElement("span",{style:{fontSize:K?"11px":"13px",fontWeight:600,fontFamily:yt,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}},"Video Call - ",(null==V?void 0:V.patientName)||"Patient")),a.default.createElement("div",{style:{display:"flex",gap:K?"4px":"6px",alignItems:"center",flexShrink:0}},!fe&&a.default.createElement("button",{onClick:ct,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:ce?"Restore":"Minimize"},ce?a.default.createElement("svg",{width:K?"14":"16",height:K?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("rect",{x:"3",y:"3",width:"10",height:"10",stroke:"white",strokeWidth:"1.8",fill:"none"})):a.default.createElement("svg",{width:K?"14":"16",height:K?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("line",{x1:"3",y1:"8",x2:"13",y2:"8",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round"}))),a.default.createElement("button",{onClick:ut,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:fe?"Exit Fullscreen":"Fullscreen"},fe?a.default.createElement("svg",{width:K?"14":"16",height:K?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M10 3H13V6M6 13H3V10M13 10V13H10M3 6V3H6",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"})):a.default.createElement("svg",{width:K?"14":"16",height:K?"14":"16",viewBox:"0 0 16 16",fill:"none"},a.default.createElement("path",{d:"M3 6V3H6M13 10V13H10M10 3H13V6M6 13H3V10",stroke:"white",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round"}))),a.default.createElement("button",{onClick:pt,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"},"×"))),!ce&&a.default.createElement("div",{style:{flex:1,background:"#000000",position:"relative"}},a.default.createElement("iframe",{src:(()=>{if(!xe)return"";const e=String(B||"").replace(/\/?$/,"/");return console.log("${base}token=${callToken}","".concat(e,"token=").concat(xe)),"".concat(e,"token=").concat(xe)})(),style:{width:"100%",height:"100%",border:"none"},allow:"camera; microphone; display-capture; autoplay",allowFullScreen:!0,title:"Video Call"})),!K&&!fe&&!ce&&a.default.createElement(a.default.Fragment,null,a.default.createElement("div",{onMouseDown:e=>gt("left",e),style:{position:"absolute",left:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>gt("right",e),style:{position:"absolute",right:0,top:"50%",transform:"translateY(-50%)",width:"8px",height:"60px",cursor:"ew-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>gt("top",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",top:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),a.default.createElement("div",{onMouseDown:e=>gt("bottom",e),style:{position:"absolute",left:"50%",transform:"translateX(-50%)",bottom:0,width:"60px",height:"8px",cursor:"ns-resize",background:"transparent",zIndex:10001}}),a.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:Te&&"left"===Ae?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}}),a.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:Te&&"right"===Ae?1:0,transition:"opacity 0.2s ease",pointerEvents:"none",zIndex:10002}})),a.default.createElement("style",null,"\n @keyframes pulse {\n 0%, 100% { opacity: 1; }\n 50% { opacity: 0.5; }\n }\n "))),a.default.createElement(b,null,ht)};let w=null;const S={showWidget:(e,t)=>{w||(w=document.createElement("div"),document.body.appendChild(w));const n=()=>a.default.createElement(a.default.Fragment,null,a.default.createElement(F,{config:e}));l.default.render(a.default.createElement(n,null),w)},closePopup:()=>{w&&(l.default.unmountComponentAtNode(w),w=null)}};window.BookingSDK=S,e.AppointmentPage=F,e.default=S,Object.defineProperty(e,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pih-appointment-widget",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "main": "dist/App.js",
5
5
  "module": "dist/App.js",
6
6
  "exports": {
@@ -279,6 +279,9 @@ const AppointmentPage = ({ config = {}}) => {
279
279
  const [resizeEdge, setResizeEdge] = useState(null); // 'left', 'right', 'top', 'bottom'
280
280
  const [resizeStart, setResizeStart] = useState({ x: 0, y: 0, width: 0, height: 0 });
281
281
 
282
+ // Profile dropdown (logout)
283
+ const [showProfileDropdown, setShowProfileDropdown] = useState(false);
284
+
282
285
  // Pagination state (Frontend only)
283
286
  const [currentPage, setCurrentPage] = useState(1);
284
287
  const limit = 20;
@@ -412,6 +415,24 @@ const AppointmentPage = ({ config = {}}) => {
412
415
  setSelectedAppointment(appointment);
413
416
  };
414
417
 
418
+ // Logout: clear storage and redirect to login page
419
+ const handleLogout = () => {
420
+ try {
421
+ if (typeof localStorage !== "undefined") {
422
+ localStorage.removeItem(STORAGE_KEY_ID_TOKEN);
423
+ localStorage.removeItem(STORAGE_KEY_EMAIL);
424
+ localStorage.removeItem(STORAGE_KEY_APP_TOKEN);
425
+ localStorage.removeItem(STORAGE_KEY_DOCTOR_ID);
426
+ localStorage.removeItem(STORAGE_KEY_USER_NAME);
427
+ }
428
+ } catch (e) {}
429
+ setShowProfileDropdown(false);
430
+ const homeUrl = config.homeUrl || WEB_URL || "";
431
+ if (homeUrl && typeof window !== "undefined") {
432
+ window.location.href = homeUrl;
433
+ }
434
+ };
435
+
415
436
  // Handle join call — call initiate API to get LiveKit token+url, then open PiP
416
437
  const handleJoinCall = async () => {
417
438
  if (!selectedAppointment || !appToken) return;
@@ -642,10 +663,15 @@ const AppointmentPage = ({ config = {}}) => {
642
663
  if (cancelled) return;
643
664
  const token = extractAppToken(response);
644
665
  if (response.status === 400) {
645
- // Login API returned 400 — redirect to home page
666
+ // Login API returned 400 — show error message then redirect to home
667
+ const message = response.err+ " " + ' Redirecting to home...' || "Invalid user. Redirecting to home...";
668
+ setTokenError(message);
669
+ setTokenLoading(false);
646
670
  const homeUrl = config.homeUrl || WEB_URL || "";
647
671
  if (homeUrl && typeof window !== "undefined") {
648
- window.location.href = homeUrl;
672
+ setTimeout(() => {
673
+ window.location.href = homeUrl;
674
+ }, 3000);
649
675
  }
650
676
  return;
651
677
  }
@@ -942,23 +968,94 @@ const AppointmentPage = ({ config = {}}) => {
942
968
  </span>
943
969
  </div>
944
970
 
945
- {/* User Profile */}
946
- <div style={{ display: "flex", alignItems: "center", gap: "8px" }}>
947
- {!isMobile && (
948
- <span style={{ fontSize: "13px", color: "#555" }}>
949
- Hello, <strong style={{ color: "#1a1a1a" }}>{displayName}</strong>
950
- </span>
951
- )}
952
- <img
953
- src="https://w7.pngwing.com/pngs/340/946/png-transparent-avatar-user-computer-icons-software-developer-avatar-child-face-heroes-thumbnail.png"
954
- alt="User"
971
+ {/* User Profile with dropdown */}
972
+ <div style={{ position: "relative" }}>
973
+ <button
974
+ type="button"
975
+ onClick={() => setShowProfileDropdown((v) => !v)}
955
976
  style={{
956
- width: "32px",
957
- height: "32px",
958
- borderRadius: "50%",
959
- objectFit: "cover",
977
+ display: "flex",
978
+ alignItems: "center",
979
+ gap: "8px",
980
+ background: "none",
981
+ border: "none",
982
+ cursor: "pointer",
983
+ padding: "4px 0",
984
+ fontFamily,
960
985
  }}
961
- />
986
+ aria-expanded={showProfileDropdown}
987
+ aria-haspopup="true"
988
+ >
989
+ {!isMobile && (
990
+ <span style={{ fontSize: "13px", color: "#555" }}>
991
+ Hello, <strong style={{ color: "#1a1a1a" }}>{displayName}</strong>
992
+ </span>
993
+ )}
994
+ <img
995
+ src="https://w7.pngwing.com/pngs/340/946/png-transparent-avatar-user-computer-icons-software-developer-avatar-child-face-heroes-thumbnail.png"
996
+ alt="User"
997
+ style={{
998
+ width: "32px",
999
+ height: "32px",
1000
+ borderRadius: "50%",
1001
+ objectFit: "cover",
1002
+ }}
1003
+ />
1004
+ <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2" style={{ flexShrink: 0, opacity: showProfileDropdown ? 0.8 : 0.5 }}>
1005
+ <polyline points="6 9 12 15 18 9" />
1006
+ </svg>
1007
+ </button>
1008
+ {showProfileDropdown && (
1009
+ <>
1010
+ <div
1011
+ style={{ position: "fixed", inset: 0, zIndex: 9998 }}
1012
+ onClick={() => setShowProfileDropdown(false)}
1013
+ aria-hidden="true"
1014
+ />
1015
+ <div
1016
+ style={{
1017
+ position: "absolute",
1018
+ right: 0,
1019
+ top: "100%",
1020
+ marginTop: "4px",
1021
+ minWidth: "140px",
1022
+ background: "#FFFFFF",
1023
+ border: "1px solid #E5E5E5",
1024
+ borderRadius: "8px",
1025
+ boxShadow: "0 4px 16px rgba(0,0,0,0.12)",
1026
+ zIndex: 9999,
1027
+ overflow: "hidden",
1028
+ }}
1029
+ >
1030
+ <button
1031
+ type="button"
1032
+ onClick={handleLogout}
1033
+ style={{
1034
+ width: "100%",
1035
+ padding: "10px 14px",
1036
+ textAlign: "left",
1037
+ background: "none",
1038
+ border: "none",
1039
+ cursor: "pointer",
1040
+ fontSize: "13px",
1041
+ fontFamily,
1042
+ color: "#e53935",
1043
+ fontWeight: 500,
1044
+ display: "flex",
1045
+ alignItems: "center",
1046
+ gap: "8px",
1047
+ }}
1048
+ >
1049
+ <svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeWidth="2">
1050
+ <path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" />
1051
+ <polyline points="16 17 21 12 16 7" />
1052
+ <line x1="21" y1="12" x2="9" y2="12" />
1053
+ </svg>
1054
+ Logout
1055
+ </button>
1056
+ </div>
1057
+ </>
1058
+ )}
962
1059
  </div>
963
1060
  </div>
964
1061
  </div>