1import{r as a,j as e,H as w,R as k,X as J,C as K}from"./index-CGHuSNT4.js";import n from"./pocketbaseClient-6qBP5-6G.js";import{m as D}from"./proxy-CMTtMpl5.js";import{L as X,S as Y,E as Q,a as ee,P as O,b as te,F as re,c as se,T as ae,C as oe}from"./trash-2-CEuONSsE.js";import{G as ne}from"./globe-BcrnYPa5.js";function le(o){return o.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").replace(/\s+/g,"-").replace(/-+/g,"-").trim()}function B(o){return o?.cover?`${n.baseURL}/api/files/${o.collectionId}/${o.id}/${o.cover}?thumb=400x200`:null}function C({type:o,msg:m}){return m?e.jsxs("div",{className:`flex items-center gap-2 rounded-xl px-4 py-3 text-sm mb-4 ${o==="error"?"bg-destructive/10 text-destructive border border-destructive/20":"bg-accent/10 text-accent border border-accent/20"}`,children:[o==="error"?e.jsx(K,{className:"h-4 w-4 flex-shrink-0"}):e.jsx(oe,{className:"h-4 w-4 flex-shrink-0"}),m]}):null}const I={title:"",slug:"",summary:"",content:"",author:"",categories:"",status:"draft",published_at:"",coverFile:null};function xe(){const[o,m]=a.useState(n.authStore.record),[x,S]=a.useState({email:"",password:""}),[E,L]=a.useState(""),[h,M]=a.useState([]),[z,P]=a.useState(!1),[G,b]=a.useState("list"),[i,A]=a.useState(null),[s,p]=a.useState(I),[U,d]=a.useState(""),[H,u]=a.useState(""),[F,_]=a.useState(!1),[f,j]=a.useState(!1),[v,N]=a.useState(null),R=a.useRef();a.useEffect(()=>n.authStore.onChange((r,c)=>m(c)),[]),a.useEffect(()=>{o&&y()},[o]);async function y(){P(!0);try{const t=await n.collection("blog_posts").getFullList({sort:"-created",requestKey:"admin-posts"});M(t)}catch(t){console.error(t)}finally{P(!1)}}async function $(t){t.preventDefault(),L("");try{await n.collection("users").authWithPassword(x.email,x.password)}catch{L("Email o contraseña incorrectos.")}}function Z(){n.authStore.clear()}function T(){A(null),p(I),d(""),u(""),j(!1),b("form")}function q(t){A(t),p({title:t.title||"",slug:t.slug||"",summary:t.summary||"",content:t.content||"",author:t.author||"",categories:t.categories||"",status:t.status||"draft",published_at:t.published_at?t.published_at.substring(0,16):"",coverFile:null}),d(""),u(""),j(!1),b("form")}function l(t,r){p(c=>{const g={...c,[t]:r};return t==="title"&&!i&&(g.slug=le(r)),g})}async function V(t){if(t.preventDefault(),d(""),u(""),!s.title.trim()){d("El tÃtulo es obligatorio.");return}if(!s.slug.trim()){d("El slug es obligatorio.");return}_(!0);try{const r=new FormData;r.append("title",s.title),r.append("slug",s.slug),r.append("summary",s.summary),r.append("content",s.content),r.append("author",s.author),r.append("categories",s.categories),r.append("status",s.status),r.append("published_at",s.published_at?new Date(s.published_at).toISOString():""),i||r.append("owner",n.authStore.record.id),s.coverFile&&r.append("cover",s.coverFile),i?(await n.collection("blog_posts").update(i.id,r),u("ArtÃculo actualizado correctamente.")):(await n.collection("blog_posts").create(r),u("ArtÃculo creado correctamente.")),await y(),setTimeout(()=>{b("list"),u("")},1200)}catch(r){const c=r?.response?.data?.slug?.message||r?.response?.data?.title?.message||r?.message||"Error al guardar.";d(c)}finally{_(!1)}}async function W(t){try{await n.collection("blog_posts").delete(t.id),N(null),await y()}catch(r){console.error(r)}}return o?G==="form"?e.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[e.jsxs(w,{children:[e.jsxs("title",{children:[i?"Editar":"Nuevo"," ArtÃculo - Admin Radio Zona 503"]}),e.jsx("meta",{name:"robots",content:"noindex"})]}),e.jsx("header",{className:"sticky top-0 z-30 border-b border-border bg-background/90 backdrop-blur-xl",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 h-14 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>b("list"),className:"flex items-center gap-2 text-sm font-semibold text-muted-foreground hover:text-foreground transition",children:[e.jsx(J,{className:"h-4 w-4"})," Cancelar"]}),e.jsx("h1",{className:"font-display text-lg",children:i?"EDITAR ARTÃCULO":"NUEVO ARTÃCULO"}),e.jsxs("button",{form:"post-form",type:"submit",disabled:F,className:"flex items-center gap-2 rounded-full bg-primary px-5 py-2 text-sm font-semibold text-primary-foreground hover:bg-primary/90 disabled:opacity-50 transition active:scale-95",children:[e.jsx(Y,{className:"h-4 w-4"})," ",F?"Guardandoâ¦":"Guardar"]})]})}),e.jsxs("div",{className:"mx-auto max-w-5xl px-5 py-8",children:[e.jsx(C,{type:"error",msg:U}),e.jsx(C,{type:"success",msg:H}),e.jsxs("form",{id:"post-form",onSubmit:V,className:"grid gap-6 lg:grid-cols-3",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"TÃtulo *"}),e.jsx("input",{type:"text",value:s.title,onChange:t=>l("title",t.target.value),placeholder:"TÃtulo del artÃculo...",className:"w-full rounded-xl border border-border bg-card px-4 py-3 text-base focus:outline-none focus:ring-2 focus:ring-accent/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Slug URL *"}),e.jsxs("div",{className:"relative",children:[e.jsx("span",{className:"absolute left-3 top-1/2 -translate-y-1/2 text-xs text-muted-foreground",children:"/blog/"}),e.jsx("input",{type:"text",value:s.slug,onChange:t=>l("slug",t.target.value),placeholder:"url-del-articulo",className:"w-full rounded-xl border border-border bg-card pl-14 pr-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent/50"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Resumen"}),e.jsx("textarea",{value:s.summary,onChange:t=>l("summary",t.target.value),rows:3,placeholder:"Breve descripción del artÃculo (también usada para SEO)...",className:"w-full rounded-xl border border-border bg-card px-4 py-3 text-sm focus:outline-none focus:ring-2 focus:ring-accent/50 resize-none"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-1.5",children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground",children:"Contenido (HTML)"}),e.jsxs("button",{type:"button",onClick:()=>j(t=>
1!t),className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition",children:[f?e.jsx(Q,{className:"h-3.5 w-3.5"}):e.jsx(ee,{className:"h-3.5 w-3.5"}),f?"Editor":"Vista previa"]})]}),f?e.jsx("div",{className:"rounded-xl border border-border bg-card p-4 min-h-[400px] overflow-auto prose-blog text-sm",dangerouslySetInnerHTML:{__html:s.content}}):e.jsx("textarea",{value:s.content,onChange:t=>l("content",t.target.value),rows:18,placeholder:"<h2>TÃtulo sección</h2><p>Contenido HTML del artÃculo...</p>",className:"w-full rounded-xl border border-border bg-card px-4 py-3 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-accent/50 resize-y"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:'Puedes usar HTML: <h2>, <p>, <strong>, <em>, <ul>, <li>, <a href="...">, <img src="...">'})]})]}),e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{className:"rounded-2xl border border-white/10 bg-card p-5 space-y-4",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Publicación"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Estado"}),e.jsxs("select",{value:s.status,onChange:t=>l("status",t.target.value),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent/50",children:[e.jsx("option",{value:"draft",children:"Borrador"}),e.jsx("option",{value:"published",children:"Publicado"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Fecha publicación"}),e.jsx("input",{type:"datetime-local",value:s.published_at,onChange:t=>l("published_at",t.target.value),className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent/50"})]})]}),e.jsxs("div",{className:"rounded-2xl border border-white/10 bg-card p-5 space-y-4",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Imagen destacada"}),i?.cover&&!s.coverFile&&e.jsx("img",{src:B(i),alt:"Portada actual",className:"rounded-xl w-full object-cover aspect-video"}),e.jsx("input",{ref:R,type:"file",accept:"image/*",onChange:t=>l("coverFile",t.target.files[0]||null),className:"hidden"}),e.jsx("button",{type:"button",onClick:()=>R.current?.click(),className:"w-full rounded-xl border-2 border-dashed border-border py-6 text-sm text-muted-foreground hover:border-accent/40 hover:text-foreground transition text-center",children:s.coverFile?s.coverFile.name:"Haz clic para subir imagen"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"JPG, PNG, WebP · Máximo 10MB"})]}),e.jsxs("div",{className:"rounded-2xl border border-white/10 bg-card p-5 space-y-4",children:[e.jsx("h3",{className:"font-semibold text-sm",children:"Metadatos"}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Autor"}),e.jsx("input",{type:"text",value:s.author,onChange:t=>l("author",t.target.value),placeholder:"Nombre del autor",className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"CategorÃas / Tags"}),e.jsx("input",{type:"text",value:s.categories,onChange:t=>l("categories",t.target.value),placeholder:"música, radio, El Salvador",className:"w-full rounded-xl border border-border bg-background px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-accent/50"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"Separar con comas"})]})]})]})]})]})]}):e.jsxs("div",{className:"min-h-screen bg-background text-foreground",children:[e.jsxs(w,{children:[e.jsx("title",{children:"Admin Blog - Radio Zona 503"}),e.jsx("meta",{name:"robots",content:"noindex"})]}),e.jsx("header",{className:"sticky top-0 z-30 border-b border-border bg-background/90 backdrop-blur-xl",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-5 h-14 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"grid place-items-center h-8 w-8 rounded-lg bg-primary text-primary-foreground",children:e.jsx(k,{className:"h-4 w-4"})}),e.jsxs("span",{className:"font-display text-base",children:["ADMIN ",e.jsx("span",{className:"text-gradient",children:"BLOG"})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("a",{href:"/admin/pages",className:"text-xs text-muted-foreground hover:text-foreground transition hidden sm:block",children:"Páginas"}),e.jsx("a",{href:"/admin/ads",className:"text-xs text-muted-foreground hover:text-foreground transition hidden sm:block",children:"Ads"}),e.jsx("span",{className:"text-xs text-muted-foreground hidden sm:block",children:o.email}),e.jsxs("button",{onClick:T,className:"flex items-center gap-2 rounded-full bg-primary px-4 py-2 text-sm font-semibold text-primary-foreground hover:bg-primary/90 transition active:scale-95",children:[e.jsx(O,{className:"h-4 w-4"})," Nuevo artÃculo"]}),e.jsx("button",{onClick:Z,className:"grid place-items-center h-9 w-9 rounded-full border border-border text-muted-foreground hover:text-foreground hover:border-destructive/40 transition",children:e.jsx(te,{className:"h-4 w-4"})})]})]})}),e.jsxs("main",{className:"mx-auto max-w-5xl px-5 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"font-display text-2xl",children:"ARTÃCULOS DEL BLOG"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[h.length," artÃculos"]})]}),z?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(t=>e.jsx("div",{className:"h-20 rounded-xl bg-card animate-pulse"},t))}):h.length===0?e.jsxs("div",{className:"text-center py-20",children:[e.jsx(re,{className:"h-12 w-12 mx-auto mb-4 text-muted-foreground
1/30"}),e.jsx("p",{className:"text-muted-foreground",children:"No hay artÃculos todavÃa."}),e.jsxs("button",{onClick:T,className:"mt-4 inline-flex items-center gap-2 rounded-full bg-primary px-5 py-2.5 text-sm font-semibold text-primary-foreground",children:[e.jsx(O,{className:"h-4 w-4"})," Crear primer artÃculo"]})]}):e.jsx("div",{className:"space-y-3",children:h.map(t=>{const r=B(t),c=t.categories?.split(",").map(g=>g.trim()).filter(Boolean)||[];return e.jsxs("div",{className:"flex items-center gap-4 rounded-xl border border-white/10 bg-card p-4 hover:border-white/20 transition",children:[r?e.jsx("img",{src:r,alt:"",className:"w-16 h-12 rounded-lg object-cover flex-shrink-0"}):e.jsx("div",{className:"w-16 h-12 rounded-lg bg-muted flex items-center justify-center flex-shrink-0",children:e.jsx(k,{className:"h-5 w-5 text-muted-foreground/40"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h3",{className:"font-semibold text-sm line-clamp-1",children:t.title}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-[10px] font-semibold uppercase tracking-wide ${t.status==="published"?"bg-accent/15 text-accent":"bg-muted text-muted-foreground"}`,children:t.status==="published"?"Publicado":"Borrador"})]}),e.jsxs("div",{className:"flex items-center gap-3 mt-1 text-xs text-muted-foreground",children:[e.jsxs("span",{children:["/blog/",t.slug]}),c[0]&&e.jsx("span",{className:"hidden sm:block",children:c.slice(0,2).join(", ")})]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[t.status==="published"&&e.jsx("a",{href:`/blog/${t.slug}`,target:"_blank",rel:"noreferrer",className:"grid place-items-center h-8 w-8 rounded-lg border border-border text-muted-foreground hover:text-accent hover:border-accent/40 transition",children:e.jsx(ne,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>q(t),className:"grid place-items-center h-8 w-8 rounded-lg border border-border text-muted-foreground hover:text-foreground hover:border-white/30 transition",children:e.jsx(se,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>N(t),className:"grid place-items-center h-8 w-8 rounded-lg border border-border text-muted-foreground hover:text-destructive hover:border-destructive/40 transition",children:e.jsx(ae,{className:"h-3.5 w-3.5"})})]})]},t.id)})})]}),v&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm px-4",children:e.jsxs(D.div,{initial:{opacity:0,scale:.95},animate:{opacity:1,scale:1},className:"w-full max-w-sm rounded-2xl border border-white/10 bg-card p-6",children:[e.jsx("h3",{className:"font-display text-xl mb-2",children:"¿Eliminar artÃculo?"}),e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:['Esta acción no se puede deshacer. Se eliminará permanentemente "',e.jsx("strong",{children:v.title}),'".']}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{onClick:()=>N(null),className:"flex-1 rounded-xl border border-border py-2.5 text-sm font-semibold hover:bg-muted transition",children:"Cancelar"}),e.jsx("button",{onClick:()=>W(v),className:"flex-1 rounded-xl bg-destructive py-2.5 text-sm font-semibold text-white hover:bg-destructive/90 transition",children:"Eliminar"})]})]})})]}):e.jsxs("div",{className:"min-h-screen bg-background text-foreground flex items-center justify-center px-4",children:[e.jsxs(w,{children:[e.jsx("title",{children:"Admin Blog - Radio Zona 503"}),e.jsx("meta",{name:"robots",content:"noindex"})]}),e.jsxs(D.div,{initial:{opacity:0,y:24},animate:{opacity:1,y:0},className:"w-full max-w-sm",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-8 justify-center",children:[e.jsx("span",{className:"grid place-items-center h-10 w-10 rounded-xl bg-primary text-primary-foreground",children:e.jsx(k,{className:"h-5 w-5"})}),e.jsxs("span",{className:"font-display text-xl",children:["RADIO ZONA ",e.jsx("span",{className:"text-gradient",children:"503"})]})]}),e.jsxs("div",{className:"rounded-2xl border border-white/10 bg-card p-8",children:[e.jsx("h1",{className:"font-display text-2xl mb-1",children:"Admin Blog"}),e.jsx("p",{className:"text-sm text-muted-foreground mb-6",children:"Inicia sesión para gestionar el blog."}),E&&e.jsx(C,{type:"error",msg:E}),e.jsxs("form",{onSubmit:$,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Email"}),e.jsx("input",{type:"email",required:!0,value:x.email,onChange:t=>S(r=>({...r,email:t.target.value})),className:"w-full rounded-xl border border-border bg-background px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent/50"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-semibold uppercase tracking-wider text-muted-foreground mb-1.5",children:"Contraseña"}),e.jsx("input",{type:"password",required:!0,value:x.password,onChange:t=>S(r=>({...r,password:t.target.value})),className:"w-full rounded-xl border border-border bg-background px-4 py-2.5 text-sm focus:outline-none focus:ring-2 focus:ring-accent/50"})]}),e.jsxs("button",{type:"submit",className:"w-full rounded-xl bg-primary py-3 text-sm font-semibold text-primary-foreground flex items-center justify-center gap-2 hover:bg-primary/90 transition active:scale-95",children:[e.jsx(X,{className:"h-4 w-4"})," Iniciar Sesión"]})]})]})]})]})}export{xe 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.