PageSourceSearch

https://tsofit.org.il/assets/DigitalScreensModule-CQZf2rDf.js

js tsofit.org.il collected 2026-10-02 14:24:09 UTC 185,065 bytes, 22 lines download raw bytes

1import{r as p,d as I,j as e,m as cr,n as xr,o as mr,p as ur,b as de,aQ as xe,aC as _e,P as se,z as y,aN as hr,B as R,F as br,a0 as pr,T as re,aq as gr,Z as le,au as fr,R as _r,a9 as ge,a1 as ot,bA as jr,cQ as vr,bD as yr,bt as Nr,cP as wr,a7 as kr,aH as Ra,a6 as Cr,_ as Sr,a4 as $r,ac as Dr,t as Tr,c5 as Ir,af as Pe,ag as it,cd as ie,at as Pr,am as Xe}from"./index-BH8Hq4fF.js";import{K as Mr}from"./KibbutzModuleGuard-BrSTzYkw.js";import{P as Be}from"./PageTitleMenu-CMXtRh6s.js";import{S as ae}from"./switch-Sj01sJJm.js";import{T as ce}from"./textarea-C9Nd53i2.js";import{S as Ar}from"./StepCards-BAMOaQ3M.js";import{P as Sa}from"./personalModules-YCfJZw3V.js";import{e as Er,r as Fr,B as zr,f as $a,g as qa,j as Je,k as dt,F as ct,l as Or,o as Ae,P as Br,q as Lr,s as Rr,v as qr,x as Da,y as Ur,E as Hr}from"./DigitalScreenDisplay-BMm9XpUo.js";import{p as Ta,c as Ia,n as Wr,b as Kr,z as Vr,S as Zr,C as Pa}from"./ContentLibrary-R2BFjW6W.js";import{M as Yr,u as Gr,S as Qr}from"./MultiScreensManagePage-Dx8GVLJV.js";import{S as Xr,B as Ma}from"./ScreenAdminBar-CXIuj-vq.js";import{b as Ve,s as Ze}from"./screenNav-C4Bp1Q9_.js";import{I as be}from"./input-RnZK1Sdh.js";import{W as Ee}from"./wand-sparkles-Cm5ailV1.js";import{C as ke}from"./copy-B_0EPT7Q.js";import{S as Jr}from"./settings-2-CQkCCTmF.js";import{U as fe}from"./upload-DtbdHLAK.js";import{P as xt}from"./palette-CIgIe0F7.js";import{S as Ua}from"./sparkles-DYMjDKmN.js";import{Q as Ha}from"./qr-code-BqoQD06H.js";import{F as et}from"./film-MuXUePXC.js";import{I as el}from"./image-plus-CFXC8_i6.js";import{I as we}from"./image-DgoP-ctX.js";import{H as tl}from"./underline-DPSayhxm.js";import{T as Ce}from"./type-BhjkmruF.js";import{C as sl}from"./circle-user-ClbNby5r.js";import{C as al}from"./cloud-sun-BKXKjNTq.js";import{G as rl}from"./grip-vertical-Bettc5f-.js";import{i as pe,F as Fe}from"./multiScreenTemplates-DfGAej47.js";import{S as tt}from"./siren-DUj7NgPZ.js";import{P as Wa}from"./play-BtMz3qTH.js";import{C as ll}from"./chevron-left-DaNP-hnR.js";import{P as Aa}from"./pencil-DlA_FTEn.js";import{K as Ka}from"./key-round-Dv0zu1qv.js";import{R as st}from"./refresh-cw-kjmzcQOe.js";import{M as nl}from"./monitor-CiE77CYT.js";import{W as ol}from"./wifi-DKAntBE4.js";import{W as il}from"./wifi-off-BbKvDvYl.js";import{P as dl}from"./power-D8qmgbb_.js";import{M as cl}from"./monitor-smartphone-B0AcigcY.js";import{A as at}from"./arrow-down-VEWBquYE.js";import"./useActionVisibility-oACH4aDh.js";import"./index-CikwpBsl.js";import"./user-pen-CzOic8sF.js";import"./headphones-U9mAMmky.js";import"./life-buoy-7W458jwF.js";import"./money-CmD9E_V-.js";import"./activity-CKfqAMQL.js";import"./interestUtils-TL6jK4tG.js";import"./tree-pine-C5mfzpOE.js";import"./music-DKTtf7a1.js";import"./leaf-DJuap4o0.js";import"./pill-CexHQAtm.js";import"./dumbbell-B6wytY5J.js";import"./baby-Cs7Gtrey.js";import"./graduation-cap-DnGVwVvF.js";import"./index-BLShlj8Y.js";import"./pdfThumbnail--4I8gdgE.js";import"./screenCanvas-DJaKKblp.js";import"./utensils-D_WButlT.js";import"./scan-line-Cxekt9RD.js";import"./digitalScreenContentTypes-IW5RLDAF.js";import"./youtube-CpfQxPon.js";import"./dnd.esm-CJAQYfEx.js";import"./tiny-invariant-BaFNuDhB.js";import"./align-right-BOvZo__j.js";import"./align-left-DTBFU8py.js";import"./maximize-2-CeboQku1.js";import"./whatsappImageCompression-Ba_dR_4a.js";import"./share-2-ZtXnrJsu.js";import"./list-CK7wCjhy.js";import"./save-B5tADMHo.js";import"./ConfirmDialog-5ehqONc0.js";import"./alert-dialog-CKlZlXSt.js";import"./MultiScreenPreview-hm8JBiZP.js";import"./screenDesign-Ds5LX-Oz.js";import"./sunset-Bz6banos.js";import"./multiTopBar-7LsXqSUe.js";import"./radio-CK2vqaOF.js";import"./MultiTopBar-B3UhEh-w.js";import"./WallFrame-4wB8qNP5.js";import"./prScreen-gbnSiWLv.js";import"./PrScreenPlayer-SI1h4uPS.js";function xl({kibbutzId:l,channelId:r,item:o,design:i}){const[f,c]=p.useState(null),[u,S]=p.useState(null),[_,g]=p.useState("idle"),[h,m]=p.useState(()=>new Date),[k,b]=p.useState(null),[N,O]=p.useState(0),C=p.useRef(null),F=p.useMemo(()=>{try{return JSON.stringify(o)}catch{return""}},[o]);p.useEffect(()=>{const P=setInterval(()=>m(new Date),1e3);return()=>clearInterval(P)},[]),p.useEffect(()=>{const P=C.current;if(!P||typeof ResizeObserver>"u")return;const D=()=>O(P.clientWidth/1920);D();const E=new ResizeObserver(D);return E.observe(P),()=>E.disconnect()},[]),p.useEffect(()=>{if(!r||!l||!(o!=null&&o.type)){c(null),g("idle");return}let P=!1;g("loading");const D=setTimeout(async()=>{try{const E=await I.functions.invoke("digitalScreenPlaylist",{community_id:l,channel_id:r,preview:!0,preview_item:o});if(P)return;const T=(E==null?void 0:E.data)||{};
1S(T.design||null),c(T.slides&&T.slides[0]||null),g("ready")}catch{P||(g("error"),c(null))}},450);return()=>{P=!0,clearTimeout(D)}},[F,r,l,o]);const $=p.useMemo(()=>({...u||{},...i||{}}),[u,i]),B=$.primary_color||"#2563eb",U=$.secondary_color||"#06b6d4";p.useEffect(()=>{if($.show_weather===!1||$.lat==null||$.lng==null){b(null);return}let P=!1;return(async()=>{try{const E=await(await fetch(`https://api.open-meteo.com/v1/forecast?latitude=${$.lat}&longitude=${$.lng}&current=temperature_2m,weather_code,wind_speed_10m,wind_direction_10m`)).json();!P&&(E!=null&&E.current)&&b({temp:Math.round(E.current.temperature_2m),code:E.current.weather_code,windSpeed:Math.round(E.current.wind_speed_10m),windDir:E.current.wind_direction_10m})}catch{}})(),()=>{P=!0}},[$.lat,$.lng,$.show_weather]);const j=f&&Er.includes(f.kind);return e.jsxs("div",{className:"rounded-2xl border border-slate-200 bg-slate-50/70 p-3",dir:"rtl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[e.jsx("span",{className:"text-xs font-bold text-slate-500",children:"תצוגה מקדימה של המסך"}),_==="loading"&&e.jsx("span",{className:"text-[0.6875rem] text-slate-400",children:"מעדכן…"})]}),e.jsx("div",{ref:C,className:"relative w-full rounded-xl overflow-hidden bg-black shadow-inner",style:{aspectRatio:"16 / 9"},children:N>0&&f?e.jsx("div",{style:{position:"absolute",top:0,right:0,width:"1920px",height:"1080px",transform:`scale(${N})`,transformOrigin:"top right"},children:e.jsxs("div",{dir:"rtl",className:"relative w-full h-full bg-black text-white overflow-hidden",children:[e.jsx("div",{className:"absolute inset-0",children:Fr({slide:f,design:$,now:h,weather:k,primary:B,secondary:U,kibbutzId:l})}),!j&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"absolute top-0 inset-x-0 z-10",children:e.jsx(zr,{design:$,now:h,weather:k,primary:B,secondary:U})}),$.ticker_text&&e.jsx("div",{className:"absolute bottom-0 inset-x-0 z-10 bg-black/60 overflow-hidden whitespace-nowrap py-1.5",children:e.jsx("div",{className:"inline-block ds-ticker text-lg font-medium px-4",children:$.ticker_text})})]})]})}):e.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-white/60 text-sm",children:_==="error"?"התצוגה המקדימה אינה זמינה כרגע":"טוען תצוגה מקדימה…"})}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400 mt-2 px-1",children:"התצוגה משקפת את הבחירות הנוכחיות עם נתונים אמיתיים מהקהילה."}),e.jsx("style",{children:`
2        @keyframes dsTicker { from { transform: translateX(-100%); } to { transform: translateX(100vw); } }
3        .ds-ticker { animation: dsTicker 22s linear infinite; }
4        @keyframes dsTitleLine { from { transform: scaleX(0); opacity: 0; } to { transform: scaleX(1); opacity: 1; } }
5        .ds-title-line { transform-origin: right center; animation: dsTitleLine 0.9s cubic-bezier(.22,1,.36,1) 0.15s both; }
6        @keyframes dsTitleH { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }
7        .ds-title-h { animation: dsTitleH 0.7s cubic-bezier(.22,1,.36,1) both; }
8        .ds-title-kicker { animation: dsTitleH 0.7s cubic-bezier(.22,1,.36,1) both; }
9        @keyframes dsMarquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }
10        .ds-marquee { animation: dsMarquee linear infinite; }
11        @keyframes dsCaret { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }
12        .ds-caret { display: inline-block; margin-inline-start: 3px; font-weight: 400; animation: dsCaret 0.85s step-end infinite; }
13        @keyframes dsTick { to { transform: rotate(360deg); } }
14        .ds-clock-sec { transform-origin: 50px 50px; animation: dsTick 60s steps(60) infinite; }
15        .ds-clock-min { transform-origin: 50px 50px; animation: dsTick 3600s linear infinite; }
16        @keyframes dsPulseOpen { 0%,100% { box-shadow: 0 0 0 0 rgba(21,128,61,0.35); } 70% { box-shadow: 0 0 0 16px rgba(21,128,61,0); } }
17        .ds-pulse-open { animation: dsPulseOpen 2.1s ease-out infinite; }
18        @keyframes dsFloatIn { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
19        .ds-float-in { animation: dsFloatIn 0.8s cubic-bezier(.22,1,.36,1) both; }
20        @keyframes dsKen { 0% { transform: scale(1) translate(0,0); } 100% { transform: scale(1.12) translate(-1.5%, -1.5%); } }
21        .ds-ken { animation: dsKen 12s ease-out both; }
22      `})]})}const Ea="__new__";function Fa({kibbutzId:l,content:r,onClose:o,onPlaced:i}){const[f,c]=p.useState(null),[u,S]=p.useState(null);p.useEffect(()=>{let h=!1;return I.entities.MultiDigitalScreen.filter({kibbutz_id:l}
22,"-updated_date",100).then(m=>{h||c(m||[])}).catch(()=>{h||c([])}),()=>{h=!0}},[l]);async function _(h){S(h.id);try{const[m,k]=await Promise.all([I.entities.MultiScreenZone.filter({screen_id:h.id,kibbutz_id:l},"display_order",200),I.entities.MultiScreenItem.filter({screen_id:h.id,kibbutz_id:l},"display_order",500)]),b=Ta(m);if(!b){y.error("למסך הזה עדיין אין פריסה — פתחו אותו ובחרו פריסה תחילה");return}await I.entities.MultiScreenItem.create(Ia({communityId:l,screenId:h.id,zoneId:b.id,content:r,order:Wr(k,b.id)})),y.success(`«${r.title||"התוכן"}» נוסף למסך «${h.name||"ללא שם"}»`),o==null||o(),i==null||i({screenId:h.id,created:!1})}catch{y.error("שגיאה בהוספה למסך")}finally{S(null)}}async function g(){S(Ea);try{const h=await I.entities.MultiDigitalScreen.create(Kr({communityId:l,content:r})),m=Vr(Zr,{communityId:l,screenId:h.id}),k=[];for(const N of m)k.push(await I.entities.MultiScreenZone.create(N));const b=Ta(k);await I.entities.MultiScreenItem.create(Ia({communityId:l,screenId:h.id,zoneId:b==null?void 0:b.id,content:r,order:0})),y.success(`המסך «${h.name}» נוצר ופעיל`),o==null||o(),i==null||i({screenId:h.id,created:!0})}catch{y.error("שגיאה ביצירת המסך")}finally{S(null)}}return e.jsx(cr,{open:!0,onOpenChange:h=>{h||o==null||o()},children:e.jsxs(xr,{className:"max-w-lg",dir:"rtl",children:[e.jsx(mr,{children:e.jsxs(ur,{className:"text-right",children:["הצגת «",(r==null?void 0:r.title)||"התוכן","» על מסך"]})}),e.jsxs("div",{className:"space-y-3",children:[f===null?e.jsx("div",{className:"flex items-center justify-center py-8",children:e.jsx(de,{className:"w-6 h-6 text-slate-300 animate-spin"})}):f.length===0?e.jsx("p",{className:"text-sm text-slate-500 text-center py-4",children:"עדיין אין מסכים. צרו מסך חדש עם התוכן הזה."}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs font-bold text-slate-500",children:"הוספה למסך קיים"}),e.jsx("div",{className:"space-y-1.5 max-h-64 overflow-auto",children:f.map(h=>e.jsxs("button",{type:"button",disabled:!!u,onClick:()=>_(h),className:"w-full flex items-center gap-2.5 p-2.5 rounded-xl border border-slate-200 bg-white hover:border-indigo-400 hover:bg-indigo-50/40 text-right disabled:opacity-50",children:[e.jsx("span",{className:"w-9 h-9 rounded-lg bg-indigo-50 text-indigo-700 grid place-items-center flex-none",children:u===h.id?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(xe,{className:"w-4 h-4"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-sm font-bold text-slate-800 truncate",children:h.name||"ללא שם"}),e.jsx("span",{className:"block text-[0.6875rem] text-slate-400",children:h.status==="active"?"פעיל":"טיוטה"})]}),e.jsx(_e,{className:"w-4 h-4 text-slate-300 flex-none"})]},h.id))})]}),e.jsxs("button",{type:"button",onClick:g,disabled:!!u,className:"w-full h-11 rounded-xl border-2 border-dashed border-slate-300 text-sm font-bold text-slate-600 hover:border-indigo-400 hover:text-indigo-600 inline-flex items-center justify-center gap-1.5 disabled:opacity-50",children:[u===Ea?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(se,{className:"w-4 h-4"}),"מסך חדש עם התוכן הזה"]}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400 text-center",children:"ייווצר מסך פעיל שבו התוכן ממלא את כל המסך. אפשר לשנות פריסה ותזמון אחר כך."})]})]})})}const ml={Newspaper:$r,CalendarDays:Sr,Images:Cr,Clock:Ra,Store:kr,Cake:wr,FileText:ge,Heart:Nr,Flame:yr,Beer:vr,ShoppingBag:jr,CloudSun:al,UserCircle:sl,Type:Ce,Heading:tl,Image:we,ImagePlus:el,Film:et,QrCode:Ha,Sparkles:Ua,Palette:xt,LayoutGrid:ot},ze=({name:l,className:r})=>{const o=ml[l]||Ce;return e.jsx(o,{className:r})};function Va({layout:l,className:r=""}){return e.jsx("div",{className:`grid gap-1 ${r}`,style:{gridTemplateColumns:l.grid.columns,gridTemplateRows:l.grid.rows,gridTemplateAreas:l.grid.areas},dir:"rtl",children:l.regions.map((o,i)=>e.jsx("div",{style:{gridArea:o.id},className:"rounded bg-white/80 border border-blue-200 flex items-center justify-center text-[0.5625rem] font-bold text-blue-600",children:i+1},o.id))})}function ul({onPick:l}){const[r,o]=p.useState("");return e.jsxs("div",{dir:"rtl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("span",{className:"w-10 h-10 rounded-xl bg-indigo-50 flex items-center justify-center",children:e.jsx(hr,{className:"w-5 h-5 text-indigo-600"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold",children:"בחירת פריסה"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"בחרו כיצד לחלק את המסך. ניתן לשנות בהמשך."})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:qa.map(i=>{const f=r===i.key;return e.jsxs("button",{onClick:()=>o(i.key),className:`text-right rounded-2xl border p-3 transition-all ${f?"border-indigo-400 ring-2 ring-indigo-200 bg-indigo-50/50 shadow-sm":"border-border bg-white hover:border-indigo-200 hover:shadow-sm"}`,children:[e.jsx("div",{className:"aspect-video rounded-lg bg-slate-100 p-1.5 mb-2",children:e.jsx(Va,{layout:i,className:"w-full h-full"})}),e.jsx("p",{className:"text-sm font-bold text-slate-800",children:i.label}),e.jsx("p",{className:"text-[0.6875rem] text-muted-foreground leading-tight mt-0.5",children:i.hint}),e.jsxs("p",{className:"text-[0.6875rem] font-semibold text-indigo-600 mt-1",children:[i.regions.length," אזורים"]})]},i.key)})}),e.jsx("div",{className:"flex justify-end mt-5",children:e.jsxs(R,{disabled:!r,onClick:()=>l(r),className:"rounded-full bg-indigo-600 hover:bg-indigo-700 gap-1.5",children:["המשך להגדרת התוכן ",e.jsx(br,{className:"w-4 h-4"})]})})]})}const za={indigo:"bg-indigo-50 text-indigo-600",blue:"bg-blue-50 text-blue-600",emerald:"bg-emerald-50 text-emerald-600"},Ye=({icon:l,children:r,accent:o="indigo"})=>{const[i,f]=(za[o]||za.indigo).split(" ");return e.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[e.jsx("span",{className:`w-7 h-7 rounded-lg ${i} flex items-center justify-center`,children:e.jsx(l,{className:`w-4 h-4 ${f}`})}),e.jsx("h4",{className:"text-sm font-bold text-slate-700",children:r})]})};
22function hl({item:l,onChange:r}){const o=l.free_type,i=l.free||{},[f,c]=p.useState(!1),u=b=>r({...l,free:{...i,...b}}),S=async(b,N)=>{if(b){c(!0);try{const{file_url:O}=await I.integrations.Core.UploadFile({file:b});u({[N]:O})}catch{y.error("שגיאה בהעלאה")}finally{c(!1)}}},_=b=>{const N=String(b||"").match(/(?:v=|youtu\.be\/|embed\/)([\w-]{11})/);return N?N[1]:""},g=()=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"יישור"}),e.jsx("div",{className:"flex gap-1.5",children:[["right","ימין"],["center","מרכז"],["left","שמאל"]].map(([b,N])=>e.jsx("button",{onClick:()=>u({align:b}),className:`flex-1 h-9 rounded-lg text-xs font-medium border ${(i.align||"center")===b?"bg-indigo-600 text-white border-transparent":"bg-white border-border"}`,children:N},b))})]}),h=()=>e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"צבע טקסט"}),e.jsx("input",{type:"color",value:i.text_color||"#ffffff",onChange:b=>u({text_color:b.target.value}),className:"w-full h-9 rounded-lg border border-border"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"צבע רקע"}),e.jsx("input",{type:"color",value:i.bg_color||"#0f172a",onChange:b=>u({bg_color:b.target.value}),className:"w-full h-9 rounded-lg border border-border"})]})]}),m=()=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"גודל כותרת"}),e.jsx("div",{className:"flex gap-1.5",children:[["sm","קטן"],["md","בינוני"],["lg","גדול"],["xl","ענק"]].map(([b,N])=>e.jsx("button",{onClick:()=>u({title_size:b}),className:`flex-1 h-9 rounded-lg text-xs font-medium border ${(i.title_size||"lg")===b?"bg-indigo-600 text-white border-transparent":"bg-white border-border"}`,children:N},b))})]}),k=({label:b="תמונה"})=>e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:b}),i.image&&e.jsx("img",{src:i.image,alt:"",className:"w-full h-28 object-cover rounded-lg border border-border mb-2"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("label",{className:"inline-flex items-center gap-1.5 h-9 px-3 rounded-lg border border-slate-300 text-sm text-slate-600 cursor-pointer hover:bg-slate-50",children:[f?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(fe,{className:"w-4 h-4"})," העלאה",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:N=>{var O;return S((O=N.target.files)==null?void 0:O[0],"image")}})]}),e.jsx(be,{value:i.image||"",onChange:N=>u({image:N.target.value}),placeholder:"או כתובת תמונה",dir:"ltr",className:"h-9 text-sm"})]}),e.jsx("div",{className:"flex gap-1.5 mt-2",children:[["cover","מילוי האזור"],["contain","התאמה מלאה"]].map(([N,O])=>e.jsx("button",{onClick:()=>u({image_fit:N}),className:`flex-1 h-8 rounded-lg text-xs font-medium border ${(i.image_fit||"cover")===N?"bg-indigo-600 text-white border-transparent":"bg-white border-border"}`,children:O},N))})]});return e.jsxs("div",{className:"space-y-3",children:[(o==="title_desc"||o==="text"||o==="color"||o==="logo"||o==="qr"||o==="image_text")&&o!=="text"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"כותרת"}),e.jsx(be,{value:i.title||"",onChange:b=>u({title:b.target.value}),className:"h-9"})]}),(o==="title_desc"||o==="text"||o==="ticker"||o==="color"||o==="image_text")&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:o==="text"?"טקסט":o==="ticker"?"טקסט הסטריפ הרץ":"תיאור"}),e.jsx(ce,{value:i.text||"",onChange:b=>u({text:b.target.value}),rows:o==="text"?4:2})]}),o==="ticker"&&e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"צבע טקסט"}),e.jsx("input",{type:"color",value:i.text_color||"#ffffff",onChange:b=>u({text_color:b.target.value}),className:"w-full h-9 rounded-lg border border-border"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"צבע רקע"}),e.jsx("input",{type:"color",value:i.bg_color||"#0f172a",onChange:b=>u({bg_color:b.target.value}),className:"w-full h-9 rounded-lg border border-border"})]})]}),(o==="image"||o==="image_text")&&e.jsx(k,{label:"תמונה"}),(o==="title_desc"||o==="text"||o==="image_text"||o==="color")&&e.jsx(g,{}),(o==="title_desc"||o==="text"||o==="color")&&e.jsx(m,{}),(o==="title_desc"||o==="text"||o==="color")&&e.jsx(h,{}),o==="color"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"צבע רקע"}),e.jsx("input",{type:"color",value:i.bg_color||"#2563eb",onChange:b=>u({bg_color:b.target.value}),className:"w-full h-10 rounded-lg border border-border"})]}),o==="logo"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"צבע רקע (לא חובה)"}),e.jsx("input",{type:"color",value:i.bg_color||"#ffffff",onChange:b=>u({bg_color:b.target.value}),className:"w-full h-10 rounded-lg border border-border"})]}),o==="qr"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"כתובת הקישור"}),e.jsx(be,{value:i.qr_url||"",onChange:b=>u({qr_url:b.target.value}),placeholder:"https://…",dir:"ltr",className:"h-9"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"טקסט מתחת לקוד"}),e.jsx(be,{value:i.qr_label||"",onChange:b=>u({qr_label:b.target.value}),className:"h-9"})]})]}),o==="video"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"קישור יוטיוב"}),e.jsx(be,{value:i.youtube_url||"",onChange:b=>u({youtube_url:b.target.value,youtube_id:_(b.target.value)}),placeholder:"https://youtube.com/…",dir:"ltr",className:"h-9"})]}),e.jsx("div",{className:"text-center text-xs text-muted-foreground",children:"או"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"העלאת סרטון"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("label",{className:"inline-flex items-center gap-1.5 h-9 px-3 rounded-lg border border-slate-300 text-sm text-slate-600 cursor-pointer hover:bg-slate-50",children:[f?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(fe,{className:"w-4 h-4"})," קובץ וידאו",e.jsx("input",{type:"file",accept:"video/*",className:"hidden",onChange:b=>{var N;return S((N=b.target.files)==null?void 0:N[0],"media_url")}})]}),i.media_url&&e.jsxs("span",{className:"inline-flex items-center text-xs text-emerald-600 gap-1",children:[e.jsx(_e,{className:"w-3.5 h-3.5"})," הועלה"]})]})]})]})]})}
22function bl({item:l,onChange:r}){const o=l.config||{},i=c=>r({...l,config:{...o,...c}}),f=qr[l.source_module];return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"כמות פריטים להצגה"}),e.jsx(be,{type:"number",min:1,max:20,value:o.item_count??6,onChange:c=>i({item_count:Math.max(1,Number(c.target.value)||1)}),className:"h-9 w-28"})]}),f&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"תצוגה"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:f.map(([c,u])=>e.jsx("button",{onClick:()=>i({view:c}),className:`h-9 px-3 rounded-lg text-xs font-medium border ${(o.view||Ae(l.source_module))===c?"bg-indigo-600 text-white border-transparent":"bg-white border-border"}`,children:u},c))})]})]})}function rt({onPickModule:l,onPickFree:r,onPickContent:o,kibbutzId:i}){const[f,c]=p.useState("content"),[u,S]=p.useState(null);_r.useEffect(()=>{f!=="content"||u||!i||I.entities.DigitalScreenContent.filter({kibbutz_id:i,is_deleted:!1},"order",500).then(g=>S(g||[])).catch(()=>S([]))},[f,u,i]);const _=(g,h)=>e.jsx("button",{onClick:()=>c(g),className:`h-10 rounded-xl text-sm font-semibold border ${f===g?"bg-indigo-600 text-white border-transparent":"bg-white border-border"}`,children:h});return e.jsxs("div",{children:[e.jsxs("div",{className:"grid grid-cols-3 gap-2 mb-3",children:[_("content","עמודי תוכן"),_("free","תוכן חופשי"),_("module","מודולים")]}),f==="content"?u==null?e.jsx("div",{className:"flex justify-center py-6",children:e.jsx(de,{className:"w-5 h-5 animate-spin text-slate-400"})}):u.length===0?e.jsxs("div",{className:"rounded-xl bg-slate-50 border border-border px-4 py-5 text-center text-xs text-slate-500",children:["אין עדיין עמודי תוכן. צרו עמוד מעוצב ב",e.jsx("b",{children:"ספריית תוכן"})," (בתפריט המודול), והוא יופיע כאן."]}):e.jsx("div",{className:"grid grid-cols-2 gap-2 max-h-64 overflow-auto",children:u.map(g=>e.jsxs("button",{onClick:()=>o(g),className:"flex items-center gap-2 rounded-xl border border-border bg-white p-2.5 text-right hover:border-cyan-300 hover:shadow-sm transition-all",children:[e.jsx("span",{className:"w-8 h-8 rounded-lg bg-cyan-50 flex items-center justify-center flex-shrink-0",children:e.jsx(ge,{className:"w-4 h-4 text-cyan-600"})}),e.jsx("span",{className:"text-sm font-medium text-slate-700 truncate",children:g.title||"ללא כותרת"})]},g.id))}):e.jsx("div",{className:"grid grid-cols-2 gap-2",children:f==="module"?dt.map(g=>e.jsxs("button",{onClick:()=>l(g),className:"flex items-center gap-2 rounded-xl border border-border bg-white p-2.5 text-right hover:border-indigo-300 hover:shadow-sm transition-all",children:[e.jsx("span",{className:"w-8 h-8 rounded-lg bg-indigo-50 flex items-center justify-center flex-shrink-0",children:e.jsx(ze,{name:g.icon,className:"w-4 h-4 text-indigo-600"})}),e.jsx("span",{className:"text-sm font-medium text-slate-700 truncate",children:g.label})]},g.key)):ct.map(g=>e.jsxs("button",{onClick:()=>r(g),className:"flex items-center gap-2 rounded-xl border border-border bg-white p-2.5 text-right hover:border-emerald-300 hover:shadow-sm transition-all",children:[e.jsx("span",{className:"w-8 h-8 rounded-lg bg-emerald-50 flex items-center justify-center flex-shrink-0",children:e.jsx(ze,{name:g.icon,className:"w-4 h-4 text-emerald-600"})}),e.jsx("span",{className:"text-sm font-medium text-slate-700 truncate",children:g.label})]},g.key))})]})}const Oe=l=>{var r,o;return!l||!l.source?"טרם הוגדר":l.source==="module"?((r=dt.find(i=>i.key===(l.module||l.source_module)))==null?void 0:r.label)||"מודול":l.source==="content_page"?l.content_title||"עמוד תוכן":((o=ct.find(i=>i.key===l.free_type))==null?void 0:o.label)||"תוכן חופשי"};function pl({region:l,onChange:r,kibbutzId:o}){const i=Array.isArray(l.items)?l.items:[],[f,c]=p.useState(0),u=l.appearance||{},[S,_]=p.useState(!1),g=j=>r({...l,items:j}),h=(j,P)=>g(i.map((D,E)=>E===j?P:D)),m=()=>{g([...i,{}]),c(i.length)},k=j=>{const P={...i[j]},D=[...i];D.splice(j+1,0,P),g(D)},b=j=>{const P=i.filter((D,E)=>E!==j);g(P),c(Math.max(0,j-1))},N=j=>r({...l,appearance:{...u,...j}}),O=async j=>{if(j){_(!0);try{const{file_url:P}=await I.integrations.Core.UploadFile({file:j});N({bg_image:P})}catch{y.error("שגיאה בהעלאה")}finally{_(!1)}}},C=i[f]||i[0]||null,F=i[f]?f:0,$=j=>h(F,{source:"module",module:j.key,type:j.type,source_module:j.source_module,config:{item_count:6,view:Ae(j.source_module)}}),B=j=>h(F,{source:"free",free_type:j.key,free:{align:"center",title_size:"lg"}}),U=j=>h(F,{source:"content_page",content_id:j.id,content_title:j.title||"עמוד תוכן"});return e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"rounded-2xl border border-border bg-white p-4",children:[e.jsx(Ye,{icon:ot,children:"בחירת תוכן"}),l.rotate&&e.jsxs("div",{className:"space-y-1.5 mb-3",children:[i.map((j,P)=>e.jsxs("div",{className:`flex items-center gap-2 rounded-xl border px-2.5 py-2 ${P===f?"border-indigo-300 bg-indigo-50/50":"border-border"}`,children:[e.jsxs("button",{onClick:()=>c(P),className:"flex-1 text-right text-sm font-medium text-slate-700 truncate",children:[P+1,". ",Oe(j)]}),e.jsx("button",{onClick:()=>k(P),className:"p-1 text-slate-400 hover:text-slate-600",title:"שכפול",children:e.jsx(ke,{className:"w-3.5 h-3.5"})}),e.jsx("button",{onClick:()=>b(P),className:"p-1 text-red-400 hover:text-red-600",title:"מחיקה",children:e.jsx(re,{className:"w-3.5 h-3.5"})})]},P)),e.jsxs(R,{onClick:m,variant:"outline",size:"sm",className:"rounded-full gap-1 w-full mt-1",children:[e.jsx(se,{className:"w-4 h-4"})," הוסף תוכן"]})]}),i.length===0?e.jsx(rt,{kibbutzId:o,onPickModule:j=>{g([{source:"module",module:j.key,type:j.type,source_module:j.source_module,config:{item_count:6,view:Ae(j.source_module)}}]),c(0)},onPickFree:j=>{g([{source:"free",free_type:j.key,free:{align:"center",title_size:"lg"}}]),c(0)},onPickContent:j=>{g([{source:"content_page",content_id:j.id,content_title:j.title||"עמוד תוכן"}]),c(0)}}):C!=null&&C.source?e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-2.5 rounded-lg bg-slate-50 px-3 py-2",children:[e.jsx("span",{className:"text-sm font-semibold text-slate-700",children:Oe(C)}),e.jsx("button",{onClick:()=>h(F,{source:""}),className:"text-xs text-indigo-600 hover:underline",children:"החלפת תוכן"})]}),C.source==="module"?e.jsx(bl,{item:C,onChange:j=>h(F,j)}):C.source==="content_page"?e.jsxs("p",{className:"text-xs text-slate-500",children:["עמוד מעוצב מספריית התוכן. הגודל מותאם אוטומטית לאזור. לעריכת התוכן עברו ל",e.
22jsx("b",{children:"ספריית תוכן"}),"."]}):e.jsx(hl,{item:C,onChange:j=>h(F,j)})]}):e.jsx(rt,{kibbutzId:o,onPickModule:$,onPickFree:B,onPickContent:U})]}),e.jsxs("div",{className:"rounded-2xl border border-border bg-white p-4",children:[e.jsx(Ye,{icon:xe,accent:"blue",children:"הגדרות תצוגה"}),e.jsx("label",{className:"block text-xs text-muted-foreground mb-1.5",children:"מיקום התוכן"}),e.jsx("div",{className:"grid grid-cols-3 gap-1 w-fit mb-3",children:Br.map(j=>e.jsx("button",{onClick:()=>r({...l,position:j.key}),title:j.label,className:`w-9 h-9 rounded-lg border flex items-center justify-center ${(l.position||"center")===j.key?"bg-blue-600 border-transparent":"bg-white border-border hover:bg-slate-50"}`,children:e.jsx("span",{className:`w-2 h-2 rounded-full ${(l.position||"center")===j.key?"bg-white":"bg-slate-300"}`})},j.key))}),e.jsxs("div",{className:"grid grid-cols-2 gap-2 mb-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"צבע רקע"}),e.jsx("input",{type:"color",value:u.bg_color||"#0f172a",onChange:j=>N({bg_color:j.target.value}),className:"w-full h-9 rounded-lg border border-border"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"תמונת רקע"}),e.jsxs("label",{className:"inline-flex items-center gap-1.5 h-9 px-3 rounded-lg border border-slate-300 text-sm text-slate-600 cursor-pointer hover:bg-slate-50 w-full",children:[S?e.jsx(de,{className:"w-4 h-4 animate-spin"}):e.jsx(fe,{className:"w-4 h-4"})," ",u.bg_image?"הוחלף":"העלאה",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:j=>{var P;return O((P=j.target.files)==null?void 0:P[0])}})]})]})]}),u.bg_image&&e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("img",{src:u.bg_image,alt:"",className:"w-14 h-9 object-cover rounded border border-border"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("label",{className:"block text-[0.6875rem] text-muted-foreground",children:"שכבת כהות"}),e.jsx("input",{type:"range",min:0,max:.8,step:.05,value:u.overlay||0,onChange:j=>N({overlay:Number(j.target.value)}),className:"w-full"})]}),e.jsx("button",{onClick:()=>N({bg_image:""}),className:"p-1 text-red-400 hover:text-red-600",children:e.jsx(le,{className:"w-4 h-4"})})]}),e.jsxs("label",{className:"flex items-center justify-between text-sm text-slate-600 py-1",children:[e.jsx("span",{children:"פינות מעוגלות"}),e.jsx(ae,{checked:u.rounded!==!1,onCheckedChange:j=>N({rounded:j})})]})]}),e.jsxs("div",{className:"rounded-2xl border border-border bg-white p-4",children:[e.jsx(Ye,{icon:ke,accent:"emerald",children:"תוכן מתחלף"}),e.jsxs("label",{className:"flex items-center justify-between text-sm text-slate-600 py-1 mb-1",children:[e.jsx("span",{children:"הצגת מספר פריטי תוכן מתחלפים"}),e.jsx(ae,{checked:!!l.rotate,onCheckedChange:j=>r({...l,rotate:j})})]}),l.rotate&&e.jsxs(e.Fragment,{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1 mt-2",children:"זמן החלפה"}),e.jsx("div",{className:"flex flex-wrap gap-1.5 mb-3",children:Lr.map(j=>e.jsxs("button",{onClick:()=>r({...l,interval_seconds:j}),className:`h-8 px-3 rounded-full text-xs font-medium border ${(l.interval_seconds||8)===j?"bg-emerald-600 text-white border-transparent":"bg-white border-border"}`,children:[j," שנ׳"]},j))}),e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"מעבר בין תכנים"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Rr.map(j=>e.jsx("button",{onClick:()=>r({...l,transition:j.key}),className:`h-8 px-3 rounded-full text-xs font-medium border ${(l.transition||"fade")===j.key?"bg-emerald-600 text-white border-transparent":"bg-white border-border"}`,children:j.label},j.key))})]})]})]})}function Me(l){return!l||!l.source?null:l.source==="content_page"?{source:"content_page",content_id:l.content_id,content_title:l.content_title}:l.source==="free"?{source:"free",free_type:l.free_type,free:{align:"center",title_size:"lg"}}:l.source==="module"?{source:"module",module:l.module,type:l.type,source_module:l.source_module,config:{item_count:6,view:Ae(l.source_module)}}:null}function Ge({data:l,icon:r,label:o,tone:i}){return e.jsxs("div",{draggable:!0,onDragStart:f=>{f.dataTransfer.setData("text/plain",JSON.stringify(l)),f.dataTransfer.effectAllowed="copy"},className:"flex items-center gap-2 rounded-xl border border-border bg-white p-2.5 cursor-grab active:cursor-grabbing hover:border-indigo-300 hover:shadow-sm transition-all select-none",children:[e.jsx(rl,{className:"w-3.5 h-3.5 text-slate-300 flex-none"}),e.jsx("span",{className:`w-8 h-8 rounded-lg grid place-items-center flex-none ${i}`,children:r}),e.jsx("span",{className:"text-sm font-medium text-slate-700 truncate",children:o})]})}function gl({kibbutzId:l}){const[r,o]=p.useState("content"),[i,f]=p.useState(null);return p.useEffect(()=>{r!=="content"||i||!l||I.entities.DigitalScreenContent.filter({kibbutz_id:l,is_deleted:!1},"order",500).then(c=>f(c||[])).catch(()=>f([]))},[r,i,l]),e.jsxs("div",{className:"rounded-2xl border border-border bg-slate-50/70 p-3 lg:sticky lg:top-4",children:[e.jsx("p",{className:"text-xs font-bold text-slate-500 mb-2",children:"גררו תוכן אל האזורים ←"}),e.jsx("div",{className:"grid grid-cols-3 gap-1.5 mb-3",children:[["content","עמודי תוכן"],["free","וידג׳טים"],["module","מודולים"]].map(([c,u])=>e.jsx("button",{onClick:()=>o(c),className:`h-9 rounded-lg text-xs font-bold border ${r===c?"bg-indigo-600 text-white border-transparent":"bg-white border-border text-slate-600"}`,children:u},c))}),e.jsxs("div",{className:"space-y-1.5 max-h-[440px] overflow-auto pl-0.5",children:[r==="content"&&(i==null?e.jsx("div",{className:"flex justify-center py-6",children:e.jsx(de,{className:"w-5 h-5 animate-spin text-slate-400"})}):i.length===0?e.jsxs("div",{className:"rounded-xl bg-white border border-border px-3 py-4 text-center text-xs text-slate-500",children:["אי×
22Ÿ עמודי תוכן. צרו ב",e.jsx("b",{children:"ספריית תוכן"}),"."]}):i.map(c=>e.jsx(Ge,{data:{source:"content_page",content_id:c.id,content_title:c.title||"עמוד תוכן"},icon:e.jsx(ge,{className:"w-4 h-4 text-cyan-600"}),label:c.title||"ללא כותרת",tone:"bg-cyan-50"},c.id))),r==="free"&&ct.map(c=>e.jsx(Ge,{data:{source:"free",free_type:c.key},icon:e.jsx(ze,{name:c.icon,className:"w-4 h-4 text-emerald-600"}),label:c.label,tone:"bg-emerald-50"},c.key)),r==="module"&&dt.map(c=>e.jsx(Ge,{data:{source:"module",module:c.key,type:c.type,source_module:c.source_module},icon:e.jsx(ze,{name:c.icon,className:"w-4 h-4 text-indigo-600"}),label:c.label,tone:"bg-indigo-50"},c.key))]})]})}function Za({title:l,onClose:r,children:o}){return fr.createPortal(e.jsxs("div",{className:"fixed inset-0 z-[80] flex items-start justify-center p-4 overflow-y-auto",dir:"rtl",children:[e.jsx("div",{className:"absolute inset-0 bg-slate-900/50 backdrop-blur-sm",onClick:r}),e.jsxs("div",{className:"relative bg-slate-50 w-full max-w-lg rounded-3xl shadow-2xl my-8 max-h-[90vh] flex flex-col",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-5 py-3.5 bg-white rounded-t-3xl border-b border-border",children:[e.jsx("h3",{className:"text-base font-extrabold text-slate-900",children:l}),e.jsx("button",{"aria-label":"סגירה",onClick:r,className:"w-9 h-9 rounded-lg grid place-items-center text-slate-400 hover:bg-slate-100",children:e.jsx(le,{className:"w-5 h-5"})})]}),e.jsx("div",{className:"p-4 overflow-y-auto",children:o})]})]}),document.body)}function fl({value:l,onChange:r,onChangeLayout:o,onReset:i,kibbutzId:f}){const c=Je(l.layout)||Je("full"),u=Array.isArray(l.regions)?l.regions:[],S=Object.fromEntries(u.map((C,F)=>[C.id,F])),[_,g]=p.useState(-1),[h,m]=p.useState(""),k=(C,F)=>r({...l,regions:u.map(($,B)=>B===C?F:$)}),b=(C,F)=>{const $=u[C];k(C,{...$,items:[...Array.isArray($.items)?$.items:[],F]})},N=(C,F)=>{const $=u[C];k(C,{...$,items:($.items||[]).filter((B,U)=>U!==F)})},O=(C,F)=>{F.preventDefault(),m("");try{const $=Me(JSON.parse(F.dataTransfer.getData("text/plain")));$&&(b(C,$),$.source==="free"&&g(C))}catch{}};return e.jsxs("div",{dir:"rtl",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3 flex-wrap",children:[e.jsx("span",{className:"text-xs font-bold text-slate-500 ml-1",children:"פריסה:"}),qa.map(C=>e.jsx("button",{title:C.label,onClick:()=>{C.key!==l.layout&&o(C.key)},className:`w-14 h-9 rounded-lg border p-1 transition-all ${C.key===l.layout?"border-indigo-500 ring-2 ring-indigo-200":"border-border bg-white hover:border-indigo-300"}`,children:e.jsx(Va,{layout:C,className:"w-full h-full"})},C.key)),i&&e.jsxs("button",{onClick:i,className:"mr-auto text-xs font-semibold text-indigo-600 hover:underline inline-flex items-center gap-1",children:[e.jsx(Ee,{className:"w-3.5 h-3.5"})," בחירת תכנים מחדש"]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[minmax(0,1.5fr)_300px] gap-4 items-start",children:[e.jsxs("div",{className:"rounded-2xl border border-border bg-slate-100 p-2",children:[e.jsx("div",{className:"w-full aspect-video grid gap-2",style:{gridTemplateColumns:c.grid.columns,gridTemplateRows:c.grid.rows,gridTemplateAreas:c.grid.areas},children:c.regions.map(C=>{const F=S[C.id],$=u[F]||{id:C.id,name:C.name,items:[]},B=Array.isArray($.items)?$.items:[],U=$.rotate&&B.length>1,j=h===C.id;return e.jsxs("div",{style:{gridArea:C.id},onDragOver:P=>{P.preventDefault(),m(C.id)},onDragLeave:()=>m(P=>P===C.id?"":P),onDrop:P=>O(F,P),className:`min-h-0 rounded-xl border-2 p-2 flex flex-col gap-1.5 overflow-auto transition-colors ${j?"border-indigo-500 bg-indigo-50":B.length?"border-solid border-slate-300 bg-white":"border-dashed border-slate-300 bg-white/70"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-1 flex-none",children:[e.jsx("span",{className:"text-[0.6875rem] font-extrabold text-slate-600 truncate",children:$.name||C.name}),e.jsxs("div",{className:"flex items-center gap-1 flex-none",children:[e.jsx("button",{onClick:()=>k(F,{...$,rotate:!$.rotate}),title:"מתחלף / קבוע",className:`text-[0.625rem] font-bold rounded-full px-2 py-0.5 border ${$.rotate?"bg-emerald-50 border-emerald-300 text-emerald-700":"bg-slate-50 border-slate-200 text-slate-500"}`,children:$.rotate?"🔁 מתחלף":"📌 קבוע"}),e.jsx("button",{onClick:()=>g(F),title:"הגדרות אזור",className:"w-6 h-6 rounded-md grid place-items-center text-slate-400 hover:bg-slate-100",children:e.jsx(Jr,{className:"w-3.5 h-3.5"})})]})]}),B.length===0?e.jsx("div",{className:"flex-1 min-h-0 grid place-items-center text-center text-[0.6875rem] text-slate-400",children:"גררו תוכן לכאן"}):e.jsx("div",{className:"flex flex-col gap-1",children:B.map((P,D)=>e.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-slate-50 border border-slate-200 px-2 py-1",children:[e.jsxs("button",{onClick:()=>g(F),className:"flex-1 text-right text-[0.6875rem] font-semibold text-slate-700 truncate",children:[D+1,". ",Oe(P)]}),e.jsx("button",{onClick:()=>N(F,D),className:"text-slate-300 hover:text-red-500",children:e.jsx(le,{className:"w-3.5 h-3.5"})})]},D))}),U&&e.jsxs("div",{className:"flex-none text-[0.625rem] text-emerald-600 font-bold",children:["מתחלף כל ",$.interval_seconds||8," שנ׳ · ",B.length," תכנים"]})]},C.id)})}),e.jsx("p",{className:"text-[0.6875rem] text-muted-foreground mt-2 text-center",children:"גררו פריט מהצד ← לתוך אזור. לחצו ⚙ להגדרות מתקדמות (מיקום, רקע, עריכת טקסט). התצוגה המלאה מטה."})]}),e.jsx(gl,{kibbutzId:f})]}),_>=0&&u[_]&&e.jsxs(Za,{title:`הגדרות · ${u[_].name||"אזור"}`,onClose:()=>g(-1),children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"שם האזור"}),e.jsx("input",{value:u[_].name||"",onChange:C=>k(_,{...u[_],name:C.target.value}),className:"w-full h-9 rounded-lg border border-border px-3 text-sm"})]}),e.jsx(pl,{region:u[_],onChange:C=>k(_,C),kibbutzId:f})]})]})}const _l=[{key:"primary",label:"ראשי",hint:"אזור גדול",tone:"bg-amber-100 text-amber-700 border-amber-300"},{key:"normal",label:"רגיל",hint:"אזור רגיל",tone:"bg-slate-100 text-slate-600 border-slate-300"},{key:"minor",label:"משני",hint:"אזור קטן",tone:"bg-slate-50 text-slate-500 border-slate-200"}],jl=[{key:"",label:"אזור נפרד"},{key:"g1",label:"מתחלף · 1"},{key:"g2",label:"מתחלף · 2"},{key:"g3",label:"מתחלף · 3"}];let vl=0;function yl({onArrange:l,onManual:r,kibbutzId:o}
22){const[i,f]=p.useState([]),[c,u]=p.useState(!1),S=m=>{m&&(f(k=>[...k,{...m,importance:"normal",group:"",_id:`ac${++vl}`}]),u(!1))},_=(m,k)=>f(b=>b.map(N=>N._id===m?{...N,...k}:N)),g=m=>f(k=>k.filter(b=>b._id!==m)),h=()=>{if(!i.length){y.error("הוסיפו תוכן קודם");return}l(Or(i)),y.success("המערכת סידרה את התוכן על המסך")};return e.jsxs("div",{dir:"rtl",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("span",{className:"w-11 h-11 rounded-2xl bg-gradient-to-br from-indigo-500 to-violet-500 flex items-center justify-center shadow-sm",children:e.jsx(Ee,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-slate-800",children:"בחרו את התכנים — המערכת תסדר אותם על המסך"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:'הוסיפו עמודי תוכן, וידג׳טים ומודולים, סמנו מה ראשי ומה מתחלף — ולחצו "סדר אוטומטית".'})]})]}),e.jsxs("div",{className:"rounded-2xl border border-border bg-white p-4",children:[i.length===0?e.jsxs("div",{className:"rounded-xl border-2 border-dashed border-slate-200 bg-slate-50/50 px-4 py-10 text-center",children:[e.jsx(pr,{className:"w-8 h-8 text-slate-300 mx-auto mb-2"}),e.jsx("p",{className:"text-sm text-slate-500 mb-3",children:"עדיין לא נבחר תוכן"}),e.jsxs(R,{onClick:()=>u(!0),className:"rounded-full bg-indigo-600 hover:bg-indigo-700 gap-1.5",children:[e.jsx(se,{className:"w-4 h-4"})," הוספת תוכן"]})]}):e.jsxs("div",{className:"space-y-2",children:[i.map((m,k)=>e.jsxs("div",{className:"rounded-xl border border-border bg-white p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2.5",children:[e.jsx("span",{className:"w-7 h-7 rounded-lg bg-slate-100 grid place-items-center text-xs font-bold text-slate-500 flex-none",children:k+1}),e.jsx("span",{className:"flex-1 text-sm font-semibold text-slate-700 truncate",children:Oe(m)}),e.jsx("button",{onClick:()=>g(m._id),className:"p-1.5 text-red-400 hover:text-red-600 flex-none",title:"הסרה",children:e.jsx(re,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"grid sm:grid-cols-2 gap-2.5",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[0.6875rem] font-semibold text-slate-500 mb-1 flex items-center gap-1",children:[e.jsx(gr,{className:"w-3 h-3"})," חשיבות"]}),e.jsx("div",{className:"flex gap-1",children:_l.map(b=>e.jsx("button",{onClick:()=>_(m._id,{importance:b.key}),title:b.hint,className:`flex-1 h-8 rounded-lg text-[0.6875rem] font-bold border transition-colors ${m.importance===b.key?b.tone:"bg-white border-border text-slate-400 hover:bg-slate-50"}`,children:b.label},b.key))})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-[0.6875rem] font-semibold text-slate-500 mb-1 flex items-center gap-1",children:[e.jsx(ke,{className:"w-3 h-3"})," תוכן מתחלף"]}),e.jsx("div",{className:"flex gap-1",children:jl.map(b=>e.jsx("button",{onClick:()=>_(m._id,{group:b.key}),className:`flex-1 h-8 rounded-lg text-[0.6875rem] font-bold border transition-colors ${(m.group||"")===b.key?"bg-emerald-600 text-white border-transparent":"bg-white border-border text-slate-400 hover:bg-slate-50"}`,children:b.label},b.key))})]})]})]},m._id)),e.jsxs(R,{onClick:()=>u(!0),variant:"outline",size:"sm",className:"rounded-full gap-1 w-full",children:[e.jsx(se,{className:"w-4 h-4"})," הוספת תוכן"]})]}),i.some(m=>m.group)&&e.jsxs("p",{className:"text-[0.6875rem] text-emerald-600 mt-2.5 flex items-center gap-1",children:[e.jsx(ke,{className:"w-3 h-3"}),' תכנים באותה קבוצת "מתחלף" יופיעו באותו אזור ויתחלפו ביניהם.']})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3 mt-5",children:[e.jsx("button",{onClick:r,className:"text-sm text-slate-500 hover:text-slate-700 hover:underline",children:"או בחרו פריסה ידנית מתוך 6 תבניות ›"}),e.jsxs(R,{onClick:h,disabled:!i.length,className:"rounded-full bg-gradient-to-l from-indigo-600 to-violet-600 hover:opacity-90 gap-1.5 px-6 shadow-sm",children:[e.jsx(Ee,{className:"w-4 h-4"})," סדר אוטומטית על המסך"]})]}),c&&e.jsx(Za,{title:"הוספת תוכן",onClose:()=>u(!1),children:e.jsx(rt,{kibbutzId:o,onPickModule:m=>S(Me({source:"module",module:m.key,type:m.type,source_module:m.source_module})),onPickFree:m=>S(Me({source:"free",free_type:m.key})),onPickContent:m=>S(Me({source:"content_page",content_id:m.id,content_title:m.title||"עמוד תוכן"}))})})]})}
22function Nl({value:l,onChange:r,kibbutzId:o}){const i=l&&l.layout?l:{layout:"",regions:[]},[f,c]=p.useState("auto"),u=g=>r($a(g)),S=g=>{i.regions.some(h=>Array.isArray(h.items)&&h.items.length)&&!window.confirm("שינוי הפריסה תאפס את התוכן באזורים. להמשיך?")||r($a(g))},_=()=>{window.confirm("לבחור תכנים מחדש? הסידור הנוכחי יימחק.")&&(c("auto"),r({layout:"",regions:[]}))};return i.layout?e.jsx(fl,{value:i,onChange:r,onChangeLayout:S,onReset:_,kibbutzId:o}):f==="manual"?e.jsxs("div",{dir:"rtl",children:[e.jsxs("button",{onClick:()=>c("auto"),className:"text-sm text-indigo-600 hover:underline mb-3 inline-flex items-center gap-1",children:[e.jsx(Ee,{className:"w-4 h-4"})," חזרה לסידור אוטומטי"]}),e.jsx(ul,{onPick:u})]}):e.jsx(yl,{onArrange:r,onManual:()=>c("manual"),kibbutzId:o})}const Ya=90*1e3,Oa={draft:{label:"טיוטה",badge:"bg-slate-100 text-slate-600"},active:{label:"פעיל",badge:"bg-emerald-50 text-emerald-600"},paused:{label:"מושהה",badge:"bg-amber-50 text-amber-700"},inactive:{label:"לא פעיל",badge:"bg-slate-100 text-slate-500"}},Ie={news_update:[["banners","חדשות ובאנרים"],["cards","חדשות וכרטסיות נוספות"]],events:[["banners","אירועים ובאנרים"],["central","אירוע מרכזי וכרטסיות"]],businesses:[["auto","שילוב מתחלף"],["marketing","מסך שיווקי להצטרפות"],["listing","תצוגת עסקים"]],business_hours:[["carousel","קרוסלת מתקנים"],["expanded","מתקן מורחב"]],photo_albums:[["featured","אלבום מלא (מוזאיקה)"],["grid","כל האלבומים (רשת)"]]},Ba=l=>l==="businesses"?"auto":l==="business_hours"?"carousel":l==="photo_albums"?"featured":"banners",wl=l=>String(l||"").trim().toLowerCase().replace(/[^\w֐-׿]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40),Ga=()=>String(Math.floor(1e5+Math.random()*9e5)),mt=(l,r)=>`${window.location.origin}/digital-screen/${l}/${r}`,La={name:"",location:"",description:"",status:"draft",password:"",password_confirm:"",logo_url:"",primary_color:"#2563eb",secondary_color:"#06b6d4",show_time:!0,show_date:!0,show_weather:!0,show_footer:!0,footer_text:"",ticker_text:"",orientation:"landscape",aspect_ratio:"16:9"},lt=l=>({primary_color:l==null?void 0:l.primary_color,secondary_color:l==null?void 0:l.secondary_color,logo_url:l==null?void 0:l.logo_url,ticker_text:l==null?void 0:l.ticker_text,show_time:l==null?void 0:l.show_time,show_date:l==null?void 0:l.show_date,show_weather:l==null?void 0:l.show_weather});function kl(){const{id:l}=Dr(),r=Tr(),[o,i]=p.useState([]),[f,c]=p.useState([]),[u,S]=p.useState([]),[_,g]=p.useState(null),[h,m]=p.useState(null),[k,b]=p.useState(!0),[N,O]=p.useState("home"),[C,F]=p.useState(()=>{const d=new URLSearchParams(window.location.search).get("tab");return["screens","content","emergency"].includes(d)?d:"screens"}),[$,B]=p.useState(null),[U,j]=p.useState(0),[P,D]=p.useState(!1),E=p.useCallback(()=>{O("home"),F("screens"),j(d=>d+1)},[]),T=p.useCallback(async()=>{b(!0);try{const[d,X,me,ue,je]=await Promise.all([I.entities.DigitalScreenChannel.filter({kibbutz_id:l},"-updated_date",200),I.entities.DigitalScreenItem.filter({kibbutz_id:l},"order_index",1e3),I.entities.DigitalScreenDevice.filter({kibbutz_id:l},"-last_seen_at",500).catch(()=>[]),I.entities.DigitalScreenSettings.filter({kibbutz_id:l}).catch(()=>[]),I.entities.Kibbutz.get(l).catch(()=>null)]);i(d||[]),c(X||[]),S(me||[]),g((ue||[])[0]||null),m(je||null)}catch(d){console.error("Digital screens load error:",d),y.error("שגיאה בטעינת הנתונים")}finally{b(!1)}},[l]);p.useEffect(()=>{T()},[T]);const[q,Y]=p.useState(null),[V,J]=p.useState(null),W=d=>{Y(d),O("wizard")},G=p.useCallback(d=>f.filter(X=>X.channel_id===d),[f]);if(k)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsx("div",{className:"w-8 h-8 border-4 border-primary/20 border-t-primary rounded-full animate-spin"})});if(N==="wizard")return e.jsx(Sl,{kibbutzId:l,kibbutz:h,settings:_,editing:q,onDone:()=>{O(q?"manage":"home"),T()},onCancel:()=>O(q?"manage":"home")});if(N==="manage"&&V){const d=o.find(X=>X.id===V.id)||V;return e.jsx(Ol,{kibbutzId:l,channel:d,items:G(d.id),devices:u.filter(X=>X.channel_id===d.id),onEditSettings:()=>W(d),onChanged:T,onBack:()=>O("home")})}if(N==="design")return e.jsx(Ml,{kibbutzId:l,kibbutz:h,settings:_,onDone:()=>{O("home"),T()}});if(N==="screens")return e.jsx(Fl,{kibbutzId:l,devices:u,channels:o,onChanged:T,onBack:()=>O("home")});if(N==="content")return e.jsxs(e.Fragment,{children:[e.jsx(Pa,{kibbutzId:l,onBack:()=>O("home"),onPlace:B}),$&&e.jsx(Fa,{kibbutzId:l,content:$,onClose:()=>B(null),onPlaced:E})]});const Q=d=>C===d,s=Qe.find(d=>d.key===C)||Qe[0];return e.jsxs("div",{dir:"rtl",children:[e.jsx(Xr,{icon:s.icon,tone:s.tone,title:s.title,de
22scription:s.desc,tabs:Qe.map(d=>({key:d.key,label:d.tab,icon:d.icon,active:Q(d.key),onClick:()=>F(d.key)})),actions:Q("screens")?e.jsxs(e.Fragment,{children:[e.jsx(Ma,{icon:xt,iconClass:"text-amber-500",onClick:()=>r(Ze(l).topbar),children:Ve.topbar}),e.jsxs("button",{type:"button",onClick:()=>r(Ze(l).ai),className:"inline-flex items-center gap-1.5 h-10 px-4 rounded-full text-white text-sm font-bold shadow-sm hover:shadow transition-shadow whitespace-nowrap",style:{background:"linear-gradient(120deg,#4f46e5,#7c3aed 55%,#a855f7)"},children:[e.jsx(Ua,{className:"w-4 h-4"})," ",Ve.ai]}),e.jsx(Ma,{icon:se,tone:"primary",onClick:()=>D(!0),children:Ve.newScreen})]}):null}),P&&e.jsx(Ll,{onClose:()=>D(!1),onPick:d=>{D(!1),r(d==="pr"?`/kibbutz/${l}/digital-screen/pr/new`:Ze(l).newScreen)}}),e.jsx("div",{className:Q("screens")?"":"hidden",children:e.jsx(Yr,{reloadKey:U})}),e.jsx("div",{className:Q("content")?"":"hidden",children:e.jsx(Pa,{kibbutzId:l,hideHeader:!0,onPlace:B})}),$&&e.jsx(Fa,{kibbutzId:l,content:$,onClose:()=>B(null),onPlaced:E}),e.jsx("div",{className:Q("emergency")?"":"hidden",children:e.jsx(El,{kibbutzId:l,settings:_,onChanged:T,open:!0,setOpen:()=>{}})})]})}const Qe=[{key:"screens",tab:"המסכים",title:"מסך דיגיטלי",desc:"המסכים שלכם — לחיצה על מסך פותחת אותו באולפן",icon:xe,tone:"bg-indigo-600"},{key:"content",tab:"ספריית תוכן",title:"ספריית תוכן",desc:"עמודים מעוצבים למסך — מיקום, גודל ושכבות, בדיוק כפי שיוצג",icon:ge,tone:"bg-cyan-600"},{key:"emergency",tab:"מצב חירום",title:"מצב חירום",desc:"התראה שמשתלטת על כל המסכים עד לכיבוי",icon:tt,tone:"bg-red-600"}],Cl=[{key:"details",label:"פרטי הערוץ",icon:xe},{key:"design",label:"עיצוב",icon:xt},{key:"content",label:"תכנים",icon:ot},{key:"order",label:"סדר והפעלה",icon:Wa}],M="w-full h-11 rounded-xl border border-border bg-white px-3 text-sm text-right focus:outline-none focus:border-cyan-400";function Sl({kibbutzId:l,kibbutz:r,settings:o,editing:i,onDone:f,onCancel:c}){const[u,S]=p.useState(0),[_,g]=p.useState((i==null?void 0:i.id)||null),[h,m]=p.useState(!1),[k,b]=p.useState([]),[N,O]=p.useState(()=>i?{...La,...i,password:"",password_confirm:""}:{...La,logo_url:(o==null?void 0:o.default_logo_url)||(r==null?void 0:r.logo_url)||"",primary_color:(o==null?void 0:o.default_primary_color)||(r==null?void 0:r.primary_color)||"#2563eb",secondary_color:(o==null?void 0:o.default_secondary_color)||(r==null?void 0:r.secondary_color)||"#06b6d4",footer_text:(o==null?void 0:o.footer_text)||"",ticker_text:(o==null?void 0:o.ticker_text)||""});p.useEffect(()=>{_&&I.entities.DigitalScreenItem.filter({kibbutz_id:l,channel_id:_},"order_index",1e3).then(b).catch(()=>{})},[_,l]);const C=T=>O(q=>({...q,...T})),F=()=>({kibbutz_id:l,name:N.name.trim(),location:N.location||void 0,description:N.description||void 0,status:N.status||"draft",logo_url:N.logo_url||void 0,primary_color:N.primary_color,secondary_color:N.secondary_color,show_time:N.show_time,show_date:N.show_date,show_weather:N.show_weather,show_footer:N.show_footer,footer_text:N.footer_text||void 0,ticker_text:N.ticker_text||void 0,orientation:N.orientation,aspect_ratio:N.aspect_ratio,updated_date:new Date().toISOString()}),$=async()=>{let T=_;if(T)await I.entities.DigitalScreenChannel.update(T,F());else{T=(await I.entities.DigitalScreenChannel.create({...F(),slug:wl(N.name)})).id,g(T);const Y=Ga();try{await I.functions.invoke("setDigitalScreenPassword",{channel_id:T,password:Y}),C({access_code:Y})}catch{}}return T},B=async T=>{if(T!==u){if(T<u){S(T);return}if(!N.name.trim()){y.error("יש להזין שם ערוץ"),S(0);return}if(!_){m(!0);try{await $()}catch{y.error("שגיאה בשמירה"),m(!1);return}m(!1)}S(T)}},U=async()=>{if(u===0&&!N.name.trim()){y.error("יש להזין שם ערוץ");return}m(!0);try{await $(),S(T=>Math.min(3,T+1))}catch(T){console.error(T),y.error("שגיאה בשמירה")}finally{m(!1)}},j=async T=>{m(!0);try{const q=await $();await I.entities.DigitalScreenChannel.update(q,{status:T?"active":"draft",updated_date:new Date().toISOString()}),y.success(T?"הערוץ הופעל":"נשמר כטיוטה"),f()}catch(q){console.error(q),y.error("שגיאה")}finally{m(!1)}},P=()=>_&&I.entities.DigitalScreenItem.filter({kibbutz_id:l,channel_id:_},"order_index",1e3).then(b).catch(()=>{}),D=T=>T===0?!N.name.trim():T===2||T===3?k.length===0:!1,E=Cl.map((T,q)=>
22({key:T.key,label:T.label,icon:T.icon,state:q===u?"current":D(q)?"error":q<u?"done":"todo"}));return e.jsxs("div",{dir:"rtl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx(Be,{title:i?"עריכת ערוץ":"ערוץ חדש",items:[]}),e.jsx(R,{variant:"outline",onClick:c,className:"rounded-full",children:"חזרה"})]}),e.jsx("div",{className:"mb-6",children:e.jsx(Ar,{steps:E,onStep:B})}),u===0&&e.jsx($l,{form:N,patch:C,channelId:_,kibbutzId:l}),u===1&&e.jsx(Dl,{form:N,patch:C,kibbutzId:l}),u===2&&e.jsx(Tl,{channelId:_,kibbutzId:l,items:k,reloadItems:P,design:lt(N)}),u===3&&e.jsx(Pl,{channelId:_,kibbutzId:l,items:k,reloadItems:P}),e.jsxs("div",{className:"flex items-center justify-between mt-6",children:[u===0?e.jsx("span",{}):e.jsxs(R,{variant:"outline",onClick:()=>S(T=>T-1),className:"rounded-full gap-1.5",children:[e.jsx(Ir,{className:"w-4 h-4"})," הקודם"]}),u<3?e.jsx(R,{onClick:U,disabled:h,className:"rounded-full gap-1.5 bg-cyan-600 hover:bg-cyan-700",children:h?"שומר…":e.jsxs(e.Fragment,{children:["המשך ",e.jsx(ll,{className:"w-4 h-4"})]})}):e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{variant:"outline",onClick:()=>j(!1),disabled:h,className:"rounded-full",children:"שמור טיוטה"}),e.jsxs(R,{onClick:()=>j(!0),disabled:h,className:"rounded-full gap-1.5 bg-emerald-600 hover:bg-emerald-700",children:[e.jsx(Wa,{className:"w-4 h-4"})," הפעל ערוץ"]})]})]})]})}function $l({form:l,patch:r,channelId:o,kibbutzId:i}){const f=o?mt(i,o):null;return e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-6",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"שם הערוץ *"}),e.jsx("input",{className:M,value:l.name,onChange:c=>r({name:c.target.value}),placeholder:"לדוגמה: מסך מרכז הקהילה"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"מיקום המסך"}),e.jsx("input",{className:M,value:l.location,onChange:c=>r({location:c.target.value}),placeholder:"לדוגמה: כניסה למזכירות"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"תיאור"}),e.jsx(ce,{rows:2,className:"rounded-xl resize-none",value:l.description,onChange:c=>r({description:c.target.value})})]})]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-border/60",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Ka,{className:"w-4 h-4 text-cyan-600"}),e.jsx("h3",{className:"text-sm font-bold",children:"קוד כניסה למסך"})]}),l.access_code?e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:"inline-flex items-center h-11 px-5 rounded-xl bg-cyan-50 text-cyan-800 text-xl font-black tracking-[0.3em]",dir:"ltr",children:l.access_code}),e.jsx("button",{type:"button",onClick:()=>{var c;(c=navigator.clipboard)==null||c.writeText(l.access_code),y.success("הקוד הועתק")},className:"h-9 px-4 rounded-full border border-border text-xs hover:bg-accent",children:"העתק קוד"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:'הזינו קוד זה במסך הפיזי כדי לחבר אותו. ניתן להחליף בכל עת דרך "החלף סיסמה".'})]}):e.jsx("p",{className:"text-xs text-muted-foreground",children:"קוד כניסה בן 6 ספרות ייווצר אוטומטית לערוץ עם השמירה הראשונה, ויוצג כאן ובעמוד הניהול."})]}),f&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-border/60",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"כתובת ייחודית למסך"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{className:`${M} font-mono text-xs`,value:f,readOnly:!0,dir:"ltr"}),e.jsx("button",{type:"button",onClick:()=>{var c;(c=navigator.clipboard)==null||c.writeText(f),y.success("הקישור הועתק")},className:"h-11 px-3 rounded-xl border border-border text-xs hover:bg-accent whitespace-nowrap",children:"העתק"})]})]})]})}function Dl({form:l,patch:r}){const{t:o}=it(),i=({k:f,label:c})=>e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border px-3 py-2.5",children:[e.jsx("span",{className:"text-sm text-foreground",children:c}),e.jsx(ae,{checked:!!l[f],onCheckedChange:u=>r({[f]:u})})]});return e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-6",dir:"rtl",children:[e.jsxs("div",{className:"rounded-xl bg-slate-50 border border-slate-100 px-4 py-3 mb-4 text-sm text-slate-500 flex items-center gap-2",children:[e.jsx(we,{className:"w-4 h-4 text-slate-400"})," ",ie("הלוגו נלקח אוטומטית מהגדרות אתר הקיבוץ.",o)]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 max-w-md",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"צבע ראשי"}),e.jsx("input",{type:"color",className:"w-full h-11 rounded-xl border border-border bg-white cursor-pointer",value:l.primary_color,onChange:f=>r({primary_color:f.target.value})})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"צבע משני"}),e.jsx("input",{type:"color",className:"w-full h-11 rounded-xl border border-border bg-white cursor-pointer",value:l.secondary_color,onChange:f=>r({secondary_color:f.target.value})})]})]}),e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2 mt-4",children:[e.jsx(i,{k:"show_time",label:"הצגת שעה"}),e.jsx(i,{k:"show_date",label:"הצגת תאריך"}),e.jsx(i,{k:"show_weather",label:"מזג אוויר"}),e.jsx(i,{k:"show_footer",label:"הצגת פוטר"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mt-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"טקסט טיקר (רץ בתחתית)"}),e.jsx("input",{className:M,value:l.ticker_text,onChange:f=>r({ticker_text:f.target.value}),placeholder:"הודעה רצה…"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"טקסט פוטר"}),e.jsx("input",{className:M,value:l.footer_text,onChange:f=>r({footer_text:f.target.value}),placeholder:"פרטי קשר / ברירת מחדל: מופעל על ידי EBUTZ"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3 mt-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"כיוון המסך"}),e.jsx("div",{className:"flex gap-2",children:[{v:"landscape",l:"לרוחב"},{v:"portrait",l:"לאורך"}].map(f=>e.jsx("button",{type:"button",onClick:()=>r({orientation:f.v}),className:`flex-1 h-11 rounded-xl border text-sm font-medium ${l.orientation===f.v?"bg-cyan-600 text-white border-transparent":"bg-white border-border hover:bg-accent"}`,children:f.l},f.v))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"יחס מסך"}),e.jsx("div",{className:"flex gap-2",children:[{v:"16:9",l:"16:9"},{v:"9:16",l:"9:16"}].map(f=>e.jsx("button",{type:"button",onClick:()=>r({aspect_ratio:f.v}),className:`flex-1 h-11 rounded-xl border text-sm font-medium ${l.aspect_ratio===f.v?"bg-cyan-600 text-white border-transparent":"bg-white border-border hover:bg-accent"}`,children:f.l},f.v))})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground mt-4",children:["פוטר קבוע: ",e.jsx("b",{children:"מופעל על ידי EBUTZ"})," — יוצג תמיד בתחתית המסך."]})]})}function Tl({channelId:l,kibbutzId:r,items:o,reloadItems:i,design:f}
22){const[c,u]=p.useState(null);return l?e.jsxs("div",{className:"space-y-4",dir:"rtl",children:[e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-5",children:[e.jsx("h3",{className:"text-sm font-bold mb-3",children:"בחירת סוגי תוכן"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2.5",children:pe.map(S=>{const _=S.icon;return e.jsxs("button",{onClick:()=>u(S),className:"flex flex-col items-center gap-2 p-4 rounded-2xl border border-border hover:border-cyan-300 hover:shadow-sm transition-all text-center",children:[e.jsx("span",{className:`w-11 h-11 rounded-xl flex items-center justify-center ${S.color}`,children:e.jsx(_,{className:"w-5 h-5"})}),e.jsx("span",{className:"text-xs font-medium text-foreground",children:S.label})]},S.key)})})]}),c&&e.jsx(nt,{def:c,channelId:l,kibbutzId:r,order:o.length,design:f,onDone:()=>{u(null),i()},onCancel:()=>u(null)},`new-${c.key}`),o.length>0&&e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-5",children:[e.jsxs("h3",{className:"text-sm font-bold mb-3",children:["תכנים שנוספו (",o.length,")"]}),e.jsx("div",{className:"space-y-2",children:o.map(S=>e.jsx(Il,{item:S,onChanged:i},S.id))})]})]}):e.jsx("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-6 text-sm text-muted-foreground",children:"יש לשמור את פרטי הערוץ תחילה."})}const Z=50;function nt({def:l,item:r,channelId:o,kibbutzId:i,order:f,onDone:c,onCancel:u,design:S}){const{t:_}=it(),g=!!r,h=l.source_module==="news_update",m=l.source_module==="events",k=l.source_module==="memorial_pages",b=l.source_module==="businesses",N=l.source_module==="birthdays",O=l.source_module==="business_hours",C=l.source_module==="photo_albums",F=l.source_module==="service_requests",$=l.source_module==="interests",B=l.source_module==="digital_pages",U=l.type==="personal_area",j=l.type==="secondhand",P=l.type==="pub",D=l.type==="weather",E=l.type==="synagogue",T=l.type==="content_page",q=h||m,Y=h||m||k||b||N||O||C||F||$||B,V=l.type==="cards",J=l.type==="video",W=l.type==="banner",G=l.type==="image",Q=l.type==="multi",[s,d]=p.useState(()=>{var t,a,n,x,w,K,te,$t,Dt,Tt,It,Pt,Mt,At,Et,Ft,zt,Ot,Bt,Lt,Rt,qt,Ut,Ht,Wt,Kt,Vt,Zt,Yt,Gt,Qt,Xt,Jt,es,ts,ss,as,rs,ls,ns,os,is,ds,cs,xs,ms,us,hs,bs,ps,gs,fs,_s,js,vs,ys,Ns,ws,ks,Cs,Ss,$s,Ds,Ts,Is,Ps,Ms,As,Es,Fs,zs,Os,Bs,Ls,Rs,qs,Us,Hs,Ws,Ks,Vs,Zs,Ys,Gs,Qs,Xs,Js,ea,ta,sa,aa,ra,la,na,oa,ia,da,ca,xa,ma,ua,ha,ba,pa,ga,fa,_a,ja,va,ya,Na,wa,ka,Ca;return g?{title:r.title||"",media_url:r.media_url||"",body:r.body||"",duration_seconds:r.duration_seconds||25,item_count:((t=r.config)==null?void 0:t.item_count)||(b?4:Y?8:5),mod_view:((a=r.config)==null?void 0:a.view)||Ba(l.source_module),mute:((n=r.config)==null?void 0:n.mute)!==!1,loop:((x=r.config)==null?void 0:x.loop)!==!1,side_banners:Array.isArray((w=r.config)==null?void 0:w.side_banners)?r.config.side_banners:[],cards:Array.isArray((K=r.config)==null?void 0:K.cards)?r.config.cards:[],pa_view:((te=r.config)==null?void 0:te.view)||"full",pa_keys:Array.isArray(($t=r.config)==null?void 0:$t.selected_keys)?r.config.selected_keys:[],sh_view:((Dt=r.config)==null?void 0:Dt.view)||"full",sh_ad_type:((Tt=r.config)==null?void 0:Tt.ad_type)||"all",sh_recency:((It=r.config)==null?void 0:It.recency_days)??30,sh_count:((Pt=r.config)==null?void 0:Pt.count)||12,sh_cats:Array.isArray((Mt=r.config)==null?void 0:Mt.category_ids)?r.config.category_ids:[],sh_show_qr:!!((At=r.config)!=null&&At.show_qr),sh_fields:{condition:!0,category:!0,publisher:!1,date:!0,...((Et=r.config)==null?void 0:Et.fields)||{}},pub_view:((Ft=r.config)==null?void 0:Ft.view)||"combined",pub_count:((zt=r.config)==null?void 0:zt.count)||8,pub_only_featured:!!((Ot=r.config)!=null&&Ot.only_featured),pub_qr_order:((Bt=r.config)==null?void 0:Bt.show_qr_order)!==!1,pub_qr_card:!!((Lt=r.config)!=null&&Lt.show_qr_card),wx_view:((Rt=r.config)==null?void 0:Rt.view)||"full",wx_fields:{precip:!0,wind:!0,humidity:!1,sun:!1,...((qt=r.config)==null?void 0:qt.fields)||{}},wx_weekend:((Ut=r.config)==null?void 0:Ut.highlight_weekend)!==!1,wx_night:((Ht=r.config)==null?void 0:Ht.night_mode)!==!1,wx_alerts:((Wt=r.config)==null?void 0:Wt.alerts)!==!1,wx_place:((Kt=r.config)==null?void 0:Kt.place_label)||"",wx_lat:((Vt=r.config)==null?void 0:Vt.override_lat)??"",wx_lng:((Zt=r.config)==null?void 0:Zt.override_lng)??"",sy_prayers:Array.isArray((Yt=r.config)==null?void 0:Yt.prayers
22)&&r.config.prayers.length?r.config.prayers:[{label:"שחרית",time:""},{label:"מנחה",time:""},{label:"ערבית",time:""}],sy_show_zmanim:((Gt=r.config)==null?void 0:Gt.show_zmanim)!==!1,sy_zmanim_keys:Array.isArray((Qt=r.config)==null?void 0:Qt.zmanim_keys)&&r.config.zmanim_keys.length?r.config.zmanim_keys:["sunrise","sofZmanShma","sofZmanTfilla","chatzot","minchaGedola","plagHaMincha","sunset","tzeit"],sy_show_shabbat:((Xt=r.config)==null?void 0:Xt.show_shabbat)!==!1,sy_show_hebrew_date:((Jt=r.config)==null?void 0:Jt.show_hebrew_date)!==!1,sy_place:((es=r.config)==null?void 0:es.place_label)||"",sy_lat:((ts=r.config)==null?void 0:ts.override_lat)??"",sy_lng:((ss=r.config)==null?void 0:ss.override_lng)??"",cp_id:((as=r.config)==null?void 0:as.content_id)||"",vid_source:((rs=r.config)==null?void 0:rs.source)||((ls=r.config)!=null&&ls.youtube_id?"youtube":"upload"),vid_aspect:((ns=r.config)==null?void 0:ns.aspect)||"16:9",vid_fit:((os=r.config)==null?void 0:os.fit)||"contain",vid_duration_mode:((is=r.config)==null?void 0:is.duration_mode)||"full",vid_clip:((ds=r.config)==null?void 0:ds.clip_seconds)??15,vid_start:((cs=r.config)==null?void 0:cs.start_at)??0,vid_stop:((xs=r.config)==null?void 0:xs.stop_at)??"",vid_autoplay:((ms=r.config)==null?void 0:ms.autoplay)!==!1,vid_mute:((us=r.config)==null?void 0:us.mute)!==!1,vid_loop:!!((hs=r.config)!=null&&hs.loop),vid_show_title:!!((bs=r.config)!=null&&bs.show_title),vid_show_desc:!!((ps=r.config)!=null&&ps.show_description),vid_youtube_url:((gs=r.config)==null?void 0:gs.youtube_url)||"",vid_youtube_id:((fs=r.config)==null?void 0:fs.youtube_id)||"",vid_file_name:((_s=r.config)==null?void 0:_s.file_name)||"",vid_file_size:((js=r.config)==null?void 0:js.file_size)||"",vid_dur:((vs=r.config)==null?void 0:vs.video_duration)||"",vid_res:((ys=r.config)==null?void 0:ys.resolution)||"",vid_view:((Ns=r.config)==null?void 0:Ns.view)||"single",vid_bg:((ws=r.config)==null?void 0:ws.bg)||"gradient",vid_text_speed:((ks=r.config)==null?void 0:ks.text_speed)??45,vid_layout:((Cs=r.config)==null?void 0:Cs.layout)||"laptop_left",vid2_source:(($s=(Ss=r.config)==null?void 0:Ss.video2)==null?void 0:$s.source)||((Ts=(Ds=r.config)==null?void 0:Ds.video2)!=null&&Ts.youtube_id?"youtube":"upload"),vid2_media_url:((Ps=(Is=r.config)==null?void 0:Is.video2)==null?void 0:Ps.media_url)||"",vid2_youtube_url:((As=(Ms=r.config)==null?void 0:Ms.video2)==null?void 0:As.youtube_url)||"",vid2_youtube_id:((Fs=(Es=r.config)==null?void 0:Es.video2)==null?void 0:Fs.youtube_id)||"",bn_layout:((zs=r.config)==null?void 0:zs.layout)||"featured",bn_count:((Os=r.config)==null?void 0:Os.count)||5,bn_banners:Array.isArray((Bs=r.config)==null?void 0:Bs.banners)?r.config.banners:[],bn_text_pos:((Ls=r.config)==null?void 0:Ls.text_position)||"br",bn_show_title:((Rs=r.config)==null?void 0:Rs.show_title)!==!1,bn_show_desc:((qs=r.config)==null?void 0:qs.show_desc)!==!1,bn_show_btitles:((Us=r.config)==null?void 0:Us.show_banner_titles)!==!1,bn_show_bdescs:((Hs=r.config)==null?void 0:Hs.show_banner_descs)!==!1,bn_rounded:((Ws=r.config)==null?void 0:Ws.rounded)!==!1,bn_overlay:((Ks=r.config)==null?void 0:Ks.overlay)??.42,bn_transition_ms:((Vs=r.config)==null?void 0:Vs.transition_ms)??700,bn_autoplay:((Zs=r.config)==null?void 0:Zs.autoplay)!==!1,bn_loop:((Ys=r.config)==null?void 0:Ys.loop)!==!1,ti_images:Array.isArray((Gs=r.config)==null?void 0:Gs.images)&&r.config.images.length?r.config.images:r.media_url?[{image:r.media_url,title:r.title||"",text:r.body||"",focus:"center"}]:[],ti_speed_title:((Qs=r.config)==null?void 0:Qs.type_speed_title)??55,ti_speed_desc:((Xs=r.config)==null?void 0:Xs.type_speed_desc)??26,ti_hold:((Js=r.config)==null?void 0:Js.hold)??1200,ti_transition:((ea=r.config)==null?void 0:ea.img_transition)||"zoom",ti_countdown:((ta=r.config)==null?void 0:ta.countdown)!==!1,ti_text_pos:((sa=r.config)==null?void 0:sa.text_position)||"cr",ti_text_color:((aa=r.config)==null?void 0:aa.text_color)||"#ffffff",ti_title_size:((ra=r.config)==null?void 0:ra.title_size)||"lg",ti_desc_size:((la=r.config)==null?void 0:la.desc_size)||"md",ti_hide_desc:!!((na=r.config)!=null&&na.hide_desc),ti_overlay:((oa=r.config)==null?void 0:oa.overlay)??.5,dp_headline:((ia=r.config)==null?void 0:ia.headline)||"",dp_subtext:((da=r.config)==null?void 0:da.subtext)||r.body||"",dp_all_cats:((ca=r.config)==null?void 0:ca.all_categories)??!(Array.isArray((xa=r.config)==null?void 0:xa.category_ids)&&r.config.category_ids.length),dp_cats:Array.isArray((ma=r.config)==null?void 0:ma.category_ids)?r.config.category_ids:[],dp_source:((ua=r.config)==null?void 0:ua.source)||"all",dp_page_ids:Array.isArray((ha=r.config)==null?void 0:ha.page_ids)?r.config.page_ids:[],dp_page_id:((ba=r.config)==null?void 0:ba.page_id)||"",dp_order:((pa=r.config)==null?void 0:pa.order)||"new",dp_per_row:((ga=r.config)==null?void 0:ga.per_row)||4,dp_footer:((fa=r.config)==null?void 0:fa.footer_style)||"light",dp_show_qr:((_a=r.config)==null?void 0:_a.show_qr)!==!1,dp_new_days:((ja=r.config)==null?void 0:ja.new_days)??14,dp_fields:{title:!0,description:!0,date:!0,category:!0,page_count:!1,new_label:!0,qr:!0,...((va=r.config)==null?void 0:va.fields)||{}},dp_autoplay:((ya=r.config)==null?void 0:ya.autoplay)!==!1,dp_group_seconds:((Na=r.config)==null?void 0:Na.group_seconds)??9,dp_transition:((wa=r.config)==null?void 0:wa.transition)||"slide",dp_dots:((ka=r.config)==null?void 0:ka.show_dots)!==!1,dp_reduce:!!((Ca=r.config)!=null&&Ca.reduce_motion),multi:r.config&&Array.isArray(r.config.regions)?r.config:{layout:"",regions:[]}}:{title:V||G?"":l.label,media_url:"",body:"",duration_seconds:Y||V||U||j||W||G?60:J?30:25,item_count:b?4:Y?8:5,mod_view:Ba(l.source_module),mute:!0,loop:!0,side_banners:[],cards:[],pa_view:"full",pa_keys:[],sh_view:"full",sh_ad_type:"all",sh_recency:30,sh_count:12,sh_cats:[],sh_show_qr:!1,sh_fields:{condition:!0,category:!0,publisher:!1,date:!0},pub_view:"combined",pub_count:8,pub_only_featured:!1,pub_qr_order:!0,pub_qr_card:!1,wx_view:"full",wx_fields:{precip:!0,wind:!0,humidity:!1,sun:!1},wx_weekend:!0,wx_night:!0,wx_alerts:!0,wx_place:"",wx_lat:"",wx_lng:"",sy_prayers:[{label:"שחרית",time:""},{label:"מנחה",time:""},{label:"ערבית",time:""}],sy_show_zmanim:!0,sy_zmanim_keys:["sunrise","sofZmanShma","sofZmanTfilla","chatzot","minchaGedola","plagHaMincha","sunset","tzeit"],sy_show_shabbat:!0,sy_show_hebrew_date:!0,sy_place:"",sy_lat:"",sy_lng:"",cp_id:"",vid_source:"upload",vid_aspect:"16:9",vid_fit:"contain",vid_duration_mode:"full",vid_clip:15,vid_start:0,vid_stop:"",vid_autoplay:!0,vid_mute:!0,vid_loop:!1,vid_show_title:!1,vid_show_desc:!1,vid_youtube_url:"",vid_youtube_id:"",vid_file_name:"",vid_file_size:"",vid_dur:"",vid_res:"",vid_view:"single",vid_bg:"gradient",vid_text_speed:45,vid_layout:"laptop_left",vid2_source:"upload",vid2_media_url:"",vid2_youtube_url:"",vid2_youtube_id:"",bn_layout:"featured",bn_count:5,bn_banners:[],bn_text_pos:"br",bn_show_title:!0,bn_show_desc:!0,bn_show_btitles:!0,bn_show_bdescs:!0,bn_rounded:!0,bn_overlay:.42,bn_transition_ms:700,bn_autoplay:!0,bn_loop:!0,ti_images:[],ti_speed_title:55,ti_speed_desc:26,ti_hold:1200,ti_transition:"zoom",ti_countdown:!0,ti_text_pos:"cr",ti_text_color:"#ffffff",ti_title_size:"lg",ti_desc_size:"md",ti_hide_desc:!1,ti_overlay:.5,dp_headline:"",dp_subtext:"",dp_all_cats:!0,dp_cats:[],dp_source:"all",dp_page_ids:[],dp_page_id:"",dp_order:"new",dp_per_row:4,dp_footer:"light",dp_show_qr:!0,dp_new_days:14,dp_fields:{title:!0,description:!0,date:!0,category:!0,page_count:!1,new_label:!0,qr:!0},dp_autoplay:!0,dp_group_seconds:9,dp_transition:"slide",dp_dots:!0,dp_reduce:!1,multi:{layout:"",regions:[]}}}),X=t=>d(a=>({...a,pa_keys:a.pa_keys.includes(t)?a.pa_keys.filter(n=>n!==t):[...a.pa_keys,t]})),me=t=>d(a=>({...a,sh_cats:a.sh_cats.includes(t)?a.sh_cats.filter(n=>n!==t):[...a.sh_cats,t]})),[ue,je]=p.useState([]);p.useEffect(()=>{j&&I.entities.SecondHandCategory.filter({kibbutz_id:i},"sort_order",200).then(t=>je(t||[])).catch(()=>{})},[j,i]);const[ne,Se]=p.useState([]),[oe,Le]=p.useState([]),[ve,Re]=p.useState(""),[$e,ye]=p.useState(-1);p.useEffect(()=>{B&&Promise.all([I.entities.DigitalPageCategory.filter({kibbutz_id:i,is_active:!0},"sort_order",200).catch(()=>[]),I.entities.DigitalPage.filter({kibbutz_id:i,status:"published",is_active:!0},"-publish_date",300).catch(()=>[])]).then(([t,a])=>{Se(t||[]),Le(a||[])})},[B,i]);const v=t=>d(a=>({...a,dp_page_ids:a.dp_page_ids.includes(t)?a.dp_page_ids.filter(n=>n!==t):[...a.dp_page_ids,t]})),L=(t,a)=>d(n=>({...n,dp_fields:{...n.dp_fields,[t]:a}})),z=p.useMemo(()=>{const t=new Set(ne.map(a=>a.id));return oe.filter(a=>t.has(a.category_id)?s.dp_all_cats?!0:s.dp_cats.includes(a.category_id):!1)},[oe,ne,s.dp_all_cats,s.dp_cats]),he=p.useMemo(()=>new Map(ne.map(t=>[t.id,t.title||""])),[ne]),[ee,De]=p.useState([]);p.useEffect(()=>{T&&I.entities.DigitalScreenContent.filter({kibbutz_id:i,is_deleted:!1},"order",500).then(t=>De(t||[])).catch(()=>{})},[T,i]);const[A,H]=p.useState(null);p.useEffect(()=>{!D&&!E||I.entities.Kibbutz.get(i).then(t=>{t&&H({lat:t.map_latitude??null,lng:t.map_longitude??null,name:t.name||t.hebrew_name||""})}).catch(()=>{})},[D,E,i]),p.useEffect(()=>{!D&&!E||!A||d(t=>{const a={...t};return D?(t.wx_lat===""&&A.lat!=null&&(a.wx_lat=String(A.lat)),t.wx_lng===""&&A.lng!=null&&(a.wx_lng=String(A.lng)),!t.wx_place&&A.name&&(a.wx_place=A.name)):(t.sy_lat===""&&A.lat!=null&&(a.sy_lat=String(A.lat)),t.sy_lng===""&&A.lng!=null&&(a.sy_lng=String(A.lng)),!t.sy_place&&A.name&&(a.sy_place=A.name)),a})},[D,E,A]);const[ut,ht]=p.useState(!1),[bt,pt]=p.useState(-1),[qe,gt]=p.useState(!1),[Ue,ft]=p.useState(!1),_t=t=>{const a=String(t||"").trim(),n=a.match(/(?:youtu\.be\/|youtube\.com\/(?:watch\?v=|embed\/|shorts\/|v\/))([\w-]{11})/);
22return n?n[1]:/^[\w-]{11}$/.test(a)?a:""},Qa=async t=>{var n;const a=(n=t.target.files)==null?void 0:n[0];if(a){if(a.size>Z*1024*1024){y.error(`הקובץ גדול מדי (עד ${Z}MB)`),t.target.value="";return}ft(!0);try{const x=await new Promise(K=>{const te=document.createElement("video");te.preload="metadata",te.onloadedmetadata=()=>K({dur:Math.round(te.duration),w:te.videoWidth,h:te.videoHeight}),te.onerror=()=>K({}),te.src=URL.createObjectURL(a)}),{file_url:w}=await I.integrations.Core.UploadFile({file:a});d(K=>({...K,media_url:w,vid_source:"upload",vid_file_name:a.name,vid_file_size:`${(a.size/1048576).toFixed(1)}MB`,vid_dur:x.dur?`${x.dur} שנ׳`:"",vid_res:x.w?`${x.w}×${x.h}`:""}))}catch(x){y.error((x==null?void 0:x.message)||"שגיאה בהעלאה")}finally{ft(!1),t.target.value=""}}},[jt,vt]=p.useState(!1),Xa=async t=>{var n;const a=(n=t.target.files)==null?void 0:n[0];if(a){if(a.size>Z*1024*1024){y.error(`הקובץ גדול מדי (עד ${Z}MB)`),t.target.value="";return}vt(!0);try{const{file_url:x}=await I.integrations.Core.UploadFile({file:a});d(w=>({...w,vid2_media_url:x,vid2_source:"upload"}))}catch(x){y.error((x==null?void 0:x.message)||"שגיאה בהעלאה")}finally{vt(!1),t.target.value=""}}},[He,yt]=p.useState(-1),Ne=(t,a)=>d(n=>({...n,bn_banners:n.bn_banners.map((x,w)=>w===t?{...x,...a}:x)})),Nt=(t,a)=>d(n=>{const x=[...n.bn_banners],w=t+a;return w<0||w>=x.length?n:([x[t],x[w]]=[x[w],x[t]],{...n,bn_banners:x})}),Ja=t=>d(a=>{let n=a.bn_banners.slice();if(n.length>t){if(typeof window<"u"&&!window.confirm(`הפחתת הכמות תסיר ${n.length-t} באנרים. להמשיך?`))return a;n=n.slice(0,t)}return{...a,bn_count:t,bn_banners:n}}),er=async(t,a)=>{var x;const n=(x=a.target.files)==null?void 0:x[0];if(n){if(n.size>Z*1024*1024){y.error(`הקובץ גדול מדי (עד ${Z}MB)`),a.target.value="";return}yt(t);try{const{file_url:w}=await I.integrations.Core.UploadFile({file:n});Ne(t,{image:w})}catch(w){y.error((w==null?void 0:w.message)||"שגיאה")}finally{yt(-1),a.target.value=""}}};p.useEffect(()=>{W&&d(t=>{if(t.bn_banners.length>=t.bn_count)return t;const a=t.bn_banners.slice();for(;a.length<t.bn_count;)a.push({image:"",title:"",text:"",label:"",active:!0});return{...t,bn_banners:a}})},[W,s.bn_count]);const[We,wt]=p.useState(-1),Te=(t,a)=>d(n=>({...n,ti_images:n.ti_images.map((x,w)=>w===t?{...x,...a}:x)})),tr=t=>d(a=>({...a,ti_images:a.ti_images.filter((n,x)=>x!==t)})),sr=()=>d(t=>t.ti_images.length>=3?t:{...t,ti_images:[...t.ti_images,{image:"",title:"",text:"",focus:"center"}]}),kt=(t,a)=>d(n=>{const x=[...n.ti_images],w=t+a;return w<0||w>=x.length?n:([x[t],x[w]]=[x[w],x[t]],{...n,ti_images:x})}),ar=async(t,a)=>{var x;const n=(x=a.target.files)==null?void 0:x[0];if(n){if(n.size>Z*1024*1024){y.error(`הקובץ גדול מדי (עד ${Z}MB)`),a.target.value="";return}wt(t);try{const{file_url:w}=await I.integrations.Core.UploadFile({file:n});Te(t,{image:w})}catch(w){y.error((w==null?void 0:w.message)||"שגיאה")}finally{wt(-1),a.target.value=""}}},rr=()=>d(t=>t.cards.length>=12?t:{...t,cards:[...t.cards,{title:"",text:"",image:""}]}),Ke=(t,a)=>d(n=>({...n,cards:n.cards.map((x,w)=>w===t?{...x,...a}:x)})),lr=t=>d(a=>({...a,cards:a.cards.filter((n,x)=>x!==t)})),nr=async(t,a)=>{var x;const n=(x=a.target.files)==null?void 0:x[0];if(n){if(n.size>Z*1024*1024){y.error(`הקובץ גדול מדי (עד ${Z}MB)`),a.target.value="";return}pt(t);try{const{file_url:w}=await I.integrations.Core.UploadFile({file:n});Ke(t,{image:w})}catch(w){y.error((w==null?void 0:w.message)||"שגיאה בהעלאה")}finally{pt(-1),a.target.value=""}}},or=async t=>{var n;const a=(n=t.target.files)==null?void 0:n[0];if(a){if(s.side_banners.length>=3){y.error("עד 3 באנרים");return}if(a.size>Z*1024*1024){y.error(`הקובץ גדול מדי (עד ${Z}MB)`);return}ht(!0);try{const{file_url:x}=await I.integrations.Core.UploadFile({file:a});d(w=>({...w,side_banners:[...w.side_banners,x]}))}catch(x){y.error((x==null?void 0:x.message)||"שגיאה בהעלאה")}finally{ht(!1)}}},Ct=()=>l.type==="text"||J||W||V||N||U||j||P||D||l.type==="module"&&Ie[l.
22source_module]?s.body||void 0:E&&s.body||void 0,St=()=>Q?s.multi&&Array.isArray(s.multi.regions)?s.multi:{layout:"",regions:[]}:B?{headline:s.dp_headline||void 0,subtext:s.dp_subtext||void 0,all_categories:s.dp_all_cats,category_ids:s.dp_all_cats?[]:s.dp_cats,source:s.dp_source,page_ids:s.dp_source==="manual"?s.dp_page_ids:[],page_id:s.dp_source==="page"&&s.dp_page_id||void 0,order:s.dp_order,per_row:Number(s.dp_per_row)||4,footer_style:s.dp_footer,show_qr:s.dp_show_qr,new_days:Number(s.dp_new_days)||0,fields:s.dp_fields,autoplay:s.dp_autoplay,group_seconds:Number(s.dp_group_seconds)||9,transition:s.dp_transition,show_dots:s.dp_dots,reduce_motion:s.dp_reduce}:l.type==="module"?{item_count:Number(s.item_count)||5,...Ie[l.source_module]?{view:s.mod_view}:{},...q?{side_banners:s.side_banners}:{}}:J?{source:s.vid_source,aspect:s.vid_aspect,fit:s.vid_fit,duration_mode:s.vid_duration_mode,clip_seconds:s.vid_duration_mode==="clip"?Number(s.vid_clip)||null:void 0,start_at:Number(s.vid_start)||0,stop_at:s.vid_stop!==""?Number(s.vid_stop):void 0,autoplay:s.vid_autoplay,mute:s.vid_mute,loop:s.vid_loop,show_title:s.vid_show_title,show_description:s.vid_show_desc,youtube_url:s.vid_source==="youtube"&&s.vid_youtube_url||void 0,youtube_id:s.vid_source==="youtube"&&s.vid_youtube_id||void 0,file_name:s.vid_file_name||void 0,file_size:s.vid_file_size||void 0,video_duration:s.vid_dur||void 0,resolution:s.vid_res||void 0,view:s.vid_view,bg:s.vid_bg,text_speed:Number(s.vid_text_speed)||45,layout:s.vid_layout,video2:s.vid_view==="two"?{source:s.vid2_source,media_url:s.vid2_source==="upload"&&s.vid2_media_url||void 0,youtube_url:s.vid2_source==="youtube"&&s.vid2_youtube_url||void 0,youtube_id:s.vid2_source==="youtube"&&s.vid2_youtube_id||void 0}:void 0}:W?{layout:s.bn_layout,count:s.bn_count,banners:s.bn_banners,text_position:s.bn_text_pos,show_title:s.bn_show_title,show_desc:s.bn_show_desc,show_banner_titles:s.bn_show_btitles,show_banner_descs:s.bn_show_bdescs,rounded:s.bn_rounded,overlay:s.bn_overlay,transition_ms:s.bn_transition_ms,autoplay:s.bn_autoplay,loop:s.bn_loop}:G?{images:s.ti_images.filter(t=>t.image),type_speed_title:Number(s.ti_speed_title)||55,type_speed_desc:Number(s.ti_speed_desc)||26,hold:Number(s.ti_hold)||0,img_transition:s.ti_transition,countdown:s.ti_countdown,text_position:s.ti_text_pos,text_color:s.ti_text_color,title_size:s.ti_title_size,desc_size:s.ti_desc_size,hide_desc:s.ti_hide_desc,overlay:s.ti_overlay}:V?{cards:s.cards.filter(t=>t.title||t.text||t.image)}:U?{view:s.pa_view,selected_keys:s.pa_view==="detailed"?s.pa_keys:[]}:j?{view:s.sh_view,ad_type:s.sh_ad_type,recency_days:s.sh_recency,count:s.sh_count,category_ids:s.sh_cats,show_qr:s.sh_show_qr,fields:s.sh_fields}:P?{view:s.pub_view,count:s.pub_count,only_featured:s.pub_only_featured,show_qr_order:s.pub_qr_order,show_qr_card:s.pub_qr_card}:D?{view:s.wx_view,fields:s.wx_fields,highlight_weekend:s.wx_weekend,night_mode:s.wx_night,alerts:s.wx_alerts,place_label:s.wx_place||void 0,override_lat:s.wx_lat!==""?Number(s.wx_lat):void 0,override_lng:s.wx_lng!==""?Number(s.wx_lng):void 0}:E?{prayers:(s.sy_prayers||[]).filter(t=>t&&(t.label||t.time)).map(t=>({label:t.label||"",time:t.time||"",note:t.note||""})),show_zmanim:s.sy_show_zmanim,zmanim_keys:s.sy_zmanim_keys,show_shabbat:s.sy_show_shabbat,show_hebrew_date:s.sy_show_hebrew_date,place_label:s.sy_place||void 0,override_lat:s.sy_lat!==""?Number(s.sy_lat):void 0,override_lng:s.sy_lng!==""?Number(s.sy_lng):void 0}:T?{content_id:s.cp_id||void 0}:void 0,ir=p.useMemo(()=>({type:l.type,source_module:l.source_module||void 0,title:s.title||l.label,body:Ct(),media_url:s.media_url||void 0,duration_seconds:Number(s.duration_seconds)||25,config:St()}),[s,l]),dr=async()=>{var t,a;if(Q){if(!((t=s.multi)!=null&&t.layout)){y.error("יש לבחור פריסת מסך");return}if(!(Array.isArray(s.multi.regions)?s.multi.regions:[]).some(x=>Array.isArray(x.items)&&x.items.some(w=>w&&w.source))){y.error("יש להגדיר תוכן לפחות באזור אחד");return}}if(V&&!s.cards.some(n=>n.title||n.text||n.image)){y.error("הוסיפו לפחות כרטסיה אחת");return}if(J){if(!((a=s.title)!=null&&a.trim())){y.error("יש להזין כותרת");return}const n=(x,w,K)=>x==="upload"?!!w:!!K;if(!n(s.vid_source,s.media_url,s.vid_youtube_id)){y.error("יש להעלות סרטון או להזין קישור YouTube תקין");return}if(s.vid_view==="two"&&!n(s.vid2_source,s.vid2_media_url,s.vid2_youtube_id)){y.error("בתצוגת שני סרטונים יש להגדיר גם את הסרטון השני");return}}if(W){const n=s.bn_banners.filter(x=>x.active!==!1);if(!n.length){y.error("יש להוסיף לפחות באנר פעיל אחד");return}if(n.some(x=>!x.image)){y.error("לכל באנר פעיל יש להוסיף תמונה");return}}if(G){const n=s.ti_images.filter(x=>x.image);if(!n.length){y.error("יש להעלות לפחות תמונת נושא אחת");return}if(n.some(x=>!x.title)){y.error("לכל תמונת נושא יש להזין כותרת");return}}if(B){if(s.dp_source==="page"){if(!s.dp_page_id){y.error("יש לבחור עמוד קטגוריה לתצוגה");return}const n=oe.find(w=>w.id===s.dp_page_id);if(!(n&&Array.isArray(n.pdf_files)?n.pdf_files.filter(w=>w&&w.url).length:0)&&!(n!=null&&n.cover_image)){y.error("לעמוד שנבחר אין תמונות או קבצים להצגה");return}}else{if(!s.dp_all_cats&&s.dp_cats.length===0){y.error("יש לבחור לפחות קטגוריה אחת לתצוגה");return}if(z.length===0){y.error("אין עלונים פעילים בקטגוריה שנבחרה");return}if(s.dp_source==="manual"&&s.dp_page_ids.length===0){y.error("בבחירה ידנית יש לסמן לפחות עלון אחד");return}}if(!Number(s.dp_group_seconds)||Number(s.dp_group_seconds)<3){y.error("זמן הצגת הקבוצה אינו תקין");return}}if(T&&!s.cp_id){y.error("בחרו עמוד תוכן מהספרייה");return}gt(!0);try{const n=St();D&&n&&A&&(A.lat!=null&&s.wx_lat!==""&&Number(s.wx_lat)===Number(A.lat)&&(n.override_lat=void 0),A.lng!=null&&s.wx_lng!==""&&Number(s.wx_lng)===Number(A.lng)&&(n.override_lng=void 0)),E&&n&&A&&(A.lat!=null&&s.sy_lat!==""&&Number(s.sy_lat)===Number(A.lat)&&(n.override_lat=void 0),A.lng!=null&&s.sy_lng!==""&&Number(s.sy_lng)===Number(A.lng)&&(n.override_lng=void 0));const x={title:s.title||l.label,body:Ct(),media_url:s.media_url||void 0,duration_seconds:Number(s.duration_seconds)||25,config:n};g?await I.entities.DigitalScreenItem.update(r.id,{...x,updated_date:new Date().toISOString()}):await I.entities.DigitalScreenItem.create({kibbutz_id:i,channel_id:o,type:l.type,source_module:l.source_module||void 0,...x,order_index:f,status:"active",transition_type:"fade"}),y.success(g?"התוכן עודכן":"התוכן נוסף"),c()}catch(n){console.error(n),y.error("שגיאה")}finally{gt(!1)}};return e.jsxs("div",{className:"bg-white rounded-2xl border border-cyan-200 shadow-sm p-5",dir:"rtl",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[e.jsx("span",{className:`w-9 h-9 rounded-lg flex items-center justify-center ${l.color}`,children:e.jsx(l.icon,{className:"w-5 h-5"})}),e.jsxs("h3",{className:"text-sm font-bold",children:[g?"עריכת":"הוספת"," ",l.label]})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:W?"כותרת המסך":J?"כותרת (שם פנימי)":G?"כותרת פנימית למסך":V?"כותרת ראשית":"כותרת"}),e.jsx("input",{className:M,value:s.title,onChange:t=>d(a=>({...a,title:t.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"משך הצגה (שניות)"}),e.jsx("input",{type:"number",min:"3",className:M,value:s.duration_seconds,onChange:t=>d(a=>({...a,duration_seconds:t.target.value}))})]}),l.type==="text"&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"טקסט"}),e.jsx(ce,{rows:3,className:"rounded-xl resize-none",value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}),Q&&e.jsx("div",{className:"md:col-span-2 mt-1",children:e.jsx(Nl,{value:s.multi,onChange:t=>d(a=>({...a,multi:t})),kibbutzId:i})}),J&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"תיאור שיווקי (יוצג בהקלדה לצד הסרטון)"}),e.jsx(ce,{rows:2,className:"rounded-xl resize-none",value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"בחירת תצוגה"}),e.jsx("div",{className:"flex gap-2",children:[["single","סרטון אחד"],["two","שני סרטונים"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,vid_view:t})),className:`flex-1 h-11 rounded-xl border text-sm font-bold ${s.vid_view===t?"bg-red-600 text-white border-transparent":"bg-white border-slate-200 text-slate-600 hover:border-red-300"}`,children:a},t))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:s.vid_view==="two"?"הסרטון הראשי (מסגרת מחשב)":"מסגרת ההצגה"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:[["16:9","מסך מחשב — לרוחב","טלוויזיה ומסכים רחבים"],["9:16","מסך נייד — לאורך","סרטונים אנכיים"]].map(([t,a,n])=>e.jsxs("button",{type:"button",onClick:()=>d(x=>({...x,vid_aspect:t})),className:`rounded-xl border p-3 text-right transition-colors ${s.vid_aspect===t?"border-red-500 bg-red-50":"border-slate-200 hover:border-red-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`rounded bg-slate-300 ${t==="9:16"?"w-4 h-7":"w-7 h-4"}`}),e.jsx("span",{className:"text-sm font-bold text-slate-800",children:a})]}),e.jsxs("div",{className:"text-xs text-slate-500 mt-1",children:[n," · ",t]})]},t))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"מקור הסרטון"}),e.jsx("div",{className:"flex gap-2",children:[["upload","העלאת סרטון"],["youtube","קישור YouTube"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,vid_source:t})),className:`flex-1 h-10 rounded-xl border text-sm font-bold ${s.vid_source===t?"bg-red-600 text-white border-transparent":"bg-white border-slate-200 text-slate-600 hover:border-red-300"}`,children:a},t))})]}),s.vid_source==="upload"?e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:["קובץ וידאו (MP4 / WebM · עד ",Z,"MB)"]}),e.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[e.jsx("div",{className:"w-28 h-16 rounded-xl bg-slate-900 overflow-hidden flex items-center justify-center flex-shrink-0",children:s.media_url?e.jsx("video",{src:s.media_url,className:"w-full h-full object-cover",muted:!0,playsInl
22ine:!0,preload:"metadata"}):e.jsx(et,{className:"w-6 h-6 text-slate-500"})}),e.jsxs("label",{className:"inline-flex items-center gap-2 h-10 px-4 rounded-full border border-dashed border-slate-300 text-sm text-slate-600 hover:border-red-400 hover:bg-red-50 cursor-pointer",children:[e.jsx(fe,{className:"w-4 h-4"})," ",Ue?"מעלה…":s.media_url?"החלפת קובץ":"העלאת קובץ",e.jsx("input",{type:"file",accept:"video/mp4,video/webm",className:"hidden",onChange:Qa,disabled:Ue})]}),s.media_url&&e.jsxs("button",{type:"button",onClick:()=>d(t=>({...t,media_url:"",vid_file_name:"",vid_file_size:"",vid_dur:"",vid_res:""})),className:"h-10 px-3 rounded-full border border-rose-200 text-rose-600 text-sm hover:bg-rose-50 inline-flex items-center gap-1",children:[e.jsx(re,{className:"w-4 h-4"})," מחיקה"]})]}),s.media_url&&(s.vid_file_name||s.vid_dur)&&e.jsxs("div",{className:"flex flex-wrap gap-x-4 gap-y-1 mt-2 text-xs text-slate-500",children:[s.vid_file_name&&e.jsxs("span",{children:["קובץ: ",s.vid_file_name]}),s.vid_file_size&&e.jsxs("span",{children:["גודל: ",s.vid_file_size]}),s.vid_dur&&e.jsxs("span",{children:["אורך: ",s.vid_dur]}),s.vid_res&&e.jsxs("span",{children:["רזולוציה: ",s.vid_res]})]})]}):e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"קישור YouTube"}),e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{className:`${M} text-left`,dir:"ltr",placeholder:"https://youtu.be/…",value:s.vid_youtube_url,onChange:t=>d(a=>({...a,vid_youtube_url:t.target.value,vid_youtube_id:_t(t.target.value)}))}),e.jsx("span",{className:"inline-flex items-center px-3 rounded-xl border border-border text-xs whitespace-nowrap",style:{background:s.vid_youtube_id?"#ecfdf5":"#fef2f2",color:s.vid_youtube_id?"#059669":"#dc2626"},children:s.vid_youtube_id?"קישור תקין":"קישור לא תקין"})]}),s.vid_youtube_id&&e.jsx("div",{className:"mt-2 w-40 h-24 rounded-xl overflow-hidden bg-slate-100",children:e.jsx("img",{src:`https://i.ytimg.com/vi/${s.vid_youtube_id}/hqdefault.jpg`,alt:"",className:"w-full h-full object-cover"})})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"התאמת הסרטון למסך"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[["contain","התאמה מלאה"],["fill","מילוי המסך"],["crop","חיתוך למילוי"],["blur","רקע מטושטש"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,vid_fit:t})),className:`rounded-xl border px-4 py-2 text-sm font-bold ${s.vid_fit===t?"border-red-500 bg-red-50 text-red-700":"border-slate-200 text-slate-600 hover:border-red-300"}`,children:a},t))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"משך ההצגה של הסרטון"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[["full","הסרטון המלא"],["clip","עצירה אחרי X שניות"],["loop","חזרה עד סיום המסך"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,vid_duration_mode:t})),className:`rounded-xl border px-4 py-2 text-sm font-bold ${s.vid_duration_mode===t?"border-red-500 bg-red-50 text-red-700":"border-slate-200 text-slate-600 hover:border-red-300"}`,children:a},t))})]}),s.vid_duration_mode==="clip"&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"עצירה אחרי (שניות)"}),e.jsx("input",{type:"number",min:"1",className:M,value:s.vid_clip,onChange:t=>d(a=>({...a,vid_clip:t.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"התחלה מנקודה (שניות)"}),e.jsx("input",{type:"number",min:"0",className:M,value:s.vid_start,onChange:t=>d(a=>({...a,vid_start:t.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"עצירה בנקודה (ריק = עד הסוף)"}),e.jsx("input",{type:"number",min:"0",className:M,value:s.vid_stop,onChange:t=>d(a=>({...a,vid_stop:t.target.value}))})]}),e.jsx("div",{className:"md:col-span-2 flex flex-wrap gap-4",children:[["vid_autoplay","הפעלה אוטומטית"],["vid_mute","השתקת קול"],["vid_loop","חזרה בלולאה"]].map(([t,a])=>e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!s[t],onChange:n=>d(x=>({...x,[t]:n.target.checked})),className:"w-4 h-4"})," ",a]},t))}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"רקע דינמי"}),e.jsxs("select",{className:M,value:s.vid_bg,onChange:t=>d(a=>({...a,vid_bg:t.target.value})),children:[e.jsx("option",{value:"gradient",children:"גרדיאנט צבעוני נע"}),e.jsx("option",{value:"dark",children:"כהה יוקרתי"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"מהירות הקלדת הטקסט (ms לתו)"}),e.jsx("input",{type:"number",min:"15",max:"120",className:M,value:s.vid_text_speed,onChange:t=>d(a=>({...a,vid_text_speed:t.target.value}))})]}),s.vid_view==="two"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"פריסת המסכים"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[["laptop_left","מחשב משמאל · טלפון מימין"],["phone_left","טלפון משמאל · מחשב מימין"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,vid_layout:t})),className:`rounded-xl border px-4 py-2 text-sm font-bold ${s.vid_layout===t?"border-red-500 bg-red-50 text-red-700":"border-slate-200 text-slate-600 hover:border-red-300"}`,children:a},t))})]}),e.jsxs("div",{className:"md:col-span-2 rounded-xl border border-slate-200 p-3 space-y-2",children:[e.jsx("div",{className:"text-sm font-bold text-slate-700",children:"הסרטון השני (מסגרת טלפון · אנכי)"}),e.jsx("div",{className:"flex gap-2",children:[["upload","העלאה"],["y
22outube","YouTube"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,vid2_source:t})),className:`flex-1 h-9 rounded-lg border text-sm font-bold ${s.vid2_source===t?"bg-red-600 text-white border-transparent":"bg-white border-slate-200 text-slate-600"}`,children:a},t))}),s.vid2_source==="upload"?e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-24 h-14 rounded-lg bg-slate-900 overflow-hidden flex items-center justify-center flex-shrink-0",children:s.vid2_media_url?e.jsx("video",{src:s.vid2_media_url,className:"w-full h-full object-cover",muted:!0,playsInline:!0,preload:"metadata"}):e.jsx(et,{className:"w-5 h-5 text-slate-500"})}),e.jsxs("label",{className:"inline-flex items-center gap-2 h-9 px-4 rounded-full border border-dashed border-slate-300 text-sm text-slate-600 hover:border-red-400 hover:bg-red-50 cursor-pointer",children:[e.jsx(fe,{className:"w-4 h-4"})," ",jt?"מעלה…":s.vid2_media_url?"החלפה":"העלאה",e.jsx("input",{type:"file",accept:"video/mp4,video/webm",className:"hidden",onChange:Xa,disabled:jt})]})]}):e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("input",{className:`${M} text-left`,dir:"ltr",placeholder:"https://youtu.be/…",value:s.vid2_youtube_url,onChange:t=>d(a=>({...a,vid2_youtube_url:t.target.value,vid2_youtube_id:_t(t.target.value)}))}),e.jsx("span",{className:"inline-flex items-center px-3 rounded-xl border border-border text-xs whitespace-nowrap",style:{background:s.vid2_youtube_id?"#ecfdf5":"#fef2f2",color:s.vid2_youtube_id?"#059669":"#dc2626"},children:s.vid2_youtube_id?"תקין":"לא תקין"})]})]})]})]}),W&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"תיאור כללי (אופציונלי)"}),e.jsx("input",{className:M,value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"מבנה תצוגה"}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-2",children:[["featured","באנר מרכזי גדול","ראשי גדול + קטנים"],["grid","רשת אחידה","כל הבאנרים בגודל זהה"],["magazine","גדלים משתנים","סגנון מגזין"],["carousel","קרוסלת באנרים","מעבר בין קבוצות"]].map(([t,a,n])=>e.jsxs("button",{type:"button",onClick:()=>d(x=>({...x,bn_layout:t})),className:`rounded-xl border p-3 text-right transition-colors ${s.bn_layout===t?"border-emerald-500 bg-emerald-50":"border-slate-200 hover:border-emerald-300"}`,children:[e.jsx("div",{className:"text-sm font-bold text-slate-800",children:a}),e.jsx("div",{className:"text-xs text-slate-500 mt-0.5",children:n})]},t))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"כמות באנרים"}),e.jsx("div",{className:"flex gap-2",children:[5,8,12].map(t=>e.jsxs("button",{type:"button",onClick:()=>Ja(t),className:`h-10 px-5 rounded-xl border text-sm font-bold ${s.bn_count===t?"bg-emerald-600 text-white border-transparent":"bg-white border-slate-200 text-slate-600 hover:border-emerald-300"}`,children:[t," באנרים"]},t))})]}),e.jsxs("div",{className:"md:col-span-2 space-y-2",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"ניהול הבאנרים"}),s.bn_banners.map((t,a)=>e.jsxs("div",{className:`flex items-start gap-3 rounded-xl border p-3 ${t.active===!1?"border-slate-200 bg-slate-50 opacity-70":"border-emerald-100 bg-emerald-50/40"}`,children:[e.jsxs("div",{className:"flex flex-col flex-shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>Nt(a,-1),disabled:a===0,className:"w-6 h-5 flex items-center justify-center text-slate-400 hover:text-slate-700 disabled:opacity-30",children:e.jsx(Xe,{className:"w-4 h-4"})}),e.jsx("button",{type:"button",onClick:()=>Nt(a,1),disabled:a===s.bn_banners.length-1,className:"w-6 h-5 flex items-center justify-center text-slate-400 hover:text-slate-700 disabled:opacity-30",children:e.jsx(at,{className:"w-4 h-4"})})]}),e.jsxs("label",{className:"w-24 h-16 rounded-lg bg-white border border-dashed border-slate-300 overflow-hidden flex items-center justify-center flex-shrink-0 cursor-pointer hover:border-emerald-400",children:[t.image?e.jsx("img",{src:t.image,alt:"",className:"w-full h-full object-cover"}):He===a?e.jsx("span",{className:"text-xs text-slate-400",children:"מעלה…"}):e.jsx(we,{className:"w-6 h-6 text-slate-300"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:n=>er(a,n),disabled:He===a})]}),e.jsxs("div",{className:"flex-1 space-y-2 min-w-0",children:[e.jsx("input",{className:M,maxLength:60,placeholder:`כותרת באנר ${a+1}`,value:t.title,onChange:n=>Ne(a,{title:n.target.value})}),e.jsx("input",{className:M,maxLength:90,placeholder:"תיאור קצר",value:t.text,onChange:n=>Ne(a,{text:n.target.value})}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsxs("select",{className:"h-9 rounded-lg border border-border px-2 text-xs",value:t.label||"",onChange:n=>Ne(a,{label:n.target.value}),children:[e.jsx("option",{value:"",children:"ללא תווית"}),["חדש","חשוב","היום","השבוע","אירוע קרוב"].map(n=>e.jsx("option",{value:n,children:n},n))]}),e.jsxs("label",{className:"flex items-center gap-1.5 text-xs cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:t.active!==!1,onChange:n=>Ne(a,{active:n.target.checked}),className:"w-4 h-4"})," פעיל"]})]})]})]},a))]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"מיקום הטקסט על הבאנר"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[["br","ימין למטה"],["tr","ימין למעלה"],["center","מרכז"],["bl","שמאל למטה"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,bn_text_pos:t})),className:`rounded-full border px-4 py-1.5 text-sm font-bold ${s.bn_text_pos===t?"border-emerald-500 bg-emerald-50 text-emerald-700":"border-slate-200 text-slate-600"}`,children:a},t))})]}),e.jsx("div",{className:"md:col-span-2 flex flex-wrap gap-4",children:[["bn_show_title","כותרת המסך"],["bn_show_desc","תיאור כללי"],["bn_show_btitles","כותרות באנרים"],["bn_show_bdescs","תיאורי באנרים"],["bn_rounded","פינות מעוגלות"]].map(([t,a])=>e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!s[t],onChange:n=>d(x=>({...x,[t]:n.target.checked})),className:"w-4 h-4"})," ",a]},t))})]}),G&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"md:col-span-2 rounded-xl bg-blue-50 border border-blue-100 px-3 py-2 text-xs text-blue-800",children:"עד שלושה נושאים מתחלפים. לכל נושא: תמונת רקע, כותרת ותיאור — עם אנימציית הקלדה וספירה לאחור 3·2·1."}),e.jsxs("div",{className:"md:col-span-2 space-y-2",children:[s.ti_images.map((t,a)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-blue-100 bg-blue-50/40 p-3",children:[e.jsxs("div",{className:"flex flex-col flex-shrink-0",children:[e.jsx("button",{type:"button",onClick:()=>kt(a,-1),disabled:a===0,className:"w-6 h-5 flex items-center justify-center text-slate-400 hover:text-slate-700 disabled:opacity-30",children:e.jsx(Xe,{className:"w-4 h-4"})}),e.jsx("button",{type:"button",onClick:()=>kt(a,1),disabled:a===s.ti_images.length-1,className:"w-6 h-5 flex items-center justify-center text-slate-400 hover:text-slate-700 disabled:opacity-30",children:e.jsx(at,{className:"w-4 h-4"})})]}),e.jsxs("label",{className:"w-28 h-20 rounded-lg bg-white border border-dashed border-slate-300 overflow-hidden flex items-center justify-center flex-shrink-0 cursor-pointer hover:border-blue-400",children:[t.image?e.jsx("img",{src:t.image,alt:"",className:"w-full h-full object-cover"}):We===a?e.jsx("span",{className:"text-xs text-slate-400",children:"מעלה…"}):e.jsx(we,{className:"w-6 h-6 text-slate-300"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:n=>ar(a,n),disabled:We===a})]}),e.jsxs("div",{className:"flex-1 space-y-2 min-w-0",children:[e.jsx("input",{className:M,placeholder:`כותרת נושא ${a+1}`,value:t.title,onChange:n=>Te(a,{title:n.target.value})}),e.jsx("input",{className:M,placeholder:"תיאור קצר",value:t.text,onChange:n=>Te(a,{text:n.target.value})}),e.jsx("select",{className:"h-9 rounded-lg border border-border px-2 text-xs",value:t.focus||"center",onChange:n=>Te(a,{focus:n.target.value}),children:[["center","מיקוד: מרכז"],["top","מיקוד: למעלה"],["bottom","מיקוד: למטה"],["right","מיקוד: ימין"],["left","מיקוד: שמאל"]].map(([n,x])=>e.jsx("option",{value:n,children:x},n))})]}),e.jsx("button",{type:"button",onClick:()=>tr(a),className:"w-8 h-8 rounded-lg text-rose-500 hover:bg-rose-50 flex items-center justify-center flex-shrink-0",children:e.jsx(re,{className:"w-4 h-4"})})]},a)),s.ti_images.length<3&&e.jsxs("button",{type:"button",onClick:sr,className:"inline-flex items-center gap-1 h-9 px-4 roun
22ded-full bg-blue-600 text-white text-xs font-bold hover:bg-blue-700",children:[e.jsx(se,{className:"w-3.5 h-3.5"})," הוספת נושא נוסף"]}),!s.ti_images.length&&e.jsx("p",{className:"text-xs text-slate-400 text-center py-4 border border-dashed border-slate-200 rounded-xl",children:"אין נושאים עדיין — הוסיפו נושא ראשון"})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"מיקום הטקסט"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[["tr","ימין למעלה"],["cr","ימין במרכז"],["br","ימין למטה"],["center","מרכז המסך"],["cl","שמאל במרכז"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,ti_text_pos:t})),className:`rounded-full border px-4 py-1.5 text-sm font-bold ${s.ti_text_pos===t?"border-blue-500 bg-blue-50 text-blue-700":"border-slate-200 text-slate-600"}`,children:a},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"מעבר בין תמונות"}),e.jsxs("select",{className:M,value:s.ti_transition,onChange:t=>d(a=>({...a,ti_transition:t.target.value})),children:[e.jsx("option",{value:"zoom",children:"זום עדין"}),e.jsx("option",{value:"fade",children:"דהייה"}),e.jsx("option",{value:"slide",children:"החלקה"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"גודל כותרת"}),e.jsxs("select",{className:M,value:s.ti_title_size,onChange:t=>d(a=>({...a,ti_title_size:t.target.value})),children:[e.jsx("option",{value:"sm",children:"קטן"}),e.jsx("option",{value:"lg",children:"בינוני"}),e.jsx("option",{value:"xl",children:"גדול"})]})]}),e.jsxs("div",{className:"md:col-span-2 flex flex-wrap gap-4 items-center",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.ti_countdown,onChange:t=>d(a=>({...a,ti_countdown:t.target.checked})),className:"w-4 h-4"})," ספירה לאחור 3·2·1"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.ti_hide_desc,onChange:t=>d(a=>({...a,ti_hide_desc:t.target.checked})),className:"w-4 h-4"})," הסתרת תיאור"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm",children:["צבע טקסט ",e.jsx("input",{type:"color",value:s.ti_text_color,onChange:t=>d(a=>({...a,ti_text_color:t.target.value})),className:"w-9 h-8 rounded border border-border cursor-pointer"})]})]})]}),V&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"תיאור ראשי"}),e.jsx(ce,{rows:2,className:"rounded-xl resize-none",value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}),V&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:"כרטסיות (כותרת · תיאור · תמונה)"}),e.jsxs("button",{type:"button",onClick:rr,disabled:s.cards.length>=12,className:"inline-flex items-center gap-1 h-8 px-3 rounded-full bg-cyan-600 text-white text-xs font-bold hover:bg-cyan-700 disabled:opacity-50",children:[e.jsx(se,{className:"w-3.5 h-3.5"})," הוסף כרטסיה"]})]}),e.jsxs("div",{className:"space-y-2",children:[s.cards.map((t,a)=>e.jsxs("div",{className:"flex items-start gap-3 rounded-xl border border-slate-200 p-3 bg-slate-50/60",children:[e.jsxs("label",{className:"w-20 h-20 rounded-lg bg-white border border-dashed border-slate-300 overflow-hidden flex items-center justify-center flex-shrink-0 cursor-pointer hover:border-cyan-400",children:[t.image?e.jsx("img",{src:t.image,alt:"",className:"w-full h-full object-cover"}):bt===a?e.jsx("span",{className:"text-xs text-slate-400",children:"מעלה…"}):e.jsx(we,{className:"w-6 h-6 text-slate-300"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:n=>nr(a,n),disabled:bt===a})]}),e.jsxs("div",{className:"flex-1 space-y-2 min-w-0",children:[e.jsx("input",{className:M,placeholder:"כותרת הכרטסיה",value:t.title,onChange:n=>Ke(a,{title:n.target.value})}),e.jsx(ce,{rows:2,className:"rounded-xl resize-none",placeholder:"תיאור קצר",value:t.text,onChange:n=>Ke(a,{text:n.target.value})})]}),e.jsx("button",{type:"button",onClick:()=>lr(a),className:"w-8 h-8 rounded-lg text-rose-500 hover:bg-rose-50 flex items-center justify-center flex-shrink-0",children:e.jsx(re,{className:"w-4 h-4"})})]},a)),!s.cards.length&&e.jsx("p",{className:"text-xs text-slate-400 text-center py-4 border border-dashed border-slate-200 rounded-xl",children:'אין כרטסיות עדיין — לחצו "הוסף כרטסיה"'})]})]}),N&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"תיאור / כותרת משנה"}),e.jsx("input",{className:M,placeholder:"החוגגים החודש",value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}
22),l.type==="module"&&Ie[l.source_module]&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"כותרת שיווקית / תיאור קצר (אופציונלי)"}),e.jsx("input",{className:M,value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"בחירת תצוגה"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:Ie[l.source_module].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,mod_view:t})),className:`rounded-xl border px-4 py-2.5 text-sm font-bold transition-colors ${s.mod_view===t?"border-cyan-500 bg-cyan-50 text-cyan-700":"border-slate-200 text-slate-600 hover:border-cyan-300"}`,children:a},t))})]})]}),l.type==="module"&&!B&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"מספר פריטים להצגה"}),e.jsx("input",{type:"number",min:"1",max:"40",className:M,value:s.item_count,onChange:t=>d(a=>({...a,item_count:t.target.value}))})]}),B&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"כותרת שיווקית (אופציונלי)"}),e.jsx("input",{className:M,placeholder:"כל מה שקורה בקהילה, במקום אחד",value:s.dp_headline,onChange:t=>d(a=>({...a,dp_headline:t.target.value}))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"תיאור קצר (אופציונלי)"}),e.jsx("input",{className:M,value:s.dp_subtext,onChange:t=>d(a=>({...a,dp_subtext:t.target.value}))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:["בחירת קטגוריה לתצוגה ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{type:"button",onClick:()=>d(t=>({...t,dp_all_cats:!0,dp_cats:[]})),className:`h-9 px-4 rounded-full text-sm font-bold border transition-colors ${s.dp_all_cats?"bg-cyan-600 text-white border-transparent":"bg-white border-slate-200 text-slate-600 hover:border-cyan-300"}`,children:"כל הקטגוריות"}),ne.map(t=>{const a=!s.dp_all_cats&&s.dp_cats.includes(t.id),n=oe.filter(x=>x.category_id===t.id).length;return e.jsxs("button",{type:"button",onClick:()=>d(x=>({...x,dp_all_cats:!1,dp_cats:x.dp_cats.includes(t.id)?x.dp_cats.filter(w=>w!==t.id):[...x.dp_cats,t.id]})),className:`h-9 px-4 rounded-full text-sm font-medium border transition-colors flex items-center gap-1.5 ${a?"bg-cyan-600 text-white border-transparent":"bg-white border-slate-200 text-slate-600 hover:border-cyan-300"}`,children:[t.title,e.jsx("span",{className:"opacity-70 text-xs",children:n})]},t.id)}),ne.length===0&&e.jsx("span",{className:"text-xs text-amber-600",children:"לא נמצאו קטגוריות פעילות במודול העלונים"})]}),e.jsxs("p",{className:`text-xs mt-2 ${z.length?"text-emerald-600":"text-amber-600"}`,children:["נמצאו ",z.length," עלונים פעילים בקטגוריה"]})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"מקור העלונים לתצוגה"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[["all","כל העלונים בקטגוריה","מתעדכן אוטומטית"],["manual","בחירת עלונים ידנית","בוחרים אילו עלונים יוצגו"],["page","עמוד קטגוריה","כל הקבצים/התמונות בעמוד אחד"]].map(([t,a,n])=>e.jsxs("button",{type:"button",onClick:()=>d(x=>({...x,dp_source:t})),className:`rounded-xl border p-3 text-right transition-colors ${s.dp_source===t?"border-cyan-500 bg-cyan-50":"border-slate-200 hover:border-cyan-300"}`,children:[e.jsx("div",{className:"text-sm font-bold text-slate-800",children:a}),e.jsx("div",{className:"text-xs text-slate-500 mt-0.5",children:n})]},t))})]}),s.dp_source==="page"&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"עמוד הקטגוריה לתצוגה"}),e.jsxs("select",{className:M,value:s.dp_page_id,onChange:t=>d(a=>({...a,dp_page_id:t.target.value})),children:[e.jsx("option",{value:"",children:"בחרו עמוד…"}),oe.map(t=>{const a=Array.isArray(t.pdf_files)?t.pdf_files.filter(n=>n&&n.url).length:0;return e.jsxs("option",{value:t.id,children:[t.title||"ללא כותרת",a?` — ${a} עלונים`:t.cover_image?" — תמונה אחת":""]},t.id)})]}),s.dp_page_id&&(()=>{const t=oe.find(n=>n.id===s.dp_page_id),a=t&&Array.isArray(t.pdf_files)?t.pdf_files.filter(n=>n&&n.url).length:0;return e.jsx("p",{className:`text-xs mt-2 ${a||t!=null&&t.cover_image?"text-emerald-600":"text-amber-600"}`,children:a?`יוצגו ${a} עלונים מהעמוד — כל אחד עם פוטר וקוד QR`:t!=null&&t.cover_image?"לעמוד אין קבצים מצורפים — תוצג תמונת הכריכה":"לעמוד אין תמונות או קבצים להצגה"})})()]}),s.dp_source==="manual"&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2 gap-2",children:[e.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:["בחירת עלונים (",s.dp_page_ids.length," נבחרו)"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>d(t=>({...t,dp_page_ids:z.map(a=>a.id)})),className:"text-xs text-cyan-600 hover:underline",children:"בחר הכל"}),e.jsx("button",{type:"button",onClick:()=>d(t=>({...t,dp_page_ids:[]})),className:"text-xs text-slate-400 hover:underline",children:"בטל הכל"})]})]}),e.jsx("div",{className:"relative mb-2",children:e.jsx("input",{className:M,placeholder:"חיפוש עלון…",value:ve,onChange:t=>Re(t.target.value)})}),e.jsxs("div",{className:"max-h-72 overflow-y-auto rounded-xl border border-slate-100 bg-slate-50/50 divide-y divide-slate-100",children:[z.filter(t=>!ve.trim()||(t.title||"").toLowerCase().includes(ve.trim().toLowerCase())).map(t=>{const a=s.dp_page_ids.includes(t.id);return e.jsxs("label",{draggable:a,onDragStart:()=>ye(s.dp_page_ids.indexOf(t.id)),onDragOver:n=>{a&&n.preventDefault()},onDrop:()=>{!a||$e<0||(d(n=>{const x=[...n.dp_page_ids],w=x.indexOf(t.id),[K]=x.splice($e,1);return x.splice(w,0,K),{...n,dp_page_ids:x}}),ye(-1))},className:`flex items-center gap-3 px-3 py-2 cursor-pointer ${a?"bg-white":"hover:bg-white/70"}`,children:[e.jsx("input",{type:"checkbox",checked:a,onChange:()=>v(t.id),className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"w-10 h-12 rounded-md overflow-hidden bg-slate-200 flex-shrink-0 flex items-center justify-center",children:t.cover_image?e.jsx("img",{src:t.cover_image,alt:"",className:"w-full h-full object-cover"}):e.jsx(ge,{className:"w-4 h-4 text-slate-400"})}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block text-sm font-semibold text-slate-800 truncate",children:t.title||"ללא כותרת"}),e.jsxs("span",{className:"block text-xs text-slate-400 truncate",children:[he.get(t.category_id)||"",t.publish_date?` · ${new Date(t.publish_date).toLocaleDateString("he-IL")}`:""]})]}),a&&e.jsxs("span",{className:"text-[0.6875rem] font-bold text-cyan-600 flex-shrink-0",children:["#",s.dp_page_ids.indexOf(t.id)+1]})]},t.id)}),z.length===0&&e.jsx("div",{className:"text-center py-6 text-xs text-slate-400",children:"אין עלונים פעילים בקטגוריה שנבחרה"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"עלונים בשורה"}),e.jsx("div",{className:"flex gap-2",children:[3,4,5,6].map(t=>e.jsx("button",{type:"button",onClick:()=>d(a=>({...a,dp_per_row:t})),className:`flex-1 h-11 rounded-xl border text-sm font-bold ${s.dp_per_row===t?"bg-cyan-600 text-white border-transparent":"bg-white border-slate-200 text-slate-600 hover:border-cyan-300"}`,children:t},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"סדר העלונים"}),e.jsxs("select",{className:M,value:s.dp_order,onChange:t=>d(a=>({...a,dp_order:t.target.value})),children:[e.jsx("option",{value:"new",children:"מהחדש לישן"}),e.jsx("option",{value:"old",children:"מהישן לחדש"}),e.jsx("option",{value:"manual",children:"סדר ידני"}),e.jsx("option",{value:"random",children:"ערבוב אוטומטי"}),e.jsx("option",{value:"selected_first",children:"עלונים נבחרים תחילה"})]})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"עיצוב הפוטר"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[["light","בהיר"],["dark","כהה"],["brand","צבעי הקיבוץ"],["overlay","שקוף על התמונה"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,dp_footer:t}
22)),className:`h-9 px-4 rounded-full text-sm font-medium border transition-colors ${s.dp_footer===t?"border-cyan-500 bg-cyan-50 text-cyan-700":"border-slate-200 text-slate-600 hover:border-cyan-300"}`,children:ie(a,_)},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:'תווית "חדש"'}),e.jsxs("select",{className:M,value:s.dp_new_days,onChange:t=>d(a=>({...a,dp_new_days:Number(t.target.value)})),children:[e.jsx("option",{value:7,children:"עד 7 ימים"}),e.jsx("option",{value:14,children:"עד 14 ימים"}),e.jsx("option",{value:30,children:"עד 30 ימים"}),e.jsx("option",{value:0,children:"ללא תווית"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"זמן הצגת קבוצה (שניות)"}),e.jsx("input",{type:"number",min:"4",className:M,value:s.dp_group_seconds,onChange:t=>d(a=>({...a,dp_group_seconds:t.target.value}))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"תוכן להצגה בפוטר"}),e.jsx("div",{className:"flex flex-wrap gap-x-5 gap-y-2",children:[["title","כותרת"],["description","תיאור"],["date","תאריך"],["category","קטגוריה"],["page_count","מספר עמודים"],["new_label","תווית חדש"]].map(([t,a])=>e.jsxs("label",{className:"flex items-center gap-2 text-sm text-slate-600 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.dp_fields[t]!==!1,onChange:n=>L(t,n.target.checked),className:"w-4 h-4"})," ",a]},t))})]}),e.jsxs("div",{className:"md:col-span-2 grid grid-cols-1 sm:grid-cols-2 gap-2.5",children:[e.jsxs("label",{className:"flex items-center justify-between rounded-xl border border-slate-200 px-3 py-2.5 text-sm",children:[e.jsxs("span",{className:"flex items-center gap-2 text-slate-700",children:[e.jsx(Ha,{className:"w-4 h-4 text-slate-400"})," קוד QR לצפייה בעלון"]}),e.jsx(ae,{checked:s.dp_show_qr,onCheckedChange:t=>d(a=>({...a,dp_show_qr:t}))})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-xl border border-slate-200 px-3 py-2.5 text-sm",children:[e.jsx("span",{className:"text-slate-700",children:"מעבר אוטומטי בין קבוצות"}),e.jsx(ae,{checked:s.dp_autoplay,onCheckedChange:t=>d(a=>({...a,dp_autoplay:t}))})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-xl border border-slate-200 px-3 py-2.5 text-sm",children:[e.jsx("span",{className:"text-slate-700",children:"חיווי עמודים (נקודות)"}),e.jsx(ae,{checked:s.dp_dots,onCheckedChange:t=>d(a=>({...a,dp_dots:t}))})]}),e.jsxs("label",{className:"flex items-center justify-between rounded-xl border border-slate-200 px-3 py-2.5 text-sm",children:[e.jsx("span",{className:"text-slate-700",children:"הפחתת תנועה"}),e.jsx(ae,{checked:s.dp_reduce,onCheckedChange:t=>d(a=>({...a,dp_reduce:t}))})]})]})]}),U&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"כותרת שיווקית (תיאור קצר)"}),e.jsx("input",{className:M,placeholder:"כל השירותים של הקהילה במקום אחד",value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"בחירת תצוגה"}),e.jsx("div",{className:"flex gap-2",children:[["full","תצוגה מלאה","כל השירותים בקרוסלת 3 שורות"],["detailed","תצוגה מפורטת","שירותים נבחרים ככרטסיות"]].map(([t,a,n])=>e.jsxs("button",{type:"button",onClick:()=>d(x=>({...x,pa_view:t})),className:`flex-1 rounded-xl border p-3 text-right transition-colors ${s.pa_view===t?"border-cyan-500 bg-cyan-50":"border-slate-200 hover:border-cyan-300"}`,children:[e.jsx("div",{className:"text-sm font-bold text-slate-800",children:a}),e.jsx("div",{className:"text-xs text-slate-500 mt-0.5",children:n})]},t))})]}),s.pa_view==="detailed"&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:["שירותים שיוצגו (",s.pa_ke
22ys.length,")"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"button",onClick:()=>d(t=>({...t,pa_keys:Sa.map(a=>a.key)})),className:"text-xs text-cyan-600 hover:underline",children:"בחר הכל"}),e.jsx("button",{type:"button",onClick:()=>d(t=>({...t,pa_keys:[]})),className:"text-xs text-slate-400 hover:underline",children:"נקה"})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-1.5 max-h-56 overflow-y-auto p-1 rounded-xl border border-slate-100 bg-slate-50/50",children:Sa.map(t=>e.jsxs("label",{className:`flex items-center gap-2 rounded-lg px-2.5 py-2 text-sm cursor-pointer border ${s.pa_keys.includes(t.key)?"border-cyan-400 bg-white":"border-transparent hover:bg-white"}`,children:[e.jsx("input",{type:"checkbox",checked:s.pa_keys.includes(t.key),onChange:()=>X(t.key),className:"w-4 h-4 flex-shrink-0"}),e.jsx("span",{className:"w-6 h-6 rounded-md flex items-center justify-center flex-shrink-0",style:{backgroundColor:`${t.color}1a`,color:t.color},children:e.jsx(t.icon,{className:"w-3.5 h-3.5"})}),e.jsx("span",{className:"truncate",children:t.barTitle||t.title})]},t.key))}),s.pa_keys.length===0&&e.jsx("p",{className:"text-xs text-amber-600 mt-1.5",children:"לא נבחרו שירותים — יוצגו כל השירותים כברירת מחדל."})]})]}),j&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"כותרת שיווקית (תיאור קצר)"}),e.jsx("input",{className:M,placeholder:"מודעות חדשות למכירה ולמסירה מתושבי הקהילה",value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"בחירת תצוגה"}),e.jsx("div",{className:"flex gap-2",children:[["full","מסך מלא (מומלץ)"],["carousel","קרוסלת מודעות"],["central","מודעה מרכזית"],["by_category","חלוקה לקטגוריות"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,sh_view:t})),className:`flex-1 rounded-xl border px-3 py-2.5 text-sm font-bold transition-colors ${s.sh_view===t?"border-cyan-500 bg-cyan-50 text-cyan-700":"border-slate-200 text-slate-600 hover:border-cyan-300"}`,children:a},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"סוגי מודעות"}),e.jsxs("select",{className:M,value:s.sh_ad_type,onChange:t=>d(a=>({...a,sh_ad_type:t.target.value})),children:[e.jsx("option",{value:"all",children:"כל המודעות"}),e.jsx("option",{value:"sale",children:"למכירה בלבד"}),e.jsx("option",{value:"giveaway",children:"למסירה בלבד"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"עדכניות"}),e.jsxs("select",{className:M,value:s.sh_recency,onChange:t=>d(a=>({...a,sh_recency:Number(t.target.value)})),children:[e.jsx("option",{value:7,children:"7 הימים האחרונים"}),e.jsx("option",{value:14,children:"14 הימים האחרונים"}),e.jsx("option",{value:30,children:"30 הימים האחרונים"}),e.jsx("option",{value:0,children:"כל המודעות הפעילות"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"כמות מודעות"}),e.jsx("select",{className:M,value:s.sh_count,onChange:t=>d(a=>({...a,sh_count:Number(t.target.value)})),children:[6,12,18,24,40].map(t=>e.jsx("option",{value:t,children:t},t))})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer h-10",children:[e.jsx("input",{type:"checkbox",checked:s.sh_show_qr,onChange:t=>d(a=>({...a,sh_show_qr:t.target.checked})),className:"w-4 h-4"})," הצגת קוד QR לחנות"]})}),ue.length>0&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:["קטגוריות (",s.sh_cats.length?s.sh_cats.length:"הכל",")"]}),e.jsx("button",{type:"button",onClick:()=>d(t=>({...t,sh_cats:[]})),className:"text-xs text-cyan-600 hover:underline",children:"כל הקטגוריות"})]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:ue.map(t=>e.jsx("button",{type:"button",onClick:()=>me(t.id),className:`h-8 px-3 rounded-full border text-xs font-medium ${s.sh_cats.includes(t.id)?"border-cyan-500 bg-cyan-50 text-cyan-700":"border-slate-200 text-slate-600 hover:border-cyan-300"}`,children:t.title},t.id))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"פרטים בכרטסייה"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:[["condition","מצב המוצר"],["category","קטגוריה"],["publisher","שם המפרסם"],["date","תאריך / חדש"]].map(([t,a])=>e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!s.sh_fields[t],onChange:n=>d(x=>({...x,sh_fields:{...x.sh_fields,[t]:n.target.checked}})),className:"w-4 h-4"})," ",a]},t))})]})]}),P&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"כותרת שיווקית (תיאור קצר)"}),e.jsx("input",{className:M,placeholder:"נפגשים הערב בפאב — מוזיקה, חברים ואווירה טובה",value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"בחירת תצוגה"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[["marketing","מסך שיווקי"],["menu","תפריט ומוצרים"],["promos","מבצעים ומומלצים"],["combined","תצוגה משולבת"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,pub_view:t})),className:`rounded-xl border px-4 py-2.5 text-sm font-bold transition-colors ${s.pub_view===t?"border-amber-500 bg-amber-50 text-amber-700":"border-slate-200 text-slate-600 hover:border-amber-300"}`,children:a},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"מספר מוצרים להצגה"}),e.jsx("input",{type:"number",min:"1",max:"30",className:M,value:s.pub_count,onChange:t=>d(a=>({...a,pub_count:Number(t.target.value)}))})]}),e.jsx("div",{className:"flex items-end",children:e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer h-10",children:[e.jsx("input",{type:"checkbox",checked:s.pub_only_featured,onChange:t=>d(a=>({...a,pub_only_featured:t.target.checked})),className:"w-4 h-4"})," מוצרים מומלצים בלבד"]})}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"קודי QR"}),e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.pub_qr_order,onChange:t=>d(a=>({...a,pub_qr_order:t.target.checked})),className:"w-4 h-4"})," QR להזמנה מהירה"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.pub_qr_card,onChange:t=>d(a=>({...a,pub_qr_card:t.target.checked})),className:"w-4 h-4"})," QR לטעינת כרטיס"]})]})]})]}),D&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"כותרת שיווקית (תיאור קצר)"}),e.jsx("input",{className:M,placeholder:"התחזית המעודכנת לשבעת הימים הקרובים",value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}),e.jsx("div",{className:"md:col-span-2 rounded-xl bg-sky-50 border border-sky-100 px-3 py-2 text-xs text-sky-800",children:A?A.lat!=null&&A.lng!=null?e.jsxs(e.Fragment,{children:[ie("מיקום הקיבוץ",_)," (כפי שהוגדר בסופר-אדמין): ",e.jsx("b",{children:A.name||ie("הקיבוץ",_)})," · ",Number(A.lat).toFixed(3),", ",Number(A.lng).toFixed(3),". השדות למטה מציגים מיקום זה — ניתן לשנות למסך זה בלבד."]}):e.jsx(e.Fragment,{children:ie("לא הוגדר מיקום לקיבוץ בהגדרות הסופר-אדמין. ניתן להזין מיקום ידני למסך זה למטה.",_)}):ie("התחזית מבוססת על מיקום הקיבוץ המוגדר בסופר-אדמין. ניתן להזין מיקום חלופי למסך זה בלבד.",_)}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"בחירת תצוגה"}),e.jsx("div",{className:"flex flex-wrap gap-2",children:[["full","תחזית שבועית מלאה"],["central","יום מרכזי וימים קרובים"],["carousel","קרוסלת ימים"],["detailed","תחזית מפורטת"]].map(([t,a])=>e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,wx_view:t})),className:`rounded-xl border px-4 py-2.5 text-sm font-bold transition-colors ${s.wx_view===t?"border-sky-500 bg-sky-50 text-sky-700":"border-slate-200 text-slate-600 hover:border-sky-300"}`,children:a},t))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"נתונים שיוצגו"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:[["precip","סיכוי למשקעים"],["wind","רוח"],["humidity","לחות"],["sun","זריחה ושקיעה"]].map(([t,a])=>e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!s.wx_fields[t],onChange:n=>d(x=>({...x,wx_fields:{...x.wx_fields,[t]:n.target.checked}})),className:"w-4 h-4"})," ",a]},t))})]}),e.jsxs("div",{className:"md:col-span-2 flex flex-wrap gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.wx_weekend,onChange:t=>d(a=>({...a,wx_weekend:t.target.checked})),className:"w-4 h-4"})," הדגשת סוף השבוע"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.wx_night,onChange:t=>d(a=>({...a,wx_night:t.target.checked})),className:"w-4 h-4"})," עיצוב לילה אוטומטי"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.wx_alerts,onChange:t=>d(a=>({...a,wx_alerts:t.target.checked})),className:"w-4 h-4"})," התראות מזג אוויר"]})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"מיקום התחזית"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[e.jsx("input",{className:M,placeholder:"שם מקום להצגה",value:s.wx_place,onChange:t=>d(a=>({...a,wx_place:t.target.value}))}),e.jsx("input",{className:M,placeholder:(A==null?void 0:A.lat)!=null?String(A.lat):"קו רוחב (lat)",value:s.wx_lat,onChange:t=>d(a=>({...a,wx_lat:t.target.value}))}),e.jsx("input",{className:M,placeholder:(A==null?void 0:A.lng)!=null?String(A.lng):"קו אורך (lng)",value:s.wx_lng,onChange:t=>d(a=>({...a,wx_lng:t.target.value}))})]}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400 mt-1",children:ie("ברירת המחדל היא מיקום הקיבוץ מהסופר-אדמין. שינוי הערכים יגדיר מיקום חלופי למסך זה בלבד.",_)})]})]}),E&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"כותרת משנה (תיאור קצר)"}),e.jsx("input",{className:M,placeholder:"לוח הזמנים היומי · בית הכנסת",value:s.body,onChange:t=>d(a=>({...a,body:t.target.value}))})]}),e.jsx("div",{className:"md:col-span-2 rounded-xl bg-indigo-50 border border-indigo-100 px-3 py-2 text-xs text-indigo-800",children:"הזמנים ההלכתיים (נץ, סוף זמן ק״ש, שקיעה, צאת הכוכבים), כניסת/יציאת השבת ופרשת השבוע נטענים אוטומטית מ‑Hebcal לפי מיקום הקהילה. לוח התפילות למטה ידני."}),e.jsxs("div",{className:"md:col-span-2 flex flex-wrap gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.sy_show_zmanim,onChange:t=>d(a=>({...a,sy_show_zmanim:t.target.checked})),className:"w-4 h-4"})," הצגת זמני היום (הלכתיים)"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.sy_show_shabbat,onChange:t=>d(a=>({...a,sy_show_shabbat:t.target.checked})),className:"w-4 h-4"})," הצגת זמני שבת ופרשה"]}),e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.sy_show_hebrew_date,onChange:t=>d(a=>({...a,sy_show_hebrew_date:t.target.checked})),className:"w-4 h-4"})," הצגת התאריך העברי"]})]}),s.sy_show_zmanim&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"אילו זמנים הלכתיים להציג"}),e.jsx("div",{className:"flex flex-wrap gap-3",children:[["alotHaShachar","עלות השחר"],["misheyakir","משיכיר"],["sunrise","הנץ החמה"],["sofZmanShma","סו״ז ק״ש"],["sofZmanTfilla","סו״ז תפילה"],["chatzot","חצות"],["minchaGedola","מנחה גדולה"],["plagHaMincha","פלג המנחה"],["sunset","שקיעה"],["tzeit","צאת הכוכבים"]].map(([t,a])=>e.jsxs("label",{className:"flex items-center gap-2 text-sm cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:s.sy_zmanim_keys.includes(t),onChange:()=>d(n=>({...n,sy_zmanim_keys:n.sy_zmanim_keys.includes(t)?n.sy_zmanim_keys.filter(x=>x!==t):[...n.sy_zmanim_keys,t]})),className:"w-4 h-4"})," ",a]},t))})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground",children:"לוח תפילות (ידני)"}),e.jsxs("button",{type:"button",onClick:()=>d(t=>({...t,sy_prayers:[...t.sy_prayers,{label:"",time:""}]})),className:"inline-flex items-center gap-1 text-xs font-bold text-indigo-600 hover:text-indigo-800",children:[e.jsx(se,{className:"w-3.5 h-3.5"})," הוסף תפילה"]})]}),e.jsxs("div",{className:"space-y-2",children:[s.sy_prayers.map((t,a)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{className:`${M} flex-1`,placeholder:"שם התפילה (שחרית / מנחה / ערבית)",value:t.label,onChange:n=>d(x=>({...x,sy_prayers:x.sy_prayers.map((w,K)=>K===a?{...w,label:n.target.value}:w)}))}),e.jsx("input",{type:"time",className:`${M} w-32`,value:t.time,onChange:n=>d(x=>({...x,sy_prayers:x.sy_prayers.map((w,K)=>K===a?{...w,time:n.target.value}:w)}))}),e.jsx("input",{className:`${M} w-40`,placeholder:"הערה (אופציונלי)",value:t.note||"",onChange:n=>d(x=>({...x,sy_prayers:x.sy_prayers.map((w,K)=>K===a?{...w,note:n.target.value}:w)}))}),e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,sy_prayers:n.sy_prayers.filter((x,w)=>w!==a)})),className:"w-9 h-9 rounded-lg flex items-center justify-center text-red-500 hover:bg-red-50 flex-none",children:e.jsx(le,{className:"w-4 h-4"})})]},a)),s.sy_prayers.length===0&&e.jsx("p",{className:"text-[0.6875rem] text-slate-400",children:"אין תפילות. ניתן להוסיף שחרית / 
22מנחה / ערבית או כל תפילה אחרת."})]})]}),e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1.5",children:"מיקום (לחישוב הזמנים)"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2",children:[e.jsx("input",{className:M,placeholder:"שם מקום להצגה",value:s.sy_place,onChange:t=>d(a=>({...a,sy_place:t.target.value}))}),e.jsx("input",{className:M,placeholder:(A==null?void 0:A.lat)!=null?String(A.lat):"קו רוחב (lat)",value:s.sy_lat,onChange:t=>d(a=>({...a,sy_lat:t.target.value}))}),e.jsx("input",{className:M,placeholder:(A==null?void 0:A.lng)!=null?String(A.lng):"קו אורך (lng)",value:s.sy_lng,onChange:t=>d(a=>({...a,sy_lng:t.target.value}))})]}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400 mt-1",children:"ברירת המחדל היא מיקום הקהילה מהסופר-אדמין. שינוי הערכים יגדיר מיקום חלופי למסך זה בלבד."})]})]}),T&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-2",children:"בחרו עמוד תוכן מהספרייה"}),ee.length===0?e.jsxs("div",{className:"rounded-xl bg-slate-50 border border-slate-200 px-4 py-6 text-center text-sm text-slate-500",children:["אין עדיין עמודי תוכן. עברו ל",e.jsx("b",{children:"ספריית תוכן"})," (בתפריט הכותרת של המודול) כדי ליצור עמוד מעוצב."]}):e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-2",children:ee.map(t=>{const a=s.cp_id===t.id;return e.jsxs("button",{type:"button",onClick:()=>d(n=>({...n,cp_id:t.id})),className:`text-right rounded-xl border p-3 transition-colors ${a?"border-cyan-500 bg-cyan-50":"border-slate-200 bg-white hover:border-cyan-300"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-7 h-7 rounded-lg bg-cyan-50 text-cyan-700 grid place-items-center flex-none",children:e.jsx(ge,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-sm font-bold text-slate-800 truncate",children:t.title||"ללא כותרת"})]}),e.jsx("div",{className:"text-[0.6875rem] text-slate-400 line-clamp-2",children:String(t.body_html||"").replace(/<[^>]+>/g," ").replace(/\s+/g," ").trim().slice(0,90)||"—"})]},t.id)})}),e.jsx("p",{className:"text-[0.6875rem] text-slate-400 mt-2",children:"הגודל והמבנה נקבעים אוטומטית לפי נפח התוכן שנשמר בעמוד."})]}),q&&e.jsxs("div",{className:"md:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"באנרים מתחלפים בצד (עד 3)"}),e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[s.side_banners.map((t,a)=>e.jsxs("div",{className:"relative w-24 h-16 rounded-lg overflow-hidden border border-border",children:[e.jsx("img",{src:t,alt:"",className:"w-full h-full object-cover"}),e.jsx("button",{type:"button",onClick:()=>d(n=>({...n,side_banners:n.side_banners.filter((x,w)=>w!==a)})),className:"absolute top-0.5 left-0.5 w-5 h-5 rounded-full bg-black/60 text-white flex items-center justify-center",children:e.jsx(le,{className:"w-3 h-3"})})]},a)),s.side_banners.length<3&&e.jsxs("label",{className:"w-24 h-16 rounded-lg border border-dashed border-slate-300 flex items-center justify-center cursor-pointer hover:border-cyan-400 hover:bg-cyan-50 text-slate-400",children:[ut?"…":e.jsx(se,{className:"w-5 h-5"}),e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:or,disabled:ut})]})]})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4",children:[e.jsx(R,{variant:"outline",onClick:u,disabled:qe,className:"rounded-full",children:"ביטול"}),e.jsxs(R,{onClick:dr,disabled:qe||Ue||He>=0||We>=0,className:"rounded-full gap-1.5 bg-cyan-600 hover:bg-cyan-700",children:[e.jsx(_e,{className:"w-4 h-4"})," ",qe?"שומר…":g?"שמור שינויים":"הוסף"]})]}),o&&e.jsx("div",{className:"mt-5 pt-4 border-t border-slate-100",children:e.jsx(xl,{kibbutzId:i,channelId:o,item:ir,design:S})})]})}
22function Il({item:l,onChanged:r}){const o=async()=>{try{await I.entities.DigitalScreenItem.delete(l.id),r()}catch{y.error("שגיאה")}},i=pe.find(c=>c.type===l.type&&(!c.source_module||c.source_module===l.source_module))||Fe,f=(i==null?void 0:i.icon)||Ce;return e.jsxs("div",{className:"flex items-center justify-between rounded-xl border border-border/60 px-3 py-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${(i==null?void 0:i.color)||"bg-slate-100 text-slate-600"}`,children:e.jsx(f,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-sm font-medium truncate",children:l.title||(i==null?void 0:i.label)}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[l.duration_seconds,"שנ׳"]})]}),e.jsx("button",{onClick:o,className:"w-8 h-8 rounded-lg flex items-center justify-center text-red-500 hover:bg-red-50",children:e.jsx(re,{className:"w-4 h-4"})})]})}function Pl({channelId:l,kibbutzId:r,items:o,reloadItems:i}){const f=async(_,g)=>{const h=[...o],m=_+g;if(!(m<0||m>=h.length)){[h[_],h[m]]=[h[m],h[_]];try{await Promise.all(h.map((k,b)=>I.entities.DigitalScreenItem.update(k.id,{order_index:b}))),i()}catch{y.error("שגיאה בשינוי הסדר")}}},c=async(_,g)=>{try{await I.entities.DigitalScreenItem.update(_.id,{duration_seconds:Number(g)||10}),i()}catch{}},u=async _=>{try{await I.entities.DigitalScreenItem.update(_.id,{status:_.status==="active"?"disabled":"active"}),i()}catch{y.error("שגיאה")}},S=async _=>{try{await I.entities.DigitalScreenItem.delete(_.id),i()}catch{y.error("שגיאה")}};return!l||o.length===0?e.jsx("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-8 text-center text-sm text-muted-foreground",children:"הוסיפו תכנים בשלב הקודם כדי לקבוע סדר."}):e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-5",dir:"rtl",children:[e.jsx("h3",{className:"text-sm font-bold mb-3",children:"רשימת השמעה — סדר ומשך"}),e.jsx("div",{className:"space-y-2",children:o.map((_,g)=>{const h=pe.find(k=>k.type===_.type&&(!k.source_module||k.source_module===_.source_module))||Fe,m=(h==null?void 0:h.icon)||Ce;return e.jsxs("div",{className:`flex flex-wrap items-center gap-2 rounded-xl border px-3 py-2 ${_.status==="disabled"?"border-border/60 opacity-60":"border-border"}`,children:[e.jsxs("div",{className:"flex flex-col",children:[e.jsx("button",{onClick:()=>f(g,-1),disabled:g===0,className:"w-6 h-5 flex items-center justify-center text-slate-400 hover:text-slate-700 disabled:opacity-30",children:e.jsx(Xe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>f(g,1),disabled:g===o.length-1,className:"w-6 h-5 flex items-center justify-center text-slate-400 hover:text-slate-700 disabled:opacity-30",children:e.jsx(at,{className:"w-4 h-4"})})]}),e.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${(h==null?void 0:h.color)||"bg-slate-100 text-slate-600"}`,children:e.jsx(m,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-sm font-medium flex-1 min-w-0 truncate",children:_.title||(h==null?void 0:h.label)}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("input",{type:"number",min:"3",value:_.duration_seconds,onChange:k=>c(_,k.target.value),className:"w-16 h-9 rounded-lg border border-border px-2 text-sm text-center"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"שנ׳"})]}),e.jsx(ae,{checked:_.status!=="disabled",onCheckedChange:()=>u(_)}),e.jsx("button",{onClick:()=>S(_),className:"w-8 h-8 rounded-lg flex items-center justify-center text-red-500 hover:bg-red-50",children:e.jsx(re,{className:"w-4 h-4"})})]},_.id)})})]})}function Ml({kibbutzId:l,kibbutz:r,settings:o,onDone:i}){const{t:f}=it(),[c,u]=p.useState(()=>({default_logo_url:(o==null?void 0:o.default_logo_url)||(r==null?void 0:r.logo_url)||"",default_primary_color:(o==null?void 0:o.default_primary_color)||(r==null?void 0:r.primary_color)||"#2563eb",default_secondary_color:(o==null?void 0:o.default_secondary_color)||(r==null?void 0:r.secondary_color)||"#06b6d4",footer_text:(o==null?void 0:o.footer_text)||"",ticker_text:(o==null?void 0:o.ticker_text)||"",orientation:(o==null?void 0:o.orientation)||"landscape",aspect_ratio:(o==null?void 0:o.aspect_ratio)||"16:9",show_weather:(o==null?void 0:o.show_weather)??!0})),[S,_]=p.useState(!1),g=async()=>{_(!0);try{const h={kibbutz_id:l,...c,updated_date:new Date().toISOString()};await I.entities.DigitalScreenSettings.bulkUpdate([h]),y.success("הגדרות העיצוב נשמרו"),i()}catch(h){console.error(h),y.error("שגיאה בשמירה")}finally{_(!1)}};return e.jsxs("div",{dir:"rtl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx(Be,{title:"הגדרות עיצוב",items:[]}),e.jsx(R,{variant:"outline",onClick:i,className:"rounded-full",children:"חזרה"})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-6 max-w-2xl",children:[e.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:ie("ברירת מחדל לעיצוב שתחול על ערוצים חדשים (ניתן לשנות פר-ערוץ). הלוגו נלקח אוטומטית מהגדרות אתר הקיבוץ.",f)}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 max-w-md",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"צבע ראשי"}),e.jsx("input",{type:"color",className:"w-full h-11 rounded-xl border border-border 
22cursor-pointer",value:c.default_primary_color,onChange:h=>u(m=>({...m,default_primary_color:h.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-muted-foreground mb-1",children:"צבע משני"}),e.jsx("input",{type:"color",className:"w-full h-11 rounded-xl border border-border cursor-pointer",value:c.default_secondary_color,onChange:h=>u(m=>({...m,default_secondary_color:h.target.value}))})]})]}),e.jsx("div",{className:"flex items-center justify-end gap-2 mt-5",children:e.jsxs(R,{onClick:g,disabled:S,className:"rounded-full gap-1.5 bg-emerald-600 hover:bg-emerald-700",children:[e.jsx(_e,{className:"w-4 h-4"})," ",S?"שומר…":"שמור"]})})]})]})}function Al(l){const r=String(l||"");if(r.trim().startsWith("{"))try{const o=JSON.parse(r);return{type:o.type||"general",title:o.title||"",text:o.text||"",image:o.image||""}}catch{}return{type:"general",title:"",text:r,image:""}}function El({kibbutzId:l,settings:r,onChanged:o,open:i,setOpen:f}){const c=!!(r!=null&&r.emergency_active),u=Al(r==null?void 0:r.emergency_text),[S,_]=p.useState(u.type),[g,h]=p.useState(u.title),[m,k]=p.useState(u.text),[b,N]=p.useState(u.image),[O,C]=p.useState(!1),[F,$]=p.useState(!1),B=Da(S),U=g||B.title,j=async D=>{if(D&&!m.trim()&&!g.trim()){y.error("יש להזין כותרת או טקסט להודעת החירום");return}C(!0);try{const E={kibbutz_id:l,emergency_active:D,emergency_text:D?JSON.stringify({type:S,title:g.trim(),text:m.trim(),image:b}):(r==null?void 0:r.emergency_text)||"",emergency_since:D?new Date().toISOString():null,updated_date:new Date().toISOString()};await I.entities.DigitalScreenSettings.bulkUpdate([E]),y.success(D?"מצב חירום הופעל בכל המסכים":"מצב חירום כובה"),f(!1),o()}catch(E){console.error(E),y.error("שגיאה")}finally{C(!1)}},P=async D=>{if(D){$(!0);try{const{file_url:E}=await I.integrations.Core.UploadFile({file:D});N(E)}catch{y.error("שגיאה בהעלאת התמונה")}finally{$(!1)}}};if(c){const D=Da(u.type);return e.jsxs("div",{className:"mb-6 rounded-2xl border-2 border-red-300 bg-red-50 p-4 flex flex-wrap items-center justify-between gap-3",dir:"rtl",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("span",{className:"w-10 h-10 rounded-xl bg-red-100 flex items-center justify-center flex-shrink-0 animate-pulse",children:e.jsx(tt,{className:"w-5 h-5 text-red-600"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("p",{className:"text-sm font-bold text-red-800",children:["מצב חירום פעיל (",D.label,") — כל המסכים מציגים את ההתראה"]}),e.jsxs("p",{className:"text-sm text-red-700 truncate",children:[u.title||D.title,u.text?` · ${u.text}`:""]})]})]}),e.jsxs(R,{onClick:()=>j(!1),disabled:O,className:"rounded-full bg-red-600 hover:bg-red-700 gap-1.5",children:[e.jsx(le,{className:"w-4 h-4"})," כבה מצב חירום"]})]})}return i?e.jsx("div",{className:"mb-6",dir:"rtl",children:e.jsxs("div",{className:"rounded-2xl border-2 border-red-200 bg-white p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(Pr,{className:"w-4 h-4 text-red-600"}),e.jsx("h3",{className:"text-sm font-bold text-red-800",children:"הפעלת מסך חירום בכל המסכים"})]}),e.jsx("p",{className:"text-xs text-muted-foreground mb-3",children:"כל המסכים יעברו למסך חירום מלא עד לכיבוי."}),e.jsx("label",{className:"block text-xs font-bold text-slate-600 mb-1.5",children:"סוג האירוע"}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-2 mb-3",children:Object.entries(Ur).map(([D,E])=>{const T=E.icon,q=S===D;return e.jsxs("button",{type:"button",onClick:()=>{_(D),g||h("")},className:`flex flex-col items-center gap-1.5 rounded-xl border-2 p-3 text-xs font-bold transition-colors ${q?"text-white border-transparent":"bg-white border-slate-200 text-slate-600 hover:border-red-300"}`,style:q?{background:`linear-gradient(160deg, ${E.from}, ${E.to})`}:void 0,children:[e.jsx(T,{className:"w-5 h-5"})," ",E.label]},D)})}),e.jsxs("label",{className:"block text-xs font-bold text-slate-600 mb-1.5",children:["כותרת (ברירת מחדל: ",B.title,")"]}),e.jsx("input",{value:g,onChange:D=>h(D.target.value),placeholder:B.title,className:"w-full h-10 rounded-xl border border-slate-200 px-3 text-sm mb-3"}),e.jsx("label",{className:"block text-xs font-bold text-slate-600 mb-1.5",children:"הודעה / הנחיות"}),e.jsx(ce,{rows:2,className:"rounded-xl resize-none mb-3",value:m,onChange:D=>k(D.target.value),placeholder:"טקסט ההנחיה לתושבים…"}),e.jsx("label",{className:"block text-xs font-bold text-slate-600 mb-1.5",children:"תמונה (אופציונלי)"}),e.jsxs("div",{className:"flex items-center gap-2 mb-3",children:[b&&e.jsx("img",{src:b,alt:"",className:"w-12 h-12 rounded-lg object-cover ring-1 ring-slate-200"}),e.jsxs("label",{className:"inline-flex items-center gap-1.5 h-9 px-3 rounded-full border border-slate-200 text-xs font-bold cursor-pointer hover:bg-slate-50",children:[e.jsx(fe,{className:"w-3.5 h-3.5"})," ",F?"מעלה…":b?"החלף תמונה":"העלה תמונה",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:D=>{var E;return P((E=D.target.files)==null?void 0:E[0])}})]}),b&&e.jsx("button",{type:"button",onClick:()=>N(""),className:"text-xs text-slate-400 hover:text-red-500",children:"הסר"})]}),e.jsx("div",{className:"rounded-xl overflow-hidden ring-1 ring-slate-200 mb-3",style:{aspectRatio:"16/6"},children:e.jsx(Hr,{emergency:{type:S,title:U,text:m,image:b},preview:!0})}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsx(R,{variant:"outline",onClick:()=>f(!1),disabled:O,className:"rounded-full",children:"ביטול"}),e.jsxs(R,{onClick:()=>j(!0),disabled:O||F,className:"rounded-full bg-red-600 hover:bg-red-700 gap-1.5",children:[e.jsx(tt,{className:"w-4 h-4"})," הפעל חירום"]})]})]})}):null}function Fl({kibbutzId:l,devices:r,channels:o,onChanged:i,onBack:f}
22){const[c,u]=p.useState(null),S=m=>{var k;return((k=o.find(b=>b.id===m))==null?void 0:k.name)||"—"},_=m=>m.status==="connected"&&m.last_seen_at&&Date.now()-new Date(m.last_seen_at).getTime()<Ya,g=async(m,k)=>{u(m.id);try{await I.functions.invoke("digitalScreenCommand",{device_id:m.id,action:k}),y.success(k==="refresh"?"נשלח רענון":k==="disconnect"?"המסך נותק":"נשלחה פקודה"),i()}catch(b){y.error((b==null?void 0:b.message)||"שגיאה")}finally{u(null)}},h=async m=>{try{await I.entities.DigitalScreenDevice.delete(m.id),i()}catch{y.error("שגיאה")}};return e.jsxs("div",{dir:"rtl",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx(Be,{title:"מסכים מחוברים",items:[]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(R,{variant:"outline",onClick:i,className:"rounded-full gap-1.5",children:[e.jsx(st,{className:"w-4 h-4"})," רענן"]}),e.jsx(R,{variant:"outline",onClick:f,className:"rounded-full",children:"חזרה"})]})]}),r.length===0?e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-12 flex flex-col items-center justify-center text-center",children:[e.jsx(nl,{className:"w-10 h-10 text-slate-300 mb-3"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"אין מסכים מחוברים עדיין — התחברו לכתובת ערוץ ממכשיר תצוגה"})]}):e.jsx("div",{className:"space-y-2.5",children:r.map(m=>{const k=_(m);return e.jsx("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-4",children:e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("span",{className:`w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 ${k?"bg-emerald-50":"bg-slate-100"}`,children:k?e.jsx(ol,{className:"w-5 h-5 text-emerald-600"}):e.jsx(il,{className:"w-5 h-5 text-slate-400"})}),e.jsx("h3",{className:"text-sm font-bold text-foreground",children:m.name||"מסך"}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${k?"bg-emerald-50 text-emerald-600":m.status==="inactive"?"bg-slate-100 text-slate-500":"bg-amber-50 text-amber-700"}`,children:k?"מחובר":m.status==="inactive"?"לא פעיל":"לא מחובר"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-xs text-muted-foreground",children:[m.location&&e.jsx("span",{children:m.location}),e.jsxs("span",{children:["ערוץ: ",S(m.channel_id)]}),m.resolution&&e.jsx("span",{children:m.resolution}),m.last_seen_at&&e.jsxs("span",{children:["נראה לאחרונה: ",new Date(m.last_seen_at).toLocaleString("he-IL")]})]})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",children:[e.jsx("button",{onClick:()=>g(m,"refresh"),disabled:c===m.id,title:"רענן",className:"w-9 h-9 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100",children:e.jsx(st,{className:"w-4 h-4"})}),m.channel_id&&e.jsx("a",{href:mt(l,m.channel_id),target:"_blank",rel:"noopener noreferrer",title:"פתח תצוגה",className:"w-9 h-9 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100",children:e.jsx(Pe,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>g(m,"disconnect"),disabled:c===m.id,title:"נתק",className:"w-9 h-9 rounded-lg flex items-center justify-center text-amber-600 hover:bg-amber-50",children:e.jsx(dl,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>h(m),title:"הסר",className:"w-9 h-9 rounded-lg flex items-center justify-center text-red-500 hover:bg-red-50",children:e.jsx(re,{className:"w-4 h-4"})})]})]})},m.id)})})]})}const zl=["א","ב","ג","ד","ה","ו","ש"];function Ol({kibbutzId:l,channel:r,items:o,devices:i,onEditSettings:f,onChanged:c,onBack:u}){const S=Gr("מסך מלא"),[_,g]=p.useState(o),[h,m]=p.useState(null),[k,b]=p.useState(null),[N,O]=p.useState(!1),[C,F]=p.useState(null),[$,B]=p.useState(!1),[U,j]=p.useState(""),[P,D]=p.useState(0),[E,T]=p.useState(!1),[q,Y]=p.useState(""),[V,J]=p.useState(!1),W=mt(l,r.id),G=_.filter(v=>v.status!=="disabled"),Q=G.reduce((v,L)=>v+(Number(L.duration_seconds)||0),0),s=v=>{const L=Math.floor(v/60),z=v%60;return L===0?`${z} שנ׳`:z?`${L} דק׳ ${z} שנ׳`:`${L} דק׳`},d=_.find(v=>v.id===k)||null,X=d?pe.find(v=>v.type===d.type&&(!v.source_module||v.source_module===d.source_module))||Fe:null,me=Oa[r.status]||Oa.draft,ue=i.filter(v=>v.status==="connected"&&v.last_seen_at&&Date.now()-new Date(v.last_seen_at).getTime()<Ya).length;p.useEffect(()=>{g(o)},[o]);const je=async v=>{g(v);try{await Promise.all(v.map((L,z)=>I.entities.DigitalScreenItem.update(L.id,{order_index:z}))),c()}catch{y.error("שגיאה בשינוי הסדר")}},ne=v=>{if(h===null||h===v)return;const L=[..._],[z]=L.splice(h,1);L.splice(v,0,z),m(null),je(L)},Se=async(v,L)=>{try{await I.entities.DigitalScreenItem.update(v.id,L),c()}catch{y.error("שגיאה")}},oe=async v=>{try{const{id:L,created_date:z,updated_date:he,...ee}=v;await I.entities.DigitalScreenItem.create({...ee,title:`${v.title||""} (עותק)`,order_index:_.length}),c(),y.success("שוכפל")}catch{y.error("שגיאה")}},Le=async v=>{try{await I.entities.DigitalScreenItem.delete(v.id),c()}catch{y.error("שגיאה")}},ve=async()=>
22{if(!U||U.length<4){y.error("סיסמה קצרה מדי");return}try{await I.functions.invoke("setDigitalScreenPassword",{channel_id:r.id,password:U}),y.success("הקוד עודכן"),j(""),B(!1),c()}catch(v){y.error((v==null?void 0:v.message)||"שגיאה")}},Re=async(v,L)=>{const z=Math.max(3,Number(L)||0);g(he=>he.map(ee=>ee.id===v.id?{...ee,duration_seconds:z}:ee));try{await I.entities.DigitalScreenItem.update(v.id,{duration_seconds:z}),c()}catch{y.error("שגיאה בשמירת המשך")}},$e=async()=>{const v=Math.max(3,Number(q)||0);if(!(!v||!_.length)){J(!0),g(L=>L.map(z=>({...z,duration_seconds:v})));try{await Promise.all(_.map(L=>I.entities.DigitalScreenItem.update(L.id,{duration_seconds:v}))),c(),y.success(`המשך עודכן ל-${v} שניות בכל הרשימה`)}catch{y.error("שגיאה בעדכון גורף")}finally{J(!1)}}},ye=(v,L)=>{var z;(z=navigator.clipboard)==null||z.writeText(v),y.success(L)};return e.jsxs("div",{dir:"rtl",children:[S.overlay,e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx(Be,{title:r.name,items:[{label:"ערוך פרטים ועיצוב",icon:Aa,onClick:f},{label:"פתח מסך (תצוגה מלאה)",icon:Pe,onClick:()=>S.show(`${W}?preview=1`)}]}),e.jsx(R,{variant:"outline",onClick:u,className:"rounded-full",children:"חזרה לרשימה"})]}),e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-5 mb-4",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap mb-2",children:[e.jsx("span",{className:"w-10 h-10 rounded-xl bg-cyan-50 flex items-center justify-center flex-shrink-0",children:e.jsx(xe,{className:"w-5 h-5 text-cyan-600"})}),e.jsx("h2",{className:"text-lg font-bold text-foreground",children:r.name}),e.jsx("span",{className:`inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium ${me.badge}`,children:me.label})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[r.location&&e.jsx("span",{children:r.location}),e.jsxs("span",{children:[_.length," תכנים"]}),e.jsxs("span",{children:[ue," מסכים מחוברים"]}),r.updated_date&&e.jsxs("span",{children:["עודכן ",new Date(r.updated_date).toLocaleString("he-IL")]})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-2",children:[e.jsx("input",{className:"w-full max-w-md h-9 rounded-lg border border-border bg-slate-50 px-2 text-xs font-mono",value:W,readOnly:!0,dir:"ltr"}),e.jsx("button",{onClick:()=>ye(W,"הקישור הועתק"),className:"h-9 px-3 rounded-lg border border-border text-xs hover:bg-accent",children:"העתק"})]}),r.access_code&&e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"קוד כניסה:"}),e.jsx("span",{className:"inline-flex items-center h-8 px-3 rounded-lg bg-cyan-50 text-cyan-800 text-sm font-black tracking-[0.25em]",dir:"ltr",children:r.access_code}),e.jsx("button",{onClick:()=>ye(r.access_code,"הקוד הועתק"),className:"h-8 px-2.5 rounded-lg border border-border text-xs hover:bg-accent",children:"העתק"})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(R,{variant:"outline",onClick:f,className:"rounded-full gap-1.5 h-9",children:[e.jsx(Aa,{className:"w-4 h-4"})," ערוך ערוץ"]}),e.jsxs(R,{variant:"outline",onClick:()=>B(v=>!v),className:"rounded-full gap-1.5 h-9",children:[e.jsx(Ka,{className:"w-4 h-4"})," החלף סיסמה"]}),e.jsxs("a",{href:W,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1.5 h-9 px-4 rounded-full bg-cyan-600 text-white text-sm font-medium hover:bg-cyan-700",children:[e.jsx(Pe,{className:"w-4 h-4"})," פתח מסך"]})]})]}),$&&e.jsxs("div",{className:"mt-3 pt-3 border-t border-border/60 flex flex-wrap items-end gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs text-muted-foreground mb-1",children:"סיסמה חדשה"}),e.jsx("input",{type:"text",className:`${M} w-56`,value:U,onChange:v=>j(v.target.value),dir:"ltr"})]}),e.jsx("button",{onClick:()=>j(Ga()),className:"text-xs text-cyan-700 hover:underline h-11",children:"צור קוד אוטומטי"}),e.jsx(R,{onClick:ve,className:"rounded-full bg-emerald-600 hover:bg-emerald-700 h-10",children:"שמור סיסמה"})]})]}),e.jsx("div",{className:"rounded-2xl overflow-hidden shadow-sm mb-4 bg-gradient-to-l from-cyan-600 to-teal-600 text-white",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4 p-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{className:"w-12 h-12 rounded-xl bg-white/15 flex items-center justify-center flex-shrink-0",children:e.jsx(Ra,{className:"w-6 h-6"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-white/80",children:"משך רשימת ההשמעה — סבב מלא"}),e.jsx("p",{className:"text-2xl font-black leading-tight",children:s(Q)}),e.jsxs("p",{className:"text-[0.6875rem] text-white/70",children:[G.length," תכנים פעילים · הסבב חוזר על עצמו במסך"]})]})]}),e.jsxs("div",{className:"flex flex-wrap items-end gap-2 bg-white/10 rounded-xl p-2.5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[0.6875rem] font-medium text-white/85 mb-1",children:"קיצור גורף — משך לכל תוכן (שניות)"}),e.jsxs("div",{className:"flex items-center gap-1.5",children:[[8,10,12,15].map(v=>e.jsx("button",{type:"button",onClick:()=>Y(String(v)),className:`h-9 w-9 rounded-lg text-sm font-bold transition ${String(v)===String(q)?"bg-white text-cyan-700":"bg-white/15 text-white hover:bg-white/25"}`,children:v},v)),e.jsx("input",{type:"number",min:"3",value:q,onChange:v=>Y(v.target.value),placeholder:"שנ׳",className:"w-16 h-9 rounded-lg border-0 px-2 text-sm text-center text-slate-800"})]})]}),e.jsxs(R,{onClick:$e,disabled:V||!q||!_.length,className:"rounded-full h-9 bg-white text-cyan-700 hover:bg-white/90 gap-1.5 font-bold disabled:opacity-60",children:[e.jsx(_e,{className:"w-4 h-4"})," ",V?"מחיל…":"החל על כל הרשימה"]})]})]})}),E?e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-4",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-bold",children:"תצוגה מקדימה"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>D(v=>v+1),title:"רענן",className:"w-9 h-9 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100",children:e.jsx(st,{className:"w-4 h-4"})}),e.jsx(Qr,{url:`${W}?preview=1`,title:"מסך מלא",className:"w-9 h-9 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100"}),e.jsxs(R,{variant:"outline",onClick:()=>T(!1),className:"rounded-full h-9 gap-1.5",children:[e.jsx(le,{className:"w-4 h-4"})," סגור תצוגה"]})]})]}),e.jsx("div",{className:"rounded-2xl border-4 border-slate-800 bg-black overflow-hidden shadow-lg mx-auto",style:{aspectRatio:r.aspect_ratio==="9:16"?"9 / 16":"16 / 9",maxHeight:"76vh",maxWidth:r.aspect_ratio==="9:16"?"43vh":"none"},children:e.jsx("iframe",{src:`${W}?preview=1`,title:"preview",className:"w-full h-full border-0"},P)}),e.jsx("p",{className:"text-xs text-muted-foreground mt-2 text-center",children:"תצוגה חיה של הערוץ (גם בטיוטה)"})]}
22):e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-5 gap-4",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsx("h3",{className:"text-sm font-bold",children:"רשימת השמעה"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(R,{variant:"outline",onClick:()=>T(!0),className:"rounded-full gap-1.5 h-9",children:[e.jsx(Pe,{className:"w-4 h-4"})," תצוגה מקדימה"]}),e.jsxs(R,{onClick:()=>{O(!0),F(null),b(null)},className:"rounded-full gap-1.5 bg-cyan-600 hover:bg-cyan-700 h-9",children:[e.jsx(se,{className:"w-4 h-4"})," הוסף תוכן"]})]})]}),_.length===0?e.jsx("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-8 text-center text-sm text-muted-foreground",children:"אין תכנים — הוסיפו תוכן ראשון"}):e.jsx("div",{className:"space-y-2",children:_.map((v,L)=>{var De,A;const z=pe.find(H=>H.type===v.type&&(!H.source_module||H.source_module===v.source_module))||Fe,he=(z==null?void 0:z.icon)||Ce,ee=k===v.id&&!N;return e.jsx("div",{draggable:!0,onDragStart:()=>m(L),onDragOver:H=>H.preventDefault(),onDrop:()=>ne(L),onClick:()=>{b(v.id),O(!1)},className:`bg-white rounded-xl border shadow-sm cursor-pointer transition ${v.status==="disabled"?"opacity-60 border-border/60":"border-border"} ${ee?"ring-2 ring-cyan-400":h===L?"ring-2 ring-cyan-200":"hover:border-cyan-200"}`,children:e.jsxs("div",{className:"flex items-center gap-2 p-3",children:[e.jsx("span",{className:"cursor-grab text-slate-300 select-none",title:"גרור",onClick:H=>H.stopPropagation(),children:"⠿"}),e.jsx("span",{className:`w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 ${(z==null?void 0:z.color)||"bg-slate-100 text-slate-600"}`,children:e.jsx(he,{className:"w-4 h-4"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:v.title||(z==null?void 0:z.label)}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:v.type==="multi"&&((De=v.config)!=null&&De.layout)?`${z==null?void 0:z.label} · ${((A=Je(v.config.layout))==null?void 0:A.label)||""} · ${(v.config.regions||[]).length} אזורים`:z==null?void 0:z.label})]}),e.jsxs("div",{className:"flex items-center gap-1 flex-shrink-0",onClick:H=>H.stopPropagation(),title:"משך הצגה (שניות)",children:[e.jsx("input",{type:"number",min:"3",value:v.duration_seconds??"",onChange:H=>Re(v,H.target.value),className:"w-14 h-8 rounded-lg border border-border px-2 text-sm text-center"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"שנ׳"})]}),e.jsx(ae,{checked:v.status!=="disabled",onClick:H=>H.stopPropagation(),onCheckedChange:()=>Se(v,{status:v.status==="disabled"?"active":"disabled"})}),e.jsx("button",{onClick:H=>{H.stopPropagation(),oe(v)},title:"שכפל",className:"w-8 h-8 rounded-lg flex items-center justify-center text-slate-500 hover:bg-slate-100",children:e.jsx(ke,{className:"w-4 h-4"})}),e.jsx("button",{onClick:H=>{H.stopPropagation(),Le(v)},title:"מחק",className:"w-8 h-8 rounded-lg flex items-center justify-center text-red-500 hover:bg-red-50",children:e.jsx(re,{className:"w-4 h-4"})})]})},v.id)})})]}),e.jsx("div",{className:"lg:col-span-3",children:e.jsx("div",{className:"lg:sticky lg:top-4",children:N?e.jsx("div",{className:"bg-white rounded-2xl border border-cyan-200 shadow-sm p-4",children:C?e.jsx(nt,{def:C,channelId:r.id,kibbutzId:l,order:_.length,design:lt(r),onDone:()=>{O(!1),F(null),c()},onCancel:()=>{F(null),O(!1)}},`new-${C.key}`):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsx("h3",{className:"text-sm font-bold",children:"בחרו סוג תוכן"}),e.jsx("button",{onClick:()=>O(!1),className:"text-slate-400 hover:text-slate-600",children:e.jsx(le,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"grid grid-cols-3 sm:grid-cols-4 gap-2",children:pe.map(v=>{const L=v.icon;return e.jsxs("button",{onClick:()=>F(v),className:"flex flex-col items-center gap-1.5 p-3 rounded-xl border border-border hover:border-cyan-300 text-center",children:[e.jsx("span",{className:`w-9 h-9 rounded-lg flex items-center justify-center ${v.color}`,children:e.jsx(L,{className:"w-4 h-4"})}),e.jsx("span",{className:"text-[0.6875rem] font-medium",children:v.label})]},v.key)})})]})}):d?e.jsxs("div",{className:"bg-white rounded-2xl border border-border shadow-sm p-4 space-y-3",children:[e.jsx(nt,{def:X,item:d,channelId:r.id,kibbutzId:l,order:_.indexOf(d),design:lt(r),onDone:()=>{b(null),c()},onCancel:()=>b(null)},d.id),e.jsx(Bl,{item:d,onSave:v=>{Se(d,v),y.success("התזמון נשמר")}})]}):e.jsxs("div",{className:"bg-white rounded-2xl border border-dashed border-border shadow-sm p-12 text-center text-sm text-muted-foreground",children:[e.jsx(xe,{className:"w-10 h-10 mx-auto mb-3 text-slate-300"}),'בחרו תוכן מהרשימה כדי לערוך אותו כאן, או לחצו "הוסף תוכן".']})})})]})]})}function Bl({item:l,onSave:r}){const o=new Date().toISOString().slice(0,10),i=l.start_at?String(l.start_at).slice(0,10):"",f=l.start_at&&l.end_at?Math.max(1,Math.round((new Date(String(l.end_at).slice(0,10))-new Date(String(l.start_at).slice(0,10)))
22/864e5)+1):"",[c,u]=p.useState({publish_at:i||o,display_days:f===""?"":String(f),mode:l.days_of_week&&String(l.days_of_week).split(",").filter(Boolean).length?"days":"constant",days:l.days_of_week?String(l.days_of_week).split(",").filter(Boolean):[]}),S=g=>u(h=>({...h,days:h.days.includes(g)?h.days.filter(m=>m!==g):[...h.days,g]})),_=()=>{const g=`${c.publish_at||o}T00:00:00`;let h=null;const m=Number(c.display_days);if(m>0){const k=new Date(c.publish_at||o);k.setDate(k.getDate()+m-1),h=`${k.toISOString().slice(0,10)}T23:59:59`}r({start_at:g,end_at:h,display_from_time:null,display_to_time:null,days_of_week:c.mode==="days"&&c.days.length?c.days.join(","):null})};return e.jsxs("div",{className:"rounded-xl border border-border bg-white p-3",dir:"rtl",children:[e.jsx("p",{className:"text-xs font-bold text-slate-600 mb-2",children:"תזמון תצוגה"}),e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[0.6875rem] text-muted-foreground mb-0.5",children:"מתאריך פרסום"}),e.jsx("input",{type:"date",className:"w-full h-9 rounded-lg border border-border px-2 text-sm",value:c.publish_at,onChange:g=>u(h=>({...h,publish_at:g.target.value}))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[0.6875rem] text-muted-foreground mb-0.5",children:"מספר ימי תצוגה (ריק = ללא הגבלה)"}),e.jsx("input",{type:"number",min:"1",placeholder:"ללא הגבלה",className:"w-full h-9 rounded-lg border border-border px-2 text-sm",value:c.display_days,onChange:g=>u(h=>({...h,display_days:g.target.value}))})]})]}),e.jsxs("div",{className:"mt-3",children:[e.jsxs("div",{className:"inline-flex rounded-full border border-border p-0.5 bg-slate-50",children:[e.jsx("button",{type:"button",onClick:()=>u(g=>({...g,mode:"constant"})),className:`h-8 px-4 rounded-full text-xs font-bold ${c.mode==="constant"?"bg-cyan-600 text-white":"text-slate-600"}`,children:"קבוע (כל יום)"}),e.jsx("button",{type:"button",onClick:()=>u(g=>({...g,mode:"days"})),className:`h-8 px-4 rounded-full text-xs font-bold ${c.mode==="days"?"bg-cyan-600 text-white":"text-slate-600"}`,children:"רק בימים מסוימים"})]}),c.mode==="days"&&e.jsx("div",{className:"flex gap-1 mt-2",children:zl.map((g,h)=>e.jsx("button",{type:"button",onClick:()=>S(String(h)),className:`w-8 h-8 rounded-lg text-xs font-bold border ${c.days.includes(String(h))?"bg-cyan-600 text-white border-transparent":"bg-white border-border text-slate-600"}`,children:g},h))})]}),e.jsx("div",{className:"flex justify-end mt-3",children:e.jsxs(R,{onClick:_,className:"rounded-full h-9 bg-emerald-600 hover:bg-emerald-700 gap-1",children:[e.jsx(_e,{className:"w-4 h-4"})," שמור תזמון"]})})]})}function fo(){return e.jsx(Mr,{moduleKey:"digital_screen",children:e.jsx(kl,{})})}function Ll({onClose:l,onPick:r}){const o=[{key:"tv",label:"מסך TV",icon:xe,tint:"bg-indigo-50 text-indigo-600",desc:"מסך שתלוי על הקיר — חדר אוכל, לובי, מועדון. פריסה לאזורים, תזמון ושיוך למכשיר."},{key:"pr",label:"מסך PR",icon:cl,tint:"bg-emerald-50 text-emerald-600",desc:"מסך שמוצג לתושבים במרחב האישי — באתר, בנייד ובאפליקציה. תוכן מהמודולים או מהספרייה, בסבב."}];return e.jsx("div",{dir:"rtl",className:"fixed inset-0 z-50 flex items-center justify-center p-4 bg-slate-900/40",onClick:l,children:e.jsxs("div",{onClick:i=>i.stopPropagation(),className:"bg-white rounded-2xl shadow-xl w-full max-w-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 px-5 py-3.5 border-b border-slate-100",children:[e.jsx("h2",{className:"text-base font-extrabold text-slate-800",children:"איזה מסך ליצור?"}),e.jsx("button",{type:"button",onClick:l,"aria-label":"סגירה",className:"w-8 h-8 rounded-lg grid place-items-center text-slate-400 hover:bg-slate-100",children:e.jsx(le,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"p-5 grid grid-cols-1 sm:grid-cols-2 gap-3",children:o.map(i=>e.jsxs("button",{type:"button",onClick:()=>r(i.key),className:"text-right rounded-2xl border-2 border-slate-200 p-4 hover:border-indigo-400 hover:bg-indigo-50/30 transition-colors",children:[e.jsx("span",{className:`w-11 h-11 rounded-xl grid place-items-center mb-2 ${i.tint}`,children:e.jsx(i.icon,{className:"w-5 h-5"})}),e.jsx("span",{className:"block text-sm font-extrabold text-slate-800",children:i.label}),e.jsx("span",{className:"block text-[0.6875rem] text-slate-500 mt-1 leading-relaxed",children:i.desc})]},i.key))})]})})}export{Oa as CHANNEL_STATUS,kl as DigitalScreensContent,fo 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.