PageSourceSearch

https://www.supernoty.cz/assets/AdminPromoPage-BZr2gUnt.js

js supernoty.cz collected 2026-10-02 22:52:43 UTC 31,467 bytes, 2 lines download raw bytes

1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/adminLog-DJf5O5-H.js","assets/index-BVx_WpMX.js","assets/query-C5nF0jqi.js","assets/vendor-CMDGo4EK.js","assets/firebase-A3MA2iqO.js","assets/sentry-BlyCWhjt.js","assets/icons-DHW7FPWn.js","assets/index-CdBlW4zP.css"])))=>i.map(i=>d[i]);
2import{d as C,z as T,H as we,c as R,_ as Q,$ as ye,aj as je}from"./index-BVx_WpMX.js";import{u as xe,j as e}from"./query-C5nF0jqi.js";import{a as u}from"./vendor-CMDGo4EK.js";import{a as re,d as M,g as J,q as ne,c as G,w as Ne,n as Se,j as te,C as ke,o as ue,T as ee,f as ge,r as Ce,i as ze,p as Ie,u as Ue}from"./firebase-A3MA2iqO.js";import{I as De}from"./ImageCropModal-BSedD9Uh.js";import{A as pe}from"./AdminLoader-Cp60miV3.js";import{g as W,a_ as _e,au as Ae,m as Pe,b5 as Te,d as le,bm as Ee,ax as me,an as be,b1 as fe,b2 as ve,ar as Oe,r as Be,f as $e,bg as Le,X as ae,bn as Fe,q as he,a as Me,a1 as Re,J as qe,av as He,a3 as Ve}from"./icons-DHW7FPWn.js";import"./sentry-BlyCWhjt.js";function nt(){const[n,U]=u.useState(!0),[q,H]=u.useState(!1),[E,_]=u.useState(!1),k=xe(),[x,P]=u.useState([]),[O,y]=u.useState([]),[r,o]=u.useState([]),[c,d]=u.useState([]),[j,B]=u.useState([]),[A,F]=u.useState([]),[D,t]=u.useState([]),[l,h]=u.useState([]),[a,z]=u.useState("");u.useEffect(()=>{(async()=>{try{const[s,f]=await Promise.all([re(M(C,"settings","homepage")),re(M(C,"settings","promo"))]),N=s.exists()?s.data():{},$=f.exists()?f.data():{},w=N.heroFloatingIds??[],m=N.trendingScoreIds??N.heroScoreIds??[],b=N.navbarScoreIds??[],p=$.featuredScoreIds??[];o(w),B(m),t(b),P(p),z(JSON.stringify({h:w,t:m,n:b,f:p}));const S=[...new Set([...w,...m,...b,...p])];if(S.length>0){const Y=[];for(let v=0;v<S.length;v+=30)Y.push(S.slice(v,v+30));const L=new Map;for(const v of Y)(await J(ne(G(C,"scores"),Ne(Se(),"in",v)))).docs.forEach(se=>L.set(se.id,{id:se.id,...se.data()}));d(w.map(v=>L.get(v)).filter(Boolean)),F(m.map(v=>L.get(v)).filter(Boolean)),h(b.map(v=>L.get(v)).filter(Boolean)),y(p.map(v=>L.get(v)).filter(Boolean));const Z=w.filter(v=>L.has(v)),oe=m.filter(v=>L.has(v)),ie=b.filter(v=>L.has(v)),ce=p.filter(v=>L.has(v)),de=w.length-Z.length+(m.length-oe.length)+(b.length-ie.length)+(p.length-ce.length);de>0&&(o(Z),B(oe),t(ie),P(ce),T(`Vyčištěno ${de} smazaných not z promo sekcí`,{icon:"🧹"}))}}catch{T.error("Načítání selhalo")}finally{U(!1)}})()},[]),u.useEffect(()=>{if(!a)return;const s=JSON.stringify({h:r,t:j,n:D,f:x});_(s!==a)},[r,j,D,x,a]);const i=async()=>{var s;H(!0);try{const f=await re(M(C,"settings","promo")),N=new Set(((s=f.data())==null?void 0:s.featuredScoreIds)??[]),$=new Set(x);await Promise.all([te(M(C,"settings","homepage"),{heroFloatingIds:r,trendingScoreIds:j,navbarScoreIds:D},{merge:!0}),te(M(C,"settings","promo"),{featuredScoreIds:x},{merge:!0})]);const w=x,m=[...N].filter(p=>!$.has(p)),b=ke(C);for(const p of w)b.update(M(C,"scores",p),{isFeatured:!0});for(const p of m)b.update(M(C,"scores",p),{isFeatured:!1});(w.length>0||m.length>0)&&await b.commit(),T.success(`Promo uloženo — ${w.length} upřednostněných, ${m.length} odstraněných`);try{const{logAdmin:p}=await Q(async()=>{const{logAdmin:S}=await import("./adminLog-DJf5O5-H.js");return{logAdmin:S}},__vite__mapDeps([0,1,2,3,4,5,6,7]));p({action:"promo.update",category:"promo",targetType:"settings",summary:`Upravil promo — hero: ${r.length}, trending: ${j.length}, featured: ${w.length} (+${w.length-[...$].filter(S=>N.has(S)).length} nových, −${m.length})`,after:{heroIds:r.slice(0,15),trendingIds:j.slice(0,15),featuredIds:x.slice(0,15)}})}catch{}k.invalidateQueries({queryKey:["settings","homepage"]}),k.invalidateQueries({queryKey:["scores"]}),z(JSON.stringify({h:r,t:j,n:D,f:x})),_(!1)}catch{T.error("Ukládání selhalo")}finally{H(!1)}},g=(s,f,N,$,w,m)=>{if(f.includes(s.id)){T.error("Už přidáno");return}if(f.length>=m){T.error(`Maximum je ${m}`);return}N([...f,s.id]),w([...$,s])},I=(s,f,N,$,w)=>{N(f.filter(m=>m!==s)),w($.filter(m=>m.id!==s))},V=(s,f,N,$,w,m)=>{const b=s+f;if(b<0||b>=N.length)return;const p=[...N],S=[...w];[p[s],p[b]]=[p[b],p[s]],[S[s],S[b]]=[S[b],S[s]],$(p),m(S)},K=[...new Set([...x,...r,...j,...D])];return n?e.jsx("div",{className:"flex justify-center py-12",children:e.jsx(W,{size:24,className:"text-wine animate-spin"})}):e.jsxs(e.Fragment,{children:[e.jsx(we,{children:e.jsx("title",{children:"Promo | Admin | SuperNoty.cz"})}),e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(_e,{size:24,className:"text-wine"}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-charcoal",children:"Promo & Propagace"}),e.jsx("p",{className:"text-sm text-warm-light",children:"Hero bannery, announcement bar a kampaně na homepage i v katalogu."})]})]}),e.jsxs("button",{onClick:i,disabled:q,className:R("inline-flex items-center gap-1.5 text-white px-4 py-2 rounded-lg text-sm font-semibold transition-colors disabled:opacity-50 whitespace-nowrap flex-shrink-0",E?"bg-red-600 hover:bg-red-500 animate-pulse":"bg-wine hover:bg-wine-light"),children:[q?e.jsx(W,{size:14,className:"animate-spin flex-shrink-0"}):e.jsx(Ae,{size:14,className:"flex-shrink-0"}),e.jsx("span",{children:E?"Uložit změny":"Uložit vše"})]})]}),e.jsxs("div",{className:"space-y-6 max-w-3xl",children:[e.jsx(Je,{}),e.jsx(We,{}),e.jsx(X,{icon:e.jsx(Pe,{size:14,className:"text-amber-600"}),title:"Upřednostněné noty",description:"Tyto noty se zobrazí na prvních pozicích v katalogu a vyhledávání. Drag & drop pro řazení. Max 20.",color:"amber",max:20,ids:x,scores:O,excludeIds:K.filter(s=>!x.includes(s)),onAdd:s=>g(s,x,P,O,y,20),onRemove:s=>I(s,x,P,O,y),onMove:(s,f)=>V(s,f,x,P,O,y)}),e.jsx(X,{icon:e.jsx(Te,{size:14,className:"text-violet-600"}),title:"Hero — Plovoucí karty",description:"Album art karty v hero sekci na homepage (vpravo). Max 4.",color:"violet",max:4,ids:r,scores:c,excludeIds:K.filter(s=>!r.includes(s)),onAdd:s=>g(s,r,o,c,d,4),onRemove:s=>I(s,r,o,c,d),onMove:(s,f)=>V(s,f,r,o,c,d)}),e.jsx(X,{icon:e.jsx(le,{size:14,className:"text-emerald-600"}),title:"Pod Hero — Právě trendy",description:"Sekce 'Právě trendy' pod hero na homepage. Max 5.",color:"emerald",max:5,ids:j,scores:A,excludeIds:K.filter(s=>!j.includes(s)),onAdd:s=>g(s,j,B,A,F,5),onRemove:s=>I(s,j,B,A,F),onMove:(s,f)=>V(s,f,j,B,A,F)}),e.jsx(X,{icon:e.jsx(Ee,{size:14,className:"text-sky-600"}),title:"Navbar Megamenu",description:"'Oblíbené noty' v navigačním menu. Max 4.",color:"sky",max:4,ids:D,scores:l,excludeIds:K.filter(s=>!D.includes(s)),onAdd:s=>g(s,D,t,l,h,4),onRemove:s=>I(s,D,t,l,h),onMove:(s,f)=>V(s,f,D,t,l,h)})]})]})}function X({icon:n,title:U,description:q,color:H,max:E,ids:_,scores:k,excludeIds:x,onAdd:P,onRemove:O,onMove:y}){const[r,o]=u.useState(""),[c,d]=u.useState([]),[j,B]=u.useState(!1),[A,F]=u.useState(null),D=u.useCallback(async()=>
2{if(r.length<2){d([]);return}B(!0);try{const g=((await ye({query:r,filters:{},page:1,limit:15})).data.hits||[]).filter(I=>!_.includes(I.id)&&!x.includes(I.id));if(g.length>0){d(g);return}}catch{}try{const{collection:i,getDocs:g,query:I,where:V,orderBy:K,limit:s}=await Q(async()=>{const{collection:m,getDocs:b,query:p,where:S,orderBy:Y,limit:L}=await import("./firebase-A3MA2iqO.js").then(Z=>Z.ac);return{collection:m,getDocs:b,query:p,where:S,orderBy:Y,limit:L}},[]),{db:f}=await Q(async()=>{const{db:m}=await import("./index-BVx_WpMX.js").then(b=>b.bo);return{db:m}},__vite__mapDeps([1,2,3,4,5,6,7])),N=r.toLowerCase(),w=(await g(I(i(f,"scores"),V("status","==","published"),K("title"),s(30)))).docs.map(m=>({id:m.id,...m.data()})).filter(m=>{var b,p,S;return(((b=m.title)==null?void 0:b.toLowerCase().includes(N))||((p=m.composer)==null?void 0:p.toLowerCase().includes(N))||((S=m.interpret)==null?void 0:S.toLowerCase().includes(N)))&&!_.includes(m.id)&&!x.includes(m.id)}).slice(0,15);d(w)}catch{d([])}finally{B(!1)}},[r,_,x]);u.useEffect(()=>{const i=setTimeout(D,300);return()=>clearTimeout(i)},[r]);const t=i=>F(i),l=(i,g)=>{if(i.preventDefault(),A===null||A===g)return;const I=g>A?1:-1;y(A,I),F(g)},h=()=>F(null),a={amber:{bg:"bg-amber-50/50",border:"border-amber-200",badge:"bg-amber-50 text-amber-700"},violet:{bg:"bg-violet-50/50",border:"border-violet-200",badge:"bg-violet-50 text-violet-700"},emerald:{bg:"bg-emerald-50/50",border:"border-emerald-200",badge:"bg-emerald-50 text-emerald-700"},sky:{bg:"bg-sky-50/50",border:"border-sky-200",badge:"bg-sky-50 text-sky-700"}},z=a[H]||a.amber;return e.jsxs("div",{className:R("rounded-xl border p-5",z.bg,z.border),children:[e.jsxs("div",{className:"flex items-center justify-between mb-1",children:[e.jsxs("h2",{className:"text-sm font-bold text-charcoal flex items-center gap-1.5",children:[n," ",U]}),e.jsxs("span",{className:R("px-1.5 py-0.5 rounded text-[10px] font-bold",z.badge),children:[k.length,"/",E]})]}),e.jsx("p",{className:"text-xs text-warm-light mb-4",children:q}),e.jsxs("div",{className:"space-y-1.5 mb-4",children:[k.map((i,g)=>e.jsxs("div",{draggable:!0,onDragStart:()=>t(g),onDragOver:I=>l(I,g),onDragEnd:h,className:R("flex items-center gap-2.5 bg-charcoal/[0.03] rounded-lg p-2.5 border border-white/5 transition-all cursor-grab active:cursor-grabbing",A===g&&"opacity-50 scale-[0.98]"),children:[e.jsx(He,{size:14,className:"text-warm-light flex-shrink-0"}),e.jsxs("div",{className:"flex flex-col gap-0.5 flex-shrink-0",children:[e.jsx("button",{onClick:()=>y(g,-1),disabled:g===0,type:"button",className:"text-warm-light hover:text-charcoal disabled:opacity-20 transition-colors",children:e.jsx(fe,{size:10})}),e.jsx("button",{onClick:()=>y(g,1),disabled:g===k.length-1,type:"button",className:"text-warm-light hover:text-charcoal disabled:opacity-20 transition-colors",children:e.jsx(ve,{size:10})})]}),i.albumArtUrl?e.jsx("img",{src:i.albumArtUrl,alt:"",className:"w-10 h-10 rounded-lg object-cover flex-shrink-0"}):e.jsx("div",{className:"w-10 h-10 rounded-lg bg-wine/10 flex items-center justify-center flex-shrink-0",children:e.jsx(le,{size:14,className:"text-wine/30"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-charcoal truncate",children:i.title}),e.jsxs("p",{className:"text-[10px] text-warm-light truncate",children:[i.interpret||i.composer,i.type==="set"&&e.jsx("span",{className:"ml-1 text-violet-600",children:"[set]"})," · ",i.price," Kč"]})]}),e.jsx("span",{className:R("text-[10px] font-bold rounded px-1.5 py-0.5",z.badge),children:g+1}),e.jsx("button",{onClick:()=>O(i.id),type:"button",className:"p-1 rounded hover:bg-red-50 text-warm-light hover:text-red-600 transition-colors",children:e.jsx(ae,{size:12})})]},i.id)),k.length===0&&e.jsx("div",{className:"text-xs text-warm-light italic py-3 text-center",children:"Žádné vybrané — zobrazí se automaticky"})]}),_.length<E&&e.jsxs("div",{className:"relative",children:[e.jsxs("div",{className:"flex items-center gap-2 bg-charcoal/[0.03] rounded-lg border border-white/5 px-3 py-2",children:[e.jsx(Ve,{size:12,className:"text-warm-light flex-shrink-0"}),e.jsx("input",{value:r,onChange:i=>o(i.target.value),placeholder:"Hledat noty nebo sety...",className:"flex-1 bg-transparent text-charcoal text-xs placeholder:text-warm-light focus:outline-none"}),j&&e.jsx(W,{size:12,className:"animate-spin text-warm-light"})]}),c.length>0&&r.length>=2&&e.jsx("div",{className:"absolute z-20 top-full mt-1 left-0 right-0 bg-white border border-warm-lightest roun
2ded-lg shadow-2xl max-h-56 overflow-y-auto",children:c.map(i=>e.jsxs("button",{type:"button",onClick:()=>{P({id:i.id,...i}),o(""),d([])},className:"w-full flex items-center gap-2.5 px-3 py-2 hover:bg-charcoal/5 transition-colors text-left",children:[i.albumArtUrl?e.jsx("img",{src:i.albumArtUrl,alt:"",className:"w-8 h-8 rounded object-cover"}):e.jsx("div",{className:"w-8 h-8 rounded bg-wine/10 flex items-center justify-center",children:e.jsx(le,{size:10,className:"text-wine/30"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-charcoal truncate",children:i.title}),e.jsx("p",{className:"text-[10px] text-warm-light truncate",children:i.interpret||i.composer})]}),i.type==="set"&&e.jsx("span",{className:"text-[9px] bg-violet-50 text-violet-700 px-1 py-0.5 rounded",children:"set"}),e.jsxs("span",{className:"text-[10px] text-wine font-bold",children:[i.price," Kč"]})]},i.id))})]})]})}const Ke={title:"",subtitle:"",imageUrl:"",bgColor:"#1a0a10",textColor:"light",overlayOpacity:50,ctaText:"Procházet katalog",ctaLink:"/noty",ctaStyle:"primary",isActive:!0,priority:0},Qe=[{value:"primary",label:"Primary (wine)"},{value:"secondary",label:"Secondary (outline)"},{value:"ghost",label:"Ghost (text only)"}];function Je(){const[n,U]=u.useState([]),[q,H]=u.useState(!0),[E,_]=u.useState(!1),[k,x]=u.useState(null),[P,O]=u.useState(null),[y,r]=u.useState(null),o=xe();u.useEffect(()=>{(async()=>{const t=await J(ne(G(C,"heroSlides"),ue("priority","asc")));U(t.docs.map(l=>({id:l.id,...l.data()}))),H(!1)})()},[]);const c=()=>{const t={...Ke,id:`slide_${Date.now()}`,priority:n.length};U([...n,t]),x(n.length)},d=(t,l,h)=>{const a=[...n];a[t][l]=h,U(a)},j=t=>{const l=n[t];l.title&&!confirm(`Smazat slide "${l.title}"?`)||(U(n.filter((h,a)=>a!==t)),k===t?x(null):k!==null&&k>t&&x(k-1))},B=(t,l)=>{const h=t+l;if(h<0||h>=n.length)return;const a=[...n];[a[t],a[h]]=[a[h],a[t]],a.forEach((z,i)=>z.priority=i),U(a),k===t?x(h):k===h&&x(t)},A=(t,l,h)=>{var z;const a=(z=t.target.files)==null?void 0:z[0];a&&(r({file:a,idx:l,field:h}),t.target.value="")},F=async(t,l)=>{if(!y)return;const{idx:h,field:a}=y;r(null),O(h);try{const z=n[h].id,g=Ce(je,`heroSlides/${z}/${a==="mobileImageUrl"?"mobile":"desktop"}-${Date.now()}.webp`);await ze(g,t);const I=await Ie(g);d(h,a,I),T.success(a==="mobileImageUrl"?"Mobilní obrázek nahrán":"Obrázek nahrán")}catch{T.error("Nahrávání obrázku selhalo")}finally{O(null)}},D=async()=>{_(!0);try{const t=await J(G(C,"heroSlides"));await Promise.all(t.docs.map(l=>ge(l.ref)));for(const l of n){const{id:h,...a}=l;await te(M(C,"heroSlides",h),{...a,updatedAt:ee.now()})}o.invalidateQueries({queryKey:["heroSlides"]});try{const{logAdmin:l}=await Q(async()=>{const{logAdmin:h}=await import("./adminLog-DJf5O5-H.js");return{logAdmin:h}},__vite__mapDeps([0,1,2,3,4,5,6,7]));l({action:"hero.update",category:"hero",targetType:"heroSlide",summary:`Uložil hero carousel — ${n.length} ${n.length===1?"slide":n.length<5?"slidy":"slidů"}`,after:{count:n.length,titles:n.map(h=>h.title).slice(0,10)}})}catch{}T.success(`Hero carousel uložen — ${n.length} slidů`)}catch(t){T.error(t.message)}finally{_(!1)}};return q?e.jsx(pe,{text:"Načítání hero slidů…",center:!0,padding:"py-6"}):e.jsxs("div",{className:"bg-white rounded-xl border border-warm-lightest p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-sm font-bold text-charcoal flex items-center gap-1.5",children:[e.jsx(me,{size:14,className:"text-rose-600"}),"Hero Carousel",e.jsx("span",{className:"text-[9px] text-warm-light font-normal",children:"hlavní sekce homepage"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:c,className:"text-xs text-wine hover:text-charcoal flex items-center gap-1 transition-colors",children:[e.jsx(be,{size:12})," Nový slide"]}),e.jsx("button",{onClick:D,disabled:E,className:"px-3 py-1 bg-wine hover:bg-wine-dark text-white rounded-lg text-xs font-semibold transition-colors disabled:opacity-50",children:E?"Ukládám...":"Uložit carousel"})]})]}),n.length===0?e.jsx("p",{className:"text-xs text-warm-gray/60 py-3",children:'Žádné slidy. Zobrazí se výchozí hero. Klikněte "Nový 
2slide" pro přidání.'}):e.jsx("div",{className:"space-y-2",children:n.map((t,l)=>{const h=k===l;return e.jsxs("div",{className:"border border-white/5 rounded-lg overflow-hidden",children:[e.jsxs("div",{className:"flex items-center gap-2 p-3 cursor-pointer hover:bg-charcoal/[0.03]",onClick:()=>x(h?null:l),children:[e.jsxs("div",{className:"flex flex-col gap-0.5 flex-shrink-0",children:[e.jsx("button",{onClick:a=>{a.stopPropagation(),B(l,-1)},disabled:l===0,type:"button",className:"text-warm-light hover:text-charcoal disabled:opacity-20 transition-colors",children:e.jsx(fe,{size:10})}),e.jsx("button",{onClick:a=>{a.stopPropagation(),B(l,1)},disabled:l===n.length-1,type:"button",className:"text-warm-light hover:text-charcoal disabled:opacity-20 transition-colors",children:e.jsx(ve,{size:10})})]}),e.jsx("div",{className:"w-16 h-9 rounded flex-shrink-0 relative overflow-hidden border border-white/10",style:{backgroundColor:t.bgColor},children:t.imageUrl&&e.jsx("img",{src:t.imageUrl,alt:"",className:"absolute inset-0 w-full h-full object-cover"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-bold text-charcoal truncate",children:t.title||"(bez názvu)"}),e.jsx("p",{className:"text-[10px] text-warm-light truncate",children:t.subtitle||"—"})]}),e.jsx("label",{className:"flex-shrink-0",onClick:a=>a.stopPropagation(),children:e.jsx("input",{type:"checkbox",checked:t.isActive,onChange:a=>d(l,"isActive",a.target.checked),className:"accent-wine"})}),e.jsxs("span",{className:"text-[10px] font-bold text-warm-light flex-shrink-0",children:["#",l+1]}),h?e.jsx(Oe,{size:14,className:"text-warm-light"}):e.jsx(Be,{size:14,className:"text-warm-light"}),e.jsx("button",{onClick:a=>{a.stopPropagation(),j(l)},className:"p-1 text-warm-light hover:text-red-600 transition-colors flex-shrink-0",children:e.jsx($e,{size:12})})]}),h&&e.jsxs("div",{className:"border-t border-white/5 p-4 space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 flex items-center gap-1",children:[e.jsx(Le,{size:9})," Nadpis"]}),e.jsx("input",{value:t.title,onChange:a=>d(l,"title",a.target.value),placeholder:"Noty, co Vás povedou",className:"w-full px-3 py-1.5 bg-white border border-warm-lightest rounded text-sm text-charcoal placeholder:text-warm-light focus:border-wine/50 focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 block",children:"Podnadpis"}),e.jsx("textarea",{value:t.subtitle,onChange:a=>d(l,"subtitle",a.target.value),placeholder:"Interaktivní zobrazení not...",rows:2,className:"w-full px-3 py-1.5 bg-white border border-warm-lightest rounded text-sm text-charcoal placeholder:text-warm-light focus:border-wine/50 focus:outline-none resize-none"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 flex items-center gap-1",children:[e.jsx(me,{size:9})," Desktop obrázek"]}),t.imageUrl?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.imageUrl,alt:"",className:"w-full h-24 object-cover rounded border border-warm-lightest"}),e.jsx("button",{onClick:()=>d(l,"imageUrl",""),className:"absolute top-1 right-1 bg-black/60 text-white p-1 rounded opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(ae,{size:10})})]}):e.jsxs("label",{className:"flex items-center justify-center h-24 border border-dashed border-warm-lightest rounded text-warm-light text-xs cursor-pointer hover:border-wine/30 transition-colors",children:[P===l?e.jsx(W,{size:14,className:"animate-spin"}):"Nahrát obrázek",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:a=>A(a,l,"imageUrl")})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 block",children:["Mobilní obrázek ",e.jsx("span",{className:"text-warm-light",children:"(volitelné)"})]}),t.mobileImageUrl?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:t.mobileImageUrl,alt:"",className:"w-full h-24 object-cover rounded border border-warm-lightest"}),e.jsx("button",{onClick:()=>d(l,"mobileImageUrl",""),className:"absolute top-1 right-1 bg-black/60 text-white p-1 rounded opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx(ae,{size:10})})]}):e.jsxs("label",{className:"flex items-center justify-center h-24 border border-dashed border-warm-lightest roun
2ded text-warm-light text-xs cursor-pointer hover:border-wine/30 transition-colors",children:[P===l?e.jsx(W,{size:14,className:"animate-spin"}):"Nahrát mobilní",e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:a=>A(a,l,"mobileImageUrl")})]})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 flex items-center gap-1",children:[e.jsx(Fe,{size:9})," Barva pozadí"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"color",value:t.bgColor,onChange:a=>d(l,"bgColor",a.target.value),className:"w-8 h-8 rounded cursor-pointer border border-warm-lightest"}),e.jsx("input",{value:t.bgColor,onChange:a=>d(l,"bgColor",a.target.value),className:"flex-1 px-2 py-1 bg-white border border-warm-lightest rounded text-xs text-charcoal font-mono focus:outline-none focus:border-wine/50"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 block",children:"Barva textu"}),e.jsxs("select",{value:t.textColor,onChange:a=>d(l,"textColor",a.target.value),className:"w-full px-2 py-1.5 bg-white border border-warm-lightest rounded text-xs text-charcoal focus:outline-none focus:border-wine/50 [color-scheme:light]",children:[e.jsx("option",{value:"light",children:"Světlý (bílý)"}),e.jsx("option",{value:"dark",children:"Tmavý (černý)"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 block",children:["Overlay ",t.overlayOpacity,"%"]}),e.jsx("input",{type:"range",min:0,max:100,value:t.overlayOpacity,onChange:a=>d(l,"overlayOpacity",Number(a.target.value)),className:"w-full accent-wine"})]})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 block",children:"CTA text"}),e.jsx("input",{value:t.ctaText,onChange:a=>d(l,"ctaText",a.target.value),placeholder:"Procházet katalog",className:"w-full px-2 py-1.5 bg-white border border-warm-lightest rounded text-xs text-charcoal placeholder:text-warm-light focus:outline-none focus:border-wine/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 block",children:"CTA odkaz"}),e.jsx("input",{value:t.ctaLink,onChange:a=>d(l,"ctaLink",a.target.value),placeholder:"/noty",className:"w-full px-2 py-1.5 bg-white border border-warm-lightest rounded text-xs text-charcoal placeholder:text-warm-light focus:outline-none focus:border-wine/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 block",children:"CTA styl"}),e.jsx("select",{value:t.ctaStyle,onChange:a=>d(l,"ctaStyle",a.target.value),className:"w-full px-2 py-1.5 bg-white border border-warm-lightest rounded text-xs text-charcoal focus:outline-none focus:border-wine/50 [color-scheme:light]",children:Qe.map(a=>e.jsx("option",{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 flex items-center gap-1",children:[e.jsx(he,{size:9})," Platný od ",e.jsx("span",{className:"text-warm-light",children:"(volitelné)"})]}),e.jsx("input",{type:"datetime-local",value:t.validFrom&&typeof t.validFrom.toDate=="function"?t.validFrom.toDate().toISOString().slice(0,16):"",onChange:a=>d(l,"validFrom",a.target.value?ee.fromDate(new Date(a.target.value)):null),className:"w-full px-2 py-1.5 bg-white border border-warm-lightest rounded text-xs text-charcoal focus:outline-none focus:border-wine/50 [color-scheme:light]"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"text-[10px] text-warm-gray font-semibold mb-1 flex items-center gap-1",children:[e.jsx(he,{size:9})," Platný do ",e.jsx("span",{className:"text-warm-light",children:"(volitelné)"})]}),e.jsx("input",{type:"datetime-local",value:t.validUntil&&typeof t.validUntil.toDate=="function"?t.validUntil.toDate().toISOString().slice(0,16):"",onCh
2ange:a=>d(l,"validUntil",a.target.value?ee.fromDate(new Date(a.target.value)):null),className:"w-full px-2 py-1.5 bg-white border border-warm-lightest rounded text-xs text-charcoal focus:outline-none focus:border-wine/50 [color-scheme:light]"})]})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] text-warm-gray font-semibold mb-2 flex items-center gap-1",children:[e.jsx(Me,{size:9})," Náhled"]}),e.jsxs("div",{className:"relative rounded-lg overflow-hidden h-32",style:{backgroundColor:t.bgColor},children:[t.imageUrl&&e.jsx("img",{src:t.imageUrl,alt:"",className:"absolute inset-0 w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0",style:{backgroundColor:`rgba(0,0,0,${t.overlayOpacity/100})`}}),e.jsxs("div",{className:"relative z-10 p-4 flex flex-col justify-center h-full",children:[e.jsx("h3",{className:R("text-lg font-bold font-display leading-tight",t.textColor==="light"?"text-white":"text-black"),children:t.title||"Nadpis slide"}),e.jsx("p",{className:R("text-xs mt-1 max-w-[60%]",t.textColor==="light"?"text-white/70":"text-black/70"),children:t.subtitle||"Podnadpis slide"}),t.ctaText&&e.jsx("div",{className:"mt-2",children:e.jsx("span",{className:R("inline-block px-3 py-1 rounded-lg text-[10px] font-bold",t.ctaStyle==="primary"&&"bg-wine text-white",t.ctaStyle==="secondary"&&"border border-white/30 text-white",t.ctaStyle==="ghost"&&"text-white underline"),children:t.ctaText})})]})]})]})]})]},t.id)})}),y&&e.jsx(De,{file:y.file,aspectRatio:y.field==="mobileImageUrl"?9/16:16/9,outputWidth:y.field==="mobileImageUrl"?600:1920,filenamePrefix:`hero-slide-${y.field==="mobileImageUrl"?"mobile":"desktop"}`,onConfirm:F,onCancel:()=>r(null)})]})}const Ge=[{value:"all",label:"Všichni"},{value:"anonymous",label:"Nepřihlášení"},{value:"logged_in",label:"Přihlášení"},{value:"no_subscription",label:"Bez předplatného"},{value:"has_subscription",label:"S předplatným"},{value:"bronze",label:"Bronze tier"},{value:"silver",label:"Silver tier"},{value:"gold",label:"Gold tier"},{value:"new_user",label:"Nový uživatel (<7 dní)"},{value:"returning",label:"Vracející se (>1 nákup)"}];function We(){const[n,U]=u.useState([]),[q,H]=u.useState(!0),[E,_]=u.useState(!1);u.useEffect(()=>{(async()=>{const r=await J(ne(G(C,"banners"),ue("priority","desc")));U(r.docs.map(o=>({id:o.id,...o.data()}))),H(!1)})()},[]);const k=()=>{const r={id:`banner_${Date.now()}`,text:"",link:"",bgColor:"#7f1d1d",textColor:"#ffffff",audience:[],isActive:!0,priority:n.length,dismissible:!0};U([...n,r])},x=(r,o,c)=>{const d=[...n];d[r][o]=c,U(d)},P=r=>{const o=n[r];o.text&&!confirm(`Smazat banner "${o.text.slice(0,30)}..."?`)||U(n.filter((c,d)=>d!==r))},O=(r,o)=>{const c=n[r].audience||[],d=c.includes(o)?c.filter(j=>j!==o):[...c,o];x(r,"audience",d)},y=async()=>{_(!0);try{const r=await J(G(C,"banners"));await Promise.all(r.docs.map(o=>ge(o.ref)));for(const o of n){const{id:c,...d}=o;await te(M(C,"banners",c),{...d,updatedAt:ee.now()})}try{await Ue(M(C,"settings","site"),{announcementEnabled:!1,announcementText:"",announcementLink:""})}catch{}try{const{logAdmin:o}=await Q(async()=>{const{logAdmin:c}=await import("./adminLog-DJf5O5-H.js");return{logAdmin:c}},__vite__mapDeps([0,1,2,3,4,5,6,7]));o({action:"promo.banners",category:"promo",targetType:"banner",summary:`Uložil ${n.length} ${n.length===1?"banner":n.length<5?"bannery":"bannerů"}`,after:{count:n.length}})}catch{}T.success("Bannery uloženy (starý banner vyčištěn)")}catch(r){T.error(r.message)}finally{_(!1)}};return q?e.jsx(pe,{text:"Načítání bannerů…",center:!0,padding:"py-6"}):e.jsxs("div",{className:"bg-white rounded-xl border border-warm-lightest p-5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("h2",{className:"text-sm font-bold text-charcoal flex items-center gap-1.5",children:[e.jsx(Re,{size:14,className:"text-pink-600"}),"Oznamovací bannery",e.jsx("span",{className:"text-[9px] text-warm-light font-normal",children:"pod navigací"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs("button",{onClick:k,className:"text-xs text-wine hover:text-charcoal flex items-center gap-1 transition-colors",children:[e.jsx(be,{size:12})," Nový banner"]}),e.jsx("button",{onClick:y,disabled:E,className:"px-3 py-1 bg-wine hover:bg-wine-dark text-white rounded-lg text-xs font-semibold transition-colors disabled:opacity-50",children:E?"Ukládám...":"Uložit bannery"})]})]}),n.length===0?e.jsx("p",{className:"text-xs text-warm-gray/60 py-3",children:'Žádné bannery. Klikněte "Nový banner" pro přidání.'}):e.jsx("div",{className:"space-y-3",children:n.map((r,o)=>e.jsxs("div",{className:"border border-white/5 rounded-lg p-3 space-y-3",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("label",{className:"mt-1 cursor-pointer",children:e.jsx("input",{type:"checkbox",checked:r.isActive,onChange:c=>x(o,"isActive",c.target.checked),className:"accent-wine"})}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("input",{value:r.text,onChange:c=>x(o,"text",c.target.value),placeholder:"🎉 Text banneru...",className:"w-full px-3 py-1.5 bg-white border border-warm-lightest roun
2ded text-sm text-charcoal placeholder:text-warm-light focus:border-wine/50 focus:outline-none"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:r.link,onChange:c=>x(o,"link",c.target.value),placeholder:"Odkaz (volitelné)",className:"flex-1 px-3 py-1.5 bg-white border border-warm-lightest rounded text-xs text-charcoal placeholder:text-warm-light focus:border-wine/50 focus:outline-none"}),e.jsx("input",{type:"color",value:r.bgColor,onChange:c=>x(o,"bgColor",c.target.value),className:"w-8 h-8 rounded cursor-pointer border border-warm-lightest",title:"Barva pozadí"}),e.jsxs("label",{className:"flex items-center gap-1 text-[10px] text-warm-gray",children:[e.jsx("input",{type:"checkbox",checked:r.dismissible,onChange:c=>x(o,"dismissible",c.target.checked),className:"accent-wine"}),"Zavíratelný"]})]})]}),e.jsx("button",{onClick:()=>P(o),className:"p-1 text-warm-gray hover:text-red-600 transition-colors",children:e.jsx(ae,{size:14})})]}),e.jsxs("div",{children:[e.jsxs("p",{className:"text-[10px] text-warm-gray font-semibold mb-1.5 flex items-center gap-1",children:[e.jsx(qe,{size:9})," Komu zobrazit:",r.audience.length===0&&e.jsx("span",{className:"text-warm-gray/50 font-normal",children:"všem"})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:Ge.map(c=>e.jsx("button",{onClick:()=>O(o,c.value),className:R("text-[10px] px-2 py-0.5 rounded-full border transition-colors",(r.audience||[]).includes(c.value)?"bg-wine/10 text-wine border-wine/30":"bg-charcoal/[0.03] text-warm-gray border-warm-lightest hover:border-charcoal/1
25"),children:c.label},c.value))})]}),r.text&&e.jsxs("div",{className:"rounded-lg text-xs text-center py-2 px-3",style:{backgroundColor:r.bgColor,color:r.textColor},children:["Náhled: ",r.text]})]},r.id))})]})}export{nt 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.