1import{j as e}from"./vendor-motion-CPxq9Xvn.js";import{a1 as zt,az as Ft,a2 as qt,a3 as Mt,u as Ne,an as S,ai as Lt,ar as Rt,I as he,f as ae,B as $,S as ue,a7 as _,eT as mt,aa as Be,o as Bt,p as ke,Y as xt,aU as ht,J as Dt,ap as F,X as Ut,a9 as ut,P as _t,C as G,U as Gt,z as De,aT as Qt,as as gt,R as Ot,ao as pt}from"./index-CFAvyuXu.js";import{B as y}from"./badge-B9GAfHbC.js";import{C as Kt}from"./checkout-dialog-CtPFKUrs.js";import{S as Vt}from"./store-announcement-banner-D6oK4znf.js";import{u as Ht,r as h}from"./vendor-i18n-CO3kK2bH.js";import{g as Ue,f as Ce}from"./pricing-BgVC2Us6.js";import{P as Jt}from"./publication-pipeline-DFwPsRBR.js";import{P as Yt}from"./pipeline-waiting-card-B1DCfEqh.js";import{M as Wt}from"./mobile-pipeline-bar-wnI4Ws72.js";import{A as se}from"./arrow-left-DY50GvQQ.js";import{M as K}from"./megaphone-CJoAWoYP.js";import{F as Xt}from"./folder-open-BVSSHnxC.js";import{E as Se}from"./eye-BcGCsLne.js";import{I as $e}from"./instagram-BJB2Fjof.js";import{D as ge}from"./download-B7FtiUYJ.js";import{H as bt}from"./heart-CzKl5jvQ.js";import{B as Zt}from"./bookmark-Cugny8Gc.js";import{P as _e}from"./pen-DP6KqCyg.js";import{M as ea}from"./minus-CYoHdJ99.js";import{F as ta}from"./file-text-DjkUcFVd.js";import{S as aa}from"./share-2-BECwSfHo.js";import"./vendor-react-CQmBMThG.js";import"./pix-qr-image-D45mJvPS.js";import"./wifi-BvXiCCFP.js";import"./alert-dialog-C9feqA9b.js";import"./book-marked-3-KNVwiq.js";import"./stamp-BZO_gJDT.js";import"./select-B26x0xAv.js";import"./index-BdQq_4o_.js";import"./globe-D0MKCb1Y.js";import"./barcode-DlYH0ciP.js";const Ge=[{id:"vibrant",label:"Vibrante e Colorido",colors:["#FF6B6B","#4ECDC4","#FFE66D","#6C5CE7"],desc:"Cores fortes que chamam atenção"},{id:"elegant",label:"Elegante e Sóbrio",colors:["#2C3E50","#BDC3C7","#D4A574","#1A1A2E"],desc:"Sofisticação e classe"},{id:"warm",label:"Quente e Acolhedor",colors:["#E17055","#FDCB6E","#F8B500","#D35400"],desc:"Tons de terra e aconchego"},{id:"cool",label:"Frio e Moderno",colors:["#0984E3","#00B894","#6C5CE7","#00CEC9"],desc:"Tecnologia e inovação"},{id:"pastel",label:"Suave e Delicado",colors:["#FFB8C6","#A8D8EA","#C3B1E1","#FFDAC1"],desc:"Leveza e sensibilidade"},{id:"dark",label:"Escuro e Misterioso",colors:["#1A1A2E","#16213E","#0F3460","#E94560"],desc:"Suspense e profundidade"},{id:"nature",label:"Natural e Orgânico",colors:["#27AE60","#6B8E23","#8B4513","#F4D03F"],desc:"Natureza e bem-estar"},{id:"luxury",label:"Luxuoso e Dourado",colors:["#C9A84C","#1A1A2E","#F5E6CC","#8B6914"],desc:"Premium e exclusivo"}],Qe=[{id:"professional",label:"Profissional",desc:"Formal, corporativo, confiança",image:"/images/styles/professional.png"},{id:"creative",label:"Criativo e ArtÃstico",desc:"Ousado, visual, expressivo",image:"/images/styles/creative.png"},{id:"minimalist",label:"Minimalista",desc:"Limpo, simples, direto",image:"/images/styles/minimalist.png"},{id:"emotional",label:"Emocional e Inspirador",desc:"Tocante, motivador, humano",image:"/images/styles/emotional.png"},{id:"playful",label:"Divertido e Leve",desc:"DescontraÃdo, jovem, animado",image:"/images/styles/playful.png"},{id:"literary",label:"Literário e Clássico",desc:"Erudito, elegante, atemporal",image:"/images/styles/literary.png"}],Oe=[{id:"persuasive",label:"Persuasivo",desc:"Convence o leitor a comprar"},{id:"informative",label:"Informativo",desc:"Explica e educa sobre o livro"},{id:"emotional",label:"Emocional",desc:"Toca o coração do leitor"},{id:"urgent",label:"Urgente",desc:"Cria senso de pressa e escassez"},{id:"storytelling",label:"Contando uma história",desc:"Narra como se fosse um conto"},{id:"conversational",label:"Conversa de amigo",desc:"Informal, próximo, autêntico"}],Ke=[{id:"general",label:"Público Geral",desc:"Para todos os leitores",image:"/images/audiences/general.png"},{id:"young",label:"Jovens (18-30)",desc:"Linguagem moderna e direta",image:"/images/audiences/young.png"},{id:"adult",label:"Adultos (30-50)",desc:"Maduro e com propósito",image:"/images/audiences/adult.png"},{id:"senior",label:"Leitores 50+",desc:"Experiência e sabedoria",image:"/images/audiences
1/senior.png"},{id:"academic",label:"Acadêmicos",desc:"Estudantes e pesquisadores",image:"/images/audiences/academic.png"},{id:"business",label:"Empreendedores",desc:"Negócios e liderança",image:"/images/audiences/business.png"},{id:"spiritual",label:"Espirituais",desc:"Autoconhecimento e fé",image:"/images/audiences/spiritual.png"},{id:"parents",label:"Pais e FamÃlias",desc:"Educação e relacionamento",image:"/images/audiences/parents.png"}],sa=[{id:"cinematic",label:"Cinematográfico",desc:"Iluminação dramática de cinema",image:"/images/styles/cinematic.png"},{id:"editorial",label:"Editorial",desc:"Estilo revista de moda",image:"/images/styles/editorial.png"},{id:"watercolor",label:"Aquarela",desc:"Arte suave e artÃstica",image:"/images/styles/watercolor.png"},{id:"photorealistic",label:"Fotorrealista",desc:"Como uma foto profissional",image:"/images/styles/photorealistic.png"},{id:"dramatic",label:"Dramático",desc:"Contraste forte e impactante",image:"/images/styles/dramatic.png"},{id:"minimalist",label:"Minimalista",desc:"Clean e elegante",image:"/images/styles/minimalist.png"},{id:"vintage",label:"Vintage",desc:"Estética retrô e nostálgica",image:"/images/styles/vintage.png"},{id:"modern-luxury",label:"Luxo Moderno",desc:"Sofisticado e premium",image:"/images/styles/modern-luxury.png"}],A=[{id:"post",label:"Imagens para Feed",description:"Imagens profissionais para Instagram e Facebook que vendem seu livro",icon:e.jsx($e,{className:"w-5 h-5"}),unitPrice:9.99,maxQty:15},{id:"story",label:"Imagens para Stories",description:"Stories envolventes que despertam curiosidade e geram cliques",icon:e.jsx(aa,{className:"w-5 h-5"}),unitPrice:7.99,maxQty:10}],re=["Analisando seu livro em profundidade...","Aplicando suas preferências de estilo e cores...","Criando textos persuasivos e emocionantes...","Gerando hashtags estratégicas...","Montando materiais de alta conversão...","Finalizando seus conteúdos..."],Ve={post:"Feed",story:"Story",carousel:"Carrossel",banner:"Banner",panfleto:"Panfleto",folder:"Folder"};function Ra(){const[ra,V]=zt(),[,ft]=Ft("/marketing/:bookId"),{user:He}=qt(),{toast:v}=Mt(),{t:ie}=Ht("pages"),m=ft?.bookId||(typeof window<"u"?new URLSearchParams(window.location.search).get("bookId"):null),[k,d]=h.useState(m?"customize":"choice"),[f,q]=h.useState(m),[C,H]=h.useState({}),[n,P]=h.useState({colorPalette:"",style:"",tone:"",targetAudience:"",authorNotes:"",imageStyle:"",includeImageText:!1}),[pe,z]=h.useState(0),[u,M]=h.useState([]),[jt,Je]=h.useState(null),[vt,Ie]=h.useState(!1),[g,E]=h.useState(()=>{try{return!!(m&&localStorage.getItem(`mkt-kit-owned:${m}`))}catch{return!1}}),[J,le]=h.useState(!1),[oe,Ye]=h.useState(!1),[I,Q]=h.useState(null),[Pe,T]=h.useState(()=>{try{if(m&&localStorage.getItem(`mkt-kit-reconcile:${m}`))return m}catch{}return null}),[ne,We]=h.useState([]),[Xe,be]=h.useState(!1),[ce,Ze]=h.useState(null),[p,Y]=h.useState(null),de=h.useRef(!1),W=h.useRef(!1),Ee=h.useRef(!1),[et,tt]=h.useState(new Set),[fe,wt]=h.useState({}),[Te,me]=h.useState(null),[yt,X]=h.useState(null),Ae=h.useCallback(t=>{be(!0),We([]);const a=new Image;a.crossOrigin="anonymous",a.onload=()=>{try{const s=document.createElement("canvas"),r=64;s.width=r,s.height=r;const l=s.getContext("2d");if(!l){be(!1);return}l.drawImage(a,0,0,r,r);const i=l.getImageData(0,0,r,r).data,c={};for(let b=0;b<i.length;b+=4){const N=Math.round(i[b]/32)*32,U=Math.round(i[b+1]/32)*32,dt=Math.round(i[b+2]/32)*32,Re=`${N},${U},${dt}`;c[Re]||(c[Re]={r:N,g:U,b:dt,count:0}),c[Re].count++}const o=Object.values(c).sort((b,N)=>N.count-b.count).filter(b=>{const N=(b.r*299+b.g*587+b.b*114)/1e3;return N>15&&N<245}),j=[];for(const b of o){if(j.length>=4)break;j.some(U=>Math.abs(U.r-b.r)+Math.abs(U.g-b.g)+Math.abs(U.b-b.b)<80)||j.push(b)}for(;j.length<4&&o.length>j.length;){const b=o.find(N=>!j.includes(N));if(b)j.push(b);else break}const te=j.map(b=>{const N=U=>Math.min(255,Math.max(0,U)).toString(16).padStart(2,"0");return`#${N(b.r)}${N(b.g)}${N(b.b)}`});We(te)}catch{}be(!1)},a.onerror=()=>be(!1),a.src=t},[]),{data:ze,isLoading:Fe}=Ne({queryKey:["/api/books"]}),Z=(ze||[]).filter(t=>!t.isExternal),x=Z.find(t=>
1t.id===f);h.useEffect(()=>{x?.coverImage&&ne.length===0&&!Xe&&Ae(x.coverImage)},[x?.coverImage]);const{data:ia,isLoading:Nt}=Ne({queryKey:["/api/services"]}),{data:kt,isLoading:xe}=Ne({queryKey:["/api/marketing/materials"],enabled:k==="choice"||k==="book_gallery"||!!m||!!I,refetchInterval:I?5e3:!1}),L=kt||[],R={post:3,story:3},{data:qe,isLoading:at,refetch:Ct}=Ne({queryKey:[`/api/service-credits/eligibility/${f}`],enabled:!!f,staleTime:3e4}),ee=qe?.enabled?qe.byService?.marketing_kit:void 0,je=!!ee&&ee.balance>0,B=je&&!!ee?.eligible,ve=!!f&&!at&&qe===void 0,we=!!Pe&&Pe===f;h.useEffect(()=>{if(I&&L.some(t=>t.bookId===I)){try{localStorage.removeItem(`mkt-kit-watch:${I}`)}catch{}try{localStorage.removeItem(`mkt-kit-owned:${I}`)}catch{}Q(null),w.invalidateQueries({queryKey:["/api/marketing/materials"]}),d("book_gallery")}},[I,L]),h.useEffect(()=>{if(!I)return;const t=setTimeout(()=>{try{localStorage.removeItem(`mkt-kit-watch:${I}`)}catch{}Q(null),w.invalidateQueries({queryKey:["/api/marketing/materials"]}),d("book_gallery")},240*1e3);return()=>clearTimeout(t)},[I]),h.useEffect(()=>{if(!m||Ee.current||Fe||!ze||xe)return;if(!Z.some(s=>s.id===m)){Ee.current=!0,d("choice"),q(null);return}Ee.current=!0;try{const s=Number(localStorage.getItem(`mkt-kit-watch:${m}`)||0);if(s&&Date.now()-s<240*1e3){E(!0),Q(m),z(re.length-1),d("generating");return}localStorage.removeItem(`mkt-kit-watch:${m}`)}catch{}if(L.filter(s=>s.bookId===m).length>0){try{localStorage.removeItem(`mkt-kit-reconcile:${m}`)}catch{}try{localStorage.removeItem(`mkt-kit-owned:${m}`)}catch{}T(null),d("book_gallery")}else(async()=>{try{const r=await(await S("GET",`/api/books/${m}/next-upsell`)).json();try{localStorage.removeItem(`mkt-kit-reconcile:${m}`)}catch{}T(null);const l=r?.pipeline?.find(i=>i.step==="marketing");if(l?.purchased){try{localStorage.setItem(`mkt-kit-owned:${m}`,"1")}catch{}if(E(!0),l?.done){w.invalidateQueries({queryKey:["/api/marketing/materials"]}),d("book_gallery");return}const i=l?.generating||l?.pipelineStep==="generating";(l?.pipelineStep==="awaiting_user"||l?.awaitingUser||!l?.pipelineStep)&&le(!0),H({...R}),d(i?"generating":"customize");return}}catch{try{localStorage.getItem(`mkt-kit-reconcile:${m}`)&&T(m)}catch{}}})()},[m,ze,Fe,L,xe]);const D=Object.values(C).reduce((t,a)=>t+a,0),st=A.reduce((t,a)=>t+(C[a.id]||0)*a.unitPrice,0),St=async t=>{if(oe)return;if(I===t){d("generating");return}try{const i=Number(localStorage.getItem(`mkt-kit-watch:${t}`)||0);if(i&&Date.now()-i<240*1e3){q(t),E(!0),Q(t),z(re.length-1),d("generating");return}localStorage.removeItem(`mkt-kit-watch:${t}`)}catch{}q(t),H({});let a=!1;try{a=!!localStorage.getItem(`mkt-kit-owned:${t}`)}catch{}E(a);let s=!1;try{s=!!localStorage.getItem(`mkt-kit-reconcile:${t}`)}catch{}T(s?t:null),le(!1),P({colorPalette:"",style:"",tone:"",targetAudience:"",authorNotes:"",imageStyle:"",includeImageText:!1});const r=Z.find(i=>i.id===t);r?.coverImage&&Ae(r.coverImage);let l=L.filter(i=>i.bookId===t);if(l.length===0&&xe)try{l=(await(await S("GET","/api/marketing/materials")).json()||[]).filter(o=>o.bookId===t)}catch{}if(l.length>0){try{localStorage.removeItem(`mkt-kit-reconcile:${t}`)}catch{}try{localStorage.removeItem(`mkt-kit-owned:${t}`)}catch{}T(null),d("book_gallery")}else{try{const c=await(await S("GET",`/api/books/${t}/next-upsell`)).json();try{localStorage.removeItem(`mkt-kit-reconcile:${t}`)}catch{}T(null);const o=c?.pipeline?.find(j=>j.step==="marketing");if(o?.purchased){try{localStorage.setItem(`mkt-kit-owned:${t}`,"1")}catch{}if(E(!0),o?.done){w.invalidateQueries({queryKey:["/api/marketing/materials"]}),d("book_gallery");return}const j=o?.generating||o?.pipelineStep==="generating";(o?.pipelineStep==="awaiting_user"||o?.awaitingUser||!o?.pipelineStep)&&le(!0),H({...R}),d(j?"generating":"customize");return}}catch{try{localStorage.getItem(`mkt-kit-reconcile:${t}`)&&T(t)}catch{}}d("customize")}},rt=(t,a)=>{H(s=>{const r=A.find(c=>c.id===t),l=s[t]||0,i=Math.max(0,Math.min(r.maxQty,l+a));if(i===0){const{[t]:c,...o}=s;return o}return{...s,[t]:i}})},$t=async()=>{Ie(!1),await it()},It=async()=>
1{if(!f||oe)return;const t=f;Ye(!0);try{localStorage.setItem(`mkt-kit-reconcile:${t}`,String(Date.now()))}catch{}try{await S("POST","/api/service-credits/redeem",{bookId:t,serviceType:"marketing_kit"});try{localStorage.removeItem(`mkt-kit-reconcile:${t}`)}catch{}try{localStorage.setItem(`mkt-kit-owned:${t}`,"1")}catch{}v({title:"Crédito usado!",description:"Kit liberado â estamos gerando suas 6 peças de divulgação."}),w.invalidateQueries({queryKey:["/api/marketing/materials"]}),w.invalidateQueries({queryKey:[`/api/service-credits/eligibility/${t}`]});try{localStorage.setItem(`mkt-kit-watch:${t}`,String(Date.now()))}catch{}E(!0),Q(t),z(0),d("generating");const a=setInterval(()=>{z(s=>s>=re.length-1?(clearInterval(a),s):s+1)},1200)}catch(a){let s="unknown";try{const i=(await(await S("GET",`/api/books/${t}/next-upsell`)).json())?.pipeline?.find(c=>c.step==="marketing");s=i?.purchased?i?.done?"done":"pending":"not_purchased"}catch{}if(s==="pending"){try{localStorage.removeItem(`mkt-kit-reconcile:${t}`)}catch{}try{localStorage.setItem(`mkt-kit-owned:${t}`,"1")}catch{}try{localStorage.setItem(`mkt-kit-watch:${t}`,String(Date.now()))}catch{}E(!0),Q(t),z(0),d("generating"),v({title:"Crédito usado!",description:"Kit liberado â estamos gerando suas 6 peças de divulgação."}),w.invalidateQueries({queryKey:["/api/marketing/materials"]})}else if(s==="done"){try{localStorage.removeItem(`mkt-kit-reconcile:${t}`)}catch{}try{localStorage.setItem(`mkt-kit-owned:${t}`,"1")}catch{}E(!0),w.invalidateQueries({queryKey:["/api/marketing/materials"]}),d("book_gallery")}else if(s==="unknown")T(t),v({variant:"destructive",title:"Não consegui confirmar o resgate",description:"Verifique na barra abaixo antes de pagar â seu crédito pode já ter sido usado."});else{try{localStorage.removeItem(`mkt-kit-reconcile:${t}`)}catch{}v({variant:"destructive",title:"Não foi possÃvel usar o crédito",description:a?.message||"Tente novamente em instantes."})}w.invalidateQueries({queryKey:[`/api/service-credits/eligibility/${t}`]})}finally{Ye(!1)}},Pt=async()=>{const t=Pe;if(t)try{const r=(await(await S("GET",`/api/books/${t}/next-upsell`)).json())?.pipeline?.find(l=>l.step==="marketing");if(r?.purchased){try{localStorage.setItem(`mkt-kit-owned:${t}`,"1")}catch{}T(null);try{localStorage.removeItem(`mkt-kit-reconcile:${t}`)}catch{}if(E(!0),v({title:"Kit confirmado!",description:"Este livro já tem kit de marketing â sem nova cobrança."}),w.invalidateQueries({queryKey:["/api/marketing/materials"]}),r?.done)d("book_gallery");else{try{localStorage.setItem(`mkt-kit-watch:${t}`,String(Date.now()))}catch{}Q(t),z(0),d("generating")}}else{T(null);try{localStorage.removeItem(`mkt-kit-reconcile:${t}`)}catch{}}}catch{v({variant:"destructive",title:"Ainda sem confirmação",description:"Tente novamente em instantes."})}},it=async()=>{if(J&&f)try{await S("POST",`/api/books/${f}/pipeline-start/marketing`),le(!1)}catch{le(!1)}d("generating"),z(0);const t=setInterval(()=>{z(a=>a>=re.length-1?(clearInterval(t),a):a+1)},1200);try{const a=Object.entries(C).filter(([c,o])=>o>0).map(([c,o])=>({type:c,quantity:o})),s={};if(n.colorPalette)if(n.colorPalette==="cover"&&ne.length>0)s.colorPalette=`Tons da capa do livro â usar exatamente estas cores: ${ne.join(", ")}`;else{const c=Ge.find(o=>o.id===n.colorPalette);s.colorPalette=c?`${c.label} (${c.desc})`:n.colorPalette}if(n.style){const c=Qe.find(o=>o.id===n.style);s.style=c?`${c.label} â ${c.desc}`:n.style}if(n.tone){const c=Oe.find(o=>o.id===n.tone);s.tone=c?`${c.label} â ${c.desc}`:n.tone}if(n.targetAudience){const c=Ke.find(o=>o.id===n.targetAudience);s.targetAudience=c?`${c.label} â ${c.desc}`:n.targetAudience}n.authorNotes&&(s.authorNotes=n.authorNotes),s.includeImageText=n.includeImageText;const l=await(await S("POST","/api/marketing/generate",{bookId:f,contentTypes:a,preferences:Object.keys(s).length>0?s:void 0})).json();clearInterval(t),z(re.length-1);const i=(l.contents||[]).map(c=>{let o=c.content;return Array.isArray(o)?o=o.join(` 2 3`):typeof o=="object"&&o!==null&&(o=Object.entries(o).map(([j,te])=>`${j}: ${te}`).join(` 4`)),{...c,content:String(o||"")}});w.invalidateQueries({queryKey:["/api/marketing/materials"]}),setTimeout(()=>{M(i),d("results")},600)}catch(a){clearInterval(t),v({title:"Erro ao gerar conteúdo",description:a.message||"Tente novamente.",variant:"destructive"}),d("planning")}},Et=async(t,a)=>{const s=`${t.title?t.title+` 5 6`:""}${t.content}${t.hashtags?.length?` 7 8`+t.hashtags.join(" "):""}`;try{await navigator.clipboard.writeText(s),Je(a),v({title:"Copiado!"}),setTimeout(()=>Je(null),2500)}catch{v({title:"Erro ao copiar",variant:"destructive"})}},w=Lt(),Me=async(t,a=!1)=>{const s=u[t];if(s?.imagePrompt){Ze(t),M(r=>r.map((l,i)=>i===t?{...l,imageFailed:void 0}:l));try{let r;s.materialId?r=await(await S("POST",`/api/marketing/materials/${s.materialId}/generate-image`)).json():r=await(await S("POST","/api/marketing/generate-image",{imagePrompt:s.imagePrompt,imageStyle:s.imageStyle,aspectRatio:s.type==="story"?"9:16":"1:1",includeImageText:n.includeImageText})).json(),r.imageUrl&&(M(l=>l.map((i,c)=>c===t?{...i,imageUrl:r.imageUrl}:i)),w.invalidateQueries({queryKey:["/api/marketing/materials"]}),a||v({title:"Imagem gerada com sucesso!"}))}catch(r){if(s.materialId)try{const c=(await(await S("GET","/api/marketing/materials")).json()||[]).find(o=>o.id===s.materialId);if(c?.imageUrl){M(o=>o.map((j,te)=>te===t?{...j,imageUrl:c.imageUrl}:j)),w.invalidateQueries({queryKey:["/api/marketing/materials"]}),a||v({title:"Imagem gerada com sucesso!"});return}}catch{}M(l=>l.map((i,c)=>c===t?{...i,imageFailed:!0}:i)),a||v({title:"Erro ao gerar imagem",description:r.message||"Tente novamente.",variant:"destructive"})}finally{Ze(null)}}};h.useEffect(()=>k!=="results"||u.length===0||de.current?void 0:(de.current=!0,W.current=!1,(async()=>{for(let a=0;a<u.length&&!W.current;a++){const s=u[a];s.imagePrompt&&!s.imageUrl&&await Me(a,!0)}})(),()=>{W.current=!0}),[k,u.length]);const lt=(t,a)=>{const s=document.createElement("a");s.href=t,s.download=`imagem-${(a||"marketing").replace(/\s+/g,"-").toLowerCase()}.png`,s.click()},Tt=()=>{const t=u.map((i,c)=>`âââ ${(Ve[i.type]||i.type).toUpperCase()} ${c+1} âââ 9${i.title?`TÃtulo: ${i.title} 10 11`:""}${i.content} 12${i.hashtags?.length?` 13Hashtags: ${i.hashtags.join(" ")} 14`:""}${i.platform?`Plataforma sugerida: ${i.platform} 15`:""}`),a=`MATERIAL DE DIVULGAÃÃO â ${x?.title} 16Gerado por SÃBHIA Books 17${"â".repeat(50)} 18 19${t.join(` 20 21`)}`,s=new Blob([a],{type:"text/plain;charset=utf-8"}),r=URL.createObjectURL(s),l=document.createElement("a");l.href=r,l.download=`divulgacao-${(x?.title||"livro").replace(/\s+/g,"-").toLowerCase()}.txt`,l.click(),URL.revokeObjectURL(r),v({title:ie("marketingPage.downloadStarted")})},At=A.reduce((t,a)=>t+(C[a.id]||0)*Ue(a.unitPrice),0),ye=g?A.reduce((t,a)=>{const s=R[a.id]||0,r=Math.max(0,(C[a.id]||0)-s);return t+r*a.unitPrice},0):0,O=g&&ye>0,ot=(()=>
21{if(D<=0)return null;if(O){const t=A.filter(a=>{const s=R[a.id]||0;return(C[a.id]||0)>s}).map(a=>{const s=R[a.id]||0;return`${(C[a.id]||0)-s}x ${a.label} (extra)`});return{title:"Conteúdos extras de divulgação",price:Number(ye.toFixed(2)),originalPrice:Number((ye*1.5).toFixed(2)),description:`Conteúdos adicionais além do pacote para "${x?.title||""}"`,features:t}}return{title:ie("marketingPage.materialTitle"),price:st,originalPrice:Number(At.toFixed(2)),description:`${D} peças de conteúdo profissional para "${x?.title||""}"`,features:Object.entries(C).filter(([t,a])=>a>0).map(([t,a])=>{const s=A.find(r=>r.id===t);return`${a}x ${s?.label||t}`})}})(),nt=h.useCallback(async t=>{if(!et.has(t)){tt(a=>new Set(a).add(t));try{const s=await(await S("POST",`/api/marketing/materials/${t}/generate-image`)).json();s.imageUrl&&(wt(r=>({...r,[t]:s.imageUrl})),w.invalidateQueries({queryKey:["/api/marketing/materials"]}))}catch(a){console.error(`[MKT_IMG] Failed to generate image for ${t}:`,a)}finally{tt(a=>{const s=new Set(a);return s.delete(t),s})}}},[et,w]);h.useCallback(async t=>{const a=t.filter(s=>s.imagePrompt&&!s.imageUrl&&!fe[s.id]);for(const s of a)await nt(s.id)},[nt,fe]);const ct=n.colorPalette||n.style||n.tone||n.targetAudience||n.authorNotes.trim(),Le=[n.colorPalette&&(n.colorPalette==="cover"?"Tons da capa":Ge.find(t=>t.id===n.colorPalette)?.label),n.style&&Qe.find(t=>t.id===n.style)?.label,n.tone&&Oe.find(t=>t.id===n.tone)?.label,n.targetAudience&&Ke.find(t=>t.id===n.targetAudience)?.label,n.includeImageText?"Com texto nas imagens":null].filter(Boolean);return e.jsxs(Rt,{children:[e.jsxs("div",{className:`min-h-screen ${f?"lg:pr-[316px]":""}`,children:[k==="pipeline_waiting"&&x&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sticky top-0 z-40 border-b border-white/10 bg-background/80 backdrop-blur-xl",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 md:px-6 h-14 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>m?V(`/book/${m}`):(d("choice"),q(null)),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-white transition-colors","data-testid":"divulgacao-waiting-back",children:[e.jsx(se,{className:"w-4 h-4"}),e.jsx("span",{children:m?"Voltar ao livro":"Escolher outro livro"})]}),e.jsxs(y,{className:"bg-primary/20 text-primary border-primary/20 text-xs shrink-0","data-testid":"badge-divulgacao-waiting",children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),"Divulgação"]})]})}),e.jsx("div",{className:"max-w-2xl mx-auto px-4 md:px-6 py-12",children:e.jsx(Yt,{bookId:f||"",bookTitle:x?.title||"",serviceName:"marketing",pipelineStatus:{},onBack:()=>{d("choice"),q(null)}})})]}),k==="book_gallery"&&x&&(()=>{const t=L.filter(a=>a.bookId===f);return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sticky top-0 z-40 border-b border-white/10 bg-background/80 backdrop-blur-xl",children:e.jsxs("div",{className:"max-w-5xl mx-auto px-4 md:px-6 h-14 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>m?V(`/book/${m}`):(d("choice"),q(null)),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-white transition-colors","data-testid":"divulgacao-bookgallery-back",children:[e.jsx(se,{className:"w-4 h-4"}),e.jsx("span",{children:m?"Voltar ao livro":"Escolher outro livro"})]}),e.jsxs(y,{className:"bg-primary/20 text-primary border-primary/20 text-xs shrink-0",children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),"Divulgação"]})]})}),e.jsx("div",{className:"max-w-5xl mx-auto px-4 md:px-6 py-8 space-y-8 pb-40 md:pb-24",children:e.jsxs("div",{className:"animate-in fade-in slide-in-from-bottom-4 duration-500 space-y-8",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-14 h-20 rounded-xl overflow-hidden border border-white/10 bg-gradient-to-b from-[#1a1a2e] to-[#0f0f1a] flex-shrink-0 shadow-lg",children:x.coverImage?e.jsx(he,{src:x.coverImage,alt:x.title,widths:[96,128,160,200],sizes:"120px",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(ae,{className:"w-5 h-5 text-primary/60"})})}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold text-white",children:x.title}),e.jsxs("p",{className:"text-base text-muted-foreground mt-1",children:[t.length," ",t.length===1?"material criado":"materiais criados"]})]})]}),e.jsxs($,{onClick:()=>{const a=Z.find(s=>s.id===f);a?.coverImage&&Ae(a.coverImage),d("customize")},className:"gap-2 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white rounded-xl","data-testid":"btn-bookgallery-create-more",children:[e.jsx(ue,{className:"w-4 h-4"}),"Criar mais"]})]}),xe?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(_,{className:"w-10 h-10 text-primary animate-spin mb
21-4"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Carregando seus materiais..."})]}):t.length===0?e.jsxs("div",{className:"text-center py-16",children:[e.jsx("div",{className:"w-20 h-20 mx-auto mb-6 rounded-2xl bg-primary/10 border border-primary/20 flex items-center justify-center",children:e.jsx(Xt,{className:"w-10 h-10 text-primary/60"})}),e.jsx("h3",{className:"text-xl font-bold text-white mb-2",children:"Nenhum material ainda"}),e.jsx("p",{className:"text-base text-muted-foreground mb-6 max-w-md mx-auto",children:"Crie materiais de divulgação incrÃveis para este livro."}),e.jsxs($,{onClick:()=>d("customize"),className:"gap-2 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white rounded-xl h-12 text-base","data-testid":"btn-bookgallery-create",children:[e.jsx(ue,{className:"w-5 h-5"}),"Criar meus primeiros materiais"]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:t.map(a=>{const s=a.imageUrl||fe[a.id],r=a.type==="story"||a.type==="instagram_story";return e.jsxs("div",{onClick:()=>me(a.id),className:"glass-card rounded-2xl border border-white/10 hover:border-primary/30 hover:shadow-lg hover:shadow-primary/5 transition-all duration-300 overflow-hidden group cursor-pointer","data-testid":`gallery-material-${a.id}`,children:[s?e.jsxs("div",{className:"relative w-full aspect-[4/3] overflow-hidden bg-black/20",children:[e.jsx("img",{src:s,alt:a.title||"Material de divulgação",className:"w-full h-full object-cover group-hover:scale-105 transition-transform duration-500","data-testid":`gallery-img-${a.id}`}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/40 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"}),e.jsx("div",{className:"absolute bottom-3 right-3 opacity-0 group-hover:opacity-100 transition-opacity duration-300",children:e.jsx("div",{className:"w-9 h-9 rounded-full bg-black/60 backdrop-blur-sm flex items-center justify-center",children:e.jsx(Se,{className:"w-4 h-4 text-white"})})}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx(y,{className:"bg-black/60 text-white border-white/20 text-xs backdrop-blur-sm",children:r?"Story":"Feed"})}),e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx("span",{className:"text-[10px] text-white/80 bg-black/50 px-1.5 py-0.5 rounded backdrop-blur-sm",children:a.createdAt?new Date(a.createdAt).toLocaleDateString("pt-BR"):""})})]}):e.jsxs("div",{className:"relative w-full aspect-[4/3] overflow-hidden",children:[e.jsx("div",{className:`absolute inset-0 ${r?"bg-gradient-to-br from-violet-900/60 via-indigo-900/40 to-teal-900/60":"bg-gradient-to-br from-teal-900/60 via-emerald-900/40 to-cyan-900/60"}`}),e.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-3 p-4",children:[r?e.jsx($e,{className:"w-8 h-8 text-white/30"}):e.jsx(mt,{className:"w-8 h-8 text-white/30"}),e.jsx("span",{className:"text-[11px] text-white/40 font-medium uppercase tracking-wider",children:r?"Story":"Feed"})]}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx(y,{className:"bg-black/40 text-white/80 border-white/10 text-xs backdrop-blur-sm",children:r?"Story":"Feed"})})]}),e.jsxs("div",{className:"p-4 space-y-2",children:[a.title&&e.jsx("h4",{className:"text-sm font-bold text-white line-clamp-2",children:a.title}),e.jsx("p",{className:"text-sm text-white/70 line-clamp-3 whitespace-pre-wrap",children:a.content}),a.hashtags?.length>0&&e.jsxs("div",{className:"flex flex-wrap gap-1 pt-1",children:[a.hashtags.slice(0,3).map((l,i)=>e.jsx("span",{className:"text-[10px] text-primary/70 bg-primary/5 px-1.5 py-0.5 rounded",children:l},i)),a.hashtags.length>3&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["+",a.hashtags.length-3]})]})]}),e.jsxs("div",{className:"px-4 py-2.5 border-t border-white/5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] text-white/30 group-hover:text-white/50 transition-colors flex items-center gap-1",children:[e.jsx(Se,{className:"w-3 h-3"})," Abrir"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[s&&e.jsx("button",{onClick:l=>{l.stopPropagation();const i=document.createElement("a");i.href=s,i.download=`${(a.title||"divulgacao").replace(/\s+/g,"-").toLowerCase()}.png`,i.click()},className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-primary transition-colors px-2 py-1 rounded-lg hover:bg-white/5","data-testid":`btn-gallery-download-${a.id}`,children:e.jsx(ge,{className:"w-3 h-3"})}),e.jsx("button",{onClick:async l=>{l.stopPropagation();const i=`${a.title?a.title+` 22 23`:""}${a.content}${a.hashtags?.length?` 24 25`+a.hashtags.join(" "):""}`;try{await navigator.clipboard.writeText(i),v({title:"Texto copiado!"})}catch{v({title:"Erro ao copiar",variant:"destructive"})}},className:"flex items-center gap-1 text-xs text-muted-foreground hover:text-primary transition-colors px-2 py-1 rounded-lg hover:bg-white/5","data-testid":`btn-gallery-copy-${a.id}`,children:e.jsx(Be,{className:"w-3 h-3"})})]})]})]},a.id)})}),Te&&(()=>{const a=t.find(o=>o.id===Te);if(!a)return null;const s=a.imageUrl||fe[a.id],r=a.type==="story"||a.type==="instagram_story",l=t.findIndex(o=>o.id===Te),i=He?.penName||He?.name||"Autor",c=i.charAt(0).toUpperCase();return e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center p-4","data-testid":"gallery-preview-modal",children:[e.jsx("div",{className:"absolute inset-0 bg-black/90 backdrop-blur-lg",onClick:()=>{me(null),X(null)}}),t.length>1&&e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>{const o=l>0?t[l-1].id:t[t.length-1].id;me(o),X(null)},className:"absolute left-2 md:left-6 z-20 w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors backdrop-blur-sm","data-testid":"btn-gallery-prev",children:e.jsx(Bt,{className:"w-5 h-5 text-white"})}),e.jsx("button",{onClick:()=>{const o=l<t.length-1?t[l+1].id:t[0].id;me(o),X(null)},className:"absolute right-2 md:right-6 z-20 w-10 h-10 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors backdrop-blur-sm","data-testid":"btn-gallery-next",children:e.jsx(ke,{className:"w-5 h-5 text-white"})})]}),e.jsx("button",{onClick:()=>{me(null),X(null)},className:"absolute top-4 right-4 z-20 w-9 h-9 rounded-full bg-white/10 hover:bg-white/20 flex items-center justify-center transition-colors backdrop-blur-sm","data-testid":"btn-gallery-close",children:e.jsx(xt,{className:"w-5 h-5 text-white"})}),e.jsxs("div",{className:"absolute top-4 left-4 z-20 flex items-center gap-3",children:[e.jsxs(y,{className:`text-xs ${r?"bg-violet-500/20 text-violet-300 border-violet-500/30":"bg-primary/20 text-primary border-primary/30"} backdrop-blur-sm`,children:[e.jsx($e,{className:"w-3 h-3 mr-1"}),r?"Story":"Feed"]}),e.jsxs("span",{className:"text-xs text-white/50",children:[l+1," / ",t.length]})]}),e.jsxs("div",{className:"relative z-10 flex flex-col lg:flex-row gap-5 max-h-[90vh] w-full max-w-4xl",children:[r?e.jsx("div",{className:"flex-shrink-0 mx-auto",style:{width:"min(320px, 100%)"},children:e.jsxs("div",{className:"relative bg-black rounded-[2rem] border-[3px] border-white/10 overflow-hidden shadow-2xl",style:{aspectRatio:"9/16"},children:[e.jsxs("div",{className:"absolute top-0 left-0 right-0 z-10 p-3",children:[e.jsxs("div",{className:"flex gap-1 mb-3",children:[e.jsx("div",{className:"flex-1 h-[2px] rounded-full bg-white/80"}),e.jsx("div",{className:"flex-1 h-[2px] rounded-full bg-white/30"}),e.jsx("div",{className:"flex-1 h-[2px] rounded-full bg-white/30"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-br from-violet-500 to-pink-500 flex items-center justify-center ring-2 ring-pink-500/50",children:e.jsx("span",{className:"text-[10px] font-bold text-white",children:c})}),e.jsx("span",{className:"text-xs font-semibold text-white drop-shadow-lg",children:i}),e.jsx("span",{className:"text-[10px] text-white/60",children:"⢠agora"})]})]}),s?e.jsx("img",{src:s,alt:a.title||"",className:"w-full h-full object-cover","data-testid":"gallery-preview-image"}):e.jsx("div",{className:"w-full h-full bg-gradient-to-br from-violet-900 via-indigo-900 to-purple-900 flex items-center justify-center",children:e.jsx($e,{className:"w-12 h-12 text-white/20"})}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-4 bg-gradient-to-t from-black/60 to-transparent",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("div",{className:"flex-1 bg-white/10 backdrop-blur-sm rounded-full px-4 py-2",children:e.jsx("span",{className:"text-xs text-white/50",children:"Enviar mensagem"})}),e.jsxs("div",{className:"flex gap-3 ml-3",children:[e.jsx(bt,{className:"w-5 h-5 text-white"}),e.jsx(ht,{className:"w-5 h-5 text-white"})]})]})})]})}):e.jsx("div",{className:"flex-shrink-0 mx-auto w-full max-w-[420px]",children:e.jsxs("div",{className:"bg-black rounded-2xl border border-white/10 overflow-hidden shadow-2xl",children:[e.jsxs("div",{className:"flex items-center gap-3 px-4 py-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-gradient-to-br from-primary to-teal-500 flex items-center justify-center ring-2 ring-primary/30",children:e.jsx("span",{className:"text-xs font-bold text-white",children:c})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-white truncate",children:i}),e.jsx("p",{className:"text-[10px] text-white/40",children:"Patrocinado"})]}),e.jsxs("div",{className:"flex gap-0.5",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-white/50"}),e.jsx("span",{className:"w-1 h-1 rounded-full bg-white/50"}),e.jsx("span",{className:"w-1 h-1 rounded-full bg-white/50"})]})]}),s?e.jsx("img",{src:s,alt:a.title||"",className:"w-full aspect-square object-cover","data-testid":"gallery-preview-image"}):e.jsx("div",{className:"w-full aspect-square bg-gradient-to-br from-teal-900 via-emerald-900 to-cyan-900 flex items-center justify-center",children:e.jsx(mt,{className:"w-12 h-12 text-white/20"})}),e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(bt,{className:"w-6 h-6 text-white hover:text-red-400 transition-colors cursor-pointer"}),e.jsx(Dt,{className:"w-6 h-6 text-white"}),e.jsx(ht,{className:"w-6 h-6 text-white"})]}),e.jsx(Zt,{className:"w-6 h-6 text-white"})]}),e.jsxs("p",{className:"text-sm text-white mb-1",children:[e.jsx("span",{className:"font-semibold",children:i})," ",e.jsxs("span",{className:"text-white/80",children:[a.content?.substring(0,100),a.content?.length>100?"...":""]})]}),a.hashtags?.length>0&&e.jsx("p",{className:"text-sm text-[#00376b] dark:text-blue-400",children:a.hashtags.slice(0,5).join(" ")}),e.jsx("p",{className:"text-[11px] text-white/30 mt-1 uppercase",children:"agora mesmo"})]})]})}),e.jsxs("div",{className:"flex-1 min-w-0 flex flex-col bg-[#0c0c0e] rounded-2xl border border-white/10 overflow-hidden lg:max-h-[80vh]",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-white/5 flex items-center justify-between",children:[e.jsx("h3",{className:"text-base font-bold text-white",children:a.title||(r?"Story":"Post")}),e.jsx(y,{variant:"outline",className:"text-[10px] border-white/10 text-white/50",children:a.createdAt?new Date(a.createdAt).toLocaleDateString("pt-BR"):""})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-white/30 font-semibold mb-2",children:"Texto para postar"}),e.jsx("div",{className:"text-[15px] text-white/85 leading-relaxed whitespace-pre-wrap bg-white/[0.02] rounded-xl p-4 border border-white/5",children:a.content})]}),a.hashtags?.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-[11px] uppercase tracking-wider text-white/30 font-semibold mb-2",children:"Hashtags"}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:a.hashtags.map((o,j)=>e.jsx("span",{className:"text-xs text-primary bg-primary/10 px-2.5 py-1 rounded-lg font-medium",children:o},j))})]})]}),e.jsxs("div",{className:"border-t border-white/5 bg-[#0c0c0e]/95 backdrop-blur-sm px-5 py-4 space-y-2",children:[e.jsx($,{onClick:async()=>{const o=`${a.title?a.title+` 26 27`:""}${a.content}${a.hashtags?.length?` 28 29`+a.hashtags.join(" "):""}`;try{await navigator.clipboard.writeText(o),X(a.id),v({title:"Texto e hashtags copiados! Cole no Instagram."}),setTimeout(()=>X(null),3e3)}catch{v({title:"Erro ao copiar",variant:"destructive"})}},className:"w-full gap-2 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white rounded-xl h-12 text-sm font-semibold","data-testid":"btn-gallery-preview-copy",children:yt===a.id?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4"})," Copiado!"]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-4 h-4"})," Copiar texto e hashtags"]})}),s&&e.jsxs($,{onClick:()=>{const o=document.createElement("a");o.href=s,o.download=`${(a.title||"divulgacao").replace(/\s+/g,"-").toLowerCase()}.png`,o.click()},variant:"outline",className:"w-full gap-2 border-white/10 text-white hover:bg-white/5 rounded-xl h-12 text-sm font-semibold","data-testid":"btn-gallery-preview-download",children:[e.jsx(ge,{className:"w-4 h-4"})," Baixar imagem"]})]})]})]})]})})()]})]})})]})})(),k==="choice"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sticky top-0 z-40 border-b border-white/10 bg-background/80 backdrop-blur-xl",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 py-3 flex items-center justify-between gap-3",children:[e.jsxs("button",{onClick:()=>V(m?`/book/${m}
29`:"/dashboard"),className:"flex items-center gap-2 text-muted-foreground hover:text-white transition-colors text-sm","data-testid":"divulgacao-back",children:[e.jsx(se,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:m?"Voltar ao livro":"Voltar ao painel"}),e.jsx("span",{className:"sm:hidden",children:"Voltar"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(K,{className:"w-5 h-5 text-primary"}),e.jsx("span",{className:"text-sm font-semibold text-primary uppercase tracking-wider hidden sm:inline",children:ie("marketingPage.title")})]})]})}),e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-6 space-y-6 pb-40 md:pb-24",children:e.jsxs("section",{"data-testid":"divulgacao-choice-section",children:[e.jsx(Vt,{}),e.jsx("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-4 mt-6 mb-6",children:e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl md:text-3xl font-heading font-bold text-white mb-1","data-testid":"divulgacao-title",children:ie("marketingPage.title")}),e.jsx("p",{className:"text-muted-foreground","data-testid":"divulgacao-subtitle",children:ie("marketingPage.subtitle")})]})}),Fe||xe?e.jsxs("div",{className:"flex flex-col items-center justify-center py-16",children:[e.jsx(_,{className:"w-10 h-10 text-primary animate-spin mb-4"}),e.jsx("p",{className:"text-lg text-muted-foreground",children:"Carregando seus livros..."})]}):Z.length===0?e.jsxs("div",{className:"glass-card rounded-2xl border border-white/10 p-8 text-center","data-testid":"divulgacao-no-books",children:[e.jsx("div",{className:"w-16 h-16 rounded-full bg-amber-500/10 flex items-center justify-center mx-auto mb-4",children:e.jsx(ae,{className:"w-8 h-8 text-amber-400"})}),e.jsx("h3",{className:"text-xl font-bold text-white mb-2",children:"Nenhum livro encontrado"}),e.jsx("p",{className:"text-base text-muted-foreground mb-6",children:"Crie um livro primeiro para poder gerar conteúdo de divulgação."}),e.jsx($,{onClick:()=>V("/book/new"),className:"gap-2 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white rounded-xl","data-testid":"button-create-new-book",children:"Criar novo livro"})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-5 max-w-4xl mx-auto",children:Z.map(t=>{const a=t.status==="writing"||t.status==="completed";return e.jsxs("button",{onClick:()=>a?St(t.id):V(`/book/${t.id}`),className:`group relative h-[260px] glass-card rounded-2xl border transition-all duration-300 overflow-hidden text-left ${a?"border-white/5 hover:border-primary/30 hover:shadow-[0_10px_40px_-10px_hsl(178_86%_39%_/_0.15)]":"border-white/5 opacity-70"}`,"data-testid":`divulgacao-book-${t.id}`,children:[t.coverImage&&e.jsx(he,{src:t.coverImage,alt:"",widths:[160,200,260,320],sizes:"(max-width: 768px) 50vw, 240px",quality:65,className:"absolute inset-0 w-full h-full object-cover opacity-60 group-hover:opacity-75 transition-all duration-500 group-hover:scale-105 transform-gpu z-[1]",onError:s=>{s.target.style.display="none"}}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/90 via-black/40 to-transparent z-[2]"}),e.jsxs("div",{className:"relative z-10 h-full flex flex-col justify-between p-5",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsx("div",{className:"w-16 h-22 rounded-lg shadow-xl overflow-hidden border border-white/10 bg-gradient-to-b from-[#1a1a2e] to-[#0f0f1a] flex flex-col items-center justify-center",children:t.coverImage?e.jsx(he,{src:t.coverImage,alt:t.title,widths:[96,128,160],sizes:"96px",className:"w-full h-full object-cover"}):e.jsx(ae,{className:"w-6 h-6 text-primary/60"})}),!a&&e.jsx(y,{className:"bg-amber-500/20 text-amber-400 border-amber-500/30 text-xs backdrop-blur-sm",children:"Finalize a escrita"}),a&&t.chapters?.length>0&&e.jsxs(y,{className:"bg-white/10 text-white/80 border-white/10 text-xs backdrop-blur-sm",children:[t.chapters.length," cap."]}),a&&(()=>{const s=L.filter(r=>r.bookId===t.id).length;return s>0?e.jsxs(y,{className:"bg-primary/10 text-primary border-primary/20 text-xs backdrop-blur-sm",children:[s," ",s===1?"material":"materiais"]}):null})()]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white leading-tight line-clamp-2 mb-1 drop-shadow-lg",children:t.title}),t.author&&e.jsx("p",{className:"text-sm text-white/70 truncate drop-shadow-md",children:t.author}),a?(()=>{const s=L.some(r=>r.bookId===t.id);return e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm font-semibold text-primary group-hover:text-primary/80 transition-colors",children:[e.jsx("span",{children:s?"Ver materiais":"Criar material de divulgação"}),e.jsx(ke,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})})():e.jsxs("div",{className:"mt-3 flex items-center gap-2 text-sm font-semibold text-amber-400 transition-colors",children:[e.jsx("span",{children:"Continuar escrita"}),e.jsx(ke,{className:"w-4 h-4 group-hover:translate-x-1 transition-transform"})]})]})]})]},t.id)})})]})})]}),k==="customize"&&x&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sticky top-0 z-40 border-b border-white/5 bg-background/80 backdrop-blur-xl",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-6 h-14 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>m?V(`/book/${m}`):(d("choice"),q(null),E(!1)),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-white transition-colors","data-testid":"divulgacao-back-choice",children:[e.jsx(se,{className:"w-4 h-4"}),e.jsx("span",{children:m?"Voltar ao livro":"Escolher outro livro"})]}),e.jsxs(y,{className:"bg-primary/20 text-primary border-primary/20 hover:bg-primary/20 text-xs shrink-0",children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),"Divulgação"]})]})}),e.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-6 py-8 space-y-8 pb-40 md:pb-32",children:[e.jsx("div",{className:"glass-card rounded-2xl border border-white/10 p-5 md:p-6","data-testid":"divulgacao-book-summary",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-22 rounded-xl overflow-hidden border border-white/10 bg-gradient-to-b from-[#1a1a2e] to-[#0f0f1a] flex-shrink-0 shadow-lg",children:x.coverImage?e.jsx(he,{src:x.coverImage,alt:x.title,widths:[96,128,160,200],sizes:"120px",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(ae,{className:"w-6 h-6 text-primary/60"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white leading-tight line-clamp-2",children:x.title}),x.author&&e.jsx("p",{className:"text-base text-muted-foreground mt-1",children:x.author})]})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary flex items-center justify-center text-white text-sm font-bold",children:"1"}),e.jsx("span",{className:"text-sm font-semibold text-primary hidden sm:inline",children:"Personalizar"})]}),e.jsx("div",{className:"w-8 h-px bg-white/20"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-white/10 flex items-center justify-center text-muted-foreground text-sm font-bold",children:"2"}),e.jsx("span",{className:"text-sm text-muted-foreground hidden sm:inline",children:"Escolher conteúdos"})]})]}),g&&e.jsx("div",{className:ut("rounded-xl p-4 flex items-start gap-3",J?"bg-blue-500/10 border border-blue-500/30":"bg-amber-500/10 border border-amber-500/30"),"data-testid":"banner-already-purchased",children:J?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-5 h-5 text-blue-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-blue-300",children:"Marketing já incluso no seu pacote!"}),e.jsx("p",{className:"text-sm text-blue-200/70 mt-1",children:"Já escolheu sua capa? Personalize suas preferências e clique em gerar quando estiver pronto."})]})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ut,{className:"w-5 h-5 text-amber-400 mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium text-amber-300",children:"O processamento automático teve um problema."}),e.jsx("p",{className:"text-sm text-amber-200/70 mt-1",children:"Você pode personalizar e gerar seus materiais novamente â sem custo adicional."})]})]})}),e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-white",children:"Como você quer sua divulgação?"}),e.jsx("p",{className:"text-base md:text-lg text-muted-foreground max-w-xl mx-auto leading-relaxed",children:"Escolha o visual, o estilo e o tom do seu material. Tudo é opcional â se preferir, pode pular e a SÃBHIA decide por você."})]}),e.jsxs("div",{className:"space-y-4","data-testid":"divulgacao-colors",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(_t,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Cores do material"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Escolha uma paleta que combine com seu livro"})]})]}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[x?.coverImage&&e.jsxs("button",{onClick:()=>P(t=>({...t,colorPalette:t.colorPalette==="cover"?"":"cover"})),className:`relative group glass-card rounded-xl border p-3 transition-all duration-200 text-left ${n.colorPalette==="cover"?"border-primary/50 bg-primary/5 ring-1 ring-primary/30":"border-white/10 hover:border-white/20"}`,"data-testid":"color-cover",children:[e.jsx("div",{className:"flex gap-1 mb-2",children:Xe?e.jsxs("div",{className:"flex items-center gap-2 h-6",children:[e.jsx(_,{className:"w-4 h-4 text-primary animate-spin"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"Lendo capa..."})]}):ne.length>0?ne.map((t,a)=>e.jsx("div",{className:"w-6 h-6 rounded-md border border-white/10 shadow-sm",style:{backgroundColor:t}},a)):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"w-6 h-6 rounded-md border border-white/10 bg-white/10 animate-pulse"}),e.jsx("div",{className:"w-6 h-6 rounded-md border border-white/10 bg-white/10 animate-pulse"}),e.jsx("div",{className:"w-6 h-6 rounded-md border border-white/10 bg-white/10 animate-pulse"}),e.jsx("div",{className:"w-6 h-6 rounded-md border border-white/10 bg-white/10 animate-pulse"})]})}),e.jsxs("div",{className:"text-sm font-semibold text-white leading-tight flex items-center gap-1.5",children:[e.jsx(ae,{className:"w-3.5 h-3.5 text-primary shrink-0"}),"Tons da Capa"]}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:"Cores extraÃdas da capa do seu livro"}),n.colorPalette==="cover"&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(G,{className:"w-4 h-4 text-primary"})})]}),Ge.map(t=>e.jsxs("button",{onClick:()=>P(a=>({...a,colorPalette:a.colorPalette===t.id?"":t.id})),className:`relative group glass-card rounded-xl border p-3 transition-all duration-200 text-left ${n.colorPalette===t.id?"border-primary/50 bg-primary/5 ring-1 ring-primary/30":"border-white/10 hover:border-white/20"}`,"data-testid":`color-${t.id}`,children:[e.jsx("div",{className:"flex gap-1 mb-2",children:t.colors.map((a,s)=>e.jsx("div",{className:"w-6 h-6 rounded-md border border-white/10",style:{backgroundColor:a}},s))}),e.jsx("div",{className:"text-sm font-semibold text-white leading-tight",children:t.label}),e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:t.desc}),n.colorPalette===t.id&&e.jsx("div",{className:"absolute top-2 right-2",children:e.jsx(G,{className:"w-4 h-4 text-primary"})})]},t.id))]})]}),e.jsxs("div",{className:"space-y-4","data-testid":"divulgacao-styles",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(ue,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Estilo visual"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Como você quer que o material pareça"})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:Qe.map(t=>e.jsxs("button",{onClick:()=>P(a=>({...a,style:a.style===t.id?"":t.id})),className:`group relative rounded-xl border overflow-hidden h-[120px] transition-all duration-200 text-left ${n.style===t.id?"border-primary/50 ring-1 ring-primary/30":"border-white/10 hover:border-white/20"}`,"data-testid":`style-${t.id}`,children:[e.jsx("img",{src:t.image,alt:t.label,className:"absolute inset-0 w-full h-full object-cover opacity-50 group-hover:opacity-65 transition-all duration-300 group-hover:scale-105 transform-gpu"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent"}),e.jsxs("div",{className:"relative z-10 h-full flex flex-col justify-end p-4",children:[e.jsx("div",{className:"text-sm font-bold text-white drop-shadow-lg",children:t.label}),e.jsx("div",{className:"text-xs text-white/70 mt-0.5 drop-shadow-md",children:t.desc})]}),n.style===t.id&&e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(G,{className:"w-5 h-5 text-primary drop-shadow-lg"})})]},t.id))})]}),e.jsxs("div",{className:"space-y-4","data-testid":"divulgacao-tones",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(_e,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Tom dos textos"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Como a SÃBHIA vai se comunicar"})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 gap-3",children:Oe.map(t=>e.jsxs("button",{onClick:()=>P(a=>({...a,tone:a.tone===t.id?"":t.id})),className:`glass-card rounded-xl border p-4 transition-all duration-200 text-left ${n.tone===t.id?"border-primary/50 bg-primary/5 ring-1 ring-primary/30":"border-white/10 hover:border-white/20"}`,"data-testid":`tone-${t.id}`,children:[e.jsx("div",{className:"text-sm font-bold text-white",children:t.label}),e.jsx("div",{className:"text-xs text-muted-foreground mt-1",children:t.desc})]},t.id))})]}),e.jsxs("div",{className:"space-y-4","data-testid":"divulgacao-audience",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(Gt,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Público-alvo"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Para quem é o seu livro"})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:Ke.map(t=>e.jsxs("button",{onClick:()=>P(a=>({...a,targetAudience:a.targetAudience===t.id?"":t.id})),className:`group relative rounded-xl border overflow-hidden h-[120px] transition-all duration-200 text-left ${n.targetAudience===t.id?"border-primary/50 ring-1 ring-primary/30":"border-white/10 hover:border-white/20"}`,"data-testid":`audience-${t.id}`,children:[e.jsx("img",{src:t.image,alt:t.label,className:"absolute inset-0 w-full h-full object-cover opacity-50 group-hover:opacity-65 transition-all duration-300 group-hover:scale-105 transform-gpu"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent"}),e.jsxs("div",{className:"relative z-10 h-full flex flex-col justify-end p-3",children:[e.jsx("div",{className:"text-sm font-bold text-white drop-shadow-lg",children:t.label}),e.jsx("div",{className:"text-xs text-white/70 mt-0.5 drop-shadow-md",children:t.desc})]}),n.targetAudience===t.id&&e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(G,{className:"w-5 h-5 text-primary drop-shadow-lg"})})]},t.id))})]}),e.jsxs("div",{className:"space-y-4","data-te
29stid":"divulgacao-image-styles",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-purple-500/10 flex items-center justify-center",children:e.jsx(De,{className:"w-5 h-5 text-purple-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Estilo das imagens"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Escolha o estilo visual das imagens"})]})]}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:sa.map(t=>e.jsxs("button",{onClick:()=>P(a=>({...a,imageStyle:a.imageStyle===t.id?"":t.id})),className:`group relative rounded-xl border overflow-hidden h-[120px] transition-all duration-200 text-left ${n.imageStyle===t.id?"border-purple-500/50 ring-1 ring-purple-500/30":"border-white/10 hover:border-white/20"}`,"data-testid":`image-style-${t.id}`,children:[e.jsx("img",{src:t.image,alt:t.label,className:"absolute inset-0 w-full h-full object-cover opacity-50 group-hover:opacity-65 transition-all duration-300 group-hover:scale-105 transform-gpu"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/30 to-transparent"}),e.jsxs("div",{className:"relative z-10 h-full flex flex-col justify-end p-3",children:[e.jsx("div",{className:"text-sm font-bold text-white drop-shadow-lg",children:t.label}),e.jsx("div",{className:"text-xs text-white/70 mt-0.5 drop-shadow-md",children:t.desc})]}),n.imageStyle===t.id&&e.jsx("div",{className:"absolute top-2 right-2 z-10",children:e.jsx(G,{className:"w-5 h-5 text-purple-400 drop-shadow-lg"})})]},t.id))})]}),e.jsxs("div",{className:"space-y-4","data-testid":"divulgacao-image-text",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-amber-500/10 flex items-center justify-center",children:e.jsx(_e,{className:"w-5 h-5 text-amber-400"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Texto nas imagens"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Quer que a SÃBHIA escreva frases chamativas diretamente nas imagens?"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("button",{onClick:()=>P(t=>({...t,includeImageText:!0})),className:`group relative glass-card rounded-xl border p-5 transition-all duration-200 text-left ${n.includeImageText?"border-amber-500/50 bg-amber-500/5 ring-1 ring-amber-500/30":"border-white/10 hover:border-white/20"}`,"data-testid":"image-text-yes",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center ${n.includeImageText?"bg-amber-500/20":"bg-white/5"}`,children:e.jsx(_e,{className:`w-5 h-5 ${n.includeImageText?"text-amber-400":"text-muted-foreground"}`})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-bold text-white",children:"Sim, com texto"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Frases que geram desejo e curiosidade"})]})]}),e.jsx("p",{className:"text-sm text-white/60 leading-relaxed",children:"Vamos criar frases poderosas e impactantes escritas diretamente nas imagens, prontas para publicar."}),n.includeImageText&&e.jsx("div",{className:"absolute top-3 right-3",children:e.jsx(G,{className:"w-5 h-5 text-amber-400"})})]}),e.jsxs("button",{onClick:()=>P(t=>({...t,includeImageText:!1})),className:`group relative glass-card rounded-xl border p-5 transition-all duration-200 text-left ${n.includeImageText?"border-white/10 hover:border-white/20":"border-primary/50 bg-primary/5 ring-1 ring-primary/30"}`,"data-testid":"image-text-no",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[e.jsx("div",{className:`w-10 h-10 rounded-xl flex items-center justify-center ${n.includeImageText?"bg-white/5":"bg-primary/20"}`,children:e.jsx(De,{className:`w-5 h-5 ${n.includeImageText?"text-muted-foreground":"text-primary"}`})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-base font-bold text-white",children:"Não, sem texto"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Imagens limpas e artÃsticas"})]})]}),e.jsx("p",{className:"text-sm text-white/60 leading-relaxed",children:"As imagens serão criadas sem nenhum texto, perfeitas para usar com legendas que você mesmo escreve."}),!n.includeImageText&&e.jsx("div",{className:"absolute top-3 right-3",children:e.jsx(G,{className:"w-5 h-5 text-primary"})})]})]})]}),e.jsxs("div",{className:"space-y-4","data-testid":"divulgacao-notes",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(Qt,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-bold text-white",children:"Suas instruções"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Escreva o que quiser â vamos seguir suas orientações"})]})]}),e.jsx("textarea",{value:n.authorNotes,onChange:t=>P(a=>({...a,authorNotes:t.target.value})),placeholder:"Exemplo: Quero que destaque que o livro é baseado em uma história real. Use frases curtas e diretas. Mencione que está disponÃvel na Amazon. Não use a palavra 'incrÃvel'...",maxLength:2e3,rows:4,className:"w-full rounded-xl border border-white/10 bg-white/[0.03] px-4 py-3 text-base text-white placeholder:text-muted-foreground
29/50 focus:border-primary/50 focus:ring-1 focus:ring-primary/30 focus:outline-none resize-none transition-all","data-testid":"input-author-notes"}),e.jsxs("div",{className:"text-xs text-muted-foreground text-right",children:[n.authorNotes.length,"/2000"]})]})]}),e.jsx("div",{className:"fixed bottom-0 left-0 right-0 md:left-64 z-50 border-t border-white/10 bg-background/95 backdrop-blur-xl safe-area-bottom fixed-above-tabs",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-6 py-4 flex items-center justify-between gap-4",children:[e.jsx("div",{className:"flex-1 min-w-0",children:ct?e.jsxs("div",{className:"text-sm text-muted-foreground",children:[Le.length>0&&e.jsx("span",{children:Le.join(" · ")}),n.authorNotes.trim()&&e.jsx("span",{className:"block text-xs mt-0.5 text-primary/70",children:"+ instruções personalizadas"})]}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"Nenhuma preferência selecionada (a SÃBHIA vai decidir)"})}),e.jsxs($,{onClick:()=>d("planning"),className:"gap-2 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white rounded-xl text-base h-12 px-8 shadow-lg shadow-primary/20","data-testid":"btn-continue-to-planning",children:[e.jsx("span",{className:"hidden sm:inline",children:"Escolher conteúdos"}),e.jsx("span",{className:"sm:hidden",children:"Continuar"}),e.jsx(ke,{className:"w-5 h-5"})]})]})})]}),k==="planning"&&x&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sticky top-0 z-40 border-b border-white/5 bg-background/80 backdrop-blur-xl",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-6 h-14 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>d("customize"),className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-white transition-colors","data-testid":"divulgacao-back-customize",children:[e.jsx(se,{className:"w-4 h-4"}),e.jsx("span",{children:"Voltar à s preferências"})]}),e.jsxs(y,{className:"bg-primary/20 text-primary border-primary/20 hover:bg-primary/20 text-xs shrink-0",children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),"Divulgação"]})]})}),e.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-6 py-8 space-y-8 pb-40 md:pb-32",children:[e.jsx("div",{className:"glass-card rounded-2xl border border-white/10 p-5 md:p-6","data-testid":"divulgacao-book-summary-plan",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-16 h-22 rounded-xl overflow-hidden border border-white/10 bg-gradient-to-b from-[#1a1a2e] to-[#0f0f1a] flex-shrink-0 shadow-lg",children:x.coverImage?e.jsx(he,{src:x.coverImage,alt:x.title,widths:[96,128,160,200],sizes:"120px",className:"w-full h-full object-cover"}):e.jsx("div",{className:"w-full h-full flex items-center justify-center",children:e.jsx(ae,{className:"w-6 h-6 text-primary/60"})})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h2",{className:"text-xl md:text-2xl font-bold text-white leading-tight line-clamp-2",children:x.title}),x.author&&e.jsx("p",{className:"text-base text-muted-foreground mt-1",children:x.author})]})]})}),e.jsxs("div",{className:"flex items-center justify-center gap-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(F,{className:"w-4 h-4 text-primary"})}),e.jsx("span",{className:"text-sm text-primary hidden sm:inline",children:"Personalizar"})]}),e.jsx("div",{className:"w-8 h-px bg-primary/40"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary flex items-center justify-center text-white text-sm font-bold",children:"2"}),e.jsx("span",{className:"text-sm font-semibold text-primary hidden sm:inline",children:"Escolher conteúdos"})]})]}),ct&&e.jsx("div",{className:"glass-card rounded-xl border border-primary/10 bg-primary/[0.03] p-4","data-testid":"divulgacao-pref-summary",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(ue,{className:"w-4 h-4 text-primary mt-0.5 shrink-0"}),e.jsxs("div",{className:"text-sm text-muted-foreground",children:[e.jsx("span",{className:"text-white font-semibold",children:"Suas preferências: "}),Le.join(" · "),n.authorNotes.trim()&&e.jsx("span",{children:" · Instruções personalizadas"}),e.jsx("button",{onClick:()=>d("customize"),className:"text-primary hover:text-primary/80 ml-2 underline underline-offset-2 text-xs",children:"editar"})]})]})}),e.jsxs("div",{className:"text-center space-y-3",children:[e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-white",children:g?"Seus conteúdos inclusos":"Agora escolha a quantidade"}),e.jsx("p",{className:"text-base md:text-lg text-muted-foreground max-w-xl mx-auto leading-relaxed",children:g?"Seu pacote já inclui 3 imagens de cada tipo â prontas para gerar. Quer mais? Adicione quantas quiser.":"Selecione quantas peças de cada tipo você precisa. Vamos criar tudo de uma vez."})]}),e.jsx("div",{className:"space-y-3","data-testid":"divulgacao-content-types",children:A.map(t=>{const a=C[t.id]||0,s=a>0,r=g&&R[t.id]||0,l=Math.max(0,a-r),i=g?r:0;return e.jsx("div",{className:`glass-card rounded-xl border p-4 md:p-5 transition-all duration-200 ${s?"border-primary/30 bg-primary/5":"border-white/10"}`,"data-testid":`content-type-${t.id}`,children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl flex items-center justify-center shrink-0 ${s?"bg-primary/20 text-primary":"bg-white/5 text-muted-foreground"}`,children:t.icon}),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:"text-base font-bold text-white",children:t.label}),g?e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs font-semibold text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-2 py-0.5 rounded-full",children:[e.jsx(F,{className:"w-3 h-3"}),r," incluÃdas no pacote"]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-xs text-white/40 line-through mr-1",children:["R$ ",Ce(Ue(t.unitPrice))]}),e.jsxs("span",{className:"text-xs font-extrabold text-emerald-400",children:["R$ ",t.unitPrice.toFixed(2).replace(".",",")," cada"]})]})]}),e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5 leading-relaxed line-clamp-1",children:t.description}),g&&l>0&&e.jsxs("p",{className:"text-xs text-amber-400 mt-1",children:["+ ",l," extra",l>1?"s":""," · R$ ",Ce(l*t.unitPrice)]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[e.jsx("button",{onClick:()=>rt(t.id,-1),disabled:a<=i,className:"w-9 h-9 rounded-lg bg-white/5 border border-white/10 flex items-center justify-center text-white hover:bg-white/10 disabled:opacity-30 disabled:cursor-not-allowed transition-all","data-testid":`btn-minus-${t.id}`,children:e.jsx(ea,{className:"w-4 h-4"})}),e.jsx("span",{className:`w-8 text-center text-lg font-bold ${s?"text-primary":"text-muted-foreground"}`,"data-testid":`qty-${t.id}`,children:a}),e.jsx("button",{onClick:()=>rt(t.id,1),disabled:a>=t.maxQty,className:"w-9 h-9 rounded-lg bg-white/5 border border-white/10 flex items-center justify-center text-white hover:bg-white/10 disabled:opacity-30 disabled:cursor-not-allowed transition-all","data-testid":`btn-plus-${t.id}`,children:e.jsx(gt,{className:"w-4 h-4"})})]})]})},t.id)})})]}),D===0&&!g&&e.jsx("div",{className:"fixed bottom-0 left-0 right-0 md:left-64 z-50 border-t border-white/10 bg-background/95 backdrop-blur-xl safe-area-bottom fixed-above-tabs","data-testid":"divulgacao-hint-bar",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-6 py-4 flex items-center justify-center gap-3 text-muted-foreground",children:[e.jsx(ue,{className:"w-5 h-5 text-primary/60 shrink-0"}),e.jsxs("p",{className:"text-sm",children:["Selecione a quantidade de ca
29da tipo de conteúdo acima usando os botões ",e.jsx("strong",{className:"text-white",children:"+"})," para habilitar a geração."]})]})}),(D>0||g||je||ve||we)&&e.jsx("div",{className:"fixed bottom-0 left-0 right-0 md:left-64 z-50 border-t border-white/10 bg-background/95 backdrop-blur-xl safe-area-bottom fixed-above-tabs","data-testid":"divulgacao-bottom-bar",children:e.jsxs("div",{className:"max-w-4xl mx-auto px-4 md:px-6 py-4 flex items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"text-sm text-muted-foreground",children:[D," ",D===1?"conteúdo":"conteúdos"," selecionado",D>1?"s":""]}),g?(()=>{const t=A.reduce((a,s)=>{const r=R[s.id]||0,l=Math.max(0,(C[s.id]||0)-r);return a+l*s.unitPrice},0);return t>0?e.jsxs("span",{className:"text-sm text-amber-400 font-medium",children:["Inclusos no pacote + R$ ",Ce(t)," extras"]}):e.jsxs("span",{className:"text-sm text-emerald-400 font-medium flex items-center gap-1.5",children:[e.jsx(F,{className:"w-3.5 h-3.5"})," Tudo incluso no seu pacote â sem custo"]})})():we?e.jsx("button",{type:"button",onClick:Pt,className:"text-sm text-amber-400 font-medium text-left hover:text-amber-300 transition-colors","data-testid":"btn-reconcile-kit",children:"Não consegui confirmar seu kit â tocar para verificar antes de pagar"}):ve?e.jsx("button",{type:"button",onClick:()=>Ct(),className:"text-sm text-amber-400 font-medium text-left hover:text-amber-300 transition-colors","data-testid":"btn-retry-credit-check",children:"Não consegui verificar seus créditos â tocar para tentar de novo"}):je?B?e.jsxs("span",{className:"text-sm text-emerald-400 font-medium flex items-center gap-1.5",children:[e.jsx(F,{className:"w-3.5 h-3.5"})," Você tem ",ee.balance," kit de marketing em créditos â sem nova cobrança"]}):e.jsxs("span",{className:"text-sm text-amber-400 font-medium",children:["Você tem ",ee.balance," kit de marketing em créditos",ee.reason==="book_not_ready"?" â liberado quando o livro estiver pronto":""]}):e.jsxs(e.Fragment,{children:[e.jsxs("span",{className:"text-sm text-white/40 line-through mr-2",children:["R$ ",Ce(A.reduce((t,a)=>t+(C[a.id]||0)*Ue(a.unitPrice),0))]}),e.jsxs("span",{className:"text-2xl font-extrabold text-emerald-400",children:["R$ ",st.toFixed(2).replace(".",",")]})]})]}),(!we||g)&&(!ve||g)&&(!je||g||B)&&e.jsxs($,{onClick:()=>!g&&B?It():g&&!O?it():Ie(!0),disabled:Nt||at&&!g||oe||D===0&&!(!g&&B),className:ut("gap-2 text-white rounded-xl text-base h-13 px-8 shadow-lg",!g&&B?"bg-gradient-to-r from-amber-500 to-yellow-600 hover:from-amber-400 hover:to-yellow-500 shadow-amber-500/20":J?"bg-blue-600 hover:bg-blue-500 shadow-blue-500/20":O?"bg-gradient-to-r from-amber-600 to-orange-600 hover:from-amber-500 hover:to-orange-500 shadow-amber-500/20":"bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 shadow-primary/20"),"data-testid":"btn-generate-divulgacao",children:[e.jsx(Ot,{className:"w-5 h-5"}),e.jsx("span",{className:"hidden sm:inline",children:!g&&B?oe?"Usando crédito...":"Usar crédito do kit â sem custo":J?"Já Escolhi Minha Capa â Gerar Materiais de Marketing":O?`Pagar R$ ${ye.toFixed(2).replace(".",",")} extras e gerar`:g?"Gerar (sem custo)":"Gerar material de divulgação"}),e.jsx("span",{className:"sm:hidden",children:!g&&B?oe?"Usando...":"Usar crédito":J?"Gerar Marketing":O?"Pagar extras":g?"Gerar":"Gerar conteúdo"})]})]})}),ot&&e.jsx(Kt,{open:vt&&(g||!B&&!ve&&!we),onOpenChange:Ie,product:ot,onConfirm:$t,bookId:f||void 0,bookTitle:x?.title,orderType:O?"marketing_extra":"marketing_content",metadata:O?{extras:Object.fromEntries(A.map(t=>{const a=R[t.id]||0,s=Math.max(0,(C[t.id]||0)-a);return[t.id,s]}).filter(([t,a])=>a>0))}:void 0})]}),k==="generating"&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sticky top-0 z-40 border-b border-white/5 bg-background/80 backdrop-blur-xl",children:e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-3 flex items-center justify-center",children:e.jsxs(y,{className:"bg-primary/20 text-primary border-primary/20 text-xs",children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),"Divulgação"]})})}),e.jsx("div",{className:"max-w-4xl mx-auto px-4 py-8 pb-40 md:pb-24",children:e.jsxs("section",{"data-testid":"divulgacao-generating",className:"flex flex-col items-center justify-center py-12",children:[e.jsx("div",{className:"w-20 h-20 rounded-full bg-primary/10 flex items-center justify-center mb-8",children:e.jsx(_,{className:"w-10 h-10 text-primary animate-spin"})}),e.jsx("h2",{className:"text-2xl md:text-3xl font-bold text-white mb-3 text-center",children:"Criando conteúdos poderosos..."}),e.jsx("p",{className:"text-base text-muted-foreground text-center mb-8 max-w-md",children:"Estamos preparando materiais de altÃssimo valor para divulgar seu livro."}),e.jsx("div",{className:"space-y-4 w-full max-w-md",children:re.map((t,a)=>e.jsxs("div",{className:`flex items-center gap-3 transition-all duration-500 ${a<=pe?"opacity-100":"opacity-30"}`,"data-testid":`generation-step-${a}`,children:[a<pe?e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center shrink-0",children:e.jsx(F,{className:"w-4 h-4 text-primary"})}):a===pe?e.jsx("div",{className:"w-8 h-8 rounded-full bg-primary/20 flex items-center justify-center shrink-0",children:e.jsx(_,{className:"w-4 h-4 text-primary animate-spin"})}):e.jsx("div",{className:"w-8 h-8 rounded-full bg-white/5 flex items-center justify-center shrink-0",children:e.jsx("div",{className:"w-2 h-2 rounded-full bg-white/20"})}),e.jsx("span",{className:`text-base ${a<=pe?"text-white":"text-muted-foreground"}`,children:t})]},a))})]})})]}),k==="results"&&x&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sticky top-0 z-40 border-b border-white/5 bg-background/80 backdrop-blur-xl",children:e.jsxs("div",{className:"max-w-6xl mx-auto px-4 md:px-6 h-14 flex items-center justify-between",children:[e.jsxs("button",{onClick:()=>{de.current=!1,W.current=!0,d("choice"),q(null),H({}),M([]),Y(null)},className:"flex items-center gap-2 text-sm text-muted-foreground hover:text-white transition-colors","data-testid":"divulgacao-back-results",children:[e.jsx(se,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Criar mais conteúdo"}),e.jsx("span",{className:"sm:hidden",children:"Voltar"})]}),e.jsx("h1",{className:"text-sm font-medium text-white truncate max-w-[180px] md:max-w-md text-center",children:x.title}),e.jsxs(y,{className:"bg-primary/20 text-primary border-primary/20 text-xs shrink-0",children:[e.jsx(K,{className:"w-3 h-3 mr-1"}),"Divulgação"]})]})}),e.jsxs("div",{className:"max-w-6xl mx-auto px-4 md:px-6 py-8 space-y-6 pb-40 md:pb-24",children:[e.jsx("div",{className:"glass-card rounded-2xl border border-emerald-500/20 bg-gradient-to-br from-emerald-500/5 to-transparent p-5 md:p-6","data-testid":"divulgacao-success",children:e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-emerald-500/20 flex items-center justify-center shrink-0",children:e.jsx(G,{className:"w-6 h-6 text-emerald-400"})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h2",{className:"text-xl font-bold text-white",children:"Seus conteúdos estão prontos!"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:[u.length," peças criadas. ",ce!==null?"Gerando imagens automaticamente...":"Clique em qualquer peça para ver a publicação completa."]})]}),e.jsxs("div",{className:"flex gap-2 shrink-0",children:[e.jsxs($,{onClick:Tt,size:"sm",className:"gap-1.5 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white rounded-xl text-sm","data-testid":"btn-download-all",children:[e.jsx(ge,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Baixar tudo"})]}),e.jsxs($,{onClick:()=>{de.current=!1,W.current=!0,M([]),Y(null),w.invalidateQueries({queryKey:["/api/marketing/materials"]}),d("book_gallery")},variant:"outline",size:"sm",className:"gap-1.5 border-white/10 text-white hover:bg-white/5 rounded-xl text-sm","data-testid":"btn-view-gallery",children:[e.jsx(Se,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Ver galeria"})]}),e.jsxs($,{onClick:()=>{de.current=!1,W.current=!0,M([]),Y(null),H({}),d("customize")},variant:"outline",size:"sm",className:"gap-1.5 border-white/10 text-white hover:bg-white/5 rounded-xl text-sm","data-testid":"btn-create-more",children:[e.jsx(gt,{className:"w-4 h-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Criar mais"})]})]})]})}),e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-3 md:gap-4",children:u.map((t,a)=>{const s=ce===a,r=!!t.imageUrl,l=!!t.imagePrompt,i=!!t.imageFailed&&!r,c=l&&!r&&!s&&!i;return e.jsxs("div",{onClick:()=>{i&&!s?Me(a):Y(a)},className:`group relative rounded-2xl overflow-hidden border transition-all duration-300 cursor-pointer ${r?"border-white/10 hover:border-primary/40 hover:shadow-lg hover:shadow-
29primary/10 hover:scale-[1.02]":s?"border-primary/20 animate-pulse":"border-white/10 hover:border-white/20"}`,style:{aspectRatio:t.type==="story"?"9/16":"1/1"},"data-testid":`gallery-card-${a}`,children:[r?e.jsxs(e.Fragment,{children:[e.jsx("img",{src:t.imageUrl,alt:t.title||"",className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 via-black/20 to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300"}),e.jsx("div",{className:"absolute bottom-0 left-0 right-0 p-3 opacity-0 group-hover:opacity-100 transition-opacity duration-300",children:e.jsx("p",{className:"text-xs font-semibold text-white line-clamp-2 leading-tight",children:t.title})}),e.jsx("div",{className:"absolute top-2 right-2 opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("div",{className:"w-8 h-8 rounded-full bg-black/50 backdrop-blur-sm flex items-center justify-center",children:e.jsx(Se,{className:"w-4 h-4 text-white"})})})]}):s?e.jsxs("div",{className:"w-full h-full bg-gradient-to-br from-primary/5 to-primary/10 flex flex-col items-center justify-center gap-3 p-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-primary/20 flex items-center justify-center",children:e.jsx(_,{className:"w-6 h-6 text-primary animate-spin"})}),e.jsx("p",{className:"text-xs text-primary/80 text-center font-medium",children:"Criando imagem..."})]}):i?e.jsxs("div",{className:"w-full h-full bg-red-500/5 flex flex-col items-center justify-center gap-3 p-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-red-500/10 flex items-center justify-center",children:e.jsx(pt,{className:"w-6 h-6 text-red-400/60"})}),e.jsx("p",{className:"text-xs text-red-400/70 text-center font-medium",children:"Falhou â clique para tentar"})]}):c?e.jsxs("div",{className:"w-full h-full bg-white/[0.02] flex flex-col items-center justify-center gap-3 p-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-white/5 flex items-center justify-center",children:e.jsx(De,{className:"w-6 h-6 text-white/20"})}),e.jsx("p",{className:"text-xs text-white/30 text-center",children:"Na fila..."})]}):e.jsxs("div",{className:"w-full h-full bg-gradient-to-br from-white/[0.03] to-white/[0.01] flex flex-col items-center justify-center gap-3 p-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-white/5 flex items-center justify-center",children:e.jsx(ta,{className:"w-6 h-6 text-white/40"})}),e.jsx("p",{className:"text-xs text-white/50 text-center font-medium line-clamp-2",children:t.title})]}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsx(y,{className:`text-[10px] px-1.5 py-0.5 ${r?"bg-black/50 backdrop-blur-sm text-white border-0":"bg-white/5 text-white/60 border-white/10"}`,children:Ve[t.type]||t.type})}),r&&e.jsx("div",{className:"absolute top-2 right-2 group-hover:opacity-0 transition-opacity",children:e.jsx("div",{className:"w-5 h-5 rounded-full bg-emerald-500/80 flex items-center justify-center",children:e.jsx(F,{className:"w-3 h-3 text-white"})})})]},a)})})]}),p!==null&&u[p]&&e.jsxs("div",{className:"fixed inset-0 z-[100] flex items-center justify-center","data-testid":"post-preview-modal",children:[e.jsx("div",{className:"absolute inset-0 bg-black/80 backdrop-blur-sm",onClick:()=>Y(null)}),e.jsxs("div",{className:"relative w-full max-w-lg mx-4 max-h-[90vh] overflow-y-auto rounded-2xl border border-white/10 bg-[#0c0c0e] shadow-2xl shadow-black/50",children:[e.jsxs("div",{className:"sticky top-0 z-10 flex items-center justify-between px-4 py-3 border-b border-white/5 bg-[#0c0c0e]/95 backdrop-blur-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(y,{className:"bg-primary/10 text-primary border-primary/20 text-xs",children:Ve[u[p].type]||u[p].type}),u[p].platform&&e.jsx("span",{className:"text-xs text-muted-foreground",children:u[p].platform})]}),e.jsx("button",{onClick:()=>Y(null),className:"w-8 h-8 rounded-full bg-white/5 hover:bg-white/10 flex items-center justify-center transition-colors","data-testid":"btn-close-preview",children:e.jsx(xt,{className:"w-4 h-4 text-white/70"})})]}),u[p].imageUrl?e.jsxs("div",{className:"relative group",children:[e.jsx("img",{src:u[p].imageUrl,alt:u[p].title||"",className:"w-full object-contain max-h-[50vh]","data-testid":"preview-image"}),e.jsxs("div",{className:"absolute bottom-3 right-3 flex gap-2 opacity-0 group-hover:opacity-100 transition-opacity",children:[e.jsxs("button",{onClick:t=>{t.stopPropagation(),lt(u[p].imageUrl,u[p].title)},className:"flex items-center gap-1.5 text-xs bg-black/70 backdrop-blur-sm text-white px-3 py-2 rounded-xl hover:bg-black/90 transition-colors","data-testid":"btn-preview-download-img",children:[e.jsx(ge,{className:"w-3.5 h-3.5"})," Baixar"]}),e.jsxs("button",{onClick:t=>{t.stopPropagation(),Me(p)},disabled:ce!==null,className:"flex items-center gap-1.5 text-xs bg-black/70 backdrop-blur-sm text-white px-3 py-2 rounded-xl hover:bg-black/90 transition-colors disabled:opacity-50","data-testid":"btn-preview-regen-img",children:[ce===p?e.jsx(_,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(pt,{className:"w-3.5 h-3.5"}),"Nova imagem"]})]})]}):ce===p?e.jsxs("div",{className:"h-64 bg-gradient-to-br from-primary/5 to-primary/10 flex flex-col items-center justify-center gap-3",children:[e.jsx(_,{className:"w-8 h-8 text-primary animate-spin"}),e.jsx("p",{className:"text-sm text-primary/80",children:"Criando imagem..."})]}):null,e.jsxs("div",{className:"p-5 space-y-4",children:[u[p].title&&e.jsx("h3",{className:"text-lg font-bold text-white leading-tight",children:u[p].title}),e.jsx("div",{className:"text-[15px] text-white/80 leading-relaxed whitespace-pre-wrap",children:u[p].content}),u[p].hashtags?.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5 pt-1",children:u[p].hashtags.map((t,a)=>e.jsx("span",{className:"text-xs text-primary bg-primary/10 px-2.5 py-1 rounded-lg font-medium",children:t},a))})]}),e.jsxs("div",{className:"sticky bottom-0 border-t border-white/5 bg-[#0c0c0e]/95 backdrop-blur-sm px-5 py-3 flex gap-2",children:[e.jsx($,{onClick:()=>Et(u[p],p),className:"flex-1 gap-2 bg-gradient-to-r from-emerald-600 to-teal-600 hover:from-emerald-500 hover:to-teal-500 text-white rounded-xl h-11","data-testid":"btn-preview-copy",children:jt===p?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4"})," Copiado!"]}):e.jsxs(e.Fragment,{children:[e.jsx(Be,{className:"w-4 h-4"})," Copiar texto e hashtags"]})}),u[p].imageUrl&&e.jsxs($,{onClick:()=>lt(u[p].imageUrl,u[p].title),variant:"outline",className:"gap-2 border-white/10 text-white hover:bg-white/5 rounded-xl h-11","data-testid":"btn-preview-download",children:[e.jsx(ge,{className:"w-4 h-4"})," Imagem"]})]})]})]})]})]}),f&&e.jsx("div",{className:"hidden lg:block fixed right-4 top-20 w-[300px] max-h-[calc(100vh-6rem)] overflow-y-auto z-30",children:e.jsx(Jt,{bookId:f,currentStep:"marketing"})}),f&&k!=="customize"&&k!=="planning"&&e.jsx(Wt,{bookId:f,currentStep:"marketing"})]})}
29export{Ra 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.