1import{j as e}from"./vendor-query-ClTBLi42.js";import{r as m}from"./vendor-react-BqRewklv.js";import{A as U}from"./AdminLayout-QL9o9cOy.js";import{B as c,X as E,s as d}from"./index-DGpp3eJC.js";import{C as Z,a as F}from"./card-DPTViJzM.js";import{I as l}from"./input-CKnX-Jhw.js";import{L as i}from"./label-GGeZhsGQ.js";import{T as I}from"./textarea-9ZFeI_Oe.js";import{S as w,a as z,b as S,c as L,d as j}from"./select-BHSnos8o.js";import{S as D}from"./switch-CzGQXmFL.js";import{D as R,a as V,b as B,c as X,d as Y}from"./dialog-BVqnggpa.js";import{u as o}from"./index-COB36PEp.js";import{CATEGORY_COLORS as h}from"./AttractionDialog-lVLyzTtt.js";import{M as K}from"./map-pin-yq2QYqsc.js";import{P as G}from"./plus-BXiaRCE9.js";import{L as v}from"./loader-circle-DxghVRV2.js";import{E as T}from"./external-link-D3JFd_PG.js";import{S as H}from"./square-pen-CVGIjLUz.js";import{T as J}from"./trash-2-DPhdOip7.js";import"./index-BtUkuaxN.js";import"./index-DzVnluf7.js";import"./vendor-supabase-Clqdqihj.js";import"./index-vlChlfhG.js";import"./sparkles-Cksq33fz.js";import"./qr-code-CnLrZIQ4.js";import"./users-DMSel5sO.js";import"./newspaper-D2WBcztj.js";import"./gift-DjR9WRP9.js";import"./mail-BulA7arx.js";import"./image-Dg87EHdT.js";import"./file-text-MvZK9k2z.js";import"./trending-up-CdBRmtkC.js";import"./shield-check-badJAafZ.js";import"./shield-BZD8Pqny.js";import"./eye-D9HWoTra.js";import"./vendor-helmet-B3WFvB_A.js";import"./vendor-i18n-CzlVjiK3.js";import"./index-CIJXpiZ_.js";import"./index-BFLjGiQW.js";import"./index-CqyPM0RU.js";import"./chevron-up-eYdkrTS1.js";import"./check-1uH3r8mc.js";const Q={name:"",short:"",category:"Túra",duration:"",distance_km:0,mode:"foot",image_url:"",lat:49.1142846,lng:19.8009764,sort_order:0,is_active:!0,color:h.Túra||""},Fe=()=>{const[g,A]=m.useState([]),[P,f]=m.useState(!0),[s,a]=m.useState(null),[N,b]=m.useState(!1),[k,y]=m.useState(!1),$=async r=>{if(!s)return;if(r.size>5*1024*1024)return o.error("Max 5 MB");y(!0);const t=r.name.split(".").pop()||"jpg",n=`attractions/${Date.now()}-${Math.random().toString(36).slice(2,8)}.${t}`,{error:p}=await d.storage.from("gallery").upload(n,r,{cacheControl:"31536000",upsert:!1,contentType:r.type});if(y(!1),p)return o.error(p.message);const{data:x}=d.storage.from("gallery").getPublicUrl(n);a({...s,image_url:x.publicUrl}),o.success("Obrázok nahraný")},u=async()=>{f(!0);const{data:r,error:t}=await d.from("attractions").select("*").order("sort_order",{ascending:!0});t&&o.error(t.message),A(r||[]),f(!1)};m.useEffect(()=>{u()},[]);const q=async r=>{var p,x,C;if(r.preventDefault(),!s)return;b(!0);const t={name:s.name.trim(),short:s.short.trim(),category:s.category.trim()||"Tip",duration:((p=s.duration)==null?void 0:p.trim())||null,distance_km:Number(s.distance_km)||0,mode:s.mode,image_url:((x=s.image_url)==null?void 0:x.trim())||null,lat:Number(s.lat),lng:Number(s.lng),sort_order:Number(s.sort_order)||0,is_active:s.is_active,moderation_status:"approved",color:((C=s.color)==null?void 0:C.trim())||null},{error:n}=s.id?await d.from("attractions").update(t).eq("id",s.id):await d.from("attractions").insert(t);if(b(!1),n)return o.error(n.message);o.success(s.id?"Atrakcia upravená":"Atrakcia pridaná"),a(null),u()},O=async r=>{if(!confirm("Naozaj zmazaÅ¥ túto atrakciu?"))return;const{error:t}=await d.from("attractions").delete().eq("id",r);if(t)return o.error(t.message);o.success("Zmazané"),u()},M=async r=>{const{error:t}=await d.from("attractions").update({is_active:!r.is_active}).eq("id",r.id);if(t)return o.error(t.message);u()},_=async(r,t)=>{const{error:n}=await d.from("attractions").update({moderation_status:t}).eq("id",r.id);if(n)return o.error(n.message);o.success(t==="approved"?"Schválené a zverejnené":"Zamietnuté"),u()};return e.jsx(U,{children:e.jsxs("div",{className:"max-w-5xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(K,{className:"w-6 h-6"})," Atrakcie /app"]}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:['Modul âInÅ¡pirácia z RaÄkovej". Cieľové súradnice nájdi na ',e.jsx("a",{className:"underline",href:"https://mapy.com",target:"_blank",rel:"noopener noreferrer",children:"mapy.com"}),' â pravý klik na bod â âÄo je tu" â skopÃruj ',e.jsx("code",{children:"lat, lng"}),"."]})]}),e.jsxs(c,{onClick:()=>a({...Q,sort_order:g.length+1}),children:[e.jsx(G,{className:"w-4 h-4 mr-2"})," PridaÅ¥ atrakciu"]})]}),P?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(v,{className:"w-6 h-6 animate-spin"})}):e.jsxs("div",{className:"grid gap-3",children:[g.map(r=>e.jsx(Z,{className:r.is_active?"":"opacity-60",children:e.jsxs(F,{className:"p-4 flex items-center gap-4",children:[r.image_url&&e.jsx("img",{src:r.image_url,alt:"",className:"w-20 h-20 rounded-lg object-cover shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1 flex-wrap",children:[e.jsx("h3",{className:"font-bold truncate",children:r.name}),e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-muted",children:r.category}),e.jsx("span",{className:"text-xs text-muted-foreground",children:r.mode==="foot"?"peÅ¡o":"autom"}),r.moderation_status&&r.moderation_status!=="approved"&&e.jsx("span",{className:"text-xs px-2 py-0.5 rounded bg-amber-500/15 text-amber-700 dark:text-amber-400",children:r.moderation_status==="pending"?"Äaká na schválenie":"zamietnuté"})]}),e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-2",children:r.short}),e.jsxs("p",{className:"text-[11px] text-muted-foreground mt-1 font-mono",children:[r.lat.toFixed(5),", ",r.lng.toFixed(5)," · #",r.sort_order,e.jsxs("a",{href:`https://mapy.com/sk/turisticka?source=coor&id=${r.lng}%2C${r.lat}&x=${r.lng}&y=${r.lat}&z=15`,target:"_blank",rel:"noopener noreferrer",className:"ml-2 inline-flex items-center gap-0.5 underline",children:["overiÅ¥ ",e.jsx(T,{className:"w-3 h-3"})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[r.moderation_status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsx(c,{size:"sm",onClick:()=>_(r,"approved"),children:"SchváliÅ¥"}),e.jsx(c,{size:"sm",variant:"outline",onClick:()=>_(r,"rejected"),children:"ZamietnuÅ¥"})]}),e.jsx(D,{checked:r.is_active,onCheckedChange:()=>M(r)}),e.jsx(c,{size:"sm",variant:"outline",onClick:()=>a(r),children:e.jsx(H,{className:"w-3.5 h-3.5"})}),e.jsx(c,{size:"sm",variant:"outline",onClick:()=>O(r.id),children:e.jsx(J,{className:"w-3.5 h-3.5"})})]})]})},r.id)),g.length===0&&e.jsx("p",{className:"text-center text-sm text-muted-foreground py-12",children:"Žiadne atrakcie. Pridaj prvú."})]}),e.jsx(R,{open:!!s,onOpenChange:r=>!r&&a(null),children:e.jsxs(V,{className:"max-w-lg max-h-[90vh] overflow-y-auto",children:[e.jsx(B,{children:e.jsx(X,{children:s!=null&&s.id?"UpraviÅ¥ atrakciu":"PridaÅ¥ atrakciu"})}),s&&e.jsxs("form",{onSubmit:q,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx(i,{children:"Názov"}),e.jsx(l,{value:s.name,onChange:r=>a({...s,name:r.target.value}),required:!0})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Krátky popis (2â3 vety)"}),e.jsx(I,{rows:3,value:s.short,onChange:r=>a({...s,short:r.target.value}),required:!0})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(i,{children:"Kategória"}),e.jsxs(w,{value:s.category,onValueChange:r=>a({...s,category:r,color:h[r]||""}),children:[e.jsx(z,{children:e.jsx(S,{})}),e.jsx(L,{children:Object.keys(h).map(r=>e.jsx(j,{value:r,children:e.jsxs("span",{className:"inline-flex items-center gap-2",children:[e.jsx("span",{className:"inline-block w-3 h-3 rounded-full",style:{backgroundColor:h[r]}}),r]})},r))})]}),e.jsx("p",{className:"text-[10px] text-muted-foreground mt-1",children:"Známe kategórie majú vlastnú farbu pinu na mape v /app."})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Trvanie"}),e.jsx(l,{value:s.duration||"",onChange:r=>a({...s,duration:r.target.value}),placeholder:"napr. 4 h"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(i,{children:"VzdialenosÅ¥ (km)"}
1),e.jsx(l,{type:"number",step:"0.1",value:s.distance_km,onChange:r=>a({...s,distance_km:Number(r.target.value)})})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Doprava"}),e.jsxs(w,{value:s.mode,onValueChange:r=>a({...s,mode:r}),children:[e.jsx(z,{children:e.jsx(S,{})}),e.jsxs(L,{children:[e.jsx(j,{value:"foot",children:"PeÅ¡o (turistická navigácia)"}),e.jsx(j,{value:"car",children:"Autom"})]})]})]})]}),e.jsxs("div",{className:"rounded-lg border p-3 bg-muted/40 space-y-2",children:[e.jsx(i,{className:"text-xs uppercase tracking-wide",children:"Cieľ â súradnice"}),e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["Na ",e.jsx("a",{className:"underline",href:"https://mapy.com",target:"_blank",rel:"noopener noreferrer",children:"mapy.com"}),' klikni pravým na bod â âÄo je tu". Zobrazà ',e.jsx("code",{children:"49.18..., 19.78..."}),". Prvé ÄÃslo = ",e.jsx("strong",{children:"Lat (Y)"}),", druhé = ",e.jsx("strong",{children:"Lng (X)"}),"."]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx(i,{children:"Lat (Y)"}),e.jsx(l,{type:"number",step:"0.000001",value:s.lat,onChange:r=>a({...s,lat:Number(r.target.value)}),required:!0})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Lng (X)"}),e.jsx(l,{type:"number",step:"0.000001",value:s.lng,onChange:r=>a({...s,lng:Number(r.target.value)}),required:!0})]})]}),s.lat&&s.lng&&e.jsxs("a",{href:`https://mapy.com/sk/turisticka?source=coor&id=${s.lng}%2C${s.lat}&x=${s.lng}&y=${s.lat}&z=15`,target:"_blank",rel:"noopener noreferrer",className:"text-xs underline inline-flex items-center gap-1",children:["OveriÅ¥ bod na mapy.com ",e.jsx(T,{className:"w-3 h-3"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(i,{children:"Obrázok"}),s.image_url&&e.jsxs("div",{className:"relative inline-block",children:[e.jsx("img",{src:s.image_url,alt:"",className:"w-32 h-32 object-cover rounded-lg border"}),e.jsx("button",{type:"button",onClick:()=>a({...s,image_url:""}),className:"absolute -top-2 -right-2 bg-destructive text-destructive-foreground rounded-full w-6 h-6 flex items-center justify-center","aria-label":"OdstrániÅ¥",children:e.jsx(E,{className:"w-3.5 h-3.5"})})]}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(l,{type:"file",accept:"image/*",onChange:r=>{var n;const t=(n=r.target.files)==null?void 0:n[0];t&&$(t),r.target.value=""},disabled:k,className:"flex-1"}),k&&e.jsx(v,{className:"w-4 h-4 animate-spin"})]}),e.jsx(l,{value:s.image_url||"",onChange:r=>a({...s,image_url:r.target.value}),placeholder:"alebo vlož URL: https://â¦"})]}),e.jsxs("div",{children:[e.jsx(i,{children:"Farba pinu (override)"}),e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(l,{type:"color",value:s.color||"#34D399",onChange:r=>a({...s,color:r.target.value}),className:"w-14 h-10 p-1"}),e.jsx(l,{value:s.color||"",onChange:r=>a({...s,color:r.target.value}),placeholder:"napr. #34D399 â prázdne = farba podľa kategórie",className:"flex-1"}),s.color&&e.jsx(c,{type:"button",size:"sm",variant:"outline",onClick:()=>a({...s,color:""}),children:"Ã"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 items-end",children:[e.jsxs("div",{children:[e.jsx(i,{children:"Poradie"}),e.jsx(l,{type:"number",value:s.sort_order,onChange:r=>a({...s,sort_order:Number(r.target.value)})})]}),e.jsxs("label",{className:"flex items-center gap-2 pb-2",children:[e.jsx(D,{checked:s.is_active,onCheckedChange:r=>a({...s,is_active:r})}),e.jsx("span",{className:"text-sm",children:"AktÃvna"})]})]}),e.jsxs(Y,{children:[e.jsx(c,{type:"button",variant:"outline",onClick:()=>a(null),children:"ZruÅ¡iÅ¥"}),e.jsxs(c,{type:"submit",disabled:N,children:[N&&e.jsx(v,{className:"w-4 h-4 mr-2 animate-spin"}),"UložiÅ¥"]})]})]})]})})]})})};export{Fe 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.