PageSourceSearch

https://smartofertaai.com.br/assets/converterPostCopy-uiGp-jK5.js

js smartofertaai.com.br collected 2026-09-24 14:35:43 UTC 65,370 bytes, 15 lines download raw bytes

1import{r as F,j as s,d as ze}from"./react-vendor-Cvme-g6x.js";import{r as ae,s as Wt,a as We,b as ie,c as Ue,S as Ye}from"./schedulePostCopy-CPUUT2uG.js";import{c as Ve,m as T,z as qe,F as Xe,G as Ge,J as Ze,K as Je,B as Tt,j as tt,C as bt}from"./index-BJjQW3BE.js";import{S as Ke}from"./sliders-horizontal-CT0i5L8e.js";import{C as se,a as ce,b as le}from"./collapsible-CDu8U8yv.js";import{n as Qe}from"./ScheduleCouponField-CukCHoHP.js";import{C as tr}from"./checkbox-DaiRD0wh.js";import{n as er}from"./affiliateUrlCompact-CPGnhjyE.js";import{I as rr}from"./images-oNwFn1Ft.js";/**
2 * @license lucide-react v0.453.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const nr=Ve("LayoutTemplate",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);function ue(t,e=100){const r=D(e)/100,n=(t.style.lineHeight??t.style.fontSize)*r;return t.y+n/2}function D(t){const e=typeof t=="number"?t:Number(t);return Number.isFinite(e)?Math.min(vt,Math.max(Pt,Math.round(e/Et)*Et)):U}const de=3;function he(t){const e=t.productTitle,r=36;let n=e.width??Math.round(t.width*.84);t.exportRect&&(n=Math.min(n,t.exportRect.width-r*2)),n=Math.min(n,t.width-r*2);const o=t.exportRect?t.exportRect.x+t.exportRect.width/2:e.x;return{...e,x:o,width:Math.max(200,n)}}const fe="so_banner_text_layout",me="so_banner_text_layout_v1",or="so_banner_text_offset_y",St=-3,Ft=14,ar=.5,R={title:2,price:0,cta:0,fontScale:100},Pt=90,vt=135,Et=5,U=100;function Wn(t){return t.startsWith("banner-")?72:t.startsWith("story-")?52:(t.startsWith("feed-"),60)}function I(t){const e=typeof t=="number"?t:Number(t);return Number.isFinite(e)?Math.min(Ft,Math.max(St,Math.round(e*2)/2)):R.title}function J(t){if(t&&typeof t=="object"&&!Array.isArray(t)){const e=t;return{title:I(e.title),price:I(e.price??0),cta:I(e.cta??0),fontScale:D(e.fontScale??U)}}return typeof t=="number"||typeof t=="string"?{...R,title:I(t)}:{...R}}function Ut(t,e){try{const r=t.getItem(e);return r?J(JSON.parse(r)):null}catch{return null}}function ir(){if(typeof window>"u")return{...R};try{const t=Ut(window.localStorage,me);if(t)return t;const e=Ut(window.sessionStorage,fe);if(e)return e;const r=window.sessionStorage.getItem(or);if(r!=null)return{...R,title:I(JSON.parse(r))}}catch{}return{...R}}function sr(t){if(typeof window>"u")return;const e=JSON.stringify(J(t));try{window.localStorage.setItem(me,e)}catch{}try{window.sessionStorage.setItem(fe,e)}catch{}}function Z(t,e,r){const n=I(e);return n===0?t:{...t,y:t.y+n/100*r}}function jt(t,e){if(!t.discountPercent)return;const r=e.fontScalePercent??U,n=Z(t.price,e.priceOffsetYPercent,t.height),o=ue(n,r),a=10,i=D(r)/100,c=(t.discountPercent.style.lineHeight??t.discountPercent.style.fontSize)*i;return{...t.discountPercent,x:n.x,y:o+a+c/2,width:t.discountPercent.width??n.width,style:{...t.discountPercent.style,align:"center"}}}function ge(t,e){if(!t.cta)return;const r=e.fontScalePercent??U,n=D(r)/100,o=[Z(t.price,e.priceOffsetYPercent,t.height)];if(e.showOldPrice&&t.oldPrice&&o.push(Z(t.oldPrice,e.priceOffsetYPercent,t.height)),e.showDiscount&&t.discountPercent){const h=jt(t,{priceOffsetYPercent:e.priceOffsetYPercent,fontScalePercent:r});h&&o.push(h)}let a=0;for(const h of o)a=Math.max(a,ue(h,r));const i=t.format==="banner"?16:24,c=(t.cta.style.lineHeight??t.cta.style.fontSize)*n,l=a+i+c/2,d={...t.cta,x:t.price.x,y:l,width:t.cta.width??t.price.width,style:{...t.cta.style,align:t.cta.style.align??t.price.style.align}};return Z(d,e.ctaOffsetYPercent,t.height)}const pe='"Plus Jakarta Sans", "Segoe UI", system-ui, sans-serif',cr={x:48,y:220,width:984,height:864,fit:"contain"};function lr(t=pe){return{productTitle:{x:540,y:1152,width:900,style:{fontSize:44,fontFamily:t,color:"#FFFFFF",fontWeight:"800",align:"center",lineHeight:50,textShadow:"0 2px 12px rgba(0,0,0,0.55), 0 1px 2px rgba(0,0,0,0.9)"}},oldPrice:{x:540,y:1236,width:400,style:{fontSize:28,fontFamily:t,color:"#CBD5E1",fontWeight:"600",align:"center",lineHeight:32,strike:!0,textShadow:"0 1px 3px rgba(0,0,0,0.4)"}},price:{x:540,y:1314,width:600,style:{fontSize:72,fontFamily:t,color:"#FFEB3B",fontWeight:"900",align:"center",lineHeight:78,textShadow:"0 2px 16px rgba(0,0,0,0.6), 0 0 2px rgba(0,0,0,0.5), 0 1px 0 rgba(0,0,0,0.25)"}},discountPercent:{x:820,y:1316,width:200,style:{fontSize:32,fontFamily:t,color:"#6EE7B7",fontWeight:"900",align:"center",lineHeight:36,textShadow:"0 1px 4px rgba(0,0,0,0.5)"}},cta:{x:540,y:1404,width:580,style:{fontSize:30,fontFamily:t,color:"#FFFFFF",fontWeight:"800",align:"center",lineHeight:36,textShadow:"0 2px 10px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.65)"}},smallLink:{x:540,y:1474,width:720,style:{fontSize:17,fontFamily:t,color:"#E0E7FF",fontWeight:"600",align:"center",lineHeight:22,textShadow:"0 1px 4px rgba(0,0,0,0.45)"}}}}function V(t,e){const r={...t.style};for(const[n,o]of Object.entries(e))o!==void 0&&(r[n]=o);return{...t,style:{...r,fontSize:t.style.fontSize,lineHeight:t.style.lineHeight,align:t.style.align}}}function L(t,e){const r=lr(e?.fontFamily??pe);return{productImage:e?.productImage??cr,productTitle:V(r.productTitle,t.productTitle),oldPrice:r.oldPrice?V(r.oldPrice,t.oldPrice??{}):void 0,price:V(r.price,t.price),discountPercent:r.discountPercent?V(r.discountPercent,t.discountPercent??{}):void 0,cta:r.cta?V(r.cta,t.cta??{}):void 0,smallLink:r.smallLink?V(r.smallLink,t.smallLink??{}):void 0}}function at(t,e,r){return{id:t,name:e,format:"story",width:1080,height:1920,category:"marketplace",platform:"shopee",backgroundSrc:"/templates/story/story-magalu-02.png",backgroundColor:r,...L({productTitle:{color:"#FFFFFF"},oldPrice:{color:"#CBD5E1"},price:{color:"#FFEB3B"},discountPercent:{color:"#6EE7B7"},cta:{color:"#FFFFFF"},smallLink:{color:"#E0E7FF"}})}}const ur={"story-shopee-01":at("story-shopee-01","Story 1","#EE4D2D"),"story-shopee-02":at("story-shopee-02","Story 2","#2563EB"),"story-shopee-03":at("story-shopee-03","Story 3","#047857"),"story-shopee-04":at("story-shopee-04","Story 4","#7C3AED")},Yt={productTitle:{color:"#FFFFFF"},oldPrice:{color:"#CBD5E1"},price:{color:"#FFEB3B"},discountPercent:{color:"#6EE7B7"},cta:{color:"#FFFFFF"},smallLink:{color:"#E0E7FF"}};function dr(){return{id:"story-amazon-01",name:"Story Amazon 01",format:"story",width:1080,height:1920,category:"marketplace",platform:"amazon",backgroundSrc:"/templates/story/story-magalu-02.png",backgroundColor:"#131921",...L({productTitle:{color:"#FFFFFF",textShadow:"0 2px 14px rgba(0,0,0,0.65), 0 1px 2px rgba(0,0,0,0.95)"},oldPrice:{color:"#94A3B8"},price:{color:"#FF9900",textShadow:"0 2px 18px rgba(0,0,0,0.55), 0 0 1px rgba(0,0,0,0.4)"},discountPercent:{color:"#FEBD69"},cta:{color:"#FFFFFF"},smallLink:{color:"#D1D5DB"}},{productImage:{x:48,y:160,width:984,height:800,fit:"contain"}})}}const xe={"story-clean-01":{id:"story-clean-01",name:"Story Clean 01",format:"story",width:1080,height:1920,category:"clean",platform:"geral",backgroundSrc:"/templates/story/story-clean-01.png",...L({productTitle:{color:"#FFFFFF",textShadow:"0 1px 2px rgba(0,0,0,0.5), 0 2px 10px rgba(0,0,0,0.35)"},oldPrice:{color:"#E2E8F0"},price:{color:"#FFD95C"},discountPercent:{color:"#FFFFFF"},cta:{color:"#FFFFFF"},smallLink:{color:"#E2E8F0"}})}
6,"story-instagram-01":{id:"story-instagram-01",name:"Story Instagram",format:"story",width:1080,height:1920,category:"social",platform:"geral",backgroundSrc:"/templates/story/story-instagram-01.png",...L(Yt)},"story-instagram-02":{id:"story-instagram-02",name:"Story Instagram 02",format:"story",width:1080,height:1920,category:"social",platform:"geral",backgroundSrc:"/templates/story/story-instagram-02.png",...L(Yt)},"story-copa_01":{id:"story-copa_01",name:"Story Copa 01",format:"story",width:1080,height:1920,category:"social",platform:"geral",backgroundSrc:"/templates/story/story-copa_01.png",...L({productTitle:{color:"#FFFFFF",textShadow:"0 1px 2px rgba(0,0,0,0.55), 0 2px 10px rgba(0,0,0,0.35)"},oldPrice:{color:"#E2E8F0"},price:{color:"#FFEB3B"},discountPercent:{color:"#FFFFFF"},cta:{color:"#FFFFFF"},smallLink:{color:"#DCFCE7"}})},"story-copa_02":{id:"story-copa_02",name:"Story Copa 02",format:"story",width:1080,height:1920,category:"social",platform:"geral",backgroundSrc:"/templates/story/story-copa_02.png",...L({productTitle:{color:"#FFFFFF",textShadow:"0 1px 2px rgba(0,0,0,0.55), 0 2px 10px rgba(0,0,0,0.35)"},oldPrice:{color:"#E2E8F0"},price:{color:"#FFEB3B"},discountPercent:{color:"#FFFFFF"},cta:{color:"#FFFFFF"},smallLink:{color:"#DCFCE7"}})},"story-copa_03":{id:"story-copa_03",name:"Story Copa 03",format:"story",width:1080,height:1920,category:"social",platform:"geral",backgroundSrc:"/templates/story/story-copa_03.png",...L({productTitle:{color:"#FFFFFF",textShadow:"0 1px 2px rgba(0,0,0,0.55), 0 2px 10px rgba(0,0,0,0.35)"},oldPrice:{color:"#E2E8F0"},price:{color:"#FFEB3B"},discountPercent:{color:"#FFFFFF"},cta:{color:"#FFFFFF"},smallLink:{color:"#DCFCE7"}})},"story-03":{id:"story-03",name:"Story 03",format:"story",width:1080,height:1920,category:"social",platform:"geral",backgroundSrc:"/templates/story/story-03.png",...L({productTitle:{color:"#9D174D",textShadow:void 0},oldPrice:{color:"#A8A29E",textShadow:void 0},price:{color:"#BE185D",textShadow:"0 1px 0 rgba(255,255,255,0.6)"},discountPercent:{color:"#DB2777",textShadow:void 0},cta:{color:"#A21CAF",textShadow:void 0},smallLink:{color:"#9D3B5A",textShadow:void 0}})},"story-04":{id:"story-04",name:"Story 04",format:"story",width:1080,height:1920,category:"social",platform:"geral",backgroundSrc:"/templates/story/story-04.png",...L({productTitle:{color:"#831843",textShadow:void 0},oldPrice:{color:"#9CA3AF",textShadow:void 0},price:{color:"#BE185D",textShadow:"0 1px 0 rgba(255,255,255,0.55)"},discountPercent:{color:"#DB2777",textShadow:void 0},cta:{color:"#9D174D",textShadow:void 0},smallLink:{color:"#9D3B5A",textShadow:void 0}})},"story-magalu-01":{id:"story-magalu-01",name:"Story Magalu 01",format:"story",width:1080,height:1920,category:"marketplace",platform:"magalu",backgroundSrc:"/templates/story/story-magalu-02.png",backgroundColor:"#fdf2f8",...L({productTitle:{color:"#9D174D",textShadow:void 0},oldPrice:{color:"#A8A29E",textShadow:void 0},price:{color:"#BE185D",textShadow:"0 1px 0 rgba(255,255,255,0.6)"},discountPercent:{color:"#DB2777",textShadow:void 0},cta:{color:"#A21CAF",textShadow:void 0},smallLink:{color:"#9D3B5A",textShadow:void 0}})},"story-magalu-02":{id:"story-magalu-02",name:"Story Magalu 02",format:"story",width:1080,height:1920,category:"marketplace",platform:"magalu",backgroundSrc:"/templates/story/story-magalu-02.png",...L({productTitle:{color:"#FFFFFF"},oldPrice:{color:"#CBD5E1"},price:{color:"#FFEB3B"},discountPercent:{color:"#6EE7B7"},cta:{color:"#FFFFFF"},smallLink:{color:"#E0E7FF"}})},...ur,"story-amazon-01":dr(),"feed-clean-01":{id:"feed-clean-01",name:"Feed Clean 01",format:"feed",width:1080,height:1350,category:"clean",platform:"geral",backgroundSrc:"/templates/feed/feed-clean-01.png",backgroundColor:"#fdf2f8",productImage:{x:198,y:128,width:684,height:576,fit:"contain"},productTitle:{x:540,y:768,width:900,style:{fontSize:40,color:"#9D174D",fontWeight:"800",align:"center",lineHeight:48}},oldPrice:{x:540,y:902,width:640,style:{fontSize:32,color:"#A8A29E",fontWeight:"700",align:"center",lineHeight:38,strike:!0}},price:{x:540,y:990,width:900,style:{fontSize:64,color:"#BE185D",fontWeight:"900",align:"center",lineHeight:70,textShadow:"0 1px 0 rgba(255,255,255,0.5)"}},discountPercent:{x:880,y:902,width:150,style:{fontSize:28,color:"#DB2777",fontWeight:"900",align:"center",lineHeight:32}},cta:{x:540,y:1118,width:700,style:{fontSize:30,color:"#A21CAF",fontWeight:"800",align:"center",lineHeight:36}},smallLink:{x:540,y:1205,width:720,style:{fontSize:16,color:"#9D3B5A",fontWeight:"500",align:"center",lineHeight:20}}},"banner-wide-01":{id:"banner-wide-01",name:"Banner horizontal 16:9",format:"banner",width:1200,height:630,category:"clean",platform:"geral",backgroundSrc:"/templates/feed/feed-clean-01.png",backgroundColor:"#0f172a",productImage:{x:36,y:36,width:520,height:558,fit:"contain"},productTitle:{x:600,y:72,width:540,style:{fontSize:28,color:"#F8FAFC",fontWeight:"800",align:"left",lineHeight:34,textShadow:"0 1px 2px rgba(0,0,0,0.4)"}},oldPrice:{x:600,y:250,width:320,style:{fontSize:24,color:"#94A3B8",fontWeight:"700",align:"left",lineHeight:30,strike:!0}},price:{x:600,y:300,width:520,style:{fontSize:58,color:"#F59E0B",fontWeight:"900",align:"left",lineHeight:64,textShadow:"0 1px 3px rgba(0,0,0,0.45)"}},discountPercent:{x:1040,y:240,width:140,style:{fontSize:24,color:"#FFFFFF",fontWeight:"900",align:"center",lineHeight:30,textShadow:"0 1px 2px rgba(0,0,0,0.5)"}},cta:{x:600,y:460,width:520,style:{fontSize:22,color:"#E2E8F0",fontWeight:"700",align:"left",lineHeight:28}},smallLink:{x:600,y:530,width:520,style:{fontSize:15,color:"#A5B4FC",fontWeight:"600",align:"left",lineHeight:20}}},"story-mercadolivre-01":{id:"story-mercadolivre-01",name:"Story Mercado Livre 01",format:"story",width:1080,height:1920,category:"marketplace",platform:"mercadolivre",backgroundSrc:"/templates/story/story-mercadolivre-01.png",...L({productTitle:{color:"#111111",textShadow:void 0},oldPrice:{color:"#6B6B6B",textShadow:void 0},price:{color:"#111111",textShadow:void 0},discountPercent:{color:"#00A650",textShadow:void 0},cta:{color:"#3483FA",textShadow:void 0},smallLink:{color:"#6B6B6B",textShadow:void 0}})}},hr={"story-instagram-01":5,"story-instagram-02":6,"story-copa_01":7,"story-copa_02":8,"story-copa_03":9,"story-03":10,"story-04":11,"story-clean-01":12,"story-magalu-01":20,"story-magalu-02":30,"story-shopee-01":40,"story-shopee-02":41,"story-shopee-03":42,"story-shopee-04":43,"story-amazon-01":50,"story-mercadolivre-01":60};function Vt(t){return hr[t]??100}
6const Un=["banner-wide-01","feed-clean-01","story-clean-01"];function kt(t){return xe[t]??null}function fr(t){return Object.values(xe).filter(r=>!0).sort((r,n)=>Vt(r.id)-Vt(n.id)||r.name.localeCompare(n.name,"pt-BR"))}function mr(t){return t.format==="feed"?"4 / 5":t.format==="banner"?"1200 / 630":"9 / 16"}function it(t){if(t==null)return null;const e=String(t).replace(/[R$\s\u00A0]/gi,"").trim();return e?/^\d{1,3}(?:\.\d{3})+,\d{2}$/.test(e)?Number(e.replace(/\./g,"").replace(",",".")):/^\d+,\d{1,2}$/.test(e)?Number(e.replace(",",".")):/^\d+\.\d{1,2}$/.test(e)?Number(e):/^\d{1,3}(?:\.\d{3})+$/.test(e)?Number(e.replace(/\./g,"")):/^\d+$/.test(e)?Number(e):/^\d+,\d{3,}$/.test(e)?Number(e.replace(/,/g,".")):null:null}function qt(t){const e=it(t);return e==null?"":new Intl.NumberFormat("pt-BR",{style:"currency",currency:"BRL"}).format(e)}function gr(t){if(t==null||t==="")return"";const e=Number(t);return Number.isNaN(e)?String(t).includes("%")?String(t):`${t}% OFF`:`${Math.round(e)}% OFF`}function W(t,e){return`${t/e*100}%`}function pr(t){return String(t??"").replace(/\s+/g," ").trim()||"Produto em destaque"}function xr(t){const e=t?.trim();return e?e.startsWith("//")?`https:${e}`:e:""}function yr(t,e,r,n,o="default",a=100){return{...z(t,e,r,n,o,a),display:"block",boxSizing:"border-box"}}function z(t,e,r,n=0,o="default",a=100){const i=Z(t,n,r),c=i.style.align??"left",l=D(a)/100,d=Math.round(i.style.fontSize*l),h=o==="capture"?`${d}px`:o==="panel"?`clamp(6px, ${d/e*100}cqi, ${Math.round(d*.92)}px)`:`clamp(8px, ${d/e*100}cqi, ${d}px)`;return{position:"absolute",left:W(i.x,e),top:W(i.y,r),width:i.width?W(i.width,e):void 0,color:i.style.color,fontSize:h,fontWeight:i.style.fontWeight,lineHeight:i.style.lineHeight?i.style.lineHeight*l/d:1.12,fontFamily:i.style.fontFamily??"inherit",textAlign:c,textShadow:i.style.textShadow,transform:c==="center"?"translate(-50%, -50%)":c==="right"?"translate(-100%, -50%)":"translate(0, -50%)",whiteSpace:"normal",wordBreak:"break-word",overflowWrap:"anywhere",textDecoration:i.style.strike?"line-through":void 0,pointerEvents:"none",zIndex:20}}const wr=F.forwardRef(({templateId:t,productTitle:e,currentPrice:r,originalPrice:n,discountPercent:o,cta:a,bannerCopy:i,productImageUrl:c,affiliateUrl:l,backgroundSrcOverride:d,titleOffsetYPercent:h,textOffsetYPercent:p,priceOffsetYPercent:b=0,ctaOffsetYPercent:v=0,fontScalePercent:S=100,displayMode:m="default"},P)=>{const x=h??p??0,g=D(S),u=kt(t),y=!!d?.trim(),[f,E]=F.useState(!1),[k,N]=F.useState(!1);F.useEffect(()=>{E(!1)},[t,d]);const O=xr(c);if(F.useEffect(()=>{N(!1)},[c]),!u)return s.jsx("div",{className:"flex aspect-[9/16] w-full max-w-[420px] items-center justify-center rounded-[28px] border bg-muted text-sm text-muted-foreground",children:"Template não configurado"});const C=u.format==="feed"?"aspect-[4/5]":u.format==="banner"?"aspect-[1200/630]":"aspect-[9/16]",w=mr(u),B=m==="panel"?"rounded-xl max-md:rounded-lg":"rounded-[28px]",et=m==="capture"?"shrink-0":m==="panel"?u.format==="banner"?"mx-auto w-full max-w-full shrink-0 aspect-[1200/630]":u.format==="feed"?"mx-auto w-[min(100%,8.75rem)] shrink-0 aspect-[4/5] md:w-[min(100%,13.75rem)]":"mx-auto w-[min(100%,9.75rem)] shrink-0 aspect-[9/16] md:w-[min(100%,12.5rem)]":u.format==="banner"?"w-full max-w-[min(100%,56rem)] shrink-0":u.format==="feed"?"mx-auto w-full max-w-[min(100%,22rem)] shrink-0":"mx-auto w-full max-w-[min(100%,15rem)] shrink-0 md:max-w-[17.5rem]",j=y?void 0:u.backgroundColor,rt=d?.trim()||u.backgroundSrc,ut=it(r),Re=it(n),_t=!j&&!f&&!!rt,Lt=!!O&&!k,Ae=qt(r||"0,00"),nt=ae({currentPrice:r,originalPrice:n,discountPercent:o}),ot=nt?qt(nt):"",dt=nt?it(nt):Re,ht=(()=>{if(o==null||o==="")return null;const Q=Number(o);return Number.isNaN(Q)?null:Math.round(Q)})(),_e=ut!=null&&dt!=null&&dt>ut?Math.max(0,Math.min(99,Math.round((1-ut/dt)*100))):null,Y=ht!=null&&ht>0?ht:_e,Bt=pr(e),ft=a?.trim()||"",Le=!!(u.oldPrice&&ot),Ot=!!u.discountPercent&&Y!=null&&Y>0,Dt=Ot&&u.discountPercent?jt(u,{priceOffsetYPercent:b,fontScalePercent:g}):void 0,It=ft&&u.cta?ge(u,{priceOffsetYPercent:b,ctaOffsetYPercent:v,showOldPrice:Le,showDiscount:Ot,fontScalePercent:g}):void 0,Be=he(u),Oe=de,mt=u.width,gt=u.height,M=u.exportRect,De=M?.width??mt,Ie=M?.height??gt,$e={containerType:m==="capture"?void 0:"inline-size",backgroundColor:j||(_t?"transparent":"#f5f5f5")},$t=M!=null?{position:"absolute",left:0,top:0,width:`${mt/M.width*100}%`,height:`${gt/M.height*100}%`,transformOrigin:"0 0",transform:`translate(calc(-1 * ${M.x/mt} * 100%), calc(-1 * ${M.y/gt} * 100%))`}:null,Mt=s.jsxs(s.Fragment,{children:[j?null:_t?s.jsx("img",{src:rt,alt:"",onError:()=>E(!0),className:"absolute inset-0 z-0 h-full w-full object-cover object-center",crossOrigin:/^https?:\/\//i.test(rt)?"anonymous":void 0,referrerPolicy:"no-referrer"},rt):s.jsx("div",{className:"absolute inset-0 z-0 flex items-center justify-center bg-muted text-xs text-muted-foreground",children:"Fundo do template não encontrado"}),s.jsx("div",{className:["absolute z-[1] overflow-hidden",j?"rounded-2xl ring-1 ring-pink-200/50 shadow-sm":"rounded-md"].join(" "),style:{left:W(u.productImage.x,u.width),top:W(u.productImage.y,u.height),width:W(u.productImage.
6width,u.width),height:W(u.productImage.height,u.height),background:Lt?"transparent":"rgba(0,0,0,0.08)"},children:Lt?s.jsx("img",{src:O,alt:Bt,onError:()=>N(!0),className:"h-full w-full object-contain object-center",referrerPolicy:"no-referrer"}):s.jsx("div",{className:"flex h-full w-full items-center justify-center rounded-md bg-black/20 px-2 text-center text-[11px] font-medium text-white/90",children:"Imagem do produto"})}),s.jsx("div",{style:yr(Be,u.width,u.height,x,m,g),children:s.jsx("div",{style:{display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:Oe,overflow:"hidden",width:"100%",maxWidth:"100%",wordBreak:"break-word",overflowWrap:"break-word"},children:Bt})}),u.oldPrice&&ot?s.jsx("div",{style:z(u.oldPrice,u.width,u.height,b,m,g),children:t.includes("mercadolivre")?`De ${ot}`:ot}):null,s.jsx("div",{style:z(u.price,u.width,u.height,b,m,g),children:Ae}),Dt&&Y!=null&&Y>0?s.jsx("div",{style:z(Dt,u.width,u.height,0,m,g),children:t.includes("mercadolivre")?`−${Y}%`:gr(Y)}):null,It&&ft?s.jsx("div",{style:z(It,u.width,u.height,0,m,g),children:ft}):null,u.smallLink&&i?.trim()?s.jsx("div",{style:z(u.smallLink,u.width,u.height,v,m,g),children:i.trim()}):null,u.fixedTexts?.map((Q,He)=>s.jsx("div",{style:z(Q.zone,u.width,u.height,x,m,g),children:Q.text},`${u.id}-fixed-${He}`))]}),Me=m==="capture"?{width:De,height:Ie,maxWidth:"none"}:void 0,Ht=["relative mx-auto block overflow-hidden",m==="capture"?"":`border border-border shadow-lg ${B}`,et,m==="capture"||m==="panel"?"":C,m!=="capture"&&j?"ring-1 ring-pink-200/80":""].filter(Boolean).join(" "),zt={...$e,...Me??{aspectRatio:w}};return $t?s.jsx("div",{ref:P,"data-banner-capture-root":m==="capture"?!0:void 0,className:Ht,style:zt,children:s.jsx("div",{style:$t,children:Mt})}):s.jsx("div",{ref:P,"data-banner-capture-root":m==="capture"?!0:void 0,className:Ht,style:zt,children:Mt})});wr.displayName="TemplateRenderPreview";const K=48,br=8,ye="so-banner-adj-fab-pos";function G(t,e){if(typeof window>"u")return{x:t,y:e};const r=8,n=Math.max(r,window.innerWidth-K-r),o=Math.max(r,window.innerHeight-K-r-56);return{x:Math.min(n,Math.max(r,t)),y:Math.min(o,Math.max(r,e))}}function Sr(){return typeof window>"u"?{x:16,y:120}:G(window.innerWidth-K-16,window.innerHeight-K-120)}function Fr(){try{const t=sessionStorage.getItem(ye);if(!t)return null;const e=JSON.parse(t);if(typeof e?.x=="number"&&typeof e?.y=="number"&&Number.isFinite(e.x)&&Number.isFinite(e.y))return G(e.x,e.y)}catch{}return null}function Pr(t){try{sessionStorage.setItem(ye,JSON.stringify(t))}catch{}}function Yn({children:t,preview:e,className:r}){const[n,o]=F.useState(!1),[a,i]=F.useState(()=>Fr()??Sr()),[c,l]=F.useState(!1),[d,h]=F.useState(!1),p=F.useRef(null),b=F.useRef(!1);F.useEffect(()=>{h(!0),i(x=>G(x.x,x.y))},[]),F.useEffect(()=>{const x=()=>i(g=>G(g.x,g.y));return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const v=F.useCallback(x=>{x.button===0&&(x.currentTarget.setPointerCapture(x.pointerId),p.current={pointerId:x.pointerId,startX:x.clientX,startY:x.clientY,originX:a.x,originY:a.y,moved:!1},l(!0))},[a.x,a.y]),S=F.useCallback(x=>{const g=p.current;if(!g||g.pointerId!==x.pointerId)return;const u=x.clientX-g.startX,y=x.clientY-g.startY;!g.moved&&Math.hypot(u,y)>=br&&(g.moved=!0),g.moved&&(x.preventDefault(),i(G(g.originX+u,g.originY+y)))},[]),m=F.useCallback(x=>{const g=p.current;if(!(!g||g.pointerId!==x.pointerId)){try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}g.moved&&(b.current=!0,i(u=>{const y=G(u.x,u.y);return Pr(y),y})),p.current=null,l(!1)}},[]),P=s.jsxs("div",{className:T("pointer-events-none fixed z-[90] md:hidden",r),style:{left:a.x,top:a.y,width:K,height:K},children:[s.jsx("button",{type:"button",className:T("pointer-events-auto flex h-12 w-12 touch-manipulation items-center justify-center rounded-full border border-violet-300/90 bg-violet-600 text-white shadow-lg shadow-violet-600/30 transition select-none","hover:bg-violet-700 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-violet-400 focus-visible:ring-offset-2",c?"cursor-grabbing scale-105":"cursor-grab active:scale-[0.98]"),style:{touchAction:"none"},"aria-expanded":n,"aria-controls":"banner-ajustes-sheet","aria-label":"Ajustes do banner — arraste para mover, toque para abrir",title:"Arraste para mover · toque para ajustar",onPointerDown:v,onPointerMove:S,onPointerUp:m,onPointerCancel:m,onClick:()=>
6{if(b.current){b.current=!1;return}o(!0)},children:s.jsx(Ke,{className:"h-5 w-5 shrink-0","aria-hidden":!0})}),s.jsx(qe,{open:n,onOpenChange:o,children:s.jsxs(Xe,{id:"banner-ajustes-sheet",side:"bottom",className:"z-[100] flex max-h-[min(48vh,22rem)] flex-col gap-0 overflow-hidden rounded-t-2xl border-violet-100 p-0 pt-1.5 shadow-2xl",children:[s.jsxs(Ge,{className:"shrink-0 space-y-0 border-b border-violet-100 px-3 pb-2 pt-0.5 text-left",children:[s.jsx(Ze,{className:"text-base font-black text-slate-900",children:"Ajustes do banner"}),s.jsx(Je,{className:"text-[11px] leading-snug text-slate-500",children:"A prévia grande fica acima — arraste o botão roxo se estiver no caminho. Controles atualizam na hora."})]}),s.jsxs("div",{className:"flex min-h-0 flex-1 flex-row gap-2 overflow-hidden px-2 pt-2 pb-[max(0.75rem,env(safe-area-inset-bottom))]",children:[e?s.jsx("div",{className:"shrink-0 border-r border-violet-100/80 pr-2",children:e}):null,s.jsx("div",{className:"min-h-0 min-w-0 flex-1 overflow-y-auto overscroll-contain px-0.5",children:t})]})]})})]});return!d||typeof document>"u"?null:ze.createPortal(P,document.body)}function pt({id:t,label:e,hint:r,value:n,defaultValue:o,onChange:a,compact:i,sheet:c}){const l=I(n),d=c===!0,h=i||d;return s.jsxs("div",{className:T("rounded-lg border border-violet-100/80 bg-white/70",d?"space-y-1 px-2 py-1.5":h?"space-y-1 px-2.5 py-2":"space-y-1.5 px-3 py-2.5"),children:[s.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[s.jsx("label",{htmlFor:t,className:T("font-bold text-slate-700",d?"text-[10px] leading-tight":"text-xs"),children:e}),s.jsxs("span",{className:"shrink-0 text-[10px] font-black tabular-nums text-violet-700",children:[l>0?`+${l}`:l,"%"]})]}),s.jsx("input",{id:t,type:"range",min:St,max:Ft,step:ar,value:l,onChange:p=>a(I(Number(p.target.value))),className:T("w-full touch-manipulation cursor-pointer accent-violet-600",d?"h-7 min-h-[28px]":h?"h-8 min-h-[32px]":"h-10 min-h-[40px]"),"aria-valuemin":St,"aria-valuemax":Ft,"aria-valuenow":l,"aria-label":r}),h?null:s.jsx("p",{className:"text-[10px] font-medium leading-snug text-slate-500",children:r}),l!==o&&!d?s.jsxs(Tt,{type:"button",variant:"ghost",size:"sm",className:"h-7 touch-manipulation px-1.5 text-[10px] font-bold text-violet-700",onClick:()=>a(o),children:["Padrão (",o>0?`+${o}`:o,"%)"]}):null]})}function vr({id:t,value:e,onChange:r,compact:n,sheet:o}){const a=D(e),i=o===!0,c=n||i;return s.jsxs("div",{className:T("rounded-lg border border-violet-100/80 bg-white/70",i?"space-y-1 px-2 py-1.5":c?"space-y-1 px-2.5 py-2":"space-y-1.5 px-3 py-2.5"),children:[s.jsxs("div",{className:"flex items-center justify-between gap-1.5",children:[s.jsx("label",{htmlFor:t,className:T("font-bold text-slate-700",i?"text-[10px] leading-tight":"text-xs"),children:"Tamanho da fonte"}),s.jsxs("span",{className:"shrink-0 text-[10px] font-black tabular-nums text-violet-700",children:[a,"%"]})]}),s.jsx("input",{id:t,type:"range",min:Pt,max:vt,step:Et,value:a,onChange:l=>r(D(Number(l.target.value))),className:T("w-full touch-manipulation cursor-pointer accent-violet-600",i?"h-7 min-h-[28px]":c?"h-8 min-h-[32px]":"h-10 min-h-[40px]"),"aria-valuemin":Pt,"aria-valuemax":vt,"aria-valuenow":a,"aria-label":"Tamanho da fonte no banner"}),c?null:s.jsx("p",{className:"text-[10px] font-medium leading-snug text-slate-500",children:"Aumenta ou diminui título, preços e CTA no banner."}),a!==U&&!i?s.jsxs(Tt,{type:"button",variant:"ghost",size:"sm",className:"h-7 touch-manipulation px-1.5 text-[10px] font-bold text-violet-700",onClick:()=>r(U),children:["Padrão (",U,"%)"]}):null]})}function Er({value:t,onChange:e,className:r,compact:n=!1,sheet:o=!1,idPrefix:a="banner"}){const i=J(t),c=a?`${a}-`:"",l=h=>{e(J({...i,...h}))},d=i.title===R.title&&i.price===R.price&&i.cta===R.cta&&i.fontScale===R.fontScale;return s.jsxs("div",{className:T(o?"space-y-1.5":"space-y-3",r),children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-1",children:[s.jsx("p",{className:T("font-black uppercase text-violet-500",o?"text-[9px] tracking-[0.12em]":"text-[10px] tracking-widest"),children:o?"Posição":"Posição e tamanho no banner (todos os modelos)"}),d?null:s.jsx(Tt,{type:"button",variant:"ghost",size:"sm",className:T("touch-manipulation px-1.5 font-bold text-violet-700",o?"h-6 text-[10px]":"h-8 text-[11px]"),onClick:()=>e({...R}),children:o?"Restaurar":"Restaurar tudo"})]}),s.jsx(vr,{id:`${c}font-scale`,value:i.fontScale,onChange:h=>l({fontScale:h}),compact:n,sheet:o}),s.jsx(pt,{id:`${c}title-offset-y`,label:"Título",hint:"Afasta ou aproxima o título da foto do produto.",value:i.title,defaultValue:R.title,onChange:h=>l({title:h}),compact:n,sheet:o}),s.jsx(pt,{id:`${c}price-offset-y`,label:o?"Preço":"Preço e desconto",hint:"Move preço atual, preço anterior e % OFF para cima ou para baixo.",value:i.price,defaultValue:R.price,onChange:h=>l({price:h}),compact:n,sheet:o}),s.jsx(pt,{id:`${c}cta-offset-y`,label:"CTA",hint:"Move o texto do botão de ação no banner.",value:i.cta,defaultValue:R.cta,onChange:h=>l({cta:h}
6),compact:n,sheet:o})]})}const xt=80;function Vn({idPrefix:t,bannerTextOffsets:e,onBannerTextOffsetsChange:r,showPositionControls:n=!0,sheetMode:o=!1,titleEdit:a,onTitleEditChange:i,priceEdit:c,onPriceEditChange:l,originalPriceEdit:d,onOriginalPriceEditChange:h,ctaText:p,onCtaTextChange:b,bannerCopyEdit:v,onBannerCopyEditChange:S,bannerCopySafeLimit:m,bannerCopyOverSafe:P,titlePlaceholder:x="Ex.: Fone Bluetooth com cancelamento de ruído",pricePlaceholder:g="ex.: 279,90",originalPricePlaceholder:u="ex.: 399,00",ctaPlaceholder:y="Clique aqui para comprar",bannerCopyPlaceholder:f="Ex.: Oferta por tempo limitado",importImageSlot:E,className:k}){const[N,O]=F.useState(!1),C=o?`${t}-sheet`:t,w=o?"h-10 rounded-xl border-slate-200 bg-white text-sm":"h-12 rounded-2xl border-slate-200 bg-white",B=o?"mb-0.5 block text-[9px] font-black uppercase tracking-[0.12em] text-slate-500":"mb-1 block text-[10px] font-black uppercase tracking-widest text-slate-500",et=s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:`${C}-title`,className:B,children:"Título"}),s.jsx(tt,{id:`${C}-title`,value:a,onChange:j=>i(j.target.value),placeholder:x,className:w})]}),s.jsxs("div",{className:T(o?"grid grid-cols-2 gap-2":"grid gap-3 sm:grid-cols-2"),children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:`${C}-price`,className:B,children:"Preço atual"}),s.jsx(tt,{id:`${C}-price`,value:c,onChange:j=>l(j.target.value),placeholder:g,className:w})]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:`${C}-original`,className:B,children:"Preço anterior"}),s.jsx(tt,{id:`${C}-original`,value:d,onChange:j=>h(j.target.value),placeholder:u,className:w})]})]}),s.jsxs("div",{className:T(o?"space-y-2":"grid gap-2 sm:grid-cols-[1fr_auto] sm:items-end"),children:[s.jsxs("div",{children:[s.jsx("label",{htmlFor:`${C}-cta`,className:B,children:"CTA"}),s.jsx(tt,{id:`${C}-cta`,value:p,onChange:j=>b(j.target.value),placeholder:y,className:w})]}),E]}),s.jsxs("div",{children:[s.jsx("label",{htmlFor:`${C}-copy`,className:B,children:"Copy no banner"}),s.jsx(tt,{id:`${C}-copy`,value:v,onChange:j=>S(j.target.value.slice(0,xt)),maxLength:xt,placeholder:f,className:w}),o?s.jsxs("p",{className:T("mt-0.5 text-[10px] font-semibold",P?"text-amber-600":"text-slate-500"),children:[v.length,"/",m," seguro"]}):s.jsxs(s.Fragment,{children:[s.jsxs("p",{className:"mt-1 text-[11px] font-semibold text-slate-500",children:[v.length,"/",xt," caracteres (recomendado: curto e direto)"]}),s.jsxs("p",{className:T("mt-1 text-[11px] font-semibold",P?"text-amber-600":"text-emerald-600"),children:["Faixa segura deste template: até ",m," caracteres",P?" (pode sobrepor elementos).":"."]})]})]})]});return s.jsxs("div",{className:T(o?"space-y-2 pb-1":"space-y-3",k),children:[n?s.jsx(Er,{value:e,onChange:r,idPrefix:C,sheet:o,compact:!o}):null,o?s.jsxs(se,{open:N,onOpenChange:O,children:[s.jsxs(ce,{type:"button",className:"flex w-full touch-manipulation items-center justify-between rounded-lg border border-slate-200/90 bg-white px-2.5 py-2 text-left",children:[s.jsx("span",{className:"text-[10px] font-black uppercase tracking-[0.12em] text-slate-600",children:"Textos do banner"}),s.jsx(bt,{className:T("h-4 w-4 shrink-0 text-slate-500 transition-transform",N?"rotate-180":""),"aria-hidden":!0})]}),s.jsx(le,{className:"space-y-2 overflow-hidden pt-2 data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down",children:et})]}):et]})}function Cr(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const r=document.implementation.createHTMLDocument(),n=r.createElement("base"),o=r.createElement("a");return r.head.appendChild(n),r.body.appendChild(o),e&&(n.href=e),o.href=t,o.href}const Tr=(()=>{let t=0;const e=()=>`0000${(Math.random()*36**4<<0).toString(36)}`.slice(-4);return()=>(t+=1,`u${e()}${t}`)})();function $(t){const e=[];for(let r=0,n=t.length;r<n;r++)e.push(t[r]);return e}let q=null;function we(t={}){return q||(t.includeStyleProperties?(q=t.includeStyleProperties,q):(q=$(window.getComputedStyle(document.documentElement)),q))}function st(t,e){const n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return n?parseFloat(n.replace("px","")):0}function jr(t){const e=st(t,"border-left-width"),r=st(t,"border-right-width");return t.clientWidth+e+r}function kr(t){const e=st(t,"border-top-width"),r=st(t,"border-bottom-width");return t.clientHeight+e+r}function be(t,e={}
6){const r=e.width||jr(t),n=e.height||kr(t);return{width:r,height:n}}function Nr(){let t,e;try{e=process}catch{}const r=e&&e.env?e.env.devicePixelRatio:null;return r&&(t=parseInt(r,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}const _=16384;function Rr(t){(t.width>_||t.height>_)&&(t.width>_&&t.height>_?t.width>t.height?(t.height*=_/t.width,t.width=_):(t.width*=_/t.height,t.height=_):t.width>_?(t.height*=_/t.width,t.width=_):(t.width*=_/t.height,t.height=_))}function ct(t){return new Promise((e,r)=>{const n=new Image;n.onload=()=>{n.decode().then(()=>{requestAnimationFrame(()=>e(n))})},n.onerror=r,n.crossOrigin="anonymous",n.decoding="async",n.src=t})}async function Ar(t){return Promise.resolve().then(()=>new XMLSerializer().serializeToString(t)).then(encodeURIComponent).then(e=>`data:image/svg+xml;charset=utf-8,${e}`)}async function _r(t,e,r){const n="http://www.w3.org/2000/svg",o=document.createElementNS(n,"svg"),a=document.createElementNS(n,"foreignObject");return o.setAttribute("width",`${e}`),o.setAttribute("height",`${r}`),o.setAttribute("viewBox",`0 0 ${e} ${r}`),a.setAttribute("width","100%"),a.setAttribute("height","100%"),a.setAttribute("x","0"),a.setAttribute("y","0"),a.setAttribute("externalResourcesRequired","true"),o.appendChild(a),a.appendChild(t),Ar(o)}const A=(t,e)=>{if(t instanceof e)return!0;const r=Object.getPrototypeOf(t);return r===null?!1:r.constructor.name===e.name||A(r,e)};function Lr(t){const e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}function Br(t,e){return we(e).map(r=>{const n=t.getPropertyValue(r),o=t.getPropertyPriority(r);return`${r}: ${n}${o?" !important":""};`}).join(" ")}function Or(t,e,r,n){const o=`.${t}:${e}`,a=r.cssText?Lr(r):Br(r,n);return document.createTextNode(`${o}{${a}}`)}function Xt(t,e,r,n){const o=window.getComputedStyle(t,r),a=o.getPropertyValue("content");if(a===""||a==="none")return;const i=Tr();try{e.className=`${e.className} ${i}`}catch{return}const c=document.createElement("style");c.appendChild(Or(i,r,o,n)),e.appendChild(c)}function Dr(t,e,r){Xt(t,e,":before",r),Xt(t,e,":after",r)}const Gt="application/font-woff",Zt="image/jpeg",Ir={woff:Gt,woff2:Gt,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:Zt,jpeg:Zt,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function $r(t){const e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}function Nt(t){const e=$r(t).toLowerCase();return Ir[e]||""}function Mr(t){return t.split(/,/)[1]}function Ct(t){return t.search(/^(data:)/)!==-1}function Hr(t,e){return`data:${e};base64,${t}`}async function Se(t,e,r){const n=await fetch(t,e);if(n.status===404)throw new Error(`Resource "${n.url}" not found`);const o=await n.blob();return new Promise((a,i)=>{const c=new FileReader;c.onerror=i,c.onloadend=()=>{try{a(r({res:n,result:c.result}))}catch(l){i(l)}},c.readAsDataURL(o)})}const yt={};function zr(t,e,r){let n=t.replace(/\?.*/,"");return r&&(n=t),/ttf|otf|eot|woff2?/i.test(n)&&(n=n.replace(/.*\//,"")),e?`[${e}]${n}`:n}async function Rt(t,e,r){const n=zr(t,e,r.includeQueryParams);if(yt[n]!=null)return yt[n];r.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+new Date().getTime());let o;try{const a=await Se(t,r.fetchRequestInit,({res:i,result:c})=>(e||(e=i.headers.get("Content-Type")||""),Mr(c)));o=Hr(a,e)}catch(a){o=r.imagePlaceholder||"";let i=`Failed to fetch resource: ${t}`;a&&(i=typeof a=="string"?a:a.message),i&&console.warn(i)}return yt[n]=o,o}async function Wr(t){const e=t.toDataURL();return e==="data:,"?t.cloneNode(!1):ct(e)}async function Ur(t,e){if(t.currentSrc){const a=document.createElement("canvas"),i=a.getContext("2d");a.width=t.clientWidth,a.height=t.clientHeight,i?.drawImage(t,0,0,a.width,a.height);const c=a.toDataURL();return ct(c)}const r=t.poster,n=Nt(r),o=await Rt(r,n,e);return ct(o)}async function Yr(t,e){var r;try{if(!((r=t?.contentDocument)===null||r===void 0)&&r.body)return await lt(t.contentDocument.body,e,!0)}catch{}return t.cloneNode(!1)}async function Vr(t,e){return A(t,HTMLCanvasElement)?Wr(t):A(t,HTMLVideoElement)?Ur(t,e):A(t,HTMLIFrameElement)?Yr(t,e):t.cloneNode(Fe(t))}const qr=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SLOT",Fe=t=>t.tagName!=null&&t.tagName.toUpperCase()==="SVG";async function Xr(t,e,r){var n,o;if(Fe(e))return e;let a=[];return qr(t)&&t.assignedNodes?a=$(t.assignedNodes()):A(t,HTMLIFrameElement)&&(!((n=t.contentDocument)===null||n===void 0)&&n.body)?a=$(t.contentDocument.body.childNodes):a=$(((o=t.shadowRoot)!==null&&o!==void 0?o:t).childNodes),a.length===0||A(t,HTMLVideoElement)||await a.reduce((i,c)=>i.then(()=>lt(c,r)).then(l=>{l&&e.appendChild(l)}),Promise.resolve()),e}function Gr(t,e,r){const n=e.style;if(!n)return;const o=window.getComputedStyle(t);o.cssText?(n.cssText=o.cssText,n.transformOrigin=o.transformOrigin):we(r).forEach(a=>{let i=o.getPropertyValue(a);a==="font-size"&&i.endsWith("px")&&(i=`${Math.floor(parseFloat(i.substring(0,i.length-2)))-.1}px`),A(t,HTMLIFrameElement)&&a==="display"&&i==="inline"&&(i="block"),a==="d"&&e.getAttribute("d")&&(i=`path(${e.getAttribute("d")}
6)`),n.setProperty(a,i,o.getPropertyPriority(a))})}function Zr(t,e){A(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),A(t,HTMLInputElement)&&e.setAttribute("value",t.value)}function Jr(t,e){if(A(t,HTMLSelectElement)){const r=e,n=Array.from(r.children).find(o=>t.value===o.getAttribute("value"));n&&n.setAttribute("selected","")}}function Kr(t,e,r){return A(e,Element)&&(Gr(t,e,r),Dr(t,e,r),Zr(t,e),Jr(t,e)),e}async function Qr(t,e){const r=t.querySelectorAll?t.querySelectorAll("use"):[];if(r.length===0)return t;const n={};for(let a=0;a<r.length;a++){const c=r[a].getAttribute("xlink:href");if(c){const l=t.querySelector(c),d=document.querySelector(c);!l&&d&&!n[c]&&(n[c]=await lt(d,e,!0))}}const o=Object.values(n);if(o.length){const a="http://www.w3.org/1999/xhtml",i=document.createElementNS(a,"svg");i.setAttribute("xmlns",a),i.style.position="absolute",i.style.width="0",i.style.height="0",i.style.overflow="hidden",i.style.display="none";const c=document.createElementNS(a,"defs");i.appendChild(c);for(let l=0;l<o.length;l++)c.appendChild(o[l]);t.appendChild(i)}return t}async function lt(t,e,r){return!r&&e.filter&&!e.filter(t)?null:Promise.resolve(t).then(n=>Vr(n,e)).then(n=>Xr(t,n,e)).then(n=>Kr(t,n,e)).then(n=>Qr(n,e))}const Pe=/url\((['"]?)([^'"]+?)\1\)/g,tn=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,en=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function rn(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}function nn(t){const e=[];return t.replace(Pe,(r,n,o)=>(e.push(o),r)),e.filter(r=>!Ct(r))}async function on(t,e,r,n,o){try{const a=r?Cr(e,r):e,i=Nt(e);let c;return o||(c=await Rt(a,i,n)),t.replace(rn(e),`$1${c}$3`)}catch{}return t}function an(t,{preferredFontFormat:e}){return e?t.replace(en,r=>{for(;;){const[n,,o]=tn.exec(r)||[];if(!o)return"";if(o===e)return`src: ${n};`}}):t}function ve(t){return t.search(Pe)!==-1}async function Ee(t,e,r){if(!ve(t))return t;const n=an(t,r);return nn(n).reduce((a,i)=>a.then(c=>on(c,i,e,r)),Promise.resolve(n))}async function X(t,e,r){var n;const o=(n=e.style)===null||n===void 0?void 0:n.getPropertyValue(t);if(o){const a=await Ee(o,null,r);return e.style.setProperty(t,a,e.style.getPropertyPriority(t)),!0}return!1}async function sn(t,e){await X("background",t,e)||await X("background-image",t,e),await X("mask",t,e)||await X("-webkit-mask",t,e)||await X("mask-image",t,e)||await X("-webkit-mask-image",t,e)}async function cn(t,e){const r=A(t,HTMLImageElement);if(!(r&&!Ct(t.src))&&!(A(t,SVGImageElement)&&!Ct(t.href.baseVal)))return;const n=r?t.src:t.href.baseVal,o=await Rt(n,Nt(n),e);await new Promise((a,i)=>{t.onload=a,t.onerror=e.onImageErrorHandler?(...l)=>{try{a(e.onImageErrorHandler(...l))}catch(d){i(d)}}:i;const c=t;c.decode&&(c.decode=a),c.loading==="lazy"&&(c.loading="eager"),r?(t.srcset="",t.src=o):t.href.baseVal=o})}async function ln(t,e){const n=$(t.childNodes).map(o=>Ce(o,e));await Promise.all(n).then(()=>t)}async function Ce(t,e){A(t,Element)&&(await sn(t,e),await cn(t,e),await ln(t,e))}function un(t,e){const{style:r}=t;e.backgroundColor&&(r.backgroundColor=e.backgroundColor),e.width&&(r.width=`${e.width}px`),e.height&&(r.height=`${e.height}px`);const n=e.style;return n!=null&&Object.keys(n).forEach(o=>{r[o]=n[o]}),t}const Jt={};async function Kt(t){let e=Jt[t];if(e!=null)return e;const n=await(await fetch(t)).text();return e={url:t,cssText:n},Jt[t]=e,e}async function Qt(t,e){let r=t.cssText;const n=/url\(["']?([^"')]+)["']?\)/g,a=(r.match(/url\([^)]+\)/g)||[]).map(async i=>{let c=i.replace(n,"$1");return c.startsWith("https://")||(c=new URL(c,t.url).href),Se(c,e.fetchRequestInit,({result:l})=>(r=r.replace(i,`url(${l})`),[i,l]))});return Promise.all(a).then(()=>r)}function te(t){if(t==null)return[];const e=[],r=/(\/\*[\s\S]*?\*\/)/gi;let n=t.replace(r,"");const o=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)}
6)","gi");for(;;){const l=o.exec(n);if(l===null)break;e.push(l[0])}n=n.replace(o,"");const a=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,i="((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})",c=new RegExp(i,"gi");for(;;){let l=a.exec(n);if(l===null){if(l=c.exec(n),l===null)break;a.lastIndex=c.lastIndex}else c.lastIndex=a.lastIndex;e.push(l[0])}return e}async function dn(t,e){const r=[],n=[];return t.forEach(o=>{if("cssRules"in o)try{$(o.cssRules||[]).forEach((a,i)=>{if(a.type===CSSRule.IMPORT_RULE){let c=i+1;const l=a.href,d=Kt(l).then(h=>Qt(h,e)).then(h=>te(h).forEach(p=>{try{o.insertRule(p,p.startsWith("@import")?c+=1:o.cssRules.length)}catch(b){console.error("Error inserting rule from remote css",{rule:p,error:b})}})).catch(h=>{console.error("Error loading remote css",h.toString())});n.push(d)}})}catch(a){const i=t.find(c=>c.href==null)||document.styleSheets[0];o.href!=null&&n.push(Kt(o.href).then(c=>Qt(c,e)).then(c=>te(c).forEach(l=>{i.insertRule(l,i.cssRules.length)})).catch(c=>{console.error("Error loading remote stylesheet",c)})),console.error("Error inlining remote css file",a)}}),Promise.all(n).then(()=>(t.forEach(o=>{if("cssRules"in o)try{$(o.cssRules||[]).forEach(a=>{r.push(a)})}catch(a){console.error(`Error while reading CSS rules from ${o.href}`,a)}}),r))}function hn(t){return t.filter(e=>e.type===CSSRule.FONT_FACE_RULE).filter(e=>ve(e.style.getPropertyValue("src")))}async function fn(t,e){if(t.ownerDocument==null)throw new Error("Provided element is not within a Document");const r=$(t.ownerDocument.styleSheets),n=await dn(r,e);return hn(n)}function Te(t){return t.trim().replace(/["']/g,"")}function mn(t){const e=new Set;function r(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(a=>{e.add(Te(a))}),Array.from(n.children).forEach(a=>{a instanceof HTMLElement&&r(a)})}return r(t),e}async function je(t,e){const r=await fn(t,e),n=mn(t);return(await Promise.all(r.filter(a=>n.has(Te(a.style.fontFamily))).map(a=>{const i=a.parentStyleSheet?a.parentStyleSheet.href:null;return Ee(a.cssText,i,e)}))).join(`
7`)}async function gn(t,e){const r=e.fontEmbedCSS!=null?e.fontEmbedCSS:e.skipFonts?null:await je(t,e);if(r){const n=document.createElement("style"),o=document.createTextNode(r);n.appendChild(o),t.firstChild?t.insertBefore(n,t.firstChild):t.appendChild(n)}}async function pn(t,e={}){const{width:r,height:n}=be(t,e),o=await lt(t,e,!0);return await gn(o,e),await Ce(o,e),un(o,e),await _r(o,r,n)}async function xn(t,e={}){const{width:r,height:n}=be(t,e),o=await pn(t,e),a=await ct(o),i=document.createElement("canvas"),c=i.getContext("2d"),l=e.pixelRatio||Nr(),d=e.canvasWidth||r,h=e.canvasHeight||n;return i.width=d*l,i.height=h*l,e.skipAutoScale||Rr(i),i.style.width=`${d}`,i.style.height=`${h}`,e.backgroundColor&&(c.fillStyle=e.backgroundColor,c.fillRect(0,0,i.width,i.height)),c.drawImage(a,0,0,i.width,i.height),i}async function yn(t,e={}){return(await xn(t,e)).toDataURL()}async function wn(t,e={}){return je(t,e)}function ee(t){const e=t.trim();return e?new Promise(r=>{const n=new Image,o=()=>r(n.naturalWidth>0?n:null);if(n.onload=o,n.onerror=()=>r(null),/^https?:\/\//i.test(e))try{new URL(e,window.location.origin).origin!==window.location.origin&&(n.crossOrigin="anonymous")}catch{n.crossOrigin="anonymous"}n.src=e}):Promise.resolve(null)}function bn(t,e,r,n,o,a){const i=e.naturalWidth/Math.max(1,e.naturalHeight),c=o/Math.max(1,a);let l=0,d=0,h=e.naturalWidth,p=e.naturalHeight;i>c?(h=Math.round(e.naturalHeight*c),l=Math.round((e.naturalWidth-h)/2)):(p=Math.round(e.naturalWidth/c),d=Math.round((e.naturalHeight-p)/2)),t.drawImage(e,l,d,h,p,r,n,o,a)}function Sn(t,e,r,n,o,a){const i=e.naturalWidth/Math.max(1,e.naturalHeight),c=o/Math.max(1,a);let l=o,d=a,h=r,p=n;i>c?(d=o/i,p=n+(a-d)/2):(l=a*i,h=r+(o-l)/2),t.drawImage(e,h,p,l,d)}function Fn(t,e,r,n){const o=e.split(/\s+/).filter(Boolean);if(o.length===0)return[];const a=[];let i=o[0];for(let c=1;c<o.length;c++){const l=`${i} ${o[c]}`;if(t.measureText(l).width<=r)i=l;else if(a.push(i),i=o[c],a.length===n-1){const d=[i,...o.slice(c+1)].join(" ");let h=d;for(;h.length>1&&t.measureText(`${h}…`).width>r;)h=h.slice(0,-1);return a.push(t.measureText(d).width>r?`${h.trimEnd()}…`:d),a}}return a.push(i),a.slice(0,n)}function re(t,e){if(!e){t.shadowColor="transparent",t.shadowBlur=0,t.shadowOffsetX=0,t.shadowOffsetY=0;return}t.shadowOffsetX=0,t.shadowOffsetY=2,t.shadowBlur=10,t.shadowColor="rgba(0,0,0,0.55)"}function H(t,e,r,n,o,a,i){const c=e.replace(/\s+/g," ").trim();if(!c)return;const l=Z(r,o,n),d=D(a)/100,h=Math.max(8,Math.round(l.style.fontSize*d)),p=Math.max(h,Math.round((l.style.lineHeight??h*1.12)*d)),b=l.style.fontFamily??"system-ui, sans-serif",v=l.style.fontWeight??"700",S=l.style.align??"left",m=Math.max(40,l.width??800);t.font=`${v} ${h}px ${b}`,t.fillStyle=l.style.color,t.textAlign=S==="center"?"center":S==="right"?"right":"left",t.textBaseline="middle",re(t,l.
7style.textShadow);const P=Fn(t,c,m,i),x=P.length*p,g=l.y-x/2+p/2;for(let u=0;u<P.length;u++){const y=g+u*p;if(t.fillText(P[u],l.x,y),l.style.strike){const f=t.measureText(P[u]).width,E=S==="center"?l.x-f/2:S==="right"?l.x-f:l.x;t.shadowColor="transparent",t.strokeStyle=l.style.color,t.lineWidth=Math.max(2,Math.round(h*.08)),t.beginPath(),t.moveTo(E,y),t.lineTo(E+f,y),t.stroke(),re(t,l.style.textShadow)}}t.shadowColor="transparent"}function Pn(t,e){return t.includes("mercadolivre")?`−${e}%`:`${Math.round(e)}% OFF`}async function ne(t){const e=kt(t.templateId);if(!e||typeof document>"u")return null;const r=e.width,n=e.height,o=D(t.fontScalePercent??100),a=t.titleOffsetYPercent??0,i=t.priceOffsetYPercent??0,c=t.ctaOffsetYPercent??0,l=t.backgroundSrcOverride?.trim()||"",d=l?void 0:e.backgroundColor,h=l||e.backgroundSrc,p=(t.productImageUrl||"").trim(),[b,v]=await Promise.all([d&&!l?Promise.resolve(null):ee(h),ee(p)]);if(!v)return console.warn("[composeVisualBanner] Foto do produto não carregou — banner abortado.",p?p.slice(0,120):"(sem URL)"),null;const S=document.createElement("canvas");S.width=r,S.height=n;const m=S.getContext("2d");if(!m)return null;m.fillStyle=d||e.backgroundColor||"#111827",m.fillRect(0,0,r,n),b&&(!d||l)&&bn(m,b,0,0,r,n);const P=e.productImage;Sn(m,v,P.x,P.y,P.width,P.height);const x=(t.productTitle||"").replace(/\s+/g," ").trim()||"Produto em destaque",g=(t.currentPrice||"").trim(),y=(ae({currentPrice:t.currentPrice,originalPrice:t.originalPrice,discountPercent:t.discountPercent})||t.originalPrice||"").trim(),f=(()=>{if(t.discountPercent!==void 0&&t.discountPercent!==null&&t.discountPercent!==""){const w=Number(t.discountPercent);if(Number.isFinite(w)&&w>0)return Math.round(w)}return null})(),E=he(e);if(H(m,x,E,n,a,o,de),e.oldPrice&&y){const w=t.templateId.includes("mercadolivre")?`De ${y}`:y;H(m,w,e.oldPrice,n,i,o,1)}g&&H(m,g,e.price,n,i,o,1);const k=!!e.discountPercent&&f!=null&&f>0;if(k&&e.discountPercent){const w=jt(e,{priceOffsetYPercent:i,fontScalePercent:o});w&&H(m,Pn(t.templateId,f),w,n,0,o,1)}const N=(t.cta||"").trim();if(N&&e.cta){const w=ge(e,{priceOffsetYPercent:i,ctaOffsetYPercent:c,showOldPrice:!!(e.oldPrice&&y),showDiscount:k,fontScalePercent:o});w&&H(m,N,w,n,0,o,2)}const O=(t.bannerCopy||"").trim();O&&e.smallLink&&H(m,O,e.smallLink,n,c,o,2),e.fixedTexts?.forEach(w=>{H(m,w.text,w.zone,n,a,o,1)});const C=e.exportRect;if(C){const w=document.createElement("canvas");w.width=Math.max(1,Math.round(C.width)),w.height=Math.max(1,Math.round(C.height));const B=w.getContext("2d");return B?(B.fillStyle=d||e.backgroundColor||"#111827",B.fillRect(0,0,w.width,w.height),B.drawImage(S,C.x,C.y,C.width,C.height,0,0,w.width,w.height),w.toDataURL("image/jpeg",.9)):S.toDataURL("image/jpeg",.9)}return S.toDataURL("image/jpeg",.9)}async function vn(t,e=8e3){const r=Array.from(t.querySelectorAll("img")),n=Promise.all(r.map(o=>o.complete?o.naturalWidth>0?o.decode?.().catch(()=>{})??Promise.resolve():Promise.resolve():new Promise(a=>{const i=()=>a();o.addEventListener("load",i,{once:!0}),o.addEventListener("error",i,{once:!0})})));await Promise.race([n,new Promise(o=>setTimeout(o,e))])}function oe(t){if(!t)return!1;const e=t.querySelector("[data-banner-capture-root]");if(!e)return!1;const r=e.getBoundingClientRect();return r.width>0&&r.height>0}async function qn(t,e=6500){const r=Date.now();for(;Date.now()-r<e;){const o=t();if(oe(o))return o;await new Promise(a=>setTimeout(a,48))}const n=t();return oe(n)?n:null}function wt(t,e,r=.03){return Math.abs(t-e)<r}async function En(t,e){const r=e.exportRect;if(!r)return t;const{x:n,y:o,width:a,height:i}=r,c=e.width,l=e.height;return new Promise((d,h)=>{const p=new Image;p.crossOrigin="anonymous",p.onload=()=>{const b=p.naturalWidth,v=p.naturalHeight,S=b/v,m=a/i,P=c/l;if(wt(S,m)&&!wt(S,P)){d(t);return}let x=b/c,g=v/l,u=n*x,y=o*g,f=a*x,E=i*g;if(!(u>=-.5&&y>=-.5&&f>1&&E>1&&u+f<=b+1&&y+E<=v+1)){if(wt(S,m)){d(t);return}x=b/a,g=v/i,u=0,y=0,f=b,E=v}const N=document.createElement("canvas");N.width=Math.max(1,Math.round(f)),N.height=Math.max(1,Math.round(E));const O=N.getContext("2d");if(!O){h(new Error("Canvas 2D indisponível"));return}O.drawImage(p,u,y,f,E,0,0,N.width,N.height),d(N.toDataURL("image/png"))},p.onerror=()=>h(new Error("Falha ao carregar PNG para recorte do cartão")),p.src=t})}function Cn(t){return new Promise((e,r)=>{const n=new FileReader;n.onload=()=>e(String(n.result)),n.onerror=()=>r(new Error("read")),n.readAsDataURL(t)})}async function Tn(t,e){const r=new AbortController,n=window.setTimeout(()=>r.abort(),e);try{return await fetch(t,{mode:"same-origin",cache:"no-cache",signal:r.signal})}catch{return null}finally{window.clearTimeout(n)}}async function jn(t){const e=typeof window<"u"?window.location.origin:"",r=Array.from(t.querySelectorAll("img"));await Promise.all(r.map(async n=>{const o=n.currentSrc||n.getAttribute("src")||"";if(!o||o.startsWith("data:")||o.startsWith("blob:"))return;let a=o;try{a=new URL(o,e||void 0).href}catch{return}if(!a.includes("/templates/"))return;const i=await Tn(a,2500);if(i?.ok)try{const c=await i.blob();if(!c.type.startsWith("image/"))return;n.src=await Cn(c)}catch{}})),await vn(t,2500)}function kn(t){return t.querySelector("[data-banner-capture-root]")??t}async function Xn(t,e,r){if(r)try{const d=await ne(r);if(d?.startsWith("data:image/"))return d}catch(d){console.warn("Captura canvas do banner falhou, a tentar html-to-image:",d)}const n=kt(e),o=kn(t),a=o.getBoundingClientRect();let i=Math.max(1,Math.round(a.width)),c=Math.max(1,Math.round(a.height));n?.exportRect?(i=Math.max(1,Math.round(n.exportRect.width)),c=Math.max(1,Math.round(n.exportRect.height))):n&&(i=Math.max(1,Math.round(n.width)),c=Math.max(1,Math.round(n.height)));const l={width:i,height:c,cacheBust:!1,pixelRatio:i>=720?1:2,style:{margin:"0px",marginInline:"0px",maxWidth:"none",boxSizing:"border-box",opacity:"1",visibility:"visible"},backgroundColor:n?.backgroundColor||"#ffffff",onImageErrorHandler:()=>{}};n||(l.pixelRatio=Math.min(2,typeof window<"u"&&window.devicePixelRatio||2));try{const d=await wn(o,l);d?.trim()&&(l.fontEmbedCSS=d)}catch{}try{await jn(o)}catch{}try{let d=await Promise.race([yn(o,l),new Promise((h,p)=>window.setTimeout(()=>p(new Error("toPng timeout")),1e4))]);return n?.exportRect&&(d=await En(d,n)),d}catch(d){if(console.warn("html-to-image do banner falhou, a tentar canvas:",d),r){const h=await ne(r);if(h?.startsWith("data:image/"))return h}throw d}}async function Gn(t,e=.88){return t.startsWith("data:image/jpeg")?t:new Promise(r=>{const n=new Image;n.onload=()=>{const o=document.createElement("canvas");
7o.width=Math.max(1,n.naturalWidth),o.height=Math.max(1,n.naturalHeight);const a=o.getContext("2d");if(!a){r(t);return}a.fillStyle="#ffffff",a.fillRect(0,0,o.width,o.height),a.drawImage(n,0,0);try{r(o.toDataURL("image/jpeg",e))}catch{r(t)}},n.onerror=()=>r(t),n.src=t})}const At="smartoferta:campaignScheduleHandoff";function Zn(t){const e=t.indexOf(",");return e>=0?t.slice(e+1):t}function Jn(t){if(typeof window>"u")return!1;const e={version:1,createdAt:Date.now(),...t};try{return window.sessionStorage.setItem(At,JSON.stringify(e)),!0}catch{return!1}}function Kn(){if(typeof window>"u")return null;try{const t=window.sessionStorage.getItem(At);if(!t)return null;const e=JSON.parse(t);return e?.version!==1||!e.convertedUrl?.trim()||!e.postContent?.trim()?null:e}catch{return null}}function Qn(){if(!(typeof window>"u"))try{window.sessionStorage.removeItem(At)}catch{}}const to="campaignSchedule";async function Nn(t){const e=String(t||"").trim();if(!e)return null;if(e.startsWith("data:"))return e;const r=e.startsWith("//")?`https:${e}`:e;if(!/^https?:\/\//i.test(r))return null;try{const n=await fetch(r);if(!n.ok)return null;const o=await n.blob();return o.type.startsWith("image/")?await new Promise(a=>{const i=new FileReader;i.onload=()=>{a(typeof i.result=="string"?i.result:null)},i.onerror=()=>a(null),i.readAsDataURL(o)}):null}catch{return null}}function eo(t,e){const r=String(t??"").trim();return r||String(e??"").trim()||null}async function ro(t,e){const r=await Nn(t);if(r)return r;const n=String(t||"").trim();if(!n||n.startsWith("data:"))return null;const o=n.startsWith("//")?`https:${n}`:n;if(!/^https?:\/\//i.test(o)||!e)return null;try{return await e(o)}catch{return null}}function Rn(t){const e=String(t||"").split(/\n/).map(o=>o.trimEnd()),r=[];let n=[];for(const o of e){if(!o.trim()){n.length&&(r.push(n.join(`
8`)),n=[]);continue}n.push(o)}return n.length&&r.push(n.join(`
9`)),r.join(`
10
11`).trim()}function no(t){const e=new Set,r=[];for(const n of t){const o=n.trim();if(!o)continue;const a=o.replace(/\s+/g," ").toLowerCase().slice(0,240);e.has(a)||(e.add(a),r.push(Rn(o)))}return r}function oo(){const[t,e]=F.useState(()=>ir());F.useEffect(()=>{sr(t)},[t]);const r=F.useCallback(o=>{e(a=>{const i=typeof o=="function"?o(a):o;return J(i)})},[]),n=F.useCallback(()=>{e({...R})},[]);return{offsets:J(t),setOffsets:r,resetOffsets:n}}function ao(t,e){const r=Qe(e);let n=String(t??"").trim();if(!n)return n;if(/\{\{\s*coupon\s*\}\}/i.test(n))return n=n.replace(/\{\{\s*coupon\s*\}\}/gi,r),Wt(n);if(!r)return Wt(n.split(`
12`).filter(a=>!/utilize o cupom/i.test(a.trim())&&!/cupom aqui/i.test(a.trim())).join(`
13`));if(/utilize o cupom/i.test(n)||/cupom aqui/i.test(n))return n;const o=We(r);return o?`${n}
14
15${o}`.trim():n}function io({platform:t,checked:e,onCheckedChange:r,className:n}){return er(t)!=="mercadolivre"?null:s.jsxs("label",{className:T("flex min-h-[44px] cursor-pointer items-start gap-3 rounded-xl border border-slate-200 bg-slate-50/80 px-3 py-2.5 touch-manipulation",n),children:[s.jsx(tr,{checked:e,onCheckedChange:o=>r(o===!0),className:"mt-0.5"}),s.jsxs("span",{className:"text-[11px] leading-relaxed text-slate-600",children:[s.jsx("span",{className:"font-bold text-slate-700",children:"Encurtar link (Mercado Livre)"})," — ","Remove parâmetros extras do link convertido, mantendo matt_tool e comissão."]})]})}const An=new Set(["story-instagram-01","story-instagram-02","story-copa_01","story-copa_02","story-copa_03","story-03","story-04"]);function so({value:t,onChange:e,productTitle:r,currentPrice:n,originalPrice:o,discountPercent:a,cta:i,productImageUrl:c,affiliateUrl:l,restrictToTemplateIds:d,restrictToFormat:h,initialFormatFilter:p="all"}){const[b,v]=F.useState("all"),[S,m]=F.useState(h??p),[P,x]=F.useState(!1),g=F.useMemo(()=>{let f=fr();if(h&&(f=f.filter(k=>k.format===h)),!d?.length)return f;const E=new Set(d);return f.filter(k=>E.has(k.id))},[d,h]),u=F.useMemo(()=>g.filter(f=>{const E=b==="all"||f.platform===b||b==="generic"&&f.platform==="geral",k=S==="all"||f.format===S;return E&&k}),[g,b,S]),y=u.find(f=>f.id===t)??g.find(f=>f.id===t)??u[0]??g[0];return s.jsxs("div",{className:"min-w-0 max-w-full overflow-x-hidden rounded-[28px] border bg-card p-5 shadow-sm",children:[s.jsxs("div",{className:"mb-5 flex min-w-0 items-start gap-3",children:[s.jsx("div",{className:"rounded-2xl bg-primary/10 p-3 text-primary",children:s.jsx(nr,{className:"h-5 w-5"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("h3",{className:"text-lg font-semibold",children:"Modelos e filtros"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Escolha o layout; título, preços e foto da oferta entram no modelo selecionado."})]})]}),s.jsxs("div",{className:"grid min-w-0 gap-4 md:grid-cols-3",children:[s.jsxs("div",{children:[s.jsx("label",{className:"mb-2 block text-sm font-medium",children:"Plataforma"}),s.jsxs("select",{value:b,onChange:f=>v(f.target.value),className:"h-12 w-full rounded-2xl border border-input bg-background px-4 text-sm outline-none transition focus:border-primary",children:[s.jsx("option",{value:"all",children:"Todas"}),s.jsx("option",{value:"mercadolivre",children:"Mercado Livre"}),s.jsx("option",{value:"magalu",children:"Magalu"}),s.jsx("option",{value:"amazon",children:"Amazon"}),s.jsx("option",{value:"shopee",children:"Shopee"}),s.jsx("option",{value:"generic",children:"Genérico"})]})]}),h?s.jsxs("div",{className:"flex flex-col justify-end rounded-2xl border border-dashed border-primary/30 bg-primary/5 px-4 py-3",children:[s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-primary/80",children:"Formato"}),s.jsx("p",{className:"text-sm font-semibold text-foreground",children:h==="story"?"Story 9:16":h==="feed"?"Feed 4:5":"Banner 16:9"})]}):s.jsxs("div",{children:[s.jsx("label",{className:"mb-2 block text-sm font-medium",children:"Formato"}),s.jsxs("select",{value:S,onChange:f=>m(f.target.value),className:"h-12 w-full rounded-2xl border border-input bg-background px-4 text-sm outline-none transition focus:border-primary",children:[s.jsx("option",{value:"all",children:"Todos"}),s.jsx("option",{value:"story",children:"Story 9:16"}),s.jsx("option",{value:"feed",children:"Feed 4:5"}),s.jsx("option",{value:"banner",children:"Banner 16:9"})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"mb-2 block text-sm font-medium",children:"Template"}),s.jsxs("div",{className:"relative",children:[s.jsx("select",{value:y?.id??"",onChange:f=>e(f.target.value),className:"h-12 w-full appearance-none rounded-2xl border border-input bg-background px-4 pr-10 text-sm font-medium outline-none transition focus:border-primary",children:u.map(f=>s.jsx("option",{value:f.id,children:f.name},f.id))}),s.jsx(bt,{className:"pointer-events-none absolute right-4 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"})]})]})]}),u.length>0?s.jsxs(se,{open:P,onOpenChange:x,className:"mt-5",children:[s.jsx(ce,{asChild:!0,children:s.jsxs("button",{type:"button",className:"flex w-full items-center justify-between gap-3 rounded-2xl border border-border/70 bg-muted/25 px-4 py-3.5 text-left text-sm font-semibold text-foreground shadow-sm transition hover:border-primary/35 hover:bg-muted/40 active:scale-[0.99]",children:[s.jsxs("span",{className:"flex min-w-0 items-center gap-2.5",children:[s.jsx("span",{className:"flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-primary/10 text-primary",children:s.jsx(rr,{className:"h-4 w-4","aria-hidden":!0})}),s.jsxs("span",{className:"min-w-0",children:[s.jsx("span",{className:"block font-bold tracking-tight",children:"Galeria de layouts"}),s.jsx("span",{className:"mt-0.5 block text-xs font-normal text-muted-foreground",children:P?"Toque para ocultar as miniaturas":`Mostrar ${u.length} miniatura${u.length===1?"":"s"} · story, feed ou banner`})]})]}),s.jsx(bt,{className:T("h-5 w-5 shrink-0 text-muted-foreground transition-transform duration-200",P?"rotate-180":""),"aria-hidden":!0})]})}),s.jsxs(le,{className:"overflow-hidden",children:[s.jsxs("p",{className:"mb-2 mt-3 text-xs font-medium text-muted-foreground",children:["Toque na miniatura · o formato segue o modelo (9:16, 4:5 ou 16:9)."," ",u.length," layout",u.length===1?"":"s",S==="story"?" — desça para ver todos os stories.":"."]}),s.jsx("div",{className:"grid grid-cols-2 gap-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5",children:u.map(f=>{const E=t===f.id,k=An.has(f.id);return s.jsxs("button",{type:"button",onClick:()=>e(f.id),className:T("group relative rounded-2xl border-2 p-1.5 text-left transition",E?"border-primary bg-primary/5 shadow-sm ring-2 ring-primary/20":"border-border/60 bg-muted/30 hover:border-primary/40"),children:[k?s.jsx("span",{className:"absolute right-1 top-1 z-10 rounded-md bg-emerald-600 px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wide text-white shadow-sm",children:"Novo"}):null,s.jsx("div",{className:T("mx-auto w-full max-w-[72px] overflow-hidden rounded-lg border bg-white shadow-inner sm:max-w-[88px]",f.format==="story"?"aspect-[9/16]":f.format==="banner"?"aspect-[16/9]":"aspect-[4/5]"),children:f.backgroundColor?s.jsx("div",{className:"h-full w-full",style:{backgroundColor:f.backgroundColor},"aria-hidden":!0}):s.jsx("img",{src:f.backgroundSrc,alt:"",className:"h-full w-full object-cover"})}),s.jsx("p",{className:"mt-1.5 line-clamp-2 text-center text-[10px] font-medium leading-tight text-foreground
15/90",children:f.name})]},f.id)})})]})]}):null,y?s.jsxs("div",{className:"mt-6 space-y-2 rounded-[24px] border border-dashed border-border/60 bg-muted/20 p-4",children:[s.jsx("p",{className:"text-sm font-semibold",children:y.name}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:[y.platform??"geral"," •"," ",y.category??"template visual"," •"," ",y.format==="story"?"9:16":y.format==="banner"?"16:9":"4:5"]}),s.jsxs("p",{className:"text-sm text-muted-foreground",children:["A arte completa (fundo, textos e fontes) aparece em"," ",s.jsx("span",{className:"font-semibold text-foreground",children:"Prévia do banner"})," ","na página de geração; é essa imagem (PNG) que o compartilhamento usa."]})]}):null]})}const _n=72,ke=140;function Ne(t,e=_n){const r=String(t??"").replace(/\s+/g," ").trim();return r?r.length<=e?r:`${r.slice(0,Math.max(1,e-1)).trimEnd()}…`:"Oferta"}function co(t){const e=String(t.lead??"").trim();return ie({aiHook:e||void 0,useDefaultHook:!e,productTitle:Ne(t.title),currentPrice:t.currentPrice,originalPrice:t.originalPrice,discountPercent:t.discountPercent,convertedUrl:t.affiliateLink.trim(),couponCode:t.couponCode,linkMode:"inline"})}function lo(t){return(String(t||"").split(/\n/).map(r=>r.trim()).find(r=>r.length>0)??"").replace(/^🔥\s*/,"").slice(0,ke)}function uo(t){const e=String(t.hook??"").replace(/\s+/g," ").trim().slice(0,ke);return ie({aiHook:e||Ye,useDefaultHook:!1,productTitle:Ne(t.title),currentPrice:t.currentPrice,originalPrice:t.originalPrice,discountPercent:t.discountPercent,convertedUrl:t.affiliateLink.trim(),couponCode:t.couponCode,linkMode:"inline"})}function ho(t,e){return Ue(t,{productTitle:e.productTitle,currentPrice:e.currentPrice,originalPrice:e.originalPrice,discountPercent:e.discountPercent,affiliateUrl:e.affiliateUrl,platform:e.platform,category:e.category,cta:e.cta,description:e.description,coupon:e.coupon??"",closingPhrase:e.closingPhrase??""})}export{Vn as B,Un as C,io as S,wr as T,so as V,Yn as a,Er as b,ne as c,Zn as d,Xn as e,Qn as f,Wn as g,fr as h,lo as i,to as j,co as k,uo as l,ao as m,ho as n,Gn as o,ro as p,Jn as q,Kn as r,eo as s,Ne as t,oo as u,qn as v,vn as w,kt as x,Nn as y,no as z};

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.