1import{j as e,a9 as G,aa as Ve,ab as Xe,ac as Ze,ad as et,P as tt,M as at,W as nt,T as rt}from"./index-D_T1XJ3U.js";import{r as h,b as He,d as ot}from"./vendor-react-Bxgxa9T6.js";const re=[{clave:"starter",nombre:"Starter"},{clave:"pro",nombre:"Pro"},{clave:"plus",nombre:"MAX"}],st=new Set(re.map(a=>a.clave)),it={max:"plus"};function Ge(a){if(a==null)return null;let t=a;if(typeof a=="string"){if(!a.trim())return null;try{t=JSON.parse(a)}catch{return[]}}if(!Array.isArray(t))return[];const s=new Set(t.map(i=>String(i).trim().toLowerCase()).map(i=>it[i]??i).filter(i=>st.has(i))),c=re.map(i=>i.clave).filter(i=>s.has(i));return c.length===re.length?null:c}function oe(a){if(a&&a.length===0)return"ningún plan";const t=(a??re.map(s=>s.clave)).map(s=>{var c;return((c=re.find(i=>i.clave===s))==null?void 0:c.nombre)||s});return t.length<=1?t.join(""):`${t.slice(0,-1).join(", ")} y ${t[t.length-1]}`}function Ue(a){var i;if(!a)return null;const t=re.map(r=>r.clave),s=Math.min(...a.map(r=>t.indexOf(r))),c=t.slice(s+1).find(r=>!a.includes(r));return c?((i=re.find(r=>r.clave===c))==null?void 0:i.nombre)||c:null}function we({titulo:a,onCerrar:t,children:s,ancho:c=560}){return h.useEffect(()=>{const i=r=>{r.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]),He.createPortal(e.jsx("div",{onClick:t,role:"dialog","aria-modal":"true","aria-label":a,style:{position:"fixed",inset:0,zIndex:1100,background:"rgba(15,18,30,.55)",display:"flex",alignItems:"flex-start",justifyContent:"center",overflowY:"auto",padding:"clamp(12px, 6vh, 64px) 16px"},children:e.jsxs("div",{onClick:i=>i.stopPropagation(),style:{width:"100%",maxWidth:c,background:"var(--bg-card)",borderRadius:16,boxShadow:"0 30px 70px -20px rgba(0,0,0,.45)",overflow:"hidden"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"16px 18px",borderBottom:"1px solid var(--border)"},children:[e.jsx("div",{style:{flex:1,fontSize:16,fontWeight:800,color:"var(--text-primary)"},children:a}),e.jsx("button",{type:"button",onClick:t,"aria-label":"Cerrar",style:{width:32,height:32,borderRadius:"50%",border:"1px solid var(--border)",background:"var(--bg-card)",color:"var(--text-secondary)",cursor:"pointer",fontSize:18,lineHeight:1},children:"Ã"})]}),e.jsx("div",{style:{padding:18},children:s})]})}),document.body)}const xe={width:"100%",boxSizing:"border-box",padding:"10px 12px",borderRadius:10,border:"1px solid var(--border)",background:"var(--bg-input)",color:"var(--text-primary)",fontSize:14,fontFamily:"inherit"},ae={display:"block",fontSize:12.5,fontWeight:700,color:"var(--text-secondary)",margin:"0 0 6px"},ke={border:"none",background:"var(--accent-blue)",color:"#fff",fontWeight:700,fontSize:14,padding:"10px 18px",borderRadius:11,cursor:"pointer",fontFamily:"inherit"},ne={border:"1px solid var(--border)",background:"var(--bg-card)",color:"var(--text-primary)",fontWeight:700,fontSize:13.5,padding:"9px 16px",borderRadius:11,cursor:"pointer",fontFamily:"inherit"};function Q({tono:a,children:t}){const s=a==="error"?"danger":a==="aviso"?"warning":"success";return e.jsx("div",{role:a==="error"?"alert":"status",style:{padding:"10px 12px",borderRadius:10,fontSize:13,lineHeight:1.5,background:`var(--notice-${s}-bg)`,border:`1px solid var(--notice-${s}-border)`,color:`var(--notice-${s}-text)`},children:t})}function lt({inicial:a,onGuardar:t,onCerrar:s}){const[c,i]=h.useState((a==null?void 0:a.titulo)||""),[r,p]=h.useState(null),[g,S]=h.useState(!1);h.useEffect(()=>()=>{r!=null&&r.vista&&URL.revokeObjectURL(r.vista)},[r==null?void 0:r.vista]);const L=(r==null?void 0:r.vista)||(g?null:(a==null?void 0:a.icono)||null),[T,z]=h.useState((a==null?void 0:a.descripcion)||""),[x,d]=h.useState(()=>new Set((a==null?void 0:a.planes)??re.map(w=>w.clave))),[u,l]=h.useState(""),[j,R]=h.useState(!1),O=Ge([...x]),k=Ue(O),q=w=>d(P=>{const M=new Set(P);return M.has(w)?M.delete(w):M.add(w),M}),A=async()=>{if(!c.trim()){l("Ponle un nombre al curso.");return}if(x.size===0){l("Elige al menos un plan que pueda ver el curso.");return}R(!0),l("");try{const w=r?await Ve(r.archivo):g?"":void 0;await t(c.trim(),T.trim(),O,w),s()}catch(w){l((w==null?void 0:w.message)||"No se pudo guardar.")}finally{R(!1)}},E=w=>{if(w){if(!/^image\/(jpe?g|png|webp)$/i.test(w.type)){l("El Ãcono debe ser JPG, PNG o WebP.");return}if(w.size>5*1024*1024){l("El Ãcono debe pesar menos de 5 MB.");return}l(""),S(!1),p({archivo:w,vista:URL.createObjectURL(w)})}};return e.jsx(we,{titulo:a?"Editar curso":"Nuevo curso",onCerrar:s,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"acad-curso-titulo",style:ae,children:"Nombre del curso"}),e.jsx("input",{id:"acad-curso-titulo",value:c,onChange:w=>i(w.target.value),maxLength:120,placeholder:"Ej.: Meta Ads para contraentrega",style:xe,autoFocus:!0})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"acad-curso-desc",style:ae,children:"De qué trata (una lÃnea)"}),e.jsx("input",{id:"acad-curso-desc",value:T,onChange:w=>z(w.target.value),maxLength:400,placeholder:"Ej.: Campañas que escalan sin quemar el presupuesto.",style:xe})]}),e.jsxs("div",{children:[e.jsx("span",{style:ae,children:"Ãcono del curso (opcional)"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[e.jsx("span",{style:{width:48,height:48,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",background:"var(--bg-tertiary)",border:"1px solid var(--border)",color:"var(--text-muted)",fontSize:11,fontWeight:700},children:L?e.jsx("img",{src:L,alt:"Ãcono del curso",style:{width:38,height:38,objectFit:"contain",display:"block"}}):"Auto"}),e.jsx("label",{htmlFor:"acad-curso-icono",style:{...ne,display:"inline-flex",alignItems:"center",cursor:"pointer"},children:L?"Cambiar Ãcono":"Subir Ãcono"}),e.jsx("input",{id:"acad-curso-icono",type:"file",accept:"image/png,image/jpeg,image/webp",style:{display:"none"},onChange:w=>{var P;E((P=w.target.files)==null?void 0:P[0]),w.target.value=""}}),L&&e.jsx("button",{type:"button",onClick:()=>{p(null),S(!0)}
1,style:ne,children:"Quitar"})]}),e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginTop:6},children:"Un PNG cuadrado con fondo transparente se ve mejor. Sin Ãcono, la Academia pone uno según el nombre del curso."})]}),e.jsxs("fieldset",{style:{border:"none",margin:0,padding:0},children:[e.jsx("legend",{style:ae,children:"¿Qué planes pueden ver este curso?"}),e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:re.map(w=>{const P=x.has(w.clave);return e.jsxs("label",{htmlFor:`acad-plan-${w.clave}`,style:{display:"inline-flex",alignItems:"center",gap:8,padding:"8px 14px",borderRadius:999,cursor:"pointer",fontSize:13.5,fontWeight:700,border:`1.5px solid ${P?"var(--accent-blue)":"var(--border)"}`,background:P?"var(--notice-info-bg)":"var(--bg-card)",color:P?"var(--accent-blue)":"var(--text-secondary)"},children:[e.jsx("input",{id:`acad-plan-${w.clave}`,type:"checkbox",checked:P,onChange:()=>q(w.clave),style:{accentColor:"var(--accent-blue)",margin:0}}),w.nombre]},w.clave)})}),e.jsx("div",{role:"status",style:{fontSize:12.5,color:"var(--text-muted)",marginTop:8,lineHeight:1.5},children:x.size===0?"Marca al menos un plan.":O===null?"Lo ven todos los planes.":`Lo ven ${oe(O)}. Los demás ven el curso con candado y no pueden abrir sus clases.`}),k&&e.jsx("div",{style:{marginTop:8}
1,children:e.jsxs(Q,{tono:"aviso",children:["Ojo: ",k," no lo verÃa, aunque es un plan más completo."]})}),O!==null&&((a==null?void 0:a.sinProteger)||0)>0&&e.jsx("div",{style:{marginTop:8},children:e.jsxs(Q,{tono:"aviso",children:[a.sinProteger===1?"Una clase de este curso tiene":`${a.sinProteger} clases de este curso tienen`," un enlace que no vence (se subieron antes o siguen en Bunny). Quien ya lo tenÃa lo puede seguir abriendo. Protégelas en «Protección de los videos»."]})})]}),u&&e.jsx(Q,{tono:"error",children:u}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx("button",{type:"button",onClick:s,style:ne,children:"Cancelar"}),e.jsx("button",{type:"button",onClick:A,disabled:j,style:{...ke,opacity:j?.7:1},children:j?"Guardandoâ¦":"Guardar"})]})]})})}function ct({cursoTitulo:a,inicial:t,onGuardar:s,onCerrar:c}){const[i,r]=h.useState(t||""),[p,g]=h.useState(""),[S,L]=h.useState(!1),T=async()=>{if(!i.trim()){g("Ponle un nombre a la sección.");return}L(!0),g("");try{await s(i.trim()),c()}catch(z){g((z==null?void 0:z.message)||"No se pudo guardar.")}finally{L(!1)}};return e.jsx(we,{titulo:t?"Renombrar sección":`Nueva sección · ${a}`,onCerrar:c,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"acad-seccion-titulo",style:ae,children:"Nombre de la sección"}),e.jsx("input",{id:"acad-seccion-titulo",value:i,onChange:z=>r(z.target.value),maxLength:120,placeholder:"Ej.: Cómo hacer campañas en Meta",style:xe,autoFocus:!0,onKeyDown:z=>{z.key==="Enter"&&T()}}),e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)",marginTop:6},children:"Se ve como un subtÃtulo dentro del curso, con sus clases debajo."})]}),p&&e.jsx(Q,{tono:"error",children:p}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx("button",{type:"button",onClick:c,style:ne,children:"Cancelar"}),e.jsx("button",{type:"button",onClick:T,disabled:S,style:{...ke,opacity:S?.7:1},children:S?"Guardandoâ¦":"Guardar"})]})]})})}function Qe({id:a,secciones:t,valor:s,onCambio:c,deshabilitado:i}){return t.length===0?null:e.jsxs("div",{children:[e.jsx("label",{htmlFor:a,style:ae,children:"Sección (opcional)"}),e.jsxs("select",{id:a,value:s??"",disabled:i,onChange:r=>c(r.target.value?Number(r.target.value):null),style:xe,children:[e.jsx("option",{value:"",children:"Sin sección"}),t.map(r=>e.jsx("option",{value:r.id,children:r.titulo},r.id))]})]})}const dt=a=>{const t=a.replace(/\.[a-z0-9]{2,4}$/i,"").replace(/^\s*\d{1,3}\s*[.\-)_·:]\s*/,"").replace(/[_-]+/g," ").replace(/\s+/g," ").trim();return t?t.charAt(0).toUpperCase()+t.slice(1):""},ut=a=>`${(a/(1024*1024)).toFixed(a>100*1024*1024?0:1)} MB`,pt=a=>`${Math.floor(a/60)}:${String(Math.round(a%60)).padStart(2,"0")}`;function ht({cursoId:a,cursoTitulo:t,secciones:s=[],seccionInicial:c=null,onCerrar:i}){const[r,p]=h.useState(c),[g,S]=h.useState(null),[L,T]=h.useState(""),[z,x]=h.useState(""),[d,u]=h.useState(null),[l,j]=h.useState(!1),[R,O]=h.useState(!1),[k,q]=h.useState(""),[A,E]=h.useState("");h.useEffect(()=>()=>{d!=null&&d.vista&&URL.revokeObjectURL(d.vista)},[d==null?void 0:d.vista]);const w=async M=>{if(E(""),q(""),u(null),S(null),!!M){if(/\.mov$/i.test(M.name)||M.type==="video/quicktime"){E("Los .mov del iPhone se ven en negro en muchos celulares. Exporta el video en MP4 (H.264) y súbelo de nuevo.");return}if(!/\.(mp4|m4v)$/i.test(M.name)&&M.type!=="video/mp4"){E("Solo se pueden subir videos MP4.");return}j(!0);try{const J=await Xe(M);if(J==="hevc"){E("Este video está en HEVC (el formato del iPhone) y en Chrome de Windows y en muchos Android se ve negro. Expórtalo en H.264: en CapCut, Exportar â Códec: H.264.");return}J!=="h264"&&q("No pudimos confirmar que el video esté en H.264. Si después no se ve en algún celular, expórtalo en H.264 y súbelo de nuevo.");const V=await Ze(M).catch(()=>({duracion:0,portada:null,ancho:0,alto:0}));u({duracion:V.duracion,portada:V.portada,vista:V.portada?URL.createObjectURL(V.portada):null}),S(M),L||T(dt(M.name))}catch{E("No pudimos leer este video. Expórtalo de nuevo en MP4 (H.264) y vuelve a intentarlo.")}finally{j(!1)}}}
1,P=async()=>{if(g){if(!L.trim()){E("Ponle un tÃtulo a la clase.");return}E(""),O(!0);try{await et(g,{cursoId:a,seccionId:r,titulo:L.trim(),descripcion:z.trim(),duracion:(d==null?void 0:d.duracion)||0,portada:(d==null?void 0:d.portada)||null}),i()}catch(M){E(M!=null&&M.message?`No se pudo empezar: ${M.message}`:"No se pudo empezar la subida. Intenta de nuevo."),O(!1)}}};return e.jsx(we,{titulo:`Subir clase · ${t}`,onCerrar:i,ancho:620,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsxs("label",{htmlFor:"acad-archivo",style:{display:"grid",gridTemplateColumns:d!=null&&d.vista?"180px 1fr":"1fr",gap:14,alignItems:"center",padding:14,borderRadius:14,border:"1.5px dashed var(--border)",background:"var(--bg-tertiary)",cursor:"pointer"},children:[(d==null?void 0:d.vista)&&e.jsx("img",{src:d.vista,alt:"",style:{width:"100%",aspectRatio:"16 / 9",objectFit:"cover",borderRadius:10,border:"1px solid var(--border)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)"},children:l?"Revisando el videoâ¦":g?g.name:"Elige el video (MP4)"}),e.jsx("div",{style:{fontSize:12.5,color:"var(--text-secondary)",marginTop:4},children:g?`${ut(g.size)}${d!=null&&d.duracion?` · ${pt(d.duracion)}`:""} · se sube tal cual, con su calidad original`:"MP4 en H.264. Sin lÃmite de tamaño: una clase de una hora también sirve."})]}),e.jsx("input",{id:"acad-archivo",type:"file",accept:"video/mp4,.mp4,.m4v",disabled:R,onChange:M=>{var J;return w(((J=M.target.files)==null?void 0:J[0])||null)},style:{display:"none"}})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"acad-clase-titulo",style:ae,children:"TÃtulo de la clase"}),e.jsx("input",{id:"acad-clase-titulo",value:L,onChange:M=>T(M.target.value),maxLength:160,disabled:R,placeholder:"Ej.: Estructura de campaña que escala",style:xe})]}),e.jsx(Qe,{id:"acad-clase-seccion",secciones:s,valor:r,onCambio:p,deshabilitado:R}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"acad-clase-desc",style:ae,children:"Qué va a aprender (opcional)"}),e.jsx("textarea",{id:"acad-clase-desc",value:z,onChange:M=>x(M.target.value),maxLength:2e3,disabled:R,rows:3,style:{...xe,resize:"vertical"}})]}),k&&e.jsx(Q,{tono:"aviso",children:k}),A&&e.jsx(Q,{tono:"error",children:A}),g&&!A&&e.jsx("div",{style:{fontSize:12.5,color:"var(--text-muted)"},children:"Se sube en segundo plano: puedes cerrar este cuadro y seguir usando Lumy. El avance se ve abajo a la izquierda."}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx("button",{type:"button",onClick:i,disabled:R,style:ne,children:"Cerrar"}),e.jsx("button",{type:"button",onClick:P,disabled:!g||R||l,style:{...ke,opacity:!g||R||l?.6:1,cursor:!g||R?"default":"pointer"},children:R?"Preparandoâ¦":"Subir clase"})]})]})})}function xt({clase:a,planesDelCurso:t=null,secciones:s=[],cursoId:c,cursos:i=[],onListo:r,onCerrar:p}){const[g,S]=h.useState(a.seccion),[L,T]=h.useState(c),z=i.find(y=>y.id===L),x=c!=null&&L!=null&&L!==c,d=x?(z==null?void 0:z.secciones)||[]:s,u=x?(z==null?void 0:z.planes)??null:t,[l,j]=h.useState(a.titulo),[R,O]=h.useState(a.descripcion),[k,q]=h.useState(null),A=re.map(y=>y.clave),[E,w]=h.useState(!!a.planesPropios),[P,M]=h.useState(()=>new Set(a.planesPropios?a.planes??A:u??A)),[J,V]=h.useState(""),[U,de]=h.useState(!1);h.useEffect(()=>()=>{k!=null&&k.vista&&URL.revokeObjectURL(k.vista)},[k==null?void 0:k.vista]);const X=Ge([...P]),se=E?X:u,Z=new Set(u??A),ie=new Set(X??A),_=E&&[...ie].some(y=>!Z.has(y)),ee=E&&[...Z].some(y=>!ie.has(y)),le=E?Ue(X):null,ue=y=>M(F=>{const Y=new Set(F);return Y.has(y)?Y.delete(y):Y.add(y),Y}),pe=async()=>{if(!l.trim()){V("Ponle un tÃtulo a la clase.");return}if(E&&P.size===0){V("Elige al menos un plan para esta clase, o déjala como el curso.");return}de(!0),V("");try{const y={titulo:l.trim(),descripcion:R.trim(),seccion_id:g,planes:E?A.filter(F=>P.has(F)):null};x&&(y.curso_id=L),k&&(y.poster_url=await Ve(k.archivo)),await G(`/api/academia/admin/clases/${a.id}`,"PATCH",y),r(),p()}catch(y){V((y==null?void 0:y.message)||"No se pudo guardar.")}finally{de(!1)}},H=y=>
1({display:"flex",alignItems:"flex-start",gap:10,padding:"10px 12px",borderRadius:12,cursor:"pointer",border:`1.5px solid ${y?"var(--accent-blue)":"var(--border)"}`,background:y?"var(--notice-info-bg)":"var(--bg-card)"});return e.jsx(we,{titulo:"Editar clase",onCerrar:p,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsxs("label",{htmlFor:"acad-portada",style:{display:"grid",gridTemplateColumns:"180px 1fr",gap:14,alignItems:"center",cursor:"pointer"},children:[k!=null&&k.vista||a.poster?e.jsx("img",{src:(k==null?void 0:k.vista)||a.poster||"",alt:"",style:{width:"100%",aspectRatio:"16 / 9",objectFit:"cover",borderRadius:10,border:"1px solid var(--border)"}}):e.jsx("div",{style:{width:"100%",aspectRatio:"16 / 9",borderRadius:10,border:"1px dashed var(--border)",background:"var(--bg-tertiary)"}}),e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:14,fontWeight:700,color:"var(--text-primary)"},children:"Cambiar portada"}),e.jsx("div",{style:{fontSize:12.5,color:"var(--text-secondary)",marginTop:4},children:"JPG, PNG o WebP, en horizontal (16:9)."})]}),e.jsx("input",{id:"acad-portada",type:"file",accept:"image/jpeg,image/png,image/webp",style:{display:"none"},onChange:y=>{var Y;const F=(Y=y.target.files)==null?void 0:Y[0];F&&q({archivo:F,vista:URL.createObjectURL(F)})}})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"acad-editar-titulo",style:ae,children:"TÃtulo"}),e.jsx("input",{id:"acad-editar-titulo",value:l,onChange:y=>j(y.target.value),maxLength:160,style:xe})]}),i.length>1&&c!=null&&e.jsxs("div",{children:[e.jsx("label",{htmlFor:"acad-editar-curso",style:ae,children:"Curso"}),e.jsx("select",{id:"acad-editar-curso",value:L??"",onChange:y=>{T(Number(y.target.value)),S(null)},style:xe,children:i.map(y=>e.jsx("option",{value:y.id,children:y.titulo},y.id))}),x&&e.jsxs("div",{role:"status",style:{fontSize:12.5,color:"var(--text-muted)",marginTop:6},children:["La clase pasa a «",z==null?void 0:z.titulo,"» y queda de última. Si sigue al curso, la ven los planes de ese curso."]})]}),e.jsx(Qe,{id:"acad-editar-seccion",secciones:d,valor:g,onCambio:S}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"acad-editar-desc",style:ae,children:"Qué va a aprender"}),e.jsx("textarea",{id:"acad-editar-desc",value:R,onChange:y=>O(y.target.value),maxLength:2e3,rows:3,style:{...xe,resize:"vertical"}})]}),e.jsxs("fieldset",{style:{border:"none",margin:0,padding:0,display:"grid",gap:8},children:[e.jsx("legend",{style:ae,children:"¿Quién ve esta clase?"}),e.jsxs("label",{htmlFor:"acad-clase-como-curso",style:H(!E),children:[e.jsx("input",{id:"acad-clase-como-curso",type:"radio",name:"acad-clase-planes",checked:!E,onChange:()=>w(!1),style:{accentColor:"var(--accent-blue)",margin:"3px 0 0"}}),e.jsxs("span",{style:{display:"grid",gap:2},children:[e.jsx("span",{style:{fontSize:13.5,fontWeight:700,color:"var(--text-primary)"},children:"Como el curso"}),e.jsxs("span",{style:{fontSize:12.5,color:"var(--text-secondary)"},children:[u?`La ven ${oe(u)}.`:"La ven todos los planes."," Si cambias los planes del curso, cambia con él."]})]})]}),e.jsxs("label",{htmlFor:"acad-clase-propios",style:H(E),children:[e.jsx("input",{id:"acad-clase-propios",type:"radio",name:"acad-clase-planes",checked:E,onChange:()=>w(!0),style:{accentColor:"var(--accent-blue)",margin:"3px 0 0"}}),e.jsxs("span",{style:{display:"grid",gap:2},children:[e.jsx("span",{style:{fontSize:13.5,fontWeight:700,color:"var(--text-primary)"},children:"Solo estos planes"}),e.jsx("span",{style:{fontSize:12.5,color:"var(--text-secondary)"},children:"Para cerrarla más que el curso, o para dejarla abierta como clase de muestra."})]})]}),E&&e.jsxs("div",{style:{display:"grid",gap:8,paddingLeft:4},children:[e.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:re.map(y=>{const F=P.has(y.clave);return e.jsxs("label",{htmlFor:`acad-clase-plan-${y.clave}`,style:{display:"inline-flex",alignItems:"center",gap:8,padding:"7px 13px",borderRadius:999,cursor:"pointer",fontSize:13.5,fontWeight:700,border:`1.5px solid ${F?"var(--accent-blue)":"var(--border)"}`,background:F?"var(--notice-info-bg)":"var(--bg-card)",color:F?"var(--accent-blue)":"var(--text-secondary)"},children:[e.jsx("input",{id:`acad-clase-plan-${y.clave}`,type:"checkbox",checked:F,onChange:()=>ue(y.clave),style:{accentColor:"var(--accent-blue)",margin:0}}),y.nombre]},y.clave)})}),e.jsxs("div",{role:"status",style:{fontSize:12.5,color:"var(--text-muted)",lineHeight:1.5},children:[P.size===0?"Marca al menos un plan.":`La ven ${X?oe(X):"todos los planes"}.`,P.size>0&&_?" Sirve de clase de muestra: la ven aunque no tengan el plan del curso.":"",P.size>0&&ee?" Los demás la ven con candado y no la pueden abrir.":""]}
1),le&&e.jsxs(Q,{tono:"aviso",children:["Ojo: ",le," no la verÃa, aunque es un plan más completo."]})]}),se!==null&&a.sinProteger&&e.jsx(Q,{tono:"aviso",children:"Esta clase tiene un enlace que no vence (se subió antes o sigue en Bunny). Quien ya lo tenÃa lo puede seguir abriendo. Protégela desde «Protección de los videos»."})]}),J&&e.jsx(Q,{tono:"error",children:J}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx("button",{type:"button",onClick:p,style:ne,children:"Cancelar"}),e.jsx("button",{type:"button",onClick:pe,disabled:U,style:{...ke,opacity:U?.7:1},children:U?"Guardandoâ¦":"Guardar"})]})]})})}function gt({onCambio:a}){const[t,s]=h.useState(null),[c,i]=h.useState(""),[r,p]=h.useState(!1),g=async()=>{try{const l=await fetch("/api/academia/admin/proteccion"),j=await l.json().catch(()=>null);if(!l.ok||!j)throw new Error((j==null?void 0:j.message)||"No se pudo revisar la protección.");return s(j),j}catch(l){return i((l==null?void 0:l.message)||"No se pudo revisar la protección."),null}};h.useEffect(()=>{g()},[]);const S=!!(t!=null&&t.trabajo.corriendo);h.useEffect(()=>{if(!S)return;const l=setInterval(async()=>{const j=await g();j&&!j.trabajo.corriendo&&(a==null||a())},2e3);return()=>clearInterval(l)},[S]);const L=async(l=!1)=>{if(!(l&&!window.confirm(`¿Pasar al almacenamiento privado las clases que siguen en Bunny? 2 3Se baja cada video de Bunny y se sube al privado; en Lumy se siguen viendo igual. Bunny no se toca: sus videos siguen allá hasta que decidas borrarlos.`))){p(!0),i("");try{await G("/api/academia/admin/proteger","POST",l?{bunny:!0}:{}),await g()}catch(j){i((j==null?void 0:j.message)||"No se pudo empezar.")}finally{p(!1)}}},[T,z]=h.useState(""),x=async()=>{var l;if(t&&window.confirm(`¿Borrar de Bunny ${t.bunnyPorBorrar===1?"la clase que ya está protegida":`las ${t.bunnyPorBorrar} clases que ya están protegidas`}? 4 5Es lo único que hace que sus enlaces viejos de Bunny dejen de servir. En Lumy se siguen viendo igual, desde el almacenamiento privado. No se puede deshacer. La intro del inicio y el video del evento no se tocan.`)){p(!0),i(""),z("");try{const j=await G("/api/academia/admin/bunny/borrar","POST",{confirmar:!0});z(`${j.borradas} ${j.borradas===1?"borrada":"borradas"} de Bunny${(l=j.fallos)!=null&&l.length?`; ${j.fallos.length} no se pudieron (${j.fallos.map(R=>R.titulo).join(", ")})`:""}.`),await g(),a==null||a()}catch(j){i((j==null?void 0:j.message)||"No se pudo borrar de Bunny.")}finally{p(!1)}}};if(!t)return c?e.jsx("div",{style:{margin:"6px 0 16px"},children:e.jsx(Q,{tono:"error",children:c})}):null;const d=t.trabajo,u=t.privadoListo;return e.jsxs("section",{"aria-label":"Protección de los videos",style:{display:"grid",gap:10,padding:"14px 16px",margin:"6px 0 16px",borderRadius:14,background:"var(--bg-card)",border:"1px solid var(--border)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[e.jsx("span",{style:{fontSize:14,fontWeight:800,color:"var(--text-primary)"},children:"Protección de los videos"}),e.jsx("span",{style:{fontSize:12,fontWeight:700,padding:"3px 10px",borderRadius:999,border:`1px solid var(--notice-${u?"success":"warning"}-border)`,background:`var(--notice-${u?"success":"warning"}-bg)`,color:`var(--notice-${u?"success":"warning"}-text)`},children:u?`Enlaces que vencen en ${t.horasDelEnlace} h`:"Enlaces que no vencen"})]}),e.jsxs("div",{style:{fontSize:13,lineHeight:1.55,color:"var(--text-secondary)"},children:["Cada curso solo entrega sus videos a los planes que elegiste; quien no tiene el plan no recibe nada, aunque quite el candado de la pantalla.",u?` Además, cada vez que alguien abre una clase recibe un enlace que deja de servir a las ${t.horasDelEnlace} horas: copiarlo y pasarlo no sirve.`:" Falta un paso: hoy el enlace de un video no vence, asà que si un alumno lo copia y lo pasa, se puede abrir sin cuenta."]}),!u&&e.jsxs("div",{style:{fontSize:13,lineHeight:1.6,color:"var(--text-secondary)"},children:[e.jsx("b",{style:{color:"var(--text-primary)"},children:"Para cerrarlo:"})," en Cloudflare, R2 â ",e.jsx("b",{children:"Create bucket"})," con el nombre ",e.jsx("code",{children:"lumy-academia"})," (sin acceso público). Luego en Railway agrega la variable ",e.jsx("code",{children:"ACADEMIA_R2_BUCKET_PRIVADO"})," = ",e.jsx("code",{children:"lumy-academia"}),".",t.motivo&&!/ACADEMIA_R2_BUCKET_PRIVADO/.test(t.motivo)&&e.jsx("div",{style:{marginTop:6},children:e.jsx(Q,{tono:"aviso",children:t.motivo})})]}),e.jsxs("div",{style:{display:"flex",gap:16,flexWrap:"wrap",fontSize:12.5,color:"var(--text-muted)",fontVariantNumeric:"tabular-nums"},children:[e.jsxs("span",{children:[e.jsx("b",{style:{color:"var(--text-primary)"},children:t.privados})," protegidos"]}),e.jsxs("span",{children:[e.jsx("b",{style:{color:t.publicos?"var(--warning)":"var(--text-primary)"},children:t.publicos})," con enlace que no vence"]}),t.bunny>0&&e.jsxs("span",{children:[e.jsx("b",{style:{color:"var(--warning)"},children:t.bunny})," en Bunny"]}),t.porBorrar>0&&e.jsxs("span",{children:[e.jsx("b",{style:{color:"var(--warning)"},children:t.porBorrar})," copias públicas por borrar"]})]}),u&&t.publicos+t.porBorrar>0&&!d.corriendo&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[e.jsx("button",{type:"button",onClick:()=>L(),disabled:r,style:{...ke,padding:"8px 14px",fontSize:13,opacity:r?.7:1},children:r?"Empezandoâ¦":t.publicos>0?`Proteger ${t.publicos===1?"el video":`los ${t.publicos} videos`}`:"Terminar de borrar las copias públicas"}),e.jsx("span",{style:{fontSize:12.5,color:"var(--text-muted)"},children:"Se pasan al almacenamiento privado de a uno; se siguen viendo igual. Lo de Bunny no se toca."})]}),u&&t.bunny>
50&&!d.corriendo&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap",fontSize:12.5,color:"var(--text-muted)"},children:[e.jsxs("span",{children:[t.bunny===1?"La clase de Bunny se queda":`Las ${t.bunny} clases de Bunny se quedan`," como ",t.bunny===1?"está":"están",". Opcional:"]}),e.jsx("button",{type:"button",onClick:()=>L(!0),disabled:r,style:{...ne,padding:"6px 12px",fontSize:12.5},children:"Pasarlas también al privado"})]}),u&&t.bunnyPorBorrar>0&&!d.corriendo&&e.jsxs("div",{style:{display:"grid",gap:8,padding:"10px 12px",borderRadius:10,background:"var(--bg-tertiary)",border:"1px solid var(--border)"},children:[e.jsxs("div",{style:{fontSize:13,lineHeight:1.55,color:"var(--text-secondary)"},children:[e.jsxs("b",{style:{color:"var(--text-primary)"},children:[t.bunnyPorBorrar===1?"Una clase ya protegida sigue":`${t.bunnyPorBorrar} clases ya protegidas siguen`," en Bunny."]})," Quien guardó su enlace de Bunny la puede seguir viendo sin plan, porque Bunny no lo pide. Borrarlas de Bunny lo cierra; en Lumy se siguen viendo desde el privado."]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[e.jsx("button",{type:"button",onClick:x,disabled:r||!t.llaveDeBunny,style:{...ne,padding:"7px 13px",fontSize:13,color:"var(--danger)",opacity:r||!t.llaveDeBunny?.6:1},children:"Borrarlas de Bunny"}),!t.llaveDeBunny&&e.jsx("span",{style:{fontSize:12.5,color:"var(--text-muted)"},children:"Falta BUNNY_STREAM_API_KEY en Railway."})]}),T&&e.jsx(Q,{tono:"ok",children:T})]}),d.corriendo&&e.jsxs("div",{role:"status",style:{fontSize:13,fontWeight:700,color:"var(--text-secondary)",fontVariantNumeric:"tabular-nums"},children:["Protegiendo ",Math.min(d.hechos+d.fallos.length+1,d.total)," de ",d.total,"⦠puedes seguir usando Lumy."]}),!d.corriendo&&d.terminado&&d.total>0&&e.jsxs(Q,{tono:d.fallos.length?"aviso":"ok",children:[d.fallos.length===0?`Listo: ${d.hechos} ${d.hechos===1?"video protegido":"videos protegidos"}.`:`${d.hechos} protegidos y ${d.fallos.length} sin proteger:`,d.fallos.length>0&&e.jsx("ul",{style:{margin:"6px 0 0",paddingLeft:18},children:d.fallos.map(l=>e.jsxs("li",{children:[l.titulo,": ",l.motivo]},l.id))}),d.sinCache>0&&e.jsxs("div",{style:{marginTop:6},children:[d.sinCache===1?"Uno":d.sinCache," puede seguir abriendo un tiempo desde la caché de Cloudflare con su enlace viejo."]})]}),t.bunny>0&&!u&&e.jsxs("div",{style:{fontSize:12.5,lineHeight:1.55,color:"var(--text-muted)"},children:[t.bunny===1?"La clase que sigue en Bunny se entrega":`Las ${t.bunny} clases que siguen en Bunny se entregan`," solo a quien tiene el plan, pero su enlace de Bunny no vence y ya se repartió: déjalas para todos los planes. Los cursos que quieras solo para algunos planes, súbelos aquÃ."]}),c&&e.jsx(Q,{tono:"error",children:c})]})}const ft=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;async function Je(a){try{const t=await crypto.subtle.digest("SHA-256",new TextEncoder().encode(String(a).trim().toLowerCase()));return`b${[...new Uint8Array(t)].map(s=>s.toString(16).padStart(2,"0")).join("").slice(0,16)}`}catch{return null}}const me={vistas:"academia_watched_v1",posiciones:"academia_posiciones_v1",ultima:"academia_ultima_v1"},Le=(a,t,s)=>{try{const c=a.getItem(t);return c?JSON.parse(c):s}catch{return s}};async function mt(a){const t=Le(a,me.vistas,[]),s=Le(a,me.posiciones,{}),c=Le(a,me.ultima,null),i=new Set([...Array.isArray(t)?t:[],...Object.keys(s||{}),...c!=null&&c.clave?[c.clave]:[]].filter(p=>ft.test(String(p))));if(i.size===0)return!1;const r=new Map;for(const p of i){const g=await Je(p);if(!g)return!1;r.set(p,g)}try{a.setItem(me.vistas,JSON.stringify([...new Set((Array.isArray(t)?t:[]).map(g=>r.get(g)||g))]));const p={};for(const[g,S]of Object.entries(s||{}))p[r.get(g)||g]=S;a.setItem(me.posiciones,JSON.stringify(p)),c!=null&&c.clave&&r.has(c.clave)&&a.setItem(me.ultima,JSON.stringify({...c,clave:r.get(c.clave)}))}catch{return!1}return!0}function Ie(a){return String(a||"").normalize("NFC")}function ye(a){let t="";for(const s of Ie(a)){if(new RegExp("^\\p{M}$","u").test(s))continue;const i=s.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().charAt(0),r=s.length>1?" ".repeat(s.length-1):"";t+=(/[a-z0-9]/.test(i)?i:" ")+r}return t}
5function Ye(a){return ye(a).split(" ").filter(Boolean)}function Ne(a,t,s,c){const i=t.indexOf(s);if(i<0)return null;const r=Math.max(0,i-42),p=Math.min(a.length,i+s.length+60),g=S=>S.replace(/\s+/g," ");return{donde:c,antes:(r>0?"â¦":"")+g(a.slice(r,i)).replace(/^\s+/,""),palabra:a.slice(i,i+s.length),despues:g(a.slice(i+s.length,p)).replace(/\s+$/,"")+(p<a.length?"â¦":"")}}function bt(a,t){const s=Ye(t);if(s.join("").length<2)return[];const c=[];let i=0;for(const r of a){const p=ye(r.titulo),g=new Map((r.secciones||[]).map(S=>[S.id,ye(S.titulo)]));for(const S of r.clases){if(i++,S.procesando)continue;const L=ye(S.titulo),T=S.seccion!=null&&g.get(S.seccion)||"",z=Ie(S.descripcion||""),x=Ie(S.notas||""),d=ye(z),u=ye(x);let l=0,j=!0;for(const k of s){const q=L.includes(k),A=p.includes(k)||T.includes(k),E=d.includes(k),w=u.includes(k);if(!q&&!A&&!E&&!w){j=!1;break}l+=q?new RegExp(`(^| )${k}`).test(L)?12:8:A?4:E?2:1}if(!j)continue;const R=s[0],O=L.includes(R)?null:Ne(z,d,R,"descripcion")||Ne(x,u,R,"notas");c.push({curso:r,clase:S,puntos:l,fragmento:O,orden:i})}}return c.sort((r,p)=>p.puntos-r.puntos||r.orden-p.orden).map(({orden:r,...p})=>p)}const Be=1e4,yt=/https?:\/\/[^\s<>"'«»]+/gi;function vt(a){let t=a;for(;;){const s=t.slice(-1);if(/[.,;:!?¡¿\]}]/.test(s)){t=t.slice(0,-1);continue}if(s===")"&&(t.match(/\)/g)||[]).length>(t.match(/\(/g)||[]).length){t=t.slice(0,-1);continue}return t}}function jt(a){return String(a||"").split(` 6`).map(t=>{const s=[];let c=0;for(const i of t.matchAll(yt)){const r=vt(i[0]),p=i.index??0;p>c&&s.push({tipo:"texto",valor:t.slice(c,p)});let g="";try{const S=new URL(r);(S.protocol==="http:"||S.protocol==="https:")&&(g=S.href)}catch{g=""}s.push(g?{tipo:"enlace",valor:r,href:g}:{tipo:"texto",valor:r}),c=p+r.length}return c<t.length&&s.push({tipo:"texto",valor:t.slice(c)}),s})}function St(a,t=64){const s=String(a||"").replace(/^https?:\/\//i,"").replace(/\/$/,"");if(s.length<=t)return s;const c=Math.floor((t-1)/2);return`${s.slice(0,c)}â¦${s.slice(s.length-(t-1-c))}`}function ce(a,t){return t.acceso===!1||t.acceso==null&&a.acceso===!1}function wt(a,t){const s=a.secciones||[],c=new Set(s.map(p=>p.id)),i=a.clases.filter(p=>p.seccion==null||!c.has(p.seccion)),r=[];(i.length>0||t&&s.length===0)&&r.push({seccion:null,clases:i});for(const p of s){const g=a.clases.filter(S=>S.seccion===p.id);(g.length>0||t)&&r.push({seccion:p,clases:g})}return r}const kt={todos:/./i,inicio:/bienvenid|desde cero|introducci|primeros pasos|empieza/i,meta:/meta|facebook/i,tiktok:/tiktok/i,landing:/landing|tienda/i,dropi:/dropi|logÃstica/i,creativos:/creativ|campañ|testing/i,finanzas:/finanz|margen|matemática/i,conexiones:/pÃxel|pixel|conexi/i},Ct=[{match:/bienvenid|empieza|desde cero|primeros pasos|introducc/i,color:"#0866FF",icono:"brujula"},{match:/meta|facebook/i,color:"#1877F2",icono:"meta"},{match:/tiktok/i,color:"#FE2C55",icono:"tiktok"},{match:/whats\s?app/i,color:"#25D366",icono:"whatsapp"},{match:/log[Ãi]stic|env[Ãi]os? |transportador/i,color:"#F1701A",icono:"logisticas"},{match:/dropi/i,color:"#F1701A",icono:"dropi"},{match:/mastershop/i,color:"#111827",icono:"mastershop"},{match:/99\s?env/i,color:"#1E3FB8",icono:"envios99"},{match:/landing|tienda|p[áa]gina/i,color:"#0866FF",icono:"lumy"},{match:/creativ|campañ|anuncio/i,color:"#8B5CF6",icono:"chispa"},{match:/regla|automatiz/i,color:"#F59E0B",icono:"rayo"},{match:/finanz|margen|utilidad|cartera/i,color:"#B45309",icono:"grafica"},{match:/p[Ãi]xel|conexi|integraci/i,color:"#0891B2",icono:"enchufe"}];function he(a){return Ct.find(t=>t.match.test(a||""))||{color:"#0866FF",icono:"play"}}const Fe=[{key:"vc-inicio",re:/presentaci|recorrid|desde cero|bienvenid|empieza|introducc|qu[eé] es lumy|primeros pasos/i,name:"Bienvenida: Lumy desde cero"},{key:"vc-landing",re:/landing|lnading|landin|tienda|p[áa]gina de venta/i,name:"Landing y tienda"},{key:"vc-tiktok",re:/tiktok/i,name:"TikTok Ads"},{key:"vc-meta",re:/\bmeta\b|p[Ãi]xel de meta|\bumi\b|facebook/i,name:"Meta Ads"},{key:"vc-campanas",re:/campañ|escal|creativ|adset|anuncio/i,name:"Campañas y creativos"},{key:"vc-dropi",re:/dropi|cartera|log[Ãi]stic|env[Ãi]o/i,name:"Dropi y logÃstica"},{key:"vc-pixel",re:/p[Ãi]xel|conecta|integraci/i,name:"PÃxeles y conexiones"}];
6function De(a){const t=(a||"").match(/^\s*(\d{1,3})\s*[.\-)·:]?\s*/);return t?parseInt(t[1],10):null}function Oe(a){return(a||"").replace(/^\s*\d{1,3}\s*[.\-)·:]\s*/,"").replace(/\.(mp4|mov|webm|m4v)\s*$/i,"").trim()}function zt(a){var T,z;const t=String(a.libraryId||""),s=String(a.cdnHost||""),c=x=>({clave:String(x.guid),titulo:Oe(x.title),descripcion:"",duracion:Number(x.length)||0,poster:s?`https://${s}/${x.guid}/${x.thumb||"thumbnail.jpg"}`:null,bunny:{libreria:t,guid:String(x.guid)},procesando:!x.ready}),i=(x,d)=>{const u=De(x.title),l=De(d.title);return u!=null&&l!=null?u-l:u!=null?-1:l!=null?1:0},r=new Map;for(const x of a.videos||[]){const d=x.collectionId||"__none";r.set(d,[...r.get(d)||[],x])}const p=[];for(const x of a.collections||[]){const d=(r.get(String(x.id))||[]).slice().sort(i);d.length&&p.push({id:String(x.id),titulo:Oe(x.name),descripcion:"",clases:d.map(c)})}const g=new Map;for(const x of r.get("__none")||[]){const d=((T=Fe.find(u=>u.re.test(x.title||"")))==null?void 0:T.key)||"__general";g.set(d,[...g.get(d)||[],x])}for(const[x,d]of g){const u=((z=Fe.find(l=>l.key===x))==null?void 0:z.name)||"Más videos";p.push({id:x,titulo:u,descripcion:"",clases:d.slice().sort(i).map(c)})}const S=["bienvenid","conexion","landing","meta","tiktok","dropi","creativ","regla","finanz","referid","más videos"],L=x=>{const d=x.toLowerCase(),u=S.findIndex(l=>d.includes(l));return u<0?90:u};return p.sort((x,d)=>L(x.titulo)-L(d.titulo)||x.titulo.localeCompare(d.titulo))}async function qe(){var c,i;const a=await fetch("/api/academia/catalogo").then(r=>r.ok?r.json():null).catch(()=>null),t=(a==null?void 0:a.miPlan)??null;if((c=a==null?void 0:a.cursos)!=null&&c.length)return{cursos:a.cursos.map(r=>({id:String(r.id),titulo:r.titulo,descripcion:r.descripcion||"",publicado:r.publicado!==!1,secciones:r.secciones||[],clases:r.clases||[],planes:r.planes??null,acceso:r.acceso===!0,icono:r.icono||null})),bloqueado:!!a.bloqueado,fuente:"lumy",puedeEditar:!!a.puedeEditar,miPlan:t};const s=await fetch("/api/academia/library").then(r=>r.json()).catch(()=>null);if(s!=null&&s.configured&&((i=s.videos)!=null&&i.length)){const r=zt(s).map(p=>({...p,acceso:!0}));return await Promise.all(r.flatMap(p=>p.clases).map(async p=>{p.clave=await Je(p.clave)||p.clave})),{cursos:r,bloqueado:!1,fuente:"bunny",puedeEditar:!!(a!=null&&a.puedeEditar),miPlan:t}}return{cursos:[],bloqueado:!!(a!=null&&a.bloqueado||s!=null&&s.notInPlan),fuente:"vacio",puedeEditar:!!(a!=null&&a.puedeEditar),miPlan:t}}const $e="academia_watched_v1",Pe="academia_posiciones_v1",We="academia_ultima_v1";function be(a,t){try{const s=localStorage.getItem(a);return s?JSON.parse(s):t}catch{return t}}function Me(a,t){try{localStorage.setItem(a,JSON.stringify(t))}catch{}}function ve(a){if(!a)return"";const t=Math.floor(a/60),s=Math.round(a%60);return`${t}:${String(s).padStart(2,"0")}`}function Re(a){const t=Math.round(a/60);return t<60?`${t} min`:`${Math.floor(t/60)} h ${t%60?`${t%60} min`:""}`.trim()}const Et=["/logos/adropi.png","/logos/amastershop.jpg","/logos/a99envios.png"],Lt=new Set(["meta","tiktok","whatsapp","dropi","mastershop","envios99","logisticas","lumy"]);function B({tipo:a,size:t=18,color:s="currentColor"}){if(a==="logisticas"){const i=Math.round(t*.82);return e.jsx("span",{style:{display:"inline-flex",alignItems:"center"},"aria-label":"Dropi, Mastershop y 99envÃos",children:Et.map((r,p)=>e.jsx("img",{src:r,alt:"",width:i,height:i,style:{width:i,height:i,borderRadius:"50%",objectFit:"cover",background:"#fff",boxShadow:"0 0 0 1.5px #fff",marginLeft:p?-Math.round(i*.3):0,position:"relative",zIndex:3-p}},r))})}if(a==="lumy"||a==="dropi"||a==="mastershop"||a==="envios99"){const i={lumy:"/logos/iconoF.png",dropi:"/logos/adropi.png",mastershop:"/logos/amastershop.jpg",envios99:"/logos/a99envios.png"}[a];return e.jsx("img",{src:i,alt:"",width:t,height:t,style:{width:t,height:t,borderRadius:a==="lumy"?4:"50%",objectFit:"contain",display:"block"}})}if(a==="meta")return e.jsx(at,{size:t});if(a==="whatsapp")return e.jsx(nt,{size:t});if(a==="tiktok")return e.jsx(rt,{size:t});const c={brujula:e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M15.5 8.5l-2 5-5 2 2-5z"})]}),caja:e.jsxs(e.Fragment,{children:[e.jsx("path",{d:"M3 7.5L12 3l9 4.5v9L12 21l-9-4.5z"}),e.jsx("path",{d:"M3 7.5l9 4.5 9-4.5M12 12v9"})]}),pagina:e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"3.5",y:"4",width:"17",height:"16",rx:"2.5"}),e.jsx("path",{d:"M3.5 9h17M8 13.5h8M8 16.5h5"})]}),chispa:e.jsx("path",{d:"M12 3v4M12 17v4M3 12h4M17 12h4M6 6l2.5 2.5M15.5 15.5L18 18M6 18l2.5-2.5M15.5 8.5L18 6"}),rayo:e.jsx("path",{d:"M13 2L4 14h7l-1 8 9-12h-7z"}),grafica:e.jsx(e.Fragment,{children:e.jsx("path",{d:"M4 20V10M10 20V4M16 20v-7M22 20H2"})}),enchufe:e.jsx(e.Fragment,{children:e.jsx("path",{d:"M9 2v6M15 2v6M6 8h12v3a6 6 0 01-12 0zM12 17v5"})}),play:e.jsxs(e.Fragment,{children:[e.jsx("circle",{cx:"12",cy:"12",r:"9"}),e.jsx("path",{d:"M10 8.5l5.5 3.5-5.5 3.5z"})]}),check:e.jsx("path",{d:"M20 6L9 17l-5-5"}),candado:e.jsxs(e.Fragment,{children:[e.jsx("rect",{x:"5",y:"11",width:"14",height:"10",rx:"2"}),e.jsx("path",{d:"M8 11V7a4 4 0 018 0v4"})]}),"flecha-der":e.jsx("path",{d:"M9 6l6 6-6 6"}),"flecha-izq":e.jsx("path",{d:"M15 6l-6 6 6 6"}),cerrar:e.jsx("path",{d:"M6 6l12 12M18 6L6 18"})};return e.jsx("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",stroke:s,strokeWidth:a==="check"?3:1.9,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:c[a]||c.play})}const ze=({size:a=18,color:t="#fff"})=>e.jsx("svg",{width:a,height:a,viewBox:"0 0 24 24",fill:t,"aria-hidden":"true",children:e.jsx("path",{d:"M8 5.5v13l10.5-6.5z"})});function _e({clase:a,color:t,icono:s,vista:c,avance:i,bloqueado:r,grande:p,enCuadro:g}){const[S,L]=h.useState(!1);return e.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:p?14:g?10:12,overflow:"hidden",background:`${t}14`,border:g?"none":"1px solid var(--border)"},children:[a.poster&&!S?e.jsx("img",{src:a.poster,alt:"",loading:"lazy",decoding:"async",onError:()=>L(!0),style:{position:"absolute",inset:0,width:"100%",height:"100%",objectFit:"cover"}}):e.jsx("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",color:t},children:e.jsx(B,{tipo:s,size:p?44:30,color:t})}),r&&e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",inset:0,background:"rgba(15,23,42,.22)"}}),e.jsx("span",{className:r?"acad-play acad-fijo":"acad-play",style:{position:"absolute",left:"50%",top:"50%",width:p?64:46,height:p?64:46,marginLeft:p?-32:-23,marginTop:p?-32:-23,borderRadius:"50%",background:"rgba(255,255,255,.94)",boxShadow:"0 6px 18px rgba(15,23,42,.22)",display:"flex",alignItems:"center",justifyContent:"center"},children:r?e.jsx(B,{tipo:"candado",size:p?24:18,color:"#1A202C"}):e.jsx(ze,{size:p?24:17,color:"#1A202C"})}),a.duracion>0&&e.jsx("span",{style:{position:"absolute",right:8,bottom:8,fontSize:11.5,fontWeight:700,color:"#fff",background:"rgba(15,23,42,.72)",padding:"2px 7px",borderRadius:6,fontVariantNumeric:"tabular-nums"},children:ve(a.duracion)}),c&&e.jsxs("span",{style:{position:"absolute",left:8,top:8,display:"inline-flex",alignItems:"center",gap:5,fontSize:11.5,fontWeight:700,color:"#1A202C",background:"rgba(255,255,255,.95)",padding:"3px 9px 3px 6px",borderRadius:999,boxShadow:"0 2px 6px rgba(15,23,42,.18)"},children:[e.jsx("span",{style:{width:16,height:16,borderRadius:"50%",background:"#047857",display:"inline-flex",alignItems:"center",justifyContent:"center"}
6,children:e.jsx(B,{tipo:"check",size:10,color:"#fff"})}),"Vista"]}),a.procesando&&e.jsx("span",{style:{position:"absolute",left:8,top:8,fontSize:11,fontWeight:700,color:"#fff",background:"rgba(15,23,42,.72)",padding:"3px 9px",borderRadius:999},children:"Procesandoâ¦"}),!c&&!g&&i>.02&&e.jsx("span",{style:{position:"absolute",left:0,right:0,bottom:0,height:4,background:"rgba(15,23,42,.25)"},children:e.jsx("span",{style:{display:"block",height:"100%",width:`${Math.min(100,i*100)}%`,background:t}})})]})}function $t({vista:a,avance:t,duracion:s,color:c}){const i=a?1:Math.max(0,Math.min(1,t)),r=!a&&i>.02,p=r&&s>0?`Vas en ${ve(i*s)} de ${ve(s)}`:void 0;return e.jsxs("div",{title:p,style:{display:"flex",alignItems:"center",gap:10},children:[e.jsx("span",{role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(i*100),"aria-label":a?"Vista":p||"Sin empezar",style:{flex:1,height:6,borderRadius:999,background:"var(--bg-tertiary)",border:"1px solid var(--border)",overflow:"hidden"},children:e.jsx("span",{style:{display:"block",height:"100%",width:`${i*100}%`,background:a?"#047857":c,borderRadius:999,transition:"width .4s ease"}})}),e.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:700,whiteSpace:"nowrap",fontVariantNumeric:"tabular-nums",color:a?"var(--success)":r?"var(--text-secondary)":"var(--text-muted)"},children:a?e.jsxs(e.Fragment,{children:[e.jsx("span",{style:{width:16,height:16,borderRadius:"50%",background:"#047857",display:"inline-flex",alignItems:"center",justifyContent:"center"},children:e.jsx(B,{tipo:"check",size:10,color:"#fff"})}),"Vista"]}):r?`${Math.round(i*100)} %`:"Sin empezar"})]})}function Ce({hechas:a,total:t,color:s,ancho:c=120}){return e.jsx("span",{style:{display:"inline-block",width:c,height:6,borderRadius:999,background:"var(--bg-tertiary)",border:"1px solid var(--border)",overflow:"hidden",verticalAlign:"middle"},children:e.jsx("span",{style:{display:"block",height:"100%",width:`${t?a/t*100:0}%`,background:s,borderRadius:999}})})}function It(){var Te,Ae;const a=ot(),[t,s]=h.useState(null),[c,i]=h.useState("todos"),[r,p]=h.useState(null),[g,S]=h.useState(()=>new Set(be($e,[]))),[L,T]=h.useState(()=>be(Pe,{})),[z,x]=h.useState(()=>be(We,null)),[d,u]=h.useState(!1),[l,j]=h.useState(null),[R,O]=h.useState(""),[k,q]=h.useState(null),A=n=>q({tipo:"curso",titulo:n.titulo,planes:n.planes??null,clases:n.clases.filter(o=>ce(n,o)).length||n.clases.length}),[E,w]=h.useState("");h.useEffect(()=>{const n=o=>{const f=o.detail;(f==null?void 0:f.tipo)==="academia-tema"&&(i(f.tema),p(null),f.consumido=!0)};return window.addEventListener("lumy:guia-ir",n),()=>window.removeEventListener("lumy:guia-ir",n)},[]),h.useEffect(()=>{let n=!0;return qe().then(o=>{n&&s(o)}),()=>{n=!1}},[]),h.useEffect(()=>{let n;try{n=window.localStorage}catch{return}mt(n).then(o=>{o&&(S(new Set(be($e,[]))),T(be(Pe,{})),x(be(We,null)))}).catch(()=>{})},[]);const P=()=>qe().then(s);h.useEffect(()=>{const n=()=>{P()};return window.addEventListener("lumy:academia-subida-lista",n),()=>window.removeEventListener("lumy:academia-subida-lista",n)},[]);const M=(n,o)=>S(f=>{if(f.has(n)===o)return f;const b=new Set(f);return o?b.add(n):b.delete(n),Me($e,[...b]),b}),J=(n,o,f)=>T(b=>{const C={...b,[n]:{t:Math.round(o),d:Math.round(f)}};return Me(Pe,C),C}),V=n=>{const o=L[n];return o&&o.d>0?o.t/o.d:0},U=!!(t!=null&&t.bloqueado),de=h.useMemo(()=>((t==null?void 0:t.cursos)||[]).filter(n=>kt[c].test(n.titulo)),[t,c]),X=Ye(E).join("").length>=2,se=h.useMemo(()=>X?bt((t==null?void 0:t.cursos)||[],E):[],[t,E,X]),Z=h.useMemo(()=>((t==null?void 0:t.cursos)||[]).map(n=>({...n,clases:n.clases.filter(o=>!ce(n,o))})).filter(n=>n.clases.length>0),[t]),ie=h.useMemo(()=>Z.flatMap(n=>n.clases.filter(o=>!o.procesando)),[Z]),_=ie.filter(n=>g.has(n.clave)).length,ee=h.useMemo(()=>{const n=Z,o=(f,b)=>{const C=n.find(I=>I.id===f),v=C?C.clases.findIndex(I=>I.clave===b):-1;return C&&v>=0?{curso:C,i:v}:null};if(z){const f=o(z.cursoId,z.clave);if(f){if(!g.has(f.curso.clases[f.i].clave))return{curso:f.curso,clase:f.curso.clases[f.i],seguir:!0};const b=f.curso.clases.slice(f.i+1).find(C=>!g.has(C.clave)&&!C.procesando);if(b)return{curso:f.curso,clase:b,seguir:!1}}}for(const f of n){const b=f.clases.find(C=>!g.has(C.clave)&&!C.procesando);if(b)return{curso:f,clase:b,seguir:!1}}return null},[Z,z,g]),le=(n,o)=>
6{if(U){a("/facturacion");return}const f=t==null?void 0:t.cursos.find(v=>v.id===n),b=f==null?void 0:f.clases.find(v=>v.clave===o);if(f&&b&&ce(f,b)){b.planesPropios?q({tipo:"clase",titulo:b.titulo,planes:b.planes??null,clases:1}):A(f);return}p({cursoId:n,clave:o});const C={cursoId:n,clave:o};x(C),Me(We,C)},ue=n=>{var o;(o=document.getElementById(`curso-${n}`))==null||o.scrollIntoView({behavior:"smooth",block:"start"})},pe=!!(t!=null&&t.puedeEditar),H=(t==null?void 0:t.fuente)==="lumy",y=async n=>{O("");try{await n(),await P()}catch(o){O((o==null?void 0:o.message)||"No se pudo hacer el cambio.")}},F=(n,o)=>{const f=((t==null?void 0:t.cursos)||[]).map(v=>Number(v.id)),b=f.indexOf(Number(n.id)),C=b+o;b<0||C<0||C>=f.length||([f[b],f[C]]=[f[C],f[b]],y(()=>G("/api/academia/admin/orden","POST",{cursos:f})))},Y=(n,o,f,b)=>{const C=o.map(D=>Number(D.id)),v=C.indexOf(Number(f.id)),I=v+b;v<0||I<0||I>=C.length||([C[v],C[I]]=[C[I],C[v]],y(()=>G("/api/academia/admin/orden","POST",{curso_id:Number(n.id),clases:C})))},te=(n,o,f)=>{const b=(n.secciones||[]).map(I=>I.id),C=b.indexOf(o.id),v=C+f;C<0||v<0||v>=b.length||([b[C],b[v]]=[b[v],b[C]],y(()=>G("/api/academia/admin/orden","POST",{curso_id:Number(n.id),secciones:b})))},m=(n,o)=>{window.confirm(`¿Borrar la sección «${n.titulo}»?${o?` Sus ${o} clases no se borran: quedan en el curso, sin sección.`:""}`)&&y(()=>G(`/api/academia/admin/secciones/${n.id}`,"DELETE"))},$=n=>{window.confirm(`¿Borrar el curso «${n.titulo}» y sus ${n.clases.length} clases? Los videos subidos se borran y no se pueden recuperar.`)&&y(()=>G(`/api/academia/admin/cursos/${n.id}`,"DELETE"))},W=n=>{window.confirm(`¿Borrar la clase «${n.titulo}»? El video se borra y no se puede recuperar.`)&&y(()=>G(`/api/academia/admin/clases/${n.id}`,"DELETE"))},fe=()=>y(()=>G("/api/academia/admin/importar","POST",{cursos:((t==null?void 0:t.cursos)||[]).map(n=>({titulo:n.titulo,clases:n.clases.filter(o=>o.bunny).map(o=>({titulo:o.titulo,guid:o.bunny.guid,duracion:o.duracion}))}))})),N={...ne,padding:"5px 10px",fontSize:12,borderRadius:8,fontWeight:600},je=(n,o,f,b)=>{const C=n.clases.indexOf(o),v=f.indexOf(o),I=he(n.titulo).color,D=!o.procesando,K=o.publicado===!1;return e.jsxs("div",{className:"acad-cuadro",style:{display:"flex",flexDirection:"column",minWidth:0,background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:14,boxShadow:"var(--shadow-sm)",overflow:"hidden",opacity:K?.55:1},children:[e.jsxs("button",{type:"button",className:"acad-tarjeta",disabled:!D,onClick:()=>D&&le(n.id,o.clave),style:{all:"unset",boxSizing:"border-box",cursor:D?"pointer":"default",display:"flex",flexDirection:"column",gap:12,minWidth:0,padding:10,flex:1},children:[e.jsx(_e,{clase:o,color:I,icono:he(n.titulo).icono,vista:g.has(o.clave),avance:V(o.clave),bloqueado:U||ce(n,o),enCuadro:!0}),e.jsxs("div",{style:{minWidth:0,padding:"0 4px"},children:[e.jsxs("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",marginBottom:3,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[b?`${n.titulo} · `:"","Clase ",C+1,o.duracion>0?` · ${Re(o.duracion)}`:"",K?" · Oculta":""]}),e.jsx("div",{style:{fontSize:14.5,fontWeight:700,color:"var(--text-primary)",lineHeight:1.35,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden",minHeight:"2.7em"},children:o.titulo}),(b==null?void 0:b.fragmento)&&e.jsxs("div",{style:{marginTop:6,fontSize:12.5,lineHeight:1.45,color:"var(--text-secondary)",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:[e.jsx("span",{style:{fontWeight:700,color:"var(--text-muted)"},children:b.fragmento.donde==="notas"?"En las notas: ":"En la descripción: "}),b.fragmento.antes,e.jsx("mark",{style:{background:"var(--notice-warning-bg)",color:"inherit",borderRadius:3,padding:"0 1px"},children:b.fragmento.palabra}),b.fragmento.despues]})]})]}),e.jsx("div",{style:{padding:"0 14px 14px"},children:ce(n,o)?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,fontSize:12,fontWeight:700,color:"var(--text-muted)"},children:[e.jsx(B,{tipo:"candado",size:13,color:"var(--text-muted)"}),(o.planesPropios?o.planes:n.planes)?`Plan ${oe((o.planesPropios?o.planes:n.planes)??null)}`:"Con cualquier plan"]}):e.jsx($t,{vista:g.has(o.clave),avance:V(o.clave),duracion:o.duracion,color:I})}),d&&H&&o.id!=null&&e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",padding:"10px 12px",borderTop:"1px solid var(--border)",background:"var(--bg-tertiary)"},children:[o.planesPropios&&e.jsxs("span",{style:{flexBasis:"100%",display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:700,color:"var(--text-secondary)"},children:[e.jsx(B,{tipo:"candado",size:12,color:"var(--text-secondary)"}),"Esta clase: ",o.planes?oe(o.planes):"todos los planes"]}
6),e.jsx("button",{type:"button",style:N,onClick:()=>j({tipo:"clase",clase:o,curso:n}),children:"Editar"}),e.jsx("button",{type:"button",style:N,"aria-label":"Mover antes",disabled:v<=0,onClick:()=>Y(n,f,o,-1),children:"â"}),e.jsx("button",{type:"button",style:N,"aria-label":"Mover después",disabled:v===f.length-1,onClick:()=>Y(n,f,o,1),children:"â"}),e.jsx("button",{type:"button",style:N,onClick:()=>y(()=>G(`/api/academia/admin/clases/${o.id}`,"PATCH",{publicado:K})),children:K?"Publicar":"Ocultar"}),e.jsx("button",{type:"button",style:{...N,color:"var(--danger)"},onClick:()=>W(o),children:"Borrar"})]})]},o.clave)},Se=t===null,Ee=!Se&&((t==null?void 0:t.cursos.length)||0)===0;return e.jsxs("div",{style:{paddingBottom:56},children:[e.jsx("style",{children:` 7 .acad-tarjeta .acad-play { opacity: .0; transform: scale(.92); transition: opacity .18s ease, transform .18s ease; } 8 .acad-tarjeta:hover .acad-play, .acad-tarjeta:focus-visible .acad-play { opacity: 1; transform: scale(1); } 9 .acad-tarjeta .acad-play.acad-fijo { opacity: 1; transform: none; } 10 .acad-tarjeta:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 4px; border-radius: 14px; } 11 .acad-tarjeta:hover img { transform: scale(1.025); } 12 .acad-tarjeta img { transition: transform .35s ease; } 13 .acad-chip:hover { border-color: var(--text-muted) !important; } 14 .acad-cuadro { transition: box-shadow .2s ease, transform .2s ease, border-color .2s ease; } 15 .acad-cuadro:hover { box-shadow: var(--shadow-md) !important; transform: translateY(-2px); border-color: color-mix(in srgb, var(--border) 60%, var(--text-muted)); } 16 @media (prefers-reduced-motion: reduce) { .acad-cuadro, .acad-cuadro:hover { transition: none; transform: none; } } 17 .acad-chips { scrollbar-width: none; } 18 .acad-destacada { grid-template-columns: minmax(0, 620px) minmax(0, 1fr); } 19 @media (max-width: 860px) { .acad-destacada { grid-template-columns: minmax(0, 1fr); } } 20 .acad-chips::-webkit-scrollbar { display: none; } 21 .acad-buscar input:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 1px; } 22 .acad-buscar input::-webkit-search-cancel-button { display: none; } 23 @media (hover: none) { .acad-tarjeta .acad-play { opacity: 1; transform: none; } } 24 @media (prefers-reduced-motion: reduce) { .acad-tarjeta img, .acad-tarjeta .acad-play { transition: none; } } 25 `}),e.jsx(tt,{platform:"academia"}),e.jsxs("div",{children:[c!=="todos"&&e.jsxs("div",{role:"status",style:{marginBottom:16,fontSize:13,color:"var(--text-secondary)"},children:[de.length===0?"TodavÃa no hay cursos de este tema. ":"Cursos del tema que buscas. ",e.jsx("button",{type:"button",onClick:()=>i("todos"),style:{all:"unset",cursor:"pointer",color:"var(--accent-blue)",fontWeight:700},children:"Ver todos los cursos"})]}),Se?e.jsx("div",{style:{padding:56,textAlign:"center",color:"var(--text-muted)",fontSize:13.5},children:"Cargando la Academiaâ¦"}):Ee?e.jsxs("div",{style:{padding:"48px 24px",textAlign:"center",background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:16},children:[e.jsx("div",{style:{fontSize:17,fontWeight:800,color:"var(--text-primary)",marginBottom:6},children:U?"La Academia viene con tu plan":"TodavÃa no hay clases publicadas"}),e.jsx("div",{style:{fontSize:13.5,color:"var(--text-secondary)"},children:U?"ActÃvalo para ver todas las clases.":"Las primeras clases de la Academia llegan muy pronto."}),U&&e.jsx("button",{type:"button",onClick:()=>a("/facturacion"),style:{marginTop:18,border:"none",background:"var(--accent-blue)",color:"#fff",fontWeight:700,fontSize:14,padding:"10px 18px",borderRadius:11,cursor:"pointer",fontFamily:"inherit"},children:"Ver planes"}),pe&&e.jsx("button",{type:"button",onClick:()=>j({tipo:"curso"}),style:{marginTop:18,border:"none",background:"var(--accent-blue)",color:"#fff",fontWeight:700,fontSize:14,padding:"10px 18px",borderRadius:11,cursor:"pointer",fontFamily:"inherit"},children:"Crear el primer curso"})]}):e.jsxs(e.Fragment,{children:[U&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,flexWrap:"wrap",padding:"14px 18px",marginBottom:20,background:"var(--notice-info-bg)",border:"1px solid var(--notice-info-border)",borderRadius:14},children:[e.jsx(B,{tipo:"candado",size:20,color:"var(--notice-info-text)"}),e.jsxs("div",{style:{flex:1,minWidth:220,fontSize:13.5,color:"var(--notice-info-text)"},children:[e.jsx("b",{children:"La Academia viene con tu plan."})," ActÃvalo para ver todas las clases."]}),e.jsx("button",{type:"button",onClick:()=>a("/facturacion"),style:{border:"none",background:"var(--accent-blue)",color:"#fff",fontWeight:700,fontSize:13,padding:"9px 16px",borderRadius:10,cursor:"pointer",fontFamily:"inherit"},children:"Ver planes"})]}),e.jsxs("div",{role:"search",className:"acad-buscar",style:{position:"relative",maxWidth:620,marginBottom:22},children:[e.jsx("span",{"aria-hidden":"true",style:{position:"absolute",left:14,top:"50%",transform:"translateY(-50%)",display:"flex",color:"var(--text-muted)",pointerEvents:"none"},children:e.jsxs("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",children:[e.jsx("circle",{cx:"11",cy:"11",r:"7"}),e.jsx("path",{d:"M20 20l-3.5-3.5"})]})}),e.jsx("input",{id:"acad-buscar",type:"search",value:E,onChange:n=>w(n.target.value),onKeyDown:n=>{n.key==="Escape"&&E&&(n.preventDefault(),w(""))},placeholder:"Busca una clase: pÃxel, campañas, Dropiâ¦","aria-label":"Buscar en la Academia",autoComplete:"off",enterKeyHint:"search",maxLength:120,style:{width:"100%",boxSizing:"border-box",padding:"12px 44px 12px 42px",fontSize:15,borderRadius:12,border:"1px solid var(--border)",background:"var(--bg-card)",color:"var(--text-primary)",fontFamily:"inherit",boxShadow:"var(--shadow-sm)"}}),E&&e.jsx("button",{type:"button",onClick:()=>w(""),"aria-label":"Borrar la búsqueda",style:{position:"absolute",right:8,top:"50%",transform:"translateY(-50%)",width:30,height:30,borderRadius:"50%",border:"none",background:"var(--bg-tertiary)",color:"var(--text-secondary)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(B,{tipo:"cerrar",size:14})})]}),X?e.jsxs("section",{"aria-label":"Resultados de la búsqueda",children:[e.jsxs("div",{style:{display:"flex",alignItems:"baseline",gap:12,flexWrap:"wrap",marginBottom:14},children:[e.jsx("div",{role:"status",style:{fontSize:18,fontWeight:800,color:"var(--text-primary)",letterSpacing:"-.01em"},children:se.length===0?"Sin resultados":`${se.length} ${se.length===1?"clase encontrada":"clases encontradas"}`}),e.jsx("button",{type:"button",onClick:()=>w(""),style:{all:"unset",cursor:"pointer",color:"var(--accent-blue)",fontWeight:700,fontSize:13},children:"Ver todos los cursos"})]}),R&&e.jsx("div",{role:"alert",style:{margin:"0 0 14px",padding:"10px 12px",borderRadius:10,fontSize:13,background:"var(--notice-danger-bg)",border:"1px solid var(--notice-danger-border)",color:"var(--notice-danger-text)"},children:R}),se.length===0?e.jsxs("div",{style:{padding:"28px 20px",textAlign:"center",background:"var(--bg-card)",border:"1px solid var(--border)",borderRadius:14,color:"var(--text-secondary)",fontSize:14},children:["No hay clases con «",E.trim(),"». Prueba con otra palabra o con menos palabras."]}):e.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(250px, 100%), 1fr))",gap:18},children:se.map(n=>je(n.curso,n.clase,[n.clase],{fragmento:n.fragmento}))})]}):e.jsxs(e.Fragment,{children:[ee&&c==="todos"&&(()=>{const{curso:n,clase:o,seguir:f}=ee,b=he(n.titulo).color,C=(t==null?void 0:t.cursos.find(K=>K.id===n.id))||n,v=C.clases.findIndex(K=>
25K.clave===o.clave),I=n.clases.filter(K=>g.has(K.clave)).length,D=L[o.clave];return e.jsxs("section",{"aria-label":"Continúa donde ibas",className:"acad-destacada",style:{display:"grid",gap:24,alignItems:"center",padding:18,marginBottom:30,background:`linear-gradient(0deg, ${b}0a, ${b}0a), var(--bg-card)`,border:"1px solid var(--border)",borderRadius:18,boxShadow:"var(--shadow-sm)"},children:[e.jsx("button",{type:"button",className:"acad-tarjeta",onClick:()=>le(n.id,o.clave),style:{all:"unset",cursor:"pointer",display:"block"},"aria-label":`Ver ${o.titulo}`,children:e.jsx(_e,{clase:o,color:b,icono:he(n.titulo).icono,vista:!1,avance:V(o.clave),bloqueado:U,grande:!0})}),e.jsxs("div",{style:{minWidth:0,padding:"4px 6px"},children:[e.jsx("div",{style:{fontSize:12,fontWeight:800,letterSpacing:".06em",textTransform:"uppercase",color:b},children:f?"Continúa donde ibas":_===0?"Empieza por aquÃ":"Tu siguiente clase"}),e.jsx("h2",{style:{margin:"8px 0 6px",fontSize:"clamp(19px, 2.2vw, 24px)",lineHeight:1.25,fontWeight:800,color:"var(--text-primary)",letterSpacing:"-.01em",textWrap:"balance"},children:o.titulo}),e.jsxs("div",{style:{fontSize:13.5,color:"var(--text-secondary)",marginBottom:12},children:[n.titulo," · Clase ",v+1," de ",C.clases.length]}),o.descripcion&&e.jsx("p",{style:{margin:"0 0 16px",fontSize:13.5,lineHeight:1.55,color:"var(--text-secondary)",maxWidth:"60ch",display:"-webkit-box",WebkitLineClamp:3,WebkitBoxOrient:"vertical",overflow:"hidden"},children:o.descripcion}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:14,flexWrap:"wrap"},children:[e.jsxs("button",{type:"button",onClick:()=>le(n.id,o.clave),style:{display:"inline-flex",alignItems:"center",gap:8,border:"none",background:"var(--accent-blue)",color:"#fff",fontWeight:700,fontSize:14,padding:"11px 20px",borderRadius:12,cursor:"pointer",fontFamily:"inherit",boxShadow:"0 6px 16px rgba(8,102,255,.25)"},children:[e.jsx(ze,{size:15})," ",f&&(D!=null&&D.t)?"Seguir viendo":"Ver clase"]}),f&&(D!=null&&D.t)&&D.d?e.jsxs("span",{style:{fontSize:12.5,color:"var(--text-muted)",fontVariantNumeric:"tabular-nums"},children:["Vas en ",ve(D.t)," de ",ve(D.d)]}):null]}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:18,fontSize:12.5,color:"var(--text-muted)"},children:[e.jsx(Ce,{hechas:I,total:n.clases.length,color:b,ancho:140}),I," de ",n.clases.length," vistas en este curso"]})]})]})})(),e.jsxs("div",{style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:12,flexWrap:"wrap",marginBottom:10},children:[e.jsx("div",{style:{fontSize:18,fontWeight:800,color:"var(--text-primary)",letterSpacing:"-.01em"},children:"Cursos"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flexWrap:"wrap"},children:[ie.length>0&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:12.5,color:"var(--text-muted)",fontVariantNumeric:"tabular-nums"},children:[e.jsx(Ce,{hechas:_,total:ie.length,color:"var(--accent-blue)",ancho:100}),_," de ",ie.length," clases vistas"]}),pe&&d&&H&&e.jsx("button",{type:"button",style:{...ne,padding:"7px 13px",fontSize:13},onClick:()=>j({tipo:"curso"}),children:"+ Nuevo curso"}),pe&&e.jsx("button",{type:"button",onClick:()=>u(n=>!n),"aria-pressed":d,style:{...ne,padding:"7px 13px",fontSize:13,...d?{background:"var(--accent-blue)",color:"#fff",border:"1px solid var(--accent-blue)"}:{}},children:d?"Listo":"Editar Academia"})]})]}),d&&(t==null?void 0:t.fuente)==="bunny"&&e.jsxs("div",{role:"status",style:{display:"flex",alignItems:"center",gap:14,flexWrap:"wrap",padding:"14px 16px",margin:"6px 0 16px",background:"var(--notice-info-bg)",border:"1px solid var(--notice-info-border)",borderRadius:14,color:"var(--notice-info-text)",fontSize:13.5},children:[e.jsxs("div",{style:{flex:1,minWidth:240},children:[e.jsxs("b",{children:["Estos ",ie.length," videos siguen en Bunny."]})," Tráelos al catálogo de Lumy para ordenarlos, editarlos y sumarles las clases nuevas. Se siguen viendo igual."]}),e.jsx("button",{type:"button",onClick:fe,style:{border:"none",background:"var(--accent-blue)",color:"#fff",fontWeight:700,fontSize:13,padding:"9px 16px",borderRadius:10,cursor:"pointer",fontFamily:"inherit"},children:"Traer al catálogo"})]}),d&&H&&e.jsx(gt,{onCambio:P}),R&&e.jsx("div",{role:"alert",style:{margin:"6px 0 14px",padding:"10px 12px",borderRadius:10,fontSize:13,background:"var(--notice-danger-bg)",border:"1px solid var(--notice-danger-border)",color:"var(--notice-danger-text)"},children:R}),e.jsx("div",{className:"acad-chips",style:{display:"flex",gap:8,overflowX:"auto",paddingBottom:6,marginBottom:20},children:de.map(n=>e.jsxs("button",{type:"button",className:"acad-chip",onClick:()=>ue(n.id),style:{flexShrink:0,display:"inline-flex",alignItems:"center",gap:7,padding:"7px 13px",borderRadius:999,border:"1px solid var(--border)",background:"var(--bg-card)",color:"var(--text-secondary)",fontSize:12.5,fontWeight:600,cursor:"pointer",fontFamily:"inherit",whiteSpace:"nowrap"},children:[e.jsx("span",{style:{display:"inline-flex"},children:n.icono?e.jsx("img",{src:n.icono,alt:"",style:{width:16,height:16,objectFit:"contain",borderRadius:4,display:"block"}}):e.jsx(B,{tipo:he(n.titulo).icono,size:14,color:he(n.titulo).color})}),n.titulo]},n.id))}),de.map(n=>{const o=he(n.titulo),f=n.clases.filter(v=>!ce(n,v)).length,b=n.clases.filter(v=>!ce(n,v)&&g.has(v.clave)).length,C=n.clases.reduce((v,I)=>v+(I.duracion||0),0);return e.jsxs("section",{id:`curso-${n.id}`,style:{marginBottom:36,scrollMarginTop:16},children:[e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",ga
25p:14,marginBottom:16,flexWrap:"wrap"},children:[n.icono?e.jsx("span",{style:{width:40,height:40,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",overflow:"hidden",background:"var(--bg-card)",border:"1px solid var(--border)"},children:e.jsx("img",{src:n.icono,alt:"",style:{width:30,height:30,objectFit:"contain",display:"block"}})}):e.jsx("span",{style:{minWidth:40,height:40,padding:o.icono==="logisticas"?"0 8px":0,boxSizing:"border-box",borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",...Lt.has(o.icono)?{background:"var(--bg-card)",border:"1px solid var(--border)"}:{background:`${o.color}12`,border:`1px solid ${o.color}2e`}},children:e.jsx(B,{tipo:o.icono,size:o.icono==="logisticas"?30:22,color:o.color})}),e.jsxs("div",{style:{flex:1,minWidth:220},children:[e.jsx("h3",{style:{margin:0,fontSize:17,fontWeight:800,color:"var(--text-primary)",letterSpacing:"-.01em"},children:n.titulo}),e.jsxs("div",{style:{marginTop:3,fontSize:13,color:"var(--text-secondary)"},children:[n.clases.length," ",n.clases.length===1?"clase":"clases",C>0?` · ${Re(C)}`:"",n.descripcion?` · ${n.descripcion}`:""]})]}),n.acceso===!1&&(n.planes!==null||!U)?e.jsxs("button",{type:"button",onClick:()=>A(n),className:"acad-candado",style:{display:"inline-flex",alignItems:"center",gap:7,marginTop:2,padding:"7px 12px",borderRadius:999,border:"1px solid var(--border)",background:"var(--bg-card)",color:"var(--text-secondary)",fontSize:12.5,fontWeight:700,cursor:"pointer",fontFamily:"inherit",whiteSpace:"nowrap"},children:[e.jsx(B,{tipo:"candado",size:14,color:"var(--text-secondary)"}),"Disponible en ",oe(n.planes??null)]}):n.acceso===!1?null:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,fontSize:12.5,fontWeight:600,color:f>0&&b>=f?"var(--success)":"var(--text-muted)",paddingTop:4,fontVariantNumeric:"tabular-nums"},children:[e.jsx(Ce,{hechas:b,total:f,color:o.color}),f>0&&b>=f?"Curso completo":`${b} de ${f}`]})]}),d&&H&&(()=>{const v=((t==null?void 0:t.cursos)||[]).findIndex(D=>D.id===n.id),I=n.publicado===!1;return e.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center",margin:"-4px 0 16px 54px"},children:[I&&e.jsx("span",{style:{fontSize:12,fontWeight:700,color:"var(--warning)",padding:"5px 4px"},children:"Curso oculto"}),e.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:5,fontSize:12,fontWeight:700,color:"var(--text-secondary)",padding:"5px 10px",borderRadius:999,background:"var(--bg-tertiary)",border:"1px solid var(--border)"},children:[e.jsx(B,{tipo:"candado",size:12,color:"var(--text-secondary)"}),n.planes?`Lo ven: ${oe(n.planes)}`:"Lo ven: todos los planes"]}),e.jsx("button",{type:"button",style:N,onClick:()=>j({tipo:"curso",curso:n}),children:"Editar curso"}),e.jsx("button",{type:"button",style:N,onClick:()=>j({tipo:"seccion",curso:n}),children:"+ Sección"}),e.jsx("button",{type:"button",style:N,"aria-label":"Subir el curso",disabled:v<=0,onClick:()=>F(n,-1),children:"â"}),e.jsx("button",{type:"button",style:N,"aria-label":"Bajar el curso",disabled:v>=((t==null?void 0:t.cursos.length)||0)-1,onClick:()=>F(n,1),children:"â"}),e.jsx("button",{type:"button",style:N,onClick:()=>y(()=>G(`/api/academia/admin/cursos/${n.id}`,"PATCH",{publicado:I})),children:I?"Publicar":"Ocultar"}),e.jsx("button",{type:"button",style:{...N,color:"var(--danger)"},onClick:()=>$(n),children:"Borrar"})]})})(),wt(n,d&&H).map(v=>{const I=n.secciones||[],D=v.seccion?I.findIndex(ge=>ge.id===v.seccion.id):-1,K=v.clases.reduce((ge,Ke)=>ge+(Ke.duracion||0),0);return e.jsxs("div",{style:{marginTop:v.seccion?28:0},children:[v.seccion&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap",marginBottom:14},children:[e.jsx("h4",{style:{margin:0,fontSize:15.5,fontWeight:800,color:"var(--text-primary)",letterSpacing:"-.005em"},children:v.seccion.titulo}),e.jsxs("span",{style:{fontSize:12.5,color:"var(--text-muted)"},children:[v.clases.length," ",v.clases.length===1?"clase":"clases",K>0?` · ${Re(K)}`:""]}),d&&H&&e.jsxs("span",{style:{display:"inline-flex",gap:6,flexWrap:"wrap",marginLeft:"auto"},children:[e.jsx("button",{type:"button",style:N,onClick:()=>j({tipo:"seccion",curso:n,seccion:v.seccion}),children:"Renombrar"}),e.jsx("button",{type:"button",style:N,"aria-label":"Subir la sección",disabled:D<=0,onClick:()=>te(n,v.seccion,-1),children:"â"}),e.jsx("button",{type:"button",style:N,"aria-label":"Bajar la sección",disabled:D>=I.length-1,onClick:()=>te(n,v.seccion,1),children:"â"}),e.jsx("button",{type:"button",style:{...N,color:"var(--danger)"},onClick:()=>m(v.seccion,v.clases.length),children:"Borrar sección"})]})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(min(250px, 100%), 1fr))",gap:18},children:[v.clases.map(ge=>je(n,ge,v.clases)),d&&H&&e.jsxs("button",{type:"button",onClick:()=>{var ge;return j({tipo:"subir",curso:n,seccion:((ge=v.seccion)==null?void 0:ge.id)??null})},style:{minHeight:200,borderRadius:14,border:"1.5px dashed var(--border)",background:"var(--bg-tertiary)",color:"var(--text-secondary)",fontSize:14,fontWeight:700,cursor:"pointer",fontFamily:"inherit",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:6,padding:16,textAlign:"center"},children:[e.jsx("span",{style:{fontSize:26,lineHeight:1,color:"var(--accent-blue)"},children:"+"}),v.seccion?`Subir clase a «${v.seccion.titulo}»`:"Subir clase"]})]})]},v.seccion?`s${v.seccion.id}`:"sin-seccion")})]},n.id)})]})]})]}),(l==null?void 0:l.tipo)==="curso"&&e.jsx(lt,{inicial:l.curso?{titulo:l.curs
25o.titulo,descripcion:l.curso.descripcion,planes:l.curso.planes??null,icono:l.curso.icono??null,sinProteger:l.curso.clases.filter(n=>n.almacen==="publico"||n.almacen==="bunny").length}:void 0,onCerrar:()=>j(null),onGuardar:async(n,o,f,b)=>{const C=b===void 0?{}:{icono_url:b};l.curso?await G(`/api/academia/admin/cursos/${l.curso.id}`,"PATCH",{titulo:n,descripcion:o,planes:f,...C}):await G("/api/academia/admin/cursos","POST",{titulo:n,descripcion:o,planes:f,...C}),await P()}}),(l==null?void 0:l.tipo)==="subir"&&e.jsx(ht,{cursoId:Number(l.curso.id),cursoTitulo:l.curso.titulo,secciones:l.curso.secciones||[],seccionInicial:l.seccion??null,onListo:()=>{P()},onCerrar:()=>j(null)}),(l==null?void 0:l.tipo)==="clase"&&l.clase.id!=null&&e.jsx(xt,{clase:{id:l.clase.id,titulo:l.clase.titulo,descripcion:l.clase.descripcion,poster:l.clase.poster,seccion:l.clase.seccion??null,planesPropios:!!l.clase.planesPropios,planes:l.clase.planes??null,sinProteger:l.clase.almacen==="publico"||l.clase.almacen==="bunny"},planesDelCurso:l.curso.planes??null,secciones:l.curso.secciones||[],cursoId:Number(l.curso.id),cursos:((t==null?void 0:t.cursos)||[]).map(n=>({id:Number(n.id),titulo:n.titulo,planes:n.planes??null,secciones:n.secciones||[]})),onListo:()=>{P()},onCerrar:()=>j(null)}),(l==null?void 0:l.tipo)==="seccion"&&e.jsx(ct,{cursoTitulo:l.curso.titulo,inicial:(Te=l.seccion)==null?void 0:Te.titulo,onCerrar:()=>j(null),onGuardar:async n=>{l.seccion?await G(`/api/academia/admin/secciones/${l.seccion.id}`,"PATCH",{titulo:n}):await G("/api/academia/admin/secciones","POST",{curso_id:Number(l.curso.id),titulo:n}),await P()}}),k&&e.jsx(we,{titulo:`Disponible en ${oe(k.planes)}`,onCerrar:()=>q(null),ancho:460,children:e.jsxs("div",{style:{display:"grid",gap:14},children:[e.jsxs("div",{style:{display:"flex",gap:14,alignItems:"flex-start"},children:[e.jsx("span",{style:{width:44,height:44,borderRadius:12,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",background:"var(--bg-tertiary)",border:"1px solid var(--border)"},children:e.jsx(B,{tipo:"candado",size:22,color:"var(--text-secondary)"})}),e.jsxs("div",{style:{fontSize:14,lineHeight:1.55,color:"var(--text-secondary)"},children:[k.tipo==="clase"?"La clase ":"",e.jsx("b",{style:{color:"var(--text-primary)"},children:k.titulo})," viene con ",(k.planes??[0,0]).length>1?"los planes":"el plan"," ",oe(k.planes),t!=null&&t.miPlan&&t.miPlan!=="admin"?`, y tu plan es ${((Ae=re.find(n=>n.clave===t.miPlan))==null?void 0:Ae.nombre)||t.miPlan}.`:"."," ",k.tipo==="clase"?"Mejora tu plan para verla.":`Mejora tu plan para ver ${k.clases===1?"su clase":`sus ${k.clases} clases`}.`]})]}),e.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:10},children:[e.jsx("button",{type:"button",onClick:()=>q(null),style:ne,children:"Ahora no"}),e.jsx("button",{type:"button",onClick:()=>{q(null),a("/facturacion")},style:{border:"none",background:"var(--accent-blue)",color:"#fff",fontWeight:700,fontSize:14,padding:"10px 18px",borderRadius:11,cursor:"pointer",fontFamily:"inherit"},children:"Ver planes"})]})]})}),r&&t&&e.jsx(Wt,{catalogo:t,sala:r,vistas:g,posiciones:L,onAbrir:le,onCerrar:()=>p(null),onVista:M,onPosicion:J,puedeEditarNotas:pe&&H,onEditarClase:n=>{const o=t.cursos.find(f=>f.id===r.cursoId);o&&j({tipo:"clase",clase:n,curso:o})},hayDialogoEncima:l!==null||k!==null,onGuardarNotas:async(n,o)=>{await G(`/api/academia/admin/clases/${n}`,"PATCH",{notas:o}),await P()}})]})}function Pt({texto:a}){return e.jsx("div",{style:{fontSize:14,lineHeight:1.65,color:"var(--text-primary)",maxWidth:"72ch",overflowWrap:"anywhere"},children:jt(a).map((t,s)=>e.jsx("div",{style:{minHeight:"1.65em",whiteSpace:"pre-wrap"},children:t.map((c,i)=>c.tipo==="enlace"?e.jsx("a",{href:c.href,target:"_blank",rel:"noopener noreferrer nofollow",title:c.valor,style:{color:"var(--accent-blue)",fontWeight:600,textDecoration:"underline",textUnderlineOffset:2},children:St(c.valor)},i):e.jsx(h.Fragment,{children:c.valor},i))},s))})}function Wt({catalogo:a,sala:t,vistas:s,posiciones:c,onAbrir:i,onCerrar:r,onVista:p,onPosicion:g,puedeEditarNotas:S,onGuardarNotas:L,onEditarClase:T,hayDialogoEncima:z}){const x=a.cursos.find(m=>m.id===t.cursoId),d=x?Math.max(0,x.clases.findIndex(m=>m.clave===t.clave)):0,u=x==null?void 0:x.clases[d],l=he((x==null?void 0:x.titulo)||"").color,[j,R]=h.useState(!1),O=h.useRef(0),k=(u==null?void 0:u.notas)||"",[q,A]=h.useState(!1),[E,w]=h.useState(""),[P,M]=h.useState(!1),[J,V]=h.useState(""),U=h.useRef(!1);U.current=q&&E.trim()!==k.trim();const de=h.useRef(!1);de.current=z;const X=()=>!U.current||window.confirm("Tienes notas sin guardar. ¿Salir sin guardarlas?"),se=()=>{X()&&r()},Z=(m,$)=>
25{X()&&i(m,$)};h.useEffect(()=>{A(!1),V("")},[t.clave]);const ie=async()=>{if((u==null?void 0:u.id)!=null){M(!0),V("");try{await L(u.id,E),A(!1)}catch(m){V((m==null?void 0:m.message)||"No se pudieron guardar las notas. Intenta de nuevo.")}finally{M(!1)}}},[_,ee]=h.useState({estado:"cargando"}),le=h.useRef(0),ue=h.useRef(0),pe=async m=>{le.current=Date.now();const $=await fetch(`/api/academia/ver/${m}`,{method:"POST"}),W=await $.json().catch(()=>({}));if(!$.ok||!(W!=null&&W.url))throw new Error((W==null?void 0:W.message)||"No se pudo abrir la clase. Intenta de nuevo.");return{tipo:W.tipo==="bunny"?"bunny":"mp4",url:String(W.url)}};if(h.useEffect(()=>{R(!1),O.current=0,ue.current=0},[t.clave]),h.useEffect(()=>{if(!u)return;if(u.bunny){ee({estado:"listo",tipo:"bunny",url:`https://iframe.mediadelivery.net/embed/${u.bunny.libreria}/${u.bunny.guid}?preload=true&responsive=true&autoplay=true`});return}if(u.id==null){ee({estado:"error",mensaje:"Esta clase todavÃa no tiene video."});return}let m=!0;return ee({estado:"cargando"}),pe(u.id).then($=>{m&&ee({estado:"listo",...$})}).catch($=>{m&&ee({estado:"error",mensaje:($==null?void 0:$.message)||"No se pudo abrir la clase."})}),()=>{m=!1}},[u==null?void 0:u.clave]),h.useEffect(()=>{u&&_.estado==="listo"&&_.tipo==="bunny"&&p(u.clave,!0)},[u==null?void 0:u.clave,_.estado]),h.useEffect(()=>{const m=W=>{W.key!=="Escape"||W.target instanceof HTMLTextAreaElement||de.current||(!U.current||window.confirm("Tienes notas sin guardar. ¿Salir sin guardarlas?"))&&r()};window.addEventListener("keydown",m);const $=document.body.style.overflow;return document.body.style.overflow="hidden",()=>{window.removeEventListener("keydown",m),document.body.style.overflow=$}},[]),!x||!u)return null;const H=x.clases.slice(d+1).find(m=>!m.procesando&&!ce(x,m)),y=[...x.clases.slice(0,d)].reverse().find(m=>!m.procesando&&!ce(x,m)),F=s.has(u.clave),Y=x.clases.filter(m=>s.has(m.clave)).length,te=m=>({display:"inline-flex",alignItems:"center",gap:7,fontSize:13,fontWeight:700,padding:"9px 15px",borderRadius:11,cursor:"pointer",fontFamily:"inherit",border:m?"none":"1px solid var(--border)",background:m?"var(--accent-blue)":"var(--bg-card)",color:m?"#fff":"var(--text-primary)"});return He.createPortal(e.jsx("div",{onClick:se,role:"dialog","aria-modal":"true","aria-label":u.titulo,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(15,18,30,.72)",display:"flex",alignItems:"flex-start",justifyContent:"center",overflowY:"auto",padding:"clamp(0px, 3vw, 32px)"},children:e.jsxs("div",{onClick:m=>m.stopPropagation(),className:"acad-sala",style:{width:"100%",maxWidth:1240,background:"var(--bg-card)",borderRadius:18,overflow:"hidden",boxShadow:"0 40px 90px -30px rgba(0,0,0,.55)"},children:[e.jsx("style",{children:` 26 .acad-sala-cuerpo { display: grid; grid-template-columns: minmax(0, 1fr) 340px; } 27 .acad-sala-lista { border-left: 1px solid var(--border); max-height: calc(min(1240px, 100vw) * 0.5); overflow-y: auto; } 28 @media (max-width: 900px) { 29 .acad-sala-cuerpo { grid-template-columns: minmax(0, 1fr); } 30 .acad-sala-lista { border-left: none; border-top: 1px solid var(--border); max-height: none; } 31 } 32 .acad-fila:hover { background: var(--bg-hover) !important; } 33 `}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,padding:"12px 16px 12px 18px",borderBottom:"1px solid var(--border)"},children:[e.jsx("span",{style:{display:"inline-flex"},children:e.jsx(B,{tipo:he(x.titulo).icono,size:18,color:l})}),e.jsx("div",{style:{flex:1,minWidth:0,fontSize:13.5,fontWeight:700,color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x.titulo}),e.jsx("button",{type:"button",onClick:se,"aria-label":"Cerrar",style:{width:36,height:36,borderRadius:"50%",border:"1px solid var(--border)",background:"var(--bg-card)",color:"var(--text-secondary)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},children:e.jsx(B,{tipo:"cerrar",size:18})})]}),e.jsxs("div",{className:"acad-sala-cuerpo",children:[e.jsxs("div",{style:{minWidth:0},children:[e.jsxs("div",{style:{position:"relative",aspectRatio:"16 / 9",background:"#000"},children:[_.estado==="listo"&&_.tipo==="mp4"?e.jsx("video",{src:_.url,poster:u.poster||void 0,controls:!0,autoPlay:!0,playsInl
33ine:!0,preload:"metadata",controlsList:"nodownload",onContextMenu:m=>m.preventDefault(),style:{position:"absolute",inset:0,width:"100%",height:"100%",background:"#000"},onLoadedMetadata:m=>{const $=m.currentTarget;if(ue.current>0&&$.duration){$.currentTime=Math.min(ue.current,$.duration-1),ue.current=0;return}const W=c[u.clave];W&&W.t>10&&$.duration&&W.t<$.duration-10&&($.currentTime=W.t)},onError:m=>{const $=m.currentTarget.currentTime;u.id==null||Date.now()-le.current<6e4||pe(u.id).then(W=>{ue.current=$,ee({estado:"listo",...W})}).catch(W=>ee({estado:"error",mensaje:(W==null?void 0:W.message)||"No se pudo abrir la clase."}))},onTimeUpdate:m=>{const $=m.currentTarget;$.duration&&(Math.abs($.currentTime-O.current)>=5&&(O.current=$.currentTime,g(u.clave,$.currentTime,$.duration)),$.currentTime/$.duration>=.9&&p(u.clave,!0))},onEnded:m=>{p(u.clave,!0),g(u.clave,0,m.currentTarget.duration),R(!0)}},_.url):_.estado==="listo"&&_.tipo==="bunny"?e.jsx("iframe",{src:_.url,title:u.titulo,style:{border:0,position:"absolute",inset:0,width:"100%",height:"100%"},allow:"accelerometer;gyroscope;autoplay;encrypted-media;picture-in-picture;fullscreen;",allowFullScreen:!0},u.clave):e.jsx("div",{role:_.estado==="error"?"alert":"status",style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",padding:24,textAlign:"center",color:"#cbd5e1",fontSize:14},children:_.estado==="error"?_.mensaje:"Cargando la claseâ¦"}),j&&H&&e.jsxs("div",{style:{position:"absolute",inset:0,background:"rgba(15,18,30,.72)",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:14,padding:20,textAlign:"center"},children:[e.jsx("div",{style:{fontSize:13,color:"#cbd5e1",fontWeight:600},children:"Siguiente clase"}),e.jsx("div",{style:{fontSize:"clamp(16px, 2.2vw, 22px)",color:"#fff",fontWeight:800,maxWidth:560},children:H.titulo}),e.jsxs("div",{style:{display:"flex",gap:10},children:[e.jsxs("button",{type:"button",onClick:()=>Z(x.id,H.clave),style:{...te(!0),padding:"11px 20px",fontSize:14},children:[e.jsx(ze,{size:14})," Ver ahora"]}),e.jsx("button",{type:"button",onClick:()=>R(!1),style:{...te(!1),background:"transparent",color:"#fff",border:"1px solid rgba(255,255,255,.4)"},children:"Quedarme aquÃ"})]})]})]}),e.jsxs("div",{style:{padding:"18px 20px 22px"},children:[e.jsxs("div",{style:{fontSize:12.5,fontWeight:700,color:"var(--text-muted)"},children:["Clase ",d+1," de ",x.clases.length]}),e.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:12},children:[e.jsx("h2",{style:{flex:1,minWidth:0,margin:"4px 0 8px",fontSize:"clamp(18px, 2vw, 22px)",fontWeight:800,color:"var(--text-primary)",letterSpacing:"-.01em",lineHeight:1.3},children:u.titulo}),S&&u.id!=null&&e.jsx("button",{type:"button",onClick:()=>T(u),style:{...te(!1),padding:"6px 12px",fontSize:12.5,marginTop:4,flexShrink:0},children:"Editar clase"})]}),S&&u.planesPropios&&e.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:6,margin:"0 0 10px",fontSize:12.5,fontWeight:700,color:"var(--text-secondary)"},children:[e.jsx(B,{tipo:"candado",size:13,color:"var(--text-secondary)"}),"Esta clase la ven: ",u.planes?oe(u.planes):"todos los planes"]}),u.descripcion&&e.jsx("p",{style:{margin:"0 0 16px",fontSize:14,lineHeight:1.6,color:"var(--text-secondary)",maxWidth:"72ch",whiteSpace:"pre-line"},children:u.descripcion}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,flexWrap:"wrap"},children:[e.jsx("button",{type:"button",onClick:()=>p(u.clave,!F),"aria-pressed":F,style:{...te(!1),...F?{borderColor:"var(--notice-success-border)",background:"var(--notice-success-bg)",color:"var(--notice-success-text)"}:{}},children:F?e.jsxs(e.Fragment,{children:[e.jsx(B,{tipo:"check",size:14})," Vista"]}):"Marcar como vista"}),e.jsx("span",{style:{flex:1}}),y&&e.jsxs("button",{type:"button",onClick:()=>Z(x.id,y.clave),style:te(!1),children:[e.jsx(B,{tipo:"flecha-izq",size:15})," Anterior"]}),H&&e.jsxs("button",{type:"button",onClick:()=>Z(x.id,H.clave),style:te(!0),children:["Siguiente ",e.jsx(B,{tipo:"flecha-der",size:15})]})]}),(k||S&&u.id!=null)&&e.jsxs("section",{"aria-label":"Notas y enlaces de la clase",style:{marginTop:20,paddingTop:16,borderTop:"1px solid var(--border)"},children:[e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginBottom:10},children:[e.jsx("h3",{style:{margin:0,fontSize:15,fontWeight:800,color:"var(--text-primary)"},children:"Notas y enlaces"}),S&&u.id!=null&&k&&!q&&e.jsx("button",{type:"button",onClick:()=>{w(k),A(!0)},style:{...te(!1),padding:"5px 11px",fontSize:12},children:"Editar"})]}),q?e.jsxs("div",{style:{display:"grid",gap:8},children:[e.jsx("label",{htmlFor:"acad-notas",style:{fontSize:12.5,color:"var(--text-secondary)"},children:"Lo que escribas aquà lo ven, debajo del video, quienes tienen acceso a este curso. Los enlaces que empiezan por https:// se abren con un clic."}),e.jsx("textarea",{id:"acad-notas",value:E,onChange:m=>w(m.target.value),maxLength:Be,rows:8,autoFocus:!0,placeholder:`Ej.: 34Plantilla de la campaña: https://⦠35Antes de publicar, revisa que el pÃxel esté conectado.`,style:{width:"100%",boxSizing:"border-box",padding:"10px 12px",fontSize:14,lineHeight:1.55,borderRadius:10,border:"1px solid var(--border)",background:"var(--bg-card)",color:"var(--text-primary)",fontFamily:"inherit",resize:"vertical",minHeight:140}}),J&&e.jsx("div",{role:"alert",style:{padding:"8px 11px",borderRadius:9,fontSize:13,background:"var(--notice-danger-bg)",border:"1px solid var(--notice-danger-border)",color:"var(--notice-danger-text)"},children:J}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,justifyContent:"flex-end",flexWrap:"wrap"},children:[e.jsxs("span",{style:{marginRight:"auto",fontSize:12,color:"var(--text-muted)",fontVariantNumeric:"tabular-nums"}
35,children:[E.length.toLocaleString("es-CO")," / ",Be.toLocaleString("es-CO")]}),e.jsx("button",{type:"button",onClick:()=>A(!1),disabled:P,style:te(!1),children:"Cancelar"}),e.jsx("button",{type:"button",onClick:ie,disabled:P,style:{...te(!0),opacity:P?.7:1},children:P?"Guardandoâ¦":"Guardar notas"})]})]}):k?e.jsx(Pt,{texto:k}):e.jsx("button",{type:"button",onClick:()=>{w(""),A(!0)},style:{width:"100%",padding:"14px 16px",borderRadius:12,border:"1.5px dashed var(--border)",background:"var(--bg-tertiary)",color:"var(--text-secondary)",fontSize:13.5,fontWeight:700,cursor:"pointer",fontFamily:"inherit",textAlign:"left"},children:"+ Agrega notas o enlaces para esta clase"})]})]})]}),e.jsxs("aside",{className:"acad-sala-lista","aria-label":"Clases del curso",children:[e.jsxs("div",{style:{padding:"16px 16px 10px",position:"sticky",top:0,background:"var(--bg-card)",zIndex:1},children:[e.jsx("div",{style:{fontSize:14,fontWeight:800,color:"var(--text-primary)"},children:"Clases del curso"}),e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,marginTop:8,fontSize:12.5,color:"var(--text-muted)",fontVariantNumeric:"tabular-nums"},children:[e.jsx(Ce,{hechas:Y,total:x.clases.length,color:l,ancho:110}),Y," de ",x.clases.length," vistas"]})]}),e.jsx("div",{style:{padding:"0 8px 12px",display:"flex",flexDirection:"column",gap:2},children:x.clases.map((m,$)=>{var Se;const W=m.clave===u.clave,fe=s.has(m.clave),N=ce(x,m),je=m.seccion!=null&&m.seccion!==((Se=x.clases[$-1])==null?void 0:Se.seccion)?(x.secciones||[]).find(Ee=>Ee.id===m.seccion):void 0;return e.jsxs(h.Fragment,{children:[je&&e.jsx("div",{style:{padding:"12px 10px 4px",fontSize:11.5,fontWeight:800,letterSpacing:".04em",textTransform:"uppercase",color:"var(--text-muted)"},children:je.titulo}),e.jsxs("button",{type:"button",className:"acad-fila",disabled:m.procesando||N,onClick:()=>Z(x.id,m.clave),"aria-current":W?"true":void 0,title:N?`Viene con el plan ${oe((m.planesPropios?m.planes:x.planes)??null)}`:void 0,style:{display:"flex",alignItems:"center",gap:11,textAlign:"left",padding:"9px 10px",borderRadius:11,border:"none",cursor:m.procesando||N?"default":"pointer",fontFamily:"inherit",opacity:m.procesando||N?.55:1,background:W?`${l}12`:"transparent",boxShadow:W?`inset 0 0 0 1px ${l}40`:"none"},children:[e.jsx("span",{style:{width:26,height:26,flexShrink:0,borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:800,fontVariantNumeric:"tabular-nums",background:fe?"#047857":W?l:"var(--bg-tertiary)",color:fe||W?"#fff":"var(--text-secondary)",border:fe||W?"none":"1px solid var(--border)"},children:N?e.jsx(B,{tipo:"candado",size:12,color:"var(--text-secondary)"}):fe?e.jsx(B,{tipo:"check",size:12,color:"#fff"}):W?e.jsx(ze,{size:11}):$+1}),e.jsx("span",{style:{flex:1,minWidth:0,fontSize:13.5,fontWeight:W?700:600,color:"var(--text-primary)",lineHeight:1.35,display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical",overflow:"hidden"},children:m.titulo}),e.jsx("span",{style:{fontSize:12,color:"var(--text-muted)",flexShrink:0,fontVariantNumeric:"tabular-nums"},children:m.procesando?"···":ve(m.duracion)})]})]},m.clave)})})]})]})]})}),document.body)}export{It as AcademiaTab};
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.