PageSourceSearch

https://centerplatform.ai/build/assets/ConsultantBoard-DWbNlMNV.js

js centerplatform.ai collected 2026-10-05 14:55:50 UTC 67,960 bytes, 1 lines download raw bytes

1import{a as B,j as e,r as u,B as l,T as _,e as K,b as et,g as se,o as tt,D as Y,c as Q,n as it,u as he,y as $,m as Me,f as at,p as Ie,q as st}from"./app-BZMRTsuS.js";import{T as nt,a as ot}from"./Tabs-2uZniXMk.js";import{u as J}from"./useTranslateDict-CqG-Xn3N.js";import{u as rt}from"./videoService-Sf7E4KPS.js";import{C as lt,T as dt}from"./CountryPhoneInput-B-oQAJOv.js";import{i as ct}from"./countries-DhySMZQ7.js";import{f as De}from"./phone-DtDV73Ae.js";import{u as ye}from"./useNotificationsListener-CyP77ygA.js";import{u as pt}from"./index-DBW4IqEz.js";import{A as ut}from"./Alert-DheZn4tr.js";import{T as oe,F as xt,S as mt}from"./TextField-BB__fmZM.js";import{C as le}from"./Chip-CxhJjHEG.js";import{A as Fe,c as gt}from"./Autocomplete-Pj2ACIlS.js";import{A as ft}from"./AvatarEditable-zZDjsPBh.js";import{V as ht}from"./VideoPlayer-6avYL5sB.js";import{A as bt}from"./Avatar-CVR9nWsq.js";import yt from"./play-mq_m1KiG.js";import{L as Ft}from"./LinearProgress-0xsCikjF.js";import{T as ue}from"./SidebarNavigationGroup-CR-otHOw.js";import{A as _t}from"./AdminLayout-C1wEhjSO.js";import{f as jt,c as vt}from"./consultancyTimezone-UAkAxWOL.js";import{F as wt}from"./FiltersGrid-BM4W2h1y.js";import{D as Ct}from"./DefaultChip-Wh8VQ1-p.js";import{S as j}from"./Stack-lyb-H-23.js";import{P as kt}from"./Pagination-CEnWE0Iv.js";import{a as Ae,i as St,b as _e,s as Wt,e as Mt}from"./isSameMonth-BYbTS7No.js";import It from"./chevron-left-DycWhMYO.js";import Dt from"./chevron-right-C3ibg8R9.js";import{t as ze,f as At}from"./format-D_0k2AJ3.js";import{D as Re}from"./DialogContent-C-XCzMq9.js";import Te from"./calendar-days-3aDDoRN5.js";import zt from"./calendar-x-2-hySAjma4.js";import Rt from"./calendar-sync-C1eFnrxg.js";import{D as xe}from"./DefaultTextfield-DWniaLDw.js";import{I as de}from"./IconButton-DQ9YpBSr.js";import Tt from"./x-DfnlLEeA.js";import Pe from"./chevron-down-Bg91GIFX.js";import Pt from"./lock-Cbsgh3Ic.js";import $t from"./lock-open-BxrmlQFB.js";import Et from"./pencil-DBkSiSfr.js";import $e from"./trash-2-CDlyMZxB.js";import{M as je}from"./MenuItem-DHZynuzi.js";import Ot from"./settings-Bp02x2RC.js";import{C as Bt}from"./Checkbox-D0qtEP6P.js";import Ht from"./check-N2ehAS7U.js";import Lt from"./plus-Bd8ze_Bv.js";/* empty css            */import"./createLucideIcon-COrS4lSy.js";import"./createSvgIcon-CISW1gy7.js";import"./videoProcessingWaitRegistry-hDxulhKs.js";import"./v7-CElQ7RR-.js";import"./rng-Dsaz7ZGA.js";import"./KeyboardArrowDown-D9sN5Qh5.js";import"./Popper-CLLvn2vZ.js";import"./Divider-Bb2Zxy87.js";import"./listItemTextClasses-Dko_1TJd.js";import"./bell-BuPVItlS.js";import"./Close-FnJfGzK_.js";import"./useFormControl-C7GyD0k9.js";import"./formControlState-Dq1zat_P.js";import"./Menu-BCzWmKB1.js";import"./useControlled-BKFoDg_8.js";import"./PlayArrowRounded-DYCT9ODq.js";import"./hls-Cp2x8l1r.js";import"./Slider-C0Vsej77.js";import"./visuallyHidden-Dan1xhjv.js";import"./VolumeUpRounded-t1TFBUFM.js";import"./maximize-2-S4DEJPWY.js";import"./ChevronRight-4-LVU4rf.js";import"./Switch-CjoXag_M.js";import"./SwitchBase-DAt3DPDP.js";import"./ListItem-CWnbw1iL.js";import"./Collapse-FWpsRXWN.js";import"./file-question-yiXImVY3.js";import"./user-round-DF_DFx3d.js";import"./sparkles-DYwQCufG.js";import"./credit-card-DpdGHFA1.js";import"./file-up-DPPYgVgg.js";import"./messages-square-BADWRAH7.js";import"./calendar-clock-DBWGtuHd.js";import"./user-cog-WWz6O9Sp.js";import"./users-CyMmPgq9.js";import"./file-text-B0tlMGS0.js";import"./map-pin-check-CIaTLJmW.js";import"./video-D6ArB_9u.js";import"./message-circle-more-D0j6DZSY.js";import"./message-square-text-iE-njpgK.js";import"./file-pen-line-DTdgjI4z.js";import"./file-search-2-ChUsBnLL.js";import"./store-BMJ7cn2s.js";import"./handshake-DVyF4xXk.js";import"./briefcase-business-eL5CeR2W.js";import"./package-open-BudoWEbE.js";import"./building-2-Duw89aHU.js";import"./layout-dashboard-CmRb-BUP.js";import"./logo-bNh9u0wR.js";import"./cog-DOgW13ju.js";import"./headphones-DE7MQT8s.js";import"./log-out-DJr85CwM.js";import"./menu-Xdct_srT.js";import"./chevrons-right-D7y3CJ8r.js";import"./dot-B-UFNqoA.js";import"./CheckRounded-Bt_cZeKi.js";
1import"./Grid-CPvZZi00.js";import"./styled-DlUnb7Sr.js";import"./ClickAwayListener-Ckjd054_.js";import"./EpisodePublishScheduleStep3-7BNJ0ZXD.js";import"./index.esm-CMlIDCOg.js";import"./index-1oQBK7g2.js";import"./InputAdornment-CqpZyCN8.js";import"./DialogActions-BxaD9eZi.js";import"./calendar-CXvYBmWn.js";import"./index-Co8Q3YKX.js";import"./select-BCPECHhd.js";import"./index-BYbEvXNw.js";import"./index-C_tIeRss.js";import"./index-Ci9tDqVY.js";import"./chevron-up-rBMDYhe_.js";import"./clock-DQ3XyQZR.js";import"./inputUtils-pIugqgmS.js";import"./constants-Bu6SZ1v9.js";function Ee({value:t,options:a,onChange:n,ariaLabel:s="tabs",panelIdPrefix:o="default-tabpanel",indicatorHeight:i=2,scrollable:p=!1}){const{novoTheme:f}=B();return e.jsx(nt,{value:t,onChange:(d,F)=>n(F),"aria-label":s,variant:p?"scrollable":"standard",scrollButtons:!1,TabIndicatorProps:{style:{backgroundColor:"#FEB000",height:i}},sx:{minHeight:40,"& .MuiTabs-flexContainer":{gap:{xs:1,sm:2,md:3,xl:4}}},children:a.map(d=>e.jsx(ot,{id:`default-tab-${d.value}`,"aria-controls":`${o}-${d.value}`,label:d.label,disableRipple:!0,value:d.value,sx:{...f.text.tertiary,textTransform:"none",fontWeight:500,minHeight:40,color:"#B7B7B7","&.Mui-selected":{color:"#FFFFFF",fontWeight:600}}},d.value))})}function te({label:t,value:a,field:n,isEditing:s,novoTheme:o,textAlign:i="left"}){const p=u.useId(),f=u.isValidElement(n)?u.cloneElement(n,{id:p}):n;return e.jsxs(l,{sx:{display:"flex",flexDirection:"column",gap:.75,mb:{xs:2,md:2.5,xl:3},minWidth:0},children:[e.jsx(_,{component:"label",htmlFor:p,sx:{...o.text.secondary,color:"#FFFFFF",fontWeight:600,fontSize:{xs:14,md:14},lineHeight:1.35},children:t}),s?f:typeof a=="string"?e.jsx(_,{sx:{...o.text.tertiary,color:"#FFFFFF",textAlign:i,fontSize:{xs:13,md:14},lineHeight:1.5,overflowWrap:"anywhere",whiteSpace:"pre-wrap"},children:a}):e.jsx(l,{sx:{minHeight:21,display:"flex",alignItems:"center",minWidth:0},children:a})]})}const ie=t=>"isCreate"in t;function qt({isEditing:t,formValues:a,displayValues:n,novoTheme:s,isSaving:o,saveFeedbackMessage:i,saveFeedbackType:p,isCreating:f,onFieldChange:d,onCancel:F,onToggleEdit:b}){const{data:c,isLoading:S,isError:R,refetch:E}=ye({queryKey:["specialties"],queryFn:async()=>(await Q.get("/api/admin/consultant/specialties")).data}),[g,V]=u.useState(!1),[W,P]=u.useState(null),A=n?.specialties??[],T=x=>t?x.name_source??x.name:x.name,q=async(x,D)=>{V(!0),P(null);try{const H=(await Q.post("/api/admin/consultant/specialties",{name:x})).data?.specialty;if(!H?.id)throw new Error(y("page.profile.info.specialty_create_error"));await E(),d("specialty_ids",[...new Set([...D,Number(H.id)])])}catch(O){P(O?.response?.data?.message??O?.message??y("page.profile.info.specialty_create_error"))}finally{V(!1)}},{data:Z}=ye({queryKey:["languages"],queryFn:async()=>(await Q.get("/api/admin/consultant/languages")).data}),C={"& .MuiOutlinedInput-root":{fontSize:{xs:12,sm:14,md:14,lg:12,xl:14},fontWeight:400,fontFamily:"'Inter', sans-serif",WebkitFontSmoothing:"antialiased",backgroundColor:"#1A1A1A",borderRadius:"5px",minHeight:35,color:"#FFFFFF","& fieldset":{borderColor:"transparent"},"&:hover fieldset":{borderColor:K("#FFFFFF",.08)},"&.Mui-focused fieldset":{borderColor:K("#FFFFFF",.09)}},"& .MuiInputBase-input":{fontSize:{xs:12,sm:14,md:14,lg:12,xl:14},fontWeight:400,fontFamily:"'Inter', sans-serif",WebkitFontSmoothing:"antialiased",color:"#FFFFFF",px:1.5,py:.75},"& .MuiInputBase-inputMultiline":{py:1.25}},h={"& .MuiOutlinedInput-root, & .MuiInputBase-root":{backgroundColor:"#1A1A1A !important"},"& .MuiOutlinedInput-root:hover, & .MuiInputBase-root:hover":{backgroundColor:"#1A1A1A !important"},"& .MuiInputBase-input, & .MuiAutocomplete-input":{color:"#FFFFFF !important",WebkitTextFillColor:"#FFFFFF !important"}},I={width:"fit-content",maxWidth:"100%",alignSelf:"flex-start",height:27,borderRadius:"5px",backgroundColor:"#272727",color:"#FFFFFF","& .MuiChip-deleteIcon":{color:"#ffffffd2",fontSize:16},"& .MuiChip-deleteIcon:hover":{color:"#FFFFFF"},"& .MuiChip-label":{fontSize:{xs:12,sm:14,md:14,lg:12,xl:14},fontWeight:400,fontFamily:"'Inter', sans-serif",WebkitFontSmoothing:"antialiased",px:1.5,color:"#FFFFFF"}},N={backgroundColor:"#101010",color:"#FFFFFF",mt:.5,"& .MuiAutocomplete-listbox":{color:"#FFFFFF"},"& .MuiAutocomplete-option":{backgroundColor:"#202020 !important",color:"#FFFFFF !important"},"& .MuiAutocomplete-option:hover":{backgroundColor:"#232323 !important"},"& .MuiAutocomplete-option.Mui-focused":{backgroundColor:"#272727 !important"},"& .MuiAutocomplete-option.Mui-focusVisible":{backgroundColor:"#232323 !important"},"& .MuiAutocomplete-option[aria-selected='true']":{backgroundColor:"#323232 !important",color:"#FFFFFF !important"},"& .MuiAutocomplete-option[aria-selected='true'].Mui-focused, & .MuiAutocomplete-option[aria-selected='true'].Mui-focusVisible":{backgroundColor:"#323232 !important",color:"#FFFFFF !important"}},w=et();pt(w.breakpoints.down("sm"));const y=J(),M=se().props.regional,G=ct(a.country)?a.country:"BR",ee=tt(a.timezone)?a.timezone:"UTC";return e.jsxs(l,{sx:{display:"flex",flexDirection:"column",minWidth:0,height:"100%"},children:[e.jsx(_,{sx:{...s.text.primary,color:"#FFFFFF",fontWeight:600,mb:2.5},children:y("page.profile.info.title")}),i&&e.jsx(ut,{severity:p??"info",sx:{mb:1.5,borderRadius:"6px",backgroundColor:p==="error"?K("#D32F2F",.16):K(s.colors.primary,.12),color:"#FFFFFF","& .MuiAlert-icon":{color:p==="error"?"#FF8A80":s.colors.primary}},children:i}),e.jsx(te,{label:y("page.profile.info.fields.full_name"),isEditing:t,field:e.jsx(oe,{fullWidth:!0,value:a.name,onChange:x=>d("name",x.target.value),sx:C}),value:n?.name||a.name||"—",novoTheme:s}),e.jsx(te,{label:y("page.profile.info.fields.bio"),isEditing:t,field:e.jsx(oe,{fullWidth:!0,multiline:!0,minRows:2,value:a.profile_summary,onChange:x=>d("profile_summary",x.target.value),sx:C}),value:n?.profile_summary||a.profile_summary||"—",novoTheme:s,textAlign:"justify"}),e.jsx(te,{label:y("page.profile.info.fields.phone"),isEditing:t,field:e.jsx(l,{sx:h,children:e.jsx(lt,{country:G,phone:a.phone,label:"",phoneAriaLabel:y("page.profile.info.fields.phone"),locale:M?.locale??"pt-BR",onChange:x=>{d("country",x.country),d("phone",x.phone)}})}),value:De(a.phone,G,!1)||"—",novoTheme:s}),e.jsx(te,{label:y("page.profile.info.fields.timezone"),isEditing:t,field:e.jsx(l,{sx:h,children:e.jsx(dt,{options:M?.available_timezones??["UTC"],value:ee,locale:M?.locale??"pt-BR",onChange:x=>d("timezone",x)})}),value:a.timezone||"—",novoTheme:s}),e.jsx(te,{label:y("page.profile.info.fields.specialty"),isEditing:t,field:e.jsx(Fe,{filterOptions:(x,D)=>{const H=gt()(x,D),U=D.inputValue.trim(),me=x.some(ce=>!ie(ce)&&T(ce).trim().toLowerCase()===U.toLowerCase());return U!==""&&!me&&H.push({inputValue:U,name:y("page.profile.info.specialty_create",{name:U}),isCreate:!0}),H},multiple:!0,fullWidth:!0,options:c??[],loading:S||g,value:(c??[]).filter(x=>a.specialty_ids.includes(Number(x.id))),onChange:(x,D)=>{const O=D.find(ie),H=D.filter(U=>!ie(U)).map(U=>Number(U.id));if(O){q(O.inputValue,H);return}d("specialty_ids",H)},getOptionLabel:x=>ie(x)?x.name:T(x),isOptionEqualToValue:(x,D)=>!ie(x)&&!ie(D)&&x.id===D.id,renderTags:(x,D)=>x.filter(O=>!ie(O)).map((O,H)=>u.createElement(le,{...D({index:H}),key:O.id,label:T(O),sx:I})),renderInput:x=>e.jsx(oe,{...x,fullWidth:!0,sx:C,error:R||W!==null,helperText:S?y("page.profile.info.specialties_loading"):W??(R?y("page.profile.info.specialties_error"):void 0)}),sx:{"& .MuiAutocomplete-endAdornment":{right:12},"& .MuiAutocomplete-popupIndicator":{color:"#FFFFFF"},"& .MuiAutocomplete-clearIndicator":{color:"#FFFFFF"}},slotProps:{paper:{sx:N}}}),value:a.specialty_ids.length?e.jsx(l,{sx:{display:"flex",flexWrap:"wrap",gap:1},children:(t?c??[]:A).filter(x=>a.specialty_ids.includes(Number(x.id))).map(x=>e.jsx(le,{label:T(x),sx:I},x.id))}):"—",novoTheme:s}),e.jsx(te,{label:y("page.profile.info.fields.languages"),isEditing:t,field:e.jsx(Fe,{multiple:!0,fullWidth:!0,value:a.languages,options:Z??[],onChange:(x,D)=>d("languages",D),getOptionLabel:x=>y(`page.profile.info.language_labels.${x}`),isOptionEqualToValue:(x,D)=>x===D,renderTags:(x,D)=>x.map((O,H)=>u.createElement(le,{...D({index:H}),key:O,label:y(`page.profile.info.language_labels.${O}`),sx:I})),renderInput:x=>e.jsx(oe,{...x,fullWidth:!0,sx:C}),sx:{"& .MuiAutocomplete-endAdornment":{right:12},"& .MuiAutocomplete-popupIndicator":{color:"#FFFFFF"},"& .MuiAutocomplete-clearIndicator":{color:"#FFFFFF"}},slotProps:{paper:{sx:N}}}),value:a.languages.length>0?e.jsx(l,{sx:{display:"flex",flexWrap:"wrap",gap:1},children:a.languages.map(x=>e.jsx(le,{label:y(`page.profile.info.language_labels.${x}`),sx:I},x))}):"—",novoTheme:s}),e.jsx(te,{label:y("page.profile.info.fields.skills"),isEditing:t,field:e.jsx(oe,{fullWidth:!0,value:a.additional_skills,onChange:x=>d("additional_skills",x.target.value),sx:C}),value:n?.additional_skills||a.additional_skills||"—",novoTheme:s}),e.jsxs(l,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end",gap:{xs:1,md:1},width:"100%",mt:"auto",pt:{xs:2,md:2}},children:[t&&!o&&!f&&e.jsx(Y,{onPress:F,variant:"secondary",size:"small",text:y("page.profile.info.cancel"),disabled:o,textWhenDisabled:y("page.profile.info.saving"),disableFullWidth:!0,textSx:{flex:{xs:1,sm:"0 0 auto"},minWidth:{xs:0,sm:94},height:{xs:30,sm:30}}}),e.jsx(Y,{onPress:b,variant:"primary",size:"small",text:y(t?f?"page.profile.info.create":"page.profile.info.save":"page.profile.info.edit"),disabled:o,textWhenDisabled:y("page.profile.info.saving"),disableFullWidth:!0,textSx:{flex:{xs:1,sm:"0 0 auto"},minWidth:{xs:0,sm:94},height:{xs:30,sm:30}}})]})]})}function Nt({isEditing:t,photoPath:a,presentationVideoId:n,videoFile:s,novoTheme:o,videoUploadProgress:i,saveFeedbackMessage:p,isSaving:f,onChange:d}){const F=u.useRef(null),b=J(),c=u.useMemo(()=>s?URL.createObjectURL(s):null,[s]);return u.useEffect(()=>()=>{c&&URL.revokeObjectURL(c)},[c]),e.jsxs(l,{sx:{display:"flex",flexDirection:"column",gap:{xs:3.5,sm:4,md:5,lg:4,xl:5},alignItems:{xs:"center",md:"stretch"},width:"100%",maxWidth:{xs:"296px",md:"219px"},justifySelf:"center"},children:[e.jsxs(l,{sx:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center"},children:[e.jsx(_,{sx:{...o.text.secondary,color:"#FFFFFF",fontWeight:600,mb:1.5,width:"100%",textAlign:{xs:"center",md:"left"}},children:b("page.profile.media.photo_title")}),!t&&e.jsx(bt,{src:a||void 0,sx:{...o.text.large,width:{xs:98,md:122},height:{xs:99,md:122},bgcolor:"#2A2A2A",color:"#8E8E8E",fontWeight:700}}),t&&e.jsxs(e.Fragment,{children:[e.jsx(ft,{src:a||void 0,size:{xs:98,sm:98,md:122,lg:122,xl:122},onFileSelected:S=>d("image",S)}),e.jsxs(_,{sx:{...o.text.seventiary,color:"#FFFFFF",fontWeight:600,textAlign:"center",mt:2,maxWidth:120,lineHeight:1.35},children:[b("page.profile.media.photo_hint_line_1"),e.jsx("br",{}),b("page.profile.media.photo_hint_line_2")]})]})]}),e.jsxs(l,{sx:{width:"100%",display:"flex",flexDirection:"column",alignItems:"flex-start"},children:[e.jsx(_,{sx:{...o.text.secondary,color:"#FFFFFF",fontWeight:600,mb:2},children:b("page.profile.media.video_title")}),e.jsx(l,{sx:{width:"100%",height:{xs:155,md:140},borderRadius:"10px",backgroundColor:"#1F1F1F",display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",gap:1.75,overflow:"hidden"},children:c?e.jsx(l,{component:"video",src:c,controls:!0,preload:"metadata",playsInl
1ine:!0,sx:{width:"100%",height:"100%",objectFit:"cover",backgroundColor:"#000000"}}):n?e.jsx(ht,{videoId:n,image_url:a??null,className:"h-full w-full"}):e.jsxs(e.Fragment,{children:[e.jsx(l,{sx:{width:{xs:48,md:54,xl:62},height:{xs:48,md:54,xl:62},borderRadius:"999px",backgroundColor:"#595959",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(yt,{size:32,color:"#FFFFFF",strokeWidth:1})}),e.jsx(_,{sx:{...o.text.quintiary,color:"#FFFFFF",fontWeight:600},children:b("page.profile.media.no_video")})]})}),typeof i=="number"&&e.jsxs(l,{sx:{width:"100%",mt:1.5},children:[e.jsx(Ft,{variant:"determinate",value:i,sx:{height:7,borderRadius:"999px",backgroundColor:K("#FFFFFF",.08),"& .MuiLinearProgress-bar":{borderRadius:"999px",backgroundColor:o.colors.primary}}}),e.jsx(_,{sx:{...o.text.quintiary,color:"#FFFFFF",mt:1},children:b("page.profile.media.upload_progress",{progress:i})})]}),t&&!f&&e.jsxs(e.Fragment,{children:[e.jsx("input",{ref:F,type:"file",hidden:!0,accept:"video/mp4,video/quicktime,video/x-matroska,video/x-msvideo",onChange:S=>{const R=S.target.files?.[0]??null;d("video",R),S.currentTarget.value=""}}),e.jsxs(l,{sx:{display:"flex",width:"100%",mt:1.5,gap:1.5,justifyContent:"space-between"},children:[e.jsx(_,{component:"button",type:"button","aria-label":b("page.profile.media.upload_video"),onClick:()=>F.current?.click(),sx:{...o.text.quintiary,color:"#FFFFFF",textDecoration:"underline",cursor:"pointer",background:"none",border:0,p:0},children:b("page.profile.media.upload_video")}),s&&e.jsx(it,{onClick:()=>d("video",null),sx:{...o.text.quintiary,color:"#FFFFFF",minWidth:"auto",p:0,textTransform:"none",textDecoration:"underline"},children:b("page.profile.media.remove_video")})]})]})]})]})}const re=(t,a)=>{const n=t;return{name:n?.name_source??n?.name??"",phone:t?.phone??"",country:t?.country??"BR",timezone:t?.timezone??a,profile_summary:n?.profile_summary_source??n?.profile_summary??"",specialty_ids:Array.isArray(t?.specialty_ids)?t.specialty_ids.map(Number):[],languages:Array.isArray(t?.languages)?t.languages:[],additional_skills:n?.additional_skills_source??n?.additional_skills??"",presentation_video_id:t?.presentation_video_id??"",image:null,video:null}};function Gt({consultant:t,onSuccess:a}){const{novoTheme:n,toastConfig:s}=B(),o=J(),{active_timezone:i}=he(),[p,f]=u.useState(!t),[d,F]=u.useState(t),[b,c]=u.useState(()=>re(t,i)),[S,R]=u.useState(!1),[E,g]=u.useState(null),[V,W]=u.useState(null),[P,A]=u.useState(null),[T,q]=u.useState(!1);u.useEffect(()=>{F(t),c(re(t,i)),f(!t)},[t,i]);const Z=(y,z)=>{c(M=>({...M,[y]:z}))},C=()=>{W(null),A(null)},h=()=>{c(re(d,i)),g(null),C(),f(!d)},I=()=>{window.location.href="/admin/consultants/google/connect"},N=async()=>{q(!0);try{const y=await Q.delete("/admin/consultants/google/disconnect"),z=y.data?.consultant;z&&(F(z),c(re(z,i)),a?.(z)),$.success(y.data?.message??o("page.profile.google.disconnect_success"),s)}catch(y){$.error(y?.response?.data?.message??o("page.profile.google.disconnect_error"),s)}finally{q(!1)}},w=async()=>{if(!p){C(),f(!0);return}R(!0),g(null),W(o("page.profile.feedback.saving_profile")),A("info");try{let y=b.presentation_video_id||d?.presentation_video_id||"";if(b.video){W(o("page.profile.feedback.uploading_video"));const x=await rt({file:b.video,onProgress:D=>g(D)});if(!x.success||!x.id)throw new Error(o("page.profile.feedback.upload_video_error"));y=x.id}W(o(!d?"page.profile.feedback.creating_profile":"page.profile.feedback.saving_profile"));const M=new FormData;M.append("name",b.name),M.append("phone",b.phone??""),M.append("country",b.country),M.append("timezone",b.timezone),M.append("profile_summary",b.profile_summary??""),b.specialty_ids.forEach(x=>M.append("specialty_ids[]",String(x))),b.languages.length>
10?b.languages.forEach(x=>{M.append("languages[]",x)}):M.append("clear_languages","1"),M.append("additional_skills",b.additional_skills??""),M.append("presentation_video_id",y),b.image&&M.append("image",b.image);const G=d?await Q.post(`/api/admin/consultant/${d.id}`,(M.append("_method","PUT"),M),{headers:{"Content-Type":"multipart/form-data"}}):await Q.post("/api/admin/consultant",M,{headers:{"Content-Type":"multipart/form-data"}}),ee=G.data?.consultant;if(!ee)throw new Error(o("page.profile.feedback.invalid_save_response"));F(ee),c(re(ee,i)),f(!1),W(null),A(null),g(null),d||a?.(ee),$.success(G.data?.message??o(d?"page.profile.feedback.save_success":"page.profile.feedback.create_success"),s)}catch(y){const z=y?.response?.data?.errors,G=(z?Object.values(z).flat().find(Boolean):null)??y?.response?.data?.message??y?.message??o(d?"page.profile.feedback.save_error":"page.profile.feedback.create_error");W(G),A("error"),$.error(G,s)}finally{R(!1)}};return e.jsx(l,{sx:{flex:1,display:"flex",justifyContent:"center",width:"100%",minHeight:0,height:"100%"},children:e.jsx(l,{sx:{width:"100%",minHeight:"100%",height:"100%",flex:1,maxWidth:"100%",boxSizing:"border-box",backgroundColor:"#101010",display:"flex",border:{xs:"none",md:`1px solid ${K("#272727",.3)}`},borderRadius:{xs:0,md:"14px"},px:{xs:0,sm:2,md:3},py:{xs:1,sm:2.5,md:3}},children:e.jsxs(l,{sx:{width:"100%",minWidth:0,display:"grid",gridTemplateColumns:{xs:"1fr",md:"minmax(0, 219px) minmax(0, 1fr)"},rowGap:{xs:2.5,md:3},columnGap:{md:7,lg:9,xl:10},justifyContent:"stretch",alignItems:"start"},children:[e.jsxs(l,{sx:{display:"flex",flexDirection:"column",alignItems:{xs:"center",md:"stretch"},gap:{xs:4,sm:5,md:6,lg:5,xl:6},minWidth:0},children:[e.jsx(Nt,{isEditing:p,photoPath:b.image?URL.createObjectURL(b.image):d?.photo_path,presentationVideoId:b.video?null:b.presentation_video_id||d?.presentation_video_id,videoFile:b.video,novoTheme:n,videoUploadProgress:E,saveFeedbackMessage:V,isSaving:S,onChange:(y,z)=>Z(y,z)}),d&&!p&&e.jsxs(l,{children:[e.jsxs(l,{sx:{display:"flex",alignItems:"center",gap:1.5,mb:.8},children:[e.jsx(_,{sx:{...n.text.secondary,color:"#FFFFFF",fontWeight:700},children:o("page.profile.google.title")}),e.jsx(ue,{title:o("page.profile.google.tooltip"),arrow:!0,children:e.jsx(l,{component:"span",sx:{width:18,height:18,borderRadius:"50%",border:"1px solid rgba(107, 107, 107, 0.2)",background:"rgba(146, 146, 146, 0.20)",color:K("#FFFFFF",.75),display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,cursor:"help"},children:"i"})})]}),e.jsx(_,{sx:{...n.text.tertiary,color:K("#FFFFFF",.7),mb:2},children:d.google_connected_at?o("page.profile.google.connected",{email:d.google_email??""}):o("page.profile.google.disconnected")}),e.jsx(Y,{onPress:d.google_connected_at?N:I,variant:"primary",size:"small",text:d.google_connected_at?o("page.profile.google.disconnect"):o("page.profile.google.connect"),disabled:T,textWhenDisabled:o("page.profile.info.saving"),disableFullWidth:!0})]})]}),e.jsx(l,{sx:{display:"flex",flexDirection:"column",gap:2,minWidth:0,width:"100%"},children:e.jsx(qt,{isEditing:p,formValues:b,displayValues:d??t,novoTheme:n,isSaving:S,saveFeedbackMessage:V,saveFeedbackType:P,isCreating:!d,onFieldChange:Z,onCancel:h,onToggleEdit:w})})]})})})}function Ut(t,a){return t&&a(`page.calendar.appointment_card.status.${t}`)!==`page.calendar.appointment_card.status.${t}`?a(`page.calendar.appointment_card.status.${t}`):a("page.calendar.appointment_card.status.unknown")}function Vt(t){return t&&{pending:"primary",confirmed:"primary",rescheduled:"primary",completed:"secondary",cancelled:"secondary",refund:"secondary",expired:"secondary"}[t]||"secondary"}const Xt={backgroundColor:"#101010",border:"0.5px solid rgba(255,255,255,0.1)",borderRadius:"14px",boxSizing:"border-box"};function Yt({appointment:t,onCancel:a,onAccessMeeting:n}){const{novoTheme:s}=B(),{locale:o}=se().props,{active_timezone:i}=he(),p=J(),f=(o??"pt_BR").replace("_","-"),d=jt({appointmentDate:t.appointment_date,startTime:t.start_time,endTime:t.end_time,startsAt:t.starts_at??t.resolved_starts_at,endsAt:t.ends_at??t.resolved_ends_at,timeZone:i,locale:f}),F=t.client?.country,b=["pending","confirmed","rescheduled","cancelled","refund","expired","completed"].includes(t.status??""),c=["pending","confirmed"].includes(t.status??"");
1return e.jsxs(l,{sx:{...Xt,border:"none",borderRadius:"15px",width:{xs:"100%",md:243},minWidth:{xs:0,md:243},maxWidth:{xs:"100%",md:243},p:{xs:2.5,md:2.25},minHeight:283,display:"flex",flexDirection:"column"},children:[e.jsxs(j,{spacing:1,children:[e.jsx(_,{sx:{...s.text.quartiary,color:"#FFFFFF",fontWeight:600},children:t.client?.name??p("page.calendar.appointment_card.fallback_client")}),e.jsx(_,{sx:{...s.text.quartiary,color:"#FFFFFF"},children:t.client?.email??"-"}),e.jsx(_,{sx:{...s.text.quintiary,color:"#FFFFFF"},children:De(t.client?.phone,F,!1)||"-"}),e.jsx(_,{sx:{...s.text.quintiary,color:"#FFFFFF",pt:.5},children:d.dateLabel}),e.jsx(_,{sx:{...s.text.quartiary,color:"#FFFFFF",fontWeight:600,pt:.25},children:d.periodLabel}),b&&e.jsx(Ct,{variant:Vt(t.status),label:Ut(t.status,p)})]}),e.jsxs(j,{spacing:1.25,sx:{mt:"auto",pt:2.5,"& .MuiButton-root":{borderRadius:"8px",minHeight:35,px:1.5}},children:[c&&e.jsx(Y,{variant:"primary",size:"small",text:p("page.calendar.appointment_card.meeting_button"),disabled:!t.google_meet_link,onPress:n}),c&&e.jsx(Y,{variant:"secondary",size:"small",text:p("page.calendar.appointment_card.cancel_button"),disabled:!1,onPress:a})]})]},t.id)}function Kt({appointments:t,filteredAppointments:a,historyAppointments:n,selectedDate:s,view:o,onChangeView:i,selectedFilter:p,onChangeFilter:f,onCancelAppointment:d,onAccessMeeting:F}){const{novoTheme:b}=B(),c=J(),S=u.useRef(null),[R,E]=u.useState({key:"ongoing",page:1}),[g,V]=u.useState(1),W=u.useMemo(()=>[{id:"all",name:c("page.calendar.grid.filters.all")},{id:"future",name:c("page.calendar.grid.filters.future")},{id:"confirmed",name:c("page.calendar.grid.filters.confirmed")},{id:"rescheduled",name:c("page.calendar.grid.filters.rescheduled")},{id:"cancelled",name:c("page.calendar.grid.filters.cancelled")},{id:"expired",name:c("page.calendar.grid.filters.expired")},{id:"refund",name:c("page.calendar.grid.filters.refund")},{id:"completed",name:c("page.calendar.grid.filters.completed")}],[c]),P=u.useMemo(()=>o==="ongoing"?a:n,[a,n,o]);u.useEffect(()=>{const h=S.current;if(!h)return;const I=()=>{const w=h.clientWidth,y=w<600,z=y?16:w>=1200?14:24,M=y?w:243,G=y?Math.max(1,P.length):Math.max(1,Math.floor((w+z)/(M+z)));V(G)};I();const N=new ResizeObserver(()=>{I()});return N.observe(h),()=>{N.disconnect()}},[P.length]);const A=Math.max(1,Math.ceil(P.length/g)),T=`${s??"all"}:${o}`,q=Math.min(R.key===T?R.page:1,A),Z=u.useMemo(()=>{const h=(q-1)*g;return P.slice(h,h+g)},[g,q,P]),C=t.length===0?c("page.calendar.grid.empty"):c(o==="history"?"page.calendar.grid.empty_history":s?"page.calendar.grid.empty_selected_day":"page.calendar.grid.empty_filter");return e.jsxs(e.Fragment,{children:[e.jsxs(l,{children:[e.jsx(l,{sx:{display:"flex",justifyContent:"flex-end",mb:{xs:1.5,md:2}},children:e.jsx(l,{sx:{width:"100%",maxWidth:{xs:"100%",md:400}},children:e.jsx(wt,{label:c("page.calendar.grid.filters_label"),field:"status",value:W.find(h=>h.id===p)??null,options:W,haveRequirements:!0,onChange:h=>f(h?.id??"all")})})}),e.jsx(l,{sx:{borderBottom:"1px solid rgba(255,255,255,0.12)"},children:e.jsx(Ee,{value:o,options:[{value:"ongoing",label:c("page.calendar.grid.tabs.ongoing")},{value:"history",label:c("page.calendar.grid.tabs.history")}],onChange:h=>i(h),panelIdPrefix:"consultant-calendar-panel",ariaLabel:c("page.calendar.grid.tabs.label"),indicatorHeight:1})}),e.jsxs(l,{role:"tabpanel",id:`consultant-calendar-panel-${o}`,"aria-labelledby":`default-tab-${o}`,tabIndex:0,ref:S,sx:{mt:{xs:3,md:5},display:"flex",flexDirection:{xs:"column",md:"row"},flexWrap:"nowrap",gap:{xs:2,md:3,xl:1.75},ml:{xs:1,md:0},width:{xs:"calc(100% - 8px)",md:"100%"},overflow:"hidden"},children:[Z.length>0&&Z.map(h=>e.jsx(Yt,{appointment:h,onCancel:()=>d(h.id),onAccessMeeting:()=>F(h.id)},h.id)),Z.length===0&&e.jsx(l,{sx:{minHeight:283,p:{xs:2,md:2.25},display:"flex",alignItems:"center",justifyContent:"center",width:"100%"},children:e.jsx(_,{sx:{...b.text.tertiary,color:"#B7B7B7",textAlign:"center"},children:C})})]})]}),t.length>0&&A>1&&e.jsx(l,{sx:{display:"flex",justifyContent:"center",alignItems:"center",width:"100%",mt:"auto"}
1,children:e.jsx(kt,{shape:"rounded",boundaryCount:1,count:A,page:q,onChange:(h,I)=>E({key:T,page:I}),sx:{"& .MuiPaginationItem-root":{color:"#FFFFFF",backgroundColor:"transparent",fontWeight:500,"&:hover":{backgroundColor:"#2a2a2a"},"&.Mui-selected":{backgroundColor:"#1A1A1A",color:"#FFFFFF","&:hover":{backgroundColor:"#1f1f1f"}}}}})})]})}function Oe(t,a){return ze(t,a?.in).getDate()}function Zt(t,a){return ze(t,a?.in).getDay()}function Qt(t,a,n){return Ae(t,-1,n)}const Jt={backgroundColor:"#101010",border:"0.5px solid rgba(255,255,255,0.1)",borderRadius:"14px",boxSizing:"border-box"};function ei(t){return new Date(`${t}T12:00:00`)}function ti(t){const a=Wt(t),n=Mt(t),s=Oe(n),o=Zt(a),i=[];for(let p=0;p<o;p+=1)i.push(null);for(let p=1;p<=s;p+=1)i.push(new Date(a.getFullYear(),a.getMonth(),p,12,0,0));for(;i.length%7!==0;)i.push(null);return i}function ii({appointments:t,selectedDate:a,onSelectDate:n}){const{novoTheme:s}=B(),{locale:o}=se().props,i=J(),p=(o??"pt_BR").replace("_","-"),[f,d]=u.useState(()=>{const g=new Date;return new Date(g.getFullYear(),g.getMonth(),1,12,0,0)}),F=u.useMemo(()=>[i("page.calendar.selector.weekdays.sun"),i("page.calendar.selector.weekdays.mon"),i("page.calendar.selector.weekdays.tue"),i("page.calendar.selector.weekdays.wed"),i("page.calendar.selector.weekdays.thu"),i("page.calendar.selector.weekdays.fri"),i("page.calendar.selector.weekdays.sat")],[i]),b=u.useMemo(()=>t.map(g=>ei(g.appointment_date)).filter(g=>!Number.isNaN(g.getTime())),[t]),c=u.useMemo(()=>b.filter(g=>St(g,f)),[b,f]),S=u.useMemo(()=>ti(f),[f]),R=new Date,E=u.useMemo(()=>{const g=new Intl.DateTimeFormat(p,{month:"long",year:"numeric"}).format(f);return g&&`${g.charAt(0).toUpperCase()}${g.slice(1)}`},[f,p]);return e.jsx(l,{sx:{...Jt,p:2,px:2.5,minHeight:266},children:e.jsxs(j,{spacing:{xs:2,md:1.5},children:[e.jsxs(j,{direction:"row",justifyContent:"space-between",alignItems:"center",sx:{width:{xs:"100%",md:"calc(100% - 5px)"},pr:{md:1.25}},children:[e.jsx(_,{sx:{...s.text.secondary,color:"#FFFFFF",fontWeight:500},children:E}),e.jsxs(j,{direction:"row",spacing:2.25,children:[e.jsx(l,{component:"button",type:"button","aria-label":i("page.calendar.selector.previous_month"),onClick:()=>d(g=>Qt(g)),sx:{width:28,height:24,border:"none",p:0,cursor:"pointer",borderRadius:"2px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#272727",color:"#B7B7B7","&:focus-visible":{outline:`2px solid ${s.colors.primary}`,outlineOffset:"2px"}},children:e.jsx(It,{size:14})}),e.jsx(l,{component:"button",type:"button","aria-label":i("page.calendar.selector.next_month"),onClick:()=>d(g=>Ae(g,1)),sx:{width:28,height:24,border:"none",p:0,cursor:"pointer",borderRadius:"2px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"#272727",color:"#B7B7B7","&:focus-visible":{outline:`2px solid ${s.colors.primary}`,outlineOffset:"2px"}},children:e.jsx(Dt,{size:14})})]})]}),e.jsxs(l,{sx:{display:"grid",gridTemplateColumns:"repeat(7, minmax(0, 1fr))",columnGap:{xs:1,md:0},rowGap:{xs:1.1,md:.55},width:{xs:"100%",md:"calc(100% - 5px)"}},children:[F.map(g=>e.jsx(_,{sx:{...s.text.quartiary,color:"#FFFFFF",textAlign:"center",fontWeight:500},children:g},g)),S.map((g,V)=>{const W=g!==null&&_e(g,R),P=g!==null&&c.some(q=>_e(q,g)),A=g?At(g,"yyyy-MM-dd"):null,T=A!==null&&a===A;return e.jsx(l,{component:g?"button":"div",type:g?"button":void 0,"aria-label":g?new Intl.DateTimeFormat(p,{dateStyle:"full"}).format(g):void 0,"aria-pressed":g?T:void 0,onClick:g?()=>n(A):void 0,sx:{minHeight:24,display:"flex",alignItems:"center",justifyContent:"center",p:0,width:{xs:"100%",md:30},justifySelf:"center",borderRadius:"2px",outline:"none",cursor:g?"pointer":"default",backgroundColor:T?s.colors.primary:W?"#272727":P?"#4B380C":"transparent",border:T?`1px solid ${s.colors.primary}`:P?`1px solid ${s.colors.primary}`:"1px solid transparent","&:focus-visible":{outline:`2px solid ${s.colors.primary}`,outlineOffset:"2px"}},children:g&&e.jsx(_,{sx:{...s.text.quartiary,color:T?"#101010":P?s.colors.primary:"#FFFFFF",fontWeight:500,lineHeight:1},children:Oe(g)})},g?g.toISOString():`empty-${V}`)})]}),e.jsx(l,{sx:{height:"1px",width:{xs:"100%",md:"calc(100% - 5px)"},backgroundColor:K("#FFFFFF",.15)}}),e.jsxs(j,{direction:"row",spacing:{xs:3,md:4},children:[e.jsxs(j,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(l,{sx:{width:15,height:13,borderRadius:"2px",backgroundColor:"#272727"}}),e.jsx(_,{sx:{...s.text.seventiary,color:"#FFFFFF"},children:i("page.calendar.selector.legend.today")})]}),e.jsxs(j,{direction:"row",spacing:1,alignItems:"center",children:[e.jsx(l,{sx:{width:15,height:13,borderRadius:"2px",backgroundColor:"#4B380C"}}),e.jsx(_,{sx:{...s.text.seventiary,color:"#FFFFFF"},children:i("page.calendar.selector.legend.with_appointments")})]})]})]})})}function ai({open:t,processing:a,onClose:n,onConfirm:s}){const{novoTheme:o}=B(),i=J();return e.jsx(Me,{open:t,onClose:n,maxWidth:"xs",fullWidth:!0,"aria-labelledby":"
1consultant-cancel-dialog-title","aria-describedby":"consultant-cancel-dialog-description",PaperProps:{sx:{backgroundColor:"transparent",boxShadow:"none",maxWidth:"478px"}},children:e.jsx(Re,{sx:{backgroundColor:"#101010",borderRadius:"20px",px:{xs:2,sm:4},pt:{xs:3,sm:"39px"},pb:{xs:3,sm:"38px"}},children:e.jsxs(j,{spacing:{xs:3,sm:"33px"},children:[e.jsxs(j,{spacing:{xs:1.5,sm:"28px"},children:[e.jsx(_,{id:"consultant-cancel-dialog-title",sx:{...o.text.secondary,color:"#FFFFFF",fontWeight:600,fontSize:"16px"},children:i("page.calendar.cancel_dialog.title")}),e.jsxs(_,{id:"consultant-cancel-dialog-description",sx:{...o.text.quartiary,color:"#FFFFFF",lineHeight:1.45},children:[i("page.calendar.cancel_dialog.description_line_1"),e.jsx("br",{}),i("page.calendar.cancel_dialog.description_line_2")]})]}),e.jsxs(j,{direction:{xs:"column",sm:"row"},spacing:{xs:1.5,sm:"22px"},sx:{mx:{sm:"-4px"},"& .MuiButton-root":{width:{xs:"100%",sm:201},minHeight:35,borderRadius:"8px"}},children:[e.jsx(Y,{variant:"secondary",size:"small",text:i("page.calendar.cancel_dialog.back_button"),disabled:a,onPress:n}),e.jsx(Y,{variant:"primary",size:"small",text:i("page.calendar.cancel_dialog.confirm_button"),textWhenDisabled:i("page.calendar.cancel_dialog.processing_button"),disabled:a,onPress:s})]})]})})})}const si={backgroundColor:"#101010",border:"0.5px solid rgba(255,255,255,0.1)",borderRadius:"14px",boxSizing:"border-box"};function ni({appointments:t}){const{novoTheme:a}=B(),n=J(),s=u.useMemo(()=>[{id:"total",title:n("page.calendar.summary.total_appointments"),value:t.length,icon:e.jsx(Te,{size:16,color:a.colors.primary})},{id:"cancelled",title:n("page.calendar.summary.cancelled"),value:t.filter(o=>o.status==="cancelled").length,icon:e.jsx(zt,{size:16,color:a.colors.primary})},{id:"rescheduled",title:n("page.calendar.summary.rescheduled"),value:new Set(t.flatMap(o=>o.reschedule_ids)).size,icon:e.jsx(Rt,{size:16,color:a.colors.primary})}],[t,a.colors.primary,n]);return e.jsx(l,{sx:{display:"grid",gridTemplateColumns:{xs:"130px minmax(0, 1fr)",md:"repeat(2, minmax(0, 1fr))",xl:"repeat(2, minmax(0, 1fr))"},columnGap:{xs:2,md:2.25},rowGap:{xs:2,md:1.75},gridColumn:{xs:"auto",md:"2 / -1"},width:"100%",maxWidth:{md:608},justifySelf:{md:"start"},alignSelf:"start"},children:s.map((o,i)=>e.jsxs(l,{sx:{...si,minHeight:{xs:i===0?110:125,md:125},p:{xs:2.5,md:3.5},display:"flex",flexDirection:"column",justifyContent:"space-between",gridColumn:{xs:i===0?"1 / -1":"auto",md:i===2?"1 / 2":"auto",xl:i===2?"1 / 2":"auto"}},children:[e.jsx(_,{sx:{...a.text.secondary,color:"#FFFFFF",fontSize:{md:"16px"},fontWeight:600,lineHeight:{md:"normal"}},children:o.title}),e.jsxs(l,{sx:{display:"flex",alignItems:"center",gap:{xs:1.25,md:2.25}},children:[e.jsx(_,{sx:{...a.text.secondary,color:"#FFFFFF",fontSize:{xs:"25px",md:"25px"},fontWeight:600,lineHeight:{xs:1,md:"normal"}},children:o.value}),e.jsx(l,{sx:{width:30,height:30,borderRadius:"6px",backgroundColor:"#272727",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,"& svg":{width:{xs:16,md:18},height:{xs:16,md:18}}},children:o.icon})]})]},o.id))})}function Be(t,a){const n=t.resolved_starts_at??t.starts_at;if(n){const s=new Date(n);return Number.isNaN(s.getTime())?null:s}return!t.appointment_date||!t.start_time?null:vt(t.appointment_date,t.start_time,a,t.source_timezone).localDate}function ve(t,a){const n=Be(t,a);if(!n)return null;const s=new Intl.DateTimeFormat("en-CA",{timeZone:a,year:"numeric",month:"2-digit",day:"2-digit"}).formatToParts(n),o=Object.fromEntries(s.map(({type:i,value:p})=>[i,p]));return o.year&&o.month&&o.day?`${o.year}-${o.month}-${o.day}`:null}function we(t,a,n,s){const o=new Date;return t.filter(i=>{const p=Be(i,s),f=p?p>o:!1;if(!(n==="ongoing"?f:!f))return!1;switch(a){case"future":return n==="ongoing"?f:!1;case"confirmed":return i.status==="confirmed";case"rescheduled":return i.reschedule_ids.length>0;case"cancelled":return i.status==="cancelled";case"expired":return i.status==="expired";case"refund":return i.status==="refund";case"completed":return i.status==="completed";default:return!0}})}function oi({appointments:t}){const[a,n]=u.useState(null),[s,o]=u.useState(!1),[i,p]=u.useState(null),[f,d]=u.useState("future"),[F,b]=u.useState("ongoing"),c=h=>{b(h),d(h==="history"?"all":"future")},{novoTheme:S,toastConfig:R}=B(),E=J(),{locale:g}=se().props,V=(g??"pt_BR").replace("_","-"),{active_timezone:W}=he(),P=u.useMemo(()=>t.map(h=>({...h,appointment_date:ve(h,W)??h.appointment_date})),[W,t]),A=u.useMemo(()=>i?t.filter(h=>ve(h,W)===i):t,[W,t,i]),T=u.useMemo(()=>we(A,f,"ongoing",W),[W,A,f]),q=u.useMemo(()=>we(A,f,"history",W),[W,A,f]),Z=async h=>{if(h)try{o(!0),(await Q.delete(`/api/admin/consultant/appointments/${h.id}`)).data.success&&$.success(E("page.calendar.toasts.cancel_success"),R)}catch(I){$.error(E("page.calendar.toasts.cancel_error"),R),console.error(E("page.calendar.toasts.cancel_error")+" ",I)}finally{at.reload({only:["appointments"]}),n(null),o(!1)}},C=i?new Intl.DateTimeFormat(V).format(new Date(`${i}T12:00:00`)):null;return e.jsxs(e.Fragment,{children:[e.jsxs(l,{sx:{width:"100%",maxWidth:{xs:316,md:1047,xl:1275},mx:"auto",display:"flex",flexDirection:"column",gap:{xs:3,md:4},pb:{xs:3,md:1}},children:[e.jsxs(l,{children:[e.jsx(_,{sx:{...S.text.secondary,color:"#FFFFFF",fontWeight:600,mb:{xs:2,md:2.5}},children:C?E("page.calendar.grid.title_by_date",{date:C}):E("page.calendar.grid.title")}),e.jsxs(l,{sx:{display:"grid",gridTemplateColumns:{xs:"1fr",md:"minmax(0, 405px) minmax(0, 1fr)",xl:"405px minmax(0, 1fr) minmax(0, 1fr)"},gap:{xs:2,md:3},alignItems:"start"},children:[e.jsx(ii,{appointments:P,selectedDate:i,onSelectDate:h=>{const I=i===h?null:h;p(I),d(I?"all":F==="ongoing"?"future":"all")}}),e.jsx(ni,{appointments:F==="ongoing"?T:q})]})]}),e.jsx(Kt,{appointments:t,filteredAppointments:T,historyAppointments:q,selectedDate:i,view:F,onChangeView:c,selectedFilter:f,onChangeFilter:d,onCancelAppointment:h=>{const I=t.find(N=>N.id===h)??null;n(I)},onAccessMeeting:h=>{const I=t.find(N=>N.id===h);if(!I?.google_meet_link){$.error(E("page.calendar.toasts.meeting_unavailable"),R);return}window.open(I.google_meet_link,"_blank","noopener noreferrer")}})]}),e.jsx(ai,{open:!!a,onClose:()=>n(null),onConfirm:()=>Z(a),processing:s})]})}function Ce({open:t,title:a,titleId:n="availability-dialog-title",description:s,descriptionId:o="availability-dialog-description",descriptionPlacement:i="header",closeLabel:p,onClose:f,children:d,footer:F,contentOverflow:b="auto",mobileBottomSheet:c=!1}
1){const{novoTheme:S}=B();return e.jsx(Me,{open:t,onClose:f,scroll:c?"paper":"body",maxWidth:"sm",fullWidth:!0,sx:{"& .MuiDialog-container":{alignItems:{xs:c?"flex-end":"center",sm:"center"}}},"aria-labelledby":n,"aria-describedby":s?o:void 0,BackdropProps:{sx:{backgroundColor:"rgba(0, 0, 0, 0.5)"}},PaperProps:{sx:{backgroundColor:"transparent",boxShadow:"none",position:{xs:c?"fixed":"relative",sm:"relative"},left:{xs:c?0:"auto",sm:"auto"},right:{xs:c?0:"auto",sm:"auto"},width:{xs:c?"100vw":"100%",sm:"calc(100% - 32px)"},maxWidth:{xs:c?"100vw":629,sm:629},minWidth:0,minHeight:0,height:{xs:c?"87.375dvh":"auto",sm:"auto"},maxHeight:c?{xs:"87.375dvh",sm:"auto"}:{xs:"calc(100dvh - 32px)",sm:"calc(100dvh - 32px)"},boxSizing:"border-box",margin:{xs:0,sm:2},bottom:{xs:c?0:"auto",sm:"auto"},borderRadius:{xs:c?"42px 42px 0 0":"14px 14px 0 0",sm:"20px"},overflow:"visible"}},children:e.jsx(Re,{sx:{backgroundColor:"#101010",borderRadius:{xs:c?"42px 42px 0 0":"14px 14px 0 0",sm:"20px"},display:c?"flex":void 0,flexDirection:c?"column":void 0,px:{xs:2,sm:"33px"},py:{xs:2.25,sm:3},height:c?"100%":"auto",maxHeight:c?"100%":"calc(100dvh - 32px)",boxSizing:"border-box",minWidth:0,minHeight:0,overflowY:c?"hidden":b,overflowX:b==="auto"?"hidden":"visible",...S.modal.scrollbarSx},children:e.jsxs(j,{spacing:3,sx:{height:c?"100%":void 0,minHeight:0},children:[e.jsxs(j,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:1,children:[e.jsx(_,{id:n,sx:{...S.text.secondary,color:"#FFFFFF",fontWeight:500,fontSize:"16px"},children:a}),p?e.jsx(de,{size:"small","aria-label":p,onClick:f,sx:{color:"#FFFFFF",p:.5,"&:hover":{backgroundColor:"rgba(255,255,255,0.08)"},"&.Mui-focusVisible":{outline:"2px solid #FEB000",outlineOffset:2}},children:e.jsx(Tt,{size:18})}):null]}),s&&i==="header"?e.jsx(_,{id:o,sx:{...S.text.tertiary,color:"#BEBEBE"},children:s}):null,e.jsx(l,{sx:{minHeight:0,overflowY:c?b:void 0,flex:c?"1 1 auto":void 0},children:d}),e.jsx(l,{sx:{mt:c?"auto":void 0,flexShrink:0},children:F})]})})})}function ri(t){return t.replaceAll("-"," - ")}function li(t,a){const n=new Date(`${t}T12:00:00`);if(Number.isNaN(n.getTime()))return"";const s=n.toLocaleDateString(a,{weekday:"long"});return s&&`${s.charAt(0).toUpperCase()}${s.slice(1)}`}function di(t,a){const[n,s]=t.split(":").map(Number),[o,i]=a.split(":").map(Number),p=o*60+i-(n*60+s);return p>0?p:p+1440}function pe({label:t,muted:a=!1}){return e.jsx(le,{label:t,size:"small",sx:{height:16,borderRadius:"5px",border:`1px solid ${a?"rgba(255,255,255,0.35)":"rgba(254,176,0,0.85)"}`,backgroundColor:a?"rgba(255,255,255,0.04)":"rgba(226,178,4,0.05)",color:a?"#A8A8A8":"rgba(254,176,0,0.85)",fontSize:"10px",fontWeight:500,"& .MuiChip-label":{px:.75,lineHeight:1}}})}function He({schedule:t,t:a,formatScheduleTime:n}){const{novoTheme:s}=B();return e.jsxs(j,{direction:{xs:"column",md:"row"},alignItems:{md:"center"},spacing:1,sx:{minWidth:0,flex:1},children:[e.jsx(_,{sx:{...s.text.quartiary,color:"#FFFFFF",fontWeight:600,fontSize:"12px",lineHeight:1.25,overflowWrap:"anywhere"},children:n(t.start_time,t.end_time)}),e.jsxs(j,{direction:"row",spacing:1,flexWrap:"wrap",useFlexGap:!0,children:[e.jsxs(_,{sx:{...s.text.seventiary,color:"#FFFFFF",fontSize:"12px",fontWeight:600},children:["•"," ",a("page.availability.weekly_schedule.duration",{minutes:di(t.start_time,t.end_time)})]}),t.source_type==="manual"&&e.jsx(pe,{label:a("page.availability.chips.manual")}),t.has_active_appointment?e.jsx(pe,{label:a("page.availability.chips.reserved")}):t.is_available?null:e.jsx(pe,{label:a("page.availability.chips.blocked")}),t.is_locked&&!t.can_edit_time&&e.jsx(pe,{label:a("page.availability.chips.locked"),muted:!0})]})]})}function ci({schedule:t,onToggle:a,onEdit:n,onDelete:s,availableLabel:o,blockedLabel:i,editLabel:p,deleteLabel:f}){const{novoTheme:d}=B(),F={color:"#8E8E8E",p:.5,"&:hover":{color:d.colors.primaryHover,backgroundColor:K(d.colors.primary,.08)},"&.Mui-focusVisible":{outline:`2px solid ${d.colors.primary}`,outlineOffset:2}};return e.jsxs(j,{direction:"row",spacing:.5,justifyContent:"flex-end",sx:{flexShrink:0},children:[e.jsx(ue,{title:t.is_available?i:o,arrow:!0,children:e.jsx("span",{children:e.jsx(de,{size:"small",disabled:!t.can_toggle,onClick:()=>a(t,!t.is_available),"aria-label":t.is_available?i:o,sx:F,children:t.is_available?e.jsx(Pt,{size:14}):e.jsx($t,{size:14})})})}),e.jsx(ue,{title:p,arrow:!0,children:e.jsx("span",{children:e.jsx(de,{size:"small",disabled:!t.can_edit_time,onClick:()=>n(t),"aria-label":p,sx:F,children:e.jsx(Et,{size:14})})})}),e.jsx(ue,{title:f,arrow:!0,children:e.jsx("span",{children:e.jsx(de,{size:"small",disabled:!t.can_delete,onClick:()=>s(t),"aria-label":f,sx:F,children:e.jsx($e,{size:14})})})})]})}function Le({title:t,panelId:a,expanded:n,onToggle:s,children:o}){const{novoTheme:i}=B();return e.jsxs(j,{spacing:0,sx:{width:"100%",maxWidth:1089,mx:"auto",backgroundColor:"#101010",borderRadius:"14px",overflow:"hidden"},children:[e.jsxs(Ie,{"aria-controls":a,"aria-expanded":n,onClick:s,sx:{width:"100%",justifyContent:"space-between",px:{xs:2,md:2.25},minHeight:49,py:0,backgroundColor:"#272727",color:"#FFFFFF",textAlign:"left","&:hover":{backgroundColor:"#2C2C2B"}},children:[e.jsxs(j,{direction:"row",spacing:1.25,alignItems:"center",children:[e.jsx(Te,{size:16}),e.jsx(_,{id:`${a}-label`,sx:{...i.text.quartiary,color:"#FFFFFF",fontSize:"14px",lineHeight:1.25,fontWeight:600},children:t})]}),e.jsx(Pe,{size:18,style:{transform:n?"rotate(180deg)":void 0}})]}),n&&o?e.jsx(l,{id:a,sx:{backgroundColor:"#101010"},children:o}):null]})}function pi({date:t,locale:a,children:n}){const[s,o]=u.useState(!1),i=`schedule-group-${t}`,p=li(t,a);return e.jsx(Le,{title:`${p?`${p} • `:""}${ri(t)}`,panelId:i,expanded:s,onToggle:()=>
1o(f=>!f),children:n})}function ui({title:t,description:a,actionLabel:n,onAction:s,loading:o,loadingMessage:i,empty:p,emptyMessage:f,children:d}){const{novoTheme:F}=B();return e.jsxs(j,{spacing:{xs:2.5,md:3},sx:{width:"100%",maxWidth:1089,mx:"auto"},children:[e.jsxs(j,{spacing:1.5,children:[e.jsxs(l,{children:[e.jsx(_,{sx:{...F.text.primary,color:"#FFFFFF",fontWeight:600,fontSize:"16px"},children:t}),e.jsx(_,{sx:{...F.text.tertiary,color:"#FFFFFF",mt:1.25,fontSize:"14px"},children:a})]}),e.jsx(l,{sx:{width:"fit-content"},children:e.jsx(Y,{variant:"primary",size:"small",text:n,disabled:!1,onPress:s,textSx:{minWidth:113,height:30,borderRadius:"8px",px:1.5,py:0}})})]}),o?e.jsx(l,{sx:{minHeight:49,display:"grid",placeItems:"center"},children:e.jsx(_,{sx:{...F.text.tertiary,color:"#8E8E8E"},children:i})}):p?e.jsx(l,{sx:{minHeight:49,display:"grid",placeItems:"center"},children:e.jsx(_,{sx:{...F.text.tertiary,color:"#8E8E8E",textAlign:"center"},children:f})}):d]})}function xi(){return{PaperProps:{sx:{backgroundColor:"#1A1A1A",color:"#FFFFFF","& .MuiMenuItem-root.Mui-selected":{backgroundColor:"#242424"},"& .MuiMenuItem-root.Mui-selected:hover":{backgroundColor:"#2B2B2B"}}}}}const mi={"& .MuiOutlinedInput-root, &.MuiOutlinedInput-root":{height:30,borderRadius:"5px",backgroundColor:"#202020",color:"#FFFFFF",fontSize:"12px"},"& .MuiOutlinedInput-notchedOutline":{border:"none"},"&:hover .MuiOutlinedInput-notchedOutline":{border:"none"},"&.Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"},"& .Mui-focused .MuiOutlinedInput-notchedOutline":{border:"none"},"& .MuiInputBase-input":{color:"#FFFFFF",fontSize:"12px",py:0},"& .MuiSelect-select":{color:"#FFFFFF",fontSize:"12px",display:"flex",alignItems:"center"}},gi={"& button":{height:"30px !important",borderRadius:"5px !important",backgroundColor:"#202020 !important",fontSize:"12px !important",paddingInline:"8px !important",display:"flex",alignItems:"center",justifyContent:"flex-start",gap:"8px"},"& button > span:first-of-type":{order:2,padding:"0 !important",minWidth:0,lineHeight:1},"& button > span:last-of-type":{order:1,position:"static",transform:"none",display:"flex",alignItems:"center",lineHeight:0},"& button svg":{width:14,height:14,transform:"translateY(7px)"}};function fi({className:t}){return e.jsx(Pe,{className:t,size:16})}function ke({value:t,label:a,onChange:n}){return e.jsx(l,{sx:{width:"100%",flex:"1 1 0",minWidth:0,...gi},children:e.jsx(xe,{type:"time",value:t,onChange:n,fullWidth:!1,width:"100%",ariaLabel:a})})}function hi({rule:t,onChange:a,onRemove:n,t:s}){const o=s("page.availability.weekly_schedule.duration",{minutes:t.slot_duration_min});return e.jsxs(l,{sx:{display:"grid",gridTemplateColumns:{xs:"minmax(0, 1fr) auto minmax(0, 1fr) auto",sm:"minmax(0, 1fr) auto minmax(0, 1fr) minmax(0, 1fr) auto"},alignItems:"center",columnGap:1.25,rowGap:{xs:1,sm:0},width:"100%",minWidth:0,minHeight:{xs:72,sm:47},height:{xs:"auto",sm:47},px:1.5,pt:{xs:"13px",sm:0},pb:{xs:1,sm:0},border:"0.5px solid #272727",borderRadius:"8px",boxSizing:"border-box"},children:[e.jsx(ke,{value:t.start_time,label:s("page.availability.rule_dialog.start"),onChange:i=>a({start_time:i})}),e.jsx(_,{sx:{flexShrink:0,color:"#8E8E8E",fontSize:"11px",whiteSpace:"nowrap"},children:s("page.availability.rule_dialog.until")}),e.jsx(ke,{value:t.end_time,label:s("page.availability.rule_dialog.end"),onChange:i=>a({end_time:i})}),e.jsx(xt,{sx:{gridColumn:{xs:"1 / 4",sm:"auto"},gridRow:{xs:2,sm:"auto"},minWidth:0,width:"100%"},children:e.jsxs(mt,{value:t.slot_duration_min,onChange:i=>a({slot_duration_min:Number(i.target.value)}),inputProps:{"aria-label":s("page.availability.rule_dialog.duration")},renderValue:()=>o,IconComponent:fi,MenuProps:xi(),sx:{...mi,minWidth:0,"& .MuiSelect-icon":{color:"#FFFFFF",right:10,top:"calc(50% - 8px)",transition:"transform 200ms"},"& .MuiSelect-select":{paddingRight:"28px"}},children:[e.jsx(je,{value:30,sx:{fontSize:"12px"},children:s("page.availability.rule_dialog.duration_30")}),e.jsx(je,{value:60,sx:{fontSize:"12px"},children:s("page.availability.rule_dialog.duration_60")})]})}),e.jsx(de,{"aria-label":s("page.availability.rule_dialog.delete"),onClick:n,sx:{gridColumn:{xs:4,sm:"auto"},gridRow:{xs:1,sm:"auto"},flexShrink:0,minWidth:0,p:.5,ml:"auto",color:"#FFFFFF","&:hover":{color:"#FEB000",backgroundColor:"transparent"}},children:e.jsx($e,{size:15})})]})}function ae(t){return t?t.slice(0,5):""}function bi(t=0){return{weekday:t,start_time:"09:00",end_time:"09:30",slot_duration_min:30,is_active:!0}}function yi(t){return{date:t,start_time:"09:00",end_time:"09:30",is_available:!0}}function Se(t,a){return`${ae(t)} - ${ae(a)}`}function Fi(t){return t.map(a=>({...a}))}function X(t){const[a,n]=t.split(":").map(Number);return a*60+n}function _i(t){return t.some((a,n)=>t.some((s,o)=>n===o||a.weekday!==s.weekday?!1:X(a.start_time)<X(s.end_time)&&X(s.start_time)<X(a.end_time)))}function ji(t){return t[0]?.weekday??0}function vi(t){return[...new Set(t.map(a=>a.weekday))]}function We(t){const a=t%1440,n=Math.floor(a/60),s=a%60;return`${String(n).padStart(2,"0")}
1:${String(s).padStart(2,"0")}`}function wi(t){const a=[{start_time:t.start_time,end_time:t.end_time}],n=Number(t.slot_duration_min),s=X(t.start_time),o=X(t.end_time);if(!Number.isInteger(n)||n<=0||!Number.isFinite(s)||!Number.isFinite(o))return a;const i=[],p=o<=s?o+1440:o;for(let f=s;f<p;f+=n){const d=f+n;if(d>p)break;i.push({start_time:We(f),end_time:We(d)})}return i.length>0?i:a}function Ci({weekday:t,rules:a,formatScheduleTime:n,t:s}){const{novoTheme:o}=B(),[i,p]=u.useState(!1),f=`weekday-rules-automatic-list-${t.id}`,d=a.flatMap((F,b)=>wi(F).map((c,S)=>({rule:F,ruleIndex:b,slot:c,slotIndex:S})));return e.jsx(Le,{title:t.label,panelId:f,expanded:i,onToggle:()=>p(F=>!F),children:e.jsx(l,{sx:{minHeight:a.length?void 0:64,p:a.length?1.5:0},children:a.length===0?e.jsx(l,{sx:{minHeight:64,display:"grid",placeItems:"center",px:2},children:e.jsx(_,{sx:{...o.text.seventiary,color:"rgba(255,255,255,0.5)",fontSize:"12px",fontWeight:600,textAlign:"center"},children:s("page.availability.weekly_schedule.empty_day")})}):e.jsx(j,{spacing:1.25,children:d.map(({rule:F,ruleIndex:b,slot:c,slotIndex:S})=>e.jsx(l,{sx:{border:"0.5px solid rgba(255,255,255,0.35)",borderRadius:"10px",px:2,py:1.9},children:e.jsx(He,{schedule:{id:F.id??b,consultant_id:0,date:"",start_time:c.start_time,end_time:c.end_time,source_type:"generated",default_rule_id:F.id??null,is_locked:!1,is_available:F.is_active,has_active_appointment:!1,can_toggle:!1,can_edit_time:!0,can_delete:!1},t:s,formatScheduleTime:n})},`${t.id}-${F.id??b}-${S}`))})})})}function ki({consultant:t,mode:a}){const{novoTheme:n,toastConfig:s}=B(),{locale:o}=se().props,i=J(),p=i("page.availability.toasts.load_error"),f=(o??"pt_BR").replace("_","-"),d=u.useMemo(()=>[{id:0,label:i("page.availability.weekdays.sunday")},{id:1,label:i("page.availability.weekdays.monday")},{id:2,label:i("page.availability.weekdays.tuesday")},{id:3,label:i("page.availability.weekdays.wednesday")},{id:4,label:i("page.availability.weekdays.thursday")},{id:5,label:i("page.availability.weekdays.friday")},{id:6,label:i("page.availability.weekdays.saturday")}],[i]),[F,b]=u.useState([]),[c,S]=u.useState([]),[R,E]=u.useState(t.default_window_days??21),[g,V]=u.useState(!1),[W,P]=u.useState(!1),[A,T]=u.useState(!1),[q,Z]=u.useState(!1),[C,h]=u.useState(null),[I,N]=u.useState(!1),[w,y]=u.useState(null),[z,M]=u.useState(null),G=u.useRef(0),[ee]=u.useState(()=>new Date().toISOString().slice(0,10)),x=u.useMemo(()=>{const r=new Date;return r.setDate(r.getDate()+R),r.toISOString().slice(0,10)},[R]),D=u.useMemo(()=>c.reduce((r,m)=>(r[m.date]||(r[m.date]=[]),r[m.date].push(m),r),{}),[c]),O=u.useMemo(()=>d.reduce((r,m)=>(r[m.id]=F.filter(v=>v.weekday===m.id),r),{}),[F,d]),H=t?.id,U=u.useCallback(async()=>{const r=++G.current;if(!H){b([]),S([]);return}V(!0);try{const m=await Q.get("/api/admin/consultant/schedule-management",{params:{consultant_id:H,date_from:ee,date_to:x}});if(r!==G.current)return;const v=Array.isArray(m.data?.default_availability)?m.data.default_availability:[],k=Array.isArray(m.data?.schedules)?m.data.schedules:[],L=m.data?.consultant?.default_window_days;[7,14,21,30].includes(L)&&E(L),b(v.map(ne=>({...ne,start_time:ae(ne.start_time),end_time:ae(ne.end_time)}))),S(k)}catch(m){r===G.current&&$.error(m?.response?.data?.message??p,s)}finally{r===G.current&&V(!1)}},[H,ee,x,p,s]);u.useEffect(()=>{(async()=>await U())()},[U]);const me=r=>!r.start_time||!r.end_time||X(r.end_time)<=X(r.start_time)||(X(r.end_time)-X(r.start_time))%r.slot_duration_min!==0?"page.availability.toasts.validation_error":null,ce=r=>r.some(m=>me(m))||_i(r)?"page.availability.toasts.validation_error":null,qe=async()=>{if(!t?.id||!C||C.type!=="weekly")return;const r=C.rules.filter(v=>C.selectedWeekdays.includes(v.weekday)),m=ce(r);if(m){$.error(i(m),s);return}P(!0);try{await Q.put("/api/admin/consultant/default-availability",{consultant_id:t.id,default_window_days:C.defaultWindowDays,rules:r.map(v=>({weekday:v.weekday,start_time:v.start_time,end_time:v.end_time,slot_duration_min:v.slot_duration_min,is_active:v.is_active}))}),$.success(i("page.availability.toasts.save_rules_success"),s),E(C.defaultWindowDays),await U(),be()}catch(v){$.error(v?.response?.data?.message??i("page.availability.toasts.save_rules_error"),s)}finally{P(!1)}},Ne=r=>{h(m=>m&&{...m,rules:m.rules.filter(v=>v!==r)})},Ge=r=>{h(m=>m&&{...m,selectedWeekday:r,selectedWeekdays:m.selectedWeekdays.includes(r)?m.selectedWeekdays:[...m.selectedWeekdays,r],rules:[...m.rules,{...bi(r)}]})},Ue=(r,m)=>{h(v=>v&&{...v,rules:v.rules.map((k,L)=>L===r?{...k,...m}:k)})},Ve=()=>{h({type:"weekly",rules:Fi(F),defaultWindowDays:R,selectedWeekday:ji(F),selectedWeekdays:vi(F)}),Z(!0)};function be(){Z(!1),h(null)}const Xe=()=>{h(r=>r&&{...r,rules:[],selectedWeekdays:[]})},Ye=()=>{y(yi(ee)),N(!0)},Ke=r=>
1{z!==r.id&&(y({id:r.id,date:r.date,start_time:ae(r.start_time),end_time:ae(r.end_time),is_available:r.is_available}),N(!0))},ge=()=>{N(!1),y(null)},Ze=async()=>{if(!t?.id||!w||z===w.id)return;const r=!w.date||!w.start_time||!w.end_time||X(w.end_time)<=X(w.start_time)||![30,60].includes(X(w.end_time)-X(w.start_time))?i("page.availability.toasts.validation_error"):null;if(r){$.error(r,s);return}T(!0);try{w.id?await Q.put(`/api/admin/consultant/schedules/${w.id}`,{consultant_id:t.id,date:w.date,start_time:w.start_time,end_time:w.end_time,is_available:w.is_available}):await Q.post("/api/admin/consultant/schedules",{consultant_id:t.id,date:w.date,start_time:w.start_time,end_time:w.end_time,is_available:w.is_available}),$.success(i("page.availability.toasts.save_schedule_success"),s),await U(),ge()}catch(m){$.error(m?.response?.data?.message??i("page.availability.toasts.save_schedule_error"),s)}finally{T(!1)}},Qe=async(r,m)=>{if(!(!t?.id||!r.can_toggle||z!==null)){M(r.id);try{await Q.put(`/api/admin/consultant/schedules/${r.id}/availability`,{consultant_id:t.id,is_available:m}),$.success(i(m?"page.availability.toasts.schedule_released_success":"page.availability.toasts.schedule_blocked_success"),s),await U()}catch(v){$.error(v?.response?.data?.message??i("page.availability.toasts.schedule_update_error"),s)}finally{M(null)}}},Je=async r=>{if(!(!t?.id||!r.can_delete||z!==null)){M(r.id);try{await Q.delete(`/api/admin/consultant/schedules/${r.id}`,{data:{consultant_id:t.id}}),$.success(i("page.availability.toasts.delete_schedule_success"),s),await U()}catch(m){$.error(m?.response?.data?.message??i("page.availability.toasts.delete_schedule_error"),s)}finally{M(null)}}};return e.jsxs(e.Fragment,{children:[e.jsxs(l,{sx:{width:"100%",display:"flex",flexDirection:"column",gap:{xs:2.5,lg:3},maxWidth:1089,mx:"auto",pb:{xs:3,md:1}},children:[e.jsx(j,{direction:{xs:"column",sm:"row"},justifyContent:"space-between",alignItems:{sm:"flex-end"},spacing:{xs:1.5,sm:2},sx:{display:a==="automatic"?"flex":"none"},children:e.jsxs(j,{spacing:1.5,alignItems:"flex-start",sx:{flex:1,minWidth:0},children:[e.jsxs(l,{children:[e.jsx(_,{sx:{...n.text.primary,color:"#FFFFFF",fontWeight:600,fontSize:"16px"},children:i("page.availability.weekly_schedule.title")}),e.jsx(_,{sx:{...n.text.tertiary,color:"#FFFFFF",fontSize:"14px",mt:1.25},children:i("page.availability.weekly_schedule.description")})]}),e.jsx(j,{direction:{xs:"column",sm:"row"},alignItems:{xs:"stretch",sm:"center"},spacing:{xs:.5,md:1.5},children:e.jsx(l,{sx:{width:{xs:"100%",sm:"auto"}},children:e.jsx(Y,{variant:"primary",size:"small",text:i("page.availability.weekly_schedule.configure_schedule"),disabled:!1,startIcon:e.jsx(Ot,{size:16}),onPress:Ve,textSx:{borderRadius:"8px",minWidth:120,height:35,py:0}})})})]})}),e.jsx(j,{spacing:2,sx:{display:a==="automatic"?"flex":"none",width:"100%"},children:d.map(r=>e.jsx(Ci,{weekday:r,rules:O[r.id]??[],formatScheduleTime:Se,t:i},`${r.id}-${g}`))}),e.jsxs(j,{spacing:2,sx:{display:a==="manual"?"flex":"none"},children:[e.jsx(ui,{title:i("page.availability.future_schedules.title"),description:i("page.availability.future_schedules.description"),actionLabel:i("page.availability.future_schedules.new_time"),onAction:Ye,loading:g,loadingMessage:i("page.availability.future_schedules.loading"),empty:Object.keys(D).length===0,emptyMessage:i("page.availability.future_schedules.empty")}),!g&&Object.keys(D).length>0&&e.jsx(j,{spacing:2,children:Object.entries(D).map(([r,m])=>e.jsx(pi,{date:r,locale:f,children:e.jsx(l,{sx:{p:{xs:2,md:2.25}},children:e.jsx(j,{spacing:1.5,children:m.map(v=>e.jsxs(j,{direction:"row",justifyContent:"space-between",alignItems:"center",spacing:2,"aria-busy":z===v.id,sx:{minWidth:0,minHeight:45,border:`0.5px solid ${K("#FFFFFF",.35)}`,borderRadius:"8px",px:2,py:0,opacity:z===v.id?.65:1,"& .MuiIconButton-root":{color:n.colors.primary,"&:hover":{color:n.colors.primaryHover,backgroundColor:K(n.colors.primary,.08)},"&.Mui-focusVisible":{outline:`2px solid ${n.colors.primary}`,outlineOffset:2},"&.Mui-disabled":{color:n.colors.primaryDisabled}}},children:[e.jsx(He,{schedule:v,t:i,formatScheduleTime:Se}),e.jsx(ci,{schedule:v,onToggle:Qe,onEdit:Ke,onDelete:Je,availableLabel:i("page.availability.schedule_dialog.release"),blockedLabel:i("page.availability.schedule_dialog.block"),editLabel:i("page.availability.schedule_dialog.edit_action"),deleteLabel:i("page.availability.schedule_dialog.delete_action")})]},v.id))})})},r))})]})]}),e.jsx(Ce,{open:a==="automatic"&&q,mobileBottomSheet:!0,titleId:"configure-agenda-dialog-title",descriptionId:"configure-agenda-dialog-description",descriptionPlacement:"content",onClose:()=>{W||be()},title:i("page.availability.weekly_schedule.configure_schedule"),description:i("page.availability.weekly_schedule.configure_description"),contentOverflow:"auto",footer
1:e.jsxs(j,{direction:"row",flexWrap:"nowrap",justifyContent:"flex-end",spacing:1.5,children:[e.jsx(Y,{variant:"secondary",size:"small",text:i("page.availability.weekly_schedule.clear"),bgColor:"#272727",disabled:W||!C,onPress:Xe,textSx:{width:{xs:"calc((100% - 12px) / 2)",sm:131},height:35,minWidth:0,flexShrink:1,borderRadius:"8px",px:1.5,py:0}}),e.jsx(Y,{variant:"primary",size:"small",text:i("page.availability.weekly_schedule.save"),disabled:W||C?.type!=="weekly",onPress:qe,textSx:{width:{xs:"calc((100% - 12px) / 2)",sm:131},height:35,minWidth:0,flexShrink:1,borderRadius:"8px",px:1.5,py:0}})]}),closeLabel:i("page.availability.weekly_schedule.cancel"),children:C?e.jsxs(j,{spacing:2,children:[e.jsxs(j,{spacing:1,children:[e.jsx(_,{sx:{...n.text.tertiary,color:"#FFFFFF",fontWeight:500},children:i("page.availability.weekly_schedule.type")}),e.jsx(_,{id:"configure-agenda-dialog-description",sx:{...n.text.tertiary,color:"#BEBEBE"},children:i("page.availability.weekly_schedule.configure_description")}),e.jsxs(j,{direction:"row",spacing:0,role:"group","aria-label":i("page.availability.weekly_schedule.type"),sx:{position:"relative",width:"100%",height:37,minHeight:37,backgroundColor:"#4B380C",borderRadius:"15px",overflow:"hidden"},children:[e.jsx(l,{"aria-hidden":"true",sx:{position:"absolute",inset:0,width:"50%",height:"100%",borderRadius:"15px",backgroundColor:"#FEB000",transform:C.type==="monthly"?"translateX(100%)":"translateX(0)",transition:"transform 240ms cubic-bezier(0.4, 0, 0.2, 1)",pointerEvents:"none","@media (prefers-reduced-motion: reduce)":{transition:"none"}}}),["weekly","monthly"].map(r=>{const m=C.type===r;return e.jsx(Ie,{"aria-pressed":m,onClick:()=>h(v=>v&&{...v,type:r}),sx:{flex:1,position:"relative",zIndex:1,minHeight:37,px:0,py:0,borderRadius:"15px",border:"none",backgroundColor:"transparent",color:n.colors.onPrimary,fontSize:"14px",fontWeight:600,"&:focus-visible":{outline:`2px solid ${n.colors.primary}`,outlineOffset:-2}},children:i(`page.availability.weekly_schedule.${r}`)},r)})]})]}),C.type==="monthly"?e.jsx(l,{sx:{minHeight:{xs:"clamp(160px, 28dvh, 260px)",sm:"clamp(240px, 45dvh, 590px)"},overflowX:"hidden"},children:e.jsx(_,{sx:{...n.text.tertiary,color:"#BEBEBE"},children:i("page.availability.weekly_schedule.monthly_unavailable")})}):e.jsx(l,{children:e.jsxs(j,{spacing:1,children:[e.jsx(_,{sx:{...n.text.tertiary,color:"#FFFFFF",fontWeight:500},children:i("page.availability.weekly_schedule.select_days")}),e.jsx(j,{direction:"row",spacing:1,useFlexGap:!0,role:"group","aria-label":i("page.availability.weekly_schedule.select_days"),sx:{flexWrap:"wrap",rowGap:"14.5px"},children:d.map(r=>{const m=C.selectedWeekdays.includes(r.id),v=C.rules.filter(k=>k.weekday===r.id);return e.jsxs(u.Fragment,{children:[e.jsxs(j,{direction:"row",alignItems:"center",justifyContent:"space-between",spacing:{xs:1.25,sm:2},onClick:()=>h(k=>k&&{...k,selectedWeekday:r.id}),sx:{width:"100%",p:{xs:1.5,sm:1.75},borderRadius:"10px",backgroundColor:"#1A1A1A"},children:[e.jsxs(j,{direction:"row",alignItems:"center",spacing:1.25,sx:{minWidth:0},children:[e.jsx(Bt,{checked:m,onClick:k=>k.stopPropagation(),onChange:k=>h(L=>L&&{...L,selectedWeekdays:k.target.checked?[...new Set([...L.selectedWeekdays,r.id])]:L.selectedWeekdays.filter(ne=>ne!==r.id)}),icon:e.jsx(l,{component:"span",sx:{width:15,height:15,border:"2px solid #FEB000",borderRadius:"4px"}}),checkedIcon:e.jsx(l,{component:"span",sx:{width:15,height:15,display:"grid",placeItems:"center",borderRadius:"4px",backgroundColor:"#FEB000",color:"#101010"},children:e.jsx(Ht,{size:8,strokeWidth:5})}),inputProps:{"aria-label":r.label},sx:{flexShrink:0,p:.5,color:"#FEB000",cursor:"pointer","&.Mui-focusVisible":{outline:"2px solid #FEB000",outlineOffset:2}}}),e.jsx(l,{role:"button",tabIndex:0,"aria-label":`${r.label}: ${i("page.availability.weekly_schedule.select_days")}`,"aria-pressed":C.selectedWeekday===r.id,onClick:()=>h(k=>k&&{...k,selectedWeekday:r.id}),onKeyDown:k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),h(L=>L&&{...L,selectedWeekday:r.id}))},sx:{minWidth:0,cursor:"pointer","&:focus-visible":{outline:`2px solid ${n.colors.primary}`,outlineOffset:2}},children:e.jsx(_,{sx:{...n.text.quartiary,color:"#FFFFFF",fontWeight:500},children:r.label})})]}),m?e.jsx(l,{sx:{width:"auto",minWidth:0,flexShrink:0},children:e.jsx(Y,{variant:"secondary",size:"small",text:i("page.availability.weekly_schedule.add_time"),disabled:W,startIcon:e.jsx(Lt,{size:15}),onPress:k=>{k.stopPropagation(),Ge(r.id)},textSx:{width:{xs:"min(164px, 46vw)",sm:164},height:28,minWidth:0,px:0,border:"1px solid rgba(255,255,255,0.5)",backgroundColor:"transparent",color:"#FFFFFF",borderRadius:"8px",fontSize:"12px",fontWeight:500,"&:hover":{backgroundColor:K("#FFFFFF",.07)}}})}):null]}),m?v.map(k=>e.jsx(hi,{rule:k,t:i,onChange:L=>Ue(C.rules.indexOf(k),L),onRemove:()=>Ne(k)},`${r.id}-${k.id??C.rules.indexOf(k)}`)):null]},r.id)})})]})})]}):null}),e.jsx(Ce,{open:a==="manual"&&I,titleId:"manual-schedule-dialog-title",onClose:()=>{A||ge()},title:w?.id?i("page.availability.schedule_dialog.edit_title"):i("page.availability.schedule_dialog.create_title"),contentOverflow:"visible",footer:e.jsxs(j,{direction:"row",flexWrap:"nowrap",justifyContent:"flex-end",spacing:1.5,children:[e.jsx(Y,{variant:"secondary",size:"small",text:i("page.availability.schedule_dialog.cancel"),bgColor:"#272727",disabled:A,onPress:ge,textSx:{width:{xs:"calc((100% - 12px) / 2)",sm:131},height:35,minWidth:0,flexShrink:1,borderRadius:"8px",px:1.5,py:0}}),e.jsx(Y,{variant:"primary",size:"small",text:i("page.availability.schedule_dialog.save"),disabled:A,onPress:Ze,textSx:{width:{xs:"calc((100% - 12px) / 2)",sm:131},height:35,minWidth:0,flexShrink:1,borderRadius:"8px",px:1.5,py:0}})]}),children:e.jsxs(j,{spacing:2,children:[e.jsx(xe,{fullWidth:!0,type:"date",value:w?.date??"",onChange:r=>y(m=>m&&{...m,date:r})}),e.jsxs(j,{direction:{xs:"column",sm:"row"},spacing:2.75,children:[e.jsx(l,{sx:{flex:1,minWidth:0},children:e.jsx(xe,{fullWidth:!0,label:i("page.availability.schedule_dialog.start"),type:"time",value:w?.start_time??"",onChange:r=>y(m=>m&&{...m,start_time:r})})}),e.jsx(l,{sx:{flex:1,minWidth:0},children:e.jsx(xe,{fullWidth:!0,label:i("page.availability.schedule_dialog.end"),type:"time",value:w?.end_time??"",onChange:r=>y(m=>m&&{...m,end_time:r})})})]})]})})]})}function fe(t){const{children:a,value:n,index:s,disableGutters:o}=t,{novoTheme:i}=B();return n!==s?null:e.jsx(l,{role:"tabpanel",id:`default-tabpanel-${s}`,"aria-labelledby":`default-tab-${s}`,sx:{width:"100%",flex:1,minHeight:0,paddingTop:{xs:1.5,md:3},px:o?0:{xs:2,sm:3,md:4,xl:5},overflowY:"auto",...i.modal.scrollbarSx},children:a})}function Bs(){const{novoTheme:t}=B(),a=J(),{consultant:n,appointments:s}=se().props,[o,i]=u.useState(n?"calendar":"profile"),p=o==="automatic"?"automatic":o==="manual"?"manual":null,f=n?[{value:"calendar",label:a("page.page_tabs.calendar")},{value:"manual",label:a("page.page_tabs.manual_scheduling")},{value:"automatic",label:a("page.page_tabs.automatic_scheduling")},{value:"profile",label:a("page.page_tabs.profile")}]:[{value:"profile",label:a("page.page_tabs.profile")}];return e.jsx(_t,{children:e.jsxs(l,{sx:{display:"flex",flexDirection:"column",width:"100%",minHeight:"100%",height:"100%",py:{xs:2,md:2.5},boxSizing:"border-box",overflow:"hidden"},children:[e.jsx(l,{sx:{width:"100%",maxWidth:{xs:"100%",xl:1275},mx:"auto",boxSizing:"border-box",borderBottom:`1px solid ${K(t.colors.border,.4)}`,px:{xs:2,sm:3,md:4,xl:5}},children:e.jsx(Ee,{value:o,options:f,onChange:d=>i(d),ariaLabel:a("page.title"),indicatorHeight:1,scrollable:!0})}),e.jsx(fe,{value:o,index:"calendar",children:e.jsx(oi,{appointments:s})}),p?e.jsx(fe,{value:o,index:o,children:n&&e.jsx(ki,{consultant:n,mode:p})}):null,e.jsx(fe,{value:o,index:"profile",disableGutters:!0,children:e.jsx(l,{sx:{width:"100%",maxWidth:{xs:"100%",xl:1275},mx:"auto",boxSizing:"border-box",px:{xs:2,sm:3,md:4,xl:5}},children:e.jsx(Gt,{consultant:n,onSuccess:()=>st.reload({only:["consultant","appointments"]})})})})]})})}export{Bs 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.