PageSourceSearch

https://sabhia.ai/assets/canal-DH9VlWNH.js

js sabhia.ai collected 2026-10-05 12:33:17 UTC 73,772 bytes, 54 lines download raw bytes

1import{j as e}from"./vendor-motion-CPxq9Xvn.js";import{r as f}from"./vendor-i18n-CO3kK2bH.js";import{n as he,a4 as R,aJ as T,k as be,a3 as M,ai as U,a1 as ae,az as ye,u as _,a6 as $,a as se,a7 as y,aK as oe,S as G,an as q,aB as Ne,as as W,A as re,C as D,aG as we,U as J,K as ge,X as fe,ak as Ce,f as ke,Q as le,Y as ce,ao as ze,R as Se,$ as Te}from"./index-CFAvyuXu.js";import{V as Ee}from"./videos-shell-Dt9iLSCb.js";import{V as Ae}from"./videoStyles-178hiNMB.js";import{A as Pe}from"./arrow-left-DY50GvQQ.js";import{F as Z}from"./file-up-CUoIUHm5.js";import{S as Y}from"./save-QXxXVhhp.js";import{T as $e}from"./trash-2-BF2rPJAw.js";import{F as K}from"./film-5Ww7nMCK.js";import{Y as ee}from"./youtube-C3-YPqKU.js";import{S as qe}from"./square-play-B4-TDS12.js";import{P as _e}from"./pencil-DB7EhnQs.js";import{W as ie}from"./wand-sparkles-BFRdHggN.js";import{T as de}from"./target-CjPWrUoS.js";import{L as me}from"./list-checks-EUoF5j-U.js";import{C as X}from"./circle-x-DhBMAj3Y.js";import{L as Q}from"./lightbulb-BvSG_Icx.js";import{C as Oe}from"./calendar-clock-yFtimZeY.js";import{F as xe}from"./flame-BHmbROUi.js";import{C as ue}from"./circle-play-BeGABqqs.js";const Re=[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]],Le=he("sliders-horizontal",Re);const Fe=[["path",{d:"m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71",key:"yqzxt4"}],["path",{d:"m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71",key:"4qinb0"}],["line",{x1:"8",x2:"8",y1:"2",y2:"5",key:"1041cp"}],["line",{x1:"2",x2:"5",y1:"8",y2:"8",key:"14m1p5"}],["line",{x1:"16",x2:"16",y1:"19",y2:"22",key:"rzdirn"}],["line",{x1:"19",x2:"22",y1:"16",y2:"16",key:"ox905f"}]],De=he("unlink",Fe);function Me(){return{name:"",niche:"",language:"pt-BR",description:"",contentStyle:"",targetCountry:"",targetAudience:"",toneOfVoice:"",visualStyle:"",videoTypes:"",publishFrequency:"",allowedTopics:"",forbiddenTopics:"",goals:"",referenceChannels:"",editorialRules:""}}const B=t=>t.split(",").map(s=>s.trim()).filter(s=>s.length>0),I=t=>Array.isArray(t)?t.join(", "):"";function Ve(t){return{name:t.name.trim(),niche:t.niche.trim()||null,language:t.language.trim()||"pt-BR",description:t.description.trim()||null,contentStyle:t.contentStyle.trim()||null,targetCountry:t.targetCountry.trim()||null,targetAudience:t.targetAudience.trim()||null,toneOfVoice:t.toneOfVoice.trim()||null,visualStyle:t.visualStyle.trim()||null,videoTypes:B(t.videoTypes),publishFrequency:t.publishFrequency.trim()||null,allowedTopics:B(t.allowedTopics),forbiddenTopics:B(t.forbiddenTopics),goals:t.goals.trim()||null,referenceChannels:B(t.referenceChannels),editorialRules:t.editorialRules.trim()||null}}function Ue(t){const s=t?.brief||{};return{name:t?.name||"",niche:t?.niche||"",language:t?.language||"pt-BR",description:s.description||"",contentStyle:Ie(t?.contentStyle),targetCountry:s.targetCountry||"",targetAudience:s.targetAudience||"",toneOfVoice:s.toneOfVoice||"",visualStyle:s.visualStyle||"",videoTypes:I(s.videoTypes),publishFrequency:s.publishFrequency||"",allowedTopics:I(s.allowedTopics),forbiddenTopics:I(s.forbiddenTopics),goals:s.goals||"",referenceChannels:I(s.referenceChannels),editorialRules:s.editorialRules||""}}const k="bg-white/[0.03] border-white/10 text-zinc-100 placeholder:text-zinc-600 focus-visible:ring-cyan-500/40";function C({label:t,hint:s,children:d}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-300 mb-1.5",children:t}),d,s&&e.jsx("p",{className:"text-xs text-zinc-600 mt-1",children:s})]})}const Be={documentary:"real",emotional_fiction:"story",slideshow:"marina"};function Ie(t){return t?Be[t]??t:""}function Ge({value:t,onChange:s}){return e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-3","data-testid":"content-style-selector",children:Ae.map(d=>{const m=t===d.id;return e.jsxs("button",{type:"button",onClick:()=>s(m?"":d.id),className:`relative flex items-start gap-3 rounded-xl border p-4 text-left transition-all ${m?`ring-1 ${d.accent.activeBorder} ${d.accent.activeRing} ${d.accent.activeBg}
1`:"border-white/[0.06] bg-white/[0.02] hover:border-white/[0.12]"}`,"data-testid":`button-content-style-${d.id}`,children:[e.jsx("span",{className:"text-lg mt-0.5 shrink-0 leading-none select-none",children:d.icon}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("span",{className:`block text-sm font-semibold ${m?d.accent.labelColor:"text-zinc-300"}`,children:[d.label,d.badge&&e.jsx("span",{className:"ml-2 inline-block align-middle rounded-full bg-white/[0.08] px-1.5 py-0.5 text-[9px] font-bold uppercase tracking-wide text-zinc-400",children:d.badge})]}),e.jsx("span",{className:"block text-xs text-zinc-500 mt-0.5 leading-relaxed",children:d.description})]}),m&&e.jsx("span",{className:`absolute top-2 right-2 h-2 w-2 rounded-full ${d.accent.checkBg}`})]},d.id)})})}function Ke(t){return[t.targetCountry,t.publishFrequency,t.targetAudience,t.toneOfVoice,t.visualStyle,t.videoTypes,t.allowedTopics,t.forbiddenTopics,t.goals,t.referenceChannels,t.editorialRules].some(s=>s.trim().length>0)}function Qe({form:t,setForm:s,defaultAdvancedOpen:d=!1}){const[m,c]=f.useState(d),n=x=>o=>s({...t,[x]:o.target.value});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("section",{className:"rounded-2xl border border-white/[0.06] bg-white/[0.02] p-5 md:p-6 space-y-4",children:[e.jsx("h2",{className:"text-sm font-semibold uppercase tracking-[0.14em] text-cyan-400",children:"Identidade"}),e.jsx(C,{label:"Nome do canal *",children:e.jsx(R,{value:t.name,onChange:n("name"),placeholder:"Ex: Mentes Estoicas",className:k,"data-testid":"input-name"})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(C,{label:"Nicho",children:e.jsx(R,{value:t.niche,onChange:n("niche"),placeholder:"Ex: Filosofia, finanças, terror",className:k,"data-testid":"input-niche"})}),e.jsx(C,{label:"Idioma",hint:"Código do idioma da narração (ex: pt-BR, en-US, es-ES)",children:e.jsx(R,{value:t.language,onChange:n("language"),placeholder:"pt-BR",className:k,"data-testid":"input-language"})})]}),e.jsx(C,{label:"Descrição do canal",hint:"Em uma frase, do que é o canal e qual a sua proposta.",children:e.jsx(T,{value:t.description,onChange:n("description"),placeholder:"Ex: Histórias e lições da filosofia estoica para a vida moderna.",className:k,rows:2,"data-testid":"input-description"})}),e.jsx(C,{label:"Estilo de conteúdo",hint:"Define como a IA vai criar os roteiros para este canal.",children:e.jsx(Ge,{value:t.contentStyle,onChange:x=>s({...t,contentStyle:x})})})]}),e.jsxs("button",{type:"button",onClick:()=>c(x=>!x),className:"w-full flex items-center justify-between gap-3 rounded-2xl border border-white/[0.06] bg-white/[0.02] px-5 py-4 text-left hover:border-cyan-500/30 hover:bg-cyan-500/[0.04] transition-colors","data-testid":"button-toggle-advanced","aria-expanded":m,children:[e.jsxs("span",{className:"flex items-center gap-3 min-w-0",children:[e.jsx(Le,{className:"h-4 w-4 text-cyan-400 shrink-0"}),e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block text-sm font-semibold text-zinc-200",children:"Adicionar mais detalhes"}),e.jsx("span",{className:"block text-xs text-zinc-500",children:"Público, tom de voz, temas e estratégia — opcional, deixa os vídeos mais fiéis."})]})]}),e.jsx(be,{className:`h-5 w-5 text-zinc-400 shrink-0 transition-transform ${m?"rotate-180":""}`})]}),m&&e.jsxs("div",{className:"space-y-6","data-testid":"section-advanced",children:[e.jsxs("section",{className:"rounded-2xl border border-white/[0.06] bg-white/[0.02] p-5 md:p-6 space-y-4",children:[e.jsx("h2",{className:"text-sm font-semibold uppercase tracking-[0.14em] text-cyan-400",children:"Público & voz"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsx(C,{label:"País / mercado-alvo",children:e.jsx(R,{value:t.targetCountry,onChange:n("targetCountry"),placeholder:"Ex: Brasil, EUA, global",className:k,"data-testid":"input-target-country"})}),e.jsx(C,{label:"Frequência de publicação",children:e.jsx(R,{value:t.publishFrequency,onChange:n("publishFrequency"),placeholder:"Ex: 3 vídeos por semana",className:k,"data-testid":"input-frequency"})})]}),e.jsx(C,{label:"Público-alvo",hint:"Quem assiste: idade, interesses, momento de vida.",children:e.jsx(T,{value:t.targetAudience,onChange:n("targetAudience"),placeholder:"Ex: Jovens adultos 18-35 interessados em autodesenvolvimento.",className:k,rows:2,"data-testid":"input-target-audience"})}),e.jsx(C,{label:"Tom de voz",children:e.jsx(T,{value:t.toneOfVoice,onChange:n("toneOfVoice"),placeholder:"Ex: Calmo, reflexivo, inspirador, com autoridade.",className:k,rows:2,"data-testid":"input-tone"})}),e.jsx(C,{label:"Estilo visual",children:e.jsx(T,{value:t.visualStyle,onChange:n("visualStyle"),placeholder:"Ex: Cinematográfico, dark, tons dourados, b-roll histórico.",className:k,rows:2,"data-testid":"input-visual-style"})})]}),e.jsxs("section",{className:"rounded-2xl border border-white/[0.06] bg-white/[0.02] p-5 md:p-6 space-y-4",children:[e.jsx("h2",{className:"text-sm font-semibold uppercase tracking-[0.14em] text-cyan-400",children:"Conteúdo"}),e.jsx(C,{label:"Tipos de vídeo",hint:"Separe por vírgulas.",children:e.jsx(R,{value:t.videoTypes,onChange:n("videoTypes"),placeholder:"Ex: Shorts, vídeos longos, documentários",className:k,"data-testid":"input-video-types"})}),e.jsx(C,{label:"Temas permitidos",hint:"Separe por vírgulas.",children:e.jsx(T,{value:t.allowedTopics,onChange:n("allowedTopics"),placeholder:"Ex: Estoicismo, disciplina, história antiga",className:k,rows:2,"data-testid":"input-allowed-topics"})}),e.jsx(C,{label:"Temas proibidos",hint:"Separe por vírgulas. O que o canal NUNCA deve abordar.",children:e.jsx(T,{value:t.forbiddenTopics,onChange:n("forbiddenTopics"),placeholder:"Ex: Política partidária, religião, polêmicas",className:k,rows:2,"data-testid":"input-forbid
1den-topics"})})]}),e.jsxs("section",{className:"rounded-2xl border border-white/[0.06] bg-white/[0.02] p-5 md:p-6 space-y-4",children:[e.jsx("h2",{className:"text-sm font-semibold uppercase tracking-[0.14em] text-cyan-400",children:"Estratégia"}),e.jsx(C,{label:"Objetivos do canal",children:e.jsx(T,{value:t.goals,onChange:n("goals"),placeholder:"Ex: Crescer para 100k inscritos e vender um curso de filosofia aplicada.",className:k,rows:2,"data-testid":"input-goals"})}),e.jsx(C,{label:"Canais de referência",hint:"Separe por vírgulas. Canais que inspiram o estilo.",children:e.jsx(T,{value:t.referenceChannels,onChange:n("referenceChannels"),placeholder:"Ex: Einzelgänger, Pursuit of Wonder",className:k,rows:2,"data-testid":"input-reference-channels"})}),e.jsx(C,{label:"Regras editoriais",hint:"Diretrizes adicionais para a IA seguir sempre.",children:e.jsx(T,{value:t.editorialRules,onChange:n("editorialRules"),placeholder:"Ex: Nunca usar clickbait. Sempre citar fontes históricas. CTA no final.",className:k,rows:3,"data-testid":"input-editorial-rules"})})]})]})]})}function Ye(){const{toast:t}=M(),s=U(),[,d]=ae(),[,m]=ye("/videos/canais/:id"),c=m?.id,[n,x]=f.useState(Me()),[o,v]=f.useState(!1),[b,p]=f.useState(()=>new URLSearchParams(window.location.search).get("imported")==="1"),l=_({queryKey:[`/api/videos/channels/${c}`],enabled:!!c});f.useEffect(()=>{l.data&&(x(Ue(l.data)),v(!0))},[l.data]),f.useEffect(()=>{const h=new URLSearchParams(window.location.search);if(h.get("imported")){h.delete("imported");const i=h.toString();window.history.replaceState({},"",window.location.pathname+(i?`?${i}`:""))}},[]);const r=$({mutationFn:async()=>(await q("PATCH",`/api/videos/channels/${c}`,Ve(n))).json(),onSuccess:()=>{s.invalidateQueries({queryKey:[`/api/videos/channels/${c}`]}),s.invalidateQueries({queryKey:["/api/videos/channels"]}),t({title:"Alterações salvas"})},onError:h=>t({title:"Não foi possível salvar",description:h?.message,variant:"destructive"})}),N=$({mutationFn:async()=>(await q("DELETE",`/api/videos/channels/${c}`,{})).json(),onSuccess:()=>{s.invalidateQueries({queryKey:["/api/videos/channels"]}),t({title:"Canal apagado"}),d("/videos")},onError:h=>t({title:"Não foi possível apagar",description:h?.message,variant:"destructive"})}),S=n.name.trim().length>0,w=f.useRef(null),[A,g]=f.useState(!1);async function z(h){g(!0);try{const i=new FormData;i.append("document",h);const a=await fetch(`/api/videos/channels/${c}/brief/extract-document`,{method:"POST",body:i,credentials:"include"});if(!a.ok){const O=await a.json().catch(()=>({}));throw new Error(O?.message||`Erro ${a.status}`)}const u=await a.json();u?.form&&x(O=>{const V={...O},je=Object.keys(u.form);for(const ne of je){const H=u.form[ne];typeof H=="string"&&H.trim()&&(V[ne]=H)}return V}),u?.bibleSaved&&s.invalidateQueries({queryKey:[`/api/videos/channels/${c}/bible`]}),(u?.scriptwriterSaved||u?.form)&&s.invalidateQueries({queryKey:[`/api/videos/channels/${c}`]});const j=[];u?.form&&j.push("briefing"),u?.bibleSaved&&j.push("bíblia editorial"),u?.scriptwriterSaved&&j.push("roteirista");const P=j.length>0?j.join(", "):"campos";t({title:"Documento importado ✓",description:`Preenchemos: ${P}. Revise e salve as alterações.`})}catch(i){t({title:"Não foi possível importar o documento",description:i?.message,variant:"destructive"})}finally{g(!1),w.current&&(w.current.value="")}}return e.jsx(Ee,{children:e.jsxs("div",{className:"max-w-3xl mx-auto px-4 md:px-6 py-8 pb-28",children:[e.jsx(se,{href:"/videos/canais",children:e.jsxs("button",{className:"flex items-center gap-2 text-sm text-zinc-400 hover:text-zinc-200 mb-6","data-testid":"button-back",children:[e.jsx(Pe,{className:"h-4 w-4"})," Canais"]})}),l.isLoading?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(y,{className:"h-7 w-7 animate-spin text-cyan-400"})}):l.data?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center justify-between gap-3 mb-2",children:e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-gradient-to-br from-blue-500 to-cyan-400 flex items-center justify-center shrink-0",children:e.jsx(oe,{className:"h-5 w-5 text-white"})}),e.jsx("h1",{className:"text-2xl md:text-3xl font-bold tracking-tight truncate","data-testid":"text-channel-title",children:l.data.name})]})}),e.jsx("p",{className:"text-zinc-400 mb-8",children:"Ajuste o briefing editorial do canal. As alterações valem para os próximos vídeos."}),b&&e.jsxs("div",{className:"mb-6 relative overflow-hidden rounded-2xl border border-cyan-500/30 bg-gradient-to-br from-[#10224a]/50 via-[#0c1730]/45 to-[#0a1428]/35 p-5","data-testid":"banner-imported",children:[e.jsx("div",{className:"pointer-events-none absolute -top-12 -right-12 h-4
10 w-40 rounded-full bg-cyan-500/20 blur-3xl"}),e.jsxs("div",{className:"relative flex items-start gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-gradient-to-br from-blue-500 to-cyan-400 flex items-center justify-center shrink-0 shadow-lg shadow-blue-900/40",children:e.jsx(G,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h3",{className:"font-bold text-white",children:"Importamos tudo do seu YouTube 🎬"}),e.jsx("p",{className:"text-sm text-zinc-300 mt-0.5",children:"Preenchemos o que o seu canal já dizia — nome, nicho, idioma e mais. Confira o briefing abaixo e ajuste o que quiser; só você decide."})]}),e.jsx("button",{onClick:()=>p(!1),className:"text-xs text-zinc-400 hover:text-white shrink-0","data-testid":"button-dismiss-imported",children:"Ok"})]})]}),e.jsxs("div",{className:"mb-8 relative overflow-hidden rounded-2xl border border-cyan-500/20 bg-gradient-to-br from-[#071830]/70 via-[#0a1c38]/60 to-[#07121f]/50 p-5","data-testid":"section-import-document",children:[e.jsx("div",{className:"pointer-events-none absolute -top-10 -right-10 h-36 w-36 rounded-full bg-cyan-500/10 blur-3xl"}),e.jsxs("div",{className:"relative flex flex-col sm:flex-row sm:items-center gap-4",children:[e.jsxs("div",{className:"flex items-start gap-3 flex-1 min-w-0",children:[e.jsx("div",{className:"h-10 w-10 rounded-xl bg-gradient-to-br from-cyan-500 to-blue-500 flex items-center justify-center shrink-0 shadow-lg shadow-cyan-900/40",children:e.jsx(Z,{className:"h-5 w-5 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:"font-semibold text-white leading-tight",children:"Importar tudo de um documento"}),e.jsx("p",{className:"text-xs text-zinc-400 mt-0.5 leading-relaxed",children:"Suba um PDF, DOCX ou TXT com as informações do canal e a Sábhia preenche automaticamente o briefing, a bíblia editorial e as instruções do roteirista."})]})]}),e.jsx("button",{type:"button",onClick:()=>w.current?.click(),disabled:A,className:"inline-flex items-center justify-center gap-2 shrink-0 rounded-xl bg-gradient-to-r from-cyan-500 to-blue-500 px-5 py-2.5 text-sm font-semibold text-white shadow-lg shadow-cyan-900/30 hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed","data-testid":"button-import-document",children:A?e.jsxs(e.Fragment,{children:[e.jsx(y,{className:"h-4 w-4 animate-spin"})," Analisando…"]}):e.jsxs(e.Fragment,{children:[e.jsx(Z,{className:"h-4 w-4"})," Importar documento"]})})]}),e.jsx("input",{ref:w,type:"file",accept:".pdf,.docx,.epub,.txt,.md",className:"hidden","data-testid":"input-import-document",onChange:h=>{const i=h.target.files?.[0];i&&z(i)}})]}),e.jsx(We,{channelId:c}),e.jsx(He,{channelId:c}),e.jsx(et,{channelId:c}),e.jsx(Xe,{channelId:c}),e.jsx(at,{channelId:c}),e.jsx(Qe,{form:n,setForm:x,defaultAdvancedOpen:Ke(n)},o?"hydrated":"empty"),e.jsxs("div",{className:"mt-8 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[e.jsxs("button",{onClick:()=>r.mutate(),disabled:!S||r.isPending,className:"inline-flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-blue-500 to-cyan-400 px-5 py-3 font-semibold text-white shadow-lg shadow-blue-900/40 hover:opacity-95 disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"button-save-channel",children:[r.isPending?e.jsx(y,{className:"h-5 w-5 animate-spin"}):e.jsx(Y,{className:"h-5 w-5"}),"Salvar alterações"]}),e.jsxs("button",{onClick:()=>{window.confirm("Apagar este canal e seu briefing? Esta ação não pode ser desfeita.")&&N.mutate()},disabled:N.isPending,className:"inline-flex items-center justify-center gap-2 rounded-xl border border-white/10 px-4 py-3 text-sm text-zinc-400 hover:text-red-400 hover:border-red-500/30 transition-colors disabled:opacity-50","data-testid":"button-delete-channel",children:[N.isPending?e.jsx(y,{className:"h-4 w-4 animate-spin"}):e.jsx($e,{className:"h-4 w-4"}),"Apagar canal"]})]})]}):e.jsxs("div",{className:"text-center py-20 text-zinc-500","data-testid":"text-not-found",children:[e.jsx(oe,{className:"h-10 w-10 mx-auto mb-3 text-zinc-700"}),"Canal não encontrado."]})]})})}const ve={not_configured:"A conexão com o YouTube ainda não foi configurada n
1a plataforma. Avise o administrador.",base_url:"Não foi possível determinar o endereço de retorno. Tente novamente em instantes.",session:"Sua sessão expirou. Entre novamente e tente conectar.",access:"Você não tem acesso à Sábhia Vídeos.",access_denied:"Você cancelou a autorização no Google.",denied:"Você cancelou a autorização no Google.",missing_params:"A sessão de conexão expirou. Tente conectar de novo.",bad_state:"A sessão de conexão expirou ou é inválida. Tente conectar de novo.",uid_mismatch:"A sessão de conexão não confere. Tente conectar de novo.",bad_nonce:"A sessão de conexão expirou. Tente conectar de novo.",exchange:"O Google recusou a autorização. Tente novamente.",redirect_uri_mismatch:"O Google bloqueou porque o endereço de retorno não está cadastrado. Veja o passo a passo de configuração abaixo.",insufficient_scope:"Para conectar, marque TODAS as permissões (enviar vídeos + ver o canal) na tela do Google.",no_refresh_token:"O Google não liberou o acesso permanente. Remova o app em myaccount.google.com/permissions e conecte de novo.",channel_fetch:"Não conseguimos ler os dados do seu canal no YouTube. Tente novamente.",no_channel:"Não encontramos um canal do YouTube nessa conta Google. Crie um canal e tente de novo.",account_in_use:"Esse canal do YouTube já está conectado a outro canal seu aqui no Sábhia.",max_channels:"Você atingiu o limite de canais. Apague um canal existente para conectar outro.",channel:"Canal não encontrado.",unexpected:"Algo deu errado ao conectar. Tente novamente."};function pe(t){return t==null?"—":Number(t).toLocaleString("pt-BR")}function He({channelId:t}){const{toast:s}=M(),d=U(),m=[`/api/videos/channels/${t}/youtube/status`],c=_({queryKey:m,enabled:!!t}),n=_({queryKey:["/api/videos/youtube/config"]}),x=$({mutationFn:async()=>(await q("DELETE",`/api/videos/channels/${t}/youtube`,{})).json(),onSuccess:()=>{d.invalidateQueries({queryKey:m}),s({title:"Canal do YouTube desconectado"})},onError:l=>s({title:"Não foi possível desconectar",description:l?.message,variant:"destructive"})});f.useEffect(()=>{const l=new URLSearchParams(window.location.search),r=l.get("yt"),N=l.get("yt_error");
1if(r==="connected"?(s({title:"YouTube conectado! 🎬",description:"Seu canal está pronto para receber publicações."}),d.invalidateQueries({queryKey:m})):N&&s({title:"Não foi possível conectar o YouTube",description:ve[N]||"Tente novamente.",variant:"destructive"}),r||N){l.delete("yt"),l.delete("yt_error");const S=l.toString();window.history.replaceState({},"",window.location.pathname+(S?`?${S}`:""))}},[]);const o=c.data,v=n.data?.available!==!1,b=!!o?.connected,p=()=>{window.location.href=`/api/videos/channels/${t}/youtube/connect`};return e.jsxs("div",{className:"mb-8 rounded-2xl border border-white/10 bg-gradient-to-br from-zinc-900/80 to-zinc-900/40 overflow-hidden","data-testid":"card-youtube-connection",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 pt-5 pb-4 border-b border-white/5",children:[e.jsx("div",{className:"h-11 w-11 rounded-xl bg-gradient-to-br from-red-500 to-red-600 flex items-center justify-center shrink-0 shadow-lg shadow-red-900/30",children:e.jsx(ee,{className:"h-6 w-6 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-lg font-bold text-white leading-tight",children:"Publicar no YouTube"}),e.jsx("p",{className:"text-sm text-zinc-400",children:"Conecte o seu canal para a Sábhia publicar nele automaticamente."})]})]}),e.jsx("div",{className:"p-5",children:c.isLoading?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-zinc-500 py-3","data-testid":"status-youtube-loading",children:[e.jsx(y,{className:"h-4 w-4 animate-spin text-cyan-400"})," Verificando conexão…"]}):b?e.jsxs("div",{"data-testid":"state-youtube-connected",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[o.thumbnail?e.jsx("img",{src:o.thumbnail,alt:o.title,className:"h-16 w-16 rounded-full object-cover ring-2 ring-cyan-400/40 shrink-0","data-testid":"img-youtube-avatar",referrerPolicy:"no-referrer"}):e.jsx("div",{className:"h-16 w-16 rounded-full bg-zinc-800 flex items-center justify-center shrink-0",children:e.jsx(ee,{className:"h-7 w-7 text-zinc-500"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-semibold text-white truncate","data-testid":"text-youtube-title",children:o.title}),e.jsx(D,{className:"h-4 w-4 text-emerald-400 shrink-0"})]}),o.customUrl&&e.jsxs("a",{href:`https://www.youtube.com/${o.customUrl}`,target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1 text-xs text-zinc-400 hover:text-cyan-300","data-testid":"link-youtube-channel",children:[o.customUrl," ",e.jsx(we,{className:"h-3 w-3"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-1 mt-2 text-xs text-zinc-400",children:[e.jsxs("span",{className:"inline-flex items-center gap-1","data-testid":"text-youtube-subs",children:[e.jsx(J,{className:"h-3.5 w-3.5 text-cyan-400"})," ",pe(o.subscriberCount)," inscritos"]}),e.jsxs("span",{className:"inline-flex items-center gap-1","data-testid":"text-youtube-videos",children:[e.jsx(qe,{className:"h-3.5 w-3.5 text-cyan-400"})," ",pe(o.videoCount)," vídeos"]})]})]})]}),e.jsxs("div",{className:"mt-4 flex items-center gap-2 rounded-xl bg-emerald-500/[0.07] border border-emerald-500/20 px-3 py-2.5",children:[e.jsx(ge,{className:"h-4 w-4 text-emerald-400 shrink-0"}),e.jsx("span",{className:"text-xs text-emerald-200/90",children:"Conexão ativa. A Sábhia pode enviar vídeos para este canal com a sua permissão."})]}),e.jsxs("div",{className:"mt-4 flex items-center justify-between gap-3",children:[e.jsx("span",{className:"text-xs text-zinc-600","data-testid":"text-youtube-connected-at",children:o.connectedAt?`Conectado em ${new Date(o.connectedAt).toLocaleDateString("pt-BR")}`:""}),e.jsxs("button",{onClick:()=>{window.confirm("Desconectar este canal do YouTube? A Sábhia deixará de publicar nele.")&&x.mutate()},disabled:x.isPending,className:"inline-flex items-center gap-2 rounded-xl border border-white/10 px-3 py-2 text-sm text-zinc-400 hover:text-red-400 hover:border-red-500/30 transition-colors disabled:opacity-50","data-testid":"button-youtube-disconnect",children:[x.isPending?e.jsx(y,{className:"h-4 w-4 animate-spin"}):e.jsx(De,{className:"h-4 w-4"}),"Desconectar"]})]})]}):v?e.jsxs("div",{"data-testid":"state-youtube-disconnected",children:[e.jsx("ul",{className:"space-y-2 mb-5",children:["Use o SEU próprio canal — você continua dono de tudo.","Os vídeos gerados são enviados direto para o YouTube.","Você pode desconectar quando quiser, com um clique."].map((l,r)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-zinc-300",children:[e.jsx(D,{className:"h-4 w-4 text-cyan-400 shrink-0 mt-0.5"})," ",l]},r))}),e.jsxs("button",{onClick:p,className:"inline-flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-blue-500 to-cyan-400 px-5 py-3 font-semibold text-white shadow-lg shadow-blue-900/40 hover:opacity-95","data-testid":"button-youtube-connect",children:[e.jsx(Ce,{className:"h-5 w-5"})," Conectar canal do YouTube"]}),e.jsx("p",{className:"mt-3 text-xs text-zinc-500",children:"Você será levado ao Google para autorizar com segurança. A Sábhia nunca vê a sua senha."}),e.jsxs("p",{className:"mt-2 text-[11px] leading-relaxed text-zinc-500","data-testid":"text-connect-legal",children:["Ao conectar, você concorda com os"," ",e.jsx("a",{href:"https://www.youtube.com/t/terms",target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300 underline underline-offset-2","data-testid":"link-canal-yt-tos",children:"Termos do YouTube"})," ","e a"," ",e.jsx("a",{href:"https://policies.google.com/privacy",target:"_blank",rel:"noopener noreferrer",className:"text-cyan-400 hover:text-cyan-300 underline underline-offset-2","data-testid":"link-canal-google-privacy",children:"Política de Privacidade do Google"}),". Veja como tratamos seus dados na nossa"," ",e.jsx(se,{href:"/privacidade",className:"text-cyan-400 hover:text-cyan-300 underline underline-offset-2","data-testid":"link-canal-sabhia-privacy",children:"Política de Privacidade"}),"."]})]}):e.jsxs("div",{className:"flex items-start gap-3 rounded-xl bg-amber-500/[0.07] border border-amber-500/20 px-4 py-3","data-testid":"state-youtube-unavailable",children:[e.jsx(fe,{className:"h-5 w-5 text-amber-400 shrink-0 mt-0.5"}),e.jsx("span",{className:"text-sm text-amber-100/90",children:"A conexão com o YouTube ainda não foi habilitada nesta plataforma. Fale com o administrador para configurar as credenciais do Google."})]})})]})}const E={draft:{label:"Rascunho",cls:"bg-zinc-600/20 text-zinc-300 border-zinc-600/30",tab:"rascunho"},script_generating:{label:"Gerando roteiro…",cls:"bg-blue-500/15 text-blue-300 border-blue-500/25",busy:!0,tab:"producao"},script_ready:{label:"Roteiro pronto",cls:"bg-sky-500/15 text-sky-300 border-sky-500/25",tab:"producao"},awaiting_script_approval:{label:"Revisar roteiro",cls:"bg-cyan-500/15 text-cyan-200 border-cyan-500/30",tab:"producao"},assets_generating:{label:"Gerando imagens…",cls:"bg-blue-500/15 text-blue-300 border-blue-500/25",busy:!0,tab:"producao"},assets_ready:{label:"Imagens prontas",cls:"bg-sky-500/15 text-sky-300 border-sky-500/25",tab:"producao"},narration_generating:{label:"Gerando narração…",cls:"bg-blue-500/15 text-blue-300 border-blue-500/25",busy:!0,tab:"producao"},ready_for_review:{label:"Pronto para publicar",cls:"bg-cyan-500/15 text-cyan-300 border-cyan-500/25",tab:"pronto"},rendering:{label:"Renderizando…",cls:"bg-blue-500/15 text-blue-300 border-blue-500/25",busy:!0,tab:"producao"},uploading:{label:"Enviando…",cls:"bg-blue-500/15 text-blue-300 border-blue-500/25",busy:!0,tab:"producao"},scheduled:{label:"Agendado",cls:"bg-violet-500/15 text-violet-300 border-violet-500/25",tab:"pronto"},completed:{label:"Pronto para publicar",cls:"bg-emerald-500/15 text-emerald-300 border-emerald-500/25",tab:"pronto"},published:{label:"Publicado",cls:"bg-red-500/15 text-red-200 border-red-500/25",tab:"publicado"},failed:{label:"Falhou",cls:"bg-red-500/15 text-red-300 border-red-500/25",tab:"falhou"}};function Xe({channelId:t}){const{toast:s}=M(),d=U(),m=[`/api/videos/channels/${t}`],c=_({queryKey:m,enabled:!!t}),[n,x]=f.useState(""),[o,v]=f.useState(!1);f.useEffect(()=>
1{c.data&&!o&&(x(c.data.scriptwriterInstructions||""),v(!0))},[c.data,o]);const b=`Tom e estilo: educativo e apaixonante, sem ser melodramático
2Público-alvo: [descreva quem assiste — ex: adultos de 30-55 anos interessados em história]
3
4Regras de escrita:
5- NUNCA mencionar [tema proibido]
6- Sempre começar com um fato surpreendente ou pergunta retórica
7- Usar exemplos concretos e detalhes específicos (datas, nomes, números reais)
8- Terminar com reflexão ou chamada à ação emocional
9
10Temas prioritários: [ex: história brasileira, ciência, tecnologia, comportamento humano]
11Temas proibidos: [ex: política, religião polêmica, violência explícita]
12
13Formato de hook preferido: pergunta retórica → fato chocante → contexto em 10 segundos
14Estrutura favorita: Problema → Contexto histórico → Clímax → Lição ou revelação`,p=$({mutationFn:async()=>(await q("PATCH",`/api/videos/channels/${t}`,{scriptwriterInstructions:n.trim()||null})).json(),onSuccess:()=>{d.invalidateQueries({queryKey:m}),s({title:"Treinamento salvo",description:"O roteirista seguirá suas instruções nos próximos roteiros."})},onError:r=>s({title:"Não foi possível salvar",description:r?.message,variant:"destructive"})}),l=n.trim().length>0;return e.jsxs("div",{className:"mb-8 rounded-2xl border border-violet-500/20 bg-gradient-to-br from-violet-900/[0.15] via-zinc-900/40 to-[#0a1c38]/30 overflow-hidden","data-testid":"section-scriptwriter-training",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 pt-5 pb-4 border-b border-white/5",children:[e.jsx("div",{className:"h-11 w-11 rounded-xl bg-gradient-to-br from-violet-500 to-cyan-400 flex items-center justify-center shrink-0 shadow-lg shadow-violet-900/40",children:e.jsx(ie,{className:"h-6 w-6 text-white"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-lg font-bold text-white leading-tight",children:"Treinamento do Roteirista"}),l&&e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full bg-cyan-500/20 border border-cyan-400/30 px-2 py-0.5 text-[11px] font-medium text-cyan-300",children:[e.jsx(D,{className:"h-3 w-3"}),"Ativo"]})]}),e.jsx("p",{className:"text-sm text-zinc-400",children:"Defina como a IA escreve os roteiros deste canal — tom, regras, temas e estilo únicos."})]})]}),e.jsxs("div",{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx("textarea",{value:n,onChange:r=>x(r.target.value.slice(0,3e4)),rows:8,placeholder:`Instrua o roteirista de IA. Exemplo:
15
16Tom: educativo e apaixonante, sem ser melodramático
17Regras: nunca mencionar política; sempre começar com fato chocante
18Temas prioritários: história brasileira, ciência, comportamento humano
19Formato de hook: pergunta retórica → fato surpreendente → contexto rápido`,className:"w-full resize-none rounded-xl bg-white/[0.03] border border-white/10 px-4 py-3 text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none focus:ring-2 focus:ring-violet-500/40 leading-relaxed","data-testid":"textarea-scriptwriter-instructions"}),e.jsxs("span",{className:"absolute bottom-3 right-3 text-[11px] text-zinc-600 select-none",children:[n.length,"/30000"]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-3 flex-wrap",children:[e.jsxs("button",{type:"button",onClick:()=>x(b),className:"inline-flex items-center gap-1.5 rounded-lg border border-violet-400/20 bg-violet-500/[0.06] px-3 py-1.5 text-xs font-medium text-violet-300 hover:bg-violet-500/[0.12] hover:text-violet-200 transition-colors","data-testid":"button-use-scriptwriter-template",children:[e.jsx(Q,{className:"h-3.5 w-3.5"}),"Usar template de exemplo"]}),e.jsxs("button",{onClick:()=>p.mutate(),disabled:p.isPending,className:"inline-flex items-center gap-2 rounded-xl bg-gradient-to-r from-violet-600 to-cyan-500 px-5 py-2.5 text-sm font-semibold text-white shadow-lg shadow-violet-900/30 hover:opacity-90 disabled:opacity-50 disabled:cursor-not-allowed transition-opacity","data-testid":"button-save-scriptwriter-training",children:[p.isPending?e.jsx(y,{className:"h-4 w-4 animate-spin"}):e.jsx(Y,{className:"h-4 w-4"}),"Salvar treinamento"]})]})]})]})}function We({channelId:t}){const{toast:s}=M(),[,d]=ae(),[m,c]=f.useState(""),n=f.useRef(null),[x,o]=f.useState(!1),v=[`/api/videos/channels/${t}/projects`],b=_({queryKey:["/api/videos/access"]}),p=b.data?.topicMaxChars??2e4,l=b.data?.uploadEnabled??!1;async function r(a){const u=a.target.files?.[0];if(a.target.value="",!!u){o(!0);try{const j=new FormData;j.append("file",u);const P=await fetch("/api/videos/topic-extract",{method:"POST",body:j,credentials:"include"}),O=await P.json().catch(()=>null);if(!P.ok)throw new Error(O?.message||"Não foi possível ler o documento.");const V=String(O?.text||"").slice(0,p);if(!V)throw new Error("Não encontramos texto no arquivo.");c(V),s({title:"Documento carregado",description:O?.truncated?`Texto longo — usamos os primeiros ${p.toLocaleString("pt-BR")} caracteres. Edite à vontade antes de gerar.`:"Texto extraído. Revise e ajuste antes de gerar o roteiro."})}catch(j){s({title:"Não foi possível ler o documento",description:j?.message||"Tente outro arquivo (PDF, DOCX ou EPUB).",variant:"destructive"})}finally{o(!1)}}}const N=_({queryKey:v,enabled:!!t,refetchInterval:a=>(a.state.data?.projects||[]).some(P=>E[P.status]?.busy)?5e3:!1}),S=()=>{const a=new URLSearchParams({channelId:t}),u=m.trim();u&&a.set("topic",u),d(`/videos/novo?${a.toString()}`)},w=N.data?.projects||[],A=!x,[g,z]=f.useState("todos"),h=[{id:"todos",label:"Todos",count:w.length},{id:"publicado",label:"Publicados",count:w.filter(a=>(E[a.status]?.tab||"rascunho")==="publicado").length},{id:"pronto",label:"Prontos para publicar",count:w.filter(a=>(E[a.status]?.tab||"rascunho")==="pronto").length},{id:"producao",label:"Em produção",count:w.filter(a=>(E[a.status]?.tab||"rascunho")==="producao").length},{id:"rascunho",label:"Rascunhos",count:w.filter(a=>(E[a.status]?.tab||"rascunho")==="rascunho").length},{id:"falhou",label:"Falhou",count:w.filter(a=>(E[a.status]?.tab||"rascunho")==="falhou").length}].filter(a=>a.id==="todos"||(a.count??0)>0),i=g==="todos"?w:w.filter(a=>(E[a.status]?.tab||"rascunho")===g);return e.jsxs("div",{className:"mb-8 rounded-2xl border border-white/10 bg-gradient-to-br from-[#0f1f3d]/40 via-zinc-900/40 to-[#0a1c38]/30 overflow-hidden","data-testid":"section-video-projects",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 px-5 pt-5 pb-4 border-b border-white/5",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[e.jsx("div",{className:"h-11 w-11 rounded-xl bg-gradient-to-br from-blue-500 to-cyan-400 flex items-center justify-center shrink-0 shadow-lg shadow-blue-900/40",children:e.jsx(Ne,{className:"h-6 w-6 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-lg font-bold text-white leading-tight",children:"Estúdio de vídeos"}),e.jsx("p",{className:"text-sm text-zinc-400",children:"Descreva um tema e a Sábhia monta o vídeo — roteiro, imagens, narração e MP4."})]})]}),e.jsxs("button",{onClick:S,disabled:!A,className:"inline-flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-blue-500 to-cyan-400 px-4 py-2.5 text-sm font-semibold text-white shadow-lg shadow-blue-900/40 hover:opacity-95 disabled:opacity-40 disabled:cursor-not-allowed shrink-0","data-testid":"button-create-video-header",children:[e.jsx(W,{className:"h-4 w-4"})," Novo vídeo"]})]}),e.jsxs("div",{className:"p-5",children:[l&&e.jsxs("div",{className:"mb-2.5 flex items-center justify-end",children:[e.jsx("input",{ref:n,type:"file",accept:".pdf,.docx,.epub,application/pdf,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/epub+zip",className:"hidden",onChange:r,"data-testid":"input-topic-file"}),e.jsxs("button",{type:"button",onClick:()=>n.current?.click(),disabled:x,className:"inline-flex items-center gap-1.5 rounded-lg border border-cyan-500/30 bg-cyan-500/[0.06] px-3 py-1.5 text-xs font-medium text-cyan-200 hover:bg-cyan-500/[0.12] disabled:opacity-50 disabled:cursor-not-allowed transition-colors","data-testid":"button-upload-document",children:[x?e.jsx(y,{className:"h-3.5 w-3.5 animate-spin"}):e.jsx(Z,{className:"h-3.5 w-3.5"}),x?"Lendo documento…":"Enviar documento"]})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2.5 mb-6",children:[e.jsx("input",{value:m,onChange:a=>c(a.target.value.slice(0,p)),onKeyDown:a=>{a.key==="Enter"&&A&&S()},maxLength:p,placeholder:"Ex: 3 hábitos estoicos para manter a calma sob pressão",className:"flex-1 min-w-0 rounded-xl bg-white/[0.03] border border-white/10 px-4 py-3 text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none focus:ring-2 focus:ring-cyan-500/40","data-testid":"input-video-topic"}),e.jsxs("button",{onClick:S,disabled:!A,className:"inline-flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-blue-500 to-cyan-400 px-5 py-3 font-semibold text-white shadow-lg shadow-blue-900/40 hover:opacity-95 disabled:opacity-40 disabled:cursor-not-allowed shrink-0","data-testid":"button-create-video",children:[x?e.jsx(y,{className:"h-5 w-5 animate-spin"}):e.jsx(re,{className:"h-5 w-5"}),"Criar vídeo"]})]}),w.length>0&&e.jsx("div",{className:"flex items-center gap-1.5 flex-wrap mb-5",children:h.map(a=>e.jsxs("button",{onClick:()=>z(a.id),className:`inline-flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium transition-colors ${g===a.id?"bg-cyan-500/20 text-cyan-200 border border-cyan-500/30":"bg-white/[0.03] text-zinc-400 border border-white/[0.06] hover:border-white/10 hover:text-zinc-200"}`,"data-testid":`tab-status-${a.id}`,children:[a.label,(a.count??0)>0&&e.jsx("span",{className:`inline-block min-w-[18px] text-center rounded-full px-1 text-[10px] ${g===a.id?"bg-cyan-500/30 text-cyan-100":"bg-white/[0.07] text-zinc-500"}`,children:a.count})]},a.id))}),N.isLoading?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(y,{className:"h-6 w-6 animate-spin text-cyan-400"})}):w.length===0?e.jsxs("div",{className:"text-center py-8 text-sm text-zinc-500","data-testid":"empty-video-projects",children:[e.jsx(K,{className:"h-8 w-8 mx-auto mb-2 text-zinc-700"}),"Nenhum vídeo ainda. Crie o primeiro acima."]}):i.length===0?e.jsxs("div",{className:"text-center py-6 text-sm text-zinc-500","data-testid":"empty-tab-projects",children:[e.jsx(K,{className:"h-7 w-7 mx-auto mb-2 text-zinc-700"}),"Nenhum vídeo nesta categoria."]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:i.map(a=>{const u=E[a.status]||E.draft;return e.jsx(se,{href:`/videos/projetos/${a.id}`,children:e.jsxs("div",{className:"group cursor-pointer rounded-xl border border-white/[0.07] bg-white/[0.02] hover:border-cyan-500/30 hover:bg-white/[0.04] transition-all overflow-hidden","data-testid":`card-project-${a.id}`,children:[e.jsxs("div",{className:"relative aspect-video bg-gradient-to-br from-[#0d1c36] to-[#060a14] overflow-hidden",children:[a.thumbnailUrl?e.jsx("img",{src:a.thumbnailUrl,alt:a.title,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-[1.03]","data-testid":`img-project-thumb-${a.id}`}):e.jsx("div",{className:"flex items-center justify-center h-full",children:e.jsx(K,{className:"h-10 w-10 text-zinc-700"})}),e.jsx("div",{className:"absolute top-2 left-2",children:e.jsxs("span",{className:`text-[11px] px-2 py-0.5 rounded-full border backdrop-blur-sm inline-flex items-center gap-1 ${u.cls}`,children:[u.busy&&e.jsx(y,{className:"h-3 w-3 animate-spin"}),u.label]})}),a.thumbnailUrl&&e.jsx("div",{className:"absolute inset-0 flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity",children:e.jsx("div",{className:"h-10 w-10 rounded-full bg-black/60 backdrop-blur-sm flex items-center justify-center",children:e.jsx(re,{className:"h-5 w-5 text-white"})})})]}),e.jsxs("div",{className:"px-3 py-2.5",children:[e.jsx("p",{className:"font-medium text-sm text-zinc-200 group-hover:text-white line-clamp-2 leading-snug","data-testid":`text-project-title-${a.id}`,children:a.title}),a.updatedAt&&e.jsx("p",{className:"text-[11px] text-zinc-600 mt-1",children:new Date(a.updatedAt).toLocaleDateString("pt-BR",{day:"2-digit",month:"short"})})]})]})},a.id)})})]})]})}function Je(t){const s=[];
19s.push(`TEMA DO VÍDEO: ${t.title}`),t.summary&&s.push(`
20
21RESUMO: ${t.summary}`),t.metadata?.angle&&s.push(`
22
23ÂNGULO DIFERENCIAL: ${t.metadata.angle}`),t.metadata?.narrative_arc&&s.push(`
24
25ARCO NARRATIVO:
26${t.metadata.narrative_arc}`),t.metadata?.hook&&s.push(`
27
28GANCHO DE ABERTURA (primeiros 3 segundos): ${t.metadata.hook}`),t.metadata?.opening_script&&s.push(`
29
30ABERTURA EXATA (primeiros 20 segundos — use como base):
31"${t.metadata.opening_script}"`);const d=t.metadata?.retention_beats;return d&&d.length>0&&s.push(`
32
33MOMENTOS DE RETENÇÃO (mantenha o espectador assistindo):
34${d.map((m,c)=>`${c+1}. ${m}`).join(`
35`)}`),t.metadata?.ai_disclosure&&s.push(`
36
37DIVULGAÇÃO IA (inserir naturalmente no meio do vídeo):
38"${t.metadata.ai_disclosure}"`),t.metadata?.why_viral&&s.push(`
39
40POTENCIAL VIRAL: ${t.metadata.why_viral}`),s.join("")}function Ze({idea:t,channelId:s}){const[,d]=ae(),[m,c]=f.useState(!1),n=!!(t.metadata?.narrative_arc||(t.metadata?.retention_beats?.length??0)>0||t.metadata?.opening_script||t.metadata?.ai_disclosure);function x(){const o=Je(t),v=new URLSearchParams({channelId:s});v.set("topic",o),d(`/videos/novo?${v.toString()}`)}return e.jsxs("div",{className:"rounded-xl border border-white/[0.08] bg-white/[0.02] overflow-hidden transition-colors hover:border-cyan-500/20","data-testid":`card-idea-${t.id}`,children:[e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("div",{className:"flex items-start gap-2.5",children:[e.jsx(Q,{className:"h-4 w-4 text-amber-300 shrink-0 mt-0.5"}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"font-semibold text-zinc-100 leading-snug","data-testid":`text-idea-title-${t.id}`,children:t.title}),t.summary&&e.jsx("p",{className:"text-sm text-zinc-400 mt-1 leading-relaxed",children:t.summary}),e.jsxs("div",{className:"flex flex-wrap items-start gap-1.5 mt-2",children:[t.metadata?.pillar&&e.jsx(te,{children:t.metadata.pillar}),t.metadata?.why_viral&&e.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-amber-400/80 bg-amber-400/[0.07] border border-amber-400/20 rounded-full px-2 py-0.5",children:[e.jsx(xe,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"line-clamp-1",children:t.metadata.why_viral})]})]}),t.metadata?.hook&&e.jsxs("p",{className:"text-xs text-zinc-500 italic mt-2 leading-relaxed",children:['"',t.metadata.hook,'"']})]})]}),e.jsxs("div",{className:"flex items-center justify-between gap-2 mt-3 pt-2.5 border-t border-white/[0.05]",children:[n?e.jsxs("button",{onClick:()=>c(o=>!o),className:"inline-flex items-center gap-1.5 text-xs text-zinc-500 hover:text-cyan-300 transition-colors","data-testid":`button-idea-expand-${t.id}`,children:[m?e.jsx(Te,{className:"h-3.5 w-3.5"}):e.jsx(be,{className:"h-3.5 w-3.5"}),m?"Esconder narrativa":"Ver narrativa completa"]}):e.jsx("div",{}),e.jsxs("button",{onClick:x,className:"inline-flex items-center gap-1.5 rounded-lg bg-gradient-to-r from-blue-500 to-cyan-400 px-3.5 py-1.5 text-xs font-semibold text-white shadow-md shadow-blue-900/30 hover:opacity-90 transition-opacity shrink-0","data-testid":`button-idea-generate-${t.id}`,children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),"Gerar vídeo"]})]})]}),m&&n&&e.jsxs("div",{className:"border-t border-white/[0.05] bg-gradient-to-b from-white/[0.015] to-transparent px-4 pb-4 pt-3 space-y-3.5",children:[t.metadata?.narrative_arc&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold text-cyan-300 uppercase tracking-widest mb-1.5",children:[e.jsx(K,{className:"h-3 w-3"})," Arco narrativo"]}),e.jsx("p",{className:"text-xs text-zinc-300 leading-relaxed",children:t.metadata.narrative_arc})]}),(t.metadata?.retention_beats?.length??0)>0&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold text-cyan-300 uppercase tracking-widest mb-1.5",children:[e.jsx(xe,{className:"h-3 w-3"})," Momentos de retenção"]}),e.jsx("ul",{className:"space-y-1.5",children:t.metadata.retention_beats.map((o,v)=>e.jsxs("li",{className:"flex items-start gap-2 text-xs text-zinc-300 leading-relaxed",children:[e.jsx("span",{className:"shrink-0 h-4 w-4 roun
40ded-full bg-cyan-500/15 border border-cyan-500/30 flex items-center justify-center text-[10px] font-bold text-cyan-300 mt-0.5",children:v+1}),o]},v))})]}),t.metadata?.opening_script&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold text-cyan-300 uppercase tracking-widest mb-1.5",children:[e.jsx(ue,{className:"h-3 w-3"})," Abertura (20 segundos)"]}),e.jsxs("p",{className:"text-xs text-zinc-400 italic leading-relaxed bg-white/[0.03] rounded-lg px-3 py-2 border border-white/[0.05]",children:['"',t.metadata.opening_script,'"']})]}),t.metadata?.ai_disclosure&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold text-amber-300/80 uppercase tracking-widest mb-1.5",children:[e.jsx(ge,{className:"h-3 w-3"})," Divulgação IA (mid-vídeo)"]}),e.jsxs("p",{className:"text-xs text-zinc-400 italic leading-relaxed bg-amber-400/[0.04] rounded-lg px-3 py-2 border border-amber-400/[0.12]",children:['"',t.metadata.ai_disclosure,'"']})]})]})]})}function te({children:t}){return e.jsx("span",{className:"inline-flex items-center rounded-full bg-white/[0.06] border border-white/10 px-2.5 py-0.5 text-xs text-zinc-200",children:t})}function L(t){return t.split(`
41`).map(s=>s.trim()).filter(Boolean)}function F(t){return(t||[]).join(`
42`)}function et({channelId:t}){const{toast:s}=M(),d=U(),m=[`/api/videos/channels/${t}/bible`],c=_({queryKey:m,enabled:!!t}),[n,x]=f.useState(!1),[o,v]=f.useState(null),b=$({mutationFn:async()=>(await q("POST",`/api/videos/channels/${t}/bible/generate`,{})).json(),onSuccess:()=>{d.invalidateQueries({queryKey:m}),s({title:"Bíblia editorial pronta ✨",description:"A identidade do canal foi montada pela Sábhia."})},onError:i=>s({title:"Não foi possível gerar",description:i?.message,variant:"destructive"})}),p=$({mutationFn:async i=>(await q("PUT",`/api/videos/channels/${t}/bible`,{content:i})).json(),onSuccess:()=>{d.invalidateQueries({queryKey:m}),x(!1),v(null),s({title:"Bíblia salva ✓",description:"As alterações foram salvas com sucesso."})},onError:i=>s({title:"Não foi possível salvar",description:i?.message,variant:"destructive"})}),l=$({mutationFn:async()=>(await q("POST",`/api/videos/channels/${t}/ideas/generate`,{count:8})).json(),onSuccess:i=>{d.invalidateQueries({queryKey:m}),s({title:`${i?.created?.length||0} ideias geradas 💡`,description:"Escolha as que quiser transformar em vídeo."})},onError:i=>s({title:"Não foi possível gerar ideias",description:i?.message,variant:"destructive"})}),r=c.data?.bible?.content||null,N=c.data?.ideas||[],S=!!r;function w(){v(JSON.parse(JSON.stringify(r||{}))),x(!0)}function A(){v(null),x(!1)}function g(i){v(a=>({...a||{},...i}))}const z="w-full rounded-xl bg-white/[0.03] border border-white/10 px-3 py-2.5 text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none focus:ring-2 focus:ring-cyan-500/40 resize-none",h="block text-xs font-semibold text-cyan-300 mb-1.5 uppercase tracking-wide";return e.jsxs("div",{className:"mb-8 rounded-2xl border border-blue-500/20 bg-gradient-to-br from-[#0c1b3a]/55 via-[#0a1730]/45 to-[#091226]/35 overflow-hidden","data-testid":"section-editorial-bible",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 pt-5 pb-4 border-b border-white/5",children:[e.jsx("div",{className:"h-11 w-11 rounded-xl bg-gradient-to-br from-blue-500 to-cyan-400 flex items-center justify-center shrink-0 shadow-lg shadow-blue-900/40",children:e.jsx(ke,{className:"h-6 w-6 text-white"})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("h2",{className:"text-lg font-bold text-white leading-tight",children:"Bíblia editorial & ideias"}),e.jsx("p",{className:"text-sm text-zinc-400",children:"A Sábhia transforma o seu briefing na identidade do canal e em ideias prontas para gravar."})]}),S&&!n&&e.jsxs("button",{onClick:w,className:"inline-flex items-center gap-1.5 rounded-xl border border-white/10 px-3 py-2 text-xs text-zinc-400 hover:text-cyan-300 hover:border-cyan-500/30 transition-colors shrink-0","data-testid":"button-edit-bible",children:[e.jsx(_e,{className:"h-3.5 w-3.5"})," Editar"]})]}),e.jsxs("div",{className:"p-5",children:[c.isLoading?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(y,{className:"h-6 w-6 animate-spin text-cyan-400"})}):S?n&&o?e.jsxs("div",{className:"space-y-5","data-testid":"form-edit-bible",children:[e.jsxs("div",{className:"rounded-xl bg-white/[0.03] border border-white/10 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-cyan-300",children:[e.jsx(de,{className:"h-4 w-4"})," POSICIONAMENTO"]}),e.jsxs("div",{children:[e.jsx("label",{className:h,children:"Posicionamento"}),e.jsx("textarea",{rows:3,value:o.positioning||"",onChange:i=>g({positioning:i.target.value}),placeholder:"Como o canal se posiciona no mercado…",className:z,"data-testid":"input-bible-positioning"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:h,children:["Missão ",e.jsx("span",{className:"text-zinc-500 font-normal normal-case",children:"(opcional)"})]}),e.jsx("textarea",{rows:2,value:o.mission||"",onChange:i=>g({mission:i.target.value}),placeholder:"A missão do canal…",className:z,"data-testid":"input-bible-mission"})]})]}),e.jsxs("div",{className:"rounded-xl bg-white/[0.03] border border-white/10 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-cyan-300",children:[e.jsx(J,{className:"h-4 w-4"})," PÚBLICO"]}),e.jsxs("div",{children:[e.jsx("label",{className:h,children:"Quem é o público"}),e.jsx("textarea",{rows:2,value:o.audience?.who||"",onChange:i=>
42g({audience:{...o.audience||{},who:i.target.value}}),placeholder:"Descreva o público-alvo…",className:z,"data-testid":"input-bible-audience-who"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:h,children:["Dores ",e.jsx("span",{className:"text-zinc-500 font-normal normal-case",children:"(uma por linha)"})]}),e.jsx("textarea",{rows:3,value:F(o.audience?.painPoints),onChange:i=>g({audience:{...o.audience||{},painPoints:L(i.target.value)}}),placeholder:`Não sabe por onde começar
43Falta de tempo
44…`,className:z,"data-testid":"input-bible-audience-pains"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:h,children:["Desejos ",e.jsx("span",{className:"text-zinc-500 font-normal normal-case",children:"(uma por linha)"})]}),e.jsx("textarea",{rows:3,value:F(o.audience?.desires),onChange:i=>g({audience:{...o.audience||{},desires:L(i.target.value)}}),placeholder:`Aprender rápido
45Resultados visíveis
46…`,className:z,"data-testid":"input-bible-audience-desires"})]})]}),e.jsxs("div",{className:"rounded-xl bg-white/[0.03] border border-white/10 p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-cyan-300",children:[e.jsx(le,{className:"h-4 w-4"})," TOM DE VOZ"]}),e.jsxs("div",{children:[e.jsx("label",{className:h,children:"Descrição do tom"}),e.jsx("textarea",{rows:2,value:o.tone?.voice||"",onChange:i=>g({tone:{...o.tone||{},voice:i.target.value}}),placeholder:"Ex: direto, inspirador, sem jargões…",className:z,"data-testid":"input-bible-tone-voice"})]}),e.jsxs("div",{children:[e.jsxs("label",{className:h,children:["Adjetivos ",e.jsx("span",{className:"text-zinc-500 font-normal normal-case",children:"(uma por linha)"})]}),e.jsx("textarea",{rows:3,value:F(o.tone?.adjectives),onChange:i=>g({tone:{...o.tone||{},adjectives:L(i.target.value)}}),placeholder:`Autêntico
47Pragmático
48…`,className:z,"data-testid":"input-bible-tone-adjectives"})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-cyan-300",children:[e.jsx(me,{className:"h-4 w-4"})," PILARES DE CONTEÚDO"]}),e.jsxs("button",{type:"button",onClick:()=>g({pillars:[...o.pillars||[],{name:"",description:""}]}),className:"inline-flex items-center gap-1 text-xs text-zinc-400 hover:text-cyan-300 transition-colors","data-testid":"button-bible-add-pillar",children:[e.jsx(W,{className:"h-3.5 w-3.5"})," Adicionar pilar"]})]}),e.jsxs("div",{className:"space-y-2",children:[(o.pillars||[]).map((i,a)=>e.jsxs("div",{className:"rounded-xl bg-white/[0.03] border border-white/10 p-3 space-y-2","data-testid":`card-edit-pillar-${a}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{value:i.name||"",onChange:u=>{const j=[...o.pillars||[]];j[a]={...j[a],name:u.target.value},g({pillars:j})},placeholder:`Pilar ${a+1}`,className:"flex-1 rounded-lg bg-white/[0.03] border border-white/10 px-3 py-2 text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none focus:ring-2 focus:ring-cyan-500/40","data-testid":`input-pillar-name-${a}`}),e.jsx("button",{type:"button",onClick:()=>{const u=(o.pillars||[]).filter((j,P)=>P!==a);g({pillars:u})},className:"text-zinc-600 hover:text-red-400 transition-colors shrink-0","data-testid":`button-remove-pillar-${a}`,children:e.jsx(ce,{className:"h-4 w-4"})})]}),e.jsx("input",{value:i.description||"",onChange:u=>{const j=[...o.pillars||[]];j[a]={...j[a],description:u.target.value},g({pillars:j})},placeholder:"Descrição do pilar…",className:"w-full rounded-lg bg-white/[0.03] border border-white/10 px-3 py-2 text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none focus:ring-2 focus:ring-cyan-500/40","data-testid":`input-pillar-desc-${a}`})]},a)),!o.pillars?.length&&e.jsx("p",{className:"text-xs text-zinc-500 italic",children:'Nenhum pilar. Clique em "Adicionar pilar" para criar.'})]})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"rounded-xl bg-emerald-500/[0.05] border border-emerald-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-emerald-300 mb-2",children:[e.jsx(D,{className:"h-4 w-4"})," FAÇA"]}),e.jsx("textarea",{rows:5,value:F(o.doList),onChange:i=>g({doList:L(i.target.value)}),placeholder:`Uma instrução por linha
49Ex: Seja direto
50…`,className:`${z} border-emerald-500/20`,"data-testid":"input-bible-dolist"})]}),e.jsxs("div",{className:"rounded-xl bg-red-500/[0.05] border border-red-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-red-300 mb-2",children:[e.jsx(X,{className:"h-4 w-4"})," NÃO FAÇA"]}),e.jsx("textarea",{rows:5,value:F(o.dontList),onChange:i=>g({dontList:L(i.target.value)}),placeholder:`Uma instrução por linha
51Ex: Evite jargões
52…`,className:`${z} border-red-500/20`,"data-testid":"input-bible-dontlist"})]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:h,children:[e.jsxs("span",{className:"inline-flex items-center gap-1.5",children:[e.jsx(G,{className:"h-4 w-4"})," Ganchos recorrentes"]}),e.jsx("span",{className:"text-zinc-500 font-normal normal-case ml-1",children:"(um por linha)"})]}),e.jsx("textarea",{rows:3,value:F(o.hooks),onChange:i=>g({hooks:L(i.target.value)}),placeholder:`Sabia que…?
53O erro que todo mundo comete
54…`,className:z,"data-testid":"input-bible-hooks"})]}),e.jsxs("div",{children:[e.jsx("label",{className:h,children:"CTA padrão"}),e.jsx("input",{value:o.cta||"",onChange:i=>g({cta:i.target.value}),placeholder:"Ex: Se inscreva e ative o sininho para não perder…",className:"w-full rounded-xl bg-white/[0.03] border border-white/10 px-3 py-2.5 text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none focus:ring-2 focus:ring-cyan-500/40","data-testid":"input-bible-cta"})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-2",children:[e.jsxs("button",{onClick:()=>p.mutate(o),disabled:p.isPending,className:"inline-flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-blue-500 to-cyan-400 px-5 py-3 font-semibold text-white shadow-lg shadow-blue-900/40 hover:opacity-95 disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"button-save-bible",children:[p.isPending?e.jsx(y,{className:"h-5 w-5 animate-spin"}):e.jsx(Y,{className:"h-5 w-5"}),p.isPending?"Salvando…":"Salvar bíblia"]}),e.jsxs("button",{onClick:A,disabled:p.isPending,className:"inline-flex items-center gap-2 rounded-xl border border-white/10 px-4 py-3 text-sm text-zinc-400 hover:text-white hover:border-white/20 transition-colors disabled:opacity-50","data-testid":"button-cancel-edit-bible",children:[e.jsx(ce,{className:"h-4 w-4"})," Cancelar"]})]})]}):e.jsxs("div",{className:"space-y-5","data-testid":"content-editorial-bible",children:[r.positioning&&e.jsxs("div",{className:"rounded-xl bg-white/[0.03] border border-white/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-cyan-300 mb-1.5",children:[e.jsx(de,{className:"h-4 w-4"})," POSICIONAMENTO"]}),e.jsx("p",{className:"text-sm text-zinc-100","data-testid":"text-bible-positioning",children:r.positioning}),r.mission&&e.jsx("p",{className:"text-xs text-zinc-400 mt-2",children:r.mission})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[r.audience&&(r.audience.who||r.audience.painPoints?.length||r.audience.desires?.length)&&e.jsxs("div",{className:"rounded-xl bg-white/[0.03] border border-white/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-cyan-300 mb-1.5",children:[e.jsx(J,{className:"h-4 w-4"})," PÚBLICO"]}),r.audience.who&&e.jsx("p",{className:"text-sm text-zinc-200",children:r.audie
54nce.who}),!!r.audience.painPoints?.length&&e.jsxs("p",{className:"text-xs text-zinc-400 mt-2",children:[e.jsx("span",{className:"text-zinc-300",children:"Dores:"})," ",r.audience.painPoints.join(" · ")]}),!!r.audience.desires?.length&&e.jsxs("p",{className:"text-xs text-zinc-400 mt-1",children:[e.jsx("span",{className:"text-zinc-300",children:"Desejos:"})," ",r.audience.desires.join(" · ")]})]}),r.tone&&(r.tone.voice||r.tone.adjectives?.length)&&e.jsxs("div",{className:"rounded-xl bg-white/[0.03] border border-white/10 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-cyan-300 mb-1.5",children:[e.jsx(le,{className:"h-4 w-4"})," TOM DE VOZ"]}),r.tone.voice&&e.jsx("p",{className:"text-sm text-zinc-200",children:r.tone.voice}),!!r.tone.adjectives?.length&&e.jsx("div",{className:"flex flex-wrap gap-1.5 mt-2",children:r.tone.adjectives.map((i,a)=>e.jsx(te,{children:i},a))})]})]}),!!r.pillars?.length&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-cyan-300 mb-2",children:[e.jsx(me,{className:"h-4 w-4"})," PILARES DE CONTEÚDO"]}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:r.pillars.map((i,a)=>e.jsxs("div",{className:"rounded-xl bg-white/[0.03] border border-white/10 p-3","data-testid":`card-pillar-${a}`,children:[e.jsx("p",{className:"text-sm font-medium text-white",children:i.name}),i.description&&e.jsx("p",{className:"text-xs text-zinc-400 mt-0.5",children:i.description})]},a))})]}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[!!r.doList?.length&&e.jsxs("div",{className:"rounded-xl bg-emerald-500/[0.05] border border-emerald-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-emerald-300 mb-2",children:[e.jsx(D,{className:"h-4 w-4"})," FAÇA"]}),e.jsx("ul",{className:"space-y-1.5",children:r.doList.map((i,a)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-zinc-200",children:[e.jsx(D,{className:"h-3.5 w-3.5 text-emerald-400 shrink-0 mt-0.5"})," ",i]},a))})]}),!!r.dontList?.length&&e.jsxs("div",{className:"rounded-xl bg-red-500/[0.05] border border-red-500/20 p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-red-300 mb-2",children:[e.jsx(X,{className:"h-4 w-4"})," NÃO FAÇA"]}),e.jsx("ul",{className:"space-y-1.5",children:r.dontList.map((i,a)=>e.jsxs("li",{className:"flex items-start gap-2 text-sm text-zinc-200",children:[e.jsx(X,{className:"h-3.5 w-3.5 text-red-400 shrink-0 mt-0.5"})," ",i]},a))})]})]}),!!r.hooks?.length&&e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 text-xs font-semibold text-cyan-300 mb-2",children:[e.jsx(G,{className:"h-4 w-4"})," GANCHOS RECORRENTES"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:r.hooks.map((i,a)=>e.jsx(te,{children:i},a))})]}),r.cta&&e.jsxs("p",{className:"text-xs text-zinc-400",children:[e.jsx("span",{className:"text-zinc-300 font-medium",children:"CTA padrão:"})," ",r.cta]}),e.jsx("div",{className:"flex items-center justify-end pt-1",children:e.jsxs("button",{onClick:()=>{window.confirm("Regenerar a bíblia editorial a partir do briefing atual? A versão atual será substituída.")&&b.mutate()},disabled:b.isPending,className:"inline-flex items-center gap-2 rounded-xl border border-white/10 px-3 py-2 text-xs text-zinc-400 hover:text-cyan-300 hover:border-cyan-500/30 transition-colors disabled:opacity-50","data-testid":"button-regenerate-bible",children:[b.isPending?e.jsx(y,{className:"h-4 w-4 animate-spin"}):e.jsx(ze,{className:"h-4 w-4"}),"Regenerar bíblia"]})})]}):e.jsxs("div",{className:"text-center py-6","data-testid":"empty-editorial-bible",children:[e.jsx(G,{className:"h-8 w-8 mx-auto mb-3 text-cyan-400/70"}),e.jsx("p",{className:"text-sm text-zinc-300 mb-1",children:"Ainda não há uma bíblia editorial para este canal."}),e.jsx("p",{className:"text-xs text-zinc-500 mb-5 max-w-md mx-auto",children:"Salve o briefing abaixo (nome, nicho, público, tom…) e a Sábhia gera o posicionamento, os pilares de conteúdo, o tom de voz e as regras do que fazer e não fazer."}),e.jsxs("button",{onClick:()=>b.mutate(),disabled:b.isPending,className:"inline-flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-blue-500 to-cyan-400 px-5 py-3 font-semibold text-white shadow-lg shadow-blue-900/40 hover:opacity-95 disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"button-generate-bible",children:[b.isPending?e.jsx(y,{className:"h-5 w-5 animate-spin"}):e.jsx(ie,{className:"h-5 w-5"}),b.isPending?"Gerando bíblia…":"Gerar bíblia editorial"]})]}),S&&!n&&e.jsxs("div",{className:"mt-6 pt-6 border-t border-white/5","data-testid":"block-video-ideas",children:[e.jsxs("div",{className:"flex items-center justify-between gap-3 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-white",children:[e.jsx(Q,{className:"h-4 w-4 text-amber-300"})," Ideias de vídeo",N.length>0&&e.jsxs("span",{className:"text-xs font-normal text-zinc-500",children:["(",N.length,")"]})]}),e.jsxs("button",{onClick:()=>l.mutate(),disabled:l.isPending,className:"inline-flex items-center gap-2 rounded-xl bg-gradient-to-r from-blue-500 to-cyan-400 px-4 py-2 text-sm font-semibold text-white shadow-lg shadow-blue-900/40 hover:opacity-95 disabled:opacity-40 disabled:cursor-not-allowed shrink-0","data-testid":"button-generate-ideas",children:[l.isPending?e.jsx(y,{className:"h-4 w-4 animate-spin"}):e.jsx(W,{className:"h-4 w-4"}),N.length>0?"Mais ideias":"Gerar ideias"]})]}),l.isPending&&N.length===0?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(y,{className:"h-6 w-6 animate-spin text-cyan-400"})}):N.length===0?e.jsxs("div",{className:"text-center py-6 text-sm text-zinc-500","data-testid":"empty-video-ideas",children:[e.jsx(Q,{className:"h-8 w-8 mx-auto mb-2 text-zinc-700"}
54),"Sem ideias ainda. Gere um lote de ideias alinhadas à bíblia."]}):e.jsx("div",{className:"space-y-2.5",children:N.map(i=>e.jsx(Ze,{idea:i,channelId:t},i.id))})]})]})]})}const tt={private:"Privado (só você)",unlisted:"Não listado (com link)",public:"Público"};function at({channelId:t}){const{toast:s}=M(),d=U(),m=[`/api/videos/channels/${t}/autopilot`],c=_({queryKey:m,enabled:!!t}),[n,x]=f.useState(null);f.useEffect(()=>{c.data?.config&&x(c.data.config)},[c.data]);const o=$({mutationFn:async()=>(await q("PUT",`/api/videos/channels/${t}/autopilot`,n)).json(),onSuccess:l=>{l?.config&&x(l.config),d.invalidateQueries({queryKey:m}),s({title:"Piloto automático salvo ✨"})},onError:l=>s({title:"Não foi possível salvar",description:l?.message,variant:"destructive"})}),v=!!c.data?.globallyEnabled,b=!!c.data?.youtubeConnected,p=l=>x(r=>r&&{...r,...l});return e.jsxs("div",{className:"mb-8 rounded-2xl border border-blue-500/20 bg-gradient-to-br from-[#0c1b3a]/55 via-[#0a1730]/45 to-[#091226]/35 overflow-hidden","data-testid":"section-autopilot",children:[e.jsxs("div",{className:"flex items-center gap-3 px-5 pt-5 pb-4 border-b border-white/5",children:[e.jsx("div",{className:"h-11 w-11 rounded-xl bg-gradient-to-br from-blue-500 to-cyan-400 flex items-center justify-center shrink-0 shadow-lg shadow-blue-900/40",children:e.jsx(ie,{className:"h-6 w-6 text-white"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h2",{className:"text-lg font-bold text-white leading-tight",children:"Piloto automático"}),e.jsx("p",{className:"text-sm text-zinc-400",children:"A Sábhia cria vídeos sozinha no ritmo que você definir — e publica se você deixar."})]})]}),e.jsx("div",{className:"p-5",children:c.isLoading||!n?e.jsx("div",{className:"flex justify-center py-8",children:e.jsx(y,{className:"h-6 w-6 animate-spin text-cyan-400"})}):e.jsxs(e.Fragment,{children:[!v&&e.jsxs("div",{className:"mb-5 flex items-start gap-3 rounded-xl bg-amber-500/[0.07] border border-amber-500/20 px-4 py-3","data-testid":"banner-autopilot-disabled",children:[e.jsx(fe,{className:"h-5 w-5 text-amber-400 shrink-0 mt-0.5"}),e.jsx("span",{className:"text-sm text-amber-100/90",children:"O piloto automático ainda não foi habilitado nesta plataforma. Você pode deixar tudo pronto aqui — a Sábhia começa a produzir assim que o administrador ligar o recurso."})]}),e.jsxs("button",{type:"button",onClick:()=>p({enabled:!n.enabled}),className:`w-full flex items-center justify-between gap-3 rounded-xl border px-4 py-3.5 transition-colors ${n.enabled?"border-cyan-500/40 bg-cyan-500/[0.08]":"border-white/10 bg-white/[0.02] hover:border-white/20"}`,"data-testid":"toggle-autopilot-enabled",children:[e.jsxs("span",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(Se,{className:`h-5 w-5 shrink-0 ${n.enabled?"text-cyan-300":"text-zinc-500"}`}),e.jsxs("span",{className:"text-left min-w-0",children:[e.jsx("span",{className:"block font-semibold text-white",children:n.enabled?"Piloto automático LIGADO":"Piloto automático desligado"}),e.jsx("span",{className:"block text-xs text-zinc-400",children:n.enabled?"A Sábhia vai produzir no ritmo abaixo.":"Ligue para a Sábhia produzir sozinha."})]})]}),e.jsx("span",{className:`relative h-6 w-11 rounded-full transition-colors shrink-0 ${n.enabled?"bg-gradient-to-r from-blue-500 to-cyan-400":"bg-zinc-700"}`,children:e.jsx("span",{className:`absolute top-0.5 h-5 w-5 rounded-full bg-white transition-all ${n.enabled?"left-[22px]":"left-0.5"}`})})]}),e.jsxs("div",{className:"mt-5",children:[e.jsxs("label",{className:"flex items-center gap-2 text-sm font-medium text-zinc-200 mb-2",children:[e.jsx(Oe,{className:"h-4 w-4 text-cyan-400"})," Vídeos por semana"]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("input",{type:"range",min:1,max:14,value:n.videosPerWeek,onChange:l=>p({videosPerWeek:Number(l.target.value)}),className:"flex-1 accent-cyan-400","data-testid":"input-autopilot-per-week"}),e.jsxs("span",{className:"w-16 text-center text-sm font-semibold text-white tabular-nums","data-testid":"text-autopilot-per-week",children:[n.videosPerWeek,"/sem"]})]})]}),e.jsxs("div",{className:"mt-5",children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-200 mb-2",children:"Tema ou nicho das ideias"}),e.jsx("input",{value:n.topicTheme,onChange:l=>p({topicTheme:l.target.value}),maxLength:400,placeholder:"Ex: filosofia estoica do dia a dia",className:"w-full rounded-xl bg-white/[0.03] border border-white/10 px-4 py-3 text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none focus:ring-2 focus:ring-cyan-500/40","data-testid":"input-autopilot-theme"}),e.jsx("p",{className:"mt-1.5 text-xs text-zinc-500",children:"A Sábhia gera uma 
54ideia fresca a cada vídeo a partir desse tema, evitando repetir os já feitos."})]}),e.jsxs("div",{className:"mt-5",children:[e.jsxs("label",{className:"block text-sm font-medium text-zinc-200 mb-2",children:["Estilo visual/narrativo ",e.jsx("span",{className:"text-zinc-500 font-normal",children:"(opcional)"})]}),e.jsx("input",{value:n.style||"",onChange:l=>p({style:l.target.value||null}),maxLength:400,placeholder:"Ex: tom inspirador, imagens cinematográficas",className:"w-full rounded-xl bg-white/[0.03] border border-white/10 px-4 py-3 text-sm text-zinc-100 placeholder:text-zinc-600 focus:outline-none focus:ring-2 focus:ring-cyan-500/40","data-testid":"input-autopilot-style"})]}),e.jsxs("div",{className:"mt-6 rounded-xl border border-white/10 bg-white/[0.02] p-4",children:[e.jsxs("button",{type:"button",onClick:()=>b&&p({autoPublish:!n.autoPublish}),disabled:!b,className:"w-full flex items-center justify-between gap-3 disabled:opacity-60 disabled:cursor-not-allowed","data-testid":"toggle-autopilot-autopublish",children:[e.jsxs("span",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx(ee,{className:`h-5 w-5 shrink-0 ${n.autoPublish&&b?"text-red-400":"text-zinc-500"}`}),e.jsxs("span",{className:"text-left min-w-0",children:[e.jsx("span",{className:"block font-semibold text-white",children:"Publicar no YouTube automaticamente"}),e.jsx("span",{className:"block text-xs text-zinc-400",children:b?"Cada vídeo pronto é enviado direto para o seu canal.":"Conecte um canal do YouTube acima para liberar."})]})]}),e.jsx("span",{className:`relative h-6 w-11 rounded-full transition-colors shrink-0 ${n.autoPublish&&b?"bg-gradient-to-r from-blue-500 to-cyan-400":"bg-zinc-700"}`,children:e.jsx("span",{className:`absolute top-0.5 h-5 w-5 rounded-full bg-white transition-all ${n.autoPublish&&b?"left-[22px]":"left-0.5"}`})})]}),n.autoPublish&&b&&e.jsxs("div",{className:"mt-4 pt-4 border-t border-white/5",children:[e.jsx("label",{className:"block text-sm font-medium text-zinc-200 mb-2",children:"Visibilidade ao publicar"}),e.jsx("div",{className:"grid grid-cols-3 gap-2",children:["private","unlisted","public"].map(l=>e.jsx("button",{type:"button",onClick:()=>p({privacyStatus:l}),className:`rounded-xl border px-2 py-2.5 text-xs font-medium transition-colors ${n.privacyStatus===l?"border-cyan-500/50 bg-cyan-500/[0.12] text-cyan-200":"border-white/10 bg-white/[0.02] text-zinc-400 hover:border-white/20"}`,"data-testid":`button-privacy-${l}`,children:tt[l]},l))})]})]}),e.jsx("div",{className:"mt-6",children:e.jsxs("button",{onClick:()=>o.mutate(),disabled:o.isPending,className:"inline-flex items-center justify-center gap-2 rounded-xl bg-gradient-to-r from-blue-500 to-cyan-400 px-5 py-3 font-semibold text-white shadow-lg shadow-blue-900/40 hover:opacity-95 disabled:opacity-40 disabled:cursor-not-allowed","data-testid":"button-save-autopilot",children:[o.isPending?e.jsx(y,{className:"h-5 w-5 animate-spin"}):e.jsx(Y,{className:"h-5 w-5"}),"Salvar piloto automático"]})})]})})]})}const Ct=Object.freeze(Object.defineProperty({__proto__:null,YT_ERROR_MESSAGES:ve,default:Ye},Symbol.toStringTag,{value:"Module"}));export{Qe as C,ve as Y,Ve as b,Ct as c,Me as e};

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.