1import{by as _,r as c,g as k,j as e,bG as B,bB as I,_ as z,bH as E,aL as M}from"./vendor-B3bqREfz.js";import{n as q,u as D,B as d,C as L,a as P,b as Y,g as f,d as H,I as o,f as Q}from"./index-BHZdkTHk.js";import{S as U,a as F,b as K,c as O,d as R}from"./select-CdK0CD7c.js";import{S as V}from"./switch-CEyu8DAw.js";const g=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],W=["America/New_York","America/Chicago","America/Denver","America/Los_Angeles","America/Anchorage","Pacific/Honolulu","UTC"];function $(){const{user:b}=q(),{toast:m}=D(),j=_(),[u,x]=c.useState(!1),{data:r=[],isLoading:h}=k({queryKey:["/api/vendor/availability"],enabled:!!b}),[v,l]=c.useState([]),[y,N]=c.useState(!1);!y&&r.length>=0&&!h&&(l(r.length>0?[...r]:[]),N(!0));const w=(i=1)=>{l(t=>[...t,{dayOfWeek:i,startTime:"09:00",endTime:"17:00",timezone:"America/New_York",bufferMinutes:15,isActive:!0}])},C=i=>l(t=>t.filter((a,s)=>s!==i)),n=(i,t,a)=>{l(s=>s.map((p,T)=>T===i?{...p,[t]:a}:p))},A=async()=>{x(!0);try{await Q("PUT","/api/vendor/availability",{slots:v}),j.invalidateQueries({queryKey:["/api/vendor/availability"]}),m({title:"Availability saved!",description:"Your calendar availability has been updated."})}catch{m({title:"Error",description:"Failed to save availability.",variant:"destructive"})}finally{x(!1)}},S=g.map((i,t)=>({day:t,slots:v.map((a,s)=>({...a,_idx:s})).filter(a=>a.dayOfWeek===t)}));return e.jsxs("div",{className:"max-w-3xl mx-auto px-4 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(B,{className:"h-6 w-6 text-blue-600"})," Booking Availability"]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:"Set your weekly available hours for consultation bookings"})]}),e.jsxs(d,{onClick:A,disabled:u,children:[e.jsx(I,{className:"h-4 w-4 mr-2"}),u?"Saving...":"Save Changes"]})]}),h?e.jsx("div",{className:"flex items-center justify-center h-40",children:e.jsx("div",{className:"animate-spin rounded-full h-6 w-6 border-b-2 border-blue-600"})}):e.jsx("div",{className:"space-y-3",children:S.map(({day:i,slots:t})=>e.jsxs(L,{className:t.length===0?"opacity-60":"",children:[e.jsxs(P,{className:"pb-2 flex flex-row items-center justify-between",children:[e.jsxs(Y,{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx("span",{className:"w-24",children:g[i]}),t.length===0?e.jsx(f,{variant:"outline",className:"text-xs",children:"Unavailable"}):e.jsxs(f,{variant:"secondary",className:"text-xs",children:[t.length," slot",t.length>1?"s":""]})]}),e.jsxs(d,{size:"sm",variant:"ghost",onClick:()=>w(i),children:[e.jsx(z,{className:"h-4 w-4 mr-1"})," Add"]})]}),t.length>0&&e.jsx(H,{className:"space-y-3 pt-0",children:t.map(a=>e.jsxs("div",{className:"flex flex-wrap items-center gap-2 p-3 bg-muted/40 rounded-lg",children:[e.jsx(E,{className:"h-4 w-4 text-muted-foreground shrink-0"}),e.jsx(o,{type:"time",value:a.startTime,className:"w-32",onChange:s=>n(a._idx,"startTime",s.target.value)}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"to"}),e.jsx(o,{type:"time",value:a.endTime,className:"w-32",onChange:s=>n(a._idx,"endTime",s.target.value)}),e.jsxs(U,{value:a.timezone,onValueChange:s=>n(a._idx,"timezone",s),children:[e.jsx(F,{className:"w-48",children:e.jsx(K,{})}),e.jsx(O,{children:W.map(s=>e.jsx(R,{value:s,children:s.replace("America/","").replace("_"," ")},s))})]}),e.jsxs("div",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:["Buffer:",e.jsx(o,{type:"number",min:0,max:60,value:a.bufferMinutes,className:"w-16",onChange:s=>n(a._idx,"bufferMinutes",parseInt(s.target.value)||0)})," min"]}),e.jsx(V,{checked:a.isActive,onCheckedChange:s=>n(a._idx,"isActive",s)}),e.jsx(d,{variant:"ghost",size:"sm",onClick:()=>C(a._idx),children:e.jsx(M,{className:"h-4 w-4 text-red-400"})})]},a._idx))})]},i))}),e.jsxs("div",{className:"mt-6 p-4 bg-blue-50 rounded-lg text-sm text-blue-700",children:[e.jsx("strong",{children:"Tips:"})," Add a buffer between appointments to prepare. Clients will see 30-minute slots within your available hours, minus the buffer time."]})]})}export{$ 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.