PageSourceSearch

https://care.soberpedia.ai/assets/SyncVisitsPage-B9A7Y73C.js

js soberpedia.ai collected 2026-10-05 15:08:28 UTC 44,652 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SyncVisitsRoute-DN0Auxkn.js","assets/react-vendor-CU6Sz31W.js","assets/index-DEXJEDAi.js","assets/firebase-w6DYUbFN.js","assets/payment-icons-Daq1K3F1.js","assets/index-ClGd-I0y.css","assets/PracticeVisitsView-DIWP01L6.js","assets/RoutePageHeader-9W0v4VlT.js","assets/RoutePageHeaderContent-FkxdZGox.js","assets/DataTableCard-BluwWKn_.js","assets/index-BSuGcRaZ.js","assets/table-CxPdvV_9.js","assets/arrow-up-D6DFVL4j.js","assets/arrow-down-BjUlbB4f.js","assets/pill-filter-CtZSNPVl.js","assets/date-picker-filter-Qp1kqu9t.js","assets/calendar-RV2oTCrW.js","assets/addWeeks-1hrFjz19.js","assets/clear-filters-button-DmPemFGr.js","assets/ExportCsvAction-BJr9eiP6.js","assets/modal-option-cards-Dksohkou.js","assets/patient-name-link-BAfQKbEs.js","assets/text-highlight-BFqqfcjs.js","assets/useOpenPatientProfile-CASNKG5E.js","assets/PracticeVideo--u4gdaPy.js","assets/PracticeFormDialog-RdnfXKaS.js","assets/use-unsaved-changes-B6nL5Xdd.js","assets/modal-form-CqN5DZuv.js","assets/clinicalApi--8E0qkZ_.js","assets/visitPresentation-CQKFg6I_.js","assets/AccessDenied-Ba4b0-Uz.js","assets/shield-alert-DjOj07_r.js","assets/usePracticeRoute-BanfQY79.js","assets/SyncVisitsProviderNetworkAdminView-B0GYCPkx.js","assets/RoutePageTitle-D_8Od-sv.js","assets/ExplicitAvailabilityManager-ChpJp2X-.js","assets/schedulingSelection-CZL0RDzD.js","assets/parseISO-DTktcOZT.js","assets/providerOperations-ELdKx_YD.js","assets/networkLicensurePolicy-Ct3PZM4V.js","assets/ReassignVisitDialog-BEbFAHvS.js","assets/VisitSchedulePicker-4J6xpsxo.js","assets/clientProviderAvailability-CFIfqNIp.js","assets/visitDisplay-XXmI5Egl.js","assets/user-round-c4EWOTq5.js","assets/calendarBounds-DQCPEB1J.js","assets/statusBadge-Dq6-fXVv.js","assets/ScrollPagination-ChbtpYdB.js","assets/context-menu-DwAG_bm5.js","assets/useTableSort-KpNOL2n3.js","assets/rawTableExport-DjSsUxyR.js","assets/VisitHistoryStatusBadge-CwrENSqG.js","assets/VisitTranscriptModal-JgOe5reP.js","assets/useClientsById-BI_N6qCU.js","assets/useClinicalRecordMessagingActions-DbPdmNJ5.js","assets/ellipsis-vertical-C-dQ6Kzj.js","assets/arrow-right-left-B4vnGqzD.js","assets/calendar-range-DRIxB27l.js","assets/index-D8wjYP7x.js","assets/chartPalette-CFmN-0p5.js","assets/square-D7DkS8S2.js","assets/square-check-big-BIK4lrHD.js","assets/visitIcons-CG7YiClb.js","assets/badge-check-DS4dztDB.js","assets/ChartStage-kk8qB2rS.js","assets/chartTheme-By-OHNNJ.js","assets/StatTile-DQJZPnfG.js","assets/formatters-C_0Kn-_3.js","assets/ProviderScheduleVisitModal-DArCs9CI.js","assets/PatientProfileBrandingContext-B4yn3g4G.js","assets/preferredProtocolEligibility-Wx-sDe0P.js","assets/useVisitChartingLauncher-B1f2Z2_Q.js","assets/SyncVisitsProviderNetworkAdminView-DIp9f4GB.css","assets/SyncVisitsProviderView-Lq5htp9K.js","assets/VisitNoShowAction-BKPozsIT.js","assets/useNetworkTimezone-DAycysvJ.js","assets/cells-Db2ZEFlu.js","assets/visitLastUpdated-BKQcd-p2.js","assets/tenantColorRamps-QDc1G_tU.js","assets/productApprovalOnly-GEXGR3EQ.js","assets/rescheduleVisitAccess-DtrPF0pi.js","assets/arrow-right-BC3JVmLt.js","assets/useProviderVisitLauncher-C95KBL53.js","assets/useNetworkLicensurePolicy-DGC2H23P.js","assets/visitActionApi-M5kT0GW2.js","assets/useProviderGoogleCalendar-Duj0Ag4G.js","assets/providerGoogleCalendarDismissal-DleKChI2.js","assets/patientMessagingScope-DaW-b0v9.js","assets/belugaExternalScheduling-Dg_RufXJ.js","assets/calendar-plus-BpNlzHvA.js","assets/ProviderWeeklyCalendar-Bb-_FQV4.css"])))=>i.map(i=>d[i]);
2import{al as vt,b as $e,aF as Se,fg as Ue,ek as Ce,el as Pe,c6 as Qt,c3 as Xt,ef as F,pE as Ae,fJ as te,di as Zt,eb as $,i as y,fE as se,cv as ve,u as We,h5 as es,C as O,hL as ts,S as ss,y as he,eo as as,aD as ns,pF as rs,g as is,pG as os,ep as ls,as as Q,fj as ds,dy as ft,ee as ge,ce as Je,ly as ht,d as Z,ah as Le,ax as cs,c_ as ms,c$ as us,d0 as xs,d2 as ps,d3 as fs,L as hs,U as gs,d5 as bs,l as ys,t as R,pH as Ns,pI as js,nE as ue,nG as ws,pJ as ks,df as Ss,fL as Cs,au as Ps,nS as vs,lA as Vs,dY as Is,dX as zs,c5 as He}from"./index-DEXJEDAi.js";import{j as e,r as m}from"./react-vendor-CU6Sz31W.js";import{C as Vt}from"./ClinicalDeferSummary-BqK7_nqF.js";import{R as Ts}from"./RoutePageHeader-9W0v4VlT.js";import{u as Rs}from"./usePatientNavCopy-Cuv_jdT5.js";import{q as xe,w as pe,e as fe,f as Oe,g as Ms,d as _s,c as As}from"./firebase-w6DYUbFN.js";import{P as Ls}from"./PatientBookingForm-CF9FKzmx.js";import{V as Os}
2from"./VisitNoShowAction-BKPozsIT.js";import{g as be}from"./visitDisplay-XXmI5Egl.js";import{a as Es}from"./statusBadge-Dq6-fXVv.js";import{u as Ds,l as gt,m as Bs}from"./patientVisitPresentation-C0Gdthkk.js";import{updateWaitingRoomPresence as qs,startOnDemandVisit as Fs}from"./visitActionApi-M5kT0GW2.js";import{u as $s,g as bt,l as Us}from"./clientWorkflowSettingsCache-Bq3pRC3F.js";import{u as Ws}from"./useWaitingRoomPresence-Cep1VRVZ.js";import{f as yt}from"./visitLastUpdated-BKQcd-p2.js";import{i as Be,c as It,o as zt}from"./belugaExternalScheduling-Dg_RufXJ.js";import{C as Js}from"./calendar-plus-BpNlzHvA.js";import"./payment-icons-Daq1K3F1.js";import"./RoutePageHeaderContent-FkxdZGox.js";import"./IdAndPhotoUploadSection-CVePkTk1.js";import"./ContactInfoSection-2PBmPpSi.js";import"./collapsible-JRJGT2Lx.js";import"./cloud-upload-DO_CTloa.js";import"./CameraCapture-C4ah5pn_.js";import"./monitor-CzX6E2vl.js";import"./circle-dashed-BpzaptvF.js";import"./user-round-c4EWOTq5.js";import"./use-unsaved-changes-B6nL5Xdd.js";import"./alert-WsBxL0qd.js";import"./providerAssignments-C7MWOvAk.js";import"./visitIcons-CG7YiClb.js";import"./badge-check-DS4dztDB.js";import"./CheckoutShell-DPiImp5d.js";import"./checkoutDisplay-6C7UrTTD.js";import"./useAuthorizeHostedToken-CiwlhvjR.js";import"./VisitSchedulePicker-4J6xpsxo.js";import"./addWeeks-1hrFjz19.js";import"./patientAddress-D6GhuKXS.js";import"./CustomPaymentInstructionsPanel-wIf9paY9.js";import"./EmbeddedWhopCheckout-exs5FPDQ.js";import"./networkLicensurePolicy-Ct3PZM4V.js";import"./modal-option-cards-Dksohkou.js";function Hs({visit:s,onClose:n}){var P,D;const{branding:i}=vt(),a=(i==null?void 0:i.accentColor)||$e;if(!s)return null;const d=Se(),c=(s.preferredMethod||"video")==="video",p=Ue(s),g=Ce(s,d),f=Pe(s,d),b=String(((P=s.apiNetwork)==null?void 0:P.bookingLocation)||"").trim(),k=/^https?:\/\//i.test(b)?b:"",S=s.meetingLink||((D=s.apiNetwork)==null?void 0:D.bookingMeetingLink)||k,C=s.patientPhone||"";return e.jsxs("div",{className:"space-y-4 min-[1025px]:space-y-6 max-lg:space-y-2.5","data-testid":"dialog-sync-visits-view-visit",children:[e.jsx(Os,{visit:s,onSuccess:n}),e.jsx(Vt,{visit:s}),e.jsx(Qt,{className:"border-subtle bg-surface-raised p-4 min-[1025px]:p-6 max-lg:p-3",children:e.jsxs("div",{className:"space-y-6 max-lg:space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-content-tertiary mb-2 max-lg:mb-1 max-lg:text-xs",children:"Visit Type"}),e.jsx("p",{className:"text-base font-semibold text-content-primary max-lg:text-sm",children:be(s,"Visit")})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4 max-lg:gap-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-content-tertiary mb-2 flex items-center gap-2 max-lg:mb-1 max-lg:gap-1.5 max-lg:text-xs",children:[e.jsx(Xt,{className:"size-4 max-lg:size-3.5"}),p?"Scheduled date":"Requested date"]}),e.jsx("p",{className:"text-base font-semibold text-content-primary max-lg:text-sm",children:g?(()=>{const[U,W,ae]=g.split("-").map(Number),B=new Date(U,W-1,ae),J=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],ne=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return`${J[B.getDay()]}, ${ne[B.getMonth()]} ${B.getDate()}`})():"N/A"})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-content-tertiary mb-2 flex items-center gap-2 max-lg:mb-1 max-lg:gap-1.5 max-lg:text-xs",children:[e.jsx(F,{className:"size-4 max-lg:size-3.5"}),p?"Scheduled time":"Requested time"]}),e.jsx("p",{className:"text-base font-semibold text-content-primary max-lg:text-sm",children:f?Ae(f):"N/A"})]})]}),c?e.jsxs("div",{className:"space-y-3 max-lg:space-y-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-content-tertiary mb-2 flex items-center gap-2 max-lg:mb-1 max-lg:gap-1.5 max-lg:text-xs",children:[e.jsx(te,{className:"size-4 max-lg:size-3.5"}),"Meeting Method"]}),e.jsx("p",{className:"text-base font-semibold text-content-primary capitalize max-lg:text-sm",children:"Video Call"})]}),p&&S&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-content-tertiary mb-2 max-lg:mb-1 max-lg:text-xs",children:"Meeting Link"}),e.jsxs("a",{href:S,target:"_blank",rel:"noopener noreferrer",className:"inline-flex break-all items-center gap-2 underline font-medium max-lg:gap-1.5 max-lg:text-xs",style:{color:a},children:[S,e.jsx(Zt,{className:"size-4 max-lg:size-3.5"})]})]}),p?e.jsx("div",{className:"rounded-lg border p-4 max-lg:p-2.5",style:{borderColor:`${a}40`,backgroundColor:`${a}10`},children:e.jsxs("p",{className:"text-sm max-lg:text-xs max-lg:leading-snug",style:{color:a},children:[e.jsx(F,{className:"inline size-4 mr-2 max-lg:mr-1.5 max-lg:size-3.5"}),e.jsx("strong",{children:"Important:"})," Please join the meeting 5 minutes before the scheduled time (",f?Ae(f):"N/A",") to ensure everything is set up correctly."]})}):e.jsx("div",{className:"rounded-lg border p-4 max-lg:p-2.5",style:{borderColor:`${a}40`,backgroundColor:`${a}10`},children:e.jsxs("p",{className:"text-sm max-lg:text-xs max-lg:leading-snug",style:{color:a},children:[e.jsx(F,{className:"inline size-4 mr-2 max-lg:mr-1.5 max-lg:size-3.5"}),"This visit has not been booked yet. A meeting link will appear after the visit is scheduled."]})})]}):e.jsxs("div",{className:"space-y-3 max-lg:space-y-2",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"text-sm font-medium text-content-tertiary mb-2 flex items-center gap-2 max-lg:mb-1 max-lg:gap-1.5 max-lg:text-xs",children:[e.jsx($,{className:"size-4 max-lg:size-3.5"}),"Meeting Method"]}),e.jsx("p",{className:"text-base font-semibold text-content-primary capitalize max-lg:text-sm",children:"Phone Call"})]}),e.jsx("div",{className:"rounded-lg border p-4 max-lg:p-2.5",style:{borderColor:`${a}40`,backgroundColor:`${a}10`},children:p?e.jsxs("p",{className:"text-sm max-lg:text-xs max-lg:leading-snug",style:{color:a},children:[e.jsx($,{className:"inline size-4 mr-2 max-lg:mr-1.5 max-lg:size-3.5"}),"You will receive a call from your provider at the scheduled time (",f?Ae(f):"N/A",") on"," ",e.jsx("strong",{children:C||"your account phone number"}),"."]}):e.jsxs("p",{className:"text-sm max-lg:text-xs max-lg:leading-snug",style:{color:a},children:[e.jsx($,{className:"inline size-4 mr-2 max-lg:mr-1.5 max-lg:size-3.5"}),"This visit has not been booked yet. The phone call details will be finalized after scheduling."]})})]}),s.duration&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-content-tertiary mb-2 max-lg:mb-1 max-lg:text-xs",children:"Duration"}),e.jsxs("p",{className:"text-base font-semibold text-content-primary max-lg:text-sm",children:[s.duration," minutes"]})]}),s.notes&&e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-content-tertiary mb-2 max-lg:mb-1 max-lg:text-xs",children:"Patient Note"}),e.jsx("p",{className:"text-sm text-slate-700 dark:text-slate-300 max-lg:text-xs max-lg:leading-snug",children:s.notes})]})]})}),e.jsx("div",{className:"flex justify-end pt-2 max-lg:pt-1.5",children:e.jsx(y,{variant:"outline",onClick:n,className:"h-9 rounded-full px-4 dark:border-slate-600 dar
2k:text-slate-100 dark:hover:bg-slate-700 max-lg:h-8 max-lg:px-3","data-testid":"button-sync-visits-close-view-visit",children:"Close"})})]})}const Ys=600*1e3;function Ye(s){return String(s||"").trim().toLowerCase()}function ee(s){return Ye(s==null?void 0:s.status)==="in progress"}function Ks(s){return String((s==null?void 0:s.preferredMethod)||"").toLowerCase()==="video"}function Tt(s,n=new Date){if(!s)return!1;const i=Ye(s.status);if(i!=="confirmed"&&i!=="in progress"&&!se(s)||!Ks(s))return!1;if(i==="in progress")return!0;const a=ve(s);if(!a)return!1;const d=n instanceof Date?n:new Date(n);if(Number.isNaN(d.getTime()))return!1;const c=a.getTime()-Ys;return d.getTime()>=c}function Nt(s,n=new Date){if(!s)return!1;const i=Ye(s.status);if(i==="in progress")return!0;if(i!=="confirmed"&&!se(s))return!1;const a=n instanceof Date?n:new Date(n);if(Number.isNaN(a.getTime()))return!1;const d=ve(s);return d&&d>a?!0:Tt(s,n)}const q={enabled:!1,callMode:"video"},qe="gen-health.on-demand-visits-policy.v1";function Ee(s){var n;return{enabled:(s==null?void 0:s.onDemandVisitsActive)===!0,callMode:((n=s==null?void 0:s.onDemandVisits)==null?void 0:n.callMode)==="phone"?"phone":"video"}}function Gs(s,n){return s.enabled===n.enabled&&s.callMode===n.callMode}function jt(s){var n;try{const i=JSON.parse(window.sessionStorage.getItem(qe)||"null");return(i==null?void 0:i.identity)!==s||typeof((n=i.policy)==null?void 0:n.enabled)!="boolean"?null:{enabled:i.policy.enabled,callMode:i.policy.callMode==="phone"?"phone":"video"}}catch{return null}}function wt(s,n){try{n==null?window.sessionStorage.removeItem(qe):window.sessionStorage.setItem(qe,JSON.stringify({identity:s,policy:n}))}catch{}}function Qs(s){const{userDoc:n}=We(),i=n==null?void 0:n.id,a=$s(),d=JSON.stringify(es()),l=JSON.stringify([s,i,d]),c=m.useRef(l),[p,g]=m.useState(()=>{if(!s)return{...q,resolving:!1};const f=bt(s,null,i);if(f!==void 0)return{...Ee(f),resolving:!1};const b=jt(l);return b?{...b,resolving:!1}:{...q,resolving:!0}});return m.useEffect(()=>{c.current=l;let f=!1;const b=C=>g(P=>!P.resolving&&Gs(P,C)?P:{...C,resolving:!1});if(!s)return b(q),()=>{f=!0};const k=bt(s,null,i),S=k!==void 0?Ee(k):jt(l);return S&&b(S),Us(s,null,i).then(C=>{if(f)return;const P=C==null?q:Ee(C);wt(l,C==null?null:P),b(P)}).catch(C=>{f||(console.error("Failed to resolve on-demand visit policy",C),wt(l,null),b(q))}),()=>{f=!0}},[s,i,a,d,l]),c.current===l?p:{...q,resolving:!0}}function Xs({visitId:s,patientPhone:n=null,accentColor:i=$e,onLeave:a}){const[d,l]=m.useState(0),[c,p]=m.useState(!1);Ws(s,{enabled:!!s}),m.useEffect(()=>{l(0);const k=setInterval(()=>{l(S=>S+1)},1e3);return()=>clearInterval(k)},[s]);async function g(){if(!c){p(!0);try{await qs({visitId:s,present:!1})}catch(k){console.debug("Could not signal waiting room exit",(k==null?void 0:k.message)||k)}finally{p(!1),a==null||a()}}}const f=Math.floor(d/60),b=d%60;return e.jsx(O,{className:"rounded-xl border border-subtle bg-surface-raised p-5 max-lg:p-3.5",children:e.jsxs("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"shrink-0 rounded-full p-2.5",style:{backgroundColor:`${i}15`},children:e.jsx(ts,{className:"size-4",style:{color:i},"aria-hidden":!0})}),e.jsxs("div",{className:"min-w-0",role:"status","aria-live":"polite",children:[e.jsx("h3",{className:"font-display text-base font-semibold text-content-primary",children:"You're in the queue"}),e.jsxs("p",{className:"mt-1 text-sm text-content-secondary",children:["The next available provider will call you",n?e.jsxs(e.Fragment,{children:[" at ",e.jsx("span",{className:"font-medium text-content-primary",children:n})]}):null,". Please keep your phone nearby."]}),e.jsxs("p",{className:"mt-1 text-xs font-medium tabular-nums text-content-tertiary",children:["Waiting ",f,":",String(b).padStart(2,"0")]})]})]}),e.jsxs(y,{type:"button",size:"sm",variant:"outline",className:"w-full rounded-full border-red-300 text-red-600 hover:bg-red-50 dark:border-red-800 dark:text-red-400 dark:hover:bg-red-900/30 sm:w-auto",disabled:c,onClick:g,children:[c?e.jsx(ss,{size:"md",className:"mr-1",label:"Leaving queue"}):e.jsx(he,{className:"mr-1 size-4"}),"Leave queue"]})]})})}function E(s){return String(s||"").trim().toLowerCase().replace(/[\s-]+/g,"_")}function Fe(s){const n=E(s);return n==="pending_review"||n==="under_review"||n==="in_review"||n==="pending review"}function ye(s){return E(s)==="pending_patient_scheduling"}function Zs(s){const n=E(s);return n==="cancelled"||n==="completed"||["no_show","patient_no_show","provider_no_show"].includes(n)}function ea(s){return s.isVisitPaymentRequired===!0||s.needsVisitIntake===!0||s.needsVisitLabs===!0}function De(s){return ee(s)||Zs(s.status)?!1:ye(s.status)||Fe(s.status)?!0:E(s.status)==="confirmed"?!ea(s):!1}function kt(s){const n=ve(s);if(n)return n;const i=(s==null?void 0:s.completedAt)||(s==null?void 0:s.updatedAt)||(s==null?void 0:s.createdAt);return i instanceof Date?i:i!=null&&i.toDate?i.toDate():typeof i=="number"?new Date(i):null}function ta(s){if(!s)return null;const[n,i,a]=s.split("-").map(Number);return new Date(n,i-1,a)}function je(s){if(!s)return"";const n=ta(s);if(!n||isNaN(n.getTime()))return"";
2const i=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];return`${i[n.getDay()]}, ${a[n.getMonth()]} ${n.getDate()}`}function we(s){if(!s)return"";const[n,i]=s.split(":"),a=parseInt(n,10),d=a>=12?"PM":"AM";return`${a>12?a-12:a===0?12:a}:${i} ${d}`}function sa(s){const n=Se(),i=Ce(s,n),a=Pe(s,n),d=Ue(s);if(i&&a)return{prefix:d?"Scheduled for":"Requested for",dateLabel:je(i),timeLabel:we(a)};const l=s==null?void 0:s.createdAt;if(l){const c=new Date(l);if(!Number.isNaN(c.getTime())){const p=b=>String(b).padStart(2,"0"),g=`${c.getFullYear()}-${p(c.getMonth()+1)}-${p(c.getDate())}`,f=`${p(c.getHours())}:${p(c.getMinutes())}`;return{prefix:"Requested on",dateLabel:je(g),timeLabel:we(f)}}}return null}function St(s,n){const i=n?sa(s):null;if(i)return e.jsxs("p",{className:"text-sm text-content-secondary mt-1",children:[e.jsx(F,{className:"size-3 inline mr-1"}),i.prefix," ",i.dateLabel," at ",i.timeLabel]});const a=Se(),d=Ce(s,a),l=Pe(s,a),c=Ue(s);return!d||!l?null:e.jsxs("p",{className:"text-sm text-content-secondary mt-1",children:[e.jsx(F,{className:"size-3 inline mr-1"}
2),c?"Scheduled for ":"Requested for ",je(d)," at ",we(l)]})}function Ct(s,n,i=!1,a="#2563eb",d=null){if(i)return e.jsxs(Je,{className:"bg-amber-50 text-amber-600 border border-amber-200 dark:bg-amber-900/30 dark:text-amber-400 dark:border-amber-800 text-xs w-fit",children:[e.jsx(F,{className:"size-3 mr-1"}),"Awaiting lab results"]});const l=Be(s),c=l?It(s):"Schedule Now",p=!!(d!=null&&d.enabled&&!l);return e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto sm:items-end",children:[p?e.jsxs(y,{type:"button",size:"sm",className:"w-full rounded-full text-white sm:w-auto",style:{backgroundColor:a},disabled:d.starting,onClick:g=>{g.preventDefault(),g.stopPropagation(),d.onConnectNow(s)},children:[d.starting?e.jsx(Z,{className:"mr-1 h-4 w-4 animate-spin"}):d.callMode==="phone"?e.jsx($,{className:"mr-1 h-4 w-4"}):e.jsx(te,{className:"mr-1 h-4 w-4"}),d.callMode==="phone"?"Request a call now":"Connect now"]}):null,e.jsxs(y,{type:"button",size:"sm",variant:p?"outline":void 0,className:p?"w-full rounded-full dark:border-slate-600 dark:text-slate-100 dark:hover:bg-slate-700 sm:w-auto":"w-full rounded-full text-white sm:w-auto",style:p?void 0:{backgroundColor:a},onClick:g=>{if(g.preventDefault(),g.stopPropagation(),l){zt(s);return}n(s)},children:[e.jsx(ge,{className:"h-4 w-4 mr-1"}),p&&!l?"Book a time instead":c]})]})}function ke(s){return s?s.toMillis&&typeof s.toMillis=="function"?s.toMillis():s._seconds?s._seconds*1e3+(s._nanoseconds||0)/1e6:s.seconds?s.seconds*1e3:null:null}function aa(s){const n={id:s.id,...s.data()};return{...n,createdAt:ke(n.createdAt),updatedAt:ke(n.updatedAt)}}function na(s,n){var d;const i=new Map;s.forEach(l=>{var c;(c=l==null?void 0:l.docs)==null||c.forEach(p=>{i.set(p.id,aa(p))})});const a=((d=n==null?void 0:n.docs)==null?void 0:d.map(l=>{const c={id:l.id,...l.data()};return{...c,createdAt:ke(c.createdAt||c.purchaseDate),updatedAt:ke(c.updatedAt||c.createdAt||c.purchaseDate)}}))||[];return Bs(Array.from(i.values()),a).sort((l,c)=>{const p=l.createdAt||0;return(c.createdAt||0)-p})}function ra({status:s}){return e.jsx(Je,{className:`text-xs font-medium ${Es(s)}`,children:vs(s,"Pending Review")})}function ia(){var lt;const s=as(),[n,i]=ns(),{userDoc:a,clientData:d}=We(),{branding:l}=vt(),c=Rs("visits",{title:"My Visits",description:"Schedule and manage your healthcare visits"}),[p,g]=m.useState(!0),[f,b]=m.useState([]),[k,S]=m.useState(!1),[C,P]=m.useState(null),[D,U]=m.useState(""),[W,ae]=m.useState(!1),[B,J]=m.useState(()=>new Set),[ne,Ke]=m.useState(null),[Ge,Qe]=m.useState(null),[v,Ve]=m.useState(null),[Ie,Xe]=m.useState(null),Ze=m.useRef(new Map),{notifyFormsCompleted:Rt}=rs(),w=(l==null?void 0:l.accentColor)||$e,Mt=is("manageVisit"),M=(a==null?void 0:a.id)||"",H=(a==null?void 0:a.clientId)||"",et=os(a),_=ls(d==null?void 0:d.model),ze=Qs(H),tt=ze.resolving||!ze.enabled?null:{enabled:!0,callMode:ze.callMode,starting:!!ne,onConnectNow:Bt},{dialog:V,scheduleNotice:st,setScheduleNotice:_t,openBooking:At,openBookingAfterAvailabilityPreflight:Y,openPendingVisitBooking:at}=Ds({userDoc:a,source:"SyncVisitsPatientView"}),nt=m.useCallback(t=>{at(t)},[at]),Te=m.useCallback(t=>{const r=Ze.current;return r.has(t)||r.set(t,gt({orderId:t,patientId:M}).catch(o=>(console.error("Error prefetching visit intake forms:",o),r.delete(t),null))),r.get(t)},[M]);m.useEffect(()=>{!M||v||f.forEach(t=>{const r=String((t==null?void 0:t.paymentOrderId)||"").trim();(t==null?void 0:t.clientPrescriptionRequestIntake)===!0&&r&&Te(r)})},[f,M,v,Te]);const rt=m.useCallback((t,r)=>{b(na(t,r))},[]);m.useEffect(()=>{if(!(a!=null&&a.id)){b([]),g(!1);return}g(!0);let t=null,r=null,o=_?{docs:[]}:null;const u=()=>{if(!(!t||!r||!o))try{rt([t,r],o)}catch(j){console.error("Error loading visits:",j),b([])}finally{g(!1)}},x=j=>{console.error("Error watching visits:",j),b([]),g(!1);const T=j.code||j.message||"";T&&!T.includes("permission-denied")&&!T.includes("not-found")&&!T.includes("Missing or insufficient permissions")&&R.error("Unable to load visits. Please try again.")},N=xe(fe(Q,"Visits"),pe("userId","==",a.id)),h=xe(fe(Q,"Visits"),pe("patientId","==",a.id)),I=Oe(N,j=>{t=j,u()},x),z=Oe(h,j=>{r=j,u()},x),L=_?()=>{}:Oe(xe(fe(Q,"Orders"),pe("patientId","==",a.id)),j=>{o=j,u()},j=>{console.error("Error watching Visit presentation records:",j),o={docs:[]},u()});return()=>{I(),z(),L()}},[a==null?void 0:a.id,rt,_]),m.useEffect(()=>{if(_){J(new Set);return}const t=f.filter(o=>o.status==="Pending Patient Scheduling"&&(o.relatedOrderId||o.orderId));if(t.length===0){J(o=>o.size?new Set:o);return}let r=!1;return(async()=>{const o=new Set;await Promise.all(t.map(async u=>{const x=u.relatedOrderId||u.orderId;try{const N=await Ms(_s(Q,"Orders",x));N.exists()&&ds(N.data())&&o.add(u.id)}catch{}})),!r&&J(u=>u.size===o.size&&[...o].every(x=>u.has(x))?u:o)})(),()=>{r=!0}},[_,f]);const Re=m.useRef(!1),re=n.get("schedule"),A=n.get("orderId")||"";m.useEffect(()=>{re!=="1"&&(Re.current=!1)},[re]),m.useEffect(()=>{if(re!=="1"||!M||Re.current)return;Re.current=!0,i({},{replace:!0}),(async()=>{const r=H?await Ns({clientId:H}):null;if(r){await Y({forceSkipPayment:r.chargePatient===!1,durationMinutes:r.duration||30,unavailableMessage:ue,props:{pricingMode:"sync_visit",checkoutSource:js,hideVisitType
2Step:!0,initialPendingVisitId:r.pendingVisitId,formRequestId:r.formRequestId,formRequestClientProductId:r.clientProductId,formRequestProductId:r.productId,formRequestProviderNetworkId:r.providerNetworkId,forcedVisitLabel:r.visitLabel,forcedPrice:r.price,forcedVisitDuration:r.duration,required:!0}});return}const o=xe(fe(Q,"Visits"),pe("userId","==",M)),x=(await As(o)).docs.reduce((h,I)=>{const z=I.data()||{};if(z.status!=="Pending Patient Scheduling")return h;const L=String(z.visitSource||"").toLowerCase();return L!=="sync_visit"&&L!=="patient_requested_schedule"||h.push({id:I.id,...z}),h},[]),N=A?x.find(h=>h.id===A||h.id===`order_${A}`||h.relatedOrderId===A||h.orderId===A||h.visitChargeOrderId===A)||null:x[0]||null;if(N){const h=await ws({visit:N,userDoc:{clientId:H,freeVisits:a==null?void 0:a.freeVisits}});await Y({forceSkipPayment:h.forceSkipPayment,props:h.props,durationMinutes:h.durationMinutes,requestedProviderId:h.requestedProviderId,unavailableMessage:ue});return}if(A){R.error("This order has no visit waiting to be scheduled. Open the order to continue.");return}if(et){await Y({forceSkipPayment:!1,durationMinutes:30,unavailableMessage:ue,props:{pricingMode:"sync_visit",checkoutSource:"required_sync_visit",hideVisitTypeStep:!0}});return}await Y({forceSkipPayment:!1,durationMinutes:30,unavailableMessage:ue})})()},[Y,H,M,et,A,re,i,a==null?void 0:a.freeVisits]);const Lt=async()=>{if(C)try{ae(!0);const t=Ps.currentUser;if(!t){R.error("Not authenticated");return}const r=await t.getIdToken(),u=await(await fetch(Mt,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({action:"updateStatus",visitId:C.id,status:"Cancelled",cancellationReason:D||"No reason provided"})})).json();if(!u.success)throw new Error(u.error||"Unable to cancel visit. Please try again.");R.success("Visit cancelled successfully"),S(!1),P(null),U("")}catch(t){console.error("Error cancelling visit:",t),R.error("Unable to cancel visit. Please try again.")}finally{ae(!1)}},Me=m.useCallback(t=>{P(t),S(!0)},[]);async function Ot(t){const r=(a==null?void 0:a.phone)||"";V.openWith(e.jsx(Hs,{visit:{...t,patientPhone:r},onClose:()=>V.close()}),{title:"View Confirmed Visit",description:"Your visit details and instructions",headerIcon:e.jsx("div",{className:"rounded-2xl bg-blue-600 p-4 dark:bg-blue-500",children:e.jsx(Vs,{className:"size-5 text-white"})})})}function it(t){if(Be(t)){zt(t);return}V.openWith(e.jsx(Ls,{onClose:()=>V.close(),setDialogProps:V.setDialogProps,rescheduleVisit:t,onScheduled:()=>{V.close()}}),{title:"Reschedule Visit",description:"Choose a new appointment time to continue your care"})}function ie(t){return ve(t)}function Et(t){return Tt(t)}function Dt(t){s(`/visits/${t.id}`)}async function Bt(t){if(!ne){Ke(t.id);try{const r=await Fs({visitId:t.id});r.callMode==="phone"?(Qe(r.visitId),R.success("You are in the queue. A provider will call you shortly.")):s(`/visits/${r.visitId}`)}catch(r){console.error("Error starting on-demand visit:",r),R.error(r.message||"Unable to start your visit right now. Please try again.")}finally{Ke(null)}}}function qt(t){const r=String((t==null?void 0:t.paymentOrderId)||(t==null?void 0:t.visitChargeOrderId)||"").trim();r&&s(t.usesProductCheckoutPayment===!0?`/dashboard?payProductOrder=${encodeURIComponent(r)}`:`/orders?pay=${encodeURIComponent(r)}`)}async function Ft(t,r){var o,u;if(!Ie){Xe(t.id);try{let x=await Te(r);Ze.current.delete(r),(o=x==null?void 0:x.forms)!=null&&o.length||(x=await gt({orderId:r,patientId:M})),(u=x==null?void 0:x.forms)!=null&&u.length?Ve(x):R.error("We could not load your intake forms. Please try again.")}catch(x){console.error("Error loading visit intake forms:",x),R.error("We could not load your intake forms. Please try again.")}finally{Xe(null)}}}function $t(t){const r=String((t==null?void 0:t.paymentOrderId)||(t==null?void 0:t.visitChargeOrderId)||"").trim();if(!r){s("/forms");return}if(t.clientPrescriptionRequestIntake===!0){Ft(t,r);return}const o=String((t==null?void 0:t.orderPaymentStatus)||"").trim().toLowerCase()==="paid";s(o?`/dashboard?continueOrder=${encodeURIComponent(r)}`:`/dashboard?payProductOrder=${encodeURIComponent(r)}`)}function Ut(){s("/labs")}const oe=new Date,K=f.filter(t=>{if(ft(t)&&!se(t))return!0;
2if(_)return!1;const r=String(t.status||"").trim().toLowerCase().replace(/[\s-]+/g,"_");return["completed","cancelled","canceled","denied","voided","no_show","patient_no_show","provider_no_show","patient no-show","provider no-show"].includes(r)?!1:t.isVisitPaymentRequired===!0||t.needsVisitIntake===!0||t.needsVisitLabs===!0}),le=new Set(K.map(t=>t.id)),G=f.filter(t=>!le.has(t.id)).filter(t=>Nt(t,oe)).sort((t,r)=>{const o=ee(t)?1:0,u=ee(r)?1:0;if(o!==u)return u-o;const x=ie(t),N=ie(r),h=x?x.getTime():0,I=N?N.getTime():0;return h-I}),ot=f.filter(t=>le.has(t.id)?!1:Fe(t.status)),de=f.filter(t=>!le.has(t.id)&&ye(t.status)),ce=f.filter(t=>{if(le.has(t.id)||Nt(t,oe)||Fe(t.status)||ye(t.status))return!1;const r=E(t.status),o=ie(t);return o&&o<=oe&&(r==="completed"||r==="confirmed")?!0:!o&&r==="completed"}).sort((t,r)=>{const o=kt(t),u=kt(r),x=o?o.getTime():0;return(u?u.getTime():0)-x});function me(t,r=!1){const o=E(t.status)==="confirmed"||se(t),u=ee(t),x=ye(t.status),N=ft(t)&&!se(t),h=!N&&t.isVisitPaymentRequired===!0,I=!N&&t.needsVisitIntake===!0,z=!N&&t.needsVisitLabs===!0,L=h||I||z,j=t.checkoutSequence!=="payment_before_intake",T=I&&(!h||j),dt=T?"Pending Intake":h?"Pending Payment":z?"Pending Labs":t.status||"Pending Review",Jt=(t.preferredMethod||"video")==="video",Ht=t.providerId&&t.providerId!==""?t.providerName||"Provider TBD":"TBD",Yt=Et(t),ct=ie(t),Kt=N||o&&!u&&ct&&ct>oe,_e=yt(t),mt=r?O:"div";if(N){const ut=Se(),xt=je(Ce(t,ut)),pt=we(Pe(t,ut)),Gt=xt?`Was ${xt}${pt?`, ${pt}`:""}`:"";return e.jsx(mt,{className:`p-4 sm:px-5 ${r?"rounded-xl border border-subtle":""}`,children:e.jsxs("div",{role:"alert",className:"flex flex-col gap-3 rounded-xl border border-[var(--status-warning-border)] bg-[var(--status-warning-bg)] p-4 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx(ge,{className:"mt-0.5 size-5 shrink-0 text-[var(--status-warning-text)]","aria-hidden":"true"}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm font-medium text-content-primary",children:[be(t,"Visit")," needs a new time"]}),e.jsx("p",{className:"mt-0.5 text-xs text-content-secondary",children:[Gt,ks].filter(Boolean).join(" · ")})]})]}),e.jsx(y,{type:"button",size:"sm",className:"w-full shrink-0 rounded-full text-white sm:w-auto",style:{backgroundColor:w},onClick:()=>it(t),children:"Choose a new time"})]})},t.id)}return e.jsxs(mt,{className:`flex flex-col gap-3 px-4 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-5 ${r?"rounded-xl border border-slate-200 dark:border-slate-700 dark:bg-slate-800":""}`,children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"rounded-lg p-2.5",style:{backgroundColor:w},children:Jt?e.jsx(te,{className:"size-4 text-white"}):e.jsx($,{className:"size-4 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[e.jsx("h3",{className:"font-display text-base font-semibold text-content-primary",children:be(t,"Visit")}),e.jsx(ra,{status:dt})]}),e.jsxs("p",{className:"text-sm text-content-secondary",children:["Provider: ",Ht," • ",t.visitProductDuration||t.duration||30," min"]}),St(t,x),e.jsxs("p",{className:"mt-1 text-2xs text-content-tertiary",children:["Last updated ",_e.date,_e.time?`, ${_e.time}`:""]}),t.notes&&e.jsxs("p",{className:"mt-1 text-xs italic text-content-tertiary",children:["Note: ",t.notes]})]})]}),e.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:min-w-[150px] sm:items-end",children:[T?e.jsxs(y,{type:"button",size:"sm",className:"w-full rounded-full text-white sm:w-auto",style:{backgroundColor:w},onClick:()=>$t(t),disabled:Ie===t.id,children:[Ie===t.id?e.jsx(Z,{className:"mr-1 size-4 animate-spin"}):e.jsx(Le,{className:"mr-1 size-4"}),"Complete Intake"]}):null,!T&&h?e.jsxs(y,{type:"button",size:"sm",className:"w-full rounded-full text-white sm:w-auto",style:{backgroundColor:w},onClick:()=>qt(t),children:[e.jsx(Ss,{className:"mr-1 size-4"}),"Pay for Visit"]}):null,!T&&!h&&z?e.jsxs(y,{type:"button",size:"sm",className:"w-full rounded-full text-white sm:w-auto",style:{backgroundColor:w},onClick:Ut,children:[e.jsx(Cs,{className:"mr-1 size-4"}),"Order or Upload Labs"]}):null,!L&&Yt&&e.jsxs(y,{size:"sm",className:"w-full bg-green-600 text-white hover:bg-green-700 sm:w-auto",onClick:()=>Dt(t),children:[e.jsx(te,{className:"mr-1 size-4"}),u?"Rejoin Visit":"Join Visit"]}),e.jsx("div",{className:"w-full max-w-[260px] self-end",children:e.jsx(Vt,{visit:t})}),!L&&(o||u)&&e.jsxs("div",{className:"flex w-full flex-col gap-2 sm:w-auto 
2sm:items-end",children:[e.jsx(y,{size:"sm",variant:"outline",className:"w-full dark:border-slate-600 dark:text-slate-100 dark:hover:bg-slate-700 sm:w-auto",onClick:()=>Ot(t),children:"View Visit"}),Kt&&e.jsx(y,{size:"sm",variant:"outline",className:"w-full dark:border-slate-600 dark:text-slate-100 dark:hover:bg-slate-700 sm:w-auto",onClick:()=>it(t),children:Be(t)?It(t):"Reschedule"}),!u&&De(t)&&e.jsxs(y,{size:"sm",variant:"outline",className:"w-full border-red-300 text-red-600 hover:bg-red-50 dark:border-red-800 dark:text-red-400 dark:hover:bg-red-900/30 sm:w-auto",onClick:()=>Me(t),children:[e.jsx(he,{className:"mr-1 size-4"}),"Cancel"]})]}),!L&&x&&Ct(t,nt,B.has(t.id),w,tt),De(t)&&!u&&E(t.status)!=="confirmed"&&e.jsxs(y,{size:"sm",variant:"outline",className:"w-full border-red-300 text-red-600 hover:bg-red-50 dark:border-red-800 dark:text-red-400 dark:hover:bg-red-900/30 sm:w-auto",onClick:()=>Me(t),children:[e.jsx(he,{className:"mr-1 size-4"}),"Cancel"]})]})]},t.id)}function Wt(t){const o=(t.preferredMethod||"video")==="video",u=t.providerId&&t.providerId!==""?t.providerName||"Provider TBD":"TBD",x=yt(t);return e.jsxs("div",{className:"flex flex-col gap-3 px-4 py-4 sm:flex-row sm:items-center sm:justify-between sm:px-5",children:[e.jsxs("div",{className:"flex min-w-0 items-start gap-3",children:[e.jsx("div",{className:"rounded-lg p-2.5",style:{backgroundColor:w},children:o?e.jsx(te,{className:"size-4 text-white"}):e.jsx($,{className:"size-4 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-display text-base font-semibold text-content-primary",children:be(t,"Visit")}),e.jsxs("p",{className:"mt-0.5 text-sm text-content-secondary",children:["Provider: ",u," • ",t.visitProductDuration||t.duration||30," min"]}),St(t,!0),e.jsxs("p",{className:"mt-1 text-2xs text-content-tertiary",children:["Last updated ",x.date,x.time?`, ${x.time}`:""]}),t.notes&&e.jsxs("p",{className:"mt-1 text-xs italic text-content-tertiary",children:["Note: ",t.notes]})]})]}),e.jsxs("div",{className:"flex shrink-0 flex-col gap-2 sm:min-w-[150px] sm:items-end",children:[Ct(t,nt,B.has(t.id),w,tt),De(t)&&e.jsxs(y,{size:"sm",variant:"outline",className:"w-full border-red-300 text-red-600 hover:bg-red-50 dark:border-red-800 dark:text-red-400 dark:hover:bg-red-900/30 sm:w-auto",onClick:()=>Me(t),children:[e.jsx(he,{className:"mr-1 size-4"}),"Cancel"]})]})]},t.id)}return e.jsxs("main",{className:"app-page-shell space-y-6","data-testid":"page-sync-visits-patient","aria-label":"My visits",children:[e.jsx(Ts,{title:c.title,description:c.description,actions:_?null:e.jsxs(y,{className:"shrink-0 text-white",style:{backgroundColor:w},onClick:()=>At(!1),children:[e.jsx(Js,{className:"size-4 mr-2"}),"Book a Visit"]})}),Ge?e.jsx(Xs,{visitId:Ge,patientPhone:(a==null?void 0:a.phone)||(a==null?void 0:a.phoneNumber)||null,accentColor:w,onLeave:()=>Qe(null)}):null,st?e.jsx(O,{className:"rounded-xl border border-amber-200 bg-amber-50 p-4 dark:border-amber-800 dark:bg-amber-900/20",children:e.jsxs("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-amber-900 dark:text-amber-100",children:"Scheduling is not available yet"}),e.jsxs("p",{className:"mt-1 text-sm text-amber-800 dark:text-amber-200",children:[st.message," Use Schedule Now from the required visit when availability opens."]})]}),e.jsx(y,{type:"button",variant:"outline",size:"sm",className:"shrink-0 border-amber-300 text-amber-900 hover:bg-amber-100 dark:border-amber-700 dark:text-amber-100 dark:hover:bg-amber-900/30",onClick:()=>_t(null),children:"Dismiss"})]})}):null,K.length>0?e.jsxs(O,{className:"overflow-hidden rounded-xl border border-amber-200 dark:border-amber-800",children:[e.jsx("div",{className:"border-b border-amber-200 bg-amber-50 p-3 dark:border-amber-800 dark:bg-amber-900/20",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg p-1.5",style:{backgroundColor:w},children:e.jsx(ge,{className:"size-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-content-primary",children:"Needs your attention"}),e.jsx("p",{className:"text-xs text-content-secondary",children:"Complete the next step shown for each visit."})]})]}),e.jsxs(Je,{className:"border border-amber-200 bg-surface-raised text-amber-700 dark:border-amber-700 dark:bg-amber-950/40 dark:text-amber-200",children:[K.length," ",K.length===1?"visit":"visits"]})]})}
2),e.jsx("div",{className:"divide-y divide-amber-100 dark:divide-amber-900/50",children:K.map(t=>me(t))})]}):null,de.length>0&&e.jsxs(O,{className:"rounded-xl border border-blue-200 dark:border-blue-800 overflow-hidden",children:[e.jsx("div",{className:"bg-blue-50 dark:bg-blue-900/20 border-b border-blue-200 dark:border-blue-800 p-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg p-1.5",style:{backgroundColor:w},children:e.jsx(ge,{className:"size-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-content-primary",children:"Schedule Required"}),e.jsxs("p",{className:"text-xs text-content-tertiary",children:[de.length," ",de.length===1?"visit":"visits"," awaiting your scheduling"]})]})]})}),e.jsx("div",{className:"divide-y divide-blue-100 dark:divide-blue-900/50",children:de.map(t=>Wt(t))})]}),ot.length>0&&e.jsx("div",{className:"grid gap-3",children:ot.map(t=>me(t,!0))}),e.jsxs(O,{className:"rounded-xl border border-subtle dark:bg-slate-800 overflow-hidden",children:[e.jsx("div",{className:"bg-surface-sunken border-b border-subtle p-3",children:e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg p-1.5",style:{backgroundColor:w},children:e.jsx(ht,{className:"size-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-content-primary",children:G.some(t=>ee(t))?"Live & Upcoming Visits":"Upcoming Visits"}),e.jsxs("p",{className:"text-xs text-content-tertiary",children:[G.length," ",G.length===1?"visit":"visits"]})]})]})})}),p?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Z,{className:"size-8 animate-spin text-blue-600"})}):G.length===0?e.jsx("div",{className:"px-4 py-12",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"rounded-full bg-slate-100 p-3 dark:bg-slate-700",children:e.jsx(ht,{className:"size-6 text-slate-400 dark:text-slate-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-semibold text-content-primary",children:"No upcoming visits"}),e.jsx("p",{className:"mt-1 text-sm text-content-secondary",children:_?"Required visits will appear here.":"Book your first visit to get started"})]})]})}):e.jsx("div",{className:"divide-y divide-slate-200 dark:divide-slate-700",children:G.map(t=>me(t))})]}),e.jsxs(O,{className:"rounded-xl border border-subtle dark:bg-slate-800 overflow-hidden",children:[e.jsx("div",{className:"bg-surface-sunken border-b border-subtle p-3",children:e.jsx("div",{className:"flex items-center justify-between gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"rounded-lg p-1.5",style:{backgroundColor:w},children:e.jsx(Le,{className:"size-4 text-white"})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold text-content-primary",children:"Past Visits"}),e.jsxs("p",{className:"text-xs text-content-tertiary",children:[ce.length," ",ce.length===1?"visit":"visits"]})]})]})})}),p?e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(Z,{className:"size-8 animate-spin text-blue-600"})}):ce.length===0?e.jsx("div",{className:"px-4 py-12",children:e.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[e.jsx("div",{className:"rounded-full bg-slate-100 p-3 dark:bg-slate-700",children:e.jsx(Le,{className:"size-6 text-slate-400 dark:text-slate-500"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-display font-semibold text-content-primary",children:"No past visits"}),e.jsx("p",{className:"mt-1 text-sm text-content-secondary",children:"Your visit history will appear here"})]})]})}):e.jsx("div",{className:"divide-y divide-slate-200 dark:divide-slate-700",children:ce.map(t=>me(t))})]}),e.jsx(cs,{open:V.open,onOpenChange:V.onOpenChange,contentClassName:"w-full max-w-[min(100vw-2rem,64rem)]",...V.dialogProps,children:V.content}),e.jsx(ms,{open:k,onOpenChange:S,children:e.jsxs(us,{className:"w-full max-w-[min(100vw-2rem,32rem)]",children:[e.jsxs(xs,{children:[e.jsx(ps,{className:"font-display text-2xl font-semibold text-content-primary",children:"Cancel Visit"}),e.jsx(fs,{className:"text-sm text-content-secondary",children:"Please provide a reason for cancelling this visit. This will be recorded in your timeline."})]}),e.jsx("div",{className:"space-y-4 py-4",children:e.jsxs("div",{className:"space-y-2",children:[e.jsx(hs,{htmlFor:"cancellation-reason",className:"text-sm font-medium",children:"Cancellation Reason"}),e.jsx(gs,{id:"cancellation-reason",placeholder:"Enter your reason for cancelling…",value:D,onChange:t=>U(t.target.value),className:"min-h-[100px] dark:bg-slate-700 dark:text-slate-100 dar
2k:border-slate-600"})]})}),e.jsxs(bs,{className:"flex-col-reverse sm:flex-row",children:[e.jsx(y,{variant:"outline",onClick:()=>{S(!1),P(null),U("")},disabled:W,children:"Keep Visit"}),e.jsx(y,{variant:"destructive",onClick:Lt,disabled:W||!D.trim(),className:"bg-red-600 hover:bg-red-700 text-white",children:W?e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"size-4 mr-2 animate-spin"}),"Cancelling..."]}):"Cancel Visit"})]})]})}),(lt=v==null?void 0:v.forms)!=null&&lt.length?e.jsx(ys,{requiredForms:v.forms,eligibleProducts:v.eligibleProducts||[],purchasedProducts:v.purchasedProducts||[],reusableForm:v.reusableForm||null,prefillByFormId:v.prefillByFormId||{},hasProductIntakeForms:v.hasProductIntakeForms||!1,showWelcomeFiller:!1,lockFormQueue:!0,onComplete:async(t={})=>{Ve(null),await Rt(t)},onCancel:()=>Ve(null)}):null]})}const oa=m.lazy(()=>He(()=>import("./SyncVisitsRoute-DN0Auxkn.js"),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32]))),Pt=m.lazy(()=>He(()=>import("./SyncVisitsProviderNetworkAdminView-B0GYCPkx.js"),__vite__mapDeps([33,1,8,2,3,4,5,34,35,36,16,17,37,38,39,40,41,42,43,44,45,46,11,9,10,12,13,14,15,18,19,20,22,47,48,49,23,21,50,51,52,53,54,55,56,57,58,59,60,61,62,63,27,64,65,66,67,68,69,70,71,72]))),la=m.lazy(()=>He(()=>import("./SyncVisitsProviderView-Lq5htp9K.js"),__vite__mapDeps([73,1,8,2,3,4,5,34,45,44,46,74,23,58,75,43,21,22,59,16,17,9,10,11,12,13,14,15,18,19,20,76,55,53,49,51,77,50,78,79,80,81,68,69,38,39,70,41,62,63,82,83,84,71,64,65,66,67,85,86,87,88,89,90]))),Ne={default:"Track visit schedules, provider availability, and patient calls.",delegate:"Manage patient visits for your provider network without joining live visits",provider:"Manage your visit schedule and chart workflows",providerNetworkAdmin:"Manage patient visits for your provider network"};function X({description:s=Ne.default}){return e.jsx(zs,{title:"Visits",visitMode:"sync",description:s,message:"Loading sync visits…"})}function Xa({showHeader:s=!0}){const{userType:n,userDoc:i,loading:a}=We();if(a)return e.jsx(X,{});switch(n){case"Provider Network Admin":case"Business Admin":return e.jsx(m.Suspense,{fallback:e.jsx(X,{description:Ne.providerNetworkAdmin}),children:e.jsx(Pt,{showHeader:s})});case"Provider":case"Business Provider":return e.jsx(m.Suspense,{fallback:e.jsx(X,{description:Ne.provider}),children:e.jsx(la,{})});case"Provider Delegate":case"Business Provider Delegate":case"Business Staff":return e.jsx(m.Suspense,{fallback:e.jsx(X,{description:Ne.delegate}),children:e.jsx(Pt,{isDelegate:!0})});case"Patient":return i!=null&&i.practiceId?e.jsx(m.Suspense,{fallback:e.jsx(X,{}),children:e.jsx(oa,{})}):e.jsx(ia,{});default:return e.jsx(Is,{to:"/dashboard",replace:!0})}}export{Xa as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.