1import{k as le,e as ne,r as s,j as e}from"./react-vendor-zfhxSVDm.js";import{f as re,x as ie,C as S,a as ce,z,y as oe,L as g,I as C,B as W,h as k,s as me}from"./index-BV0-2aDl.js";import{T as de}from"./textarea-f3SxMAbO.js";import{g as xe,c as ue,e as he}from"./meetingsService-DG7PcNeo.js";import{C as pe}from"./clock-Br2vbK-j.js";import{V as $}from"./video-DAtZzIQF.js";import{m as b}from"./animation-vendor-DuSTuolt.js";import{C as ge}from"./circle-check-big-CaZWn_9O.js";import"./supabase-vendor-DqO-ystM.js";import"./ui-vendor-DS2gWKbO.js";function q(a,r){const n=new Date(a);return n.setDate(n.getDate()+r),n}function f(a){return new Intl.DateTimeFormat("he-IL",{weekday:"long",day:"numeric",month:"long"}).format(a)}function D(a){return new Date(a).toLocaleTimeString("he-IL",{hour:"2-digit",minute:"2-digit"})}function be(a){const r={};for(const n of a){const i=n.start.substring(0,10);r[i]||(r[i]=[]),r[i].push(n)}return r}const _=0,I=1,J=2,E=3;function _e(){const{userId:a}=le(),r=ne(),{user:n,profile:i}=re(),[l,K]=s.useState(null),[j,T]=s.useState({}),[P,L]=s.useState(!0),[d,o]=s.useState(_),[N,Q]=s.useState(null),[x,X]=s.useState(null),[u,U]=s.useState(""),[h,A]=s.useState(""),[y,B]=s.useState(""),[O,Y]=s.useState(""),[M,G]=s.useState(!1),[m,R]=s.useState(null),[v,F]=s.useState(0);s.useEffect(()=>{i&&(U(i.full_name||""),A(n?.email||""),B(i.phone||""))},[i,n]),s.useEffect(()=>{a&&xe(a).then(K).catch(()=>{})},[a]);const H=s.useCallback(async t=>{if(a){L(!0);try{const c=q(new Date,t*7),p=q(c,6),w=c.toISOString().substring(0,10),se=p.toISOString().substring(0,10),{slots:ae}=await ue(a,w,se);T(be(ae))}catch{T({})}finally{L(!1)}}},[a]);s.useEffect(()=>{H(v)},[H,v]);const V=Object.keys(j).sort(),Z=t=>{Q(t),o(I)},ee=t=>{X(t),o(J)},te=async()=>{if(!u||!h){k("ש××××","× × ×××× ×©× ×××××××");return}G(!0);try{const t=l?.meeting_price>0,c=await he({hostUserId:a,guestUserId:n?.id??null,guestName:u,guestEmail:h,guestPhone:y||null,scheduledAt:x.start,meetingType:"consultation",notes:O||null,...t?{price:l.meeting_price,payment_status:"pending"}:{}});if(t&&c?.id){const{data:p,error:w}=await me.functions.invoke("create-payment-form",{body:{featureId:"consultation",mode:"perItem",entityId:c.id,entityType:"consultation",userId:n?.id||null,clientEmail:h,clientName:u,clientPhone:y||null}});if(w||!p?.paymentUrl){k("ש××××","×× × ××ª× ××צ×ר ××פס תש×××"),R(c),o(E);return}window.location.href=p.paymentUrl;return}R(c),o(E)}catch(t){k("ש××××",t.message||"×× × ××ª× ××× ××§×××¢ ×ת ×פ××ש×")}finally{G(!1)}};return!l&&!P?e.jsx("div",{className:"min-h-screen flex items-center justify-center",dir:"rtl",children:e.jsx("p",{className:"text-slate-500",children:"×שת×ש ×× × ×צ×"})}):e.jsx("div",{className:"min-h-screen bg-brand-surface py-8 px-4",dir:"rtl",children:e.jsxs("div",{className:"max-w-lg mx-auto",children:[l&&e.jsxs("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-100 p-5 mb-6 flex items-center gap-4",children:[l.avatar_url?e.jsx("img",{src:l.avatar_url,className:"w-14 h-14 rounded-full object-cover"}):e.jsx("div",{className:"w-14 h-14 rounded-full bg-blue-100 flex items-center justify-center text-blue-700 font-bold text-xl",children:l.full_name?.[0]}),e.jsxs("div",{children:[e.jsx("h1",{className:"font-bold text-slate-900 text-lg",children:l.full_name}),e.jsxs("p",{className:"text-sm text-slate-500 flex items-center gap-1",children:[e.jsx(pe,{className:"w-3.5 h-3.5"}),l.meeting_duration_minutes," ××§×ת",l.meeting_price>0?e.jsxs("span",{className:"ms-2 text-amber-700 font-medium",children:["âª",l.meeting_price]}):e.jsx("span",{className:"ms-2 text-green-700 font-medium",children:"××× ××"})]}),e.jsxs("p",{className:"text-xs text-blue-600 flex items-center gap-1 mt-0.5",children:[e.jsx($,{className:"w-3 h-3"})," פ×××©× ××× ××××"]})]})]}),d===_&&e.jsxs(b.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"bg-white rounded-2xl shadow-sm border border-slate-100 p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"font-semibold text-slate-800 flex items-center gap-2",children:[e.jsx(ie,{className:"w-4 h-4 text-blue-600"})," ×××רת ת×ר××"]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("button",{disabled:v===0,onClick:()=>F(t=>t-1),className:"p-1 rounded hover:bg-slate-100 disabled:opacity-30",children:e.jsx(S,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>F(t=>t+1),className:"p-1 rounded hover:bg-slate-100",children:e.jsx(ce,{className:"w-4 h-4"})})]})]}),P?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(z,{className:"w-6 h-6 animate-spin text-blue-500"})}):V.length===0?e.jsx("p",{className:"text-center text-slate-500 py-8 text-sm",children:"××× ××× ×× ×¤× ×××× ×ש×××¢. × ××ª× ×× ×¡×ת ש×××¢ ×××."}):e.jsx("div",{className:"space-y-2",children:V.map(t=>e.jsxs("button",{onClick:()=>Z(t),className:"w-full flex items-center justify-between px-4 py-3 rounded-xl border border-slate-200 hover:border-blue-400 hover:bg-blue-50 transition-colors text-right",children:[e.jsx("span",{className:"text-slate-700 font-medium",children:f(new Date(t))}),e.jsxs("span",{className:"text-sm text-slate-400",children:[j[t].length," ××× ××"]})]},t))})]}),d===I&&N&&e.jsxs(b.div,{initial:{opacity:0,y:8}
1,animate:{opacity:1,y:0},className:"bg-white rounded-2xl shadow-sm border border-slate-100 p-5",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-4",children:[e.jsx("button",{onClick:()=>o(_),className:"p-1 rounded hover:bg-slate-100",children:e.jsx(S,{className:"w-4 h-4"})}),e.jsx("h2",{className:"font-semibold text-slate-800",children:f(new Date(N))})]}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:(j[N]??[]).map(t=>e.jsx("button",{onClick:()=>ee(t),className:"py-2.5 rounded-lg border border-blue-200 text-blue-700 font-medium text-sm hover:bg-blue-600 hover:text-white hover:border-blue-600 transition-colors",children:D(t.start)},t.start))})]}),d===J&&x&&e.jsxs(b.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"bg-white rounded-2xl shadow-sm border border-slate-100 p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("button",{onClick:()=>o(I),className:"p-1 rounded hover:bg-slate-100",children:e.jsx(S,{className:"w-4 h-4"})}),e.jsxs("h2",{className:"font-semibold text-slate-800 flex items-center gap-2",children:[e.jsx(oe,{className:"w-4 h-4 text-blue-600"})," פר×× ××שתתף"]})]}),e.jsxs("div",{className:"bg-blue-50 rounded-lg px-4 py-2 text-sm text-blue-800",children:[f(new Date(x.start))," - ",D(x.start)]}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(g,{children:"×©× ××× *"}),e.jsx(C,{value:u,onChange:t=>U(t.target.value),className:"text-right mt-1"})]}),e.jsxs("div",{children:[e.jsx(g,{children:"×××××× *"}),e.jsx(C,{type:"email",value:h,onChange:t=>A(t.target.value),className:"text-right mt-1",dir:"ltr"})]}),e.jsxs("div",{children:[e.jsx(g,{children:"××פ××"}),e.jsx(C,{type:"tel",value:y,onChange:t=>B(t.target.value),className:"text-right mt-1",dir:"ltr"})]}),e.jsxs("div",{children:[e.jsx(g,{children:"×ער×ת (××פצ××× ××)"}),e.jsx(de,{value:O,onChange:t=>Y(t.target.value),rows:2,className:"text-right mt-1"})]})]}),e.jsxs(W,{onClick:te,disabled:M,className:"w-full bg-blue-600 hover:bg-blue-700",children:[M?e.jsx(z,{className:"w-4 h-4 animate-spin me-2"}):null,l?.meeting_price>0?`×××©× ×תש××× (âª${l.meeting_price})`:"××ש×ר פ××ש×"]})]}),d===E&&m&&e.jsxs(b.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"bg-white rounded-2xl shadow-sm border border-slate-100 p-6 text-center space-y-4",children:[e.jsx(ge,{className:"w-14 h-14 text-green-500 mx-auto"}),e.jsx("h2",{className:"font-bold text-slate-900 text-xl",children:"×פ×××©× × ×§××¢×!"}),e.jsxs("p",{className:"text-slate-600 text-sm",children:[f(new Date(m.scheduledAt))," ××©×¢× ",D(m.scheduledAt)]}),l?.meeting_price>0&&e.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-4 space-y-1 text-start",children:[e.jsx("p",{className:"text-sm font-semibold text-amber-800",children:"תש××× × ×רש"}),e.jsxs("p",{className:"text-sm text-amber-700",children:["×¢××ת ××××¢××¥: ",e.jsxs("strong",{children:["âª",l.meeting_price]})]}),e.jsx("p",{className:"text-xs text-amber-600",children:"פר×× ×תש××× × ×©××× ×××××. ×פ×××©× ×ª××שר ×××ר ×§××ת ×תש×××."})]}),m.meetingUrl&&e.jsxs("div",{className:"bg-blue-50 rounded-xl p-4 space-y-2",children:[e.jsxs("p",{className:"text-sm text-blue-800 font-medium flex items-center justify-center gap-2",children:[e.jsx($,{className:"w-4 h-4"})," ×§×ש×ר ×פ××ש×"]}),e.jsx("a",{href:m.meetingUrl,className:"text-blue-600 underline text-sm break-all",children:m.meetingUrl})]}),e.jsx("p",{className:"text-xs text-slate-500",children:"× ×©××× ××××¢× ×¢× ×פר××× ×××××"}),e.jsx(W,{variant:"outline",onClick:()=>r("/"),className:"w-full",children:"×××¨× ×××£ ×××ת"})]})]})})}export{_e 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.