@johpaz/hive-agents 0.0.21 → 0.0.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{a as e,n as t,r as n,t as r}from"./react-CJr1g6q1.js";import{a as i,c as a,i as o,n as s,o as c,r as l,s as u,t as d}from"./index-B_1DEEUM.js";var f=180/Math.PI,p={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function m(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*f,skewX:Math.atan(c)*f,scaleX:o,scaleY:s}}var h;function g(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?p:m(t.a,t.b,t.c,t.d,t.e,t.f)}function _(e){return e==null||(h||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),h.setAttribute(`transform`,e),!(e=h.transform.baseVal.consolidate()))?p:(e=e.matrix,m(e.a,e.b,e.c,e.d,e.e,e.f))}function v(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,s,c){if(e!==i||r!==a){var l=s.push(`translate(`,null,t,null,n);c.push({i:l-4,x:o(e,i)},{i:l-2,x:o(r,a)})}else (i||a)&&s.push(`translate(`+i+t+a+n)}function s(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:o(e,t)}))}function c(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:o(e,t)})}function l(e,t,n,r,a,s){if(e!==n||t!==r){var c=a.push(i(a)+`scale(`,null,`,`,null,`)`);s.push({i:c-4,x:o(e,n)},{i:c-2,x:o(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),s(t.rotate,n.rotate,r,i),c(t.skewX,n.skewX,r,i),l(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var y=v(g,`px, `,`px)`,`deg)`),b=v(_,`, `,`)`,`)`),x=1e-12;function S(e){return((e=Math.exp(e))+1/e)/2}function C(e){return((e=Math.exp(e))-1/e)/2}function w(e){return((e=Math.exp(2*e))-1)/(e+1)}var T=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<x)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=S(y),c=s/(n*g)*(i*w(t*r+y)-C(y));return[a+c*d,o+c*f,s*i/S(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),E=e(t());function D(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var O=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return O(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return O(t)(e)}}}},k=(e,t)=>(n,r,i)=>{let a={storage:D(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return O(u.getItem.bind(u))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},A={screen:`sessions`,perfil:null,meta:``,program:null,swarmProgress:null,agentStatuses:{},coordinatorState:{status:`idle`,currentWorker:null,activeWorkers:[],totalWorkers:15},selectedProviderId:null,selectedModelId:null,sessionId:null,curriculoId:null,isGenerating:!1,sessionRestored:!1,nodoActualId:null,selectedNodeId:null,xpTotal:0,logrosDesbloqueados:[],nodosCompletados:[],tiempoInicioSesion:null,vidas:3,racha:0,xpFloat:null,respuestasEvaluacion:{},puntajeEvaluacion:null,lastFeedback:null},j=0,M=r()(k((e,t)=>({...A,setScreen:t=>e({screen:t}),setSelectedProvider:t=>e({selectedProviderId:t}),setSelectedModel:t=>e({selectedModelId:t}),setPerfil:t=>e({perfil:t}),setMeta:t=>e({meta:t}),setProgram:t=>e({program:t,tiempoInicioSesion:Date.now(),nodoActualId:t.nodos[0]?.id??null}),setSwarmProgress:t=>e({swarmProgress:t}),setAgentStatus:(t,n)=>e(e=>({agentStatuses:{...e.agentStatuses,[t]:n},coordinatorState:{...e.coordinatorState,activeWorkers:Object.entries({...e.agentStatuses,[t]:n}).filter(([,e])=>e===`running`||e===`thinking`||e===`tool_call`).map(([e])=>e)}})),setCoordinatorStatus:(t,n)=>e(e=>({coordinatorState:{...e.coordinatorState,status:t,currentWorker:n??e.coordinatorState.currentWorker}})),setSessionId:t=>e({sessionId:t}),setCurriculoId:t=>e({curriculoId:t}),setIsGenerating:t=>e({isGenerating:t}),completarNodo:(t,n)=>e(e=>{let r=e.program?.nodos??[],i=r.findIndex(e=>e.id===t),a=i>=0&&i<r.length-1?r[i+1].id:null;return{nodosCompletados:[...e.nodosCompletados,t],xpTotal:e.xpTotal+n,nodoActualId:a??e.nodoActualId,program:e.program?{...e.program,nodos:e.program.nodos.map((e,n)=>e.id===t?{...e,estado:`completado`}:n===i+1?{...e,estado:`disponible`}:e)}:null}}),desbloquearLogro:t=>e(e=>({logrosDesbloqueados:e.logrosDesbloqueados.includes(t)?e.logrosDesbloqueados:[...e.logrosDesbloqueados,t]})),setNodoActual:t=>e({nodoActualId:t}),setLastFeedback:t=>e({lastFeedback:t}),responderEvaluacion:(t,n)=>e(e=>({respuestasEvaluacion:{...e.respuestasEvaluacion,[t]:n}})),setPuntajeEvaluacion:t=>e({puntajeEvaluacion:t}),restoreSession:(t,n)=>e({program:t,sessionId:n.sessionId,xpTotal:n.xpTotal,nodosCompletados:n.nodosCompletados||[],tiempoInicioSesion:Date.now(),nodoActualId:t.nodos[0]?.id??null,sessionRestored:!0,screen:`canvas`}),reset:()=>e(e=>({...A,selectedProviderId:e.selectedProviderId,selectedModelId:e.selectedModelId})),selectNode:t=>e({selectedNodeId:t,lastFeedback:null}),deselectNode:()=>e({selectedNodeId:null,lastFeedback:null}),perderVida:()=>e(e=>({vidas:Math.max(0,e.vidas-1)})),incrementarRacha:()=>e(e=>({racha:e.racha+1})),resetRacha:()=>e({racha:0}),showXpFloat:(n,r)=>{let i=++j;e({xpFloat:{nodeId:n,xp:r,key:i}}),setTimeout(()=>{t().xpFloat?.key===i&&e({xpFloat:null})},1400)}}),{name:`hivelearn-session-v1`,storage:D(()=>localStorage),partialize:e=>({screen:e.screen,program:e.program,sessionId:e.sessionId,curriculoId:e.curriculoId,perfil:e.perfil,meta:e.meta,xpTotal:e.xpTotal,nodosCompletados:e.nodosCompletados,nodoActualId:e.nodoActualId,selectedProviderId:e.selectedProviderId,selectedModelId:e.selectedModelId,vidas:e.vidas,racha:e.racha,logrosDesbloqueados:e.logrosDesbloqueados,swarmProgress:e.swarmProgress,agentStatuses:e.agentStatuses})})),N=u();function P(){let{selectedProviderId:e,selectedModelId:t,setSelectedProvider:n,setSelectedModel:r,setScreen:i}=M(),[a,o]=(0,E.useState)([]),[s,c]=(0,E.useState)([]),[l,u]=(0,E.useState)(!0),[d,f]=(0,E.useState)(null);(0,E.useEffect)(()=>{(async()=>{try{u(!0),f(null),o(((await(await fetch(`/api/providers`)).json()).providers||[]).filter(e=>e.enabled&&e.active)),c(((await(await fetch(`/api/models`)).json()).models||[]).filter(e=>e.enabled&&e.active))}catch(e){f(`Error al cargar proveedores y modelos. Verifica la conexión.`),console.error(`Error fetching providers/models:`,e)}finally{u(!1)}})()},[]);let p=s.filter(t=>t.provider_id===e),m=()=>{e&&t&&i(`profile`)},h=a.find(t=>t.id===e)?.name,g=s.find(e=>e.id===t)?.name;return l?(0,N.jsx)(`div`,{className:`min-h-screen bg-gray-950 flex items-center justify-center p-4 sm:p-6`,children:(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(`div`,{className:`text-5xl sm:text-6xl mb-3 sm:mb-4 animate-pulse`,children:`🐝`}),(0,N.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-blue-400 mb-2`,children:`Cargando...`}),(0,N.jsx)(`p`,{className:`text-sm sm:text-base text-gray-400`,children:`Obteniendo proveedores y modelos disponibles`})]})}):d?(0,N.jsx)(`div`,{className:`min-h-screen bg-gray-950 flex items-center justify-center p-4 sm:p-6`,children:(0,N.jsx)(`div`,{className:`w-full max-w-md bg-gray-900 rounded-xl sm:rounded-2xl border border-gray-800 p-4 sm:p-6 space-y-4`,children:(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(`div`,{className:`text-5xl sm:text-6xl mb-3`,children:`⚠️`}),(0,N.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-red-400 mb-2`,children:`Error`}),(0,N.jsx)(`p`,{className:`text-sm text-gray-400 mb-4`,children:d}),(0,N.jsx)(`button`,{onClick:()=>window.location.reload(),className:`rounded-lg sm:rounded-xl bg-blue-600 px-4 sm:px-6 py-2.5 text-sm font-bold text-white hover:bg-blue-500 transition-all`,children:`Reintentar`})]})})}):a.length===0?(0,N.jsx)(`div`,{className:`min-h-screen bg-gray-950 flex items-center justify-center p-4 sm:p-6`,children:(0,N.jsx)(`div`,{className:`w-full max-w-md bg-gray-900 rounded-xl sm:rounded-2xl border border-gray-800 p-4 sm:p-6 space-y-4`,children:(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(`div`,{className:`text-5xl sm:text-6xl mb-3`,children:`🔧`}),(0,N.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-blue-400 mb-2`,children:`Sin proveedores`}),(0,N.jsx)(`p`,{className:`text-sm text-gray-400 mb-4`,children:`No hay proveedores de IA configurados. Configura al menos uno en Settings > Providers.`}),(0,N.jsx)(`a`,{href:`/providers`,className:`inline-block rounded-lg sm:rounded-xl bg-blue-600 px-4 sm:px-6 py-2.5 text-sm font-bold text-white hover:bg-blue-500 transition-all`,children:`Ir a Providers`})]})})}):(0,N.jsx)(`div`,{className:`min-h-screen bg-gray-950 flex items-center justify-center p-4 sm:p-6`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-md sm:max-w-lg`,children:[(0,N.jsxs)(`div`,{className:`text-center mb-6 sm:mb-8`,children:[(0,N.jsx)(`div`,{className:`text-5xl sm:text-6xl mb-2 sm:mb-3`,children:`🐝`}),(0,N.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold text-blue-400`,children:`HiveLearn`}),(0,N.jsx)(`p`,{className:`text-sm sm:text-base text-gray-400 mt-1`,children:`Selecciona tu proveedor y modelo de IA`})]}),(0,N.jsxs)(`div`,{className:`bg-gray-900 rounded-xl sm:rounded-2xl border border-gray-800 p-4 sm:p-6 space-y-4 sm:space-y-5`,children:[(0,N.jsx)(`h2`,{className:`text-base sm:text-lg font-bold text-white`,children:`Configuración del modelo`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-gray-400 mb-2`,children:`Proveedor de IA`}),(0,N.jsx)(`div`,{className:`grid grid-cols-1 gap-2 max-h-40 sm:max-h-48 overflow-y-auto`,children:a.map(t=>(0,N.jsxs)(`button`,{onClick:()=>{n(t.id),r(null)},className:`rounded-lg py-2.5 sm:py-3 px-3 sm:px-4 text-xs sm:text-sm font-medium border transition-all text-left
1
+ import{a as e,n as t,r as n,t as r}from"./react-CJr1g6q1.js";import{a as i,c as a,i as o,n as s,o as c,r as l,s as u,t as d}from"./index-DnfgD7Re.js";var f=180/Math.PI,p={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function m(e,t,n,r,i,a){var o,s,c;return(o=Math.sqrt(e*e+t*t))&&(e/=o,t/=o),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(s=Math.sqrt(n*n+r*r))&&(n/=s,r/=s,c/=s),e*r<t*n&&(e=-e,t=-t,c=-c,o=-o),{translateX:i,translateY:a,rotate:Math.atan2(t,e)*f,skewX:Math.atan(c)*f,scaleX:o,scaleY:s}}var h;function g(e){let t=new(typeof DOMMatrix==`function`?DOMMatrix:WebKitCSSMatrix)(e+``);return t.isIdentity?p:m(t.a,t.b,t.c,t.d,t.e,t.f)}function _(e){return e==null||(h||=document.createElementNS(`http://www.w3.org/2000/svg`,`g`),h.setAttribute(`transform`,e),!(e=h.transform.baseVal.consolidate()))?p:(e=e.matrix,m(e.a,e.b,e.c,e.d,e.e,e.f))}function v(e,t,n,r){function i(e){return e.length?e.pop()+` `:``}function a(e,r,i,a,s,c){if(e!==i||r!==a){var l=s.push(`translate(`,null,t,null,n);c.push({i:l-4,x:o(e,i)},{i:l-2,x:o(r,a)})}else (i||a)&&s.push(`translate(`+i+t+a+n)}function s(e,t,n,a){e===t?t&&n.push(i(n)+`rotate(`+t+r):(e-t>180?t+=360:t-e>180&&(e+=360),a.push({i:n.push(i(n)+`rotate(`,null,r)-2,x:o(e,t)}))}function c(e,t,n,a){e===t?t&&n.push(i(n)+`skewX(`+t+r):a.push({i:n.push(i(n)+`skewX(`,null,r)-2,x:o(e,t)})}function l(e,t,n,r,a,s){if(e!==n||t!==r){var c=a.push(i(a)+`scale(`,null,`,`,null,`)`);s.push({i:c-4,x:o(e,n)},{i:c-2,x:o(t,r)})}else (n!==1||r!==1)&&a.push(i(a)+`scale(`+n+`,`+r+`)`)}return function(t,n){var r=[],i=[];return t=e(t),n=e(n),a(t.translateX,t.translateY,n.translateX,n.translateY,r,i),s(t.rotate,n.rotate,r,i),c(t.skewX,n.skewX,r,i),l(t.scaleX,t.scaleY,n.scaleX,n.scaleY,r,i),t=n=null,function(e){for(var t=-1,n=i.length,a;++t<n;)r[(a=i[t]).i]=a.x(e);return r.join(``)}}}var y=v(g,`px, `,`px)`,`deg)`),b=v(_,`, `,`)`,`)`),x=1e-12;function S(e){return((e=Math.exp(e))+1/e)/2}function C(e){return((e=Math.exp(e))-1/e)/2}function w(e){return((e=Math.exp(2*e))-1)/(e+1)}var T=(function e(t,n,r){function i(e,i){var a=e[0],o=e[1],s=e[2],c=i[0],l=i[1],u=i[2],d=c-a,f=l-o,p=d*d+f*f,m,h;if(p<x)h=Math.log(u/s)/t,m=function(e){return[a+e*d,o+e*f,s*Math.exp(t*e*h)]};else{var g=Math.sqrt(p),_=(u*u-s*s+r*p)/(2*s*n*g),v=(u*u-s*s-r*p)/(2*u*n*g),y=Math.log(Math.sqrt(_*_+1)-_);h=(Math.log(Math.sqrt(v*v+1)-v)-y)/t,m=function(e){var r=e*h,i=S(y),c=s/(n*g)*(i*w(t*r+y)-C(y));return[a+c*d,o+c*f,s*i/S(t*r+y)]}}return m.duration=h*1e3*t/Math.SQRT2,m}return i.rho=function(t){var n=Math.max(.001,+t),r=n*n;return e(n,r,r*r)},i})(Math.SQRT2,2,4),E=e(t());function D(e,t){let n;try{n=e()}catch{return}return{getItem:e=>{let r=e=>e===null?null:JSON.parse(e,t?.reviver),i=n.getItem(e)??null;return i instanceof Promise?i.then(r):r(i)},setItem:(e,r)=>n.setItem(e,JSON.stringify(r,t?.replacer)),removeItem:e=>n.removeItem(e)}}var O=e=>t=>{try{let n=e(t);return n instanceof Promise?n:{then(e){return O(e)(n)},catch(e){return this}}}catch(e){return{then(e){return this},catch(t){return O(t)(e)}}}},k=(e,t)=>(n,r,i)=>{let a={storage:D(()=>window.localStorage),partialize:e=>e,version:0,merge:(e,t)=>({...t,...e}),...t},o=!1,s=0,c=new Set,l=new Set,u=a.storage;if(!u)return e((...e)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),n(...e)},r,i);let d=()=>{let e=a.partialize({...r()});return u.setItem(a.name,{state:e,version:a.version})},f=i.setState;i.setState=(e,t)=>(f(e,t),d());let p=e((...e)=>(n(...e),d()),r,i);i.getInitialState=()=>p;let m,h=()=>{if(!u)return;let e=++s;o=!1,c.forEach(e=>e(r()??p));let t=a.onRehydrateStorage?.call(a,r()??p)||void 0;return O(u.getItem.bind(u))(a.name).then(e=>{if(e)if(typeof e.version==`number`&&e.version!==a.version){if(a.migrate){let t=a.migrate(e.state,e.version);return t instanceof Promise?t.then(e=>[!0,e]):[!0,t]}console.error(`State loaded from storage couldn't be migrated since no migrate function was provided`)}else return[!1,e.state];return[!1,void 0]}).then(t=>{if(e!==s)return;let[i,o]=t;if(m=a.merge(o,r()??p),n(m,!0),i)return d()}).then(()=>{e===s&&(t?.(r(),void 0),m=r(),o=!0,l.forEach(e=>e(m)))}).catch(n=>{e===s&&t?.(void 0,n)})};return i.persist={setOptions:e=>{a={...a,...e},e.storage&&(u=e.storage)},clearStorage:()=>{u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>o,onHydrate:e=>(c.add(e),()=>{c.delete(e)}),onFinishHydration:e=>(l.add(e),()=>{l.delete(e)})},a.skipHydration||h(),m||p},A={screen:`sessions`,perfil:null,meta:``,program:null,swarmProgress:null,agentStatuses:{},coordinatorState:{status:`idle`,currentWorker:null,activeWorkers:[],totalWorkers:15},selectedProviderId:null,selectedModelId:null,sessionId:null,curriculoId:null,isGenerating:!1,sessionRestored:!1,nodoActualId:null,selectedNodeId:null,xpTotal:0,logrosDesbloqueados:[],nodosCompletados:[],tiempoInicioSesion:null,vidas:3,racha:0,xpFloat:null,respuestasEvaluacion:{},puntajeEvaluacion:null,lastFeedback:null},j=0,M=r()(k((e,t)=>({...A,setScreen:t=>e({screen:t}),setSelectedProvider:t=>e({selectedProviderId:t}),setSelectedModel:t=>e({selectedModelId:t}),setPerfil:t=>e({perfil:t}),setMeta:t=>e({meta:t}),setProgram:t=>e({program:t,tiempoInicioSesion:Date.now(),nodoActualId:t.nodos[0]?.id??null}),setSwarmProgress:t=>e({swarmProgress:t}),setAgentStatus:(t,n)=>e(e=>({agentStatuses:{...e.agentStatuses,[t]:n},coordinatorState:{...e.coordinatorState,activeWorkers:Object.entries({...e.agentStatuses,[t]:n}).filter(([,e])=>e===`running`||e===`thinking`||e===`tool_call`).map(([e])=>e)}})),setCoordinatorStatus:(t,n)=>e(e=>({coordinatorState:{...e.coordinatorState,status:t,currentWorker:n??e.coordinatorState.currentWorker}})),setSessionId:t=>e({sessionId:t}),setCurriculoId:t=>e({curriculoId:t}),setIsGenerating:t=>e({isGenerating:t}),completarNodo:(t,n)=>e(e=>{let r=e.program?.nodos??[],i=r.findIndex(e=>e.id===t),a=i>=0&&i<r.length-1?r[i+1].id:null;return{nodosCompletados:[...e.nodosCompletados,t],xpTotal:e.xpTotal+n,nodoActualId:a??e.nodoActualId,program:e.program?{...e.program,nodos:e.program.nodos.map((e,n)=>e.id===t?{...e,estado:`completado`}:n===i+1?{...e,estado:`disponible`}:e)}:null}}),desbloquearLogro:t=>e(e=>({logrosDesbloqueados:e.logrosDesbloqueados.includes(t)?e.logrosDesbloqueados:[...e.logrosDesbloqueados,t]})),setNodoActual:t=>e({nodoActualId:t}),setLastFeedback:t=>e({lastFeedback:t}),responderEvaluacion:(t,n)=>e(e=>({respuestasEvaluacion:{...e.respuestasEvaluacion,[t]:n}})),setPuntajeEvaluacion:t=>e({puntajeEvaluacion:t}),restoreSession:(t,n)=>e({program:t,sessionId:n.sessionId,xpTotal:n.xpTotal,nodosCompletados:n.nodosCompletados||[],tiempoInicioSesion:Date.now(),nodoActualId:t.nodos[0]?.id??null,sessionRestored:!0,screen:`canvas`}),reset:()=>e(e=>({...A,selectedProviderId:e.selectedProviderId,selectedModelId:e.selectedModelId})),selectNode:t=>e({selectedNodeId:t,lastFeedback:null}),deselectNode:()=>e({selectedNodeId:null,lastFeedback:null}),perderVida:()=>e(e=>({vidas:Math.max(0,e.vidas-1)})),incrementarRacha:()=>e(e=>({racha:e.racha+1})),resetRacha:()=>e({racha:0}),showXpFloat:(n,r)=>{let i=++j;e({xpFloat:{nodeId:n,xp:r,key:i}}),setTimeout(()=>{t().xpFloat?.key===i&&e({xpFloat:null})},1400)}}),{name:`hivelearn-session-v1`,storage:D(()=>localStorage),partialize:e=>({screen:e.screen,program:e.program,sessionId:e.sessionId,curriculoId:e.curriculoId,perfil:e.perfil,meta:e.meta,xpTotal:e.xpTotal,nodosCompletados:e.nodosCompletados,nodoActualId:e.nodoActualId,selectedProviderId:e.selectedProviderId,selectedModelId:e.selectedModelId,vidas:e.vidas,racha:e.racha,logrosDesbloqueados:e.logrosDesbloqueados,swarmProgress:e.swarmProgress,agentStatuses:e.agentStatuses})})),N=u();function P(){let{selectedProviderId:e,selectedModelId:t,setSelectedProvider:n,setSelectedModel:r,setScreen:i}=M(),[a,o]=(0,E.useState)([]),[s,c]=(0,E.useState)([]),[l,u]=(0,E.useState)(!0),[d,f]=(0,E.useState)(null);(0,E.useEffect)(()=>{(async()=>{try{u(!0),f(null),o(((await(await fetch(`/api/providers`)).json()).providers||[]).filter(e=>e.enabled&&e.active)),c(((await(await fetch(`/api/models`)).json()).models||[]).filter(e=>e.enabled&&e.active))}catch(e){f(`Error al cargar proveedores y modelos. Verifica la conexión.`),console.error(`Error fetching providers/models:`,e)}finally{u(!1)}})()},[]);let p=s.filter(t=>t.provider_id===e),m=()=>{e&&t&&i(`profile`)},h=a.find(t=>t.id===e)?.name,g=s.find(e=>e.id===t)?.name;return l?(0,N.jsx)(`div`,{className:`min-h-screen bg-gray-950 flex items-center justify-center p-4 sm:p-6`,children:(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(`div`,{className:`text-5xl sm:text-6xl mb-3 sm:mb-4 animate-pulse`,children:`🐝`}),(0,N.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-blue-400 mb-2`,children:`Cargando...`}),(0,N.jsx)(`p`,{className:`text-sm sm:text-base text-gray-400`,children:`Obteniendo proveedores y modelos disponibles`})]})}):d?(0,N.jsx)(`div`,{className:`min-h-screen bg-gray-950 flex items-center justify-center p-4 sm:p-6`,children:(0,N.jsx)(`div`,{className:`w-full max-w-md bg-gray-900 rounded-xl sm:rounded-2xl border border-gray-800 p-4 sm:p-6 space-y-4`,children:(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(`div`,{className:`text-5xl sm:text-6xl mb-3`,children:`⚠️`}),(0,N.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-red-400 mb-2`,children:`Error`}),(0,N.jsx)(`p`,{className:`text-sm text-gray-400 mb-4`,children:d}),(0,N.jsx)(`button`,{onClick:()=>window.location.reload(),className:`rounded-lg sm:rounded-xl bg-blue-600 px-4 sm:px-6 py-2.5 text-sm font-bold text-white hover:bg-blue-500 transition-all`,children:`Reintentar`})]})})}):a.length===0?(0,N.jsx)(`div`,{className:`min-h-screen bg-gray-950 flex items-center justify-center p-4 sm:p-6`,children:(0,N.jsx)(`div`,{className:`w-full max-w-md bg-gray-900 rounded-xl sm:rounded-2xl border border-gray-800 p-4 sm:p-6 space-y-4`,children:(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(`div`,{className:`text-5xl sm:text-6xl mb-3`,children:`🔧`}),(0,N.jsx)(`h2`,{className:`text-xl sm:text-2xl font-bold text-blue-400 mb-2`,children:`Sin proveedores`}),(0,N.jsx)(`p`,{className:`text-sm text-gray-400 mb-4`,children:`No hay proveedores de IA configurados. Configura al menos uno en Settings > Providers.`}),(0,N.jsx)(`a`,{href:`/providers`,className:`inline-block rounded-lg sm:rounded-xl bg-blue-600 px-4 sm:px-6 py-2.5 text-sm font-bold text-white hover:bg-blue-500 transition-all`,children:`Ir a Providers`})]})})}):(0,N.jsx)(`div`,{className:`min-h-screen bg-gray-950 flex items-center justify-center p-4 sm:p-6`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-md sm:max-w-lg`,children:[(0,N.jsxs)(`div`,{className:`text-center mb-6 sm:mb-8`,children:[(0,N.jsx)(`div`,{className:`text-5xl sm:text-6xl mb-2 sm:mb-3`,children:`🐝`}),(0,N.jsx)(`h1`,{className:`text-2xl sm:text-3xl font-bold text-blue-400`,children:`HiveLearn`}),(0,N.jsx)(`p`,{className:`text-sm sm:text-base text-gray-400 mt-1`,children:`Selecciona tu proveedor y modelo de IA`})]}),(0,N.jsxs)(`div`,{className:`bg-gray-900 rounded-xl sm:rounded-2xl border border-gray-800 p-4 sm:p-6 space-y-4 sm:space-y-5`,children:[(0,N.jsx)(`h2`,{className:`text-base sm:text-lg font-bold text-white`,children:`Configuración del modelo`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-gray-400 mb-2`,children:`Proveedor de IA`}),(0,N.jsx)(`div`,{className:`grid grid-cols-1 gap-2 max-h-40 sm:max-h-48 overflow-y-auto`,children:a.map(t=>(0,N.jsxs)(`button`,{onClick:()=>{n(t.id),r(null)},className:`rounded-lg py-2.5 sm:py-3 px-3 sm:px-4 text-xs sm:text-sm font-medium border transition-all text-left
2
2
  ${e===t.id?`bg-blue-500/20 border-blue-500 text-blue-300`:`bg-gray-800 border-gray-700 text-gray-300 hover:border-blue-500/50`}`,children:[(0,N.jsx)(`div`,{className:`font-bold`,children:t.name}),(0,N.jsxs)(`div`,{className:`text-[10px] sm:text-xs text-gray-500 mt-1`,children:[`ID: `,t.id]})]},t.id))})]}),e&&(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`label`,{className:`block text-xs text-gray-400 mb-2`,children:`Modelo`}),p.length===0?(0,N.jsx)(`div`,{className:`bg-gray-800 border border-gray-700 rounded-lg p-3 text-xs sm:text-sm text-gray-400`,children:`No hay modelos disponibles para este proveedor`}):(0,N.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2 max-h-40 sm:max-h-48 overflow-y-auto`,children:p.map(e=>(0,N.jsxs)(`button`,{onClick:()=>r(e.id),className:`rounded-lg py-2.5 sm:py-3 px-3 sm:px-4 text-xs sm:text-sm font-medium border transition-all text-left
3
3
  ${t===e.id?`bg-blue-500/20 border-blue-500 text-blue-300`:`bg-gray-800 border-gray-700 text-gray-300 hover:border-blue-500/50`}`,children:[(0,N.jsx)(`div`,{className:`font-bold`,children:e.name}),e.context_window&&(0,N.jsxs)(`div`,{className:`text-[10px] sm:text-xs text-gray-500 mt-1`,children:[`Contexto: `,(e.context_window/1e3).toFixed(0),`K tokens`]})]},e.id))})]}),e&&t&&(0,N.jsxs)(`div`,{className:`bg-blue-500/10 border border-blue-500/50 rounded-lg p-2.5 sm:p-3`,children:[(0,N.jsx)(`div`,{className:`text-[10px] sm:text-xs text-blue-400 mb-1`,children:`Selección actual:`}),(0,N.jsxs)(`div`,{className:`text-xs sm:text-sm text-white`,children:[(0,N.jsx)(`span`,{className:`font-bold`,children:h}),` → `,(0,N.jsx)(`span`,{className:`font-bold`,children:g})]})]}),(0,N.jsx)(`button`,{onClick:m,disabled:!e||!t,className:`w-full rounded-lg sm:rounded-xl bg-blue-600 py-2.5 sm:py-3 text-xs sm:text-sm font-bold text-white hover:bg-blue-500 disabled:opacity-40 disabled:cursor-not-allowed transition-all`,children:`Continuar →`})]})]})})}function F(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4),r=Math.floor(t/36e5),i=Math.floor(t/864e5);return n<60?`hace ${n} min`:r<24?`hace ${r} h`:`hace ${i} día${i===1?``:`s`}`}function I(){let{reset:e,setScreen:t,restoreSession:n,sessionId:r,program:i}=M(),[a,o]=(0,E.useState)([]),[s,c]=(0,E.useState)(!0),[l,u]=(0,E.useState)(null),[d,f]=(0,E.useState)(null),p=async()=>{try{let e=await(await fetch(`/api/hivelearn/sessions`)).json();o(Array.isArray(e)?e:[])}catch{o([])}finally{c(!1)}};(0,E.useEffect)(()=>{p()},[]);let m=()=>{e(),t(`profile`)},h=async e=>{u(e.session_id);try{if(r===e.session_id&&i){t(e.completada?`result`:`canvas`);return}let a=await fetch(`/api/hivelearn/sessions/${e.session_id}`);if(!a.ok)throw Error(`Session not found`);let o=await a.json(),s=JSON.parse(o.nodos_json||`[]`);n({sessionId:o.session_id,alumnoId:o.alumno_id,tema:o.meta??``,topicSlug:o.topic_slug??null,rangoEdad:o.rango_edad,nodos:s,gamificacion:{xpRecompensa:o.xp_total??0,logros:[],mensajeCelebracion:`¡Lección completada!`},evaluacion:{preguntas:[]},perfilAdaptacion:{rangoEdad:o.rango_edad??`adulto`,duracionSesion:o.tiempo_sesion??20,nodosRecomendados:o.total_nodos??s.length,estilo:o.estilo??`visual`,nivelPrevio:o.nivel_previo??`principiante`,tono:`amigable`}},{sessionId:o.session_id,xpTotal:o.xp_total??0,nodosCompletados:[]}),o.completada&&t(`result`)}catch(e){console.error(`[SessionsListScreen] handleContinue error:`,e)}finally{u(null)}},g=async e=>{if(window.confirm(`¿Eliminar esta sesión? No se puede deshacer.`)){f(e);try{await fetch(`/api/hivelearn/sessions/${e}`,{method:`DELETE`}),o(t=>t.filter(t=>t.session_id!==e))}catch{}finally{f(null)}}};return(0,N.jsxs)(`div`,{className:`flex-1 flex flex-col min-h-0 bg-gray-950 p-6 overflow-y-auto`,children:[(0,N.jsxs)(`div`,{className:`flex items-center justify-between mb-8`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`span`,{className:`text-3xl`,children:`🐝`}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold text-white`,children:`HiveLearn`}),(0,N.jsx)(`p`,{className:`text-xs text-gray-500`,children:`Tus sesiones de aprendizaje`})]})]}),(0,N.jsx)(`button`,{onClick:m,className:`flex items-center gap-2 px-5 py-2.5 rounded-full bg-blue-600 hover:bg-blue-500 text-white text-sm font-bold transition-all hover:scale-[1.03] active:scale-[0.97]`,children:`+ Nueva lección`})]}),s?(0,N.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(`div`,{className:`text-5xl mb-3 animate-pulse`,children:`🐝`}),(0,N.jsx)(`p`,{className:`text-gray-400 text-sm`,children:`Cargando sesiones...`})]})}):a.length===0?(0,N.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,N.jsxs)(`div`,{className:`text-center space-y-4`,children:[(0,N.jsx)(`div`,{className:`text-6xl`,children:`📚`}),(0,N.jsx)(`h2`,{className:`text-lg font-bold text-white`,children:`Sin sesiones aún`}),(0,N.jsx)(`p`,{className:`text-gray-500 text-sm`,children:`Crea tu primera lección personalizada`}),(0,N.jsx)(`button`,{onClick:m,className:`px-6 py-3 rounded-full bg-blue-600 hover:bg-blue-500 text-white text-sm font-bold transition-all`,children:`+ Nueva lección`})]})}):(0,N.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4`,children:a.map(e=>{let t=!!e.completada,n=e.total_nodos>0?Math.round(e.nodos_completados/e.total_nodos*100):0,r=l===e.session_id||d===e.session_id;return(0,N.jsxs)(`div`,{className:`rounded-2xl bg-gray-900 border border-gray-800 p-5 flex flex-col gap-4 hover:border-gray-700 transition-colors`,children:[(0,N.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,N.jsx)(`span`,{className:`text-xs font-bold px-2.5 py-1 rounded-full ${t?`bg-green-500/15 text-green-400`:`bg-blue-500/15 text-blue-400`}`,children:t?`✅ Completada`:`🔵 En progreso`}),(0,N.jsx)(`span`,{className:`text-[11px] text-gray-600`,children:F(e.created_at)})]}),(0,N.jsxs)(`div`,{children:[(0,N.jsx)(`p`,{className:`text-white font-semibold text-sm leading-snug line-clamp-2`,children:e.meta||`Sin tema`}),(0,N.jsx)(`p`,{className:`text-gray-500 text-xs mt-1`,children:e.nombre||e.alumno_id})]}),(0,N.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,N.jsxs)(`div`,{className:`flex justify-between text-xs text-gray-500`,children:[(0,N.jsxs)(`span`,{children:[e.nodos_completados,`/`,e.total_nodos,` nodos`]}),t&&e.evaluacion_puntaje!=null&&(0,N.jsxs)(`span`,{className:`text-amber-400 font-bold`,children:[e.evaluacion_puntaje,`%`]})]}),(0,N.jsx)(`div`,{className:`h-1.5 rounded-full bg-gray-800 overflow-hidden`,children:(0,N.jsx)(`div`,{className:`h-full rounded-full transition-all ${t?`bg-green-500`:`bg-blue-500`}`,style:{width:`${n}%`}})})]}),(0,N.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,N.jsx)(`span`,{className:`text-yellow-400 text-sm`,children:`⚡`}),(0,N.jsxs)(`span`,{className:`text-xs text-gray-400`,children:[e.xp_total,` XP · `,e.nivel_alcanzado]})]}),(0,N.jsxs)(`div`,{className:`flex gap-2 mt-auto pt-2 border-t border-gray-800`,children:[(0,N.jsx)(`button`,{onClick:()=>h(e),disabled:r,className:`flex-1 py-2 rounded-xl bg-blue-600/20 hover:bg-blue-600/30 text-blue-400 text-xs font-bold transition-colors disabled:opacity-50`,children:l===e.session_id?`Cargando...`:t?`Ver resultado`:`Continuar`}),(0,N.jsx)(`button`,{onClick:()=>g(e.session_id),disabled:r,className:`px-3 py-2 rounded-xl bg-red-500/10 hover:bg-red-500/20 text-red-400 text-xs transition-colors disabled:opacity-50`,title:`Eliminar sesión`,children:d===e.session_id?`...`:`🗑`})]})]},e.session_id)})})]})}function L(e){return e<=12?`nino`:e<=17?`adolescente`:`adulto`}var R={surfaceDim:`#0b1326`,surfaceContainerLowest:`#060e20`,surfaceContainerLow:`#131b2e`,surfaceContainerHigh:`#222a3d`,surfaceContainerHighest:`#2d3449`,primary:`#adc6ff`,primaryContainer:`#4d8eff`,secondary:`#ddb7ff`,secondaryContainer:`#6f00be`,onSurface:`#dae2fd`,onSurfaceVariant:`#c2c6d6`,onPrimaryFixed:`#001a42`,onPrimaryContainer:`#00285d`,outlineVariant:`#424754`,outline:`#8c909f`};function z(){return(0,N.jsxs)(`section`,{className:`flex w-[38%] xl:w-[40%] relative overflow-hidden flex-shrink-0 flex-col justify-between p-10 xl:p-12`,style:{backgroundColor:R.surfaceContainerLowest},children:[(0,N.jsxs)(`div`,{className:`absolute inset-0 z-0 pointer-events-none`,children:[(0,N.jsx)(`div`,{className:`absolute top-[-10%] right-[-10%] w-4/5 h-4/5 rounded-full`,style:{background:`radial-gradient(circle, ${R.primary}1a 0%, transparent 70%)`,filter:`blur(120px)`}}),(0,N.jsx)(`div`,{className:`absolute bottom-[-10%] left-[-10%] w-3/5 h-3/5 rounded-full`,style:{background:`radial-gradient(circle, ${R.secondary}1a 0%, transparent 70%)`,filter:`blur(100px)`}}),(0,N.jsx)(`img`,{src:`https://lh3.googleusercontent.com/aida-public/AB6AXuBGkgnfwJu1-vMqP18oBByE9qATAqmHAP3bSVLJ3EbK2jMB_AzAJgpyhYwBp5H5qcaJ7yjI-KwcyJtKLA1Jrvr4ETMSd-rkoqNfZws67nyBf_Plr9drWFQ5eGXP6asG_25PI6ihYhrKTqcUqaLpHdaMQNPKOOoPzJGAEddbDCawKI32IcTMgTeNusNLroHRO5mU90Ay0u0A-rAXYpNXUU9-AY2WhGSjsjhkaaVWlW9KxVrCPRJkN7rPGutl7bQtxPJCOmu23Icx224`,alt:`Abstract 3D digital sculpture of interconnected glowing nodes`,className:`w-full h-full object-cover scale-110`,style:{opacity:.35,mixBlendMode:`lighten`}}),(0,N.jsx)(`div`,{className:`absolute inset-0`,style:{background:`linear-gradient(to right, transparent 55%, ${R.surfaceContainerLowest}ee 100%)`}})]}),(0,N.jsx)(`div`,{className:`relative z-10 flex items-center gap-2`,children:(0,N.jsx)(`span`,{className:`text-2xl font-extrabold tracking-tight`,style:{fontFamily:`'Manrope', 'Inter', sans-serif`,color:R.onSurface},children:`🐝 HiveLearn`})}),(0,N.jsxs)(`div`,{className:`relative z-10 max-w-sm`,children:[(0,N.jsxs)(`h2`,{className:`text-4xl font-extrabold leading-tight mb-6`,style:{fontFamily:`'Manrope', 'Inter', sans-serif`,color:R.onSurface,letterSpacing:`-0.02em`},children:[`Eleva tu`,` `,(0,N.jsx)(`span`,{style:{color:R.primary},children:`curiosidad`}),` `,`al siguiente nivel.`]}),(0,N.jsx)(`p`,{className:`text-lg leading-relaxed font-light`,style:{color:R.onSurfaceVariant},children:`Únete a la red de conocimiento más avanzada, diseñada para adaptarse a tu ritmo y estilo único de aprendizaje.`})]}),(0,N.jsxs)(`div`,{className:`relative z-10 flex items-center gap-3 text-sm font-medium`,style:{color:`${R.onSurfaceVariant}77`},children:[(0,N.jsx)(`span`,{className:`w-2 h-2 rounded-full animate-pulse`,style:{backgroundColor:R.secondary}}),`Digital Nocturne Experience v1.0`]})]})}function B(){let{setPerfil:e,setScreen:t}=M(),[n,r]=(0,E.useState)({nombre:``,edad:16,tiempoSesion:30,nivelPrevio:`principiante`,estilo:`balanceado`}),[i,a]=(0,E.useState)(null),o=()=>{n.nombre.trim()&&(e({alumnoId:`alumno-${Date.now()}`,nombre:n.nombre.trim(),edad:n.edad,rangoEdad:L(n.edad),tiempoSesion:n.tiempoSesion,nivelPrevio:n.nivelPrevio,estilo:n.estilo,sesionesTotal:0,xpAcumulado:0,nivelActual:`Aprendiz`}),t(`goal`))},s=L(n.edad),c=s===`nino`?`🐣`:s===`adolescente`?`🚀`:`🎯`,l=s===`nino`?`Niño`:s===`adolescente`?`Adolescente`:`Adulto`;return(0,N.jsxs)(`div`,{className:`flex h-full overflow-hidden`,style:{backgroundColor:R.surfaceDim},children:[(0,N.jsx)(z,{}),(0,N.jsx)(`section`,{className:`w-full lg:w-[60%] flex flex-col overflow-y-auto`,style:{backgroundColor:R.surfaceDim},children:(0,N.jsxs)(`div`,{className:`w-full max-w-xl mx-auto px-6 pt-8 pb-10 sm:px-10 sm:pt-10`,children:[(0,N.jsxs)(`div`,{className:`hidden`,style:{fontFamily:`'Manrope', sans-serif`,fontWeight:700,fontSize:`1.25rem`,color:R.onSurface},children:[`🐝 `,(0,N.jsx)(`span`,{children:`HiveLearn`})]}),(0,N.jsxs)(`header`,{className:`mb-10`,children:[(0,N.jsx)(`h1`,{className:`text-3xl md:text-4xl font-black tracking-tight mb-3`,style:{fontFamily:`'Manrope', 'Inter', sans-serif`,color:R.onSurface,letterSpacing:`-0.02em`},children:`¿Quién va a aprender hoy?`}),(0,N.jsx)(`p`,{className:`text-base md:text-lg`,style:{color:R.onSurfaceVariant},children:`Configura tu perfil de Scholar para comenzar la exploración.`})]}),(0,N.jsxs)(`div`,{className:`rounded-2xl p-7 sm:p-9 space-y-7`,style:{backgroundColor:`${R.surfaceContainerLow}99`,backdropFilter:`blur(24px)`,WebkitBackdropFilter:`blur(24px)`,boxShadow:`0 0 60px -12px ${R.primary}1f`},children:[(0,N.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5`,children:[(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`label`,{className:`block text-xs font-bold uppercase tracking-widest`,style:{color:R.primary,fontFamily:`'Inter', sans-serif`},children:`Nombre del Scholar`}),(0,N.jsx)(`input`,{className:`w-full rounded-xl px-4 py-3 text-sm placeholder:text-opacity-40 transition-all`,style:{...(e=>({backgroundColor:R.surfaceContainerLowest,border:`none`,outline:`none`,boxShadow:i===e?`0 0 0 2px ${R.primary}`:`0 0 0 1px ${R.outlineVariant}33`,color:R.onSurface,transition:`box-shadow 200ms ease`}))(`nombre`),fontFamily:`inherit`},placeholder:`Ej. Alex Rivera`,value:n.nombre,onChange:e=>r(t=>({...t,nombre:e.target.value})),onFocus:()=>a(`nombre`),onBlur:()=>a(null),onKeyDown:e=>e.key===`Enter`&&o()})]}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`label`,{className:`block text-xs font-bold uppercase tracking-widest`,style:{color:R.primary,fontFamily:`'Inter', sans-serif`},children:`Edad`}),(0,N.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,N.jsx)(`input`,{type:`range`,min:6,max:60,value:n.edad,onChange:e=>r(t=>({...t,edad:Number(e.target.value)})),className:`flex-1`,style:{accentColor:R.primary}}),(0,N.jsxs)(`div`,{className:`text-right flex-shrink-0`,style:{minWidth:`72px`},children:[(0,N.jsxs)(`p`,{className:`text-sm font-bold`,style:{color:R.primary},children:[n.edad,` años`]}),(0,N.jsxs)(`p`,{className:`text-[10px]`,style:{color:R.onSurfaceVariant},children:[c,` `,l]})]})]})]})]}),(0,N.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-5`,children:[(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`label`,{className:`block text-xs font-bold uppercase tracking-widest`,style:{color:R.primary,fontFamily:`'Inter', sans-serif`},children:`Tiempo de Sesión`}),(0,N.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:[15,30,45].map(e=>{let t=n.tiempoSesion===e;return(0,N.jsxs)(`button`,{onClick:()=>r(t=>({...t,tiempoSesion:e})),className:`py-2.5 rounded-xl text-sm font-bold transition-all duration-200 hover:-translate-y-0.5 active:scale-95`,style:{backgroundColor:t?`${R.primary}22`:`${R.surfaceContainerHighest}66`,color:t?R.primary:R.onSurfaceVariant,boxShadow:t?`0 0 0 1px ${R.primary}55, 0 0 14px ${R.primary}18`:`0 0 0 1px ${R.outlineVariant}20`},children:[e,` min`]},e)})})]}),(0,N.jsxs)(`div`,{className:`space-y-2`,children:[(0,N.jsx)(`label`,{className:`block text-xs font-bold uppercase tracking-widest`,style:{color:R.primary,fontFamily:`'Inter', sans-serif`},children:`Experiencia Previa`}),(0,N.jsx)(`div`,{className:`grid grid-cols-3 gap-2`,children:[[`principiante`,`🌱`,`Explorador`],[`principiante_base`,`🌿`,`Practicante`],[`intermedio`,`🌳`,`Maestro`]].map(([e,t,i])=>{let a=n.nivelPrevio===e;return(0,N.jsxs)(`button`,{onClick:()=>r(t=>({...t,nivelPrevio:e})),className:`py-3 rounded-xl text-xs font-medium flex flex-col items-center gap-1 transition-all duration-200 hover:-translate-y-0.5 active:scale-95`,style:{backgroundColor:a?`${R.secondaryContainer}22`:`${R.surfaceContainerHighest}66`,color:a?R.secondary:R.onSurfaceVariant,boxShadow:a?`0 0 0 1px ${R.secondary}55`:`0 0 0 1px ${R.outlineVariant}18`},children:[(0,N.jsx)(`span`,{className:`text-lg`,children:t}),(0,N.jsx)(`span`,{children:i})]},e)})})]})]}),(0,N.jsxs)(`div`,{className:`space-y-3`,children:[(0,N.jsx)(`label`,{className:`block text-xs font-bold uppercase tracking-widest`,style:{color:R.primary,fontFamily:`'Inter', sans-serif`},children:`Estilo de Aprendizaje`}),(0,N.jsx)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-3`,children:[[`visual`,`🎨`,`Visual`],[`lectura`,`📖`,`Leyendo`],[`retos`,`🏆`,`Con retos`],[`balanceado`,`⚖️`,`Balanceado`]].map(([e,t,i])=>{let a=n.estilo===e;return(0,N.jsxs)(`button`,{onClick:()=>r(t=>({...t,estilo:e})),className:`flex flex-col items-center justify-center p-4 rounded-xl text-xs font-semibold transition-all duration-300 group hover:-translate-y-0.5 active:scale-95`,style:{backgroundColor:a?`${R.secondaryContainer}22`:`${R.surfaceContainerHighest}44`,color:a?R.secondary:R.onSurfaceVariant,boxShadow:a?`0 0 0 1px ${R.secondary}77, 0 0 18px ${R.secondary}14`:`0 0 0 1px ${R.outlineVariant}18`},children:[(0,N.jsx)(`span`,{className:`text-2xl mb-2 transition-transform duration-300 group-hover:scale-110`,style:{display:`block`},children:t}),i]},e)})})]}),(0,N.jsxs)(`div`,{className:`pt-2 flex flex-col gap-3`,children:[(0,N.jsxs)(`button`,{onClick:o,disabled:!n.nombre.trim(),className:`w-full py-4 px-8 rounded-full font-bold text-base flex items-center justify-center gap-3 transition-all duration-200 hover:scale-[1.02] active:scale-[0.97] disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:scale-100`,style:{background:`linear-gradient(135deg, ${R.primary}, ${R.primaryContainer})`,color:R.onPrimaryFixed,boxShadow:`0 8px 30px ${R.primary}2a, 0 4px 12px ${R.primaryContainer}33`,fontFamily:`'Manrope', 'Inter', sans-serif`},onMouseEnter:e=>{n.nombre.trim()&&(e.currentTarget.style.boxShadow=`0 12px 40px ${R.primary}44, 0 4px 16px ${R.primaryContainer}44`)},onMouseLeave:e=>{e.currentTarget.style.boxShadow=`0 8px 30px ${R.primary}2a, 0 4px 12px ${R.primaryContainer}33`},children:[`Comenzar Expedición`,(0,N.jsx)(`span`,{"aria-hidden":!0,children:`→`})]}),(0,N.jsx)(`button`,{onClick:()=>t(`sessions`),className:`w-full py-2.5 rounded-full text-sm font-medium text-gray-500 hover:text-gray-300 transition-colors`,children:`← Mis sesiones`})]})]}),(0,N.jsxs)(`div`,{className:`mt-8 flex items-center justify-center gap-8`,children:[(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,N.jsx)(`div`,{className:`w-2 h-2 rounded-full`,style:{backgroundColor:R.primary,boxShadow:`0 0 0 4px ${R.primary}33`}}),(0,N.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider`,style:{color:R.primary},children:`Perfil`})]}),(0,N.jsx)(`div`,{className:`w-12 h-px`,style:{backgroundColor:`${R.outlineVariant}33`}}),(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,N.jsx)(`div`,{className:`w-2 h-2 rounded-full`,style:{backgroundColor:`${R.outlineVariant}55`}}),(0,N.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider`,style:{color:`${R.onSurfaceVariant}55`},children:`Intereses`})]}),(0,N.jsx)(`div`,{className:`w-12 h-px`,style:{backgroundColor:`${R.outlineVariant}33`}}),(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5`,children:[(0,N.jsx)(`div`,{className:`w-2 h-2 rounded-full`,style:{backgroundColor:`${R.outlineVariant}55`}}),(0,N.jsx)(`span`,{className:`text-[10px] font-bold uppercase tracking-wider`,style:{color:`${R.onSurfaceVariant}55`},children:`Plan`})]})]})]})}),(0,N.jsx)(`div`,{className:`fixed bottom-8 right-8 w-16 h-16 rounded-full pointer-events-none animate-pulse`,style:{background:`radial-gradient(circle, ${R.secondary}, ${R.secondaryContainer})`,filter:`blur(24px)`,opacity:.35}})]})}function ee(){let{setProgram:e,setSwarmProgress:t,setScreen:n,selectedProviderId:r,selectedModelId:i,setSessionId:a,setCurriculoId:o,setIsGenerating:s,setAgentStatus:c}=M();return{generateLesson:(0,E.useCallback)(async(l,u)=>{if(!r||!i){console.error(`HiveLearn: providerId y modelId son requeridos`);return}n(`loading`),s(!0),t({etapa:`tier0`,agenteActivo:`ProfileAgent`,porcentaje:2,mensaje:`Iniciando el enjambre de agentes...`});try{let d=await fetch(`/api/hivelearn/generate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({perfil:l,meta:u,providerId:r,modelId:i})});if(!d.ok||!d.body)throw Error(`Error del servidor: ${d.status}`);let f=d.body.getReader(),p=new TextDecoder,m=``;for(;;){let{done:r,value:i}=await f.read();if(r)break;m+=p.decode(i,{stream:!0});let l=m.split(`
4
4