1import{c as me,e as ue,u as xe,a as he,r as t,s as m,j as e,L as be,S as pe,X as F,t as l}from"./main-Cc8MXM0b.js";import{c as ge,r as fe,u as je}from"./auth-middleware-DkOh8P7y.js";import{r as we}from"./lesson-memory-fNBx_t05.js";import{L as j}from"./loader-circle-BDgPbVnp.js";import{C as ke}from"./chevron-left-wJAKe9ZS.js";import{Y as D}from"./youtube-C221CwCG.js";import{P as U}from"./plus-RxBB5S-y.js";import{S as Ne}from"./search-GRLre2Yy.js";import{P as R}from"./play-BwmCKwmK.js";import{E as ve}from"./external-link-jZax2WDd.js";import{T as Y}from"./trash-2-HQKadhln.js";import{D as ye}from"./download-CVdlGcDT.js";const Ce=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Se=me("folder-plus",Ce),Fe=ge({method:"POST"}).middleware([fe]).handler(ue("6547f3785b6277827c915fc0054d45b243572a767ab83fb87cb4819808bf8bb8")),Ae=["Educação Infantil","1º ano","2º ano","3º ano","4º ano","5º ano","6º ano","7º ano","8º ano","9º ano","Ensino Médio"],Ee=["30 minutos","50 minutos","1 hora","2 horas"];function De(){const{user:c,isLoading:u}=xe(),p=he(),k=je(Fe),[N,h]=t.useState([]),[g,H]=t.useState(["Geral"]),[X,A]=t.useState(!0),[E,Z]=t.useState(""),[f,_]=t.useState("Todas"),[J,v]=t.useState(!1),[i,L]=t.useState(""),[T,K]=t.useState("Geral"),[V,P]=t.useState(!1),[Q,W]=t.useState(null),[ee,B]=t.useState(!1),[y,q]=t.useState(""),[o,G]=t.useState(null),[b,ae]=t.useState(""),[I,se]=t.useState("50 minutos"),[M,O]=t.useState(!1),[n,$]=t.useState(null);t.useEffect(()=>{!u&&!c&&p({to:"/login"}),c&&(S(),C())},[c,u]);async function C(){try{const{data:a,error:s}=await m.from("video_categories").select("name").eq("user_id",c?.id).order("name");if(!s&&a){const r=["Geral",...a.map(d=>d.name)];H(Array.from(new Set(r)))}}catch(a){console.error(a)}}async function te(){if(y.trim())try{const{error:a}=await m.from("video_categories").insert({user_id:c?.id,name:y.trim()});if(a)if(a.code==="23505")l.error("Categoria já existe");else throw a;else l.success("Categoria adicionada"),q(""),C()}catch{l.error("Erro ao adicionar categoria")}}async function re(a){if(a!=="Geral"&&confirm(`Excluir a categoria "${a}"? Os vÃdeos nela serão movidos para "Geral".`))try{await m.from("user_videos").update({category:"Geral"}).eq("user_id",c?.id).eq("category",a);const{error:s}=await m.from("video_categories").delete().eq("user_id",c?.id).eq("name",a);if(s)throw s;l.success("Categoria removida"),C(),S()}catch{l.error("Erro ao remover categoria")}}async function le(a,s){try{const{error:r}=await m.from("user_videos").update({category:s}).eq("id",a);if(r)throw r;h(d=>d.map(x=>x.id===a?{...x,category:s}:x)),l.success("Categoria atualizada")}catch{l.error("Erro ao atualizar categoria")}}const ce=a=>{const s=a.match(/(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|shorts\/))([^&?]{11})/);return s&&s[1]?`https://www.youtube.com/embed/${s[1]}?autoplay=1`:a.includes("instagram.com/reels/")||a.includes("instagram.com/reel/")?`${a.split("?")[0].replace(/\/$/,"")}/embed/captioned/`:null};async function S(){try{A(!0);const{data:a,error:s}=await m.from("user_videos").select("*").eq("user_id",c?.id).order("created_at",{ascending:!1});if(s)throw s;h(a||[])}catch(a){console.error(a)}finally{A(!1)}}async function oe(){if(i)try{P(!0);let a="VÃdeo Sem TÃtulo",s=null,r="";if(i.includes("youtube.com")||i.includes("youtu.be")){const x=i.match(/(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=|shorts\/))([^&?]{11})/);if(r=x?x[1]:"",r){s=`https://img.youtube.com/vi/${r}/mqdefault.jpg`;try{a=(await(await fetch(`https://www.youtube.com/oembed?url=${i}&format=json`)).json()).title}catch{}}}else i.includes("instagram.com")&&(a="Instagram Reel",s="https://www.instagram.com/static/images/ico/favicon.ico/36b3048a4456.ico");const{error:d}=await m.from("user_videos").insert({user_id:c?.id,url:i,title:a,thumbnail_url:s,category:T});if(d)throw d;l.success("VÃdeo adicionado!"),L(""),v(!1),S()}catch{l.error("Erro ao adicionar vÃdeo")}finally{P(!1)}}async function ie(a){if(!confirm("Excluir este vÃdeo?"))return;const{error:s}=await m.from("user_videos").delete().eq("id",a);s||(h(r=>r.filter(d=>d.id!==a)),l.success("VÃdeo removido"))}async function ne(){if(!o||!b){l.error("Selecione a série");return}try{O(!0);const a=await k({data:{videoId:o.id,videoUrl:o.url,title:o.title,de
1scription:o.notes||"",serie:b,tempo:I}});$(a),await we({titulo:a.titulo,serie:b,source:"meus-videos",link_aula:o.url,objetivo:a.objetivos?.[0]||""}),l.success("Aula gerada com sucesso!")}catch{l.error("Erro ao gerar aula")}finally{O(!1)}}const z=N.filter(a=>{const s=a.title.toLowerCase().includes(E.toLowerCase()),r=f==="Todas"||a.category===f;return s&&r});return u?e.jsx("div",{className:"h-screen grid place-items-center",children:e.jsx(j,{className:"animate-spin"})}):e.jsxs("div",{className:"min-h-screen bg-[#FFFBF3] pb-20",children:[e.jsx("header",{className:"bg-white/70 backdrop-blur-md border-b border-black/5 sticky top-0 z-30 px-6 py-4",children:e.jsxs("div",{className:"max-w-6xl mx-auto flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(be,{to:"/app",className:"p-2 hover:bg-black/5 rounded-full transition",children:e.jsx(ke,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsxs("h1",{className:"text-xl font-black flex items-center gap-2",children:[e.jsx(D,{className:"w-6 h-6 text-[#0CA678]"}),"Meus VÃdeos"]}),e.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-black/40",children:"Biblioteca Pedagógica"})]})]}),e.jsxs("button",{onClick:()=>v(!0),className:"bg-[#0CA678] text-white px-4 py-2 rounded-xl text-sm font-black flex items-center gap-2 shadow-lg shadow-[#0CA678]/20 hover:scale-105 transition",children:[e.jsx(U,{className:"w-4 h-4"})," Adicionar Link"]})]})}),e.jsxs("main",{className:"max-w-6xl mx-auto p-6 space-y-8",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("button",{onClick:()=>_("Todas"),className:`px-4 py-2 rounded-full text-[10px] font-black uppercase tracking-widest transition-all ${f==="Todas"?"bg-black text-white":"bg-white border border-black/5 text-black/40 hover:bg-black/5"}`,children:"Todas"}),g.map(a=>e.jsx("button",{onClick:()=>_(a),className:`px-4 py-2 rounded-full text-[10px] font-black uppercase tracking-widest transition-all ${f===a?"bg-[#0CA678] text-white":"bg-white border border-black/5 text-black/40 hover:bg-black/5"}`,children:a},a)),e.jsx("button",{onClick:()=>B(!0),className:"p-2 bg-white border border-black/5 rounded-full text-black/30 hover:text-black transition",title:"Gerenciar Categorias",children:e.jsx(Se,{className:"w-4 h-4"})})]}),e.jsxs("div",{className:"relative max-w-md",children:[e.jsx(Ne,{className:"absolute left-4 top-1/2 -translate-y-1/2 w-4 h-4 text-black/30"}),e.jsx("input",{value:E,onChange:a=>Z(a.target.value),placeholder:"Buscar em seus vÃdeos...",className:"w-full bg-white border border-black/5 rounded-2xl pl-11 pr-4 py-3 text-sm focus:ring-2 ring-[#0CA678]/20 outline-none transition"})]}),X?e.jsxs("div",{className:"flex flex-col items-center justify-center py-20 gap-3 opacity-30",children:[e.jsx(j,{className:"w-8 h-8 animate-spin"}),e.jsx("span",{className:"text-xs font-black uppercase tracking-widest",children:"Carregando biblioteca..."})]}):z.length===0?e.jsxs("div",{className:"text-center py-20 bg-black/[0.02] rounded-3xl border-2 border-dashed border-black/5",children:[e.jsx(D,{className:"w-12 h-12 mx-auto text-black/10 mb-4"}),e.jsx("h3",{className:"text-lg font-black text-black/40",children:"Nenhum vÃdeo encontrado"}),e.jsx("p",{className:"text-sm text-black/30 mt-1",children:'Clique em "Adicionar Link" para começar sua biblioteca.'})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-6",children:z.map(a=>e.jsxs("div",{className:"group bg-white rounded-3xl border border-black/5 overflow-hidden shadow-sm hover:shadow-xl transition-all duration-300",children:[e.jsx("div",{className:"aspect-[9/16] bg-black relative overflow-hidden",children:Q?.id===a.id?e.jsx("iframe",{src:ce(a.url)||"",className:"w-full h-full border-none",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0}):e.jsxs(e.Fragment,{children:[a.thumbnail_url?e.jsx("img",{src:a.thumbnail_url,alt:a.title,className:"w-full h-full object-cover group-hover:scale-110 transition-transform duration-500",onError:s=>{const r=s.target;r.src="https://www.instagram.com/static/images/ico/favicon.ico/36b3048a4456.ico",r.className="w-12 h-12 m-auto opacity-20"}}):e.jsx("div",{className:"w-full h-full flex items-center justify-center text-white/20",children:e.jsx(R,{className:"w-10 h-10"})}),e.jsx("div",{className:"absolute inset-0 bg-black/40 opacity-0 group-hover:opacity-100 transition-opacity grid place-items-center",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{onClick:()=>W(a),className:"p-4 bg-[#0CA678] hover:scale-110 shadow-xl rounded-full text-white transition-all",children:e.jsx(R,{className:"w-6 h-6 fill-current"})}),e.jsx("a",{href:a.url,target:"_blank",rel:"noopener",className:"p-3 bg-white/20 hover:bg-white/40 backdrop-blur-md rounded-full text-white transition",children:e.jsx(ve,{className:"w-5 h-5"})})]})})]})}),e.jsxs("div",{className:"p-5 space-y-3",children:[e.jsxs("div",{className:"min-h-[3rem]",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsx("h3",{className:"font-black text-sm leading-tight text-black/80 line-clamp-2",children:a.title}),e.jsx("div",{className:"relative group/cat",children:e.jsx("select",{value:a.category||"Geral",onChange:s=>le(a.id,s.target.value),className:"appearance-none bg-black/[0.03] text-[9px] font-black uppercase tracking-tighter px-2 py-1 rounded-md border border-transparent hover:border-black/10 outline-none cursor-pointer",children:g.map(s=>e.jsx("option",{value:s,children:s},s))})})]}),e.jsx("p",{className:"text-[10px] text-black/40 mt-1 truncate",children:a.url})]}),e.jsxs("div",{className:"flex items-center justify-between pt-2",children:[e.jsxs("button",{onClick:()=>{G(a),$(null)},className:"flex-1 mr-2 bg-[#7B2FFF] text-white py-2.5 rounded-xl text-[10px] font-black uppercase tracking-widest flex items-center justify-center gap-2 hover:brightness-110 transition",children:[e.jsx(pe,{className:"w-3.5 h-3.5"})," ⨠Criar Aula"]}),e.jsx("button",{onClick:()=>ie(a.id),className:"p-2.5 text-black/20 hover:text-red-500 hover:bg-red-50 rounded-xl transition",children:e.jsx(Y,{className:"w-4 h-4"})})]})]})]},a.id))})]}),J&&e.jsx("div",{className:"fixed inset-0 z-50 grid place-items-center p-4 bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white w-full max-w-md rounded-3xl p-8 shadow-2xl animate-in zoom-in duration-200",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-black",children:"Novo Link"}),e.jsx("button",{onClick:()=>v(!1),className:"p-2 hover:bg-black/5 rounded-full",children:e.jsx(F,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-black/40 block mb-2",children:"URL do VÃdeo (YouTube ou Instagram Reels)"}),e.jsx("input",{autoFocus:!0,value:i,onChange:a=>L(a.target.value),placeholder:"Cole o link do YouTube ou Instagram...",className:"w-full bg-black/[0.03] border border-transparent focus:border-[#0CA678]/40 focu
1s:bg-white rounded-2xl px-4 py-3 text-sm outline-none transition"})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-black/40 block mb-2",children:"Categoria"}),e.jsx("select",{value:T,onChange:a=>K(a.target.value),className:"w-full bg-black/[0.03] border border-transparent focus:bg-white rounded-2xl px-4 py-3 text-sm outline-none transition",children:g.map(a=>e.jsx("option",{value:a,children:a},a))})]}),e.jsx("button",{onClick:oe,disabled:V||!i,className:"w-full bg-[#0CA678] text-white py-4 rounded-2xl font-black uppercase tracking-widest text-xs shadow-lg shadow-[#0CA678]/20 disabled:opacity-50 transition",children:V?e.jsx(j,{className:"w-4 h-4 animate-spin mx-auto"}):"Salvar na Biblioteca"})]})]})}),ee&&e.jsx("div",{className:"fixed inset-0 z-50 grid place-items-center p-4 bg-black/60 backdrop-blur-sm",children:e.jsxs("div",{className:"bg-white w-full max-w-md rounded-[2rem] p-8 shadow-2xl",children:[e.jsxs("div",{className:"flex justify-between items-center mb-6",children:[e.jsx("h2",{className:"text-xl font-black",children:"Categorias"}),e.jsx("button",{onClick:()=>B(!1),className:"p-2 hover:bg-black/5 rounded-full",children:e.jsx(F,{className:"w-5 h-5"})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{value:y,onChange:a=>q(a.target.value),placeholder:"Nova categoria...",className:"flex-1 bg-black/[0.03] rounded-2xl px-4 py-3 text-sm outline-none"}),e.jsx("button",{onClick:te,className:"bg-black text-white px-6 rounded-2xl text-[10px] font-black uppercase",children:e.jsx(U,{className:"w-4 h-4"})})]}),e.jsx("div",{className:"max-h-[300px] overflow-y-auto space-y-2 pr-2 custom-scrollbar",children:g.map(a=>e.jsxs("div",{className:"flex items-center justify-between p-4 bg-black/[0.02] rounded-2xl border border-black/5",children:[e.jsx("span",{className:"text-sm font-bold text-black/70",children:a}),a!=="Geral"&&e.jsx("button",{onClick:()=>re(a),className:"text-black/20 hover:text-red-500 transition",children:e.jsx(Y,{className:"w-4 h-4"})})]},a))})]})]})}),o&&e.jsx("div",{className:"fixed inset-0 z-50 grid place-items-center p-4 bg-black/80 backdrop-blur-md overflow-y-auto",children:e.jsxs("div",{className:"bg-[#FFFBF3] w-full max-w-2xl rounded-[2.5rem] p-8 shadow-2xl relative my-8",children:[e.jsx("button",{onClick:()=>G(null),className:"absolute right-6 top-6 p-2 bg-black/5 hover:bg-black/10 rounded-full transition",children:e.jsx(F,{className:"w-5 h-5"})}),n?e.jsxs("div",{className:"space-y-6 max-h-[70vh] overflow-y-auto pr-2 custom-scrollbar",children:[e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-black",children:n.titulo}),e.jsxs("p",{className:"text-sm text-[#7B2FFF] font-bold",children:[n.serie," · ",n.duracao]})]}),e.jsxs("button",{className:"flex items-center gap-2 px-4 py-2 bg-black text-white rounded-xl text-[10px] font-black uppercase tracking-widest",children:[e.jsx(ye,{className:"w-4 h-4"})," Exportar DOCX"]})]}),e.jsxs("div",{className:"space-y-6 text-sm",children:[e.jsx(w,{title:"Habilidades BNCC",items:n.habilidades_bncc}),e.jsx(w,{title:"Objetivos",items:n.objetivos}),e.jsx(w,{title:"Metodologia",children:e.jsx("div",{className:"space-y-3",children:["introducao","desenvolvimento","fechamento"].map(a=>e.jsxs("div",{className:"p-4 bg-white rounded-2xl border border-black/5",children:[e.jsxs("p",{className:"text-[10px] font-black uppercase tracking-widest text-black/40 mb-1",children:[a," · ",n.metodologia[a].tempo]}),e.jsx("p",{className:"text-black/70",children:n.metodologia[a].descricao})]},a))})}),e.jsx(w,{title:"Avaliação",content:n.avaliacao})]})]}):e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("span",{className:"inline-block bg-[#7B2FFF]/10 text-[#7B2FFF] px-3 py-1 rounded-full text-[10px] font-black uppercase tracking-widest mb-2",children:"Transformação com IA"}),e.jsx("h2",{className:"text-2xl font-black",children:"Transformar vÃdeo em aula"}),e.jsx("p",{className:"text-sm text-black/60",children:"A IA vai analisar o conteúdo do vÃdeo e criar um plano de aula completo alinhado à BNCC."})]}),e.jsxs("div",{className:"flex items-center gap-4 bg-white p-4 rounded-3xl border border-black/5",children:[e.jsx("img",{src:o.thumbnail_url||"",className:"w-24 aspect-video rounded-xl object-cover"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-black text-sm text-black/80 line-clamp-1",children:o.title}),e.jsx("p",{className:"text-[10px] text-black/40 truncate",children:o.url})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-black/40 block mb-2",children:"Série / Ano"}),e.jsxs("select",{value:b,onChange:a=>ae(a.target.value),className:"w-full bg-black/[0.03] border border-transparent focus:bg-white rounded-2xl px-4 py-3 text-sm outline-none transition",children:[e.jsx("option",{value:"",children:"Selecione..."}),Ae.map(a=>e.jsx("option",{value:a,children:a},a))]})]}),e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[10px] font-black uppercase tracking-widest text-black/40 block mb-2",children:"Tempo de Aula"}),e.jsx("select",{value:I,onChange:a=>se(a.target.value),className:"w-full bg-black/[0.03] border border-transparent focus:bg-white rounded-2xl px-4 py-3 text-sm outline-none transition",children:Ee.map(a=>e.jsx("option",{value:a,children:a},a))})]})]}),e.jsx("button",{onClick:ne,disabled:M||!b,className:"w-full bg-gradient-to-r from-[#FDAA3E] via-[#EE5A70] to-[#7B2FFF] text-white py-5 rounded-[1.5rem] font-black uppercase tracking-widest text-sm shadow-xl shadow-[#7B2FFF]/30 disabled:opacity-50 transition hover:scale-[1.02]",children:M?e.jsxs("span",{className:"flex items-center justify-center gap-3",children:[e.jsx(j,{className:"w-5 h-5 animate-spin"}),"Analisando vÃdeo..."]}):"Gerar Plano de Aula Completo"})]})]})})]})}function w({title:c,items:u,content:p,children:k}){return e.jsxs("div",{className:"space-y-2",children:[e.jsx("h3",{className:"text-[10px] font-black uppercase tracking-[0.2em] text-[#FDAA3E]",children:c}),u&&e.jsx("ul",{className:"space-y-1",children:u.map((N,h)=>e.jsxs("li",{className:"flex gap-2 text-black/70",children:[e.jsx("span",{className:"text-[#7B2FFF]",children:"â¢"})," ",N]},h))}),p&&e.jsx("p",{className:"text-black/70",children:p}),k]})}export{De as component};
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.