1import{ac as $,d7 as H,r,d as w,z as m,j as e,b as T,w as K,L as O,c5 as G,bG as Q,aF as M,ap as X,af as Z,T as q,P as B,F as J,a9 as V,Q as W,Z as Y,aC as ee}from"./index-BH8Hq4fF.js";import{S as se}from"./SitePageShell-BgpTtAUN.js";import{R as te}from"./ResidentLoginRedirect-BQvN2YCV.js";import{F as P}from"./FormColumnCard-CRl3dGTi.js";import{F as ae}from"./folder-open-CWzvkunn.js";import{F as R}from"./folder-B0NEXoPZ.js";import{E as le}from"./eye-off-B4MzD2pP.js";import{P as re}from"./pencil-DlA_FTEn.js";import{U as ie}from"./upload-DtbdHLAK.js";import{I as A}from"./image-DgoP-ctX.js";import"./usePaymentPlacements-TNXseU1e.js";import"./siteLogoPanel-FM6PxkL_.js";import"./user-cog-BikfPThJ.js";import"./bell-ring-Db0rTCDW.js";import"./life-buoy-7W458jwF.js";import"./log-in-Ci9k4xKf.js";import"./kibbutzSiteUtils-BetuJpui.js";import"./info-CMJoL0mv.js";import"./graduation-cap-DnGVwVvF.js";import"./file-check-BSDzA9vo.js";import"./instagram-BHE3hi9u.js";import"./sliders-horizontal-D7cGhbbA.js";import"./youtube-CpfQxPon.js";import"./leaf-DJuap4o0.js";import"./paymentCatalogs-CvImawYM.js";import"./chevron-left-DaNP-hnR.js";import"./siren-DUj7NgPZ.js";import"./clipboard-check-BKoevPr7.js";import"./personalHeading-DPM7lbxX.js";import"./ContentPageHero-CiDpAGe7.js";const N="#16a34a";function Ae(){const{kibbutzId:o}=$(),h=H(o),_=h==null?void 0:h.phone,[t,v]=r.useState(!0),[p,y]=r.useState([]),[k,f]=r.useState([]),[L,F]=r.useState(!1),[g,j]=r.useState(null),[b,x]=r.useState(null),[C,u]=r.useState(null),U=r.useCallback(async()=>{var s,c,i;if(!_){v(!1);return}v(!0);try{const n=await w.functions.invoke("residentManagedUpdates",{community_id:o,action:"list"});y(((s=n==null?void 0:n.data)==null?void 0:s.categories)||[]),f(((c=n==null?void 0:n.data)==null?void 0:c.updates)||[]),F(!!((i=n==null?void 0:n.data)!=null&&i.all_scopes))}catch{m.error("ש×××× ×××¢×× ×ª ××¢×××× ××")}v(!1)},[o,_]);r.useEffect(()=>{U()},[U]);const d=r.useMemo(()=>g?k.filter(s=>s.category_id===g):k,[k,g]),E=s=>{var c;return((c=p.find(i=>i.id===s))==null?void 0:c.title)||"××××"};r.useEffect(()=>{if(d.length===0){b!==null&&x(null);return}d.some(s=>s.id===b)||x(d[0].id)},[d,b]);const l=d.find(s=>s.id===b)||null,I=async s=>{const c=s.status==="published"?"draft":"published";try{await w.functions.invoke("residentManagedUpdates",{community_id:o,action:"set_status",update_id:s.id,status:c}),f(i=>i.map(n=>n.id===s.id?{...n,status:c}:n)),m.success(c==="published"?"פ×רס×":"×××¢×ר ××××××")}catch{m.error("ש××××")}},S=async s=>{if(confirm("××ס×ר ×ת ××¢××××?"))try{await w.functions.invoke("residentManagedUpdates",{community_id:o,action:"delete",update_id:s}),f(c=>c.filter(i=>i.id!==s)),m.success("××¢×××× ××סר")}catch{m.error("ש×××× ××סר×")}};return e.jsx(se,{kibbutzId:o,moduleKey:"resident_registration",showHero:!1,hidePageTitleHeader:!0,hideFooter:!0,pageTitle:"× ×××× ××××¢×ת ××¢×××× ××",pageAction:e.jsxs("button",{onClick:()=>u("new"),className:"inline-flex items-center gap-2 h-11 px-5 rounded-xl text-white font-semibold shadow-sm",style:{backgroundColor:N},children:[e.jsx(B,{className:"w-4 h-4"})," ×¢×××× ××ש"]}),mainClassName:"flex-1 w-full pt-24 md:pt-28 pb-12",children:()=>h?t?e.jsx("div",{className:"flex justify-center py-24",children:e.jsx(T,{className:"w-8 h-8 animate-spin text-slate-400"})}):!p.length&&!L?e.jsxs("div",{className:"max-w-md mx-auto px-4 py-20 text-center",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-slate-100 flex items-center justify-center mx-auto mb-4",children:e.jsx(K,{className:"w-8 h-8 text-slate-400"})}),e.jsx("p",{className:"text-slate-600 font-semibold mb-1",children:"×× ××××רת ×××ר×× ×¢× ×§×××ר××ת ×¢×××× ××"}),e.jsx("p",{className:"text-sm text-slate-400",children:"××שר ×× ×× ××§×××× ××××ר ×××ª× ×××ר×× ×¢× ×§×××ר××ת ××××¢×ת ××¢×××× ××, ××× ×ª×פ××¢ ×××."}),e.jsxs(O,{to:Q(`/kibbutz-site/${o}/personal`),className:"inline-flex items-center gap-1 mt-6 text-sm font-medium",style:{color:N},children:[e.jsx(G,{className:"w-4 h-4"})," ×××¨× ××××ר ×××ש×"]})]}):C?e.jsx(ne,{kibbutzId:o,categories:p,allScopes:L,editing:C==="new"?null:C,onClose:()=>u(null),onSaved:()=>{u(null),U()}}):e.jsxs("div",{className:"max-w-5xl mx-auto w-full px-4",dir:"rtl",children:[p.length>0&&e.jsxs("div",{className:"mb-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(ae,{className:"w-4 h-4",style:{color:N}}),e.jsx("h2",{className:"text-sm font-semibold text-slate-700",children:"×§×××ר××ת"}),g&&e.jsx("button",{onClick:()=>j(null),className:"text-xs mr-2 hover:underline",style:{color:N},children:"××¦× ×××"})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-5 ga
1p-3",children:p.map(s=>{const c=k.filter(n=>n.category_id===s.id).length,i=g===s.id;return e.jsxs("button",{onClick:()=>j(i?null:s.id),className:`card-float p-3 text-right transition-all ${i?"ring-2 ring-green-400":"hover:shadow-md"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-8 h-8 rounded-lg bg-green-50 flex items-center justify-center flex-shrink-0",children:e.jsx(R,{className:"w-4 h-4 text-green-600"})}),e.jsx("p",{className:"text-sm font-medium text-slate-800 line-clamp-1",children:s.title})]}),e.jsxs("p",{className:"text-xs text-slate-400 mt-1",children:[c," ×¢×××× ××"]})]},s.id)})})]}),d.length===0?e.jsxs("div",{className:"card-float p-12 text-center",children:[e.jsx(M,{className:"w-9 h-9 text-slate-300 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-slate-500",children:'××× ×¢×××× ×× ××§×××ר×× ××. ×××¦× ×¢× "×¢×××× ××ש" ××× ×××ס××£.'})]}):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[minmax(0,360px)_1fr] gap-4 items-start",children:[e.jsx("div",{className:"card-float p-2",children:e.jsx("div",{className:"lg:max-h-[68vh] overflow-y-auto space-y-1",children:d.map(s=>{const c=s.id===b,i=s.status==="published";return e.jsxs("div",{onClick:()=>x(s.id),className:`flex items-center gap-2.5 p-2.5 rounded-xl cursor-pointer transition-all ${c?"bg-green-50 ring-2 ring-green-200":"hover:bg-slate-50"}`,children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-green-50 flex items-center justify-center flex-shrink-0 overflow-hidden",children:s.image_url?e.jsx("img",{src:s.image_url,alt:"",className:"w-full h-full object-cover"}):e.jsx(M,{className:"w-4 h-4 text-green-600"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium text-slate-800 line-clamp-1",children:s.title}),e.jsxs("span",{className:"inline-flex items-center gap-1 mt-1 px-1.5 py-0.5 rounded-full bg-green-50 text-green-700 text-[0.6875rem] font-medium max-w-[140px]",children:[e.jsx(R,{className:"w-2.5 h-2.5 flex-shrink-0"}),e.jsx("span",{className:"truncate",children:E(s.category_id)})]})]}),e.jsx("span",{className:`text-[0.6875rem] font-medium px-2 py-0.5 rounded-full flex-shrink-0 ${i?"bg-emerald-50 text-emerald-600":"bg-slate-100 text-slate-400"}`,children:i?"×פ×רס×":"×××××"})]},s.id)})})}),e.jsx("div",{className:"card-float p-5 lg:sticky lg:top-4",children:l?e.jsxs("div",{className:"space-y-5",children:[l.image_url&&e.jsx("div",{className:"rounded-xl overflow-hidden bg-slate-100 aspect-video",children:e.jsx("img",{src:l.image_url,alt:"",className:"w-full h-full object-cover"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-slate-900 break-words",children:l.title}),l.summary&&e.jsx("p",{className:"text-sm text-slate-500 mt-1 leading-relaxed",children:l.summary})]}),l.content&&e.jsx("p",{className:"text-sm text-slate-700 whitespace-pre-line leading-relaxed",children:l.content}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{className:"rounded-xl bg-slate-50 p-3",children:[e.jsxs("p",{className:"text-xs text-slate-400 mb-0.5 flex items-center gap-1",children:[e.jsx(R,{className:"w-3 h-3"})," ×§×××ר××"]}),e.jsx("p",{className:"text-sm font-medium text-slate-800 line-clamp-1",children:E(l.category_id)})]}),e.jsxs("div",{className:"rounded-xl bg-slate-50 p-3",children:[e.jsxs("p",{className:"text-xs text-slate-400 mb-0.5 flex items-center gap-1",children:[e.jsx(X,{className:"w-3 h-3"})," ת×ר××"]}),e.jsx("p",{className:"text-sm font-medium text-slate-800",children:l.publish_date?new Date(l.publish_date).toLocaleDateString("he-IL"):l.created_date?new Date(l.created_date).toLocaleDateString("he-IL"):"â"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-3 border-t border-slate-100",children:[e.jsx("button",{onClick:()=>I(l),className:"inline-flex items-center gap-1.5 h-10 px-4 rounded-xl text-white text-sm font-medium",style:{backgroundColor:l.status==="published"?"#64748b":N},children:l.status==="published"?e.jsxs(e.Fragment,{children:[e.jsx(le,{className:"w-4 h-4"})," ××¢×ר ××××××"]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"w-4 h-4"})," פרס××"]})}),e.jsxs("button",{onClick:()=>
1u(l),className:"inline-flex items-center gap-1.5 h-10 px-4 rounded-xl border border-slate-200 text-sm font-medium text-slate-600 hover:bg-slate-100",children:[e.jsx(re,{className:"w-4 h-4"})," ער×××"]}),e.jsxs("button",{onClick:()=>S(l.id),className:"inline-flex items-center gap-1.5 h-10 px-4 rounded-xl border border-red-200 text-sm font-medium text-red-600 hover:bg-red-50",children:[e.jsx(q,{className:"w-4 h-4"})," ××××§×"]})]})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 text-center text-slate-400",children:[e.jsx(M,{className:"w-10 h-10 text-slate-300 mb-3"}),e.jsx("p",{className:"text-sm",children:"×××¨× ×¢×××× ××רש××× ××× ×צפ×ת ×פר×××"})]})})]})]}):e.jsx(te,{kibbutzId:o})})}function ne({kibbutzId:o,categories:h,allScopes:_,editing:t,onClose:v,onSaved:p}){var n;const[y,k]=r.useState((t==null?void 0:t.title)||""),[f,L]=r.useState((t==null?void 0:t.summary)||""),[F,g]=r.useState((t==null?void 0:t.content)||""),[j,b]=r.useState((t==null?void 0:t.category_id)||((n=h[0])==null?void 0:n.id)||""),[x,C]=r.useState((t==null?void 0:t.image_url)||""),[u,U]=r.useState(t?t.status==="published":!0),[d,E]=r.useState(!1),[l,I]=r.useState(!1),S=!!t,s=async a=>{const z=(a.target.files||[])[0];if(z){E(!0);try{const{file_url:D}=await w.integrations.Core.UploadFile({file:z});C(D)}catch{m.error("ש×××× ×××¢××ת ×ת××× ×")}E(!1),a.target.value=""}},c=async()=>{if(!y.trim()){m.error("×ש ××××× ××תרת");return}if(!_&&!j){m.error("×ש ××××ר ×§×××ר××");return}I(!0);try{if(S){await w.functions.invoke("residentManagedUpdates",{community_id:o,action:"update",update_id:t.id,title:y.trim(),summary:f.trim(),content:F.trim(),category_id:j||null,image_url:x||""});const a=u?"published":"draft";a!==t.status&&await w.functions.invoke("residentManagedUpdates",{community_id:o,action:"set_status",update_id:t.id,status:a})}else await w.functions.invoke("residentManagedUpdates",{community_id:o,action:"create",title:y.trim(),summary:f.trim(),content:F.trim(),category_id:j||void 0,image_url:x||void 0,status:u?"published":"draft"});m.success(S?"××¢×××× × ×©×ר":"××¢×××× × ×סף"),p()}catch(a){m.error((a==null?void 0:a.message)||"ש×××× ×ש××ר×")}I(!1)},i="w-full h-10 rounded-xl border border-slate-200 bg-slate-50 px-3 text-sm focus:outline-none focus:ring-2 focus:ring-green-100 focus:bg-white";return e.jsxs("div",{className:"max-w-6xl mx-auto w-full px-4",dir:"rtl",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-5 flex-wrap",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"w-11 h-11 rounded-2xl flex items-center justify-center text-white",style:{backgroundColor:N},children:e.jsx(M,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-extrabold text-slate-900",children:S?"ער××ת ×¢××××":"×¢×××× ××ש"}),e.jsx("p",{className:"text-sm text-slate-500",children:"×××× ×ת פר×× ××¢×××× ×פרס×× ×צ×××ר ××§×××ר×× ×©×××××¨×ª× ×¢×××."})]})]}),e.jsxs("button",{onClick:v,className:"inline-flex items-center gap-1.5 h-10 px-4 rounded-xl border border-slate-200 bg-white text-sm font-medium text-slate-600 hover:bg-slate-50",children:[e.jsx(J,{className:"w-4 h-4"})," ×××¨× ×רש×××"]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4 items-start",children:[e.jsxs(P,{icon:V,title:"פר×× ××¢××××",tone:"emerald",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"××תרת *"}),e.jsx("input",{value:y,onChange:a=>k(a.target.value),className:i,placeholder:"××תרת ××¢××××"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"תקצ×ר (רש×ת)"}),e.jsx("input",{value:f,onChange:a=>L(a.target.value),className:i,placeholder:"תקצ×ר קצר ×תצ××× ×רש×××"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"ת×××"}),e.jsx("textarea",{value:F,onChange:a=>
1g(a.target.value),rows:7,className:"w-full rounded-xl border border-slate-200 bg-slate-50 px-3 py-2 text-sm resize-none focus:outline-none focus:ring-2 focus:ring-green-100 focus:bg-white",placeholder:"ת××× ××¢××××"})]})]}),e.jsxs(P,{icon:W,title:"×§×××ר×× ×פרס××",tone:"emerald",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"×§×××ר××"}),e.jsxs("select",{value:j,onChange:a=>b(a.target.value),className:i,children:[_&&e.jsx("option",{value:"",children:"××× ×§×××ר××"}),h.map(a=>e.jsx("option",{value:a.id,children:a.title},a.id))]})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none rounded-xl border border-slate-200 bg-slate-50 px-3 py-2.5",children:[e.jsx("input",{type:"checkbox",checked:u,onChange:a=>U(a.target.checked),className:"w-4 h-4 rounded accent-green-600"}),e.jsxs("span",{className:"text-sm font-medium text-slate-700 flex items-center gap-1.5",children:[e.jsx(ie,{className:"w-3.5 h-3.5"})," פרס×× ××××× ×צ×××ר"]})]}),e.jsx("p",{className:"text-xs text-slate-400",children:"×ש××× ×¡×××× â ××¢×××× ××ש×ר ×××××× ××× ×××¦× ×צ×××ר ×¢× ×פרס××."})]}),e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(P,{icon:A,title:"××××",tone
1:"emerald",children:e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold text-slate-500 mb-1",children:"ת××× × ×¨×ש×ת (רש×ת)"}),x?e.jsxs("div",{className:"relative rounded-xl overflow-hidden bg-slate-100 aspect-video",children:[e.jsx("img",{src:x,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{onClick:()=>C(""),className:"absolute top-2 left-2 w-8 h-8 rounded-lg bg-white/90 flex items-center justify-center text-red-500 hover:bg-white",children:e.jsx(Y,{className:"w-4 h-4"})})]}):e.jsxs("label",{className:"flex items-center justify-center gap-2 h-24 rounded-xl border-2 border-dashed border-slate-300 cursor-pointer hover:bg-slate-50 text-slate-500",children:[d?e.jsx(T,{className:"w-5 h-5 animate-spin"}):e.jsxs(e.Fragment,{children:[e.jsx(A,{className:"w-5 h-5"}),e.jsx("span",{className:"text-sm",children:"×××¨× ×ª××× ×"})]}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:s})]})]})}),e.jsxs("div",{className:"flex items-center gap-2 pb-6",children:[e.jsx("button",{onClick:v,className:"inline-flex items-center gap-2 h-11 px-6 rounded-full bg-white border border-slate-200 text-sm font-medium text-slate-600 hover:bg-slate-50",children:"×××××"}),e.jsxs("button",{onClick:c,disabled:l||d,className:"flex-1 inline-flex items-center justify-center gap-2 h-11 px-6 rounded-full text-white text-sm font-bold disabled:opacity-60 shadow-sm",style:{backgroundColor:N},children:[l?e.jsx(T,{className:"w-4 h-4 animate-spin"}):e.jsx(ee,{className:"w-4 h-4"})," ",S?"ש××רת ×¢××××":"××ספת ×¢××××"]})]})]})]})]})}export{Ae 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.