1import{r,j as e,L as se}from"./react-vendor-Cvme-g6x.js";import{c as oe,t as h,S as le,B as d,P as re,Z as ie}from"./index-Dij6-G9-.js";import{M as f,a as P,D as F}from"./marketplaceClosingPhrases-BSVOaX_g.js";import{a as B}from"./scheduleHandoffCopy-BoTnzdyR.js";import{S as V}from"./save-QCo7QYyZ.js";import{C as H}from"./copy-BkDvKeOr.js";import{T as ne}from"./trash-2-DZbsnt_v.js";import"./trpc-vendor-CcQiuHv2.js";import"./recharts-vendor-D3gx481F.js";import"./framer-vendor-vyqLUUua.js";import"./schedulePostCopy-T_RAiZwK.js";import"./parseFlexibleMoney-B6RdYWM1.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 ce=oe("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]]),i={productTitle:"Smart TV 50 Polegadas 4K UHD",currentPrice:"R$ 1.899,90",price:"R$ 1.899,90",originalPrice:"R$ 2.499,90",discountPercent:"24",affiliateUrl:"https://seulinkafiliado.com/produto",platform:"Amazon",category:"Eletrônicos",cta:"Compre agora",coupon:"OFERTASMELI",closingPhrase:`ðï¸ Resgate seus cupons aqui: 7ð https://seulinkafiliado.com/produto`};function K(v){return v.replaceAll("{{productTitle}}",i.productTitle).replaceAll("{{price}}",i.price).replaceAll("{{currentPrice}}",i.currentPrice).replaceAll("{{originalPrice}}",i.originalPrice).replaceAll("{{discountPercent}}",i.discountPercent).replaceAll("{{affiliateUrl}}",i.affiliateUrl).replaceAll("{{platform}}",i.platform).replaceAll("{{category}}",i.category).replaceAll("{{cta}}",i.cta).replaceAll("{{coupon}}",i.coupon).replaceAll("{{closingPhrase}}",i.closingPhrase).replaceAll("{{description}}","ð¥ Uma frase curta e persuasiva gerada pela IA aparecerá aqui!")}function ye(){const v=h.useUtils(),[l,y]=r.useState(""),[C,G]=r.useState(""),[N,b]=r.useState(""),[x,g]=r.useState(""),[L,s]=r.useState(""),[j,S]=r.useState(""),[w,k]=r.useState(""),[A,T]=r.useState({shopee:"",amazon:"",mercadolivre:"",magalu:"",tiktokshop:"",shein:""}),[z,U]=r.useState({shopee:"",amazon:"",mercadolivre:"",magalu:"",tiktokshop:"",shein:""}),[n,R]=r.useState("shopee"),{data:m=[],isLoading:Q}=h.templates.list.useQuery(),c=h.templates.getCopyPreferences.useQuery(void 0,{staleTime:3e4}),E=h.templates.saveCopyPreferences.useMutation({onSuccess:async()=>{s("â Preferências de copy salvas."),await c.refetch()},onError:t=>s(`â ${t.message}`)}),$=h.templates.create.useMutation({onSuccess:async()=>{s("â Modelo de copy criado com sucesso!"),await v.templates.list.invalidate()},onError:t=>s(`â Erro: ${t.message}`)}),D=h.templates.update.useMutation({onSuccess:async()=>{s("â Modelo de copy atualizado com sucesso!"),await v.templates.list.invalidate()},onError:t=>s(`â Erro: ${t.message}`)}),O=h.templates.delete.useMutation({onSuccess:async()=>{s("ðï¸ Modelo excluÃdo."),y(""),await v.templates.list.invalidate()},onError:t=>s(`â Erro: ${t.message}`)}),_=r.useMemo(()=>{const t=C.toLowerCase().trim();return t?m.filter(a=>a.name.toLowerCase().includes(t)||a.content.toLowerCase().includes(t)):m},[m,C]),u=r.useMemo(()=>m.find(t=>t.id===l)??null,[m,l]);r.useEffect(()=>{if(!c.data)return;S(c.data.generalCopyTemplateId!=null?String(c.data.generalCopyTemplateId):""),k(c.data.autopilotCopyTemplateId!=null?String(c.data.autopilotCopyTemplateId):"");const t={shopee:"",amazon:"",mercadolivre:"",magalu:"",tiktokshop:"",shein:""};for(const o of f){const p=c.data.platformCopyTemplateIds?.[o];t[o]=p!=null?String(p):""}T(t);const a={shopee:"",amazon:"",mercadolivre:"",magalu:"",tiktokshop:"",shein:""};for(const o of f)a[o]=c.data.platformClosingPhrases?.[o]??"";U(a)},[c.data]),r.useEffect(()=>{u?(b(u.name),g(u.content)):(b(""),g(""))},[u]);function Y(){y(""),b("Novo modelo de copy"),g(`ð¥ {{productTitle}} 8 9{{description}} 10 11ð° {{currentPrice}} 12ð·ï¸ De: {{originalPrice}} 13ð¥ {{discountPercent}}% OFF 14ð {{affiliateUrl}} 15 16{{closingPhrase}}`),s("")}async function Z(){s("");const t={};for(const o of f){const p=A[o];t[o]=p?Number(p):null}const a={};for(const o of f){const p=z[o].trim();p&&(a[o]=p)}await E.mutateAsync({generalCopyTemplateId:j?Number(j):null,autopilotCopyTemplateId:w?Number(w):null,platformCopyTemplateIds:t,platformClosingPhrases:a})}function M(t){if(!l){s("â ï¸ Selecione um modelo na lista primeiro.");return}t==="general"?S(String(l)):t==="autopilot"?k(String(l)):(T(a=>({...a,[t]:String(l)}
16)),R(t)),s(t==="general"?"Modelo marcado como copy geral â clique em «Salvar preferências».":t==="autopilot"?"Modelo marcado para o Piloto â clique em «Salvar preferências».":`Modelo marcado para ${P[t]} â clique em «Salvar preferências».`)}async function W(){if(s(""),!N.trim()||!x.trim()){s("â ï¸ O nome e o conteúdo são obrigatórios.");return}l?await D.mutateAsync({id:l,name:N.trim(),content:x.trim()}):await $.mutateAsync({name:N.trim(),content:x.trim()})}function J(){u&&(y(""),b(`${u.name} (Cópia)`),g(u.content),s("Cópia criada. Clique em salvar para confirmar."))}async function X(){l&&window.confirm("Tem certeza que deseja excluir este modelo de copy?")&&await O.mutateAsync({id:l})}async function ee(){try{await navigator.clipboard.writeText(K(x)),s("â Preview copiado.")}catch{s("â Não foi possÃvel copiar.")}}function te(t){g(a=>`${a}${a.endsWith(` 17`)||a.length===0?"":` 18`}${t}`)}const I=$.isPending||D.isPending||O.isPending||E.isPending,ae=["{{description}}","{{productTitle}}","{{currentPrice}}","{{originalPrice}}","{{discountPercent}}","{{affiliateUrl}}","{{coupon}}","{{closingPhrase}}","{{platform}}","{{category}}","{{cta}}"];function q(t){const a=[];j===String(t)&&a.push("Geral"),w===String(t)&&a.push("Piloto");for(const o of f)A[o]===String(t)&&a.push(P[o]);return a}return e.jsxs("div",{className:"space-y-4 pb-2 max-md:space-y-3 md:space-y-6",children:[e.jsx("div",{className:"rounded-2xl border border-violet-100 bg-white p-3 shadow-sm sm:rounded-3xl sm:p-5 md:p-6",children:e.jsxs("div",{className:"flex flex-col gap-4 lg:flex-row lg:items-center lg:justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"mb-2 inline-flex items-center gap-2 rounded-full border border-violet-200 bg-violet-50 px-3 py-1 text-xs font-semibold text-violet-700",children:[e.jsx(le,{className:"h-4 w-4"}),"Copy e variáveis"]}),e.jsx("h2",{className:"text-xl font-bold tracking-tight text-slate-900 [overflow-wrap:anywhere] sm:text-2xl",children:"Modelos de postagem"}),e.jsx("p",{className:"mt-1 text-sm text-slate-500 [overflow-wrap:anywhere]",children:"Edite o texto base do copy, com variáveis, e salve para reutilizar nas ofertas."})]}),e.jsxs(d,{onClick:Y,className:"h-11 min-h-[44px] gap-2 touch-manipulation rounded-xl bg-gradient-to-r from-violet-500 via-fuchsia-500 to-purple-700 text-white hover:opacity-95",children:[e.jsx(re,{className:"h-4 w-4"}),"Novo modelo"]})]})}),L?e.jsx("div",{className:"rounded-2xl border border-violet-200 bg-violet-50 px-4 py-3 text-sm font-semibold text-violet-700",children:L}):null,e.jsxs("div",{className:"rounded-2xl border border-violet-100 bg-white p-4 shadow-sm sm:p-5",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-2 sm:flex-row sm:items-start sm:justify-between",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-base font-bold text-slate-900 sm:text-lg",children:"Onde usar cada modelo"}),e.jsx("p",{className:"mt-1 max-w-2xl text-sm text-slate-500",children:"Escolha um modelo salvo ou deixe «Padrão do sistema» (texto automático com preço e link). Pode editar o conteúdo acima e salvar quantos modelos quiser."})]}),e.jsxs(d,{type:"button",onClick:()=>void Z(),disabled:E.isPending,className:"h-11 min-h-[44px] shrink-0 touch-manipulation rounded-xl bg-violet-950 text-white hover:bg-violet-900",children:[e.jsx(V,{className:"mr-2 h-4 w-4"}),"Salvar preferências"]})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"block space-y-2",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-bold text-slate-700",children:[e.jsx(H,{className:"h-4 w-4 text-violet-500"}),"Copy geral (agendamento, vitrine, biblioteca)"]}),e.jsxs("select",{value:j,onChange:t=>S(t.target.value),className:"h-11 w-full min-h-[44px] touch-manipulation rounded-xl border border-violet-100 bg-violet-50/40 px-3 text-sm outline-none focus:border-violet-300 focus:bg-white",children:[e.jsx("option",{value:"",children:"Padrão do sistema"}),m.map(t=>e.jsx("option",{value:String(t.id),children:t.name},t.id))]}),j?null:e.jsx("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded-xl border border-dashed border-slate-200 bg-slate-50 p-3 text-[11px] leading-relaxed text-slate-700",children:B()}),l?e.jsx(d,{type:"button",variant:"outline",size:"sm",className:"h-9 touch-manipulation rounded-lg text-xs",onClick:()=>M("general"),children:"Usar modelo aberto"}):null]}),e.jsxs("label",{className:"block space-y-2",children:[e.jsxs("span",{className:"flex items-center gap-2 text-sm font-bold text-slate-700",children:[e.jsx(ie,{className:"h-4 w-4 text-amber-500"}),"Copy do Piloto automático"]}),e.jsxs("select",{value:w,onChange:t=>k(t.target.value),className:"h-11 w-full min-h-[44px] touch-manipulation rounded-xl border border-violet-100 bg-violet-50/40 px-3 text-sm outline-none focus:border-violet-300 focus:bg-white",children:[e.jsx("option",{value:"",children:"Padrão do sistema"}),m.map(t=>e.jsx("option",{value:String(t.id),children:t.name},t.id))]}),w?null:e.jsx("pre",{className:"max-h-40 overflow-auto whitespace-pre-wrap rounded-xl border border-dashed border-slate-200 bg-slate-50 p-3 text-[11px] leading-relaxed text-slate-700",children:B()}),l?e.jsx(d,{type:"button",variant:"outline",size:"sm",className:"h-9 touch-manipulation rounded-lg text-xs",onClick:()=>M("autopilot"),children:"Usar modelo aberto"}):null,e.jsxs("p",{className:"text-[11px] leading-relaxed text-slate-500",children:["O Piloto usa este texto em cada dis
18paro. Configure também em"," ",e.jsx(se,{to:"/piloto-automatico",className:"font-semibold text-violet-700 underline",children:"Piloto automático"}),"."]})]})]}),e.jsxs("div",{className:"mt-6 space-y-4 border-t border-violet-100 pt-5",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-bold text-slate-900 sm:text-base",children:"Copy por marketplace"}),e.jsxs("p",{className:"mt-1 max-w-2xl text-sm text-slate-500",children:["Escolha um modelo diferente para Shopee, Amazon, Mercado Livre ou Magalu. Se vazio, usa o copy geral. A frase de fechamento preenche"," ",e.jsx("code",{className:"rounded bg-violet-50 px-1 text-xs",children:"{{closingPhrase}}"})," ","no template."]})]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:f.map(t=>e.jsx("button",{type:"button",onClick:()=>R(t),className:["h-11 min-h-[44px] touch-manipulation rounded-xl px-4 text-sm font-bold transition",n===t?"bg-violet-950 text-white shadow-sm":"border border-violet-100 bg-violet-50/50 text-violet-800 hover:bg-violet-100"].join(" "),children:P[t]},t))}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs("label",{className:"block space-y-2 md:col-span-1",children:[e.jsxs("span",{className:"text-sm font-bold text-slate-700",children:["Modelo â ",P[n]]}),e.jsxs("select",{value:A[n],onChange:t=>T(a=>({...a,[n]:t.target.value})),className:"h-11 w-full min-h-[44px] touch-manipulation rounded-xl border border-violet-100 bg-violet-50/40 px-3 text-sm outline-none focus:border-violet-300 focus:bg-white",children:[e.jsx("option",{value:"",children:"Usar copy geral"}),m.map(t=>e.jsx("option",{value:String(t.id),children:t.name},t.id))]}),l?e.jsx(d,{type:"button",variant:"outline",size:"sm",className:"h-9 touch-manipulation rounded-lg text-xs",onClick:()=>M(n),children:"Usar modelo aberto"}):null]}),e.jsxs("label",{className:"block space-y-2 md:col-span-1",children:[e.jsx("span",{className:"text-sm font-bold text-slate-700",children:"Frase de fechamento (opcional)"}),e.jsx("textarea",{value:z[n],onChange:t=>U(a=>({...a,[n]:t.target.value})),rows:3,placeholder:F[n],className:"min-h-[88px] w-full resize-y rounded-xl border border-violet-100 bg-white px-3 py-2 text-sm outline-none focus:border-violet-300"}),e.jsxs("p",{className:"text-[11px] leading-relaxed text-slate-500",children:["Padrão:"," ",F[n].replace("{{affiliateUrl}}","link")]})]})]})]})]}),e.jsxs("div",{className:"grid gap-4 max-md:gap-3 xl:grid-cols-[360px_minmax(0,1fr)] xl:gap-6",children:[e.jsxs("aside",{className:"rounded-2xl border border-violet-100 bg-white p-3 shadow-sm sm:rounded-3xl sm:p-5 md:p-6",children:[e.jsx("div",{className:"mb-4",children:e.jsx("h3",{className:"text-lg font-bold text-slate-900",children:"Modelos salvos"})}),e.jsx("div",{className:"space-y-3",children:e.jsx("input",{value:C,onChange:t=>G(t.target.value),placeholder:"Buscar...",className:"h-11 w-full rounded-2xl border border-violet-100 bg-violet-50/40 px-4 text-sm outline-none focus:bg-white"})}),e.jsx("div",{className:"mt-5 max-h-[500px] space-y-3 overflow-y-auto pr-2",children:Q?e.jsx("p",{className:"text-center text-sm text-slate-400",children:"Carregando..."}):_.length===0?e.jsx("div",{className:"rounded-2xl border border-dashed border-violet-200 p-5 text-center text-sm text-slate-500",children:"Nenhum modelo encontrado."}):_.map(t=>{const a=t.id===l;return e.jsxs("button",{onClick:()=>y(t.id),className:["w-full rounded-2xl border p-3 text-left transition sm:p-4",a?"border-violet-300 bg-violet-50 shadow-sm ring-1 ring-violet-200":"border-violet-100 bg-white hover:bg-violet-50/50"].join(" "),children:[e.jsx("div",{className:"truncate text-sm font-bold text-slate-900",children:t.name}),q(t.id).length>0?e.jsx("div",{className:"mt-1.5 flex flex-wrap gap-1",children:q(t.id).map(o=>e.jsx("span",{className:"rounded-full bg-violet-100 px-2 py-0.5 text-[10px] font-bold uppercase tracking-wide text-violet-800",children:o},o))}):null,e.jsxs("div",{className:"mt-2 text-xs text-slate-400",children:["Atualizado em"," ",new Date(t.updatedAt).toLocaleString("pt-BR")]})]},t.id)})})]}),e.jsxs("section",{className:"space-y-6",children:[e.jsxs("div",{className:"rounded-2xl border border-violet-100 bg-white p-3 shadow-sm sm:rounded-3xl sm:p-5 md:p-6",children:[e.jsxs("div",{className:"mb-4 flex flex-col gap-3 sm:mb-5 lg:flex-row lg:items-center lg:justify-between",children:[e.jsx("div",{className:"min-w-0",children:e.jsx("h3",{className:"text-base font-bold text-slate-900 sm:text-lg",children:"Editor de copy"})}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs(d,{variant:"outline",onClick:J,disabled:!l||I,className:"h-10 touch-manipulation rounded-xl text-xs sm:h-10 sm:text-sm",children:[e.jsx(H,{className:"mr-1.5 h-4 w-4 sm:mr-2"}),"Duplicar"]}),e.jsxs(d,{variant:"outline",onClick:X,disabled:!l||I,className:"h-10 touch-manipulation rounded-xl text-xs text-red-600 hover:text-red-700 sm:text-sm",children:[e.jsx(ne,{className:"mr-1.5 h-4 w-4 sm:mr-2"}),"Excluir"]}),e.jsxs(d,{onClick:W,disabled:I,className:"h-10 min-h-[44px] touch-manipulation rounded-xl bg-violet-950 text-xs text-white hover:bg-violet-900 sm:text-sm",children:[e.jsx(V,{className:"mr-1.5 h-4 w-4 sm:mr-2"}),"Salvar no Banco"]})]})]}),e.jsxs("div",{className:"grid gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-bold text-slate-700",children:"Nome do modelo"}),e.jsx("input",{value:N,onChange:t=>b(t.target.value),placeholder:"Ex.: Oferta Relâmpago",className:"h-11 w-full rounded-2xl border border-violet-100 bg-violet-50/40 px-4 text-sm outline-none focus:border-violet-300 focus:bg-white"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-bold text-slate-700",children:"Conteúdo (copy)"}),e.jsx("textarea",{value:x,onChange:t=>g(t.target.value),className:"min-h-[200px] w-full min-w-0 rounded-2xl border border-violet-100 bg-violet-50/30 p-3 text-sm outline-none focus:border-violet-300 focus:bg-white sm:min-h-[220px] sm:rou
18nded-3xl sm:p-4"})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2 text-sm font-bold text-slate-700",children:[e.jsx(ce,{className:"h-4 w-4 text-violet-500"}),"Variáveis disponÃveis"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5 sm:gap-2",children:ae.map(t=>e.jsx("button",{type:"button",onClick:()=>te(t),className:"min-h-[40px] touch-manipulation rounded-full border border-violet-200 bg-violet-50 px-2.5 py-1.5 text-[10px] font-semibold leading-tight text-violet-700 hover:bg-violet-100 sm:min-h-0 sm:px-3 sm:text-xs",children:t},t))}),e.jsxs("p",{className:"mt-2 text-xs text-slate-500 [overflow-wrap:anywhere]",children:["*A variável ",e.jsx("b",{children:"{{description}}"})," é onde a IA pode injetar uma frase persuasiva. Use ",e.jsx("b",{children:"{{coupon}}"})," para cupom (linha some se estiver vazio)."]})]})]})]}),e.jsxs("div",{className:"rounded-2xl border border-violet-100 bg-white p-3 shadow-sm sm:rounded-3xl sm:p-5 md:p-6",children:[e.jsxs("div",{className:"mb-3 flex min-w-0 items-center justify-between gap-2 sm:mb-4",children:[e.jsx("h3",{className:"min-w-0 text-base font-bold text-slate-900 sm:text-lg",children:"Preview Visual"}),e.jsx(d,{variant:"outline",onClick:ee,className:"h-9 min-h-[36px] shrink-0 touch-manipulation rounded-xl px-3 text-xs sm:h-8",children:"Copiar"})]}),e.jsx("pre",{className:"min-w-0 max-w-full whitespace-pre-wrap break-words [overflow-wrap:anywhere] rounded-xl border border-violet-100 bg-violet-50/30 p-3 text-[13px] leading-relaxed text-slate-700 sm:rounded-2xl sm:p-4 sm:text-sm sm:leading-6",children:x.trim()?K(x):"Digite o copy acima."})]})]})]})]})}export{ye 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.