import{r as m,j as e}from"./client-BbMi5ewG.js";import{u as Oe,A as Be}from"./ActionButton-CK3Uoxvt.js";import{C as Re}from"./CrudLayout-Cx6KhKUY.js";import{B as G}from"./Button-1dacbE2T.js";import{I as F}from"./input-DhCVOJC-.js";import{D as Ge,a as Ue,E as Ve,b as ze,c as be}from"./dropdown-menu-B1ZTMBvw.js";import{c as Fe,a as ye,X as ve}from"./utils-Q0fnGDhj.js";import{S as I}from"./skeleton-ImO4uxQ7.js";import{a as H,u as V,s as _,c as We,f as qe}from"./store-jX25q14N.js";import{C as He}from"./ConfirmDialog-C2asEKXG.js";import{S as Ze}from"./Search-BPdeYakj.js";import{E as Je}from"./Edit-C8qVzzd7.js";import{T as Xe}from"./Trash-AmoyyqPS.js";import{C as B,a as R}from"./card-CZBIFpqn.js";import{B as Ye}from"./badge-C2Ir4HoT.js";import{u as Ee,i as Ke,M as Ne,f as Qe,R as es,g as Z}from"./index-CM0LBdHD.js";import{V as q,C as _e,G as ss,S as ts,b as we}from"./CalenderCheck-BuHSX8YD.js";import{D as Ce}from"./dollar-sign-DRtWdm2i.js";import{U as as}from"./user-jdISm6se.js";import{C as is}from"./code-C_CKrAh6.js";import{C as ke}from"./check-DMod5j-l.js";import{C as Me}from"./copy-C2TM1za3.js";import{L as rs,T as Q}from"./time-picker-MqsQbh0l.js";import{L as y}from"./label-1wXMewvs.js";import{T as ns}from"./textarea-QytFj8hO.js";import{S as Se,a as Ae,b as De,c as Pe,f as J}from"./select-CPHcJnpt.js";import{S as U}from"./switch-BXH9Uq5p.js";import{T as ls,a as os,b as X,c as Y}from"./tabs-sf64UEkO.js";import{G as cs,S as ds,P as ms}from"./GoogleCalender-V160dMVJ.js";import{G as xs,Z as hs}from"./Zoom-BvAPmLs4.js";import{P as z}from"./ProFeatureCard-jTC0MhR9.js";import{T as Le}from"./trash-2-wbt0ZJUy.js";import{P as te}from"./plus-DcvXjop0.js";import{D as us}from"./date-picker-Dhqqi79b.js";import{u as ps}from"./useValidation-ETdGTgzi.js";import{I as gs}from"./ImageUpload-DbfzQEp2.js";import{u as fs}from"./useMediaUploader-lszBTVoc.js";import{I as js}from"./withIconDefaults-C8UfSjn1.js";import{C as bs}from"./calendar-CjyQ6Zau.js";import{C as Te}from"./circle-alert-CG2uW-Df.js";import{A as ys,a as vs}from"./arrow-right-B8h6q6X7.js";import{S as se}from"./save-CE8wXkbA.js";import"./vendor-DDjlQeP6.js";import"./loader-circle--S58donA.js";import"./ArrowLeftIcon-DrGyoHe_.js";import"./index-BbWn2ja9.js";import"./index-CeptMk_f.js";import"./dialog-C9IQloQy.js";import"./index-BE6isdVb.js";import"./circle-CwRJMw1I.js";import"./lodash-Bd-B7UeG.js";import"./defineProperty-DbXIQDXj.js";import"./typeof-QjJsDpFa.js";import"./apiConfig-D-T4C2Ae.js";import"./index-D59bwJy3.js";import"./toast-1-c8k_LJ.js";import"./preload-helper-Dp1pzeXC.js";import"./tag-CvsOfBQf.js";import"./shield-Bmp_421z.js";import"./proxy-DChtKkEh.js";import"./circle-check-big-uMTsaxsq.js";import"./scroll-area-BldTLQYj.js";import"./popover-C75zZF26.js";import"./index-C4Ytkwtd.js";import"./crown-BdDHOvET.js";import"./lock-DbcYKLM6.js";import"./format-KhiMdRwp.js";/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const Ns=[["path",{d:"M4.2 4.2A2 2 0 0 0 3 6v14a2 2 0 0 0 2 2h14a2 2 0 0 0 1.82-1.18",key:"16swn3"}],["path",{d:"M21 15.5V6a2 2 0 0 0-2-2H9.5",key:"yhw86o"}],["path",{d:"M16 2v4",key:"4m81vk"}],["path",{d:"M3 10h7",key:"1wap6i"}],["path",{d:"M21 10h-5.5",key:"quycpq"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],_s=Fe("calendar-off",Ns);/**
 * @license lucide-react v0.525.0 - ISC
 *
 * This source code is licensed under the ISC license.
 * See the LICENSE file in the root directory of this source tree.
 */const ws=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],Cs=Fe("link-2",ws);function ks(){const d=H(),o=Ee(),l=Ke(),{filters:v,meetingTypes:N,loading:k,pagination:w}=V(t=>{const x=t(_);return{filters:x.getMeetingTypeFilters(),meetingTypes:x.getMeetingTypes(),loading:x.getMeetingTypeLoading(),pagination:x.getMeetingTypePagination()}},[]),p=m.useMemo(()=>JSON.stringify(v),[v]),[f,j]=m.useState(0);m.useEffect(()=>{d(_).fetchMeetingTypes(v)},[d,p,f,l.pathname]);const[b,S]=m.useState(""),[E,D]=m.useState(!1),[$,C]=m.useState(null),[a,L]=m.useState(null),P=(t,x)=>{try{const g=document.createElement("textarea");g.value=t,g.style.position="fixed",g.style.opacity="0",document.body.appendChild(g),g.select(),document.execCommand("copy"),document.body.removeChild(g),L(x),setTimeout(()=>L(null),2e3)}catch{navigator.clipboard&&navigator.clipboard.writeText(t).then(()=>{L(x),setTimeout(()=>L(null),2e3)})}},i=t=>{C(t),D(!0)},h=async()=>{await d(_).deleteMeetingType($),D(!1),d(_).fetchMeetingTypes(v)},r=m.useMemo(()=>{if(!b)return N;const t=b.toLowerCase();return N.filter(x=>{var g,O;return((g=x.name)==null?void 0:g.toLowerCase().includes(t))||((O=x.description)==null?void 0:O.toLowerCase().includes(t))})},[N,b]),c=t=>{if(!t)return"N/A";if(t<60)return`${t} min`;const x=Math.floor(t/60),g=t%60;return g>0?`${x}h ${g}m`:`${x}h`},n=(t,x)=>{const g=parseFloat(t);return!g||g===0?"Free":`${x||"$"}${g.toFixed(2)}`},u=t=>{switch(t){case"online":return"Online";case"in_person":return"In Person";case"phone":return"Phone";default:return t||"N/A"}};return k?e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rtrb-card p-6",children:e.jsx("div",{className:"flex items-center gap-4",children:e.jsx(I,{className:"h-[45px] w-full max-w-md rounded-[8px]"})})}),[1,2,3].map(t=>e.jsx("div",{className:"bg-white rounded-2xl rtrb-card overflow-hidden p-4",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(I,{className:"w-10 h-10 rounded-xl flex-shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(I,{className:"h-5 w-1/3 rounded"}),e.jsx(I,{className:"h-4 w-2/3 rounded"})]}),e.jsx(I,{className:"h-6 w-16 rounded-full"}),e.jsx(I,{className:"h-4 w-20 rounded"}),e.jsx(I,{className:"h-4 w-16 rounded"}),e.jsx(I,{className:"h-9 w-9 rounded-lg"})]})},t))]}):e.jsxs(e.Fragment,{children:[e.jsxs("main",{className:"min-h-screen",children:[e.jsx("header",{className:"z-40 p-0",children:e.jsx("div",{className:"rtrb-card p-6",children:e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs("div",{className:"relative flex-1 max-w-md mr-auto",children:[e.jsx(Ze,{className:"absolute right-3 top-1/2 -translate-y-1/2 text-small-font"}),e.jsx(F,{placeholder:"Search meeting types...",className:"h-[45px] bg-white rounded-[8px]",value:b,onChange:t=>S(t.target.value)})]})})})}),e.jsx("div",{className:"py-6 space-y-3",children:r.length>0?r.map(t=>e.jsxs("div",{className:"group bg-white border border-border rounded-xl overflow-hidden hover:shadow-md transition-all duration-200",children:[e.jsxs("div",{className:"px-5 py-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-1 min-w-0",children:[e.jsx("div",{className:"w-11 h-11 rounded-xl overflow-hidden flex items-center justify-center text-white font-bold shrink-0",style:{backgroundColor:t.color||"#0040ff"},children:t.picture_thumb_path?e.jsx("img",{className:"w-full h-full object-cover",alt:t.name,src:t.picture_thumb_path,loading:"lazy"}):e.jsx(q,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{onClick:()=>o(`${t.id}/edit`),className:"font-semibold text-[15px] text-title cursor-pointer hover:text-primary truncate",children:t.name}),t.description&&e.jsx("p",{className:"text-sm text-title2 mt-0.5 line-clamp-1",children:t.description})]})]}),e.jsxs("div",{className:"flex items-center gap-3 shrink-0",children:[e.jsxs("div",{className:"hidden md:flex items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-title bg-gray-50 border border-border px-2.5 py-1 rounded-md",children:[e.jsx(_e,{className:"w-3.5 h-3.5 text-primary"}),c(t.duration)]}),e.jsxs("span",{className:ye("inline-flex items-center gap-1.5 text-xs font-medium px-2.5 py-1 rounded-md border",parseFloat(t.price)>0?"text-green-700 bg-green-50 border-green-200":"text-title bg-gray-50 border-border"),children:[e.jsx(Ce,{className:"w-3.5 h-3.5"}),n(t.price,t.currency_symbol)]}),e.jsxs("span",{className:"inline-flex items-center gap-1.5 text-xs font-medium text-title bg-gray-50 border border-border px-2.5 py-1 rounded-md",children:[e.jsx(Ne,{className:"w-3.5 h-3.5 text-primary"}),u(t.location_type)]})]}),t.employee_name&&e.jsxs("span",{className:"hidden lg:inline-flex items-center gap-1.5 text-xs font-medium text-title bg-gray-50 border border-border px-2.5 py-1 rounded-md",children:[e.jsx(as,{className:"w-3.5 h-3.5 text-primary"}),t.employee_name]}),e.jsx(Ye,{className:ye("text-[11px] shrink-0",Number(t.is_active)===1?"bg-green-100 text-green-700 hover:bg-green-100":"bg-gray-100 text-gray-500 hover:bg-gray-100"),children:Number(t.is_active)===1?"Active":"Inactive"}),e.jsxs(Ge,{children:[e.jsx(Ue,{asChild:!0,children:e.jsx(G,{variant:"ghost",size:"icon",className:"h-9 w-9 rounded-lg bg-gray-50 group-hover:bg-gray-100",children:e.jsx(Ve,{className:"w-4 h-4"})})}),e.jsxs(ze,{align:"end",className:"w-48",children:[e.jsxs(be,{onClick:()=>o(`${t.id}/edit`),className:"cursor-pointer",children:[e.jsx(Je,{})," Edit Meeting Type"]}),e.jsxs(be,{onClick:()=>i(t.id),className:"cursor-pointer text-red-600 focus:text-red-600",children:[e.jsx(Xe,{})," Delete Meeting Type"]})]})]})]})]}),e.jsxs("div",{className:"flex md:hidden items-center gap-2 mt-3 flex-wrap",children:[e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-title bg-gray-50 border border-border px-2 py-0.5 rounded-md",children:[e.jsx(_e,{className:"w-3 h-3 text-primary"})," ",c(t.duration)]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-title bg-gray-50 border border-border px-2 py-0.5 rounded-md",children:[e.jsx(Ce,{className:"w-3 h-3"})," ",n(t.price,t.currency_symbol)]}),e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-title bg-gray-50 border border-border px-2 py-0.5 rounded-md",children:[e.jsx(Ne,{className:"w-3 h-3 text-primary"})," ",u(t.location_type)]})]})]}),t.slug&&e.jsx("div",{className:"px-5 py-2.5 bg-[#FAFBFC] border-t border-border/60",children:e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(is,{className:"w-3 h-3 text-slate-400 shrink-0"}),e.jsx("code",{className:"text-[11px] bg-slate-100 text-slate-600 px-2 py-0.5 rounded font-mono select-all",children:`[rtrb_meeting_booking slug="${t.slug}"]`}),e.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),P(`[rtrb_meeting_booking slug="${t.slug}"]`,`sc-${t.id}`)},className:"p-1 rounded hover:bg-slate-200 transition-colors shrink-0",title:"Copy shortcode",children:a===`sc-${t.id}`?e.jsx(ke,{className:"w-3 h-3 text-green-600"}):e.jsx(Me,{className:"w-3 h-3 text-slate-400"})})]}),t.shareable_url&&e.jsx("div",{className:"w-px h-4 bg-border hidden sm:block"}),t.shareable_url&&e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(rs,{className:"w-3 h-3 text-slate-400 shrink-0"}),e.jsx("code",{className:"text-[11px] bg-blue-50 text-blue-600 px-2 py-0.5 rounded font-mono truncate max-w-[350px] select-all",children:t.shareable_url}),e.jsx("button",{type:"button",onClick:x=>{x.stopPropagation(),P(t.shareable_url,`url-${t.id}`)},className:"p-1 rounded hover:bg-slate-200 transition-colors shrink-0",title:"Copy booking URL",children:a===`url-${t.id}`?e.jsx(ke,{className:"w-3 h-3 text-green-600"}):e.jsx(Me,{className:"w-3 h-3 text-slate-400"})})]})]})})]},t.id)):e.jsx(B,{className:"border-border shadow-sm",children:e.jsx(R,{className:"flex items-center justify-center py-16",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-16 h-16 bg-blue-100 rounded-full flex items-center justify-center mx-auto mb-4",children:e.jsx(q,{className:"w-8 h-8 text-blue-600"})}),e.jsx("h3",{className:"text-lg font-bold text-title mb-2",children:"No Meeting Types Found"}),e.jsx("p",{className:"text-sm text-small-font",children:"Create your first meeting type to get started."})]})})})})]}),e.jsx(He,{open:E,onClose:()=>D(!1),onConfirm:h,title:"Are you sure?",description:"This action will permanently delete this meeting type.",confirmText:"Delete"})]})}const Ie=[{index:0,label:"Sunday",name:"sunday"},{index:1,label:"Monday",name:"monday"},{index:2,label:"Tuesday",name:"tuesday"},{index:3,label:"Wednesday",name:"wednesday"},{index:4,label:"Thursday",name:"thursday"},{index:5,label:"Friday",name:"friday"},{index:6,label:"Saturday",name:"saturday"}],ee={start_time:"09:00",end_time:"17:00"};function Ms(d){return d?Ie.filter(o=>{var l;return(l=d[o.name])==null?void 0:l.enabled}).map(o=>{const l=d[o.name];return{day_of_week:o.index,start_time:l.start||"09:00",end_time:l.end||"17:00",time_windows:[{start_time:l.start||"09:00",end_time:l.end||"17:00"}]}}):[]}function Ss(){var P;const d=H(),o=V(i=>i(_).getMeetingType(),[]),l=o.availability||[],[v,N]=m.useState(null),k=!!((P=o==null?void 0:o.settings)!=null&&P.useCustomAvailability),w=m.useRef(o);w.current=o,m.useEffect(()=>{We("weeklySchedule").then(i=>{var r;const h=((r=i==null?void 0:i.data)==null?void 0:r.data)||(i==null?void 0:i.data)||null;N(h)}).catch(()=>{})},[]);const p=m.useMemo(()=>Ms(v),[v]),f=m.useCallback(i=>{const r={...w.current,...i};w.current=r,d(_).setMeetingTypeData(r)},[d]),j=m.useCallback(i=>{f({availability:i})},[f]),b=m.useCallback(i=>{const h=w.current,r=h.settings&&typeof h.settings=="object"?h.settings:{};if(i){const c=p.length>0?p:[];f({availability:c,settings:{...r,useCustomAvailability:!0}})}else f({availability:[],settings:{...r,useCustomAvailability:!1}})},[p,f]),S=i=>l.find(h=>h.day_of_week===i)||null,E=i=>{const h=S(i);j(h?l.filter(r=>r.day_of_week!==i):[...l,{day_of_week:i,start_time:ee.start_time,end_time:ee.end_time,time_windows:[{...ee}]}])},D=(i,h,r,c)=>{const n=l.map(u=>{var x,g;if(u.day_of_week!==i)return u;const t=u.time_windows?[...u.time_windows]:[{start_time:u.start_time,end_time:u.end_time}];return t[h]={...t[h],[r]:c},{...u,time_windows:t,start_time:((x=t[0])==null?void 0:x.start_time)||u.start_time,end_time:((g=t[0])==null?void 0:g.end_time)||u.end_time}});j(n)},$=i=>{const h=l.map(r=>{if(r.day_of_week!==i)return r;const c=r.time_windows?[...r.time_windows]:[{start_time:r.start_time,end_time:r.end_time}];return{...r,time_windows:[...c,{start_time:"13:00",end_time:"17:00"}]}});j(h)},C=(i,h)=>{const r=l.map(c=>{var u,t;if(c.day_of_week!==i)return c;const n=(c.time_windows||[]).filter((x,g)=>g!==h);return n.length===0?null:{...c,time_windows:n,start_time:((u=n[0])==null?void 0:u.start_time)||c.start_time,end_time:((t=n[0])==null?void 0:t.end_time)||c.end_time}}).filter(Boolean);j(r)},a=k?l:p,L=(i,h)=>{const r=a.find(u=>u.day_of_week===i.index)||null,c=!!r,n=(r==null?void 0:r.time_windows)||(r?[{start_time:r.start_time,end_time:r.end_time}]:[]);return e.jsxs("div",{className:`flex items-start gap-4 p-3 rounded-lg border transition-colors ${c?"border-border bg-white":"border-transparent bg-gray-50"}`,children:[e.jsxs("div",{className:"flex items-center gap-3 w-36 pt-1.5",children:[h?e.jsx(U,{checked:c,onCheckedChange:()=>E(i.index)}):e.jsx("div",{className:`w-4 h-4 rounded-full ${c?"bg-green-500":"bg-gray-300"}`}),e.jsx("span",{className:`text-sm font-medium ${c?"text-title":"text-muted-foreground"}`,children:i.label})]}),c&&e.jsxs("div",{className:"flex-1 space-y-2",children:[n.map((u,t)=>e.jsx("div",{className:"flex items-center gap-2",children:h?e.jsxs(e.Fragment,{children:[e.jsx(Q,{value:u.start_time||"09:00",onChange:x=>D(i.index,t,"start_time",x)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(Q,{value:u.end_time||"17:00",onChange:x=>D(i.index,t,"end_time",x)}),n.length>1&&e.jsx(G,{variant:"ghost",size:"icon",className:"h-8 w-8 text-red-400 hover:text-red-600 hover:bg-red-50",onClick:()=>C(i.index,t),children:e.jsx(Le,{className:"w-3.5 h-3.5"})})]}):e.jsxs("span",{className:"text-sm text-title",children:[u.start_time||"09:00"," — ",u.end_time||"17:00"]})},t)),h&&e.jsxs(G,{variant:"ghost",size:"sm",className:"text-xs text-primary hover:text-primary/80 h-7 px-2",onClick:()=>$(i.index),children:[e.jsx(te,{className:"w-3 h-3 mr-1"})," Add time window"]})]}),!c&&e.jsx("div",{className:"flex-1 pt-1.5",children:e.jsx("span",{className:"text-sm text-muted-foreground",children:"Unavailable"})})]},i.index)};return e.jsx(B,{className:"border-border shadow-sm",children:e.jsxs(R,{className:"p-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-title mb-1",children:"Weekly Availability"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-5",children:"Set the hours available for this meeting type."}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-border bg-white mb-5",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-blue-50 border border-blue-100",children:e.jsx(ss,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-title",children:"Custom Schedule"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:k?"This meeting type has a custom availability schedule":"This meeting type follows the global schedule from Settings"})]})]}),e.jsx(U,{checked:k,onCheckedChange:b})]}),e.jsx("div",{className:"space-y-3",children:Ie.map(i=>L(i,k))})]})})}function As(){const d=H(),o=V(p=>p(_).getMeetingType(),[]),l=o.date_overrides||[],v=m.useCallback(p=>{d(_).setMeetingTypeData({...o,date_overrides:p})},[o,d]),N=()=>{v([...l,{override_date:"",is_unavailable:!0,start_time:"09:00",end_time:"17:00"}])},k=p=>{v(l.filter((f,j)=>j!==p))},w=(p,f,j)=>{const b=l.map((S,E)=>E!==p?S:{...S,[f]:j});v(b)};return e.jsx(B,{className:"border-border shadow-sm",children:e.jsxs(R,{className:"p-6",children:[e.jsxs("div",{className:"flex items-center justify-between mb-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold text-title",children:"Date Overrides"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Override availability for specific dates (e.g. holidays, special hours)."})]}),e.jsxs(G,{variant:"outline",size:"sm",onClick:N,className:"h-9 text-sm",children:[e.jsx(te,{className:"w-4 h-4 mr-1"}),"Add Date Override"]})]}),l.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(_s,{className:"w-10 h-10 text-muted-foreground mx-auto mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No date overrides configured."}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Add overrides for holidays or special availability."})]}):e.jsx("div",{className:"space-y-3",children:l.map((p,f)=>{const j=p.is_unavailable===!0||p.is_unavailable===1||p.is_unavailable==="1";return e.jsxs("div",{className:"flex items-end gap-4 p-4 rounded-lg border border-border bg-white",children:[e.jsxs("div",{className:"space-y-1 w-48",children:[e.jsx(y,{className:"text-xs text-muted-foreground",children:"Date"}),e.jsx(us,{date:p.override_date,setDate:b=>w(f,"override_date",b),placeholder:"Pick a date",className:"h-9"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{className:"text-xs text-muted-foreground",children:"Availability"}),e.jsxs("div",{className:"flex items-center gap-2 h-9",children:[e.jsx(U,{checked:!j,onCheckedChange:b=>w(f,"is_unavailable",!b)}),e.jsx("span",{className:`text-sm font-medium ${j?"text-red-500":"text-green-600"}`,children:j?"Closed":"Open (Custom Hours)"})]})]}),!j&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{className:"text-xs text-muted-foreground",children:"Start"}),e.jsx(Q,{value:p.start_time||"09:00",onChange:b=>w(f,"start_time",b)})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{className:"text-xs text-muted-foreground",children:"End"}),e.jsx(Q,{value:p.end_time||"17:00",onChange:b=>w(f,"end_time",b)})]})]}),e.jsx("div",{className:"flex-1"}),e.jsx(G,{variant:"ghost",size:"icon",className:"h-9 w-9 text-red-400 hover:text-red-600 hover:bg-red-50 shrink-0",onClick:()=>k(f),children:e.jsx(Le,{className:"w-4 h-4"})})]},f)})})]})})}const W=["general","availability","advanced","settings"];function Ds(d){return d?typeof d=="string"?d:d!=null&&d.first_message?d.first_message:Array.isArray(d==null?void 0:d.messages)?d.messages[0]:null:null}function Ps({activeTab:d="general",onTabChange:o,onSave:l,isSaving:v=!1}){var ae,ie,re,ne,le,oe,ce,de,me,xe,he,ue,pe;const N=H(),{id:k}=Qe(),w=m.useMemo(()=>k!==void 0,[k]),[p,f]=m.useState([]),[j,b]=m.useState(!1),S=W.indexOf(d),E=S===0,D=S===W.length-1,$=()=>{E||o==null||o(W[S-1])},C=async()=>{const s=D?null:W[S+1];await(l==null?void 0:l(s))&&s&&(o==null||o(s))},{meetingType:a,loading:L,errors:P}=V(s=>{const M=s(_);return{meetingType:M.getMeetingType(),loading:M.getMeetingTypeLoading(),errors:M.getMeetingTypeError()}},[]),i=m.useMemo(()=>({name:[{check:s=>!!(s!=null&&s.trim()),message:"Meeting type name is required"},{check:s=>(s==null?void 0:s.length)>=2,message:"Min 2 characters"}],employee_id:[{check:s=>!!s,message:"Please select an host"}],duration:[{check:s=>!!s,message:"Duration is required"},{check:s=>Number(s)>=1,message:"Min 1 minute"}]}),[]),{validate:h}=ps(i,s=>N(_).setMeetingTypeError(s));m.useEffect(()=>(window.__meetingTypeValidate=()=>h(a),()=>{delete window.__meetingTypeValidate}),[a,h]),m.useEffect(()=>(w&&N(_).fetchMeetingType(k),()=>{N(_).setDefaultMeetingType()}),[k]),m.useEffect(()=>{b(!0),qe().then(s=>{var A;const M=((A=s==null?void 0:s.data)==null?void 0:A.map(T=>({value:String(T.id),label:(T.first_name||"")+" "+(T.last_name||"")})))||[];f(M)}).catch(()=>{f([])}).finally(()=>{b(!1)})},[]);const r=((ae=window.radius_booking_param)==null?void 0:ae.is_pro)||!1,c=m.useRef(a);c.current=a;const n=m.useCallback((s,M)=>{const A=c.current||{};let T;if(s.startsWith("settings.")){const ge=s.split("."),fe=ge[1],$e=ge[2],je=A.settings&&typeof A.settings=="object"?A.settings:{};T={...A,settings:{...je,[fe]:{...je[fe]||{},[$e]:M}}}}else T={...A,[s]:M};c.current=T,N(_).setMeetingTypeData(T)},[N]),u=s=>{const M=P==null?void 0:P[s],A=Ds(M);return A?e.jsxs("p",{className:"text-xs text-red-600 flex items-center gap-1 mt-1",children:[e.jsx(Te,{className:"h-3 w-3 shrink-0"}),A]}):null},t=fs(),x=m.useCallback(()=>{t({title:"Select Meeting Type Image",onSelect:({url:s,sizes:M})=>{var T;const A=c.current||{};c.current={...A,picture_full_path:s,picture_thumb_path:((T=M==null?void 0:M.thumbnail)==null?void 0:T.url)||s},N(_).setMeetingTypeData(c.current)}})},[t,N]),g=m.useCallback(()=>{const s=c.current||{};c.current={...s,picture_full_path:"",picture_thumb_path:""},N(_).setMeetingTypeData(c.current)},[N]),O=s=>P!=null&&P[s]?"border-red-300 focus:border-red-500 focus:ring-red-200 bg-red-50/50":"";return L?e.jsx("div",{className:"space-y-6",children:e.jsx(B,{className:"border-border shadow-sm",children:e.jsx(R,{className:"p-6 space-y-4",children:[1,2,3,4,5].map(s=>e.jsxs("div",{className:"space-y-2",children:[e.jsx(I,{className:"h-4 w-24 rounded"}),e.jsx(I,{className:"h-10 w-full rounded"})]},s))})})}):e.jsxs("div",{children:[e.jsxs(ls,{value:d,onValueChange:o,className:"w-full",children:[e.jsxs(os,{className:"bg-white border border-border rounded-lg p-1 mb-6",children:[e.jsxs(X,{value:"general",className:"flex items-center gap-2 data-[state=active]:bg-primary data-[state=active]:text-white rounded-md px-4 py-2",children:[e.jsx(js,{className:"w-4 h-4"}),"General"]}),e.jsxs(X,{value:"availability",className:"flex items-center gap-2 data-[state=active]:bg-primary data-[state=active]:text-white rounded-md px-4 py-2",children:[e.jsx(bs,{className:"w-4 h-4"}),"Availability"]}),e.jsxs(X,{value:"advanced",className:"flex items-center gap-2 data-[state=active]:bg-primary data-[state=active]:text-white rounded-md px-4 py-2",children:[e.jsx(ts,{className:"w-4 h-4"}),"Advanced"]}),e.jsxs(X,{value:"settings",className:"flex items-center gap-2 data-[state=active]:bg-primary data-[state=active]:text-white rounded-md px-4 py-2",children:[e.jsx(Cs,{className:"w-4 h-4"}),"Settings"]})]}),e.jsx(Y,{value:"general",children:e.jsx(B,{className:"border-border shadow-sm",children:e.jsxs(R,{className:"p-6 space-y-5",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(y,{htmlFor:"name",children:["Meeting Schedule Name ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(F,{id:"name",name:"name",placeholder:"e.g. 30 Minute Consultation",value:a.name||"",onChange:s=>n("name",s.target.value),className:`h-10 ${O("name")}`}),u("name")]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{htmlFor:"description",children:"Description"}),e.jsx(ns,{id:"description",placeholder:"Brief description of this meeting type...",value:a.description||"",onChange:s=>n("description",s.target.value),rows:3})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs(y,{htmlFor:"employee_id",children:["Host ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(Se,{value:a.employee_id?String(a.employee_id):"",onValueChange:s=>n("employee_id",s),disabled:j,children:[e.jsx(Ae,{className:`h-10 ${O("employee_id")}`,"data-field":"employee_id",children:e.jsx(De,{placeholder:j?"Loading employees...":"Select an host"})}),e.jsx(Pe,{children:p.map(s=>e.jsx(J,{value:s.value,children:s.label},s.value))})]}),u("employee_id")]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs(y,{htmlFor:"duration",children:["Duration (minutes) ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(F,{id:"duration",name:"duration",type:"number",min:1,placeholder:"30",value:a.duration||"",onChange:s=>n("duration",parseInt(s.target.value)||""),className:`h-10 ${O("duration")}`}),u("duration")]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{htmlFor:"price",children:"Price"}),e.jsx(F,{id:"price",type:"number",step:"0.01",min:0,placeholder:"0.00",value:a.price||"",onChange:s=>n("price",s.target.value),className:"h-10"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{htmlFor:"color",children:"Color"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{id:"color",type:"color",value:a.color||"#0040ff",onChange:s=>n("color",s.target.value),className:"w-10 h-10 rounded-lg border border-border cursor-pointer"}),e.jsx(F,{value:a.color||"#0040ff",onChange:s=>n("color",s.target.value),className:"h-10 w-32",placeholder:"#0040ff"})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{htmlFor:"location_type",children:"Location Type"}),e.jsxs(Se,{value:a.location_type||"online",onValueChange:s=>n("location_type",s),children:[e.jsx(Ae,{className:"h-10",children:e.jsx(De,{placeholder:"Select location type"})}),e.jsxs(Pe,{children:[e.jsx(J,{value:"online",children:"Online"}),e.jsx(J,{value:"in_person",children:"In Person"}),e.jsx(J,{value:"phone",children:"Phone"})]})]})]}),a.location_type&&a.location_type!=="online"&&e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{htmlFor:"location_details",children:"Location Details"}),e.jsx(F,{id:"location_details",placeholder:a.location_type==="phone"?"Phone number":"Address or room number",value:a.location_details||"",onChange:s=>n("location_details",s.target.value),className:"h-10"})]}),e.jsxs("div",{className:"space-y-4 pt-4 border-t border-border",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(y,{children:"Active"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Make this meeting type available for booking"})]}),e.jsx(U,{checked:a.is_active??!0,onCheckedChange:s=>n("is_active",s)})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx(y,{children:"Requires Confirmation"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Bookings need manual confirmation before they are confirmed"})]}),e.jsx(U,{checked:a.requires_confirmation??!1,onCheckedChange:s=>n("requires_confirmation",s)})]})]})]})})}),e.jsx(Y,{value:"availability",children:e.jsxs("div",{className:"space-y-4",children:[e.jsx(Ss,{}),e.jsx(As,{})]})}),e.jsx(Y,{value:"advanced",children:e.jsx(B,{className:"border-border shadow-sm",children:e.jsxs(R,{className:"p-6 space-y-5",children:[e.jsx("h3",{className:"text-lg font-semibold text-title",children:"Buffer & Limits"}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{htmlFor:"buffer_before",children:"Buffer Before (minutes)"}),e.jsx(F,{id:"buffer_before",type:"number",min:0,placeholder:"0",value:a.buffer_before??0,onChange:s=>n("buffer_before",parseInt(s.target.value)||0),className:"h-10"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Free time before the meeting starts"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{htmlFor:"buffer_after",children:"Buffer After (minutes)"}),e.jsx(F,{id:"buffer_after",type:"number",min:0,placeholder:"0",value:a.buffer_after??0,onChange:s=>n("buffer_after",parseInt(s.target.value)||0),className:"h-10"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Free time after the meeting ends"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{htmlFor:"max_bookings_per_day",children:"Max Bookings Per Day"}),e.jsx(F,{id:"max_bookings_per_day",type:"number",min:0,placeholder:"Unlimited",value:a.max_bookings_per_day??"",onChange:s=>n("max_bookings_per_day",s.target.value?parseInt(s.target.value):null),className:"h-10"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Leave empty for unlimited"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{htmlFor:"min_notice_minutes",children:"Min Notice (minutes)"}),e.jsx(F,{id:"min_notice_minutes",type:"number",min:0,placeholder:"60",value:a.min_notice_minutes??60,onChange:s=>n("min_notice_minutes",parseInt(s.target.value)||0),className:"h-10"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How far in advance bookings must be made"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(y,{htmlFor:"max_advance_days",children:"Max Advance Days"}),e.jsx(F,{id:"max_advance_days",type:"number",min:1,placeholder:"60",value:a.max_advance_days??60,onChange:s=>n("max_advance_days",parseInt(s.target.value)||1),className:"h-10"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"How far in the future bookings can be made"})]})]}),e.jsxs("div",{className:"space-y-1 pt-4 border-t border-border",children:[e.jsx(y,{children:"Picture"}),e.jsx(gs,{imagePath:a.picture_full_path,onUpload:x,onRemove:g,title:"Upload meeting type image",subtitle:"PNG, JPG, up to 5MB"})]})]})})}),e.jsx(Y,{value:"settings",children:e.jsx(B,{className:"border-border shadow-sm",children:e.jsxs(R,{className:"p-6 divide-y divide-border",children:[e.jsxs("section",{className:"pb-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"h-10 w-10 bg-blue-50 rounded-lg flex items-center justify-center border border-blue-100",children:e.jsx(q,{className:"h-5 w-5 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-title text-base",children:"Integrations"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Connect with external calendar and video services"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{icon:e.jsx(cs,{size:"24px"}),title:"Google Calendar",description:"Sync meeting bookings to Google Calendar",checked:((re=(ie=a==null?void 0:a.settings)==null?void 0:ie.integrations)==null?void 0:re.googleCalender)||!1,onCheckedChange:s=>n("settings.integrations.googleCalender",s),isPro:!0}),e.jsx(z,{icon:e.jsx(xs,{size:"24px"}),title:"Google Meet",description:"Auto-create Google Meet links for meetings",checked:((le=(ne=a==null?void 0:a.settings)==null?void 0:ne.integrations)==null?void 0:le.googleMeet)||!1,onCheckedChange:s=>n("settings.integrations.googleMeet",s),isPro:!0}),e.jsx(z,{icon:e.jsx(hs,{size:"27px"}),title:"Zoom",description:"Create Zoom meeting rooms automatically",checked:((ce=(oe=a==null?void 0:a.settings)==null?void 0:oe.integrations)==null?void 0:ce.zoom)||!1,onCheckedChange:s=>n("settings.integrations.zoom",s),isPro:r})]})]}),e.jsxs("section",{className:"pt-6",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-5",children:[e.jsx("div",{className:"h-10 w-10 bg-green-50 rounded-lg flex items-center justify-center border border-green-100",children:e.jsx(we,{className:"h-5 w-5 text-green-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-title text-base",children:"Payment Methods"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Choose which payment methods are available for this meeting type"})]})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsx(z,{icon:e.jsx(ds,{size:"26px"}),title:"Stripe",description:"Accept credit/debit card payments via Stripe",checked:((me=(de=a==null?void 0:a.settings)==null?void 0:de.paymentMethods)==null?void 0:me.stripe)||!1,onCheckedChange:s=>n("settings.paymentMethods.stripe",s),isPro:r}),e.jsx(z,{icon:e.jsx(ms,{size:"26px"}),title:"PayPal",description:"Accept payments via PayPal",checked:((he=(xe=a==null?void 0:a.settings)==null?void 0:xe.paymentMethods)==null?void 0:he.paypal)||!1,onCheckedChange:s=>n("settings.paymentMethods.paypal",s),isPro:!0}),e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-lg border border-border bg-white",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg flex items-center justify-center bg-gray-50 border border-gray-200",children:e.jsx(we,{className:"h-5 w-5 text-gray-500"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm text-title",children:"Offline / Pay on Arrival"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Collect payment manually"})]})]}),e.jsx(U,{checked:((pe=(ue=a==null?void 0:a.settings)==null?void 0:ue.paymentMethods)==null?void 0:pe.offline)!==!1,onCheckedChange:s=>n("settings.paymentMethods.offline",s)})]})]}),parseFloat((a==null?void 0:a.price)||0)===0&&e.jsxs("div",{className:"mt-4 p-3 bg-yellow-50 border border-yellow-200 rounded-lg flex items-center gap-2",children:[e.jsx(Te,{className:"w-4 h-4 text-yellow-600 shrink-0"}),e.jsx("p",{className:"text-xs text-yellow-700",children:"This meeting type has no price set. Payment methods will only apply when a price is configured in the General tab."})]})]})]})})})]}),e.jsxs("div",{className:"sticky bottom-0 left-0 right-0 px-6 py-3 bg-white border-t border-border shadow-[0_-2px_8px_rgba(0,0,0,0.04)] flex items-center justify-between gap-3 z-10",children:[e.jsxs("div",{className:"text-xs text-muted-foreground",children:["Step ",S+1," of ",W.length]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(G,{type:"button",variant:"outline",onClick:$,disabled:E||v,children:[e.jsx(ys,{className:"w-4 h-4"}),"Previous"]}),e.jsx(G,{type:"button",onClick:C,disabled:v,children:D?e.jsxs(e.Fragment,{children:[e.jsx(se,{className:"w-4 h-4"}),v?"Saving...":w?"Update":"Save"]}):e.jsxs(e.Fragment,{children:[v?"Saving...":"Save & Next",!v&&e.jsx(vs,{className:"w-4 h-4"})]})})]})]})]})}function Ts(){var D,$;if(!(($=(D=window.radius_booking_param)==null?void 0:D.active_modules)==null?void 0:$.meeting))return e.jsx("div",{className:"flex items-center justify-center min-h-[400px]",children:e.jsxs("div",{className:"text-center",children:[e.jsx(q,{className:"w-12 h-12 mx-auto mb-4 text-gray-400"}),e.jsx("h2",{className:"text-xl font-semibold text-gray-700 mb-2",children:"Meeting Module is Inactive"}),e.jsx("p",{className:"text-gray-500",children:"Enable the Meeting module from Settings > Modules to use this feature."})]})});const o=Oe("/meeting-types"),{mode:l}=o,v=Ee(),N=H(),k=V(C=>C(_).getMeetingType(),[]),w=V(C=>C(_).isMeetingTypeSaving(),[]),[p,f]=m.useState("general");m.useEffect(()=>{l==="create"&&f("general")},[l]);const j=async(C=null)=>{if(window.__meetingTypeValidate){const{isValid:L}=window.__meetingTypeValidate();if(!L)return!1}const a=await N(_).saveMeetingType(k);return a?(l==="create"&&v(`/meeting-types/${a}/edit`),!0):!1},b=()=>{switch(l){case"list":return e.jsx(ks,{});case"edit":case"create":return e.jsx(Ps,{activeTab:p,onTabChange:f,onSave:j,isSaving:w});default:return null}},E=({list:[{key:"add-meeting-type",label:"New Meeting",icon:te,onClick:o.navigateTo.create,variant:"primary"}],create:[{key:"save-meeting-type",label:"Save",icon:se,onClick:j,loading:w,variant:"primary"},{key:"cancel",label:"Cancel",icon:ve,onClick:o.navigateTo.list,variant:"cancel"}],edit:[{key:"update-meeting-type",label:"Update",icon:se,onClick:j,loading:w,variant:"primary"},{key:"cancel",label:"Cancel",icon:ve,onClick:o.navigateTo.list,variant:"cancel"}]}[l]||[]).map(C=>e.jsx(Be,{label:C.label,icon:C.icon,onClick:C.onClick,loading:C.loading||!1,variant:C.variant||"primary"},C.key));return e.jsx(Re,{title:"Meeting Types",description:"Manage your meeting types for scheduling",showBack:l!=="list",onBack:o.navigateTo.list,actions:E,icon:e.jsx(q,{className:"w-5 h-5 text-primary-colordefault"}),children:b()})}const K=m.memo(Ts);function qt(){return e.jsxs(es,{children:[e.jsx(Z,{path:"/",element:e.jsx(K,{})}),e.jsx(Z,{path:"create",element:e.jsx(K,{})}),e.jsx(Z,{path:":id",element:e.jsx(K,{})}),e.jsx(Z,{path:":id/edit",element:e.jsx(K,{})})]})}export{qt as default};
//# sourceMappingURL=index-Cg4o0DOQ.js.map
