PageSourceSearch

https://tsofit.org.il/assets/AlertModuleDetailPage-DtUNSNhc.js

js tsofit.org.il collected 2026-09-25 02:12:52 UTC 27,125 bytes, 1 lines download raw bytes

1import{aa as $e,t as Me,ae as ne,al as Ie,ah as re,bV as Ae,ao as Pe,r as i,d as _,j as e,F as Re,A as Be,aJ as Le,C as ze,ad as oe,a0 as Ke,bp as ie,Z as Oe,w as De,X as ce,b as J,a3 as X,aE as He,aj as Ve,M as Fe,a8 as Ue,x as We,z as O}from"./index-BuF13C9R.js";import{u as qe}from"./useDashboardData-LAwTBCIK.js";import{c as Ge}from"./dashboardUtils-BNRxAObU.js";import{s as Ye,c as Je,a as Z,r as Xe,S as Ze,T as Qe,C as de}from"./notificationCatalog-BP5L2CAl.js";import{P as et}from"./PageTitleMenu-DlabIv_d.js";import{u as tt,E as st}from"./useCommunityEmailBrand-CBT_dQWF.js";import{C as at}from"./clipboard-check-CMT0h_dd.js";import{C as lt}from"./chevron-left-D2IUBEPa.js";import{B as Q}from"./bell-ring-DHDlhRvf.js";import{P as nt}from"./pencil-CoE4mwuD.js";import"./softDelete-X2GBluex.js";import"./eventUtils-CXcXESVM.js";import"./money-CmD9E_V-.js";import"./sparkles-Bk9eJtR5.js";import"./upload-DeFZlL4S.js";import"./dumbbell-BjAgLDIP.js";import"./palette-CUQSS43O.js";import"./mic-g0118XVV.js";import"./film-BOiDnw57.js";import"./utensils-r-GP3VfR.js";import"./party-popper-gcJ6l8qF.js";import"./trophy-DMauxpio.js";import"./graduation-cap-D9zn9IjR.js";import"./baby-BUG_dxit.js";import"./music-2TdapQX4.js";import"./ticket-CDYxoEs8.js";import"./qr-code-3JiqBCAV.js";import"./calendar-plus-D4QZ2Dyk.js";import"./dollar-sign-B6wkvb6V.js";import"./votingUtils-3kN6dDVT.js";import"./headphones-Bk55olo7.js";import"./useActionVisibility-DLgqAw2q.js";import"./communityEmail-DHv9zmVf.js";const rt={"public_venues|resident":{label:"למעקב אחר ההזמנה",target:"personal"},"public_venues|manager":{label:"לניהול היומן",target:"module"}};function xe(t,r){return rt[`${t}|${r}`]||null}const ot={ok:"bg-emerald-50 text-emerald-700 border-emerald-200",warn:"bg-amber-50 text-amber-700 border-amber-200",off:"bg-slate-100 text-slate-500 border-slate-200"},le={whatsapp:{cls:"bg-emerald-50 text-emerald-700 border-emerald-200",Icon:Ue},email:{cls:"bg-blue-50 text-blue-700 border-blue-200",Icon:Fe},inapp:{cls:"bg-violet-50 text-violet-700 border-violet-200",Icon:Ve},push:{cls:"bg-slate-100 text-slate-500 border-slate-200",Icon:Q}},it={manager:De,responsible:Oe,resident:ie,voter:Ke,observer:oe},ct={manager:"bg-slate-800 text-white",responsible:"bg-cyan-600 text-white",resident:"bg-violet-500 text-white",voter:"bg-indigo-600 text-white",observer:"bg-amber-600 text-white"},U=(t,r)=>`${t}|${r}`,W=(t,r,d)=>`${t}|${r}|${d}`,dt={"{{שם_מלא}}":"ישראל ישראלי","{{שם_פרטי}}":"ישראל","{{מרחב}}":"מרחב לדוגמה","{{מועד}}":"יום ג׳, 20/08 בשעה 19:00","{{קישור}}":"https://app.eshuv.co.il/…","{{קישור_אנדרואיד}}":"https://play.google.com/store/apps/eshuv","{{קישור_אפל}}":"https://apps.apple.com/app/eshuv"},me=t=>({...dt,"{{שם_קיבוץ}}":t||"הקהילה"}),pe=(t,r)=>String(t||"").replace(/\{\{[^}]+\}\}/g,d=>d in r?r[d]:d),he=t=>t==="inapp"?"push":t;function q({ch:t}){var m;const r=le[t]||le.push,d=r.Icon;return e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] font-bold rounded-md px-2 py-0.5 border ${r.cls}`,children:[e.jsx(d,{className:"w-3 h-3"})," ",((m=de[t])==null?void 0:m.short)||t]})}function xt({checked:t,disabled:r,tone:d="ok",busy:m,onChange:S}){return e.jsx("button",{type:"button",role:"switch","aria-checked":t,disabled:r||m,onClick:()=>!r&&!m&&S(!t),title:r?"התראה זו אינה מחוברת לשליחה":"הפעלה/כיבוי",className:`relative inline-flex h-6 w-11 items-center rounded-full flex-none transition-colors ${t?d==="warn"?"bg-amber-400":"bg-emerald-500":"bg-slate-200"} ${r?"opacity-50 cursor-not-allowed":"cursor-pointer"}`,children:e.jsx("span",{className:`inline-block h-4 w-4 rounded-full bg-white shadow transform transition-transform ${t?"translate-x-1":"translate-x-6"}`})})}function mt({item:t,enabled:r,busy:d,onToggle:m,onEdit:S,onChannelHover:v,onChannelLeave:b}){const c=Ze[t.state],n=t.state!=="off",f=t.template&&Object.keys(t.template).length>0;return e.jsx("div",{onClick:()=>f&&S(t),role:f?"button":void 0,title:f?"לחצו לעריכת נוסח ההתראה":"",className:`rounded-xl border bg-white shadow-sm transition-colors ${f?"cursor-pointer border-slate-200 hover:border-cyan-300 hover:bg-cyan-50/50":"border-slate-200 hover:bg-slate-50/60"}`,children:e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-2 px-3 sm:px-4 py-3",children:[e.jsx("span",{className:`inline-flex items-center gap-1 text-[11px] font-bold rounded-md px-2 py-1 border whitespace-nowrap ${ot[c.tone]}`,children:c.label}),e.jsxs("div",{className:"min-w-0 flex-1 order-last sm:order-none w-full sm:w-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-800",children:t.name}),n&&(t.wired?e.jsx("span",{className:"text-[10px] font-bold text-emerald-700 bg-emerald-50 border border-emerald-200 rounded px-1.5 py-0.5",children:"בתוקף"}):e.jsx("span",{className:"text-[10px] font-bold text-slate-500 bg-slate-100 border border-slate-200 rounded px-1.5 py-0.5",children:"יישמר · ייכנס לתוקף בהמשך"}))]}),t.note&&e.jsx("div",{className:"text-xs text-slate-500 mt-0.5",children:t.note})]}),e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap",children:t.channels.length>0?t.channels.map(g=>e.jsx("span",{className:"cursor-help",onMouseEnter:k=>v(t,g,k),onMouseLeave:b,children:e.jsx(q,{ch:g})},g)):e.jsx("span",{className:"text-[11px] font-semibold text-slate-400 border border-dashed border-slate-200 rounded-md px-2 py-0.5",children:"ללא ערוץ"})}),e.jsx("span",{className:"flex-none",onClick:g=>g.stopPropagation(),children:e.jsx(xt,{checked:n&&r,disabled:!n,tone:c.tone,busy:d,onChange:g=>m(t,g)})}),f&&e.jsx(nt,{className:"w-4 h-4 text-slate-300 flex-none"})]})})}function ue({channel:t,text:r,image:d,left:m,top:S,communityName:v,name:b,images:c,brand:n,cta:f}){const g=r||"(אין טקסט)";if(t==="email")return e.jsx("div",{className:"fixed inset-0 z-[80] grid place-items-center p-4 pointer-events-none",dir:"rtl",children:e.jsxs("div",{className:"pointer-events-auto w-[380px] max-w-[92vw] rounded-2xl bg-white shadow-2xl border border-slate-200 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-[11.5px] font-bold text-slate-500 border-b border-slate-100",children:[e.jsx(q,{ch:"email"})," תצוגה מקדימה במייל"]}),e.jsx(st,{width:380,height:520,className:"rounded-none border-0 border-t",opts:{...n||{},communityName:(n==null?void 0:n.communityName)||v,title:b,body:r,imageUrl:d||void 0,...f?{ctaUrl:"#",ctaLabel:f.label}:{},senderLabel:"דוא״ל התראות",sentAt:new Date().toLocaleStr
1ing("he-IL",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}),year:String(new Date().getFullYear())}})]})});const k=(c==null?void 0:c.push)||"",j=(c==null?void 0:c.push)||(c==null?void 0:c.whatsapp)||(c==null?void 0:c.email)||"";return e.jsx("div",{className:"fixed z-[80] w-80 pointer-events-none",style:{left:m,top:S},dir:"rtl",children:e.jsxs("div",{className:"rounded-2xl bg-white shadow-2xl border border-slate-200 p-3",children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-2 text-[11.5px] font-bold text-slate-500",children:[e.jsx(q,{ch:t})," תצוגה מקדימה"]}),t==="whatsapp"?e.jsx("div",{className:"rounded-xl bg-emerald-50 p-2.5",children:e.jsxs("div",{className:"bg-white rounded-xl rounded-tr-sm shadow-sm overflow-hidden",children:[d&&e.jsx("img",{src:d,alt:"",className:"w-full max-h-36 object-cover"}),e.jsx("div",{className:"px-3 py-2 text-[12.5px] text-slate-800 whitespace-pre-wrap leading-relaxed",children:g}),e.jsx("div",{className:"px-3 pb-1.5 text-[10px] text-slate-400 text-left",children:"10:24 ✓✓"})]})}):e.jsx("div",{className:"rounded-[26px] bg-slate-100 p-2 shadow-inner",children:e.jsxs("div",{className:"bg-white rounded-[22px] shadow-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3.5 pt-3 pb-2",children:[k?e.jsx("img",{src:k,alt:"",className:"w-6 h-6 rounded-md object-cover flex-none"}):e.jsx("span",{className:"w-6 h-6 rounded-md bg-primary grid place-items-center flex-none text-white",children:e.jsx(Q,{className:"w-3.5 h-3.5"})}),e.jsx("span",{className:"text-[11.5px] font-semibold text-slate-500 truncate flex-1",children:v||"מערכת לניהול היישוב"}),e.jsx("span",{className:"text-[10.5px] text-slate-400 flex-none",children:"· עכשיו"}),e.jsx(He,{className:"w-4 h-4 text-slate-300 flex-none"})]}),j&&e.jsx("img",{src:j,alt:"",className:"w-full max-h-40 object-cover"}),e.jsxs("div",{className:"px-3.5 py-3",children:[e.jsx("div",{className:"text-[14px] font-extrabold text-slate-900 leading-tight",children:b}),e.jsx("div",{className:"text-[12.5px] text-slate-600 leading-relaxed line-clamp-3 mt-1 whitespace-pre-wrap",children:g})]})]})})]})})}function pt({moduleKey:t,communityId:r,canSendTest:d,situation:m,initial:S,saving:v,images:b,communityName:c,onClose:n,onSave:f}){var L;const{t:g}=ne(),k=i.useMemo(()=>{const p=(m.channels||[]).filter(E=>E!=="push"),C=p.length?p:Object.keys(m.template||{});return C.length?C:["whatsapp"]},[m]),j=tt(r),[T,x]=i.useState(k[0]),[y,h]=i.useState(S),[M,$]=i.useState(!1),[D,P]=i.useState(!1),R=i.useRef(null),w=p=>h(C=>({...C,[T]:p})),B=p=>{const C=R.current,E=y[T]||"";if(!C){w(E+p);return}const V=C.selectionStart??E.length,A=C.selectionEnd??E.length;w(E.slice(0,V)+p+E.slice(A)),requestAnimationFrame(()=>{C.focus();const F=V+p.length;C.setSelectionRange(F,F)})},H=y[T]??"";return e.jsxs("div",{className:"fixed inset-0 z-[60]",dir:"rtl",children:[e.jsx("div",{className:"absolute inset-0 bg-slate-900/50",onClick:n}),e.jsxs("aside",{className:"absolute inset-y-0 start-0 w-[min(480px,94vw)] bg-white shadow-2xl flex flex-col",children:[e.jsxs("div",{className:"flex items-start gap-3 px-5 py-4 border-b border-slate-100",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-base font-extrabold text-slate-800",children:m.name}),e.jsxs("div",{className:"text-xs text-slate-500 mt-0.5",children:[re(t,g).label," · ",(L=Z[m.recipient])==null?void 0:L.label]})]}),e.jsx("button",{onClick:n,className:"ms-auto w-8 h-8 grid place-items-center rounded-lg bg-slate-50 border border-slate-200 text-slate-500 hover:bg-slate-100",children:e.jsx(ce,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"px-5 py-4 overflow-auto flex-1",children:[e.jsx("div",{className:`rounded-xl px-3 py-2.5 text-[12.5px] font-semibold mb-4 border ${m.wired?"bg-emerald-50 text-emerald-700 border-emerald-200":"bg-slate-50 text-slate-600 border-slate-200"}`,children:m.wired?"התראה מחוברת — עריכת הנוסח תשפיע על ההודעות שיישלחו.":"הנוסח יישמר וייכנס לתוקף כשההתראה תחובר לשליחה. אפשר לנסח מראש."}),k.length>1&&e.jsx("div",{className:"flex gap-2 mb-3",children:k.map(p=>e.jsx("button",{onClick:()=>x(p),className:`inline-flex items-center gap-1.5 text-[12.5px] font-bold rounded-lg px-3 py-1.5 border ${T===p?"bg-cyan-50 border-cyan-300 text-cyan-700":"bg-slate-50 border-slate-200 text-slate-500"}`,children:e.jsx(q,{ch:p})},p))}),e.jsx("div",{className:"text-xs font-bold text-slate-500 mb-1.5",children:"טקסט ההודעה"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-2",children:Qe.map(p=>e.jsx("button",{type:"button",onClick:()=>B(p),className:"text-[11px] font-semibold text-cyan-700 bg-cyan-50 border border-dashed border-cyan-300 rounded px-2 py-0.5 hover:bg-cyan-100",children:p},p))}),e.jsx("textarea",{ref:R,value:H,onChange:p=>w(p.target.value),spellCheck:!1,className:"w-full min-h-[130px] resize-y rounded-xl border border-slate-200 bg-slate-50 px-3.5 py-3 text-sm leading-relaxed text-slate-800 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 focu
1s:border-cyan-400"}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 flex-wrap",children:[e.jsxs("button",{type:"button",onMouseEnter:()=>P(!0),onMouseLeave:()=>P(!1),onClick:()=>P(p=>!p),className:"inline-flex items-center gap-1.5 text-[12.5px] font-bold rounded-lg px-3 py-2 border bg-cyan-50 border-cyan-200 text-cyan-700 hover:bg-cyan-100",children:[e.jsx(oe,{className:"w-4 h-4"})," תצוגה מוקדמת"]}),e.jsx("span",{className:"text-[11px] text-slate-400",children:"עמדו על הכפתור לצפייה בתצוגה מקדימה במרכז המסך"})]})]}),e.jsxs("div",{className:"px-5 py-3.5 border-t border-slate-100 flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>f(y),disabled:v,className:"inline-flex items-center gap-2 bg-cyan-600 hover:bg-cyan-700 text-white font-bold text-sm rounded-lg px-4 py-2.5 disabled:opacity-60",children:[v&&e.jsx(J,{className:"w-4 h-4 animate-spin"})," שמירת התבנית"]}),e.jsx("button",{onClick:n,className:"text-slate-500 font-semibold text-sm rounded-lg px-4 py-2.5 bg-slate-50 border border-slate-200 hover:bg-slate-100",children:"ביטול"}),d&&e.jsxs("button",{onClick:()=>$(!0),className:"ms-auto inline-flex items-center gap-1.5 text-fuchsia-700 bg-fuchsia-50 border border-fuchsia-200 hover:bg-fuchsia-100 font-bold text-sm rounded-lg px-4 py-2.5",children:[e.jsx(X,{className:"w-4 h-4"})," שלח לבדיקה"]})]})]}),D&&e.jsx(ue,{channel:T,text:pe(H,me(c)),image:(b==null?void 0:b[he(T)])||(b==null?void 0:b.email)||"",left:Math.max(12,Math.round((window.innerWidth-320)/2)),top:Math.max(12,Math.round((window.innerHeight-360)/2)),communityName:c,name:m.name,images:b,brand:j,cta:xe(t,m.recipient)}),M&&e.jsx(ht,{moduleKey:t,communityId:r,situation:m,channels:k,draft:y,onClose:()=>$(!1)})]})}function ht({moduleKey:t,communityId:r,situation:d,channels:m,draft:S,onClose:v}){const[b,c]=i.useState(null),[n,f]=i.useState({}),[g,k]=i.useState(!1);i.useEffect(()=>{let x=!1;return _.entities.NotificationTestRecipient.list("-created_date",200).then(y=>{x||(c(y||[]),f(Object.fromEntries((y||[]).map(h=>[h.id,!0]))))}).catch(()=>{x||c([])}),()=>{x=!0}},[]);const j=m.filter(x=>["whatsapp","email","push"].includes(x)),T=async()=>{const x=Object.keys(n).filter(h=>n[h]);if(!x.length){O.error("בחרו לפחות נמען אחד");return}const y=j.map(h=>({channel:h,text:S[h]||""})).filter(h=>h.text.trim());if(!y.length){O.error("אין טקסט לשליחה בערוצים הפעילים");return}k(!0);try{const h=await _.functions.invoke("sendTemplateTest",{communityId:r,moduleKey:t,situationKey:d.key,subject:d.name,recipientIds:x,sends:y}),M=(h==null?void 0:h.data)||{};M.success?(O.success(`נשלחו ${M.sent} הודעות בדיקה`),v()):O.error("שליחת הבדיקה נכשלה")}catch(h){console.error(h),O.error("שגיאה בשליחת הבדיקה")}finally{k(!1)}};return e.jsxs("div",{className:"fixed inset-0 z-[70] flex items-center justify-center p-4",dir:"rtl",onClick:v,children:[e.jsx("div",{className:"absolute inset-0 bg-slate-900/50"}),e.jsxs("div",{className:"relative w-full max-w-md bg-white rounded-2xl shadow-2xl flex flex-col max-h-[85vh]",onClick:x=>x.stopPropagation(),children:[e.jsxs("div",{className:"flex items-center gap-2 px-5 py-4 border-b border-slate-100",children:[e.jsx("span",{className:"w-8 h-8 rounded-lg grid place-items-center bg-fuchsia-50 text-fuchsia-600 flex-none",children:e.jsx(X,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[15px] font-extrabold text-slate-800",children:"שליחת בדיקה"}),e.jsxs("div",{className:"text-[12px] text-slate-500",children:[d.name," · ערוצים: ",j.map(x=>{var y;return((y=de[x])==null?void 0:y.short)||x}).join(" · ")||"—"]})]}),e.jsx("button",{onClick:v,className:"ms-auto w-8 h-8 grid place-items-center rounded-lg bg-slate-50 border border-slate-200 text-slate-500",children:e.jsx(ce,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"p-4 overflow-y-auto flex-1",children:[e.jsxs("div",{className:"text-[12px] font-bold text-slate-500 mb-2 flex items-center gap-1.5",children:[e.jsx(We,{className:"w-3.5 h-3.5"})," בחרו נמעני בדיקה"]}),b===null?e.jsx("div",{className:"flex justify-center py-6 text-slate-400",children:e.jsx(J,{className:"w-5 h-5 animate-spin"})}):b.length===0?e.jsx("p",{className:"text-sm text-slate-400 text-center py-6",children:"אין נמעני בדיקה. הוסיפו ברשימת «תמונות להתראות» בממשק הסופר-אדמין."}):e.jsx("div",{className:"space-y-1.5",children:b.map(x=>e.jsxs("label",{className:"flex items-center gap-2.5 rounded-xl border border-slate-200 px-3 py-2 cursor-pointer hover:bg-slate-50",children:[e.jsx("input",{type:"checkbox",checked:!!n[x.id],onChange:y=>f(h=>({...h,[x.id]:y.target.checked})),className:"w-4 h-4 accent-fuchsia-600"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[13.5px] font-bold text-slate-800 truncate",children:x.name||"—"}),e.jsx("div",{className:"text-[11.5px] text-slate-400 truncate",dir:"ltr",children:[x.phone,x.email].filter(
1Boolean).join(" · ")})]})]},x.id))})]}),e.jsxs("div",{className:"px-5 py-3.5 border-t border-slate-100 flex items-center gap-2",children:[e.jsxs("button",{onClick:T,disabled:g||!(b!=null&&b.length),className:"inline-flex items-center gap-2 bg-fuchsia-600 hover:bg-fuchsia-700 text-white font-bold text-sm rounded-lg px-4 py-2.5 disabled:opacity-60",children:[g?e.jsx(J,{className:"w-4 h-4 animate-spin"}):e.jsx(X,{className:"w-4 h-4"})," שלח בדיקה"]}),e.jsx("button",{onClick:v,className:"text-slate-500 font-semibold text-sm rounded-lg px-4 py-2.5 bg-slate-50 border border-slate-200 hover:bg-slate-100",children:"ביטול"})]})]})]})}function Gt(){const{id:t,moduleKey:r}=$e(),d=Me(),{t:m}=ne(),{data:S,loading:v}=qe(t),{authorized:b}=Ie(),c=`/kibbutz/${t}`,n=Xe(r),f=re(r),g=Ae(f.label||"",m),k=f.icon||Pe,j=i.useMemo(()=>{const a=(Ge(S)||[]).find(o=>o.key===r);return a?{count:a.count||0,unit:a.unit||"",to:`${c}${a.path||f.path||`/${r}`}${a.query||""}`}:null},[S,r,c,f.path]),T=Ye(r),x=Je(r),y=T.total>0,[h,M]=i.useState({}),[$,D]=i.useState({}),[P,R]=i.useState(null),[w,B]=i.useState(null),[H,L]=i.useState(!1),[p,C]=i.useState(""),[E,V]=i.useState("notifications"),[A,F]=i.useState(""),[z,be]=i.useState({}),[ee,te]=i.useState(null),[se,fe]=i.useState(()=>new Set),I=i.useCallback(s=>{C(s),window.clearTimeout(I._t),I._t=window.setTimeout(()=>C(""),2200)},[]);i.useEffect(()=>{if(!t||!y)return;let s=!1;return(async()=>{try{const[a,o]=await Promise.all([_.entities.NotificationSetting.filter({community_id:t,module_key:n}),_.entities.NotificationTemplate.filter({community_id:t,module_key:n})]);if(s)return;const l={};for(const u of a||[])l[U(u.module_key,u.situation_key)]={id:u.id,enabled:u.enabled!==!1};const N={};for(const u of o||[])N[W(u.module_key,u.situation_key,u.channel)]={id:u.id,body:u.body||""};M(l),D(N)}catch{}})(),()=>{s=!0}},[t,n,y]),i.useEffect(()=>{if(!t)return;let s=!1;return _.entities.NotificationChannelPolicy.filter({community_id:t}).then(a=>{if(s)return;const o=new Set;for(const l of a||[])l&&l.allowed===!1&&l.recipient_role&&l.channel&&o.add(`${l.recipient_role}|${l.channel}`);fe(o)}).catch(()=>{}),()=>{s=!0}},[t]);const G=i.useCallback((s,a)=>{const o=a==="push"?"inapp":a;return!se.has(`${s}|${o}`)},[se]),ge=i.useMemo(()=>x.map(s=>({...s,items:s.items.map(a=>{const o=(a.channels||[]).filter(N=>G(a.recipient,N)),l={};for(const[N,u]of Object.entries(a.template||{}))G(a.recipient,N)&&(l[N]=u);return{...a,channels:o,template:l}})})),[x,G]);i.useEffect(()=>{if(!t)return;let s=!1;return _.entities.Kibbutz.get(t).then(a=>{s||F((a==null?void 0:a.name)||"")}).catch(()=>{}),()=>{s=!0}},[t]),i.useEffect(()=>{if(!n)return;let s=!1;return _.entities.NotificationImage.filter({module_key:n}).then(a=>{if(s)return;const o={};for(const l of a||[])l.image_url&&(o[l.channel]=l.image_url);be(o)}).catch(()=>{}),()=>{s=!0}},[n]);const je=i.useCallback((s,a,o)=>{var ae;const l=o.currentTarget.getBoundingClientRect(),N=320,u=360,K=Math.max(12,Math.round((window.innerWidth-N)/2)),Se=Math.max(12,Math.min(Math.round(l.top+l.height/2-u/2),window.innerHeight-u-12)),Y=$[W(n,s.key,a)],Te=(Y==null?void 0:Y.body)??((ae=s.template)==null?void 0:ae[a])??"",Ee=pe(Te,me(A)),_e=z[he(a)]||z.email||"";te({channel:a,text:Ee,image:_e,left:K,top:Se,name:s.name,cta:xe(n,s.recipient)})},[$,n,A,z]),ye=i.useCallback(()=>te(null),[]),Ne=i.useCallback(s=>{const a=h[U(n,s.key)];return a?a.enabled:s.state!=="off"},[h,n]),we=i.useCallback(async(s,a)=>{const o=U(n,s.key);R(o);try{const l=h[o];if(l!=null&&l.id)await _.entities.NotificationSetting.update(l.id,{enabled:a}),M(N=>({...N,[o]:{...l,enabled:a}}));else{const N=await _.entities.NotificationSetting.create({community_id:t,module_key:n,situation_key:s.key,enabled:a});M(u=>({...u,[o]:{id:N==null?void 0:N.id,enabled:a}}))}I(a?"ההתראה הופעלה":"ההתראה כובתה")}catch{I("השמירה נכשלה — נסו שוב")}finally{R(null)}},[h,n,t,I]),ve=i.useCallback(s=>B(s),[]),ke=i.useMemo(()=>{var a;if(!w)return{};const s={};for(const o of Object.keys(w.template||{})){const l=$[W(n,w.key,o)];s[o]=(l==null?void 0:l.body)??w.template[o]}for(const o of w.channels||[])s[o]==null&&(s[o]=((a=w.template)==null?void 0:a[o])||"");return s},[w,$,n]),Ce=i.useCallback(async s=>{if(w){L(!0);try{const a={};for(const[o,l]of Object.entries(s)){if(o==="push")continue;const N=W(n,w.key,o),u=$[N];if(u!=null&&u.id)await _.entities.NotificationTemplate.update(u.id,{body:l}),a[N]={...u,body:l};else{const K=await _.entities.NotificationTemplate.create({community_id:t,module_key:n,situation_key:w.key,channel:o,body:l});a[N]={id:K==null?void 0:K.id,body:l}}}D(o=>({...o,...a})),B(null),I("התבנית נשמרה")}catch{I("שמירת התבנית נכשלה — נסו שוב")}finally{L(!1)}}},[w,$,n,t,I]);return e.jsxs("div",{dir:"rtl",className:"flex flex-col gap-5",children:[e.jsx("div",{className:"flex",children:e.jsx(et,{title:`התראות · ${g||r}`,items:[{label:"חזרה ללוח ההתראות",icon:Re,iconBg:"bg-blue-50",iconColor:"text-blue-600",onClick:()=>d(`${c}/alerts`)},{label:`מעבר למודול ${g||""}`.trim(),icon:Be,iconBg:"bg-slate-50",iconColor:"text-slate-600",onClick:()=>d(`${c}${f.path||`/${r}`}`)}]})}),e.jsx("div",{className:"grid grid-cols-2 gap-3",children:[{key:"pending",label:"דורש טיפול",de
1sc:"פריטים הממתינים לטיפול",Icon:at,value:(j==null?void 0:j.count)||0,warn:((j==null?void 0:j.count)||0)>0},{key:"notifications",label:"ניהול התראות",desc:"הפעלה ועריכת נוסחי ההתראות",Icon:k,value:T.total,warn:!1}].map(s=>{const a=E===s.key;return e.jsxs("button",{type:"button",onClick:()=>V(s.key),className:`card-float text-right px-4 py-4 flex items-center gap-3 transition-all ${a?"ring-2 ring-primary/40 border-primary/30":"hover:shadow-md hover:-translate-y-0.5"}`,children:[e.jsx("span",{className:`w-12 h-12 rounded-xl grid place-items-center flex-none ${a?"bg-primary/10 text-primary":"bg-slate-100 text-slate-500"}`,children:e.jsx(s.Icon,{className:"w-6 h-6"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[15px] font-extrabold text-slate-800",children:s.label}),e.jsx("span",{className:`text-xl font-extrabold tabular-nums leading-none ${s.warn?"text-amber-600":"text-slate-800"}`,children:s.value})]}),e.jsx("div",{className:"text-xs text-slate-500 mt-0.5 truncate",children:s.desc})]})]},s.key)})}),e.jsxs("div",{dir:"rtl",children:[E==="pending"&&(v?e.jsx("div",{className:"flex items-center justify-center h-40",children:e.jsx("div",{className:"w-8 h-8 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})}):e.jsx("div",{className:"card-float p-6",children:j&&j.count>0?e.jsxs("div",{className:"flex flex-col items-start gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"w-12 h-12 rounded-xl bg-amber-100 text-amber-600 grid place-items-center flex-none",children:e.jsx(Le,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-extrabold text-amber-600 tabular-nums leading-none",children:j.count}),e.jsx("div",{className:"text-sm text-slate-600 mt-1",children:j.unit||"פריטים ממתינים לטיפול"})]})]}),e.jsxs("button",{type:"button",onClick:()=>d(j.to),className:"inline-flex items-center gap-1.5 text-sm font-bold text-white bg-primary hover:bg-primary/90 rounded-lg px-4 py-2",children:["עבור לטיפול ",e.jsx(lt,{className:"w-4 h-4"})]})]}):e.jsxs("div",{className:"flex flex-col items-center text-center py-6 text-slate-400",children:[e.jsx(ze,{className:"w-9 h-9 text-emerald-400 mb-2"}),e.jsx("div",{className:"text-[15px] font-bold text-slate-600",children:"אין פריטים הממתינים לטיפול"}),e.jsx("div",{className:"text-[13px] mt-1",children:"כשיגיעו פריטים חדשים במודול זה — הם יופיעו כאן."})]})})),E==="notifications"&&(y?e.jsxs("div",{className:"flex flex-col gap-4",children:[ge.map(({role:s,items:a})=>{const o=it[s]||ie;return e.jsxs("div",{className:"card-float overflow-hidden p-0",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 bg-slate-50 border-b border-slate-100",children:[e.jsx("span",{className:`w-9 h-9 rounded-full grid place-items-center flex-none ${ct[s]}`,children:e.jsx(o,{className:"w-[18px] h-[18px]"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[15px] font-extrabold text-slate-800",children:Z[s].label}),e.jsx("div",{className:"text-xs text-slate-500",children:Z[s].desc})]}),e.jsxs("span",{className:"ms-auto text-xs font-bold text-slate-400",children:[a.length," התראות"]})]}),e.jsx("div",{className:"p-2.5 flex flex-col gap-2 bg-slate-50/40",children:a.map(l=>e.jsx(mt,{item:l,enabled:Ne(l),busy:P===U(n,l.key),onToggle:we,onEdit:ve,onChannelHover:je,onChannelLeave:ye},l.key))})]},s)}),e.jsx("p",{className:"text-[12px] text-slate-400 px-1",children:"תגית «בתוקף» מסמנת התראות שכבר קוראות את ההגדרות והנוסחים בזמן אמת. השאר יישמרו וייכנסו לתוקף עם המשך החיווט."})]}):e.jsxs("div",{className:"card-float p-8 flex flex-col items-center text-center text-slate-400",children:[e.jsx(Q,{className:"w-9 h-9 opacity-50 mb-2"}),e.jsx("div",{className:"text-[15px] font-bold text-slate-600",children:"אין התראות מוגדרות במודול זה"}),e.jsxs("div",{className:"text-[13px] mt-1",children:["כרגע אין טריגרים של התראות ב«",g||r,"». אפשר להוסיף בהמשך."]})]}))]}),w&&e.jsx(pt,{moduleKey:n,communityId:t,canSendTest:b,situation:w,initial:ke,saving:H,images:z,communityName:A,onClose:()=>B(null),onSave:Ce}),ee&&e.jsx(ue,{...ee,communityName:A,images:z}),p&&e.jsx("div",{className:"fixed bottom-6 start-1/2 translate-x-1/2 z-[70] bg-slate-800 text-white text-sm font-bold px-5 py-2.5 rounded-xl shadow-lg",children:p})]})}export{Gt 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.