PageSourceSearch

https://carexa.ai/assets/TelehealthSettings-DdumdKxD.js

js carexa.ai collected 2026-10-05 11:55:38 UTC 137,771 bytes, 7 lines download raw bytes

1import{d as _,j as e,r as c,a8 as Ee,K as Ae,B as r,T as l,L as qt,q as Di,n as M,P as ie,g as at,o as H,c9 as Wi,D as me,I as ke,c as $e,W as qi,E as Ui,a1 as Fi,a4 as $i}from"./index-_eNdN4Js.js";import{R as ht}from"./RefreshRounded-Ch_QGO-2.js";import{t as vt,q as Ut,v as Ki,w as _i,x as Ji,y as Gi,z as Yi,A as Zi,B as Xi,C as Qi,D as en}from"./TelehealthAPI-MBUj1HgI.js";import{L as tn}from"./LocalHospitalOutlined-D4GWS3rl.js";import{P as bt,E as At,n as rt,o as Ft,q as nn,r as Ct}from"./TelehealthSiteSettingsUtils-CPPwwIZC.js";import{S as hi}from"./ScheduleOutlined-t1-5c1Dp.js";import{F as xi}from"./FactCheckOutlined-DbbcPkpn.js";import{L as on}from"./ListItemButton-CJiyq_q4.js";import{L as rn}from"./ListItemIcon-DSW4OxrH.js";import{O as sn}from"./OpenInNewRounded-besL_iGx.js";import{L as an}from"./LockOutlined-DvJj-ypG.js";import{S as p}from"./Stack-D5AjnWMI.js";import{C as ue}from"./Chip-DxI2lEMx.js";import{A as yt}from"./ArrowBackRounded-Bs_SP-P0.js";import{C as mi}from"./CloudUploadOutlined-Czs--Kgm.js";import{D as Mt}from"./DeleteOutlineRounded-ClKlLTDh.js";import{R as xt,S as lt}from"./SaveRounded-B_BAO4M3.js";import{A as ce}from"./Alert-CP2ROx5D.js";import{F as Fe}from"./InputLabel-D34ayV_C.js";import{F as Ye,T as D}from"./TextField-C6jRR99D.js";import{A as ln}from"./ArrowForwardRounded-DAv0-Anh.js";import{A as gi}from"./AutoAwesomeOutlined-6mGw_l2H.js";import{C as Rt}from"./CheckCircleRounded-DARhqjKZ.js";import{S as Se}from"./SettingSwitchCard-DBpcUhXP.js";import{L as cn}from"./LinearProgress-DuQiyAJz.js";import{T as we}from"./Tooltip-DZhYAV4i.js";import{I as he}from"./InputAdornment-CSZJNT8g.js";import{S as dn}from"./Select-CVODo0QG.js";import{M as ge}from"./MenuItem-Cac0UMvd.js";import{P as un}from"./PersonAddAltOutlined-DwXMBvOI.js";import{I as pn}from"./InfoOutlined-BmJs76gU.js";import{A as $t}from"./AccessTimeRounded-BGj10HhA.js";import{A as mt}from"./AddRounded-Cp4IC0DF.js";import{B as hn}from"./BusinessOutlined-HeBRwzEU.js";import{E as Ot}from"./ExpandMoreRounded-DEJdXQ-I.js";import{P as xn}from"./PaidOutlined-C0eXDdTB.js";import{S as fi}from"./SearchRounded-Cqa-fbeF.js";import{A as Vt,a as Nt}from"./AccordionSummary-DhxJS6DH.js";import{A as Lt}from"./AccordionDetails-D01I9Bg_.js";import{S as mn}from"./ScheduleRounded-Db61fZLd.js";import{S as gt}from"./StyledSwitch-DPmzbvKn.js";import{T as gn}from"./ToggleButtonGroup-CvcT-NAD.js";import{T as Kt}from"./ToggleButton-DFJCDsR7.js";import{A as fn}from"./Autocomplete-Bm7qZjB4.js";import{F as ft}from"./FormControlLabel-B_nDiQp-.js";import{p as bn}from"./purify.es-5AjVNlXF.js";import{D as bi}from"./DescriptionOutlined-BZrBdhK5.js";import{M as yn}from"./MicOutlined-B0xtESWe.js";import{C as jn}from"./CheckCircleOutlineRounded-BD9uKW-Y.js";import{C as vn}from"./CheckCircleOutlined-BJzwdYAK.js";import{u as Ke,o as Ze,a as Cn,b as wn,p as We,c as Sn,d as kn,q as Bn,r as Xe,f as Pn,R as In,h as Tn,s as En,t as An,i as Mn,j as wt,k as Rn,l as On,n as Vn}from"./RichTextField-D4JCcWLX.js";import{u as Nn}from"./useThemeProps-nqRv-rxw.js";import{D as Ln,a as Hn}from"./DialogContent-H1msgWYQ.js";import{D as zn}from"./DialogTitle-C3ZEL4GZ.js";import{I as Dn}from"./InfoOutlineRounded-BECRn2yD.js";import{D as Wn}from"./DialogContentText-DvsQbGMx.js";import{D as qn}from"./DialogActions-C-d9MWjQ.js";import{S as Un}from"./Snackbar-DzvwzFw9.js";import"./ActivitiesAPI-C_Yd7rU-.js";import"./listItemIconClasses-CDuuTCG8.js";import"./chipClasses-BIBmwDS5.js";import"./Close-C5vhJiwN.js";import"./useFormControl-CkGXkoLw.js";import"./Input-DSTJIT3-.js";import"./useControlled-BEeieUbk.js";import"./Grow-D0yUcrps.js";import"./Popper-DgDCVp2Q.js";import"./useSlotProps-YA8UxGuh.js";import"./isMuiElement-CXvr9MBD.js";import"./Menu-Cxs_kIPA.js";import"./Popover-DGN6T1uE.js";import"./useRovingTabIndex-DzVEojs1.js";import"./menuItemClasses-B5SH4gE1.js";import"./Collapse-CXtVXH8-.js";import"./Switch-B2RPIRE7.js";import"./SwitchBase-82DfE3Ne.js";import"./toggleButtonGroupClasses-C0sAr3nm.js";import"./toggleButtonClasses-BKAHdtQo.js";import"./usePreviousProps-Bu5SrrCF.js";import"./ListSubheader-woSg960Z.js";import"./FormatListBulleted-BQAjcZcK.js";import"./with-selector-Bv61jQ5F.js";import"./ClickAwayListener-BJz9da5L.js";const yi=_(e.jsx("path",{d:"m19.46 8 .79-1.75L22 5.46c.39-.18.39-.73 0-.91l-1.75-.79L19.46 2c-.18-.39-.73-.39-.91 0l-.79 1.75-1.76.79c-.39.18-.39.73 0 .91l1.75.79.79 1.76c.18.39.74.39.92 0M11.5 9.5 9.91 6c-.35-.78-1.47-.78-1.82 0L6.5 9.5 3 11.09c-.78.36-.78 1.47 0 1.82l3.5 1.59L8.09 18c.36.78 1.47.78 1.82 0l1.59-3.5 3.5-1.59c.78-.36.78-1.47 0-1.82zm7.04 6.5-.79 1.75-1.75.79c-.39.18-.39.73 0 .91l1.75.79.79 1.76c.18.39.73.39.91 0l.79-1.75 1.76-.79c.39-.18.39-.73 0-.91l-1.75-.79-.79-1.76c-.18-.39-.74-.39-.92 0"}
1)),Fn=_(e.jsx("path",{d:"M20 7h-5V4c0-1.1-.9-2-2-2h-2c-1.1 0-2 .9-2 2v3H4c-1.1 0-2 .9-2 2v11c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V9c0-1.1-.9-2-2-2M9 12c.83 0 1.5.67 1.5 1.5S9.83 15 9 15s-1.5-.67-1.5-1.5S8.17 12 9 12m3 6H6v-.43c0-.6.36-1.15.92-1.39.64-.28 1.34-.43 2.08-.43s1.44.15 2.08.43c.55.24.92.78.92 1.39zm1-9h-2V4h2zm4.25 7.5h-2.5c-.41 0-.75-.34-.75-.75s.34-.75.75-.75h2.5c.41 0 .75.34.75.75s-.34.75-.75.75m0-3h-2.5c-.41 0-.75-.34-.75-.75s.34-.75.75-.75h2.5c.41 0 .75.34.75.75s-.34.75-.75.75"})),$n=_(e.jsx("path",{d:"M10.67 21c-.35 0-.62-.31-.57-.66L11 14H7.5c-.88 0-.33-.75-.31-.78 1.26-2.23 3.15-5.53 5.65-9.93.1-.18.3-.29.5-.29.35 0 .62.31.57.66l-.9 6.34h3.51c.4 0 .62.19.4.66-3.29 5.74-5.2 9.09-5.75 10.05-.1.18-.29.29-.5.29"})),Kn=_(e.jsx("path",{d:"M12 7V3H2v18h20V7zM6 19H4v-2h2zm0-4H4v-2h2zm0-4H4V9h2zm0-4H4V5h2zm4 12H8v-2h2zm0-4H8v-2h2zm0-4H8V9h2zm0-4H8V5h2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8zm-2-8h-2v2h2zm0 4h-2v2h2z"})),_n=_(e.jsx("path",{d:"m18.85 10.39 1.06-1.06c.78-.78.78-2.05 0-2.83L18.5 5.09c-.78-.78-2.05-.78-2.83 0l-1.06 1.06zm-4.24 1.42L7.41 19H6v-1.41l7.19-7.19zm-1.42-4.25L4 16.76V21h4.24l9.19-9.19zM19 17.5c0 2.19-2.54 3.5-5 3.5-.55 0-1-.45-1-1s.45-1 1-1c1.54 0 3-.73 3-1.5 0-.47-.48-.87-1.23-1.2l1.48-1.48c1.07.63 1.75 1.47 1.75 2.68M4.58 13.35C3.61 12.79 3 12.06 3 11c0-1.8 1.89-2.63 3.56-3.36C7.59 7.18 9 6.56 9 6c0-.41-.78-1-2-1-1.26 0-1.8.61-1.83.64-.35.41-.98.46-1.4.12-.41-.34-.49-.95-.15-1.38C3.73 4.24 4.76 3 7 3s4 1.32 4 3c0 1.87-1.93 2.72-3.64 3.47C6.42 9.88 5 10.5 5 11c0 .31.43.6 1.07.86z"})),ji=_(e.jsx("path",{d:"M16 10.53c-.29-.29-.77-.29-1.06 0l-4.35 4.35L9 13.29c-.29-.29-.77-.29-1.06 0s-.29.77 0 1.06l1.94 1.94c.39.39 1.02.39 1.41 0l4.7-4.7c.3-.29.3-.77.01-1.06M19 3h-1V2c0-.55-.45-1-1-1s-1 .45-1 1v1H8V2c0-.55-.45-1-1-1s-1 .45-1 1v1H5c-1.11 0-1.99.9-1.99 2L3 19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2m-1 16H6c-.55 0-1-.45-1-1V8h14v10c0 .55-.45 1-1 1"})),Jn=_(e.jsx("path",{fillRule:"evenodd",d:"M20 3H4c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2M9 17H6c-.55 0-1-.45-1-1s.45-1 1-1h3c.55 0 1 .45 1 1s-.45 1-1 1m0-4H6c-.55 0-1-.45-1-1s.45-1 1-1h3c.55 0 1 .45 1 1s-.45 1-1 1m0-4H6c-.55 0-1-.45-1-1s.45-1 1-1h3c.55 0 1 .45 1 1s-.45 1-1 1m9.7 2.12-3.17 3.17c-.39.39-1.03.39-1.42 0l-1.41-1.42a.996.996 0 0 1 0-1.41c.39-.39 1.02-.39 1.41 0l.71.71 2.47-2.47c.39-.39 1.02-.39 1.41 0l.01.01c.38.39.38 1.03-.01 1.41"})),Gn=_(e.jsx("circle",{cx:"12",cy:"12",r:"8"})),Yn=_(e.jsx("path",{d:"M3.27 5 2 6.27l6.97 6.97L6.5 19h3l1.57-3.66L16.73 21 18 19.73 3.55 5.27zM6 5v.18L8.82 8h2.4l-.72 1.68 2.1 2.1L14.21 8H20V5z"})),Zn=_(e.jsx("path",{d:"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2zm1-9h1V4H2v1h1zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2zm5-6v2h14V5zm0 14h14v-2H7zm0-6h14v-2H7z"})),Xn=_(e.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})),Qn=_(e.jsx("path",{d:"M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6m-7 2v2h14v-2z"})),eo=_(e.jsx("path",{d:"M9 13.75c-2.34 0-7 1.17-7 3.5V19h14v-1.75c0-2.33-4.66-3.5-7-3.5M4.34 17c.84-.58 2.87-1.25 4.66-1.25s3.82.67 4.66 1.25zM9 12c1.93 0 3.5-1.57 3.5-3.5S10.93 5 9 5 5.5 6.57 5.5 8.5 7.07 12 9 12m0-5c.83 0 1.5.67 1.5 1.5S9.83 10 9 10s-1.5-.67-1.5-1.5S8.17 7 9 7m7.04 6.81c1.16.84 1.96 1.96 1.96 3.44V19h4v-1.75c0-2.02-3.5-3.17-5.96-3.44M15 12c1.93 0 3.5-1.57 3.5-3.5S16.93 5 15 5c-.54 0-1.04.13-1.5.35.63.89 1 1.98 1 3.15s-.37 2.26-1 3.15c.46.22.96.35 1.5.35"})),to=_(e.jsx("path",{d:"M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m-1 14H5c-.55 0-1-.45-1-1V8l6.94 4.34c.65.41 1.47.41 2.12 0L20 8v9c0 .55-.45 1-1 1m-7-7L4 6h16z"})),io=_(e.jsx("path",{d:"M7 9H2V7h5zm0 3H2v2h5zm13.59 7-3.83-3.83c-.8.52-1.74.83-2.76.83-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5c0 1.02-.31 1.96-.83 2.75L22 17.59zM17 11c0-1.65-1.35-3-3-3s-3 1.35-3 3 1.35 3 3 3 3-1.35 3-3M2 19h10v-2H2z"})),no=_(e.jsx("path",{d:"M4 18h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1m0-5h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1s.45 1 1 1M3 7c0 .55.45 1 1 1h16c.55 0 1-.45 1-1s-.45-1-1-1H4c-.55 0-1 .45-1 1"})),vi=_(e.jsx("path",{d:"M21 11.01 3 11v2h18zM3 16h12v2H3zM21 6H3v2.01L21 8z"})),Ci=_([e.jsx("path",{d:"M12 22C6.49 22 2 17.51 2 12S6.49 2 12 2s10 4.04 10 9c0 3.31-2.69 6-6 6h-1.77c-.28 0-.5.22-.5.5 0 .12.05.23.13.33.41.47.64 1.06.64 1.67 0 1.38-1.12 2.5-2.5 2.5m0-18c-4.41 0-8 3.59-8 8s3.59 8 8 8c.28 0 .5-.22.5-.5 0-.16-.08-.28-.14-.35-.41-.46-.63-1.05-.63-1.65 0-1.38 1.12-2.5 2.5-2.5H16c2.21 0 4-1.79 4-4 0-3.86-3.59-7-8-7"},"0"),e.jsx("circle",{cx:"6.5",cy:"11.5",r:"1.5"},"1"),e.jsx("circle",{cx:"9.5",cy:"7.5",r:"1.5"},"2"),e.jsx("circle",{cx:"14.5",cy:"7.5",r:"1.5"},"3"),e.jsx("circle",{cx:"17.5",cy:"11.5",r:"1.5"},"4")]),oo=_(e.jsx("path",{d:"M23 8v10c0 1.1-.9 2-2 2H5c-.55 0-1-.45-1-1s.45-1 1-1h16V8c0-.55.45-1 1-1s1 .45 1 1M4 16c-1.66 0-3-1.34-3-3V7c0-1.66 1.34-3 3-3h12c1.66 0 3 1.34 3 3v7c0 1.1-.9 2-2 2zm3-6c0 1.66 1.34 3 3 3s3-1.34 3-3-1.34-3-3-3-3 1.34-3 3"})),ro=_(e.jsx("path",{d:"M15.5 1h-8C6.12 1 5 2.12 5 3.5v17C5 21.88 6.12 23 7.5 23h8c1.38 0 2.5-1.12 2.5-2.5v-17C18 2.12 16.88 1 15.5 1m-4 21c-.83 0-1.5-.67-1.5-1.5s.67-1.5 1.5-1.5 1.5.67 1.5 1.5-.67 1.5-1.5 1.5m4.5-4H7V4h9z"})),so=_(e.jsx("path",{d:"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z"})),_t=_(e.jsx("path",{d:"M9.19 6.35c-2.04 2.29-3.44 5.58-3.57 5.89l-2.26-.97c-.65-.28-.81-1.13-.31-1.63l3.01-3.01c.47-.47 1.15-.68 1.81-.55zm1.49 10.16c.3.3.74.38 1.12.2 1.16-.54 3.65-1.81 5.26-3.42 4.59-4.59 4.63-8.33 4.36-9.93-.07-.4-.39-.72-.79-.79-1.6-.27-5.34-.23-9.93 4.36-1.61 1.61-2.87 4.1-3.42 5.26-.18.38-.09.83.2 1.12zm6.97-1.7c-2.29 2.04-5.58 3.44-5.89 3.57l.97 2.26c.28.65 1.13.81 1.63.31l3.01-3.01c.47-.47.68-1.15.55-1.81zm-8.71 2.6c.2 1.06-.15 2.04-.82 2.71-.77.77-3.16 1.34-4.71 1.64-.69.13-1.3-.48-1.17-1.17.3-1.55.86-3.94 1.64-4.71.67-.67 1.65-1.02 2.71-.82 1.17.22 2.13 1.18 2.35 2.35M13 9c0-1.1.9-2 2-2s2 .9 2 2-.9 2-2 2-2-.9-2-2"})),ao=_(e.jsx("path",{d:"M10 6.35V4.26c-.66.17-1.29.43-1.88.75l1.5 1.5c.13-.05.25-.11.38-.16M20 12c0-2.21-.91-4.2-2.36-5.64L20 4h-6v6l2.24-2.24C17.32 8.85 18 10.34 18 12c0 .85-.19 1.65-.51 2.38l1.5 1.5C19.63 14.74 20 13.41 20 12M4.27 4 2.86 5.41l2.36 2.36C4.45 8.99 4 10.44 4 12c0 2.21.91 4.2 2.36 5.64L4 20h6v-6l-2.24 2.24C6.68 15.15 6 13.66 6 12c0-1 .25-1.94.68-2.77l8.08 8.08c-.25.13-.5.24-.76.34v2.09c.8-.21 1.55-.54 2.23-.96l2.58 2.58 1.41-1.41z"})),wi=_(e.jsx("path",{d:"M12 4V2.21c0-.45-.54-.67-.85-.35l-2.8 2.79c-.2.2-.2.51 0 .71l2.79 2.79c.32.31.86.09.86-.36V6c3.31 0 6 2.69 6 6 0 .79-.15 1.56-.44 2.25-.15.36-.04.77.23 1.04.51.51 1.37.33 1.64-.34.37-.91.57-1.91.57-2.95 0-4.42-3.58-8-8-8m0 14c-3.31 0-6-2.69-6-6 0-.79.15-1.56.44-2.25.15-.36.04-.77-.23-1.04-.51-.51-1.37-.33-1.64.34C4.2 9.96 4 10.96 4 12c0 4.42 3.58 8 8 8v1.79c0 .45.54.67.85.35l2.79-2.79c.2-.2.2-.51 0-.71l-2.79-2.79c-.31-.31-.85-.09-.85.36z"})),lo=_(e.jsx("path",{d:"M12.65 15.67c.14-.36.05-.77-.23-1.05l-2.09-2.06.03-.03c1.74-1.94 2.98-4.17 3.71-6.53h1.94c.54 0 .99-.45.99-.99v-.02c0-.54-.45-.99-.99-.99H10V3c0-.55-.45-1-1-1s-1 .45-1 1v1H1.99c-.54 0-.99.45-.99.99 0 .55.45.99.99.99h10.18C11.5 7.92 10.44 9.75 9 11.35c-.81-.89-1.49-1.86-2.06-2.88-.16-.29-.45-.47-.78-.47-.69 0-1.13.75-.79 1.35.63 1.13 1.4 2.21 2.3 3.21L3.3 16.87c-.4.39-.4 1.03 0 1.42.39.39 1.02.39 1.42 0L9 14l2.02 2.02c.51.51 1.38.32 1.63-.35M17.5 10c-.6 0-1.14.37-1.35.94l-3.67 9.8c-.24.61.22 1.26.87 1.26.39 0 .74-.24.88-.61l.89-2.39h4.75l.9 2.39c.14.36.49.61.88.61.65 0 1.11-.65.88-1.26l-3.67-9.8c-.22-.57-.76-.94-1.36-.94m-1.62 7 1.62-4.33L19.12 17z"})),co=_(e.jsx("path",{d:"M3 18c0 .55.45 1 1 1h5v-2H4c-.55 0-1 .45-1 1M3 6c0 .55.45 1 1 1h9V5H4c-.55 0-1 .45-1 1m10 14v-1h7c.55 0 1-.45 1-1s-.45-1-1-1h-7v-1c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1s1-.45 1-1M7 10v1H4c-.55 0-1 .45-1 1s.45 1 1 1h3v1c0 .55.45 1 1 1s1-.45 1-1v-4c0-.55-.45-1-1-1s-1 .45-1 1m14 2c0-.55-.45-1-1-1h-9v2h9c.55 0 1-.45 1-1m-5-3c.55 0 1-.45 1-1V7h3c.55 0 1-.45 1-1s-.45-1-1-1h-3V4c0-.55-.45-1-1-1s-1 .45-1 1v4c0 .55.45 1 1 1"})),uo=_(e.jsx("path",{d:"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8"}
1)),Ht=_(e.jsx("path",{d:"M12 1 3 5v6c0 5.55 3.84 10.74 9 12 5.16-1.26 9-6.45 9-12V5zm7 10c0 4.52-2.98 8.69-7 9.93-4.02-1.24-7-5.41-7-9.93V6.3l7-3.11 7 3.11zm-11.59.59L6 13l4 4 8-8-1.41-1.42L10 14.17z"})),po=_(e.jsx("path",{d:"M17 10.5V7c0-.55-.45-1-1-1H4c-.55 0-1 .45-1 1v10c0 .55.45 1 1 1h12c.55 0 1-.45 1-1v-3.5l4 4v-11zM15 16H5V8h10zm-6-1h2v-2h2v-2h-2V9H9v2H7v2h2z"}));function ho(t){var i;const o=Ke();return e.jsx(Ze,{tooltipLabel:"Blockquote",tooltipShortcutKeys:["mod","Shift","B"],IconComponent:Xn,selected:(i=o==null?void 0:o.isActive("blockquote"))!==null&&i!==void 0?i:!1,disabled:!(o!=null&&o.isEditable)||!o.can().toggleBlockquote(),onClick:()=>o==null?void 0:o.chain().focus().toggleBlockquote().run(),...t})}function xo(t){var i;const o=Ke();return e.jsx(Ze,{tooltipLabel:"Ordered list",tooltipShortcutKeys:["mod","Shift","7"],IconComponent:Zn,selected:(i=o==null?void 0:o.isActive("orderedList"))!==null&&i!==void 0?i:!1,disabled:!(o!=null&&o.isEditable)||!o.can().toggleOrderedList(),onClick:()=>o==null?void 0:o.chain().focus().toggleOrderedList().run(),...t})}function mo(t){const i=Ke();return e.jsx(Ze,{tooltipLabel:"Redo",tooltipShortcutKeys:["mod","Shift","Z"],IconComponent:so,disabled:!(i!=null&&i.isEditable)||!i.can().redo(),onClick:()=>i==null?void 0:i.chain().focus().redo().run(),...t})}function go(t){const i=Ke();return e.jsx(Ze,{tooltipLabel:"Remove inline formatting",IconComponent:Yn,disabled:!(i!=null&&i.isEditable)||!i.can().unsetAllMarks(),onClick:()=>i==null?void 0:i.chain().focus().unsetAllMarks().run(),...t})}function fo(t){var i;const o=Ke();return e.jsx(Ze,{tooltipLabel:"Underline",tooltipShortcutKeys:["mod","U"],IconComponent:Qn,selected:(i=o==null?void 0:o.isActive("underline"))!==null&&i!==void 0?i:!1,disabled:!(o!=null&&o.isEditable)||!o.can().toggleUnderline(),onClick:()=>o==null?void 0:o.chain().focus().toggleUnderline().run(),...t})}function bo(t){const i=Ke();return e.jsx(Ze,{tooltipLabel:"Undo",tooltipShortcutKeys:["mod","Z"],IconComponent:uo,disabled:!(i!=null&&i.isEditable)||!i.can().undo(),onClick:()=>i==null?void 0:i.chain().focus().undo().run(),...t})}const re=Cn("MenuSelectHeading",["root","selectInput","menuOption","paragraphOption","headingOption","headingOption1","headingOption2","headingOption3","headingOption4","headingOption5","headingOption6"]),Be=Sn("MenuSelectHeading"),yo=Ae(kn,{name:Be,slot:"root",overridesResolver:(t,i)=>i.root})({[`& .${re.selectInput}`]:{width:77}}),Si=Ae(Bn,{name:Be,slot:"menuOption",overridesResolver:(t,i)=>i.menuOption})({display:"block",width:"100%"}),Qe=Ae(Si,{name:Be,slot:"headingOption",overridesResolver:(t,i)=>i.option})({marginBlockStart:0,marginBlockEnd:0,fontWeight:"bold"}),jo=Ae(Qe,{name:Be,slot:"headingOption1",overridesResolver:(t,i)=>i.headingOption1})(({theme:t})=>({fontSize:Xe(t)["& h1"].fontSize})),vo=Ae(Qe,{name:Be,slot:"headingOption2",overridesResolver:(t,i)=>i.headingOption2})(({theme:t})=>({fontSize:Xe(t)["& h2"].fontSize})),Co=Ae(Qe,{name:Be,slot:"headingOption3",overridesResolver:(t,i)=>i.headingOption3})(({theme:t})=>({fontSize:Xe(t)["& h3"].fontSize})),wo=Ae(Qe,{name:Be,slot:"headingOption4",overridesResolver:(t,i)=>i.headingOption4})(({theme:t})=>({fontSize:Xe(t)["& h4"].fontSize})),So=Ae(Qe,{name:Be,slot:"headingOption5",overridesResolver:(t,i)=>i.headingOption5})(({theme:t})=>({fontSize:Xe(t)["& h5"].fontSize})),ko=Ae(Qe,{name:Be,slot:"headingOption6",overridesResolver:(t,i)=>i.headingOption6})(({theme:t})=>({fontSize:Xe(t)["& h6"].fontSize})),L={Paragraph:"Paragraph",Heading1:"Heading 1",Heading2:"Heading 2",Heading3:"Heading 3",Heading4:"Heading 4",Heading5:"Heading 5",Heading6:"Heading 6"},Jt={[L.Heading1]:1,[L.Heading2]:2,[L.Heading3]:3,[L.Heading4]:4,[L.Heading5]:5,[L.Heading6]:6},Gt={1:L.Heading1,2:L.Heading2,3:L.Heading3,4:L.Heading4,5:L.Heading5,6:L.Heading6};function Bo(t){var i,o,s,d,f,h,y,B,C,g,w,a,W,G,J;const u=Nn({props:t,name:Be}),{labels:j,shortcutKeys:E,hideShortcuts:q=!1,classes:v={},sx:$,...z}=u,b=q?void 0:{paragraph:(i=E==null?void 0:E.paragraph)!==null&&i!==void 0?i:["mod","alt","0"],heading1:(o=E==null?void 0:E.heading1)!==null&&o!==void 0?o:["mod","alt","1"],heading2:(s=E==null?void 0:E.heading2)!==null&&s!==void 0?s:["mod","alt","2"],heading3:(d=E==null?void 0:E.heading3)!==null&&d!==void 0?d:["mod","alt","3"],heading4:(f=E==null?void 0:E.heading4)!==null&&f!==void 0?f:["mod","alt","4"],heading5:(h=E==null?void 0:E.heading5)!==null&&h!==void 0?h:["mod","alt","5"],heading6:(y=E==null?void 0:E.heading6)!==null&&y!==void 0?y:["mod","alt","6"]},I=Ke(),K=c.useCallback(Z=>{const ee=Z.target.value;ee===L.Paragraph?I==null||I.chain().setParagraph().focus().run():ee in Jt&&(I==null||I.chain().setHeading({level:Jt[ee]}).focus().run())},[I]);let V="",Y;if(I!=null&&I.isActive("paragraph"))V=L.Paragraph;else if(I!=null&&I.isActive("heading")){const ee=wn(I.state,"heading").map(X=>X.level);Y=new Set(ee).size===1?ee[0]:void 0,Y&&Y in Gt&&(V=Gt[Y])}const Q=V!=="",ne=!!(I!=null&&I.can().setParagraph()),de=c.useMemo(()=>{var Z;const ee=I==null?void 0:I.extensionManager.extensions.find(xe=>xe.name=="heading");return new Set((Z=ee==null?void 0:ee.options.levels)!==null&&Z!==void 0?Z:[])},[I]),P=de.values().next(),U=P.done?void 0:P.value,se=U!==void 0&&(Y===U||!!(I!=null&&I.can().setHeading({level:U})));return e.jsxs(yo,{onChange:K,disabled:!(I!=null&&I.isEditable)||!Q&&!ne&&!se,dis
1playEmpty:!0,renderValue:Z=>{var ee,xe;let X;return Z===""?X=(xe=(ee=j==null?void 0:j.emptyValue)!==null&&ee!==void 0?ee:j==null?void 0:j.empty)!==null&&xe!==void 0?xe:e.jsx("em",{children:"Change to…"}):Z===L.Paragraph?X=j==null?void 0:j.paragraph:Z===L.Heading1?X=j==null?void 0:j.heading1:Z===L.Heading2?X=j==null?void 0:j.heading2:Z===L.Heading3?X=j==null?void 0:j.heading3:Z===L.Heading4?X=j==null?void 0:j.heading4:Z===L.Heading5?X=j==null?void 0:j.heading5:Z===L.Heading6&&(X=j==null?void 0:j.heading6),X??Z},tooltipTitle:"Styles",...z,value:V,inputProps:{...z.inputProps,className:Ee([re.selectInput,v.selectInput,(B=z.inputProps)===null||B===void 0?void 0:B.className])},className:Ee([re.root,v.root,z.className]),sx:$,children:[e.jsx(ge,{value:L.Paragraph,disabled:!Q&&!ne,"aria-description":We(b==null?void 0:b.paragraph),children:e.jsx(Si,{label:"",shortcutKeys:b==null?void 0:b.paragraph,placement:"right",classes:{contentWrapper:Ee([re.menuOption,v.menuOption,re.paragraphOption,v.paragraphOption])},children:(C=j==null?void 0:j.paragraph)!==null&&C!==void 0?C:L.Paragraph})}),de.has(1)&&e.jsx(ge,{value:L.Heading1,disabled:!se,"aria-description":We(b==null?void 0:b.heading1),children:e.jsx(jo,{label:"",shortcutKeys:b==null?void 0:b.heading1,placement:"right",className:Ee([re.menuOption,v.menuOption,re.headingOption,v.headingOption,re.headingOption1,v.headingOption1]),children:(g=j==null?void 0:j.heading1)!==null&&g!==void 0?g:L.Heading1})}),de.has(2)&&e.jsx(ge,{value:L.Heading2,disabled:!se,"aria-description":We(b==null?void 0:b.heading2),children:e.jsx(vo,{label:"",shortcutKeys:b==null?void 0:b.heading2,placement:"right",className:Ee([re.menuOption,v.menuOption,re.headingOption,v.headingOption,re.headingOption2,v.headingOption2]),children:(w=j==null?void 0:j.heading2)!==null&&w!==void 0?w:L.Heading2})}),de.has(3)&&e.jsx(ge,{value:L.Heading3,disabled:!se,"aria-description":We(b==null?void 0:b.heading3),children:e.jsx(Co,{label:"",shortcutKeys:b==null?void 0:b.heading3,placement:"right",className:Ee([re.menuOption,v.menuOption,re.headingOption,v.headingOption,re.headingOption3,v.headingOption3]),children:(a=j==null?void 0:j.heading3)!==null&&a!==void 0?a:L.Heading3})}),de.has(4)&&e.jsx(ge,{value:L.Heading4,disabled:!se,"aria-description":We(b==null?void 0:b.heading4),children:e.jsx(wo,{label:"",shortcutKeys:b==null?void 0:b.heading4,placement:"right",className:Ee([re.menuOption,v.menuOption,re.headingOption,v.headingOption,re.headingOption4,v.headingOption4]),children:(W=j==null?void 0:j.heading4)!==null&&W!==void 0?W:L.Heading4})}),de.has(5)&&e.jsx(ge,{value:L.Heading5,disabled:!se,"aria-description":We(b==null?void 0:b.heading5),children:e.jsx(So,{label:"",shortcutKeys:b==null?void 0:b.heading5,placement:"right",className:Ee([re.menuOption,v.menuOption,re.headingOption,v.headingOption,re.headingOption5,v.headingOption5]),children:(G=j==null?void 0:j.heading5)!==null&&G!==void 0?G:L.Heading5})}),de.has(6)&&e.jsx(ge,{value:L.Heading6,disabled:!se,"aria-description":We(b==null?void 0:b.heading6),children:e.jsx(ko,{label:"",shortcutKeys:b==null?void 0:b.heading6,placement:"right",className:Ee([re.menuOption,v.menuOption,re.headingOption,v.headingOption,re.headingOption6,v.headingOption6]),children:(J=j==null?void 0:j.heading6)!==null&&J!==void 0?J:L.Heading6})})]})}const Po=c.forwardRef(function({className:i,renderControls:o,RichTextFieldProps:s={},sx:d,children:f,editorDependencies:h=[],editable:y=!0,shouldRerenderOnTransaction:B=!0,...C},g){const w={editable:y,shouldRerenderOnTransaction:B,...C},a=Pn(w,h);return c.useImperativeHandle(g,()=>({editor:a}),[a]),c.useEffect(()=>{!a||a.isDestroyed||a.isEditable===y||queueMicrotask(()=>{a.setEditable(y)})},[y,a]),e.jsxs(In,{editor:a,children:[e.jsx(Tn,{disabled:!y,controls:o==null?void 0:o(a),className:i,sx:d,...s}),f==null?void 0:f(a)]})}),Io=[{id:"branding",label:"Branding",icon:Ci},{id:"booking",label:"Booking access",icon:bt},{id:"verification",label:"Verification",icon:Ht},{id:"scheduling",label:"Scheduling",icon:hi},{id:"instructions",label:"Visit instructions",icon:vi}];function St({id:t,label:i,Icon:o,activeSection:s,dirty:d,onSelect:f}){const h=s===t;return e.jsxs(on,{selected:h,onClick:()=>f(t),sx:{mb:.5,px:1.25,py:.5,minHeight:42,borderRadius:2,color:h?"text.primary":"text.secondary","&.Mu
1i-selected":{bgcolor:"action.selected","&:hover":{bgcolor:"action.hover"}}},children:[e.jsx(rn,{sx:{minWidth:36,color:h?"text.primary":"text.secondary"},children:e.jsx(o,{fontSize:"small"})}),e.jsx(Di,{primary:i,slotProps:{primary:{variant:"body2",sx:{fontWeight:h?700:500,lineHeight:1.25}}}}),d&&e.jsx(r,{role:"status","aria-label":"Unsaved changes",sx:{width:7,height:7,borderRadius:"50%",bgcolor:"warning.main"}})]})}function Yt({activeSection:t,dirtySections:i,onSelect:o}){return e.jsxs(r,{sx:{width:"90%",height:"100%",bgcolor:"background.paper",py:2},children:[e.jsx(l,{variant:"overline",sx:{display:"block",px:1.5,mb:.75,color:"text.secondary",fontWeight:700},children:"Booking site"}),e.jsx(qt,{disablePadding:!0,sx:{px:1},children:Io.map(s=>e.jsx(St,{id:s.id,label:s.label,Icon:s.icon,activeSection:t,dirty:i.has(s.id),onSelect:o},s.id))}),e.jsx(l,{variant:"overline",sx:{display:"block",px:1.5,mt:2.25,mb:.75,color:"text.secondary",fontWeight:700},children:"Visit configuration"}),e.jsxs(qt,{disablePadding:!0,sx:{px:1},children:[e.jsx(St,{id:"visitTypes",label:"Visit types",Icon:tn,activeSection:t,dirty:!1,onSelect:o}),e.jsx(St,{id:"consents",label:"Consent templates",Icon:xi,activeSection:t,dirty:!1,onSelect:o})]})]})}const To="#374151",Eo="#6B7280";function Zt(t){return!!(t&&/^#[0-9A-Fa-f]{6}$/.test(t))}function Ao(t){return Wi(t,"#FFFFFF")>=4.5?"#FFFFFF":"#111827"}function st({value:t}){var w,a,W;const i=t.primaryColor,o=t.accentColor,s=Zt(i)?i:To,d=Zt(o)?o:Eo,f=Ao(s),h=((w=t.displayName)==null?void 0:w.trim())||"Your clinic",y=((a=t.description)==null?void 0:a.trim())||"Connect with our care team through a secure video visit.",B=(W=t.beforeVisit)==null?void 0:W.trim(),C=t.theme||"",g=C==="classic"?M(s,.045):C==="minimal"?"#FFFFFF":"#F9FAFB";return e.jsx(r,{sx:{flex:1,minHeight:0,p:{xs:1.5,sm:2.5},overflow:"auto"},children:e.jsxs(ie,{elevation:0,sx:{minHeight:"100%",display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid",borderColor:"divider",borderRadius:2.5,bgcolor:"background.paper"},children:[e.jsxs(r,{sx:{flexShrink:0,px:{xs:1.75,sm:2.25},py:1.5,display:"flex",alignItems:"center",justifyContent:"space-between",gap:1.5,borderBottom:"1px solid",borderColor:"divider",bgcolor:"background.paper"},children:[e.jsxs(p,{direction:"row",spacing:1.25,sx:{minWidth:0,alignItems:"center"},children:[e.jsx(at,{src:t.logoUrl||void 0,variant:"rounded",sx:{width:42,he
1ight:42,flexShrink:0,bgcolor:M(s,.12),color:s,fontWeight:800},children:h.charAt(0).toUpperCase()}),e.jsxs(r,{sx:{minWidth:0},children:[e.jsx(l,{variant:"subtitle2",noWrap:!0,sx:{fontWeight:750},children:h}),e.jsxs(p,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:[e.jsx(an,{sx:{fontSize:13,color:"text.secondary"}}),e.jsx(l,{variant:"caption",color:"text.secondary",noWrap:!0,children:"Secure telehealth booking"})]})]})]}),e.jsx(ue,{size:"small",label:"Secure care",sx:{display:{xs:"none",sm:"inline-flex"},flexShrink:0,bgcolor:M(d,.12),color:d,fontWeight:750}})]}),e.jsx(r,{sx:{flex:1,minHeight:0,px:{xs:2,sm:4},py:{xs:3,sm:4},display:"grid",placeItems:"center",textAlign:"center",bgcolor:g},children:e.jsxs(r,{sx:{width:"100%",maxWidth:460},children:[e.jsx(at,{src:t.logoUrl||void 0,sx:{width:74,height:74,mx:"auto",mb:2,bgcolor:M(s,.12),color:s,fontSize:28,fontWeight:800,border:"1px solid",borderColor:M(s,.18)},children:h.charAt(0).toUpperCase()}),e.jsx(l,{variant:"h5",sx:{fontWeight:780,letterSpacing:-.35},children:"Book a telehealth visit"}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:1,lineHeight:1.65},children:y}),e.jsxs(ie,{variant:"outlined",sx:{mt:3,p:2,borderRadius:2.25,textAlign:"left",bgcolor:"background.paper"},children:[e.jsxs(p,{direction:"row",spacing:.75,sx:{alignItems:"center"},children:[e.jsx(po,{sx:{fontSize:17,color:s}}),e.jsx(l,{variant:"caption",color:"text.secondary",sx:{fontWeight:700},children:"Select an appointment"})]}),e.jsx(r,{sx:{height:44,mt:1.25,borderRadius:1.5,bgcolor:"action.hover",border:"1px solid",borderColor:"divider"}}),e.jsx(H,{fullWidth:!0,variant:"contained",disableElevation:!0,sx:{mt:1.5,minHeight:42,bgcolor:s,color:f,"&:hover":{bgcolor:s,filter:"brightness(0.95)"}},children:"Continue"})]}),B&&e.jsxs(r,{sx:{mt:2,px:1.5,py:1.25,borderRadius:1.75,textAlign:"left",bgcolor:M(d,.08),border:"1px solid",borderColor:M(d,.18)},children:[e.jsx(l,{variant:"caption",sx:{display:"block",color:d,fontWeight:750},children:"Before your visit"}),e.jsx(l,{variant:"caption",color:"text.secondary",sx:{mt:.35,display:"block"},children:B})]})]})})]})})}function Mo(t){return t.trim().charAt(0).toUpperCase()||"C"}function Xt(t,i){return rt(t)?t:i}function Qt({label:t,color:i}){return e.jsxs(p,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(r,{sx:{width:24,height:24,flex:"0 0 auto",borderRadius:1,bgcolor:i,border:"1px solid",borderColor:"divider"}}),e.jsxs(r,{children:[e.jsx(l,{variant:"caption",color:"text.secondary",sx:{display:"block"},children:t}),e.jsx(l,{variant:"body2",sx:{fontWeight:600},children:i.toUpperCase()})]})]})}function Ro({value:t,clinicSlug:i,dirty:o,onEdit:s}){var g,w;const d=Xt(t.primaryColor,"#00576F"),f=Xt(t.accentColor,"#02B894"),h=String(t.branding.theme??"modern"),y=typeof((g=t.branding)==null?void 0:g.theme)=="string"?t.branding.theme:"",B=typeof((w=t.publicInstructions)==null?void 0:w.beforeVisit)=="string"?t.publicInstructions.beforeVisit:"",C={displayName:t.displayName,description:t.description,logoUrl:t.logoUrl,primaryColor:t.primaryColor,accentColor:t.accentColor,theme:y,beforeVisit:B};return e.jsx(r,{sx:{px:{xs:1,md:2}},children:e.jsxs(r,{sx:{width:"100%",maxWidth:1280,mx:"auto"},children:[e.jsxs(p,{direction:{xs:"column",sm:"row"},spacing:2,sx:{mb:3,alignItems:{xs:"stretch",sm:"center"},justifyContent:"space-between"},children:[e.jsxs(r,{children:[e.jsxs(p,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(l,{variant:"h6",sx:{fontWeight:650},children:"Branding"}),o&&e.jsx(ue,{size:"small",label:"Unsaved",color:"warning",variant:"outlined"})]}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:"Review the patient-facing telehealth experience."})]}),e.jsx(H,{variant:"contained",disableElevation:!0,startIcon:e.jsx(At,{}),onClick:s,sx:{alignSelf:{xs:"flex-start",sm:"center"}},children:"Edit branding"})]}),e.jsxs(ie,{variant:"outlined",sx:{borderRadius:3,overflow:"hidden"},children:[e.jsxs(r,{sx:{p:{xs:2,sm:2.5},display:"grid",gridTemplateColumns:{xs:"1fr",md:"minmax(260px, 1.3fr) repeat(3, minmax(130px, auto))"},gap:2.5,alignItems:"center"},children:[e.jsxs(p,{direction:"row",spacing:1.5,sx:{alignItems:"center",minWidth:0},children:[e.jsx(at,{src:t.logoUrl||void 0,variant:"rounded",sx:{width:52,height:52,bgcolor:M(d,.12),color:d,fontWeight:800},children:Mo(t.displayName)}),e.jsxs(r,{sx:{minWidth:0},children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:700},noWrap:!0,children:t.displayName||"Your clinic"}),e.jsxs(l,{variant:"body2",color:"text.secondary",noWrap:!0,children:["/telehealth/",i]})]})]}),e.jsx(Qt,{label:"Primary",color:d}),e.jsx(Qt,{label:"Accent",color:f}),e.jsxs(r,{children:[e.jsx(l,{variant:"caption",color:"text.secondary",sx:{dis
1play:"block"},children:"Theme"}),e.jsx(l,{variant:"body2",sx:{fontWeight:600,textTransform:"capitalize"},children:h})]})]}),e.jsx(me,{}),e.jsx(r,{sx:{p:{xs:1.5,sm:2.5,lg:3}},children:e.jsx(st,{value:C,width:"100%",height:620,title:"Live patient preview"})}),e.jsx(me,{}),e.jsxs(r,{sx:{px:{xs:2,sm:2.5},py:1.5,display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,bgcolor:"#FAFBFC"},children:[e.jsx(l,{variant:"body2",color:"text.secondary",children:"Patient preview"}),e.jsx(H,{size:"small",color:"inherit",endIcon:e.jsx(sn,{fontSize:"small"}),href:`/telehealth/${i}`,target:"_blank",rel:"noreferrer",children:"Open public page"})]})]})]})})}const Oo=10*1024*1024,Vo=["image/png","image/jpeg"];function ei({label:t,value:i,onChange:o}){const s=rt(i),d=s?i:"#000000",f=y=>{const B=y.target.value.replace(/\s/g,"").toUpperCase().slice(0,7);o(B)},h=y=>{o(y.target.value.toUpperCase())};return e.jsxs(r,{children:[e.jsx(Fe,{sx:{display:"block",mb:.75,fontSize:13,fontWeight:600,color:"text.primary"},children:t}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:"44px minmax(0, 1fr)",gap:1.25,alignItems:"center"},children:[e.jsx(r,{component:"label","aria-label":`Choose ${t.toLowerCase()}`,sx:{position:"relative",width:40,height:36,display:"block",overflow:"hidden",border:"1px solid",borderColor:s?"divider":"error.main",borderRadius:1.5,bgcolor:d,cursor:"pointer",boxShadow:"inset 0 0 0 3px rgba(255,255,255,0.85)",transition:y=>y.transitions.create(["border-color","box-shadow","transform"],{duration:y.transitions.duration.shortest}),"&:hover":{boxShadow:"inset 0 0 0 3px rgba(255,255,255,0.85), 0 4px 12px rgba(15, 23, 42, 0.12)"},"&:focus-within":{borderColor:"primary.main",boxShadow:y=>`0 0 0 3px ${M(y.palette.primary.main,.16)}`}},children:e.jsx(r,{component:"input",type:"color",value:d,onChange:h,"aria-label":`${t} color picker`,sx:{position:"absolute",inset:0,width:"100%",height:"100%",p:0,border:0,opacity:0,cursor:"pointer"}})}),e.jsx(D,{fullWidth:!0,size:"small",value:i,onChange:f,error:!s,placeholder:"#00576F",slotProps:{htmlInput:{maxLength:7,spellCheck:!1,"aria-label":`${t} hex value`}}})]}),!s&&e.jsx(Ye,{error:!0,sx:{mt:.75,ml:"56px"},children:"Enter a valid HEX value, such as #00576F."})]})}function kt({title:t,description:i}){return e.jsxs(r,{children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:700},children:t}),i&&e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.25},children:i})]})}function No({value:t,clinicSlug:i,dirty:o,saving:s,error:d,onDismissError:f,onChange:h,onReset:y,onSave:B,onBack:C,onUploadLogo:g}){var K;const w=c.useRef(null),[a,W]=c.useState(!1),[G,J]=c.useState(null),u=c.useMemo(()=>String(t.branding.theme??"modern"),[t.branding.theme]),E=rt(t.primaryColor)&&rt(t.accentColor)&&!!t.displayName.trim(),q=!o||!E||s||a,v=rt(t.primaryColor)?t.primaryColor:"#00576F",$=typeof((K=t.publicInstructions)==null?void 0:K.beforeVisit)=="string"?t.publicInstructions.beforeVisit:"",z={displayName:t.displayName,description:t.description,logoUrl:t.logoUrl,primaryColor:t.primaryColor,accentColor:t.accentColor,theme:u,beforeVisit:$},b=async V=>{var Q;const Y=(Q=V.target.files)==null?void 0:Q[0];if(V.target.value="",!!Y){if(!Vo.includes(Y.type)){J("Choose a PNG or JPG image.");return}if(Y.size>Oo){J("The image must be smaller than 10 MB.");return}if(!g){J("A logo upload function has not been configured.");return}try{W(!0),J(null);const ne=await g(Y);h({logoUrl:ne})}catch(ne){J(ne instanceof Error?ne.message:"Logo upload failed.")}finally{W(!1)}}},I=async V=>{V.preventDefault(),!q&&await B()};return e.jsxs(ie,{component:"form",variant:"outlined",onSubmit:I,sx:V=>({minHeight:"calc(100vh - 64px)",backgroundColor:M(V.palette.divider,.02),mt:1,borderRadius:5}),children:[e.jsx(r,{sx:{position:"sticky",top:0,zIndex:10,borderBottom:"1px solid",borderColor:"divider",bgcolor:"rgba(255, 255, 255, 0.96)",backdropFilter:"blur(12px)"},children:e.jsxs(r,{sx:{width:"100%",maxWidth:1440,mx:"auto",p:1.5,display:"flex",alignItems:"center",justifyContent:"space-between",gap:2},children:[e.jsxs(p,{direction:"row",spacing:1.25,sx:{alignItems:"center",minWidth:0},children:[e.jsx(ke,{"aria-label":"Back to branding",onClick:C,edge:"start",children:e.jsx(yt,{})}),e.jsxs(r,{sx:{minWidth:0},children:[e.jsx(l,{variant:"h6",sx:{fontWeight:750},noWrap:!0,children:"Edit branding"}
1),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{display:{xs:"none",sm:"block"}},noWrap:!0,children:"Changes appear instantly in the preview."})]})]}),e.jsxs(p,{direction:"row",spacing:1,children:[e.jsx(H,{color:"inherit",startIcon:e.jsx(xt,{}),onClick:y,disabled:!o||s||a,sx:{display:{xs:"none",sm:"inline-flex"}},children:"Reset"}),e.jsx(H,{type:"submit",variant:"contained",disableElevation:!0,startIcon:e.jsx(lt,{}),disabled:q,children:s?"Saving…":"Save changes"})]})]})}),d&&e.jsx(ce,{severity:"error",onClose:f,sx:{borderRadius:0},children:d}),e.jsx(r,{sx:{width:"100%",maxWidth:1440,mx:"auto",p:{xs:1.5,md:2.5}},children:e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"minmax(0, 1fr)",lg:"minmax(390px, 460px) minmax(0, 1fr)"},gap:{xs:2.5,lg:3.5},alignItems:"start"},children:[e.jsxs(ie,{variant:"outlined",sx:{borderRadius:3,overflow:"hidden"},children:[e.jsxs(r,{sx:{p:{xs:2.25,sm:3}},children:[e.jsx(kt,{title:"Clinic identity"}),(G||!E)&&e.jsxs(p,{spacing:1.25,sx:{mt:2},children:[G&&e.jsx(ce,{severity:"error",onClose:()=>J(null),children:G}),!t.displayName.trim()&&e.jsx(ce,{severity:"warning",children:"Clinic display name is required."})]}),e.jsxs(p,{spacing:2.5,sx:{mt:2.5},children:[e.jsxs(r,{children:[e.jsx(Fe,{sx:{fontSize:13,fontWeight:600},children:"Clinic logo"}),e.jsxs(p,{direction:"row",spacing:2,sx:{mt:1,alignItems:"center"},children:[e.jsx(at,{src:t.logoUrl||void 0,variant:"rounded",sx:{width:76,height:76,border:"1px solid",borderColor:"divider",bgcolor:M(v,.1),color:v,fontWeight:800,fontSize:26},children:t.displayName.trim().charAt(0).toUpperCase()||"C"}),e.jsxs(r,{children:[e.jsx("input",{ref:w,hidden:!0,type:"file",accept:"image/png,image/jpeg",onChange:b}),e.jsxs(p,{direction:"row",spacing:1,sx:{flexWrap:"wrap"},useFlexGap:!0,children:[e.jsx(H,{size:"small",variant:"outlined",startIcon:e.jsx(mi,{}),onClick:()=>{var V;return(V=w.current)==null?void 0:V.click()},disabled:a,children:a?"Uploading…":"Upload"}),e.jsx(H,{size:"small",color:"inherit",startIcon:e.jsx(Mt,{}),onClick:()=>h({logoUrl:""}),disabled:!t.logoUrl||a,children:"Remove"})]}),e.jsx(Ye,{sx:{mt:.75},children:"PNG or JPG, up to 10 MB."})]})]})]}),e.jsxs(p,{spacing:.75,children:[e.jsx(Fe,{sx:{fontSize:13,fontWeight:600},children:"Clinic display name"}),e.jsx(D,{fullWidth:!0,required:!0,size:"small",value:t.displayName,onChange:V=>h({displayName:V.target.value}),slotProps:{htmlInput:{maxLength:100}},error:!t.displayName.trim()})]}),e.jsxs(p,{spacing:.75,children:[e.jsx(Fe,{sx:{fontSize:13,fontWeight:600},children:"Patient-facing description"}),e.jsx(D,{fullWidth:!0,multiline:!0,minRows:3,value:t.description,onChange:V=>h({description:V.target.value}),slotProps:{htmlInput:{maxLength:280}},helperText:`${t.description.length}/280`})]})]})]}),e.jsx(me,{}),e.jsxs(r,{sx:{p:{xs:2.25,sm:3}},children:[e.jsx(kt,{title:"Brand colors"}),e.jsxs(r,{sx:{mt:2.25,display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr",lg:"1fr"},gap:2},children:[e.jsx(ei,{label:"Primary color",value:t.primaryColor,onChange:V=>h({primaryColor:V})}),e.jsx(ei,{label:"Accent color",value:t.accentColor,onChange:V=>h({accentColor:V})})]})]}),e.jsx(me,{}),e.jsxs(r,{sx:{p:{xs:2.25,sm:3}},children:[e.jsx(kt,{title:"Appearance"}),e.jsxs(p,{spacing:2,sx:{mt:2.25},children:[e.jsxs(p,{spacing:.75,children:[e.jsx(Fe,{sx:{fontSize:13,fontWeight:600},children:"Theme style"}),e.jsxs(D,{select:!0,fullWidth:!0,size:"small",value:u,onChange:V=>h({branding:{...t.branding,theme:V.target.value}}),slotProps:{select:{native:!0}},children:[e.jsx("option",{value:"modern",children:"Modern"}),e.jsx("option",{value:"classic",children:"Classic"}),e.jsx("option",{value:"minimal",children:"Minimal"})]})]}),e.jsxs(r,{sx:{px:1.5,py:1.25,borderRadius:2,bgcolor:"action.hover"},children:[e.jsx(l,{variant:"caption",color:"text.secondary",children:"Public page"}),e.jsxs(l,{variant:"body2",sx:{mt:.25,fontWeight:600,wordBreak:"break-word"},children:["/telehealth/",i]})]})]})]})]}),e.jsxs(r,{sx:{minWidth:0,position:{lg:"sticky"},top:{lg:96}},children:[e.jsxs(p,{spacing:1.25,sx:{mb:1.5},children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:700},children:"Live preview"}),e.jsx(l,{variant:"body2",color:"text.secondary",children:"This is how patients will see your telehealth experience."})]}),e.jsx(st,{value:z,width:"100%",height:620,title:"Live patient preview"})]})]})})]})}const Lo=10*1024*1024,Ho=["image/png","image/jpeg"],ti="Please join from a quiet, private place and have your medication list nearby.",Oe=[{id:"identity",label:"Clinic identity",shortLabel:"Identity",icon:Kn},{id:"branding",label:"Brand appearance",shortLabel:"Branding",icon:Ci}
1,{id:"booking",label:"Booking access",shortLabel:"Booking",icon:bt},{id:"verification",label:"Patient verification",shortLabel:"Verification",icon:Ht},{id:"scheduling",label:"Scheduling rules",shortLabel:"Scheduling",icon:hi},{id:"instructions",label:"Visit instructions",shortLabel:"Instructions",icon:vi},{id:"review",label:"Review and create",shortLabel:"Review",icon:Rt}];function ot(t){return/^#[0-9A-Fa-f]{6}$/.test(t)}function ct(t){return/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(t)}function ii(t){return t.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)}function zo(){return{slug:"",displayName:"",description:"",logoUrl:"",primaryColor:"",accentColor:"",theme:"",isPublicBookingEnabled:!1,allowNewTelehealthGuests:!1,allowExistingPatientLookup:!1,requirePhoneVerification:!1,requireEmailVerification:!1,defaultSlotHoldMinutes:"",minLeadTimeMinutes:"",maxAdvanceBookingDays:"",beforeVisit:""}}function qe({eyebrow:t,title:i,description:o,action:s}){return e.jsxs(r,{sx:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:2,flexWrap:"wrap"},children:[e.jsxs(r,{sx:{minWidth:0},children:[e.jsx(l,{variant:"overline",sx:{display:"block",color:"primary.main",fontWeight:800,letterSpacing:.8,lineHeight:1.4},children:t}),e.jsx(l,{variant:"h6",sx:{mt:.5,fontSize:22,fontWeight:650,letterSpacing:-.3},children:i}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.75,lineHeight:1.65},children:o})]}),s&&e.jsx(r,{sx:{flexShrink:0},children:s})]})}function it({onClick:t,label:i="Use recommended values"}){return e.jsx(H,{type:"button",size:"small",variant:"outlined",startIcon:e.jsx(gi,{}),onClick:t,sx:{whiteSpace:"nowrap"},children:i})}function Ve({label:t,required:i,helperText:o,error:s,children:d}){return e.jsxs(r,{children:[e.jsx(Fe,{required:i,error:s,sx:{display:"block",mb:.75,color:"text.primary",fontSize:13,fontWeight:700},children:t}),d,o&&e.jsx(Ye,{error:s,sx:{mt:.7,ml:0},children:o})]})}function ni({label:t,value:i,onChange:o}){const s=ot(i),d=s?i:"#E5E7EB",f=!!i&&!s;return e.jsxs(r,{children:[e.jsx(Fe,{sx:{display:"block",mb:.75,color:"text.primary",fontSize:13,fontWeight:700},children:t}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:"44px minmax(0, 1fr)",gap:1.25,alignItems:"center"},children:[e.jsx(r,{component:"label",sx:{position:"relative",width:44,height:40,overflow:"hidden",border:"1px solid",borderColor:f?"error.main":"divider",borderRadius:1.5,bgcolor:d,cursor:"pointer",boxShadow:"inset 0 0 0 3px rgba(255,255,255,0.88)","&:focus-within":{borderColor:"primary.main",boxShadow:h=>`0 0 0 3px ${M(h.palette.primary.main,.16)}`}},children:e.jsx(r,{component:"input",type:"color",value:d,onChange:h=>o(h.target.value.toUpperCase()),"aria-label":`${t} color picker`,sx:{position:"absolute",inset:0,width:"100%",height:"100%",opacity:0,cursor:"pointer"}})}),e.jsx(D,{fullWidth:!0,size:"small",value:i,error:f,placeholder:"#00576F",onChange:h=>o(h.target.value.replace(/\s/g,"").toUpperCase().slice(0,7)),slotProps:{htmlInput:{maxLength:7,spellCheck:!1}}})]}),f&&e.jsx(Ye,{error:!0,sx:{ml:"56px",mt:.5},children:"Enter a six-digit HEX value, such as #00576F."})]})}function _e({label:t,value:i}){return e.jsxs(p,{direction:"row",spacing:2,sx:{alignItems:"flex-start",justifyContent:"space-between"},children:[e.jsx(l,{variant:"body2",color:"text.secondary",children:t}),e.jsx(r,{sx:{textAlign:"right"},children:typeof i=="string"?e.jsx(l,{variant:"body2",sx:{fontWeight:650},children:i}):i})]})}function Do({defaults:t,selectedFacilityId:i,creating:o,error:s,onDismissError:d,onCreate:f,onUploadLogo:h}){const y=c.useRef(null),[B,C]=c.useState(0),[g,w]=c.useState(0),[a,W]=c.useState(zo),[G,J]=c.useState(!1),[u,j]=c.useState(!1),[E,q]=c.useState(null),v=Oe[B],$=(B+1)/Oe.length*100,z=(m,O)=>{W(ae=>({...ae,[m]:O}))},b=Number(a.defaultSlotHoldMinutes),I=Number(a.minLeadTimeMinutes),K=Number(a.maxAdvanceBookingDays),V=a.defaultSlotHoldMinutes.trim()!==""&&Number.isFinite(b)&&b>=1&&b<=60,Y=a.minLeadTimeMinutes.trim()!==""&&Number.isFinite(I)&&I>=0&&I<=10080,Q=a.maxAdvanceBookingDays.trim()!==""&&Number.isFinite(K)&&K>=1&&K<=365,ne=!!a.displayName.trim()&&ct(a.slug.trim()),de=ot(a.primaryColor)&&ot(a.accentColor)&&!!a.theme,P=V&&Y&&Q,U=ne&&de&&P,se=c.useMemo(()=>({identity:ne,branding:de,booking:!0,verification:!0,scheduling:P,instructions:!0,review:U}),[de,U,ne,P]),Z=se[v.id],ee=m=>{if(m<=B)return!0;const O=Oe.slice(0,m).every(pe=>se[pe.id]),ae=m<=g+1;return O&&ae},xe=m=>{W(O=>({...O,displayName:m,slug:G?O.slug:ii(m)}))},X=async m=>{var ae;const O=(ae=m.target.files)==null?void 0:ae[0];if(m.target.value="",!!O){if(!Ho.includes(O.type)){q("Choose a PNG or JPG image.");return}if(O.size>Lo){q("The logo must be smaller than 10 MB.");return}if(!h){q("A logo upload function has not been configured.");return}try{j(!0),q(null);const pe=await h(O);z("logoUrl",pe)}catch(pe){q(pe instanceof Error?pe.message:"Logo upload failed.")}finally{j(!1)}}},te=m=>{ee(m)&&(w(O=>Math.max(O,m)),C(m),window.scrollTo({top:0,behavior:"smooth"}))},He=()=>
1{const m=B+1;!Z||m>=Oe.length||!ee(m)||(w(O=>Math.max(O,m)),C(m),window.scrollTo({top:0,behavior:"smooth"}))},R=()=>{B!==0&&(C(m=>m-1),window.scrollTo({top:0,behavior:"smooth"}))},Pe=()=>{W(m=>({...m,isPublicBookingEnabled:t.isPublicBookingEnabled,allowNewTelehealthGuests:t.allowNewTelehealthGuests,allowExistingPatientLookup:t.allowExistingPatientLookup}))},fe=()=>{W(m=>({...m,requirePhoneVerification:t.requirePhoneVerification,requireEmailVerification:t.requireEmailVerification}))},oe=()=>{W(m=>({...m,defaultSlotHoldMinutes:String(t.defaultSlotHoldMinutes),minLeadTimeMinutes:String(t.minLeadTimeMinutes),maxAdvanceBookingDays:String(t.maxAdvanceBookingDays)}))},Me=()=>{W(m=>({...m,isPublicBookingEnabled:t.isPublicBookingEnabled,allowNewTelehealthGuests:t.allowNewTelehealthGuests,allowExistingPatientLookup:t.allowExistingPatientLookup,requirePhoneVerification:t.requirePhoneVerification,requireEmailVerification:t.requireEmailVerification,defaultSlotHoldMinutes:String(t.defaultSlotHoldMinutes),minLeadTimeMinutes:String(t.minLeadTimeMinutes),maxAdvanceBookingDays:String(t.maxAdvanceBookingDays),beforeVisit:m.beforeVisit||ti}))},ze=async m=>{if(m.preventDefault(),B<Oe.length-1){He();return}if(!U||o||u)return;const O={facilityId:i||null,clinicRoomId:null,slug:a.slug.trim(),displayName:a.displayName.trim(),description:a.description.trim(),logoUrl:a.logoUrl.trim()||null,primaryColor:a.primaryColor.toUpperCase(),accentColor:a.accentColor.toUpperCase(),brandingJson:JSON.stringify({theme:a.theme}),publicInstructionsJson:JSON.stringify({beforeVisit:a.beforeVisit.trim()}),metadata:JSON.stringify({source:"telehealth-settings-admin"}),isPublicBookingEnabled:a.isPublicBookingEnabled,allowNewTelehealthGuests:a.allowNewTelehealthGuests,allowExistingPatientLookup:a.allowExistingPatientLookup,requirePhoneVerification:a.requirePhoneVerification,requireEmailVerification:a.requireEmailVerification,defaultSlotHoldMinutes:b,minLeadTimeMinutes:I,maxAdvanceBookingDays:K};await f(O)},je=()=>{switch(v.id){case"identity":return e.jsxs(p,{spacing:3,children:[e.jsx(qe,{eyebrow:"Step 1",title:"Create the clinic booking site",description:"Set the patient-facing clinic name, public address, and the short description patients will see during booking."}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",lg:"minmax(300px, 390px) minmax(0, 1fr)"},gap:3,alignItems:"start"},children:[e.jsxs(p,{spacing:2.25,children:[e.jsx(Ve,{label:"Clinic display name",required:!0,children:e.jsx(D,{required:!0,fullWidth:!0,value:a.displayName,onChange:m=>xe(m.target.value),slotProps:{htmlInput:{maxLength:100}},placeholder:"Carexa Demo Clinic"})}),e.jsx(Ve,{label:"Booking site slug",required:!0,error:!!a.slug&&!ct(a.slug),helperText:a.slug&&!ct(a.slug)?"Use lowercase letters, numbers, and single hyphens.":"This becomes the clinic booking URL and should remain stable.",children:e.jsx(D,{required:!0,fullWidth:!0,value:a.slug,onChange:m=>{J(!0),z("slug",ii(m.target.value))},error:!!a.slug&&!ct(a.slug),placeholder:"carexa-demo-clinic",slotProps:{input:{startAdornment:e.jsx(he,{position:"start",children:"/book/"})}}})}),e.jsx(Ve,{label:"Patient-facing description",helperText:`${a.description.length}/280 characters`,children:e.jsx(D,{fullWidth:!0,multiline:!0,minRows:4,value:a.description,onChange:m=>z("description",m.target.value),slotProps:{htmlInput:{maxLength:280}},placeholder:"Describe the care experience in one short sentence."})}),e.jsx(ie,{variant:"outlined",sx:{p:2,borderRadius:2.5,bgcolor:"background.paper"},children:e.jsx(_e,{label:"Site scope",value:i?"Current facility":"Organization-wide"})})]}),e.jsx(r,{sx:{position:{lg:"sticky"},top:{lg:104},minWidth:0},children:e.jsx(st,{value:a,width:"100%",height:620})})]})]});case"branding":return e.jsxs(p,{spacing:3,children:[e.jsx(qe,{eyebrow:"Step 2",title:"Make the booking experience recognizable",description:"Add the clinic logo and colors. The preview updates immediately so you can check contrast and visual balance."}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",lg:"minmax(300px, 390px) minmax(0, 1fr)"},gap:3,alignItems:"start"},children:[e.jsxs(p,{spacing:2.5,children:[E&&e.jsx(ce,{severity:"error",onClose:()=>q(null),children:E}),e.jsxs(ie,{variant:"outlined",sx:{p:2.25,borderRadius:2.5},children:[e.jsx(l,{variant:"subtitle2",sx:{fontWeight:750},children:"Clinic logo"}),e.jsxs(p,{direction:"row",spacing:2,sx:{mt:1.75,alignItems:"center"},children:[e.jsx(at,{src:a.logoUrl||void 0,variant:"rounded",sx:{width:76,height:76,border:"1px solid",borderColor:"divider",bgcolor:M(ot(a.primaryColor)?a.primaryColor:"#374151",.08),color:ot(a.primaryColor)?a.primaryColor:"#374151",fontSize:28},children:a.displayName.trim().charAt(0).toUpperCase()||"C"}),e.jsxs(p,{spacing:1,children:[e.jsx("input",{ref:y,hidden:!0,type:"file",accept:"image/png,image/jpeg",onChange:X}),e.jsx(H,{type:"button",variant:"outlined",size:"small",startIcon:e.jsx(mi,{}),disabled:u,onClick:()=>{var m;return(m=y.current)==null?void 0:m.click()},children:u?"Uploading…":"Upload logo"}),e.jsx(H,{type:"button",color:"inherit",size:"small",startIcon:e.jsx(Mt,{}),disabled:!a.logoUrl||u,onClick:()=>z("logoUrl",""),children:"Remove"})]})]}),e.jsx(Ye,{sx:{mt:1.25,ml:0},children:"PNG or JPG, up to 10 MB."})]}),e.jsxs(ie,{variant:"outlined",sx:{p:2.25,borderRadius:2.5},children:[e.jsx(l,{variant:"subtitle2",sx:{fontWeight:750,mb:2},children:"Brand palette"}),e.jsxs(p,{spacing:2,children:[e.jsx(ni,{label:"Primary color",value:a.primaryColor,onChange:m=>z("primaryColor",m)}),e.jsx(ni,{label:"Accent color",value:a.accentColor,onChange:m=>z("accentColor",m)})]})]}),e.jsx(Ve,{label:"Visual theme",required:!0,error:!a.theme,helperText:"Cho
1ose the overall visual treatment for the patient booking page.",children:e.jsxs(dn,{fullWidth:!0,size:"small",displayEmpty:!0,value:a.theme,onChange:m=>z("theme",m.target.value),renderValue:m=>m?m.charAt(0).toUpperCase()+m.slice(1):e.jsx(l,{color:"text.secondary",children:"Select a theme"}),children:[e.jsx(ge,{value:"",disabled:!0,children:"Select a theme"}),e.jsx(ge,{value:"modern",children:"Modern"}),e.jsx(ge,{value:"classic",children:"Classic"}),e.jsx(ge,{value:"minimal",children:"Minimal"})]})})]}),e.jsx(r,{sx:{position:{lg:"sticky"},top:{lg:104},minWidth:0},children:e.jsx(st,{value:a,width:"100%",height:620})})]})]});case"booking":return e.jsxs(p,{spacing:3,children:[e.jsx(qe,{eyebrow:"Step 3",title:"Choose who can request a visit",description:"Control how patients enter the booking flow. Choose the access options that match your clinic policy.",action:e.jsx(it,{onClick:Pe})}),e.jsxs(p,{spacing:1.5,children:[e.jsx(Se,{title:"Enable public booking",description:"Allow patients with the booking link to view availability and request a telehealth visit.",checked:a.isPublicBookingEnabled,onChange:m=>W(O=>({...O,isPublicBookingEnabled:m,...m?{}:{allowNewTelehealthGuests:!1,allowExistingPatientLookup:!1}}))}),e.jsx(Se,{title:"Allow new telehealth guests",description:"Let people who are not yet registered as patients begin the booking flow.",checked:a.allowNewTelehealthGuests,disabled:!a.isPublicBookingEnabled,onChange:m=>z("allowNewTelehealthGuests",m)}),e.jsx(Se,{title:"Allow existing patient lookup",description:"Let returning patients find their record using the verification options configured next.",checked:a.allowExistingPatientLookup,disabled:!a.isPublicBookingEnabled,onChange:m=>z("allowExistingPatientLookup",m)})]})]});case"verification":return e.jsxs(p,{spacing:3,children:[e.jsx(qe,{eyebrow:"Step 4",title:"Protect patient access",description:"Require verification only where it improves safety. More requirements can reduce booking completion.",action:e.jsx(it,{onClick:fe})}),e.jsxs(p,{spacing:1.5,children:[e.jsx(Se,{title:"Require phone verification",description:"Patients confirm access to their phone before continuing.",checked:a.requirePhoneVerification,onChange:m=>z("requirePhoneVerification",m)}),e.jsx(Se,{title:"Require email verification",description:"Patients confirm their email address before completing the booking.",checked:a.requireEmailVerification,onChange:m=>z("requireEmailVerification",m)})]}),!a.requirePhoneVerification&&!a.requireEmailVerification&&e.jsx(ce,{severity:"info",icon:e.jsx(Ht,{}),children:"Patients will not be asked for phone or email verification."})]});case"scheduling":return e.jsxs(p,{spacing:3,children:[e.jsx(qe,{eyebrow:"Step 5",title:"Set practical booking limits",description:"Define how long a slot is reserved, how soon a patient may book, and how far into the future availability is shown.",action:e.jsx(it,{onClick:oe})}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"repeat(3, minmax(0, 1fr))"},gap:2},children:[e.jsx(Ve,{label:"Slot hold",required:!0,error:!!a.defaultSlotHoldMinutes&&!V,helperText:"Minutes a selected time remains reserved.",children:e.jsx(D,{fullWidth:!0,type:"number",value:a.defaultSlotHoldMinutes,onChange:m=>z("defaultSlotHoldMinutes",m.target.value),error:!!a.defaultSlotHoldMinutes&&!V,placeholder:"5",slotProps:{htmlInput:{min:1,max:60,step:1},input:{endAdornment:e.jsx(he,{position:"end",children:"min"})}}})}),e.jsx(Ve,{label:"Minimum lead time",required:!0,error:!!a.minLeadTimeMinutes&&!Y,helperText:"Prevents last-minute appointments.",children:e.jsx(D,{fullWidth:!0,type:"number",value:a.minLeadTimeMinutes,onChange:m=>z("minLeadTimeMinutes",m.target.value),error:!!a.minLeadTimeMinutes&&!Y,placeholder:"30",slotProps:{htmlInput:{min:0,max:10080,step:5},input:{endAdornment:e.jsx(he,{position:"end",children:"min"})}}})}),e.jsx(Ve,{label:"Advance booking window",required:!0,error:!!a.maxAdvanceBookingDays&&!Q,helperText:"How far ahead patients can book.",children:e.jsx(D,{fullWidth:!0,type:"number",value:a.maxAdvanceBookingDays,onChange:m=>z("maxAdvanceBookingDays",m.target.value),error:!!a.maxAdvanceBookingDays&&!Q,placeholder:"30",slotProps:{htmlInput:{min:1,max:365,step:1}
1,input:{endAdornment:e.jsx(he,{position:"end",children:"days"})}}})})]})]});case"instructions":return e.jsxs(p,{spacing:3,children:[e.jsx(qe,{eyebrow:"Step 6",title:"Help patients prepare",description:"Add one short instruction that appears before the visit. Keep it specific and easy to scan.",action:e.jsx(it,{label:"Use suggested instruction",onClick:()=>z("beforeVisit",ti)})}),e.jsx(Ve,{label:"Before-visit instructions",helperText:`${a.beforeVisit.length}/800 characters`,children:e.jsx(D,{fullWidth:!0,multiline:!0,minRows:6,placeholder:"Tell patients what to prepare before joining the visit.",value:a.beforeVisit,onChange:m=>z("beforeVisit",m.target.value),slotProps:{htmlInput:{maxLength:800}}})})]});case"review":return e.jsxs(p,{spacing:3,children:[e.jsx(qe,{eyebrow:"Final step",title:"Review the patient experience",description:"Confirm the key settings below. Creating the site makes this configuration available to the telehealth booking workflow.",action:e.jsx(it,{label:"Apply recommended settings",onClick:Me})}),!U&&e.jsx(ce,{severity:"warning",children:"Complete the required Identity, Branding, and Scheduling fields before creating the site. You can click any step above to continue editing."}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",lg:"minmax(280px, 370px) minmax(0, 1fr)"},gap:3,alignItems:"start"},children:[e.jsxs(p,{spacing:2,children:[e.jsx(ie,{variant:"outlined",sx:{p:2.25,borderRadius:2.5},children:e.jsxs(p,{spacing:1.5,children:[e.jsx(_e,{label:"Clinic",value:a.displayName||"Not set"}),e.jsx(me,{}),e.jsx(_e,{label:"Booking URL",value:a.slug?`/book/${a.slug}`:"Not set"}),e.jsx(me,{}),e.jsx(_e,{label:"Public booking",value:e.jsx(ue,{size:"small",label:a.isPublicBookingEnabled?"Enabled":"Disabled",color:a.isPublicBookingEnabled?"success":"default"})}),e.jsx(me,{}),e.jsx(_e,{label:"Verification",value:a.requirePhoneVerification||a.requireEmailVerification?[a.requirePhoneVerification?"Phone":null,a.requireEmailVerification?"Email":null].filter(Boolean).join(" and "):"Not required"}),e.jsx(me,{}),e.jsx(_e,{label:"Booking window",value:a.maxAdvanceBookingDays?`${a.maxAdvanceBookingDays} days`:"Not set"})]})}),U&&e.jsx(ce,{severity:"success",icon:e.jsx(gi,{}),children:"The site is ready to create. You can edit every section later from Telehealth Settings."})]}),e.jsx(r,{sx:{position:{lg:"sticky"},top:{lg:104},minWidth:0},children:e.jsx(st,{value:a,width:"100%",height:620})})]})]});default:return null}};return e.jsxs(r,{component:"form",onSubmit:ze,sx:{minHeight:"calc(100vh - 64px)",bgcolor:"background.default"},children:[e.jsxs(r,{sx:{position:"sticky",top:0,zIndex:10,borderBottom:"1px solid",borderColor:"divider",bgcolor:"rgba(255,255,255,0.96)",backdropFilter:"blur(12px)"},children:[e.jsxs(r,{sx:{width:"100%",maxWidth:1480,mx:"auto",px:{xs:2,sm:3,lg:4},py:1.5,display:"flex",alignItems:"center",justifyContent:"space-between",gap:2},children:[e.jsxs(p,{direction:"row",spacing:1.25,sx:{alignItems:"center"},children:[e.jsx(r,{sx:{width:40,height:40,display:"grid",placeItems:"center",borderRadius:2,bgcolor:"primary.main",color:"primary.contrastText"},children:e.jsx(_t,{fontSize:"small"})}),e.jsxs(r,{children:[e.jsx(l,{variant:"h6",sx:{fontWeight:760},children:"Create telehealth booking site"}),e.jsxs(l,{variant:"body2",color:"text.secondary",sx:{display:{xs:"none",sm:"block"}},children:[v.label," · Step ",B+1," of"," ",Oe.length]})]})]}),e.jsx(ue,{size:"small",label:`${Math.round($)}% complete`,sx:{display:{xs:"none",sm:"inline-flex"}}})]}),e.jsx(r,{component:"nav","aria-label":"Create telehealth site steps",sx:{width:"100%",overflowX:"auto",overflowY:"hidden",bgcolor:"background.paper",scrollbarWidth:"thin","&::-webkit-scrollbar":{height:6},"&::-webkit-scrollbar-thumb":{borderRadius:999,bgcolor:"divider"}},children:e.jsx(r,{sx:{display:"grid",gridTemplateColumns:{xs:"repeat(7, minmax(108px, 1fr))",md:"repeat(7, minmax(0, 1fr))"},minWidth:{xs:756,md:0},gap:{xs:.5,md:.5}},children:Oe.map((m,O)=>{const ae=m.icon,pe=O===B,ve=O<B&&se[m.id],n=O>B,S=ee(O),T=o||n&&!S;return e.jsx(H,{type:"button",color:"inherit",disabled:T,onClick:()=>te(O),"aria-current":pe?"step":void 0,"aria-label":T?`${m.label} is unavailable until previous required fields are complete`:m.label,title:T?"Complete the previous required step first.":m.label,startIcon:ve?e.jsx(Rt,{sx:{fontSize:{xs:19,md:20},color:"success.main"}}):e.jsx(ae,{sx:{fontSize:{xs:19,md:20}}}),sx:{position:"relative",minWidth:0,minHeight:{xs:20},px:{xs:.75,md:.5,lg:1},display:"flex",flexDirection:"column",justifyContent:"center",gap:.5,textTransform:"none",color:pe?"primary.main":ve?"text.primary":"text.secondary",bgcolor:pe?"action.selected":"transparent",transition:A=>A.transitions.create(["background-color","color"]),"& .MuiButton-startIcon":{m:0},"&:hover":{bgcolor:pe?"action.selected":"action.hover"},"&.Mui-disabled":{color:"text.disabled",bgcolor:"transparent",opacity:.7}},children:e.jsx(l,{component:"span",variant:"caption",noWrap:!0,sx:{display:"block",width:"100%",overflow:"hidden",textOverflow:"ellipsis",textAlign:"center",fontSize:{xs:10.5,md:10.5,lg:11.5},lineHeight:1.25,fontWeight:pe?750:650},children:m.shortLabel})},m.id)})})}),e.jsx(cn,{variant:"determinate",value:$,sx:{height:3}})]}),s&&e.jsx(ce,{severity:"error",onClose:d,sx:{borderRadius:0},children:s}),e.jsx(r,{sx:{width:"100%",maxWidth:1480,mx:"auto",px:{xs:2,sm:3,lg:4},py:{xs:2.5,md:3}},children:e.jsxs(ie,{variant:"outlined",sx:{minWidth:0,overflow:"hidden",borderRadius:3},children:[e.jsx(r,{sx:{p:{xs:2.25,sm:3,md:3.5,lg:4}},children:je()}),e.jsx(me,{}),e.jsxs(r,{sx:{px:{xs:2.25,sm:3,md:3.5,lg:4},py:2,display:"flex",alignItems:"center",justifyContent:"space-between",gap:2,bgcolor:"background.paper"},children:[e.jsx(H,{type:"button",color:"inherit",startIcon:e.jsx(yt,{}),disabled:B===0||o,onClick:R,children:"Back"}),e.jsxs(p,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[!Z&&e.jsx(we,{title:"Complete the required fields before continuing",children:e.jsx(l,{variant:"caption",color:"error.main",sx:{dis
1play:{xs:"none",sm:"block"}},children:"Check required fields"})}),B<Oe.length-1?e.jsx(H,{type:"submit",variant:"contained",disableElevation:!0,endIcon:e.jsx(ln,{}),disabled:!Z||o||u,children:"Continue"}):e.jsx(H,{type:"submit",variant:"contained",disableElevation:!0,startIcon:e.jsx(_t,{}),disabled:!U||o||u,children:o?"Creating site…":"Create booking site"})]})]})]})})]})}function jt({title:t,description:i,children:o,dirty:s,saving:d,onReset:f,onSave:h,saveDisabled:y=!1,maxWidth:B=980}){return e.jsxs(r,{sx:{minHeight:"100%",display:"flex",flexDirection:"column"},children:[e.jsxs(r,{sx:{px:2,bgcolor:"background.paper"},children:[e.jsx(l,{variant:"h6",sx:{fontWeight:750,letterSpacing:"-0.02em"},children:t}),e.jsx(l,{variant:"body2",sx:{mt:.75,color:"text.secondary",maxWidth:720,lineHeight:1.65},children:i})]}),e.jsx(r,{sx:{flex:1,px:2,py:3},children:e.jsx(r,{sx:{width:"100%",maxWidth:B},children:o})}),e.jsx(r,{sx:{position:"sticky",bottom:0,zIndex:2,px:{xs:2,sm:3,lg:5},py:2,borderTop:"1px solid",borderColor:"divider",bgcolor:"rgba(255,255,255,0.96)",backdropFilter:"blur(12px)"},children:e.jsxs(p,{direction:"row",spacing:1.25,sx:{justifyContent:"flex-end"},children:[e.jsx(H,{variant:"text",color:"inherit",startIcon:e.jsx(xt,{}),onClick:f,disabled:!s||d,children:"Reset"}),e.jsx(H,{variant:"contained",startIcon:d?e.jsx($e,{size:17,color:"inherit"}):e.jsx(lt,{}),onClick:h,disabled:!s||d||y,sx:{minWidth:138,boxShadow:"none"},children:d?"Saving…":"Save changes"})]})})]})}function Wo({value:t,defaults:i,dirty:o,saving:s,onChange:d,onReset:f,onSave:h}){return e.jsx(jt,{title:"Booking access",description:"Control whether patients can find the clinic and which patient journeys are available.",dirty:o,saving:s,onReset:f,onSave:h,children:e.jsxs(p,{spacing:2,children:[e.jsx(r,{sx:{display:"flex",justifyContent:"flex-end"},children:e.jsx(H,{size:"small",color:"inherit",onClick:()=>d({isPublicBookingEnabled:i.isPublicBookingEnabled,allowNewTelehealthGuests:i.allowNewTelehealthGuests,allowExistingPatientLookup:i.allowExistingPatientLookup}),children:"Use recommended defaults"})}),!t.isPublicBookingEnabled&&e.jsx(ce,{severity:"info",children:"Public booking is off. The options below are retained but will not be visible to patients."}),e.jsx(Se,{title:"Enable public booking",description:"Allow patients to open the clinic booking page and request an available telehealth visit.",checked:t.isPublicBookingEnabled,onChange:y=>d({isPublicBookingEnabled:y}),icon:e.jsx(bt,{})}),e.jsx(Se,{title:"Allow new telehealth guests",description:"Let people who are not yet registered as patients begin the booking flow.",checked:t.allowNewTelehealthGuests,onChange:y=>d({allowNewTelehealthGuests:y}),icon:e.jsx(un,{}),disabled:!t.isPublicBookingEnabled}),e.jsx(Se,{title:"Allow existing patient lookup",description:"Let returning patients find their record using the verification methods configured for this clinic.",checked:t.allowExistingPatientLookup,onChange:y=>d({allowExistingPatientLookup:y}),icon:e.jsx(io,{}),disabled:!t.isPublicBookingEnabled})]})})}function qo({value:t,defaults:i,dirty:o,saving:s,onChange:d,onReset:f,onSave:h}){return e.jsx(jt,{title:"Patient verification",description:"Choose which contact methods patients must verify before completing public booking or record lookup.",dirty:o,saving:s,onReset:f,onSave:h,children:e.jsxs(p,{spacing:2,children:[e.jsx(r,{sx:{display:"flex",justifyContent:"flex-end"},children:e.jsx(H,{size:"small",color:"inherit",onClick:()=>d({requirePhoneVerification:i.requirePhoneVerification,requireEmailVerification:i.requireEmailVerification}),children:"Use recommended defaults"})}),!t.requirePhoneVerification&&!t.requireEmailVerification&&e.jsx(ce,{severity:"warning",children:"No contact verification is required. Confirm that this matches your clinic's privacy and identity policies."}),e.jsx(Se,{title:"Require phone verification",description:"Send a one-time code to the patient's phone number before the booking can be completed.",checked:t.requirePhoneVerification,onChange:y=>d({requirePhoneVerification:y}),icon:e.jsx(ro,{})}),e.jsx(Se,{title:"Require email verification",description:"Send a one-time code to the patient's email address before the booking can be completed.",checked:t.requireEmailVerification,onChange:y=>
1d({requireEmailVerification:y}),icon:e.jsx(to,{})})]})})}function Bt(t,i){const o=Number(t);return Number.isFinite(o)?o:i}function Uo({value:t,defaults:i,dirty:o,saving:s,onChange:d,onReset:f,onSave:h}){const y=t.defaultSlotHoldMinutes<1||t.defaultSlotHoldMinutes>30,B=t.minLeadTimeMinutes<0||t.minLeadTimeMinutes>10080,C=t.maxAdvanceBookingDays<1||t.maxAdvanceBookingDays>365,g=y||B||C;return e.jsx(jt,{title:"Scheduling rules",description:"Set booking timing limits that apply to the public telehealth experience.",dirty:o,saving:s,onReset:f,onSave:h,saveDisabled:g,children:e.jsx(ie,{variant:"outlined",sx:{p:{xs:2,sm:3},borderRadius:3},children:e.jsxs(p,{spacing:3,children:[e.jsx(r,{sx:{display:"flex",justifyContent:"flex-end"},children:e.jsx(H,{size:"small",color:"inherit",onClick:()=>d({defaultSlotHoldMinutes:i.defaultSlotHoldMinutes,minLeadTimeMinutes:i.minLeadTimeMinutes,maxAdvanceBookingDays:i.maxAdvanceBookingDays}),children:"Use recommended defaults"})}),e.jsxs(r,{children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:750},children:"Availability controls"}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:"These limits help prevent stale reservations and last-minute bookings that the clinic cannot support."})]}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"repeat(3, minmax(0, 1fr))"},gap:2},children:[e.jsx(D,{fullWidth:!0,type:"number",label:"Slot hold time",value:t.defaultSlotHoldMinutes,onChange:w=>d({defaultSlotHoldMinutes:Bt(w.target.value,t.defaultSlotHoldMinutes)}),error:y,helperText:y?"Use 1–30 minutes.":"How long an in-progress slot is reserved.",slotProps:{htmlInput:{min:1,max:30,step:1},input:{endAdornment:e.jsx(he,{position:"end",children:"min"})}}}),e.jsx(D,{fullWidth:!0,type:"number",label:"Minimum lead time",value:t.minLeadTimeMinutes,onChange:w=>d({minLeadTimeMinutes:Bt(w.target.value,t.minLeadTimeMinutes)}),error:B,helperText:B?"Use 0–10,080 minutes.":"Earliest a patient may book before a visit.",slotProps:{htmlInput:{min:0,max:10080,step:5},input:{endAdornment:e.jsx(he,{position:"end",children:"min"})}}}),e.jsx(D,{fullWidth:!0,type:"number",label:"Advance booking window",value:t.maxAdvanceBookingDays,onChange:w=>d({maxAdvanceBookingDays:Bt(w.target.value,t.maxAdvanceBookingDays)}),error:C,helperText:C?"Use 1–365 days.":"Furthest date patients may book.",slotProps:{htmlInput:{min:1,max:365,step:1},input:{endAdornment:e.jsx(he,{position:"end",children:"days"})}}})]})]})})})}function Fo({value:t,dirty:i,saving:o,onChange:s,onReset:d,onSave:f}){const h=String(t.publicInstructions.beforeVisit??"");return e.jsx(jt,{title:"Visit instructions",description:"Share clear preparation guidance with patients before they enter the telehealth waiting room.",dirty:i,saving:o,onReset:d,onSave:f,children:e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",lg:"minmax(0, 1fr) 340px"},gap:3,alignItems:"start"},children:[e.jsx(ie,{variant:"outlined",sx:{p:{xs:2,sm:3},borderRadius:3},children:e.jsxs(p,{spacing:1.5,children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:750},children:"Before the visit"}),e.jsx(D,{fullWidth:!0,multiline:!0,minRows:8,value:h,onChange:y=>s({publicInstructions:{...t.publicInstructions,beforeVisit:y.target.value}}),placeholder:"Example: Please join from a quiet, private place and have your medication list available.",helperText:`${h.length}/1200 characters`})]})}),e.jsx(ie,{variant:"outlined",sx:{p:2.5,borderRadius:3,bgcolor:"background.default"},children:e.jsxs(p,{direction:"row",spacing:1.25,sx:{alignItems:"flex-start"},children:[e.jsx(pn,{color:"primary"}),e.jsxs(r,{children:[e.jsx(l,{variant:"subtitle2",sx:{fontWeight:750},children:"Patient preview"}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:1,whiteSpace:"pre-wrap",lineHeight:1.7},children:h||"Your preparation instructions will appear here."})]})]})})]})})}function oi(t,i){if(t==null)return"Not set";try{return new Intl.NumberFormat("en-US",{style:"currency",currency:i||"USD"}).format(t)}catch{return`${i||"USD"} ${t.toFixed(2)}`}}function $o(t){const i=[t.isNewPatientAllowed?"New patients":"",t.isExistingPatientAllowed?"Existing patients":""].filter(
1Boolean);return i.length>0?i.join(" and "):"No patients enabled"}function Ko(t){const i=[t.supportsScheduled?"Scheduled":"",t.supportsOnDemand?"On-demand":""].filter(Boolean);return i.length>0?i.join(" and "):"No booking mode enabled"}function dt({icon:t,label:i}){return e.jsxs(p,{direction:"row",spacing:.75,sx:{alignItems:"center",color:"text.secondary",whiteSpace:"nowrap"},children:[e.jsx(r,{sx:{display:"flex",fontSize:18},children:t}),e.jsx(l,{variant:"caption",sx:{fontWeight:600},children:i})]})}function ye({label:t,value:i,status:o}){return e.jsxs(r,{sx:{minWidth:0},children:[e.jsx(l,{variant:"caption",sx:{display:"block",color:"text.secondary",fontWeight:600,letterSpacing:.15,mb:.5},children:t}),o?e.jsx(ue,{size:"small",label:i,variant:"outlined",color:o==="highlight"?"primary":"default",sx:{height:26,maxWidth:"100%","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis"}}}):e.jsx(l,{variant:"body2",sx:{fontWeight:650,lineHeight:1.45},children:i})]})}function Pt({title:t,description:i,children:o}){return e.jsxs(r,{sx:{height:"100%",p:{xs:2,sm:2.25},border:"1px solid",borderColor:"divider",borderRadius:2.5,bgcolor:"background.paper"},children:[e.jsx(p,{direction:"row",spacing:1.25,sx:{alignItems:"flex-start",mb:2},children:e.jsxs(r,{sx:{minWidth:0},children:[e.jsx(l,{variant:"subtitle2",sx:{fontWeight:750},children:t}),e.jsx(l,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:.2},children:i})]})}),e.jsx(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(4, minmax(0, 1fr))"},gap:2},children:o})]})}function _o({values:t,loading:i,error:o,search:s,onSearchChange:d,onCreate:f,onEdit:h,onRetry:y}){const[B,C]=c.useState(!1);return c.useEffect(()=>{B!==!1&&!t.some(g=>g.id===B)&&C(!1)},[B,t]),e.jsxs(r,{sx:{width:"100%",px:{xs:0,sm:1.5}},children:[e.jsxs(p,{direction:{xs:"column",sm:"row"},spacing:2,sx:{mb:3,justifyContent:"space-between",alignItems:{sm:"center"}},children:[e.jsxs(r,{children:[e.jsx(l,{variant:"h6",sx:{fontWeight:750},children:"Visit types"}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:"Configure appointment duration, access, pricing, and booking rules."})]}),e.jsx(H,{variant:"contained",disableElevation:!0,startIcon:e.jsx(mt,{}),onClick:f,sx:{alignSelf:{xs:"flex-start",sm:"center"},borderRadius:2},children:"Create visit type"})]}),e.jsxs(r,{children:[e.jsx(D,{value:s,onChange:g=>d(g.target.value),placeholder:"Search by visit type, description, or code",size:"small",fullWidth:!0,slotProps:{input:{startAdornment:e.jsx(he,{position:"start",children:e.jsx(fi,{fontSize:"small"})})}},sx:{mb:2,"& .MuiOutlinedInput-root":{borderRadius:2.25,bgcolor:"background.paper"}}}),o&&e.jsx(ce,{severity:"error",action:e.jsx(H,{color:"inherit",size:"small",startIcon:e.jsx(ht,{}),onClick:y,children:"Retry"}),sx:{mb:2,borderRadius:2},children:o}),i?e.jsx(r,{sx:{minHeight:280,display:"grid",placeItems:"center"},children:e.jsxs(p,{spacing:1.5,sx:{alignItems:"center"},children:[e.jsx($e,{size:32}),e.jsx(l,{variant:"body2",color:"text.secondary",children:"Loading visit types…"})]})}):t.length===0?e.jsxs(r,{sx:{px:3,py:7,textAlign:"center",border:"1px dashed",borderColor:"divider",borderRadius:3,bgcolor:"background.paper"},children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:700},children:s?"No matching visit types":"No visit types yet"}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.75},children:s?"Try a different name, description, or visit code.":"Create the first visit type for telehealth booking."}),!s&&e.jsx(H,{sx:{mt:2},startIcon:e.jsx(mt,{}),onClick:f,children:"Create visit type"})]}):e.jsx(p,{sx:{border:"1px solid",borderColor:"divider",borderRadius:2},children:t.map((g,w)=>{const a=B===g.id,W=w===t.length-1;return e.jsxs(Vt,{expanded:a,onChange:(G,J)=>{C(J?g.id:!1)},disableGutters:!0,elevation:0,slotProps:{transition:{unmountOnExit:!0}},sx:G=>({borderBottom:W?0:"1px solid",borderColor:"divider",overflow:"hidden",bgcolor:a?M(G.palette.action.selected,.03):"background.default",transition:G.transitions.create(["border-color","box-shadow"]),boxShadow:a?`0 10px 30px ${M(G.palette.common.black,.08)}`:"none","&:before":{display:"none"}}),children:[e.jsx(Nt,{id:`visit-type-${g.id}-header`,"aria-controls":`visit-type-${g.id}-content`,expandIcon:e.jsx(Ot,{sx:{color:"text.secondary",fontSize:21}}),sx:{minWidth:0,px:{xs:1.5,sm:2.25},my:1,minHeight:42,"& .MuiAccordionSummary-content":{minWidth:0}},children:e.jsxs(p,{direction:{xs:"column",md:"row"},spacing:{xs:1.5,md:2.5},sx:{width:"100%",minWidth:0,alignItems:{xs:"flex-start",md:"center"},justifyContent:"space-between"},children:[e.jsx(p,{direction:"row",spacing:1.5,sx:{alignItems:"flex-start",minWidth:0},children:e.jsxs(r,{sx:{minWidth:0},children:[e.jsxs(p,{direction:"row",spacing:1,useFlexGap:!0,sx:{flexWrap:"wrap",alignItems:"center"},children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:750,lineHeight:1.35},children:g.displayName}),e.jsx(ue,{size:"small",label:g.isPublicBookable?"Public":"Internal",icon:e.jsx(r,{sx:{"& .MuiSvgIcon-root":{fontSize:14}},children:g.isPublicBookable?e.jsx(bt,{sx:{fontSize:14}}):e.jsx(hn,{sx:{fontSize:14}})}),variant:"outlined",color:g.isPublicBookable?"primary":"default",sx:{height:24,px:.5}})]}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.45,maxWidth:620,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:g.description||"No description provided."})]})}),e.jsxs(p,{direction:"row",spacing:2,useFlexGap:!0,sx:{pl:{xs:1.25,md:0},pr:{md:1},flexWrap:"wrap",alignItems:"center"},children:[e.jsx(dt,{icon:e.jsx($t,{sx:{fontSize:17}}),label:`${g.defaultDurationMinutes} min`}),e.jsx(dt,{icon:e.jsx(xn,{sx:{fontSize:17}}),label:oi(g.selfPayPrice,g.currencyCode)}),g.supportsScheduled&&e.jsx(dt,{icon:e.jsx(ji,{sx:{fontSize:17}}),label:"Scheduled"}),g.supportsOnDemand&&e.jsx(dt,{icon:e.jsx($n,{sx:{fontSize:17}}),label:"On-demand"})]})]})}),e.jsx(Lt,{id:`visit-type-${g.id}-content`,sx:{px:{xs:1.5,sm:2.25},pb:2.5},children:e.jsxs(p,{spacing:2,children:[e.jsxs(p,{direction:{xs:"column",sm:"row"},spacing:1,sx:{alignItems:{xs:"flex-start",sm:"center"},justifyContent:"space-between"},children:[e.jsxs(p,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(co,{sx:{fontSize:18,color:"text.secondary"}}),e.jsx(l,{variant:"body2",sx:{fontWeight:650},children:"Configuration overview"})]}),e.jsxs(p,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[g.code&&e.jsx(ue,{size:"small",label:`Code: ${g.code}`,variant:"outlined",sx:{height:32,fontFamily:"monospace",bgcolor:"background.paper"}}),e.jsx(H,{size:"small",variant:"outlined",startIcon:e.jsx(At,{}),onClick:()=>h(g),sx:{borderRadius:1.5,whiteSpace:"nowrap",bgcolor:"background.default"},children:"Edit configuration"})]})]}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr"},gap:1.5},children:[e.jsxs(Pt,{icon:e.jsx($t,{fontSize:"small"}),title:"Scheduling",description:"Timing, availability, and booking limits",children:[e.jsx(ye,{label:"Default duration",value:`${g.defaultDurationMinutes} minutes`}),e.jsx(ye,{label:"Visit modes",value:Ko(g)}),e.jsx(ye,{label:"Buffers",value:`${g.bufferBeforeMinutes} min before · ${g.bufferAfterMinutes} min after`}),e.jsx(ye,{label:"Booking window",value:`${g.minAdvanceMinutes} min notice · ${g.maxAdvanceDays} days ahead`})]}),e.jsxs(Pt,{icon:e.jsx(eo,{fontSize:"small"}),title:"Patient access",description:"Eligibility, visibility, and patient pricing",children:[e.jsx(ye,{label:"Eligible patients",value:$o(g)}),e.jsx(ye,{label:"Booking access",value:g.isPublicBookable?"Public booking":"Internal booking only",status:g.isPublicBookable?"highlight":"neutral"}
1),e.jsx(ye,{label:"Self-pay price",value:oi(g.selfPayPrice,g.currencyCode)}),e.jsx(ye,{label:"Facility scope",value:g.facilityId?"Facility-specific":"Organization-wide"})]}),e.jsxs(Pt,{icon:e.jsx(xi,{fontSize:"small"}),title:"Visit requirements",description:"Approval, forms, and consent workflow",children:[e.jsx(ye,{label:"Provider approval",value:g.requiresProviderApprovalByDefault?"Required":"Automatic",status:g.requiresProviderApprovalByDefault?"highlight":"neutral"}),e.jsx(ye,{label:"Check-in form",value:g.requiresCheckInForm?"Required":"Not required",status:g.requiresCheckInForm?"highlight":"neutral"}),e.jsx(ye,{label:"Consent before join",value:g.requiresConsentBeforeJoin?"Required":"Not required",status:g.requiresConsentBeforeJoin?"highlight":"neutral"})]})]})]})})]},g.id)})})]})]})}function Jo({values:t,loading:i,error:o,onCreate:s,onEdit:d,onRetry:f}){const[h,y]=c.useState(""),B=c.useMemo(()=>{const C=h.trim().toLowerCase();return C?t.filter(g=>[g.displayName,g.code,g.description??""].some(w=>w.toLowerCase().includes(C))):t},[h,t]);return e.jsx(_o,{values:B,loading:i,error:o,search:h,onSearchChange:y,onCreate:s,onEdit:d,onRetry:f})}const Go=["code","displayName","description","defaultDurationMinutes","bufferBeforeMinutes","bufferAfterMinutes","minAdvanceMinutes","maxAdvanceDays","isPublicBookable","supportsScheduled","supportsOnDemand","requiresProviderApprovalByDefault","autoAcceptBookingsByDefault","isNewPatientAllowed","isExistingPatientAllowed","requiresConsentBeforeJoin","requiresCheckInForm","selfPayPrice","currencyCode"];function Yo(t,i){return Go.some(o=>!Object.is(t[o],i[o]))}function ri(t){return Object.values(t).some(i=>typeof i=="string"&&i.length>0)}const Zo=["USD","CAD","EUR","GBP","AUD"];function It(t,i){const o=t;for(const s of i){const d=o[s];if(typeof d=="string"&&d.trim())return d.trim()}}function Xo(t){const i=It(t,["consentTemplateKey","templateKey","key","code"]);if(!i)return null;const o=It(t,["displayName","name","title","templateName"])??i,s=It(t,["languageCode","defaultLanguageCode"])??"en-US";return{key:i,label:o,languageCode:s}}function si(t){if(!t)return"";const i=new Date(t);if(Number.isNaN(i.getTime()))return"";const o=i.getTimezoneOffset()*6e4;return new Date(i.getTime()-o).toISOString().slice(0,16)}function Je(t){if(!t.trim())return null;const i=new Date(t);return Number.isNaN(i.getTime())?null:i.toISOString()}function Qo(t){if(t==null)return"";if(typeof t=="string")return t;try{return JSON.stringify(t,null,2)}catch{return""}}function er(t){return{consentTemplateKey:t.consentTemplateKey,languageCode:t.languageCode||"en-US",isEnabled:t.isEnabled,isRequiredBeforeJoin:t.isRequiredBeforeJoin,appliesToNewPatients:t.appliesToNewPatients,appliesToExistingPatients:t.appliesToExistingPatients,displayOrder:t.displayOrder,effectiveFromUtc:si(t.effectiveFromUtc),effectiveToUtc:si(t.effectiveToUtc),metadataJson:Qo(t.metadata),rowVersion:t.rowVersion??null}}function tr(t){return[...t].sort((i,o)=>i.displayOrder-o.displayOrder).map(er)}function ai(t){return JSON.stringify([...t].sort((i,o)=>i.displayOrder-o.displayOrder).map(i=>({...i,metadataJson:i.metadataJson.trim()})))}function li(t,i){if(!t)return{errors:{}};const o={};return i.length===0?{selectionError:"Select at least one consent template.",errors:o}:(i.forEach(s=>{const d={};s.languageCode.trim()||(d.languageCode="Language is required."),(!Number.isInteger(s.displayOrder)||s.displayOrder<1)&&(d.displayOrder="Display order must be 1 or greater."),!s.appliesToNewPatients&&!s.appliesToExistingPatients&&(d.patientApplicability="Apply this consent to at least one patient type."),s.effectiveFromUtc&&!Je(s.effectiveFromUtc)&&(d.effectiveFromUtc="Enter a valid start date and time."),s.effectiveToUtc&&!Je(s.effectiveToUtc)&&(d.effectiveToUtc="Enter a valid end date and time.");const f=Je(s.effectiveFromUtc),h=Je(s.effectiveToUtc);if(f&&h&&new Date(h).getTime()<=new Date(f).getTime()&&(d.effectiveToUtc="End date must be after the start date."),s.metadataJson.trim())try{JSON.parse(s.metadataJson)}catch{d.metadataJson="Metadata must be valid JSON."}Object.keys(d).length>0&&(o[s.consentTemplateKey]=d)}),{errors:o})}const ut={schedule:{defaultDurationMinutes:"30",bufferBeforeMinutes:"0",bufferAfterMinutes:"0",minAdvanceMinutes:"60",maxAdvanceDays:"30"},availability:{isPublicBookable:!0,supportsScheduled:!0,supportsOnDemand:!1,isNewPatientAllowed:!0,isExistingPatientAllowed:!0}
1,workflow:{requiresProviderApprovalByDefault:!1,autoAcceptBookingsByDefault:!0,requiresConsentBeforeJoin:!1,requiresCheckInForm:!1},pricing:{selfPayPrice:"",currencyCode:"USD"}};function ir(t){return t?{code:t.code,displayName:t.displayName,description:t.description??"",defaultDurationMinutes:String(t.defaultDurationMinutes),bufferBeforeMinutes:String(t.bufferBeforeMinutes),bufferAfterMinutes:String(t.bufferAfterMinutes),minAdvanceMinutes:String(t.minAdvanceMinutes),maxAdvanceDays:String(t.maxAdvanceDays),isPublicBookable:t.isPublicBookable,supportsScheduled:t.supportsScheduled,supportsOnDemand:t.supportsOnDemand,requiresProviderApprovalByDefault:t.requiresProviderApprovalByDefault,autoAcceptBookingsByDefault:t.requiresProviderApprovalByDefault?!1:t.autoAcceptBookingsByDefault,isNewPatientAllowed:t.isNewPatientAllowed,isExistingPatientAllowed:t.isExistingPatientAllowed,requiresConsentBeforeJoin:t.requiresConsentBeforeJoin,requiresCheckInForm:t.requiresCheckInForm,selfPayPrice:t.selfPayPrice==null?"":String(t.selfPayPrice),currencyCode:t.currencyCode||"USD"}:{code:"",displayName:"",description:"",defaultDurationMinutes:"",bufferBeforeMinutes:"",bufferAfterMinutes:"",minAdvanceMinutes:"",maxAdvanceDays:"",isPublicBookable:!1,supportsScheduled:!1,supportsOnDemand:!1,requiresProviderApprovalByDefault:!1,autoAcceptBookingsByDefault:!1,isNewPatientAllowed:!1,isExistingPatientAllowed:!1,requiresConsentBeforeJoin:!1,requiresCheckInForm:!1,selfPayPrice:"",currencyCode:""}}function ci(t){const i={},o=/^[a-z0-9]+(?:_[a-z0-9]+)*$/;if(t.displayName.trim()||(i.displayName="Name is required."),t.code.trim()?o.test(t.code.trim())||(i.code="Use lowercase letters, numbers, and underscores."):i.code="Code is required.",[["defaultDurationMinutes","Duration",1],["bufferBeforeMinutes","Buffer before",0],["bufferAfterMinutes","Buffer after",0],["minAdvanceMinutes","Minimum notice",0],["maxAdvanceDays","Advance window",1]].forEach(([d,f,h])=>{if(!String(t[d]).trim()){i[d]=`${f} is required.`;return}const y=Number(t[d]);(!Number.isInteger(y)||y<h)&&(i[d]=`${f} must be a whole number of ${h} or more.`)}),!t.supportsScheduled&&!t.supportsOnDemand&&(i.supportsScheduled="Enable at least one visit mode."),!t.isNewPatientAllowed&&!t.isExistingPatientAllowed&&(i.isNewPatientAllowed="Allow at least one patient type."),t.requiresProviderApprovalByDefault===t.autoAcceptBookingsByDefault&&(i.requiresProviderApprovalByDefault="Choose how eligible bookings are handled."),t.selfPayPrice.trim()){const d=Number(t.selfPayPrice);(!Number.isFinite(d)||d<0)&&(i.selfPayPrice="Enter a valid non-negative price.")}return t.currencyCode||(i.currencyCode="Choose a currency."),i}function Tt(t){const i=Number(t);return Number.isFinite(i)?i:0}function nt({icon:t,title:i,description:o,children:s,onApplyRecommendation:d,recommendationDisabled:f=!1}){return e.jsxs(ie,{variant:"outlined",sx:h=>({overflow:"hidden",borderRadius:3,borderColor:M(h.palette.text.primary,.1),boxShadow:`0 1px 2px ${M(h.palette.common.black,.03)}`}),children:[e.jsx(r,{sx:{px:{xs:2,sm:2.5},py:2.25},children:e.jsxs(p,{direction:{xs:"column",sm:"row"},spacing:1.5,sx:{alignItems:{xs:"stretch",sm:"center"},justifyContent:"space-between"},children:[e.jsxs(p,{direction:"row",spacing:1.5,sx:{alignItems:"flex-start",minWidth:0},children:[e.jsx(r,{sx:{display:"grid",placeItems:"center",width:38,height:38,flexShrink:0,borderRadius:2,color:"text.secondary"},children:t}),e.jsxs(r,{sx:{minWidth:0},children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:750},children:i}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.25,lineHeight:1.5},children:o})]})]}),d&&e.jsx(H,{type:"button",size:"small",variant:"outlined",startIcon:e.jsx(yi,{fontSize:"small"}),onClick:d,disabled:f,sx:{flexShrink:0,alignSelf:{sm:"flex-start"}},children:"Use recommended"})]})}),e.jsx(me,{}),e.jsx(r,{sx:{p:{xs:2,sm:2.5}},children:s})]})}function Ue({checked:t,title:i,description:o,onChange:s,disabled:d=!1,error:f=!1}){return e.jsx(ft,{disabled:d,labelPlacement:"start",control:e.jsx(gt,{checked:t,onChange:(h,y)=>s(y),slotProps:{input:{"aria-label":i}}}),label:e.jsxs(r,{sx:{minWidth:0,pr:1.5},children:[e.jsx(l,{variant:"body2",sx:{fontWeight:700,color:"text.primary"},children:i}
1),e.jsx(l,{variant:"caption",color:"text.secondary",sx:{display:"block",mt:.35,lineHeight:1.45},children:o})]}),sx:h=>({width:"100%",minHeight:76,m:0,px:1.75,py:1.25,gap:1,justifyContent:"space-between",alignItems:"center",border:"1px solid",borderColor:f?h.palette.error.main:t?M(h.palette.primary.main,.5):M(h.palette.text.primary,.1),borderRadius:2.5,bgcolor:t?M(h.palette.primary.main,.045):h.palette.background.paper,transition:h.transitions.create(["border-color","background-color","box-shadow"],{duration:h.transitions.duration.shorter}),"&:hover":d?void 0:{borderColor:t?h.palette.primary.main:M(h.palette.text.primary,.22),boxShadow:`0 4px 14px ${M(h.palette.common.black,.045)}`},"& .MuiFormControlLabel-label":{flex:1},"&.Mui-disabled":{opacity:.62}})})}function pt({checked:t,label:i,description:o,onChange:s,disabled:d=!1}){return e.jsx(ft,{disabled:d,labelPlacement:"start",control:e.jsx(gt,{checked:t,onChange:(f,h)=>s(h),slotProps:{input:{"aria-label":i}}}),label:e.jsxs(r,{sx:{pr:1.5},children:[e.jsx(l,{variant:"body2",sx:{fontWeight:700},children:i}),e.jsx(l,{variant:"caption",color:"text.secondary",children:o})]}),sx:f=>({width:"100%",m:0,px:1.5,py:1.1,minHeight:66,justifyContent:"space-between",border:"1px solid",borderColor:t?M(f.palette.primary.main,.4):M(f.palette.text.primary,.1),borderRadius:2,bgcolor:t?M(f.palette.primary.main,.035):f.palette.background.paper,"& .MuiFormControlLabel-label":{flex:1}})})}function Ne({label:t,value:i}){return e.jsxs(p,{direction:"row",spacing:2,sx:{justifyContent:"space-between",alignItems:"flex-start"},children:[e.jsx(l,{variant:"body2",color:"text.secondary",children:t}),e.jsx(l,{variant:"body2",sx:{fontWeight:700,textAlign:"right",maxWidth:"60%"},children:i})]})}function nr({mode:t,value:i,selectedFacilityId:o,saving:s,error:d,consentTemplates:f,consentTemplatesLoading:h,consentTemplatesError:y,consentRequirements:B,consentRequirementsLoading:C,onRetryConsentTemplates:g,onDismissError:w,onBack:a,onSave:W}){const G=c.useMemo(()=>ir(t==="edit"?i:null),[t,i]),J=c.useMemo(()=>tr(B),[B]),[u,j]=c.useState(G),[E,q]=c.useState(J),[v,$]=c.useState({}),[z,b]=c.useState({}),[I,K]=c.useState(),[V,Y]=c.useState(!1);c.useEffect(()=>{j(G),$({}),Y(!1)},[G]),c.useEffect(()=>{q(J),b({}),K(void 0)},[J]);const Q=c.useMemo(()=>{const n=f.map(Xo).filter(A=>A!==null),S=new Set(n.map(A=>A.key)),T=E.filter(A=>!S.has(A.consentTemplateKey)).map(A=>({key:A.consentTemplateKey,label:A.consentTemplateKey,languageCode:A.languageCode||"en-US",unavailable:!0}));return[...n,...T].sort((A,N)=>A.label.localeCompare(N.label))},[E,f]),ne=c.useMemo(()=>{const n=new Map(Q.map(S=>[S.key,S]));return E.map(S=>n.get(S.consentTemplateKey)).filter(S=>!!S)},[Q,E]),de=c.useMemo(()=>ci(u),[u]),P=c.useMemo(()=>li(u.requiresConsentBeforeJoin,E),[E,u.requiresConsentBeforeJoin]),U=!ri(de)&&!P.selectionError&&Object.keys(P.errors).length===0,se=c.useMemo(()=>Yo(u,G)||ai(E)!==ai(J),[E,u,J,G]),Z=!s&&!C&&U&&(t==="create"||se),ee=Tt(u.defaultDurationMinutes),xe=ee+Tt(u.bufferBeforeMinutes)+Tt(u.bufferAfterMinutes),X=Object.keys(z).reduce((n,S)=>n+Object.keys(z[S]??{}).length,0),te=Object.keys(v).filter(n=>!!v[n]).length+X+(I?1:0),He=[u.supportsScheduled?"Scheduled":null,u.supportsOnDemand?"On-demand":null].filter(Boolean),R=[u.isNewPatientAllowed?"New":null,u.isExistingPatientAllowed?"Existing":null].filter(Boolean),Pe=u.requiresProviderApprovalByDefault?"provider-approval":u.autoAcceptBookingsByDefault?"automatic":null,fe=c.useMemo(()=>{if(!u.selfPayPrice.trim())return null;const n=Number(u.selfPayPrice);if(!Number.isFinite(n))return null;if(!u.currencyCode)return n.toFixed(2);try{return new Intl.NumberFormat("en-US",{style:"currency",currency:u.currencyCode}).format(n)}catch{return`${u.currencyCode} ${n.toFixed(2)}`}},[u.currencyCode,u.selfPayPrice]),oe=(n,S)=>{j(T=>({...T,[n]:S})),$(T=>({...T,[n]:void 0}))},Me=n=>{j(S=>({...S,...n})),$(S=>{const T={...S};return Object.keys(n).forEach(A=>{delete T[A]}),T})};function ze(n){return n.trim().toLowerCase().normalize("NFKD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,"")}const je=n=>{j(S=>
1({...S,requiresProviderApprovalByDefault:n==="provider-approval",autoAcceptBookingsByDefault:n==="automatic"})),$(S=>({...S,requiresProviderApprovalByDefault:void 0,autoAcceptBookingsByDefault:void 0}))},m=n=>{q(S=>{const T=new Map(S.map(N=>[N.consentTemplateKey,N]));let A=S.reduce((N,F)=>Math.max(N,F.displayOrder),0)+1;return n.map(N=>{const F=T.get(N.key);if(F)return F;const Re={consentTemplateKey:N.key,languageCode:N.languageCode||"en-US",isEnabled:!0,isRequiredBeforeJoin:!0,appliesToNewPatients:!0,appliesToExistingPatients:!0,displayOrder:A,effectiveFromUtc:"",effectiveToUtc:"",metadataJson:"",rowVersion:null};return A+=1,Re})}),K(void 0)},O=(n,S)=>{q(T=>T.map(A=>A.consentTemplateKey===n?{...A,...S}:A)),b(T=>{if(!T[n])return T;const A={...T};return delete A[n],A})},ae=n=>{q(S=>S.filter(T=>T.consentTemplateKey!==n)),b(S=>{const T={...S};return delete T[n],T})},pe=()=>{j(G),q(J),$({}),b({}),K(void 0),Y(!1)},ve=async()=>{if(s)return;const n=ci(u),S=li(u.requiresConsentBeforeJoin,E);if($(n),b(S.errors),K(S.selectionError),Y(!0),ri(n)||S.selectionError||Object.keys(S.errors).length>0){window.scrollTo({top:0,behavior:"smooth"});return}if(t==="edit"&&!se)return;const T={facilityId:(i==null?void 0:i.facilityId)??o??null,code:u.code.trim(),displayName:u.displayName.trim(),description:u.description.trim(),defaultDurationMinutes:Number(u.defaultDurationMinutes),bufferBeforeMinutes:Number(u.bufferBeforeMinutes),bufferAfterMinutes:Number(u.bufferAfterMinutes),minAdvanceMinutes:Number(u.minAdvanceMinutes),maxAdvanceDays:Number(u.maxAdvanceDays),isPublicBookable:u.isPublicBookable,supportsScheduled:u.supportsScheduled,supportsOnDemand:u.supportsOnDemand,requiresProviderApprovalByDefault:u.requiresProviderApprovalByDefault,autoAcceptBookingsByDefault:u.requiresProviderApprovalByDefault?!1:u.autoAcceptBookingsByDefault,isNewPatientAllowed:u.isNewPatientAllowed,isExistingPatientAllowed:u.isExistingPatientAllowed,requiresConsentBeforeJoin:u.requiresConsentBeforeJoin,requiresCheckInForm:u.requiresCheckInForm,selfPayPrice:u.selfPayPrice.trim()?Number(u.selfPayPrice):null,currencyCode:u.currencyCode,metadata:(i==null?void 0:i.metadata)??null,rowVersion:(i==null?void 0:i.rowVersion)??null},A={requirements:u.requiresConsentBeforeJoin?[...E].sort((N,F)=>N.displayOrder-F.displayOrder).map(N=>({consentTemplateKey:N.consentTemplateKey,languageCode:N.languageCode.trim(),isEnabled:N.isEnabled,isRequiredBeforeJoin:N.isRequiredBeforeJoin,appliesToNewPatients:N.appliesToNewPatients,appliesToExistingPatients:N.appliesToExistingPatients,displayOrder:N.displayOrder,effectiveFromUtc:Je(N.effectiveFromUtc),effectiveToUtc:Je(N.effectiveToUtc),metadata:N.metadataJson.trim()?JSON.parse(N.metadataJson):null,rowVersion:N.rowVersion??null})):[]};await W(T,A)};return e.jsxs(r,{component:"form",noValidate:!0,onSubmit:n=>{n.preventDefault(),ve()},sx:{minHeight:"calc(100vh - 64px)"},children:[e.jsx(ie,{square:!0,elevation:0,sx:n=>({position:"sticky",top:0,zIndex:n.zIndex.appBar,borderBottom:"1px solid",borderColor:M(n.palette.text.primary,.1),bgcolor:M(n.palette.background.paper,.96),backdropFilter:"blur(12px)"}),children:e.jsx(r,{sx:{px:{xs:1.5,sm:3},py:1.5},children:e.jsxs(p,{direction:"row",spacing:1.5,sx:{alignItems:"center"},children:[e.jsx(we,{title:"Back",children:e.jsx(ke,{"aria-label":"Back",color:"inherit",onClick:a,children:e.jsx(yt,{})})}),e.jsxs(r,{sx:{flex:1,minWidth:0},children:[e.jsx(p,{direction:"row",spacing:1,sx:{alignItems:"center"},children:e.jsx(l,{variant:"h6",sx:{fontWeight:800},noWrap:!0,children:t==="create"?"Create visit type":"Edit visit type"})}),e.jsx(l,{variant:"caption",color:"text.secondary",children:t==="create"?"Configure the patient booking experience and clinical workflow.":i==null?void 0:i.displayName})]}),e.jsx(H,{color:"inherit",startIcon:e.jsx(xt,{}),onClick:pe,disabled:s||!se,sx:{display:{xs:"none",sm:"inline-flex"}},children:"Reset"}),e.jsx(H,{type:"submit",variant:"contained",disableElevation:!0,startIcon:e.jsx(lt,{}),disabled:!Z,sx:{display:{xs:"none",sm:"inline-flex"}},children:s?"Saving…":t==="create"?"Create visit type":"Save changes"})]})})}),e.jsx(r,{sx:{px:{xs:1.5,sm:3},py:{xs:2,sm:3},pb:{xs:11,sm:4}},children:e.jsxs(p,{spacing:2,children:[d&&e.jsx(ce,{severity:"error",onClose:w,children:d}),V&&te>0&&e.jsxs(ce,{severity:"warning",children:["Review ",te," highlighted ",te===1?"field":"fields"," before saving."]}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",lg:"minmax(0, 1fr) 320px"},gap:{xs:2,lg:3},alignItems:"start"},children:[e.jsxs(p,{spacing:2.25,children:[e.jsx(nt,{icon:e.jsx(Fn,{fontSize:"small"}),title:"Visit identity",description:"Set the patient-facing name and the stable internal identifier used by your team.",recommendationDisabled:s,children:e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"1.25fr 0.75fr"},gap:2},children:[e.jsx(D,{label:"Visit type name",placeholder:"Example: Initial virtual consultation",value:u.displayName,onChange:n=>{const S=n.target.value;j(T=>({...T,displayName:S,code:t==="create"?ze(S):T.code})),$(T=>({...T,displayName:void 0,...t==="create"?{code:void 0}:{}}))},error:!!v.displayName,helperText:v.displayName||"",required:!0,fullWidth:!0,slotProps:{inputLabel:{shrink:!0}}}
1),e.jsx(D,{label:"Internal code",placeholder:"initial_consultation",value:u.code,onChange:n=>oe("code",n.target.value.toLowerCase().replace(/\s+/g,"_")),error:!!v.code,helperText:v.code||"",required:!0,disabled:t==="edit",fullWidth:!0,slotProps:{inputLabel:{shrink:!0},input:{endAdornment:t==="create"?e.jsx(he,{position:"end",children:e.jsx(we,{title:"Sync code from visit type name",children:e.jsx(ke,{edge:"end",size:"small","aria-label":"Sync internal code from visit type name",onClick:()=>oe("code",ze(u.displayName)),disabled:!u.displayName.trim(),children:e.jsx(wi,{fontSize:"small"})})})}):void 0}}}),e.jsx(D,{label:"Visit type description",placeholder:"Explain what this visit is for and what the patient should expect.",value:u.description,onChange:n=>oe("description",n.target.value),multiline:!0,minRows:3,fullWidth:!0,slotProps:{inputLabel:{shrink:!0},htmlInput:{maxLength:500}},helperText:`${u.description.length}/500 characters`,sx:{gridColumn:{md:"1 / -1"},mt:2}})]})}),e.jsx(nt,{icon:e.jsx(mn,{}),title:"Schedule and booking window",description:"Define the calendar footprint and how far in advance patients can book.",onApplyRecommendation:t==="create"?()=>Me(ut.schedule):void 0,recommendationDisabled:s,children:e.jsxs(p,{spacing:2.5,children:[e.jsxs(r,{children:[e.jsx(l,{variant:"body2",sx:{fontWeight:750,mb:1.75},children:"Calendar footprint "}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"repeat(3, minmax(0, 1fr))"},gap:1.5},children:[e.jsx(D,{label:"Visit duration",type:"number",value:u.defaultDurationMinutes,onChange:n=>oe("defaultDurationMinutes",n.target.value),error:!!v.defaultDurationMinutes,helperText:v.defaultDurationMinutes,slotProps:{inputLabel:{shrink:!0},htmlInput:{min:1},input:{endAdornment:e.jsx(he,{position:"end",children:"min"})}}}),e.jsx(D,{label:"Buffer before",type:"number",value:u.bufferBeforeMinutes,onChange:n=>oe("bufferBeforeMinutes",n.target.value),error:!!v.bufferBeforeMinutes,helperText:v.bufferBeforeMinutes,slotProps:{inputLabel:{shrink:!0},htmlInput:{min:0},input:{endAdornment:e.jsx(he,{position:"end",children:"min"})}}}),e.jsx(D,{label:"Buffer after",type:"number",value:u.bufferAfterMinutes,onChange:n=>oe("bufferAfterMinutes",n.target.value),error:!!v.bufferAfterMinutes,helperText:v.bufferAfterMinutes,slotProps:{inputLabel:{shrink:!0},htmlInput:{min:0},input:{endAdornment:e.jsx(he,{position:"end",children:"min"})}}})]}),e.jsx(r,{sx:n=>({mt:1.5,px:1.5,py:1.25,borderRadius:2,bgcolor:M(n.palette.info.main,.07),border:"1px solid",borderColor:M(n.palette.info.main,.18)}),children:e.jsxs(l,{variant:"body2",color:"text.secondary",children:["Each booking reserves"," ",e.jsxs(r,{component:"span",sx:{color:"text.primary",fontWeight:750},children:[xe," minutes"]})," ","on the provider calendar, including buffers."]})})]}),e.jsxs(r,{children:[e.jsx(l,{variant:"body2",sx:{fontWeight:750,my:1.75},children:"Booking window "}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1.5},children:[e.jsx(D,{label:"Minimum booking notice",type:"number",value:u.minAdvanceMinutes,onChange:n=>oe("minAdvanceMinutes",n.target.value),error:!!v.minAdvanceMinutes,helperText:v.minAdvanceMinutes||"How soon a patient can book.",slotProps:{inputLabel:{shrink:!0},htmlInput:{min:0},input:{endAdornment:e.jsx(he,{position:"end",children:"min"})}}}),e.jsx(D,{label:"Maximum advance booking",type:"number",value:u.maxAdvanceDays,onChange:n=>oe("maxAdvanceDays",n.target.value),error:!!v.maxAdvanceDays,helperText:v.maxAdvanceDays||"How far into the future patients can book.",slotProps:{inputLabel:{shrink:!0},htmlInput:{min:1},input:{endAdornment:e.jsx(he,{position:"end",children:"days"})}}})]})]})]})}),e.jsx(nt,{icon:e.jsx(ji,{fontSize:"small"}),title:"Booking availability",description:"Choose where this visit appears, how it can be requested, and who can book it.",onApplyRecommendation:t==="create"?()=>Me(ut.availability):void 0,recommendationDisabled:s,children:e.jsxs(p,{spacing:2.5,children:[e.jsxs(r,{children:[e.jsx(l,{variant:"body2",sx:{fontWeight:750,mb:1.25},children:"Patient visibility "}),e.jsx(Ue,{checked:u.isPublicBookable,onChange:n=>oe("isPublicBookable",n),title:"Publicly bookable",description:"Show this visit in patient self-scheduling experiences. Turn this off for staff-only booking."})]}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"1fr 1fr"},gap:2.5},children:[e.jsxs(r,{children:[e.jsx(l,{variant:"body2",sx:{fontWeight:750,mb:1.25},children:"Visit modes "}),e.jsxs(p,{spacing:1.25,children:[e.jsx(Ue,{checked:u.supportsScheduled,onChange:n=>oe("supportsScheduled",n),title:"Scheduled appointments",description:"Patients choose an available date and time.",error:!!v.supportsScheduled}),e.jsx(Ue,{checked:u.supportsOnDemand,onChange:n=>oe("supportsOnDemand",n),title:"On-demand visits",description:"Patients request care without selecting a future time.",error:!!v.supportsScheduled}),v.supportsScheduled&&e.jsx(l,{variant:"caption",color:"error.main",children:v.supportsScheduled})]})]}),e.jsxs(r,{children:[e.jsx(l,{variant:"body2",sx:{fontWeight:750,mb:1.25},children:"Patient eligibility "}),e.jsxs(p,{spacing:1.25,children:[e.jsx(Ue,{checked:u.isNewPatientAllowed,onChange:n=>oe("isNewPatientAllowed",n),title:"New patients",description:"Allow patients without an existing relationship to book.",error:!!v.isNewPatientAllowed}),e.jsx(Ue,{checked:u.isExistingPatientAllowed,onChange:n=>oe("isExistingPatientAllowed",n),title:"Existing patients",description:"Allow established patients to book this visit.",error:!!v.isNewPatientAllowed}),v.isNewPatientAllowed&&e.jsx(l,{variant:"caption",color:"error.main",children:v.isNewPatientAllowed})]})]})]})]})}),e.jsx(nt,{icon:e.jsx(Jn,{fontSize:"small"}),title:"Clinical workflow",description:"Configure approval rules and the steps patients must complete before joining.",onApplyRecommendation:t==="create"?()=>Me(ut.workflow):void 0,recommendationDisabled:s,children:e.jsxs(p,{spacing:2.5,children:[e.jsxs(r,{children:[e.jsx(l,{variant:"body2",sx:{fontWeight:750,mb:1.25},children:"Booking approval"}),e.jsxs(gn,{exclusive:!0,fullWidth:!0,value:Pe,onChange:(n,S)=>{S&&je(S)},"aria-label":"Booking approval behavior",sx:n=>
1({gap:1,p:.75,border:"1px solid",borderColor:v.requiresProviderApprovalByDefault?n.palette.error.main:M(n.palette.text.primary,.14),borderRadius:2.5,bgcolor:M(n.palette.text.primary,.035),"& .MuiToggleButtonGroup-grouped":{flex:1,minHeight:54,m:0,border:"1px solid transparent",borderRadius:"10px !important",color:n.palette.text.secondary,fontWeight:700,textTransform:"none",transition:n.transitions.create(["background-color","border-color","box-shadow","color"]),"&:not(:first-of-type)":{borderLeft:"1px solid transparent"},"&:hover":{bgcolor:n.palette.background.paper},"&.Mui-selected":{color:n.palette.primary.main,bgcolor:n.palette.background.paper,borderColor:M(n.palette.primary.main,.7),boxShadow:`0 2px 5px ${M(n.palette.common.black,.14)}`,"&:hover":{bgcolor:n.palette.background.paper}}}}),children:[e.jsx(we,{title:"Bookings remain pending until a provider accepts them.",children:e.jsx(Kt,{value:"provider-approval","aria-label":"Require provider approval",children:"Require provider approval"})}),e.jsx(we,{title:"Confirm eligible bookings immediately without manual review.",children:e.jsx(Kt,{value:"automatic","aria-label":"Automatically accept bookings",children:"Automatically accept"})})]}),v.requiresProviderApprovalByDefault&&e.jsx(l,{variant:"caption",color:"error.main",sx:{display:"block",mt:.75},children:v.requiresProviderApprovalByDefault})]}),e.jsx(me,{}),e.jsxs(r,{children:[e.jsx(l,{variant:"body2",sx:{fontWeight:750,mb:1.25},children:"Pre-visit requirements "}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1.25},children:[e.jsx(Ue,{checked:u.requiresConsentBeforeJoin,onChange:n=>{oe("requiresConsentBeforeJoin",n),K(void 0),b({})},title:"Require consent",description:"Patients must review and accept consent before joining."}),e.jsx(Ue,{checked:u.requiresCheckInForm,onChange:n=>oe("requiresCheckInForm",n),title:"Require check-in form",description:"Patients complete intake questions before entering the visit."})]})]}),u.requiresConsentBeforeJoin&&e.jsx(ie,{variant:"outlined",sx:n=>({p:{xs:1.5,sm:2},borderRadius:2.5,borderColor:I?n.palette.error.main:M(n.palette.primary.main,.22),bgcolor:M(n.palette.primary.main,.018)}),children:e.jsxs(p,{spacing:2,children:[e.jsxs(r,{children:[e.jsx(l,{variant:"subtitle2",sx:{fontWeight:800},children:"Consent templates"}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.35},children:"Select the documents patients must review. Configure each template only after it is selected."})]}),y&&e.jsx(ce,{severity:"warning",action:e.jsx(H,{color:"inherit",size:"small",onClick:g,children:"Retry"}),children:y}),e.jsx(fn,{multiple:!0,disableCloseOnSelect:!0,options:Q,value:ne,loading:h,isOptionEqualToValue:(n,S)=>n.key===S.key,getOptionLabel:n=>n.label,getOptionDisabled:n=>!!n.unavailable,onChange:(n,S)=>{m(S)},renderOption:(n,S)=>{const{key:T,...A}=n;return e.jsx(r,{component:"li",...A,children:e.jsxs(r,{sx:{minWidth:0},children:[e.jsx(l,{variant:"body2",sx:{fontWeight:700},children:S.label}),e.jsxs(l,{variant:"caption",color:"text.secondary",children:[S.key," · ",S.languageCode]})]})},T)},renderValue:(n,S)=>n.map((T,A)=>{const{key:N,...F}=S({index:A});return e.jsx(ue,{...F,size:"small",label:T.label},N??T.key)}),renderInput:n=>{var S;return e.jsx(D,{...n,label:"Search and select consents",placeholder:ne.length===0?"Search by consent name or key":void 0,error:!!I,helperText:I||"Only selected templates will be assigned to this visit type.",slotProps:{...n.slotProps,input:{...n.slotProps.input,endAdornment:e.jsxs(e.Fragment,{children:[h&&e.jsx($e,{color:"inherit",size:18,sx:{mr:1}}),(S=n.slotProps.input)==null?void 0:S.endAdornment]})},inputLabel:{shrink:!0}}})}}),C?e.jsxs(p,{direction:"row",spacing:1.25,sx:{alignItems:"center",py:2},children:[e.jsx($e,{size:20}),e.jsx(l,{variant:"body2",color:"text.secondary",children:"Loading assigned consent settings…"})]}):e.jsx(p,{spacing:1.25,children:[...E].sort((n,S)=>n.displayOrder-S.displayOrder).map((n,S)=>{const T=Q.find(F=>F.key===n.consentTemplateKey),A=z[n.consentTemplateKey]??{},N=[n.appliesToNewPatients?"New":null,n.appliesToExistingPatients?"Existing":null].filter(
1Boolean).join(" + ");return e.jsxs(Vt,{defaultExpanded:E.length===1,disableGutters:!0,elevation:0,sx:F=>({border:"1px solid",borderColor:Object.keys(A).length>0?F.palette.error.main:M(F.palette.text.primary,.12),borderRadius:"12px !important",overflow:"hidden","&:before":{display:"none"}}),children:[e.jsx(Nt,{expandIcon:e.jsx(Ot,{}),sx:{px:1.75,minHeight:68},children:e.jsxs(p,{direction:"row",spacing:1.25,sx:{flex:1,minWidth:0,alignItems:"center",pr:1},children:[e.jsx(ue,{size:"small",label:n.displayOrder||S+1,variant:"outlined"}),e.jsxs(r,{sx:{minWidth:0,flex:1},children:[e.jsx(l,{variant:"body2",sx:{fontWeight:800},noWrap:!0,children:(T==null?void 0:T.label)??n.consentTemplateKey}),e.jsxs(p,{direction:"row",sx:{gap:.75,mt:.5,flexWrap:"wrap"},children:[e.jsx(l,{variant:"caption",color:"text.secondary",children:n.languageCode||"No language"}),e.jsxs(l,{variant:"caption",color:"text.secondary",children:["• ",N||"No patient type"]}),e.jsxs(l,{variant:"caption",color:n.isEnabled?"success.main":"text.secondary",children:["• ",n.isEnabled?"Enabled":"Disabled"]})]})]}),e.jsx(we,{title:"Remove consent",children:e.jsx(ke,{size:"small","aria-label":`Remove ${(T==null?void 0:T.label)??n.consentTemplateKey}`,onClick:F=>{F.stopPropagation(),ae(n.consentTemplateKey)},children:e.jsx(Mt,{fontSize:"small"})})})]})}),e.jsxs(Lt,{sx:{px:{xs:1.5,sm:2},pt:0,pb:2},children:[e.jsx(me,{sx:{mb:2}}),e.jsxs(p,{spacing:2,children:[e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1fr) 150px"},gap:1.5},children:[e.jsx(D,{label:"Language code",value:n.languageCode,onChange:F=>O(n.consentTemplateKey,{languageCode:F.target.value}),error:!!A.languageCode,helperText:A.languageCode||"Example: en-US",required:!0}),e.jsx(D,{label:"Display order",type:"number",value:n.displayOrder,onChange:F=>O(n.consentTemplateKey,{displayOrder:Number(F.target.value)}),error:!!A.displayOrder,helperText:A.displayOrder,slotProps:{htmlInput:{min:1,step:1}},required:!0})]}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"1fr 1fr"},gap:1.25},children:[e.jsx(pt,{checked:n.isEnabled,label:"Enabled",description:"Make this requirement active for bookings.",onChange:F=>O(n.consentTemplateKey,{isEnabled:F})}),e.jsx(pt,{checked:n.isRequiredBeforeJoin,label:"Required before join",description:"Block entry until the consent is accepted.",onChange:F=>O(n.consentTemplateKey,{isRequiredBeforeJoin:F})}),e.jsx(pt,{checked:n.appliesToNewPatients,label:"New patients",description:"Apply this consent to first-time patients.",onChange:F=>O(n.consentTemplateKey,{appliesToNewPatients:F})}),e.jsx(pt,{checked:n.appliesToExistingPatients,label:"Existing patients",description:"Apply this consent to returning patients.",onChange:F=>O(n.consentTemplateKey,{appliesToExistingPatients:F})})]}),A.patientApplicability&&e.jsx(ce,{severity:"error",children:A.patientApplicability})]})]})]},n.consentTemplateKey)})})]})})]})}),e.jsx(nt,{icon:e.jsx(oo,{fontSize:"small"}),title:"Self-pay pricing",description:"Optionally show a clear out-of-pocket price to patients during booking.",onApplyRecommendation:t==="create"?()=>Me(ut.pricing):void 0,recommendationDisabled:s,children:e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 2fr) minmax(140px, 1fr)"},gap:1.5,maxWidth:600},children:[e.jsx(D,{label:"Self-pay price",type:"number",value:u.selfPayPrice,onChange:n=>oe("selfPayPrice",n.target.value),error:!!v.selfPayPrice,helperText:v.selfPayPrice||"Leave empty when pricing is not shown or does not apply.",slotProps:{inputLabel:{shrink:!0},htmlInput:{min:0,step:.01},input:{startAdornment:u.currencyCode?e.jsx(he,{position:"start",children:u.currencyCode}):void 0}}}),e.jsxs(D,{select:!0,label:"Currency",value:u.currencyCode,onChange:n=>oe("currencyCode",n.target.value),error:!!v.currencyCode,helperText:v.currencyCode,required:!0,slotProps:{inputLabel:{shrink:!0}},children:[e.jsx(ge,{value:"",children:e.jsx("em",{children:"Select currency"})}),Zo.map(n=>e.jsx(ge,{value:n,children:n},n))]})]})})]}),e.jsxs(p,{spacing:2,sx:{position:{lg:"sticky"},top:{lg:96}},children:[e.jsx(ie,{variant:"outlined",sx:n=>({overflow:"hidden",borderRadius:3,borderColor:M(n.palette.primary.main,.22),boxShadow:`0 10px 32px ${M(n.palette.primary.main,.07)}`}),children:e.jsxs(r,{sx:n=>({p:2.25,background:`linear-gradient(145deg, ${M(n.palette.primary.main,.11)}, ${M(n.palette.primary.main,.025)})`}),children:[e.jsxs(p,{direction:"row",spacing:1,sx:{justifyContent:"space-between",alignItems:"center"},children:[e.jsx(l,{variant:"overline",color:"primary.main",sx:{fontWeight:800},children:"Patient preview"}),e.jsx(ue,{size:"small",label:u.isPublicBookable?"Visible":"Staff only",color:u.isPublicBookable?"success":"default",variant:"outlined"})]}),e.jsx(l,{variant:"h6",sx:{mt:1.5,fontWeight:800},children:u.displayName.trim()||"Visit type name"}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.75,minHeight:42,lineHeight:1.5},children:u.description.trim()||"A short patient-friendly description will appear here."}),e.jsxs(p,{direction:"row",sx:{mt:2,gap:.75,flexWrap:"wrap"},children:[e.jsx(ue,{size:"small",label:`${ee||"—"} min`}),He.map(n=>e.jsx(ue,{size:"small",label:n},n)),fe&&e.jsx(ue,{size:"small",color:"primary",variant:"outlined",label:fe})]})]})}),e.jsxs(ie,{variant:"outlined",sx:n=>({p:2.25,borderRadius:3,borderColor:M(n.palette.text.primary,.1)}),children:[e.jsxs(p,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(Rt,{color:"success",fontSize:"small"}),e.jsx(l,{variant:"subtitle2",sx:{fontWeight:800},children:"Configuration summary"})]}),e.jsxs(p,{spacing:1.4,divider:e.jsx(me,{flexItem:!0}),sx:{mt:2}
1,children:[e.jsx(Ne,{label:"Internal code",value:u.code.trim()||"Not set"}),e.jsx(Ne,{label:"Calendar slot",value:u.defaultDurationMinutes.trim()?`${xe} min`:"Not set"}),e.jsx(Ne,{label:"Visit modes",value:He.join(", ")||"None selected"}),e.jsx(Ne,{label:"Patients",value:R.join(" and ")||"None selected"}),e.jsx(Ne,{label:"Approval",value:u.requiresProviderApprovalByDefault?"Provider review":u.autoAcceptBookingsByDefault?"Automatic":"Not selected"}),e.jsx(Ne,{label:"Pre-visit steps",value:[u.requiresConsentBeforeJoin?"Consent":null,u.requiresCheckInForm?"Check-in form":null].filter(Boolean).join(", ")||"None"}),u.requiresConsentBeforeJoin&&e.jsx(Ne,{label:"Assigned consents",value:C?"Loading…":`${E.length} selected`}),e.jsx(Ne,{label:"Self-pay",value:fe||"Not configured"})]})]})]})]})]})}),e.jsx(ie,{square:!0,elevation:8,sx:{display:{xs:"block",sm:"none"},position:"fixed",right:0,bottom:0,left:0,zIndex:n=>n.zIndex.appBar,px:1.5,py:1.25,borderTop:"1px solid",borderColor:"divider"},children:e.jsxs(p,{direction:"row",spacing:1,children:[e.jsx(we,{title:"Reset form",children:e.jsx("span",{children:e.jsx(ke,{"aria-label":"Reset form",onClick:pe,disabled:s||!se,sx:{border:"1px solid",borderColor:"divider"},children:e.jsx(xt,{})})})}),e.jsx(H,{type:"submit",fullWidth:!0,variant:"contained",disableElevation:!0,startIcon:e.jsx(lt,{}),disabled:!Z,children:s?"Saving…":t==="create"?"Create visit type":"Save changes"})]})})]})}function or(t){return t.trim().toLocaleLowerCase()}function rr({values:t,loading:i,error:o,search:s,statusFilter:d,onSearchChange:f,onCreate:h,onEdit:y,onRetry:B}){const[C,g]=c.useState(!1);return c.useEffect(()=>{C!==!1&&!t.some(w=>w.templateId===C)&&g(!1)},[C,t]),e.jsxs(r,{sx:{width:"100%",px:{xs:0,sm:1.5}},children:[e.jsxs(p,{direction:{xs:"column",sm:"row"},spacing:2,sx:{mb:3,justifyContent:"space-between",alignItems:{sm:"center"}},children:[e.jsxs(r,{children:[e.jsx(l,{variant:"h6",sx:{fontWeight:750},children:"Consent templates"}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.5},children:"Manage the legal language patients review before joining a telehealth visit."})]}),e.jsx(H,{variant:"contained",disableElevation:!0,startIcon:e.jsx(mt,{}),onClick:h,sx:{alignSelf:{xs:"flex-start",sm:"center"},borderRadius:2},children:"Create consent"})]}),e.jsx(r,{sx:{p:1.25,mb:2.25},children:e.jsx(D,{value:s,onChange:w=>f(w.target.value),placeholder:"Search title, key, language, or content",size:"small",fullWidth:!0,slotProps:{input:{startAdornment:e.jsx(he,{position:"start",children:e.jsx(fi,{fontSize:"small"})})}},sx:{flex:1,"& .MuiOutlinedInput-root":{borderRadius:2}}})}),o&&e.jsx(ce,{severity:"error",action:e.jsx(H,{color:"inherit",size:"small",startIcon:e.jsx(ht,{}),onClick:B,children:"Retry"}),sx:{mb:2,borderRadius:2},children:o}),i?e.jsx(r,{sx:{minHeight:280,display:"grid",placeItems:"center"},children:e.jsxs(p,{spacing:1.5,sx:{alignItems:"center"},children:[e.jsx($e,{size:32}),e.jsx(l,{variant:"body2",color:"text.secondary",children:"Loading consent templates…"})]})}):t.length===0?e.jsxs(r,{sx:{px:3,py:7,textAlign:"center",border:"1px dashed",borderColor:"divider",borderRadius:3,bgcolor:"background.paper"},children:[e.jsx(r,{sx:w=>({width:48,height:48,mx:"auto",mb:1.5,display:"grid",placeItems:"center",borderRadius:2.5,color:"primary.main",bgcolor:M(w.palette.primary.main,.08)}),children:e.jsx(bi,{})}),e.jsx(l,{variant:"subtitle1",sx:{fontWeight:700},children:s||d!=="all"?"No matching consent templates":"No consent templates yet"}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:.75},children:s||d!=="all"?"Adjust the search or status filter.":"Create the first reusable consent for your telehealth workflow."}),!s&&d==="all"&&e.jsx(H,{sx:{mt:2},startIcon:e.jsx(mt,{}),onClick:h,children:"Create consent"})]}):e.jsx(p,{sx:{border:"1px solid",borderColor:"divider",borderRadius:2,overflow:"hidden"},children:t.map((w,a)=>{const W=C===w.templateId,G=a===t.length-1,J=bn.sanitize(w.htmlBody??"");return e.jsxs(Vt,{expanded:W,onChange:(u,j)=>{g(j?w.templateId:!1)},disableGutters:!0,elevation:0,slotProps:{transition:{unmountOnExit:!0}},sx:u=>({borderBottom:G?0:"1px solid",borderColor:"divider",overflow:"hidden",bgcolor:W?M(u.palette.action.selected,.03):"background.default",transition:u.transitions.create(["border-color","box-shadow"]),boxShadow:W?`0 10px 30px ${M(u.palette.common.black,.08)}`:"none","&:before":{display:"none"}}),children:[e.jsx(Nt,{id:`consent-template-${w.templateId}-header`,"aria-controls":`consent-template-${w.templateId}-content`,expandIcon:e.jsx(Ot,{sx:{color:"text.secondary",fontSize:21}}),sx:{minWidth:0,px:{xs:1.5,sm:2.25},my:1,minHeight:42,"& .MuiAccordionSummary-content":{minWidth:0}},children:e.jsxs(p,{direction:{xs:"column",md:"row"},spacing:{xs:1.5,md:2.5},sx:{width:"100%",minWidth:0,alignItems:{xs:"flex-start",md:"center"},justifyContent:"space-between"},children:[e.jsxs(r,{sx:{minWidth:0},children:[e.jsxs(p,{direction:"row",spacing:1,useFlexGap:!0,sx:{flexWrap:"wrap",alignItems:"center"},children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:750,lineHeight:1.35},children:w.title||"Untitled consent"}),e.jsx(ue,{size:"small",icon:e.jsx(Gn,{sx:{fontSize:"10px !important"}}),label:w.isActive?"Active":"Inactive",color:w.isActive?"success":"default",variant:w.isActive?"f
1illed":"outlined",sx:{height:24}})]}),e.jsxs(p,{direction:"row",spacing:1.5,useFlexGap:!0,sx:{mt:.65,flexWrap:"wrap",color:"text.secondary"},children:[e.jsx(l,{variant:"caption",sx:{fontFamily:"monospace"},children:w.templateKey}),e.jsxs(l,{variant:"caption",children:["Version ",w.versionNo]}),e.jsxs(p,{direction:"row",spacing:.5,sx:{alignItems:"center"},children:[e.jsx(lo,{sx:{fontSize:15}}),e.jsx(l,{variant:"caption",children:w.languageCode})]})]})]}),e.jsxs(p,{direction:"row",spacing:.75,useFlexGap:!0,sx:{pr:{md:1},flexWrap:"wrap",alignItems:"center"},children:[w.requiresSignature&&e.jsx(we,{title:"Signature required",children:e.jsx(ue,{size:"small",icon:e.jsx(_n,{}),label:"Signature",variant:"outlined"})}),w.requiresRecordingConsent&&e.jsx(we,{title:"Recording consent required",children:e.jsx(ue,{size:"small",icon:e.jsx(yn,{}),label:"Recording",variant:"outlined"})})]})]})}),e.jsx(Lt,{id:`consent-template-${w.templateId}-content`,sx:{px:{xs:1.5,sm:2.25},pb:2.5},children:e.jsxs(p,{spacing:2,children:[e.jsxs(p,{direction:{xs:"column",sm:"row"},spacing:1,sx:{alignItems:{xs:"flex-start",sm:"flex-end"},justifyContent:"space-between"},children:[e.jsx(l,{variant:"caption",color:"text.secondary",sx:{fontWeight:700,letterSpacing:.25},children:"PATIENT PREVIEW"}),e.jsx(H,{size:"small",variant:"outlined",startIcon:e.jsx(At,{}),onClick:()=>y(w),sx:{borderRadius:1.5,whiteSpace:"nowrap",bgcolor:"background.default"},children:"Edit configuration"})]}),e.jsx(ie,{variant:"outlined",sx:{mt:.75,p:2,maxHeight:220,overflow:"auto",borderRadius:2,bgcolor:"background.paper",whiteSpace:"pre-wrap"},children:w.htmlBody?e.jsx(r,{sx:{px:2,lineHeight:1.7,fontSize:"0.875rem"},dangerouslySetInnerHTML:{__html:J}}):e.jsx(l,{variant:"body2",color:"text.secondary",children:"No preview is available."})})]})})]},w.templateId)})})]})}function sr({values:t,loading:i,error:o,onCreate:s,onEdit:d,onRetry:f}){const[h,y]=c.useState(""),[B,C]=c.useState("all"),g=c.useMemo(()=>{const w=or(h);return t.filter(a=>B==="active"&&!a.isActive||B==="inactive"&&a.isActive?!1:w?[a.title,a.templateKey,a.languageCode,a.plainTextBody].some(W=>(W??"").toLocaleLowerCase().includes(w)):!0)},[h,B,t]);return e.jsx(rr,{values:g,loading:i,error:o,search:h,statusFilter:B,onSearchChange:y,onStatusFilterChange:C,onCreate:s,onEdit:d,onRetry:f})}const ar=[{value:"en-US",label:"English (United States)"},{value:"es-US",label:"Spanish (United States)"},{value:"en-GB",label:"English (United Kingdom)"},{value:"fr-CA",label:"French (Canada)"}],di="<p></p>";function Et(t){return t.trim().toUpperCase().replace(/[^A-Z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,100)}function Ge(t){return t?typeof DOMParser<"u"?(new DOMParser().parseFromString(t,"text/html").body.textContent??"").replace(/\u00a0/g," ").replace(/[ \t]+\n/g,`
2`).replace(/\n{3,}/g,`
3
4`).trim():t.replace(/<br\s*\/?\s*>/gi,`
5`).replace(/<\/p>/gi,`
6
7`).replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim():""}function lr(t){return{templateKey:(t==null?void 0:t.templateKey)??"",title:(t==null?void 0:t.title)??"",languageCode:(t==null?void 0:t.languageCode)??"en-US",htmlBody:(t==null?void 0:t.htmlBody)||di,plainTextBody:Ge((t==null?void 0:t.htmlBody)||di),requiresSignature:(t==null?void 0:t.requiresSignature)??!0,requiresRecordingConsent:(t==null?void 0:t.requiresRecordingConsent)??!1}}function ui(t){const i={},o=t.templateKey.trim(),s=t.title.trim(),d=t.languageCode.trim(),f=Ge(t.htmlBody);return o?/^[A-Z0-9][A-Z0-9._-]{2,99}$/.test(o)||(i.templateKey="Use 3–100 uppercase letters, numbers, dots, underscores, or hyphens."):i.templateKey="Template key is required.",s?s.length>160&&(i.title="Title must be 160 characters or fewer."):i.title="Title is required.",d?/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/.test(d)||(i.languageCode="Enter a valid language code such as en-US."):i.languageCode="Language is required.",f||(i.htmlBody="Consent content is required."),i}function cr({mode:t,value:i,saving:o,error:s,onDismissError:d,onBack:f,onSave:h}){const y=c.useMemo(()=>lr(i),[i]),B=c.useRef(null),[C,g]=c.useState(y),[w,a]=c.useState(!1),[W,G]=c.useState(!1),[J,u]=c.useState({}),[j,E]=c.useState(()=>!i||i.templateKey===Et(i.title)),q=c.useMemo(()=>ui(C),[C]),v=c.useMemo(()=>JSON.stringify(C)!==JSON.stringify(y),[y,C]);c.useEffect(()=>{const P=U=>{!v||o||(U.preventDefault(),U.returnValue="")};return window.addEventListener("beforeunload",P),()=>window.removeEventListener("beforeunload",P)},[v,o]);const $=(P,U)=>{g(se=>({...se,[P]:U}))},z=P=>{u(U=>({...U,[P]:!0}))},b=P=>W||J[P]?q[P]:void 0,I=P=>{g(U=>({...U,title:P,...j?{templateKey:Et(P)}:{}}))},K=P=>{E(!1),$("templateKey",P.toUpperCase())},V=()=>{E(!0),$("templateKey",Et(C.title))},Y=P=>{g(U=>({...U,htmlBody:P,plainTextBody:Ge(P)}))},Q=async()=>{const P={...C,templateKey:C.templateKey.trim(),title:C.title.trim(),languageCode:C.languageCode.trim(),plainTextBody:Ge(C.htmlBody)},U=ui(P);if(G(!0),Object.keys(U).length>0)return;await h(P)&&g(P)},ne=()=>{if(v&&!o){a(!0);return}f()}
7,de=Ge(C.htmlBody).trim().split(/\s+/).filter(Boolean).length;return e.jsxs(r,{sx:{minHeight:"calc(100vh - 64px)",bgcolor:"background.default"},children:[e.jsx(qi,{position:"sticky",color:"inherit",elevation:0,sx:{borderBottom:"1px solid",borderColor:"divider"},children:e.jsxs(Ui,{sx:{gap:1.5},children:[e.jsx(ke,{onClick:ne,"aria-label":"Back to consent templates",children:e.jsx(yt,{})}),e.jsxs(r,{sx:{minWidth:0,flex:1},children:[e.jsxs(p,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(l,{variant:"h6",noWrap:!0,sx:{fontWeight:750},children:t==="create"?"Create consent":"Edit consent"}),v&&e.jsx(ue,{size:"small",label:"Unsaved",color:"warning",variant:"outlined"})]}),e.jsx(l,{variant:"caption",color:"text.secondary",noWrap:!0,children:"Create clear, accessible consent language for telehealth visits."})]}),e.jsx(H,{variant:"contained",disableElevation:!0,startIcon:o?e.jsx($e,{size:17,color:"inherit"}):e.jsx(lt,{}),disabled:o,onClick:()=>void Q(),sx:{borderRadius:2,minWidth:116},children:o?"Saving…":t==="create"?"Create":"Save"})]})}),e.jsxs(r,{sx:{width:"100%",maxWidth:1240,mx:"auto",p:{xs:1.5,sm:2.5,lg:3},display:"grid",gridTemplateColumns:{xs:"1fr",lg:"minmax(0, 1fr) 320px"},gap:2.5,alignItems:"start"},children:[e.jsxs(p,{spacing:2.5,sx:{minWidth:0},children:[s&&e.jsx(ce,{severity:"error",onClose:d,sx:{borderRadius:2},children:s}),e.jsxs(ie,{variant:"outlined",sx:{p:{xs:2,sm:2.5},borderRadius:3},children:[e.jsxs(p,{direction:"row",spacing:1.25,sx:{mb:2.5,alignItems:"flex-start"},children:[e.jsx(bi,{color:"primary"}),e.jsxs(r,{children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:750},children:"Template identity"}),e.jsx(l,{variant:"body2",color:"text.secondary",children:"Give administrators a recognizable title and a stable integration key."})]})]}),e.jsxs(r,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",sm:"minmax(0, 1fr) 220px"},gap:2},children:[e.jsx(D,{label:"Consent title",value:C.title,onChange:P=>I(P.target.value),onBlur:()=>z("title"),error:!!b("title"),helperText:b("title")??`${C.title.length}/160 characters`,slotProps:{htmlInput:{maxLength:160},inputLabel:{shrink:!0}},fullWidth:!0,autoFocus:!0}),e.jsx(D,{select:!0,label:"Language",value:C.languageCode,onChange:P=>$("languageCode",P.target.value),onBlur:()=>z("languageCode"),error:!!b("languageCode"),helperText:b("languageCode")??"BCP 47 language code",fullWidth:!0,children:ar.map(P=>e.jsx(ge,{value:P.value,children:P.label},P.value))}),e.jsx(D,{label:"Template key",value:C.templateKey,onChange:P=>K(P.target.value),onBlur:()=>z("templateKey"),error:!!b("templateKey"),helperText:b("templateKey")??"Stable key generated from the consent title.",fullWidth:!0,sx:{gridColumn:{sm:"1 / -1"}},slotProps:{htmlInput:{spellCheck:!1},inputLabel:{shrink:!0},input:{endAdornment:e.jsx(he,{position:"end",children:e.jsx(we,{title:"Sync key with title",children:e.jsx(ke,{edge:"end",onClick:V,disabled:o,color:j?"primary":"default","aria-label":"Sync template key with consent title",children:j?e.jsx(wi,{}):e.jsx(ao,{})})})})}}})]})]}),e.jsxs(ie,{variant:"outlined",sx:{overflow:"hidden",borderRadius:3},children:[e.jsx(r,{sx:{px:{xs:2,sm:2.5},pt:2.25,pb:1.75},children:e.jsxs(p,{direction:{xs:"column",sm:"row"},spacing:1,sx:{justifyContent:"space-between",alignItems:{sm:"center"}},children:[e.jsxs(r,{children:[e.jsx(l,{variant:"subtitle1",sx:{fontWeight:750},children:"Consent content"}),e.jsx(l,{variant:"body2",color:"text.secondary",children:"Use headings and short sections so patients can scan the document easily."})]}),e.jsx(ue,{size:"small",label:`${de} words`,variant:"outlined"})]})}),e.jsx(me,{}),e.jsx(Po,{ref:B,extensions:[En,An],content:C.htmlBody,onUpdate:({editor:P})=>Y(P.getHTML()),onBlur:()=>z("htmlBody"),renderControls:()=>e.jsxs(Mn,{children:[e.jsx(Bo,{}),e.jsx(wt,{}),e.jsx(Rn,{}),e.jsx(On,{}),e.jsx(fo,{}),e.jsx(wt,{}),e.jsx(Vn,{}),e.jsx(xo,{}),e.jsx(ho,{}),e.jsx(wt,{}),e.jsx(go,{}),e.jsx(bo,{}),e.jsx(mo,{})]}),sx:{"& .MuiTiptap-FieldContainer-root":{border:0,borderRadius:0},"& .MuiTiptap-RichTextField-content":{minHeight:360,px:{xs:2,sm:3},py:2.5,"& .ProseMirror":{minHeight:310,outline:"none",lineHeight:1.7}}}}),b("htmlBody")&&e.jsx(Ye,{error:!0,sx:{px:2.5,pb:2},children:b("htmlBody")})]})]}),e.jsxs(p,{spacing:2,sx:{position:{lg:"sticky"},top:{lg:88}},children:[e.jsxs(ie,{variant:"outlined",sx:{p:2.25,borderRadius:3},children:[e.jsxs(p,{direction:"row",spacing:1,sx:{alignItems:"center",mb:.75},children:[e.jsx(vn,{color:"primary"}),e.jsx(l,{variant:"subtitle1",sx:{fontWeight:750},children:"Patient confirmation"})]}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mb:1.5},children:"Choose what the patient must confirm before continuing."}),e.jsxs(p,{spacing:1,children:[e.jsx(ft,{control:e.jsx(gt,{checked:C.requiresSignature,onChange:P=>$("requiresSignature",P.target.checked)}),label:e.jsx(l,{variant:"body2",sx:{px:1,fontWeight:700},children:"Require signature"})}),e.jsx(ft,{control:e.jsx(gt,{checked:C.requiresRecordingConsent,onChange:P=>$("requiresRecordingConsent",P.target.checked)}),label:e.jsx(l,{variant:"body2",sx:{px:1,fontWeight:600},children:"Require recording consent"})})]})]}),e.jsxs(ie,{variant:"outlined",sx:{p:2.25,borderRadius:3,bgcolor:"action.hover",borderStyle:"dashed"},children:[e.jsxs(p,{direction:"row",spacing:1,sx:{alignItems:"center",mb:1},children:[e.jsx(yi,{color:"primary"}),e.jsx(l,{variant:"subtitle2",sx:{fontWeight:750},children:"Publishing checklist"})]}),e.jsx(p,{spacing:1.1,children:[["Clear title and stable key",!!(C.title.trim()&&C.templateKey.trim())],["Formatted consent content",!!Ge(C.htmlBody)],["Accessible plain-text fallback",!!C.plainTextBody.trim()]].map(([P,U])=>e.jsxs(p,{direction:"row",spacing:1,sx:{alignItems:"center"},children:[e.jsx(jn,{color:U?"success":"disabled",sx:{fontSize:19}}),e.jsx(l,{variant:"body2",color:U?"text.primary":"text.secondary",children:P})]},String(P)))})]})]})]}),e.jsxs(Ln,{open:w,onClose:()=>a(!1),maxWidth:"xs",fullWidth:!0,children:[e.jsx(zn,{children:e.jsxs(p,{direction:"row",spacing:2,sx:{alignItems:"center"},children:[e.jsx(Dn,{fontSize:"small"}),e.jsx(l,{variant:"h6",sx:{fontWeight:600},children:"Discard unsaved changes?"})]})}),e.jsx(me,{}),e.jsx(Hn,{children:e.jsx(Wn,{children:"Your changes to this consent template have not been saved."})}),e.jsxs(qn,{children:[e.jsx(H,{onClick:()=>a(!1),children:"Keep editing"}),e.jsx(H,{variant:"contained",color:"error",onClick:f,children:"Discard changes"})]})]})]})}const dr=["branding","booking","verification","scheduling","instructions"],pi={branding:"Branding",booking:"Booking access",verification:"Verification",scheduling:"Scheduling",instructions:"Visit instructions"};function Le(t,i){return t instanceof Error&&t.message?t.message:i}function ur(t){return typeof t=="object"&&t!==null}function pr(t){const i=[{value:t,depth:0}],o=new Set;for(;i.length>0;){const s=i.shift();if(!s||o.has(s.value)||(o.add(s.value),!ur(s.value)))continue;const d=s.value.id??s.value.visitTypeId;
7if(typeof d=="string"&&d.trim())return d.trim();if(s.depth<3)for(const f of["data","visitType","result","value"])i.push({value:s.value[f],depth:s.depth+1})}return null}function hr(t){return Array.isArray(t)?t:Array.isArray(t.requirements)?t.requirements:[]}function Fs({onUploadLogo:t}){const{selectedFacilityId:i}=Fi(),[o,s]=c.useState("branding"),[d,f]=c.useState(!1),[h,y]=c.useState(!1),[B,C]=c.useState(null),[g,w]=c.useState(null),[a,W]=c.useState([]),[G,J]=c.useState(!1),[u,j]=c.useState(!1),[E,q]=c.useState(null),[v,$]=c.useState([]),[z,b]=c.useState(!1),I=c.useRef(null),K=c.useRef(null),[V,Y]=c.useState(null),[Q,ne]=c.useState(null),[de,P]=c.useState([]),[U,se]=c.useState(!1),[Z,ee]=c.useState(!1),[xe,X]=c.useState(null),[te,He]=c.useState(null),[R,Pe]=c.useState(null),[fe,oe]=c.useState(null),[Me,ze]=c.useState(!0),[je,m]=c.useState(!1),[O,ae]=c.useState(null),[pe,ve]=c.useState("Telehealth settings saved."),[n,S]=c.useState(!1),T=c.useCallback(x=>{if(He(x),!x.exists||!x.site){Pe(null),oe(null);return}const k=Ft(x.site);Pe(k),oe(k)},[]),A=c.useCallback(async x=>{try{ze(!0),ae(null);const k=await vt(i,{signal:x});if(x!=null&&x.aborted)return;T(k)}catch(k){if(x!=null&&x.aborted)return;ae(Le(k,"Unable to load telehealth settings."))}finally{x!=null&&x.aborted||ze(!1)}},[T,i]),N=c.useCallback(async x=>{try{J(!0),q(null);const k=await Ut(i,{signal:x});x!=null&&x.aborted||W(k)}catch(k){x!=null&&x.aborted||q(Le(k,"Unable to load visit types."))}finally{x!=null&&x.aborted||J(!1)}},[i]),F=c.useCallback(async(x,k)=>{try{b(!0),q(null);const le=await Ki(x,i,{signal:k});k!=null&&k.aborted||$(hr(le))}catch(le){k!=null&&k.aborted||($([]),q(Le(le,"Unable to load the assigned consent requirements.")))}finally{k!=null&&k.aborted||b(!1)}},[i]),Re=c.useCallback(async x=>{try{se(!0),X(null);const k=await _i(i,{signal:x});x!=null&&x.aborted||P([...k].sort((le,be)=>(be.updatedAt||"").localeCompare(le.updatedAt||"")))}catch(k){x!=null&&x.aborted||X(Le(k,"Unable to load consent templates."))}finally{x!=null&&x.aborted||se(!1)}},[i]);c.useEffect(()=>{var k;const x=new AbortController;return f(!1),(k=K.current)==null||k.abort(),K.current=null,I.current=null,C(null),w(null),$([]),b(!1),Y(null),ne(null),y(!1),s("branding"),A(x.signal),N(x.signal),Re(x.signal),()=>x.abort()},[Re,A,N]),c.useEffect(()=>()=>{var x;(x=K.current)==null||x.abort()},[]);const Ie=c.useMemo(()=>{const x=new Set;return!R||!fe||dr.forEach(k=>{nn(k,R,fe)&&x.add(k)}),x},[fe,R]);c.useEffect(()=>{const x=k=>{Ie.size!==0&&(k.preventDefault(),k.returnValue="")};return window.addEventListener("beforeunload",x),()=>{window.removeEventListener("beforeunload",x)}},[Ie.size]);const et=c.useCallback(x=>{Pe(k=>k&&{...k,...x})},[]),tt=c.useCallback(x=>{!R||!fe||Pe(Ct(x,R,fe))},[fe,R]),ki=c.useCallback(async x=>{try{m(!0),ae(null),await Ji(x,i);const k=await vt(i);if(!k.exists||!k.site)throw new Error("The booking site was submitted but could not be loaded afterward.");return T(k),s("branding"),f(!1),y(!1),ve("Telehealth booking site created."),S(!0),!0}catch(k){return ae(Le(k,"Unable to create the telehealth booking site.")),!1}finally{m(!1)}},[T,i]),Ce=c.useCallback(async(x,k)=>{const le=te==null?void 0:te.site;if(!le)return ae("Telehealth site settings are not available."),!1;try{m(!0),ae(null),await Gi({section:x,currentSite:le,changes:k,selectedFacilityId:i});const be=await vt(i);if(!be.exists||!be.site)throw new Error("The telehealth site could not be loaded after saving.");const De=Ft(be.site);return He(be),Pe(Te=>Te?Ct(x,Te,De):De),oe(Te=>Te?Ct(x,Te,De):De),ve(`${pi[x]} settings saved.`),S(!0),!0}catch(be){return ae(Le(be,`Unable to save ${pi[x].toLowerCase()} settings.`)),!1}finally{m(!1)}},[te==null?void 0:te.site,i]),Bi=c.useCallback(async()=>R?Ce("branding",{displayName:R.displayName.trim(),description:R.description.trim(),logoUrl:R.logoUrl.trim()||null,primaryColor:R.primaryColor.toUpperCase(),accentColor:R.accentColor.toUpperCase(),brandingJson:JSON.stringify(R.branding??{})}):!1,[R,Ce]),Pi=c.useCallback(async()=>R?Ce("booking",{isPublicBookingEnabled:R.isPublicBookingEnabled,allowNewTelehealthGuests:R.allowNewTelehealthGuests,allowExistingPatientLookup:R.allowExistingPatientLookup}):!1,[R,Ce]),Ii=c.useCallback(async()=>R?Ce("verification",{requirePhoneVerification:R.requirePhoneVerification,requireEmailVerification:R.requireEmailVerification}):!1,[R,Ce]),Ti=c.useCallback(async()=>R?Ce("scheduling",{defaultSlotHoldMinutes:Number(R.defaultSlotHoldMinutes),minLeadTimeMinutes:Number(R.minLeadTimeMinutes),maxAdvanceBookingDays:Number(R.maxAdvanceBookingDays)}):!1,[R,Ce]),Ei=c.useCallback(async()=>R?Ce("instructions",{publicInstructionsJson:JSON.stringify(R.publicInstructions??{})}):!1,[R,Ce]),Ai=c.useCallback(()=>{var x;(x=K.current)==null||x.abort(),K.current=null,I.current=null,q(null),w(null),$([]),b(!1),C("create")},[]),Mi=c.useCallback(x=>{var le;(le=K.current)==null||le.abort();const k=new AbortController;K.current=k,I.current=null,q(null),w(x),$([]),C("edit"),F(x.id,k.signal)},[F]),Ri=c.useCallback(()=>{var k;if(u)return;const x=!!I.current;(k=K.current)==null||k.abort(),K.current=null,I.current=null,q(null),w(null),$([]),b(!1),C(null),x&&N()}
7,[N,u]),Oi=c.useCallback(async(x,k)=>{var De;let le=(g==null?void 0:g.id)??I.current,be=!1;try{if(j(!0),q(null),le)await Yi(le,x,i);else{const Te=await Zi(x,i);if(le=pr(Te),le||(le=((De=(await Ut(i)).find(zi=>zi.code===x.code))==null?void 0:De.id)??null),!le)throw new Error("The visit type was created, but its ID could not be resolved for consent assignment.");I.current=le}return be=!0,await Xi(le,k,i),await N(),ve(B==="edit"||g?"Visit type updated.":"Visit type created."),S(!0),I.current=null,$([]),C(null),w(null),!0}catch(Te){return q(Le(Te,be?"Visit type details were saved, but consent requirements could not be saved. Review the configuration and retry.":"Unable to save the visit type.")),!1}finally{j(!1)}},[N,i,g,B]),Vi=c.useCallback(()=>{X(null),ne(null),Y("create")},[]),Ni=c.useCallback(x=>{X(null),ne(x),Y("edit")},[]),Li=c.useCallback(()=>{Z||(X(null),ne(null),Y(null))},[Z]),Hi=c.useCallback(async x=>{try{return ee(!0),X(null),V==="edit"&&Q?(await Qi(Q.templateId,x,i),ve("Consent template updated.")):(await en(x,i),ve("Consent template created.")),await Re(),S(!0),Y(null),ne(null),!0}catch(k){return X(Le(k,"Unable to save the consent template.")),!1}finally{ee(!1)}},[V,Re,Q,i]),zt=c.useCallback(x=>{var k;s(x),f(!1),y(!1),x!=="visitTypes"&&((k=K.current)==null||k.abort(),K.current=null,I.current=null,C(null),w(null),$([]),b(!1),q(null)),x!=="consents"&&(Y(null),ne(null),X(null))},[]);if(Me)return e.jsx(r,{sx:{minHeight:"calc(100vh - 64px)",display:"grid",placeItems:"center",bgcolor:"background.default"},children:e.jsxs(r,{sx:{textAlign:"center"},children:[e.jsx($e,{size:34}),e.jsx(l,{variant:"body2",color:"text.secondary",sx:{mt:1.5},children:"Loading telehealth settings…"})]})});if(O&&!te)return e.jsx(r,{sx:{p:3,maxWidth:720,mx:"auto"},children:e.jsx(ce,{severity:"error",action:e.jsx(ke,{color:"inherit",size:"small","aria-label":"Reload telehealth settings",onClick:()=>void A(),children:e.jsx(ht,{})}),children:O})});if(te&&!te.exists&&!te.site)return e.jsx(Do,{defaults:te.defaults,selectedFacilityId:i,creating:je,error:O,onDismissError:()=>ae(null),onCreate:ki,onUploadLogo:t});if(!(te!=null&&te.site)||!R||!fe)return e.jsx(r,{sx:{p:3,maxWidth:720,mx:"auto"},children:e.jsx(ce,{severity:"error",action:e.jsx(ke,{color:"inherit",size:"small","aria-label":"Reload telehealth settings",onClick:()=>void A(),children:e.jsx(ht,{})}),children:O||"Telehealth settings could not be initialized."})});const Dt=te.site,Wt=Ie.has("branding");return d?e.jsx(No,{value:R,clinicSlug:Dt.slug,dirty:Wt,saving:je,error:O,onDismissError:()=>ae(null),onChange:et,onReset:()=>tt("branding"),onSave:Bi,onBack:()=>f(!1),onUploadLogo:t}):B?e.jsx(nr,{mode:B,value:g,selectedFacilityId:i,saving:u,error:E,consentTemplates:de,consentTemplatesLoading:U,consentTemplatesError:xe,consentRequirements:v,consentRequirementsLoading:z,onRetryConsentTemplates:()=>void Re(),onDismissError:()=>q(null),onBack:Ri,onSave:Oi},`${B}-${(g==null?void 0:g.id)??"new"}`):V?e.jsx(cr,{mode:V,value:Q,saving:Z,error:xe,onDismissError:()=>X(null),onBack:Li,onSave:Hi},`${V}-${(Q==null?void 0:Q.templateId)??"new"}`):e.jsxs(r,{sx:{display:"flex",minHeight:"calc(100vh - 64px)",bgcolor:"background.default"},children:[e.jsx(r,{component:"aside",sx:{display:{xs:"none",md:"block"},width:260,flex:"0 0 260px",bgcolor:"background.paper"},children:e.jsx(r,{sx:{position:"sticky",top:0,height:"calc(100vh - 64px)"},children:e.jsx(Yt,{activeSection:o,dirtySections:Ie,onSelect:zt})})}),e.jsx($i,{open:h,onClose:()=>y(!1),ModalProps:{keepMounted:!0},slotProps:{paper:{sx:{width:288}}},children:e.jsx(Yt,{activeSection:o,dirtySections:Ie,onSelect:zt})}),e.jsxs(r,{component:"main",sx:{minWidth:0,flex:1},children:[e.jsxs(r,{sx:{display:{xs:"flex",md:"none"},alignItems:"center",gap:1,px:1.25,py:1,bgcolor:"background.paper",borderBottom:"1px solid",borderColor:"divider"},children:[e.jsx(ke,{onClick:()=>y(!0),"aria-label":"Open telehealth settings menu",children:e.jsx(no,{})}),e.jsx(l,{variant:"subtitle1",sx:{fontWeight:700},children:"Telehealth settings"})]}),O&&o!=="visitTypes"&&o!=="consents"&&e.jsx(ce,{severity:"error",onClose:()=>ae(null),sx:{borderRadius:0},children:O}),o==="branding"&&e.jsx(Ro,{value:R,clinicSlug:Dt.slug,dirty:Wt,onEdit:()=>f(!0)}),o==="booking"&&e.jsx(Wo,{value:R,dirty:Ie.has("booking"),saving:je,defaults:te.defaults,onChange:et,onReset:()=>tt("booking"),onSave:()=>void Pi()}),o==="visitTypes"&&e.jsx(Jo,{values:a,loading:G,error:E,onCreate:Ai,onEdit:Mi,onRetry:()=>void N()}),o==="verification"&&e.jsx(qo,{value:R,dirty:Ie.has("verification"),saving:je,defaults:te.defaults,onChange:et,onReset:()=>tt("verification"),onSave:()=>void Ii()}),o==="scheduling"&&e.jsx(Uo,{value:R,dirty:Ie.has("scheduling"),saving:je,defaults:te.defaults,onChange:et,onReset:()=>tt("scheduling"),onSave:()=>void Ti()}),o==="instructions"&&e.jsx(Fo,{value:R,dirty:Ie.has("instructions"),saving:je,onChange:et,onReset:()=>tt("instructions"),onSave:()=>void Ei()}),o==="consents"&&e.jsx(sr,{values:de,loading:U,error:xe,onCreate:Vi,onEdit:Ni,onRetry:()=>void Re()})]}),e.jsx(Un,{open:n,autoHideDuration:3500,onClose:()=>S(!1),message:pe,anchorOrigin:{vertical:"bottom",horizontal:"center"}})]})}export{Fs 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.