1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomeComponentsEditor-DuA7ANIa.js","assets/vendor-DUddqOgK.js","assets/sheet-B8Eq8VIp.js","assets/index-aMKfrLBt.js","assets/index-Ip_VRdfg.css","assets/homeComponents-Bdl5Kn2h.js"])))=>i.map(i=>d[i]); 2import{N as S,k as _,q as L,_ as q}from"./index-aMKfrLBt.js";import{u as O,j as e,bt as H,r as i,ap as I,ac as T,c$ as R,d0 as A,d1 as D,d2 as M,as as U,ay as F}from"./vendor-DUddqOgK.js";import{L as J}from"./Layout-KOl3AXIY.js";const Q=i.lazy(()=>q(()=>import("./HomeComponentsEditor-DuA7ANIa.js"),__vite__mapDeps([0,1,2,3,4,5])).then(l=>({default:l.HomeComponentsEditor}))),y="/api/admin/page-components/home",z=[{slug:"home",label:"Home",publicPath:"/"},{slug:"quem-somos",label:"Quem Somos",publicPath:"/quem-somos"},{slug:"associados",label:"Associados",publicPath:"/associados"},{slug:"editoras-associadas",label:"Editoras Associadas",publicPath:"/editoras-associadas"},{slug:"premio-abeu",label:"Prêmio ABEU",publicPath:"/premio-abeu"},{slug:"finalistas",label:"Finalistas",publicPath:"/premio-abeu/finalistas",child:!0},{slug:"premiacao",label:"Premiação",publicPath:"/premio-abeu/premiacao",child:!0},{slug:"jurados",label:"Jurados",publicPath:"/premio-abeu/jurados",child:!0},{slug:"conteudos",label:"Conteúdos",publicPath:"/conteudos"},{slug:"link-na-bio",label:"Link na Bio",publicPath:"/bio"},{slug:"politica-de-privacidade",label:"PolÃtica de Privacidade",publicPath:"/politica-de-privacidade"}];function G(){const[l,x]=i.useState([]),[d,o]=i.useState(!0),[u,b]=i.useState(""),[N,w]=i.useState(""),[h,P]=i.useState(!1),[p,E]=i.useState(null),[g,f]=i.useState(null),m=i.useCallback(async()=>{o(!0),b("");try{const s=await fetch(y,{credentials:"include"}),t=await s.json().catch(()=>null);if(!s.ok)throw new Error(t?.message||`Não foi possÃvel carregar os componentes (${s.status}).`);if(!Array.isArray(t))throw new Error("A resposta de componentes está em um formato inesperado.");x(t.map(a=>({...a,id:String(a.id)})).sort((a,c)=>a.order-c.order))}catch(s){b(s instanceof Error?s.message:"Não foi possÃvel carregar os componentes.")}finally{o(!1)}},[]);i.useEffect(()=>{m()},[m]);const k=async(s,t)=>{P(!0),b("");try{const a=await fetch(y,{credentials:"include"}),c=await a.json().catch(()=>null);if(!a.ok||!Array.isArray(c))throw new Error(c?.message||"Não foi possÃvel atualizar a ordem dos componentes.");const r=c.map(n=>({...n,id:String(n.id)})).sort((n,B)=>n.order-B.order),j=r.findIndex(n=>n.id===s),v=j+t;if(j<0||v<0||v>=r.length){x(r);return}[r[j],r[v]]=[r[v],r[j]];const C=await fetch(`${y}/order`,{method:"PUT",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:r.map(n=>n.id)})});if(!C.ok){const n=await C.json().catch(()=>null);throw new Error(n?.message||"Não foi possÃvel atualizar a ordem dos componentes.")}await m()}catch(a){b(a instanceof Error?a.message:"Não foi possÃvel atualizar a ordem.")}finally{P(!1)}},$=async(s,t)=>{if(!(p||h)&&window.confirm(`Excluir ${s.type==="Banner1"?"Banner 1":s.type} da posição ${t+1}? O componente será removido da Home. Esta ação não pode ser desfeita.`)){E(s.id
2),w("");try{const a=await fetch(`${y}/${encodeURIComponent(s.id)}`,{method:"DELETE",credentials:"include"});if(!a.ok){const c=await a.json().catch(()=>null);throw new Error(c?.message||`Não foi possÃvel excluir o componente (${a.status}).`)}await L.invalidateQueries({queryKey:["/api/page-components/home"]}),await m()}catch(a){w(a instanceof Error?a.message:"Não foi possÃvel excluir o componente.")}finally{E(null)}}};return e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"mb-7 flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.16em] text-blue-700",children:"Gerenciamento da página"}),e.jsx("h2",{id:"portal-page-heading",className:"mt-2 text-2xl font-semibold tracking-tight text-slate-900",children:"Home"}),e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-6 text-slate-600",children:"Organize os destaques e imagens que aparecem na página inicial."})]}),e.jsxs("button",{type:"button",onClick:()=>f({mode:"catalog"}),className:"inline-flex min-h-10 items-center justify-center gap-2 rounded-md bg-blue-800 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-blue-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-700 focus-visible:ring-offset-2",children:[e.jsx(I,{size:16})," Adicionar componente"]})]}),N&&e.jsx("p",{role:"alert",className:"mb-3 rounded-md border border-rose-200 bg-rose-50 px-4 py-3 text-sm text-rose-900",children:N}),d?e.jsx("div",{"aria-label":"Carregando componentes",className:"space-y-3",children:[1,2].map(s=>e.jsx("div",{className:"h-[76px] animate-pulse rounded-lg border border-slate-200 bg-slate-100"},s))}):u?e.jsxs("div",{role:"alert",className:"flex flex-col items-start gap-3 rounded-lg border border-rose-200 bg-rose-50 p-5 text-sm text-rose-900 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx(T,{size:17}),u]}),e.jsxs("button",{type:"button",onClick:()=>{m()},className:"inline-flex items-center gap-2 rounded-md border border-rose-300 px-3 py-2 font-medium hover:bg-rose-100",children:[e.jsx(R,{size:15})," Tentar novamente"]})]}):e.jsxs("div",{className:"overflow-hidden rounded-lg border border-slate-200 bg-white",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-slate-200 bg-slate-50/80 px-5 py-3",children:[e.jsx("span",{className:"text-xs font-semibold uppercase tracking-wider text-slate-500",children:"Componentes gerenciados"}),e.jsxs("span",{className:"text-xs text-slate-500",children:[l.length," ",l.length===1?"componente":"componentes"]})]}),l.length?e.jsx("ul",{className:"divide-y divide-slate-100",children:l.map((s,t)=>{const a=s.type.toLowerCase()==="banner1";return e.jsxs("li",{className:"flex items-center gap-3 px-4 py-4 sm:gap-4 sm:px-5",children:[e.jsx("span",{className:"flex h-10 w-10 shrink-0 items-center justify-center rounded-md bg-blue-50 text-blue-700",children:e.jsx(A,{size:18})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-sm font-semibold text-slate-800",children:a?"Banner 1":s.type}),e.jsx("p",{className:"mt-0.5 text-xs text-slate-500",children:a?"Carrossel principal":"Componente da página inicial"})]}),e.jsx("button",{type:"button","aria-label":`Mover ${a?"Banner 1":s.type} da posição ${t+1} para cima`,disabled:h||!!p||t===0,onClick:()=>{k(s.id,-1)},className:"rounded p-2 text-slate-500 hover:bg-slate-100 hover:text-blue-700 disabled:opacity-30",children:e.jsx(D,{size:15})}),e.jsx("button",{type:"button","aria-label":`Mover ${a?"Banner 1":s.type} da posição ${t+1} para baixo`,disabled:h||!!p||t===l.length-1,onClick:()=>{k(s.id,1)},className:"rounded p-2 text-slate-500 hover:bg-slate-100 hover:text-blue-700 disabled:opacity-30",children:e.jsx(M,{size:15})}),a&&e.jsx("button",{type:"button","aria-label":`Editar Banner 1 da posição ${t+1}`,title:"Editar componente",disabled:!!p,onClick:()=>f({mode:"edit",record:s}),className:"rounded p-2 text-blue-800 hover:bg-blue-50 hover:text-blue-950 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 disabled:opacity-40",children:e.jsx(U,{size:17,"aria-hidden":"true"})}),a&&e.jsx("button",{type:"button","aria-label":`Excluir Banner 1 da posição ${t+1}`,title:"Excluir componente",disabled:!!p||h,onClick:()=>{$(s,t)},className:"rounded p-2 text-rose-700 hover:bg-rose-50 hover:text-rose-900 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-rose-600 disabled:opacity-40",children:e.jsx(F,{size:17,"aria-hidden":"true"})})]},s.id)})}):e.jsxs("div",{className:"px-5 py-10 text-center",children:[e.jsx("span",{className:"mx-auto flex h-11 w-11 items-center justify-center rounded-full bg-blue-50 text-blue-700",children:e.jsx(A,{size:19})}),e.jsx("p",{className:"mt-3 text-sm font-semibold text-slate-800",children:"Nenhum componente cadastrado"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500",children:"Adicione o Banner 1 para começar a organizar os destaques."})]})]}),g&&e.jsx(i.Suspense,{fallback:e.jsx("div",{role:"status","aria-label":"Carregando editor",className:"fixed inset-0 z-50 bg-[#f2f5f4]/80 p-8",children:e.jsx("div",{className:"ml-auto h-full max-w-5xl animate-pulse rounded-lg bg-white"})}),children:e.jsx(Q,{mode:g.mode,record:g.mode==="edit"?g.record:void 0,onSaved:async()=>{f(null),await m()},onClosed:()=>f(null)})})]})}function X(){const[l]=O(),x=l==="/admin/portal"?"home":l.slice(14),d=z.find(o=>o.slug===x);
2return d?e.jsx(J,{breadcrumbs:[{label:"Portal",href:"/admin/portal"},{label:d.label}],children:e.jsxs("div",{className:"mx-auto w-full max-w-6xl",children:[e.jsxs("header",{className:"mb-8",children:[e.jsx("h1",{className:"text-2xl font-semibold text-neutral-900",children:"Portal"}),e.jsx("p",{className:"mt-2 text-sm text-neutral-600",children:"Páginas públicas do site"})]}),e.jsxs("div",{className:"grid min-w-0 gap-6 lg:grid-cols-[240px_minmax(0,1fr)]",children:[e.jsxs("nav",{"aria-label":"Páginas do Portal",className:"min-w-0 rounded-lg border border-neutral-200 bg-white p-2 lg:self-start",children:[e.jsx("p",{className:"px-3 py-2 text-xs font-semibold uppercase tracking-wide text-neutral-500",children:"Páginas"}),e.jsx("div",{className:"flex flex-col gap-0.5",children:z.map(o=>{const u=d.slug===o.slug;return e.jsx(H,{href:`/admin/portal/${o.slug}`,"aria-current":u?"page":void 0,className:_("block rounded-md py-2 pr-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600","child"in o&&o.child?"ml-4 border-l border-neutral-200 pl-4":"pl-3",u?"bg-blue-50 font-semibold text-blue-800":"text-neutral-700 hover:bg-neutral-100"),children:o.label},o.slug)})})]}),e.jsx("section",{"aria-labelledby":"portal-page-heading",className:"min-w-0 rounded-lg border border-neutral-200 bg-white p-6 sm:p-8",children:d.slug==="home"?e.jsx(G,{}):e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-xs font-medium uppercase tracking-wide text-neutral-500",children:"Página selecionada"}),e.jsx("h2",{id:"portal-page-heading",className:"mt-2 text-xl font-semibold text-neutral-900",children:d.label}),e.jsx("p",{className:"mt-4 text-sm leading-6 text-neutral-600",children:"As configurações desta página estarão disponÃveis aqui futuramente."})]})})]})]})}):e.jsx(S,{})}export{X as AdminPortalPages,z as portalPages};
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.