PageSourceSearch

https://snew.ai/assets/LandingSceneAdminPage-CzVKlm6V.js

js snew.ai collected 2026-10-05 15:08:48 UTC 39,797 bytes, 1 lines download raw bytes

1import{r as c,j as e}from"./index-L9AYrVUw.js";import{o as K,u as D,a8 as Ee,bB as Ae,n as De,a6 as $e,a3 as Me,a4 as Ie,s as ze,c as Be,l as Ue}from"./PlanAccessModal-P_W2GThH.js";import{B as k}from"./button-Bt8F5TkE.js";import{Link as Pe}from"./index-p7aFGi8o.js";import{D as ce,a as ue,b as me,c as xe}from"./FloatingTopMenu-CIhwk2RR.js";import{C as V}from"./CoverUploadButton-Ci0Jf5jO.js";import{f as ae,s as Oe,n as he,h as _e,d as Le,a as Re}from"./howBoardScene-B4aogWYK.js";import{v as pe,a as Te}from"./showcase-qHVT8Yso.js";import{t as te,a as oe,i as qe,b as He}from"./overrides-DxGb-X-q.js";import{n as ve,d as Fe,F as Ge}from"./floatingSnapshot-BDIOQ2DO.js";import{D as Ve,a as Qe,b as Je,c as je,d as Ke}from"./dropdown-menu-mjIVraPt.js";import{f as We}from"./entries-DM0IuApj.js";import{e as Xe,T as R,E as Ne,a as de,C as S,s as we,f as Ye}from"./heroScene-DvqR1vE_.js";import{l as Ze}from"./store-CVXWfzEM.js";import{a as Z,S as ee}from"./types-YVLQw7aQ.js";import{c as Q}from"./locale-Cctu0V3Y.js";import{m as es}from"./DotsSixVertical.es-CqAy0LdQ.js";import{l as ss,e as rs,b as G,L as re,c as as,f as ye,D as ts}from"./stagingLeanLibrary-OoJ8Uo_5.js";import{u as os}from"./useFullInventory-COSthsrP.js";import{$ as ns,a0 as Ce,a1 as Y,a2 as ls}from"./App-DyVHSnY3.js";import"./productFunnel-DiJFcMU2.js";import"./SnewLogo-Cg53XTnQ.js";import"./Spinner.es-C_ZGu2no.js";import"./UploadSimple.es-BDJIa312.js";import"./catalog-CkHlpXUG.js";import"./index-Eo00qZvG.js";import"./index-BKpKuXmL.js";import"./sceneCovers-B-dE7_Ce.js";import"./Trash.es-D2Zs5Rpt.js";import"./dissolve-CQo8GAUH.js";function le(o){return o.map(r=>({...r,images:Array.from({length:5},(i,n)=>r.images[n%r.images.length]??"")}))}function is({tick:o}){const[r,i]=c.useState(()=>le(ae())),[n,v]=c.useState(!1),[m,E]=c.useState(!1),[a,A]=c.useState(null),[B,$]=c.useState("");c.useEffect(()=>{!n&&!m&&i(le(ae()))},[o,n,m]);const M=c.useMemo(()=>{const u=new Set;return[...pe().entries()].flatMap(([g,s])=>s.flatMap(t=>{const f=te(t.id,g);return!f||u.has(f)?[]:(u.add(f),[{url:f,name:oe(t)}])}))},[o]),p=c.useMemo(()=>Array.from({length:10},(u,g)=>{const s=Ge.findIndex(w=>w===g),t=r[s],f=g%5;return{slot:g,productIndex:s,product:t,card:f,image:(t==null?void 0:t.images[f])??"",position:`${g<5?"Superior":"Inferior"} ${g%5+1}`}}),[r]);function x(u,g){i(s=>s.map((t,f)=>f===u?{...t,...g}:t)),v(!0)}function j(u,g,s){i(t=>t.map((f,w)=>w===u?{...f,images:f.images.map((P,T)=>T===g?s:P)}:f)),v(!0)}async function U(u,g){const s=`landing-floating/${u}/product-cutout-${Date.now()}.png`,t=await Ee({resource:"image",action:"remove_background",bucket:"template-thumbnails",sourcePath:g,outputPath:s},{timeoutMs:105e3});if(!(t!=null&&t.publicUrl))throw new Error("O recorte foi concluído sem uma imagem de saída.");return t.publicUrl}async function I(){E(!0);try{await Oe(r),v(!1),D.success("Hero flutuante publicado. A landing já usa essas imagens.")}catch(u){D.error(u instanceof Error?u.message:"Não foi possível publicar.")}finally{E(!1)}}return e.jsxs("section",{id:"hero-flutuante",className:"mt-10 border-t border-border pt-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Hero flutuante"}),e.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:"10 produtos · uma imagem inicial com remoção automática de fundo e cinco imagens por produto, na ordem dos cliques."})]}),e.jsx(Pe,{to:"/landing-floating",target:"_blank",className:"text-sm underline",children:"Abrir landing"})]}),e.jsx("p",{className:"mt-3 text-sm text-muted-foreground",children:"As alterações entram na landing ao publicar. As fotos são exibidas em 1:1. Confira se cada foto corresponde ao produto; slots repetidos podem ser substituídos individualmente."}),e.jsxs("fieldset",{disabled:m||!K(),className:"mt-6 space-y-6 disabled:opacity-60",children:[e.jsxs("section",{"aria-labelledby":"grade-final-title",className:"rounded-xl border border-border bg-secondary/30 p-4 sm:p-5",children:[e.jsxs("div",{children:[e.jsx("h3",{id:"grade-final-title",className:"text-lg font-semibold",children:"Grade final"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Troque diretamente os dez cards na mesma ordem em que aparecem na landing."})]}),e.jsx("div",{className:"mt-4 grid grid-cols-2 gap-3 md:grid-cols-5",children:p.map(({slot:u,productIndex:g,product:s,card:t,image:f,position:w})=>e.jsxs("article",{className:"min-w-0 rounded-lg border border-border bg-background p-2.5",children:[e.jsx("p",{className:"truncate text-xs font-medium",children:w}),e.jsx("p",{className:"mb-2 truncate text-[11px] text-muted-foreground",children:(s==null?void 0:s.name)??`Produto ${g+1}`}),e.jsx("img",{src:f,alt:`${w} · ${(s==null?void 0:s.name)??"produto"}`,className:"aspect-square w-full rounded-md object-cover"}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx(k,{type:"button",size:"sm",variant:"outline",className:"w-full",onClick:()=>{$(""),A({product:g,card:t,label:`Grade final · ${w}`})},children:"Biblioteca"}),e.jsx(V,{pathPrefix:`landing-floating/${g}/final-grid-${u}`,label:"Enviar imagem",onUploaded:P=>j(g,t,P)})]})]},u))}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center gap-3 border-t border-border pt-4",children:[e.jsx(k,{type:"button",onClick:I,disabled:!n||!ve(r),children:m?"Publicando…":"Publicar alterações"}),e.jsx("span",{className:"text-sm text-muted-foreground",role:"status",children:n?"Alterações ainda não publicadas":"Grade sincronizada com a landing"})]})]}),e.jsxs("div",{className:"pt-2",children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Produtos e sequência do morph"}),e.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Ajuste o recorte inicial e as cinco etapas de cada produto."})]}),r.map((u,g)=>e.jsxs("article",{className:"rounded-xl border border-border p-4",children:[e.jsxs("label",{className:"mb-4 flex items-center gap-3 text-sm",children:["Produto ",g+1,e.jsx("input",{"aria-label":`Nome do produto ${g+1}`,value:u.name,onChange:s=>x(g,{name:s.target.value}),className:"rounded-md border border-border bg-background px-3 py-2"})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm font-medium",children:"Inicial · re
1corte automático"}),e.jsx("div",{className:"aspect-square rounded-lg border border-dashed border-border bg-secondary p-3",children:e.jsx("img",{src:u.product,alt:u.name,className:"h-full w-full object-contain"})}),e.jsx(V,{pathPrefix:`landing-floating/${g}/product-source`,label:"Trocar imagem",processingLabel:"Removendo fundo…",processUploaded:({path:s})=>U(g,s),onUploaded:s=>x(g,{product:s})})]}),u.images.map((s,t)=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Clique ",t+1]}),e.jsx("img",{src:s,alt:`${u.name}, clique ${t+1}`,className:"aspect-square w-full rounded-lg object-cover"}),e.jsx(k,{type:"button",size:"sm",variant:"outline",onClick:()=>{$(""),A({product:g,card:t})},children:"Biblioteca"}),e.jsx(V,{pathPrefix:`landing-floating/${g}/card-${t}`,label:"Enviar imagem",onUploaded:f=>j(g,t,f)})]},t))]})]},u.id)),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(k,{type:"button",onClick:I,disabled:!n||!ve(r),children:m?"Publicando…":"Publicar hero flutuante"}),e.jsx(k,{type:"button",variant:"outline",onClick:()=>{i(le(Fe())),v(!0)},children:"Restaurar padrão"}),n&&e.jsx(k,{type:"button",variant:"ghost",onClick:()=>v(!1),children:"Descartar alterações"}),e.jsx("span",{className:"text-sm text-muted-foreground",role:"status",children:K()?n?"Alterações não publicadas":"Sem alterações pendentes":"Carregando curadoria…"})]})]}),e.jsx(ce,{open:a!==null,onOpenChange:u=>{u||A(null)},children:e.jsxs(ue,{className:"max-h-[85vh] overflow-y-auto sm:max-w-3xl",children:[e.jsx(me,{children:e.jsxs(xe,{children:["Escolher imagem · ",(a==null?void 0:a.label)??`clique ${((a==null?void 0:a.card)??0)+1}`]})}),e.jsx("input",{"aria-label":"Buscar imagem na biblioteca",placeholder:"Buscar preset…",value:B,onChange:u=>$(u.target.value),className:"rounded-md border border-border bg-background px-3 py-2"}),e.jsx("div",{className:"grid grid-cols-3 gap-3",children:M.filter(u=>u.name.toLocaleLowerCase().includes(B.toLocaleLowerCase())).map(u=>e.jsxs("button",{type:"button",className:"text-left",onClick:()=>{a&&j(a.product,a.card,u.url),A(null)},children:[e.jsx("img",{src:u.url,alt:"",loading:"lazy",className:"aspect-square w-full rounded-lg object-cover"}),e.jsx("span",{className:"mt-1 block text-sm",children:u.name})]},u.url))})]})})]})}function Se(o){return o.trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}function ge(o){const r=new Set;return o.filter(i=>!i.url||r.has(i.url)?!1:(r.add(i.url),!0))}function ds(){const o=[];for(const r of Ae())for(const i of We(r))!i.thumb||i.missing||o.push({url:i.thumb,nome:i.label,origem:"collection",origemId:r.slug,grupoId:r.slug,grupoNome:r.title});return ge(o)}function cs(){const o=[];for(const[r,i]of pe())for(const n of i){const v=te(n.id,r);v&&o.push({url:v,nome:oe(n),origem:"style",origemId:n.id,grupoId:r,grupoNome:Z[r]??r})}for(const r of Ze())o.push({url:r.imageUrl,nome:r.name,origem:"style",origemId:`saved:${r.id}`,grupoId:"saved",grupoNome:"Presets salvos"});return ge(o)}function us(o){if(o.length!==R||o.some(n=>n===null))return null;const r=o,i=[];for(let n=0;n<de;n++)i.push(r.slice(n*S,(n+1)*S));return i}function ms(o){return Array.from({length:R},(r,i)=>{const n=o[i];return n?{url:n.url,nome:n.nome,origem:n.origem,origemId:n.origemId}:null})}function xs({tick:o}){const[r,i]=c.useState("collection"),[n,v]=c.useState("all"),[m,E]=c.useState(""),[a,A]=c.useState(0),[B,$]=c.useState(!1),[M,p]=c.useState(!1),[x,j]=c.useState(!1),U=c.useMemo(()=>Ae(),[o]),I=c.useMemo(()=>ds(),[o]),u=c.useMemo(()=>cs(),[o]),g=c.useMemo(()=>ms(ge([...u,...I])),[I,u]),s=c.useMemo(()=>Xe(),[o]),t=c.useMemo(()=>K(),[o]),f=s.camadas,[w,P]=c.useState(()=>(f==null?void 0:f.flat())??g);c.useEffect(()=>{x||P((f==null?void 0:f.flat())??g)},[x,g,f]);const T=c.useMemo(()=>{const l=Se(m);return(r==="collection"?I:u).filter(C=>r==="collection"&&n!=="all"&&C.grupoId!==n?!1:!l||Se(`${C.nome} ${C.grupoNome} ${C.origemId??""}`).includes(l))},[m,n,I,u,r]),d=c.useMemo(()=>{const l=new Map;return w.forEach((y,C)=>{y&&l.set(y.url,C)}),l},[w]),b=l=>{P(y=>{const C=[...y],se=C.findIndex(_=>(_==null?void 0:_.url)===l.url),H=C[a],F={url:l.url,nome:l.nome,origem:l.origem,origemId:l.origemId};return se>=0&&se!==a&&(C[se]=H),C[a]=F,C}),j(!0),$(!1)},N=()=>{P(g),A(0),j(!0)},h=async()=>{const l=us(w);if(!l){D.error(`Preencha as ${R} imagens antes de salvar`);return}p(!0);try{await we(l),j(!1),D.success("A curadoria do fluxo do hero foi atualizada")}catch(y){D.error(y instanceof Error?y.message:"Não foi possível salvar")}finally{p(!1)}},L=async()=>{p(!0);try{await we(null),P(g),A(0),j(!1),D.success("Hero voltou à seleção automática da biblioteca")}catch(l){D.error(l instanceof Error?l.message:"Não foi possível restaurar")}finally{p(!1)}}
1,O=w.filter(Boolean).length,q=new Set(w.filter(Boolean).map(l=>l.url)).size===O,z=Math.floor(a/S),ne=a%S,W=Ne[z],X=w[a];return e.jsxs("section",{className:"rounded-snew-2xl border border-border p-5",children:[e.jsx("div",{children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("h2",{className:"font-heading text-[20px] font-semibold",children:"Hero · fluxo atual"}),e.jsx("span",{"data-hero-admin-status":t?s.status:"loading",className:Q("rounded-full px-2.5 py-1 text-[10px] font-semibold uppercase tracking-[0.04em]",t?s.status==="published"?"bg-foreground text-background":s.status==="invalid"?"bg-destructive/10 text-destructive":"bg-secondary text-muted-foreground":"bg-secondary text-muted-foreground"),children:t?s.status==="published"?`${R}/${R} publicados`:s.status==="invalid"?"configuração antiga não aplicada":"seleção automática":"carregando curadoria"})]}),e.jsx("p",{className:"mt-1 max-w-[720px] text-[13px] leading-relaxed text-muted-foreground",children:"Cada card abaixo corresponde a uma posição real do hero. Clique em um card, escolha sua imagem e publique as alterações."})]})}),e.jsxs("div",{className:"mt-5 rounded-snew-xl border border-border bg-secondary/35 p-4",children:[e.jsx("div",{className:"grid gap-3 sm:grid-cols-3",children:[["1","Escolha um card","Clique em uma posição abaixo."],["2","Escolha a imagem","Use a biblioteca ou faça upload."],["3","Publique","A landing é atualizada ao salvar."]].map(([l,y,C])=>e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-foreground text-[11px] font-semibold text-background",children:l}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-semibold",children:y}),e.jsx("div",{className:"mt-0.5 text-[11px] text-muted-foreground",children:C})]})]},l))}),e.jsxs("div",{className:"mt-4 flex flex-wrap items-center justify-between gap-3 border-t border-border pt-4",children:[e.jsxs("div",{className:"flex min-w-0 items-center gap-3",children:[e.jsx("div",{className:"h-12 w-12 shrink-0 overflow-hidden rounded-snew-md border border-border bg-secondary",children:X?e.jsx("img",{src:X.url,alt:"",className:"h-full w-full object-cover"}):null}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-[10px] font-semibold uppercase tracking-[0.04em] text-muted-foreground",children:"Card selecionado"}),e.jsxs("div",{className:"truncate text-[12px] font-medium",children:[(W==null?void 0:W.titulo)??`Estágio ${z+1}`," · card ",ne+1]})]}),e.jsx(k,{variant:"outline",size:"sm",disabled:M||!t,onClick:()=>$(!0),children:"Escolher imagem"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs(Ve,{children:[e.jsx(Qe,{asChild:!0,children:e.jsx(k,{variant:"outline",size:"sm",disabled:M||!t,children:"Opções automáticas"})}),e.jsxs(Je,{align:"end",className:"w-64",children:[e.jsx(je,{onSelect:N,children:"Preencher todos automaticamente"}),e.jsx(Ke,{}),e.jsx(je,{disabled:s.status==="automatic",onSelect:()=>void L(),children:"Remover curadoria e usar automático"})]})]}),e.jsx(k,{size:"sm",disabled:M||!t||!x||O!==R||!q,onClick:h,children:M?"Publicando…":x?"Publicar alterações":s.status==="published"?"Tudo publicado":"Sem alterações"})]})]})]}),t&&s.status==="invalid"&&e.jsxs("div",{className:"mt-5 rounded-snew-xl border border-destructive/20 bg-destructive/5 p-4 text-[12px] leading-relaxed text-destructive",children:["Existe uma curadoria salva em um formato anterior, mas ela não corresponde aos ",de," estágios de ",S," imagens do hero atual. Preencha e publique os ",R," slots abaixo para substituí-la, ou use “Opções automáticas” para removê-la."]}),e.jsx("div",{className:"mt-6 space-y-5",children:Array.from({length:de},(l,y)=>{const C=Ne[y];return e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsxs("div",{className:"flex min-w-0 items-baseline gap-2",children:[e.jsxs("span",{className:"text-[12px] font-semibold",children:[y+1,". ",(C==null?void 0:C.titulo)??`Estágio ${y+1}`]}),e.jsx("span",{className:"truncate text-[11px] text-muted-foreground",children:C==null?void 0:C.descricao})]}),e.jsxs("span",{className:"text-[11px] text-muted-foreground",children:[S," imagens"]})]}),e.jsx("div",{className:"grid grid-cols-2 items-start gap-2 sm:grid-cols-5 xl:grid-cols-10",children:Array.from({length:S},(se,H)=>{const F=y*S+H,_=w[F],fe=a===F,be=Ye(y,H);return e.jsxs("button",{type:"button","aria-pressed":fe,"aria-label":`Trocar imagem do estágio ${y+1}, posição ${H+1}`,onClick:()=>{A(F),$(!0)},className:Q("group relative overflow-hidden rounded-[14px] border bg-secondary text-left transition-colors",be==="3:4"?"aspect-[3/4]":"aspect-square",fe?"border-[hsl(var(--board-selection))] ring-2 ring-[hsl(var(--board-selection)/0.18)]":"border-border hover:border-foreground
1/35"),children:[_?e.jsx("img",{src:_.url,alt:"",className:"h-full w-full object-cover"}):e.jsx("span",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"vazio"}),e.jsx("span",{className:"absolute left-2 top-2 flex h-5 min-w-5 items-center justify-center rounded-full bg-background/90 px-1 text-[10px] font-medium shadow-sm backdrop-blur",children:H+1}),e.jsx("span",{className:"absolute right-2 top-2 rounded-full bg-background/90 px-2 py-1 text-[9px] font-medium shadow-sm backdrop-blur",children:be}),_&&e.jsxs("span",{className:"absolute inset-x-0 bottom-0 flex items-center justify-between gap-2 bg-black/60 px-2 py-1.5 text-[10px] text-white opacity-0 transition-opacity group-hover:opacity-100",children:[e.jsx("span",{className:"truncate",children:_.nome}),e.jsx("span",{className:"shrink-0 font-medium",children:"Trocar"})]})]},F)})})]},y)})}),B&&e.jsx("div",{role:"dialog","aria-modal":"true","aria-label":`Trocar imagem do estágio ${Math.floor(a/S)+1}`,className:"fixed inset-0 z-[100] flex items-center justify-center bg-black/45 p-4",onClick:()=>$(!1),children:e.jsxs("div",{className:"flex h-[min(760px,90vh)] w-full max-w-[1060px] flex-col overflow-hidden rounded-snew-2xl border border-border bg-background p-5 shadow-2xl",onClick:l=>l.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"font-heading text-[18px] font-semibold",children:["Trocar imagem · estágio ",Math.floor(a/S)+1,", posição"," ",a%S+1]}),e.jsx("p",{className:"mt-1 text-[12px] text-muted-foreground",children:"Escolha uma imagem abaixo. A substituição aparece imediatamente no slot."})]}),e.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[e.jsx(V,{pathPrefix:`landing/hero/camada-${Math.floor(a/S)+1}-card-${a%S+1}`,label:"Carregar imagem",onUploaded:l=>b({url:l,nome:`Upload · estágio ${Math.floor(a/S)+1}, posição ${a%S+1}`,origem:"upload",origemId:`camada-${Math.floor(a/S)+1}-card-${a%S+1}`})}),e.jsx("button",{type:"button","aria-label":"Fechar picker",onClick:()=>$(!1),className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-full border border-border text-muted-foreground hover:bg-secondary hover:text-foreground",children:e.jsx(De,{size:16})})]})]}),e.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-2",children:[e.jsx("div",{className:"inline-flex rounded-snew-md bg-secondary p-1",children:["collection","style"].map(l=>e.jsx("button",{type:"button",onClick:()=>i(l),className:Q("h-8 rounded-snew-sm px-3 text-[12px] transition-colors",r===l?"bg-background text-foreground shadow-sm":"text-muted-foreground"),children:l==="collection"?"Collections":"Styles"},l))}),r==="collection"&&e.jsxs("select",{value:n,onChange:l=>v(l.target.value),className:"h-10 max-w-[260px] rounded-snew-md border border-border bg-background px-3 text-[12px]",children:[e.jsx("option",{value:"all",children:"Todas as collections"}),U.map(l=>e.jsx("option",{value:l.slug,children:l.title},l.slug))]}),e.jsxs("label",{className:"relative min-w-[220px] flex-1",children:[e.jsx($e,{size:15,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{value:m,onChange:l=>E(l.target.value),placeholder:"Buscar imagem, preset ou collection",className:"h-10 w-full rounded-snew-md border border-border bg-background pl-9 pr-3 text-[12px] outline-none focus:border-foreground
1/40"})]})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between text-[11px] text-muted-foreground",children:[e.jsxs("span",{children:["Camada ",Math.floor(a/S)+1,", card"," ",a%S+1]}),e.jsxs("span",{children:[T.length," imagens disponíveis"]})]}),e.jsx("div",{className:"mt-3 grid min-h-0 flex-1 auto-rows-max content-start grid-cols-3 gap-2 overflow-y-auto pr-1 sm:grid-cols-5 lg:grid-cols-7",children:T.map(l=>{const y=d.get(l.url);return e.jsxs("button",{type:"button",onClick:()=>b(l),className:"group relative overflow-hidden rounded-[14px] border border-border bg-secondary text-left hover:border-foreground/40",title:`${l.nome} · ${l.grupoNome}`,children:[e.jsx("div",{className:"aspect-[3/4] overflow-hidden",children:e.jsx("img",{src:l.url,alt:"",loading:"lazy",className:"h-full w-full object-cover transition-transform duration-200 group-hover:scale-[1.03]"})}),e.jsxs("div",{className:"min-w-0 px-2 py-2",children:[e.jsx("div",{className:"truncate text-[11px] font-medium",children:l.nome}),e.jsx("div",{className:"mt-0.5 truncate text-[10px] text-muted-foreground",children:l.grupoNome})]}),y!==void 0&&e.jsxs("span",{className:"absolute right-1.5 top-1.5 flex h-6 items-center gap-1 rounded-full bg-foreground px-2 text-[9px] font-medium text-background shadow-sm",children:[e.jsx(Me,{size:11,weight:"bold"}),Math.floor(y/S)+1,".",y%S+1]})]},`${l.origem}:${l.grupoId}:${l.url}`)})})]})})]})}function J(o,r,i){return as(o,r,i[o.id])??o.thumbnailUrl??void 0}function ps(o,r,i){const n=new Set;return[r,...ee.filter(m=>m!==r)].flatMap(m=>{const E=J(o,m,i);return!E||n.has(E)?[]:(n.add(E),[{segment:m,url:E}])})}function ke(o,r){const i=o.strongSegments.find(n=>ee.includes(n));
1return i&&J(o,i,r)?i:ee.find(n=>J(o,n,r))??"fas"}function gs(o,r){return o.length===r.length&&o.every((i,n)=>{var v,m;return i.id===((v=r[n])==null?void 0:v.id)&&i.segment===((m=r[n])==null?void 0:m.segment)})}function fs({tick:o}){const{entries:r,thumbs:i,ready:n}=os(),v=c.useMemo(()=>ss(),[o]),[m,E]=c.useState(v),[a,A]=c.useState(null),[B,$]=c.useState(""),[M,p]=c.useState(!1),x=c.useRef(null);c.useEffect(()=>{E(v)},[v]);const j=c.useMemo(()=>{const d=r.filter(h=>!h.inactive&&qe(h.id,{includeDrafts:!0})),b=new Set(d.map(h=>h.id)),N=rs().filter(h=>b.has(h.id)?!1:(b.add(h.id),!0));return[...d,...N].filter(h=>ee.some(L=>!!J(h,L,i)))},[r,i,o]),U=c.useMemo(()=>new Map(j.map(d=>[d.id,d])),[j]),I=B.trim().toLocaleLowerCase("pt-BR"),u=I?j.filter(d=>G(d).toLocaleLowerCase("pt-BR").includes(I)||d.id.toLocaleLowerCase("pt-BR").includes(I)||d.strongSegments.some(b=>Z[b].toLocaleLowerCase("pt-BR").includes(I))):j,g=!gs(m,v),s=c.useMemo(()=>{const d=m.filter(N=>!U.has(N.id));if(d.length>0)return`${d.length} ${d.length===1?"preset não está":"presets não estão"} disponível na Library.`;const b=new Map;for(const N of m){const h=U.get(N.id);if(!h)continue;const L=J(h,N.segment,i);if(!L)return`${G(h)} está sem capa.`;const O=b.get(L);if(O)return`Capa repetida entre ${O} e ${G(h)}.`;b.set(L,G(h))}return null},[U,i,m]),t=(d,b)=>{d===b||d<0||b<0||d>=m.length||b>=m.length||E(N=>{const h=[...N],[L]=h.splice(d,1);return h.splice(b,0,L),h})},f=d=>{$(""),A(d)},w=(d,b)=>{E(N=>{if(!N[d])return N;const h=N.findIndex(O=>O.id===b.id);if(h===d)return N;const L=[...N];return h>=0?N:(L[d]={id:b.id,segment:ke(b,i)},L)}),A(null)},P=async()=>{p(!0);try{if(s)throw new Error(s);await ye(m),D.success("Presets da landing publicados")}catch(d){D.error(d instanceof Error?d.message:"Não foi possível salvar")}finally{p(!1)}},T=async()=>{p(!0);try{await ye(null),E(ts.map(d=>({...d}))),D.success("Presets da landing voltaram ao padrão")}catch(d){D.error(d instanceof Error?d.message:"Não foi possível restaurar")}finally{p(!1)}};return e.jsxs("section",{className:"mt-14 border-t border-border pt-10",children:[e.jsx("h2",{className:"font-heading text-[20px] font-semibold",children:"Presets da landing"}),e.jsxs("p",{className:"mt-2 max-w-[760px] text-[14px] text-muted-foreground",children:["Escolha exatamente ",re," presets. A ordem abaixo define as duas fileiras da landing; em cada card, selecione qual capa de categoria deve aparecer."]}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3",children:[e.jsx(k,{size:"sm",disabled:M||m.length!==re||!g||!!s,onClick:()=>void P(),children:M?"Salvando…":`Salvar na landing (${m.length}/${re})`}),e.jsx(k,{variant:"outline",size:"sm",disabled:M,onClick:()=>void T(),children:"Voltar ao padrão"}),e.jsx(Pe,{to:"/library",className:"text-[13px] text-muted-foreground underline-offset-4 hover:text-foreground hover:underline",children:"Editar as capas na Library"})]}),s&&e.jsxs("p",{className:"mt-3 text-[13px] text-destructive",role:"alert",children:[s," Troque o card ou atualize sua capa antes de publicar."]}),e.jsx("div",{className:"mt-6 grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4",children:m.map((d,b)=>{var O,q;const N=U.get(d.id),h=N?ps(N,d.segment,i):[],L=((O=h.find(z=>z.segment===d.segment))==null?void 0:O.url)??((q=h[0])==null?void 0:q.url);return e.jsxs("article",{draggable:!0,onDragStart:()=>{x.current=b},onDragOver:z=>z.preventDefault(),onDrop:z=>{z.preventDefault(),x.current!==null&&t(x.current,b),x.current=null},onDragEnd:()=>{x.current=null},className:"group overflow-hidden rounded-snew-xl border border-border bg-background",children:[e.jsxs("div",{className:"relative aspect-[3/4] bg-secondary",children:[L?e.jsx("img",{src:L,alt:"",className:"h-full w-full object-cover"}):e.jsx("div",{className:"flex h-full items-center justify-center text-[12px] text-muted-foreground",children:"Capa indisponível"}),e.jsx("span",{className:"absolute left-2 top-2 flex h-6 min-w-6 items-center justify-center rounded-full bg-foreground px-1.5 text-[11px] font-semibold text-background",children:b+1}),e.jsx("span",{className:"absolute left-1/2 top-2 flex h-7 -translate-x-1/2 cursor-grab items-center justify-center rounded-full bg-black/35 px-2 text-white opacity-0 backdrop-blur-sm transition-opacity group-hover:opacity-100",children:e.jsx(es,{size:15,weight:"bold"})})]}),e.jsxs("div",{className:"p-3",children:[e.jsx("div",{className:"line-clamp-2 min-h-10 text-[13px] font-medium leading-5",children:N?G(N):d.id}),e.jsx(k,{type:"button",variant:"outline",size:"sm",className:"mt-3 w-full",onClick:()=>f(b),children:"Trocar card"}),h.length>0&&e.jsxs("label",{className:"mt-3 block text-[11px] text-muted-foreground",children:["Capa",e.jsx("select",{value:d.segment,onChange:z=>{const ne=z.target.value;E(W=>W.map((X,l)=>l===b?{...X,segment:ne}:X))},className:"mt-1 h-8 w-full rounded-snew-md border border-border bg-background px-2 text-[12px] text-foreground",children:h.map(z=>e.jsx("option",{value:z.segment,children:Z[z.segment]},z.segment))})]}),e.jsxs("div",{className:"mt-3 flex items-center justify-between",children:[e.jsx("button",{type:"button",disabled:b===0,onClick:()=>t(b,b-1),className:"flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground hover:bg-secondary hover:text-foreground disabled:opacity-25","aria-label":"Mover para trás",children:e.jsx(Ie,{size:14})}),e.jsx("button",{type:"button",disabled:b===m.length-1,onClick:()=>t(b,b+1),className:"flex h-8 w-8 items-center justify-center rounded-full text-muted-foreground hover:bg-secondary hover:text-foreground disabled:opacity-25","aria-label":"Mover para frente",children:e.jsx(ze,{size:14})})]})]})]},d.id)})}),g&&e.jsxs("div",{className:"sticky bottom-4 z-20 mt-6 flex flex-wrap items-center justify-between gap-3 rounded-snew-xl border border-foreground
1/15 bg-background/95 p-3 shadow-lg backdrop-blur-md",children:[e.jsx("span",{className:"text-[13px] text-muted-foreground",children:"Alterações ainda não publicadas"}),e.jsx(k,{disabled:M||m.length!==re||!!s,onClick:()=>void P(),children:M?"Salvando…":"Salvar na landing"})]}),e.jsx(ce,{open:a!==null,onOpenChange:d=>{d||A(null)},children:e.jsxs(ue,{className:"flex max-h-[88vh] flex-col overflow-hidden sm:max-w-4xl",children:[e.jsx(me,{children:e.jsxs(xe,{children:["Trocar card ",a===null?"":a+1]})}),e.jsxs("div",{className:"relative mt-1",children:[e.jsx($e,{size:16,className:"pointer-events-none absolute left-3 top-1/2 -translate-y-1/2 text-muted-foreground"}),e.jsx("input",{type:"search",autoFocus:!0,value:B,onChange:d=>$(d.target.value),placeholder:"Buscar na Library por nome ou categoria",className:"h-10 w-full rounded-full border border-border bg-background pl-10 pr-4 text-[13px] outline-none focus:border-foreground/50"})]}),e.jsx("p",{className:"text-[12px] text-muted-foreground",children:"O inventário completo da Library está disponível, incluindo presets do banco e rascunhos do admin. Os que já estão na landing aparecem marcados e não podem ser repetidos."}),e.jsx("div",{className:"text-[12px] text-muted-foreground",children:n?`${u.length} ${u.length===1?"preset encontrado":"presets encontrados"}`:"Carregando o inventário completo da Library…"}),e.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto pr-1",children:u.length>0?e.jsx("div",{className:"grid grid-cols-2 gap-3 pb-2 sm:grid-cols-3 lg:grid-cols-4",children:u.map(d=>{const b=m.findIndex(q=>q.id===d.id),N=b>=0?m[b]:void 0,h=(N==null?void 0:N.segment)??ke(d,i),L=J(d,h,i),O=b===a;return e.jsxs("button",{type:"button",disabled:b>=0,onClick:()=>{a!==null&&w(a,d)},className:Q("group overflow-hidden rounded-snew-lg border bg-background text-left transition-colors",O?"border-foreground ring-1 ring-foreground":b>=0?"cursor-not-allowed border-border opacity-50":"border-border hover:border-foreground
1/50"),children:[e.jsxs("div",{className:"relative aspect-[3/4] bg-secondary",children:[L?e.jsx("img",{src:L,alt:"",loading:"lazy",className:"h-full w-full object-cover"}):null,b>=0&&e.jsxs("span",{className:"absolute left-2 top-2 rounded-full bg-foreground px-2 py-1 text-[10px] font-semibold text-background",children:["Card ",b+1]})]}),e.jsxs("div",{className:"p-2.5",children:[e.jsx("div",{className:"line-clamp-2 min-h-10 text-[12px] font-medium leading-5",children:G(d)}),e.jsx("div",{className:"mt-1 text-[11px] text-muted-foreground",children:Z[h]})]})]},d.id)})}):e.jsx("div",{className:"flex min-h-40 items-center justify-center rounded-snew-lg border border-dashed border-border text-[13px] text-muted-foreground",children:"Nenhum preset encontrado na Library"})})]})})]})}function ie(){const o=ae();return _e(o)??Le(o)??{name:"Produto Snew",product:"",images:Array(10).fill("")}}function bs({tick:o}){const[r,i]=c.useState(ie),[n,v]=c.useState(!1),[m,E]=c.useState(!1),[a,A]=c.useState(null),[B,$]=c.useState("");c.useEffect(()=>{!n&&!m&&i(ie())},[o,n,m]);const p=c.useMemo(()=>{const s=new Set;return[...pe().entries()].flatMap(([t,f])=>f.flatMap(w=>{const P=te(w.id,t);return!P||s.has(P)?[]:(s.add(P),[{name:oe(w),resultUrl:P,productUrl:He(w.id,t)}])}))},[o]).filter(s=>(a==null?void 0:a.type)==="product"&&!s.productUrl?!1:s.name.toLocaleLowerCase().includes(B.toLocaleLowerCase())),x=s=>{i(t=>({...t,...s})),v(!0)},j=(s,t)=>{i(f=>({...f,images:f.images.map((w,P)=>P===s?t:w)})),v(!0)},U=s=>{a&&(a.type==="product"?x({product:s.productUrl,name:s.name}):j(a.index,s.resultUrl),A(null))},I=async s=>{const t=`landing-how-board/product-cutout-${Date.now()}.png`,f=await Ee({resource:"image",action:"remove_background",bucket:"template-thumbnails",sourcePath:s,outputPath:t},{timeoutMs:105e3});if(!(f!=null&&f.publicUrl))throw new Error("O recorte foi concluído sem uma imagem de saída.");return f.publicUrl},u=async()=>{E(!0);try{await Re(r),v(!1),D.success("Board de How Snew works publicado na landing.")}catch(s){D.error(s instanceof Error?s.message:"Não foi possível publicar o board.")}finally{E(!1)}},g=()=>{const s=Le(ae());if(!s){D.error("O hero não tem imagens suficientes para montar o board.");return}i(s),v(!0)};return e.jsxs("section",{id:"how-snew-works-board",className:"mt-10 border-t border-border pt-8",children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-semibold",children:"How Snew works · Board"}),e.jsx("p",{className:"mt-2 max-w-[720px] text-sm text-muted-foreground",children:"Escolha o produto principal e as dez imagens independentes que aparecem na demonstração do board. Uploads são salvos no storage e esta seleção é publicada no banco."})]}),e.jsx(k,{type:"button",onClick:u,disabled:m||!n||!he(r),children:m?"Publicando…":"Publicar board"})]}),e.jsxs("fieldset",{disabled:m||!K(),className:"mt-6 space-y-6 disabled:opacity-60",children:[e.jsx("article",{className:"rounded-xl border border-border bg-secondary/30 p-4 sm:p-5",children:e.jsxs("div",{className:"grid gap-5 md:grid-cols-[220px_1fr]",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Produto principal"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"O upload remove o fundo automaticamente."})]}),e.jsx("div",{className:"aspect-square rounded-lg border border-dashed border-border bg-background p-4",children:r.product&&e.jsx("img",{src:r.product,alt:r.name,className:"h-full w-full object-contain"})}),e.jsx("input",{"aria-label":"Nome do produto do board",value:r.name,onChange:s=>x({name:s.target.value}),className:"w-full rounded-md border border-border bg-background px-3 py-2 text-sm"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(k,{type:"button",size:"sm",variant:"outline",onClick:()=>{$(""),A({type:"product"})},children:"Biblioteca"}),e.jsx(V,{pathPrefix:"landing-how-board/product-source",label:"Enviar produto",processingLabel:"Removendo fundo…",processUploaded:({path:s})=>I(s),onUploaded:s=>x({product:s})})]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:"Resultados do board"}),e.jsx("p",{className:"mt-1 text-xs text-muted-foreground",children:"A ordem abaixo corresponde aos dez cards da animação."}),e.jsx("div",{className:"mt-3 grid grid-cols-2 gap-3 sm:grid-cols-5",children:r.images.map((s,t)=>e.jsxs("div",{className:"rounded-lg border border-border bg-background p-2.5",children:[e.jsxs("p",{className:"mb-2 text-xs font-medium",children:["Resultado ",t+1
1]}),e.jsx("div",{className:"aspect-square overflow-hidden rounded-md bg-secondary",children:s&&e.jsx("img",{src:s,alt:`Resultado ${t+1}`,className:"h-full w-full object-cover"})}),e.jsxs("div",{className:"mt-2 flex flex-col gap-2",children:[e.jsx(k,{type:"button",size:"sm",variant:"outline",className:"w-full",onClick:()=>{$(""),A({type:"result",index:t})},children:"Biblioteca"}),e.jsx(V,{pathPrefix:`landing-how-board/result-${t}`,label:"Enviar imagem",onUploaded:f=>j(t,f)})]})]},t))})]})]})}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(k,{type:"button",onClick:u,disabled:!n||!he(r),children:m?"Publicando…":"Publicar board"}),e.jsx(k,{type:"button",variant:"outline",onClick:g,children:"Usar imagens do hero"}),n&&e.jsx(k,{type:"button",variant:"ghost",onClick:()=>{i(ie()),v(!1)},children:"Descartar alterações"}),e.jsx("span",{className:"text-sm text-muted-foreground",role:"status",children:K()?n?"Alterações ainda não publicadas":"Board sincronizado com a landing":"Carregando curadoria…"})]})]}),e.jsx(ce,{open:a!==null,onOpenChange:s=>{s||A(null)},children:e.jsxs(ue,{className:"max-h-[85vh] overflow-y-auto sm:max-w-4xl",children:[e.jsx(me,{children:e.jsx(xe,{children:(a==null?void 0:a.type)==="product"?"Escolher produto":`Escolher resultado ${((a==null?void 0:a.index)??0)+1}`})}),e.jsx("input",{"aria-label":"Buscar na biblioteca",placeholder:"Buscar em todos os presets…",value:B,onChange:s=>$(s.target.value),className:"rounded-md border border-border bg-background px-3 py-2"}),e.jsx("div",{className:"grid grid-cols-2 gap-3 sm:grid-cols-3 md:grid-cols-4",children:p.map(s=>{const t=(a==null?void 0:a.type)==="product"?s.productUrl:s.resultUrl;return e.jsxs("button",{type:"button",className:"text-left",onClick:()=>U(s),children:[e.jsx("img",{src:t,alt:"",loading:"lazy",className:"aspect-square w-full rounded-lg bg-secondary object-contain"}),e.jsx("span",{className:"mt-1 block text-sm",children:s.name})]},`${s.resultUrl}-${t}`)})})]})})]})}function Js(){const[o,r]=c.useState(0),[i,n]=c.useState(null);c.useEffect(()=>{const p=Be(()=>r(x=>x+1));return Ue(K()).catch(x=>{D.error(x instanceof Error?`Não foi possível carregar a curadoria: ${x.message}`:"Não foi possível carregar a curadoria")}),()=>{p()}},[]);const v=c.useMemo(()=>ns(),[o]),[m,E]=c.useState("fas"),[a,A]=c.useState([]);c.useEffect(()=>{A(v.length===Y?v:[...Ce])},[v]);const B=c.useMemo(()=>{const p=[...Ce.map((j,U)=>({url:j,label:`Campanha padrão ${U+1}`})),...Te(m).map(j=>({url:te(j.id,m),label:oe(j)}))],x=new Set;return p.filter(j=>!!j.url&&!x.has(j.url)&&!!x.add(j.url))},[m,o]),$=p=>{A(x=>x.includes(p)?x.filter(j=>j!==p):x.length>=Y?x:[...x,p])},M=async p=>{n("auth");try{await ls(p),D.success(p?"Imagens do acesso publicadas":"Imagens do acesso voltaram ao padrão"),r(x=>x+1)}catch(x){D.error(x instanceof Error?x.message:"Não foi possível salvar")}finally{n(null)}};return e.jsxs("div",{className:"mx-auto w-full max-w-[1100px] px-6 py-10",children:[e.jsx("h1",{className:"font-heading text-[28px] font-semibold",children:"Landing · curadoria"}),e.jsx("p",{className:"mt-2 max-w-[680px] text-[14px] text-muted-foreground",children:"Edite as imagens do hero, do board How Snew works, os presets em destaque e os visuais das páginas de login e cadastro."}),e.jsx(is,{tick:o}),e.jsx(bs,{tick:o}),e.jsx("div",{className:"mt-8",children:e.jsx(xs,{tick:o})}),e.jsx(fs,{tick:o}),e.jsxs("section",{className:"mt-14 border-t border-border pt-10",children:[e.jsx("h2",{className:"font-heading text-[20px] font-semibold",children:"Login e cadastro"}),e.jsxs("p",{className:"mt-2 max-w-[680px] text-[14px] text-muted-foreground",children:["Escolha exatamente ",Y," imagens, na ordem em que elas devem aparecer no dissolve das páginas de acesso."]}),e.jsx("div",{className:"mt-6 grid grid-cols-3 gap-3 sm:grid-cols-6",children:a.map((p,x)=>e.jsxs("button",{type:"button",onClick:()=>$(p),className:"relative aspect-[3/4] overflow-hidden rounded-snew-md border border-foreground",title:"Remover da seleção",children:[e.jsx("img",{src:p,alt:"",className:"h-full w-full object-cover"}),e.jsx("span",{className:"absolute left-1.5 top-1.5 flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-[11px] font-semibold text-background",children:x+1})]},`${p}-${x}`))}),e.jsxs("div",{className:"mt-5 flex flex-wrap items-center gap-3",children:[e.jsxs(k,{size:"sm",disabled:i!==null||a.length!==Y,onClick:()=>M(a),children:["Salvar sequência (",a.length,"/",Y,")"]}),e.jsx(k,{variant:"outline",size:"sm",disabled:i!==null||v.length===0,onClick:()=>M(null),children:"Voltar ao padrão"}),e.jsx("span",{className:"text-[13px] text-muted-foreground",children:"Clique em uma imagem numerada para removê-la."})]}),e.jsx("div",{className:"mt-8 flex gap-2 overflow-x-auto pb-2",role:"tablist","aria-label":"Categorias da biblioteca",children:ee.map(p=>e.jsx("button",{type:"button",role:"tab","aria-selected":m===p,onClick:()=>E(p),className:Q("shrink-0 rounded-full px-3 py-1.5 text-[12px] transition-colors",m===p?"bg-foreground text-background":"bg-secondary text-muted-foreground hover:text-foreground"),children:Z[p]},p))}),e.jsx("div",{className:"mt-4 grid grid-cols-2 gap-3 sm:grid-cols-4 lg:grid-cols-6",children:B.map(p=>{const x=a.includes(p.url),j=a.indexOf(p.url)+1;return e.jsxs("button",{type:"button",onClick:()=>$(p.url),className:Q("relative aspect-[3/4] overflow-hidden rounded-snew-md border transition-colors",x?"border-foreground":"border-border hover:border-foreground
1/40"),title:p.label,children:[e.jsx("img",{src:p.url,alt:"",className:"h-full w-full object-cover"}),x&&e.jsx("span",{className:"absolute left-1.5 top-1.5 flex h-5 w-5 items-center justify-center rounded-full bg-foreground text-[11px] font-semibold text-background",children:j})]},p.url)})})]})]})}export{Js 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.