🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 line
104 KiB
JavaScript
1 line
104 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[644],{9644:function(e,s,t){Promise.resolve().then(t.bind(t,7815))},7815:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return O}});var a=t(7437),r=t(2265),l=t(9186),i=t(3217),n=t(6610),c=t(887),d=t(1226),o=t(1809),m=t(1706),x=t(7154),u=t(6754),h=t(832),p=t(787),y=t(7287),b=t(1543),g=t(9367),v=t(2893),j=t(2938),N=t(7057),f=t(6108),w=t(4238),z=t(4713),S=t(1095),k=t(9172),C=t(3770),P=t(6689),A=t(5290),I=t(1039),Z=t(5255),T=t(9649),E=t(4020),U=t(5468),D=t(893);let R=[{id:"terms",title:"Terms & Conditions",description:"Review and accept the software license agreement",component:function(e){var s;let{systemInfo:t,configData:i,onComplete:d,onBack:o,isCompleted:m}=e,[x,u]=(0,r.useState)((null==i?void 0:null===(s=i.terms)||void 0===s?void 0:s.agreed)||!1),[h,p]=(0,r.useState)("");return(0,a.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!x){p("You must agree to the Terms and Conditions to continue");return}p(""),d({terms:{agreed:!0,timestamp:new Date().toISOString()}})},className:"space-y-8",children:[(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Terms and Conditions"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Please review and accept the terms and conditions to continue with BZZZ setup."})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)(n.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"BZZZ Software License Agreement"})]}),(0,a.jsx)("div",{className:"bg-gray-50 border border-gray-200 rounded-lg p-6 max-h-96 overflow-y-auto",children:(0,a.jsxs)("div",{className:"prose prose-sm max-w-none text-gray-700",children:[(0,a.jsx)("h4",{className:"text-base font-semibold text-gray-900 mb-3",children:"1. License Grant"}),(0,a.jsx)("p",{className:"mb-4",children:'Subject to the terms and conditions of this Agreement, Chorus Services grants you a non-exclusive, non-transferable license to use BZZZ (the "Software") for distributed AI coordination and task management.'}),(0,a.jsx)("h4",{className:"text-base font-semibold text-gray-900 mb-3",children:"2. Permitted Uses"}),(0,a.jsxs)("ul",{className:"list-disc list-inside mb-4 space-y-1",children:[(0,a.jsx)("li",{children:"Install and operate BZZZ on your infrastructure"}),(0,a.jsx)("li",{children:"Configure cluster nodes for distributed processing"}),(0,a.jsx)("li",{children:"Integrate with supported AI models and services"}),(0,a.jsx)("li",{children:"Use for commercial and non-commercial purposes"})]}),(0,a.jsx)("h4",{className:"text-base font-semibold text-gray-900 mb-3",children:"3. Restrictions"}),(0,a.jsxs)("ul",{className:"list-disc list-inside mb-4 space-y-1",children:[(0,a.jsx)("li",{children:"You may not redistribute, sublicense, or sell the Software"}),(0,a.jsx)("li",{children:"You may not reverse engineer or decompile the Software"}),(0,a.jsx)("li",{children:"You may not use the Software for illegal or harmful purposes"}),(0,a.jsx)("li",{children:"You may not remove or modify proprietary notices"})]}),(0,a.jsx)("h4",{className:"text-base font-semibold text-gray-900 mb-3",children:"4. Data Privacy"}),(0,a.jsx)("p",{className:"mb-4",children:"BZZZ processes data locally on your infrastructure. Chorus Services does not collect or store your operational data. Telemetry data may be collected for software improvement purposes."}),(0,a.jsx)("h4",{className:"text-base font-semibold text-gray-900 mb-3",children:"5. Support and Updates"}),(0,a.jsx)("p",{className:"mb-4",children:"Licensed users receive access to software updates, security patches, and community support. Premium support tiers are available separately."}),(0,a.jsx)("h4",{className:"text-base font-semibold text-gray-900 mb-3",children:"6. Disclaimer of Warranty"}),(0,a.jsx)("p",{className:"mb-4",children:'THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. CHORUS SERVICES DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.'}),(0,a.jsx)("h4",{className:"text-base font-semibold text-gray-900 mb-3",children:"7. Limitation of Liability"}),(0,a.jsx)("p",{className:"mb-4",children:"IN NO EVENT SHALL CHORUS SERVICES BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THE SOFTWARE."}),(0,a.jsx)("h4",{className:"text-base font-semibold text-gray-900 mb-3",children:"8. Termination"}),(0,a.jsx)("p",{className:"mb-4",children:"This license is effective until terminated. You may terminate it at any time by uninstalling the Software. Chorus Services may terminate this license if you violate any terms of this Agreement."}),(0,a.jsx)("div",{className:"bg-blue-50 border-l-4 border-blue-400 p-4 mt-6",children:(0,a.jsxs)("div",{className:"flex",children:[(0,a.jsx)(c.Z,{className:"h-5 w-5 text-blue-500 mt-0.5 mr-2"}),(0,a.jsxs)("div",{className:"text-sm text-blue-700",children:[(0,a.jsx)("p",{children:(0,a.jsx)("strong",{children:"Contact Information:"})}),(0,a.jsxs)("p",{children:["Chorus Services",(0,a.jsx)("br",{}),"Email: legal@chorus.services",(0,a.jsx)("br",{}),"Website: https://chorus.services"]})]})]})})]})})]}),(0,a.jsx)("div",{className:"card",children:(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("label",{className:"flex items-start",children:[(0,a.jsx)("input",{type:"checkbox",checked:x,onChange:e=>u(e.target.checked),className:"mt-1 mr-3 h-4 w-4 text-bzzz-primary border-gray-300 rounded focus:ring-bzzz-primary"}),(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsx)("span",{className:"font-medium text-gray-900",children:"I have read and agree to the Terms and Conditions"}),(0,a.jsx)("p",{className:"text-gray-600 mt-1",children:"By checking this box, you acknowledge that you have read, understood, and agree to be bound by the terms and conditions outlined above."})]})]}),h&&(0,a.jsxs)("div",{className:"flex items-center text-red-600 text-sm",children:[(0,a.jsx)(c.Z,{className:"h-4 w-4 mr-1"}),h]}),x&&(0,a.jsxs)("div",{className:"flex items-center text-green-600 text-sm",children:[(0,a.jsx)(l.Z,{className:"h-4 w-4 mr-1"}),"Thank you for accepting the terms and conditions"]})]})}),(0,a.jsxs)("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[(0,a.jsx)("div",{children:o&&(0,a.jsx)("button",{type:"button",onClick:o,className:"btn-outline",children:"Back"})}),(0,a.jsx)("button",{type:"submit",disabled:!x,className:"".concat(x?"btn-primary":"btn-disabled"),children:m?"Continue":"Next: License Validation"})]})]})}},{id:"license",title:"License Validation",description:"Validate your BZZZ license key and email",component:function(e){var s,t,i;let{systemInfo:m,configData:x,onComplete:u,onBack:h,isCompleted:p}=e,[y,b]=(0,r.useState)({email:(null==x?void 0:null===(s=x.license)||void 0===s?void 0:s.email)||"",licenseKey:(null==x?void 0:null===(t=x.license)||void 0===t?void 0:t.licenseKey)||"",organizationName:(null==x?void 0:null===(i=x.license)||void 0===i?void 0:i.organizationName)||""}),[g,v]=(0,r.useState)(!1),[j,N]=(0,r.useState)(null),[f,w]=(0,r.useState)(""),z=e=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e),S=y.email&&z(y.email)&&y.licenseKey,k=async()=>{if(!y.email||!y.licenseKey){w("Both email and license key are required");return}if(!z(y.email)){w("Please enter a valid email address");return}v(!0),w(""),N(null);try{let e=await fetch("/api/setup/license/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:y.email,licenseKey:y.licenseKey,organizationName:y.organizationName})}),s=await e.json();e.ok&&s.valid?N({valid:!0,message:s.message||"License validated successfully",details:s.details}):N({valid:!1,message:s.message||"License validation failed",details:s.details})}catch(e){console.error("License validation error:",e),N({valid:!1,message:"Failed to validate license. Please check your connection and try again."})}finally{v(!1)}};return(0,a.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!y.email||!y.licenseKey){w("Both email and license key are required");return}if(!(null==j?void 0:j.valid)){w("Please validate your license before continuing");return}w(""),u({license:{...y,validatedAt:new Date().toISOString(),validationDetails:j.details}})},className:"space-y-8",children:[(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"License Validation"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Enter your CHORUS:agents license key and email to activate your installation."})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)(d.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"License Information"}),(null==j?void 0:j.valid)&&(0,a.jsx)(l.Z,{className:"h-5 w-5 text-green-500 ml-2"})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Email Address"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(o.Z,{className:"h-5 w-5 text-gray-400 absolute left-3 top-1/2 transform -translate-y-1/2"}),(0,a.jsx)("input",{type:"email",value:y.email,onChange:e=>b(s=>({...s,email:e.target.value})),placeholder:"your-email@company.com",className:"w-full pl-10 pr-4 py-3 border rounded-lg focus:ring-bzzz-primary focus:border-bzzz-primary ".concat(y.email&&!z(y.email)?"border-red-300 bg-red-50":"border-gray-300"),required:!0})]}),y.email&&!z(y.email)?(0,a.jsx)("p",{className:"text-sm text-red-600 mt-1",children:"Please enter a valid email address"}):(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"The email address associated with your CHORUS:agents license"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"License Key"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(d.Z,{className:"h-5 w-5 text-gray-400 absolute left-3 top-1/2 transform -translate-y-1/2"}),(0,a.jsx)("input",{type:"text",value:y.licenseKey,onChange:e=>b(s=>({...s,licenseKey:e.target.value})),placeholder:"BZZZ-XXXX-XXXX-XXXX-XXXX",className:"w-full pl-10 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-bzzz-primary focus:border-bzzz-primary font-mono",required:!0})]}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Your unique CHORUS:agents license key (found in your purchase confirmation email)"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Organization Name (Optional)"}),(0,a.jsx)("input",{type:"text",value:y.organizationName,onChange:e=>b(s=>({...s,organizationName:e.target.value})),placeholder:"Your Company Name",className:"w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-bzzz-primary focus:border-bzzz-primary"}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Optional: Organization name for license tracking"})]}),(0,a.jsx)("button",{type:"button",onClick:k,disabled:g||!S,className:"w-full py-3 px-4 rounded-lg font-medium transition-colors ".concat(g||!S?"bg-gray-100 text-gray-400 cursor-not-allowed":"bg-bzzz-primary text-white hover:bg-bzzz-primary-dark"),children:g?"Validating License...":"Validate License"})]})]}),j&&(0,a.jsx)("div",{className:"card ".concat(j.valid?"border-green-200 bg-green-50":"border-red-200 bg-red-50"),children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:j.valid?(0,a.jsx)(l.Z,{className:"h-6 w-6 text-green-500"}):(0,a.jsx)(c.Z,{className:"h-6 w-6 text-red-500"})}),(0,a.jsxs)("div",{className:"ml-3",children:[(0,a.jsx)("h4",{className:"text-sm font-medium ".concat(j.valid?"text-green-800":"text-red-800"),children:j.valid?"License Valid":"License Invalid"}),(0,a.jsx)("p",{className:"text-sm mt-1 ".concat(j.valid?"text-green-700":"text-red-700"),children:j.message}),j.valid&&j.details&&(0,a.jsxs)("div",{className:"mt-3 text-sm text-green-700",children:[(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"License Type:"})," ",j.details.licenseType||"Standard"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Max Nodes:"})," ",j.details.maxNodes||"Unlimited"]}),(0,a.jsxs)("p",{children:[(0,a.jsx)("strong",{children:"Expires:"})," ",j.details.expiresAt||"Never"]})]})]})]})}),f&&(0,a.jsxs)("div",{className:"flex items-center text-red-600 text-sm",children:[(0,a.jsx)(c.Z,{className:"h-4 w-4 mr-1"}),f]}),(0,a.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)(n.Z,{className:"h-5 w-5 text-blue-500 mt-0.5 mr-2"}),(0,a.jsxs)("div",{className:"text-sm",children:[(0,a.jsx)("h4",{className:"font-medium text-blue-800 mb-1",children:"Need a License?"}),(0,a.jsx)("p",{className:"text-blue-700",children:"If you don't have a CHORUS:agents license yet, you can:"}),(0,a.jsxs)("ul",{className:"text-blue-700 mt-1 space-y-1 ml-4",children:[(0,a.jsxs)("li",{children:["• Visit ",(0,a.jsx)("a",{href:"https://chorus.services/bzzz",target:"_blank",className:"underline hover:no-underline",children:"chorus.services/bzzz"})," to purchase a license"]}),(0,a.jsxs)("li",{children:["• Contact our sales team at ",(0,a.jsx)("a",{href:"mailto:sales@chorus.services",className:"underline hover:no-underline",children:"sales@chorus.services"})]}),(0,a.jsx)("li",{children:"• Request a trial license for evaluation purposes"})]})]})]})}),(0,a.jsxs)("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[(0,a.jsx)("div",{children:h&&(0,a.jsx)("button",{type:"button",onClick:h,className:"btn-outline",children:"Back"})}),(0,a.jsx)("button",{type:"submit",disabled:!(null==j?void 0:j.valid),className:"".concat((null==j?void 0:j.valid)?"btn-primary":"btn-disabled"),children:p?"Continue":"Next: System Detection"})]})]})}},{id:"detection",title:"System Detection",description:"Detect hardware and validate installation",component:function(e){let{systemInfo:s,configData:t,onComplete:i,onBack:n,isCompleted:d}=e,[o,y]=(0,r.useState)(!s),[b,g]=(0,r.useState)(!1),[v,j]=(0,r.useState)(s);(0,r.useEffect)(()=>{v||N()},[]);let N=async()=>{g(!0);try{let e=await fetch("/api/setup/system");if(e.ok){let s=await e.json();j(s.system_info)}}catch(e){console.error("Failed to detect system info:",e)}finally{y(!1),g(!1)}},f=e=>e?"text-green-600":"text-red-600",w=e=>e?l.Z:c.Z;return o?(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)(m.Z,{className:"h-8 w-8 text-bzzz-primary animate-spin mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Detecting system configuration..."})]})}):v?(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"System Overview"}),(0,a.jsx)("button",{onClick:N,disabled:b,className:"text-bzzz-primary hover:text-bzzz-primary/80 transition-colors",children:(0,a.jsx)(m.Z,{className:"h-5 w-5 ".concat(b?"animate-spin":"")})})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-700",children:"Hostname"}),(0,a.jsx)("div",{className:"text-lg text-gray-900",children:v.network.hostname})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-700",children:"Operating System"}),(0,a.jsxs)("div",{className:"text-lg text-gray-900",children:[v.os," (",v.architecture,")"]})]})]})]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-6",children:[(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)(x.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"CPU & Memory"})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-700",children:"CPU"}),(0,a.jsxs)("div",{className:"text-gray-900",children:[v.cpu_cores," cores"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-700",children:"Memory"}),(0,a.jsxs)("div",{className:"text-gray-900",children:[Math.round(v.memory_mb/1024)," GB total"]})]})]})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)(u.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"Storage"})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-700",children:"Disk Space"}),(0,a.jsxs)("div",{className:"text-gray-900",children:[v.storage.total_space_gb," GB total, "," ",v.storage.free_space_gb," GB available"]})]}),(0,a.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2",children:(0,a.jsx)("div",{className:"bg-bzzz-primary h-2 rounded-full",style:{width:"".concat((v.storage.total_space_gb-v.storage.free_space_gb)/v.storage.total_space_gb*100,"%")}})})]})]})]}),v.gpus&&v.gpus.length>0&&(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)(h.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900",children:["GPU Configuration (",v.gpus.length," GPU",1!==v.gpus.length?"s":"",")"]})]}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:v.gpus.map((e,s)=>(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-4",children:[(0,a.jsx)("div",{className:"font-medium text-gray-900",children:e.name}),(0,a.jsxs)("div",{className:"text-sm text-gray-600",children:[e.type.toUpperCase()," • ",e.memory," • ",e.driver]})]},s))})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)(p.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"Network Configuration"})]}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-700",children:"Hostname"}),(0,a.jsx)("div",{className:"text-gray-900",children:v.network.hostname})]}),v.network.private_ips&&v.network.private_ips.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-700 mb-2",children:"Private IP Addresses"}),(0,a.jsx)("div",{className:"space-y-2",children:v.network.private_ips.map((e,s)=>(0,a.jsxs)("div",{className:"flex justify-between items-center text-sm",children:[(0,a.jsx)("span",{children:e}),(0,a.jsx)("span",{className:"status-indicator status-online",children:"active"})]},s))})]}),v.network.public_ip&&(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-700",children:"Public IP"}),(0,a.jsx)("div",{className:"text-gray-900",children:v.network.public_ip})]})]})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Software Requirements"}),(0,a.jsx)("div",{className:"space-y-4",children:[{name:"Docker",installed:v.docker.available,version:v.docker.version,required:!0},{name:"Docker Compose",installed:v.docker.compose_available,version:void 0,required:!1},{name:"Docker Swarm",installed:v.docker.swarm_mode,version:void 0,required:!1}].map((e,s)=>{let t=w(e.installed);return(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(t,{className:"h-5 w-5 mr-3 ".concat(f(e.installed))}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"font-medium text-gray-900",children:e.name}),e.version&&(0,a.jsxs)("div",{className:"text-sm text-gray-600",children:["Version: ",e.version]})]})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[e.required&&(0,a.jsx)("span",{className:"text-xs bg-bzzz-primary text-white px-2 py-1 rounded mr-2",children:"Required"}),(0,a.jsx)("span",{className:"text-sm font-medium ".concat(f(e.installed)),children:e.installed?"Installed":"Missing"})]})]},s)})})]}),(0,a.jsxs)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-6",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-blue-900 mb-4",children:"System Validation"}),(0,a.jsx)("div",{className:"space-y-2",children:[{check:"Minimum memory (2GB required)",passed:v.memory_mb>=2048,warning:v.memory_mb<4096},{check:"Available disk space (10GB required)",passed:v.storage.free_space_gb>=10},{check:"Docker installed and running",passed:v.docker.available}].map((e,s)=>{let t=w(e.passed);return(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(t,{className:"h-4 w-4 mr-3 ".concat(e.passed?"text-green-600":"text-red-600")}),(0,a.jsxs)("span",{className:"text-sm ".concat(e.passed?"text-green-800":"text-red-800"),children:[e.check,e.warning&&e.passed&&(0,a.jsx)("span",{className:"text-yellow-600 ml-2",children:"(Warning: Recommend 4GB+)"})]})]},s)})})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[(0,a.jsx)("div",{children:n&&(0,a.jsx)("button",{onClick:n,className:"btn-outline",children:"Back"})}),(0,a.jsxs)("div",{className:"flex space-x-3",children:[(0,a.jsx)("button",{onClick:N,disabled:b,className:"btn-outline",children:b?"Refreshing...":"Refresh"}),(0,a.jsx)("button",{onClick:()=>{v&&i({system:v,validated:!0})},className:"btn-primary",disabled:!v.docker.available,children:d?"Continue":"Next: Repository Setup"})]})]})]}):(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)(c.Z,{className:"h-12 w-12 text-red-500 mx-auto mb-4"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"System Detection Failed"}),(0,a.jsx)("p",{className:"text-gray-600 mb-4",children:"Unable to detect system configuration. Please try again."}),(0,a.jsx)("button",{onClick:N,disabled:b,className:"btn-primary",children:b?"Retrying...":"Retry Detection"})]})}},{id:"repository",title:"Repository Setup",description:"Configure Git repository for task management",component:function(e){let{systemInfo:s,configData:t,onComplete:i,onBack:n,isCompleted:c}=e,[d,o]=(0,r.useState)([]),[x,u]=(0,r.useState)({provider:"",baseURL:"",accessToken:"",owner:"",repository:""}),[h,p]=(0,r.useState)(null),[j,N]=(0,r.useState)(!1),[f,w]=(0,r.useState)(!1),[z,S]=(0,r.useState)(!0);(0,r.useEffect)(()=>{t.repository&&u({...t.repository})},[t]),(0,r.useEffect)(()=>{k()},[]);let k=async()=>{try{let e=await fetch("/api/setup/repository/providers");if(e.ok){let s=((await e.json()).providers||[]).map(e=>{switch(e.toLowerCase()){case"gitea":return{name:"gitea",displayName:"Gitea",description:"Self-hosted Git service with issue tracking",requiresBaseURL:!0,defaultBaseURL:"http://gitea.local"};case"github":return{name:"github",displayName:"GitHub",description:"Cloud-based Git repository hosting service",requiresBaseURL:!1,defaultBaseURL:"https://api.github.com"};default:return{name:e.toLowerCase(),displayName:e,description:"Git repository service",requiresBaseURL:!0}}});if(o(s),!x.provider&&s.length>0){let e=s.find(e=>"gitea"===e.name)||s[0];C(e.name)}}}catch(e){console.error("Failed to load providers:",e)}finally{S(!1)}},C=e=>{let s=d.find(s=>s.name===e);u(t=>({...t,provider:e,baseURL:(null==s?void 0:s.defaultBaseURL)||t.baseURL})),p(null)},P=(e,s)=>{u(t=>({...t,[e]:s})),p(null)},A=async()=>{if(!x.provider||!x.accessToken||!x.owner||!x.repository){p({valid:!1,error:"Please fill in all required fields"});return}N(!0),p(null);try{let e=await fetch("/api/setup/repository/validate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(x)}),s=await e.json();e.ok&&s.valid?p({valid:!0,message:s.message||"Repository connection successful"}):p({valid:!1,error:s.error||"Validation failed"})}catch(e){p({valid:!1,error:"Network error: Unable to validate repository"})}finally{N(!1)}},I=d.find(e=>e.name===x.provider),Z=x.provider&&x.accessToken&&x.owner&&x.repository&&(!(null==I?void 0:I.requiresBaseURL)||x.baseURL);return z?(0,a.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,a.jsxs)("div",{className:"text-center",children:[(0,a.jsx)(m.Z,{className:"h-8 w-8 text-bzzz-primary animate-spin mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Loading repository providers..."})]})}):(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),(null==h?void 0:h.valid)?i({repository:x}):A()},className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-6",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 mb-4 flex items-center",children:[(0,a.jsx)(y.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"Repository Provider"]}),(0,a.jsx)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:d.map(e=>(0,a.jsx)("div",{className:"border-2 rounded-lg p-4 cursor-pointer transition-all ".concat(x.provider===e.name?"border-bzzz-primary bg-bzzz-primary bg-opacity-10":"border-gray-200 hover:border-gray-300"),onClick:()=>C(e.name),children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",name:"provider",value:e.name,checked:x.provider===e.name,onChange:()=>C(e.name),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300"}),(0,a.jsxs)("div",{className:"ml-3",children:[(0,a.jsx)("div",{className:"font-medium text-gray-900",children:e.displayName}),(0,a.jsx)("div",{className:"text-sm text-gray-600",children:e.description})]})]})},e.name))})]}),x.provider&&(0,a.jsxs)("div",{className:"space-y-6",children:[(null==I?void 0:I.requiresBaseURL)&&(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Base URL *"}),(0,a.jsx)("input",{type:"url",value:x.baseURL,onChange:e=>P("baseURL",e.target.value),placeholder:"e.g., ".concat(I.defaultBaseURL||"https://git.example.com"),className:"input-field",required:!0}),(0,a.jsxs)("p",{className:"text-sm text-gray-600 mt-1",children:["The base URL for your ",I.displayName," instance"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Access Token *"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{type:f?"text":"password",value:x.accessToken,onChange:e=>P("accessToken",e.target.value),placeholder:"Your ".concat(null==I?void 0:I.displayName," access token"),className:"input-field pr-10",required:!0}),(0,a.jsx)("button",{type:"button",onClick:()=>w(!f),className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:f?(0,a.jsx)(b.Z,{className:"h-5 w-5 text-gray-400"}):(0,a.jsx)(g.Z,{className:"h-5 w-5 text-gray-400"})})]}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:(null==I?void 0:I.name)==="github"?"Generate a personal access token with repo and admin:repo_hook permissions":"Generate an access token with repository read/write permissions"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Owner/Organization *"}),(0,a.jsx)("input",{type:"text",value:x.owner,onChange:e=>P("owner",e.target.value),placeholder:"username or organization",className:"input-field",required:!0}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"The username or organization that owns the repository"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Repository Name *"}),(0,a.jsx)("input",{type:"text",value:x.repository,onChange:e=>P("repository",e.target.value),placeholder:"repository-name",className:"input-field",required:!0}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"The name of the repository for task management"})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsx)("h4",{className:"text-md font-medium text-gray-900 mb-3",children:"Connection Test"}),h&&(0,a.jsxs)("div",{className:"flex items-center p-3 rounded-lg mb-4 ".concat(h.valid?"bg-green-50 border border-green-200":"bg-red-50 border border-red-200"),children:[h.valid?(0,a.jsx)(l.Z,{className:"h-5 w-5 text-green-600 mr-2"}):(0,a.jsx)(v.Z,{className:"h-5 w-5 text-red-600 mr-2"}),(0,a.jsx)("span",{className:"text-sm ".concat(h.valid?"text-green-800":"text-red-800"),children:h.valid?h.message:h.error})]}),(0,a.jsx)("button",{type:"button",onClick:A,disabled:!Z||j,className:"btn-outline w-full sm:w-auto",children:j?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(m.Z,{className:"h-4 w-4 animate-spin mr-2"}),"Testing Connection..."]}):"Test Repository Connection"}),!Z&&(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-2",children:"Please fill in all required fields to test the connection"})]})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[(0,a.jsx)("div",{children:n&&(0,a.jsx)("button",{type:"button",onClick:n,className:"btn-outline",children:"Back"})}),(0,a.jsx)("button",{type:"submit",disabled:!(null==h?void 0:h.valid),className:"btn-primary",children:(null==h?void 0:h.valid)?c?"Continue":"Next: Network Configuration":"Validate & Continue"})]})]})}},{id:"network",title:"Network Configuration",description:"Configure network and firewall settings",component:function(e){var s,t;let{systemInfo:l,configData:i,onComplete:n,onBack:d,isCompleted:o}=e,[m,x]=(0,r.useState)({primaryInterface:"",primaryIP:"",bzzzPort:8080,mcpPort:3e3,webUIPort:8080,p2pPort:7e3,autoFirewall:!0,allowedIPs:["192.168.0.0/16","10.0.0.0/8","172.16.0.0/12"],dnsServers:["8.8.8.8","8.8.4.4"]}),[u,y]=(0,r.useState)([]),[b,g]=(0,r.useState)([]);(0,r.useEffect)(()=>{(null==l?void 0:l.network)&&x(e=>{var s,t;return{...e,primaryInterface:(null===(s=l.network.interfaces)||void 0===s?void 0:s[0])||e.primaryInterface,primaryIP:(null===(t=l.network.private_ips)||void 0===t?void 0:t[0])||e.primaryIP}}),i.network&&x(e=>({...e,...i.network}))},[l,i]),(0,r.useEffect)(()=>{v()},[m]);let v=()=>{let e=[],s=[],t=[m.bzzzPort,m.mcpPort,m.webUIPort,m.p2pPort];new Set(t).size!==t.length&&s.push("Port numbers must be unique"),t.forEach((s,t)=>{let a=["BZZZ API","MCP Server","Web UI","P2P Network"];s<1024&&e.push("".concat(a[t]," port should be above 1024 to avoid requiring root privileges")),s>65535&&e.push("".concat(a[t]," port must be below 65536"))}),m.allowedIPs.forEach(s=>{s&&!f(s)&&e.push("Invalid CIDR notation: ".concat(s))}),m.dnsServers.forEach(s=>{s&&!w(s)&&e.push("Invalid DNS server IP: ".concat(s))}),y(e),g(s)},f=e=>/^(\d{1,3}\.){3}\d{1,3}\/\d{1,2}$/.test(e),w=e=>!!/^(\d{1,3}\.){3}\d{1,3}$/.test(e)&&e.split(".").every(e=>parseInt(e)>=0&&255>=parseInt(e)),z=(e,s)=>{let t=parseInt(s)||0;x(s=>({...s,[e]:t}))},S=(e,s,t)=>{x(a=>({...a,[e]:a[e].map((e,a)=>a===s?t:e)}))},k=e=>{x(s=>({...s,[e]:[...s[e],""]}))},C=(e,s)=>{x(t=>({...t,[e]:t[e].filter((e,t)=>t!==s)}))},P=0===u.length&&0===b.length;return(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),0===u.length&&0===b.length&&n({network:m})},className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-6",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 mb-4 flex items-center",children:[(0,a.jsx)(p.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"Network Interface"]}),(null==l?void 0:null===(s=l.network)||void 0===s?void 0:s.interfaces)&&(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsx)("label",{className:"label",children:"Primary Network Interface"}),(0,a.jsxs)("select",{value:m.primaryInterface,onChange:e=>x(s=>({...s,primaryInterface:e.target.value})),className:"input-field",children:[(0,a.jsx)("option",{value:"",children:"Select network interface"}),l.network.interfaces.map((e,s)=>(0,a.jsxs)("option",{value:e,children:[e," - ",l.network.private_ips[s]||"Unknown IP"]},s))]}),m.primaryInterface&&(0,a.jsxs)("div",{className:"text-sm text-gray-600",children:["Primary IP: ",(null===(t=l.network.private_ips)||void 0===t?void 0:t[l.network.interfaces.indexOf(m.primaryInterface)])||"Unknown"]})]})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 mb-4 flex items-center",children:[(0,a.jsx)(h.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"Port Configuration"]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"BZZZ API Port"}),(0,a.jsx)("input",{type:"number",value:m.bzzzPort,onChange:e=>z("bzzzPort",e.target.value),min:"1024",max:"65535",className:"input-field"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"Main BZZZ HTTP API endpoint"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"MCP Server Port"}),(0,a.jsx)("input",{type:"number",value:m.mcpPort,onChange:e=>z("mcpPort",e.target.value),min:"1024",max:"65535",className:"input-field"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"Model Context Protocol server"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Web UI Port"}),(0,a.jsx)("input",{type:"number",value:m.webUIPort,onChange:e=>z("webUIPort",e.target.value),min:"1024",max:"65535",className:"input-field"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"Web interface port"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"P2P Network Port"}),(0,a.jsx)("input",{type:"number",value:m.p2pPort,onChange:e=>z("p2pPort",e.target.value),min:"1024",max:"65535",className:"input-field"}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"Peer-to-peer communication"})]})]}),b.length>0&&(0,a.jsxs)("div",{className:"mt-4 p-3 bg-red-50 border border-red-200 rounded-lg",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(c.Z,{className:"h-5 w-5 text-red-600 mr-2"}),(0,a.jsx)("span",{className:"text-red-800 font-medium",children:"Port Conflicts"})]}),b.map((e,s)=>(0,a.jsx)("p",{className:"text-red-700 text-sm mt-1",children:e},s))]})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 mb-4 flex items-center",children:[(0,a.jsx)(j.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"Security & Access Control"]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"autoFirewall",checked:m.autoFirewall,onChange:e=>x(s=>({...s,autoFirewall:e.target.checked})),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300 rounded"}),(0,a.jsx)("label",{htmlFor:"autoFirewall",className:"ml-2 text-sm font-medium text-gray-700",children:"Automatically configure firewall rules"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Allowed IP Ranges (CIDR)"}),m.allowedIPs.map((e,s)=>(0,a.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,a.jsx)("input",{type:"text",value:e,onChange:e=>S("allowedIPs",s,e.target.value),placeholder:"192.168.1.0/24",className:"input-field flex-1"}),(0,a.jsx)("button",{type:"button",onClick:()=>C("allowedIPs",s),className:"text-red-600 hover:text-red-800",children:"Remove"})]},s)),(0,a.jsx)("button",{type:"button",onClick:()=>k("allowedIPs"),className:"text-bzzz-primary hover:text-bzzz-primary/80 text-sm",children:"+ Add IP Range"})]})]})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"DNS Configuration"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"DNS Servers"}),m.dnsServers.map((e,s)=>(0,a.jsxs)("div",{className:"flex items-center space-x-2 mb-2",children:[(0,a.jsx)("input",{type:"text",value:e,onChange:e=>S("dnsServers",s,e.target.value),placeholder:"8.8.8.8",className:"input-field flex-1"}),(0,a.jsx)("button",{type:"button",onClick:()=>C("dnsServers",s),className:"text-red-600 hover:text-red-800",children:"Remove"})]},s)),(0,a.jsx)("button",{type:"button",onClick:()=>k("dnsServers"),className:"text-bzzz-primary hover:text-bzzz-primary/80 text-sm",children:"+ Add DNS Server"})]})]}),u.length>0&&(0,a.jsxs)("div",{className:"bg-red-50 border border-red-200 rounded-lg p-4",children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[(0,a.jsx)(c.Z,{className:"h-5 w-5 text-red-600 mr-2"}),(0,a.jsx)("span",{className:"text-red-800 font-medium",children:"Configuration Issues"})]}),u.map((e,s)=>(0,a.jsx)("p",{className:"text-red-700 text-sm",children:e},s))]}),P&&(0,a.jsxs)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[(0,a.jsx)(N.Z,{className:"h-5 w-5 text-blue-600 mr-2"}),(0,a.jsx)("span",{className:"text-blue-800 font-medium",children:"Configuration Summary"})]}),(0,a.jsxs)("div",{className:"text-blue-700 text-sm space-y-1",children:[(0,a.jsxs)("p",{children:["• Primary interface: ",m.primaryInterface]}),(0,a.jsxs)("p",{children:["• BZZZ API will be available on port ",m.bzzzPort]}),(0,a.jsxs)("p",{children:["• MCP server will run on port ",m.mcpPort]}),(0,a.jsxs)("p",{children:["• Web UI will be accessible on port ",m.webUIPort]}),(0,a.jsxs)("p",{children:["• P2P network will use port ",m.p2pPort]}),m.autoFirewall&&(0,a.jsx)("p",{children:"• Firewall rules will be configured automatically"})]})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[(0,a.jsx)("div",{children:d&&(0,a.jsx)("button",{type:"button",onClick:d,className:"btn-outline",children:"Back"})}),(0,a.jsx)("button",{type:"submit",disabled:!P,className:"btn-primary",children:o?"Continue":"Next: Security Setup"})]})]})}},{id:"security",title:"Security Setup",description:"Configure authentication and SSH access",component:function(e){let{systemInfo:s,configData:t,onComplete:i,onBack:n,isCompleted:o}=e;console.log("SecuritySetup: Component rendered with configData:",t);let[m,x]=(0,r.useState)({sshKeyType:"generate",sshPublicKey:"",sshPrivateKey:"",sshUsername:"ubuntu",sshPassword:"",sshPort:22,enableTLS:!0,tlsCertType:"self-signed",tlsCertPath:"",tlsKeyPath:"",authMethod:"token",clusterSecret:"",accessPolicy:"restricted",enableFirewall:!0,allowedPorts:["22","8080","8090","9100","3000"],trustedIPs:[],...null==t?void 0:t.security}),[u,p]=(0,r.useState)(!1),[y,N]=(0,r.useState)(!1),[z,S]=(0,r.useState)(!1),[k,C]=(0,r.useState)(!1),[P,A]=(0,r.useState)({}),[I,Z]=(0,r.useState)(!1);(0,r.useEffect)(()=>{m.clusterSecret||T()},[]),(0,r.useEffect)(()=>{var e,s,a,r,l,i;if(console.log("SecuritySetup: configData changed",{hasNetwork:!!(null==t?void 0:t.network),portsInitialized:I,hasSavedSecurity:!!(null==t?void 0:null===(e=t.security)||void 0===e?void 0:e.allowedPorts),networkConfig:null==t?void 0:t.network}),(null==t?void 0:t.network)&&!I&&!(null==t?void 0:null===(s=t.security)||void 0===s?void 0:s.allowedPorts)){let e=t.network,s=[null===(a=e.bzzzPort)||void 0===a?void 0:a.toString(),null===(r=e.mcpPort)||void 0===r?void 0:r.toString(),null===(l=e.webUIPort)||void 0===l?void 0:l.toString(),null===(i=e.p2pPort)||void 0===i?void 0:i.toString()].filter(e=>e&&"undefined"!==e);console.log("SecuritySetup: Auto-populating ports",{networkPorts:s,networkConfig:e});let n=[...new Set(["22","8090",...s])];console.log("SecuritySetup: Setting allowed ports to",n),x(e=>({...e,allowedPorts:n})),Z(!0)}},[t,I]);let T=()=>{let e=Array.from(crypto.getRandomValues(new Uint8Array(32))).map(e=>e.toString(16).padStart(2,"0")).join("");x(s=>({...s,clusterSecret:e}))},E=async()=>{C(!0);try{var e;await new Promise(e=>setTimeout(e,2e3));let t="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC... chorus@".concat((null==s?void 0:null===(e=s.network)||void 0===e?void 0:e.hostname)||"localhost");x(e=>({...e,sshPublicKey:t,sshPrivateKey:"-----BEGIN OPENSSH PRIVATE KEY-----\nb3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAFwwAAAAd...\n-----END OPENSSH PRIVATE KEY-----"})),A(e=>({...e,sshKeys:!0}))}catch(e){console.error("Failed to generate SSH keys:",e),A(e=>({...e,sshKeys:!1}))}finally{C(!1)}},U=async e=>{try{await navigator.clipboard.writeText(e)}catch(e){console.error("Failed to copy to clipboard:",e)}};return(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault();let s={};("generate"!==m.sshKeyType||m.sshPublicKey)&&("existing"!==m.sshKeyType||m.sshPublicKey)?s.sshKeys=!0:s.sshKeys=!1,!m.enableTLS||"existing"!==m.tlsCertType||m.tlsCertPath&&m.tlsKeyPath?s.tlsCert=!0:s.tlsCert=!1,m.clusterSecret?s.clusterSecret=!0:s.clusterSecret=!1,"manual"!==m.sshKeyType||m.sshUsername&&m.sshPassword?s.sshCredentials=!0:s.sshCredentials=!1,A(s),Object.values(s).every(e=>e)&&i({security:m})},className:"space-y-8",children:[(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Security Setup"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Configure authentication, SSH access, and security certificates for your BZZZ cluster."})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)(d.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"SSH Key Management"}),!0===P.sshKeys&&(0,a.jsx)(l.Z,{className:"h-5 w-5 text-green-500 ml-2"}),!1===P.sshKeys&&(0,a.jsx)(v.Z,{className:"h-5 w-5 text-red-500 ml-2"})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"SSH Key Type"}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",value:"generate",checked:"generate"===m.sshKeyType,onChange:e=>x(s=>({...s,sshKeyType:e.target.value})),className:"mr-2"}),"Generate new SSH key pair"]}),(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",value:"existing",checked:"existing"===m.sshKeyType,onChange:e=>x(s=>({...s,sshKeyType:e.target.value})),className:"mr-2"}),"Use existing SSH key"]}),(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",value:"manual",checked:"manual"===m.sshKeyType,onChange:e=>x(s=>({...s,sshKeyType:e.target.value})),className:"mr-2"}),"Configure manually with SSH username/password"]})]})]}),"generate"===m.sshKeyType&&(0,a.jsx)("div",{className:"space-y-4",children:m.sshPublicKey?(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Public Key"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("textarea",{value:m.sshPublicKey,readOnly:!0,className:"w-full p-3 border border-gray-300 rounded-lg bg-gray-50 font-mono text-sm",rows:3}),(0,a.jsx)("button",{type:"button",onClick:()=>U(m.sshPublicKey),className:"absolute top-2 right-2 p-1 text-gray-500 hover:text-gray-700",children:(0,a.jsx)(f.Z,{className:"h-4 w-4"})})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Private Key"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("textarea",{value:u?m.sshPrivateKey:"••••••••••••••••••••••••••••••••",readOnly:!0,className:"w-full p-3 border border-gray-300 rounded-lg bg-gray-50 font-mono text-sm",rows:6}),(0,a.jsxs)("div",{className:"absolute top-2 right-2 flex space-x-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>p(!u),className:"p-1 text-gray-500 hover:text-gray-700",children:u?(0,a.jsx)(b.Z,{className:"h-4 w-4"}):(0,a.jsx)(g.Z,{className:"h-4 w-4"})}),(0,a.jsx)("button",{type:"button",onClick:()=>U(m.sshPrivateKey),className:"p-1 text-gray-500 hover:text-gray-700",children:(0,a.jsx)(f.Z,{className:"h-4 w-4"})})]})]}),(0,a.jsx)("p",{className:"text-sm text-yellow-600 mt-1",children:"⚠️ Store this private key securely. It cannot be recovered."})]})]}):(0,a.jsx)("button",{type:"button",onClick:E,disabled:k,className:"btn-primary",children:k?"Generating Keys...":"Generate SSH Key Pair"})}),"existing"===m.sshKeyType&&(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"SSH Public Key"}),(0,a.jsx)("textarea",{value:m.sshPublicKey,onChange:e=>x(s=>({...s,sshPublicKey:e.target.value})),placeholder:"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC...",className:"w-full p-3 border border-gray-300 rounded-lg font-mono text-sm",rows:3})]}),"manual"===m.sshKeyType&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsx)("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)(c.Z,{className:"h-5 w-5 text-yellow-600 mt-0.5"})}),(0,a.jsxs)("div",{className:"ml-3",children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-yellow-800",children:"Manual SSH Configuration"}),(0,a.jsxs)("p",{className:"text-sm text-yellow-700 mt-1",children:["Provide SSH credentials for cluster machines. SSH keys will be automatically generated and deployed using these credentials.",(0,a.jsx)("strong",{children:" Passwords are only used during setup and are not stored."})]})]})]})}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:["SSH Username ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("input",{type:"text",value:m.sshUsername,onChange:e=>x(s=>({...s,sshUsername:e.target.value})),placeholder:"ubuntu",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-bzzz-primary focus:border-bzzz-primary",required:!0}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Exact SSH username for cluster machines"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"SSH Port"}),(0,a.jsx)("input",{type:"number",value:m.sshPort,onChange:e=>x(s=>({...s,sshPort:parseInt(e.target.value)||22})),min:"1",max:"65535",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:ring-bzzz-primary focus:border-bzzz-primary"}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"SSH port number (default: 22)"})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:["SSH Password ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{type:z?"text":"password",value:m.sshPassword,onChange:e=>x(s=>({...s,sshPassword:e.target.value})),placeholder:"Enter SSH password for cluster machines",className:"w-full px-3 py-2 pr-10 border border-gray-300 rounded-lg focus:ring-bzzz-primary focus:border-bzzz-primary",required:!0}),(0,a.jsx)("button",{type:"button",onClick:()=>S(!z),className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:z?(0,a.jsx)(b.Z,{className:"h-4 w-4 text-gray-400"}):(0,a.jsx)(g.Z,{className:"h-4 w-4 text-gray-400"})})]}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"SSH password for the specified username (used only during setup)"})]})]})]})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)(w.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"TLS/SSL Configuration"}),!0===P.tlsCert&&(0,a.jsx)(l.Z,{className:"h-5 w-5 text-green-500 ml-2"}),!1===P.tlsCert&&(0,a.jsx)(v.Z,{className:"h-5 w-5 text-red-500 ml-2"})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",checked:m.enableTLS,onChange:e=>x(s=>({...s,enableTLS:e.target.checked})),className:"mr-2"}),"Enable TLS encryption for cluster communication"]}),m.enableTLS&&(0,a.jsxs)("div",{className:"space-y-4 ml-6",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Certificate Type"}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",value:"self-signed",checked:"self-signed"===m.tlsCertType,onChange:e=>x(s=>({...s,tlsCertType:e.target.value})),className:"mr-2"}),"Generate self-signed certificate"]}),(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",value:"letsencrypt",checked:"letsencrypt"===m.tlsCertType,onChange:e=>x(s=>({...s,tlsCertType:e.target.value})),className:"mr-2"}),"Use Let's Encrypt (requires domain)"]}),(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",value:"existing",checked:"existing"===m.tlsCertType,onChange:e=>x(s=>({...s,tlsCertType:e.target.value})),className:"mr-2"}),"Use existing certificate"]})]})]}),"existing"===m.tlsCertType&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Certificate Path"}),(0,a.jsx)("input",{type:"text",value:m.tlsCertPath,onChange:e=>x(s=>({...s,tlsCertPath:e.target.value})),placeholder:"/path/to/certificate.crt",className:"w-full p-3 border border-gray-300 rounded-lg"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Private Key Path"}),(0,a.jsx)("input",{type:"text",value:m.tlsKeyPath,onChange:e=>x(s=>({...s,tlsKeyPath:e.target.value})),placeholder:"/path/to/private.key",className:"w-full p-3 border border-gray-300 rounded-lg"})]})]})]})]})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)(j.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"Authentication Method"})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Authentication Type"}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",value:"token",checked:"token"===m.authMethod,onChange:e=>x(s=>({...s,authMethod:e.target.value})),className:"mr-2"}),"API Token-based authentication"]}),(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",value:"certificate",checked:"certificate"===m.authMethod,onChange:e=>x(s=>({...s,authMethod:e.target.value})),className:"mr-2"}),"Certificate-based authentication"]}),(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",value:"hybrid",checked:"hybrid"===m.authMethod,onChange:e=>x(s=>({...s,authMethod:e.target.value})),className:"mr-2"}),"Hybrid (Token + Certificate)"]})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Cluster Secret"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("input",{type:y?"text":"password",value:m.clusterSecret,onChange:e=>x(s=>({...s,clusterSecret:e.target.value})),className:"w-full p-3 border border-gray-300 rounded-lg font-mono",placeholder:"Cluster authentication secret"}),(0,a.jsxs)("div",{className:"absolute right-2 top-1/2 transform -translate-y-1/2 flex space-x-1",children:[(0,a.jsx)("button",{type:"button",onClick:()=>N(!y),className:"p-1 text-gray-500 hover:text-gray-700",children:y?(0,a.jsx)(b.Z,{className:"h-4 w-4"}):(0,a.jsx)(g.Z,{className:"h-4 w-4"})}),(0,a.jsx)("button",{type:"button",onClick:T,className:"p-1 text-gray-500 hover:text-gray-700",children:(0,a.jsx)(d.Z,{className:"h-4 w-4"})})]})]}),!1===P.clusterSecret&&(0,a.jsx)("p",{className:"text-sm text-red-600 mt-1",children:"Cluster secret is required"})]})]})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center mb-4",children:[(0,a.jsx)(h.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"Access Control"})]}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Access Policy"}),(0,a.jsxs)("select",{value:m.accessPolicy,onChange:e=>x(s=>({...s,accessPolicy:e.target.value})),className:"w-full p-3 border border-gray-300 rounded-lg",children:[(0,a.jsx)("option",{value:"open",children:"Open (Anyone can join cluster)"}),(0,a.jsx)("option",{value:"restricted",children:"Restricted (Require authentication)"}),(0,a.jsx)("option",{value:"invite-only",children:"Invite Only (Manual approval required)"})]})]}),(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",checked:m.enableFirewall,onChange:e=>x(s=>({...s,enableFirewall:e.target.checked})),className:"mr-2"}),"Enable firewall configuration"]}),m.enableFirewall&&(0,a.jsx)("div",{className:"ml-6 space-y-4",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Allowed Ports"}),(0,a.jsx)("input",{type:"text",value:m.allowedPorts.join(", "),onChange:e=>x(s=>({...s,allowedPorts:e.target.value.split(",").map(e=>e.trim()).filter(e=>e)})),placeholder:"22, 8080, 8090, 9100, 3000",className:"w-full p-3 border border-gray-300 rounded-lg"}),(null==t?void 0:t.network)&&(0,a.jsxs)("p",{className:"text-sm text-green-600 mt-1 flex items-center",children:[(0,a.jsx)(l.Z,{className:"h-4 w-4 mr-1"}),"Ports automatically configured from Network Settings: ",[t.network.bzzzPort,t.network.mcpPort,t.network.webUIPort,t.network.p2pPort].filter(e=>e).join(", ")]}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1",children:"Comma-separated list of ports to allow through the firewall"})]})})]})]}),(0,a.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)(c.Z,{className:"h-5 w-5 text-blue-500 mt-0.5 mr-2"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h4",{className:"text-sm font-medium text-blue-800",children:"Security Summary"}),(0,a.jsxs)("ul",{className:"text-sm text-blue-700 mt-1 space-y-1",children:[(0,a.jsxs)("li",{children:["• SSH access: ","generate"===m.sshKeyType?"New key pair will be generated":"existing"===m.sshKeyType?"Using provided key":"Manual configuration"]}),(0,a.jsxs)("li",{children:["• TLS encryption: ",m.enableTLS?"Enabled":"Disabled"]}),(0,a.jsxs)("li",{children:["• Authentication: ",m.authMethod]}),(0,a.jsxs)("li",{children:["• Access policy: ",m.accessPolicy]}),(0,a.jsxs)("li",{children:["• Firewall: ",m.enableFirewall?"Enabled":"Disabled"]})]})]})]})}),(0,a.jsxs)("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[(0,a.jsx)("div",{children:n&&(0,a.jsx)("button",{type:"button",onClick:n,className:"btn-outline",children:"Back"})}),(0,a.jsx)("button",{type:"submit",disabled:"generate"===m.sshKeyType&&!m.sshPublicKey,className:"btn-primary",children:o?"Continue":"Next: AI Integration"})]})]})}},{id:"ai",title:"AI Integration",description:"Configure OpenAI and Ollama/Parallama",component:function(e){let{systemInfo:s,configData:t,onComplete:i,onBack:n,isCompleted:d}=e,[o,u]=(0,r.useState)({openaiEnabled:!1,openaiApiKey:"",openaiOrganization:"",openaiDefaultModel:"gpt-4",dailyCostLimit:50,monthlyCostLimit:500,costAlerts:!0,localAIEnabled:!0,localAIType:"ollama",localAIEndpoint:"http://localhost:11434",localAIModels:["llama2","codellama"],gpuAcceleration:!1,preferredGPU:"",maxGPUMemory:8,preferredProvider:"local",fallbackEnabled:!0}),[p,y]=(0,r.useState)(!1),[v,j]=(0,r.useState)(!1),[f,w]=(0,r.useState)(!1),[k,C]=(0,r.useState)(null),[P,A]=(0,r.useState)(null);(0,r.useEffect)(()=>{var e;if(t.ai&&u(e=>({...e,...t.ai})),(null==s?void 0:null===(e=s.gpus)||void 0===e?void 0:e.length)>0){let e=s.gpus.some(e=>"nvidia"===e.type),t=s.gpus.some(e=>"amd"===e.type);e?u(e=>{var t;return{...e,gpuAcceleration:!0,localAIType:"parallama",preferredGPU:(null===(t=s.gpus.find(e=>"nvidia"===e.type))||void 0===t?void 0:t.name)||""}}):t&&u(e=>{var t;return{...e,gpuAcceleration:!0,localAIType:"ollama",preferredGPU:(null===(t=s.gpus.find(e=>"amd"===e.type))||void 0===t?void 0:t.name)||""}})}},[s,t]);let I=async()=>{if(!o.openaiApiKey){C(!1);return}j(!0);try{await new Promise(e=>setTimeout(e,1e3)),C(!0)}catch(e){C(!1)}finally{j(!1)}},Z=async()=>{if(!o.localAIEndpoint){A(!1);return}w(!0);try{let e=await fetch("".concat(o.localAIEndpoint,"/api/tags"));A(e.ok)}catch(e){A(!1)}finally{w(!1)}},T=(()=>{var e;if(!(null==s?void 0:null===(e=s.gpus)||void 0===e?void 0:e.length))return{recommendation:"No GPU detected. CPU-only processing will be used.",type:"info",details:"Consider adding a GPU for better AI performance."};let t=s.gpus,a=t.filter(e=>"nvidia"===e.type),r=t.filter(e=>"amd"===e.type);return a.length>0?{recommendation:"NVIDIA GPU detected - Parallama recommended for optimal performance",type:"success",details:"".concat(a[0].name," with ").concat(a[0].memory," VRAM detected. Parallama provides excellent NVIDIA GPU acceleration.")}:r.length>0?{recommendation:"AMD GPU detected - Ollama with ROCm support recommended",type:"warning",details:"".concat(r[0].name," detected. Ollama provides good AMD GPU support through ROCm.")}:{recommendation:"Integrated GPU detected - Limited AI acceleration available",type:"warning",details:"Integrated GPUs provide limited AI acceleration. Consider a dedicated GPU for better performance."}})(),E=(()=>{let e=(null==s?void 0:s.memory_mb)?Math.round(s.memory_mb/1024):8;return e>=32?["llama2:70b","codellama:34b","mixtral:8x7b"]:e>=16?["llama2:13b","codellama:13b","llama2:7b"]:["llama2:7b","codellama:7b","phi2"]})();return(0,a.jsxs)("form",{onSubmit:e=>{if(e.preventDefault(),!o.openaiEnabled&&!o.localAIEnabled){alert("Please enable at least one AI provider (OpenAI or Local AI)");return}i({ai:o})},className:"space-y-6",children:[(null==s?void 0:s.gpus)&&(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-6",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 mb-4 flex items-center",children:[(0,a.jsx)(x.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"GPU Configuration"]}),(0,a.jsx)("div",{className:"p-4 rounded-lg border mb-4 ".concat("success"===T.type?"bg-green-50 border-green-200":"warning"===T.type?"bg-yellow-50 border-yellow-200":"bg-blue-50 border-blue-200"),children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)(N.Z,{className:"h-5 w-5 mt-0.5 mr-2 ".concat("success"===T.type?"text-green-600":"warning"===T.type?"text-yellow-600":"text-blue-600")}),(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"font-medium ".concat("success"===T.type?"text-green-800":"warning"===T.type?"text-yellow-800":"text-blue-800"),children:T.recommendation}),(0,a.jsx)("div",{className:"text-sm mt-1 ".concat("success"===T.type?"text-green-700":"warning"===T.type?"text-yellow-700":"text-blue-700"),children:T.details})]})]})}),s.gpus.length>0&&(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"gpuAcceleration",checked:o.gpuAcceleration,onChange:e=>u(s=>({...s,gpuAcceleration:e.target.checked})),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300 rounded"}),(0,a.jsx)("label",{htmlFor:"gpuAcceleration",className:"ml-2 text-sm font-medium text-gray-700",children:"Enable GPU acceleration for AI processing"})]}),o.gpuAcceleration&&(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Preferred GPU"}),(0,a.jsxs)("select",{value:o.preferredGPU,onChange:e=>u(s=>({...s,preferredGPU:e.target.value})),className:"input-field",children:[(0,a.jsx)("option",{value:"",children:"Auto-select"}),s.gpus.map((e,s)=>(0,a.jsxs)("option",{value:e.name,children:[e.name," (",e.type.toUpperCase(),") - ",e.memory]},s))]})]})]})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 flex items-center",children:[(0,a.jsx)(h.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"Local AI (Ollama/Parallama)"]}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"localAIEnabled",checked:o.localAIEnabled,onChange:e=>u(s=>({...s,localAIEnabled:e.target.checked})),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300 rounded"}),(0,a.jsx)("label",{htmlFor:"localAIEnabled",className:"ml-2 text-sm font-medium text-gray-700",children:"Enable Local AI"})]})]}),o.localAIEnabled&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Local AI Provider"}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{className:"border-2 rounded-lg p-4 cursor-pointer transition-all ".concat("ollama"===o.localAIType?"border-bzzz-primary bg-bzzz-primary bg-opacity-10":"border-gray-200 hover:border-gray-300"),onClick:()=>u(e=>({...e,localAIType:"ollama"})),children:[(0,a.jsx)("div",{className:"font-medium text-gray-900",children:"Ollama"}),(0,a.jsx)("div",{className:"text-sm text-gray-600",children:"Open-source, self-hosted AI models"}),(0,a.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:"Best for: AMD GPUs, CPU-only setups"})]}),(0,a.jsxs)("div",{className:"border-2 rounded-lg p-4 cursor-pointer transition-all ".concat("parallama"===o.localAIType?"border-bzzz-primary bg-bzzz-primary bg-opacity-10":"border-gray-200 hover:border-gray-300"),onClick:()=>u(e=>({...e,localAIType:"parallama"})),children:[(0,a.jsx)("div",{className:"font-medium text-gray-900",children:"Parallama"}),(0,a.jsx)("div",{className:"text-sm text-gray-600",children:"Optimized for parallel processing"}),(0,a.jsx)("div",{className:"text-xs text-gray-500 mt-1",children:"Best for: NVIDIA GPUs, high performance"})]})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"API Endpoint"}),(0,a.jsxs)("div",{className:"flex space-x-2",children:[(0,a.jsx)("input",{type:"url",value:o.localAIEndpoint,onChange:e=>u(s=>({...s,localAIEndpoint:e.target.value})),placeholder:"http://localhost:11434",className:"input-field flex-1"}),(0,a.jsx)("button",{type:"button",onClick:Z,disabled:f,className:"btn-outline whitespace-nowrap",children:f?(0,a.jsx)(m.Z,{className:"h-4 w-4 animate-spin"}):"Test"})]}),!0===P&&(0,a.jsxs)("div",{className:"flex items-center mt-1 text-green-600 text-sm",children:[(0,a.jsx)(l.Z,{className:"h-4 w-4 mr-1"}),"Connection successful"]}),!1===P&&(0,a.jsxs)("div",{className:"flex items-center mt-1 text-red-600 text-sm",children:[(0,a.jsx)(c.Z,{className:"h-4 w-4 mr-1"}),"Connection failed"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Recommended Models for your system"}),(0,a.jsx)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-3",children:(0,a.jsxs)("div",{className:"text-sm text-blue-800",children:[(0,a.jsxs)("p",{className:"font-medium mb-2",children:["Based on your system memory (",Math.round((null==s?void 0:s.memory_mb)/1024||8)," GB):"]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-2",children:E.map((e,s)=>(0,a.jsx)("span",{className:"bg-blue-100 text-blue-800 px-2 py-1 rounded text-xs",children:e},s))})]})})]})]})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 flex items-center",children:[(0,a.jsx)(z.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"OpenAI API"]}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"openaiEnabled",checked:o.openaiEnabled,onChange:e=>u(s=>({...s,openaiEnabled:e.target.checked})),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300 rounded"}),(0,a.jsx)("label",{htmlFor:"openaiEnabled",className:"ml-2 text-sm font-medium text-gray-700",children:"Enable OpenAI API"})]})]}),o.openaiEnabled&&(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"API Key"}),(0,a.jsxs)("div",{className:"flex space-x-2",children:[(0,a.jsxs)("div",{className:"relative flex-1",children:[(0,a.jsx)("input",{type:p?"text":"password",value:o.openaiApiKey,onChange:e=>u(s=>({...s,openaiApiKey:e.target.value})),placeholder:"sk-...",className:"input-field pr-10"}),(0,a.jsx)("button",{type:"button",onClick:()=>y(!p),className:"absolute inset-y-0 right-0 pr-3 flex items-center",children:p?(0,a.jsx)(b.Z,{className:"h-5 w-5 text-gray-400"}):(0,a.jsx)(g.Z,{className:"h-5 w-5 text-gray-400"})})]}),(0,a.jsx)("button",{type:"button",onClick:I,disabled:v||!o.openaiApiKey,className:"btn-outline whitespace-nowrap",children:v?(0,a.jsx)(m.Z,{className:"h-4 w-4 animate-spin"}):"Validate"})]}),!0===k&&(0,a.jsxs)("div",{className:"flex items-center mt-1 text-green-600 text-sm",children:[(0,a.jsx)(l.Z,{className:"h-4 w-4 mr-1"}),"API key valid"]}),!1===k&&(0,a.jsxs)("div",{className:"flex items-center mt-1 text-red-600 text-sm",children:[(0,a.jsx)(c.Z,{className:"h-4 w-4 mr-1"}),"Invalid API key"]})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Organization (Optional)"}),(0,a.jsx)("input",{type:"text",value:o.openaiOrganization,onChange:e=>u(s=>({...s,openaiOrganization:e.target.value})),placeholder:"org-...",className:"input-field"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Default Model"}),(0,a.jsxs)("select",{value:o.openaiDefaultModel,onChange:e=>u(s=>({...s,openaiDefaultModel:e.target.value})),className:"input-field",children:[(0,a.jsx)("option",{value:"gpt-4",children:"GPT-4"}),(0,a.jsx)("option",{value:"gpt-4-turbo",children:"GPT-4 Turbo"}),(0,a.jsx)("option",{value:"gpt-3.5-turbo",children:"GPT-3.5 Turbo"})]})]})]})]}),o.openaiEnabled&&(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 mb-4 flex items-center",children:[(0,a.jsx)(S.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"Cost Management"]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Daily Cost Limit ($)"}),(0,a.jsx)("input",{type:"number",value:o.dailyCostLimit,onChange:e=>u(s=>({...s,dailyCostLimit:parseFloat(e.target.value)||0})),min:"0",step:"0.01",className:"input-field"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Monthly Cost Limit ($)"}),(0,a.jsx)("input",{type:"number",value:o.monthlyCostLimit,onChange:e=>u(s=>({...s,monthlyCostLimit:parseFloat(e.target.value)||0})),min:"0",step:"0.01",className:"input-field"})]})]}),(0,a.jsx)("div",{className:"mt-4",children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"costAlerts",checked:o.costAlerts,onChange:e=>u(s=>({...s,costAlerts:e.target.checked})),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300 rounded"}),(0,a.jsx)("label",{htmlFor:"costAlerts",className:"ml-2 text-sm font-medium text-gray-700",children:"Send alerts when approaching cost limits"})]})})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Provider Preference"}),(0,a.jsxs)("div",{className:"space-y-3",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Preferred AI Provider"}),(0,a.jsxs)("select",{value:o.preferredProvider,onChange:e=>u(s=>({...s,preferredProvider:e.target.value})),className:"input-field",children:[(0,a.jsx)("option",{value:"local",children:"Local AI Only"}),(0,a.jsx)("option",{value:"openai",children:"OpenAI Only"}),(0,a.jsx)("option",{value:"hybrid",children:"Hybrid (Local first, OpenAI fallback)"})]})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"fallbackEnabled",checked:o.fallbackEnabled,onChange:e=>u(s=>({...s,fallbackEnabled:e.target.checked})),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300 rounded"}),(0,a.jsx)("label",{htmlFor:"fallbackEnabled",className:"ml-2 text-sm font-medium text-gray-700",children:"Enable automatic fallback between providers"})]})]})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[(0,a.jsx)("div",{children:n&&(0,a.jsx)("button",{type:"button",onClick:n,className:"btn-outline",children:"Back"})}),(0,a.jsx)("button",{type:"submit",className:"btn-primary",disabled:!o.openaiEnabled&&!o.localAIEnabled,children:d?"Continue":"Next: Resource Allocation"})]})]})}},{id:"deployment",title:"Service Deployment",description:"Deploy and configure CHORUS:agents services",component:function(e){var s,t,i,d;let{systemInfo:o,configData:x,onComplete:u,onBack:p,isCompleted:y}=e,[b,g]=(0,r.useState)([]),[j,N]=(0,r.useState)(!1),[f,w]=(0,r.useState)(0),[z,S]=(0,r.useState)(""),[I,Z]=(0,r.useState)(null),[T,E]=(0,r.useState)({}),[U,D]=(0,r.useState)({deploymentMethod:"systemd",autoStart:!0,healthCheckInterval:30,selectedMachines:[]});(0,r.useEffect)(()=>{var e,s,t;g([{id:"localhost",hostname:(null==o?void 0:null===(e=o.network)||void 0===e?void 0:e.hostname)||"localhost",ip:(null==x?void 0:null===(s=x.network)||void 0===s?void 0:s.primaryIP)||"127.0.0.1",os:(null==o?void 0:o.os)||"linux",osVersion:"Current Host",sshStatus:"connected",deployStatus:"running",selected:!0,systemInfo:{cpu:(null==o?void 0:o.cpu_cores)||0,memory:Math.round(((null==o?void 0:o.memory_mb)||0)/1024),disk:(null==o?void 0:null===(t=o.storage)||void 0===t?void 0:t.free_space_gb)||0}}]),D(e=>({...e,selectedMachines:["localhost"]}))},[o,x]);let R=async()=>{N(!0),w(0),S("Initializing network scan...");try{var e,s,t,a;let r=setInterval(()=>{w(e=>{let s=e+10;return s<=30?S("Scanning network subnet..."):s<=60?S("Checking SSH accessibility..."):s<=90?S("Gathering system information..."):S("Finalizing discovery..."),Math.min(s,95)})},200),l=await fetch("/api/setup/discover-machines",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({subnet:(null==x?void 0:null===(s=x.network)||void 0===s?void 0:null===(e=s.allowedIPs)||void 0===e?void 0:e[0])||"192.168.1.0/24",sshKey:null==x?void 0:null===(t=x.security)||void 0===t?void 0:t.sshPublicKey})});if(clearInterval(r),w(100),l.ok){let e=await l.json();S("Found ".concat((null===(a=e.machines)||void 0===a?void 0:a.length)||0," machines"));let s=e.machines.map(e=>({id:e.ip,hostname:e.hostname||"Unknown",ip:e.ip,os:e.os||"unknown",osVersion:e.os_version||"Unknown",sshStatus:"unknown",deployStatus:"not_deployed",selected:!1,lastSeen:new Date().toISOString(),systemInfo:e.system_info}));g(e=>{let t=e.find(e=>"localhost"===e.id);return t?[t,...s]:s})}else S("Discovery failed - check network configuration")}catch(e){console.error("Discovery failed:",e),S("Discovery error - network unreachable")}finally{setTimeout(()=>{N(!1),w(0),S("")},2e3)}},O=async e=>{g(s=>s.map(s=>s.id===e?{...s,sshStatus:"testing"}:s));try{var s,t,a,r;let l=b.find(s=>s.id===e),i=await fetch("/api/setup/test-ssh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ip:null==l?void 0:l.ip,sshKey:null==x?void 0:null===(s=x.security)||void 0===s?void 0:s.sshPrivateKey,sshUsername:(null==x?void 0:null===(t=x.security)||void 0===t?void 0:t.sshUsername)||"ubuntu",sshPassword:null==x?void 0:null===(a=x.security)||void 0===a?void 0:a.sshPassword,sshPort:(null==x?void 0:null===(r=x.security)||void 0===r?void 0:r.sshPort)||22})}),n=await i.json();g(s=>s.map(s=>s.id===e?{...s,sshStatus:n.success?"connected":"failed",os:n.os||s.os,osVersion:n.os_version||s.osVersion,systemInfo:n.system_info||s.systemInfo}:s))}catch(s){g(s=>s.map(s=>s.id===e?{...s,sshStatus:"failed"}:s))}},L=async e=>{g(s=>s.map(s=>s.id===e?{...s,deployStatus:"installing",deployProgress:0,deployStep:"Initializing deployment..."}:s));let s=[];E(t=>({...t,[e]:s}));let t=[{progress:10,step:"Establishing SSH connection..."},{progress:30,step:"Copying BZZZ binary..."},{progress:60,step:"Creating systemd service..."},{progress:80,step:"Starting service..."},{progress:100,step:"Deployment complete!"}],a=a=>{if(a<t.length){let{progress:r,step:l}=t[a];g(s=>s.map(s=>s.id===e?{...s,deployProgress:r,deployStep:l}:s)),s.push("\uD83D\uDCE6 ".concat(l)),E(s=>({...s,[e]:[...s[e]||[],"\uD83D\uDCE6 ".concat(l)]}))}};try{var r,l,i,n,c,d,o,m;let u=b.find(s=>s.id===e);for(let e=0;e<t.length-1;e++)a(e),await new Promise(e=>setTimeout(e,1e3));let h=await fetch("/api/setup/deploy-service",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({ip:null==u?void 0:u.ip,sshKey:null==x?void 0:null===(r=x.security)||void 0===r?void 0:r.sshPrivateKey,sshUsername:(null==x?void 0:null===(l=x.security)||void 0===l?void 0:l.sshUsername)||"ubuntu",sshPassword:null==x?void 0:null===(i=x.security)||void 0===i?void 0:i.sshPassword,sshPort:(null==x?void 0:null===(n=x.security)||void 0===n?void 0:n.sshPort)||22,config:{ports:{api:(null==x?void 0:null===(c=x.network)||void 0===c?void 0:c.bzzzPort)||8080,mcp:(null==x?void 0:null===(d=x.network)||void 0===d?void 0:d.mcpPort)||3e3,webui:(null==x?void 0:null===(o=x.network)||void 0===o?void 0:o.webUIPort)||8080,p2p:(null==x?void 0:null===(m=x.network)||void 0===m?void 0:m.p2pPort)||7e3},security:null==x?void 0:x.security,autoStart:U.autoStart}})}),p=await h.json();p.success?(a(t.length-1),g(s=>s.map(s=>s.id===e?{...s,deployStatus:"running",deployProgress:100,deployStep:"Running"}:s)),s.push("✅ Deployment completed successfully"),p.steps&&p.steps.forEach(e=>s.push(e))):(g(s=>s.map(s=>s.id===e?{...s,deployStatus:"error",deployProgress:0,deployStep:"Failed"}:s)),s.push("❌ Deployment failed: ".concat(p.error)))}catch(t){g(s=>s.map(s=>s.id===e?{...s,deployStatus:"error",deployProgress:0,deployStep:"Error"}:s)),s.push("❌ Deployment error: ".concat(t))}E(t=>({...t,[e]:s}))},K=e=>{g(s=>s.map(s=>s.id===e?{...s,selected:!s.selected}:s)),D(s=>({...s,selectedMachines:b.map(s=>s.id===e?{...s,selected:!s.selected}:s).filter(e=>e.selected).map(e=>e.id)}))},B=async()=>{for(let e of b.filter(e=>e.selected&&"connected"===e.sshStatus))"not_deployed"===e.deployStatus&&await L(e.id)},M=e=>{"localhost"!==e&&(g(s=>s.filter(s=>s.id!==e)),D(s=>({...s,selectedMachines:s.selectedMachines.filter(s=>s!==e)})),E(s=>{let{[e]:t,...a}=s;return a}))},H=e=>{switch(e){case"connected":case"running":return(0,a.jsx)(l.Z,{className:"h-5 w-5 text-green-500"});case"failed":case"error":return(0,a.jsx)(v.Z,{className:"h-5 w-5 text-red-500"});case"testing":case"installing":return(0,a.jsx)(m.Z,{className:"h-5 w-5 text-blue-500 animate-spin"});case"stopped":return(0,a.jsx)(k.Z,{className:"h-5 w-5 text-yellow-500"});default:return(0,a.jsx)(h.Z,{className:"h-5 w-5 text-gray-400"})}};return(0,a.jsxs)("form",{onSubmit:e=>{e.preventDefault(),u({deployment:{...U,machines:b.filter(e=>e.selected).map(e=>({id:e.id,ip:e.ip,hostname:e.hostname,deployStatus:e.deployStatus}))}})},className:"space-y-6",children:[(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold text-gray-900 mb-2",children:"Service Deployment"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Deploy and configure CHORUS:agents services across your cluster machines."})]}),(0,a.jsx)("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)(c.Z,{className:"h-5 w-5 text-yellow-600 mt-0.5 mr-3 flex-shrink-0"}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-sm font-medium text-yellow-800",children:"Operating System Support"}),(0,a.jsxs)("p",{className:"text-sm text-yellow-700 mt-1",children:["CHORUS:agents automated deployment supports ",(0,a.jsx)("strong",{children:"Linux distributions that use systemd by default"})," (Ubuntu 16+, CentOS 7+, Debian 8+, RHEL 7+, etc.). For other operating systems or init systems, you'll need to manually deploy the CHORUS:agents binary and configure services on your cluster."]})]})]})}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 flex items-center",children:[(0,a.jsx)(h.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"Machine Discovery"]}),(0,a.jsxs)("button",{type:"button",onClick:R,disabled:j,className:"btn-outline flex items-center",children:[(0,a.jsx)(m.Z,{className:"h-4 w-4 mr-2 ".concat(j?"animate-spin":"")}),j?"Discovering...":"Discover Machines"]})]}),(0,a.jsxs)("p",{className:"text-sm text-gray-600 mb-4",children:["Scan network subnet: ",(null==x?void 0:null===(t=x.network)||void 0===t?void 0:null===(s=t.allowedIPs)||void 0===s?void 0:s[0])||"192.168.1.0/24"]}),j&&(0,a.jsxs)("div",{className:"mb-4",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("span",{className:"text-sm font-medium text-gray-700",children:z}),(0,a.jsxs)("span",{className:"text-sm text-gray-500",children:[f,"%"]})]}),(0,a.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2",children:(0,a.jsx)("div",{className:"bg-bzzz-primary h-2 rounded-full transition-all duration-300 ease-out",style:{width:"".concat(f,"%")}})})]})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"Cluster Machines"}),(0,a.jsxs)("button",{type:"button",onClick:B,disabled:0===b.filter(e=>e.selected&&"connected"===e.sshStatus).length,className:"btn-primary flex items-center",children:[(0,a.jsx)(C.Z,{className:"h-4 w-4 mr-2"}),"Deploy to Selected"]})]}),(0,a.jsx)("div",{className:"overflow-x-auto",children:(0,a.jsxs)("table",{className:"min-w-full divide-y divide-gray-200",children:[(0,a.jsx)("thead",{className:"bg-gray-50",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Select"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Machine"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Operating System"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"IP Address"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"SSH Status"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Deploy Status"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Actions"}),(0,a.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Remove"})]})}),(0,a.jsx)("tbody",{className:"bg-white divide-y divide-gray-200",children:b.map(e=>(0,a.jsxs)("tr",{className:e.selected?"bg-blue-50":"",children:[(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,a.jsx)("input",{type:"checkbox",checked:e.selected,onChange:()=>K(e.id),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300 rounded"})}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,a.jsxs)("div",{children:[(0,a.jsx)("div",{className:"text-sm font-medium text-gray-900",children:e.hostname}),e.systemInfo&&(0,a.jsxs)("div",{className:"text-xs text-gray-500",children:[e.systemInfo.cpu," cores • ",e.systemInfo.memory,"GB RAM • ",e.systemInfo.disk,"GB disk"]})]})}),(0,a.jsxs)("td",{className:"px-6 py-4 whitespace-nowrap",children:[(0,a.jsx)("div",{className:"text-sm text-gray-900",children:e.os}),(0,a.jsx)("div",{className:"text-xs text-gray-500",children:e.osVersion})]}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-gray-900",children:e.ip}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,a.jsxs)("div",{className:"flex items-center",children:[H(e.sshStatus),(0,a.jsx)("span",{className:"ml-2 text-sm text-gray-900 capitalize",children:e.sshStatus.replace("_"," ")})]})}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,a.jsxs)("div",{className:"flex items-center",children:[H(e.deployStatus),(0,a.jsxs)("div",{className:"ml-2 flex-1",children:[(0,a.jsx)("div",{className:"text-sm text-gray-900 capitalize",children:e.deployStatus.replace("_"," ")}),"installing"===e.deployStatus&&(0,a.jsxs)("div",{className:"mt-1",children:[(0,a.jsx)("div",{className:"text-xs text-gray-500 mb-1",children:e.deployStep||"Deploying..."}),(0,a.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2",children:(0,a.jsx)("div",{className:"bg-blue-500 h-2 rounded-full transition-all duration-300",style:{width:"".concat(e.deployProgress||0,"%")}})}),(0,a.jsxs)("div",{className:"text-xs text-gray-500 mt-1",children:[e.deployProgress||0,"%"]})]})]})]})}),(0,a.jsxs)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium space-x-2",children:["localhost"!==e.id&&"connected"!==e.sshStatus&&(0,a.jsx)("button",{type:"button",onClick:()=>O(e.id),className:"text-blue-600 hover:text-blue-900",disabled:"testing"===e.sshStatus,children:"Test SSH"}),"connected"===e.sshStatus&&"not_deployed"===e.deployStatus&&(0,a.jsx)("button",{type:"button",onClick:()=>L(e.id),className:"text-green-600 hover:text-green-900",children:"Install"}),"not_deployed"!==e.deployStatus&&(0,a.jsx)("button",{type:"button",onClick:()=>Z(e.id),className:"text-gray-600 hover:text-gray-900",children:(0,a.jsx)(n.Z,{className:"h-4 w-4 inline"})})]}),(0,a.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:"localhost"!==e.id&&(0,a.jsx)("button",{type:"button",onClick:()=>M(e.id),className:"text-red-600 hover:text-red-900 p-1 rounded hover:bg-red-50",title:"Remove machine",children:(0,a.jsx)(P.Z,{className:"h-4 w-4"})})})]},e.id))})]})}),0===b.length&&(0,a.jsxs)("div",{className:"text-center py-8",children:[(0,a.jsx)(h.Z,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-gray-500",children:'No machines discovered yet. Click "Discover Machines" to scan your network.'})]})]}),(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 mb-4 flex items-center",children:[(0,a.jsx)(A.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"Deployment Configuration"]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsx)("div",{children:(0,a.jsxs)("label",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",checked:U.autoStart,onChange:e=>D(s=>({...s,autoStart:e.target.checked})),className:"mr-2"}),"Auto-start services after deployment"]})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Health Check Interval (seconds)"}),(0,a.jsx)("input",{type:"number",value:U.healthCheckInterval,onChange:e=>D(s=>({...s,healthCheckInterval:parseInt(e.target.value)})),min:"10",max:"300",className:"input-field"})]})]})]}),I&&(0,a.jsx)("div",{className:"fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50",children:(0,a.jsxs)("div",{className:"bg-white rounded-lg p-6 max-w-2xl w-full max-h-96 overflow-auto",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center mb-4",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium",children:["Deployment Logs - ",null===(i=b.find(e=>e.id===I))||void 0===i?void 0:i.hostname]}),(0,a.jsx)("button",{onClick:()=>Z(null),className:"text-gray-400 hover:text-gray-600",children:"✕"})]}),(0,a.jsx)("div",{className:"bg-gray-900 text-green-400 p-4 rounded font-mono text-sm max-h-64 overflow-y-auto",children:(null===(d=T[I])||void 0===d?void 0:d.map((e,s)=>(0,a.jsx)("div",{children:e},s)))||(0,a.jsx)("div",{children:"No logs available"})})]})}),(0,a.jsxs)("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[(0,a.jsx)("div",{children:p&&(0,a.jsx)("button",{type:"button",onClick:p,className:"btn-outline",children:"Back"})}),(0,a.jsx)("button",{type:"submit",className:"btn-primary",children:y?"Continue":"Next: Cluster Formation"})]})]})}},{id:"cluster",title:"Cluster Formation",description:"Join or create CHORUS:agents cluster",component:function(e){var s,t,i;let{systemInfo:n,configData:c,onComplete:o,onBack:x,isCompleted:u}=e,[h,p]=(0,r.useState)({mode:"create",networkId:"",clusterName:"",nodeRole:"hybrid",autoDiscovery:!0,encryption:!0,redundancy:2}),[y,b]=(0,r.useState)([]),[g,v]=(0,r.useState)(!1),[j,f]=(0,r.useState)(!1),[w,z]=(0,r.useState)("");(0,r.useEffect)(()=>{var e;if(c.cluster&&p(e=>({...e,...c.cluster})),!h.networkId&&(null==n?void 0:null===(e=n.network)||void 0===e?void 0:e.hostname)){let e=n.network.hostname,s=Date.now().toString(36).slice(-4);p(t=>({...t,networkId:"bzzz-".concat(e,"-").concat(s),clusterName:"".concat(e," BZZZ Cluster")}))}},[n,c]),(0,r.useEffect)(()=>{"join"===h.mode&&h.autoDiscovery&&S()},[h.mode,h.autoDiscovery]);let S=async()=>{v(!0);try{await new Promise(e=>setTimeout(e,2e3));let e=[{id:"node-001",hostname:"ironwood",ip:"192.168.1.72",port:8080,version:"2.0.0",capabilities:["coordinator","storage","compute"],status:"online",lastSeen:new Date},{id:"node-002",hostname:"walnut",ip:"192.168.1.27",port:8080,version:"2.0.0",capabilities:["worker","compute"],status:"online",lastSeen:new Date}];b(e)}catch(e){console.error("Node discovery failed:",e)}finally{v(!1)}},k=async()=>{f(!0);try{let e=Array.from(crypto.getRandomValues(new Uint8Array(32))).map(e=>e.toString(16).padStart(2,"0")).join("");z(e)}catch(e){z(Math.random().toString(36).substr(2,32))}finally{f(!1)}},C=e=>{switch(e){case"coordinator":return"Manages cluster state and coordinates tasks. Requires stable network connection.";case"worker":return"Executes tasks assigned by coordinators. Can be dynamically added/removed.";case"hybrid":return"Can act as both coordinator and worker. Recommended for most deployments.";default:return""}},P=(()=>{var e;let s=(null==n?void 0:n.memory_mb)?Math.round(n.memory_mb/1024):8,t=(null==n?void 0:n.cpu_cores)||4,a=(null==n?void 0:null===(e=n.gpus)||void 0===e?void 0:e.length)>0;return s>=16&&t>=8?{role:"coordinator",reason:"High-performance system suitable for cluster coordination"}:a?{role:"hybrid",reason:"GPU acceleration available - good for both coordination and compute tasks"}:{role:"worker",reason:"Resource-optimized configuration for task execution"}})();return(0,a.jsxs)("form",{onSubmit:e=>{var s,t,a,r;e.preventDefault(),o({cluster:{...h,clusterKey:"create"===h.mode?w:void 0,systemInfo:{hostname:null==n?void 0:null===(s=n.network)||void 0===s?void 0:s.hostname,ip:null==n?void 0:null===(a=n.network)||void 0===a?void 0:null===(t=a.private_ips)||void 0===t?void 0:t[0],capabilities:(null==n?void 0:null===(r=n.gpus)||void 0===r?void 0:r.length)>0?["compute","gpu"]:["compute"]}}})},className:"space-y-6",children:[(0,a.jsxs)("div",{className:"bg-gray-50 rounded-lg p-6",children:[(0,a.jsxs)("h3",{className:"text-lg font-medium text-gray-900 mb-4 flex items-center",children:[(0,a.jsx)(I.Z,{className:"h-6 w-6 text-bzzz-primary mr-2"}),"Cluster Mode"]}),(0,a.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[(0,a.jsxs)("div",{className:"border-2 rounded-lg p-4 cursor-pointer transition-all ".concat("create"===h.mode?"border-bzzz-primary bg-bzzz-primary bg-opacity-10":"border-gray-200 hover:border-gray-300"),onClick:()=>p(e=>({...e,mode:"create"})),children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[(0,a.jsx)(Z.Z,{className:"h-5 w-5 text-bzzz-primary mr-2"}),(0,a.jsx)("div",{className:"font-medium text-gray-900",children:"Create New Cluster"})]}),(0,a.jsx)("div",{className:"text-sm text-gray-600",children:"Start a new BZZZ cluster and become the initial coordinator node."})]}),(0,a.jsxs)("div",{className:"border-2 rounded-lg p-4 cursor-pointer transition-all ".concat("join"===h.mode?"border-bzzz-primary bg-bzzz-primary bg-opacity-10":"border-gray-200 hover:border-gray-300"),onClick:()=>p(e=>({...e,mode:"join"})),children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[(0,a.jsx)(T.Z,{className:"h-5 w-5 text-bzzz-primary mr-2"}),(0,a.jsx)("div",{className:"font-medium text-gray-900",children:"Join Existing Cluster"})]}),(0,a.jsx)("div",{className:"text-sm text-gray-600",children:"Connect to an existing BZZZ cluster as a worker or coordinator node."})]})]})]}),"create"===h.mode&&(0,a.jsx)("div",{className:"space-y-6",children:(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"New Cluster Configuration"}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Cluster Name"}),(0,a.jsx)("input",{type:"text",value:h.clusterName,onChange:e=>p(s=>({...s,clusterName:e.target.value})),placeholder:"My BZZZ Cluster",className:"input-field",required:!0})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Network ID"}),(0,a.jsx)("input",{type:"text",value:h.networkId,onChange:e=>p(s=>({...s,networkId:e.target.value})),placeholder:"bzzz-cluster-001",className:"input-field",required:!0}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"Unique identifier for your cluster network"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Cluster Security Key"}),(0,a.jsxs)("div",{className:"flex space-x-2",children:[(0,a.jsx)("input",{type:"text",value:w,onChange:e=>z(e.target.value),placeholder:"Click generate or enter custom key",className:"input-field flex-1",readOnly:!w}),(0,a.jsx)("button",{type:"button",onClick:k,disabled:j,className:"btn-outline whitespace-nowrap",children:j?(0,a.jsx)(m.Z,{className:"h-4 w-4 animate-spin"}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(d.Z,{className:"h-4 w-4 mr-1"}),"Generate"]})})]}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"This key will be required for other nodes to join your cluster"})]})]})]})}),"join"===h.mode&&(0,a.jsx)("div",{className:"space-y-6",children:(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"Available Clusters"}),(0,a.jsx)("button",{type:"button",onClick:S,disabled:g,className:"btn-outline text-sm",children:g?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(m.Z,{className:"h-4 w-4 animate-spin mr-1"}),"Scanning..."]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(E.Z,{className:"h-4 w-4 mr-1"}),"Scan Network"]})})]}),y.length>0?(0,a.jsx)("div",{className:"space-y-3",children:y.map(e=>(0,a.jsx)("div",{className:"border rounded-lg p-4 cursor-pointer transition-all ".concat(h.targetNode===e.id?"border-bzzz-primary bg-bzzz-primary bg-opacity-10":"border-gray-200 hover:border-gray-300"),onClick:()=>p(s=>({...s,targetNode:e.id})),children:(0,a.jsxs)("div",{className:"flex items-center justify-between",children:[(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)(U.Z,{className:"h-5 w-5 text-gray-500 mr-2"}),(0,a.jsx)("span",{className:"font-medium text-gray-900",children:e.hostname}),(0,a.jsx)("span",{className:"ml-2 status-indicator ".concat("online"===e.status?"status-online":"status-offline"),children:e.status})]}),(0,a.jsxs)("div",{className:"text-sm text-gray-600 mt-1",children:[e.ip,":",e.port," • Version ",e.version]}),(0,a.jsx)("div",{className:"flex flex-wrap gap-1 mt-1",children:e.capabilities.map((e,s)=>(0,a.jsx)("span",{className:"bg-gray-100 text-gray-700 px-2 py-1 rounded text-xs",children:e},s))})]}),(0,a.jsx)(D.Z,{className:"h-5 w-5 text-bzzz-primary"})]})},e.id))}):(0,a.jsxs)("div",{className:"text-center py-8",children:[(0,a.jsx)(E.Z,{className:"h-12 w-12 text-gray-400 mx-auto mb-4"}),(0,a.jsx)("p",{className:"text-gray-600",children:g?"Scanning for BZZZ clusters...":"No clusters found. Click scan to search for available clusters."})]}),h.targetNode&&(0,a.jsxs)("div",{className:"mt-4 pt-4 border-t border-gray-200",children:[(0,a.jsx)("label",{className:"label",children:"Cluster Join Key"}),(0,a.jsx)("input",{type:"password",value:h.joinKey||"",onChange:e=>p(s=>({...s,joinKey:e.target.value})),placeholder:"Enter cluster security key",className:"input-field",required:!0}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"Enter the security key provided by the cluster administrator"})]})]})}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Node Role"}),(0,a.jsx)("div",{className:"mb-4 p-4 bg-blue-50 border border-blue-200 rounded-lg",children:(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)(N.Z,{className:"h-5 w-5 text-blue-600 mr-2 mt-0.5"}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"font-medium text-blue-800",children:["Recommended: ",P.role.charAt(0).toUpperCase()+P.role.slice(1)]}),(0,a.jsx)("div",{className:"text-sm text-blue-700 mt-1",children:P.reason})]})]})}),(0,a.jsx)("div",{className:"space-y-3",children:["coordinator","worker","hybrid"].map(e=>(0,a.jsx)("div",{className:"border-2 rounded-lg p-4 cursor-pointer transition-all ".concat(h.nodeRole===e?"border-bzzz-primary bg-bzzz-primary bg-opacity-10":"border-gray-200 hover:border-gray-300"),onClick:()=>p(s=>({...s,nodeRole:e})),children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"radio",name:"nodeRole",value:e,checked:h.nodeRole===e,onChange:()=>p(s=>({...s,nodeRole:e})),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300"}),(0,a.jsxs)("div",{className:"ml-3",children:[(0,a.jsx)("div",{className:"font-medium text-gray-900 capitalize",children:e}),(0,a.jsx)("div",{className:"text-sm text-gray-600",children:C(e)})]})]})},e))})]}),(0,a.jsxs)("div",{className:"bg-white border border-gray-200 rounded-lg p-6",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-4",children:"Advanced Options"}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"autoDiscovery",checked:h.autoDiscovery,onChange:e=>p(s=>({...s,autoDiscovery:e.target.checked})),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300 rounded"}),(0,a.jsx)("label",{htmlFor:"autoDiscovery",className:"ml-2 text-sm font-medium text-gray-700",children:"Enable automatic node discovery (mDNS)"})]}),(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("input",{type:"checkbox",id:"encryption",checked:h.encryption,onChange:e=>p(s=>({...s,encryption:e.target.checked})),className:"h-4 w-4 text-bzzz-primary focus:ring-bzzz-primary border-gray-300 rounded"}),(0,a.jsx)("label",{htmlFor:"encryption",className:"ml-2 text-sm font-medium text-gray-700",children:"Enable end-to-end encryption for cluster communication"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"label",children:"Redundancy Level"}),(0,a.jsxs)("select",{value:h.redundancy,onChange:e=>p(s=>({...s,redundancy:parseInt(e.target.value)})),className:"input-field",children:[(0,a.jsx)("option",{value:1,children:"Low (1 replica)"}),(0,a.jsx)("option",{value:2,children:"Medium (2 replicas)"}),(0,a.jsx)("option",{value:3,children:"High (3 replicas)"})]}),(0,a.jsx)("p",{className:"text-sm text-gray-600 mt-1",children:"Number of replicas for critical cluster data"})]})]})]}),(0,a.jsxs)("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4",children:[(0,a.jsxs)("div",{className:"flex items-center mb-2",children:[(0,a.jsx)(l.Z,{className:"h-5 w-5 text-blue-600 mr-2"}),(0,a.jsx)("span",{className:"text-blue-800 font-medium",children:"Configuration Summary"})]}),(0,a.jsxs)("div",{className:"text-blue-700 text-sm space-y-1",children:[(0,a.jsxs)("p",{children:["• Mode: ","create"===h.mode?"Create new cluster":"Join existing cluster"]}),(0,a.jsxs)("p",{children:["• Role: ",h.nodeRole]}),(0,a.jsxs)("p",{children:["• Hostname: ",(null==n?void 0:null===(s=n.network)||void 0===s?void 0:s.hostname)||"Unknown"]}),(0,a.jsxs)("p",{children:["• IP Address: ",(null==n?void 0:null===(i=n.network)||void 0===i?void 0:null===(t=i.private_ips)||void 0===t?void 0:t[0])||"Unknown"]}),"create"===h.mode&&(0,a.jsxs)("p",{children:["• Cluster: ",h.clusterName]}),h.encryption&&(0,a.jsx)("p",{children:"• Security: Encrypted communication enabled"})]})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[(0,a.jsx)("div",{children:x&&(0,a.jsx)("button",{type:"button",onClick:x,className:"btn-outline",children:"Back"})}),(0,a.jsx)("button",{type:"submit",disabled:"create"===h.mode&&(!h.clusterName||!h.networkId||!w)||"join"===h.mode&&(!h.targetNode||!h.joinKey),className:"btn-primary",children:u?"Continue":"Next: Testing & Validation"})]})]})}},{id:"testing",title:"Testing & Validation",description:"Validate configuration and test connectivity",component:function(e){let{systemInfo:s,configData:t,onComplete:l,onBack:i,isCompleted:n}=e,[c,d]=(0,r.useState)(!1),o=async()=>{d(!0),await new Promise(e=>setTimeout(e,3e3)),d(!1),l({testing:{passed:!0,completedAt:new Date().toISOString()}})};return(0,a.jsxs)("div",{className:"space-y-6",children:[(0,a.jsxs)("div",{className:"text-center py-12",children:[(0,a.jsx)("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:"Testing & Validation"}),(0,a.jsx)("p",{className:"text-gray-600",children:"Validate your BZZZ cluster configuration and test all connections."}),(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)("div",{className:"bg-yellow-50 border border-yellow-200 rounded-lg p-4 text-yellow-800",children:"This component is under development. Testing and validation will be implemented here."})}),!n&&(0,a.jsx)("div",{className:"mt-8",children:(0,a.jsx)("button",{onClick:o,disabled:c,className:"btn-primary",children:c?"Running Tests...":"Run Validation Tests"})}),n&&(0,a.jsxs)("div",{className:"mt-8 bg-green-50 border border-green-200 rounded-lg p-6",children:[(0,a.jsx)("h4",{className:"text-lg font-medium text-green-900 mb-2",children:"\uD83C\uDF89 Setup Complete!"}),(0,a.jsx)("p",{className:"text-green-700 mb-4",children:"Your BZZZ cluster has been successfully configured and validated."}),(0,a.jsxs)("div",{className:"space-y-2 text-sm text-green-600",children:[(0,a.jsx)("div",{children:"✓ System configuration validated"}),(0,a.jsx)("div",{children:"✓ Network connectivity tested"}),(0,a.jsx)("div",{children:"✓ AI services configured"}),(0,a.jsx)("div",{children:"✓ Cluster formation completed"})]})]})]}),(0,a.jsxs)("div",{className:"flex justify-between pt-6 border-t border-gray-200",children:[(0,a.jsx)("div",{children:i&&(0,a.jsx)("button",{onClick:i,className:"btn-outline",children:"Back"})}),n&&(0,a.jsx)("a",{href:"/dashboard",className:"btn-primary",children:"Go to Dashboard"})]})]})}}];function O(){let[e,s]=(0,r.useState)(0),[t,n]=(0,r.useState)(new Set),[c,d]=(0,r.useState)({}),[o,m]=(0,r.useState)(null);(0,r.useEffect)(()=>{x(),p()},[]),(0,r.useEffect)(()=>{u()},[e,t,c]);let x=()=>{try{let e=localStorage.getItem("bzzz-setup-state");if(e){let t=JSON.parse(e);s(t.currentStep||0),n(new Set(t.completedSteps||[])),d(t.configData||{})}}catch(e){console.error("Failed to load persisted setup data:",e)}},u=()=>{try{let s={currentStep:e,completedSteps:Array.from(t),configData:c,timestamp:new Date().toISOString()};localStorage.setItem("bzzz-setup-state",JSON.stringify(s))}catch(e){console.error("Failed to save setup state:",e)}},h=()=>{try{localStorage.removeItem("bzzz-setup-state"),s(0),n(new Set),d({})}catch(e){console.error("Failed to clear persisted data:",e)}},p=async()=>{try{let e=await fetch("/api/setup/system");if(e.ok){let s=await e.json();m(s.system_info)}}catch(e){console.error("Failed to fetch system info:",e)}},y=(e,t)=>{console.log("Setup Page: Step complete",{stepIndex:e,data:t,currentConfigData:c}),n(s=>new Set([...s,e])),d(e=>{let s={...e,...t};return console.log("Setup Page: Updated configData",{prev:e,data:t,newConfigData:s}),s}),e<R.length-1?s(e+1):setTimeout(()=>{h()},2e3)},b=R[e].component,g=e>0||t.size>0||Object.keys(c).length>0;return(0,a.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[(0,a.jsxs)("div",{className:"mb-8",children:[(0,a.jsx)("h1",{className:"text-3xl font-bold text-gray-900 mb-2",children:"Welcome to CHORUS:agents Setup"}),(0,a.jsxs)("p",{className:"text-lg text-gray-600",children:["Let's configure your distributed AI agent coordination cluster in ",R.length," simple steps."]})]}),g&&(0,a.jsx)("div",{className:"mb-6 bg-blue-50 border border-blue-200 rounded-lg p-4",children:(0,a.jsxs)("div",{className:"flex items-start justify-between",children:[(0,a.jsxs)("div",{className:"flex items-start",children:[(0,a.jsx)("div",{className:"flex-shrink-0",children:(0,a.jsx)("svg",{className:"h-5 w-5 text-blue-500 mt-0.5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:(0,a.jsx)("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})})}),(0,a.jsxs)("div",{className:"ml-3",children:[(0,a.jsx)("h3",{className:"text-sm font-medium text-blue-800",children:"Setup Progress Restored"}),(0,a.jsxs)("p",{className:"text-sm text-blue-700 mt-1",children:["Your previous setup progress has been restored. You're currently on step ",e+1," of ",R.length,".",t.size>0&&" You've completed ".concat(t.size," step").concat(1!==t.size?"s":"",".")]})]})]}),(0,a.jsx)("button",{onClick:h,className:"text-blue-500 hover:text-blue-700 text-sm font-medium",children:"Start Over"})]})}),(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-4 gap-8",children:[(0,a.jsx)("div",{className:"lg:col-span-1",children:(0,a.jsxs)("div",{className:"card sticky top-8",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold text-gray-900 mb-4",children:"Setup Progress"}),(0,a.jsx)("nav",{className:"space-y-2",children:R.map((r,n)=>{let c=t.has(n),d=n===e,o=n<=e||t.has(n);return(0,a.jsx)("button",{onClick:()=>o&&s(n),disabled:!o,className:"w-full text-left p-3 rounded-lg border transition-all duration-200 ".concat(d?"border-bzzz-primary bg-bzzz-primary bg-opacity-10 text-bzzz-primary":c?"border-green-200 bg-green-50 text-green-700":o?"border-gray-200 hover:border-gray-300 text-gray-700":"border-gray-100 text-gray-400 cursor-not-allowed"),children:(0,a.jsxs)("div",{className:"flex items-center",children:[(0,a.jsx)("div",{className:"flex-shrink-0 mr-3",children:c?(0,a.jsx)(l.Z,{className:"h-5 w-5 text-green-500"}):(0,a.jsx)("div",{className:"w-5 h-5 rounded-full border-2 flex items-center justify-center text-xs font-medium ".concat(d?"border-bzzz-primary bg-bzzz-primary text-white":"border-gray-300 text-gray-500"),children:n+1})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("div",{className:"text-sm font-medium truncate",children:r.title}),(0,a.jsx)("div",{className:"text-xs opacity-75 truncate",children:r.description})]}),o&&!c&&(0,a.jsx)(i.Z,{className:"h-4 w-4 opacity-50"})]})},r.id)})}),(0,a.jsxs)("div",{className:"mt-6 pt-4 border-t border-gray-200",children:[(0,a.jsxs)("div",{className:"text-sm text-gray-600 mb-2",children:["Progress: ",t.size," of ",R.length," steps"]}),(0,a.jsx)("div",{className:"w-full bg-gray-200 rounded-full h-2",children:(0,a.jsx)("div",{className:"bg-bzzz-primary h-2 rounded-full transition-all duration-500",style:{width:"".concat(t.size/R.length*100,"%")}})})]})]})}),(0,a.jsx)("div",{className:"lg:col-span-3",children:(0,a.jsxs)("div",{className:"card",children:[(0,a.jsxs)("div",{className:"mb-6",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between mb-2",children:[(0,a.jsx)("h2",{className:"text-2xl font-bold text-gray-900",children:R[e].title}),(0,a.jsxs)("div",{className:"text-sm text-gray-500",children:["Step ",e+1," of ",R.length]})]}),(0,a.jsx)("p",{className:"text-gray-600",children:R[e].description})]}),(0,a.jsx)(b,{systemInfo:o,configData:c,onComplete:s=>y(e,s),onBack:e>0?()=>{e>0&&s(e-1)}:void 0,isCompleted:t.has(e)})]})})]})]})}}}]); |