PageSourceSearch

https://snew.ai/assets/SnewStudioPageBackup-CTLPvHXr.js

js snew.ai collected 2026-10-05 15:08:03 UTC 360,987 bytes, 411 lines download raw bytes

1import{r as a,j as t,R as Uc,b as Tc,u as Fp,c as Sp}from"./index-L9AYrVUw.js";import{g as St,A as Gc,b as kp,a as Cp,u as Ho,c as Ap,L as zp,H as Rp,C as Tp,I as Ep,d as Ip,m as Ec,e as Ic,f as $c,s as $p,F as Uo,h as Dp,p as Mp,i as Pp,j as Np,k as Vc,n as qc,P as Wp,S as Bp,l as Lp,o as Op,q as _p}from"./FontCategorySelector-BFC0ZGOm.js";import{i as Dc}from"./ArrowCounterClockwise.es-B3mF2JQM.js";import{h as Hp,al as Ur,u as E,bg as oa,n as je,b as Mr,a as Vo,aE as Tt,b3 as Mc,a3 as oi,a6 as Up,a5 as Yc,a7 as Gr,s as Gp}from"./PlanAccessModal-P_W2GThH.js";import{m as Pr}from"./ArrowsClockwise.es-CX8V1pij.js";import{m as Pc,n as Vp,k as qp}from"./App-DyVHSnY3.js";import{s as Yp}from"./CaretDoubleLeft.es-C52M4NEJ.js";import{s as Xp}from"./CaretLeft.es-CVEVfjVi.js";import{s as sa,f as Nr,M as Jp,A as Qp}from"./FloatingTopMenu-CIhwk2RR.js";import{n as Kp}from"./Clock.es-DgpzZNmC.js";import{s as Zp}from"./Copy.es-BkRzHo-W.js";import{n as eg}from"./Cube.es-DwVS_HfU.js";import{n as Nc,l as jn}from"./Trash.es-D2Zs5Rpt.js";import{n as na}from"./Eye.es-UdlNEHEy.js";import{n as ia}from"./EyeSlash.es-c1uHZmoR.js";import{m as Wc}from"./FloppyDisk.es-DCGe340Q.js";import{n as tg}from"./Heart.es-Bf3nCVn7.js";import{I as ni}from"./Image.es-BLTC_PgL.js";import{n as ii}from"./Package.es-CyLjTX4J.js";import{n as og}from"./Palette.es-Dd5ZEM4v.js";import{a as Bc}from"./PencilSimple.es-DDA0fpvv.js";import{n as ng}from"./Play.es-DBh2Tn7f.js";import{n as Wr}from"./Plus.es-BeVefyFz.js";import{c as ig}from"./Resize.es-BwoWh9ki.js";import{l as ag}from"./UploadSimple.es-BDJIa312.js";import{n as Lc}from"./Users.es-CZggLr1m.js";import{s as Br}from"./VideoCamera.es-CCLoNiT_.js";import{loadScheduledPosts as rg,saveScheduledPosts as sg}from"./PostCalendarPage-B9VW1rlv.js";import{S as lg}from"./StudioChatPanel-CTMIdRq6.js";import{B as aa}from"./button-Bt8F5TkE.js";import{s as V}from"./productFunnel-DiJFcMU2.js";import{s as cg}from"./seasonalCalendar-CyVTeHw6.js";import{loadStoreContext as la,loadBrandReferencesBase64 as dg}from"./KnowledgeBasePage-DJT9Fkps.js";import{g as ug}from"./historyKey-GcKgTVWl.js";import"./generation-shimmer-CRk6nK9x.js";import"./pill-BK5sCDTV.js";import"./pill-dropdown-menu-CmrSXir-.js";import"./aspectRatios-DDqw6bsx.js";import"./use-exclusive-open-LN4OUcjO.js";import"./boardChromeCopy-DnmOEM-I.js";import"./welcomeBoard-4xJYHWeA.js";import"./locale-Cctu0V3Y.js";import"./index-p7aFGi8o.js";import"./dissolve-CQo8GAUH.js";import"./SnewLogo-Cg53XTnQ.js";import"./productHeight-D88Bzh8q.js";import"./ArrowUp.es-sg_sCqx1.js";import"./FrameCorners.es-DEsKEYQB.js";import"./ThumbsDown.es-CGNKh3eu.js";import"./ThumbsUp.es-D_c5yKbs.js";import"./ChatSubmitButton-Bm0hHp2J.js";import"./SearchInput-h5gAN-Be.js";import"./round-icon-button-DJH-lznp.js";import"./ThumbCard-ZN7h4mu8.js";import"./ProductPickerModal-DZV-fDl_.js";import"./firstAsset-DWUwvZpm.js";import"./modal-close-button-BhLoO4jQ.js";import"./tabs-CmDZA0dx.js";import"./index-BKpKuXmL.js";import"./index-Eo00qZvG.js";import"./ImageSquare.es-Ckk4CjAE.js";import"./overImage-BfLII5AZ.js";import"./ChatCircle.es-ys8V5LKI.js";import"./Globe.es-5iBT42E4.js";import"./MagicWand.es-CAihBnXI.js";import"./Target.es-Ds7XP-fd.js";import"./WarningCircle.es-CHfqKWRY.js";import"./hydrateStoreContext-CnRDd9GD.js";const pg=["text in image","letters","words","typography","font overlay","text overlay","graphic text","magazine text","editorial text","vertical text","diagonal text","headline text","title text","watermark","logo","signature","branding overlay","caption","subtitle","label text","price tag text","chrome","metallic sheen","polished metal","steel surface","marble","polished stone","glossy surface","shiny surface","specular highlight","lens flare","glowing edges","neon glow","glass reflection","mirror reflection","iridescent","holographic","gold foil","glitter","sparkle","oversaturated","neon colors","vibrant pop colors","hyper vivid","HDR glow","bloom effect","heavy vignette","stock photo smile","stock photography pose","generic stock look","corporate stock image","overly perfect lighting","illustration","watercolor","painting","cartoon","digital art","3d render","CGI","vector art"].join(", "),gg=["Editorial photography with personality and character.","Natural organic materials — raw wood, unpolished stone, dried botanicals, linen, terracotta.","Muted earthy color palette: warm sand, sage green, clay, linen white, warm stone.","Low saturation, film-like color grade.","Soft directional natural light — gentle shadows, not harsh or rigid.","Slight film grain texture. Authentic imperfection.","No stock photo aesthetic. No corporate polish. No perfect symmetry.","Photorealistic, magazine editorial quality."].join(" "),Go=[{id:"gemini-3.1-flash-image-preview",name:"Nano Banana 2",badge:"Recomendado",time:"~15s",description:"Melhor para referências visuais — padrão"},{id:"gemini-3-pro-image-preview",name:"Nano Banana Pro",badge:"Premium",time:"~30s",description:"Máxima qualidade e fidelidade"},{id:"gemini-2.5-flash-image",name:"Nano Banana",badge:null,time:"~10s",description:"Rápido, boa qualidade"}
1],mg="snew:visual-dna",mt=[{id:"9:16",label:"9:16",sublabel:"Social story",width:1080,height:1920,supportsCarousel:!0},{id:"1:1",label:"1:1",sublabel:"Square",width:1080,height:1080,supportsCarousel:!0},{id:"4:5",label:"4:5",sublabel:"Social post",width:1080,height:1350,supportsCarousel:!0},{id:"16:9",label:"16:9",sublabel:"Widescreen",width:1920,height:1080,supportsCarousel:!1},{id:"2:3",label:"2:3",sublabel:"Portrait",width:1080,height:1620,supportsCarousel:!0},{id:"3:4",label:"3:4",sublabel:"Traditional",width:1080,height:1440,supportsCarousel:!0},{id:"1:2",label:"1:2",sublabel:"Vertical",width:1080,height:2160,supportsCarousel:!0},{id:"5:8",label:"5:8",sublabel:"Tall portrait",width:1080,height:1728,supportsCarousel:!0},{id:"2:1",label:"2:1",sublabel:"Horizontal",width:2160,height:1080,supportsCarousel:!1},{id:"3:2",label:"3:2",sublabel:"Standard",width:1620,height:1080,supportsCarousel:!0},{id:"4:3",label:"4:3",sublabel:"Classic",width:1440,height:1080,supportsCarousel:!0}],hg=({ratio:h})=>{const _={"9:16":{w:9,h:16},"1:1":{w:14,h:14},"4:5":{w:11,h:14},"16:9":{w:16,h:9},"2:3":{w:10,h:15},"3:4":{w:11,h:15},"1:2":{w:8,h:16},"2:1":{w:16,h:8},"3:2":{w:15,h:10},"4:3":{w:15,h:11}}[h]??{w:14,h:14},se=16/Math.max(_.w,_.h);return t.jsx("div",{style:{width:18,height:18,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx("div",{style:{width:Math.round(_.w*se),height:Math.round(_.h*se),border:"1.5px solid currentColor",borderRadius:2,opacity:.7}})})};Ur.map(h=>({id:h.product_id,name:h.name,sku:h.sku,image:h.image}));const fg=Gc,xg="https://fonts.googleapis.com/css2?family=Monsieur+La+Doulaise&family=Kapakana&family=Pinyon+Script&family=Lexend:wght@300;400;500;600;700&family=Outfit:wght@300;400;500;600;700&family=Onest:wght@300;400;500;600;700&family=Dongle:wght@300;400;700&family=Gochi+Hand&family=Meow+Script&family=Pangolin&family=Scope+One&family=Playfair+Display+SC:wght@400;700&family=Playfair+Display:wght@400;500;700&family=DM+Serif+Display&family=Fraunces:wght@300;400;700&family=Cormorant+Garamond:wght@300;400;600&family=Lora:wght@400;500;700&family=Inter:wght@300;400;500;600;700&family=Poppins:wght@300;400;500;600;700&family=Montserrat:wght@300;400;500;600;700&family=Space+Grotesk:wght@300;400;500;700&family=Raleway:wght@300;400;500;700&family=Bebas+Neue&family=Oswald:wght@300;400;500;700&family=Anton&family=Dancing+Script:wght@400;700&family=Great+Vibes&family=Pacifico&display=swap",bg={sm:18,md:22,lg:26,xl:32},ai=[{id:"brand-dna",name:"Brand DNA",description:"Consistência de marca em todo criativo",category:"photo",preview:"linear-gradient(135deg, #1A1A1A, #333333)",isBrandDna:!0,font:"playfair",textCase:"normal",fontWeight:"500",textColor:"#FFFFFF",ctaColor:"#D4A064",ctaTextColor:"#FFFFFF",ctaRadius:"8px",overlayType:"gradient",overlayColor:"#000000",overlayOpacity:.45,overlayPosition:"bottom",textHAlign:"left",textVAlign:"bottom",letterSpacing:"0em",imageStyle:"lifestyle product photography, brand aesthetic",headingSize:"lg"},{id:"minimal",name:"Minimalista",description:"Alto ticket médio, produto como herói",category:"photo",preview:"linear-gradient(135deg, #F5F0E8, #E8E0D0)",font:"cormorant",textCase:"normal",fontWeight:"400",textColor:"#FFFFFF",ctaColor:"transparent",ctaTextColor:"#FFFFFF",ctaRadius:"0px",overlayType:"gradient",overlayColor:"#1A1008",overlayOpacity:.3,overlayPosition:"bottom",textHAlign:"left",textVAlign:"bottom",letterSpacing:"0.01em",imageStyle:"minimalist product photography, negative space, soft neutral background",headingSize:"xl"},{id:"bold",name:"TextB",description:"Para de rolar. Atenção imediata no feed",category:"illustration",preview:"linear-gradient(135deg, #1A1A1A, #333)",font:"bebas",textCase:"uppercase",fontWeight:"600",textColor:"#FFFFFF",ctaColor:"#FFFFFF",ctaTextColor:"#1A1A1A",ctaRadius:"4px",overlayType:"solid",overlayColor:"#000000",overlayOpacity:.5,overlayPosition:"full",textHAlign:"center",textVAlign:"center",letterSpacing:"0.04em",imageStyle:"dramatic product photography, high contrast, dark moody background",headingSize:"xl"},{id:"casual",name:"Casual",description:"UGC feel. Prova social que converte",category:"illustration",preview:"linear-gradient(135deg, #FFF3E0, #FFE0B2)",font:"fraunces",textCase:"normal",fontWeight:"500",textColor:"#FFFFFF",ctaColor:"#FF6B35",ctaTextColor:"#FFFFFF",ctaRadius:"999px",overlayType:"gradient",overlayColor:"#2D1A00",overlayOpacity:.45,overlayPosition:"bottom",textHAlign:"left",textVAlign:"bottom",letterSpacing:"0em",imageStyle:"casual lifestyle photography, natural light, warm tones",headingSize:"lg"},{id:"modern",name:"Moderno",description:"Lançamento, tech e produto novo",category:"3d",preview:"linear-gradient(135deg, #0F0F23, #1A1A3E)",font:"space-grotesk",textCase:"normal",fontWeight:"500",textColor:"#FFFFFF",ctaColor:"#6366F1",ctaTextColor:"#FFFFFF",ctaRadius:"8px",overlayType:"gradient",overlayColor:"#050518",overlayOpacity:.6,overlayPosition:"full",textHAlign:"left",textVAlign:"center",letterSpacing:"-0.01em",imageStyle:"modern clean product photography, geometric composition, cool tones",headingSize:"lg"},{id:"editorial",name:"Editorial",description:"Aspiracional. Eleva o valor percebido",category:"photo",preview:"linear-gradient(135deg, #F0EDE8, #D4C9B8)",font:"dm-serif",textCase:"normal",fontWeight:"400",textColor:"#FFFFFF",ctaColor:"rgba(255,255,255,0.15)",ctaTextColor:"#FFFFFF",ctaRadius:"0px",overlayType:"gradient",overlayColor:"#0A0806",overlayOpacity:.55,overlayPosition:"bottom",textHAlign:"center",textVAlign:"bottom",letterSpacing:"0.08em",imageStyle:"editorial fashion photography, high-end magazine style",headingSize:"xl"},{id:"urgency",name:"Urgência",description:"Escassez, prazo e oferta relâmpago",category:"design",preview:"linear-gradient(135deg, #DC2626, #991B1B)",font:"inter",textCase:"uppercase",fontWeight:"600",textColor:"#FFFFFF",ctaColor:"#FACC15",ctaTextColor:"#1A1A1A",ctaRadius:"6px",overlayType:"solid",overlayColor:"#1A0000",overlayOpacity:.65,overlayPosition:"full",textHAlign:"center",textVAlign:"center",letterSpacing:"0.03em",imageStyle:"product photography with urgency, vivid colors, promotional style",headingSize:"lg",enablePrice:!0},{id:"warm",name:"Quente",description:"Presente, datas especiais, apelo emocional",category:"photo",preview:"linear-gradient(135deg, #7C2D12, #C2410C)",font:"playfair",textCase:"normal",fontWeight:"500",textColor:"#FFF8F0",ctaColor:"#D4A064",ctaTextColor:"#FFFFFF",ctaRadius:"999px",overlayType:"gradient",overlayColor:"#3D1500",overlayOpacity:.55,overlayPosition:"bottom",textHAlign:"center",textVAlign:"bottom",letterSpacing:"0.01em",imageStyle:"warm cozy lifestyle photography, golden hour light, warm amber tones",headingSize:"lg"},{id:"dark-luxury",name:"Dark Luxury",description:"Premium. Justifica preço alto sem desconto",category:"design",preview:"linear-gradient(135deg, #0A0A0A, #1C1408)",font:"cormorant",textCase:"normal",fontWeight:"300",textColor:"#D4A064",ctaColor:"#D4A064",ctaTextColor:"#0A0A0A",ctaRadius:"0px",overlayType:"solid",overlayColor:"#050505",overlayOpacity:.7,overlayPosition:"full",textHAlign:"left",textVAlign:"center",letterSpacing:"0.12em",imageStyle:"dark luxury product photography, black background, gold accents",headingSize:"xl"},{id:"performance",name:"Performance",description:"Atributos + foto. Informa e converte",category:"photo",preview:"linear-gradient(135deg, #0A0A0A, #1A1A2E)",font:"inter",textCase:"normal",fontWeight:"600",textColor:"#FFFFFF",ctaColor:"#FFFFFF",ctaTextColor:"#1A1A1A",ctaRadius:"6px",overlayType:"solid",overlayColor:"#0A0A0A",overlayOpacity:.55,overlayPosition:"full",textHAlign:"right",textVAlign:"bottom",letterSpacing:"0em",imageStyle:"person using product confidently, clean lifestyle photography, natural light, side space for text overlay",headingSize:"lg",enableAttributes:!0}],Lr=h=>St(h),Or=({label:h,value:O,thumbUrl:_,active:se,onClick:F})=>t.jsxs("button",{className:`ig-item-row ${se?"active":""}`,onClick:F,children:[_&&t.jsx("div",{style:{width:36,height:36,borderRadius:7,overflow:"hidden",flexShrink:0,border:"1.5px solid rgba(255,255,255,0.15)",boxShadow:"0 1px 4px rgba(0,0,0,0.3)"},children:t.jsx("img",{src:_,alt:"",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})}),t.jsxs("div",{className:"ig-item-text",children:[t.jsx("span",{className:"ig-item-label",children:h}),t.jsx("span",{className:"ig-item-value",children:O})]}),t.jsx(sa,{size:14,className:"ig-item-chevron"})]}),yg=h=>{if(!h||typeof h!="string")return"0, 0, 0";const O=parseInt(h.slice(1,3),16)||0,_=parseInt(h.slice(3,5),16)||0,se=parseInt(h.slice(5,7),16)||0;return`${O}, ${_}, ${se}`},Oc=(h,O,_,se)=>{const F=yg(O);return h==="solid"?{position:"absolute",inset:0,background:`rgba(${F}, ${_})`}:{position:"absolute",inset:0,background:{bottom:`linear-gradient(to top, rgba(${F}, ${_}) 0%, rgba(${F}, ${_*.6}) 40%, transparent 75%)`,top:`linear-gradient(to bottom, rgba(${F}, ${_}) 0%, rgba(${F}, ${_*.6}) 40%, transparent 75%)`,full:`linear-gradient(to top, rgba(${F}, ${_}) 0%, rgba(${F}, ${_*.3}) 50%, rgba(${F}, ${_}) 100%)`}[se]}},vg=[{id:"direto",label:"Direto",emoji:"→",icon:t.jsx(Gp,{size:14})},{id:"emocional",label:"Emocional",emoji:"",icon:t.jsx(tg,{size:14})},{id:"urgencia",label:"Urgência",emoji:"",icon:t.jsx(Gr,{size:14,color:"#F59E0B"})},{id:"aspiracional",label:"Aspiracional",emoji:"",icon:t.jsx(Vo,{size:14})},{id:"humoristico",label:"Bem-humorado",emoji:"◡",icon:t.jsx(Lp,{size:14})},{id:"escassez",label:"Escassez",emoji:"⏱",icon:t.jsx(Vc,{size:14})},{id:"prova-social",label:"Prova social",emoji:"",icon:t.jsx(Yc,{size:14})},{id:"promocao",label:"Promoção",emoji:"%",icon:t.jsx(qc,{size:14})},{id:"exclusividade",label:"Exclusividade",emoji:"◈",icon:t.jsx(Op,{size:14})},{id:"curiosidade",label:"Curiosidade",emoji:"?",icon:t.jsx(_p,{size:14})}],_r=[{id:"script-warm",triggers:["warm","lifestyle","baby","family","soft","natural","golden","cozy","emotional","pastel"],font:"dancing-script",color:"#2C1810",size:38,shadow:"0 2px 12px rgba(44,24,16,0.25)",label:"Script Quente"},{id:"script-elegant",triggers:["elegant","luxury","premium","aesthetic","fas
1hion","editorial","marble","linen","beige","cream"],font:"great-vibes",color:"#1A1209",size:44,shadow:"0 1px 8px rgba(26,18,9,0.2)",label:"Script Elegante"},{id:"serif-editorial",triggers:["editorial","magazine","product hero","advertising","campaign","bold composition","dark background"],font:"playfair",color:"#FFFFFF",size:36,shadow:"0 2px 16px rgba(0,0,0,0.6), 0 0 32px rgba(0,0,0,0.3)",label:"Serif Editorial"},{id:"serif-clean",triggers:["white background","clean","ecommerce","studio","minimal","product only","retail"],font:"dm-serif",color:"#1A1A1A",size:32,shadow:"none",label:"Serif Clean"},{id:"bold-display",triggers:["bold","contrast","urgency","promotion","vivid","graphic","dark","dramatic lighting"],font:"bebas",color:"#FFFFFF",size:52,shadow:"0 3px 0px rgba(0,0,0,0.9), 0 6px 20px rgba(0,0,0,0.5)",label:"TextB Display"},{id:"handwritten-casual",triggers:["candid","authentic","ugc","casual","outdoor","film grain","person","real people","street"],font:"gochi-hand",color:"#FFFFFF",size:34,shadow:"0 2px 8px rgba(0,0,0,0.5)",label:"Handwritten"}],Hr=({fieldKey:h,value:O,onChange:_,style:se,isCta:F=!1,selectedElement:Re,editingElement:k,setSelectedElement:Q,setEditingElement:W})=>{const q=a.useRef(null),B=Re===h,X=k===h,[Me,C]=a.useState(O),f=ce=>{ce.stopPropagation(),X||(Q(h),W(null))},z=ce=>{ce.stopPropagation(),C(O),Q(h),W(h),setTimeout(()=>{const b=q.current;if(!b)return;b.focus();const x=document.createRange(),I=window.getSelection();x.selectNodeContents(b),x.collapse(!1),I==null||I.removeAllRanges(),I==null||I.addRange(x)},0)},K=()=>{var b,x;const ce=((x=(b=q.current)==null?void 0:b.innerText)==null?void 0:x.trim())??O;_(ce),W(null)},Ee=ce=>{X&&(ce.key==="Enter"&&!ce.shiftKey&&(ce.preventDefault(),K()),ce.key==="Escape"&&(q.current&&(q.current.innerText=Me),W(null)))};return t.jsx("div",{ref:q,"data-field":h,className:`selectable-text ${B&&!X?"element-selected":""} ${X?"element-editing":""} ${F?"is-cta":""}`,style:se,contentEditable:X,suppressContentEditableWarning:!0,onClick:f,onDoubleClick:z,onBlur:X?K:void 0,onKeyDown:Ee,children:X?void 0:O})},wg=({box:h,canvasW:O,canvasH:_,isSelected:se,isEditing:F,onSelect:Re,onEdit:k,onBlur:Q,onDelete:W,onUpdate:q,onOpenGen:B,onDuplicate:X,onApplyCreative:Me,isApplyingCreative:C})=>{const f=a.useRef(null),z={x:Math.round((h.xRel??.06)*O),y:Math.round((h.yRel??.5)*_),fontSize:Math.max(8,Math.round((h.fontSizeRel??.06)*O)),boxWidth:Math.round((h.boxWidthRel??.88)*O)},K=x=>{if(F||x.target.closest("[data-handle]"))return;x.preventDefault(),x.stopPropagation(),Re();const I=document.querySelector("[data-canvas-frame]");if(!I)return;const R=I.getBoundingClientRect(),T=x.clientX-R.left-z.x,oe=x.clientY-R.top-z.y,Z=le=>{var Fn,li;const _e=I.getBoundingClientRect(),Pe=((Fn=f.current)==null?void 0:Fn.offsetWidth)??z.boxWidth,Lt=((li=f.current)==null?void 0:li.offsetHeight)??40,ht=Math.max(0,Math.min(_e.width-Pe,le.clientX-_e.left-T)),ca=Math.max(0,Math.min(_e.height-Lt,le.clientY-_e.top-oe));q({xRel:ht/_e.width,yRel:ca/_e.height})},ge=()=>{document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",ge)};document.addEventListener("mousemove",Z),document.addEventListener("mouseup",ge)},Ee=(x,I)=>{var ge;x.preventDefault(),x.stopPropagation();const R=x.clientX,T=((ge=f.current)==null?void 0:ge.offsetWidth)??z.boxWidth,oe=le=>{var ht;const _e=I==="tr"||I==="br"?le.clientX-R:R-le.clientX,Pe=((ht=document.querySelector("[data-canvas-frame]"))==null?void 0:ht.getBoundingClientRect().width)??O,Lt=Math.max(8,Math.min(400,Math.round(z.fontSize+_e/T*z.fontSize)));q({fontSizeRel:Lt/Pe})},Z=()=>{document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",Z)};document.addEventListener("mousemove",oe),document.addEventListener("mouseup",Z)},ce=(x,I)=>{x.preventDefault(),x.stopPropagation();const R=x.clientX,T=h.boxWidthRel??.88,oe=h.xRel??.06,Z=le=>{var Lt;const _e=((Lt=document.querySelector("[data-canvas-frame]"))==null?void 0:Lt.getBoundingClientRect().width)??O,Pe=le.clientX-R;if(I==="right")q({boxWidthRel:Math.max(.05,T+Pe/_e)});else{const ht=Math.max(.05,T-Pe/_e);q({boxWidthRel:ht,xRel:oe+(T-ht)})}},ge=()=>{document.removeEventListener("mousemove",Z),document.removeEventListener("mouseup",ge)};document.addEventListener("mousemove",Z),document.addEventListener("mouseup",ge)},b=x=>
1({position:"absolute",background:"#18A0FB",border:"2px solid #FFF",zIndex:25,...x});return t.jsxs("div",{ref:f,onMouseDown:K,onClick:x=>{x.stopPropagation()},onDoubleClick:x=>{x.stopPropagation(),k()},style:{position:"absolute",left:z.x,top:z.y,width:z.boxWidth,overflow:"visible",fontFamily:h.fontFamily,fontSize:z.fontSize,fontWeight:400,color:h.color,lineHeight:1.25,zIndex:10,userSelect:"none",cursor:F?"text":"move",textShadow:h.textShadow??"none",boxSizing:"border-box"},children:[t.jsx("div",{style:{overflow:"hidden",width:"100%",wordBreak:"break-word",whiteSpace:"pre-wrap",textAlign:h.textAlign},children:h.text==="..."?t.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[t.jsx("span",{className:"textbox-loading-label",children:"inserindo texto"}),t.jsx("span",{className:"textbox-cursor"})]}):t.jsx("div",{contentEditable:F,suppressContentEditableWarning:!0,onBlur:x=>{F&&Q(x.currentTarget.innerText||h.text)},onKeyDown:x=>{F&&(x.stopPropagation(),x.key==="Escape"&&x.currentTarget.blur(),x.key==="Enter"&&!x.shift
1Key&&(x.preventDefault(),x.currentTarget.blur()))},ref:x=>{F&&x&&setTimeout(()=>{x.focus();const I=document.createRange(),R=window.getSelection();I.selectNodeContents(x),I.collapse(!1),R==null||R.removeAllRanges(),R==null||R.addRange(I)},10)},style:{outline:"none",display:"block",minHeight:"1em",fontFamily:h.fontFamily,fontSize:"inherit",fontWeight:"inherit",color:"inherit"},children:h.text})}),se&&!F&&h.text!=="..."&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{position:"absolute",inset:-1,border:"1.5px solid #18A0FB",borderRadius:2,pointerEvents:"none",zIndex:15}}),t.jsx("div",{"data-handle":"true",onMouseDown:x=>{x.stopPropagation(),x.preventDefault()},style:{position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:2,background:"#1C1C1C",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,padding:"4px 6px",whiteSpace:"nowrap",zIndex:30,boxShadow:"0 4px 16px rgba(0,0,0,0.4)"},children:[{label:"Gerar",action:B,style:{color:"rgba(255,255,255,0.9)",paddingRight:8}},{label:"⧉",action:X,style:{color:"rgba(255,255,255,0.65)"}},{label:"",action:W,style:{color:"rgba(255,255,255,0.65)"}}].map((x,I)=>t.jsx("button",{onClick:R=>{R.stopPropagation(),x.action()},style:{height:26,minWidth:26,padding:"0 6px",border:"none",borderRadius:4,background:"transparent",fontSize:12,fontWeight:500,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"'Inter',sans-serif",...x.style},children:x.label},I))}),[["tl",{top:-5,left:-5,cursor:"nw-resize"}],["tr",{top:-5,right:-5,cursor:"ne-resize"}],["bl",{bottom:-5,left:-5,cursor:"sw-resize"}],["br",{bottom:-5,right:-5,cursor:"se-resize"}]].map(([x,I])=>t.jsx("div",{"data-handle":"true",onMouseDown:R=>Ee(R,x),style:b({width:10,height:10,borderRadius:2,...I})},x)),[["left",{top:"50%",left:-5,transform:"translateY(-50%)",cursor:"ew-resize"}],["right",{top:"50%",right:-5,transform:"translateY(-50%)",cursor:"ew-resize"}]].map(([x,I])=>t.jsx("div",{"data-handle":"true",onMouseDown:R=>ce(R,x),style:b({width:10,height:22,borderRadius:3,...I})},x))]})]})},jg=({card:h,product:O,canvasW:_,canvasH:se,isSelected:F,onSelect:Re,onDelete:k,onUpdate:Q,onChangeProd:W})=>{const q=a.useRef(null),B={x:Math.round(h.xRel*_),y:Math.round(h.yRel*se),w:Math.round(h.widthRel*_),h:Math.round(h.heightRel*se)},X=z=>{if(z.target.closest("[data-handle]"))return;z.preventDefault(),z.stopPropagation(),Re();const K=document.querySelector("[data-canvas-frame]");if(!K)return;const Ee=K.getBoundingClientRect(),ce=z.clientX-Ee.left-B.x,b=z.clientY-Ee.top-B.y,x=R=>{var le;const T=K.getBoundingClientRect(),oe=((le=q.current)==null?void 0:le.offsetHeight)??B.h??80,Z=Math.max(0,Math.min(T.width-B.w,R.clientX-T.left-ce)),ge=Math.max(0,Math.min(T.height-oe,R.clientY-T.top-b));Q({xRel:Z/T.width,yRel:ge/T.height})},I=()=>{document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",I)},Me=z=>{z.preventDefault(),z.stopPropagation();const K=z.clientX,Ee=z.clientY,ce=h.widthRel,b=h.heightRel,x=R=>{const T=document.querySelector("[data-canvas-frame]");if(!T)return;const oe=T.getBoundingClientRect().width,Z=T.getBoundingClientRect().height;Q({widthRel:Math.max(.15,ce+(R.clientX-K)/oe),heightRel:Math.max(.1,b+(R.clientY-Ee)/Z)})},I=()=>{document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",I)},C=Math.round(B.h*.68),f=Math.max(9,Math.round(B.w*.09));return t.jsxs("div",{ref:q,onMouseDown:X,onClick:z=>{z.stopPropagation(),Re()},style:{position:"absolute",left:B.x,top:B.y,width:B.w,height:B.h,cursor:"move",zIndex:11,userSelect:"none"},children:[t.jsxs("div",{style:{width:"100%",height:"100%",background:"#FFFFFF",borderRadius:Math.round(B.w*.06),overflow:"hidden",boxShadow:"0 2px 12px rgba(0,0,0,0.15)",display:"flex",flexDirection:"column",alignItems:"center"},children:[t.jsx("div",{style:{width:"100%",height:C,background:"#F5F5F5",flexShrink:0,overflow:"hidden"},children:(O==null?void 0:O.image)&&t.jsx("img",{src:O.image,alt:O.name,style:{width:"100%",height:"100%",objectFit:"cover"}})}),t.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:`${Math.round(B.h*.03)}px ${Math.round(B.w*.06)}px`,width:"100%",boxSizing:"border-box"},children:t.jsx("span",{style:{fontSize:f,fontWeight:500,color:"#1A1A1A",textAlign:"center",lineHeight:1.3,overflow:"hidden",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",fontFamily:"'Inter', sans-serif"},children:(O==null?void 0:O.name)??"Selecionar produto"})})]}),F&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{position:"absolute",inset:-2,border:"1.5px solid #18A0FB",borderRadius:Math.round(B.w*.06)+2,pointerEvents:"none",zIndex:15}}),t.jsxs("div",{"data-handle":"true",onMouseDown:z=>{z.stopPropagation(),z.preventDefault()},style:{position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:2,background:"#1C1C1C",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,padding:"4px 6px",whiteSpace:"nowrap",zIndex:30,boxShadow:"0 4px 16px rgba(0,0,0,0.4)"},children:[t.jsx("button",{onClick:z=>{z.stopPropagation(),W()},style:{height:26,padding:"0 8px",border:"none",borderRadius:4,background:"transparent",fontSize:11,fontWeight:500,color:"rgba(255,255,255,0.9)",cursor:"pointer",fontFamily:"'Inter',sans-serif"},children:"↺ Produto"}),t.jsx("button",{onClick:z=>{z.stopPropagation(),k()},style:{height:26,width:26,border:"none",borderRadius:4,background:"transparent",fontSize:12,color:"rgba(255,255,255,0.65)",cursor:"pointer"}})]}),t.jsx("div",{"data-handle":"true",onMouseDown:Me,style:{position:"absolute",bottom:-5,right:-5,width:10,height:10,borderRadius:2,background:"#18A0FB",border:"2px s
1olid #FFF",cursor:"se-resize",zIndex:25}})]})]})},Fg=({card:h,canvasW:O,canvasH:_,isSelected:se,isEditing:F,onSelect:Re,onEdit:k,onBlur:Q,onDelete:W,onUpdate:q})=>{const B=a.useRef(null),X={x:Math.round(h.xRel*O),y:Math.round(h.yRel*_),w:Math.round(h.widthRel*O)},Me=Math.max(10,Math.round(X.w*.052)),C=Math.max(9,Math.round(X.w*.04)),f=Math.max(10,Math.round(X.w*.052)),z=Math.round(X.w*.06),K=Math.round(X.w*.05),Ee=b=>{if(F||b.target.closest("[data-handle]"))return;b.preventDefault(),b.stopPropagation(),Re();const x=document.querySelector("[data-canvas-frame]");if(!x)return;const I=x.getBoundingClientRect(),R=b.clientX-I.left-X.x,T=b.clientY-I.top-X.y,oe=ge=>{var ht;const le=x.getBoundingClientRect(),_e=((ht=B.current)==null?void 0:ht.offsetHeight)??80,Pe=Math.max(0,Math.min(le.width-X.w,ge.clientX-le.left-R)),Lt=Math.max(0,Math.min(le.height-_e,ge.clientY-le.top-T));q({xRel:Pe/le.width,yRel:Lt/le.height})},Z=()=>{document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",Z)};document.addEventListener("mousemove",oe),document.addEventListener("mouseup",Z)},ce=b=>{b.preventDefault(),b.stopPropagation();const x=b.clientX,I=h.widthRel,R=oe=>{const Z=document.querySelector("[data-canvas-frame]");if(!Z)return;const ge=Z.getBoundingClientRect().width;q({widthRel:Math.max(.2,I+(oe.clientX-x)/ge)})},T=()=>{document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",T)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",T)};return t.jsxs("div",{ref:B,onMouseDown:Ee,onClick:b=>{b.stopPropagation(),F||Re()},onDoubleClick:b=>{b.stopPropagation(),k()},style:{position:"absolute",left:X.x,top:X.y,width:X.w,cursor:F?"default":"move",zIndex:11,userSelect:"none"},children:[t.jsxs("div",{style:{background:"rgba(255,255,255,0.96)",borderRadius:K,padding:z,boxShadow:"0 4px 20px rgba(0,0,0,0.12)",display:"flex",flexDirection:"column",gap:Math.round(X.w*.03)},children:[t.jsx("div",{style:{display:"flex",gap:2},children:[1,2,3,4,5].map(b=>t.jsx("span",{"data-handle":F?"true":void 0,onClick:x=>{F&&(x.stopPropagation(),q({rating:b}))},style:{fontSize:f,lineHeight:1,color:b<=h.rating?"#F59E0B":"#E5E7EB",cursor:F?"pointer":"inherit"}},b))}),t.jsx("div",{contentEditable:F,suppressContentEditableWarning:!0,onBlur:b=>{var x;F&&Q({reviewText:((x=b.currentTarget.innerText)==null?void 0:x.trim())||h.reviewText})},onKeyDown:b=>{b.stopPropagation(),b.key==="Escape"&&b.currentTarget.blur()},style:{fontSize:Me,lineHeight:1.45,color:"#1A1A1A",fontFamily:"'Inter', sans-serif",fontWeight:400,outline:"none",borderBottom:F?"1px dashed rgba(24,160,251,0.4)":"none"},children:h.reviewText}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:Math.round(X.w*.025)},children:[t.jsx("div",{style:{width:Math.round(C*1.8),height:Math.round(C*1.8),borderRadius:"50%",background:"#E5E7EB",display:"flex",alignItems:"center",justifyContent:"center",fontSize:C*.75,fontWeight:600,color:"#6B7280",flexShrink:0,fontFamily:"'Inter', sans-serif"},children:h.reviewerName.charAt(0).toUpperCase()}),t.jsx("div",{contentEditable:F,suppressContentEditableWarning:!0,onBlur:b=>{var x;F&&Q({reviewerName:((x=b.currentTarget.innerText)==null?void 0:x.trim())||h.reviewerName})},onKeyDown:b=>{b.stopPropagation(),b.key==="Enter"&&(b.preventDefault(),b.currentTarget.blur()),b.key==="Escape"&&b.currentTarget.blur()},style:{fontSize:C,fontWeight:600,color:"#374151",fontFamily:"'Inter', sans-serif",outline:"none",borderBottom:F?"1px dashed rgba(24,160,251,0.4)":"none"},children:h.reviewerName}),t.jsx("span",{style:{fontSize:C*.85,color:"#10B981",marginLeft:"auto",flexShrink:0},children:"verificado"})]})]}),se&&!F&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{position:"absolute",inset:-2,border:"1.5px solid #18A0FB",borderRadius:K+2,pointerEvents:"none",zIndex:15}}),t.jsxs("div",{"data-handle":"true",onMouseDown:b=>{b.stopPropagation(),b.preventDefault()},style:{position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:2,background:"#1C1C1C",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,padding:"4px 6px",whiteSpace:"nowrap",zIndex:30,boxShadow:"0 4px 16px rgba(0,0,0,0.4)"},children:[t.jsx("button",{onClick:b=>{b.stopPropagation(),k()},style:{height:26,padding:"0 8px",border:"none",borderRadius:4,background:"transparent",fontSize:11,fontWeight:500,color:"rgba(255,255,255,0.9)",cursor:"pointer",fontFamily:"'Inter',sans-serif"},children:"Editar"}),t.jsx("button",{onClick:b=>{b.stopPropagation(),W()},style:{height:26,width:26,border:"none",borderRadius:4,background:"transparent",fontSize:12,color:"rgba(255,255,255,0.65)",cursor:"pointer"}})]}),t.jsx("div",{"data-handle":"true",onMouseDown:ce,style:{position:"absolute",top:"50%",right:-5,transform:"translateY(-50%)",width:10,height:22,borderRadius:3,background:"#18A0FB",border:"2px s
1olid #FFF",cursor:"ew-resize",zIndex:25}})]}),F&&t.jsx("div",{style:{position:"absolute",inset:-2,border:"1.5px dashed #18A0FB",borderRadius:K+2,pointerEvents:"none",zIndex:15}})]})},Sg=({widget:h,canvasW:O,canvasH:_,isSelected:se,onSelect:F,onDelete:Re,onUpdate:k})=>{const Q=a.useRef(null),[W,q]=a.useState({h:0,m:0,s:0});a.useEffect(()=>{const b=()=>{const I=Math.max(0,h.endsAt-Date.now());q({h:Math.floor(I/36e5),m:Math.floor(I%36e5/6e4),s:Math.floor(I%6e4/1e3)})};b();const x=setInterval(b,1e3);return()=>clearInterval(x)},[h.endsAt]);const B={x:Math.round(h.xRel*O),y:Math.round(h.yRel*_),w:Math.round(h.widthRel*O)},X=b=>String(b).padStart(2,"0"),Me=Math.max(14,Math.round(B.w*.13)),C=Math.max(8,Math.round(B.w*.038)),f=Math.round(B.w*.04),z=Math.round(B.w*.04),K=Math.round(B.w*.02),Ee=b=>{if(b.target.closest("[data-handle]"))return;b.preventDefault(),b.stopPropagation(),F();const x=document.querySelector("[data-canvas-frame]");if(!x)return;const I=x.getBoundingClientRect(),R=b.clientX-I.left-B.x,T=b.clientY-I.top-B.y,oe=ge=>{var Pe;const le=x.getBoundingClientRect(),_e=((Pe=Q.current)==null?void 0:Pe.offsetHeight)??60;k({xRel:Math.max(0,Math.min(le.width-B.w,ge.clientX-le.left-R))/le.width,yRel:Math.max(0,Math.min(le.height-_e,ge.clientY-le.top-T))/le.height})},Z=()=>{document.removeEventListener("mousemove",oe),document.removeEventListener("mouseup",Z)};document.addEventListener("mousemove",oe),document.addEventListener("mouseup",Z)},ce=[{value:W.h,label:"horas"},{value:W.m,label:"min"},{value:W.s,label:"seg"}];return t.jsxs("div",{ref:Q,onMouseDown:Ee,onClick:b=>{b.stopPropagation(),F()},style:{position:"absolute",left:B.x,top:B.y,width:B.w,cursor:"move",zIndex:11,userSelect:"none"},children:[t.jsxs("div",{style:{background:"#1A1A1A",borderRadius:z,padding:f,display:"flex",flexDirection:"column",alignItems:"center",gap:K},children:[t.jsx("span",{style:{fontSize:C,fontWeight:500,color:"rgba(255,255,255,0.6)",fontFamily:"'Inter',sans-serif",letterSpacing:"0.04em",textTransform:"uppercase"},children:h.label}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:K*1.5,width:"100%",justifyContent:"center"},children:ce.map((b,x)=>t.jsxs(Uc.Fragment,{children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:2},children:[t.jsx("div",{style:{background:"rgba(255,255,255,0.1)",borderRadius:Math.round(z*.6),padding:`${Math.round(f*.4)}px ${Math.round(f*.7)}px`,minWidth:Math.round(B.w*.18),display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("span",{style:{fontSize:Me,fontWeight:600,color:"#FFFFFF",fontFamily:"'Inter',sans-serif",fontVariantNumeric:"tabular-nums",lineHeight:1},children:X(b.value)})}),t.jsx("span",{style:{fontSize:C*.9,color:"rgba(255,255,255,0.4)",fontFamily:"'Inter',sans-serif"},children:b.label})]}),x<2&&t.jsx("span",{style:{fontSize:Me,fontWeight:600,color:"rgba(255,255,255,0.4)",lineHeight:1,marginBottom:Math.round(C*1.2)},children:":"})]},b.label))})]}),se&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{position:"absolute",inset:-2,border:"1.5px solid #18A0FB",borderRadius:z+2,pointerEvents:"none",zIndex:15}}),t.jsxs("div",{"data-handle":"true",onMouseDown:b=>{b.stopPropagation(),b.preventDefault()},style:{position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:2,background:"#1C1C1C",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,padding:"4px 6px",whiteSpace:"nowrap",zIndex:30,boxShadow:"0 4px 16px rgba(0,0,0,0.4)"},children:[t.jsx("button",{onClick:b=>{b.stopPropagation(),k({endsAt:Date.now()+2*60*60*1e3})},style:{height:26,padding:"0 8px",border:"none",borderRadius:4,background:"transparent",fontSize:11,fontWeight:500,color:"rgba(255,255,255,0.9)",cursor:"pointer",fontFamily:"'Inter',sans-serif"},children:"↺ Reset"}),t.jsx("button",{onClick:b=>{b.stopPropagation(),Re()},style:{height:26,width:26,border:"none",borderRadius:4,background:"transparent",fontSize:12,color:"rgba(255,255,255,0.65)",cursor:"pointer"}})]})]})]})},kg=({widget:h,canvasW:O,canvasH:_,isSelected:se,onSelect:F,onDelete:Re,onUpdate:k})=>{const Q=a.useRef(null),W={x:Math.round(h.xRel*O),y:Math.round(h.yRel*_),w:Math.round(h.widthRel*O)},q=Math.round(W.w*.05),B=Math.round(W.w*.04),X=Math.max(9,Math.round(W.w*.045)),Me=Math.max(16,Math.round(W.w*.1)),C=Math.max(8,Math.round(W.w*.038)),f=Math.max(10,Math.round(W.w*.048)),z=K=>{if(K.target.closest("[data-handle]"))return;K.preventDefault(),K.stopPropagation(),F();const Ee=document.querySelector("[data-canvas-frame]");if(!Ee)return;const ce=Ee.getBoundingClientRect(),b=K.clientX-ce.left-W.x,x=K.clientY-ce.top-W.y,I=T=>{var ge;const oe=Ee.getBoundingClientRect(),Z=((ge=Q.current)==null?void 0:ge.offsetHeight)??80;k({xRel:Math.max(0,Math.min(oe.width-W.w,T.clientX-oe.left-b))/oe.width,yRel:Math.max(0,Math.min(oe.height-Z,T.clientY-oe.top-x))/oe.height})},R=()=>{document.removeEventListener("mousemove",I),document.removeEventListener("mouseup",R)};document.addEventListener("mousemove",I),document.addEventListener("mouseup",R)};return t.jsxs("div",{ref:Q,onMouseDown:z,onClick:K=>{K.stopPropagation(),F()},style:{position:"absolute",left:W.x,top:W.y,width:W.w,cursor:"move",zIndex:11,userSelect:"none"},children:[t.jsxs("div",{style:{background:"rgba(255,255,255,0.96)",borderRadius:B,padding:q,boxShadow:"0 4px 20px rgba(0,0,0,0.15)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:q},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:Math.round(W.w*.02)},children:[t.jsx("span",{style:{fontSize:X,color:"#999",textDecoration:"line-through",fontFamily:"'Inter',sans-serif"},children:h.originalPrice}),t.jsx("span",{style:{fontSize:C,fontWeight:600,color:"#FFFFFF",background:"#EF4444",borderRadius:4,padding:"1px 5px",fontFamily:"'Inter',sans-serif"},children:h.discountBadge})]}),t.jsx("span",{style:{fontSize:Me,fontWeight:600,color:"#1A1A1A",fontFamily:"'Inter',sans-serif",lineHeight:1},children:h.discountPrice})]}),t.jsx("div",{style:{background:"#1A1A1A",borderRadius:Math.round(B*.8),padding:`${Math.round(q*.6)}px ${Math.round(q*1.2)}px`,flexShrink:0},children:t.jsx("span",{style:{fontSize:f,fontWeight:500,color:"#FFFFFF",fontFamily:"'Inter',sans-serif",whiteSpace:"nowrap"},children:h.ctaLabel})})]}),se&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{position:"absolute",inset:-2,border:"1.5px solid #18A0FB",borderRadius:B+2,pointerEvents:"none",zIndex:15}}),t.jsx("div",{"data-handle":"true",onMouseDown:K=>{K.stopPropagation(),K.preventDefault()},style:{position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:2,background:"#1C1C1C",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,padding:"4px 6px",whiteSpace:"nowrap",zIndex:30,boxShadow:"0 4px 16px rgba(0,0,0,0.4)"},children:t.jsx("button",{onClick:K=>{K.stopPropagation(),Re()},style:{height:26,width:26,border:"none",borderRadius:4,background:"transparent",fontSize:12,color:"rgba(255,255,255,0.65)",cursor:"pointer"}})})]})]})},Cg=({widget:h,canvasW:O,canvasH:_,isSelected:se,onSelect:F,onDelete:Re,onUpdate:k})=>{const Q=a.useRef(null),W={x:Math.round(h.xRel*O),y:Math.round(h.yRel*_),w:Math.round(h.widthRel*O)},q=Math.round(W.w*.04),B=Math.round(W.w*.06),X=Math.max(12,Math.round(W.w*.07)),Me=Math.max(9,Math.round(W.w*.042)),C=Math.max(5,Math.round(W.w*.025)),f=z=>{if(z.target.closest("[data-handle]"))return;z.preventDefault(),z.stopPropagation(),F();const K=document.querySelector("[data-canvas-frame]");if(!K)return;const Ee=K.getBoundingClientRect(),ce=z.clientX-Ee.left-W.x,b=z.clientY-Ee.top-W.y,x=R=>{var Z;const T=K.getBoundingClientRect(),oe=((Z=Q.current)==null?void 0:Z.offsetHeight)??40;k({xRel:Math.max(0,Math.min(T.width-W.w,R.clientX-T.left-ce))/T.width,yRel:Math.max(0,Math.min(T.height-oe,R.clientY-T.top-b))/T.height})},I=()=>{document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",I)};return t.jsxs("div",{ref:Q,onMouseDown:f,onClick:z=>{z.stopPropagation(),F()},style:{position:"absolute",left:W.x,top:W.y,width:W.w,cursor:"move",zIndex:11,userSelect:"none"},children:[t.jsxs("div",{style:{background:"rgba(255,255,255,0.96)",borderRadius:B,padding:`${Math.round(q*.8)}px ${q}px`,boxShadow:"0 2px 12px rgba(0,0,0,0.1)",display:"flex",alignItems:"center",gap:Math.round(W.w*.03)},children:[t.jsxs("div",{style:{position:"relative",flexShrink:0,width:C*2.5,height:C*2.5,display:"flex",alignItems:"center",justifyContent:"center"},children:[t.jsx("div",{style:{position:"absolute",width:C*2.5,height:C*2.5,borderRadius:"50%",background:"rgba(34,197,94,0.2)",animation:"softPulse 1.5s ease-in-out infinite"}}),t.jsx("div",{style:{width:C,height:C,borderRadius:"50%",background:"#22C55E",flexShrink:0}})]}),t.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:Math.round(W.w*.015)},children:[t.jsx("span",{style:{fontSize:X,fontWeight:600,color:"#1A1A1A",fontFamily:"'Inter',sans-serif",fontVariantNumeric:"tabular-nums"},children:h.count}),t.jsx("span",{style:{fontSize:Me,color:"#666",fontFamily:"'Inter',sans-serif"},children:h.label})]})]}),se&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{position:"absolute",inset:-2,border:"1.5px solid #18A0FB",borderRadius:B+2,pointerEvents:"none",zIndex:15}}),t.jsx("div",{"data-handle":"true",onMouseDown:z=>{z.stopPropagation(),z.preventDefault()},style:{position:"absolute",bottom:"calc(100% + 8px)",left:"50%",transform:"translateX(-50%)",display:"flex",alignItems:"center",gap:2,background:"#1C1C1C",border:"1px solid rgba(255,255,255,0.12)",borderRadius:8,padding:"4px 6px",whiteSpace:"nowrap",zIndex:30,boxShadow:"0 4px 16px rgba(0,0,0,0.4)"},children:t.jsx("button",{onClick:z=>{z.stopPropagation(),Re()},style:{height:26,width:26,border:"none",borderRadius:4,background:"transparent",fontSize:12,color:"rgba(255,255,255,0.65)",cursor:"pointer"}})})]})]})},ra={"1:1":"1:1","9:16":"9:16","16:9":"16:9","3:4":"3:4","4:3":"4:3","4:5":"3:4","2:3":"9:16","1:2":"9:16","5:8":"9:16","2:1":"16:9","3:2":"4:3"},ri=[{id:"kling-3.0",name:"Kling 3.0",label:"Kuaishou",badge:"novo",de
1sc:"Melhor qualidade — movimento realista e coerente",maxDuration:10,icon:"◉"},{id:"seedance-2.0",name:"Seedance 2.0",label:"Bytedance",badge:null,desc:"Movimento natural, alta fidelidade",maxDuration:10,icon:"◈"},{id:"kling-2.1",name:"Kling 2.1",label:"Kuaishou",badge:"premium",desc:"Melhor qualidade cinematic",maxDuration:10,icon:"◉"},{id:"kling-1.6",name:"Kling 1.6",label:"Kuaishou",badge:null,desc:"Rápido e consistente",maxDuration:10,icon:"◉"},{id:"wan-pro",name:"Wan Pro",label:"Alibaba",badge:null,desc:"Ótimo para produto em cena",maxDuration:5,icon:"▣"},{id:"minimax-video",name:"Minimax VideoCamera",label:"Minimax",badge:null,desc:"Movimento expressivo",maxDuration:6,icon:"▦"}],si={"ecommerce-photography":{thumb:"https://images.unsplash.com/photo-1523275335684-37898b6baf30?w=320&h=240&fit=crop&crop=center",description:"Produto limpo, fundo neutro, luz uniforme. Ideal para marketplace e loja online."},"advertising-product":{thumb:"",description:"Props de ingredientes, fundo dominante, luz dramática e composição editorial."},packshot:{thumb:"https://images.unsplash.com/photo-1596462502278-27bfdc403348?w=320&h=240&fit=crop&crop=center",description:"Produto centralizado, embalagem em destaque, fundo branco ou gradiente suave."},"advertising-portrait":{thumb:"https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=320&h=240&fit=crop&crop=faces",description:"Pessoa com expressão forte, produto integrado à cena. Alto impacto emocional."},"fashion-on-model":{thumb:"https://images.unsplash.com/photo-1469334031218-e382a71b716b?w=320&h=240&fit=crop&crop=center",description:"Produto vestido por modelo em estúdio. Luz clean, pose editorial, caimento real."},"ghost-mannequin":{thumb:"https://images.unsplash.com/photo-1620799140408-edc6dcb6d633?w=320&h=240&fit=crop&crop=center",description:"Roupa estruturada sem modelo, efeito manequim fantasma. Padrão e-commerce de moda."},"product-lifestyle":{thumb:"https://images.unsplash.com/photo-1556742049-0cfed4f6a45d?w=320&h=240&fit=crop&crop=center",description:"Produto em uso no dia a dia. Luz natural, ambiente real, sensação autêntica."},"flat-lay-editorial":{thumb:"https://images.unsplash.com/photo-1515955656352-a1fa3ffcd111?w=320&h=240&fit=crop&crop=center",description:"Vista aérea com composição cuidadosa. Objetos complementares criam narrativa visual."},unboxing:{thumb:"https://images.unsplash.com/photo-1607082348824-0a96f2a4b9da?w=320&h=240&fit=crop&crop=center",description:"Experiência de abertura da embalagem. Gera antecipação e prova social orgânica."},"material-detail":{thumb:"https://images.unsplash.com/photo-1553062407-98eeb64c6a62?w=320&h=240&fit=crop&crop=center",description:"Macro extremo na textura e material do produto. Comunica qualidade sem palavras."},"product-attributes":{thumb:"https://images.unsplash.com/photo-1585386959984-a4155224a1ad?w=320&h=240&fit=crop&crop=center",description:"Callouts visuais anotando os atributos do produto diretamente na imagem."},"pop-illustration":{thumb:"https://images.unsplash.com/photo-1561070791-2526d30994b5?w=320&h=240&fit=crop&crop=center",description:"Foto real com ilustração cartoon bold. Roupas com outline, elementos 2D ao redor."},"product-infographic":{thumb:"",description:"Macro do material com ícones de atributos sobrepostos, estilo editorial premium."}},Ag=({data:h,onClose:O,embedded:_,initialBoardMode:se,initialMode:F})=>{var Jl,Ql,Kl,Zl,ec,tc,oc,nc,ic,ac,rc,sc,lc,cc,dc,uc,pc,gc,mc,hc,fc,xc,bc,yc,vc,wc,jc,Fc,Sc,kc,Cc,Ac,zc,Rc;a.useEffect(()=>{try{localStorage.removeItem("snew_visual_dna"),localStorage.removeItem("visual_dna"),localStorage.removeItem(mg)}catch{}},[]),a.useEffect(()=>{const e=document.querySelector("link[data-snew-fonts]");e&&e.remove();const o=document.createElement("link");o.rel="stylesheet",o.setAttribute("data-snew-fonts","true"),o.href=xg,document.head.appendChild(o)},[]);const{products:Re}=Hp(),k=a.useMemo(()=>{var n;const e=new Map(Re.map(i=>[i.product_id,i])),o=Ur.map(i=>{var u;const l=e.get(i.product_id),s=(u=l==null?void 0:l.image_url)==null?void 0:u.trim();return{id:i.product_id,name:(l==null?void 0:l.name)||i.name,sku:(l==null?void 0:l.sku)||i.sku,image:s||i.image}});for(const i of Re)Ur.some(l=>l.product_id===i.product_id)||(n=i.image_url)!=null&&n.trim()&&o.push({id:i.product_id,name:i.name,sku:i.sku,image:i.image_url});return o},[Re]),Q=cg.dates.map(e=>({id:e.id,title:e.label,date:e.date})),[W,q]=a.useState(((Jl=Q.find(e=>e.title===h.campaignTitle))==null?void 0:Jl.id)||((Ql=Q[0])==null?void 0:Ql.id)),[B,X]=a.useState(!1),Me=a.useRef(null);a.useEffect(()=>{const e=o=>
1{Me.current&&!Me.current.contains(o.target)&&X(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const C=Q.find(e=>e.id===W)||Q[0]||{id:"default",title:"",date:""},[f,z]=a.useState(mt[0]),[K,Ee]=a.useState(!1),ce=a.useRef(null);a.useEffect(()=>{const e=o=>{ce.current&&!ce.current.contains(o.target)&&Ee(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[]);const b=f.id,[x,I]=a.useState(!1),[R,T]=a.useState(null),[oe,Z]=a.useState(null),[ge,le]=a.useState(null),[_e,Pe]=a.useState(null),[Lt,ht]=a.useState(!0),[ca,Fn]=a.useState(!1),[li,Vr]=a.useState(!1),[da,qr]=a.useState(!1),[Xc,Yr]=a.useState(!1),qo=a.useRef(null),[Jc,Xr]=a.useState(!1),Jr=a.useRef(null);a.useRef(null),a.useRef(null),a.useRef(null);const ua=e=>{const o=mt.find(n=>n.id===e)??mt[0];z(o),I(!1),Ct([]),To(0)},Qc=()=>{I(!0),uo(!0)},Kc=()=>{I(!1),Ct([]),To(0)},[ee,jo]=a.useState(""),[rt,Fo]=a.useState(""),[Qe,So]=a.useState(""),[Kt,ko]=a.useState(!1),[Zt,Sn]=a.useState(!1),[eo,kn]=a.useState(!1),[Co,pa]=a.useState(!1),[Qr,Zc]=a.useState(20),[ga,Kr]=a.useState(""),[ma,Eg]=a.useState(!1),[ed,Ig]=a.useState(!0),[td,$g]=a.useState(!1),[od,Dg]=a.useState(!1),[Zr,Mg]=a.useState(!1),[nd,Pg]=a.useState("bold-white"),[id,Ng]=a.useState("bottom"),[ha,es]=a.useState(!1),[Wg,Bg]=a.useState(null),[Ke,Cn]=a.useState(!1),[fa,ts]=a.useState(!1),[Yo,An]=a.useState(""),[xa,os]=a.useState(!1),[Et,zn]=a.useState(null),[Ot,be]=a.useState([]),[ye,He]=a.useState(null),[ci,to]=a.use
1State(null),[ad,di]=a.useState([]),[rd,oo]=a.useState(null),[ns,ba]=a.useState(null),[sd,ui]=a.useState([]),[ld,no]=a.useState(null),[cd,pi]=a.useState(null),[dd,ya]=a.useState([]),[ud,Xo]=a.useState(null),[pd,va]=a.useState([]),[gd,Jo]=a.useState(null),[md,wa]=a.useState([]),[hd,Qo]=a.useState(null),[is,as]=a.useState(null),[fd,Rn]=a.useState(!1),[Ko,ja]=a.useState(null),[gi,mi]=a.useState(""),[xd,Fa]=a.useState(!1),rs=a.useRef(null),[Lg,ss]=a.useState(""),[Og,ls]=a.useState(!1),_t=a.useRef(""),Te=(e,o)=>be(n=>n.map(i=>i.id===e?{...i,...o}:i)),bd=e=>({"9:16":{maxWidth:"80% of width",position:"lower 25%",fontSize:"4-5% of height"},"1:1":{maxWidth:"70% of width",position:"lower 30%",fontSize:"5-6% of width"},"4:5":{maxWidth:"75% of width",position:"lower 28%",fontSize:"4-5% of height"},"16:9":{maxWidth:"55% of width",position:"lower 30%",fontSize:"8-10% of height"},"2:3":{maxWidth:"80% of width",position:"lower 25%",fontSize:"4-5% of height"}})[e]??{maxWidth:"70% of width",position:"lower 30%",fontSize:"5% of image"},yd=()=>{if(!Zr||!ee)return"";const e=(f==null?void 0:f.id)==="9:16"||(f==null?void 0:f.id)==="1:2"||(f==null?void 0:f.id)==="2:3"||(f==null?void 0:f.id)==="5:8",o=(f==null?void 0:f.id)==="1:1"||(f==null?void 0:f.id)==="4:5",n=e?"vertical (portrait)":o?"square":"horizontal (landscape)",i=Gc.find(u=>u.id===ke),l=i?`${i.name} ${i.family.includes("serif")&&!i.family.includes("sans")?"serif":i.family.includes("cursive")?"script/calligraphy":"sans-serif"}`:"clean sans-serif",s=bd((f==null?void 0:f.id)??"1:1");return`
2
3TEXT RENDERING INSTRUCTIONS — follow exactly, this is critical:
4
5TEXT TO RENDER: "${ee}"
6
7STRICT SIZE RULES:
8- The text must fit ENTIRELY within the image — no cropping, no overflow
9- Font size: ${s.fontSize}. Text max width: ${s.maxWidth}
10- If the text is long, break it into 2-3 lines naturally
11- Each line must be fully visible with clear margins on both sides
12
13STRICT POSITION RULES:
14- Place text in the ${s.position} of the image
15- Minimum padding from ALL edges: 8% of the image dimension
16- Text must never touch or go beyond the image borders
17- Horizontal alignment: left-aligned with left margin of 8%
18
19TYPOGRAPHY — critical:
20- Font: ${l}
21- Font weight: medium (500) or regular (400) — NEVER bold or heavy
22- The text must feel editorial, refined, and elegant — not aggressive
23- Color: ${ft??"white"}
24- Letter spacing: -0.01em to 0em (tight, not expanded)
25- Line height: 1.15 to 1.25
26- Subtle text shadow: rgba(0,0,0,0.5), 1px offset, 8px blur
27
28STYLE REFERENCE: Think Celine, Bottega Veneta, or AppleLogo campaign typography —
29confident but never shouting. Medium weight, generous spacing around the text block.
30
31COMPOSITION:
32- This is a ${n} image
33- The text is the SECONDARY element — the product/scene is primary
34- Leave breathing room between the text and the main subject
35- The text should look like professional ad copy typography, not a title card
36- Do NOT fill the entire bottom with text — keep it compact and elegant
37
38CRITICAL: Medium/regular weight text that is fully visible > bold text that is cropped.
39`.trim()},[hi,vd]=a.useState("none"),[wd,jd]=a.useState("#000000"),[cs,Fd]=a.useState(.5),[Ao,Sa]=a.useState("bottom"),[io,ka]=a.useState("left"),[ke,ao]=a.useState("inter"),[ft,zo]=a.useState("#FFFFFF"),[Ht,fi]=a.useState("#FFFFFF"),[Sd,ds]=a.useState("#1A1A1A"),[st,Ca]=a.useState(null),[kd,xi]=a.useState(!1),[Cd,Ad]=a.useState("normal"),[Aa,zd]=a.use
39State("500"),[bi,Rd]=a.useState("0em"),[za,Td]=a.useState("8px"),[Ra,Tn]=a.useState(26),[Ta,Ed]=a.useState(13),[Ea,Id]=a.useState(12),[_g,Hg]=a.useState(null),[Ug,Gg]=a.useState(!1),$d=async()=>{var n,i;const e=`text-${Date.now()}`,o={id:e,text:"...",xRel:(1-.88)/2,yRel:.46,fontSizeRel:.048,color:ft??"#FFFFFF",fontFamily:St(ke),textAlign:"center",boxWidthRel:.88};if(be(l=>[...l,o]),He(e),T(null),!y||L(y)){Te(e,{text:""}),setTimeout(()=>to(e),50);return}try{const l=((n=v==null?void 0:v.name)==null?void 0:n.trim())||"",s=((i=S==null?void 0:S.name)==null?void 0:i.trim())||"",u=(f==null?void 0:f.sublabel)||"InstagramLogo";let r=null;try{r=await me(y)}catch{}const p=["Você é um redator criativo de e-commerce especialista em copy para redes sociais.","Analise a imagem fornecida e crie UMA frase curta, impactante e relevante para usar como headline desta imagem.",l?`Produto: ${l}.`:"",s?`Estilo visual da imagem: ${s}.`:"",`Canal: ${u}.`,"Máximo 8 palavras. Responda APENAS com o texto, sem aspas, sem explicações, sem pontuação final.",'Exemplos de tom: "Feito para durar.", "Seu próximo favorito.", "O detalhe que faz a diferença."'].filter(Boolean).join(`
40`);let d="";if(r){const{data:m,error:w}=await V.functions.invoke("gemini-generate",{body:{prompt:p,model:"gemini-2.0-flash-exp",images:[r],textOnly:!0}});w||(d=(m==null?void 0:m.text)??(m==null?void 0:m.content)??"")}if(!d){const{data:m}=await V.functions.invoke("generate-copy",{body:{action:"freetext",prompt:p,brandContext:pt}});d=(m==null?void 0:m.text)??""}const g=d.replace(/^["'«»]|["'«»]$/g,"").replace(/\.$/,"").trim();g?Te(e,{text:g}):(Te(e,{text:""}),setTimeout(()=>to(e),50))}catch{Te(e,{text:""}),setTimeout(()=>to(e),50)}},us=()=>{var n;const e=`card-${Date.now()}`,o={id:e,productId:((n=k[0])==null?void 0:n.id)??"",xRel:.04,yRel:.6,widthRel:.44,heightRel:.28};di(i=>[...i,o]),oo(e)};a.useEffect(()=>{let e=!1;const o=new ResizeObserver(i=>{const{width:l,height:s}=i[0].contentRect;l<50||s<50||e||(e=!0,be([{id:"main-text",text:ee,xRel:(1-.88)/2,yRel:.46,fontSizeRel:.055,color:"#FFFFFF",fontFamily:St(ke),textAlign:"center",boxWidthRel:.88}]))}),n=$t.current;return n&&o.observe(n),()=>o.disconnect()},[]),a.useEffect(()=>{Te("main-text",{text:ee})},[ee]),a.useEffect(()=>{const e=St(ke);be(o=>o.some(n=>n.id==="main-text")?o.map(n=>n.id==="main-text"?{...n,fontFamily:e}:n):o)},[ke]),a.useEffect(()=>{const e=o=>{var i;if(ci)return;const n=(i=document.activeElement)==null?void 0:i.tagName;n==="INPUT"||n==="TEXTAREA"||((o.key==="Delete"||o.key==="Backspace")&&ye&&(o.preventDefault(),be(l=>l.filter(s=>s.id!==ye)),He(null)),o.key==="Escape"&&(He(null),to(null),T(null)))};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[ye,ci]),a.useEffect(()=>{const e=o=>{if(!ye&&!R)return;const n=o.target;if(n.closest("[data-handle], .selection-toolbar, .canvas-top-toolbar, .float-window, .font-selector-portal"))return;const i=$t.current;i&&i.contains(n)||(He(null),to(null),T(null),Z(null),Pe(null))};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[ye,R]);const[Ne,yi]=a.useState("gradient"),[We,It]=a.useState(0),[Ut,Ia]=a.useState("#000000"),[kt,ps]=a.useState("bottom"),[Vg,qg]=a.useState(!1),$a=((Kl=fg.find(e=>e.id===ke))==null?void 0:Kl.family)||"'Inter', sans-serif",[Da,Ma]=a.useState(!1),[vi,gs]=a.useState("pt"),[Dd,wi]=a.useState([]),[ji,ms]=a.useState("left"),[Fi,hs]=a.useState(!1),En=k.find(e=>
40e.name===h.product)??null,[Ze,ro]=a.useState(En?[En.id]:[]),v=k.find(e=>e.id===Ze[0])??null,A=((Zl=v==null?void 0:v.name)==null?void 0:Zl.trim())||"",Md=()=>wi(e=>[...e,{id:Date.now().toString(),icon:"",label:""}]),Pd=e=>wi(o=>o.filter((n,i)=>i!==e)),fs=(e,o,n)=>wi(i=>i.map((l,s)=>s===e?{...l,[o]:n}:l)),Zo=a.useCallback(async(e=vi)=>{var i,l;const o=k.find(s=>s.id===Ze[0])??null,n=((i=o==null?void 0:o.name)==null?void 0:i.trim())||"";hs(!0);try{const{data:s,error:u}=await V.functions.invoke("generate-copy",{body:{action:"generate-attributes",field:"attributes",tone:(c==null?void 0:c.tone)??st??"direto",language:e,campaign:{title:(de==null?void 0:de.slice(0,120))||yo||(o==null?void 0:o.name)||"criativo",product:n,visualContext:_t.current,context:de?`Imagem gerada com: ${de.slice(0,200)}`:void 0,brandContext:pt}}});if(u)throw u;(l=s==null?void 0:s.attributes)!=null&&l.length&&(wi(s.attributes),Ma(!0))}catch(s){console.error("Generate attributes error:",s),E.error("Erro ao gerar atributos")}finally{hs(!1)}},[vi,st,k,Ze]),[xs,so]=a.useState(!1),[y,ne]=a.useState(h.productImageUrl||(En==null?void 0:En.image)||""),[lo,et]=a.useState("cover"),[lt,Ye]=a.useState({x:50,y:50}),[Ro,tt]=a.useState(100),[Si,Gt]=a.useState(null),[Yg,Nd]=a.useState([]),[Xg,Wd]=a.useState(null),[Jg,Pa]=a.useState([]),[Qg,Bd]=a.useState(!1),[Kg,Na]=a.useState(null),[bs,ys]=a.useState(!1),[In,xt]=a.useState(null),[ot,Wa]=a.useState(null),[D,Ld]=a.useState(null),[ct,Od]=a.use
40State(null),[dt,ki]=a.useState(null),[vs,Ba]=a.useState(null),[_d,Ci]=a.useState(!1),[Hd,Ai]=a.useState(!1),[Ud,Gd]=a.useState([]),[Vd,La]=a.useState([]),[en,ws]=a.useState(!1),js=a.useRef(null),Fs=a.useRef(null);a.useEffect(()=>{ct!=="tv-ad"&&(Ba(null),ki(null))},[ct]);const[Zg,$n]=a.useState(null),[Be,co]=a.useState(!1),[Oa,ut]=a.useState(""),[nt,Dn]=a.useState(!1),[zi,tn]=a.useState(""),[M,To]=a.useState(0),Vt=a.useRef(null);a.useRef(null);const $t=a.useRef(null),_a=a.useRef(null),[H,Ct]=a.useState([]),[qd,uo]=a.useState(!1),[qt,po]=a.useState("auto"),[on,nn]=a.useState(5),[an,Ss]=a.useState(!1),[c,Yd]=a.useState(()=>la());a.useEffect(()=>{const e=()=>Yd(la());return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[]);const rn=a.useMemo(()=>kp(c),[c]),pt=a.useMemo(()=>Cp(c),[c]),go=a.useCallback(()=>{const e=k.find(r=>r.id===Ze[0])??null,o=(e==null?void 0:e.name)??A??"",n=(C==null?void 0:C.title)??h.campaignTitle??"",i=n.toLowerCase();if(!o&&!n)return rn?rn.trim():"";const l={natal:`${o}, cena natalina aconchegante, luz quente, decoração sutil`,"chá de revelação":`${o}, cena suave e delicada, balões e flores, tons pastel`,nascimento:`${o}, ambiente clean e acolhedor, luz natural suave`,"dia das mães":`${o}, lifestyle emocional, mãe e bebê, luz golden hour`,"dia dos pais":`${o}, cena afetiva, pai e bebê, ambiente familiar`,"black friday":`${o}, composição clean e impactante, fundo escuro premium`,lançamento:`${o}, hero shot clean, fundo neutro, produto em destaque`,liquidação:`${o}, ambiente vibrante, destaque visual do produto`,páscoa:`${o}, cena primaveril, flores e luz natural`,aniversário:`${o}, celebração festiva, cores alegres e calorosas`},s=Object.keys(l).find(r=>i.includes(r));return`${s?l[s]:`${o}, lifestyle photography, soft natural light, clean background, warm tones`}${rn}`},[k,Ze,A,h.campaignTitle,C==null?void 0:C.title,rn]),[ks,Cs]=a.useState(!1),[Ha,Ua]=a.useState([]),[Ga,Xd]=a.useState("technical"),[em,As]=a.useState(!1),[de,At]=a.useState(""),[tm,om]=a.useState(!0),[Va,Ri]=a.useState(!1),[qa,Jd]=a.useState("gemini-3.1-flash-image-preview"),[nm,im]=a.useState(!1),sn=Go.find(e=>e.id===qa)||Go[1],[zs,am]=a.useState("generate"),[Ti,Qd]=a.useState(null),[Ya,rm]=a.useState(null),[Rs,sm]=a.useState("neutral"),[Xa,lm]=a.useState(""),[Ts,Kd]=a.useState(!1),[cm,dm]=a.useState(""),[Eo,Zd]=a.useState(null);a.useRef(null),a.useRef(null);const Es=a.useRef(null);a.useEffect(()=>{const e=o=>{Es.current&&!Es.current.contains(o.target)&&Kd(!1)};return Ts&&document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)},[Ts]),a.useEffect(()=>{if(zs==="combine"&&!Ti){const e=k.find(o=>o.id===Ze[0]&&o.image);e&&(Qd(e.image),Zd(e))}},[zs]);const eu={neutral:"clean neutral background, soft studio lighting, product hero shot",lifestyle:"lifestyle scene, natural light, real environment, authentic moment",studio:"professional studio setup, controlled lighting, commercial photography",outdoor:"outdoor natural environment, golden hour, ambient lighting"},[Ja,Io]=a.useState(!1),[um,tu]=a.useState(!1),[Qa,ln]=a.useState(""),[pm,gm]=a.useState(!0),[mm,ou]=a.useState(!1),[mo,$o]=a.use
40State(null),Ka=e=>$o(o=>o===e?null:e),[Le,ho]=a.useState([]),[hm,fm]=a.useState("editorial"),[xm,bm]=a.useState(1),Za=a.useRef(null),nu=e=>ho(o=>o.filter(n=>n.id!==e)),[Do,Fe]=a.useState(null),[Is,er]=a.useState(!1),[iu,cn]=a.useState(!1),[Mn,au]=a.useState("all"),[$s,Mo]=a.useState(!1),[Ds,Ei]=a.useState(!1),[Ms,tr]=a.useState(!1),[Ps,dn]=a.useState(!1),[or,fo]=a.useState(!1),Ns=a.useCallback(()=>so(!1),[]),Ws=a.useCallback(()=>{er(!1),Fe(null)},[]),Bs=a.useCallback(()=>{Mo(!1),Fe(null)},[]),Ls=a.useCallback(()=>{Ei(!1),Fe(null)},[]),Os=a.useCallback(()=>{tr(!1),Fe(null)},[]),_s=a.useCallback(()=>{dn(!1),Fe(null)},[]),Hs=a.useCallback(()=>{fo(!1),Fe(null)},[]),Ii=a.useRef(null);a.useEffect(()=>{if(!Ja)return;const e=n=>{Ii.current&&(Ii.current.contains(n.target)||(Io(!1),$o(null)))},o=setTimeout(()=>{document.addEventListener("mousedown",e)},50);return()=>{clearTimeout(o),document.removeEventListener("mousedown",e)}},[Ja]);const Us=Ho({onClose:Ns,enabled:xs}),Gs=Ho({onClose:Ws,enabled:Is}),Vs=Ho({onClose:Bs,enabled:$s}),qs=Ho({onClose:Ls,enabled:Ds}),Ys=Ho({onClose:Os,enabled:Ms}),Xs=Ho({onClose:_s,enabled:Ps}),Js=Ho({onClose:Hs,enabled:or}),[$i,Qs]=a.useState(!!se),[Dt,Po]=a.useState("product"),[Ks,ru]=a.useState(null),[su,lu]=a.useState(null),[nr,cu]=a.useState(""),[ir,Zs]=a.use
40State(12),[un,ar]=a.useState(!1),rr=k.filter(e=>!nr||e.name.toLowerCase().includes(nr.toLowerCase())),du=rr.slice(0,ir),uu=rr.length>ir,el=e=>{if(!(e!=null&&e.type.startsWith("image/")))return;const o=new FileReader;o.onload=n=>{var l;const i=(l=n.target)==null?void 0:l.result;ho(s=>[...s.slice(-2),{id:`ref-${Date.now()}`,dataUrl:i,base64:i.split(",")[1],mimeType:e.type}]),Po("style")},o.readAsDataURL(e)},[Di,tl]=a.useState(F==="gemini"&&!se),[Mt,Mi]=a.useState({x:0,y:0}),[Ge,Pn]=a.useState(1),[sr,ol]=a.useState(!1),Nn=a.useRef({x:0,y:0,ox:0,oy:0}),Wn=a.useRef(null),[Bn,Pi]=a.useState([]),Ln=a.useRef(null),nl=a.useCallback(async({productName:e,productDescription:o,brandName:n,imageBase64:i})=>{if(i)try{const{data:d,error:g}=await V.functions.invoke("gemini-generate",{body:{prompt:`Analyze this product image and respond ONLY with a JSON object. No other text.
41{
42  "dominantColor": "one color name that would make a great solid background (e.g. 'warm terracotta', 'vibrant lemon yellow', 'sage green', 'dusty rose', 'burnt orange', 'deep teal', 'warm sand')",
43  "sceneElements": "3-5 natural props that relate to this product's ingredients, materials, or use case — be specific (e.g. 'fresh orange slices, dried lavender stems, smooth white river stones')",
44  "mood": "one word: fresh / warm / luxurious / energetic / minimal / organic"
45}`,model:"gemini-3.1-flash-image-preview",images:[i],responseType:"text"}});if(!g&&(d!=null&&d.text)){const m=d.text.match(/\{[\s\S]*\}/);if(m){const w=JSON.parse(m[0]),{dominantColor:j,sceneElements:P,mood:N}=w;return[`Commercial product photography of ${e}.`,`Solid ${j} background — clean, no gradients, no texture.`,"Product placed slightly off-center as the absolute hero of the composition.",`Scene elements arranged around the product: ${P}.`,"Every prop placed with deliberate intention — editorial composition, nothing random.","Directional warm light from above-left, casting soft intentional shadows.",N==="luxurious"?"Rich deep shadows, high contrast, premium feel.":"",N==="fresh"?"Bright airy light, crisp shadows, clean energy.":"",N==="warm"?"Golden warm light, soft shadows, inviting atmosphere.":"",`Rich saturated color grade matching the ${j} background.`,"Slight 3/4 overhead angle, product fully sharp and in focus.","Background elements in soft bokeh, shallow depth of field.","High-end commercial photography quality, magazine-worthy.",o?`Product: ${o}.`:"",n?`Brand: ${n}.`:""].filter(Boolean).join(`
46`)}}}catch{}const l=`${e} ${o??""}`.toLowerCase(),u=[{keywords:["perfume","fragrance","parfum","cologne","eau de"],color:"warm amber orange",elements:"fresh citrus halves, smooth river stones, dried flower petals, green botanical stems"},{keywords:["skincare","serum","creme","moisturizer","facial","skin"],color:"sage green",elements:"fresh tropical leaves, water droplets on glass, smooth white stones, aloe vera leaf"},{keywords:["shampoo","conditioner","hair","cabelo"],color:"dusty rose",elements:"dried botanicals, silk ribbon, smooth oval stones, fresh eucalyptus sprigs"},{keywords:["energético","energy drink","bebida","drink","suco","juice"],color:"vibrant lemon yellow",elements:"fresh citrus slices, ice cubes, mint sprigs, bright citrus zest curls"},{keywords:["suplemento","vitamina","supplement","protein","whey"],color:"clean white with warm shadow",elements:"fresh berries, green leaves, wooden surface details, scattered seeds"},{keywords:["candle","vela","diffuser","aroma"],color:"warm terracotta",elements:"dried sage bundles, smooth pebbles, dried orange slices, cotton stems"},{keywords:["food","alimento","snack","chocolate","café","coffee"],color:"warm burnt orange",elements:"roasted coffee beans, cinnamon sticks, dark chocolate shards, dried figs"},{keywords:["baby","bebê","infantil","criança"],color:"soft warm cream",elements:"soft cotton fabric, dried chamomile flowers, smooth wooden beads, pastel ribbon"},{keywords:["moda","fashion","roupa","clothing","bolsa","bag","shoes","sapato"],color:"deep slate blue",elements:"polished smooth stones, dried pampas grass, architectural concrete blocks, minimal geometric props"}].find(d=>d.keywords.some(g=>l.includes(g))),{color:r,elements:p}=u??{color:"warm neutral sand",elements:"smooth river stones, dried botanical stems, fresh green leaves, geometric marble block"};return[`Commercial product photography of ${e}.`,`Solid ${r}
46 background — clean, no gradients, no texture.`,"Product placed slightly off-center as the absolute hero of the composition.",`Scene elements arranged around the product: ${p}.`,"Every prop placed with deliberate intention — editorial composition, nothing random.","Directional warm light from above-left, casting soft intentional shadows.","Rich saturated color grade matching the background tone.","Slight 3/4 overhead angle, product fully sharp and in focus.","Background elements in soft bokeh, shallow depth of field.","High-end commercial photography quality, magazine-worthy.",o?`Product: ${o}.`:"",n?`Brand: ${n}.`:""].filter(Boolean).join(`
47`)},[]),il=[{id:"photo",label:"PRODUTO ISOLADO",styles:["ecommerce-photography","advertising-product","packshot"]},{id:"person",label:"COM PESSOA",styles:["advertising-portrait","fashion-on-model","ghost-mannequin","product-lifestyle"]},{id:"composition",label:"COMPOSIÇÃO",styles:["flat-lay-editorial","unboxing"]},{id:"detail",label:"DETALHE",styles:["material-detail","product-attributes","product-infographic"]},{id:"campaign",label:"CAMPANHA",styles:["pop-illustration"]}],[ve,pu]=a.useState(oa),[S,Ve]=a.useState(()=>oa().find(e=>e.id==="ecommerce-photography")??oa()[0]??null),[pn,gn]=a.useState("animate"),[Xe,gu]=a.useState(null),[Yt,al]=a.useState(8),[Ni,rl]=a.useState(!1),[On,sl]=a.useState(!1),[it,bt]=a.useState(""),[Xt,ll]=a.useState(!0),[xo,Wi]=a.useState(10),[Pt,lr]=a.useState(!1),[Jt,Bi]=a.useState(null),[Li,cl]=a.useState(null),mn=e=>e?/\.(mp4|webm|mov)/i.test(e)||e.includes("fal.media")||e.includes("fal.run")||e.includes("video")&&!e.includes("image"):!1,[yt,_n]=a.useState("kling-3.0"),[dl,No]=a.useState(""),[Oi,_i]=a.useState(null),[mu,Hn]=a.useState(!1),[hu,Un]=a.useState(!1),[fu,xu]=a.useState(""),[ym,bu]=a.useState(""),[yu,ul]=a.useState([]),te=a.useRef(null),[cr,Hi]=a.useState(null),Wo=a.useRef(),Ui=a.useCallback(e=>{const o=e.basePrompt??de??go(),n=e.product??A??"",i=e.channel??"",l=e.style??"",u={"Feed 1:1":"1:1","Stories 9:16":"9:16","Reels vertical":"9:16",Reels:"9:16",LinkedinLogo:"1:1",PinterestLogo:"2:3"}[i];if(u){const p=mt.find(d=>d.id===u);p&&z(p)}const r=[o,n&&!o.toLowerCase().includes(n.toLowerCase())?`Product: ${n}.`:"",i&&i!=="→ Gerar agora"?`Optimized for ${i}.`:"",l&&l!=="→ Gerar agora"?`Visual style: ${l}.`:""].filter(Boolean).join(" ");At(r),Hi(null),setTimeout(()=>{var p;return(p=Wo.current)==null?void 0:p.call(Wo,r)},100)},[A,de,go,z]),dr=a.useRef(()=>{}),ur=a.useRef(()=>{}),pr=a.useRef(()=>{}),pl=a.useCallback((e,o,n)=>e==="product"?o?n?"generate":"style":"channel":e==="channel"?n?"generate":"style":"generate",[]),hn=a.useCallback(e=>{if(!cr)return;const{step:o,answers:n,hasStyle:i,hasChannel:l,hasProduct:s,basePrompt:u}=cr,r={...n,[o]:e},p=s||o==="product",d=l||o==="channel",g=i||o==="style",m=pl(o,d,g);if(m==="generate"){Ui(r),Hi(null);return}Hi({active:!0,step:m,answers:r,basePrompt:u,hasStyle:g,hasChannel:d,hasProduct:p}),setTimeout(()=>{m==="product"?pr.current():m==="channel"?dr.current(u):m==="style"&&ur.current(u)},100)},[cr,Ui,pl]),Gn=a.useCallback((e,o)=>{var g;if(/gerar agora|pode gerar|gera aí|sem perguntas|gera agora/i.test(e)){(g=Wo.current)==null||g.call(Wo,e);return}const i=(A==null?void 0:A.trim())||/produto|product|tênis|roupa|bolsa|perfume|skin|suplemento|body|macacão|vestido|camisa/i.test(e),l=/feed|stories|reels|linkedin|9:16|1:1|vertical|horizontal|pinterest/i.test(e),s=(o==null?void 0:o.hasProduct)??!!i,u=(o==null?void 0:o.hasChannel)??l,r=(o==null?void 0:o.hasStyle)??!1,p={basePrompt:e};o!=null&&o.channelAnswer&&(p.channel=o.channelAnswer),o!=null&&o.productAnswer&&(p.product=o.productAnswer),A!=null&&A.trim()&&(p.product=A);const d=s?u?r?"generate":"style":"channel":"product";if(d==="generate"){Ui(p);return}Hi({active:!0,step:d,answers:p,basePrompt:e,hasStyle:r,hasChannel:u,hasProduct:s}),setTimeout(()=>{d==="product"?pr.current():d==="channel"?dr.current(e):d==="style"&&ur.current(e)},100)},[A,Ui,h.styleId]),Nt=a.useCallback((e,o,n,i,l)=>{var s;(s=te.current)==null||s.pushActivity(e,o,n,i,l)},[]),Vn=a.useRef(()=>{});a.useEffect(()=>{Vn.current=e=>{var o,n,i,l;switch(e){case"open_image_gen":Gn("Gerar imagem com IA");break;case"open_image_gen_with_product":Ri(!0),Gn("Gerar imagem com IA para o produto");break;case"generate_lifestyle":{const s=`${A}, lifestyle photography, warm natural light, emotional, authentic moment, soft background`;At(s),Ce(s);break}case"generate_carousel":I(!0),uo(!0);break;case"open_image_edit":Cn(!0);break;case"open_publish":Hn(!0);break;case"open_document_poll":Pl();break;case"open_schedule":Un(!0);break;case"open_scan":Qn(!0);break;case"open_calendar":window.location.href="/studio/calendar";break;case"new_asset":ne(null),be([]);break;case"regenerate_image":Fr();break;case"open_gen_panel":Rn(!0);break;case"save_asset":Kn();break;case"show_text":ko(!0),It(.3),Fe("typography");break;case"feedback_like":E.success("ótimo! imagem salva como favorita."),Ue();break;case"feedback_dislike":E.info("entendido. gerando uma nova versão..."),setTimeout(()=>Ce(de),300);break;case"generate_email":Fe("copy"),ou(!0),E.info("abrindo gerador de e-mail...");break;case"generate_caption":{const s=((o=v==null?void 0:v.name)==null?void 0:o.trim())||"",u=(f==null?void 0:f.sublabel)??"InstagramLogo";V.functions.invoke("generate-copy",{body:{action:"auto-generate",field:"caption",tone:"emocional",campaign:{title:(C==null?void 0:C.title)??"",product:s,channel:`${u} — legenda natural, máximo 150 caracteres, sem hashtags`,context:(_t==null?void 0:_t.current)??"",brandContext:pt}}}).then(({data:r})=>{const p=(r==null?void 0:r.caption)??(r==null?void 0:r.heading)??"";if(p){const d=`caption-${Date.now()}`;be(g=>[...g,{id:d,text:p,xRel:.06,yRel:.78,fontSizeRel:.028,color:"#FFFFFF",fontFamily:St(ke),textAlign:"center",boxWidthRel:.88}]),ko(!0),It(.3),E.success("legenda gerada!")}});break}case"open_style_variant":cn(!0),Fe("style");break;case"apply_style_product_attributes":{const s=ve.find(u=>u.id==="product-attributes");if(s){Ve(s);const u=((n=s.buildPrompt)==null?void 0:n.call(s,{productName:(v==null?void 0:v.name)||"",productDescription:(v==null?void 0:v.description)??"",brandName:(c==null?void 0:c.name)??h.campaignTitle??"",context:(f==null?void 0:f.id)??"1:1"}))??"";u&&setTimeout(()=>Ce(u),100)}break}case"open_luma_mode":Ci(!0);break;case"open_higgs_mode":Ai(!0);break;case"open_video_panel":{const s=zt.find(p=>p.id===ct)??zt[0],u=(D==null?void 0:D.name)??A??((i=c==null?void 0:c.productTypes)==null?void 0:i[0])??"",r=it.trim()||s.buildPrompt(u);(l=te.current)!=null&&l.pushVideoFlowMessage?te.current.pushVideoFlowMessage({presetId:s.id,presetLabel:s.label,presetDesc:s.desc,prompt:r,duration:xo,modelId:yt??"kling-3.0",productId:D==null?void 0:D.id,productName:D==null?void 0:D.name,productImageUrl:D==null?void 0:D.image,onGenerate:async p=>{bt(p.prompt),Wi(p.duration),_n(p.modelId);let d=p.refBase64;if(!d&&p.productId){const g=k.find(m=>m.id===p.productId);if(g!=null&&g.image)try{d=await me(g.image)}catch{}}Vi(d)}}):(dn(!0),gn("ai"));break}case"copy_document":jt!=null&&jt.rawText&&(navigator.clipboard.writeText(jt.rawText),E.success("Documento copiado!"));break;case"dismiss":break;default:if(e.startsWith("preview_image:")){const s=e.replace("preview_image:","");s&&(ne(s),Gt(s),et("cover"),tt(100),Ye({x:50,y:50}),be(u=>u.map(r=>r.id==="main-text"?{...r,text:ee||""}:r)),Ue(s),E.success("Imagem carregada no canvas"))}break}}});const gl=a.useCallback(e=>{Vn.current(e)},[]);a.useEffect(()=>{ul(rg())},[]);const vu=e=>{const o=[...yu,e];ul(o),sg(o)};a.useEffect(()=>{try{const e=new Set(["ecommerce-photography","advertising-product","packshot","advertising-portrait","fashion-on-model","ghost-mannequin","product-lifestyle","flat-lay-editorial","unboxing","material-detail","product-attributes","product-infographic","pop-illustration"]),o=["app:styles","snew:image-styles"];for(const l of o){const s=localStorage.getItem(l);if(s)try{const u=JSON.parse(s);if(u.some(p=>
47!e.has(p.id))){const p=u.filter(d=>e.has(d.id));p.length>0?localStorage.setItem(l,JSON.stringify(p)):localStorage.removeItem(l)}}catch{localStorage.removeItem(l)}}const n=oa();pu(n);const i=localStorage.getItem("app:active-style");if(i){const l=JSON.parse(i);if(e.has(l.id)){const s=n.find(u=>u.id===l.id);Ve(s??l)}else{localStorage.removeItem("app:active-style");const s=n.find(u=>u.id==="ecommerce-photography")??n[0]??null;Ve(s)}}else Ve(l=>l?n.find(u=>u.id===l.id)??l:n.find(u=>u.id==="ecommerce-photography")??n[0]??null)}catch{}},[]);const gr=()=>{Fe(null),er(!1),cn(!1),Mo(!1),Ei(!1),tr(!1),dn(!1),fo(!1),$o(null)},mr=e=>{var o,n;if(e==="export"){vr();return}if(e==="channel"){Mo(!0),Fe("channel");return}if(e==="video"){const i=zt.find(u=>u.id===ct)??zt[0],l=(D==null?void 0:D.name)??A??((o=c==null?void 0:c.productTypes)==null?void 0:o[0])??"",s=it.trim()||i.buildPrompt(l);if((n=te.current)!=null&&n.pushVideoFlowMessage){te.current.pushVideoFlowMessage({presetId:i.id,presetLabel:i.label,presetDesc:i.desc,prompt:s,duration:xo,modelId:yt??"kling-3.0",productId:D==null?void 0:D.id,productName:D==null?void 0:D.name,productImageUrl:D==null?void 0:D.image,onGenerate:async u=>{bt(u.prompt),Wi(u.duration),_n(u.modelId);let r=u.refBase64;if(!r&&u.productId){const p=k.find(d=>d.id===u.productId);if(p!=null&&p.image)try{r=await me(p.image)}catch{}}Vi(r)}}),dn(!1);return}}if(Do===e){gr();return}Fe(e),er(e==="overlay"),cn(e==="style"),Mo(e==="channel"),Ei(e==="typography"),tr(e==="attributes"),dn(e==="video")},ml=()=>{const e=`review-${Date.now()}`,o={id:e,reviewText:"Produto incrível! Superou todas as minhas expectativas.",reviewerName:"Maria S.",rating:5,xRel:.04,yRel:.55,widthRel:.88};ui(n=>[...n,o]),no(e)},hl=()=>{const e=`countdown-${Date.now()}`;ya(o=>[...o,{id:e,label:"Oferta termina em",endsAt:Date.now()+2*60*60*1e3,xRel:.04,yRel:.04,widthRel:.92}]),Xo(e)},fl=()=>{const e=`price-${Date.now()}`;va(o=>[...o,{id:e,originalPrice:"R$ 249,90",discountPrice:"R$ 189,90",discountBadge:"24% OFF",ctaLabel:"Comprar agora",xRel:.04,yRel:.75,widthRel:.92}]),Jo(e)},xl=()=>{const e=`social-${Date.now()}`;wa(o=>[...o,{id:e,count:"247",label:"pessoas compraram hoje",xRel:.04,yRel:.88,widthRel:.92}]),Qo(e)};a.useEffect(()=>{var s;if(!((s=h.autoPrompt)!=null&&s.trim()))return;if(h.styleId==="snew"){xt(null),Po("product");return}/v[ií]deo|video|reels|motion/i.test(h.autoPrompt)&&xt("video");const o=h.styleName??null,n=h.styleDesc??null,i=o?`${o} — novo criativo`:h.autoPrompt.slice(0,60);fr(i),(!xn||xn==="snew studio")&&qi(o?o.toLowerCase():h.autoPrompt.slice(0,45).toLowerCase());const l=setTimeout(()=>{var u,r,p;if(o){const d=c!=null&&c.name?` para ${c.name}`:"",g=(u=c==null?void 0:c.productTypes)!=null&&u[0]?` de ${c.productTypes[0]}`:"",m=n?` (${n.toLowerCase()})`:"",w=[`Estilo: ${o}${m}`,"",`Vou criar um visual${g}${d} nesse estilo.`,"","Qual formato você quer?"].join(`
48`),j=[{label:"Feed 1:1",action:"format:1:1"},{label:"Stories 9:16",action:"format:9:16"},{label:"Reels vertical",action:"format:9:16"},{label:"LinkedinLogo",action:"format:1:1"},{label:"PinterestLogo 2:3",action:"format:2:3"}];(p=(r=te.current)==null?void 0:r.pushAssistantMessage)==null||p.call(r,{content:w,chips:j,onChipClick:P=>{const pe={"format:1:1":"1:1","format:9:16":"9:16","format:2:3":"2:3"}[P.action];if(pe){const he=mt.find(U=>U.id===pe);he&&z(he)}Gn(h.autoPrompt,{hasStyle:!0,hasChannel:!0,channelAnswer:P.label})}})}else Gn(h.autoPrompt,{hasStyle:!1})},600);return()=>clearTimeout(l)},[]);const wu=[{id:"zoom-in",label:"Zoom In",icon:"⊕",desc:"Zoom suave na imagem"},{id:"parallax",label:"Parallax",icon:"⟂",desc:"Movimento de profundidade"},{id:"fade-up",label:"Fade Up",icon:"↑",desc:"Texto sobe ao entrar"},{id:"slide-left",label:"Slide",icon:"→",desc:"Elementos deslizam"},{id:"ken-burns",label:"Ken Burns",icon:"◻",desc:"Pan e zoom cinematográfico"},{id:"reveal",label:"Reveal",icon:"◈",desc:"Texto revelado linha a linha"}],zt=[{id:"advertising-product",label:"Advertising",icon:"",desc:"Hero shot dramático",refHint:"produto",refLabel:"Adicione o produto para o hero shot",buildPrompt:e=>`Cinematic advertising video of ${e||"the product"}. Opens with extreme close-up on the product surface — texture, material, sheen. Camera slowly pulls back in a single fluid motion, revealing the full product against a dark neutral background. Single dramatic key light casting deep shadows on one side. The product rotates 15 degrees during the reveal. Slow motion 24fps, film grain, matte color grade. No person, no text, no background clutter. Ends on a clean hero shot held for 2 seconds.`},{id:"close-up-detail",label:"Close-up",icon:"◎",desc:"Macro do produto",refHint:"produto",refLabel:"Adicione o produto para o macro",buildPrompt:e=>`Extreme macro video exploring the surface of ${e||"the product"}. Camera drifts slowly across the material in a continuous glide — reveal
48ing texture, stitching, weave, grain, or finish in microscopic detail. Raking side light accentuates every ridge and imperfection. Ultra-shallow depth of field with soft bokeh. Movement is slow and deliberate, almost meditative. No cuts — single continuous take. No person, no text.`},{id:"lifestyle-motion",label:"Lifestyle",icon:"",desc:"Cena de uso real",refHint:"personagem",refLabel:"Adicione uma foto da pessoa",buildPrompt:e=>`Warm lifestyle video of ${e||"the product"} in natural, authentic use. Scene: bright home interior, golden morning light streaming through sheer curtains. Handheld camera with gentle organic movement. Person's hands interact naturally with the product — not posed, not staged. Shallow depth of field, soft bokeh background. Color grade: warm, slightly desaturated, film-like. Candid and emotional. No text. Feels like a real moment, not an ad.`},{id:"orbit-360",label:"Orbit",icon:"↻",desc:"Câmera orbita o produto",refHint:"produto",refLabel:"Adicione o produto para orbitar",buildPrompt:e=>`${e||"The product"} centered on a clean light-gray surface. Camera orbits slowly in a perfect 360-degree arc at eye level, completing one full rotation. Soft diffused studio lighting — large softbox from above and left, subtle fill from right. Product stays razor-sharp and perfectly centered throughout. Shadows rotate naturally with the camera. Loop-ready: last frame matches first frame. No text, no hands, no distractions.`},{id:"unboxing-reveal",label:"Unboxing",icon:"◻",desc:"Abertura e revelação",refHint:"imagem",refLabel:"Adicione a embalagem ou produto",buildPrompt:e=>`Luxurious unboxing video of ${e||"the product"}. Opens on pristine white packaging on a marble surface. Elegant hands enter frame — deliberate, slow movements. Lid lifts in slow motion, tissue paper parts, ${e||"the product"} is revealed beneath. Camera pushes in smoothly as the product emerges. Warm natural light from a large window on the left. Shallow depth of field. Tactile and satisfying. No text overlay.`},{id:"floating-product",label:"Float",icon:"",desc:"Produto flutuante",refHint:"produto",refLabel:"Adicione o produto para flutuar",buildPrompt:e=>`${e||"The product"} floating in mid-air against a clean gradient background — soft off-white to light warm gray. Gentle continuous rotation on the vertical axis, 1 full turn per 8 seconds. Subtle upward and downward drift, 2cm amplitude, 4-second cycle. Soft ambient light wrapping evenly around the product with a delicate shadow beneath. Camera slowly zooms in 5% over the duration. Minimal, modern, almost weightless. No text, no hands.`},{id:"story-emotional",label:"Story",icon:"◈",desc:"Narrativa emocional",refHint:"personagem",refLabel:"Adicione uma foto da pessoa",buildPrompt:e=>`Cinematic short-form story built around ${e||"the product"}. A sequence of intimate 1-2 second vignettes: morning light hitting the product on a nightstand, hands reaching for it, a close-up of someone's expression as they use it, a wide shot placing it in a real moment of life. Warm, slightly desaturated color grade. No camera movement — let the edit create the rhythm. Each cut is intentional. Ends on the product alone, held for 1.5 seconds.`},{id:"social-energy",label:"Energy",icon:"",desc:"Ritmo rápido, cortes",refHint:"none",refLabel:"Opcional: adicione imagem de referência",buildPrompt:e=>`High-energy social video for ${e||"the product"}. Rapid-fire cuts between 5-7 different angles: close-up texture, dynamic side shot, top-down flat lay, dramatic low angle. Each cut 0.5-1 second. Camera motion between cuts — quick whip pans, snap zooms, push-ins. TextB, saturated color grade with high contrast. Strong directional light creating graphic shadows. Energetic, confident, scroll-stopping. Designed for InstagramLogo Reels and TiktokLogo. No text overlay.`},{id:"tv-ad",label:"Anúncio TV",icon:"▣",desc:"Pessoa + produto",refHint:"both",refLabel:"Adicione produto + foto da pessoa",buildPrompt:e=>`Cinematic 30-second TV commercial for ${e||"the product"}. A person moves naturally through a beautiful, lived-in space — not looking at camera, not performing. ${e||"The product"} is present in the scene as a natural part of their life. Shallow depth of field throughout. Camera moves slowly and purposefully — gentle push-ins, smooth tracking. Golden hour lighting, warm and soft. Color grade: rich, slightly warm, filmic. Aspirational without being unattainable. Ends on the product in a hero moment. No text overlays.`}],Gi=a.useCallback((e,o)=>{const n=_a.current,i=$t.current;if(!n||!i)return;i.style.overflow="hidden",i.style.borderRadius="16px",n.style.animation="none",n.offsetWidth;const l=`${o}s`,s=i.querySelectorAll("[data-field]");switch(e){case"zoom-in":n.style.animation=`canvasZoomIn ${l} ease-in-out forwards`;break;case"ken-burns":n.style.animation=`canvasKenBurns ${l} ease-in-out forwards`;break;case"fade-up":s.forEach((u,r)=>{u.style.animation=`canvasFadeUp 0.8s ease ${.3+r*.3}s both`});break;case"slide-left":n.style.animation=`canvasSlideFromRight ${l} ease-in-out forwards`;break;case"parallax":n.style.animation=`canvasParallax ${l} ease-in-out forwards`;break;case"reveal":s.forEach(u=>{u.style.animation="canvasRevealText 1.2s ease 0.3s both"});break}},[]),ju=a.useCallback(()=>{Xe&&(rl(!0),Gi(Xe,Yt),setTimeout(()=>{rl(!1);const e=_a.current,o=$t.current;e&&(e.style.animation="none",e.querySelectorAll("[data-field]").forEach(n=>
48{n.style.animation="none"})),o&&(o.style.overflow="visible")},Yt*1e3))},[Xe,Yt,Gi]),Fu=a.useCallback(async()=>{if(!(!Xe||!Vt.current)){sl(!0);try{E.info("Exportando vídeo... isso pode demorar."),Gi(Xe,Yt),await new Promise(e=>setTimeout(e,Yt*1e3)),E.success("Animação finalizada! Use gravação de tela para capturar.")}catch(e){console.error(e),E.error("Erro ao exportar vídeo")}finally{sl(!1);const e=Vt.current;e&&(e.style.animation="none")}}},[Xe,Yt,Gi,C.title]),qn=a.useCallback(()=>{var r,p,d;const e=k.find(g=>g.id===Ze[0]),o=((r=e==null?void 0:e.name)==null?void 0:r.trim())??A??((p=c==null?void 0:c.productTypes)==null?void 0:p[0])??"",n=((d=C==null?void 0:C.title)==null?void 0:d.trim())??"",i=(ee==null?void 0:ee.trim())??"";if(!o&&!n&&!i)return"Cinematic product video, lifestyle scene, natural light, slow camera movement, commercial quality.";const s={"ecommerce-photography":"slow zoom in on product, clean studio reveal, crisp and elegant","advertising-product":"dramatic cinematic push in, deep shadows, high contrast motion, hero moment","commercial-product":"warm handheld movement, natural light, lifestyle atmosphere","product-lifestyle":"golden hour slow pan, candid emotional movement, film grain feel","aesthetic-product-sh
48oot":"ultra slow macro drift, textural detail reveal, sensorial and luxurious","campaign-editorial":"bold graphic motion, unexpected angles, high-concept visual energy","warm-lifestyle":"slow intimate pan, golden warmth, soft focus drift, cozy atmosphere","bold-vibrant":"energetic fast cuts, vivid saturated motion, Gen Z campaign energy","fashion-on-model":"elegant slow walk, clean studio light, confident fluid movement","material-detail":"extreme slow macro zoom into texture, tactile surface reveal"}[(S==null?void 0:S.id)??""]??"smooth cinematic motion, commercial quality, lifestyle feel";return[o?`${o} product video`:"Cinematic product video",n?`for ${n}`:"",i?`Visual message: "${i}"`:"",s,"High-end commercial quality."].filter(Boolean).join(". ").replace(/\.\./g,".").trim()},[k,Ze,A,C,ee,S,c]);a.useEffect(()=>{if(!Xt)return;const e=qn();bt(e)},[Xt,qn,Ze,S==null?void 0:S.id,C==null?void 0:C.id]);const L=e=>e?e.includes("picsum.photos")||e.includes("placeholder")||e==="":!0,Su=a.useCallback(async()=>{var n,i;const e=l=>new Promise((s,u)=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>{const p=document.createElement("canvas");p.width=r.naturalWidth,p.height=r.naturalHeight,p.getContext("2d").drawImage(r,0,0),s(p.toDataURL("image/jpeg",.92).split(",")[1])},r.onerror=u,r.src=l}),o=D?((n=k.find(l=>l.id===D.id))==null?void 0:n.image)??null:ot??null;if(!o&&!dt)return null;ws(!0);try{const l=[];if(o)if(o.startsWith("data:"))l.push(o.split(",")[1]);else try{l.push(await e(o))}catch{}if(dt)if(dt.startsWith("data:"))l.push(dt.split(",")[1]);else try{l.push(await e(dt))}catch{}if(l.length===0)return null;const s=(D==null?void 0:D.name)??A??((i=c==null?void 0:c.productTypes)==null?void 0:i[0])??"the product",u=l.length===2?`Create a single cinematic still frame for a TV commercial.
49The image must contain BOTH subjects from the reference photos:
501. The product from the first image (${s}) — clearly visible, well lit, prominent
512. The person from the second image — preserve their exact face, hair, skin tone, and style
52
53Scene: the person is naturally interacting with or holding the product in a real lifestyle setting.
54Style: cinematic photography, shallow depth of field f/1.8, warm golden color grade,
55soft backlight rim lighting, commercial photography quality.
56Composition: person in foreground slightly off-center, product in focus in frame.
57NO text overlays. NO logos. Photorealistic.`:`Create a cinematic still frame for a TV commercial featuring ${s}.
58The ${l[0]&&!dt?"product":"person"} from the reference image
59placed in a lifestyle setting. Cinematic photography, shallow depth of field,
60warm color grade, soft backlight. NO text overlays. Photorealistic.`,r=ra[f.id]??"16:9",{data:p,error:d}=await V.functions.invoke("gemini-generate",{body:{prompt:u,model:"gemini-2.5-flash-image",aspectRatio:r,images:l,personGeneration:"allow_adult",negativePrompt:["text in image","letters","words","watermark","logo","illustration","cartoon","3d render","CGI","split image","collage","two separate images"].join(", ")}});if(d||p!=null&&p.error)return console.error("Composite frame error:",d??(p==null?void 0:p.error)),null;const g=(p==null?void 0:p.imageUrl)??null;return g&&Ba(g),g}catch(l){return console.error("generateCompositeFrame error:",l),null}finally{ws(!1)}},[D,ot,dt,k,A,c,f]),Vi=a.useCallback(async e=>{lr(!0),_i(null),Bi(null),No("Enviando para fila..."),dn(!1),Fe(null);try{let o;if(e)o=e;else if(y&&!L(y))if(y.startsWith("data:"))o=y.split(",")[1]??void 0;else try{o=await me(y)}catch{}const n=!o&&it?`${it}. photorealistic, cinematic quality, no text overlay, no watermark.`:it,{data:i,error:l}=await V.functions.invoke("generate-video",{body:{prompt:n,imageBase64:o,duration:xo,aspectRatio:f.id,modelId:yt??"kling-3.0",mode:o?"image-to-video":"text-to-video"}});if(l)throw new Error(l.message);if(i!=null&&i.error)throw new Error(i.error);const{requestId:s,endpoint:u,statusUrl:r,responseUrl:p}=i??{};if(!s)throw new Error("Sem request_id da fila.");No("Na fila...");let d=0;const g=75,m=async()=>{if(d++>=g)throw new Error("Tempo limite excedido (5 min). Tente novamente.");await new Promise(he=>setTimeout(he,4e3));const{data:w,error:j}=await V.functions.invoke("check-video-status",{body:{requestId:s,endpoint:u,statusUrl:r,responseUrl:p}});if(j)throw new Error(j.message);if(w!=null&&w.error)throw new Error(w.error);const{status:P,videoUrl:N,queuePosition:pe}=w??{};if(P==="COMPLETED"){if(!N)throw new Error("Vídeo concluído mas sem URL.");Bi(N),E.success("Vídeo gerado!");return}if(P==="FAILED")throw new Error((w==null?void 0:w.error)||"Falha na geração.");return No(P==="IN_PROGRESS"?"Gerando vídeo...":pe!=null?`Na fila (pos. ${pe})...`:"Processando..."),m()};await m()}catch(o){console.error("VideoCamera generation error:",o),_i((o==null?void 0:o.message)||"Não foi possível gerar. Tente novamente.")}finally{lr(!1),No("")}},[it,xo,f,y,yt]),[fn,ku]=a.useState([]),Cu=a.useCallback(e=>{ku(o=>typeof e=="function"?e(o):e)},[]),[Au,Yn]=a.useState(!1),[bo,hr]=a.useState("saved"),[yo,fr]=a.useState("Sem título"),[zu,xr]=a.useState(!1),Ru=((ec=h.styleName)==null?void 0:ec.toLowerCase())||((tc=h.autoPrompt)==null?void 0:tc.slice(0,45).toLowerCase())||"",{session:Xn,children:Tu,parent:Eu,rename:bl,createChild:Iu}=Ap(Ru,"studio"),xn=Xn.title,qi=e=>bl(e),[Yi,Jn]=a.useState(null),[vm,$u]=a.useState(null),[gt,yl]=a.useState(""),[vt,vl]=a.useState([]),[Wt,Du]=a.useState(["instagram-feed","instagram-stories"]),[bn,wl]=a.useState([]),[Mu,jl]=a.useState(!1),[Fl,Sl]=a.useState(0),[vo,Pu]=a.useState("editorial"),[Bo,Nu]=a.useState(""),[Lo,Wu]=a.useState("all"),Bu=e=>vl(o=>o.includes(e)?o.filter(n=>n!==e):[...o,e]),Lu=e=>Du(o=>o.includes(e)?o.filter(n=>n!==e):[...o,e]),Bt=a.useCallback((e,o)=>{wl(n=>n.map(i=>i.id===e?{...i,...o}:i))},[]),Ou=a.useCallback(async()=>{xr(!1),jl(!0),Sl(0),Yn(!0),hr("auto");const e={"instagram-feed":"1:1","instagram-stories":"9:16",whatsapp:"1:1","site-banner":"16:9"},o={"instagram-feed":"square 1:1, InstagramLogo Feed","instagram-stories":"vertical 9:16, InstagramLogo Stories",whatsapp:"square 1:1, WhatsappLogo","
60site-banner":"horizontal 16:9, site banner"},n={"instagram-feed":"InstagramLogo Feed — copy curta, emocional, sem hashtags","instagram-stories":"InstagramLogo Stories — urgência, CTA direto, máx 8 palavras no heading",whatsapp:"WhatsappLogo — tom pessoal, direto, com emoji","site-banner":"Banner de site — headline impactante, benefício imediato"},i=k.filter(g=>vt.includes(g.id));let l=[];for(const g of i)for(const m of Wt)l.push({product:g,format:m});Lo!=="all"&&typeof Lo=="number"&&(l=l.slice(0,Lo));const s=l.length;let u=0;const r=l.map(({product:g,format:m})=>({id:`auto-${Date.now()}-${Math.random().toString(36).slice(2)}`,productId:g.id,productName:g.name,channel:e[m]??"1:1",imageUrl:"",heading:"",description:"",cta:"",price:"R$ 189",styleId:vo,createdAt:new Date,theme:gt,status:"pending"}));wl(r);const p=2,d=800;for(let g=0;g<r.length;g+=p){const m=r.slice(g,g+p);await Promise.all(m.map(async w=>{Bt(w.id,{status:"generating"});try{const j=k.find(Se=>Se.id===w.productId),P=Object.keys(e).find(Se=>e[Se]===w.channel)??"instagram-feed",N=ai.find(Se=>Se.id===vo),pe=(N==null?void 0:N.name)??vo,he=(N==null?void 0:N.imageStyle)??"editorial lifestyle photography, natural light, shallow depth of field, film grain, authentic moment, magazine quality, photorealistic",{data:U}=await V.functions.invoke("generate-copy",{body:{action:"auto-generate",field:"full",tone:"emocional",campaign:{title:gt,product:w.productName,channel:n[P]??P,style:pe,instructions:Bo||void 0,context:`Campanha: ${gt}. Produto: ${w.productName}. ${Bo?`Instruções extras: ${Bo}`:""}`,brandContext:pt}}});let ie;try{const Se=typeof U=="string"?U.replace(/```json|```/g,"").trim():null,Ft=Se?JSON.parse(Se):U;ie=Ft!=null&&Ft.heading?Ft:{heading:`${gt} — ${w.productName}`,description:w.productName,cta:"Garantir agora →"}}catch{ie={heading:`${gt} — ${w.productName}`,description:w.productName,cta:"Garantir agora →"}}Bt(w.id,{heading:ie.heading,description:ie.description,cta:ie.cta,status:"generating"});const Ie=o[P]??"square",we=Bo?` ${Bo}.`:"",$={prompt:`${w.productName}, ${he}, ${gt} campaign.${we} ${Ie}. High quality commercial photography. Style: editorial lifestyle photography, natural light, shallow depth of field, film grain, authentic moment, magazine quality, photorealistic. Avoid: illustration, cartoon, 3d render, painting, drawing, digital art.`,model:"gemini-2.5-flash-image",aspectRatio:ra[f.id]??"1:1"};if(j!=null&&j.image)try{const Se=await new Promise((Ft,De)=>{const Ae=new Image;Ae.crossOrigin="anonymous",Ae.onload=()=>{const G=document.createElement("canvas");G.width=Ae.naturalWidth,G.height=Ae.naturalHeight,G.getContext("2d").drawImage(Ae,0,0),Ft(G.toDataURL("image/jpeg",.85).split(",")[1])},Ae.onerror=De,Ae.src=j.image});$.images=[Se]}catch{}const{data:ae,error:$e}=await V.functions.invoke("gemini-generate",{body:$});if($e)throw $e;Bt(w.id,{imageUrl:(ae==null?void 0:ae.imageUrl)||"",styleId:vo,status:ae!=null&&ae.imageUrl?"done":"error",errorMsg:ae!=null&&ae.imageUrl?void 0:"Imagem não retornada"})}catch(j){Bt(w.id,{status:"error",errorMsg:(j==null?void 0:j.message)??"Erro desconhecido"})}u++,Sl(Math.round(u/s*100))})),g+p<r.length&&await new Promise(w=>setTimeout(w,d))}jl(!1)},[k,vt,Wt,gt,vo,Bo,Lo,Bt]),_u=a.useCallback(async e=>{const o=bn.find(n=>n.id===e);if(o){Bt(e,{status:"generating",errorMsg:void 0});try{const{data:n}=await V.functions.invoke("generate-copy",{body:{action:"auto-generate",field:"full",tone:"direto",campaign:{title:o.theme,product:o.productName,channel:o.channel,brandContext:pt}}});let i;n!=null&&n.heading?i=n:i={heading:`${o.productName} — ${o.theme}`,description:o.productName,cta:"Comprar agora →"},Bt(e,{heading:i.heading,description:i.description,cta:i.cta});const l=`${o.productName} product photography for ${o.theme} campaign. ${i.heading}. Commercial quality, clean background. High resolution.`,{data:s,error:u}=await V.functions.invoke("gemini-generate",{body:{prompt:l,model:"gemini-2.5-flash-image",aspectRatio:ra[f.id]??"1:1"}});if(u)throw u;Bt(e,{imageUrl:(s==null?void 0:s.imageUrl)||"",status:s!=null&&s.imageUrl?"done":"error",errorMsg:s!=null&&s.imageUrl?void 0:"Imagem não retornada"})}catch(n){Bt(e,{status:"error",errorMsg:(n==null?void 0:n.message)??"Erro ao tentar novamente"})}}},[bn,Bt]),kl=a.useCallback(e=>{ne(e.imageUrl),jo(e.heading),Fo(e.description),So(e.cta),z(mt.find(o=>o.id===e.channel)??mt[0]),Ca(e.styleId),et("cover"),tt(100),Ye({x:50,y:50}),be(o=>o.some(n=>n.id==="main-text")?o.map(n=>n.id==="main-text"?{...n,text:e.heading}:n):o),Yn(!1),E.success("Post carregado no canvas")},[]);a.useEffect(()=>{const e=o=>{o.key==="Escape"&&(Io(!1),so(!1),tu(!1),gr())};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[]);const Ue=a.useCallback(e=>{var r,p,d;const o=e??y;
60if(!o||o.length<10||L(o))return;const n=mn(o),l=(((p=(r=te.current)==null?void 0:r.getMessages)==null?void 0:p.call(r))??[]).filter(g=>!("type"in g&&g.type==="activity")).map(g=>({role:g.role,content:g.content,actions:g.actions,followUps:g.followUps})).slice(-20),s=(ee==null?void 0:ee.trim())||(A==null?void 0:A.trim())||((d=S==null?void 0:S.name)==null?void 0:d.trim())||yo||"Criativo",u={id:`asset-${Date.now()}`,createdAt:new Date,imageUrl:o,heading:ee,description:rt,cta:Qe,channel:b,styleId:st,isCarousel:x,slides:x?[...H??[]]:void 0,sessionTitle:s,imageHasEmbeddedText:ha,isVideo:n,videoUrl:n?o:void 0,chatMessages:l,imagePosition:{...lt},imageScale:Ro,imageFit:lo};Cu(g=>g.some(m=>m.imageUrl===o&&m.channel===b)?g:[u,...g])},[y,ee,rt,Qe,b,st,x,H,yo,ha,mn,A,S,lt,Ro,lo]),Cl=a.useCallback(e=>{var n;jo(e.heading),Fo(e.description),So(e.cta),ne(e.imageUrl),z(mt.find(i=>i.id===e.channel)??mt[0]),Ca(e.styleId),I(e.isCarousel),e.isCarousel&&e.slides&&Ct(e.slides),es(e.imageHasEmbeddedText??!1);const o=e.sessionTitle??e.channel??"sessão";fr(o),qi(o.toLowerCase()),Yn(!1),e.imagePosition?Ye(e.imagePosition):Ye({x:50,y:50}),e.imageScale!==void 0?tt(e.imageScale):tt(100),e.imageFit?et(e.imageFit):et("cover"),(n=e.chatMessages)!=null&&n.length?setTimeout(()=>{var i,l;(l=(i=te.current)==null?void 0:i.setMessages)==null||l.call(i,e.chatMessages)},100):setTimeout(()=>{var i,l;(l=(i=te.current)==null?void 0:i.setMessages)==null||l.call(i,[{role:"assistant",content:`Asset restaurado: ${e.sessionTitle||e.channel}. O que você quer ajustar?`}])},100)},[]),Hu=a.useCallback(e=>{var i;if(!e.imageUrl)return;const o=document.createElement("a"),n=(((i=e.heading)==null?void 0:i.trim())||e.sessionTitle||"criativo").replace(/[^a-zA-Z0-9À-ÿ\s-]/g,"").slice(0,40).trim();o.download=`${n}-${e.channel}-snew.png`,o.href=e.imageUrl,o.click(),E.success("DownloadSimple iniciado")},[]),Uu=e=>({"instagram-feed":"Feed","instagram-stories":"Stories",whatsapp:"WhatsappLogo","site-banner":"Banner"})[e]??e,Gu=e=>{const o=new Date(e),n=Date.now()-o.getTime(),i=Math.floor(n/6e4);if(i<1)return"agora";if(i<60)return`há ${i}min`;const l=Math.floor(i/60);return l<24?`há ${l}h`:o.toLocaleDateString("pt-BR",{day:"2-digit",month:"short"})},[Vu,Qn]=a.useState(!1),[re,br]=a.useState(null),[yr,Al]=a.useState(!1),[zl,Rl]=a.useState(!1),[wt,yn]=a.useState({campaignObjective:"conversion",ticketAverage:0,audience:"",productCategory:"",isPromotional:!1}),Qt=f,Tl=Qt.supportsCarousel,El=x&&Tl,qu=e=>{var o;return((o=k.find(n=>n.id===e))==null?void 0:o.image)||""};El?Ze.map(e=>{var o;return{image:qu(e),name:((o=k.find(n=>n.id===e))==null?void 0:o.name)||""}}):v!=null&&v.name;const Oo=a.useCallback(e=>{Ca(e.id),ao(e.font),zo(e.textColor),fi(e.ctaColor),ds(e.ctaTextColor),Td(e.ctaRadius),ka(e.textHAlign),Sa(e.textVAlign),Ad(e.textCase),zd(e.fontWeight),Rd(e.letterSpacing),Tn(bg[e.headingSize]||26),yi(e.overlayType),Ia(e.overlayColor),ps(e.overlayPosition),xi(!1),e.enableAttributes&&(Ma(!0),Zo()),e.enablePrice?(pa(!0),ga||Kr("R$ 189,90")):pa(!1)},[Zo,ga]);a.useEffect(()=>{pr.current=()=>{var e,o;(o=(e=te.current)==null?void 0:e.pushQualificationMessage)==null||o.call(e,{question:c!=null&&c.name?`Qual produto de ${c.name} você quer destacar?`:"Qual produto você quer destacar?",chips:void 0,onSkip:()=>hn("")})},dr.current=e=>{var i,l;const o=(c==null?void 0:c.audience)??"",n=o?`Onde vai publicar para ${o.split(",")[0].trim()}?`:"Onde vai publicar esse criativo?";(l=(i=te.current)==null?void 0:i.pushQualificationMessage)==null||l.call(i,{question:n,chips:["Feed 1:1","Stories 9:16","Reels vertical","LinkedinLogo","PinterestLogo 2:3","→ Gerar agora"],onSkip:()=>hn("→ Gerar agora")})},ur.current=e=>{var i,l;const o=(c==null?void 0:c.niche)??"",n=ve.filter(s=>o.includes("moda")||o.includes("roupa")?["fashion-on-model","ghost-mannequin","advertising-portrait","ecommerce-photography"].includes(s.id):o.includes("cosmético")||o.includes("beleza")?["advertising-product","product-lifestyle","material-detail","packshot"].includes(s.id):o.includes("bebê")||o.includes("infantil")?["ecommerce-photography","product-lifestyle","advertising-portrait","flat-lay-editorial"].includes(s.id
60):!0).slice(0,6);(l=(i=te.current)==null?void 0:i.pushStylePickerMessage)==null||l.call(i,{question:"Qual estilo visual?",styles:n.map(s=>({id:s.id,name:s.name,description:s.description??s.category??"",thumbnailUrl:s.thumbnailUrl??""})),onSelect:(s,u)=>{const r=ve.find(p=>p.id===s);r&&(Ve(r),Oo(r)),hn(u)},onSkip:()=>hn("→ Gerar agora")})}},[c,ve,Oo,hn]);const Kn=a.useCallback(()=>{!y||L(y)||(Ue(y),qr(!0),Yr(!0),setTimeout(()=>qr(!1),900),setTimeout(()=>Yr(!1),2200),Nt("asset_saved","Salvo ","Guardado. Pronto pra publicar ou quer refinar mais?",[]))},[y,Ue,Nt]),Il=a.useCallback(async()=>{const e=Li??(mn(y)?y:null);if(!e){E.error("Nenhum vídeo no canvas.");return}const n=((ee==null?void 0:ee.trim())||(yo==null?void 0:yo.trim())||(A==null?void 0:A.trim())||"snew-criativo").toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").replace(/[^a-z0-9\s-]/g,"").trim().replace(/\s+/g,"-").slice(0,40),i=We>0,l=Ot.some(u=>u.text&&u.text!=="...");if(!(i||l)){E.info("Baixando vídeo...");try{const u=await fetch(e,{mode:"cors"});if(!u.ok)throw new Error("fetch failed");const r=await u.blob(),p=new Blob([r],{type:"video/mp4"}),d=URL.createObjectURL(p),g=document.createElement("a");g.href=d,g.download=`${n}-snew.mp4`,document.body.appendChild(g),g.click(),document.body.removeChild(g),setTimeout(()=>URL.revokeObjectURL(d),1e4),E.success(`DownloadSimple iniciado — ${n}-snew.mp4`)}catch{window.open(e,"_blank"),E.info("Vídeo aberto em nova aba — salve manualmente.")}return}E.info("Compondo vídeo criativo...");try{const u=document.createElement("video");u.crossOrigin="anonymous",u.muted=!0,u.playsInline=!0,u.src=e,u.style.cssText="position:absolute;width:0;height:0;opacity:0;pointer-events:none",document.body.appendChild(u),await new Promise((G,ue)=>{u.onloadedmetadata=()=>G(),u.onerror=()=>ue(new Error("Falha ao carregar vídeo")),setTimeout(()=>ue(new Error("Timeout ao carregar vídeo")),2e4)});const r=u.videoWidth||f.width,p=u.videoHeight||f.height,d=document.createElement("canvas");d.width=r,d.height=p;const g=d.getContext("2d");await document.fonts.ready;const m=St(ke);if(m)try{await document.fonts.load(`600 48px "${m}"`)}catch{}for(const G of Ot)if(G.fontFamily)try{await document.fonts.load(`600 48px "${G.fontFamily}"`)}catch{}const w=()=>{if(We<=0)return;const G=Ut.replace("#","").match(/.{2}/g),ue=G?G.map(ze=>parseInt(ze,16)).join(","):"0,0,0";if(g.save(),Ne==="solid")g.fillStyle=`rgba(${ue},${We})`,g.fillRect(0,0,r,p);else{const ze=kt==="top"?0:p,vn=kt==="top"?p:0,qe=g.createLinearGradient(0,ze,0,vn);qe.addColorStop(0,`rgba(${ue},${We})`),qe.addColorStop(1,`rgba(${ue},0)`),g.fillStyle=qe,g.fillRect(0,0,r,p)}g.restore()},j=()=>{for(const G of Ot){if(!G.text||G.text==="...")continue;const ue=Math.max(8,Math.round((G.fontSizeRel??.06)*r)),ze=Math.round((G.xRel??.06)*r),vn=Math.round((G.yRel??.5)*p),qe=Math.round((G.boxWidthRel??.88)*r),Y=(G.fontFamily??m??"Inter").replace(/'/g,"").split(",")[0].trim();g.save(),g.font=`600 ${ue}px "${Y}"`,g.fillStyle=G.color??"#FFFFFF",g.textAlign=G.textAlign??"center",g.textBaseline="top",G.textShadow&&(g.shadowColor="rgba(0,0,0,0.7)",g.shadowBlur=8,g.shadowOffsetX=0,g.shadowOffsetY=2);const J=G.text.split(" "),at=[];let Rt="";for(const wo of J){const wn=Rt?`${Rt} ${wo}`:wo;g.measureText(wn).width<=qe?Rt=wn:(Rt&&at.push(Rt),Rt=wo)}Rt&&at.push(Rt);const $r=G.textAlign==="center"?ze+qe/2:G.textAlign==="right"?ze+qe:ze,Dr=ue*1.25;at.forEach((wo,wn)=>g.fillText(wo,$r,vn+wn*Dr)),g.restore()}},P=MediaRecorder.isTypeSupported("video/webm;codecs=vp9")?"video/webm;codecs=vp9":MediaRecorder.isTypeSupported("video/webm;codecs=vp8")?"video/webm;codecs=vp8":"video/webm",N=d.captureStream(30),pe=new MediaRecorder(N,{mimeType:P,videoBitsPerSecond:8e6}),he=[];pe.ondataavailable=G=>{G.data.size>0&&he.push(G.data)};const U=new Promise(G=>{pe.onstop=()=>G()});pe.start(100),u.currentTime=0,await u.play(),await new Promise(G=>{let ue;const ze=()=>{if(u.ended||u.paused){cancelAnimationFrame(ue),pe.stop(),G();return}g.clearRect(0,0,r,p),g.drawImage(u,0,0,r,p),w(),j(),ue=requestAnimationFrame(ze)};ue=requestAnimationFrame(ze)}),await U,document.body.removeChild(u);const ie=new Blob(he,{type:"video/webm"});E.info("Convertendo para MP4...");const Ie=`temp-${Date.now()}-${Math.random().toString(36).slice(2,8)}.webm`,{error:we}=await V.storage.from("temp-videos").upload(Ie,ie,{contentType:"video/webm",upsert:!0});if(we){console.warn("Storage upload failed, falling back to WebM download:",we);const G=URL.createObjectURL(ie),ue=document.createElement("a");ue.href=G,ue.download=`${n}-snew.webm`,document.body.appendChild(ue),ue.click(),document.body.removeChild(ue),setTimeout(()=>URL.revokeObjectURL(G),1e4),E.info("Baixado como .webm — upload para conversão falhou.");return}const{data:fe}=V.storage.from("temp-videos").getPublicUrl(Ie),xe=fe==null?void 0:fe.publicUrl;if(!xe)throw new Error("Could not get public URL for uploaded video");const{data:$,error:ae}=await V.functions.invoke("convert-video",{body:{videoUrl:xe}});if(V.storage.from("temp-videos").remove([Ie]).catch(()=>{}),ae||$!=null&&$.error){console.warn("CloudConvert failed, falling back to WebM:",ae??($==null?void 0:$.error));const G=URL.createObjectURL(ie),ue=document.createElement("a");ue.href=G,ue.download=`${n}-snew.webm`,document.body.appendChild(ue),ue.click(),document.body.removeChild(ue),setTimeout(()=>URL.revokeObjectURL(G),1e4),E.info("Baixado como .webm — conversão MP4 indisponível.");return}const $e=$.mp4Url,Ft=await(await fetch($e)).blob(),De=URL.createObjectURL(Ft),Ae=document.createElement("a");Ae.href=De,Ae.download=`${n}-snew.mp4`,document.body.appendChild(Ae),Ae.click(),document.body.removeChild(Ae),setTimeout(()=>URL.revokeObjectURL(De),1e4),E.success(`DownloadSimple · ${n}-snew.mp4`)}catch(u){console.error("[downloadVideoCreative]",u);try{E.info("Baixando vídeo original...");const p=await(await fetch(e)).blob(),d=e.includes(".mp4")?"mp4":"webm",g=URL.createObjectURL(p),m=document.createElement("a");m.href=g,m.download=`${n}.${d}`,document.body.appendChild(m),m.click(),document.body.removeChild(m),setTimeout(()=>URL.revokeObjectURL(g),5e3),E.success("DownloadSimple do vídeo original iniciado.")}catch{E.error("Não foi possível baixar o vídeo. Tente novamente.")}}},[Li,y,mn,ee,yo,A,f,ke,Ot,We,Ut,Ne,kt]),vr=a.useCallback(async()=>
60{if(!y||L(y)){E.error("Nenhuma imagem para exportar.");return}if(Li||mn(y)){await Il();return}try{await document.fonts.ready;const e=St(ke);if(e)try{await document.fonts.load(`400 48px ${e}`)}catch{}const o=new Set(Ot.map(U=>U.fontFamily).filter(Boolean));for(const U of o)try{await document.fonts.load(`600 48px ${U}`)}catch{}const n=f.width,i=f.height,l=document.createElement("canvas");l.width=n,l.height=i;const s=l.getContext("2d");if(!s)throw new Error("no context");s.fillStyle="#111111",s.fillRect(0,0,n,i);const u=new Image;u.crossOrigin="anonymous",await new Promise((U,ie)=>{u.onload=()=>U(),u.onerror=()=>ie(new Error("Falha ao carregar imagem")),u.src=y});const r=u.naturalWidth/u.naturalHeight,p=n/i,d=lo==="contain"?"contain":"cover",g=Ro/100,m=lt.x/100,w=lt.y/100;let j,P;d==="cover"?r>p?(P=i*g,j=P*r):(j=n*g,P=j/r):r>p?(j=n*g,P=j/r):(P=i*g,j=P*r);const N=(n-j)*m,pe=(i-P)*w;if(s.drawImage(u,N,pe,j,P),We>0){s.save();const U=Ut.replace("#","").match(/.{2}/g),ie=U?U.map(Ie=>parseInt(Ie,16)).join(","):"0,0,0";if(Ne==="solid")s.fillStyle=`rgba(${ie},${We})`,s.fillRect(0,0,n,i);else{const Ie=Ne,we=s.createLinearGradient(0,Ie==="gradient-bottom"?i:0,0,Ie==="gradient-bottom"?0:i);we.addColorStop(0,`rgba(${ie},${We})`),we.addColorStop(1,`rgba(${ie},0)`),s.fillStyle=we,s.fillRect(0,0,n,i)}s.restore()}for(const U of Ot){if(!U.text||U.text==="...")continue;const ie=Math.max(8,Math.round((U.fontSizeRel??.06)*n)),Ie=Math.round((U.xRel??.06)*n),we=Math.round((U.yRel??.5)*i),fe=Math.round((U.boxWidthRel??.88)*n),xe=(U.fontFamily??e??"Inter").replace(/'/g,"").split(",")[0].trim();s.save(),s.font=`600 ${ie}px "${xe}"`,s.fillStyle=U.color??"#FFFFFF",s.textAlign=U.textAlign??"center",s.textBaseline="top",U.textShadow&&(s.shadowColor="rgba(0,0,0,0.7)",s.shadowBlur=8,s.shadowOffsetX=0,s.shadowOffsetY=2);const $=U.text.split(" "),ae=[];let $e="";for(const De of $){const Ae=$e?`${$e} ${De}`:De;s.measureText(Ae).width<=fe?$e=Ae:($e&&ae.push($e),$e=De)}$e&&ae.push($e);const Se=U.textAlign==="center"?Ie+fe/2:U.textAlign==="right"?Ie+fe:Ie,Ft=ie*1.25;ae.forEach((De,Ae)=>s.fillText(De,Se,we+Ae*Ft)),s.restore()}const he=document.createElement("a");he.download=`${(C==null?void 0:C.title)||"criativo"}-${b||"post"}-snew.png`,he.href=l.toDataURL("image/png"),he.click(),E.success(`DownloadSimple · ${n}×${i}px`)}catch(e){console.error("DownloadSimple error:",e),E.error("Erro ao exportar. Tente novamente.")}},[y,Li,C.title,b,f,ke,Ot,We,Ut,Ne,kt,lt,Ro,lo]),[Yu,wr]=a.useState(!1),[Xi,Xu]=a.useState(""),Ju=e=>{const o=parseInt(e.slice(1,3),16),n=parseInt(e.slice(3,5),16),i=parseInt(e.slice(5,7),16);return`${o}, ${n}, ${i}`},$l=a.useCallback(e=>{const o=Ju(e.overlayColor),n=e.overlayType==="solid"?`background: rgba(${o}, ${e.overlayOpacity});`:{bottom:`background: linear-gradient(to top, rgba(${o}, ${e.overlayOpacity}) 0%, rgba(${o}, ${e.overlayOpacity*.5}) 50%, transparent 100%);`,top:`background: linear-gradient(to bottom, rgba(${o}, ${e.overlayOpacity}) 0%, rgba(${o}, ${e.overlayOpacity*.5}) 50%, transparent 100%);`,full:`background: linear-gradient(to top, rgba(${o}, ${e.overlayOpacity}) 0%, rgba(${o}, ${e.overlayOpacity*.3}) 50%, rgba(${o}, ${e.overlayOpacity}) 100%);`}[e.overlayPosition],i={left:"flex-start",center:"center",right:"flex-end"},l={top:"flex-start",center:"center",bottom:"flex-end"};return`<!DOCTYPE html>
61<html lang="pt-BR">
62<head>
63<meta charset="UTF-8">
64<meta name="viewport" content="width=device-width, initial-scale=1.0">
65<link href="https://fonts.googleapis.com/css2?family=Playfair+Display:wght@700&family=DM+Serif+Display&family=Inter:wght@400;600;700&family=Fraunces:wght@700&family=Space+Grotesk:wght@500;700&family=Cormorant+Garamond:wght@600&family=Raleway:wght@400;700&family=Bebas+Neue&display=swap" rel="stylesheet">
66<style>
67*,*::before,*::after{box-sizing:border-box;margin:0;padding:0}
68.snew-banner{position:relative;width:100%;max-width:1200px;height:628px;overflow:hidden;border-radius:12px;font-family:${e.fontFamily}}
69.snew-banner__bg{position:absolute;inset:0;background-image:url('${e.imageUrl}');background-size:cover;background-position:center;background-repeat:no-repeat}
70.snew-banner__overlay{position:absolute;inset:0;${n}}
71.snew-banner__content{position:absolute;inset:0;padding:48px 56px;display:flex;flex-direction:column;align-items:${i[e.textHAlign]};justify-content:${l[e.textVAlign]};gap:16px;text-align:${e.textHAlign}}
72.snew-banner__heading{font-size:clamp(28px,3.5vw,48px);font-weight:${e.fontWeight};color:${e.textColor};line-height:1.15;letter-spacing:${e.letterSpacing};max-width:640px;text-shadow:0 2px 8px rgba(0,0,0,0.2)}
73.snew-banner__description{font-size:clamp(14px,1.4vw,18px);font-weight:400;color:${e.textColor};opacity:0.9;line-height:1.5;max-width:520px;text-shadow:0 1px 4px rgba(0,0,0,0.2)}
74.snew-banner__cta{display:inline-flex;align-items:center;gap:8px;padding:14px 28px;background:${e.ctaColor};color:${e.ctaTextColor};font-family:inherit;font-size:clamp(14px,1.2vw,16px);font-weight:600;letter-spacing:0.02em;border-radius:999px;border:none;cursor:pointer;text-decoration:none;transition:opacity 0.2s ease,transform 0.15s ease;margin-top:8px}
75.snew-banner__cta:hover{opacity:0.9;transform:translateY(-1px)}
76@media(max-width:768px){.snew-banner{height:auto;min-height:320px}.snew-banner__content{padding:32px}}
77</style>
78</head>
79<body>
80<div class="snew-banner" role="img" aria-label="${e.heading}">
81<div class="snew-banner__bg"></div>
82<div class="snew-banner__overlay"></div>
83<div class="snew-banner__content">
84${e.heading?`<h2 class="snew-banner__heading">${e.heading}</h2>`:""}
85${e.description?`<p class="snew-banner__description">${e.description}</p>`:""}
86${e.cta?`<a href="${e.ctaUrl}" class="snew-banner__cta">${e.cta}</a>`:""}
87</div>
88</div>
89</body>
90</html>`},[]);a.useCallback(()=>{const e=$l({imageUrl:y??"",heading:Kt?ee:"",description:Zt?rt:"",cta:eo?Qe:"",ctaColor:Ht,ctaTextColor:Ht==="#FFFFFF"?"#1A1A1A":"#FFFFFF",ctaRadius:za,textColor:ft,overlayType:Ne,overlayColor:Ut,overlayOpacity:We,overlayPosition:kt,fontFamily:Lr(ke),textHAlign:io,textVAlign:Ao,fontWeight:Aa||"700",letterSpacing:bi||"0em",ctaUrl:"#"});Xu(e),wr(!0)},[y,ee,Kt,rt,Zt,Qe,eo,Ht,za,ft,Ne,Ut,We,kt,ke,io,Ao,Aa,bi,$l]);const Qu=a.useCallback(()=>{const e=new Blob([Xi],{type:"text/html; charset=utf-8"}),o=document.createElement("a");o.href=URL.createObjectURL(e),o.download=`banner-${C.title.toLowerCase().replace(/\s+/g,"-")}.html`,o.click(),URL.revokeObjectURL(o.href),E.success("Banner HTML baixado")},[Xi,C.title]),me=a.useCallback(e=>
90new Promise((o,n)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=()=>{const l=document.createElement("canvas");l.width=i.naturalWidth,l.height=i.naturalHeight,l.getContext("2d").drawImage(i,0,0),o(l.toDataURL("image/jpeg",.92).split(",")[1])},i.onerror=n,i.src=e}),[]),[jr,Zn]=a.useState(!1),[wm,Dl]=a.useState(!1),[jt,Ku]=a.useState(null),Ml=a.useRef(()=>{}),Pl=a.useCallback(()=>{var e,o,n;console.log("[openDocumentPoll] called, ref:",!!te.current,"pushPollMessage:",typeof((e=te.current)==null?void 0:e.pushPollMessage)),(n=(o=te.current)==null?void 0:o.pushPollMessage)==null||n.call(o,{question:"Que tipo de conteúdo você quer criar com essa imagem?",options:[{id:"email",label:"Template de e-mail marketing"},{id:"copy",label:"Copy completo (headline + body + CTA)"},{id:"social",label:"Pacote para redes sociais"},{id:"briefing",label:"Briefing de campanha"},{id:"campaign",label:"Campanha completa (todos os formatos)"}],onSelect:(i,l)=>{Ml.current(i,l)}})},[]),Zu=a.useCallback(async(e,o)=>{var n,i,l,s,u,r,p,d,g;if(!y||L(y)){E.info("Gere uma imagem primeiro para criar o documento.");return}Dl(!0),(i=(n=te.current)==null?void 0:n.pushAssistantMessage)==null||i.call(n,{content:`Gerando ${o.toLowerCase()}...`});try{let m;try{m=await me(y)}catch{}const w=A??((l=c==null?void 0:c.productTypes)==null?void 0:l[0])??"produto",j=(c==null?void 0:c.name)??"",P=(c==null?void 0:c.niche)??"",N=(c==null?void 0:c.audience)??"",pe=(c==null?void 0:c.tone)??"emocional",he=(f==null?void 0:f.sublabel)??"InstagramLogo",U=[`Brand: ${j||"marca"}`,w?`Product: ${w}`:"",P?`Niche: ${P}`:"",N?`Audience: ${N}`:"",`Channel: ${he}`,`Tone: ${pe}`].filter(Boolean).join(" | ");let ie=[],Ie="";if(e==="email"){const we=`You are a professional email marketing copywriter.
91${U}
92The attached image is the hero visual for this email campaign.
93Generate a complete marketing email template in Brazilian Portuguese with this exact JSON structure:
94{
95  "subject": "email subject line (max 50 chars)",
96  "preheader": "preview text (max 90 chars)",
97  "headline": "hero headline that matches the image mood",
98  "subheadline": "supporting line",
99  "body": "2-3 short paragraphs, conversational, benefit-focused",
100  "cta": "button text (max 4 words)",
101  "ps": "optional PS line for urgency or social proof"
102}
103Respond with ONLY the JSON. No markdown, no preamble.`,{data:fe,error:xe}=await V.functions.invoke("gemini-generate",{body:{prompt:we,model:"gemini-2.5-flash",responseType:"text",images:m?[m]:[]}});if(xe)throw xe;const $=JSON.parse(((fe==null?void 0:fe.text)??"").replace(/```json|```/g,"").trim());ie=[{label:"assunto",text:$.subject??""},{label:"pré-header",text:$.preheader??""},{label:"headline",text:$.headline??""},{label:"subtítulo",text:$.subheadline??""},{label:"corpo",text:$.body??""},{label:"botão CTA",text:$.cta??""},{label:"ps",text:$.ps??""}].filter(ae=>ae.text)}else if(e==="copy"){const we=`You are a senior copywriter.
104${U}
105The attached image shows the product/campaign visual.
106Generate a complete copywriting document in Brazilian Portuguese with this exact JSON:
107{
108  "headline": "main headline — bold, benefit-driven, max 8 words",
109  "subheadline": "supporting headline, max 12 words",
110  "body": "3 benefit paragraphs, each 2-3 sentences",
111  "cta_primary": "primary CTA button text",
112  "cta_secondary": "secondary/softer CTA",
113  "cta_urgency": "urgency variant CTA"
114}
115Respond with ONLY the JSON.`,{data:fe,error:xe}=await V.functions.invoke("gemini-generate",{body:{prompt:we,model:"gemini-2.5-flash",responseType:"text",images:m?[m]:[]}});if(xe)throw xe;const $=JSON.parse(((fe==null?void 0:fe.text)??"").replace(/```json|```/g,"").trim());ie=[{label:"headline",text:$.headline??""},{label:"subtítulo",text:$.subheadline??""},{label:"corpo",text:$.body??""},{label:"cta principal",text:$.cta_primary??""},{label:"cta alternativo",text:$.cta_secondary??""},{label:"cta urgência",text:$.cta_urgency??""}].filter(ae=>ae.text)}else if(e==="social"){const we=[{id:"feed",label:"feed instagram",instruction:"max 150 chars + 5 hashtags, emotional"},{id:"stories",label:"stories / reels",instruction:"max 80 chars, punchy, direct 
115CTA"},{id:"linkedin",label:"linkedin",instruction:"professional tone, 200-300 chars, no hashtag spam"},{id:"email",label:"legenda email",instruction:"50-80 chars, subject-line style"}];ie=(await Promise.all(we.map(async xe=>{const{data:$}=await V.functions.invoke("generate-copy",{body:{action:"auto-generate",field:"caption",tone:pe,campaign:{title:w,product:w,channel:xe.instruction,context:`${U}. Platform: ${xe.label}. ${xe.instruction}`,brandContext:pt}}}),ae=($==null?void 0:$.caption)??($==null?void 0:$.heading)??($==null?void 0:$.text)??"";return{label:xe.label,text:ae}}))).filter(xe=>xe.text)}else if(e==="briefing"){const we=`You are a marketing strategist.
116${U}
117The attached image is the key visual for this campaign.
118Generate a complete campaign briefing in Brazilian Portuguese with this exact JSON:
119{
120  "objective": "campaign objective in 1 sentence",
121  "target_audience": "detailed audience description",
122  "key_message": "single most important message",
123  "channels": "recommended channels list",
124  "kpis": "3-4 key performance indicators",
125  "timeline": "suggested 2-week timeline with milestones",
126  "budget_split": "suggested budget % split across channels"
127}
128Respond with ONLY the JSON.`,{data:fe,error:xe}=await V.functions.invoke("gemini-generate",{body:{prompt:we,model:"gemini-2.5-flash",responseType:"text",images:m?[m]:[]}});if(xe)throw xe;const $=JSON.parse(((fe==null?void 0:fe.text)??"").replace(/```json|```/g,"").trim());ie=[{label:"objetivo",text:$.objective??""},{label:"público-alvo",text:$.target_audience??""},{label:"mensagem-chave",text:$.key_message??""},{label:"canais",text:$.channels??""},{label:"kpis",text:$.kpis??""},{label:"cronograma",text:$.timeline??""},{label:"distribuição budget",text:$.budget_split??""}].filter(ae=>ae.text)}else if(e==="campaign"){(u=(s=te.current)==null?void 0:s.pushAssistantMessage)==null||u.call(s,{content:"Gerando campanha completa (e-mail + copy + social)..."});const[we,fe,xe]=await Promise.all([V.functions.invoke("gemini-generate",{body:{prompt:`Generate a marketing email template for ${w} from ${j}. ${U}. Return JSON: { subject, headline, body, cta }. Only JSON.`,model:"gemini-2.5-flash",responseType:"text",images:m?[m]:[]}}),V.functions.invoke("gemini-generate",{body:{prompt:`Generate complete copy for ${w} from ${j}. ${U}. Return JSON: { headline, body, cta_primary }. Only JSON.`,model:"gemini-2.5-flash",responseType:"text",images:m?[m]:[]}}),V.functions.invoke("generate-copy",{body:{action:"auto-generate",field:"full",tone:pe,campaign:{title:`Campanha ${w}`,product:w,channel:"InstagramLogo Feed",context:U,brandContext:pt}}})]),$=(()=>{var Se;try{return JSON.parse((((Se=we.data)==null?void 0:Se.text)??"").replace(/```json|```/g,"").trim())}catch{return{}}})(),ae=(()=>{var Se;try{return JSON.parse((((Se=fe.data)==null?void 0:Se.text)??"").replace(/```json|```/g,"").trim())}catch{return{}}})(),$e=xe.data??{};ie=[{label:"e-mail · assunto",text:$.subject??""},{label:"e-mail · headline",text:$.headline??""},{label:"e-mail · corpo",text:$.body??""},{label:"e-mail · cta",text:$.cta??""},{label:"copy · headline",text:ae.headline??""},{label:"copy · corpo",text:ae.body??""},{label:"copy · cta",text:ae.cta_primary??""},{label:"social · feed",text:$e.heading??$e.description??""},{label:"social · cta",text:$e.cta??""}].filter(Se=>Se.text)}Ie=ie.map(we=>`${we.label.toUpperCase()}
129${we.text}`).join(`
130
131`),Ku({type:e,imageUrl:y,sections:ie,rawText:Ie}),Zn(!0),(p=(r=te.current)==null?void 0:r.pushAssistantMessage)==null||p.call(r,{content:`${o} criado com base na imagem. Veja no painel ao lado.`})}catch(m){console.error("generateDocument error:",m),(g=(d=te.current)==null?void 0:d.pushAssistantMessage)==null||g.call(d,{content:"Erro ao gerar. Tente novamente."})}finally{Dl(!1)}},[y,L,me,A,c,pt,f,V]);Ml.current=Zu;const ei=a.useRef(null),Nl=a.useRef(""),Wl=a.useCallback(async e=>{if(!e||L(e))return"";try{const o=await me(e),{data:n,error:i}=await V.functions.invoke("gemini-generate",{body:{prompt:`Analyze this product image and respond ONLY with a JSON object, no other text:
132{
133  "product": "what product is shown (be specific)",
134  "mood": "emotional tone of the image in 3 words",
135  "style": "visual style (e.g. pop illustration, lifestyle, studio, editorial)",
136  "colors": "dominant colors",
137  "context": "one sentence describing what makes this image unique and what feeling it conveys"
138}`,model:"gemini-2.5-flash",images:[o],responseType:"text"}});if(i||!(n!=null&&n.text))return"";const l=n.text.match(/\{[\s\S]*\}/);if(!l)return"";const s=JSON.parse(l[0]),u=`Product shown: ${s.product}. Visual mood: ${s.mood}. Style: ${s.style}. Colors: ${s.colors}. Context: ${s.context}`;return _t.current=u,u}catch{return""}},[L,me]);a.useEffect(()=>{if(!y||L(y)){ss(""),_t.current="";return}if(Nl.current===y)return;ei.current&&clearTimeout(ei.current);let e=!1;return ei.current=setTimeout(()=>{e||(Nl.current=y,ls(!0),Wl(y).then(o=>{e||(ss(o),_t.current=o,ls(!1))}))},2e3),()=>{e=!0,ei.current&&clearTimeout(ei.current)}},[y,Wl,L]);const Ce=a.useCallback(async(e,o=1,n)=>{var i,l,s,u,r;ys(!0),$n(null),co(!0),ut(`Gerando com ${sn.name}...`);try{const p=n!==void 0?n:S,d=A??"the product",g=(v==null?void 0:v.description)??(v==null?void 0:v.name)??"";let m,w;
138if((p==null?void 0:p.id)==="material-detail"){const Y=y;if(Y&&!L(Y))try{ut("Analisando produto..."),w=await me(Y)}catch{}m=`You are given a product photograph. Transform it into an extreme macro detail shot.
139DO NOT generate a new product. Use the exact product shown in the reference image.
140Zoom into the most visually interesting detail of the product in the reference image:
141a button, texture, edge, surface pattern, clasp, label, stitching, or material grain.
142The detail should fill 85% of the frame.
143Shot from a diagonal angle with soft side lighting from the left.
144f/2.0 aperture: razor-sharp focus on the chosen detail, everything else in soft bokeh.
145Background: same neutral tone as the original image, softly blurred.
146Color grade: slightly desaturated, matte, cool-neutral — preserve the product's original colors accurately.
147No people. No props. No lifestyle elements.
148The output must feel like a macro photography detail of the exact same product.`,ut(`Gerando com ${sn.name}...`)}else if((p==null?void 0:p.id)==="commercial-product"){const Y=(v==null?void 0:v.image)??(v==null?void 0:v.imageUrl);let J;if(Y)try{J=await me(Y)}catch{}ut("Analisando produto..."),m=await nl({productName:d,productDescription:g,brandName:(c==null?void 0:c.name)??h.campaignTitle??"",imageBase64:J}),ut(`Gerando com ${sn.name}...`)}else if(p!=null&&p.buildPrompt){if(m=p.buildPrompt({productName:d,productDescription:g,brandName:(c==null?void 0:c.name)??h.campaignTitle??"",niche:(c==null?void 0:c.niche)??"",audience:(c==null?void 0:c.audience)??"",tone:(c==null?void 0:c.tone)??"",modelGender:((i=c==null?void 0:c.modelProfile)==null?void 0:i.gender)??"",modelAge:((l=c==null?void 0:c.modelProfile)==null?void 0:l.ageRange)??"",modelPose:((s=c==null?void 0:c.modelProfile)==null?void 0:s.pose)??"",visualConcept:(c==null?void 0:c.visualConcept)??"",shootingStyle:(c==null?void 0:c.shootingStyle)??"",lightingMood:(c==null?void 0:c.lightingMood)??"",colorMood:(c==null?void 0:c.colorMood)??"",context:p.id==="product-attributes"?(f==null?void 0:f.id)??"1:1":e}),p.id==="product-attributes"){const Y=(v==null?void 0:v.attributes)??(v==null?void 0:v.features)??[];Y.length>0&&(m+=`
149Product features to annotate: ${Y.map(J=>J.label||J).join(", ")}.`)}}else m=(p==null?void 0:p.promptBase)??gg;const j=p!=null&&p.buildPrompt?"":`. Style: ${m}`,P=p!=null&&p.buildPrompt?m:"",N=` Avoid: ${(p==null?void 0:p.negativePrompt)??pg}.`,he=!!(Va&&(Eo||v)),U=he?` CRITICAL PRODUCT FIDELITY — The first reference image shows the EXACT product that MUST appear in this scene. Follow these rules strictly:
1501. COLOR: Use the exact color(s) shown — do not shift hue, saturation, or change colorway.
1512. SILHOUETTE: Preserve the exact shape — neckline, sleeve length (short/long/sleeveless), leg length, overall silhouette.
1523. CLOSURES: Replicate exactly — if the product has buttons, show them in the same position and count; if it has no buttons, do not add any; preserve zippers, snaps, ties as shown.
1534. FABRIC & TEXTURE: Preserve the exact material appearance — knit pattern, weave, ribbing, cable pattern, embroidery, print.
1545. DETAILS: Keep all decorative elements — pockets, collars, cuffs, straps, labels, embroidery exactly as shown.
1556. DO NOT substitute, replace, reimagine, or "improve" the product. The reference image is ground truth.`:"",ie=yd(),Ie=Zr&&ee?"Compose this scene leaving clear empty space in the lower 30% of the image for text overlay. The lower portion should have a clean background or dark gradient suitable for white text. ":"",we=[],fe="",xe=Le.length>0?" Use the uploaded reference images as visual style guidance — adapt their composition, lighting, and mood to the scene.":"",$=(()=>{const Y=e.toLowerCase(),J=/trocar|substituir|trocar por|mudar para|usar|colocar|mostrar|quero ver|lata|garrafa|tênis|roupa|camisa|vestido|bolsa/i,at=(A??"").toLowerCase().slice(0,8);return J.test(Y)&&(!at||!Y.includes(at))})(),ae=y&&!L(y)?$?`
156Style reference: apply the same lighting quality, color treatment and photographic style as the reference image. But generate a COMPLETELY NEW scene with the new subject described. Do NOT keep any elements from the previous image.`:`
157Canvas reference: maintain the same product, composition quality and overall aesthetic. Apply only the requested change.`:"",$e="IMPORTANT: NO text, NO letters, NO words, NO typography overlay in the image. Pure photography only. ",Se=P?`${U}${$e}${Ie}${P}. User intent: ${e}${xe}${ae}${fe}${rn}${ie?`
158
159`+ie:""}`:`${U}${$e}${Ie}${e}${j}${xe}${ae}${fe}${rn}${ie?`
160
161`+ie:""}`,Ft=ma&&ie?"gemini-3.1-flash-image-preview":sn.id,De=[...we],Ae=la();if((u=Ae==null?void 0:Ae.brandReferences)!=null&&u.length)try{const Y=await dg(Ae.brandReferences,3);for(const J of Y)De.unshift(J)}catch{}if(w&&De.unshift(w),(r=p==null?void 0:p.styleReferences)!=null&&r.length)for(const Y of p.styleReferences)Y.base64&&De.unshift(Y.base64);for(const Y of Le)Y.base64&&De.push(Y.base64);if(Va){const Y=(Eo==null?void 0:Eo.image)||(Eo==null?void 0:Eo.imageUrl)||(v==null?void 0:v.image);if(Y)try{const J=await me(Y);De.unshift(J)}catch(J){console.warn("Could not convert product image to base64:",J)}}if(y&&!L(y))try{const Y=await me(y);De.push(Y)}catch(Y){console.warn("Could not convert canvas image to base64:",Y)}const G=ra[f.id]??"1:1",ue={prompt:Se,model:Ft,aspectRatio:G,negativePrompt:["text in image","letters","words","typography overlay","vertical text","diagonal text","headline overlay","watermark","logo overlay","signature","chrome","glossy surface","neon glow","holographic","glitter","illustration","watercolor","cartoon","3d render","CGI","vector art","oversaturated","stock photo smile",...he?["different product","wrong color","wrong sleeve length","added buttons","removed buttons","wrong neckline","wrong pattern","wrong silhouette","reimagined product","similar product","inspired by","variation of"]:[],...p!=null&&p.negativePrompt?p.negativePrompt.split(",").map(Y=>Y.trim()):[]].join(", "),personGeneration:(()=>{const Y=/baby|beb[êe]|crian[çc]a|child|infant|model[oa]?|pessoa|mulher|homem|woman|man|menin[oa]|boy|girl|family|fam[ií]lia|portrait|advertising-portrait/i,J=["product-lifestyle","warm-lifestyle","bold-vibrant","pop-illustration","fashion-on-model","campaign-editorial","product-attributes","advertising-portrait"].includes((p==null?void 0:p.id)??""),at=Y.test(e)||Y.test(Se);return J||at?"allow_adult":"dont_allow"})()};De.length>0&&(ue.images=De);const{data:ze,error:vn}=await V.functions.invoke("gemini-generate",{body:ue});if(vn)throw vn;if(ze!=null&&ze.fallback||ze!=null&&ze.error)throw new Error((ze==null?void 0:ze.error)||"Falha ao gerar imagem. Tente novamente.");const qe=ze==null?void 0:ze.imageUrl;if(qe){Gt(qe),ne(qe);const Y=`g-${Date.now()}`;if(Nd(Oe=>[...Oe,{id:Y,url:qe}]),Wd(Y),!ee||ee===""||ee==="main-text")try{const{data:Oe}=await V.functions.invoke("generate-copy",{body:{action:"auto-generate",field:"full",tone:"emocional",campaign:{title:e.slice(0,120),product:A??"",channel:"InstagramLogo Stories — copy curta, emocional",context:`Imagem gerada com prompt: ${e.slice(0,200)}`,brandContext:pt}}});Oe!=null&&Oe.heading&&(jo(Oe.heading),be(ea=>ea.map(ta=>ta.id==="main-text"?{...ta,text:Oe.heading}:ta)),Oe.description&&Fo(Oe.description),Oe.cta&&So(Oe.cta))}catch(Oe){console.warn("Auto copy generation failed:",Oe)}if(et("cover"),tt(100),Ye({x:50,y:50}),es(ma),It(0),ko(!1),Sn(!1),kn(!1),be([]),He(null),o>1){const Oe=`var-${Date.now()}`;Pa(ea=>[...ea,{id:Oe,url:qe,label:`Variação ${ea.length+1}`}]),Na(Oe),Bd(!0)}else Pa([]),Na(null);E.success(o>1?"Variação gerada!":"Imagem gerada!"),Ue(qe);const J=A||(v==null?void 0:v.name)||"",at=(p==null?void 0:p.name)??"editorial photo",Rt=(f==null?void 0:f.sublabel)??"stories";if(!xn){const Oe=J?`${at.toLowerCase()} · ${J}
161`:at.toLowerCase();qi(Oe)}const $r={"ecommerce-photography":[`${J?`${J} em e-commerce photography`:"foto produto"} — fundo limpo, luz uniforme.`,`${J||"produto"} isolado com luz de estúdio. pronto para loja.`],"product-lifestyle":[`${J||"produto"} em cena de uso real. lifestyle aplicado.`,`${J||"produto"} no mundo real — lifestyle natural.`],"fashion-on-model":[`${J||"peça"} vestida — editorial fashion aplicado.`,`${J?`${J} em modelo`:"editorial com modelo"} — foto editorial.`],"flat-lay-editorial":[`${J||"produto"} em flat lay editorial. composição limpa.`]},Dr=(p==null?void 0:p.id)??"",wo=$r[Dr]??[`${J?`${J} · `:""}${at.toLowerCase()} aplicado.`,`gerado com estilo ${at.toLowerCase()}${J?` para ${J}`:""}.`],wn=wo[fn.length%wo.length],jp=J?`${J} · ${Rt}`:`${at.toLowerCase()} · ${Rt}`;return tl(!1),Po("done"),Nt("image_generated",jp,wn,[],qe),qe}else return $n("Não foi possível gerar a imagem"),null}catch(p){return console.error("Gemini error:",p),$n("Erro ao gerar imagem. Tente novamente."),null}finally{ys(!1),co(!1),ut(""),Dn(!1),tn("")}},[b,sn.id,Va,v,me,S,ma,ed,td,od,nd,id,ee,rt,Qe,ke,ft,Ue,Nt,Le,nl]),Fr=a.useCallback(async e=>{var s,u;const o=(A==null?void 0:A.trim())??"",n=(v==null?void 0:v.description)??"";if(!(e!=null&&e.trim())&&!de.trim()&&!o){E.info("Selecione um produto antes de gerar a imagem.");return}const i=(e==null?void 0:e.trim())||de.trim();let l;if(S!=null&&S.buildPrompt){const r=S.buildPrompt({productName:o||"the product",productDescription:n,brandName:(c==null?void 0:c.name)??h.campaignTitle??"",niche:(c==null?void 0:c.niche)??"",audience:(c==null?void 0:c.audience)??"",tone:(c==null?void 0:c.tone)??"",modelGender:((s=c==null?void 0:c.modelProfile)==null?void 0:s.gender)??"",modelAge:((u=c==null?void 0:c.modelProfile)==null?void 0:u.ageRange)??"",context:(f==null?void 0:f.id)??"1:1"});i&&!r.toLowerCase().includes(i.toLowerCase().slice(0,20))?l=`${r}. ${i}`:l=r}else if(S!=null&&S.promptBase){const r=o?`${o}, ${S.promptBase}`:S.promptBase;l=i?`${r}. ${i}`:r}else if(i)o&&!i.toLowerCase().includes(o.toLowerCase())?l=`${o}, ${i}`:l=i;else{if(!o){E.info("Descreva a imagem ou selecione um produto.");return}l=o}if(!l.trim()){E.info("Selecione um produto ou descreva o que gerar.");return}await Ce(l)},[de,go,S,v,A,h,f,Ce]);a.useEffect(()=>{Wo.current=Ce},[Ce]);const Bl=a.useCallback(async(e,o,n="pt")=>{const i={pt:"Write ALL labels and sublabels in Brazilian Portuguese only.",en:"Write ALL labels and sublabels in English only.",es:"Write ALL labels and sublabels in Spanish only."}[n],l=`You are a product copywriter for e-commerce.
162Given this product: "${e}". ${o?`Description: ${o}`:""}
163
164Extract exactly 3 to 4 key product features that would appear as callout annotations on a product image.
165Each feature needs a short label (2-4 words max) and an anchor position on the image.
166
167${i}
168
169Respond ONLY with valid JSON, no other text:
170{
171  "features": [
172    {
173      "id": "f1",
174      "label": "Algodao Premium",
175      "sublabel": "Toque macio",
176      "anchor": { "x": 0.65, "y": 0.55 },
177      "labelSide": "right"
178    }
179  ]
180}
181
182Rules for anchor positions:
183- Spread features around the product — top, middle, bottom areas
184- x between 0.15 and 0.85, y between 0.15 and 0.85
185- Alternate labelSide: right for x > 0.5, left for x < 0.5
186- Features should point to distinct parts of the product`,{data:s,error:u}=await V.functions.invoke("gemini-generate",{body:{prompt:l,model:"gemini-3.1-flash-image-preview",responseType:"text"}});if(u)throw u;try{const p=((s==null?void 0:s.text)??"").match(/\{[\s\S]*\}/);if(!p)throw new Error("No JSON found");return JSON.parse(p[0]).features??[]}catch{return[{id:"f1",label:"Premium material",anchor:{x:.7,y:.35},labelSide:"right"},{id:"f2",label:"Adjustable strap",anchor:{x:.3,y:.25},labelSide:"left"},{id:"f3",label:"Spacious interior",anchor:{x:.6,y:.65},labelSide:"right"}]}},[]);a.useCallback(async()=>{const e=A??"product",o=(v==null?void 0:v.description)??"";As(!0),Ua([]);try{const n=await Bl(e,o);Ua(n);const i=`Studio product photography of ${e}.
187Pure white or very light grey seamless background.
188Product centered, perfectly sharp, professional commercial photography.
189Shot from slight 3/4 angle to show depth and multiple surfaces.
190Soft studio lighting, no harsh shadows, product fills 65% of frame.
191${o?`Product details: ${o}.`:""}
192High resolution, retail-ready, multiple product details visible.`;await Ce(i),Cs(!0)}catch(n){console.error("Features generation error:",n),E.error("Erro ao gerar features. Tente novamente.")}finally{As(!1)}},[v,A,Bl,Ce]);const ep=a.useCallback(()=>{let u=[...fn];try{const N=JSON.parse(localStorage.getItem(ug())??"[]"),pe=new Set(u.map(he=>he.id));for(const he of N)pe.has(he.id)||(u.push(he),pe.add(he.id))}catch{}const r=u.filter(N=>N.imageUrl&&N.imageUrl.length>10&&!N.imageUrl.includes("placeholder")&&!N.imageUrl.includes("picsum.photos")||N.type==="document").slice(0,30).map((N,pe)=>({id:N.id,imageUrl:N.imageUrl??"",x:pe%3*244,y:Math.floor(pe/3)*364,width:220,height:300,label:N.documentTitle??N.heading??N.channel??"",channel:N.channel??"",type:N.type??"image",documentExcerpt:N.documentExcerpt??"",documentMarkdown:N.documentMarkdown??""}));Pi(r);const p=Wn.current,d=(p==null?void 0:p.offsetWidth)??window.innerWidth,g=(p==null?void 0:p.offsetHeight)??window.innerHeight,m=Math.min(r.length,3),w=Math.ceil(r.length/3),j=m*220+Math.max(0,m-1)*24,P=w*340+Math.max(0,w-1)*24;Mi({x:d/2-j/2,y:g/2-P/2}),Pn(1),Qs(!0)},[fn]),Sr=a.useCallback(()=>Qs(!1),[]);a.useEffect(()=>{se&&ep(),F==="luma"&&Ci(!0),F==="higgs"&&Ai(!0)},[]);const tp=a.useCallback(e=>{e.target.closest("[data-board-asset]")||(e.preventDefault(),ol(!0),Nn.current={x:e.clientX,y:e.clientY,ox:Mt.x,oy:Mt.y})},[Mt]),op=a.useCallback(e=>{if(sr&&!Ln.current){Mi({x:Nn.current.ox+e.clientX-Nn.current.x,y:Nn.current.oy+e.clientY-Nn.current.y});return}if(Ln.current){const{id:o,startX:n,startY:i,ax:l,ay:s}=Ln.current;Pi(u=>u.map(r=>r.id===o?{...r,x:l+(e.clientX-n)/Ge,y:s+(e.clientY-i)/Ge}:r))}},[sr,Ge]),Ll=a.useCallback(()=>{ol(!1),Ln.current=null,Pi(e=>e.map(o=>({...o,isDragging:!1})))},[]),np=a.useCallback(e=>{e.preventDefault();const o=e.deltaY>0?.9:1.1,n=Math.min(Math.max(Ge*o,.2),3),i=Wn.current.getBoundingClientRect(),l=e.clientX-i.left,s=e.clientY-i.top,u=(l-Mt.x)/Ge,r=(s-Mt.y)/Ge;Pn(n),Mi({x:l-u*n,y:s-r*n})},[Ge,Mt]),ip=a.useCallback((e,o)=>{e.stopPropagation();const n=Bn.find(i=>i.id===o);n&&(Ln.current={id:o,startX:e.clientX,startY:e.clientY,ax:n.x,ay:n.y},Pi(i=>i.map(l=>l.id===o?{...l,isDragging:!0}:l)))},[Bn]),Ol=a.useCallback(e=>{ne(e.imageUrl),Sr()},[Sr]),_l=a.useCallback(async()=>
192{if(!(!Yo.trim()||!y)){os(!0);try{const e=Et||y,o=e.startsWith("data:")?e.split(",")[1]:await me(e),{data:n,error:i}=await V.functions.invoke("gemini-generate",{body:{prompt:`Pencil this image: ${Yo}.
193Keep everything else exactly the same — only apply the requested change.
194Maintain the same composition, lighting quality, and overall style.
195Output a high quality image.`,model:"gemini-3.1-flash-image-preview",images:[o]}});if(i)throw i;if(n!=null&&n.fallback||n!=null&&n.error)throw new Error((n==null?void 0:n.error)||"Falha ao editar imagem");const l=n==null?void 0:n.imageUrl;if(!l)throw new Error("Sem imagem na resposta");zn(l),An(""),E.success("Edição aplicada — clique Salvar para confirmar")}catch(e){console.error("Pencil error:",e),E.error("Erro ao editar imagem. Tente novamente.")}finally{os(!1)}}},[Yo,y,Et,me]),ap=a.useCallback(()=>{Et&&(ne(Et),Cn(!1),zn(null),An(""),Ue(Et),E.success("Imagem editada salva!"),Nt("image_edited","Edição aplicada ","Ficou melhor. Quer que eu analise se vai converter bem?",[],Et))},[Et,Ue]),rp=a.useCallback(()=>{Cn(!1),zn(null),An("")},[]),sp=a.useCallback(async()=>{if(y){ts(!0),co(!0),ut("Expandindo fundo com IA...");try{const e=await me(y),o=f.id,n=`Expand and extend this image to fill a ${o} format canvas naturally. 
196Seamlessly continue the background, environment, lighting, and atmosphere beyond the original image borders. 
197The original subject must remain exactly as-is in the center. 
198Generate realistic, coherent surroundings that match the existing scene perfectly — same lighting, color palette, depth of field, and style. 
199Output a complete ${o} image with no seams, no borders, no artifacts.`,{data:i,error:l}=await V.functions.invoke("gemini-generate",{body:{prompt:n,model:"gemini-3.1-flash-image-preview",images:[e]}});if(l)throw l;const s=i==null?void 0:i.imageUrl;if(!s)throw new Error("Sem imagem na resposta");ne(s),Gt(s),et("cover"),tt(100),Ye({x:50,y:50}),Ue(s),It(0),ko(!1),Sn(!1),kn(!1),E.success("Fundo expandido!"),Nt("image_edited","Fundo expandido ","IA expandiu o ambiente da imagem. Quer ajustar o posicionamento?",[],s)}catch(e){console.error("Expand background error:",e),E.error("Erro ao expandir fundo. Tente novamente.")}finally{ts(!1),co(!1),ut("")}}},[y,f,me,Ue,Nt]);a.useCallback(async()=>{if(Ti){co(!0),ut("Combinando imagens..."),$n(null);try{const e=async g=>g.startsWith("data:")?g:`data:image/jpeg;base64,${await me(g)}`,o=await e(Ti),n=Ya?await e(Ya):null,i=eu[Rs],l=Xa.trim()?`. ${Xa.trim()}`:"";let s;
199n?s=`Combine the objects from the first image and the second image into a single photorealistic scene without altering them. Place them in a ${i}. Unify lighting, tone, and depth-of-field across both. Blend naturally with ambient shadows, subtle grain, minimal lens effects, RAW-style grading, and final sharpening${l}. High quality commercial photography.`:s=`Create a professional product photography mockup of this product. Place it in a ${i}. Photorealistic, commercial grade. Maintain the exact product appearance${l}. RAW-style grading, subtle shadows, high detail.`;const u=[o];n&&u.push(n);const{data:r,error:p}=await V.functions.invoke("gemini-generate",{body:{prompt:s,model:"gemini-3.1-flash-image-preview",images:u}});if(p)throw p;const d=r==null?void 0:r.imageUrl;if(d)ne(d),Gt(d),Io(!1),Ue(d),E.success("Imagem combinada gerada!");else throw new Error("No image returned")}catch(e){console.error("Combine error:",e),$n("Não foi possível combinar as imagens. Tente novamente.")}finally{co(!1),ut("")}}},[Ti,Ya,Rs,Xa,me,Ue]),a.useCallback(()=>{Si&&(ne(Si),Gt(null),E.success("Imagem aplicada ao canvas"))},[Si]);const kr=a.useCallback(async()=>{Al(!0),br(null);let e=null;if(C.date){const o=Math.ceil((new Date(C.date).getTime()-Date.now())/864e5);e=o>0?o:null}try{const{data:o,error:n}=await V.functions.invoke("conversion-scanner",{body:{heading:ee,description:rt,cta:Qe,channel:b,styleId:st,textColor:ft,ctaColor:Ht,overlayOpacity:We,font:ke,textHAlign:io,textVAlign:Ao,hasImage:!!y,product:A,productCategory:wt.productCategory,ticketAverage:wt.ticketAverage,campaignTitle:C.title,campaignObjective:wt.campaignObjective,audience:wt.audience,placement:b.includes("stories")||b.includes("reels")?"stories":"feed",isPromotional:wt.isPromotional,daysToEvent:e}});if(n)throw n;br(o)}catch(o){console.error("Scan error:",o),E.error("Erro ao analisar criativo.")}finally{Al(!1)}},[h,b,ee,rt,Qe,ft,Ht,ke,io,Ao,y,wt,C,st,v]),[Hl,Ji]=a.useState([]),lp=a.useCallback(async()=>{if(!(re!=null&&re.improveInstructions))return;Rl(!0);const e=re.score,o=re.improveInstructions,n=[{label:"Aplicando textos sugeridos",done:!1,active:!1},{label:"Ajustando cores e overlay",done:!1,active:!1},...o.imagePrompt?[{label:"Gerando nova imagem",done:!1,active:!1}]:[],{label:"Reanalisando criativo",done:!1,active:!1}];Ji([...n]);const i=(l,s)=>{Ji(u=>u.map((r,p)=>p===l?{...r,active:s==="active",done:s==="done"}:p<l?{...r,active:!1,done:!0}:r))};try{i(0,"active"),o.heading&&jo(o.heading),o.description&&Fo(o.description),o.cta&&So(o.cta),await new Promise(u=>setTimeout(u,400)),i(0,"done"),i(1,"active"),o.textColor&&zo(o.textColor),o.ctaColor&&fi(o.ctaColor),o.overlayOpacity!=null&&It(o.overlayOpacity),o.font&&ao(o.font),o.textHAlign&&ka(o.textHAlign),o.textVAlign&&Sa(o.textVAlign),await new Promise(u=>setTimeout(u,400)),i(1,"done");let l=2;if(o.imagePrompt){i(l,"active"),At(o.imagePrompt);try{await Ce(o.imagePrompt)}catch(u){console.error("Auto-improve image error:",u)}i(l,"done"),l++}i(l,"active"),Ue();const s=[];o.heading&&s.push(`Heading: "${o.heading}"`),o.cta&&s.push(`CTA: "${o.cta}"`),o.ctaColor&&s.push(`Cor do CTA: ${o.ctaColor}`),o.overlayOpacity!=null&&s.push(`Overlay: ${Math.round(o.overlayOpacity*100)}%`),o.imagePrompt&&s.push("Nova imagem gerada"),E.success(`${s.length} melhoria${s.length>1?"s":""} aplicada${s.length>1?"s":""}! Score anterior: ${e}/100`),await new Promise(u=>setTimeout(u,600)),i(l,"done"),setTimeout(()=>{Ji([]),kr()},800)}catch(l){console.error("Auto-improve error:",l),Ji([])}finally{Rl(!1)}},[re,Ce,kr,Ue]),Cr=a.useCallback(async()=>{Ss(!0),uo(!1),co(!0),ut("Criando storytelling...");try{const{data:e,error:o}=await V.functions.invoke("generate-carousel",{body:{campaignTitle:C.title,product:A,heading:ee,description:rt,cta:Qe,slideCountMode:qt,slideCount:on,brandContext:pt}});if(o)throw o;const n=(e==null?void 0:e.slides)||[],i=n.map((s,u)=>({id:s.id||`slide-${u+1}`,heading:s.heading,description:s.description,cta:s.cta||(s.role==="cta"?Qe:null),image:y,product:A,role:s.role}));Ct(i),To(0),E.success(`Carrossel com ${i.length} slides gerado!`),ut("Gerando imagens dos slides...");const l=3;for(let s=0;s<n.length;s+=l){const u=n.slice(s,s+l),r=await Promise.allSettled(u.map(async(p,d)=>{const g=s+d;try{const{data:m}=await V.functions.invoke("gemini-generate",{body:{prompt:`${p.imagePrompt}, ${A}, high quality commercial photography`,model:"gemini-2.5-flash-image"}});m!=null&&m.imageUrl&&Ct(w=>w.map((j,P)=>P===g?{...j,image:m.imageUrl}:j))}catch(m){console.warn(`Slide ${g+1} image failed:`,m)}}))}}catch(e){console.error("Carousel generation error:",e),E.error("Erro ao gerar carrossel. Tente novamente.")}finally{Ss(!1),co(!1),ut("")}},[h,ee,rt,Qe,qt,on,y]),Ar=a.useCallback((e,o,n)=>{Ct(i=>i.map((l,s)=>s===e?{...l,[o]:n}:l))}
199,[]),[zr,Qi]=a.useState(!1),[cp,Ki]=a.useState(!1),[ti,Rr]=a.useState(""),[Tr,Ul]=a.useState(!1),[Gl,Vl]=a.useState(!1),[Zi,ql]=a.useState("gemini-3.1-flash-image-preview"),[Yl,Er]=a.useState(!1),[jm,Fm]=a.useState(!1),_o=Go.find(e=>e.id===Zi)||Go[1];a.useEffect(()=>{var e;zr&&H[M]&&(Rr(((e=H[M])==null?void 0:e.imagePrompt)||`${A}, high quality commercial photography`),ql("gemini-3.1-flash-image-preview"),Er(!1),Ki(!1))},[zr,M]);const dp=a.useCallback(e=>{Ct(o=>o.map((n,i)=>i===M?{...n,image:e.image,product:e.name}:n)),Ki(!1),Qi(!1)},[M]),up=a.useCallback(async()=>{if(ti.trim()){Vl(!0),Ct(e=>e.map((o,n)=>n===M?{...o,image:void 0}:o));try{const{data:e,error:o}=await V.functions.invoke("gemini-generate",{body:{prompt:`${ti}, ${A}, high quality commercial photography`,model:_o.id}});if(o)throw o;e!=null&&e.imageUrl&&(Ct(n=>n.map((i,l)=>l===M?{...i,image:e.imageUrl}:i)),Qi(!1),E.success("Imagem do slide gerada!"))}catch(e){console.error("Slide image error:",e),Ct(o=>o.map((n,i)=>i===M?{...n,image:"error"}:n)),E.error("Erro ao gerar imagem do slide")}finally{Vl(!1)}}},[ti,M,_o,A]),pp={position:"absolute",left:0,right:0,padding:28,zIndex:2,display:"flex",flexDirection:"column",textAlign:io,...Ao==="top"?{top:0}:Ao==="center"?{top:"50%",transform:"translateY(-50%)"}:{bottom:0}},gp=a.useCallback(async(e,o)=>{le(e),Pe(null);try{const n=e==="heading"?ee:e==="description"?rt:Qe,i=A??"",{data:l,error:s}=await V.functions.invoke("generate-copy",{body:{action:"regenerate",field:e,currentValue:n,tone:o,campaign:{title:de||(C==null?void 0:C.title)||(v==null?void 0:v.name)||"campanha",product:i,visualContext:_t.current,imageStyle:(S==null?void 0:S.name)??"",channel:b??"",context:de?`A imagem gerada mostra: ${de}`:void 0,brandContext:pt}}});if(s)throw s;l!=null&&l.text&&(e==="heading"?jo(l.text):e==="description"?Fo(l.text):e==="cta"&&So(l.text))}catch(n){console.error("Toolbar generate error:",n),E.error("Erro ao gerar texto")}finally{le(null)}},[ee,rt,Qe,C.title,A]),mp=a.useCallback(async e=>{var o;le(e);try{const{data:n,error:i}=await V.functions.invoke("generate-copy",{body:{action:"versions",field:e,tone:"direto",campaign:{title:(de==null?void 0:de.slice(0,120))||yo||(v==null?void 0:v.name)||"criativo",product:A??"",visualContext:_t.current,imageStyle:(S==null?void 0:S.name)??"",context:de?`Imagem gerada com: ${de.slice(0,200)}`:void 0,brandContext:pt},count:4}});if(i)throw i;(o=n==null?void 0:n.versions)!=null&&o[0]&&(e==="heading"?jo(n.versions[0]):e==="description"?Fo(n.versions[0]):e==="cta"&&So(n.versions[0]),E.success("Versão aplicada"))}catch(n){console.error("Versions error:",n),E.error("Erro ao gerar versões")}finally{le(null)}},[C.title,A]),Ir=a.useCallback(()=>{T(null),Z(null),Pe(null),He(null),to(null),oo(null),no(null),pi(null),Xo(null),Jo(null),Qo(null),gr()},[]),hp=a.useCallback(async()=>{var e,o;if(!(!y||L(y))){Fn(!0);try{const n=await me(y),{data:i,error:l}=await V.functions.invoke("gemini-generate",{body:{prompt:'Analyze this image and describe its visual mood in 3-5 keywords in English, focusing on: lighting quality, color temperature, emotional tone, scene type, and style. Examples of keywords: "warm", "lifestyle", "golden hour", "editorial", "dark", "bold", "clean", "aesthetic", "candid", "luxury". Respond with ONLY a JSON object in this exact format: {"mood": ["keyword1", "keyword2", "keyword3"]}. No other text.',model:"gemini-3.1-flash-image-preview",images:[n],responseType:"text"}});if(l)throw l;let s=[];try{const m=((i==null?void 0:i.text)??"").match(/\{[\s\S]*\}/);m&&(s=JSON.parse(m[0]).mood??[])}catch{s=((i==null?void 0:i.text)??"").toLowerCase().split(/[\s,]+/).slice(0,5)}let u=_r[0],r=0;for(const g of _r){const m=g.triggers.filter(w=>s.some(j=>j.includes(w)||w.includes(j))).length;m>r&&(r=m,u=g)}r===0&&(u=_r[0]);const p=St(u.font)||"'Inter', sans-serif",d=((e=document.querySelector("[data-canvas-frame]"))==null?void 0:e.getBoundingClientRect().width)??300;ao(u.font),zo(u.color),Tn(u.size),be(g=>{var w;const m=ye||((w=g[0])==null?void 0:w.id);return g.map(j=>j.id===m||j.id==="main-text"?{...j,fontFamily:p,color:u.color,fontSizeRel:u.size/d,textShadow:u.shadow!=="none"?u.shadow:void 0}:j)}),Nt("font_changed",`Creative: ${u.label}`,`Analisei a imagem e apliquei ${u.label} -- combina com o mood ${s.slice(0,2).join(", ")}. Quer ajustar?`,[]),E.success(`Estilo ${u.label}
199 aplicado`)}catch(n){console.error("Creative style error:",n);const i=St("dancing-script");ao("dancing-script"),zo("#2C1810"),Tn(38);const l=((o=document.querySelector("[data-canvas-frame]"))==null?void 0:o.getBoundingClientRect().width)??300;be(s=>{var r;const u=ye||((r=s[0])==null?void 0:r.id);return s.map(p=>p.id===u||p.id==="main-text"?{...p,fontFamily:i,color:"#2C1810",fontSizeRel:38/l}:p)}),E.info("Estilo criativo aplicado")}finally{Fn(!1)}}},[y,me,ao,zo,Tn,be,Nt]),Xl=()=>{var u;if(!R||oe)return null;if(R==="image")return t.jsxs("div",{onClick:r=>r.stopPropagation(),className:"canvas-top-toolbar",style:{},children:[t.jsxs("button",{className:"ctt-btn ctt-icon-only",title:"Gerar imagem",onClick:()=>{Io(!0),Io(!0),so(!1),T(null)},children:[t.jsx(Vo,{size:15}),t.jsx("span",{className:"ctt-label",children:"Gerar imagem"})]}),t.jsx("div",{className:"ctt-divider"}),t.jsxs("button",{className:"ctt-btn ctt-icon-only",title:"Selecionar produto",onClick:()=>{so(!0),Io(!1),ln(""),T(null)},children:[t.jsx(ii,{size:15}),t.jsx("span",{className:"ctt-label",children:"Produto"})]}),t.jsx("div",{className:"ctt-divider"}),t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("button",{className:"ctt-btn ctt-icon-only",title:"Regenerar",onClick:()=>Vr(r=>!r),disabled:Be,children:[Be?t.jsx(Tt,{size:15,className:"animate-spin"}):t.jsx(Pr,{size:15}),t.jsx("span",{className:"ctt-label",children:"Regenerar"})]}),li&&t.jsx("div",{className:"regen-style-dropdown",onClick:r=>r.stopPropagation(),children:il.map(r=>t.jsxs("div",{children:[t.jsx("div",{className:"regen-cat-label",children:r.label}),r.styles.map(p=>{const d=ve.find(m=>m.id===p);if(!d)return null;const g=(S==null?void 0:S.id)===d.id;return t.jsxs("button",{className:`regen-style-item ${g?"active":""}`,onClick:()=>{var P,N;Ve(d),Vr(!1),T(null);const m=A??"the product",w=(v==null?void 0:v.description)??"";let j=m;d.buildPrompt?j=d.buildPrompt({productName:m,productDescription:w,brandName:(c==null?void 0:c.name)??h.campaignTitle??"",niche:(c==null?void 0:c.niche)??"",audience:(c==null?void 0:c.audience)??"",modelGender:((P=c==null?void 0:c.modelProfile)==null?void 0:P.gender)??"",modelAge:((N=c==null?void 0:c.modelProfile)==null?void 0:N.ageRange)??"",context:""}):d.promptBase&&(j=`${m}, ${d.promptBase}`),At(j),Ce(j,1,d)},children:[t.jsx("span",{className:"regen-style-dot",style:{background:d.color||"#888"}}),t.jsx("span",{className:"regen-style-name",children:d.name}),g&&t.jsx(oi,{size:12,style:{opacity:.5,flexShrink:0}})]},d.id)})]},r.id))})]}),t.jsx("div",{className:"ctt-divider"}),t.jsxs("button",{className:"ctt-btn ctt-icon-only",title:"Editar",onClick:()=>{Cn(!0),T(null),zn(null),An("")},children:[t.jsx(Bc,{size:15}),t.jsx("span",{className:"ctt-label",children:"Editar"})]}),t.jsx("div",{className:"ctt-divider"}),t.jsxs("button",{className:"ctt-btn ctt-icon-only",title:"Dimensionar",onClick:()=>Fe(r=>r==="imagefit"?null:"imagefit"),children:[t.jsx(qp,{size:15}),t.jsx("span",{className:"ctt-label",children:"Dimensionar"})]}),t.jsx("div",{className:"ctt-divider"}),t.jsxs("button",{className:"ctt-btn ctt-icon-only",title:"Gerar vídeo",onClick:()=>{T(null),mr("video"),gn("ai"),Xt&&bt(qn())},disabled:Pt,children:[Pt?t.jsx(Tt,{size:15,className:"animate-spin"}):t.jsx(Br,{size:15}),t.jsx("span",{className:"ctt-label",children:"Vídeo"})]}),t.jsx("div",{className:"ctt-divider"}),t.jsxs("button",{className:"ctt-btn ctt-icon-only",title:"DownloadSimple",onClick:()=>vr(),children:[t.jsx(jn,{size:15}),t.jsx("span",{className:"ctt-label",children:"DownloadSimple"})]}),t.jsxs("button",{ref:qo,className:`ctt-btn ctt-icon-only ${da?"save-animating":""}`,title:"Salvar",onClick:Kn,children:[t.jsx(Wc,{size:15}),t.jsx("span",{className:"ctt-label",children:"Salvar"})]}),t.jsx("div",{className:"ctt-divider"}),t.jsxs("button",{className:"ctt-btn ctt-icon-only",title:"Deletar imagem",onClick:()=>{ne(""),T(null)},children:[t.jsx(Nc,{size:15}),t.jsx("span",{className:"ctt-label",children:"Deletar"})]})]});if(!["heading","description","cta"].includes(R))return null;const o=(u=Vt.current)==null?void 0:u.querySelector(`[data-field="${R}"]`);if(!o||!Vt.current)return null;const n=o.getBoundingClientRect(),i=Vt.current.getBoundingClientRect(),l=n.top-i.top-38,s=n.left-i.left;return t.jsxs("div",{className:"selection-toolbar",style:{position:"absolute",top:l,left:s,zIndex:20},children:[t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("button",{className:"stb-btn stb-generate",onClick:()=>Pe(r=>r===R?null:R),disabled:ge===R,children:[ge===R?t.jsx(Tt,{size:12,className:"animate-spin"}):t.jsx(Vo,{size:12}),t.jsx("span",{children:"Gerar texto"}),t.jsx(Mr,{size:10})]}),_e===R&&t.jsx("div",{className:"stb-tone-dropdown",children:vg.map(r=>
199t.jsxs("button",{className:"stb-tone-option",onClick:()=>gp(R,r.id),disabled:ge===R,children:[t.jsx("span",{className:"stb-tone-icon",children:r.emoji}),t.jsx("span",{children:r.label})]},r.id))})]}),t.jsxs("button",{className:"stb-btn",onClick:()=>mp(R),disabled:ge===R,children:[t.jsx(Mc,{size:12}),t.jsx("span",{children:"Versões"})]}),t.jsxs("button",{className:"stb-btn stb-hint",title:"Abrir opções de tipografia",onClick:r=>{r.stopPropagation(),Ei(!0),Fe("typography")},children:[t.jsx(Pc,{size:11}),t.jsx("span",{children:"Editar"})]})]})},fp=[{id:"sans",label:"Sans Serif",fonts:[{id:"inter",name:"Inter",family:"'Inter', sans-serif"},{id:"poppins",name:"Poppins",family:"'Poppins', sans-serif"},{id:"montserrat",name:"Montserrat",family:"'Montserrat', sans-serif"},{id:"lexend",name:"Lexend",family:"'Lexend', sans-serif"},{id:"outfit",name:"Outfit",family:"'Outfit', sans-serif"},{id:"onest",name:"Onest",family:"'Onest', sans-serif"},{id:"dongle",name:"Dongle",family:"'Dongle', sans-serif"}]},{id:"serif",label:"Serif",fonts:[{id:"playfair",name:"Playfair Display",family:"'Playfair Display', serif"},{id:"playfair-sc",name:"Playfair SC",family:"'Playfair Display SC', serif"},{id:"lora",name:"Lora",family:"'Lora', serif"},{id:"cormorant",name:"Cormorant",family:"'Cormorant Garamond', serif"},{id:"scope-one",name:"Scope One",family:"'Scope One', serif"}]},{id:"display",label:"Display",fonts:[{id:"bebas",name:"Bebas Neue",family:"'Bebas Neue', sans-serif"},{id:"oswald",name:"Oswald",family:"'Oswald', sans-serif"},{id:"anton",name:"Anton",family:"'Anton', sans-serif"}]},{id:"script",label:"Script",fonts:[{id:"monsieur-la-doulaise",name:"Monsieur La Doulaise",family:"'Monsieur La Doulaise', cursive"},{id:"pinyon-script",name:"Pinyon Script",family:"'Pinyon Script', cursive"},{id:"meow-script",name:"Meow Script",family:"'Meow Script', cursive"},{id:"dancing",name:"Dancing Script",family:"'Dancing Script', cursive"},{id:"great-vibes",name:"Great Vibes",family:"'Great Vibes', cursive"},{id:"pacifico",name:"Pacifico",family:"'Pacifico', cursive"}]},{id:"handwritten",label:"Handwritten",fonts:[{id:"gochi-hand",name:"Gochi Hand",family:"'Gochi Hand', cursive"},{id:"pangolin",name:"Pangolin",family:"'Pangolin', cursive"},{id:"kapakana",name:"Kapakana",family:"'Kapakana', cursive"}]}],xp=({isOpen:e,anchorEl:o,selectedFontId:n,onSelect:i,onClose:l})=>{const[s,u]=a.useState({top:0,left:0}),[r,p]=a.useState("sans");return a.useEffect(()=>{if(e&&o){const d=o.getBoundingClientRect();u({top:d.bottom+8,left:d.left})}},[e,o]),a.useEffect(()=>{if(!e)return;const d=g=>{const m=document.getElementById("font-selector-portal");m&&!m.contains(g.target)&&l()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[e,l]),e?Tc.createPortal(t.jsx("div",{id:"font-selector-portal",style:{position:"fixed",top:s.top,left:s.left,width:220,background:"#1E1E1E",border:"1px solid rgba(255,255,255,0.12)",borderRadius:10,boxShadow:"0 8px 32px rgba(0,0,0,0.4)",zIndex:99999,maxHeight:400,overflowY:"auto"},children:fp.map(d=>t.jsxs("div",{children:[t.jsxs("button",{onMouseDown:g=>{g.stopPropagation(),g.preventDefault(),p(m=>m===d.id?"":d.id)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"9px 14px",background:"transparent",border:"none",borderBottom:"1px solid rgba(255,255,255,0.06)",color:"rgba(255,255,255,0.65)",fontSize:11,fontWeight:600,letterSpacing:"0.06em",textTransform:"uppercase",cursor:"pointer",fontFamily:"'Inter', sans-serif"},children:[d.label,t.jsx("span",{style:{opacity:.4,fontSize:10},children:r===d.id?"▲":"▼"})]}),r===d.id&&d.fonts.map(g=>t.jsxs("button",{onMouseDown:m=>{m.stopPropagation(),m.preventDefault(),i(g),l()},style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"10px 14px",background:n===g.id?"rgba(255,255,255,0.1)":"transparent",border:"none",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",fontFamily:g.family,fontSize:16,fontWeight:400,color:"#FFF",textAlign:"left"},children:[g.name,n===g.id&&t.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontFamily:"'Inter',sans-serif"}})]},g.id))]},d.id))}),document.body):null}
199,[Je,bp]=a.useState({w:300,h:400});a.useEffect(()=>{const e=$t.current;if(!e)return;const o=new ResizeObserver(n=>{const{width:i,height:l}=n[0].contentRect;i>50&&l>50&&bp({w:i,h:l})});return o.observe(e),()=>o.disconnect()},[]);const yp=(e,o,n,i,l=!0)=>{var u;const s=Ke&&Et?Et:n;return t.jsxs("div",{ref:i,onClick:r=>{r.target===r.currentTarget&&Ir()},style:{width:"100%",maxWidth:o,aspectRatio:e.replace(" / ","/"),maxHeight:"calc(100vh - 180px)",position:"relative",borderRadius:16,overflow:"visible",boxShadow:"0 8px 40px rgba(0,0,0,0.15)"},children:[t.jsxs("div",{ref:_a,"data-canvas-frame":"true",style:{position:"absolute",inset:0,borderRadius:16,overflow:"hidden",backgroundColor:L(s)?"#F2F2F0":"#111"},children:[L(s)?t.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:20,padding:32,background:"#F7F6F3"},children:[t.jsx("div",{style:{position:"absolute",inset:16,border:"1.5px dashed #CCCCCC",borderRadius:12,pointerEvents:"none"}}),t.jsx("div",{style:{width:52,height:52,borderRadius:"50%",background:Be||nt?"#1A1A1A":"#EBEBEB",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.3s"},children:Be||nt?t.jsx("div",{style:{width:22,height:22,border:"2px solid rgba(0,0,0,0.08)",borderTopColor:"#555",borderRadius:"50%",animation:"spin 0.75s linear infinite"}}):t.jsx(Vo,{size:22,style:{color:"#AAAAAA"}})}),t.jsxs("div",{style:{textAlign:"center",display:"flex",flexDirection:"column",gap:8},children:[t.jsx("p",{style:{fontSize:14,fontWeight:500,margin:0,lineHeight:1.4,...Be||nt?{background:"linear-gradient(90deg, #AAAAAA 0%, #444444 50%, #AAAAAA 100%)",backgroundSize:"200% 100%",WebkitBackgroundClip:"text",WebkitTextFillColor:"transparent",animation:"shimmerText 2s ease-in-out infinite"}:{color:"#555555"}},children:Be||nt?Oa||zi||"Gerando...":"Descreva o criativo no chat"}),!(Be||nt)&&t.jsx("p",{style:{fontSize:12,color:"#AAAAAA",margin:0,lineHeight:1.5},children:"ou escolha uma ação abaixo para começar"})]}),!(Be||nt)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,width:"100%",maxWidth:200},children:[{icon:t.jsx(Vo,{size:16}),label:"Gerar imagem com IA",action:()=>{var r,p;(p=(r=te.current)==null?void 0:r.sendMessage)==null||p.call(r,"Gerar imagem com IA")}},{icon:t.jsx(ii,{size:16}),label:"Usar foto do produto",action:()=>{var r,p;(p=(r=te.current)==null?void 0:r.sendMessage)==null||p.call(r,"Usar foto do produto")}},{icon:t.jsx(Nr,{size:16}),label:"Criar carrossel",action:()=>{var r,p;(p=(r=te.current)==null?void 0:r.sendMessage)==null||p.call(r,"Criar carrossel")}}].map((r,p)=>t.jsxs("button",{onClick:r.action,style:{display:"flex",alignItems:"center",gap:8,padding:"9px 14px",borderRadius:8,border:"1px solid #E2E2E2",background:"#FFFFFF",fontSize:12,fontWeight:500,color:"#444",cursor:"pointer",transition:"all 0.12s",fontFamily:"inherit",textAlign:"left",boxShadow:"0 1px 3px rgba(0,0,0,0.06)"},onMouseEnter:d=>{d.currentTarget.style.borderColor="#1A1A1A",d.currentTarget.style.color="#1A1A1A"},onMouseLeave:d=>{d.currentTarget.style.borderColor="#E2E2E2",d.currentTarget.style.color="#444"},children:[t.jsx("span",{style:{flexShrink:0,display:"flex",alignItems:"center"},children:r.icon}),r.label]},p))}),t.jsx("p",{style:{fontSize:11,color:"#CCCCCC",margin:0,textAlign:"center"},children:"ou arraste uma imagem aqui"})]})]}):mn(s)?t.jsx("video",{src:s,autoPlay:!0,loop:!0,muted:!0,playsInline:!0,style:{position:"absolute",width:"100%",height:"100%",objectFit:"cover",pointerEvents:"none"}},s):t.jsx("img",{src:s,alt:"",style:{position:"absolute",width:"100%",height:"100%",objectFit:lo==="contain"?"contain":"cover",objectPosition:`${lt.x}% ${lt.y}%`,transform:`scale(${Ro/100})`,transformOrigin:`${lt.x}% ${lt.y}%`,transition:"transform 0.1s, object-position 0.1s",pointerEvents:"none",userSelect:"none"}}),!Ke&&t.jsx("div",{onDragOver:r=>{r.preventDefault(),r.stopPropagation()},onDrop:r=>{r.preventDefault(),r.stopPropagation();const p=r.dataTransfer.files[0];if(!(p!=null&&p.type.startsWith("image/")))return;const d=new FileReader;d.onload=g=>{var w;const m=(w=g.target)==null?void 0:w.result;ne(m),Gt(m)},d.readAsDataURL(p)},style:{position:"absolute",inset:0,zIndex:1,pointerEvents:L(s)?"none":"auto",cursor:"default",borderRadius:"inherit"}}),(Be||nt)&&!Ke&&t.jsxs("div",{style:{position:"absolute",inset:0,zIndex:20,borderRadius:"inherit",background:"rgba(0,0,0,0.4)",backdropFilter:"blur(1px)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12},children:[t.jsx("div",{style:{width:36,height:36,borderRadius:"50%",border:"2.5px solid rgba(255,255,255,0.2)",borderTopColor:"#FFFFFF",animation:"spin 0.75s linear infinite"}}),t.jsx("span",{style:{fontSize:12,fontWeight:500,fontFamily:"'Inter', sans-serif",background:"linear-gradient(90deg, rgba(255,255,255,0.5) 0%, rgba(255,255,255,1) 50%, rgba(255,255,255,0.5) 100%)",backgroundSize:"200% 100%",WebkitBackgroun
199dClip:"text",WebkitTextFillColor:"transparent",animation:"shimmerText 2s ease-in-out infinite"},children:Be?Oa||"Gerando...":zi||"Aplicando..."})]}),!Ke&&!L(s)&&t.jsx("div",{style:Oc(Ne,Ut,We,kt)}),!Ke&&st==="brand-dna"&&l&&t.jsx("div",{style:{position:"absolute",top:12,right:12,background:"rgba(0,0,0,0.5)",color:"white",fontSize:10,fontWeight:600,padding:"4px 10px",borderRadius:999,letterSpacing:"0.05em",zIndex:3},children:"Brand DNA"}),Ke&&t.jsxs("div",{className:"image-edit-overlay",children:[t.jsxs("div",{className:"image-edit-top-bar",children:[t.jsxs("button",{className:"image-edit-cancel-btn",onClick:rp,children:[t.jsx(je,{size:13})," Cancelar"]}),Et&&t.jsxs("button",{className:"image-edit-save-btn",onClick:ap,children:[t.jsx(oi,{size:13})," Salvar"]})]}),t.jsxs("div",{className:"image-edit-input-bar",children:[t.jsx("textarea",{className:"image-edit-prompt",value:Yo,onChange:r=>An(r.target.value),placeholder:"Descreva a edição... ex: trocar fundo por floresta, adicionar sombra, mudar tom para dourado",rows:2,autoFocus:!0,onKeyDown:r=>{r.key==="Enter"&&!r.shiftKey&&(r.preventDefault(),Yo.trim()&&!xa&&_l())}}),t.jsx("button",{className:"image-edit-apply-btn",onClick:_l,disabled:!Yo.trim()||xa,children:xa?t.jsx(Tt,{size:14,className:"animate-spin"}):t.jsx(Vo,{size:14})})]})]})]}),ks&&Ha.length>0&&y&&!L(y)&&(()=>{const r=Je.w||400,p=Je.h||500;return t.jsx("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",zIndex:10,overflow:"visible"},viewBox:`0 0 ${r} ${p}`,xmlns:"http://www.w3.org/2000/svg",children:Ha.map(d=>{const g=d.anchor.x*r,m=d.anchor.y*p,w=d.labelSide==="right",j=w?g+80:g-80,P=w?j+6:j-6,N=w?"start":"end";if(Ga==="technical")return t.jsxs("g",{children:[t.jsx("circle",{cx:g,cy:m,r:3,fill:"rgba(20,20,20,0.7)"}),t.jsx("line",{x1:g,y1:m,x2:j,y2:m,stroke:"rgba(20,20,20,0.55)",strokeWidth:.75}),t.jsx("text",{x:P,y:m-4,textAnchor:N,fontSize:11,fontFamily:"'Inter', sans-serif",fontWeight:500,fill:"rgba(20,20,20,0.85)",letterSpacing:.2,children:d.label}),d.sublabel&&t.jsx("text",{x:P,y:m+9,textAnchor:N,fontSize:9,fontFamily:"'Inter', sans-serif",fontWeight:400,fill:"rgba(20,20,20,0.45)",children:d.sublabel})]},d.id);const pe=(g+j)/2,he=m-20;return t.jsxs("g",{children:[t.jsx("defs",{children:t.jsx("marker",{id:`arrow-${d.id}`,markerWidth:6,markerHeight:6,refX:3,refY:3,orient:"auto",children:t.jsx("path",{d:"M0,0 L0,6 L6,3 z",fill:"rgba(40,30,20,0.6)"})})}),t.jsx("path",{d:`M ${g} ${m} Q ${pe} ${he} ${j} ${m}`,fill:"none",stroke:"rgba(40,30,20,0.6)",strokeWidth:1.2,strokeLinecap:"round",markerEnd:`url(#arrow-${d.id})`}),t.jsx("text",{x:P,y:m-8,textAnchor:N,fontSize:12,fontFamily:"'Dancing Script', cursive",fontWeight:600,fill:"rgba(40,30,20,0.8)",children:d.label}),d.sublabel&&t.jsx("text",{x:P,y:m+6,textAnchor:N,fontSize:10,fontFamily:"'Dancing Script', cursive",fontWeight:400,fill:"rgba(40,30,20,0.5)",children:d.sublabel})]},d.id)})})})(),!Ke&&!L(s)&&Ot.map(r=>{const p=ye===r.id,d=ci===r.id;return t.jsx("div",{children:Be?null:t.jsx(wg,{box:r,isSelected:p,isEditing:d,canvasW:Je.w,canvasH:Je.h,onSelect:()=>{He(r.id),T("text"),Z(null),Pe(null)},onEdit:()=>{He(r.id),to(r.id)},onBlur:g=>{Te(r.id,{text:g}),to(null)},onUpdate:g=>Te(r.id,g),onDelete:()=>{be(g=>g.filter(m=>m.id!==r.id)),He(null)},onOpenGen:()=>{ja(r.id),mi(r.text),Rn(!0)},onDuplicate:()=>{const g={...r,id:`text-${Date.now()}`,xRel:(r.xRel??.06)+.03,yRel:(r.yRel??.46)+.03};be(m=>[...m,g]),He(g.id)},onApplyCreative:hp,isApplyingCreative:ca})},r.id)}),!Ke&&!L(s)&&ad.map(r=>{const p=k.find(d=>d.id===r.productId);
199return t.jsx(jg,{card:r,product:p,canvasW:Je.w,canvasH:Je.h,isSelected:rd===r.id,onSelect:()=>{oo(r.id),He(null),T(null)},onDelete:()=>{di(d=>d.filter(g=>g.id!==r.id)),oo(null)},onUpdate:d=>di(g=>g.map(m=>m.id===r.id?{...m,...d}:m)),onChangeProd:()=>ba(r.id)},r.id)}),!Ke&&!L(s)&&sd.map(r=>t.jsx(Fg,{card:r,canvasW:Je.w,canvasH:Je.h,isSelected:ld===r.id,isEditing:cd===r.id,onSelect:()=>{no(r.id),He(null),oo(null),T(null)},onEdit:()=>{no(r.id),pi(r.id)},onBlur:p=>{ui(d=>d.map(g=>g.id===r.id?{...g,...p}:g)),pi(null)},onDelete:()=>{ui(p=>p.filter(d=>d.id!==r.id)),no(null),pi(null)},onUpdate:p=>ui(d=>d.map(g=>g.id===r.id?{...g,...p}:g))},r.id)),!Ke&&!L(s)&&dd.map(r=>t.jsx(Sg,{widget:r,canvasW:Je.w,canvasH:Je.h,isSelected:ud===r.id,onSelect:()=>{Xo(r.id),He(null),oo(null),no(null),Jo(null),Qo(null),T(null)},onDelete:()=>{ya(p=>p.filter(d=>d.id!==r.id)),Xo(null)},onUpdate:p=>ya(d=>d.map(g=>g.id===r.id?{...g,...p}:g))},r.id)),!Ke&&!L(s)&&pd.map(r=>t.jsx(kg,{widget:r,canvasW:Je.w,canvasH:Je.h,isSelected:gd===r.id,onSelect:()=>{Jo(r.id),He(null),oo(null),no(null),Xo(null),Qo(null),T(null)},onDelete:()=>{va(p=>p.filter(d=>d.id!==r.id)),Jo(null)},onUpdate:p=>va(d=>d.map(g=>g.id===r.id?{...g,...p}:g))},r.id)),!Ke&&!L(s)&&md.map(r=>t.jsx(Cg,{widget:r,canvasW:Je.w,canvasH:Je.h,isSelected:hd===r.id,onSelect:()=>{Qo(r.id),He(null),oo(null),no(null),Xo(null),Jo(null),T(null)},onDelete:()=>{wa(p=>p.filter(d=>d.id!==r.id)),Qo(null)},onUpdate:p=>wa(d=>d.map(g=>g.id===r.id?{...g,...p}:g))},r.id)),ns&&t.jsxs("div",{className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50},onClick:r=>r.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[t.jsx("span",{className:"float-window-title",style:{margin:0},children:"Selecionar produto"}),t.jsx("button",{onClick:()=>ba(null),style:{background:"none",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.5)",display:"flex"},children:t.jsx(je,{size:14})})]}),t.jsx("div",{className:"float-product-list",children:k.map(r=>t.jsxs("button",{className:"float-product-item",onClick:()=>{di(p=>p.map(d=>d.id===ns?{...d,productId:r.id}:d)),ba(null)},children:[t.jsx("div",{className:"float-product-thumb",children:t.jsx("img",{src:r.image,alt:r.name})}),t.jsx("div",{style:{flex:1},children:t.jsx("span",{className:"float-product-name",children:r.name})})]},r.id))})]}),Xc&&t.jsxs("div",{className:"save-toast-bar",children:[t.jsx("span",{className:"save-toast-check"}),t.jsx("span",{children:"Salvo no histórico"})]}),da&&qo.current&&Tc.createPortal(t.jsx("div",{className:"save-sparkles",style:{position:"fixed",left:qo.current.getBoundingClientRect().left+qo.current.getBoundingClientRect().width/2-20,top:qo.current.getBoundingClientRect().top+qo.current.getBoundingClientRect().height/2-20,width:40,height:40,pointerEvents:"none",zIndex:9999},children:[...Array(6)].map((r,p)=>t.jsx("span",{className:`sparkle-particle sparkle-${p}`},p))}),document.body),!Ke&&Xl(),Pt&&t.jsxs("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.75)",backdropFilter:"blur(4px)",borderRadius:16,zIndex:30,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:20},children:[t.jsx("div",{style:{width:52,height:52,border:"2px solid rgba(255,255,255,0.15)",borderTopColor:"#FFFFFF",borderRadius:"50%",animation:"spin 0.9s linear infinite"}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:14,fontWeight:400,color:"rgba(255,255,255,0.9)",fontFamily:"inherit"},children:dl||"gerando vídeo..."}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontFamily:"inherit"},children:[((u=ri.find(r=>r.id===yt))==null?void 0:u.name)??"IA"," · pode levar até 2 min"]})]}),t.jsx("button",{onClick:()=>{lr(!1),No(""),_i(null)},style:{marginTop:8,padding:"6px 16px",borderRadius:999,border:"1px solid rgba(255,255,255,0.2)",background:"transparent",color:"rgba(255,255,255,0.5)",fontSize:11,fontWeight:400,cursor:"pointer",fontFamily:"inherit"},onMouseEnter:r=>r.currentTarget.style.color="rgba(255,255,255,0.9)",onMouseLeave:r=>r.currentTarget.style.color="rgba(255,255,255,0.5)",children:"cancelar"})]}),Jt&&!Pt&&t.jsxs("div",{style:{position:"absolute",inset:0,borderRadius:16,zIndex:30,overflow:"hidden",background:"#000"},children:[t.jsx("video",{src:Jt,autoPlay:!0,loop:!0,muted:!0,playsInl
199ine:!0,controls:!1,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),t.jsxs("div",{style:{position:"absolute",bottom:16,left:0,right:0,display:"flex",justifyContent:"center",gap:8,zIndex:31},children:[t.jsx("button",{onClick:async()=>{Jt&&(ne(Jt),cl(Jt),Bi(null),E.success("Vídeo aplicado no canvas!"),Ue(Jt))},style:{height:36,padding:"0 18px",borderRadius:999,border:"none",background:"#FFFFFF",color:"#1A1A1A",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",gap:6},children:"▶ aplicar no canvas"}),t.jsx("button",{onClick:async()=>{Jt&&(ne(Jt),cl(Jt),await new Promise(r=>setTimeout(r,100)),await Il())},style:{height:36,width:36,borderRadius:999,border:"1px solid rgba(255,255,255,0.3)",background:"rgba(0,0,0,0.4)",backdropFilter:"blur(8px)",color:"#FFFFFF",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},title:"Baixar vídeo",children:t.jsx(jn,{size:14})}),t.jsx("button",{onClick:()=>Bi(null),style:{height:36,width:36,borderRadius:999,border:"1px solid rgba(255,255,255,0.15)",background:"rgba(0,0,0,0.4)",backdropFilter:"blur(8px)",color:"rgba(255,255,255,0.6)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},title:"Descartar",children:t.jsx(je,{size:14})})]})]}),Oi&&!Pt&&t.jsxs("div",{style:{position:"absolute",bottom:16,left:16,right:16,zIndex:25,padding:"12px 16px",borderRadius:10,background:"rgba(239,68,68,0.15)",border:"1px solid rgba(239,68,68,0.3)",display:"flex",alignItems:"flex-start",gap:8},children:[t.jsx("span",{style:{fontSize:11,color:"#FCA5A5",lineHeight:1.5,flex:1},children:Oi}),t.jsx("button",{onClick:()=>_i(null),style:{background:"none",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.4)",flexShrink:0,padding:0},children:t.jsx(je,{size:12})})]})]})},vp=a.useCallback(()=>{var e,o,n;return{channel:b,heading:ee,description:rt,cta:Qe,style:st,styleName:(S==null?void 0:S.name)??st??"",product:A,productDescription:(v==null?void 0:v.description)??"",campaign:(C==null?void 0:C.title)??h.campaignTitle??"",isCarouselMode:x,textColor:ft,ctaColor:Ht,overlayOpacity:We,font:ke,lastGeneratedPrompt:de??"",hasImage:!!y&&!L(y),storeName:(c==null?void 0:c.name)??"",storeNiche:(c==null?void 0:c.niche)??"",storeTone:(c==null?void 0:c.tone)??"",storeAudience:(c==null?void 0:c.audience)??"",storeKeywords:(c==null?void 0:c.keywords)??[],storeProducts:(c==null?void 0:c.productTypes)??[],storeColors:(c==null?void 0:c.colors)??[],visualConcept:(c==null?void 0:c.visualConcept)??"",modelGender:((e=c==null?void 0:c.modelProfile)==null?void 0:e.gender)??"",modelAge:((o=c==null?void 0:c.modelProfile)==null?void 0:o.ageRange)??"",modelPose:((n=c==null?void 0:c.modelProfile)==null?void 0:n.pose)??"",shootingStyle:(c==null?void 0:c.shootingStyle)??"",lightingMood:(c==null?void 0:c.lightingMood)??"",colorMood:(c==null?void 0:c.colorMood)??""}},[b,ee,rt,Qe,st,S,A,v,C,h.campaignTitle,x,ft,Ht,We,ke,de,y,c]),wp=a.useCallback(async e=>{switch(console.log("[executeAction] received:",JSON.stringify(e)),e.type){case"set_heading":case"set_text":{const o=e.value??e.text??"";return jo(o),be(n=>n.map(i=>i.id==="main-text"?{...i,text:o}:i)),{icon:"",label:"Texto atualizado"}}case"add_text_box":{const o=e.text??e.value??"Novo texto",i={top:.08,middle:.46,bottom:.75}[e.position??"middle"]??.46,l=`text-${Date.now()}`,s={id:l,text:o,xRel:.06,yRel:i,fontSizeRel:.055,color:e.color??"#FFFFFF",fontFamily:St(ke),textAlign:"center",boxWidthRel:.88};return be(u=>[...u,s]),He(l),{icon:"",label:"Texto adicionado"}}case"set_description":{Fo(e.value??"");const o="desc-text";return be(n=>n.some(i=>i.id===o)?n.map(i=>i.id===o?{...i,text:e.value}:i):[...n,{id:o,text:e.value??"",xRel:.06,yRel:.58,fontSizeRel:.028,color:"#FFFFFF",fontFamily:St(ke),textAlign:"center",boxWidthRel:.88}]),{icon:"",label:"Descrição atualizada"}}case"set_cta":{So(e.value??"");const o="cta-text";return be(n=>n.some(i=>i.id===o)?n.map(i=>i.id===o?{...i,text:e.value}:i):[...n,{id:o,text:e.value??"",xRel:.06,yRel:.72,fontSizeRel:.022,color:"#FFFFFF",fontFamily:St(ke),textAlign:"center",boxWidthRel:.88}]),{icon:"",label:"CTA atualizado"}}case"set_style":{const o=ve.find(r=>{var p;return r.id===e.value||r.name.toLowerCase()===((p=e.value)==null?void 0:p.toLowerCase())}),n=ai.find(r=>{var p;return r.id===e.value||r.name.toLowerCase()===((p=e.value)==null?void 0:p.toLowerCase())}),i=o??n;if(!i)return{icon:"◈",label:`Estilo não encontrado: ${e.value}`};
199if(Oo(i),Ve(o??null),It(0),ko(!1),Sn(!1),kn(!1),e.__skipGenerate)return{icon:"◈",label:`Estilo ${i.name} aplicado`};const l=(A==null?void 0:A.trim())||"",s=(de==null?void 0:de.trim())||go();let u=s;return o!=null&&o.buildPrompt?u=o.buildPrompt({productName:l||"the product",productDescription:(v==null?void 0:v.description)??"",brandName:(c==null?void 0:c.name)??h.campaignTitle??"",niche:(c==null?void 0:c.niche)??"",audience:(c==null?void 0:c.audience)??"",tone:(c==null?void 0:c.tone)??"",context:(f==null?void 0:f.id)??"1:1"}):o!=null&&o.promptBase&&(u=`${s}. ${o.promptBase}`),setTimeout(()=>{Ce(u,1,o??void 0)},150),{icon:"◈",label:`Gerando com estilo ${i.name}...`}}case"set_channel":return ua(e.value),{icon:"▣",label:`Formato ${e.value}`};case"set_text_color":return zo(e.value),be(o=>o.map(n=>n.id==="main-text"?{...n,color:e.value}:n)),{icon:"◉",label:`Cor do texto: ${e.value}`};case"set_cta_color":return fi(e.value),{icon:"◉",label:`Cor do CTA: ${e.value}`};case"set_overlay_opacity":return It(e.value),{icon:"▣",label:`Overlay ${Math.round(e.value*100)}%`};case"set_overlay_type":return yi(e.value),{icon:"▣",label:`Overlay: ${e.value}`};case"set_overlay_color":return e.value&&Ia(e.value),e.opacity!==void 0&&It(e.opacity),{icon:"▣",label:"Overlay atualizado"};case"set_font":{const o={inter:"'Inter', sans-serif",poppins:"'Poppins', sans-serif",montserrat:"'Montserrat', sans-serif",playfair:"'Playfair Display', serif",lora:"'Lora', serif",cormorant:"'Cormorant Garamond', serif",bebas:"'Bebas Neue', sans-serif",oswald:"'Oswald', sans-serif",anton:"'Anton', sans-serif","dancing-script":"'Dancing Script', cursive","great-vibes":"'Great Vibes', cursive",pacifico:"'Pacifico', cursive","dm-serif":"'DM Serif Display', serif",fraunces:"'Fraunces', serif","space-grotesk":"'Space Grotesk', sans-serif",raleway:"'Raleway', sans-serif"},n=e.fontFamily||o[e.value]||`'${e.value}', sans-serif`;return ao(e.value),be(i=>i.map(l=>l.id==="main-text"?{...l,fontFamily:n}:l)),{icon:"T",label:`Fonte: ${e.value}`}}case"set_font_size":return be(o=>o.map(n=>n.id==="main-text"?{...n,fontSizeRel:(e.value??48)/(Je.h||600)}:n)),{icon:"T",label:`Tamanho: ${e.value}px`};case"set_image_position":return Ye({x:e.x??50,y:e.y??50}),{icon:"◈",label:"Posição da imagem ajustada"};case"set_image_scale":return tt(e.value??100),{icon:"◈",label:`Escala: ${e.value}%`};case"set_image_fit":return et(e.value==="contain"?"contain":"cover"),{icon:"◈",label:`Ajuste: ${e.value}`};case"add_widget":switch(e.widget){case"countdown":hl();break;case"price":fl();break;case"social-proof":xl();break;case"review":ml();break;case"product-card":us();break}return{icon:"▣",label:`Widget ${e.widget} adicionado`};case"generate_image":{const o=e.count??e.variations??1,n=e.__styleOverride;return Dn(!0),tn(o>1?`Gerando ${o} variações...`:"Gerando imagem..."),At(e.prompt??""),o>1?(Pa([]),Na(null),(async()=>{for(let i=0;i<o;i++)tn(`Gerando variação ${i+1} de ${o}...`),await Ce(e.prompt??"",o,n??void 0);Dn(!1),tn("")})()):Ce(e.prompt??"",1,n??void 0),{icon:"",label:o>1?`Gerando ${o} variações...`:"Gerando imagem..."}}case"generate_carousel":return e.slide_count?(po("manual"),nn(e.slide_count)):po("auto"),I(!0),Cr(),{icon:"▣",label:`Carrossel de ${e.slide_count??"auto"} slides`};case"open_publish":return Hn(!0),{icon:"↗",label:"Publicar"};case"open_schedule":return Un(!0),{icon:"◷",label:"Agendar"};case"save_asset":return Kn(),{icon:"",label:"Asset salvo"};case"open_gen_panel":return Rn(!0),{icon:"",label:"Painel de texto aberto"};case"open_font_panel":return He("main-text"),{icon:"T",label:"Selecione a fonte na toolbar"};case"open_scan":return Qn(!0),{icon:"◈",label:"Analisando criativo"};case"open_brand_dna":return Qn(!0),{icon:"◈",label:"Analisando Brand DNA"};case"new_asset":return Kn(),ne(null),be([]),{icon:"",label:"Novo asset"};case"set_attributes_language":{const o=e.value??"pt";return gs(o),await Zo(o),{icon:"◈",label:`Atributos em ${o==="pt"?"Portugues":o==="en"?"Ingles":"Espanhol"}`}}case"regenerate_attributes":{const o=e.language??vi;return gs(o),await Zo(o),{icon:"◈",label:"Atributos regenerados"}}case"open_document_poll":return Pl(),{icon:"",label:"Escolha o tipo de conteúdo"};default:return console.warn("[executeAction] unknown action type:",e.type),null}},[Oo,ua,Ce,Cr,ve,A,de,go,v,h.campaignTitle,f,Zo,vi]);return t.jsxs("div",{style:{position:_?"relative":"fixed",inset:_?void 0:0,zIndex:_?void 0:260,width:_?"100%":"100vw",height:_?"100%":"100vh",display:"grid",gridTemplateColumns:$i||Di?"1fr":"380px 1fr",gridTemplateRows:"100%",background:"#F2F2F2",overflow:"hidden",transition:"grid-template-columns 0.25s ease"},children:[_d&&t.jsxs("div",{style:{position:"absolute",inset:0,zIndex:300},children:[t.jsx(zp,{styles:ve.map(e=>({id:e.id,name:e.name,thumbnailUrl:e.thumbnailUrl,color:e.color,buildPrompt:e.buildPrompt})),products:k.map(e=>({id:e.id,name:e.name,image:e.image,description:e.description})),isGenerating:bs,storeName:(c==null?void 0:c.name)??h.campaignTitle,onGenerate:({prompt:e,styleId:o,productId:n,onResult:i,onError:l})=>{var g,m,w;const s=`luma-${Date.now()}`,u=o?ve.find(j=>j.id===o):null;if(u&&Ve(u),n){ro([n]);const j=k.find(P=>P.id===n);j&&ne(j.image)}const r=n?k.find(j=>j.id===n):v,p=((g=r==null?void 0:r.name)==null?void 0:g.trim())||"",d=u!=null&&u.buildPrompt?u.buildPrompt({productName:p||"the product",productDescription:(r==null?void 0:r.description)??"",brandName:(c==null?void 0:c.name)??h.campaignTitle??"",niche:(c==null?void 0:c.niche)??"",audience:(c==null?void 0:c.audience)??"",modelGender:((m=c==null?void 0:c.modelProfile)==null?void 0:m.gender)??"",modelAge:((w=c==null?void 0:c.modelProfile)==null?void 0:w.ageRange)??"",context:(f==null?void 0:f.id)??"1:1"}):e;
199At(d),Ce(d,1,u??void 0).then(j=>{j?i(s,j):l(s)}).catch(()=>l(s))},onCardOpen:e=>{e.imageUrl&&(ne(e.imageUrl),Ci(!1))}}),t.jsx("button",{onClick:()=>Ci(!1),style:{position:"absolute",top:16,left:16,zIndex:400,padding:"6px 14px",borderRadius:8,border:"1px solid rgba(255,255,255,0.15)",background:"rgba(20,20,20,0.85)",fontSize:12,fontWeight:500,color:"rgba(255,255,255,0.7)",cursor:"pointer",fontFamily:"inherit",backdropFilter:"blur(8px)"},children:"← Studio"})]}),Hd&&t.jsxs("div",{style:{position:"absolute",inset:0,zIndex:300},children:[t.jsx(Rp,{styles:ve.map(e=>({id:e.id,name:e.name,thumbnailUrl:e.thumbnailUrl,color:e.color})),products:k.map(e=>({id:e.id,name:e.name,image:e.image})),images:Ud,generatingSlots:Vd,storeName:(c==null?void 0:c.name)??h.campaignTitle,onGenerate:({prompt:e,styleId:o,productId:n,aspectRatio:i})=>{var d,g,m;const l=`higgs-${Date.now()}`;La(w=>[...w,{id:l,prompt:e,aspectRatio:i}]);const s=o?ve.find(w=>w.id===o):null;if(s&&Ve(s),n){ro([n]);const w=k.find(j=>j.id===n);w&&ne(w.image)}const u=n?k.find(w=>w.id===n):v,r=((d=u==null?void 0:u.name)==null?void 0:d.trim())||"",p=s!=null&&s.buildPrompt?s.buildPrompt({productName:r||"the product",productDescription:(u==null?void 0:u.description)??"",brandName:(c==null?void 0:c.name)??h.campaignTitle??"",niche:(c==null?void 0:c.niche)??"",audience:(c==null?void 0:c.audience)??"",modelGender:((g=c==null?void 0:c.modelProfile)==null?void 0:g.gender)??"",modelAge:((m=c==null?void 0:c.modelProfile)==null?void 0:m.ageRange)??"",context:i??"1:1"}):e;At(p),Ce(p,1,s??void 0).then(w=>{w&&Gd(j=>[{id:l,url:w,prompt:e,styleId:o,productId:n,aspectRatio:i,createdAt:new Date},...j]),La(j=>j.filter(P=>P.id!==l))}).catch(()=>La(w=>w.filter(j=>j.id!==l)))},onEditImage:e=>{ne(e.url),Ai(!1)}}),t.jsx("button",{onClick:()=>Ai(!1),style:{position:"absolute",top:16,left:16,zIndex:400,padding:"6px 14px",borderRadius:8,border:"1px solid rgba(255,255,255,0.15)",background:"rgba(14,14,14,0.9)",fontSize:12,fontWeight:500,color:"rgba(255,255,255,0.6)",cursor:"pointer",fontFamily:"inherit",backdropFilter:"blur(8px)"},children:"← Studio"})]}),!$i&&t.jsx("div",{style:{height:"100%",maxHeight:"100%",padding:"12px 0 12px 12px",boxSizing:"border-box",display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:t.jsxs("div",{style:{flex:1,minHeight:0,background:"transparent",borderRadius:16,border:"none",display:"flex",flexDirection:"column",overflow:"hidden",minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",height:44,padding:"0 14px",flexShrink:0,background:"#FAFAFA"},children:[t.jsx(Tp,{session:Xn,children:Tu,parent:Eu,onRename:bl,onNavigate:e=>{e.parentId===null?Jn(null):Jn(e)},onNewChat:()=>{var e,o;(o=(e=te.current)==null?void 0:e.clearMessages)==null||o.call(e),Jn(null)},onDelete:()=>{var e,o;(o=(e=te.current)==null?void 0:e.clearMessages)==null||o.call(e),Jn(null)}}),t.jsx("div",{style:{display:"flex",alignItems:"center",gap:6},children:t.jsx("button",{onClick:()=>{},title:"Minimizar chat",style:{width:28,height:28,borderRadius:7,border:"none",background:"transparent",color:"#CCC",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"color 0.1s",flexShrink:0},onMouseEnter:e=>e.currentTarget.style.color="#1A1A1A",onMouseLeave:e=>e.currentTarget.style.color="#CCC",children:t.jsx(Yp,{size:15})})})]}),t.jsxs("div",{style:{flex:1,minHeight:0,overflow:"hidden",display:"flex",flexDirection:"column"},children:[Di&&t.jsx(Ep,{styles:ve.map(e=>({id:e.id,name:e.name,thumbnailUrl:e.thumbnailUrl,color:e.color})),products:k.map(e=>({id:e.id,name:e.name,image:e.image})),isGenerating:bs,generatedImageUrl:Si,preselectedStyle:h.styleName&&ve.find(e=>e.name===h.styleName)?{id:ve.find(e=>e.name===h.styleName).id,name:h.styleName,thumbnailUrl:(oc=ve.find(e=>e.name===h.styleName))==null?void 0:oc.thumbnailUrl}:null,onGenerate:({prompt:e,styleId:o,productId:n})=>{var r,p,d;const i=o?ve.find(g=>g.id===o):null;if(i&&Ve(i),n){ro([n]);const g=k.find(m=>m.id===n);g&&ne(g.image)}const l=n?k.find(g=>g.id===n):v,s=((r=l==null?void 0:l.name)==null?void 0:r.trim())||"",u=i!=null&&i.buildPrompt?i.buildPrompt({productName:s||"the product",productDescription:(l==null?void 0:l.description)??"",brandName:(c==null?void 0:c.name)??h.campaignTitle??"",niche:(c==null?void 0:c.niche)??"",audience:(c==null?void 0:c.audience)??"",modelGender:((p=c==null?void 0:c.modelProfile)==null?void 0:p.gender)??"",modelAge:((d=c==null?void 0:c.modelProfile)==null?void 0:d.ageRange)??"",context:(f==null?void 0:f.id)??"1:1"}):e;At(u),Ce(u,1,i??void 0)},onEdit:e=>{ne(e),tl(!1)},onRetry:()=>{Ce(de||go())}}),t.jsx("div",{style:{display:Di?"none":"flex",flex:1,minHeight:0,flexDirection:"column",overflow:"hidden"},children:t.jsx(lg,{ref:te,creativeState:vp(),initialMessages:h.restoreChatMessages,suppressWelcome:!!((nc=h.autoPrompt)!=null&&nc.trim())&&h.styleId!=="snew",imageStyles:ve.map(e=>({id:e.id,name:e.name,category:e.category,color:e.color,thumbnailUrl:e.thumbnailUrl??"",description:e.description??""})),products:k.slice(0,8).map(e=>({id:e.id,name:e.name,image:e.image})),onGenerateWithStyle:(e,o)=>{var s;const n=ve.find(u=>u.id===e);
199if(n&&Ve(n),o){ro([o]);const u=k.find(r=>r.id===o);u&&ne(u.image)}const i=o?k.find(u=>u.id===o):v,l=((s=i==null?void 0:i.name)==null?void 0:s.trim())||"";setTimeout(()=>{var u,r;if(n!=null&&n.buildPrompt){const p=n.buildPrompt({productName:l||"the product",productDescription:(i==null?void 0:i.description)??"",brandName:(c==null?void 0:c.name)??h.campaignTitle??"",niche:(c==null?void 0:c.niche)??"",audience:(c==null?void 0:c.audience)??"",modelGender:((u=c==null?void 0:c.modelProfile)==null?void 0:u.gender)??"",modelAge:((r=c==null?void 0:c.modelProfile)==null?void 0:r.ageRange)??"",context:(f==null?void 0:f.id)??"1:1"});At(p),Ce(p,1,n)}else Ce(l||go())},100)},onAction:async e=>{const o=e.type==="generate_image"?"Gerando imagem...":e.type==="generate_carousel"?"Gerando carrossel...":e.type==="set_style"?"Aplicando estilo...":e.type==="set_channel"?"Ajustando formato...":e.type==="set_font"?"Trocando fonte...":e.type==="set_overlay_color"||e.type==="set_overlay_opacity"?"Ajustando overlay...":e.type==="set_text_color"?"Atualizando cores...":e.type==="set_heading"||e.type==="set_text"?"Aplicando texto...":e.type==="add_text_box"?"Inserindo texto...":e.type==="add_widget"?"Adicionando widget...":"Aplicando...";Dn(!0),tn(o);const n=await wp(e);return e.type!=="generate_image"&&e.type!=="generate_carousel"&&setTimeout(()=>{Dn(!1),tn("")},400),n},onArtifactReady:()=>ht(!0),onSuggestionAction:gl,onReferenceImageDrop:(e,o,n,i)=>{ho(l=>[...l.slice(-2),{id:`ref-${Date.now()}`,dataUrl:n,base64:e,mimeType:o}]),i&&Ri(!0)},onFirstMessage:e=>{if(!xn||xn==="snew studio"||xn==="sem título"){const o=e.slice(0,45).toLowerCase();qi(o),fr(e.slice(0,60))}},onQualificationAnswer:hn,onAgentHandoff:e=>{const o=Iu(e,"agent");Jn(o),$u({title:e,session:o}),setTimeout(()=>{var n;return(n=Vn.current)==null?void 0:n.call(Vn,"open_document_poll")},150)}})})]})]})}),t.jsxs("div",{style:{display:Di?"none":"flex",flexDirection:"column",height:"100%",position:"relative",minWidth:0,background:"#F2F2F2"},children:[kd&&t.jsx("div",{style:{position:"absolute",top:0,right:0,left:0,height:"100%",background:"rgba(0,0,0,0.3)",zIndex:15,display:"flex",alignItems:"center",justifyContent:"center",animation:"dropIn 0.15s ease"},onClick:()=>xi(!1),children:t.jsxs("div",{style:{background:"#FFFFFF",borderRadius:16,padding:24,maxWidth:680,width:"90%",maxHeight:"80vh",overflowY:"auto",boxShadow:"0 20px 60px rgba(0,0,0,0.2)"},onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:20},children:[t.jsx("h3",{style:{fontSize:16,fontWeight:600,margin:0,color:"#1A1A1A"},children:"Estilos artísticos"}),t.jsx("button",{onClick:()=>xi(!1),style:{width:28,height:28,borderRadius:8,border:"1px solid #E2E2E2",background:"#FFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"#999"},children:t.jsx(je,{size:14})})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(140px, 1fr))",gap:10},children:ai.map(e=>t.jsxs("button",{onClick:()=>Oo(e),style:{display:"flex",flexDirection:"column",padding:0,border:`2px solid ${st===e.id?e.isBrandDna?"#C47A20":"#1A1A1A":e.isBrandDna?"#D4A064":"#E8E8E8"}`,borderRadius:12,overflow:"hidden",cursor:"pointer",textAlign:"left",fontFamily:"inherit",transition:"all 0.15s",background:e.isBrandDna?"linear-gradient(135deg, #FFFBF5, #FFF8EE)":"#FFFFFF"},children:[t.jsxs("div",{style:{width:"100%",height:80,position:"relative",background:e.preview,display:"flex",alignItems:"center",justifyContent:"center"},children:[e.isBrandDna&&t.jsx("span",{style:{position:"absolute",top:6,right:6,fontSize:12,color:"#D4A064",filter:"drop-shadow(0 1px 2px rgba(0,0,0,0.3))"}}),t.jsx("span",{style:{fontSize:24,fontFamily:Lr(e.font),textTransform:e.textCase,fontWeight:Number(e.fontWeight),letterSpacing:e.letterSpacing,color:e.textColor},children:"Aa"}),st===e.id&&t.jsx("span",{style:{position:"absolute",top:6,left:6,width:18,height:18,borderRadius:"50%",background:"#1A1A1A",color:"#FFF",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11}})]}),t.jsxs("div",{style:{padding:"8px 10px"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,flexWrap:"wrap"},children:[t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#1A1A1A"},children:e.name}),e.isBrandDna&&t.jsx("span",{style:{fontSize:9,fontWeight:600,color:"#C47A20",background:"#FFF0D6",border:"1px solid #F5CFA0",borderRadius:999,padding:"1px 5px",whiteSpace:"nowrap"},children:"Sua marca"})]}
199),t.jsx("span",{style:{fontSize:10,color:"#999",display:"block",marginTop:2,lineHeight:1.3},children:e.description})]})]},e.id))})]})}),Vu&&t.jsxs("div",{className:"scanner-drawer",style:{position:"absolute",top:0,right:0,width:360,height:"100%",background:"#FFFFFF",borderLeft:"1px solid #EBEBEB",display:"flex",flexDirection:"column",zIndex:20,overflowY:"auto",animation:"slideInRight 0.2s ease"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",justifyContent:"space-between",padding:"24px 20px 16px",borderBottom:"1px solid #F0F0F0"},children:[t.jsxs("div",{children:[t.jsx("p",{style:{fontSize:15,fontWeight:600,color:"#1A1A1A",margin:0},children:"Conversion Scanner"}),t.jsx("p",{style:{fontSize:12,color:"#999",margin:"2px 0 0"},children:"Análise de CMO"})]}),t.jsx("button",{onClick:()=>Qn(!1),style:{background:"none",border:"none",cursor:"pointer",color:"#999",display:"flex",alignItems:"center"},children:t.jsx(je,{size:16})})]}),!re&&!yr&&t.jsxs("div",{className:"scanner-setup",children:[t.jsxs("div",{className:"scanner-field",children:[t.jsx("label",{className:"scanner-label",children:"Objetivo da campanha"}),t.jsx("div",{className:"scanner-pills",children:[{id:"conversion",label:"Conversão direta"},{id:"retargeting",label:"Remarketing"},{id:"launch",label:"Lançamento"},{id:"awareness",label:"Awareness"}].map(e=>t.jsx("button",{className:`scanner-pill ${wt.campaignObjective===e.id?"active":""}`,onClick:()=>yn(o=>({...o,campaignObjective:e.id})),children:e.label},e.id))})]}),t.jsxs("div",{className:"scanner-field",children:[t.jsx("label",{className:"scanner-label",children:"Ticket médio (R$)"}),t.jsx("input",{type:"number",className:"scanner-input",value:wt.ticketAverage||"",onChange:e=>yn(o=>({...o,ticketAverage:Number(e.target.value)})),placeholder:"189"})]}),t.jsxs("div",{className:"scanner-field",children:[t.jsx("label",{className:"scanner-label",children:"Público-alvo"}),t.jsx("input",{type:"text",className:"scanner-input",value:wt.audience,onChange:e=>yn(o=>({...o,audience:e.target.value})),placeholder:"Ex: Mães de bebês, 25-40 anos"})]}),t.jsxs("div",{className:"scanner-field",children:[t.jsx("label",{className:"scanner-label",children:"Categoria do produto"}),t.jsx("input",{type:"text",className:"scanner-input",value:wt.productCategory,onChange:e=>yn(o=>({...o,productCategory:e.target.value})),placeholder:"Ex: Moda infantil"})]}),t.jsxs("div",{className:"scanner-field",children:[t.jsx("label",{className:"scanner-label",children:"Tem oferta / desconto?"}),t.jsxs("div",{className:"scanner-pills",children:[t.jsx("button",{className:`scanner-pill ${wt.isPromotional?"active":""}`,onClick:()=>yn(e=>({...e,isPromotional:!0})),children:"Sim"}),t.jsx("button",{className:`scanner-pill ${wt.isPromotional?"":"active"}`,onClick:()=>yn(e=>({...e,isPromotional:!1})),children:"Não"})]})]}),t.jsx(aa,{className:"w-full rounded-xl",onClick:kr,children:"Analisar criativo"})]}),yr&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,flex:1,padding:"40px 20px",color:"#888",fontSize:13},children:[t.jsx("div",{style:{width:48,height:48,borderRadius:"50%",border:"3px solid #E8E8E8",borderTopColor:"#1A1A1A",animation:"spin 0.8s linear infinite"}}),t.jsx("p",{style:{margin:0},children:"Analisando com olhar de CMO..."})]}),re&&!yr&&t.jsxs("div",{style:{padding:20,display:"flex",flexDirection:"column",gap:16},children:[t.jsxs("div",{style:{borderRadius:14,padding:20,textAlign:"center",display:"flex",flexDirection:"column",gap:4,background:re.level==="high"?"#F0FAF4":re.level==="medium"?"#FFF8EC":"#FEF2F2",border:`1.5px solid ${re.level==="high"?"#A8D5A2":re.level==="medium"?"#F5CFA0":"#FBBFBF"}`},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",color:"#888"},children:"Chance de conversão"}),t.jsxs("span",{style:{fontSize:40,fontWeight:800,lineHeight:1,color:re.level==="high"?"#2E7D52":re.level==="medium"?"#B45309":"#DC2626"},children:[re.score,"/100"]}),t.jsx("span",{style:{fontSize:13,fontWeight:600,color:re.level==="high"?"#2E7D52":re.level==="medium"?"#B45309":"#DC2626"},children:re.levelLabel})]}),re.cmoVerdict&&t.jsxs("div",{className:"cmo-verdict",children:[t.jsx("span",{className:"cmo-verdict-icon",children:"◎"}),t.jsxs("p",{className:"cmo-verdict-text",children:['"',re.cmoVerdict,'"']})]}),re.roasRiskLabel&&t.jsxs("div",{className:`roas-risk roas-${re.roasRisk||"medium"}`,children:[t.jsx("span",{style:{flexShrink:0},children:re.roasRisk==="high"?"▲":re.roasRisk==="low"?"":"→"}),t.jsx("span",{children:re.roasRiskLabel})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:(ic=re.dimensions)==null?void 0:ic.map(e=>t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[t.jsx("span",{style:{fontSize:12,fontWeight:500,color:"#444"},children:e.name}),t.jsxs("span",{style:{fontSize:12,fontWeight:600,color:e.level==="high"?"#2E7D52":e.level==="medium"?"#B45309":"#DC2626"},children:[e.score,"/100"]})]}),t.jsx("div",{style:{height:5,background:"#F0F0F0",borderRadius:999,overflow:"hidden"},children:t.jsx("div",{style:{height:"100%",borderRadius:999,transition:"width 0.5s ease",width:`${e.score}%`,background:e.level==="high"?"#4CAF7D":e.level==="medium"?"#F59E0B":"#EF4444"}})}
199),e.insight&&t.jsx("p",{className:"dim-insight",children:e.insight})]},e.id))}),((ac=re.risks)==null?void 0:ac.length)>0&&t.jsxs("div",{className:"scanner-section",children:[t.jsx("h4",{className:"scanner-section-title",children:"Riscos de ROAS"}),re.risks.map((e,o)=>t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start",padding:"6px 0"},children:[t.jsx("span",{style:{fontSize:13,fontWeight:600,flexShrink:0,marginTop:1,color:e.priority==="high"?"#DC2626":e.priority==="medium"?"#F59E0B":"#6B7280"},children:e.priority==="high"?"↑":e.priority==="medium"?"→":"↓"}),t.jsx("span",{style:{fontSize:12,color:"#444",lineHeight:1.5},children:e.text})]},o))]}),((rc=re.opportunities)==null?void 0:rc.length)>0&&t.jsxs("div",{className:"scanner-section",children:[t.jsx("h4",{className:"scanner-section-title",children:"Oportunidades"}),re.opportunities.map((e,o)=>t.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start",padding:"6px 0"},children:[t.jsx("span",{style:{fontSize:13,fontWeight:600,flexShrink:0,marginTop:1,color:e.priority==="high"?"#2E7D52":"#F59E0B"},children:e.priority==="high"?"↑":"→"}),t.jsx("span",{style:{fontSize:12,color:"#444",lineHeight:1.5},children:e.text})]},o))]}),zl&&Hl.length>0&&t.jsx("div",{className:"scanner-improving",children:Hl.map((e,o)=>t.jsxs("div",{className:`improve-step ${e.done?"done":e.active?"active":""}`,children:[t.jsx("span",{className:"improve-step-icon",children:e.done?"":e.active?"●":"○"}),t.jsx("span",{className:"improve-step-label",children:e.label})]},o))}),!zl&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx(aa,{className:"w-full rounded-xl",onClick:lp,children:"Aumentar chances de conversão"}),t.jsxs("button",{onClick:()=>{br(null)},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,height:32,background:"none",border:"none",fontSize:12,color:"#888",cursor:"pointer",transition:"color 0.15s",fontFamily:"inherit"},onMouseEnter:e=>e.currentTarget.style.color="#1A1A1A",onMouseLeave:e=>e.currentTarget.style.color="#888",children:[t.jsx(Pr,{size:12})," Reanalisar"]})]})]})]}),Yi&&t.jsxs("div",{style:{flexShrink:0,background:"#F2F2F2",display:"flex",alignItems:"center",height:44},children:[t.jsx("div",{style:{flex:1},children:t.jsx(Ip,{session:Yi,parent:Xn,activeId:jr?Yi.id:Xn.id,onNavigate:e=>{e.id===Xn.id?Zn(!1):e.id===Yi.id&&jt&&Zn(!0)}})}),jr&&t.jsxs("button",{onClick:()=>{Zn(!1)},style:{padding:"0 12px",height:28,marginRight:8,border:"1px solid transparent",borderRadius:6,background:"transparent",cursor:"pointer",fontSize:12,color:"hsl(var(--muted-foreground))",fontFamily:"inherit",display:"inline-flex",alignItems:"center",gap:5,flexShrink:0,transition:"background .12s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(0,0,0,0.04)"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:[t.jsx(je,{size:12})," voltar ao canvas"]})]}),t.jsxs("div",{onClick:()=>Ir(),onDragOver:e=>{L(y)&&(e.preventDefault(),e.stopPropagation())},onDrop:e=>{if(!L(y))return;e.preventDefault(),e.stopPropagation();const o=e.dataTransfer.files[0];if(!(o!=null&&o.type.startsWith("image/")))return;const n=new FileReader;n.onload=i=>{var s;const l=(s=i.target)==null?void 0:s.result;ne(l),Gt(l),et("cover"),tt(100),Ye({x:50,y:50})},n.readAsDataURL(o)},style:{position:"relative",flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",background:"#F2F2F2",padding:40,overflow:"auto"},children:[ye&&!Be&&!nt&&(()=>{var o;const e=Ot.find(n=>n.id===ye);return e?t.jsxs("div",{onClick:n=>n.stopPropagation(),className:"canvas-top-toolbar",style:{position:"absolute",top:8,left:"50%",transform:"translateX(-50%)",zIndex:999},children:[t.jsxs("button",{ref:rs,onMouseDown:n=>{n.stopPropagation(),Fa(i=>!i)},className:"ctt-btn ctt-font",children:[e.fontFamily.split(",")[0].replace(/['"]/g,"").trim()??"Inter",t.jsx(Mr,{size:11})]}),t.jsx(xp,{isOpen:xd,anchorEl:rs.current,selectedFontId:ke,onSelect:n=>{ao(n.id),Te(ye,{fontFamily:n.family}),Fa(!1)},onClose:()=>Fa(!1)}),t.jsx("div",{className:"ctt-divider"}),t.jsx("button",{className:"ctt-btn ctt-icon",title:"Texto esquerda",onClick:()=>Te(ye,{textAlign:"left"}),children:t.jsx(Ec,{size:13})}),t.jsx("button",{className:"ctt-btn ctt-icon",title:"Texto centro",onClick:()=>Te(ye,{textAlign:"center"}),children:t.jsx(Ic,{size:13})}),t.jsx("button",{className:"ctt-btn ctt-icon",title:"Texto direita",onClick:()=>Te(ye,{textAlign:"right"}),children:t.jsx($c,{size:13})}),t.jsx("div",{className:"ctt-divider"}),t.jsx("button",{className:"ctt-btn ctt-icon",title:"Mover textbox para esquerda",onClick:()=>Te(ye,{xRel:.04}),children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:[t.jsx("rect",{x:"1",y:"1",width:"2",height:"11",rx:"1",fill:"currentColor"}
199),t.jsx("rect",{x:"4",y:"4",width:"8",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2",fill:"none"})]})}),t.jsx("button",{className:"ctt-btn ctt-icon",title:"Centralizar textbox horizontalmente",onClick:()=>{const n=e.boxWidthRel??.88;Te(ye,{xRel:(1-n)/2})},children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:[t.jsx("rect",{x:"6",y:"1",width:"1.2",height:"11",rx:"0.6",fill:"currentColor"}),t.jsx("rect",{x:"2.5",y:"4",width:"8",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2",fill:"none"})]})}),t.jsx("button",{className:"ctt-btn ctt-icon",title:"Mover textbox para direita",onClick:()=>Te(ye,{xRel:Math.max(0,1-(e.boxWidthRel??.88)-.04)}),children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:[t.jsx("rect",{x:"10",y:"1",width:"2",height:"11",rx:"1",fill:"currentColor"}),t.jsx("rect",{x:"1",y:"4",width:"8",height:"5",rx:"1",stroke:"currentColor",strokeWidth:"1.2",fill:"none"})]})}),t.jsx("div",{className:"ctt-divider"}),t.jsx("button",{className:"ctt-btn ctt-icon",title:"Mover textbox para o topo",onClick:()=>Te(ye,{yRel:.04}),children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:[t.jsx("rect",{x:"1",y:"1",width:"11",height:"2",rx:"1",fill:"currentColor"}),t.jsx("rect",{x:"4",y:"4",width:"5",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.2",fill:"none"})]})}),t.jsx("button",{className:"ctt-btn ctt-icon",title:"Centralizar textbox verticalmente",onClick:()=>Te(ye,{yRel:.46}),children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:[t.jsx("rect",{x:"1",y:"6",width:"11",height:"1.2",rx:"0.6",fill:"currentColor"}),t.jsx("rect",{x:"4",y:"2.5",width:"5",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.2",fill:"none"})]})}),t.jsx("button",{className:"ctt-btn ctt-icon",title:"Mover textbox para a base",onClick:()=>Te(ye,{yRel:.88}),children:t.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 13 13",fill:"none",children:[t.jsx("rect",{x:"1",y:"10",width:"11",height:"2",rx:"1",fill:"currentColor"}),t.jsx("rect",{x:"4",y:"1",width:"5",height:"8",rx:"1",stroke:"currentColor",strokeWidth:"1.2",fill:"none"})]})}),t.jsx("div",{className:"ctt-divider"}),t.jsx("button",{className:"ctt-btn",onClick:()=>{var l;const n=((l=$t.current)==null?void 0:l.offsetWidth)??300,i=Math.round((e.fontSizeRel??.06)*n);Te(ye,{fontSizeRel:Math.max(8,i-2)/n})},children:"A-"}),t.jsxs("span",{className:"ctt-size",children:[Math.round((e.fontSizeRel??.06)*(((o=$t.current)==null?void 0:o.offsetWidth)??300)),"px"]}),t.jsx("button",{className:"ctt-btn",onClick:()=>{var l;const n=((l=$t.current)==null?void 0:l.offsetWidth)??300,i=Math.round((e.fontSizeRel??.06)*n);Te(ye,{fontSizeRel:Math.min(200,i+2)/n})},children:"A+"}),t.jsx("div",{className:"ctt-divider"}),t.jsxs("div",{className:"ctt-color-wrap",children:[t.jsx("input",{type:"color",value:e.color,onChange:n=>Te(ye,{color:n.target.value}),className:"ctt-color-input"}),t.jsx("div",{className:"ctt-color-preview",style:{background:e.color}})]}),t.jsx("div",{className:"ctt-divider"}),t.jsx("button",{className:"ctt-btn",title:e.textShadow?"Remover sombra":"Adicionar sombra",onClick:()=>Te(ye,{textShadow:e.textShadow?void 0:"0 2px 8px rgba(0,0,0,0.7)"}),style:{opacity:e.textShadow?1:.4,fontSize:12},children:"S"})]}):null})(),$i&&t.jsxs("div",{ref:Wn,className:"infinite-board",onMouseDown:tp,onMouseMove:op,onMouseUp:Ll,onMouseLeave:Ll,onWheel:np,style:{cursor:sr?"grabbing":"grab"},children:[t.jsxs("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none"},children:[t.jsx("defs",{children:t.jsx("pattern",{id:"board-dots",x:Mt.x%(20*Ge),y:Mt.y%(20*Ge),width:20*Ge,height:20*Ge,patternUnits:"userSpaceOnUse",children:t.jsx("circle",{cx:10*Ge,cy:10*Ge,r:Math.max(.8,Ge*.9),fill:"rgba(0,0,0,0.12)"})})}),t.jsx("rect",{width:"100%",height:"100%",fill:"url(#board-dots)"})]}),t.jsxs("div",{style:{position:"absolute",transform:`translate(${Mt.x}px, ${Mt.y}px) scale(${Ge})`,transformOrigin:"0 0",willChange:"transform"},children:[Bn.map(e=>t.jsxs("div",{"data-board-asset":"true",className:`board-asset-card ${e.isDragging?"is-dragging":""}`,style:{position:"absolute",left:e.x,top:e.y,width:e.width},onMouseDown:o=>ip(o,e.id),onDoubleClick:()=>Ol(e),children:[e.type==="document"?t.jsxs("div",{style:{height:e.height,background:"#FFFFFF",borderRadius:"10px 10px 0 0",display:"flex",flexDirection:"column",overflow:"hidden",border:"1px solid #E8E8E4"},children:[t.jsxs("div",{style:{padding:"16px 16px 12px",borderBottom:"1px solid #F0F0EC"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,marginBottom:8},children:[t.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#8B5CF6",flexShrink:0}}),t.jsx("span",{style:{fontSize:9,fontWeight:600,color:"#999",textTransform:"uppercase",letterSpacing:"0.04em"},children:"Documento"})]}),t.jsx("p",{style:{fontSize:13,fontWeight:600,color:"#1A1A1A",margin:0,lineHeight:1.3,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.label})]}),t.jsx("div",{style:{flex:1,padding:"12px 16px",overflow:"hidden"},children:t.jsx("p",{style:{fontSize:11,color:"#888",margin:0,lineHeight:1.6,display:"-webkit-box",WebkitLineClamp:6,WebkitBoxOrient:"vertical",overflow:"hidden"},children:e.documentExcerpt})}),t.jsx("div",{className:"board-asset-hover-overlay",style:{borderRadius:"10px 10px 0 0"},children:t.jsx("button",{className:"board-asset-open-btn",onClick:o=>{o.stopPropagation();try{sessionStorage.setItem("snew:restore-doc",JSON.stringify({markdown:e.documentMarkdown,title:e.label}))}catch{}window.location.href="/agent"},children:"Abrir no Agent"})})]}):t.jsx(t.Fragment,{children:t.jsxs("div",{className:"board-asset-image",style:{height:e.height},children:[t.jsx("img",{src:e.imageUrl,alt:e.label,draggable:!1,style:{width:"100%",height:"100%",objectFit:"cover",borderRadius:"10px 10px 0 0",display:"block",userSelect:"none"}}),t.jsx("div",{className:"board-asset-hover-overlay",children:t.jsx("button",{className:"board-asset-open-btn",onClick:o=>{o.stopPropagation(),Ol(e)},children:"Abrir no Studio"})})]})}),e.label&&e.type!=="document"&&t.jsxs("div",{className:"board-asset-label",children:[t.jsx("span",{className:"board-asset-label-text",children:e.label}),e.channel&&t.jsx("span",{className:"board-asset-channel-badge",children:e.channel})]})]},e.id)),Bn.length===0&&t.jsxs("div",{className:"board-empty-state",children:[t.jsx("span",{style:{fontSize:32,opacity:.3},children:"◈"}),t.jsx("p",{children:"Gere assets no Studio para organizá-los aqui"})]})]}),t.jsxs("div",{className:"board-hud",children:[t.jsxs("div",{className:"board-zoom-control
199s",children:[t.jsx("button",{onClick:()=>Pn(e=>Math.min(e*1.2,3)),className:"board-hud-btn",children:"+"}),t.jsxs("span",{className:"board-zoom-label",children:[Math.round(Ge*100),"%"]}),t.jsx("button",{onClick:()=>Pn(e=>Math.max(e*.8,.2)),className:"board-hud-btn",children:"−"}),t.jsx("button",{onClick:()=>{var j,P;const u=Bn.length,r=Math.min(u,3),p=Math.ceil(u/3),d=r*220+Math.max(0,r-1)*24,g=p*340+Math.max(0,p-1)*24,m=((j=Wn.current)==null?void 0:j.offsetWidth)??window.innerWidth,w=((P=Wn.current)==null?void 0:P.offsetHeight)??window.innerHeight;Pn(1),Mi({x:m/2-d/2,y:w/2-g/2})},className:"board-hud-btn",children:"◈"})]}),t.jsx("button",{onClick:Sr,className:"board-exit-btn",children:"← Voltar ao Studio"})]})]}),jr&&jt&&t.jsx("div",{style:{position:"absolute",inset:0,zIndex:50,display:"flex",flexDirection:"column",background:"hsl(var(--color-background-primary))",overflow:"hidden"},children:t.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"32px 40px",display:"flex",flexDirection:"column",gap:16,maxWidth:680,width:"100%",margin:"0 auto"},children:[t.jsx("div",{style:{borderRadius:10,overflow:"hidden",border:"1px solid hsl(var(--border))"},children:t.jsx("img",{src:jt.imageUrl,alt:"",style:{width:"100%",maxHeight:260,objectFit:"cover",display:"block"}})}),t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontSize:11,fontWeight:500,letterSpacing:"0.05em",textTransform:"uppercase",color:"hsl(var(--color-text-tertiary))"},children:{email:"Template de e-mail",copy:"Copy completo",social:"Pacote social",briefing:"Briefing de campanha",campaign:"Campanha completa",legenda:"Legenda",campanha:"Campanha",promocao:"Promoção",stories:"Stories",produto:"Descrição de produto"}[jt.type]??jt.type}),t.jsx("button",{onClick:()=>{navigator.clipboard.writeText(jt.rawText),E.success("Copiado!")},style:{fontSize:12,padding:"4px 12px",borderRadius:6,border:"1px solid hsl(var(--border))",background:"transparent",color:"hsl(var(--color-text-secondary))",cursor:"pointer",fontFamily:"inherit",transition:"background .1s"},onMouseEnter:e=>{e.currentTarget.style.background="hsl(var(--color-background-secondary))"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:"copiar tudo"})]}),jt.sections.map((e,o)=>t.jsxs("div",{children:[t.jsx("p",{style:{fontSize:10,fontWeight:500,letterSpacing:"0.05em",textTransform:"uppercase",color:"hsl(var(--color-text-tertiary))",margin:"0 0 6px"},children:e.label}),t.jsx("p",{style:{fontSize:14,lineHeight:1.7,margin:0,color:"hsl(var(--color-text-primary))",background:"hsl(var(--color-background-secondary))",borderRadius:8,padding:"12px 14px",whiteSpace:"pre-wrap"},children:e.text})]},o)),t.jsxs("div",{style:{display:"flex",gap:8,paddingTop:8,paddingBottom:32},children:[t.jsx("button",{onClick:()=>{Zn(!1),setTimeout(()=>gl("open_document_poll"),100)},style:{flex:1,padding:"9px 0",borderRadius:8,border:"1px solid hsl(var(--border))",background:"transparent",fontSize:13,color:"hsl(var(--color-text-secondary))",cursor:"pointer",fontFamily:"inherit",transition:"background .1s"},onMouseEnter:e=>{e.currentTarget.style.background="hsl(var(--color-background-secondary))"},onMouseLeave:e=>{e.currentTarget.style.background="transparent"},children:"↻ gerar outro tipo"}),t.jsx("button",{onClick:()=>{navigator.clipboard.writeText(jt.rawText),E.success("Copiado!")},style:{flex:1,padding:"9px 0",borderRadius:8,border:"none",background:"hsl(var(--foreground))",color:"hsl(var(--background))",fontSize:13,fontWeight:500,cursor:"pointer",fontFamily:"inherit",transition:"opacity .1s"},onMouseEnter:e=>{e.currentTarget.style.opacity=".8"},onMouseLeave:e=>{e.currentTarget.style.opacity="1"},children:"copiar tudo"})]})]})}),!$i&&t.jsx("div",{onClick:e=>e.stopPropagation(),style:{display:"flex",alignItems:"center",gap:16,width:"100%"},children:t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center"},children:[El?t.jsx("div",{ref:Vt,style:{width:"100%",display:"flex",flexDirection:"column",alignItems:"center"},children:H.length===0&&!an?t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,padding:"40px 24px",textAlign:"center",width:"min(520px, calc(100% - 80px))"},children:[t.jsx("span",{style:{fontSize:32,color:"#CCC",marginBottom:4},children:"▣"}),t.jsx("span",{style:{fontSize:16,fontWeight:600,color:"#1A1A1A"},children:"Criar carrossel"}),t.jsx("span",{style:{fontSize:13,color:"#888",lineHeight:1.5},children:"Gere slides com storytelling automático ou defina quantos slides quer."}),t.jsx("button",{onClick:()=>uo(!0),style:{display:"flex",alignItems:"center",gap:6,height:44,padding:"0 24px",borderRadius:12,border:"none",background:"#1A1A1A",color:"#FFFFFF",fontSize:14,fontWeight:600,cursor:"pointer",fontFamily:"inherit",marginTop:8,transition:"opacity 0.15s"},onMouseEnter:e=>e.currentTarget.style.opacity="0.85",onMouseLeave:e=>e.currentTarget.style.opacity="1",children:"Gerar carrossel"})]}):an&&H.length===0?t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:16,padding:"60px 24px",color:"#888",fontSize:13},children:[t.jsx("div",{style:{width:48,height:48,borderRadius:"50%",border:"3px solid #E8E8E8",borderTopColor:"#1A1A1A",animation:"spin 0.8s linear infinite"}}),t.jsx("p",{style:{margin:0},children:"Gerando slides com storytelling..."})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,justifyContent:"center",width:"100%"},children:[t.jsx("button",{onClick:()=>To(e=>Math.max(0,e-1)),disabled:M===0,style:{...Hc,opacity:M===0?.25:1,
199cursor:M===0?"not-allowed":"pointer"},children:t.jsx(Xp,{size:20})}),t.jsxs("div",{ref:Vt,onClick:e=>{e.target===e.currentTarget&&Ir()},style:{flex:1,maxWidth:480,aspectRatio:`${Qt.width} / ${Qt.height}`,maxHeight:"calc(100vh - 200px)",position:"relative",borderRadius:16,overflow:"visible",boxShadow:"0 8px 40px rgba(0,0,0,0.15)"},children:[t.jsxs("div",{style:{position:"absolute",inset:0,borderRadius:16,overflow:"hidden",backgroundImage:(sc=H[M])!=null&&sc.image&&((lc=H[M])==null?void 0:lc.image)!=="error"?`url(${H[M].image})`:`url(${y})`,backgroundSize:"cover",backgroundPosition:"center"},children:[t.jsx("div",{onClick:e=>{e.stopPropagation(),T(o=>o==="image"?null:"image"),Z(null),Pe(null)},style:{position:"absolute",inset:0,zIndex:1,cursor:"pointer",borderRadius:"inherit",outline:R==="image"?"2px solid #18A0FB":"none",outlineOffset:R==="image"?-2:0}}),!((cc=H[M])!=null&&cc.image)&&t.jsxs("div",{className:"slide-generating",style:{position:"absolute",inset:0,background:"#F2F2F2",borderRadius:"inherit",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center",zIndex:5},children:[t.jsx("div",{className:"conic-spinner",style:{animationDuration:"2.5s"}}),t.jsx("div",{className:"skeleton-noise"}),t.jsxs("div",{style:{position:"relative",zIndex:2,display:"flex",flexDirection:"column",alignItems:"center",gap:8},children:[t.jsx("div",{style:{display:"flex",gap:6},children:[0,1,2].map(e=>t.jsx("span",{className:"skeleton-dot",style:{animationDelay:`${e*.2}s`}},e))}),t.jsxs("span",{style:{fontSize:10,fontWeight:500,color:"rgba(0,0,0,0.35)",letterSpacing:"0.04em"},children:["Slide ",M+1]})]})]}),((dc=H[M])==null?void 0:dc.image)==="error"&&t.jsx("div",{style:{position:"absolute",inset:0,background:"#F5F5F5",display:"flex",alignItems:"center",justifyContent:"center",color:"#999",fontSize:12,zIndex:5},children:"Erro ao gerar imagem"}),t.jsx("div",{style:Oc(Ne,Ut,We,kt)}),t.jsxs("div",{style:pp,children:[((uc=H[M])==null?void 0:uc.heading)&&t.jsx(Hr,{fieldKey:"heading",value:H[M].heading,onChange:e=>Ar(M,"heading",e),selectedElement:R,editingElement:oe,setSelectedElement:T,setEditingElement:Z,style:{fontSize:Ra,fontWeight:Number(Aa)||700,color:ft,lineHeight:1.3,margin:0,marginBottom:6,fontFamily:$a,textTransform:Cd,letterSpacing:bi}}),((pc=H[M])==null?void 0:pc.description)&&t.jsx(Hr,{fieldKey:"description",value:H[M].description,onChange:e=>Ar(M,"description",e),selectedElement:R,editingElement:oe,setSelectedElement:T,setEditingElement:Z,style:{fontSize:Ta,fontWeight:400,color:ft,opacity:.85,lineHeight:1.4,margin:0,marginBottom:(gc=H[M])!=null&&gc.cta?10:0,fontFamily:$a,letterSpacing:bi}}),((mc=H[M])==null?void 0:mc.cta)&&t.jsx(Hr,{fieldKey:"cta",value:H[M].cta,onChange:e=>Ar(M,"cta",e),isCta:!0,selectedElement:R,editingElement:oe,setSelectedElement:T,setEditingElement:Z,style:{display:"inline-block",padding:"6px 16px",background:Ht,color:Sd,borderRadius:za,fontSize:Ea,fontWeight:600,fontFamily:$a,alignSelf:io==="right"?"flex-end":io==="center"?"center":"flex-start"}})]}),t.jsxs("p",{style:{position:"absolute",bottom:8,right:16,fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.08em",color:"rgba(255,255,255,0.5)",margin:0,zIndex:3},children:[((fc=(hc=H[M])==null?void 0:hc.product)==null?void 0:fc.toUpperCase())||A.toUpperCase()||"PRODUTO"," · SLIDE ",M+1,"/",H.length]})]}),Xl(),H.length>1&&t.jsx("button",{onClick:()=>{Ct(e=>e.filter((o,n)=>n!==M)),To(e=>Math.min(e,H.length-2))},style:{position:"absolute",top:12,right:12,zIndex:4,display:"flex",alignItems:"center",gap:5,padding:"6px 10px",background:"rgba(255,255,255,0.92)",backdropFilter:"blur(4px)",border:"none",borderRadius:8,fontSize:12,fontWeight:600,color:"#E53E3E",cursor:"pointer",boxShadow:"0 2px 8px rgba(0,0,0,0.12)",transition:"all 0.15s"},onMouseEnter:e=>{e.currentTarget.style.background="#FFF5F5"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255,255,255,0.92)"},children:t.jsx(Nc,{size:13})})]}),t.jsx("button",{onClick:()=>To(e=>Math.min(H.length-1,e+1)),disabled:M===H.length-1,style:{...Hc,opacity:M===H.length-1?.25:1,cursor:M===H.length-1?"not-allowed":"pointer"},children:t.jsx(sa,{size:20})})]}),t.jsx("div",{style:{display:"flex",gap:6,alignItems:"center",marginTop:16},children:H.map((e,o)=>t.jsx("button",{onClick:()=>To(o),style:{width:M===o?20:7,height:7,borderRadius:M===o?4:999,border:"none",cursor:"pointer",background:M===o?"#1A1A1A":"#CCCCCC",transition:"all 0.2s"}},o))}),t.jsx("button",{onClick:()=>uo(!0),style:{display:"flex",alignItems:"center",gap:6,background:"none",border:"none",fontSize:12,color:"#888",cursor:"pointer",marginTop:6,transition:"color 0.15s",fontFamily:"inherit"},onMouseEnter:e=>e.currentTarget.style.color="#1A1A1A",onMouseLeave:e=>e.currentTarget.style.color="#888",children:"↻ Regenerar carrossel"})]})}):L(y)?t.jsxs("div",{ref:Vt,style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",width:"100%",flex:1,gap:24},children:[t.jsx("div",{ref:$t,style:{position:"absolute",width:0,height:0,pointerEvents:"none"}}),Be||nt?t.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[t.jsx("div",{style:{width:48,height:48,borderRadius:"50%",border:"2.5px solid #E8E8E8",borderTopColor:"#1A1A1A",animation:"spin 0.8s linear infinite"}}),t.jsx("p",{style:{fontSize:13,fontWeight:500,color:"#555",margin:0,fontFamily:"inherit"},children:Oa||zi||"Gerando..."})]}):t.jsx("div",{style:{width:"100%",height:"100%",overflowY:"auto",padding:"28px 32px",boxSizing:"border-box",display:"flex",flexDirection:"column",gap:20},children:In?In==="video"?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16,maxWidth:600,margin:"0 auto",width:"100%",background:"#FFFFFF",borderRadius:16,padding:48,boxShadow:"0 1px 4px rgba(0,0,0,0.06)"},children:[t.jsx("textarea",{value:it,onChange:e=>bt(e.target.value),placeholder:"Descreva a cena ou deixe o Snew gerar automaticamente...",rows:3,style:{width:"100%",borderRadius:8,border:"1px solid #E5E3DC",padding:"10px 12px",fontSize:13,color:"#1A1A1A",background:"#FFFFFF",fontFamily:"inherit",resize:"none",outline:"none",lineHeight:1.55,boxSizing:"border-box"},onFocus:e=>{e.target.style.borderColor="#1A1A1A"},onBlur:e=>{e.target.style.borderColor="#E5E3DC"}}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr",gap:6},children:[t.jsxs("div",{style:{position:"relative"},children:[t.jsx("select",{value:yt,onChange:e=>_n(e.target.value),style:{width:"100%",appearance:"none",padding:"8px 32px 8px 12px",border:"1px solid #E5E3DC",borderRadius:8,fontSize:12,color:"#1A1A1A",background:"#FFFFFF",cursor:"pointer",fontFamily:"inherit",outline:"none"},children:ri.map(e=>t.jsx("option",{value:e.id,children:e.name},e.id))}),t.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",fontSize:10,
199color:"#9B978F"},children:"▾"})]}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx("select",{value:f.id,onChange:e=>{const o=mt.find(n=>n.id===e.target.value);o&&z(o)},style:{width:"100%",appearance:"none",padding:"8px 32px 8px 12px",border:"1px solid #E5E3DC",borderRadius:8,fontSize:12,color:"#1A1A1A",background:"#FFFFFF",cursor:"pointer",fontFamily:"inherit",outline:"none"},children:mt.map(e=>t.jsxs("option",{value:e.id,children:[e.label," — ",e.sublabel]},e.id))}),t.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",fontSize:10,color:"#9B978F"},children:"▾"})]}),t.jsxs("div",{style:{position:"relative"},children:[t.jsxs("select",{value:Yt,onChange:e=>al(Number(e.target.value)),style:{width:"100%",appearance:"none",padding:"8px 32px 8px 12px",border:"1px solid #E5E3DC",borderRadius:8,fontSize:12,color:"#1A1A1A",background:"#FFFFFF",cursor:"pointer",fontFamily:"inherit",outline:"none"},children:[t.jsx("option",{value:5,children:"5 segundos"}),t.jsx("option",{value:10,children:"10 segundos"})]}),t.jsx("span",{style:{position:"absolute",right:10,top:"50%",transform:"translateY(-50%)",pointerEvents:"none",fontSize:10,color:"#9B978F"},children:"▾"})]})]}),t.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr 1fr 1fr",gap:6},children:[ot?t.jsxs("div",{style:{position:"relative",borderRadius:8,overflow:"hidden",height:96,border:"1.5px solid #E5E3DC"},children:[t.jsx("img",{src:ot,alt:"ref",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),t.jsx("button",{onClick:()=>Wa(null),style:{position:"absolute",top:4,right:4,width:20,height:20,borderRadius:"50%",background:"rgba(0,0,0,0.5)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#FFF"},children:t.jsx(je,{size:10})}),t.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"3px 6px",background:"rgba(0,0,0,0.4)",fontSize:9,color:"rgba(255,255,255,0.9)",fontWeight:500},children:"Imagem"})]}):t.jsxs("div",{onClick:()=>{var e;return(e=Fs.current)==null?void 0:e.click()},onDragOver:e=>{e.preventDefault(),e.currentTarget.style.borderColor="#1A1A1A"},onDragLeave:e=>{e.currentTarget.style.borderColor="#D0CEC8"},onDrop:e=>{e.preventDefault(),e.currentTarget.style.borderColor="#D0CEC8";const o=e.dataTransfer.files[0];if(!(o!=null&&o.type.startsWith("image/")))return;const n=new FileReader;n.onload=i=>{var l;return Wa((l=i.target)==null?void 0:l.result)},n.readAsDataURL(o)},style:{height:96,borderRadius:8,cursor:"pointer",border:"1.5px dashed #D0CEC8",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:4,transition:"border-color .12s"},onMouseEnter:e=>{e.currentTarget.style.borderColor="#1A1A1A",e.currentTarget.style.background="#F5F4F1"},onMouseLeave:e=>{e.currentTarget.style.borderColor="#D0CEC8",e.currentTarget.style.background="transparent"},children:[t.jsx(ni,{size:14,color:"#9B978F"}),t.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#2C2A25"},children:"Imagem"}),t.jsx("span",{style:{fontSize:10,color:"#9B978F"},children:"Solte ou clique"})]}),t.jsx("input",{ref:Fs,type:"file",accept:"image/*",style:{display:"none"},onChange:e=>{var i;const o=(i=e.target.files)==null?void 0:i[0];if(!o)return;const n=new FileReader;n.onload=l=>{var s;return Wa((s=l.target)==null?void 0:s.result)},n.readAsDataURL(o),e.target.value=""}}),D?t.jsxs("div",{style:{position:"relative",borderRadius:8,overflow:"hidden",height:96,border:"1.5px solid #E5E3DC"},children:[t.jsx("img",{src:D.image,alt:D.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),t.jsx("button",{onClick:()=>Ld(null),style:{position:"absolute",top:4,right:4,width:20,height:20,borderRadius:"50%",background:"rgba(0,0,0,0.5)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#FFF"},children:t.jsx(je,{size:10})}),t.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"3px 6px",background:"rgba(0,0,0,0.4)",fontSize:9,color:"rgba(255,255,255,0.9)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:D.name})]}):t.jsxs("div",{onClick:()=>{so(!0),ln("")},style:{height:96,borderRadius:8,cursor:"pointer",border:"1.5px dashed #D0CEC8",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:4,transition:"all .12s"},onMouseEnter:e=>{e.currentTarget.style.borderColor="#1A1A1A",e.currentTarget.style.background="#F5F4F1"},onMouseLeave:e=>{e.currentTarget.style.borderColor="#D0CEC8",e.currentTarget.style.background="transparent"},children:[t.jsx(ii,{size:14,color:"#9B978F"}),t.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#2C2A25"},children:"Produto"}
199),t.jsx("span",{style:{fontSize:10,color:"#9B978F"},children:"Da sua loja"})]}),dt?t.jsxs("div",{style:{position:"relative",borderRadius:8,overflow:"hidden",height:96,border:"1.5px solid #E5E3DC"},children:[t.jsx("img",{src:dt,alt:"character",style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}),t.jsx("button",{onClick:()=>ki(null),style:{position:"absolute",top:4,right:4,width:20,height:20,borderRadius:"50%",background:"rgba(0,0,0,0.5)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#FFF"},children:t.jsx(je,{size:10})}),t.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"3px 6px",background:"rgba(0,0,0,0.4)",fontSize:9,color:"rgba(255,255,255,0.9)",fontWeight:500},children:"Personagem"})]}):t.jsxs("div",{onClick:()=>{var e;return(e=js.current)==null?void 0:e.click()},onDragOver:e=>{e.preventDefault(),e.currentTarget.style.borderColor="#1A1A1A"},onDragLeave:e=>{e.currentTarget.style.borderColor="#D0CEC8"},onDrop:e=>{e.preventDefault(),e.currentTarget.style.borderColor="#D0CEC8";const o=e.dataTransfer.files[0];if(!(o!=null&&o.type.startsWith("image/")))return;const n=new FileReader;n.onload=i=>{var l;return ki((l=i.target)==null?void 0:l.result)},n.readAsDataURL(o)},style:{height:96,borderRadius:8,cursor:"pointer",border:"1.5px dashed #D0CEC8",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:4,transition:"border-color .12s"},onMouseEnter:e=>{e.currentTarget.style.borderColor="#1A1A1A",e.currentTarget.style.background="#F5F4F1"},onMouseLeave:e=>{e.currentTarget.style.borderColor="#D0CEC8",e.currentTarget.style.background="transparent"},children:[t.jsx(Lc,{size:14,color:"#9B978F"}),t.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#2C2A25"},children:"Personagem"}),t.jsx("span",{style:{fontSize:10,color:"#9B978F"},children:"Foto da pessoa"})]}),t.jsx("input",{ref:js,type:"file",accept:"image/*",style:{display:"none"},onChange:e=>{var i;const o=(i=e.target.files)==null?void 0:i[0];if(!o)return;const n=new FileReader;n.onload=l=>{var s;return ki((s=l.target)==null?void 0:s.result)},n.readAsDataURL(o),e.target.value=""}}),t.jsxs("div",{style:{height:96,borderRadius:8,cursor:"pointer",border:"1.5px dashed #E5E3DC",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:4,transition:"all .12s",color:"#C2BFB5"},onMouseEnter:e=>{e.currentTarget.style.borderColor="#C2BFB5"},onMouseLeave:e=>{e.currentTarget.style.borderColor="#E5E3DC"},children:[t.jsx(Wr,{size:16,color:"#C2BFB5"}),t.jsx("span",{style:{fontSize:10,color:"#C2BFB5"},children:"Adicionar"})]})]}),vs&&t.jsxs("div",{style:{position:"relative",borderRadius:10,overflow:"hidden",border:"1.5px solid #E5E3DC"},children:[t.jsx("img",{src:vs,alt:"composite frame",style:{width:"100%",display:"block",borderRadius:10}}),t.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"6px 10px",background:"linear-gradient(transparent, rgba(0,0,0,0.5))",fontSize:10,color:"rgba(255,255,255,0.9)",fontWeight:500},children:"frame composto · pronto para animar"}),t.jsx("button",{onClick:()=>Ba(null),style:{position:"absolute",top:8,right:8,width:22,height:22,borderRadius:"50%",background:"rgba(0,0,0,0.5)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"#FFF"},children:t.jsx(je,{size:10})})]}),t.jsx("p",{style:{fontSize:11,fontWeight:500,color:"#9B978F",margin:0,letterSpacing:"0.04em"},children:"Estilo de motion"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:6},children:zt.map(e=>{const o=ct===e.id;return t.jsxs("button",{onClick:()=>{var i;const n=o?null:e.id;if(Od(n),n){const l=(D==null?void 0:D.name)??A??((i=c==null?void 0:c.productTypes)==null?void 0:i[0])??"";bt(e.buildPrompt(l))}else bt("")},style:{padding:0,border:"none",background:"none",cursor:"pointer",fontFamily:"inherit",display:"flex",flexDirection:"column",gap:5,textAlign:"left"},children:[t.jsxs("div",{style:{width:"100%",height:96,borderRadius:8,overflow:"hidden",position:"relative",border:o?"2px solid #1A1A1A":"1.5px solid #E5E3DC",background:"#F0EDE8",transition:"border-color .12s",flexShrink:0},onMouseEnter:n=>{o||(n.currentTarget.style.borderColor="#C2BFB5")}
199,onMouseLeave:n=>{o||(n.currentTarget.style.borderColor="#E5E3DC")},children:[t.jsx("video",{src:e.id==="advertising-product"?"https://videos.pexels.com/video-files/3571264/3571264-uhd_2560_1440_30fps.mp4":e.id==="close-up-detail"?"https://videos.pexels.com/video-files/3195394/3195394-uhd_2560_1440_25fps.mp4":e.id==="lifestyle-motion"?"https://videos.pexels.com/video-files/5483077/5483077-hd_1920_1080_25fps.mp4":e.id==="orbit-360"?"https://videos.pexels.com/video-files/4763824/4763824-hd_1920_1080_30fps.mp4":e.id==="unboxing-reveal"?"https://videos.pexels.com/video-files/7710229/7710229-hd_1920_1080_24fps.mp4":e.id==="floating-product"?"https://videos.pexels.com/video-files/3943988/3943988-hd_1920_1080_25fps.mp4":e.id==="story-emotional"||e.id==="tv-ad"?"https://videos.pexels.com/video-files/3571264/3571264-uhd_2560_1440_30fps.mp4":"https://videos.pexels.com/video-files/5483077/5483077-hd_1920_1080_25fps.mp4",autoPlay:!0,loop:!0,muted:!0,playsInline:!0,style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}),o&&t.jsx("div",{style:{position:"absolute",top:5,right:5,width:16,height:16,borderRadius:"50%",background:"#1A1A1A",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("svg",{width:"8",height:"6",viewBox:"0 0 8 6",fill:"none",children:t.jsx("path",{d:"M1 3l2 2 4-4",stroke:"#FFF",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})})]}),t.jsx("span",{style:{fontSize:11,fontWeight:o?500:400,color:o?"#1A1A1A":"#6B6760"},children:e.label})]},e.id)})}),ct&&(()=>{const e=zt.find(l=>l.id===ct);if(!e||e.refHint==="none")return null;const o=!!(D||ot),n=!!dt;return(e.refHint==="produto"?o:e.refHint==="personagem"?n:e.refHint==="both"?o&&n:!0)?null:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"9px 12px",borderRadius:8,background:"#FAFAF8",border:"1px solid #E5E3DC",fontSize:12,color:"#6B6760"},children:[t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",children:[t.jsx("circle",{cx:"7",cy:"7",r:"6",stroke:"#C2BFB5",strokeWidth:"1.2"}),t.jsx("path",{d:"M7 6v4M7 4.5v.5",stroke:"#C2BFB5",strokeWidth:"1.2",strokeLinecap:"round"})]}),t.jsx("span",{children:e.refLabel})]})})(),t.jsx("button",{disabled:en,onClick:async()=>{var r,p;const e=zt.find(d=>d.id===ct)??zt[0],o=(D==null?void 0:D.name)??A??((r=c==null?void 0:c.productTypes)==null?void 0:r[0])??"produto",n=ct==="tv-ad",i=!!dt,l=!!(D||ot);xt(null),gn("ai");let s;if(n&&(l||i)){No("Compondo cena com Gemini...");const d=await Su();if(d){if(ne(d),d.startsWith("data:"))s=d.split(",")[1];else try{s=await me(d)}catch{}No("Frame gerado. Animando com Kling...")}else{const g=ot??(D?(p=k.find(m=>m.id===D.id))==null?void 0:p.image:null)??dt;if(g){if(g.startsWith("data:"))s=g.split(",")[1];else try{s=await me(g)}catch{}ne(g)}}}else if(ot)if(ot.startsWith("data:"))s=ot.split(",")[1]??void 0,ne(ot);else try{s=await me(ot),ne(ot)}catch{}else if(D){const d=k.find(g=>g.id===D.id);if(d!=null&&d.image){if(d.image.startsWith("data:"))s=d.image.split(",")[1]??void 0;else try{s=await me(d.image)}catch{}ne(d.image)}}let u=it.trim()||e.buildPrompt(o);if(n&&i&&l&&(u+=" Animate the scene with slow cinematic camera movement. Person moves naturally with the product. Maintain commercial quality throughout."),bt(u),D){const d=k.find(g=>g.id===D.id);d&&ro([d.id])}s&&yt==="seedance-2.0"&&_n("kling-1.6"),Vi(s)},style:{width:"auto",height:40,borderRadius:8,padding:"0 24px",border:"none",background:"#1A1A1A",color:"#FFFFFF",fontSize:13,fontWeight:500,cursor:en?"wait":"pointer",fontFamily:"inherit",transition:"opacity .15s",display:"flex",alignItems:"center",justifyContent:"center",gap:7,alignSelf:"center",opacity:en?.7:1},onMouseEnter:e=>{en||(e.currentTarget.style.opacity=".85")},onMouseLeave:e=>{e.currentTarget.style.opacity=en?"0.7":"1"},children:en?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{size:14,style:{animation:"spin 1s linear infinite"}}),"Compondo cena..."]}):t.jsxs(t.Fragment,{children:[ct==="tv-ad"&&(D||ot)&&dt?"Compor + Gerar vídeo":"Gerar vídeo",ct&&zt.find(e=>e.id===ct)&&t.jsxs("span",{style:{opacity:.55,fontWeight:400},children:["· ",zt.find(e=>e.id===ct).label]})]})})]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[t.jsx("p",{style:{fontSize:11,fontWeight:700,color:"#AAA",textTransform:"uppercase",letterSpacing:"0.07em",margin:0},children:In==="image"?"Estilos de imagem":In==="carousel"?"Modelos de carrossel":"Copies e textos"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:12},children:(()=>{var l,s,u,r,p;const e=(c==null?void 0:c.name)??"sua loja",o=((l=c==null?void 0:c.productTypes)==null?void 0:l[0])??"produto",n=d=>{const g=ve.find(m=>m.id===d);g&&(Ve(g),Oo(g),Gn(go()||g.name,{hasStyle:!0})),xt(null)};return({image:[{id:"ecommerce",thumb:(s=ve.find(d=>d.id==="ecommerce-photography"))==null?void 0:s.thumbnailUrl,label:"E-commerce Photography",desc:"Produto limpo, fundo neutro, luz uniforme",action:()=>n("ecommerce-photography")},{id:"advertising",thumb:(u=ve.find(d=>d.id==="advertising-product"))==null?void 0:u.thumbnailUrl,label:"Advertising Product",desc:"Props, fundo dominante, luz dramática",action:()=>n("advertising-product")},{id:"lifestyle",thumb:(r=ve.find(d=>d.id==="product-lifestyle"))==null?void 0:r.thumbnailUrl,label:"Product Lifestyle",desc:"Produto integrado à cena real",action:()=>n("product-lifestyle")},{id:"fashion",thumb:(p=ve.find(d=>d.id==="fashion-on-model"))==null?void 0:p.thumbnailUrl,label:"Fashion On-Model",desc:"Pose de atitude, produto em destaque",action:()=>n("fashion-on-model")}
199],carousel:[{id:"benefits",emoji:"",bg:"#ECFDF5",label:"Benefícios do produto",desc:"1 benefício por slide, 5 slides",action:()=>{var d,g;I(!0),po("manual"),nn(5),(g=(d=te.current)==null?void 0:d.sendMessage)==null||g.call(d,`Criar carrossel de benefícios de ${o} de ${e}: 5 slides`),xt(null)}},{id:"before-after",emoji:"↔",bg:"#F5F3FF",label:"Antes e Depois",desc:"Transformação ou comparação, 4 slides",action:()=>{var d,g;I(!0),po("manual"),nn(4),(g=(d=te.current)==null?void 0:d.sendMessage)==null||g.call(d,`Criar carrossel antes e depois para ${e}: 4 slides`),xt(null)}},{id:"social-proof",emoji:"",bg:"#FFFBEB",label:"Prova Social",desc:"Reviews e depoimentos, 6 slides",action:()=>{var d,g;I(!0),po("manual"),nn(6),(g=(d=te.current)==null?void 0:d.sendMessage)==null||g.call(d,`Criar carrossel de prova social para ${e}: 6 slides`),xt(null)}},{id:"educational",emoji:"",bg:"#EFF6FF",label:"Educacional",desc:"Ensina algo sobre o produto, 5 slides",action:()=>{var d,g;I(!0),po("manual"),nn(5),(g=(d=te.current)==null?void 0:d.sendMessage)==null||g.call(d,`Criar carrossel educacional sobre ${o} de ${e}: 5 slides`),xt(null)}}],copy:[{id:"pack-6",emoji:"",bg:"#FFFBEB",label:"Pack 6 canais",desc:"InstagramLogo, Stories, WhatsappLogo, Email, TiktokLogo, LinkedinLogo",action:()=>{var d,g;(g=(d=te.current)==null?void 0:d.sendMessage)==null||g.call(d,`Pack de copies para ${o} de ${e}: 6 canais com headline, corpo e CTA`),xt(null)}},{id:"email-seq",emoji:"",bg:"#EFF6FF",label:"Sequência de e-mail",desc:"Boas-vindas, nurturing e retenção",action:()=>{var d,g;(g=(d=te.current)==null?void 0:d.sendMessage)==null||g.call(d,`Sequência de e-mails para ${e}: D0 boas-vindas, D3 nurturing, D14 conversão, D30 retenção`),xt(null)}},{id:"whatsapp",emoji:"",bg:"#ECFDF5",label:"Fluxos WhatsappLogo",desc:"Carrinho abandonado, pós-compra, reativação",action:()=>{var d,g;(g=(d=te.current)==null?void 0:d.sendMessage)==null||g.call(d,`Fluxos de WhatsappLogo para ${e}: carrinho abandonado, pós-compra e reativação`),xt(null)}},{id:"ads-copy",emoji:"",bg:"#FEF2F2",label:"Copies para Ads",desc:"Meta e Google com headlines e variações",action:()=>{var d,g;(g=(d=te.current)==null?void 0:d.sendMessage)==null||g.call(d,`Copies para Meta Ads e Google Ads de ${o} de ${e}: headlines, descrições e variações`),xt(null)}}]}[In]??[]).map((d,g)=>t.jsxs("button",{onClick:d.action,style:{border:"1px solid #EEECEA",borderRadius:14,padding:0,background:"#FFFFFF",cursor:"pointer",fontFamily:"inherit",textAlign:"left",overflow:"hidden",transition:"all 0.15s",animation:"fadeSlideUp 0.25s ease both",animationDelay:`${g*50}ms`},onMouseEnter:m=>{m.currentTarget.style.transform="translateY(-3px)",m.currentTarget.style.boxShadow="0 8px 24px rgba(0,0,0,0.10)",m.currentTarget.style.borderColor="#D0CEC8"},onMouseLeave:m=>{m.currentTarget.style.transform="none",m.currentTarget.style.boxShadow="none",m.currentTarget.style.borderColor="#EEECEA"},children:[t.jsx("div",{style:{width:"100%",aspectRatio:"16/9",background:d.bg??"#F0EEE8",overflow:"hidden",display:"flex",alignItems:"center",justifyContent:"center"},children:d.thumb?t.jsx("img",{src:d.thumb,alt:d.label,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):t.jsx("span",{style:{fontSize:36,opacity:.7},children:d.emoji})}),t.jsxs("div",{style:{padding:"12px 14px 14px"},children:[t.jsx("p",{style:{fontSize:13,fontWeight:600,color:"#1A1A1A",margin:"0 0 4px",lineHeight:1.3},children:d.label}),t.jsx("p",{style:{fontSize:11,color:"#888",margin:0,lineHeight:1.5},children:d.desc})]})]},d.id))})()})]}):t.jsx("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",overflow:"hidden"},children:Dt!=="done"?t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",width:"100%",overflow:"hidden"},children:[t.jsxs("div",{style:{flexShrink:0,padding:"28px 36px 16px",display:"flex",flexDirection:"column",alignItems:"center",gap:16},children:[t.jsx("div",{style:{display:"flex",alignItems:"center",gap:8},children:["product","style"].map((e,o)=>t.jsxs(Uc.Fragment,{children:[t.jsx("div",{style:{width:24,height:24,borderRadius:"50%",background:Dt===e?"#1A1A1A":"#E8E8E8",display:"flex",alignItems:"center",justifyContent:"center",fontSize:10,fontWeight:500,color:Dt===e?"#FFF":"#AAA",transition:"all .2s"},children:o+1}),o===0&&t.jsx("div",{style:{width:32,height:1,background:"#E8E8E8"}})]},e))}),t.jsxs("div",{style:{textAlign:"center"},children:[t.jsx("p",{style:{fontSize:18,fontWeight:500,color:"#1A1A1A",margin:"0 0 4px"},children:Dt==="product"?"Qual produto você quer destacar?":"Qual estilo visual?"}),t.jsx("p",{style:{fontSize:12,color:"#AAA",margin:0},children:Dt==="product"?"Escolha um produto da sua loja ou faça upload de uma imagem":"Escolha um estilo visual para a imagem"})]}),Dt==="product"&&t.jsxs("div",{style:{position:"relative",width:"100%",maxWidth:400},children:[t.jsx("input",{type:"text",placeholder:"Buscar produto...",value:nr,onChange:e=>{cu(e.target.value),Zs(12)},style:{width:"100%",padding:"9px 14px 9px 36px",borderRadius:10,border:"1px solid #E8E8E8",background:"#FAFAF8",fontSize:13,color:"#1A1A1A",fontFamily:"inherit",outline:"none",boxSizing:"border-box"},onFocus:e=>{e.target.style.borderColor="#1A1A1A",e.target.style.background="#FFF"},onBlur:e=>{e.target.style.borderColor="#E8E8E8",e.target.style.background="#FAFAF8"}}),t.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",style:{position:"absolute",left:12,top:"50%",transform:"translateY(-50%)",pointerEvents:"none"},children:[t.jsx("circle",{cx:"6",cy:"6",r:"4.5",stroke:"#BBB",strokeWidth:"1.3"}),t.jsx("path",{d:"M10 10l2.5 2.5",stroke:"#BBB",strokeWidth:"1.3",strokeLinecap:"round"})]})]})]}),t.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"0 36px"},children:[t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8,paddingBottom:12},children:Dt==="product"?du.map(e=>{const o=Ks===e.id;return t.jsxs("button",{onClick:()=>{ru(e.id),ro([e.id]),Po("style")},style:{padding:0,border:`2px solid ${o?"#1A1A1A":"transparent"}`,borderRadius:10,overflow:"hidden",background:"#F5F5F3",cursor:"pointer",textAlign:"left",transition:"border-color .12s, transform .12s"},onMouseEnter:n=>{n.currentTarget.style.borderColor="#CCC",n.currentTarget.style.transform="scale(1.02)"},onMouseLeave:n=>{n.currentTarget.style.borderColor=o?"#1A1A1A":"transparent",n.currentTarget.style.transform="scale(1)"},children:[t.jsx("div",{style:{width:"100%",aspectRatio:"1/1",overflow:"hidden"},children:t.jsx("img",{src:e.image,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}})}),t.jsx("div",{style:{padding:"6px 8px",background:"#FFFFFF"},children:t.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#1A1A1A",dis
199play:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})})]},e.id)}):ve.map(e=>{const o=su===e.id;return t.jsxs("button",{onClick:()=>{var l,s,u;lu(e.id),Ve(e),Po("done");const n=k.find(r=>r.id===Ks),i=((l=n==null?void 0:n.name)==null?void 0:l.trim())||"";if(e.buildPrompt){const r=e.buildPrompt({productName:i||"the product",productDescription:(n==null?void 0:n.description)??"",brandName:(c==null?void 0:c.name)??"",niche:(c==null?void 0:c.niche)??"",audience:(c==null?void 0:c.audience)??"",modelGender:((s=c==null?void 0:c.modelProfile)==null?void 0:s.gender)??"",modelAge:((u=c==null?void 0:c.modelProfile)==null?void 0:u.ageRange)??"",context:(f==null?void 0:f.id)??"1:1"});At(r),Ce(r,1,e)}},style:{padding:0,border:`2px solid ${o?"#1A1A1A":"transparent"}`,borderRadius:10,overflow:"hidden",background:"#F5F5F3",cursor:"pointer",textAlign:"left",transition:"border-color .12s, transform .12s"},onMouseEnter:n=>{n.currentTarget.style.borderColor="#CCC",n.currentTarget.style.transform="scale(1.02)"},onMouseLeave:n=>{n.currentTarget.style.borderColor=o?"#1A1A1A":"transparent",n.currentTarget.style.transform="scale(1)"},children:[t.jsx("div",{style:{width:"100%",aspectRatio:"4/3",overflow:"hidden",background:e.color??"#E8E6E0"},children:e.thumbnailUrl?t.jsx("img",{src:e.thumbnailUrl,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):t.jsx("div",{style:{width:"100%",height:"100%",background:e.color??"#DEDBD6"}})}),t.jsx("div",{style:{padding:"6px 8px",background:"#FFFFFF"},children:t.jsx("span",{style:{fontSize:11,fontWeight:500,color:"#1A1A1A",display:"block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.name})})]},e.id)})}),Dt==="product"&&uu&&t.jsx("div",{style:{display:"flex",justifyContent:"center",paddingBottom:16},children:t.jsxs("button",{onClick:()=>Zs(e=>e+12),style:{padding:"7px 20px",borderRadius:8,border:"1px solid #E8E8E8",background:"transparent",fontSize:12,color:"#888",cursor:"pointer",fontFamily:"inherit",transition:"all .1s"},onMouseEnter:e=>{e.currentTarget.style.borderColor="#1A1A1A",e.currentTarget.style.color="#1A1A1A"},onMouseLeave:e=>{e.currentTarget.style.borderColor="#E8E8E8",e.currentTarget.style.color="#888"},children:["carregar mais (",rr.length-ir," restantes)"]})}),Dt==="product"&&t.jsxs("div",{onDragOver:e=>{e.preventDefault(),ar(!0)},onDragLeave:()=>ar(!1),onDrop:e=>{var n;e.preventDefault(),ar(!1);const o=(n=e.dataTransfer.files)==null?void 0:n[0];o&&el(o)},style:{border:`1.5px dashed ${un?"#1A1A1A":"#DDDDD8"}`,borderRadius:12,padding:"20px 16px",marginBottom:16,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,background:un?"#F5F5F3":"transparent",transition:"border-color .15s, background .15s"},children:[t.jsxs("svg",{width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",children:[t.jsx("rect",{x:"2",y:"2",width:"18",height:"18",rx:"4",stroke:un?"#1A1A1A":"#CCC",strokeWidth:"1.3"}),t.jsx("circle",{cx:"7.5",cy:"7.5",r:"2",stroke:un?"#1A1A1A":"#CCC",strokeWidth:"1.3"}),t.jsx("path",{d:"M2 14.5l5-5 4 4 3-3 6 6",stroke:un?"#1A1A1A":"#CCC",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round"})]}),t.jsx("p",{style:{fontSize:12,color:un?"#1A1A1A":"#BBB",margin:0,textAlign:"center",transition:"color .15s"},children:"Arraste uma imagem de referência aqui"}),t.jsxs("label",{style:{fontSize:11,color:"#CCC",cursor:"pointer",textDecoration:"underline",textUnderlineOffset:2},children:["ou clique para fazer upload",t.jsx("input",{type:"file",accept:"image/*",style:{display:"none"},onChange:e=>{var n;const o=(n=e.target.files)==null?void 0:n[0];o&&(el(o),e.target.value="")}})]})]})]}),t.jsxs("div",{style:{flexShrink:0,padding:"12px 36px 20px",display:"flex",gap:16,alignItems:"center",justifyContent:"center"},children:[Dt==="style"&&t.jsx("button",{onClick:()=>Po("product"),style:{fontSize:12,color:"#BBB",background:"transparent",border:"none",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:e=>{e.currentTarget.style.color="#888"},onMouseLeave:e=>{e.currentTarget.style.color="#BBB"},children:"← voltar"}),t.jsx("button",{onClick:()=>Po("done"),style:{fontSize:12,color:"#BBB",background:"transparent",border:"none",cursor:"pointer",fontFamily:"inherit"},onMouseEnter:e=>{e.currentTarget.style.color="#888"},onMouseLeave:e=>{e.currentTarget.style.color="#BBB"},children:"pular →"})]})]}):t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:12,opacity:.35},children:[t.jsx(Vo,{size:26,style:{color:"#AAA"}}),t.jsx("p",{style:{fontSize:13,color:"#AAA",margin:0},children:"Descreva o que quer criar no chat"})]})})})]}):t.jsx("div",{ref:Vt,style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%",gap:10},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:e=>{e.preventDefault(),e.stopPropagation();const o=e.dataTransfer.files[0];if(!(o!=null&&o.type.startsWith("image/")))return;const n=new FileReader;n.onload=i=>{var s;const l=(s=i.target)==null?void 0:s.result;ne(l),Gt(l),et("cover"),tt(100),Ye({x:50,y:50})},n.readAsDataURL(o)},children:t.jsxs("div",{onMouseEnter:()=>Xr(!0),onMouseLeave:()=>Xr(!1),style:{position:"relative",width:`min(100%, ${Qt.width>=Qt.height?720:480}px)`},children:[yp(`${Qt.width} / ${Qt.height}`,Qt.width>=Qt.height?720:480,y,$t),!L(y)&&Jc&&!ye&&!ci&&!Ke&&!R&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{position:"absolute",top:10,left:10,display:"flex",gap:5,zIndex:20,animation:"pillsFadeIn 0.18s ease-out both"},children:[(f==null?void 0:f.id)??"9:16",`${(f==null?void 0:f.width)??1080} × ${(f==null?void 0:f.height)??1920}
199`,S==null?void 0:S.name].filter(Boolean).map((e,o)=>t.jsx("span",{style:{fontSize:10,fontWeight:500,color:"rgba(255,255,255,0.85)",background:"rgba(0,0,0,0.45)",backdropFilter:"blur(8px)",padding:"3px 8px",borderRadius:6,letterSpacing:"0.01em"},children:e},o))}),t.jsxs("div",{style:{position:"absolute",bottom:10,left:10,display:"flex",gap:6,zIndex:20,animation:"regenFadeIn 0.18s ease-out both"},children:[t.jsx("button",{onClick:e=>{e.stopPropagation(),Fr()},title:"Gerar nova versão",style:{width:32,height:32,borderRadius:"50%",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(8px)",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.9)",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.12s"},onMouseEnter:e=>e.currentTarget.style.background="rgba(0,0,0,0.82)",onMouseLeave:e=>e.currentTarget.style.background="rgba(0,0,0,0.55)",children:t.jsx(Dc,{size:14})}),t.jsx("button",{onClick:e=>{var o;e.stopPropagation(),(o=Jr.current)==null||o.click()},title:"Substituir imagem",style:{width:32,height:32,borderRadius:"50%",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(8px)",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.9)",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.12s"},onMouseEnter:e=>e.currentTarget.style.background="rgba(0,0,0,0.82)",onMouseLeave:e=>e.currentTarget.style.background="rgba(0,0,0,0.55)",children:t.jsx(ni,{size:14})})]}),t.jsxs("div",{style:{position:"absolute",bottom:10,right:10,display:"flex",gap:6,zIndex:20,animation:"regenFadeIn 0.18s ease-out both"},children:[t.jsx("button",{onClick:e=>{e.stopPropagation(),T(null),Cn(!0),zn(null)},title:"Editar imagem",style:{width:32,height:32,borderRadius:"50%",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(8px)",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.9)",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.12s"},onMouseEnter:e=>e.currentTarget.style.background="rgba(0,0,0,0.82)",onMouseLeave:e=>e.currentTarget.style.background="rgba(0,0,0,0.55)",children:t.jsx(Pc,{size:14})}),t.jsx("button",{onClick:e=>{e.stopPropagation(),T(null),Fe(o=>o==="imagefit"?null:"imagefit")},title:"Dimensionar",style:{width:32,height:32,borderRadius:"50%",background:Do==="imagefit"?"rgba(0,0,0,0.85)":"rgba(0,0,0,0.55)",backdropFilter:"blur(8px)",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.9)",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.12s"},onMouseEnter:e=>e.currentTarget.style.background="rgba(0,0,0,0.82)",onMouseLeave:e=>e.currentTarget.style.background=Do==="imagefit"?"rgba(0,0,0,0.85)":"rgba(0,0,0,0.55)",children:t.jsx(ig,{size:14})}),t.jsx("button",{onClick:e=>{e.stopPropagation(),T(null),mr("video"),gn("ai"),Xt&&bt(qn())},title:"Gerar vídeo",style:{width:32,height:32,borderRadius:"50%",background:"rgba(0,0,0,0.55)",backdropFilter:"blur(8px)",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.9)",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.12s"},onMouseEnter:e=>e.currentTarget.style.background="rgba(0,0,0,0.82)",onMouseLeave:e=>e.currentTarget.style.background="rgba(0,0,0,0.55)",children:t.jsx(Br,{size:14})})]}),t.jsx("input",{ref:Jr,type:"file",accept:"image/*",style:{display:"none"},onChange:e=>{var i;const o=(i=e.target.files)==null?void 0:i[0];if(!o)return;const n=new FileReader;n.onload=l=>{var u;const s=(u=l.target)==null?void 0:u.result;ne(s),Gt(s),et("cover"),tt(100),Ye({x:50,y:50}),It(0),ko(!1),Sn(!1),kn(!1),Ue(),E.success("imagem substituída.")},n.readAsDataURL(o),e.target.value=""}})]})]})}),(()=>{if(!y||L(y))return null;const e=fn.filter(i=>i.imageUrl&&i.imageUrl.length>10&&!L(i.imageUrl)),o=new Set,n=[];for(const i of e)o.has(i.imageUrl)||(o.add(i.imageUrl),n.push({id:i.id,url:i.imageUrl,channel:i.channel,isVideo:i.isVideo}));return o.has(y)||n.unshift({id:"__current__",url:y}),n.length<2?null:t.jsxs("div",{style:{position:"absolute",bottom:16,left:"50%",transform:"translateX(-50%)",display:"flex",gap:6,alignItems:"center",background:"rgba(255,255,255,0.92)",backdropFilter:"blur(12px)",borderRadius:14,padding:"6px 8px",boxShadow:"0 2px 16px rgba(0,0,0,0.1)",zIndex:50,overflowX:"auto",maxWidth:"90%",scrollbarWidth:"none"},children:[n.slice(0,10).map(i=>{const l=i.url===y;return t.jsx("button",{onClick:s=>{if(s.preventDefault(),s.stopPropagation(),i.url!==y){if(ne(i.url),i.channel){const u=mt.find(r=>r.id===i.channel);u&&z(u)}et("cover"),tt(100),Ye({x:50,y:50})}},style:{padding:0,background:"none",cursor:"pointer",flexShrink:0,borderRadius:8,overflow:"hidden",border:`2.5px solid ${l?"#1A1A1A":"transparent"}`,outline:"none",transition:"all 0.12s",transform:l?"scale(1.05)":"scale(1)",boxShadow:l?"0 2px 8px rgba(0,0,0,0.15)":"none"},children:t.jsxs("div",{style:{position:"relative",width:48,height:48},children:[t.jsx("img",{src:i.url,alt:"",draggable:!1,style:{width:48,height:48,objectFit:"cover",display:"block"}}),i.isVideo&&t.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(0,0,0,0.25)"},children:t.jsx(ng,{size:16,fill:"#fff",color:"#fff",style:{marginLeft:2}})})]})},i.id)}),t.jsxs("label",{title:"UploadSimple imagem",style:{padding:0,cursor:"pointer",flexShrink:0,borderRadius:8,overflow:"hidden",border:"2px dashed #ccc",outline:"none",width:48,height:48,display:"flex",alignItems:"center",justifyContent:"center",background:"#F0F0F0",transition:"all 0.12s"},onMouseEnter:i=>{i.currentTarget.style.borderColor="#999",i.currentTarget.style.background="#E8E8E8"},onMouseLeave:i=>{i.currentTarget.style.borderColor="#ccc",i.currentTarget.style.background="#F0F0F0"},children:[t.jsx(ni,{size:20,color:"#999"}),t.jsx("input",{type:"file",accept:"image/*",style:{display:"none"},onChange:i=>{var u;const l=(u=i.target.files)==null?void 0:u[0];if(!l)return;const s=new FileReader;s.onload=r=>{var d;const p=(d=r.target)==null?void 0:d.result;p&&(ne(p),et("cover"),tt(100),Ye({x:50,y:50}))},s.readAsDataURL(l),i.target.value=""}})]})]})})(),!L(y)&&t.jsxs("div",{className:"image-edit-sidebar",onClick:e=>e.stopPropagation(),children:[t.jsxs("button",{className:`ies-item ${Do==="style"?"active":""}`,onClick:()=>{xi(!0),T(null)},title:"Modelos",children:[t.jsx(og,{size:16}),t.jsx("span",{children:"Modelos"})]}),t.jsxs("button",{className:`ies-item ${Do==="overlay"?"active":""}`,onClick:()=>mr("overlay"),title:"Overlay",children:[t.jsx(Mc,{size:16}),t.jsx("span",{children:"Overlay"})]}),t.jsxs("button",{className:`ies-item ${Do==="channel"?"active":""}`,onClick:()=>{Mo(!0),Fe("channel"),T(null)},title:"Formato",children:[t.jsx(Nr,{size:16}),t.jsx("span",{children:"Formato"})]}),t.jsxs("button",{className:"ies-item",onClick:$d,title:"Adicionar conteúdo",children:[t.jsx(Wr,{size:16}),t.jsx("span",{children:"Conteúdo"})]}),t.jsxs("button",{className:`ies-item ${or?"active":""}`,onClick:()=>fo(e=>!e),title:"Widgets",children:[t.jsx(eg,{size:16}),t.jsx("span",{children:"Widgets"})]}),t.jsx("div",{className:"ies-divider"}),t.jsxs("button",{className:"ies-item",onClick:()=>Qn(!0),title:"Scan",style:{opacity:L(y)?.3:1,pointerEvents:L(y)?"none":"auto"},children:[t.jsx($p,{size:16}),t.jsx("span",{children:"Scan"})]}),t.jsxs("button",{className:"ies-item",onClick:()=>Hn(!0),title:"Publicar",style:{opacity:L(y)?.3:1,pointerEvents:L(y)?"none":"auto"},children:[t.jsx(Vp,{size:16}),t.jsx("span",{children:"Publicar"})]}),t.jsx("div",{className:"ies-divider"}),t.jsxs("button",{className:"ies-item",onClick:()=>vr(),title:"DownloadSimple",style:{opacity:L(y)?.3:1,pointerEvents:L(y)?"none":"auto"},children:[t.jsx(jn,{size:16}),t.jsx("span",{children:"DownloadSimple"})]}),t.jsxs("button",{className:`ies-item ${da?"save-animating":""}`,onClick:Kn,title:"Salvar",style:{opacity:L(y)?.3:1,pointerEvents:L(y)?"none":"auto"},children:[t.jsx(Wc,{size:16}),t.jsx("span",{children:"Salvar"})]})]}),ks&&Ha.length>0&&t.jsxs("div",{onClick:e=>e.stopPropagation(),style:{position:"absolute",right:60,top:12,display:"flex",flexDirection:"column",gap:8,padding:"12px 14px",background:"rgba(30,30,30,0.92)",backdropFilter:"blur(12px)",borderRadius:10,zIndex:30,minWidth:160},children:[t.jsx("span",{style:{fontSize:10,fontWeight:600,color:"rgba(255,255,255,0.4)",textTransform:"uppercase",letterSpacing:"0.08em"},children:"Estilo de anotação"}),t.jsx("div",{style:{display:"flex",gap:4},children:["technical","editorial"].map(e=>t.jsx("button",{onClick:()=>Xd(e),style:{flex:1,height:30,borderRadius:6,border:"none",background:Ga===e?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.05)",color:Ga===e?"#FFFFFF":"rgba(255,255,255,0.4)",fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:e==="technical"?"⊢ Technical":"↝ Editorial"},e))}),t.jsx("button",{onClick:()=>{Cs(!1),Ua([])},style:{height:28,borderRadius:6,border:"1px solid rgba(255,255,255,0.1)",background:"transparent",color:"rgba(255,255,255,0.35)",fontSize:11,cursor:"pointer",fontFamily:"inherit"},children:"Remover anotações"})]})]})}),null,ha&&t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:11,color:"#999",padding:"4px 10px",borderRadius:999,background:"#F0F0F0",marginTop:-4,alignSelf:"center"},children:[t.jsx(ni,{size:11}),"Texto gerado na imagem"]}),!1,!1]}),fd&&Ko&&t.jsxs("div",{className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50,width:300},onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[t.jsx("span",{className:"float-window-title",style:{margin:0},children:"Gerar texto"}),t.jsx("button",{onClick:()=>{Rn(!1),ja(null)},style:{background:"none",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.5)",display:"flex",alignItems:"center"},children:t.jsx(je,{size:14})})]}),t.jsx("textarea",{className:"ig-textarea",value:gi,onChange:e=>mi(e.target.value),rows:3,autoFocus:!0,placeholder:"Texto do box...",style:{marginBottom:10}}),t.jsxs("div",{className:"ig-field",children:[t.jsx("span",{className:"ig-label",children:"Estilo"}),t.jsx("div",{className:"ftg-tone-grid",children:[{id:"emotional",emoji:"",label:"Emocional"},{id:"urgent",emoji:"",label:"Urgente"},{id:"playful",emoji:"◡",label:"Divertido"},{id:"elegant",emoji:"",label:"Elegante"},{id:"direct",emoji:"→",label:"Direto"},{id:"promotional",emoji:"%",label:"Promoção"},{id:"scarcity",emoji:"⏱",label:"Escassez"},{id:"surprise",emoji:"",label:"Surpreenda-me"}].map(e=>t.jsx("button",{className:"ftg-tone-btn",disabled:is===Ko,onClick:async()=>{var o,n;as(Ko);try{const i=((o=v==null?void 0:v.name)==null?void 0:o.trim())||(A==null?void 0:A.trim())||"",l=((n=S==null?void 0:S.name)==null?void 0:n.trim())||"";let s=null;if(y&&!L(y))try{s=await me(y)}catch{}const u=["Você é um redator de e-commerce especialista em copy para redes sociais.",s?"Analise a imagem fornecida e crie uma frase que descreva ou valorize exatamente o que está sendo mostrado nela.":"Crie uma frase curta para um post de e-commerce.",i?`Produto em foco: ${i}.`:"",l?`Visual da imagem: estilo ${l}.`:"",`Tom desejado: ${e.label}.`,gi?`Melhore ou substitua o texto atual: "${gi}".`:"","Máximo 10 palavras. Responda APENAS com o texto final, sem aspas, sem explicações."].filter(
199Boolean).join(`
200`);if(s){const{data:r,error:p}=await V.functions.invoke("gemini-generate",{body:{prompt:u,model:"gemini-3-flash-preview",images:[s],responseType:"text"}});if(!p){const d=(r==null?void 0:r.text)??"";d&&mi(d.replace(/^["']|["']$/g,"").trim())}}else{const{data:r,error:p}=await V.functions.invoke("generate-copy",{body:{action:"freetext",prompt:u,brandContext:pt}});!p&&(r!=null&&r.text)&&mi(r.text.trim())}}catch(i){console.error(i)}finally{as(null)}},children:is===Ko?t.jsx(Tt,{size:11,className:"animate-spin"}):t.jsxs(t.Fragment,{children:[e.emoji," ",e.label]})},e.id))})]}),t.jsx("button",{className:"ig-generate-btn",style:{marginTop:10,width:"100%"},onClick:()=>{Ko&&Te(Ko,{text:gi}),Rn(!1),ja(null)},children:"Aplicar"})]}),Ja&&t.jsxs("div",{ref:Ii,className:"image-gen-wrapper",style:{position:"absolute",top:24,left:24},children:[t.jsxs("div",{className:`image-gen-main ${mo?"has-subpanel":""}`,children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:6,cursor:"grab",userSelect:"none"},onMouseDown:e=>{if(e.target.closest("button"))return;const o=Ii.current;if(!o)return;const n=o.getBoundingClientRect(),i=e.clientX,l=e.clientY,s=n.left,u=n.top;o.style.position="fixed",o.style.left=`${s}px`,o.style.top=`${u}px`,o.style.right="auto",o.style.bottom="auto";const r=d=>{const g=Math.max(0,Math.min(window.innerWidth-o.offsetWidth,s+d.clientX-i)),m=Math.max(0,Math.min(window.innerHeight-o.offsetHeight,u+d.clientY-l));o.style.left=`${g}px`,o.style.top=`${m}px`},p=()=>{document.removeEventListener("mousemove",r),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",r),document.addEventListener("mouseup",p)},children:[t.jsx("span",{style:{fontSize:13,fontWeight:600,color:"#FFF",pointerEvents:"none"},children:"Imagem"}),t.jsx("button",{onClick:()=>{Io(!1),$o(null)},style:{background:"none",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.5)",display:"flex",alignItems:"center"},children:t.jsx(je,{size:14})})]}),t.jsxs("div",{className:"ig-field",children:[t.jsx("span",{className:"ig-label",children:"Prompt da imagem"}),t.jsx("textarea",{className:"ig-textarea",value:de,onChange:e=>At(e.target.value),placeholder:"Descreva a cena, ambiente ou direção criativa...",rows:4,autoFocus:!0}),S&&t.jsxs("p",{style:{fontSize:10,color:"rgba(255,255,255,0.3)",margin:"4px 0 0",lineHeight:1.4},children:["Estilo ",t.jsx("span",{style:{color:"rgba(255,255,255,0.55)"},children:S.name})," aplicado automaticamente"]})]}),t.jsx(Or,{label:"Modelo",value:sn.name,active:mo==="model",onClick:()=>Ka("model")}),t.jsx(Or,{label:"Estilo",value:(S==null?void 0:S.name)??"Nenhum",thumbUrl:(S==null?void 0:S.thumbnailUrl)||((xc=si[(S==null?void 0:S.id)??""])==null?void 0:xc.thumb),active:mo==="style",onClick:()=>Ka("style")}),t.jsxs("div",{style:{position:"relative"},children:[t.jsx(Or,{label:"Referência",value:v?v.name+(Le.length>0?` + ${Le.length} ref`:""):Le.length>0?`${Le.length} imagem${Le.length>1?"ns":""}`:"Adicionar referência visual",thumbUrl:(v==null?void 0:v.image)||((bc=Le[0])==null?void 0:bc.dataUrl),active:mo==="reference",onClick:()=>Ka("reference")}),Le.length>0&&t.jsx("button",{onClick:e=>{e.stopPropagation(),ho([])},title:"Remover referências",style:{position:"absolute",right:36,top:"50%",transform:"translateY(-50%)",width:20,height:20,borderRadius:"50%",background:"rgba(255,255,255,0.12)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"rgba(255,255,255,0.6)",transition:"background 0.1s",zIndex:2},onMouseEnter:e=>e.currentTarget.style.background="rgba(255,255,255,0.25)",onMouseLeave:e=>e.currentTarget.style.background="rgba(255,255,255,0.12)",children:t.jsx(je,{size:11})})]}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:t.jsx("button",{onClick:()=>{$o(null),Fr()},disabled:Be||nt||!de.trim(),style:{width:"100%",height:44,borderRadius:10,border:"none",background:Be||nt?"rgba(255,255,255,0.15)":"#FFFFFF",color:Be||nt?"rgba(255,255,255,0.5)":"#1A1A1A",fontSize:13,fontWeight:500,cursor:Be||nt?"not-allowed":"pointer",fontFamily:"inherit",transition:"all 0.15s",display:"flex",alignItems:"center",justifyContent:"center",gap:8},children:Be||nt?t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{width:14,height:14,border:"2px s
200olid rgba(255,255,255,0.3)",borderTopColor:"rgba(255,255,255,0.8)",borderRadius:"50%",animation:"spin 0.75s linear infinite"}})," ",zi||"Gerando..."]}):t.jsx(t.Fragment,{children:"Gerar imagem"})})})]}),mo&&t.jsxs("div",{className:"image-gen-subpanel",children:[mo==="model"&&t.jsxs("div",{className:"ig-subpanel-content",children:[t.jsx("p",{className:"ig-subpanel-title",children:"Modelo"}),t.jsx("div",{className:"ig-subpanel-list",children:Go.map(e=>t.jsxs("button",{className:`ig-subpanel-item ${qa===e.id?"active":""}`,onClick:()=>{Jd(e.id),$o(null)},children:[t.jsxs("div",{className:"ig-subpanel-item-info",children:[t.jsx("span",{className:"ig-subpanel-item-name",children:e.name}),t.jsx("span",{className:"ig-subpanel-item-desc",children:e.description})]}),t.jsxs("div",{className:"ig-subpanel-item-right",children:[e.badge&&t.jsx("span",{className:"ig-badge",children:e.badge}),t.jsx("span",{className:"ig-subpanel-item-time",children:e.time}),qa===e.id&&t.jsx(oi,{size:13,style:{color:"#FFF",marginLeft:4}})]})]},e.id))})]}),mo==="style"&&t.jsxs("div",{className:"ig-subpanel-content",style:{padding:"16px 14px",overflowY:"auto"},children:[t.jsx("p",{className:"ig-subpanel-title",style:{marginBottom:14},children:"Estilo da geração"}),S?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"10px 10px",borderRadius:10,border:"1px solid rgba(255,255,255,0.25)",background:"rgba(255,255,255,0.08)"},children:[t.jsx("div",{style:{width:64,height:48,borderRadius:7,flexShrink:0,overflow:"hidden",background:S.color??"#333"},children:S.thumbnailUrl||(yc=si[S.id])!=null&&yc.thumb?t.jsx("img",{src:S.thumbnailUrl||((vc=si[S.id])==null?void 0:vc.thumb),alt:S.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):t.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600,color:"rgba(255,255,255,0.4)"},children:S.name.split(" ").map(e=>e[0]).join("").slice(0,2).toUpperCase()})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("p",{style:{fontSize:12,fontWeight:500,color:"#FFFFFF",margin:"0 0 3px",lineHeight:1.3},children:S.name}),t.jsx("p",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",margin:0,lineHeight:1.45,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:((wc=si[S.id])==null?void 0:wc.description)??S.category??""})]}),t.jsx("div",{style:{width:18,height:18,borderRadius:"50%",background:"rgba(255,255,255,0.9)",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:t.jsx(oi,{size:10,style:{color:"#1A1A1A"}})})]}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsxs("button",{onClick:()=>Ve(null),style:{flex:1,height:32,borderRadius:8,border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.05)",color:"rgba(255,255,255,0.7)",fontSize:11,fontWeight:400,cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",justifyContent:"center",gap:5,transition:"all 0.12s"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(255,255,255,0.1)",e.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255,255,255,0.05)",e.currentTarget.style.borderColor="rgba(255,255,255,0.12)"},children:[t.jsx(Pr,{size:11}),"Trocar estilo"]}),t.jsx("button",{onClick:()=>{Ve(null),$o(null)},style:{width:32,height:32,borderRadius:8,border:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.03)",color:"rgba(255,255,255,0.35)",cursor:"pointer",fontFamily:"inherit",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.12s",flexShrink:0},onMouseEnter:e=>{e.currentTarget.style.background="rgba(239,68,68,0.15)",e.currentTarget.style.borderColor="rgba(239,68,68,0.3)",e.currentTarget.style.color="#EF4444"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255,255,255,0.03)",e.currentTarget.style.borderColor="rgba(255,255,255,0.08)",e.currentTarget.style.color="rgba(255,255,255,0.35)"},title:"Remover estilo",children:t.jsx(je,{size:12})})]})]}):t.jsx(t.Fragment,{children:il.map(e=>t.jsxs("div",{style:{marginBottom:20},children:[t.jsx("p",{style:{fontSize:10,fontWeight:600,letterSpacing:"0.07em",color:"rgba(255,255,255,0.3)",textTransform:"uppercase",margin:"0 0 8px",padding:"0 2px"},children:e.label}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.styles.map(o=>{const n=ve.find(u=>u.id===o);if(!n)return null;const i=si[n.id],l=n.thumbnailUrl||(i==null?void 0:i.thumb),s=(i==null?void 0:i.description)??n.category??"";return t.jsxs("button",{onClick:()=>Ve(n),style:{display:"flex",alignItems:"center",gap:12,padding:"10px 10px",borderRadius:10,border:"1px solid rgba(255,255,255,0.07)",background:"rgba(255,255,255,0.03)",cursor:"pointer",fontFamily:"inherit",textAlign:"left",transition:"all 0.12s"},onMouseEnter:u=>{u.currentTarget.style.background="rgba(255,255,255,0.07)",u.currentTarget.style.borderColor="rgba(255,255,255,0.15)"},onMouseLeave:u=>{u.currentTarget.style.background="rgba(255,255,255,0.03)",u.currentTarget.style.borderColor="rgba(255,255,255,0.07)"},children:[t.jsx("div",{style:{width:64,height:48,borderRadius:7,flexShrink:0,overflow:"hidden",background:n.color??"#333"},children:l?t.jsx("img",{src:l,alt:n.name,style:{width:"100%",height:"100%",objectFit:"cover",display:"block"}}):t.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:13,fontWeight:600,color:"rgba(255,255,255,0.4)"},children:n.name.split(" ").map(u=>u[0]).join("").slice(0,2).toUpperCase()})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("p",{style:{fontSize:12,fontWeight:500,color:"rgba(255,255,255,0.85)",margin:"0 0 3px",lineHeight:1.3},children:n.name}),t.jsx("p",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",margin:0,lineHeight:1.45,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:s})]})]},n.id)})})]},e.id))})]}),mo==="reference"&&t.jsxs("div",{className:"ig-subpanel-content",style:{padding:20,display:"flex",flexDirection:"column",gap:20},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("p",{style:{fontSize:10,fontWeight:600,color:"rgba(255,255,255,0.35)",textTransform:"uppercase",letterSpacing:"0.06em",margin:0},children:"Produto"}),Ze.length>0&&k.find(e=>Ze.includes(e.id))?(()=>{const e=k.find(o=>Ze.includes(o.id));return t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,padding:"10px 12px",borderRadius:10,border:"1px solid rgba(255,255,255,0.15)",background:"rgba(255,255,255,0.04)"},children:[t.jsx("img",{src:e.image,alt:e.name,style:{width:40,height:40,borderRadius:7,objectFit:"cover",flexShrink:0}}),t.jsx("span",{style:{flex:1,fontSize:12,fontWeight:400,color:"rgba(255,255,255,0.8)"},children:e.name}),t.jsx("button",{onClick:()=>ro([]),style:{width:24,height:24,borderRadius:6,border:"none",flexShrink:0,background:"rgba(255,255,255,0.06)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"rgba(255,255,255,0.4)"},onMouseEnter:o=>{o.currentTarget.style.background="rgba(239,68,68,0.2)",o.currentTarget.style.color="#EF4444"},onMouseLeave:o=>{o.currentTarget.style.background="rgba(255,255,255,0.06)",o.currentTarget.style.color="rgba(255,255,255,0.4)"},children:t.jsx(je,{size:11})})]})})():t.jsxs("button",{onClick:()=>{so(!0),ln("")},style:{display:"flex",alignItems:"center",gap:10,padding:"11px 14px",borderRadius:10,width:"100%",border:"1px solid rgba(255,255,255,0.1)",background:"rgba(255,255,255,0.03)",cursor:"pointer",transition:"all 0.15s",fontFamily:"inherit",textAlign:"left"},onMouseEnter:e=>{e.currentTarget.style.borderColor="rgba(255,255,255,0.25)",e.currentTarget.style.background="rgba(255,255,255,0.06)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="rgba(255,255,255,0.1)",e.currentTarget.style.background="rgba(255,255,255,0.03)"},children:[t.jsx("div",{style:{width:32,height:32,borderRadius:7,flexShrink:0,background:"rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(ii,{size:14,style:{color:"rgba(255,255,255,0.35)"}})}),t.jsx("span",{style:{fontSize:12,color:"rgba(255,255,255,0.4)",flex:1},children:"Selecione um produto"}),t.jsx(sa,{size:13,style:{color:"rgba(255,255,255,0.25)",flexShrink:0}})]})]}),t.jsx("div",{style:{height:1,background:"rgba(255,255,255,0.07)"}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("p",{style:{fontSize:10,fontWeight:600,color:"rgba(255,255,255,0.35)",textTransform:"uppercase",letterSpacing:"0.06em",margin:0},children:["Referências visuais ",Le.length>0&&`(${Le.length}/5)`]}),Le.length>0&&t.jsx("button",{onClick:()=>
200ho([]),style:{fontSize:10,color:"rgba(255,255,255,0.3)",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit",padding:0},onMouseEnter:e=>e.currentTarget.style.color="rgba(255,255,255,0.7)",onMouseLeave:e=>e.currentTarget.style.color="rgba(255,255,255,0.3)",children:"Limpar tudo"})]}),Le.length>0&&t.jsxs("div",{style:{display:"flex",gap:7,flexWrap:"wrap"},children:[Le.map(e=>t.jsxs("div",{style:{position:"relative"},children:[t.jsx("img",{src:e.dataUrl,alt:"",style:{width:56,height:56,borderRadius:8,objectFit:"cover",display:"block"}}),t.jsx("button",{onClick:()=>nu(e.id),style:{position:"absolute",top:-5,right:-5,width:18,height:18,borderRadius:"50%",background:"#EF4444",border:"2px solid #1A1A1A",cursor:"pointer",color:"white",fontSize:9,display:"flex",alignItems:"center",justifyContent:"center",padding:0}})]},e.id)),Le.length<5&&t.jsx("button",{onClick:()=>{var e;return(e=Za.current)==null?void 0:e.click()},style:{width:56,height:56,borderRadius:8,border:"1.5px dashed rgba(255,255,255,0.15)",background:"rgba(255,255,255,0.03)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",color:"rgba(255,255,255,0.3)",flexShrink:0,transition:"all 0.12s"},onMouseEnter:e=>{e.currentTarget.style.borderColor="rgba(255,255,255,0.4)",e.currentTarget.style.color="rgba(255,255,255,0.7)"},onMouseLeave:e=>{e.currentTarget.style.borderColor="rgba(255,255,255,0.15)",e.currentTarget.style.color="rgba(255,255,255,0.3)"},children:t.jsx("span",{style:{fontSize:22,lineHeight:1,marginTop:-2},children:"+"})})]}),Le.length===0&&t.jsxs("div",{onDragOver:e=>{e.preventDefault(),e.currentTarget.style.borderColor="rgba(255,255,255,0.4)",e.currentTarget.style.background="rgba(255,255,255,0.05)"},onDragLeave:e=>{e.currentTarget.style.borderColor="rgba(255,255,255,0.1)",e.currentTarget.style.background="rgba(255,255,255,0.02)"},onDrop:e=>{e.preventDefault(),e.currentTarget.style.borderColor="rgba(255,255,255,0.1)",e.currentTarget.style.background="rgba(255,255,255,0.02)";const o=Array.from(e.dataTransfer.files).filter(n=>n.type.startsWith("image/")).slice(0,5);o.length&&o.forEach((n,i)=>{const l=new FileReader;l.onload=s=>{var r;const u=(r=s.target)==null?void 0:r.result;ho(p=>[...p,{id:`ref-${Date.now()}-${i}`,dataUrl:u,base64:u.split(",")[1],mimeType:n.type||"image/jpeg"}].slice(-5))},l.readAsDataURL(n)})},onClick:()=>{var e;return(e=Za.current)==null?void 0:e.click()},style:{border:"1.5px dashed rgba(255,255,255,0.1)",borderRadius:10,padding:"20px 16px",textAlign:"center",display:"flex",flexDirection:"column",alignItems:"center",gap:8,cursor:"pointer",transition:"all 0.15s",background:"rgba(255,255,255,0.02)"},children:[t.jsx(ni,{size:20,style:{color:"rgba(255,255,255,0.25)"}}),t.jsxs("div",{children:[t.jsx("p",{style:{fontSize:12,fontWeight:400,color:"rgba(255,255,255,0.55)",margin:"0 0 2px"},children:"Arraste ou clique para fazer upload"}),t.jsx("p",{style:{fontSize:11,color:"rgba(255,255,255,0.25)",margin:0},children:"JPG, PNG — até 5 imagens"})]})]}),t.jsx("input",{ref:Za,type:"file",accept:"image/*",multiple:!0,style:{display:"none"},onChange:e=>{const o=Array.from(e.target.files??[]).slice(0,5-Le.length);o.length&&(o.forEach((n,i)=>{const l=new FileReader;l.onload=s=>{var r;const u=(r=s.target)==null?void 0:r.result;ho(p=>[...p,{id:`ref-${Date.now()}-${i}`,dataUrl:u,base64:u.split(",")[1],mimeType:n.type||"image/jpeg"}].slice(-5))},l.readAsDataURL(n)}),e.target.value="")}})]})]})]})]}),xs&&t.jsxs("div",{ref:Us.ref,className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50,width:280},children:[t.jsx(Uo,{title:"Selecionar produto",onClose:Ns,onDragStart:Us.startDrag}),t.jsxs("div",{className:"float-search-wrapper",style:{marginBottom:8,padding:"0 10px"},children:[t.jsx(Up,{size:13,className:"float-search-icon"}),t.jsx("input",{className:"float-search-input",placeholder:"Buscar produto...",value:Qa,onChange:e=>ln(e.target.value),autoFocus:!0})]}),t.jsxs("div",{className:"float-product-list",children:[k.filter(e=>e.name.toLowerCase().includes(Qa.toLowerCase())).map(e=>{const o=Ze.includes(e.id);return t.jsxs("button",{className:`float-product-item ${o?"active":""}`,onClick:()=>{ro([e.id]),Ri(!0),so(!1),ln("")},children:[t.jsx("div",{className:"float-product-thumb",children:t.jsx("img",{src:e.image,alt:e.name})}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("span",{className:"float-product-name",children:e.name}
200),t.jsx("span",{style:{display:"block",fontSize:10,color:"rgba(255,255,255,0.3)",marginTop:1},children:e.sku})]}),o&&t.jsx("span",{style:{fontSize:12,color:"rgba(255,255,255,0.5)",flexShrink:0}})]},e.id)}),k.filter(e=>e.name.toLowerCase().includes(Qa.toLowerCase())).length===0&&t.jsx("p",{style:{fontSize:12,color:"rgba(255,255,255,0.3)",padding:"12px 10px",margin:0},children:"Nenhum produto encontrado."})]}),t.jsx("div",{style:{borderTop:"1px solid rgba(255,255,255,0.07)",padding:"10px 10px 4px"},children:t.jsxs("button",{onClick:()=>{const e=document.createElement("input");e.type="file",e.accept="image/*",e.onchange=()=>{var i;const o=(i=e.files)==null?void 0:i[0];if(!o)return;const n=new FileReader;n.onload=l=>{var r;const s=(r=l.target)==null?void 0:r.result,u=s.split(",")[1];ho(p=>[...p,{id:`ref-${Date.now()}`,dataUrl:s,base64:u,mimeType:o.type||"image/jpeg"}].slice(-5)),Ri(!0),so(!1),ln(""),E.success("Imagem do produto carregada — será usada como referência exata.")},n.readAsDataURL(o)},e.click()},style:{display:"flex",alignItems:"center",gap:8,width:"100%",padding:"8px 10px",borderRadius:8,border:"none",background:"transparent",cursor:"pointer",fontFamily:"inherit",transition:"background 0.12s",textAlign:"left"},onMouseEnter:e=>e.currentTarget.style.background="rgba(255,255,255,0.06)",onMouseLeave:e=>e.currentTarget.style.background="transparent",children:[t.jsx("div",{style:{width:28,height:28,borderRadius:6,flexShrink:0,background:"rgba(255,255,255,0.06)",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(ag,{size:12,style:{color:"rgba(255,255,255,0.45)"}})}),t.jsxs("div",{style:{flex:1},children:[t.jsx("span",{style:{fontSize:12,color:"rgba(255,255,255,0.6)",display:"block"},children:"UploadSimple de imagem"}),t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.25)"},children:"Produto ainda não publicado na loja"})]})]})})]}),Is&&t.jsxs("div",{ref:Gs.ref,className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50},children:[t.jsx(Uo,{title:"Overlay",onClose:Ws,onDragStart:Gs.startDrag}),t.jsxs("div",{style:{display:"flex",gap:4},children:[t.jsx("button",{className:`float-toggle-btn ${Ne==="gradient"?"active":""}`,onClick:()=>yi("gradient"),style:{flex:1,padding:"6px 8px",borderRadius:6,border:`1px solid ${Ne==="gradient"?"rgba(255,255,255,0.2)":"rgba(255,255,255,0.1)"}`,background:Ne==="gradient"?"rgba(255,255,255,0.15)":"transparent",fontSize:11,fontWeight:500,color:Ne==="gradient"?"#FFF":"rgba(255,255,255,0.5)",cursor:"pointer",fontFamily:"inherit"},children:"Gradiente"}),t.jsxs("button",{className:`float-toggle-btn ${Ne==="solid"?"active":""}`,onClick:()=>yi("solid"),style:{flex:1,padding:"6px 8px",borderRadius:6,border:`1px solid ${Ne==="solid"?"rgba(255,255,255,0.2)":"rgba(255,255,255,0.1)"}`,background:Ne==="solid"?"rgba(255,255,255,0.15)":"transparent",fontSize:11,fontWeight:500,color:Ne==="solid"?"#FFF":"rgba(255,255,255,0.5)",cursor:"pointer",fontFamily:"inherit"},children:[t.jsx(Jp,{size:13})," Sólido"]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"rgba(255,255,255,0.4)"},children:"Intensidade"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("input",{type:"range",min:0,max:100,value:Math.round(We*100),onChange:e=>It(Number(e.target.value)/100),style:{flex:1,accentColor:"#FFFFFF",cursor:"pointer"}}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.5)",minWidth:32,textAlign:"right"},children:[Math.round(We*100),"%"]})]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"rgba(255,255,255,0.4)"},children:"Cor"}),t.jsx("input",{type:"color",value:Ut,onChange:e=>Ia(e.target.value),style:{width:32,height:32,borderRadius:6,border:"1px solid rgba(255,255,255,0.15)",cursor:"pointer",overflow:"hidden",background:"none",padding:0}})]}),Ne==="gradient"&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"rgba(255,255,255,0.4)"},children:"Posição"}),t.jsx("div",{style:{display:"flex",gap:4},children:[{id:"bottom",label:"Base"},{id:"top",label:"Topo"},{id:"full",label:"Total"}].map(e=>t.jsx("button",{onClick:()=>ps(e.id),style:{flex:1,padding:"6px 8px",borderRadius:6,border:`1px solid ${kt===e.id?"rgba(255,255,255,0.2)":"rgba(255,255,255,0.1)"}`,background:kt===e.id?"rgba(255,255,255,0.15)":"transparent",fontSize:11,fontWeight:500,color:kt===e.id?"#FFF":"rgba(255,255,255,0.5)",cursor:"pointer",fontFamily:"inherit"},children:e.label},e.id))})]})]}),Do==="imagefit"&&t.jsxs("div",{className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50,width:260},onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[t.jsx("span",{className:"float-window-title",style:{margin:0},children:"Posição da imagem"}),t.jsx("button",{onClick:()=>{Fe(null)},style:{background:"none",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.5)",display:"flex",alignItems:"center"},children:t.jsx(je,{size:14})})]}),t.jsx("div",{style:{display:"flex",gap:4,marginBottom:12},children:["cover","contain"].map(e=>t.jsx("button",{onClick:()=>et(e),style:{flex:1,padding:"6px 0",borderRadius:6,border:`1px solid ${lo===e?"rgba(255,255,255,0.4)":"rgba(255,255,255,0.1)"}`,background:lo===e?"rgba(255,255,255,0.15)":"transparent",color:lo===e?"#FFF":"rgba(255,255,255,0.5)",fontSize:11,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:e==="cover"?"Preencher":"Encaixar"},e))}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:12},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[t.jsx("label",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"rgba(255,255,255,0.4)"},children:"Escala"}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[Ro,"%"]})]}),t.jsx("input",{type:"range",min:80,max:300,step:1,value:Ro,onChange:e=>tt(Number(e.target.value)),style:{width:"100%",accentColor:"#FFFFFF"}}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:2}
200,children:[t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.3)"},children:"80%"}),t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.3)"},children:"300%"})]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:12},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[t.jsx("label",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"rgba(255,255,255,0.4)"},children:"Posição horizontal"}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[lt.x,"%"]})]}),t.jsx("input",{type:"range",min:0,max:100,value:lt.x,onChange:e=>Ye(o=>({...o,x:Number(e.target.value)})),style:{width:"100%",accentColor:"#FFFFFF"}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginBottom:12},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[t.jsx("label",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"rgba(255,255,255,0.4)"},children:"Posição vertical"}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[lt.y,"%"]})]}),t.jsx("input",{type:"range",min:0,max:100,value:lt.y,onChange:e=>Ye(o=>({...o,y:Number(e.target.value)})),style:{width:"100%",accentColor:"#FFFFFF"}})]}),t.jsxs("div",{style:{display:"flex",gap:6,marginBottom:8},children:[t.jsx("button",{onClick:()=>{et("cover"),tt(100),Ye({x:50,y:50})},style:{flex:1,padding:"7px 0",borderRadius:6,border:"1px solid rgba(255,255,255,0.1)",background:"transparent",color:"rgba(255,255,255,0.5)",fontSize:11,cursor:"pointer",fontFamily:"inherit"},children:"Resetar"}),t.jsx("button",{onClick:()=>{Ue(),Fe(null),E.success("Posição salva!")},style:{flex:1,padding:"7px 0",borderRadius:6,border:"1px solid rgba(255,255,255,0.2)",background:"rgba(255,255,255,0.1)",color:"rgba(255,255,255,0.8)",fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"Aplicar"})]}),t.jsxs("button",{onClick:sp,disabled:!y||fa,style:{width:"100%",padding:"8px 0",borderRadius:6,border:"1px solid rgba(255,255,255,0.15)",background:fa?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.05)",color:y?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.25)",fontSize:11,fontWeight:500,cursor:y?"pointer":"not-allowed",fontFamily:"inherit",display:"flex",alignItems:"center",justifyContent:"center",gap:6,transition:"all 0.15s"},children:[fa?t.jsx(Tt,{size:13,className:"animate-spin"}):t.jsx("span",{style:{fontSize:13},children:"⤢"}),"Expandir fundo com IA"]})]}),Ds&&t.jsxs("div",{ref:qs.ref,className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50},children:[t.jsx(Uo,{title:"Tipografia",onClose:Ls,onDragStart:qs.startDrag}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"rgba(255,255,255,0.4)"},children:"Fonte"}),t.jsx(Dp,{selectedFontId:ke,onSelect:e=>{ao(e.id),be(o=>o.map(n=>n.id==="main-text"?{...n,fontFamily:e.family}:n))}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"rgba(255,255,255,0.4)"},children:"Alinhamento"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("div",{className:"float-align-group",children:["left","center","right"].map(e=>t.jsx("button",{className:`float-align-btn ${io===e?"active":""}`,onClick:()=>ka(e),children:e==="left"?t.jsx(Ec,{size:13}):e==="center"?t.jsx(Ic,{size:13}):t.jsx($c,{size:13})},e))}),t.jsx("div",{style:{width:1,height:20,background:"rgba(255,255,255,0.1)"}}),t.jsx("div",{className:"float-align-group",children:["top","center","bottom"].map(e=>t.jsx("button",{className:`float-align-btn ${Ao===e?"active":""}`,onClick:()=>Sa(e),children:e==="top"?t.jsx(Mp,{size:13}):e==="center"?t.jsx(Pp,{size:13}):t.jsx(Np,{size:13})},e))})]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("label",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"rgba(255,255,255,0.4)"},children:"Cor"}),t.jsxs("div",{style:{display:"flex",gap:12},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.5)"},children:"Texto"}
200),t.jsx("input",{type:"color",value:ft,onChange:e=>zo(e.target.value),style:{width:28,height:28,borderRadius:6,border:"1px solid rgba(255,255,255,0.15)",cursor:"pointer",overflow:"hidden",background:"none",padding:0}})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.5)"},children:"CTA"}),t.jsx("input",{type:"color",value:Ht,onChange:e=>{fi(e.target.value),ds(e.target.value==="#FFFFFF"||e.target.value==="#D4A064"?"#1A1A1A":"#FFFFFF")},style:{width:28,height:28,borderRadius:6,border:"1px solid rgba(255,255,255,0.15)",cursor:"pointer",overflow:"hidden",background:"none",padding:0}})]})]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6,marginTop:4},children:[t.jsx("label",{style:{fontSize:10,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.06em",color:"rgba(255,255,255,0.4)"},children:"Elementos"}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[t.jsx("button",{onClick:()=>ko(e=>!e),style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"flex",alignItems:"center",color:Kt?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.25)",transition:"color 0.2s"},children:Kt?t.jsx(na,{size:16}):t.jsx(ia,{size:16})}),t.jsx("span",{style:{fontSize:12,color:Kt?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.35)",fontWeight:500},children:"Heading"})]}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontVariantNumeric:"tabular-nums",minWidth:32,textAlign:"right"},children:[Ra,"px"]})]}),t.jsx("input",{type:"range",min:14,max:72,step:1,value:Ra,onChange:e=>Tn(Number(e.target.value)),disabled:!Kt,style:{width:"100%",accentColor:"#FFFFFF",opacity:Kt?1:.25,cursor:Kt?"pointer":"not-allowed"}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[t.jsx("button",{onClick:()=>Sn(e=>!e),style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"flex",alignItems:"center",color:Zt?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.25)",transition:"color 0.2s"},children:Zt?t.jsx(na,{size:16}):t.jsx(ia,{size:16})}),t.jsx("span",{style:{fontSize:12,color:Zt?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.35)",fontWeight:500},children:"Descrição"})]}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontVariantNumeric:"tabular-nums",minWidth:32,textAlign:"right"},children:[Ta,"px"]})]}),t.jsx("input",{type:"range",min:10,max:32,step:1,value:Ta,onChange:e=>Ed(Number(e.target.value)),disabled:!Zt,style:{width:"100%",accentColor:"#FFFFFF",opacity:Zt?1:.25,cursor:Zt?"pointer":"not-allowed"}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[t.jsx("button",{onClick:()=>kn(e=>!e),style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"flex",alignItems:"center",color:eo?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.25)",transition:"color 0.2s"},children:eo?t.jsx(na,{size:16}):t.jsx(ia,{size:16})}),t.jsx("span",{style:{fontSize:12,color:eo?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.35)",fontWeight:500},children:"CTA"})]}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontVariantNumeric:"tabular-nums",minWidth:32,textAlign:"right"},children:[Ea,"px"]})]}),t.jsx("input",{type:"range",min:10,max:28,step:1,value:Ea,onChange:e=>Id(Number(e.target.value)),disabled:!eo,style:{width:"100%",accentColor:"#FFFFFF",opacity:eo?1:.25,cursor:eo?"pointer":"not-allowed"}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:6,cursor:"pointer"},children:[t.jsx("button",{onClick:()=>pa(e=>!e),style:{background:"none",border:"none",cursor:"pointer",padding:0,display:"flex",alignItems:"center",color:Co?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.25)",transition:"color 0.2s"},children:Co?t.jsx(na,{size:16}):t.jsx(ia,{size:16})}),t.jsx("span",{style:{fontSize:12,color:Co?"rgba(255,255,255,0.7)":"rgba(255,255,255,0.35)",fontWeight:500}
200,children:"Preço"})]}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontVariantNumeric:"tabular-nums",minWidth:32,textAlign:"right"},children:[Qr,"px"]})]}),t.jsx("input",{type:"range",min:12,max:48,step:1,value:Qr,onChange:e=>Zc(Number(e.target.value)),disabled:!Co,style:{width:"100%",accentColor:"#FFFFFF",opacity:Co?1:.25,cursor:Co?"pointer":"not-allowed"}}),Co&&t.jsx("input",{type:"text",value:ga,onChange:e=>Kr(e.target.value),placeholder:"R$ 189,90",style:{width:"100%",padding:"6px 10px",borderRadius:6,background:"#1A1A1A",border:"1px solid rgba(255,255,255,0.1)",color:"#FFFFFF",fontSize:12,fontFamily:"inherit",outline:"none"}})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8,borderTop:"1px solid rgba(255,255,255,0.08)",paddingTop:12,marginTop:4},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Contraste do texto"}),t.jsx("div",{style:{display:"flex",gap:6},children:[{id:"none",label:"Nenhum",previewStyle:{}},{id:"solid",label:"Cube",previewStyle:{background:"rgba(0,0,0,0.6)",borderRadius:2,padding:"2px 4px"}},{id:"pill",label:"Pill",previewStyle:{background:"rgba(0,0,0,0.6)",borderRadius:999,padding:"2px 8px"}},{id:"blur",label:"Blur",previewStyle:{background:"rgba(0,0,0,0.4)",borderRadius:4,padding:"2px 4px"}},{id:"shadow",label:"Sombra",previewStyle:{textShadow:"0 2px 6px rgba(0,0,0,0.9), 0 0 12px rgba(0,0,0,0.6)"}}].map(e=>t.jsxs("button",{onClick:()=>vd(e.id),style:{display:"flex",flexDirection:"column",alignItems:"center",gap:4,padding:"8px 6px",flex:1,borderRadius:8,border:`1.5px solid ${hi===e.id?"rgba(255,255,255,0.6)":"rgba(255,255,255,0.08)"}`,background:"#1A1A1A",cursor:"pointer",transition:"all 0.15s",fontSize:10,color:hi===e.id?"#FFFFFF":"rgba(255,255,255,0.5)",fontFamily:"inherit"},children:[t.jsx("span",{style:{fontSize:14,fontWeight:600,color:"#FFFFFF",lineHeight:1,...e.previewStyle},children:"Aa"}),t.jsx("span",{children:e.label})]},e.id))}),hi!=="none"&&hi!=="shadow"&&t.jsxs("div",{style:{display:"flex",gap:12,alignItems:"center"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.5)"},children:"Cor"}),t.jsx("input",{type:"color",value:wd,onChange:e=>jd(e.target.value),style:{width:24,height:24,border:"1.5px solid rgba(255,255,255,0.15)",borderRadius:6,background:"none",cursor:"pointer",padding:0}})]}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:4},children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.5)"},children:"Opacidade"}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontVariantNumeric:"tabular-nums"},children:[Math.round(cs*100),"%"]})]}),t.jsx("input",{type:"range",min:10,max:100,step:5,value:Math.round(cs*100),onChange:e=>Fd(Number(e.target.value)/100),style:{width:"100%",accentColor:"#FFFFFF"}})]})]})]})]})]})]}),iu&&t.jsxs("div",{className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50,width:460},onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:8},children:[t.jsx("span",{className:"float-window-title",style:{margin:0},children:"Estilo da campanha"}),t.jsx("button",{onClick:()=>{cn(!1),Fe(null)},style:{background:"none",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.5)",display:"flex",alignItems:"center"},children:t.jsx(je,{size:14})})]}),t.jsx("div",{style:{display:"flex",gap:5,marginBottom:10},children:[{id:"all",label:"Todos"},{id:"photo",label:"Photo"},{id:"illustration",label:"Illustration"},{id:"3d",label:"3D"},{id:"design",label:"Design"}].map(e=>t.jsx("button",{onClick:()=>au(e.id),style:{padding:"3px 10px",borderRadius:999,fontSize:11,fontWeight:500,border:`1px solid ${Mn===e.id?"rgba(255,255,255,0.4)":"rgba(255,255,255,0.1)"}`,background:Mn===e.id?"rgba(255,255,255,0.15)":"transparent",color:Mn===e.id?"#FFFFFF":"rgba(255,255,255,0.5)",cursor:"pointer",transition:"all 0.12s",fontFamily:"inherit"},children:e.label},e.id))}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:8,maxHeight:380,overflowY:"auto"},children:ai.filter(e=>Mn==="all"||e.category===Mn).map(e=>t.jsxs("button",{onClick:()=>{Oo(e),cn(!1),Fe(null)},style:{display:"flex",flexDirection:"column",gap:5,border:`1.5px solid ${st===e.id?"rgba(255,255,255,0.5)":"rgba(255,255,255,0.08)"}
200`,borderRadius:10,background:"transparent",cursor:"pointer",padding:6,transition:"all 0.12s",textAlign:"left",fontFamily:"inherit"},children:[t.jsxs("div",{style:{width:"100%",aspectRatio:"1/1",borderRadius:6,display:"flex",alignItems:"flex-end",padding:6,fontSize:18,background:e.thumbnailUrl?`url(${e.thumbnailUrl}) center/cover`:e.preview},children:[e.isBrandDna&&t.jsx("span",{}),t.jsx("span",{style:{fontFamily:Lr(e.font),textTransform:e.textCase,fontWeight:e.fontWeight,color:e.textColor},children:"Aa"})]}),t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#FFFFFF"},children:e.name}),t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",lineHeight:1.3},children:e.description})]},e.id))}),t.jsx("div",{style:{height:1,background:"rgba(255,255,255,0.08)",margin:"10px 0"}}),t.jsxs("button",{onClick:()=>{cn(!1),Fe(null),window.open("/settings/styles","_blank")},style:{display:"flex",alignItems:"center",gap:6,width:"100%",padding:"8px 10px",borderRadius:8,border:"none",background:"transparent",cursor:"pointer",color:"rgba(255,255,255,0.5)",fontSize:12,fontWeight:500,fontFamily:"inherit",transition:"color 0.12s"},onMouseEnter:e=>e.currentTarget.style.color="#FFFFFF",onMouseLeave:e=>e.currentTarget.style.color="rgba(255,255,255,0.5)",children:[t.jsx(Wr,{size:12})," Gerenciar estilos"]})]}),$s&&t.jsxs("div",{ref:Vs.ref,className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50},children:[t.jsx(Uo,{title:"Formato",onClose:Bs,onDragStart:Vs.startDrag}),mt.map(e=>t.jsxs("button",{onClick:()=>{ua(e.id),Mo(!1),Fe(null)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%",padding:"9px 10px",borderRadius:8,border:"none",background:b===e.id?"rgba(255,255,255,0.12)":"transparent",cursor:"pointer",transition:"background 0.1s",fontFamily:"inherit"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(hg,{ratio:e.id}),t.jsx("span",{style:{fontSize:13,fontWeight:500,color:"#FFFFFF"},children:e.label})]}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:[e.sublabel," · ",e.width,"×",e.height]})]},e.id)),Tl&&t.jsxs(t.Fragment,{children:[t.jsx("div",{style:{height:1,background:"rgba(255,255,255,0.08)",margin:"4px 0"}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("button",{onClick:()=>x?Kc():Qc(),style:{display:"flex",alignItems:"center",gap:10,width:"100%",padding:"9px 10px",borderRadius:8,border:"none",background:x?"rgba(255,255,255,0.12)":"transparent",cursor:"pointer",transition:"background 0.1s",fontFamily:"inherit"},children:[t.jsx(Nr,{size:14,style:{color:x?"#FFFFFF":"rgba(255,255,255,0.6)",flexShrink:0}}),t.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:1,textAlign:"left"},children:[t.jsx("span",{style:{fontSize:13,fontWeight:500,color:"#FFFFFF"},children:"Carrossel"}),t.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)"},children:x?`${H.length} slide${H.length!==1?"s":""} gerado${H.length!==1?"s":""}`:"até 10 slides"})]}),x&&t.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:"#4CAF7D",flexShrink:0}})]}),x&&t.jsx("button",{onClick:()=>{uo(!0),Mo(!1),Fe(null)},style:{width:"100%",padding:8,borderRadius:8,border:"1px solid rgba(255,255,255,0.15)",background:"rgba(255,255,255,0.06)",color:"#FFFFFF",fontSize:12,fontWeight:500,cursor:"pointer",transition:"all 0.12s",display:"flex",alignItems:"center",justifyContent:"center",fontFamily:"inherit"},onMouseEnter:e=>{e.currentTarget.style.background="rgba(255,255,255,0.1)",e.currentTarget.style.borderColor="rgba(255,255,255,0.25)"},onMouseLeave:e=>{e.currentTarget.style.background="rgba(255,255,255,0.06)",e.currentTarget.style.borderColor="rgba(255,255,255,0.15)"},children:H.length===0?"Gerar carrossel":"↻ Regenerar carrossel"})]})]})]}),Ms&&t.jsxs("div",{ref:Ys.ref,className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50},children:[t.jsx(Uo,{title:"Atributos",onClose:Os,onDragStart:Ys.startDrag}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 0"},children:[t.jsx("span",{style:{fontSize:12,color:"rgba(255,255,255,0.6)"},children:"Mostrar no criativo"}),t.jsx("button",{onClick:()=>Ma(e=>!e),style:{width:36,height:20,borderRadius:10,border:"none",cursor:"pointer",background:Da?"#4CAF7D":"rgba(255,255,255,0.15)",position:"relative",transition:"background 0.2s"},children:t.jsx("span",{style:{position:"absolute",top:2,left:Da?18:2,width:16,height:16,borderRadius:"50%",background:"#FFFFFF",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.3)"}})})]}),Da&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{marginTop:8},children:[t.jsx("label",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.06em",display:"block",marginBottom:6},children:"Posição"}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{onClick:()=>ms("left"),style:{flex:1,padding:"7px 0",borderRadius:6,border:"1px solid",borderColor:ji==="left"?"rgba(255,255,255,0.3)":"rgba(255,255,255,0.08)",background:ji==="left"?"rgba(255,255,255,0.12)":"transparent",color:"#FFFFFF",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:"← Esquerda"}),t.jsx("button",{onClick:()=>ms("right"),style:{flex:1,padding:"7px 0",borderRadius:6,border:"1px solid",borderColor:ji==="right"?"rgba(255,255,255,0.3)":"rgba(255,255,255,0.08)",background:ji==="right"?"rgba(255,255,255,0.12)":"transparent",color:"#FFFFFF",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:"Direita →"})]})]}),t.jsxs("div",{style:{marginTop:10},children:[t.jsx("label",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.06em",display:"block",marginBottom:6},children:"Itens"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:Dd.map((e,o)=>t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("input",{value:e.icon,onChange:n=>
200fs(o,"icon",n.target.value),placeholder:"◈",maxLength:4,style:{width:36,textAlign:"center",padding:"6px 4px",fontSize:15,background:"#1A1A1A",border:"1px solid rgba(255,255,255,0.08)",borderRadius:6,color:"#FFFFFF",outline:"none",fontFamily:"inherit"}}),t.jsx("input",{value:e.label,onChange:n=>fs(o,"label",n.target.value),placeholder:"Proteção UV400",style:{flex:1,padding:"6px 10px",fontSize:12,background:"#1A1A1A",border:"1px solid rgba(255,255,255,0.08)",borderRadius:6,color:"#FFFFFF",outline:"none",fontFamily:"inherit"}}),t.jsx("button",{onClick:()=>Pd(o),style:{background:"none",border:"none",cursor:"pointer",color:"rgba(255,255,255,0.3)",padding:4,display:"flex",alignItems:"center"},children:t.jsx(je,{size:12})})]},e.id))})]}),t.jsxs("div",{style:{display:"flex",gap:6,marginTop:10},children:[t.jsx("button",{onClick:Md,style:{flex:1,padding:"8px 0",borderRadius:6,border:"1px solid rgba(255,255,255,0.08)",background:"transparent",color:"#FFFFFF",fontSize:12,fontWeight:500,cursor:"pointer",fontFamily:"inherit"},children:"+ Adicionar"}),t.jsx("button",{onClick:()=>Zo(),disabled:Fi,style:{flex:1,padding:"8px 0",borderRadius:6,border:"none",background:"#FFFFFF",color:"#000000",fontSize:12,fontWeight:600,cursor:Fi?"wait":"pointer",fontFamily:"inherit",opacity:Fi?.6:1},children:Fi?"Gerando...":"Gerar com IA"})]})]})]}),Ps&&t.jsxs("div",{ref:Xs.ref,className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50,width:320},children:[t.jsx(Uo,{title:"Vídeo",onClose:_s,onDragStart:Xs.startDrag}),t.jsxs("div",{style:{display:"flex",gap:4,marginBottom:12,background:"rgba(255,255,255,0.05)",borderRadius:8,padding:3},children:[t.jsx("button",{onClick:()=>gn("animate"),style:{flex:1,height:30,borderRadius:6,border:"none",background:pn==="animate"?"rgba(255,255,255,0.12)":"transparent",color:pn==="animate"?"#FFFFFF":"rgba(255,255,255,0.4)",fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"all 0.15s"},children:"▶ Animar"}),t.jsx("button",{onClick:()=>gn("ai"),style:{flex:1,height:30,borderRadius:6,border:"none",background:pn==="ai"?"rgba(255,255,255,0.12)":"transparent",color:pn==="ai"?"#FFFFFF":"rgba(255,255,255,0.4)",fontSize:12,fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"all 0.15s"},children:"Gerar com IA"})]}),pn==="animate"&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[t.jsxs("div",{children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8,display:"block"},children:"Animação"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:6},children:wu.map(e=>t.jsxs("button",{onClick:()=>gu(e.id),style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,padding:"10px 6px",borderRadius:8,border:`1px solid ${Xe===e.id?"rgba(255,255,255,0.6)":"rgba(255,255,255,0.08)"}`,background:Xe===e.id?"rgba(255,255,255,0.06)":"#1A1A1A",cursor:"pointer",transition:"all 0.12s",textAlign:"center",fontFamily:"inherit"},children:[t.jsx("span",{style:{fontSize:18},children:e.icon}),t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"#FFFFFF"},children:e.label}),t.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.4)",lineHeight:1.3},children:e.desc})]},e.id))})]}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:6},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Duração"}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontVariantNumeric:"tabular-nums"},children:[Yt,"s"]})]}),t.jsx("input",{type:"range",min:3,max:30,step:1,value:Yt,onChange:e=>al(Number(e.target.value)),style:{width:"100%",accentColor:"#FFFFFF"}}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:4},children:[t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.3)"},children:"3s (Reels)"}),t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.3)"},children:"30s"})]})]}),t.jsxs("div",{style:{display:"flex",gap:6},children:[t.jsx("button",{onClick:ju,disabled:!Xe||Ni,style:{flex:1,height:36,borderRadius:8,border:"1px solid rgba(255,255,255,0.15)",background:"transparent",color:"#FFFFFF",fontSize:12,fontWeight:600,cursor:Xe&&!Ni?"pointer":"not-allowed",opacity:Xe&&!Ni?1:.4,fontFamily:"inherit",transition:"all 0.15s"},children:Ni?"Reproduzindo...":"▶ Preview"}),t.jsx("button",{onClick:Fu,disabled:!Xe||On,style:{flex:1,height:36,borderRadius:8,border:"none",background:Xe&&!On?"#FFFFFF":"rgba(255,255,255,0.1)",color:Xe&&!On?"#1A1A1A":"rgba(255,255,255,0.3)",fontSize:12,fontWeight:600,cursor:Xe&&!On?"pointer":"not-allowed",fontFamily:"inherit",transition:"all 0.15s",display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:On?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{size:13,className:"animate-spin"})," Exportando..."]}):"↓ Exportar"})]})]}),pn==="ai"&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[y&&!L(y)?t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Frame base"}),t.jsx("div",{style:{width:"100%",borderRadius:8,overflow:"hidden",border:"1px solid rgba(255,255,255,0.08)"},children:t.jsx("img",{src:y,alt:"Frame base",style:{width:"100%",display:"block",objectFit:"cover",maxHeight:120}})}
200),t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.35)"},children:"O vídeo será gerado a partir desta imagem"})]}):t.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8,padding:"10px 12px",borderRadius:8,background:"rgba(255,255,255,0.04)",border:"1px solid rgba(255,255,255,0.08)"},children:[t.jsx(Br,{size:13,style:{color:"rgba(255,255,255,0.4)",flexShrink:0,marginTop:1}}),t.jsxs("div",{children:[t.jsx("p",{style:{fontSize:12,fontWeight:500,color:"rgba(255,255,255,0.7)",margin:"0 0 2px"},children:"Modo text-to-video"}),t.jsx("p",{style:{fontSize:11,color:"rgba(255,255,255,0.35)",margin:0,lineHeight:1.5},children:"Sem imagem no canvas. O vídeo será gerado direto do prompt. Gere uma imagem antes para mais controle visual."})]})]}),t.jsxs("div",{children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6,display:"block"},children:"Modelo"}),t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:4},children:ri.map(e=>t.jsxs("button",{onClick:()=>{_n(e.id),xo>e.maxDuration&&Wi(e.maxDuration)},style:{display:"flex",alignItems:"center",gap:10,padding:"9px 12px",borderRadius:8,border:`1px solid ${yt===e.id?"rgba(255,255,255,0.4)":"rgba(255,255,255,0.08)"}`,background:yt===e.id?"rgba(255,255,255,0.08)":"transparent",cursor:"pointer",fontFamily:"inherit",transition:"all 0.12s",textAlign:"left"},children:[t.jsx("span",{style:{fontSize:16},children:e.icon}),t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#FFFFFF"},children:e.name}),e.badge&&t.jsx("span",{style:{fontSize:9,fontWeight:700,textTransform:"uppercase",background:e.badge==="novo"?"rgba(34,197,94,0.2)":"rgba(168,85,247,0.2)",color:e.badge==="novo"?"#22C55E":"#A855F7",padding:"1px 5px",borderRadius:4,letterSpacing:"0.05em"},children:e.badge})]}),t.jsxs("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)"},children:[e.desc," · até ",e.maxDuration,"s"]})]}),yt===e.id&&t.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#FFFFFF"}})]},e.id))})]}),t.jsxs("div",{children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:8,display:"block"},children:"Estilo de motion"}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:5},children:zt.map(e=>{const o=it===e.buildPrompt((v==null?void 0:v.name)??"");return t.jsxs("button",{onClick:()=>{var i;const n=e.buildPrompt(((i=v==null?void 0:v.name)==null?void 0:i.trim())||"");bt(n),ll(!1)},style:{display:"flex",flexDirection:"column",alignItems:"center",gap:3,padding:"9px 4px",borderRadius:8,border:`1px solid ${o?"rgba(255,255,255,0.5)":"rgba(255,255,255,0.08)"}`,background:o?"rgba(255,255,255,0.1)":"rgba(255,255,255,0.03)",cursor:"pointer",transition:"all 0.12s",textAlign:"center",fontFamily:"inherit"},onMouseEnter:n=>{o||(n.currentTarget.style.background="rgba(255,255,255,0.06)")},onMouseLeave:n=>{o||(n.currentTarget.style.background="rgba(255,255,255,0.03)")},children:[t.jsx("span",{style:{fontSize:14},children:e.icon}),t.jsx("span",{style:{fontSize:10,fontWeight:600,color:"#FFFFFF",lineHeight:1.2},children:e.label}),t.jsx("span",{style:{fontSize:9,color:"rgba(255,255,255,0.35)",lineHeight:1.2},children:e.desc})]},e.id)})})]}),t.jsxs("div",{children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.05em",marginBottom:6,display:"block"},children:"Prompt de vídeo"}),t.jsx("textarea",{value:it,onChange:e=>bt(e.target.value),placeholder:"Descreva o movimento, a cena e o mood do vídeo...",rows:4,style:{width:"100%",padding:"10px 12px",borderRadius:8,background:"#1A1A1A",border:"1px solid rgba(255,255,255,0.1)",color:"#FFFFFF",fontSize:12,fontFamily:"inherit",outline:"none",resize:"none",lineHeight:1.5}}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,marginTop:6,cursor:"pointer"},children:[t.jsx("div",{onClick:()=>{ll(!Xt),Xt||bt(qn())},style:{width:32,height:18,borderRadius:999,cursor:"pointer",background:Xt?"#FFFFFF":"rgba(255,255,255,0.15)",position:"relative",transition:"background 0.2s"},children:t.jsx("div",{style:{width:14,height:14,borderRadius:"50%",background:Xt?"#1A1A1A":"rgba(255,255,255,0.4)",position:"absolute",top:2,left:Xt?16:2,transition:"all 0.2s"}})}),t.jsx("span",{style:{fontSize:11,color:"rgba(255,255,255,0.5)"},children:"AI prompt automático"})]})]}),t.jsxs("div",{children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:6},children:[t.jsx("span",{style:{fontSize:11,fontWeight:600,color:"rgba(255,255,255,0.5)",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Duração"}),t.jsxs("span",{style:{fontSize:11,color:"rgba(255,255,255,0.4)",fontVariantNumeric:"tabular-nums"},children:[xo,"s"]})]}),t.jsx("div",{style:{display:"flex",gap:4},children:[5,10].filter(e=>{var o;return e<=(((o=ri.find(n=>n.id===yt))==null?void 0:o.maxDuration)??10)}).map(e=>t.jsxs("button",{onClick:()=>Wi(e),style:{flex:1,height:30,borderRadius:6,border:"none",background:xo===e?"rgba(255,255,255,0.15)":"rgba(255,255,255,0.05)",color:xo===e?"#FFFFFF":"rgba(255,255,255,0.4)",fontSize:11,fontWeight:600,cursor:"pointer",fontFamily:"inherit",transition:"all 0.15s"},children:[e,"s"]},e))})]}),t.jsx("button",{onClick:()=>Vi(),disabled:Pt||!it.trim(),style:{width:"100%",height:40,borderRadius:8,border:"none",background:!Pt&&it.trim()?"#FFFFFF":"rgba(255,255,255,0.1)",color:!Pt&&it.trim()?"#1A1A1A":"rgba(255,255,255,0.3)",fontSize:13,fontWeight:600,cursor:!Pt&&it.trim()?"pointer":"not-allowed",fontFamily:"inherit",transition:"all 0.15s",display:"flex",alignItems:"center",justifyContent:"center",gap:6},children:Pt?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{size:14,className:"animate-spin"})," ",dl||"Gerando..."]}):`Gerar com ${((jc=ri.find(e=>e.id===yt))==null?void 0:jc.name)??"IA"}`}),Oi&&t.jsx("p",{style:{fontSize:11,color:"#EF4444",margin:0},children:Oi})]})]}),or&&t.jsxs("div",{ref:Js.ref,className:"float-window",style:{position:"absolute",top:24,left:24,zIndex:50,width:240},children:[t.jsx(Uo,{title:"Widgets",onClose:Hs,onDragStart:Js.startDrag}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("button",{onClick:()=>{us(),fo(!1)},style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.05)",cursor:"pointer",textAlign:"left",fontFamily:"inherit",transition:"background 0.12s",width:"100%"},onMouseEnter:e=>e.currentTarget.style.background="rgba(255,255,255,0.12)",onMouseLeave:e=>e.currentTarget.style.background="rgba(255,255,255,0.05)",children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,flexShrink:0,background:"rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(ii,{size:16,style:{color:"rgba(255,255,255,0.7)"}})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#FFFFFF"},children:"Card de produto"}
200),t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",lineHeight:1.3},children:"Foto + nome do produto clicável"})]})]}),t.jsxs("button",{onClick:()=>{ml(),fo(!1)},style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.05)",cursor:"pointer",textAlign:"left",fontFamily:"inherit",transition:"background 0.12s",width:"100%"},onMouseEnter:e=>e.currentTarget.style.background="rgba(255,255,255,0.12)",onMouseLeave:e=>e.currentTarget.style.background="rgba(255,255,255,0.05)",children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,flexShrink:0,background:"rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(Yc,{size:16,style:{color:"rgba(255,255,255,0.7)"}})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#FFFFFF"},children:"Review de cliente"}),t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",lineHeight:1.3},children:"Texto, nome e rating com estrelas"})]})]}),t.jsxs("button",{onClick:()=>{hl(),fo(!1)},style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.05)",cursor:"pointer",textAlign:"left",fontFamily:"inherit",transition:"background 0.12s",width:"100%"},onMouseEnter:e=>e.currentTarget.style.background="rgba(255,255,255,0.12)",onMouseLeave:e=>e.currentTarget.style.background="rgba(255,255,255,0.05)",children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,flexShrink:0,background:"rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(Vc,{size:16,style:{color:"rgba(255,255,255,0.7)"}})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:12,fontWeight:500,color:"#FFFFFF"},children:"Countdown"}),t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",lineHeight:1.3},children:"Contador regressivo de oferta"})]})]}),t.jsxs("button",{onClick:()=>{fl(),fo(!1)},style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.05)",cursor:"pointer",textAlign:"left",fontFamily:"inherit",transition:"background 0.12s",width:"100%"},onMouseEnter:e=>e.currentTarget.style.background="rgba(255,255,255,0.12)",onMouseLeave:e=>e.currentTarget.style.background="rgba(255,255,255,0.05)",children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,flexShrink:0,background:"rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(qc,{size:16,style:{color:"rgba(255,255,255,0.7)"}})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:12,fontWeight:500,color:"#FFFFFF"},children:"Preco + CTA"}),t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",lineHeight:1.3},children:"Preco com desconto e botao"})]})]}),t.jsxs("button",{onClick:()=>{xl(),fo(!1)},style:{display:"flex",alignItems:"center",gap:12,padding:"10px 12px",borderRadius:8,border:"1px solid rgba(255,255,255,0.08)",background:"rgba(255,255,255,0.05)",cursor:"pointer",textAlign:"left",fontFamily:"inherit",transition:"background 0.12s",width:"100%"},onMouseEnter:e=>e.currentTarget.style.background="rgba(255,255,255,0.12)",onMouseLeave:e=>e.currentTarget.style.background="rgba(255,255,255,0.05)",children:[t.jsx("div",{style:{width:36,height:36,borderRadius:8,flexShrink:0,background:"rgba(255,255,255,0.1)",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(Lc,{size:16,style:{color:"rgba(255,255,255,0.7)"}})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:12,fontWeight:500,color:"#FFFFFF"},children:"Prova social"}),t.jsx("span",{style:{fontSize:10,color:"rgba(255,255,255,0.4)",lineHeight:1.3},children:"Contador de vendas ao vivo"})]})]})]})]}),Au&&t.jsx("div",{style:{position:"fixed",inset:0,zIndex:300,background:"rgba(0,0,0,0.5)",backdropFilter:"blur(4px)",display:"flex",alignItems:"center",justifyContent:"center",animation:"dropIn 0.2s ease"},onClick:()=>Yn(!1),children:t.jsxs("div",{style:{width:"calc(100vw - 80px)",maxWidth:1100,height:"calc(100vh - 80px)",maxHeight:860,background:"#FFFFFF",borderRadius:20,boxSh
200adow:"0 24px 80px rgba(0,0,0,0.25)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"20px 28px",borderBottom:"1px solid #F0F0F0",flexShrink:0},children:[t.jsx("h2",{style:{fontSize:18,fontWeight:600,color:"#1A1A1A",margin:0},children:"Histórico"}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[t.jsxs("div",{style:{display:"flex",gap:4,background:"#F5F5F5",borderRadius:8,padding:3},children:[t.jsx("button",{onClick:()=>hr("saved"),style:{height:30,padding:"0 16px",borderRadius:6,border:"none",background:bo==="saved"?"#FFFFFF":"transparent",fontSize:13,fontWeight:500,color:bo==="saved"?"#1A1A1A":"#888",cursor:"pointer",transition:"all 0.15s",fontFamily:"inherit",boxShadow:bo==="saved"?"0 1px 3px rgba(0,0,0,0.1)":"none"},children:"Salvos"}),t.jsxs("button",{onClick:()=>hr("auto"),style:{height:30,padding:"0 16px",borderRadius:6,border:"none",background:bo==="auto"?"#FFFFFF":"transparent",fontSize:13,fontWeight:500,color:bo==="auto"?"#1A1A1A":"#888",cursor:"pointer",transition:"all 0.15s",fontFamily:"inherit",boxShadow:bo==="auto"?"0 1px 3px rgba(0,0,0,0.1)":"none",display:"flex",alignItems:"center",gap:6},children:["Auto",bn.length>0&&t.jsx("span",{style:{background:"#1A1A1A",color:"white",fontSize:10,fontWeight:600,padding:"1px 6px",borderRadius:999,lineHeight:1.4},children:bn.length})]})]}),t.jsx("button",{onClick:()=>Yn(!1),style:{width:32,height:32,borderRadius:8,border:"1px solid #E2E2E2",background:"#FFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"#888"},children:t.jsx(je,{size:15})})]})]}),t.jsxs("div",{style:{flex:1,minHeight:0,overflowY:"auto",padding:24},children:[bo==="saved"&&(fn.length===0?t.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,color:"#CCC"},children:[t.jsx(Kp,{size:36}),t.jsx("p",{style:{fontSize:13,margin:0,color:"#AAA"},children:"Nenhum criativo salvo ainda."})]}):t.jsx("div",{style:{display:"flex",flexDirection:"column",gap:24},children:(()=>{const e=[];for(const o of fn){const n=o.sessionTitle||"Sem título",i=e.find(l=>l.title===n);i?i.items.push(o):e.push({title:n,items:[o]})}return e.map((o,n)=>t.jsxs("div",{style:{background:"#FAFAFA",borderRadius:14,border:"1px solid #EFEFEF",overflow:"hidden"},children:[t.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid #EFEFEF",display:"flex",alignItems:"center",gap:8},children:[t.jsx("div",{style:{width:6,height:6,borderRadius:"50%",background:"#1A1A1A",flexShrink:0}}),t.jsx("span",{style:{fontSize:13,fontWeight:600,color:"#1A1A1A",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:o.title}),t.jsxs("span",{style:{fontSize:11,color:"#AAA",flexShrink:0,marginLeft:"auto"},children:[o.items.length," ",o.items.length===1?"asset":"assets"]})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(180px, 1fr))",gap:12,padding:12,alignContent:"start"},children:o.items.map(i=>t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[t.jsxs("div",{style:{position:"relative",aspectRatio:"1/1",borderRadius:10,overflow:"hidden",background:"#F2F2F2",cursor:"pointer"},className:"history-thumb-item",onClick:()=>Cl(i),children:[i.imageUrl?t.jsx("img",{src:i.imageUrl,alt:i.heading,style:{width:"100%",height:"100%",objectFit:"cover"}}):t.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center",color:"#CCC",fontSize:24},children:"▣"}),i.isCarousel&&i.slides&&t.jsxs("span",{style:{position:"absolute",bottom:6,left:6,background:"rgba(0,0,0,0.6)",color:"white",fontSize:10,fontWeight:600,padding:"2px 7px",borderRadius:6},children:[i.slides.length," slides"]}),t.jsxs("div",{className:"history-overlay",style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:0,transition:"opacity 0.15s"},children:[t.jsx("button",{onClick:l=>{l.stopPropagation(),Cl(i)},style:{width:32,height:32,borderRadius:"50%",background:"rgba(255,255,255,0.9)",border:"none",cursor:"pointer",color:"#1A1A1A",dis
200play:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(Dc,{size:13})}),t.jsx("button",{onClick:l=>{l.stopPropagation(),Hu(i)},style:{width:32,height:32,borderRadius:"50%",background:"rgba(255,255,255,0.9)",border:"none",cursor:"pointer",color:"#1A1A1A",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(jn,{size:13})})]})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("p",{style:{fontSize:11,fontWeight:500,color:"#1A1A1A",margin:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:i.heading||"(sem texto)"}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontSize:10,color:"#999"},children:Uu(i.channel)}),t.jsx("span",{style:{fontSize:10,color:"#BBB"},children:Gu(i.createdAt)})]})]})]},i.id))})]},n))})()})),bo==="auto"&&t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12},children:[Mu&&t.jsxs("div",{style:{padding:"12px 0"},children:[t.jsxs("div",{style:{fontSize:12,color:"#888",marginBottom:6},children:["Gerando posts... ",Fl,"%"]}),t.jsx("div",{style:{height:3,background:"#F0F0F0",borderRadius:999,overflow:"hidden"},children:t.jsx("div",{style:{height:"100%",background:"#1A1A1A",borderRadius:999,transition:"width 0.3s ease",width:`${Fl}%`}})})]}),bn.length===0?t.jsxs("div",{style:{height:300,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:10,color:"#CCC"},children:[t.jsx(Gr,{size:36}),t.jsx("p",{style:{fontSize:13,margin:0,color:"#AAA"},children:"Nenhum post gerado ainda."})]}):t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:16,alignContent:"start"},children:bn.map(e=>t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("div",{style:{position:"relative",aspectRatio:"1/1",borderRadius:12,overflow:"hidden",background:"#F2F2F2"},className:"history-thumb-item",children:e.status==="generating"||e.status==="pending"?t.jsxs("div",{style:{width:"100%",height:"100%",background:"#F2F2F2",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8},children:[t.jsx("div",{style:{width:32,height:32,borderRadius:"50%",border:"2px solid #E8E8E8",borderTopColor:"#1A1A1A",animation:"spin 0.8s linear infinite"}}),t.jsx("span",{style:{fontSize:11,color:"#999"},children:e.status==="generating"?"Gerando...":"Na fila"})]}):e.status==="error"?t.jsxs("div",{style:{width:"100%",height:"100%",background:"#FEF2F2",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:8,padding:12},children:[t.jsx("p",{style:{fontSize:11,color:"#DC2626",textAlign:"center",margin:0},children:e.errorMsg??"Erro"}),t.jsx("button",{onClick:()=>_u(e.id),style:{fontSize:11,color:"#DC2626",background:"none",border:"1px solid #FECACA",borderRadius:6,cursor:"pointer",fontFamily:"inherit",padding:"3px 10px"},children:"Tentar de novo"})]}):t.jsxs(t.Fragment,{children:[t.jsx("img",{src:e.imageUrl,alt:e.heading,onClick:()=>kl(e),style:{width:"100%",height:"100%",objectFit:"cover",cursor:"pointer"}}),t.jsxs("div",{className:"history-overlay",style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:0,transition:"opacity 0.15s"},children:[t.jsx("button",{onClick:()=>kl(e),style:{width:34,height:34,borderRadius:"50%",background:"rgba(255,255,255,0.9)",border:"none",cursor:"pointer",color:"#1A1A1A",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(Bc,{size:13})}),t.jsx("button",{onClick:()=>{if(!e.imageUrl)return;const o=document.createElement("a");o.download=`${e.theme}-${e.productName}.png`,o.href=e.imageUrl,o.click()},style:{width:34,height:34,borderRadius:"50%",background:"rgba(255,255,255,0.9)",border:"none",cursor:"pointer",color:"#1A1A1A",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx(jn,{size:13})})]})]})}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3},children:[t.jsx("p",{style:{fontSize:12,fontWeight:500,color:"#1A1A1A",margin:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.productName}),t.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[t.jsx("span",{style:{fontSize:11,color:"#999"},children:e.channel}),t.jsx("span",{style:{fontSize:11,color:"#555",fontWeight:500},children:"R$ 189"})]})]})]},e.id))})]})]})]})})]}),qd&&t.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.4)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:300},onClick:()=>uo(!1),children:t.jsxs("div",{style:{width:400,background:"#FFFFFF",borderRadius:16,padding:24,display:"flex",flexDirection:"column",gap:10,boxShadow:"0 12px 40px rgba(0,0,0,0.15)",animation:"popIn 0.2s ease"},onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:4},children:[t.jsx("h3",{style:{fontSize:16,fontWeight:600,color:"#1A1A1A",margin:0},children:"Criar carrossel"}),t.jsx("button",{onClick:()=>uo(!1),style:{background:"none",border:"none",cursor:"pointer",color:"#999"},children:t.jsx(je,{size:16})})]}),t.jsxs("button",{onClick:()=>
200po("auto"),style:{display:"flex",alignItems:"flex-start",gap:12,padding:14,borderRadius:12,border:`1.5px solid ${qt==="auto"?"#1A1A1A":"#E8E8E8"}`,background:qt==="auto"?"#FFFFFF":"#FAFAFA",cursor:"pointer",textAlign:"left",position:"relative",fontFamily:"inherit",transition:"all 0.15s"},children:[t.jsx("span",{style:{fontSize:20,flexShrink:0,color:"#555",marginTop:1}}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3,flex:1},children:[t.jsx("span",{style:{fontSize:14,fontWeight:600,color:"#1A1A1A"},children:"Automático"}),t.jsx("span",{style:{fontSize:12,color:"#888",lineHeight:1.4},children:"O app cria o número ideal de slides para contar a história da campanha — hook, benefícios, prova social e CTA."})]}),qt==="auto"&&t.jsx("span",{style:{position:"absolute",top:10,right:12,fontSize:13,fontWeight:600,color:"#1A1A1A"}})]}),t.jsxs("button",{onClick:()=>po("manual"),style:{display:"flex",alignItems:"flex-start",gap:12,padding:14,borderRadius:12,border:`1.5px solid ${qt==="manual"?"#1A1A1A":"#E8E8E8"}`,background:"#FFFFFF",cursor:"pointer",textAlign:"left",position:"relative",fontFamily:"inherit",transition:"all 0.15s"},children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:3,flex:1},children:[t.jsx("span",{style:{fontSize:14,fontWeight:600,color:"#1A1A1A"},children:"Definir quantidade"}),t.jsx("span",{style:{fontSize:12,color:"#888",lineHeight:1.4},children:"Escolha quantos slides quer gerar."})]}),qt==="manual"&&t.jsx("span",{style:{position:"absolute",top:10,right:12,fontSize:13,fontWeight:600,color:"#1A1A1A"}})]}),qt==="manual"&&t.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap",padding:"4px 0"},children:[3,4,5,6,7,8,10].map(e=>t.jsx("button",{onClick:()=>nn(e),style:{width:40,height:40,borderRadius:8,border:`1.5px solid ${on===e?"#1A1A1A":"#E2E2E2"}`,background:on===e?"#1A1A1A":"#FFFFFF",fontSize:14,fontWeight:600,color:on===e?"#FFFFFF":"#555",cursor:"pointer",transition:"all 0.15s",display:"flex",alignItems:"center",justifyContent:"center"},children:e},e))}),t.jsx("button",{onClick:Cr,disabled:an,style:{height:44,borderRadius:12,border:"none",background:"#1A1A1A",color:"#FFFFFF",fontSize:14,fontWeight:600,cursor:an?"wait":"pointer",fontFamily:"inherit",marginTop:4,transition:"opacity 0.15s",display:"flex",alignItems:"center",justifyContent:"center",gap:8,opacity:an?.7:1},children:an?t.jsxs(t.Fragment,{children:[t.jsx(Tt,{size:14,className:"animate-spin"})," Gerando slides..."]}):`Gerar ${qt==="auto"?"carrossel automático":`${on} slides`}`})]})}),zr&&t.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.35)",zIndex:300,display:"flex",alignItems:"center",justifyContent:"center"},onClick:()=>Qi(!1),children:t.jsxs("div",{style:{width:"100%",maxWidth:520,background:"#FFFFFF",borderRadius:20,padding:32,display:"flex",flexDirection:"column",gap:16,maxHeight:"80vh",overflowY:"auto",animation:"popIn 0.2s ease",boxShadow:"0 12px 40px rgba(0,0,0,0.15)"},onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[t.jsxs("div",{children:[t.jsxs("h4",{style:{fontSize:15,fontWeight:600,color:"#1A1A1A",margin:0},children:["Imagem · Slide ",M+1]}),t.jsx("p",{style:{fontSize:11,color:"#999",margin:"2px 0 0",textTransform:"uppercase",letterSpacing:"0.06em"},children:((Fc=H[M])==null?void 0:Fc.role)==="hook"?"Hook":((Sc=H[M])==null?void 0:Sc.role)==="benefit"?"Benefício":((kc=H[M])==null?void 0:kc.role)==="proof"?"Prova social":((Cc=H[M])==null?void 0:Cc.role)==="cta"?"CTA":"Slide"})]}),t.jsx("button",{onClick:()=>Qi(!1),style:{background:"none",border:"none",cursor:"pointer",color:"#999"},children:t.jsx(je,{size:14})})]}),t.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("label",{style:_c,children:"Produto"}),t.jsxs("button",{onClick:()=>Ki(!0),style:{width:"100%",display:"flex",alignItems:"center",gap:12,padding:12,background:"#FFFFFF",border:"1.5px solid #E2E2E2",borderRadius:12,cursor:"pointer",textAlign:"left",fontFamily:"inherit",transition:"border-color 0.15s"},onMouseEnter:e=>e.currentTarget.style.borderColor="#1A1A1A",onMouseLeave:e=>e.currentTarget.style.borderColor="#E2E2E2",children:[t.jsx("img",{src:(Ac=H[M])!=null&&Ac.image&&((zc=H[M])==null?void 0:zc.image)!=="error"?H[M].image:y,alt:"",style:{width:40,height:40,borderRadius:8,objectFit:"cover"}}),t.jsx("span",{style:{fontSize:13,fontWeight:500,color:"#1A1A1A",flex:1},children:((Rc=H[M])==null?void 0:Rc.product)||(v==null?void 0:v.name)||""}),t.jsx(sa,{size:16,style:{color:"#999"}})]})]}),t.jsxs("section",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx("label",{style:_c,children:"Gerar imagem"}),t.jsxs("div",{style:{border:"1.5px solid #E2E2E2",borderRadius:10,overflow:"hidden",background:"#FFFFFF"},children:[t.jsx("textarea",{placeholder:"Descreva a imagem deste slide...",value:ti,onChange:e=>{Rr(e.target.value),Ul(!1)},rows:3,style:{width:"100%",padding:12,border:"none",fontSize:13,color:"#1A1A1A",resize:"none",lineHeight:1.5,background:"transparent",fontFamily:"inherit",outline:"none",boxSizing:"border-box"}}),t.jsx("div",{style:{padding:"8px 12px",borderTop:"1px solid #F0F0F0"},children:t.jsxs("button",{onClick:()=>Er(e=>!e),style:{display:"flex",alignItems:"center",gap:6,background:"none",border:"none",cursor:"pointer",padding:0,width:"100%",fontFamily:"inherit"},children:[t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#1A1A1A"},children:_o.name}),_o.badge&&t.jsx("span",{style:{fontSize:10,fontWeight:600,color:"#2E7D52",background:"#F0FAF4",border:"1px solid #A8D5A2",borderRadius:999,padding:"2px 7px"},children:_o.badge}),t.jsx("span",{style:{fontSize:11,color:"#999",marginLeft:"auto"},children:_o.time}),t.jsx(Mr,{size:12,style:{color:"#999",transition:"transform 0.2s",transform:Yl?"rotate(180deg)":"none"}})]})}),Yl&&t.jsx("div",{style:{animation:"dropIn 0.15s ease"},children:Go.map((e,o)=>t.jsxs("button",{onClick:()=>{ql(e.id),Er(!1)},style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12,width:"100%",padding:"10px 12px",border:"none",borderBottom:o<Go.length-1?"1px solid #F5F5F5":"none",fontFamily:"inherit",background:Zi===e.id?"#F7F7F7":"#FFFFFF",cursor:"pointer",textAlign:"left",transition:"background 0.12s"},onMouseEnter:n=>n.currentTarget.style.background="#FAFAFA",onMouseLeave:n=>n.currentTarget.style.background=Zi===e.id?"#F7F7F7":"#FFFFFF",children:[t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:2},children:[t.jsx("span",{style:{fontSize:13,fontWeight:600,color:"#1A1A1A"},children:e.name}),t.jsx("span",{style:{fontSize:11,color:"#999"},children:e.description})]}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexShrink:0},children:[e.badge&&t.jsx("span",{style:{fontSize:10,fontWeight:600,color:"#2E7D52",background:"#F0FAF4",border:"1px solid #A8D5A2",borderRadius:999,padding:"2px 7px"},children:e.badge}),t.jsx("span",{style:{fontSize:11,color:"#999"},children:e.time}),Zi===e.id&&t.jsx(oi,{size:13,style:{color:"#1A1A1A"}})]})]},e.id))}),t.jsxs("label",{style:{...zg,borderTop:"1px solid #F0F0F0"},children:[t.jsx("span",{style:{flex:1,fontSize:12,color:"#555",userSelect:"none"},children:"AI prompt"}),t.jsx("input",{type:"checkbox",checked:Tr,onChange:e=>{var o;Ul(e.target.checked),e.target.checked&&H[M]&&Rr(((o=H[M])==null?void 0:o.imagePrompt)||`${A}, high quality commercial photography`)},style:{display:"none"}}),t.jsx("span",{style:Rg(Tr),children:t.jsx("span",{style:Tg(Tr)})})]})]}),t.jsx(aa,{className:"w-full mt-1 rounded-lg",variant:"outline",onClick:up,disabled:Gl||!ti.trim(),children:Gl?t.jsxs("span",{style:{display:"flex",alignItems:"center",gap:8},children:[t.jsx(Tt,{size:14,className:"animate-spin"}),t.jsxs("span",{style:{fontSize:12,color:"#888"},children:["Gerando com ",_o.name,"..."]})]}):"Gerar imagem para este slide"})]}),cp&&t.jsxs("div",{style:{position:"absolute",inset:0,background:"#FFFFFF",zIndex:10,display:"flex",flexDirection:"column",animation:"slideInLeft 0.2s ease",borderRadius:"16px 16px 0 0"},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"20px 20px 16px",borderBottom:"1px solid #EBEBEB"},children:[t.jsx("h3",{style:{flex:1,fontSize:15,fontWeight:600,margin:0,color:"#1A1A1A"},children:"Selecionar produto"}),t.jsx("button",{onClick:()=>Ki(!1),style:{width:28,height:28,borderRadius:8,border:"1px solid #E2E2E2",background:"#FFF",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",color:"#999"},children:t.jsx(je,{size:14})})]}),t.jsx("div",{style:{flex:1,overflowY:"auto",padding:"12px 16px",display:"flex",flexDirection:"column",gap:6},children:k.map(e=>t.jsxs("button",{onClick:()=>dp(e),style:{display:"flex",alignItems:"center",gap:12,padding:12,border:"1.5px solid #EBEBEB",borderRadius:10,background:"#fff",cursor:"pointer",textAlign:"left",fontFamily:"inherit",width:"100%",transition:"border-color 0.15s"},onMouseEnter:o=>o.currentTarget.style.borderColor="#1A1A1A",onMouseLeave:o=>o.currentTarget.style.borderColor="#EBEBEB",children:[t.jsx("img",{src:e.image,alt:e.name,style:{width:44,height:44,borderRadius:8,objectFit:"cover"}}),t.jsxs("div",{style:{flex:1},children:[t.jsx("span",{style:{display:"block",fontSize:13,fontWeight:600,color:"#1A1A1A"},children:e.name}),t.jsx("span",{style:{display:"block",fontSize:11,color:"#999",marginTop:2},children:e.sku})]})]},e.id))})]})]})}),t.jsx("style",{children:`
201        @keyframes slideInLeft {
202          from { transform: translateX(-16px); opacity: 0; }
203          to   { transform: translateX(0);     opacity: 1; }
204        }
205        @keyframes dropIn {
206          from { opacity: 0; transform: translateY(-6px); }
207          to   { opacity: 1; transform: translateY(0); }
208        }
209        @keyframes blink {
210          0%, 100% { opacity: 0.2; }
211          50% { opacity: 1; }
212        }
213        .version-use-label { opacity: 0 !important; transition: opacity 0.15s; }
214        button:hover > .version-use-label { opacity: 1 !important; }
215
216        /* Selectable text — FigmaLogo style */
217        .selectable-text {
218          cursor: default;
219          position: relative;
220          border-radius: 2px;
221          transition: outline 0.1s ease;
222        }
223        .selectable-text:hover:not(.element-selected):not(.element-editing) {
224          outline: 1.5px dashed rgba(255,255,255,0.35);
225          outline-offset: 3px;
226        }
227
228        /* Selected — solid blue FigmaLogo outline */
229        .element-selected {
230          outline: 2px solid #18A0FB !important;
231          outline-offset: 3px;
232        }
233        .element-selected::before,
234        .element-selected::after {
235          display: none;
236        }
237
238        /* Editing — dashed blue outline */
239        .element-editing {
240          outline: 1.5px dashed #18A0FB !important;
241          outline-offset: 3px;
242          caret-color: #18A0FB;
243          cursor: text;
244          background: rgba(0,0,0,0.1);
245          padding: 2px 6px;
246          min-width: 40px;
247        }
248        .element-editing:focus {
249          outline: 1.5px dashed #18A0FB !important;
250        }
251
252        /* Selection toolbar */
253        .selection-toolbar {
254          display: flex;
255          align-items: center;
256          gap: 2px;
257          background: #2C2C2C;
258          border-radius: 6px;
259          padding: 4px 5px;
260          box-shadow: 0 2px 12px rgba(0,0,0,0.25);
261          white-space: nowrap;
262          animation: toolbarIn 0.1s ease;
263        }
264        @keyframes toolbarIn {
265          from { opacity: 0; }
266          to   { opacity: 1; }
267        }
268        .stb-btn {
269          display: flex; align-items: center; gap: 5px;
270          padding: 4px 8px; border-radius: 4px;
271          border: none; background: transparent;
272          font-size: 11px; font-weight: 500; color: #DDDDDD;
273          cursor: pointer; transition: background 0.1s;
274          font-family: inherit;
275        }
276        .stb-btn:hover:not(:disabled) { background: rgba(255,255,255,0.12); }
277        .stb-btn:disabled { opacity: 0.4; cursor: not-allowed; }
278        .stb-generate { color: #FFFFFF; }
279        .stb-hint { color: #999; }
280        .stb-creative {
281          background: linear-gradient(135deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.06) 100%);
282          border: 1px solid rgba(255,255,255,0.2) !important;
283          color: rgba(255,255,255,0.95) !important;
284          position: relative;
285          overflow: hidden;
286        }
287        .stb-creative::before {
288          content: "";
289          position: absolute;
290          inset: 0;
291          background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
292          transform: translateX(-100%);
293          transition: transform 0.4s ease;
294        }
295        .stb-creative:hover::before {
296          transform: translateX(100%);
297        }
298        .stb-creative:disabled {
299          opacity: 0.35;
300          cursor: not-allowed;
301        }
302        .stb-btn + .stb-btn { border-left: 1px solid rgba(255,255,255,0.08); }
303
304        /* FloppyDisk sparkle animation */
305        .save-animating { animation: saveIconPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
306        @keyframes saveIconPop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 70% { transform: scale(0.92); } 100% { transform: scale(1); } }
307        .save-sparkles { position: absolute; inset: 0; pointer-events: none; }
308        .sparkle-particle { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: #F5C842; top: 50%; left: 50%; opacity: 0; animation: sparkleFly 0.7s ease-out forwards; }
309        .sparkle-0 { animation-delay: 0ms;  --dx: -14px; --dy: -16px; }
310        .sparkle-1 { animation-delay: 30ms; --dx: 16px;  --dy: -12px; }
311        .sparkle-2 { animation-delay: 60ms; --dx: 18px;  --dy: 8px; }
312        .sparkle-3 { animation-delay: 20ms; --dx: -8px;  --dy: 18px; }
313        .sparkle-4 { animation-delay: 50ms; --dx: -18px; --dy: 6px; }
314        .sparkle-5 { animation-delay: 10ms; --dx: 6px;   --dy: -20px; width: 3px; height: 3px; background: #FFFFFF; }
315        @keyframes sparkleFly { 0% { transform: translate(-50%,-50%) scale(0); opacity: 1; } 60% { opacity: 1; } 100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1); opacity: 0; } }
316
317        /* FloppyDisk toast */
318        .save-toast-bar { position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 18px; border-radius: 999px; background: rgba(20,20,20,0.82); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); color: #FFF; font-size: 12px; font-weight: 500; letter-spacing: 0.01em; white-space: nowrap; pointer-events: none; z-index: 30; animation: toastIn 0.25s cubic-bezier(0.34,1.56,0.64,1) forwards, toastOut 0.3s ease-in 1.9s forwards; }
319        .save-toast-check { font-size: 13px; color: #4ADE80; }
320        @keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px) scale(0.95); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
321        @keyframes toastOut { from { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } to { opacity: 0; transform: translateX(-50%) translateY(6px) scale(0.97); } }
322        @keyframes pillsFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
323        @keyframes regenFadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
324
325         .stb-tone-dropdown {
326          position: absolute;
327          top: calc(100% + 4px);
328          left: 0;
329          background: #2C2C2C;
330          border-radius: 8px;
331          overflow: hidden;
332          box-shadow: 0 4px 16px rgba(0,0,0,0.3);
333          z-index: 30;
334          min-width: 140px;
335          animation: dropIn 0.12s ease;
336        }
337        .stb-tone-option {
338          display: flex; align-items: center; gap: 8px;
339          width: 100%; padding: 8px 12px;
340          border: none; background: transparent;
341          font-size: 12px; color: #DDD; cursor: pointer;
342          transition: background 0.1s; text-align: left;
343          font-family: inherit;
344        }
345        .stb-tone-option:hover:not(:disabled) { background: rgba(255,255,255,0.1); }
346        .stb-tone-option:not(:last-child) { border-bottom: 1px solid rgba(255,255,255,0.06); }
347        .stb-tone-icon { font-size: 13px; width: 16px; text-align: center; }
348        @keyframes slideInRight {
349          from { transform: translateX(20px); opacity: 0; }
350          to   { transform: translateX(0);    opacity: 1; }
351        }
352        @keyframes spin { to { transform: rotate(360deg); } }
353        @keyframes textCursor {
354          0%, 100% { opacity: 1; }
355          50%       { opacity: 0; }
356        }
357        @keyframes shimmerText {
358          0%   { background-position: -200% center; }
359          100% { background-position: 200% center; }
360        }
361        .textbox-loading-label {
362          font-size: inherit;
363          font-family: inherit;
364          font-weight: 400;
365          color: transparent;
366          background: linear-gradient(
367            90deg,
368            rgba(255,255,255,0.15) 0%,
369            rgba(255,255,255,0.55) 40%,
370            rgba(255,255,255,0.15) 80%
371          );
372          background-size: 200% auto;
373          -webkit-background-clip: text;
374          background-clip: text;
375          animation: shimmerText 1.4s linear infinite;
376          white-space: nowrap;
377          pointer-events: none;
378          user-select: none;
379        }
380        .textbox-cursor {
381          display: inline-block;
382          width: 2px;
383          height: 1em;
384          background: rgba(255,255,255,0.7);
385          margin-left: 3px;
386          vertical-align: text-bottom;
387          border-radius: 1px;
388          animation: textCursor 0.9s ease-in-out infinite;
389        }
390        @keyframes softPulse { 0%, 100% { transform: scale(1); opacity: 0.6; } 50% { transform: scale(1.4);
390 opacity: 0.2; } }
391        @keyframes popIn {
392          from { transform: scale(0.95); opacity: 0; }
393          to   { transform: scale(1);    opacity: 1; }
394        }
395        @keyframes slideUp {
396          from { transform: translateY(100%); }
397          to   { transform: translateY(0); }
398        }
399        .history-thumb-item:hover .history-overlay { opacity: 1 !important; }
400        .history-thumb-item .history-overlay button:hover { background: #FFFFFF !important; }
401
402        @keyframes loadingBar {
403          0%   { width: 0%; margin-left: 0; }
404          50%  { width: 60%; margin-left: 20%; }
405          100% { width: 0%; margin-left: 100%; }
406        }
407        @keyframes loadingShimmer {
408          0%   { background-position: 200% 0; }
409          100% { background-position: -200% 0; }
410        }
411      `}),Yu&&t.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:60},onClick:()=>wr(!1),children:t.jsxs("div",{style:{width:520,background:"#FFFFFF",borderRadius:16,padding:24,display:"flex",flexDirection:"column",gap:16,boxShadow:"0 16px 48px rgba(0,0,0,0.2)"},onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsx("h3",{style:{fontSize:16,fontWeight:600,color:"#1A1A1A",margin:0},children:"Banner pronto para publicar"}),t.jsx("button",{onClick:()=>wr(!1),style:{background:"none",border:"none",cursor:"pointer",color:"#999",padding:4},children:t.jsx(je,{size:16})})]}),t.jsxs("div",{style:{background:"#F5F5F5",borderRadius:8,padding:16,fontSize:11,color:"#555",overflow:"hidden",maxHeight:140,fontFamily:"'SF Mono', 'Fira Code', monospace",lineHeight:1.5,whiteSpace:"pre-wrap",wordBreak:"break-all"},children:[Xi.slice(0,400),"..."]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsxs(aa,{className:"w-full",onClick:Qu,children:[t.jsx(jn,{size:14})," Baixar banner.html"]}),t.jsxs("button",{onClick:()=>{navigator.clipboard.writeText(Xi),E.success("Código copiado!")},style:{display:"flex",alignItems:"center",justifyContent:"center",gap:6,height:36,borderRadius:8,border:"1.5px solid #E2E2E2",background:"#FFF",fontSize:13,color:"#555",cursor:"pointer",transition:"all 0.15s",fontFamily:"inherit"},children:[t.jsx(Zp,{size:14})," Copiar código"]})]}),t.jsxs("p",{style:{fontSize:12,color:"#888",lineHeight:1.5},children:["Cole o código no HTML da sua loja. Troque ",t.jsx("code",{style:{background:"#F0F0F0",padding:"1px 5px",borderRadius:3,fontFamily:"monospace",fontSize:11},children:'href="#"'})," pela URL do produto."]})]})}),zu&&t.jsx("div",{style:{position:"fixed",inset:0,background:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:300},onClick:()=>xr(!1),children:t.jsxs("div",{style:{width:640,maxHeight:"90vh",background:"#FFFFFF",borderRadius:16,padding:28,overflowY:"auto",display:"flex",flexDirection:"column",gap:24,boxShadow:"0 16px 48px rgba(0,0,0,0.2)",animation:"popIn 0.2s ease"},onClick:e=>e.stopPropagation(),children:[t.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start"},children:[t.jsxs("div",{children:[t.jsx("h2",{style:{fontSize:20,fontWeight:600,color:"#1A1A1A",margin:0},children:"Auto Generate"}),t.jsx("p",{style:{fontSize:13,color:"#888",marginTop:3,marginBottom:0},children:"Gere posts para todos os canais com um clique"})]}),t.jsx("button",{onClick:()=>xr(!1),style:{background:"none",border:"none",cursor:"pointer",color:"#999"},children:t.jsx(je,{size:15})})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:"#1A1A1A"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:"50%",background:"#1A1A1A",color:"white",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"1"}),"Tema da campanha"]}),t.jsx("input",{style:{width:"100%",padding:"10px 14px",border:"1.5px solid #E2E2E2",borderRadius:8,fontSize:13,color:"#1A1A1A",fontFamily:"inherit",outline:"none",boxSizing:"border-box"},placeholder:"Ex: Black Friday, Lançamento, Liquidação, Volta às aulas...",value:gt,onCh
411ange:e=>yl(e.target.value)}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:["Black Friday","Dia das Mães","Lançamento","Liquidação","Promoção"].map(e=>t.jsx("button",{onClick:()=>yl(e),style:{padding:"4px 10px",borderRadius:999,border:`1.5px solid ${gt===e?"#1A1A1A":"#E2E2E2"}`,background:gt===e?"#1A1A1A":"#FFF",fontSize:11,fontWeight:500,color:gt===e?"#FFF":"#555",cursor:"pointer",transition:"all 0.15s",fontFamily:"inherit"},children:e},e))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:"#1A1A1A"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:"50%",background:"#1A1A1A",color:"white",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"2"}),"Produtos"]}),t.jsx("button",{onClick:()=>vl(vt.length===k.length?[]:k.map(e=>e.id)),style:{fontSize:12,color:"#888",background:"none",border:"none",cursor:"pointer",fontFamily:"inherit"},children:vt.length===k.length?"Desselecionar todos":"Selecionar todos"})]}),t.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(4, 1fr)",gap:8,maxHeight:240,overflowY:"auto"},children:k.map(e=>t.jsxs("button",{onClick:()=>Bu(e.id),style:{display:"flex",flexDirection:"column",gap:4,border:`1.5px solid ${vt.includes(e.id)?"#1A1A1A":"#EBEBEB"}`,borderRadius:10,padding:8,background:"#FFF",cursor:"pointer",transition:"all 0.15s",textAlign:"left",fontFamily:"inherit"},children:[t.jsxs("div",{style:{position:"relative",aspectRatio:"1/1",borderRadius:6,overflow:"hidden",background:"#F2F2F2"},children:[t.jsx("img",{src:e.image,alt:e.name,style:{width:"100%",height:"100%",objectFit:"cover"}}),vt.includes(e.id)&&t.jsx("div",{style:{position:"absolute",inset:0,background:"rgba(0,0,0,0.45)",display:"flex",alignItems:"center",justifyContent:"center",color:"white",fontSize:18,fontWeight:600}})]}),t.jsx("p",{style:{fontSize:11,fontWeight:600,color:"#1A1A1A",margin:0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:e.name})]},e.id))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:"#1A1A1A"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:"50%",background:"#1A1A1A",color:"white",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"3"}),"Formatos"]}),t.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[{id:"instagram-feed",label:"Feed",dim:"1080×1080"},{id:"instagram-stories",label:"Stories",dim:"1080×1920"},{id:"whatsapp",label:"WhatsappLogo",dim:"800×800"},{id:"site-banner",label:"Banner",dim:"1200×628"}].map(e=>t.jsxs("button",{onClick:()=>Lu(e.id),style:{display:"flex",flexDirection:"column",gap:2,padding:"8px 14px",borderRadius:8,border:`1.5px solid ${Wt.includes(e.id)?"#1A1A1A":"#E2E2E2"}`,background:Wt.includes(e.id)?"#FAFAFA":"#FFF",cursor:"pointer",transition:"all 0.15s",textAlign:"center",fontFamily:"inherit"},children:[t.jsx("span",{style:{fontSize:12,fontWeight:600,color:"#1A1A1A"},children:e.label}),t.jsx("span",{style:{fontSize:10,color:"#AAA"},children:e.dim})]},e.id))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:"#1A1A1A"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:"50%",background:"#1A1A1A",color:"white",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"4"}),"Estilo visual"]}),t.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:ai.map(e=>t.jsx("button",{onClick:()=>Pu(e.id),style:{padding:"5px 12px",borderRadius:999,border:`1.5px solid ${vo===e.id?"#1A1A1A":"#E2E2E2"}`,background:vo===e.id?"#1A1A1A":"#FFF",fontSize:11,fontWeight:500,color:vo===e.id?"#FFF":"#555",cursor:"pointer",transition:"all 0.12s",fontFamily:"inherit"},children:e.name},e.id))})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:"#1A1A1A"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:"50%",background:"#1A1A1A",color:"white",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"5"}),"Instruções extras",t.jsx("span",{style:{fontSize:11,fontWeight:400,color:"#AAA"},children:"opcional"})]}),t.jsx("textarea",{value:Bo,onChange:e=>Nu(e.target.value),placeholder:"Ex: usar cores vibrantes, destacar desconto de 30%, tom divertido...",rows:2,style:{width:"100%",padding:"10px 14px",border:"1.5px solid #E2E2E2",borderRadius:8,fontSize:13,color:"#1A1A1A",fontFamily:"inherit",outline:"none",resize:"none",lineHeight:1.5,boxSizing:"border-box"},onFocus:e=>e.currentTarget.style.borderColor="#1A1A1A",onBlur:e=>e.currentTarget.style.borderColor="#E2E2E2"})]}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:13,fontWeight:600,color:"#1A1A1A"},children:[t.jsx("span",{style:{width:20,height:20,borderRadius:"50%",background:"#1A1A1A",color:"white",fontSize:11,fontWeight:600,display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:"6"}),"Quantidade de posts"]}),t.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:["all",2,4,6,8,10].map(e=>t.jsx("button",{onClick:()=>Wu(e),style:{padding:"5px 14px",borderRadius:999,border:`1.5px solid ${Lo===e?"#1A1A1A":"#E2E2E2"}`,background:Lo===e?"#1A1A1A":"#FFF",fontSize:11,fontWeight:500,color:Lo===e?"#FFF":"#555",cursor:"pointer",transition:"all 0.12s",fontFamily:"inherit"},children:e==="all"?"Todos":e},String(e)))})]}),t.jsxs("div",{style:{fontSize:13,color:"#555",textAlign:"center",padding:10,background:"#F7F7F7",borderRadius:8},children:[vt.length," produto",vt.length!==1?"s":""," ×"," ",Wt.length," formato",Wt.length!==1?"s":""," ="," ",t.jsxs("strong",{children:[vt.length*Wt.length," posts"]})]}),t.jsxs("button",{onClick:Ou,disabled:!gt.trim()||vt.length===0||Wt.length===0,style:{width:"100%",height:48,background:"#1A1A1A",color:"#FFF",border:"none",borderRadius:12,fontSize:14,fontWeight:600,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",gap:8,transition:"opacity 0.15s",fontFamily:"inherit",opacity:!gt.trim()||vt.length===0||Wt.length===0?.35:1},children:[t.jsx(Gr,{size:15}),"Gerar ",vt.length*Wt.length," posts automaticamente"]})]})}),mu&&t.jsx(Wp,{imageUrl:y,product:(v==null?void 0:v.name)??h.product,campaign:(C==null?void 0:C.title)??"",onClose:()=>Hn(!1),onSchedule:({platform:e,legenda:o})=>{Hn(!1),bu(e),xu(o),Un(!0)}}),hu&&t.jsx(Bp,{imageUrl:y,legenda:fu,onClose:()=>Un(!1),onScheduled:e=>{vu(e),Un(!1),E.success("Post agendado!"),Nt("post_scheduled","Agendado ",`Publicação marcada pra ${e.date} às ${e.time}. Que tal criar o próximo post enquanto isso?`,[])}})]})},_c={fontSize:11,fontWeight:600,textTransform:"uppercase",letterSpacing:"0.07em",color:"#999",display:"block",marginBottom:10},Hc={width:36,height:36,borderRadius:"50%",border:"1.5px solid #E2E2E2",background:"#FFFFFF",color:"#555",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0,transition:"all 0.15s",boxShadow:"0 1px 4px rgba(0,0,0,0.08)"},zg={display:"flex",alignItems:"center",gap:8,padding:"8px 12px",cursor:"pointer",transition:"background 0.15s"},Rg=h=>({width:28,height:16,borderRadius:999,background:h?"#1A1A1A":"#DDDDDD",position:"relative",flexShrink:0,transition:"background 0.2s",display:"inline-block"}),Tg=h=>({position:"absolute",top:2,left:h?14:2,width:12,height:12,borderRadius:"50%",background:"white",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"});function Wh(){var X;const h=Fp(),O=Sp(),[_,se]=a.useState(!0),F=O.state,Re=(F==null?void 0:F.autoPrompt)??"",k=(F==null?void 0:F.openBoard)??!1,Q=F==null?void 0:F.restoreItem,W=(F==null?void 0:F._ts)??O.key,q=a.useMemo(()=>la(),[]),B={campaignTitle:(Q==null?void 0:Q.sessionTitle)??(q==null?void 0:q.name)??"",product:((X=q==null?void 0:q.productTypes)==null?void 0:X[0])??"",productImageUrl:(Q==null?void 0:Q.imageUrl)??"",copyText:"",selectedTone:(q==null?void 0:q.tone)??"",autoPrompt:Re||"",restoreChatMessages:Q==null?void 0:Q.chatMessages,styleId:(F==null?void 0:F.styleId)??null,styleName:(F==null?void 0:F.styleName)??null,styleDesc:(F==null?void 0:F.styleDesc)??null};return t.jsxs("div",{style:{display:"flex",width:"100vw",height:"100vh",overflow:"hidden"},children:[t.jsx(Qp,{collapsed:_,onToggleCollapse:()=>
411se(Me=>!Me)}),t.jsx("div",{style:{flex:1,minWidth:0,minHeight:0,height:"100%",overflow:"hidden",position:"relative"},children:t.jsx(Ag,{data:B,onClose:()=>h("/snew-studio"),embedded:!0,initialBoardMode:k,initialMode:(F==null?void 0:F.initialMode)??null},W)})]})}export{Wh 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.