PageSourceSearch

https://tsofit.org.il/assets/SalesCustomerEdit-DRaCFNxw.js

js tsofit.org.il collected 2026-10-02 14:22:06 UTC 60,485 bytes, 1 lines download raw bytes

1import{r as o,j as e,ap as Pe,Z as ke,aH as Be,ao as je,x as Se,U as st,y as at,b as se,a5 as Ce,T as xe,at as Ne,d as L,z as h,af as lt,aa as Ee,M as Le,a9 as De,aC as te,aX as Oe,ac as rt,t as nt,l as Ae,A as it,aK as ot,aq as ct,P as dt}from"./index-BH8Hq4fF.js";import{s as mt,a as xt,S as ut}from"./salesStatus-DacX2vgZ.js";import{S as ht}from"./SuggestInput-Dw6uowgY.js";import{D as pt}from"./DemoInviteDialog-Bytsnkw3.js";import{i as bt,d as Ue,a as ze,b as ft,S as gt}from"./SentMessageDialog-BLpTr0Qa.js";import{l as he,u as Qe,S as We,W as Re}from"./demoInvite-C6uHE16y.js";import{M as jt}from"./mail-open-D2maS5CF.js";import{A as Nt,P as Ke,a as wt}from"./PrintableDocument-CTa0MSKi.js";import{P as yt}from"./printer-EDa6zP4x.js";import{s as He}from"./salesMessages-Do06lsB_.js";import{S as vt}from"./SignaturePad-BVXURMv7.js";import{D as _t,m as kt,a as St,b as $t,C as Ct,c as qe,d as ye,e as Et,h as $e,s as Ve,f as Ye}from"./salesAgreement-CGXfxtmS.js";import{F as Lt}from"./file-pen-line-tRJ0J_Pm.js";import{C as Xe}from"./copy-B_0EPT7Q.js";import{Q as Dt,q as At}from"./QuoteDocument-rx0woytj.js";import{D as Te,p as qt,m as Tt,q as Mt,t as Ft,b as It,L as Pt,s as pe,P as Bt,a as Ge,c as Ze,d as Ot}from"./salesQuote-Bcsvg3aD.js";import{R as Ut}from"./receipt-CPIbDC3-.js";import{L as zt}from"./CustomerContactCells-U8S6NwFE.js";import{a as Qt,c as Wt}from"./salesContactLog-DXFJiFqW.js";import"./video-Dnmc63gI.js";import"./EshuvEmailPreview-DWAwjhVz.js";import"./communityEmail-DHv9zmVf.js";import"./WaText-B67wDB8t.js";import"./eraser-CLQXmIV-.js";import"./landmark-CnHOESNE.js";import"./repeat-Casuh03o.js";import"./money-CmD9E_V-.js";import"./phone-DXeRciLF.js";import"./bell-ring-Db0rTCDW.js";const Rt="w-full h-11 px-3 rounded-xl border border-slate-200 bg-white text-sm focus:outline-none focus:ring-2 focus:ring-blue-100 focus:border-blue-300",Kt=(c,N)=>{const m=N.trim().toLowerCase();return m?[c.name,c.phone,c.email].some(b=>String(b||"").toLowerCase().includes(m)):!0};function Ht({demo:c,customer:N,contacts:m,senderName:b,onClose:k,onChanged:d,onViewMessage:p}){const[O,w]=o.useState(""),[M,$]=o.useState([]),[D,g]=o.useState(""),[Q,l]=o.useState(!1),[U,n]=o.useState(!0);o.useEffect(()=>{const r=x=>{x.key==="Escape"&&!D&&k()};return document.addEventListener("keydown",r),()=>document.removeEventListener("keydown",r)},[k,D]);const F=o.useMemo(()=>bt(c),[c]),S=o.useMemo(()=>m.filter(r=>F.has(String(r.id))),[m,F]),f=o.useMemo(()=>m.filter(r=>!F.has(String(r.id))&&!M.includes(r.id)&&Kt(r,O)),[m,F,M,O]),W=o.useMemo(()=>m.filter(r=>M.includes(r.id)),[m,M]),H=S.filter(r=>he(r.email)).length,y=S.length-H;async function z(){if(W.length){g("add");try{const{data:r}=await L.functions.invoke("salesDemoInvite",{mode:"add_guests",activity_id:c.id,contact_ids:M,sender_name:b||""}),x=(r==null?void 0:r.sent)||0;x?h.success(`${x} הזמנות נשלחו למוזמנים החדשים`):h.error("אף שליחה לא הצליחה"),$([]),d==null||d(),x&&k()}catch(r){h.error(String((r==null?void 0:r.message)||r).slice(0,160))}finally{g("")}}}async function v(){g("cancel");try{const{data:r}=await L.functions.invoke("salesDemoInvite",{mode:"cancel",activity_id:c.id,notify:U}),x=(r==null?void 0:r.notified)||0;h.success(x?`ההדגמה בוטלה · ${x} מוזמנים עודכנו בדוא״ל`:"ההדגמה בוטלה"),d==null||d(),k()}catch(r){h.error(String((r==null?void 0:r.message)||r).slice(0,160))}finally{g("")}}return e.jsx("div",{dir:"rtl",className:"fixed inset-0 z-50 bg-black/40 flex items-start sm:items-center justify-center p-3 overflow-auto",onMouseDown:r=>{r.target===r.currentTarget&&!D&&k()},children:e.jsxs("div",{className:"bg-white w-full max-w-lg rounded-2xl shadow-xl my-6 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 py-4 border-b border-slate-100",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-11 h-11 rounded-full bg-blue-50 flex items-center justify-center shrink-0",children:e.jsx(Pe,{className:"w-5 h-5 text-blue-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-lg font-extrabold text-slate-800 truncate",children:"הדגמה מתוכננת"}),e.jsx("p",{className:"text-xs text-slate-400 truncate",children:N==null?void 0:N.name})]})]}),e.jsx("button",{onClick:k,disabled:!!D,className:"p-2 rounded-lg hover:bg-slate-100 text-slate-400 disabled:opacity-40","aria-label":"סגירה",children:e.jsx(ke,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"px-5 py-4 bg-blue-50/60 border-b border-blue-100",children:[e.jsxs("p",{className:"text-sm font-extrabold text-blue-900 flex items-center gap-1.5",children:[e.jsx(Be,{className:"w-4 h-4"})," ",Ue(c)||"מועד לא ידוע"]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 mt-1.5",children:[e.jsx("span",{className:"text-xs font-bold text-blue-700",children:ze(c)}),c.meet_url&&e.jsxs("a",{href:c.meet_url,target:"_blank",rel:"noreferrer",className:"text-xs font-bold text-blue-600 hover:text-blue-800 inline-flex items-center gap-1",children:["פתח Meet ",e.jsx(je,{className:"w-3 h-3"})]}),p&&e.jsxs("button",{type:"button",onClick:()=>p(c),className:"text-xs font-bold text-blue-600 hover:text-blue-800 inline-flex items-center gap-1",children:[e.jsx(jt,{className:"w-3 h-3"})," ההודעה שנשלחה"]})]})]}),e.jsxs("div",{className:"px-5 py-4 border-b border-slate-100",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 mb-2",children:[e.jsx(Se,{className:"w-4 h-4 text-slate-400"})," מוזמנים (",S.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:S.length===0?e.jsx("span",{className:"text-xs text-slate-400",children:"לא נמצאו אנשי הקשר שהוזמנו."}):S.map(r=>e.jsx("span",{className:"inline-flex items-center h-8 px-3 rounded-full border border-slate-200 bg-slate-50 text-slate-700 text-sm",children:r.name||r.phone},r.id))})]}),e.jsxs("div",{className:"px-5 py-4 border-b border-slate-100",children:[e.jsxs("h3",{className:"text-sm font-bold text-slate-800 flex items-center gap-1.5 mb-2",children:[e.jsx(st,{className:"w-4 h-4 text-emerald-600"})," הוספת מוזמנים"]}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400 mb-2",children:"מי שיתווסף יקבל בדיוק את אותה הזמנה — אותו מועד, אותו קישור. מי שכבר הוזמן לא יקבל הודעה נוספת."}),W.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:W.map(r=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 h-8 pl-1.5 pr-3 rounded-full border border-emerald-200 bg-emerald-50 text-emerald-800 text-sm",children:[r.name||r.phone,e.jsx("button",{onClick:()=>$(x=>x.filter(A=>A!==r.id)),"aria-label":`הסרת ${r.name||"איש קשר"}`,className:"p-0.5 rounded-full hover:bg-emerald-100",children:e.jsx(ke,{className:"w-3.5 h-3.5"})})]},r.id))}),e.jsxs("div",{className:"relative",children:[e.jsx(at,{className:"w-4 h-4 text-slate-400 absolute left-3 top-1/2 -translate-y-1/2"}),e.jsx("input",{value:O,onChange:r=>w(r.target.value),placeholder:"חיפוש איש קשר...","aria-label":"חיפוש איש קשר",className:`${Rt} pl-9`})]}),f.length>0&&e.jsx("ul",{className:"mt-2 max-h-36 overflow-auto rounded-xl border border-slate-100 divide-y divide-slate-50",children:f.map(r=>e.jsx("li",{children:e.jsxs("button",{type:"button",onClick:()=>$(x=>[...x,r.id]),className:"w-full text-right px-3 py-2 hover:bg-slate-50 flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-sm text-slate-700 truncate",children:r.name||"—"}),e.jsx("span",{className:"text-xs text-slate-400 shrink-0",dir:"ltr",style:{unicodeBidi:"plaintext"},children:r.phone||r.email||""})]})},r.id))}),e.jsxs("button",{type:"button",onClick:z,disabled:!W.length||!!D,className:"w-full h-11 mt-3 rounded-xl bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 disabled:opacity-40 inline-flex items-center justify-center gap-2",children:[D==="add"?e.jsx(se,{className:"w-4 h-4 animate-spin"}):e.jsx(Ce,{className:"w-4 h-4"}),"שליחת ההזמנה ל-",W.length," מוזמנים חדשים"]})]}),e.jsxs("div",{className:"px-5 py-4",children:[Q?e.jsxs("div",{className:"rounded-xl border border-rose-200 bg-rose-50/60 p-3.5 space-y-3",children:[e.jsxs("p",{className:"text-sm font-bold text-rose-900 flex items-start gap-1.5",children:[e.jsx(Ne,{className:"w-4 h-4 mt-0.5 flex-none"}),"לבטל את ההדגמה? הפגישה תוסר מהיומן והקישור יפסיק לעבוד."]}),e.jsxs("label",{className:"flex items-start gap-2 text-[0.8125rem] text-slate-700",children:[e.jsx("input",{type:"checkbox",checked:U,onChange:r=>n(r.target.checked),className:"mt-0.5 w-4 h-4 rounded border-slate-300 text-rose-600 focus:ring-rose-200"}),e.jsxs("span",{children:["לשלוח למוזמנים הודעת ביטול בדוא״ל",H>0&&e.jsxs("b",{children:[" (",H," מתוך ",S.length,")"]})]})]}),y>0&&e.jsxs("p",{className:"text-[0.6875rem] text-rose-800 leading-relaxed",children:["ל-",y," מהמוזמנים אי×
1Ÿ כתובת דוא״ל, והודעת ביטול בוואטסאפ דורשת תבנית מאושרת של Meta שאינה קיימת. כדאי להתקשר אליהם."]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{type:"button",onClick:v,disabled:!!D,className:"flex-1 h-11 rounded-xl bg-rose-600 text-white text-sm font-bold hover:bg-rose-700 disabled:opacity-50 inline-flex items-center justify-center gap-2",children:[D==="cancel"?e.jsx(se,{className:"w-4 h-4 animate-spin"}):e.jsx(xe,{className:"w-4 h-4"}),"כן, לבטל"]}),e.jsx("button",{type:"button",onClick:()=>l(!1),disabled:!!D,className:"w-28 h-11 rounded-xl border border-slate-200 bg-white text-sm font-bold text-slate-600 hover:bg-slate-50",children:"חזרה"})]})]}):e.jsxs("button",{type:"button",onClick:()=>l(!0),disabled:!!D,className:"w-full h-11 rounded-xl border border-rose-200 text-rose-600 text-sm font-bold hover:bg-rose-50 disabled:opacity-40 inline-flex items-center justify-center gap-2",children:[e.jsx(xe,{className:"w-4 h-4"})," ביטול ההדגמה והזימון"]}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400 mt-2 leading-relaxed",children:"לשינוי מועד — בטלו את ההדגמה וקבעו חדשה. שינוי השעה של הזמנה שכבר נשלחה היה משאיר את היומן ואת ההודעות שבידי הלקוח חלוקים על מועד הפגישה."})]})]})})}function Je({sendLabel:c,viewLabel:N,deleteLabel:m,deleteWarning:b,url:k,busy:d,canSend:p,onSend:O,onDelete:w}){const[M,$]=o.useState(!1);return M?e.jsxs("div",{className:"rounded-xl border-2 border-rose-200 bg-rose-50/60 p-3 space-y-2",children:[e.jsxs("p",{className:"text-sm font-bold text-rose-800 flex items-center gap-1.5",children:[e.jsx(Ne,{className:"w-4 h-4"})," ",m,"?"]}),e.jsx("p",{className:"text-[0.6875rem] text-rose-700 leading-relaxed",children:b}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("button",{type:"button",onClick:()=>{$(!1),w()},disabled:!!d,className:"h-10 rounded-xl bg-rose-600 text-white text-sm font-bold hover:bg-rose-700 disabled:opacity-60",children:d==="delete"?e.jsx(se,{className:"w-4 h-4 animate-spin mx-auto"}):"כן, למחוק"}),e.jsx("button",{type:"button",onClick:()=>$(!1),className:"h-10 rounded-xl border border-slate-200 bg-white text-sm font-medium text-slate-600 hover:bg-slate-50",children:"ביטול"})]})]}):e.jsxs("div",{className:"grid grid-cols-3 gap-2",children:[e.jsxs("button",{type:"button",onClick:O,disabled:!!d||!p,className:"h-11 rounded-xl bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 disabled:opacity-50 inline-flex items-center justify-center gap-1.5",children:[d==="send"?e.jsx(se,{className:"w-4 h-4 animate-spin"}):e.jsx(Ce,{className:"w-4 h-4"}),c]}),e.jsxs("a",{href:k||"#",target:"_blank",rel:"noreferrer",className:`h-11 rounded-xl border border-slate-200 text-sm font-bold text-slate-600 hover:bg-slate-50 inline-flex items-center justify-center gap-1.5 ${k?"":"pointer-events-none opacity-40"}`,children:[e.jsx(lt,{className:"w-4 h-4"})," ",N]}),e.jsxs("button",{type:"button",onClick:()=>$(!0),disabled:!!d,className:"h-11 rounded-xl border border-rose-200 text-sm font-bold text-rose-600 hover:bg-rose-50 disabled:opacity-50 inline-flex items-center justify-center gap-1.5",children:[e.jsx(xe,{className:"w-4 h-4"})," ",m]})]})}function et({icon:c,iconTone:N="bg-slate-100 text-slate-600",title:m,subtitle:b,status:k,busy:d,onClose:p,form:O,docLabel:w,doc:M,whatsapp:$,email:D,tab:g,onTab:Q,footer:l,onPrint:U,print:n}){o.useEffect(()=>{const f=W=>{W.key==="Escape"&&!d&&p()};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[p,d]);const F=[{key:"msg",label:"וואטסאפ",icon:Ee},{key:"email",label:"דוא״ל",icon:Le},{key:"doc",label:w,icon:De}],S=g==="doc"?M:g==="email"?D:$;return e.jsxs(e.Fragment,{children:[n,e.jsx("div",{dir:"rtl",className:"fixed inset-0 z-50 bg-black/40 flex items-center justify-center p-3",onMouseDown:f=>{f.target===f.currentTarget&&!d&&p()},children:e.jsxs("div",{className:"bg-white w-full max-w-6xl rounded-2xl shadow-xl flex flex-col max-h-[94vh] overflow-hidden",children:[e.jsxs("header",{className:"shrink-0 flex items-center justify-between gap-3 px-5 py-4 border-b border-slate-100",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:`w-11 h-11 rounded-full flex items-center justify-center shrink-0 ${N}`,children:e.jsx(c,{className:"w-5 h-5"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-lg font-extrabold text-slate-800 truncate",children:m}),e.jsx("p",{className:"text-xs text-slate-400 truncate",children:b})]}),k]}),e.jsx("button",{onClick:p,disabled:!!d,"aria-label":"סגירה",className:"p-2 rounded-lg hover:bg-slate-100 text-slate-400 disabled:opacity-40",children:e.jsx(ke,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"flex-1 min-h-0 grid grid-cols-1 lg:grid-cols-5",children:[e.jsx("div",{className:"lg:col-span-2 bg-slate-50 border-l border-slate-200 overflow-y-auto p-4 space-y-3",children:O}),e.jsxs("div",{className:"lg:col-span-3 overflow-y-auto p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("div",{className:"inline-flex rounded-xl bg-slate-100 p-1",children:F.map(f=>e.jsxs("button",{type:"button",onClick:()=>Q(f.key),"aria-pressed":g===f.key,className:`h-8 px-3 rounded-lg text-xs font-bold inline-flex items-center gap-1.5 transition-colors ${g===f.key?"bg-white text-slate-800 shadow-sm":"text-slate-500 hover:text-slate-700"}`,children:[e.jsx(f.icon,{className:"w-3.5 h-3.5"})," ",f.label]},f.key))}),g==="doc"&&U&&e.jsxs("button",{type:"button",onClick:U,className:"text-xs font-bold text-slate-500 hover:text-slate-700 inline-flex items-center gap-1",children:[e.jsx(yt,{className:"w-3.5 h-3.5"})," הדפסה / PDF"]})]}),S]})]}),e.jsx("footer",{className:"shrink-0 border-t border-slate-200 bg-white px-5 py-3",children:l})]})})]})}function J({title:c,hint:N,tone:m="",children:b}){return e.jsxs("section",{className:`rounded-xl border bg-white p-3.5 ${m||"border-slate-200"}`,children:[c&&e.jsx("p",{className:"text-[0.8125rem] font-bold text-slate-800 mb-0.5",children:c}),N&&e.jsx("p",{className:"text-[0.6875rem] text-slate-500 mb-2.5",children:N}),!N&&c&&e.jsx("div",{className:"mb-2.5"}),b]})}const ve=He("agreement"),ne="w-full h-10 px-3 rounded-xl border border-slate-200 bg-white text-sm focus:outline-none focus:ring-2 focus:ring-emerald-100 focus:border-emerald-300 transition-colors",de="block text-xs font-medium text-slate-600 mb-1",Me=()=>new Date().toISOString().slice(0,10);function Vt({customer:c,contacts:N,senderName:m,existing:b,onClose:k,onChanged:d}){var a,_;const[p,O]=o.useState((b==null?void 0:b.committee_type)||_t),[w,M]=o.use
1State(()=>({committeeName:c.name,signingPlace:"",contractDate:Me(),...(b==null?void 0:b.fields)||{}})),[$,D]=o.useState((b==null?void 0:b.contact_id)||((a=N.find(s=>s.is_starred))==null?void 0:a.id)||((_=N[0])==null?void 0:_.id)||""),[g,Q]=o.useState({whatsapp:!0,email:!0}),[l,U]=o.useState("msg"),[n,F]=o.useState(b||null),[S,f]=o.useState(""),[W,H]=o.useState(!1),[y,z]=o.useState({image:"",name:m||"",role:"",date:Me()}),[v,r]=o.useState(!1),x=Qe("sales_agreement"),A=kt(w),E=N.find(s=>s.id===$),P=St(n),R=P!=="draft",I=n!=null&&n.token?`${window.location.origin}/agreement/${n.token}`:"",q=!!(E!=null&&E.phone),T=he(E==null?void 0:E.email),B=g.whatsapp&&q,V=g.email&&T,X=o.useMemo(()=>$t({committeeName:w.committeeName||c.name,contactName:(E==null?void 0:E.name)||"",url:I||`${window.location.origin}/agreement/…`,senderName:m}),[w.committeeName,c.name,E,I,m]),Y=s=>u=>M(G=>({...G,[s]:u.target.value}));async function ie(){f("save");try{const{data:s}=await L.functions.invoke("salesAgreement",{mode:"save",id:n==null?void 0:n.id,customer_id:c.id,contact_id:$||null,committee_type:p,fields:w});if(!(s!=null&&s.agreement))throw new Error("השמירה לא הוחזרה מהשרת");return F(s.agreement),d==null||d(),s.agreement}catch(s){return h.error(String((s==null?void 0:s.message)||s).slice(0,160)),null}finally{f("")}}async function ae(){if(A.length){h.error(`חסרים: ${A.map(u=>u.label).join(", ")}`);return}if(!E){h.error("בחרו איש קשר");return}if(!B&&!V){h.error("בחרו ערוץ שליחה");return}const s=await ie();if(s){f("send");try{const{data:u}=await L.functions.invoke("salesAgreement",{mode:"send",id:s.id,contact_id:$,sender_name:m||"",channels:{whatsapp:g.whatsapp,email:g.email}});if(u!=null&&u.ok)F(u.agreement),h.success(`ההסכם נשלח ל${E.name||"איש הקשר"}`),d==null||d();else{const G=((u==null?void 0:u.results)||[]).filter(Z=>!Z.ok).map(Z=>`${Z.channel}: ${Z.error||"נכשל"}`).join(" · ");h.error(G||"השליחה נכשלה")}}catch(u){h.error(String((u==null?void 0:u.message)||u).slice(0,160))}finally{f("")}}}async function oe(){f("delete");try{const{data:s}=await L.functions.invoke("salesAgreement",{mode:"delete",id:n.id});if(!(s!=null&&s.ok))throw new Error("המחיקה נכשלה");h.success("ההסכם נמחק — אפשר לשלוח הסכם חדש"),d==null||d(),k()}catch(s){h.error(String((s==null?void 0:s.message)||s).slice(0,160))}finally{f("")}}async function le(){if(!y.image){h.error("נדרשת חתימה");return}if(!y.name.trim()||!y.role.trim()){h.error("יש למלא שם ותפקיד");return}f("countersign");try{const{data:s}=await L.functions.invoke("salesAgreement",{mode:"countersign",id:n.id,signature:y.image,signer_name:y.name,signer_role:y.role,sign_date:y.date});if(!(s!=null&&s.agreement))throw new Error("החתימה לא נשמרה");F(s.agreement),H(!1),h.success("ההסכם חתום על ידי שני הצדדים"),d==null||d()}catch(s){h.error(String((s==null?void 0:s.message)||s).slice(0,160))}finally{f("")}}const ee=({on:s,able:u,icon:G,label:Z,onToggle:we,why:t})=>e.jsxs("button",{type:"button",onClick:we,disabled:!u,className:`h-9 px-3 rounded-full border text-xs font-bold inline-flex items-center gap-1.5 transition-colors disabled:opacity-40 ${s&&u?"bg-emerald-600 text-white border-emerald-600":"bg-white text-slate-600 border-slate-200 hover:bg-slate-50"}`,title:u?"":t,children:[e.jsx(G,{className:"w-3.5 h-3.5"})," ",Z,s&&u&&e.jsx(te,{className:"w-3 h-3"})]}),re=e.jsxs(e.Fragment,{children:[e.jsxs(J,{title:"סוג הוועד",hint:"הבחירה מחליפה את המונח בכל מקום בהסכם — במבוא, בהגדרות ובסעיפים.",children:[e.jsx("div",{className:"grid grid-cols-4 gap-2",children:Ct.map(s=>e.jsx("button",{type:"button",disabled:R,onClick:()=>O(s.key),className:`h-10 rounded-xl text-sm font-bold border transition-colors disabled:opacity-50 ${p===s.key?"bg-emerald-600 text-white border-emerald-600":"bg-white text-slate-600 border-slate-200 hover:bg-slate-50"}`,children:s.label},s.key))}),p==="other"&&e.jsxs("div",{className:"mt-3",children:[e.jsx("label",{className:de,htmlFor:"ag-other",children:"סוג הגוף, כפי שייכתב בהסכם"}),e.jsx("input",{id:"ag-other",value:w[qe]||"",onChange:Y(qe),disabled:R,placeholder:"לדוגמה: עמותה, מועצה דתית, חברה קהילתית",className:ne}),e.jsxs("p",{className:"text-[0.6875rem] text-slate-400 mt-1",children:["המונח יופיע בכל מקום שבו ההסכם אומר «",ye(p,w).noun,"»."]})]})]}),e.jsxs(J,{title:"פרטי ההסכם",children:[e.jsx("label",{className:de,htmlFor:"ag-name",children:"שם הוועד"}),e.jsx("input",{id:"ag-name",value:w.committeeName||"",onChange:Y("committeeName"),disabled:R,className:ne}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 mt-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:de,htmlFor:"ag-place",children:"מקום עריכת ההסכם"}),e.jsx("input",{id:"ag-place",value:w.signingPlace||"",onChange:Y("signingPlace"),disabled:R,placeholder:"לדוגמה: כפר רות",className:ne})]}),e.jsxs("div",{children:[e.jsx("label",{className:de,htmlFor:"ag-d
1ate",children:"תאריך ההסכם"}),e.jsx("input",{id:"ag-date",type:"date",value:w.contractDate||"",onChange:Y("contractDate"),disabled:R,className:ne})]})]})]}),e.jsxs("div",{className:"rounded-xl bg-white/60 border border-dashed border-slate-300 p-3",children:[e.jsx("p",{className:"text-xs font-bold text-slate-600 mb-1",children:"הלקוח משלים על ההסכם"}),e.jsxs("ul",{className:"text-[0.6875rem] text-slate-500 space-y-0.5",children:[Et.map(s=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-slate-300"}),s.label,s.required?"":" (רשות)",w[s.key]&&e.jsx(te,{className:"w-3 h-3 text-emerald-600"})]},s.key)),e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-slate-300"}),"תקופת ההתקשרות — מתחילה ביום ההחלטה, שנה, ומתחדשת"]})]})]}),e.jsxs(J,{title:"נמען ושליחה",children:[e.jsx("label",{className:de,htmlFor:"ag-contact",children:"איש קשר לחתימה"}),e.jsxs("select",{id:"ag-contact",value:$,onChange:s=>D(s.target.value),className:ne,children:[e.jsx("option",{value:"",children:"— בחרו —"}),N.map(s=>e.jsxs("option",{value:s.id,children:[s.name||"—",s.phone?` · ${s.phone}`:"",he(s.email)?' · דוא"ל':""]},s.id))]}),e.jsx("span",{className:`${de} mt-3`,children:"שליחה ב־"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(ee,{on:g.whatsapp,able:q,icon:Ee,label:"וואטסאפ",why:"לאיש הקשר אין נייד",onToggle:()=>Q(s=>({...s,whatsapp:!s.whatsapp}))}),e.jsx(ee,{on:g.email,able:T,icon:Le,label:'דוא"ל',why:'לאיש הקשר אין דוא"ל',onToggle:()=>Q(s=>({...s,email:!s.email}))})]}),E&&!q&&!T&&e.jsx("p",{className:"text-[0.6875rem] text-amber-600 mt-1.5",children:'לאיש הקשר הזה אין נייד או דוא"ל — אי אפשר לשלוח אליו.'})]}),R&&e.jsxs(J,{title:"התיעוד",children:[e.jsxs("dl",{className:"text-xs text-slate-600 space-y-1",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"נשלח אל"}),e.jsx("dd",{className:"font-medium",children:(n==null?void 0:n.sent_to)||"—"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"נשלח ב־"}),e.jsx("dd",{className:"font-medium",children:n!=null&&n.sent_date?new Date(n.sent_date).toLocaleString("he-IL"):"—"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"סוג הוועד"}),e.jsx("dd",{className:"font-medium",children:ye(n==null?void 0:n.committee_type,n==null?void 0:n.fields).label})]}),(n==null?void 0:n.customer_signer_name)&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"נחתם על ידי"}),e.jsxs("dd",{className:"font-medium",children:[n.customer_signer_name," · ",n.customer_signer_role]})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"ביום"}),e.jsx("dd",{className:"font-medium",children:$e(n.customer_sign_date)})]})]})]}),(n==null?void 0:n.customer_signature)&&e.jsx("img",{src:n.customer_signature,alt:"חתימת הלקוח",className:"h-16 object-contain mt-2"})]}),A.length>0&&e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-3 text-xs text-amber-800 flex gap-2",children:[e.jsx(Ne,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsxs("span",{children:["חסר להפקת ההסכם: ",A.map(s=>s.label).join(", ")]})]}),P==="signed"&&e.jsxs(J,{tone:"border-emerald-200",children:[e.jsxs("p",{className:"text-sm font-bold text-emerald-800 flex items-center gap-1.5",children:[e.jsx(te,{className:"w-4 h-4"})," הלקוח חתם — נותרה חתימת החברה"]}),e.jsx("p",{className:"text-[0.6875rem] text-emerald-700 mt-1 mb-2",children:"החתימה מתווספת לאותו מסמך. אין צורך לשלוח שוב ללקוח — הקישור שלו יציג את ההסכם חתום בשני הצדדים."}),W?e.jsxs("div",{className:"space-y-2",children:[e.jsx("input",{value:y.name,onChange:s=>
1z(u=>({...u,name:s.target.value})),placeholder:"שם מלא","aria-label":"שם החותם מטעם החברה",className:ne}),e.jsx("input",{value:y.role,onChange:s=>z(u=>({...u,role:s.target.value})),placeholder:"תפקיד","aria-label":"תפקיד החותם מטעם החברה",className:ne}),e.jsx("input",{type:"date",value:y.date,onChange:s=>z(u=>({...u,date:s.target.value})),"aria-label":"תאריך חתימת החברה",className:ne}),e.jsx(vt,{height:140,onChange:s=>z(u=>({...u,image:s}))}),e.jsxs("button",{type:"button",onClick:le,disabled:S==="countersign",className:"w-full h-10 rounded-xl bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 disabled:opacity-60 inline-flex items-center justify-center gap-2",children:[S==="countersign"?e.jsx(se,{className:"w-4 h-4 animate-spin"}):e.jsx(te,{className:"w-4 h-4"})," אישור החתימה"]})]}):e.jsxs("button",{type:"button",onClick:()=>H(!0),className:"w-full h-10 rounded-xl bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 inline-flex items-center justify-center gap-2",children:[e.jsx(Lt,{className:"w-4 h-4"})," חתימת החברה"]})]}),P==="countersigned"&&e.jsxs("div",{className:"rounded-xl border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-800 flex items-center gap-2",children:[e.jsx(te,{className:"w-4 h-4"})," ההסכם חתום על ידי שני הצדדים ושמור אצל הלקוח."]}),I&&e.jsxs("div",{className:"flex items-center gap-3 px-1",children:[e.jsxs("a",{href:I,target:"_blank",rel:"noreferrer",className:"text-xs font-bold text-blue-600 hover:text-blue-700 inline-flex items-center gap-1",children:["קישור החתימה של הלקוח ",e.jsx(je,{className:"w-3 h-3"})]}),e.jsxs("button",{type:"button",onClick:()=>{var s;(s=navigator.clipboard)==null||s.writeText(I),h.success("הקישור הועתק")},className:"text-xs font-bold text-slate-500 hover:text-slate-700 inline-flex items-center gap-1",children:[e.jsx(Xe,{className:"w-3 h-3"})," העתקה"]})]})]});return e.jsx(et,{icon:Oe,iconTone:"bg-amber-50 text-amber-600",title:"הסכם התקשרות",subtitle:`${c.name} · ${ye(p,w).label}`,status:e.jsx("span",{className:`px-2.5 py-0.5 rounded-full text-xs font-medium shrink-0 ${Ye(n)}`,children:Ve(n)}),busy:S,onClose:k,tab:l,onTab:U,onPrint:()=>r(!0),print:v&&e.jsx(Ke,{title:"הסכם התקשרות",subtitle:w.committeeName||c.name,watermark:P==="countersigned"?"":"טיוטה לחתימה",blocks:wt({committee:p,fields:w,agreement:n,forPrint:!0}),onDone:()=>r(!1)}),form:re,docLabel:"ההסכם",doc:e.jsx("div",{className:"rounded-2xl border border-slate-200 p-5 bg-white text-[0.8125rem]",children:e.jsx(Nt,{committee:p,fields:w,agreement:n})}),whatsapp:e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-bold text-slate-500 mb-2 text-center",children:["וואטסאפ · ",X.whatsappParams.length," פסקאות"]}),e.jsx(Re,{paragraphs:X.whatsappParams,imageUrl:(x==null?void 0:x.image_url)||"",videoUrl:(x==null?void 0:x.video_file_url)||"",note:"כל פסקה נשלחת בשורה אחת — מטא דוחה מעבר שורה בתוך פרמטר. את הנוסח והתמונה עורכים ב«תבניות שיווק»."})]}),email:e.jsx(We,{title:ve.title,description:ve.description,accent:ve.accent,customerName:c==null?void 0:c.name,body:X.text,ctas:I?[{url:I,label:X.cta}]:[]}),footer:P==="draft"?e.jsxs("div",{className:"flex flex-col sm:flex-row-reverse gap-2",children:[e.jsxs("button",{type:"button",onClick:ae,disabled:!!S||A.length>0||!E||!B&&!V,className:"flex-1 h-12 rounded-xl bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 disabled:opacity-50 inline-flex items-center justify-center gap-2",children:[S?e.jsx(se,{className:"w-4 h-4 animate-spin"}):e.jsx(Ce,{className:"w-4 h-4"}),"הפקת ההסכם ושליחה ללקוח",(B||V)&&` (${[B&&"וואטסאפ",V&&'דוא"ל'].filter(Boolean).join(" + ")})`]}),e.jsx("button",{type:"button",onClick:ie,disabled:!!S,className:"sm:w-36 h-12 rounded-xl border border-slate-200 text-sm font-medium text-slate-600 hover:bg-slate-50 disabled:opacity-50",children:"שמירת טיוטה"}),(n==null?void 0:n.id)&&e.jsxs("button",{type:"button",onClick:oe,disabled:!!S,className:"sm:w-36 h-12 rounded-xl border border-rose-200 text-sm font-medium text-rose-600 hover:bg-rose-50 disabled:opacity-50 inline-flex items-center justify-center gap-1.5",children:[e.jsx(xe,{className:"w-4 h-4"})," מחיקת הטיוטה"]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-xs text-slate-500 text-center mb-2",children:[P==="sent"&&`נשלח ל${(n==null?void 0:n.sent_to)||"איש הקשר"} — ממתין לחתימת הלקוח.`,P==="signed"&&`נחתם על ידי ${n==null?void 0:n.customer_signer_name}.`,P==="countersigned"&&"הושלם — חתום על ידי שני הצדדים."]}),e.jsx(Je,{sendLabel:"שלח שוב",viewLabel:"צפייה בהסכם",deleteLabel:"מחיקת ההסכם",deleteWarning:"ההסכם יימחק ואפשר יהיה לשלוח הסכם חדש. התיעוד של מה שנשלח ומה שנחתם נשמר בהערות ותיעוד.",url:I,busy:S,canSend:!!E,onSend:ae,onDelete:oe})]})})}const _e=He("quote"),ce="w-full h-10 px-3 rounded-xl border border-slate-200 bg-white text-sm focus:outline-none focus:ring-2 focus:ring-emerald-100 focus:border-emerald-300 transition-colors",be="block text-xs font-medium text-slate-600 mb-1",Fe=()=>new Date().toISOString().slice(0,10);function Yt({customer:c,contacts:N,senderName:m,existing:b,onClose:k,onChanged:d}){var ee,re;const[p,O]=o.useState(()=>({setup_price:"",setup_discount:"",monthly_price:"",monthly_discount:"",vat_rate:Te,quote_date:Fe(),valid_until:qt(Fe(),Ot),...b||{}}
1)),[w,M]=o.useState((b==null?void 0:b.contact_id)||((ee=N.find(a=>a.is_starred))==null?void 0:ee.id)||((re=N[0])==null?void 0:re.id)||""),[$,D]=o.useState({whatsapp:!0,email:!0}),[g,Q]=o.useState("msg"),[l,U]=o.useState(b||null),[n,F]=o.useState(""),[S,f]=o.useState({url:"",note:""}),[W,H]=o.useState(!1),y=Qe("sales_quote"),z=Tt(p),v=N.find(a=>a.id===w),r=Mt(l),x=r!=="draft",A=l!=null&&l.token?`${window.location.origin}/quote/${l.token}`:"",E=Ft(p),P=!!(v!=null&&v.phone),R=he(v==null?void 0:v.email),I=$.whatsapp&&P,q=$.email&&R,T=o.useMemo(()=>It({customerName:c.name,contactName:(v==null?void 0:v.name)||"",url:A||`${window.location.origin}/quote/…`,senderName:m,quote:p}),[c.name,v,A,m,p]),B=a=>_=>O(s=>({...s,[a]:_.target.value}));async function V(a,_){F(_);try{const{data:s}=await L.functions.invoke("salesQuote",a);return s}catch(s){return h.error(String((s==null?void 0:s.message)||s).slice(0,160)),null}finally{F("")}}async function X(){const a=await V({mode:"save",id:l==null?void 0:l.id,customer_id:c.id,contact_id:w||null,setup_price:p.setup_price,setup_discount:p.setup_discount,monthly_price:p.monthly_price,monthly_discount:p.monthly_discount,vat_rate:p.vat_rate,quote_date:p.quote_date,valid_until:p.valid_until},"save");return a!=null&&a.quote?(U(a.quote),O(_=>({..._,...a.quote})),d==null||d(),a.quote):(a&&h.error("השמירה לא הוחזרה מהשרת"),null)}async function Y(){if(z.length){h.error(`חסר: ${z.map(s=>s.label).join(", ")}`);return}if(!v){h.error("בחרו איש קשר");return}if(!I&&!q){h.error("בחרו ערוץ שליחה");return}const a=await X();if(!a)return;const _=await V({mode:"send",id:a.id,contact_id:w,sender_name:m||"",channels:{whatsapp:$.whatsapp,email:$.email}},"send");if(_!=null&&_.ok)U(_.quote),h.success(`ההצעה נשלחה ל${v.name||"איש הקשר"}`),d==null||d();else if(_){const s=(_.results||[]).filter(u=>!u.ok).map(u=>`${u.channel}: ${u.error||"נכשל"}`).join(" · ");h.error(s||"השליחה נכשלה")}}async function ie(){if(!/^https:\/\//i.test(S.url.trim())){h.error("קישור האסמכתא חייב להתחיל ב-https://");return}const a=await V({mode:"receipt",id:l.id,receipt_url:S.url.trim(),receipt_note:S.note},"receipt");a!=null&&a.quote&&(U(a.quote),f({url:"",note:""}),h.success("האסמכתא נשמרה"),d==null||d())}async function ae(){const a=await V({mode:"delete",id:l.id},"delete");a!=null&&a.ok&&(h.success("ההצעה נמחקה — אפשר לשלוח הצעה חדשה"),d==null||d(),k())}const oe=({on:a,able:_,icon:s,label:u,onToggle:G,why:Z})=>e.jsxs("button",{type:"button",onClick:G,disabled:!_,className:`h-9 px-3 rounded-full border text-xs font-bold inline-flex items-center gap-1.5 transition-colors disabled:opacity-40 ${a&&_?"bg-emerald-600 text-white border-emerald-600":"bg-white text-slate-600 border-slate-200 hover:bg-slate-50"}`,title:_?"":Z,children:[e.jsx(s,{className:"w-3.5 h-3.5"})," ",u,a&&_&&e.jsx(te,{className:"w-3 h-3"})]}),le=e.jsxs(e.Fragment,{children:[Pt.map(a=>e.jsxs(J,{title:a.priceLabel,children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[0.6875rem] text-slate-500 mb-1 block",children:"לפני מע״מ"}),e.jsx("input",{value:p[a.priceKey]??"",onChange:B(a.priceKey),disabled:x,inputMode:"numeric",placeholder:"0","aria-label":a.priceLabel,dir:"ltr",className:`${ce} text-left`})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[0.6875rem] text-slate-500 mb-1 block",children:a.discountLabel}),e.jsx("input",{value:p[a.discountKey]??"",onChange:B(a.discountKey),disabled:x,inputMode:"numeric",placeholder:"0","aria-label":a.discountLabel,dir:"ltr",className:`${ce} text-left`})]})]}),e.jsxs("p",{className:"text-[0.6875rem] text-slate-500 mt-2",dir:"ltr",style:{unicodeBidi:"plaintext"},children:[pe(E[a.key].net)," + מע״מ ",E.rate,"% = ",e.jsx("strong",{className:"text-slate-700",children:pe(E[a.key].gross)})]})]},a.key)),e.jsx(J,{title:"תוקף ומע״מ",children:e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:be,htmlFor:"q-valid",children:"תוקף ההצעה"}),e.jsx("input",{id:"q-valid",type:"date",value:p.valid_until||"",onChange:B("valid_until"),disabled:x,className:ce})]}),e.jsxs("div",{children:[e.jsx("label",{className:be,htmlFor:"q-vat",children:"שיעור מע״מ %"}),e.jsx("input",{id:"q-vat",value:p.vat_rate??Te,onChange:B("vat_rate"),disabled:x,inputMode:"numeric",dir:"ltr",className:`${ce} text-left`})]})]})}),!x&&e.jsxs(J,{title:"נמען ושליחה",children:[e.jsx("label",{className:be,htmlFor:"q-contact",children:"איש קשר לאישור"}),e.jsxs("select",{id:"q-contact",value:w,onChange:a=>M(a.target.value),className:ce,children:[e.jsx("option",{value:"",children:"— בחרו —"}),N.map(a=>e.jsxs("option",{value:a.id,children:[a.name||"—",a.phone?` · ${a.phone}`:"",he(a.email)?' · דוא"ל':""]},a.id))]}),e.jsx("span",{className:`${be} mt-3`,children:"שליחה ב־"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(oe,{on:$.whatsapp,able:P,icon:Ee,label:"וואטסאפ",why:"לאיש הקשר אין נייד",onToggle:()=>D(a=>({...a,whatsapp:!a.whatsapp}))}),e.jsx(oe,{on:$.email,able:R,icon:Le,label:'דוא"ל',why:'לאיש הקשר אין דוא"ל',onToggle:()=>D(a=>({...a,email:!a.email}))})]}),v&&!P&&!R&&e.jsx("p",{className:"text-[0.6875rem] text-amber-600 mt-1.5",children:'לאיש הקשר הזה אין נייד או דוא"ל — אי אפשר לשלוח אליו.'})]}),z.length>0&&!x&&e.jsxs("div",{className:"rounded-xl bg-amber-50 border border-amber-200 p-3 text-xs text-amber-800 flex gap-2",children:[e.jsx(Ne,{className:"w-4 h-4 shrink-0 mt-0.5"}),e.jsxs("span",{children:["חסר לשליחת ההצעה: ",z.map(a=>
1a.label).join(", ")]})]}),x&&e.jsxs(J,{title:"התיעוד",children:[e.jsxs("dl",{className:"text-xs text-slate-600 space-y-1",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"מספר הצעה"}),e.jsx("dd",{className:"font-medium",children:l==null?void 0:l.quote_number})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"נשלחה אל"}),e.jsx("dd",{className:"font-medium",children:(l==null?void 0:l.sent_to)||"—"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"נשלחה ב־"}),e.jsx("dd",{className:"font-medium",children:l!=null&&l.sent_date?new Date(l.sent_date).toLocaleString("he-IL"):"—"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"תוקף"}),e.jsx("dd",{className:"font-medium",children:$e(l==null?void 0:l.valid_until)||"—"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"סה״כ חד־פעמי"}),e.jsx("dd",{className:"font-bold",dir:"ltr",children:pe(E.setup.gross)})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"סה״כ חודשי"}),e.jsx("dd",{className:"font-bold",dir:"ltr",children:pe(E.monthly.gross)})]})]}),r==="expired"&&e.jsxs("p",{className:"mt-2 pt-2 border-t border-slate-100 text-xs text-rose-700 flex items-center gap-1.5",children:[e.jsx(Be,{className:"w-3.5 h-3.5"})," תוקף ההצעה פג. אפשר למחוק ולשלוח הצעה חדשה."]}),(l==null?void 0:l.approver_signature)&&e.jsxs("div",{className:"mt-2 pt-2 border-t border-slate-100",children:[e.jsxs("p",{className:"text-[0.6875rem] font-bold text-emerald-700 mb-1.5 flex items-center gap-1.5",children:[e.jsx(te,{className:"w-3.5 h-3.5"})," אישור הלקוח"]}),e.jsxs("dl",{className:"text-xs text-slate-600 space-y-1 mb-2",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"שם"}),e.jsx("dd",{className:"font-medium",children:l.approver_name})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"תפקיד"}),e.jsx("dd",{className:"font-medium",children:l.approver_role})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("dt",{className:"w-24 text-slate-400",children:"תאריך"}),e.jsx("dd",{className:"font-medium",children:$e(l.approve_date)})]})]}),e.jsx("img",{src:l.approver_signature,alt:"חתימת המאשר",className:"h-16 object-contain"})]})]}),(l==null?void 0:l.approver_signature)&&e.jsxs(J,{tone:"border-emerald-200",children:[e.jsxs("p",{className:"text-sm font-bold text-emerald-800 flex items-center gap-1.5 mb-2",children:[e.jsx(Ut,{className:"w-4 h-4"})," אסמכתא לתשלום"]}),l.receipt_url?e.jsxs(e.Fragment,{children:[e.jsxs("a",{href:l.receipt_url,target:"_blank",rel:"noreferrer",className:"text-xs font-bold text-blue-600 hover:text-blue-700 inline-flex items-center gap-1",children:["צפייה באסמכתא ",e.jsx(je,{className:"w-3 h-3"})]}),l.receipt_note&&e.jsx("p",{className:"text-[0.6875rem] text-slate-600 mt-1",children:l.receipt_note})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-[0.6875rem] text-emerald-700",children:["הלקוח שולח את האסמכתא בוואטסאפ למספר ",Bt.receiptWhatsapp,". הדביקו כאן את הקישור אליה."]}),e.jsx("input",{value:S.url,onChange:a=>f(_=>({..._,url:a.target.value})),placeholder:"https://…","aria-label":"קישור לאסמכתא",dir:"ltr",className:`${ce} text-left`}),e.jsx("input",{value:S.note,onChange:a=>f(_=>({..._,note:a.target.value})),placeholder:"הערה (רשות)","aria-label":"הערה לאסמכתא",className:ce}),e.jsx("button",{type:"button",onClick:ie,disabled:!!n,className:"w-full h-10 rounded-xl bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 disabled:opacity-60",children:n==="receipt"?e.jsx(se,{className:"w-4 h-4 animate-spin mx-auto"}):"שמירת האסמכתא"})]})]}),A&&e.jsxs("div",{className:"flex items-center gap-3 px-1",children:[e.jsxs("a",{href:A,target:"_blank",rel:"noreferrer",className:"text-xs font-bold text-blue-600 hover:text-blue-700 inline-flex items-center gap-1",children:["קישור האישור של הלקוח ",e.jsx(je,{className:"w-3 h-3"})]}),e.jsxs("button",{type:"button",onClick:()=>{var a;(a=navigator.clipboard)==null||a.writeText(A),h.success("הקישור הועתק")},className:"text-xs font-bold text-slate-500 hover:text-slate-700 inline-flex items-center gap-1",children:[e.jsx(Xe,{className:"w-3 h-3"})," העתקה"]})]})]});return e.jsx(et,{icon:De,iconTone:"bg-purple-50 text-purple-600",title:"הצעת מחיר",subtitle:`${c.name}${l!=null&&l.quote_number?` · ${l.quote_number}`:""}`,status:e.jsx("span",{className:`px-2.5 py-0.5 rounded-full text-xs font-medium shrink-0 ${Ze(l)}`,children:Ge(l)}),busy:n,onClose:k,tab:g,onTab:Q,onPrint:()=>H(!0),print:W&&e.jsx(Ke,{title:"הצעת מחיר",subtitle:c.name,reference:(l==null?void 0:l.quote_number)||"",watermark:r==="draft"?"טיוטה":"",blocks:At({quote:{...p,...l||{}},customerName:c.name}),onePerPage:!0,onDone:()=>H(!1)}),form:le,docLabel:"ההצעה",doc:e.jsx("div",{className:"rounded-2xl border border-slate-200 p-5 bg-white text-[0.8125rem]",children:e.jsx(Dt,{quote:{...p,...l||{}},customerName:c.name})}),whatsapp:e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-bold text-slate-500 mb-2 text-center",children:["וואטסאפ · ",T.whatsappParams.length," פסקאות"]}),e.jsx(Re,{paragraphs:T.whatsappParams,imageUrl:(y==null?void 0:y.image_url)||"",videoUrl:(y==null?void 0:y.video_file_url)||"",note:"כל פסקה נשלחת בשורה אחת — מטא דוחה מעבר שורה בתוך פרמטר. את הנוסח והתמונה עורכים ב«תבניות שיווק»."})]}
1),email:e.jsx(We,{title:_e.title,description:_e.description,accent:_e.accent,customerName:c==null?void 0:c.name,body:T.text,ctas:A?[{url:A,label:T.cta}]:[]}),footer:x?e.jsx(Je,{sendLabel:"שלח שוב",viewLabel:"צפייה בהצעה",deleteLabel:"מחיקת ההצעה",deleteWarning:"ההצעה תימחק ואפשר יהיה לשלוח הצעה חדשה. התיעוד של מה שנשלח ומה שאושר נשמר בהערות ותיעוד.",url:A,busy:n,canSend:!!v,onSend:Y,onDelete:ae}):e.jsxs("div",{className:"flex flex-col sm:flex-row-reverse gap-2",children:[e.jsxs("button",{type:"button",onClick:Y,disabled:!!n||z.length>0||!v||!I&&!q,className:"flex-1 h-12 rounded-xl bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 disabled:opacity-50 inline-flex items-center justify-center gap-2",children:[n?e.jsx(se,{className:"w-4 h-4 animate-spin"}):e.jsx(te,{className:"w-4 h-4"}),"שליחה לאישור הלקוח",(I||q)&&` (${[I&&"וואטסאפ",q&&'דוא"ל'].filter(Boolean).join(" + ")})`]}),e.jsx("button",{type:"button",onClick:X,disabled:!!n,className:"sm:w-36 h-12 rounded-xl border border-slate-200 text-sm font-medium text-slate-600 hover:bg-slate-50 disabled:opacity-50",children:"שמירת טיוטה"}),(l==null?void 0:l.id)&&e.jsxs("button",{type:"button",onClick:ae,disabled:!!n,className:"sm:w-36 h-12 rounded-xl border border-rose-200 text-sm font-medium text-rose-600 hover:bg-rose-50 disabled:opacity-50 inline-flex items-center justify-center gap-1.5",children:[e.jsx(xe,{className:"w-4 h-4"})," מחיקת הטיוטה"]})]})})}const me="w-full h-10 px-3 rounded-xl border border-slate-200 bg-white text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 focus-visible:ring-offset-1 focus:ring-2 focus:ring-emerald-100 focus:border-emerald-300 transition-colors",fe="block text-xs font-medium text-slate-600 mb-1",Ie="h-9 px-2 rounded-lg border border-transparent hover:border-slate-200 focus:border-emerald-300 focus:bg-white focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 focus-visible:ring-offset-1 text-sm bg-transparent transition-colors",ge=()=>crypto.randomUUID?crypto.randomUUID():`sc_${Date.now()}_${Math.random().toString(36).slice(2)}`,Xt={name:"שם",phone:"נייד",email:"דוא״ל"},Gt=[{key:"demo",label:"הזמנה להדגמה",icon:Pe,tint:"bg-blue-50 text-blue-600",ring:"hover:border-blue-300"},{key:"quote",label:"הצעת מחיר",icon:De,tint:"bg-purple-50 text-purple-600",ring:"hover:border-purple-300"},{key:"contract",label:"הסכם התקשרות",icon:Oe,tint:"bg-amber-50 text-amber-600",ring:"hover:border-amber-300"},{key:"notes",label:"הערות ותיעוד",icon:ot,tint:"bg-cyan-50 text-cyan-600",ring:"hover:border-cyan-300"}];function $s(){const{id:c}=rt(),N=nt(),[m,b]=o.useState(null),[k,d]=o.useState([]),[p,O]=o.useState([]),[w,M]=o.useState(!0),[$,D]=o.useState(0),[g,Q]=o.useState({name:"",phone:"",email:""}),[l,U]=o.useState([]),[n,F]=o.useState(!1),[S,f]=o.useState(!1),[W,H]=o.useState(!1),[y,z]=o.useState([]),[v,r]=o.useState([]),[x,A]=o.useState(null),[E,P]=o.useState(!1),[R,I]=o.useState(null),q=o.useMemo(()=>ft(l),[l]);o.useEffect(()=>{T()},[c]),o.useEffect(()=>{L.auth.me().then(A).catch(()=>A(null))},[]);async function T(){M(t=>t||!m),le.current=!1;try{const[t,i,j,C,K,ue]=await Promise.all([L.entities.SalesCustomer.filter({id:c},null,1),L.entities.SalesContact.filterAll({customer_id:c},"-is_starred"),L.entities.SalesCustomer.filterAllFields({},["moatza"],"moatza"),L.entities.SalesActivity.filterAll({customer_id:c},"-created_date").catch(()=>[]),L.entities.SalesAgreement.filterAll({customer_id:c},"-created_date").catch(()=>[]),L.entities.SalesQuote.filterAll({customer_id:c},"-created_date").catch(()=>[])]);b((t==null?void 0:t[0])||null),d(i||[]),O([...new Set((j||[]).map(tt=>(tt.moatza||"").trim()).filter(Boolean))].sort()),U(C||[]),r(K||[]),z(ue||[])}catch{h.error("שגיאה בטעינת הלקוח")}finally{M(!1)}}const B=()=>{D(Date.now())},[V,X]=o.useState(!1);o.useEffect(()=>{if(!$)return;X(!0);const t=setTimeout(()=>X(!1),1600);return()=>clearTimeout(t)},[$]);const Y=o.useMemo(()=>[...k].sort((t,i)=>
1(i.is_starred?1:0)-(t.is_starred?1:0)),[k]),ie=Y.filter(t=>t.is_starred).length,ae=o.useMemo(()=>Qt(l),[l]),oe=o.useMemo(()=>Wt(l,{agreements:v,quotes:y}),[l,v,y]),le=o.useRef(!1),ee=t=>{le.current=!0,b(i=>({...i,...t}))};async function re(t,i){if(!le.current)return;const j=i===void 0?m==null?void 0:m[t]:i;if(t==="name"&&!String(j||"").trim()){h.error("שם הלקוח הוא שדה חובה"),T();return}const C=typeof j=="string"?j.trim()||null:j;try{await L.entities.SalesCustomer.update(m.id,{[t]:C,updated_date:new Date().toISOString()}),le.current=!1,B()}catch(K){h.error(/duplicate|unique/i.test(String(K==null?void 0:K.message))?"לקוח בשם הזה כבר קיים":"שגיאה בשמירה"),T()}}async function a(t){const i=m.status;if(t!==i){b(j=>({...j,status:t}));try{await L.entities.SalesCustomer.update(m.id,{status:t,updated_date:new Date().toISOString()}),L.entities.SalesStatusEvent.create({id:ge(),customer_id:m.id,from_status:i||null,to_status:t,created_by:(x==null?void 0:x.email)||null}).catch(()=>{}),B()}catch{b(j=>({...j,status:i})),h.error("שגיאה בעדכון הסטאטוס")}}}async function _(t){const i=!t.is_starred;d(j=>j.map(C=>C.id===t.id?{...C,is_starred:i}:C));try{await L.entities.SalesContact.update(t.id,{is_starred:i,updated_date:new Date().toISOString()}),B()}catch{d(j=>j.map(C=>C.id===t.id?{...C,is_starred:!i}:C)),h.error("שגיאה בעדכון")}}const s=(t,i)=>d(j=>j.map(C=>C.id===t.id?{...C,...i,_dirty:!0,_before:C._before??{name:C.name,phone:C.phone,email:C.email}}:C));async function u(t,i){try{await L.entities.SalesActivity.create({id:ge(),customer_id:c,kind:"contact",title:t,body:i||null,results:[],created_by:(x==null?void 0:x.email)||null}),U(j=>[{id:ge(),customer_id:c,kind:"contact",title:t,body:i,results:[],created_date:new Date().toISOString()},...j])}catch{}}async function G(t,i){if(!t._dirty)return;const j=(t._before??{})[i],C=(t[i]??"")===""?null:t[i];try{await L.entities.SalesContact.update(t.id,{[i]:C,updated_date:new Date().toISOString()}),d(K=>K.map(ue=>ue.id===t.id?{...ue,_dirty:!1,_before:void 0}:ue)),u(`עודכנו פרטי איש קשר · ${t.name||"ללא שם"}`,`${Xt[i]||i}: ${j||"—"} ← ${C||"—"}`),B()}catch(K){h.error(/duplicate|unique/i.test(String(K==null?void 0:K.message))?"נייד כזה כבר קיים אצל הלקוח":"שגיאה בעדכון איש הקשר"),T()}}async function Z(t){if(confirm(`למחוק את ${t.name||"איש הקשר"}?`))try{await L.entities.SalesContact.delete(t.id),d(i=>i.filter(j=>j.id!==t.id)),u(`נמחק איש קשר · ${t.name||"ללא שם"}`,[t.phone,t.email].filter(Boolean).join(" · ")),h.success("איש הקשר נמחק")}catch{h.error("שגיאה במחיקה")}}async function we(t){if(t.preventDefault(),!(!g.name.trim()&&!g.phone.trim()))try{const i=await L.entities.SalesContact.create({id:ge(),customer_id:c,name:g.name.trim()||null,phone:g.phone.trim()||null,email:g.email.trim()||null,is_starred:!1});d(j=>[...j,i]),u(`נוסף איש קשר · ${i.name||"ללא שם"}`,[i.phone,i.email].filter(Boolean).join(" · ")),Q({name:"",phone:"",email:""}),B()}catch(i){h.error(/duplicate|unique/i.test(String(i==null?void 0:i.message))?"איש קשר עם הנייד הזה כבר קיים אצל הלקוח":"שגיאה בהוספה")}}return w?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(se,{className:"w-6 h-6 text-emerald-600 animate-spin"})}):m?e.jsxs("div",{dir:"rtl",className:"p-4 sm:p-6 max-w-6xl mx-auto space-y-4",children:[e.jsxs("div",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm px-4 sm:px-5 py-4 flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3 min-w-0",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-emerald-50 flex items-center justify-center shrink-0",children:e.jsx(Ae,{className:"w-5 h-5 text-emerald-600"})}),e.jsx("h1",{className:"text-xl sm:text-2xl font-extrabold text-slate-800 truncate",children:m.name}),e.jsx("span",{className:`px-2.5 py-0.5 rounded-full text-xs font-medium ${xt(m.status)}`,children:mt(m.status)}),e.jsxs("span",{className:"text-xs text-slate-400 flex items-center gap-1 whitespace-nowrap",children:[e.jsx(Se,{className:"w-3.5 h-3.5"})," ",k.length," אנשי קשר",ie>0&&e.jsxs(e.Fragment,{children:[" · ",ie," מועדפים"]})]}),e.jsxs("span",{className:`text-xs text-emerald-600 flex items-center gap-1 transition-opacity duration-300 ${V?"opacity-100":"opacity-0"}`,children:[e.jsx(te,{className:"w-3.5 h-3.5"})," נשמר"]})]}),e.jsxs("button",{onClick:()=>N("/sales/customers"),className:"inline-flex items-center gap-1.5 h-10 px-4 roun
1ded-full border border-slate-200 text-sm font-medium text-slate-600 hover:bg-slate-50 shrink-0",children:[e.jsx(it,{className:"w-4 h-4"})," חזרה לרשימה"]})]}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:Gt.map(t=>{const i=t.icon,j=()=>t.soon?h("בקרוב",{icon:"🛠️"}):t.key==="demo"?q?P(!0):F(!0):t.key==="contract"?f(!0):t.key==="quote"?H(!0):N(`/sales/customers/${c}/notes`);return e.jsxs("button",{type:"button",onClick:j,className:`text-right rounded-2xl border shadow-sm p-3 transition-all hover:shadow-md ${t.key==="demo"&&q?"bg-blue-50/70 border-blue-300 ring-1 ring-blue-200":`bg-white border-slate-200 ${t.ring}`}`,children:[e.jsx("div",{className:`w-9 h-9 rounded-xl ${t.tint} flex items-center justify-center mb-2`,children:e.jsx(i,{className:"w-4.5 h-4.5"})}),e.jsx("p",{className:"text-sm font-bold text-slate-800 leading-tight",children:t.key==="demo"&&q?"הזמנה להדגמה פעילה":t.label}),t.soon?e.jsx("span",{className:"inline-block mt-1 px-1.5 py-0.5 rounded-full bg-slate-100 text-slate-500 text-[0.625rem] font-bold",children:"בקרוב"}):t.key==="demo"&&q?e.jsxs("span",{className:"block mt-1",children:[e.jsx("span",{className:"inline-block px-1.5 py-0.5 rounded-full bg-blue-100 text-blue-800 text-[0.625rem] font-bold",children:ze(q)}),e.jsx("span",{className:"block text-[0.625rem] text-blue-700 font-bold mt-0.5 truncate",children:Ue(q)})]}):t.key==="notes"&&l.length>0?e.jsxs("span",{className:"inline-block mt-1 px-1.5 py-0.5 rounded-full bg-cyan-50 text-cyan-700 text-[0.625rem] font-bold",children:[l.length," רשומות"]}):t.key==="contract"&&v[0]?e.jsx("span",{className:`inline-block mt-1 px-1.5 py-0.5 rounded-full text-[0.625rem] font-bold ${Ye(v[0])}`,children:Ve(v[0])}):t.key==="quote"&&y[0]?e.jsx("span",{className:`inline-block mt-1 px-1.5 py-0.5 rounded-full text-[0.625rem] font-bold ${Ze(y[0])}`,children:Ge(y[0])}):e.jsx("span",{className:"inline-block mt-1 text-[0.625rem] font-bold text-slate-400",children:" "})]},t.key)})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4 items-start",children:[e.jsxs("section",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-slate-100",children:[e.jsxs("h2",{className:"text-sm font-bold text-slate-800 flex items-center gap-2",children:[e.jsx(Ae,{className:"w-4 h-4 text-emerald-600"})," פרטי הלקוח"]}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400",children:"נשמר אוטומטית"})]}),e.jsxs("div",{className:"p-4 space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:fe,htmlFor:"ce-name",children:"שם הלקוח"}),e.jsx("input",{id:"ce-name",value:m.name||"",onChange:t=>ee({name:t.target.value}),onBlur:()=>re("name"),className:me})]}),e.jsxs("div",{children:[e.jsx("label",{className:fe,htmlFor:"ce-moatza",children:"מועצה"}),e.jsx(ht,{id:"ce-moatza",value:m.moatza||"",options:p,onChange:t=>ee({moatza:t}),onCommit:t=>re("moatza",t),placeholder:"מטה אשר",newLabel:"הוספת מועצה",className:me})]}),e.jsxs("div",{children:[e.jsx("label",{className:fe,htmlFor:"ce-status",children:"סטאטוס"}),e.jsx("select",{id:"ce-status",value:m.status,onChange:t=>a(t.target.value),className:me,children:ut.map(t=>e.jsx("option",{value:t.key,children:t.short},t.key))})]}),e.jsxs("div",{children:[e.jsx("label",{className:fe,htmlFor:"ce-notes",children:"הערות"}),e.jsx("textarea",{id:"ce-notes",rows:4,value:m.notes||"",onChange:t=>ee({notes:t.target.value}),onBlur:()=>re("notes"),className:"w-full rounded-xl border border-slate-200 bg-white p-3 text-sm focus:outline-none focus-visible:ring-2 focus-visible:ring-blue-400 focus-visible:ring-offset-1 focus:ring-2 focus:ring-emerald-100 focus:border-emerald-300"})]})]})]}),e.jsxs("section",{className:"bg-white rounded-2xl border border-slate-200 shadow-sm overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-4 py-3 border-b border-slate-100",children:[e.jsxs("h2",{className:"text-sm font-bold text-slate-800 flex items-center gap-2",children:[e.jsx(Se,{className:"w-4 h-4 text-blue-600"})," אנשי הקשר"]}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400",children:"נשמר אוטומטית"})]}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400 px-4 pt-2",children:'הכוכב מסמן איש קשר מועדף — אליו נשלחות הודעות כשבוחרים "רק מסומנים בכוכב".'}),Y.length===0?e.jsx("p",{className:"text-sm text-slate-500 px-4 py-8 text-center",children:"אין עדיין אנשי קשר ללקוח הזה."}):e.jsx("div",{className:"divide-y divide-slate-100 mt-1",children:Y.map(t=>e.jsxs("div",{className:"px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("button",{type:"button",onClick:()=>_(t),"aria-pressed":!!t.is_starred,"aria-label":t.is_starred?`הסר מועדף מ${t.name||"איש הקשר"}`:`סמן את ${t.name||"איש הקשר"} כמועדף`,className:"p-1.5 rounded-lg hover:bg-amber-50 shrink-0",children:e.jsx(ct,{className:`w-4 h-4 ${t.is_starred?"text-amber-500 fill-amber-400":"text-slate-300"}`})}),e.jsx("input",{value:t.name||"",onChange:i=>s(t,{name:i.target.value}),onBlur:()=>G(t,"name"),"aria-label":"שם איש הקשר",placeholder:"שם",className:`${Ie} flex-1 min-w-0 font-medium`}),e.jsx("button",{type:"button",onClick:()=>Z(t),"aria-label":`מחק את ${t.name||"איש הקשר"}`,className:"p-1.5 rounded-lg hover:bg-red-50 text-red-500 shrink-0",children:e.jsx(xe,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"pr-8 space-y-1",children:[{field:"phone",label:"נייד",placeholder:"050-1234567"},{field:"email",label:'דוא"ל',placeholder:"[email protected]"}].map(({field:i,label:j,placeholder:C})=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[0.6875rem] text-slate-400 w-12 shrink-0 text-right",children:j}),e.jsx("input",{value:t[i]||"",onChange:K=>s(t,{[i]:K.target.value}),onBlur:()=>G(t,i),"aria-label":j,placeholder:C,dir:"ltr",className:`${Ie} flex-1 min-w-0 text-slate-600 text-left`,style:{unicodeBidi:"plaintext"}})]},i))}),ae&&e.jsx("div",{className:"pr-8 mt-1",children:e.jsx(zt,{last:ae,timeline:oe})})]},t.id))}),e.jsxs("form",{onSubmit:we,className:"px-3 py-3 bg-slate-50 border-t border-slate-100 space-y-2",children:[e.jsx("p",{className:"text-xs font-bold text-slate-600",children:"הוספת איש קשר"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx("input",{value:g.name,onChange:t=>Q(i=>({...i,name:t.target.value})),placeholder:"שם","aria-label":"שם איש קשר חדש",className:me}),e.jsx("input",{value:g.phone,onChange:t=>Q(i=>({...i,phone:t.target.value})),placeholder:"נייד","aria-label":"נייד של איש קשר חדש",dir:"ltr",className:me}),e.jsx("input",{value:g.email,onChange:t=>Q(i=>({...i,email:t.target.value})),placeholder:'דוא"ל',"aria-label":"דואר אלקטרוני של איש קשר חדש",dir:"ltr",className:me}),e.jsxs("button",{type:"submit",disabled:!g.name.trim()&&!g.phone.trim(),className:"inline-flex items-center justify-center gap-1.5 h-10 rounded-full bg-emerald-600 text-white text-sm font-bold hover:bg-emerald-700 disabled:opacity-40",children:[e.jsx(dt,{className:"w-4 h-4"})," הוסף איש קשר"]})]})]})]})]}),W&&e.jsx(Yt,{customer:m,contacts:k,senderName:(x==null?void 0:x.full_name)||"",existing:y[0]||null,onClose:()=>H(!1),onChanged:()=>T()}),S&&e.jsx(Vt,{customer:m,contacts:k,senderName:(x==null?void 0:x.full_name)||"",existing:v[0]||null,onClose:()=>f(!1),onChanged:()=>T()}),n&&e.jsx(pt,{target:m,contacts:k,senderName:(x==null?void 0:x.full_name)||"",onClose:()=>F(!1),onAddPerson:t=>d(i=>[...i,t]),onSent:()=>T()}),E&&q&&e.jsx(Ht,{demo:q,customer:m,contacts:k,senderName:(x==null?void 0:x.full_name)||"",onClose:()=>P(!1),onChanged:()=>T(),onViewMessage:t=>I(t)}),R&&e.jsx(gt,{activity:R,customerName:m.name,onClose:()=>I(null)})]}):e.jsxs("div",{dir:"rtl",className:"p-6 max-w-3xl mx-auto text-center",children:[e.jsx("p",{className:"text-sm text-slate-500 mb-4",children:"הלקוח לא נמצא."}),e.jsx("button",{onClick:()=>N("/sales/customers"),className:"h-10 px-5 rounded-full border border-slate-200 text-sm font-medium hover:bg-slate-50",children:"חזרה לרשימה"})]})}
1export{$s 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.