@must-b/must-b 1.74.44 → 1.74.45
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/BUILD.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@must-b/must-b",
|
|
3
|
-
"version": "1.74.
|
|
4
|
-
"gitHash": "
|
|
5
|
-
"buildTime": "2026-06-01T09:
|
|
3
|
+
"version": "1.74.45",
|
|
4
|
+
"gitHash": "e43068da",
|
|
5
|
+
"buildTime": "2026-06-01T09:53:41.164Z",
|
|
6
6
|
"node": "v24.14.0",
|
|
7
7
|
"platform": "win32"
|
|
8
8
|
}
|
package/dist/index.cjs
CHANGED
|
@@ -5024,7 +5024,7 @@ ${p}${m}`+g.repeat(u)+`${p}`,E}function c(u,h,f,p){return`${h}${p}`+f.repeat(u)+
|
|
|
5024
5024
|
\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D
|
|
5025
5025
|
\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
|
|
5026
5026
|
\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D
|
|
5027
|
-
\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D `;function vYA(){try{return"1.74.
|
|
5027
|
+
\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D `;function vYA(){try{return"1.74.45"}catch{return"1.0.0"}}function MYA(){try{return"e43068da"}catch{return""}}function SD(s,e=58){let t=s.replace(/\x1b\[[0-9;]*m/g,""),A=Math.max(0,Math.floor((e-t.length)/2));return" ".repeat(A)+s}function wZe(s="\u2500",e=58){return Fp(" "+s.repeat(e))}function tN(s,e){let t=vYA(),A=MYA();console.log(BZe(OYA)),console.log(""),console.log(SD(kYA(IYA("Must-b"))+" "+QZe("v"+t))),console.log(SD(Fp("Professional AI Operating System"))),console.log(""),console.log(SD(BZe("\u26A1 Autonomous \xB7 Precise \xB7 Always On"))),console.log(SD(Fp("Vision")+Fp(" \xB7 ")+Fp("Voice")+Fp(" \xB7 ")+Fp("OS Control")+Fp(" \xB7 ")+Fp("Multi-Agent Hierarchy"))),console.log(""),console.log(wZe()),console.log("");let i=[`Node ${process.version}`,`Mode: ${s.toUpperCase()}`,`PID ${process.pid}`,A?`#${A}`:null].filter(Boolean).join(Fp(" \xB7 "));console.log(SD(Fp(i))),s==="web"&&(console.log(""),console.log(SD(CYA("\u25B6 ")+QZe(`http://localhost:${e}`))),console.log(SD(Fp("Dashboard is live \u2014 open in your browser")))),console.log(""),console.log(wZe()),console.log(SD(Fp("Built by Auto Step \xB7 https://must-b.com"))),console.log("")}var Qet=require("events"),wet=require("module"),OO=Ve(require("path"),1),vO=Ve(require("fs"),1),Lp=Ve(require("os"),1),yet=Ve(require("crypto"),1);var n$e=require("events"),IO=Ve(require("os"),1),zBe=Ve(require("fs"),1),a$e=Ve(require("path"),1);wO();Ko();var VVA=[{re:/connection refused|ECONNREFUSED/i,kind:"network",level:"warning",message:"Network connection refused.",recommendation:"LLM provider unreachable. Check API key and network in .env.",healable:!1},{re:/model not found|model.*does not exist|no such model/i,kind:"model",level:"warning",message:"Specified model not found.",recommendation:"Check MUSTB_MODEL or select a valid model in Settings > Model.",healable:!1},{re:/JavaScript heap out of memory|out of memory/i,kind:"oom",level:"critical",message:"Node.js memory limit reached.",recommendation:"Switch to a smaller model or start with NODE_OPTIONS=--max-old-space-size=4096.",healable:!1},{re:/python.*not found|pip.*not found|\'python\' is not recognized/i,kind:"path",level:"warning",message:"Python not found on PATH.",recommendation:"Run must-b doctor --fix to auto-repair.",healable:!0},{re:/cannot find module|module not found/i,kind:"module",level:"warning",message:"Missing Node.js module detected.",recommendation:"Run must-b doctor --fix to repair npm dependencies.",healable:!0},{re:/ENOENT.*node_modules/i,kind:"deps",level:"warning",message:"node_modules missing or corrupt.",recommendation:"Run must-b doctor --fix to trigger npm install.",healable:!0}],i$e=80,WVA=75,dN=85,jVA=90,zVA=5*60*1e3,tee=class extends n$e.EventEmitter{constructor(t){super();this.resourceTimer=null;this.logWatcher=null;this.liteActive=!1;this.healing=!1;this.watcherSuspended=!1;this.syncSuspended=!1;this.cloudSync=null;this.lastAlertTs=new Map;this._lastCpu=0;this._lastRam=0;this.patternHits=new Map;this.PATTERN_WINDOW_MS=5*60*1e3;this.PATTERN_THRESHOLD=3;this.root=t.root,this.logger=t.logger,this.logDir=pQ}start(){this.startResourceMonitor(),this.startLogScanner(),this.logger.info("[GhostGuard] Resource monitor + log scanner active.")}getStats(){return{cpu:Math.round(this._lastCpu),ram:Math.round(this._lastRam),liteMode:this.liteActive,safeMode:this.watcherSuspended,ts:Date.now()}}registerCloudSync(t){this.cloudSync=t}stop(){this.resourceTimer&&(clearInterval(this.resourceTimer),this.resourceTimer=null),this.logWatcher?.close(),this.logWatcher=null,this.logger.info("[GhostGuard] Stopped.")}startResourceMonitor(){let t=this.sampleCpu();this.resourceTimer=setInterval(()=>{let A=this.ramUsagePct(),i=this.sampleCpu(),r=this.deltaCpu(t,i);t=i,this.onResourceSample(r,A)},5e3),this.resourceTimer.unref()}ramUsagePct(){let t=IO.default.totalmem(),A=IO.default.freemem();return(t-A)/t*100}sampleCpu(){let t=0,A=0;for(let i of IO.default.cpus()){for(let r of Object.values(i.times))A+=r;t+=i.times.idle}return{idle:t,total:A}}deltaCpu(t,A){let i=A.total-t.total,r=A.idle-t.idle;return i===0?0:Math.max(0,Math.min(100,100*(1-r/i)))}onResourceSample(t,A){if(this._lastCpu=t,this._lastRam=A,A>=i$e&&!this.liteActive){this.liteActive=!0;let i=`RAM at ${A.toFixed(1)}% \u2014 Lite Mode active`;this.logger.warn(`[GhostGuard] ${i}`),this.emit("liteMode",{active:!0,reason:i})}else if(A<i$e-5&&this.liteActive){this.liteActive=!1;let i=`RAM dropped to ${A.toFixed(1)}% \u2014 Lite Mode off`;this.logger.info(`[GhostGuard] ${i}`),this.emit("liteMode",{active:!1,reason:i})}if(A>=dN&&!this.watcherSuspended?(this.watcherSuspended=!0,this.logWatcher?.close(),this.logWatcher=null,this.emit("purgeOldMemory"),this.logger.warn(`[GhostGuard] RAM critical (${A.toFixed(1)}%) \u2014 log watcher suspended; older semantic memory will be purged, last 5 conversation turns preserved`)):A<dN-5&&this.watcherSuspended&&(this.watcherSuspended=!1,this.startLogScanner(),this.logger.info(`[GhostGuard] RAM recovered (${A.toFixed(1)}%) \u2014 log watcher resumed`)),this.cloudSync&&(A>=dN&&!this.syncSuspended?(this.syncSuspended=!0,this.cloudSync.stopAutoSync(),this.logger.warn("[GhostGuard] RAM critical \u2014 CloudSync auto-sync paused")):A<dN-5&&this.syncSuspended&&(this.syncSuspended=!1,this.cloudSync.startAutoSync(60),this.logger.info("[GhostGuard] RAM recovered \u2014 CloudSync auto-sync resumed"))),A>=dN){let i=process.env.LLM_MODEL??process.env.MUSTB_MODEL??"",r=/70b|32b|34b|72b/i.test(i);this.emitAlert({level:"critical",kind:"ram_critical",message:`RAM at ${A.toFixed(1)}% \u2014 system lockup risk.`,recommendation:r?`${i} requires too much RAM. Switch to an 8B or 14B model.`:"Close unused applications or restart Must-b."})}else if(A>=WVA){let i=process.env.LLM_MODEL??process.env.MUSTB_MODEL??"",r=/70b|32b|34b|72b/i.test(i);this.emitAlert({level:"warning",kind:"ram_high",message:`RAM at ${A.toFixed(1)}% \u2014 performance may degrade.`,recommendation:r?`${i} is RAM-intensive. Consider switching to an 8B model.`:"RAM pressure high. Lite Mode may activate."})}t>=jVA&&this.emitAlert({level:"warning",kind:"cpu_high",message:`CPU at ${t.toFixed(1)}% \u2014 LLM load is saturating the system.`,recommendation:"Close background processes or switch to a smaller model."})}startLogScanner(){try{zBe.default.mkdirSync(this.logDir,{recursive:!0})}catch{}this.logWatcher=fQ(a$e.default.join(this.logDir,"*.md"),{ignoreInitial:!0,persistent:!1}),this.logWatcher.on("add",t=>this.scanLogFile(t)),this.logWatcher.on("change",t=>this.scanLogFile(t))}scanLogFile(t){let A="";try{A=zBe.default.readFileSync(t,"utf-8")}catch{return}for(let i of VVA){if(!i.re.test(A))continue;let r=Date.now(),[n,a]=this.patternHits.get(i.kind)??[0,r],o=r-a<this.PATTERN_WINDOW_MS?n+1:1,c=r-a<this.PATTERN_WINDOW_MS?a:r;this.patternHits.set(i.kind,[o,c]),o>=this.PATTERN_THRESHOLD&&(this.logger.warn(`[GhostGuard] Tekrarlayan hata: ${i.kind} (${o}\xD7)`),this.emitAlert({level:i.level,kind:i.kind,message:`Recurring error (${o}\xD7): ${i.message}`,recommendation:i.recommendation}),this.patternHits.set(i.kind,[0,r]),i.healable&&this.triggerAutoHeal(i.kind));break}}triggerAutoHeal(t){this.healing||(this.healing=!0,this.logger.info(`[GhostGuard] Auto-heal starting: ${t}`),this.emit("autoHeal",{kind:t,message:`doctor --fix triggered (${t})`}),Promise.resolve().then(()=>(DO(),A$e)).then(({runDoctor:A})=>A(this.root,!0,!0)).then(()=>{this.logger.info("[GhostGuard] Auto-heal complete.")}).catch(A=>{this.logger.error(`[GhostGuard] Auto-heal failed: ${A.message}`)}).finally(()=>{this.healing=!1}))}emitAlert(t){let A=Date.now(),i=this.lastAlertTs.get(t.kind)??0;if(A-i<zVA)return;this.lastAlertTs.set(t.kind,A);let r={...t,ts:A};this.logger.warn(`[GhostGuard] Alert [${r.level}/${r.kind}]: ${r.message}`),this.emit("alert",r)}},$$=null,eee=null,KVA=2e3;function s$e(){let s=0,e=0;for(let t of IO.default.cpus()){for(let A of Object.values(t.times))e+=A;s+=t.times.idle}return{idle:s,total:e}}function r$e(s,e){let t=e.total-s.total,A=e.idle-s.idle;return t===0?0:Math.max(0,Math.min(100,100*(1-A/t)))}async function o$e(){let s=Date.now();if(eee&&s-eee.ts<KVA)return eee.result;let e=s$e(),t=0;if($$)t=r$e($$,e);else{await new Promise(a=>setTimeout(a,150));let n=s$e();t=r$e(e,n),$$=n}$$=e;let A=IO.default.freemem()/IO.default.totalmem()*100,r={isCritical:t>80||A<15,cpuUsage:Math.round(t),memFreePercent:Math.round(A)};return eee={result:r,ts:s},r}var Aee=Ve(require("fs"),1),KBe=Ve(require("path"),1),c$e=["must-b.md","ARCHITECTURE.md","database.md","checklist.md"],JVA={"must-b.md":`# Must-b \u2014 Persona & Core Rules
|
|
5028
5028
|
|
|
5029
5029
|
## Identity
|
|
5030
5030
|
You are Must-b \u2014 an autonomous AI operating system. Not a chatbot. A Cognitive OS:
|
package/dist/index.js
CHANGED
|
@@ -5024,7 +5024,7 @@ ${p}${m}`+g.repeat(u)+`${p}`,E}function c(u,h,f,p){return`${h}${p}`+f.repeat(u)+
|
|
|
5024
5024
|
\u2588\u2588\u2554\u2588\u2588\u2588\u2588\u2554\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2551\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D
|
|
5025
5025
|
\u2588\u2588\u2551\u255A\u2588\u2588\u2554\u255D\u2588\u2588\u2551\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u2588\u2588\u2551 \u2588\u2588\u2551\u255A\u2550\u2550\u2550\u2550\u255D \u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
|
|
5026
5026
|
\u2588\u2588\u2551 \u255A\u2550\u255D \u2588\u2588\u2551\u255A\u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2551 \u2588\u2588\u2551 \u2588\u2588\u2588\u2588\u2588\u2588\u2554\u255D
|
|
5027
|
-
\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D `;function vYA(){try{return"1.74.
|
|
5027
|
+
\u255A\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u2550\u255D \u255A\u2550\u255D \u255A\u2550\u2550\u2550\u2550\u2550\u255D `;function vYA(){try{return"1.74.45"}catch{return"1.0.0"}}function MYA(){try{return"e43068da"}catch{return""}}function SD(s,e=58){let t=s.replace(/\x1b\[[0-9;]*m/g,""),A=Math.max(0,Math.floor((e-t.length)/2));return" ".repeat(A)+s}function wZe(s="\u2500",e=58){return Fp(" "+s.repeat(e))}function tN(s,e){let t=vYA(),A=MYA();console.log(BZe(OYA)),console.log(""),console.log(SD(kYA(IYA("Must-b"))+" "+QZe("v"+t))),console.log(SD(Fp("Professional AI Operating System"))),console.log(""),console.log(SD(BZe("\u26A1 Autonomous \xB7 Precise \xB7 Always On"))),console.log(SD(Fp("Vision")+Fp(" \xB7 ")+Fp("Voice")+Fp(" \xB7 ")+Fp("OS Control")+Fp(" \xB7 ")+Fp("Multi-Agent Hierarchy"))),console.log(""),console.log(wZe()),console.log("");let i=[`Node ${process.version}`,`Mode: ${s.toUpperCase()}`,`PID ${process.pid}`,A?`#${A}`:null].filter(Boolean).join(Fp(" \xB7 "));console.log(SD(Fp(i))),s==="web"&&(console.log(""),console.log(SD(CYA("\u25B6 ")+QZe(`http://localhost:${e}`))),console.log(SD(Fp("Dashboard is live \u2014 open in your browser")))),console.log(""),console.log(wZe()),console.log(SD(Fp("Built by Auto Step \xB7 https://must-b.com"))),console.log("")}var Qet=require("events"),wet=require("module"),OO=Ve(require("path"),1),vO=Ve(require("fs"),1),Lp=Ve(require("os"),1),yet=Ve(require("crypto"),1);var n$e=require("events"),IO=Ve(require("os"),1),zBe=Ve(require("fs"),1),a$e=Ve(require("path"),1);wO();Ko();var VVA=[{re:/connection refused|ECONNREFUSED/i,kind:"network",level:"warning",message:"Network connection refused.",recommendation:"LLM provider unreachable. Check API key and network in .env.",healable:!1},{re:/model not found|model.*does not exist|no such model/i,kind:"model",level:"warning",message:"Specified model not found.",recommendation:"Check MUSTB_MODEL or select a valid model in Settings > Model.",healable:!1},{re:/JavaScript heap out of memory|out of memory/i,kind:"oom",level:"critical",message:"Node.js memory limit reached.",recommendation:"Switch to a smaller model or start with NODE_OPTIONS=--max-old-space-size=4096.",healable:!1},{re:/python.*not found|pip.*not found|\'python\' is not recognized/i,kind:"path",level:"warning",message:"Python not found on PATH.",recommendation:"Run must-b doctor --fix to auto-repair.",healable:!0},{re:/cannot find module|module not found/i,kind:"module",level:"warning",message:"Missing Node.js module detected.",recommendation:"Run must-b doctor --fix to repair npm dependencies.",healable:!0},{re:/ENOENT.*node_modules/i,kind:"deps",level:"warning",message:"node_modules missing or corrupt.",recommendation:"Run must-b doctor --fix to trigger npm install.",healable:!0}],i$e=80,WVA=75,dN=85,jVA=90,zVA=5*60*1e3,tee=class extends n$e.EventEmitter{constructor(t){super();this.resourceTimer=null;this.logWatcher=null;this.liteActive=!1;this.healing=!1;this.watcherSuspended=!1;this.syncSuspended=!1;this.cloudSync=null;this.lastAlertTs=new Map;this._lastCpu=0;this._lastRam=0;this.patternHits=new Map;this.PATTERN_WINDOW_MS=5*60*1e3;this.PATTERN_THRESHOLD=3;this.root=t.root,this.logger=t.logger,this.logDir=pQ}start(){this.startResourceMonitor(),this.startLogScanner(),this.logger.info("[GhostGuard] Resource monitor + log scanner active.")}getStats(){return{cpu:Math.round(this._lastCpu),ram:Math.round(this._lastRam),liteMode:this.liteActive,safeMode:this.watcherSuspended,ts:Date.now()}}registerCloudSync(t){this.cloudSync=t}stop(){this.resourceTimer&&(clearInterval(this.resourceTimer),this.resourceTimer=null),this.logWatcher?.close(),this.logWatcher=null,this.logger.info("[GhostGuard] Stopped.")}startResourceMonitor(){let t=this.sampleCpu();this.resourceTimer=setInterval(()=>{let A=this.ramUsagePct(),i=this.sampleCpu(),r=this.deltaCpu(t,i);t=i,this.onResourceSample(r,A)},5e3),this.resourceTimer.unref()}ramUsagePct(){let t=IO.default.totalmem(),A=IO.default.freemem();return(t-A)/t*100}sampleCpu(){let t=0,A=0;for(let i of IO.default.cpus()){for(let r of Object.values(i.times))A+=r;t+=i.times.idle}return{idle:t,total:A}}deltaCpu(t,A){let i=A.total-t.total,r=A.idle-t.idle;return i===0?0:Math.max(0,Math.min(100,100*(1-r/i)))}onResourceSample(t,A){if(this._lastCpu=t,this._lastRam=A,A>=i$e&&!this.liteActive){this.liteActive=!0;let i=`RAM at ${A.toFixed(1)}% \u2014 Lite Mode active`;this.logger.warn(`[GhostGuard] ${i}`),this.emit("liteMode",{active:!0,reason:i})}else if(A<i$e-5&&this.liteActive){this.liteActive=!1;let i=`RAM dropped to ${A.toFixed(1)}% \u2014 Lite Mode off`;this.logger.info(`[GhostGuard] ${i}`),this.emit("liteMode",{active:!1,reason:i})}if(A>=dN&&!this.watcherSuspended?(this.watcherSuspended=!0,this.logWatcher?.close(),this.logWatcher=null,this.emit("purgeOldMemory"),this.logger.warn(`[GhostGuard] RAM critical (${A.toFixed(1)}%) \u2014 log watcher suspended; older semantic memory will be purged, last 5 conversation turns preserved`)):A<dN-5&&this.watcherSuspended&&(this.watcherSuspended=!1,this.startLogScanner(),this.logger.info(`[GhostGuard] RAM recovered (${A.toFixed(1)}%) \u2014 log watcher resumed`)),this.cloudSync&&(A>=dN&&!this.syncSuspended?(this.syncSuspended=!0,this.cloudSync.stopAutoSync(),this.logger.warn("[GhostGuard] RAM critical \u2014 CloudSync auto-sync paused")):A<dN-5&&this.syncSuspended&&(this.syncSuspended=!1,this.cloudSync.startAutoSync(60),this.logger.info("[GhostGuard] RAM recovered \u2014 CloudSync auto-sync resumed"))),A>=dN){let i=process.env.LLM_MODEL??process.env.MUSTB_MODEL??"",r=/70b|32b|34b|72b/i.test(i);this.emitAlert({level:"critical",kind:"ram_critical",message:`RAM at ${A.toFixed(1)}% \u2014 system lockup risk.`,recommendation:r?`${i} requires too much RAM. Switch to an 8B or 14B model.`:"Close unused applications or restart Must-b."})}else if(A>=WVA){let i=process.env.LLM_MODEL??process.env.MUSTB_MODEL??"",r=/70b|32b|34b|72b/i.test(i);this.emitAlert({level:"warning",kind:"ram_high",message:`RAM at ${A.toFixed(1)}% \u2014 performance may degrade.`,recommendation:r?`${i} is RAM-intensive. Consider switching to an 8B model.`:"RAM pressure high. Lite Mode may activate."})}t>=jVA&&this.emitAlert({level:"warning",kind:"cpu_high",message:`CPU at ${t.toFixed(1)}% \u2014 LLM load is saturating the system.`,recommendation:"Close background processes or switch to a smaller model."})}startLogScanner(){try{zBe.default.mkdirSync(this.logDir,{recursive:!0})}catch{}this.logWatcher=fQ(a$e.default.join(this.logDir,"*.md"),{ignoreInitial:!0,persistent:!1}),this.logWatcher.on("add",t=>this.scanLogFile(t)),this.logWatcher.on("change",t=>this.scanLogFile(t))}scanLogFile(t){let A="";try{A=zBe.default.readFileSync(t,"utf-8")}catch{return}for(let i of VVA){if(!i.re.test(A))continue;let r=Date.now(),[n,a]=this.patternHits.get(i.kind)??[0,r],o=r-a<this.PATTERN_WINDOW_MS?n+1:1,c=r-a<this.PATTERN_WINDOW_MS?a:r;this.patternHits.set(i.kind,[o,c]),o>=this.PATTERN_THRESHOLD&&(this.logger.warn(`[GhostGuard] Tekrarlayan hata: ${i.kind} (${o}\xD7)`),this.emitAlert({level:i.level,kind:i.kind,message:`Recurring error (${o}\xD7): ${i.message}`,recommendation:i.recommendation}),this.patternHits.set(i.kind,[0,r]),i.healable&&this.triggerAutoHeal(i.kind));break}}triggerAutoHeal(t){this.healing||(this.healing=!0,this.logger.info(`[GhostGuard] Auto-heal starting: ${t}`),this.emit("autoHeal",{kind:t,message:`doctor --fix triggered (${t})`}),Promise.resolve().then(()=>(DO(),A$e)).then(({runDoctor:A})=>A(this.root,!0,!0)).then(()=>{this.logger.info("[GhostGuard] Auto-heal complete.")}).catch(A=>{this.logger.error(`[GhostGuard] Auto-heal failed: ${A.message}`)}).finally(()=>{this.healing=!1}))}emitAlert(t){let A=Date.now(),i=this.lastAlertTs.get(t.kind)??0;if(A-i<zVA)return;this.lastAlertTs.set(t.kind,A);let r={...t,ts:A};this.logger.warn(`[GhostGuard] Alert [${r.level}/${r.kind}]: ${r.message}`),this.emit("alert",r)}},$$=null,eee=null,KVA=2e3;function s$e(){let s=0,e=0;for(let t of IO.default.cpus()){for(let A of Object.values(t.times))e+=A;s+=t.times.idle}return{idle:s,total:e}}function r$e(s,e){let t=e.total-s.total,A=e.idle-s.idle;return t===0?0:Math.max(0,Math.min(100,100*(1-A/t)))}async function o$e(){let s=Date.now();if(eee&&s-eee.ts<KVA)return eee.result;let e=s$e(),t=0;if($$)t=r$e($$,e);else{await new Promise(a=>setTimeout(a,150));let n=s$e();t=r$e(e,n),$$=n}$$=e;let A=IO.default.freemem()/IO.default.totalmem()*100,r={isCritical:t>80||A<15,cpuUsage:Math.round(t),memFreePercent:Math.round(A)};return eee={result:r,ts:s},r}var Aee=Ve(require("fs"),1),KBe=Ve(require("path"),1),c$e=["must-b.md","ARCHITECTURE.md","database.md","checklist.md"],JVA={"must-b.md":`# Must-b \u2014 Persona & Core Rules
|
|
5028
5028
|
|
|
5029
5029
|
## Identity
|
|
5030
5030
|
You are Must-b \u2014 an autonomous AI operating system. Not a chatbot. A Cognitive OS:
|
|
@@ -836,7 +836,7 @@ Burada senin hakkında öğrendiğim bilgiler yer alır.
|
|
|
836
836
|
|
|
837
837
|
If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
838
838
|
|
|
839
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return u.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},kP="DialogDescriptionWarning",jP=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${hb(kP).contentName}}.`;return u.useEffect(()=>{var i;const a=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},NP=Zv,SP=nb,CP=sb,EP=rb,_P=ib,TP=lb,G0=db;const q0=e=>{let t;const n=new Set,r=(d,h)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const f=t;t=h??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(m=>m(t,f))}},a=()=>t,l={setState:r,getState:a,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d))},c=t=e(r,a,l);return l},PP=e=>e?q0(e):q0,AP=e=>e;function MP(e,t=AP){const n=Y.useSyncExternalStore(e.subscribe,Y.useCallback(()=>t(e.getState()),[e,t]),Y.useCallback(()=>t(e.getInitialState()),[e,t]));return Y.useDebugValue(n),n}const Y0=e=>{const t=PP(e),n=r=>MP(t,r);return Object.assign(n,t),n},zP=e=>e?Y0(e):Y0,_i=zP(e=>{let t=!1,n=null,r=null,a=!1,i=null,o=[];try{t=localStorage.getItem("mustb_trader_installed")==="true",n=localStorage.getItem("mustb_trader_template");const l=localStorage.getItem("mustb_trader_accounts");if(l&&(o=JSON.parse(l)),r=localStorage.getItem("mustb_trader_exchange"),a=localStorage.getItem("mustb_trader_testnet")==="true",i=localStorage.getItem("mustb_trader_account_type"),o.length===0&&r)o=[{id:r.toLowerCase().trim(),name:r,type:i||"crypto",isTestnet:a}],localStorage.setItem("mustb_trader_accounts",JSON.stringify(o));else if(o.length>0&&!r){const c=o[0];r=c.name,i=c.type,a=c.isTestnet,localStorage.setItem("mustb_trader_exchange",c.name),localStorage.setItem("mustb_trader_account_type",c.type),localStorage.setItem("mustb_trader_testnet",String(c.isTestnet))}}catch{}return{isTradingPackageInstalled:t,selectedTemplate:n,accounts:o,connectedExchange:r,isTestnet:a,accountType:i,setTradingPackageInstalled:l=>{e({isTradingPackageInstalled:l});try{localStorage.setItem("mustb_trader_installed",String(l))}catch{}},setSelectedTemplate:l=>{e({selectedTemplate:l});try{l?localStorage.setItem("mustb_trader_template",l):localStorage.removeItem("mustb_trader_template")}catch{}},setConnectedExchange:l=>{e({connectedExchange:l});try{l?localStorage.setItem("mustb_trader_exchange",l):localStorage.removeItem("mustb_trader_exchange")}catch{}},setTestnet:l=>{e({isTestnet:l});try{localStorage.setItem("mustb_trader_testnet",String(l))}catch{}},setAccountType:l=>{e({accountType:l});try{l?localStorage.setItem("mustb_trader_account_type",l):localStorage.removeItem("mustb_trader_account_type")}catch{}},addAccount:l=>{e(c=>{const h=c.accounts.some(f=>f.id===l.id)?c.accounts.map(f=>f.id===l.id?l:f):[...c.accounts,l];try{localStorage.setItem("mustb_trader_accounts",JSON.stringify(h))}catch{}const p=h[0];if(p){try{localStorage.setItem("mustb_trader_exchange",p.name),localStorage.setItem("mustb_trader_account_type",p.type),localStorage.setItem("mustb_trader_testnet",String(p.isTestnet))}catch{}return{accounts:h,connectedExchange:p.name,accountType:p.type,isTestnet:p.isTestnet}}return{accounts:h}})},removeAccount:l=>{e(c=>{const d=c.accounts.filter(p=>p.id!==l);try{localStorage.setItem("mustb_trader_accounts",JSON.stringify(d))}catch{}const h=d[0];if(h){try{localStorage.setItem("mustb_trader_exchange",h.name),localStorage.setItem("mustb_trader_account_type",h.type),localStorage.setItem("mustb_trader_testnet",String(h.isTestnet))}catch{}return{accounts:d,connectedExchange:h.name,accountType:h.type,isTestnet:h.isTestnet}}else{try{localStorage.removeItem("mustb_trader_exchange"),localStorage.removeItem("mustb_trader_account_type"),localStorage.removeItem("mustb_trader_testnet")}catch{}return{accounts:[],connectedExchange:null,accountType:null,isTestnet:!1}}})}}}),RP={Messaging:{icon:"💬",accent:"text-blue-300",border:"border-blue-500/20",bg:"bg-blue-500/10",iconBg:"bg-blue-500/10"},Finance:{icon:"📈",accent:"text-emerald-300",border:"border-emerald-500/20",bg:"bg-emerald-500/10",iconBg:"bg-emerald-500/10"},System:{icon:"âš™ï¸",accent:"text-orange-300",border:"border-orange-500/20",bg:"bg-orange-500/10",iconBg:"bg-orange-500/10"}};function LP(e){return RP[e]??{icon:"🔌",accent:"text-white/60",border:"border-white/10",bg:"bg-white/5",iconBg:"bg-white/5"}}function OP({name:e}){return s.jsx("span",{className:"inline-block px-2 py-0.5 rounded-md text-[10px] font-mono bg-white/5 text-white/40 border border-white/8",children:e})}function IP({pack:e,installing:t,installLog:n,onInstall:r,onConfigure:a}){const[i,o]=u.useState(!1),l=LP(e.category),c=e.extensions.length===0;return s.jsxs("div",{className:"flex flex-col bg-white/5 border border-white/8 rounded-2xl p-5 gap-3 hover:bg-white/[0.07] hover:border-white/12 transition-all duration-200",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-12 h-12 rounded-xl ${l.iconBg} flex items-center justify-center text-[24px] shrink-0 select-none border ${l.border}`,children:l.icon}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:e.name}),s.jsx(Er,{size:14,className:`text-emerald-400 shrink-0 transition-opacity duration-200 ${e.installed?"opacity-100":"opacity-0 pointer-events-none"}`})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${l.accent}`,children:e.category}),s.jsxs("span",{className:`text-[10px] text-white/30 ${c?"hidden":"inline"}`,children:[e.extensions.length," extension",e.extensions.length!==1?"s":""]}),s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md bg-yellow-500/10 text-yellow-400 border border-yellow-500/20 font-medium ${c?"inline":"hidden"}`,children:"Coming Soon"})]})]})]}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed",children:e.description}),s.jsx("p",{className:"text-[11px] font-mono text-white/25",children:e.npmPackage}),s.jsxs("div",{className:`${e.extensions.length>0?"block":"hidden"}`,children:[s.jsxs("button",{onClick:()=>o(d=>!d),className:"flex items-center gap-1 text-[11px] text-white/30 hover:text-white/60 transition-colors mb-2",children:[s.jsx(Ys,{size:12,className:`transition-transform duration-200 ${i?"rotate-180":"rotate-0"}`}),s.jsx("span",{children:"Show included extensions"})]}),s.jsx("div",{className:`flex flex-wrap gap-1.5 transition-all duration-200 overflow-hidden ${i?"max-h-[300px] opacity-100 mt-2":"max-h-0 opacity-0"}`,children:e.extensions.map(d=>s.jsx(OP,{name:d},d))})]}),s.jsx("pre",{className:`text-[10px] text-white/40 bg-black/40 rounded-xl p-2.5 max-h-[72px] overflow-y-auto font-mono whitespace-pre-wrap break-all border border-white/6 transition-all duration-200 ${t&&n?"block opacity-100 mt-2":"hidden opacity-0"}`,children:n}),s.jsxs("div",{className:"mt-auto pt-1",children:[s.jsx("div",{className:`w-full py-2 rounded-xl text-[12px] font-medium text-center bg-white/4 text-white/25 border border-white/8 cursor-default select-none ${c?"block":"hidden"}`,children:"Not yet available"}),s.jsx("button",{onClick:a,className:`w-full py-2 rounded-xl text-[12px] font-medium bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 hover:bg-emerald-500/15 hover:border-emerald-500/30 transition-colors ${!c&&e.installed?"block":"hidden"}`,children:"Installed — Configure Keys"}),s.jsxs("button",{onClick:r,disabled:t,className:`w-full flex items-center justify-center gap-2 py-2 rounded-xl text-[12px] font-semibold ${l.bg} ${l.accent} border ${l.border} hover:brightness-125 disabled:opacity-50 disabled:cursor-not-allowed transition-all ${!c&&!e.installed?"flex":"hidden"}`,children:[s.jsx(ne,{size:13,className:`animate-spin shrink-0 ${t?"inline-block":"hidden"}`}),s.jsx(Xs,{size:13,className:`shrink-0 ${t?"hidden":"inline-block"}`}),s.jsx("span",{children:t?"Installing…":"Install Pack"})]})]})]})}function DP({pack:e,onClose:t}){const[n,r]=u.useState({}),[a,i]=u.useState(!1);u.useEffect(()=>{e&&r({})},[e]);const o=async()=>{if(e){i(!0);try{if(!(await U("/api/store/configure",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({keys:n})})).ok)throw new Error("Configure request failed");se.success(`${e.name} configured — keys saved to .env`),t()}catch(c){se.error(c instanceof Error?c.message:"Configure failed")}finally{i(!1)}}},l={};for(const c of(e==null?void 0:e.requiredKeys)??[]){const d=c.forExtension??"general";(l[d]??(l[d]=[])).push(c)}return s.jsx(NP,{open:!!e,onOpenChange:c=>{c||t()},children:s.jsxs(SP,{children:[s.jsx(CP,{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-sm"}),s.jsxs(EP,{className:"fixed z-50 left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-full max-w-[460px] mx-4 bg-[#0d0f14] border border-white/10 rounded-2xl p-6 shadow-2xl max-h-[85vh] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsxs(_P,{className:"text-white/90 font-semibold text-[15px]",children:["Configure ",e==null?void 0:e.name]}),s.jsx(G0,{className:"w-7 h-7 flex items-center justify-center rounded-lg text-white/30 hover:text-white/70 hover:bg-white/6 transition-colors",children:s.jsx(Ie,{size:15})})]}),s.jsxs(TP,{className:"text-white/40 text-[12px] mb-5 leading-relaxed",children:["Fill in the keys for the extensions you want to use. Leave others blank — they can be added later. Keys are saved to your local"," ",s.jsx("code",{className:"font-mono text-white/60 bg-white/8 px-1 rounded",children:".env"})," file."]}),s.jsx("div",{className:"space-y-5",children:Object.entries(l).map(([c,d])=>s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-white/30 mb-2.5",children:c}),s.jsx("div",{className:"space-y-3",children:d.map(h=>s.jsxs("div",{children:[s.jsx("label",{className:"block text-[12px] font-medium text-white/70 mb-1",children:h.label}),h.hint&&s.jsx("p",{className:"text-[11px] text-white/35 mb-1.5",children:h.hint}),s.jsx("input",{type:"password",autoComplete:"off",value:n[h.env]??"",onChange:p=>r(f=>({...f,[h.env]:p.target.value})),className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2.5 text-sm text-white/80 placeholder-white/20 focus:outline-none focus:border-orange-500/40 focus:bg-white/[0.07] transition-colors font-mono",placeholder:`Enter ${h.label}`})]},h.env))})]},c))}),s.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[s.jsxs("button",{onClick:o,disabled:a,className:"flex-1 flex items-center justify-center gap-2 bg-orange-500/20 hover:bg-orange-500/30 border border-orange-500/30 hover:border-orange-500/50 disabled:opacity-60 text-orange-300 rounded-xl py-2.5 text-[13px] font-semibold transition-all active:scale-[0.97]",children:[a?s.jsx(ne,{size:14,className:"animate-spin"}):s.jsx(Er,{size:14}),"Save & Activate"]}),s.jsx(G0,{className:"px-4 py-2.5 text-[13px] text-white/35 hover:text-white/60 transition-colors rounded-xl hover:bg-white/5",children:"Skip"})]})]})]})})}const BP=12e4;function FP(){const{isTradingPackageInstalled:e,setTradingPackageInstalled:t}=_i(),[n,r]=u.useState([]),[a,i]=u.useState(!0),[o,l]=u.useState(null),[c,d]=u.useState({}),[h,p]=u.useState(null),f=u.useRef(null),[m,b]=u.useState(!1),[y,v]=u.useState(!1),[x,g]=u.useState(""),[w,j]=u.useState(!1),[k,N]=u.useState(""),C=u.useCallback(async()=>{if(!x||x.trim().length<10){const O="Lütfen geçerli bir Web3 cüzdan gizli anahtarı (Private Key) girin.";N(O),window.alert(O);return}j(!0),N("");try{const O=await U("/api/web3/vault",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({walletPrivateKey:x.trim()})}),z=await O.json();if(!O.ok||!z.ok)throw new Error(z.error||"Web3 cüzdan anahtarı kaydedilemedi.");window.alert("Polymarket AI Oracle başarıyla kuruldu ve anahtarınız ~/.must-b/ klasöründe şifrelendi!"),v(!1),g(""),A()}catch(O){const z=O instanceof Error?O.message:"Kurulum başarısız oldu.";N(z),window.alert(z)}finally{j(!1)}},[x,A]),A=u.useCallback(async()=>{try{const O=await U("/api/web3/vault");if(O.ok){const z=await O.json();b(z.configured)}}catch{}},[]),S=u.useCallback(async()=>{i(!0);try{const O=await U("/api/store/extensions");O.ok&&r(await O.json())}catch{}finally{i(!1)}},[]);u.useEffect(()=>{S(),A()},[S,A]);const T=u.useCallback(async O=>{var R;(R=f.current)==null||R.abort();const z=new AbortController;f.current=z,l(O.id),d(M=>({...M,[O.id]:""}));const $=setTimeout(()=>{z.abort()},BP);try{const M=await U("/api/store/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:O.id}),signal:z.signal},{retries:1,retryDelay:0});if(!M.body)throw new Error("No response stream");const P=M.body.getReader(),E=new TextDecoder;let _="";for(;;){const{done:I,value:W}=await P.read();if(I)break;const B=E.decode(W,{stream:!0});_+=B,d(G=>({...G,[O.id]:_}))}if(_.includes("__MUSTB_INSTALL_OK__")){se.success(`${O.name} installed!`);try{r(I=>I.map(W=>W.id===O.id?{...W,installed:!0}:W)),O.requiredKeys.length>0&&p(O)}catch(I){console.error("Defensive UI update error caught:",I)}}else _.includes("__MUSTB_INSTALL_FAILED__")?se.error(`${O.name} installation failed — check the log above.`):se.error(`${O.name} installation failed.`)}catch(M){M.name==="AbortError"?se.error(`Install timed out — is ${O.npmPackage} published to npm?`):se.error(M instanceof Error?M.message:"Install failed")}finally{clearTimeout($),l(null)}},[S]),L=n.filter(O=>O.installed).length;return s.jsxs("div",{className:"min-h-screen bg-transparent pt-4 pb-10 px-4 sm:px-6 max-w-5xl mx-auto",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl bg-orange-500/10 border border-orange-500/20 flex items-center justify-center shrink-0",children:s.jsx(xv,{size:18,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[22px] font-black text-white/95 leading-none",children:"Extension Store"}),s.jsxs("span",{className:`text-[11px] text-emerald-400/80 font-medium ${L>0?"inline-block":"hidden"}`,children:[L," pack",L!==1?"s":""," installed"]})]})]}),s.jsxs("p",{className:"text-white/40 text-[13px] leading-relaxed max-w-2xl mt-1",children:["Extensions are grouped into themed packs."," ","Install one pack to get all its integrations — fetched directly from npm into"," ",s.jsx("code",{className:"font-mono text-white/60 bg-white/5 px-1.5 py-0.5 rounded text-[11px] border border-white/8",children:"~/.must-b/extensions/"})]})]}),s.jsx("button",{onClick:S,title:"Refresh",className:"p-2.5 rounded-xl text-white/30 hover:text-white/70 hover:bg-white/6 border border-white/8 transition-all shrink-0",children:s.jsx(ge,{size:15})})]}),s.jsxs("div",{className:"mb-8 px-3 py-2.5 rounded-xl bg-white/5 border border-white/8 flex items-center gap-3",children:[s.jsx("code",{className:"text-[11px] font-mono text-white/30 shrink-0",children:"CLI:"}),s.jsxs("code",{className:"text-[12px] font-mono text-white/50",children:[s.jsx("span",{className:"text-orange-400",children:"must-b ext list"})," · ",s.jsx("span",{className:"text-orange-400",children:"must-b ext install channels"})," · ",s.jsx("span",{className:"text-orange-400",children:"must-b ext install system"})]})]}),s.jsxs("div",{className:`flex flex-col items-center justify-center py-24 gap-3 ${a?"flex":"hidden"}`,children:[s.jsx(ne,{size:22,className:"animate-spin text-orange-400"}),s.jsx("p",{className:"text-white/35 text-[13px]",children:"Loading extension store…"})]}),s.jsxs("div",{className:`flex flex-col items-center justify-center py-24 gap-3 ${!a&&n.length===0?"flex":"hidden"}`,children:[s.jsx(Xs,{size:28,className:"text-white/20"}),s.jsx("p",{className:"text-white/35 text-[13px]",children:"No packs available — backend may not be running."}),s.jsx("button",{onClick:S,className:"mt-1 px-4 py-2 rounded-xl bg-orange-500/10 border border-orange-500/20 text-orange-400 text-[12px] font-medium hover:bg-orange-500/20 transition-colors",children:"Retry"})]}),s.jsxs("div",{className:`grid grid-cols-1 lg:grid-cols-3 gap-5 ${!a&&n.length>0?"grid":"hidden"}`,children:[s.jsxs("div",{className:"flex flex-col bg-gradient-to-b from-[#131d27]/70 to-[#0c0f18]/70 border border-emerald-500/20 rounded-2xl p-5 gap-4 shadow-xl hover:border-emerald-500/35 transition-all duration-200 justify-between",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-bold text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-2 py-0.5 rounded-full uppercase tracking-widest",children:"Premium Algorithmic Package"}),s.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:"Borsa & Otomasyon Paketi"}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed mt-2",children:"Binance, OKX ve Bitget borsaları ile doÄŸrudan bütünleÅŸik, geliÅŸmiÅŸ RSI ve Grid trading bot arayüzünü içerir."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-white/5 flex items-center justify-between mt-auto",children:[s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wider font-semibold",children:"Durum / Status"}),s.jsxs("p",{className:`text-xs font-bold ${e?"text-emerald-400":"text-gray-400"}`,children:[s.jsx("span",{className:e?"inline":"hidden",children:"Kuruldu / Installed"}),s.jsx("span",{className:e?"hidden":"inline",children:"Kurulmadı / Available"})]})]}),s.jsxs("button",{onClick:()=>{t(!0),se.success("Borsa & Botlar paketi baÅŸarıyla kuruldu!")},disabled:e,className:`px-5 py-2 rounded-xl text-xs font-bold transition-all shadow-md active:scale-[0.98] ${e?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 cursor-default":"bg-emerald-600 text-white hover:bg-emerald-500 shadow-emerald-500/10"}`,children:[s.jsx("span",{className:e?"inline":"hidden",children:"Kuruldu"}),s.jsx("span",{className:e?"hidden":"inline",children:"Paketi Kur"})]})]})]}),s.jsxs("div",{className:"flex flex-col bg-gradient-to-b from-[#1c1a2e]/70 to-[#0e0c18]/70 border border-purple-500/20 rounded-2xl p-5 gap-4 shadow-xl hover:border-purple-500/35 transition-all duration-200 justify-between",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-bold text-purple-400 bg-purple-500/10 border border-purple-500/20 px-2 py-0.5 rounded-full uppercase tracking-widest",children:"Web3 & Prediction Markets"}),s.jsx("div",{className:`w-2 h-2 rounded-full ${m?"bg-purple-400 animate-pulse":"bg-purple-800"}`})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:"Polymarket AI Oracle"}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed mt-2",children:"Polymarket tahmin piyasalarında otomatik iÅŸlem yapmayı saÄŸlayan, yapay zeka destekli oracle ve iÅŸlem modülü."})]})]}),s.jsxs("div",{className:`mt-2 space-y-3 border-t border-white/5 pt-3 transition-all ${y?"block":"hidden"}`,children:[s.jsx("label",{className:"block text-[11px] font-medium text-white/60",children:"Web3 Cüzdan Gizli Anahtarı (Private Key)"}),s.jsx("input",{type:"password",autoComplete:"off",value:x,onChange:O=>g(O.target.value),className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2 text-xs text-white/80 placeholder-white/20 focus:outline-none focus:border-purple-500/40 focus:bg-white/[0.07] font-mono",placeholder:"0x..."}),k&&s.jsx("p",{className:"text-[10px] text-red-400 font-medium leading-relaxed",children:k}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:C,disabled:w,className:"flex-1 py-1.5 rounded-lg text-[11px] font-semibold bg-purple-600 text-white hover:bg-purple-500 disabled:opacity-50 transition-colors",children:w?"Kaydediliyor...":"Kaydet"}),s.jsx("button",{onClick:()=>{v(!1),N("")},disabled:w,className:"px-3 py-1.5 rounded-lg text-[11px] text-white/40 hover:text-white/70 hover:bg-white/5 transition-all",children:"İptal"})]})]}),s.jsxs("div",{className:`pt-4 border-t border-white/5 flex items-center justify-between mt-auto ${y?"hidden":"flex"}`,children:[s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wider font-semibold",children:"Durum / Status"}),s.jsxs("p",{className:`text-xs font-bold ${m?"text-purple-400":"text-gray-400"}`,children:[s.jsx("span",{className:m?"inline":"hidden",children:"Kuruldu / Configured"}),s.jsx("span",{className:m?"hidden":"inline",children:"Kurulmadı / Available"})]})]}),s.jsxs("button",{onClick:()=>setPolymarketModalOpen(!0),className:`px-5 py-2 rounded-xl text-xs font-bold transition-all shadow-md active:scale-[0.98] ${m?"bg-purple-500/10 text-purple-400 border border-purple-500/20 hover:bg-purple-500/20 cursor-pointer":"bg-purple-600 text-white hover:bg-purple-500 shadow-purple-500/10"}`,children:[s.jsx("span",{className:m?"inline":"hidden",children:"Yapılandır"}),s.jsx("span",{className:m?"hidden":"inline",children:"Kur / Configure"})]})]})]}),n.map(O=>s.jsx(IP,{pack:O,installing:o===O.id,installLog:c[O.id]??"",onInstall:()=>T(O),onConfigure:()=>p(O)},O.id))]}),s.jsxs("p",{className:"text-center text-white/20 text-[11px] mt-12",children:["Packs are built with"," ",s.jsx("code",{className:"font-mono bg-white/5 px-1 rounded border border-white/8",children:"npm run build:packs"})," ","and published to npm. Run"," ",s.jsx("code",{className:"font-mono bg-white/5 px-1 rounded border border-white/8",children:"must-b ext list"})," ","for the CLI interface."]}),s.jsx(DP,{pack:h,onClose:()=>p(null)})]})}const $P=[{id:"grid-trading",name:"Grid Trading Bot",desc:"Grid strategy for sideways markets."},{id:"rsi-scalper",name:"RSI Scalper Dashboard",desc:"Fast scalping layout based on RSI crossovers."},{id:"arbitrage",name:"Cross-Exchange Arbitrage",desc:"Arbitrage monitoring dashboard."},{id:"dca-accumulator",name:"DCA Accumulator",desc:"Dollar-cost averaging dashboard."},{id:"portfolio-rebalance",name:"Portfolio Auto-Rebalancer",desc:"Dynamic asset weights management layout."}];function VP(){const e=gt(),{selectedTemplate:t,setSelectedTemplate:n}=_i(),r=(a,i)=>{n(a),se.success(`Şablon seçildi: ${i}`),e("/app/trader/connect")};return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto",children:[s.jsxs("div",{className:"mb-10 text-center sm:text-left",children:[s.jsxs("div",{className:"flex items-center gap-3 justify-center sm:justify-start mb-2",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shrink-0",children:s.jsx(A3,{size:18,className:"text-emerald-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-black text-white/95 leading-none",children:"Kontrol Paneli Şablonları"}),s.jsx("p",{className:"text-[11px] text-emerald-400/80 font-medium mt-1",children:"Lütfen bir işlem arayüzü şablonu seçin"})]})]}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed max-w-xl mt-2",children:"İşlem botlarınızın ve portföyünüzün performansını izlemek için optimize edilmiş minimal şablon yapıları."})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:$P.map(a=>s.jsxs("div",{className:`flex flex-col bg-white/3 border rounded-2xl p-4 gap-4 hover:bg-white/5 hover:border-white/20 transition-all duration-200 justify-between ${t===a.id?"border-emerald-500/50":"border-white/8"}`,children:[s.jsxs("div",{className:"space-y-2 bg-black/40 border border-white/6 rounded-xl p-3 h-[140px] flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"w-8 h-2.5 rounded bg-white/10"}),s.jsx("div",{className:"w-3 h-3 rounded-full bg-white/10"})]}),s.jsxs("div",{className:"space-y-1.5 flex-1 flex flex-col justify-center",children:[s.jsx("div",{className:"w-full h-4 rounded bg-white/5 border border-white/8"}),s.jsx("div",{className:"w-3/4 h-2.5 rounded bg-white/5"}),s.jsx("div",{className:"w-1/2 h-2 rounded bg-white/5"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("div",{className:"w-6 h-3 rounded bg-white/10"}),s.jsx("div",{className:"w-8 h-3 rounded bg-white/10"})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col justify-between",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-sm leading-snug mt-2",children:a.name}),s.jsx("p",{className:"text-white/35 text-[11px] leading-relaxed mt-1",children:a.desc})]}),s.jsx("button",{onClick:()=>r(a.id,a.name),className:`w-full flex items-center justify-center gap-1.5 py-2 mt-4 rounded-xl text-[11px] font-bold border transition-all ${t===a.id?"bg-emerald-500/10 text-emerald-400 border-emerald-500/30":"bg-white/5 text-white/60 border-white/10 hover:border-white/25"}`,children:t===a.id?s.jsxs(s.Fragment,{children:[s.jsx(it,{size:12}),s.jsx("span",{children:"Seçildi"})]}):s.jsxs(s.Fragment,{children:[s.jsx(mn,{size:12}),s.jsx("span",{children:"Şablonu Kaydet"})]})})]})]},a.id))})]})}function UP(){const e=gt(),{setConnectedExchange:t,setTestnet:n,setAccountType:r,addAccount:a}=_i(),[i,o]=u.useState("crypto"),[l,c]=u.useState("binance"),[d,h]=u.useState(""),[p,f]=u.useState(""),[m,b]=u.useState(""),[y,v]=u.useState("FBS"),[x,g]=u.useState(""),[w,j]=u.useState("FBS-Real"),[k,N]=u.useState(""),[C,A]=u.useState(!1),[S,T]=u.useState(!1),L=async O=>{if(O.preventDefault(),i==="crypto"){if(!d.trim()||!p.trim()){se.error("API Anahtarı ve Secret alanları boş bırakılamaz.");return}if(l==="okx"&&!m.trim()){se.error("OKX bağlantısı için API parolası (Passphrase) gereklidir.");return}}else{if(!y.trim()||!x.trim()||!m.trim()||!w.trim()){se.error("Broker, Login, Şifre ve Sunucu alanları boş bırakılamaz.");return}if(!k.trim()){se.error("MetaApi Token alanı boş bırakılamaz. MetaApi Cloud hesabınızdan token alın.");return}}T(!0);const z=i==="crypto"?l.toUpperCase():y,$=se.loading(`${z} ${C?"(Testnet) ":""}bağlantısı doğrulanıyor...`);try{const R=i==="crypto"?{accountType:"crypto",exchangeId:l,apiKey:d.trim(),secret:p.trim(),password:m.trim()||void 0,isTestnet:C}:{accountType:"tradfi",broker:y.trim(),login:x.trim(),password:m.trim(),server:w.trim(),apiKey:k.trim(),isTestnet:C},M=await fetch("/api/trader/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)}),P=await M.json();if(!M.ok)throw new Error(P.error||"Bağlantı doğrulanamadı.");se.success(`${z} ${C?"(Testnet) ":""}başarıyla bağlandı!`,{id:$});const E=i==="crypto"?l==="binance"?"Binance":l==="okx"?"OKX":"Bitget":y;t(E),n(C),r(i);const _=i==="crypto"?l.toLowerCase():y.toLowerCase();a({id:_,name:E,type:i,isTestnet:C}),e("/app/trader/dashboard")}catch(R){se.error(R.message||"Bağlantı hatası oluştu.",{id:$})}finally{T(!1)}};return s.jsxs("div",{className:"min-h-[80vh] flex items-center justify-center px-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] h-[400px] bg-emerald-500/10 rounded-full blur-[120px] pointer-events-none"}),s.jsx("div",{className:"absolute bottom-1/4 left-1/3 w-[300px] h-[300px] bg-amber-500/5 rounded-full blur-[100px] pointer-events-none"}),s.jsxs("div",{className:"w-full max-w-lg bg-gradient-to-b from-[#131d27]/90 to-[#0c0f18]/90 border border-emerald-500/20 rounded-3xl p-8 shadow-2xl backdrop-blur-md relative z-10",children:[s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shadow-lg shadow-emerald-500/5",children:s.jsx(cp,{size:26,className:"text-emerald-400"})})}),s.jsxs("div",{className:"text-center mb-6",children:[s.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Güvenli İşlem Bağlantısı"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1 max-w-xs mx-auto leading-relaxed",children:"API anahtarlarınızı veya aracı kurum bilgilerinizi kullanarak bağlantı kurun ve otomatik işlemleri başlatın."})]}),s.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-2xl p-4 mb-6 flex items-start gap-3",children:[s.jsx(Hs,{size:18,className:"text-amber-400 shrink-0 mt-0.5"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h4",{className:"text-xs font-semibold text-amber-300",children:"Önemli Güvenlik Uyarısı"}),s.jsxs("p",{className:"text-[11px] text-amber-200/90 leading-relaxed",children:["API anahtarlarınızda veya kurum hesap yetkilerinizde ",s.jsx("strong",{children:"PARA ÇEKME (Withdraw)"})," yetkisinin KAPALI olduğundan emin olun. Verileriniz cihazınızda şifrelenerek saklanır, buluta gönderilmez."]})]})]}),s.jsxs("form",{onSubmit:L,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"Hesap Tipi"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 bg-zinc-950/40 p-1 border border-zinc-800 rounded-xl",children:[s.jsx("button",{type:"button",onClick:()=>o("crypto"),className:`py-2 text-xs font-bold rounded-lg transition-all ${i==="crypto"?"bg-emerald-600/20 border border-emerald-500/30 text-emerald-400 shadow-md":"text-zinc-400 hover:text-white"}`,children:"Kripto Borsası"}),s.jsx("button",{type:"button",onClick:()=>o("tradfi"),className:`py-2 text-xs font-bold rounded-lg transition-all ${i==="tradfi"?"bg-emerald-600/20 border border-emerald-500/30 text-emerald-400 shadow-md":"text-zinc-400 hover:text-white"}`,children:"Aracı Kurum (TradFi)"})]})]}),s.jsxs("div",{className:"bg-zinc-950/40 border border-zinc-800 rounded-xl p-3.5 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-[12px] font-semibold text-white block",children:"Demo Modu (Testnet)"}),s.jsx("span",{className:"text-[10px] text-zinc-500 mt-0.5 block leading-tight",children:"Gerçek para riske atmadan, sanal bakiye ile stratejilerinizi test edin."})]}),s.jsx("button",{type:"button",onClick:()=>A(!C),disabled:S,className:`w-10 h-6 shrink-0 rounded-full p-1 transition-all duration-300 relative outline-none ${C?"bg-amber-500":"bg-zinc-800"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow-md transform transition-all duration-300 ${C?"translate-x-4":"translate-x-0"}`})})]}),i==="crypto"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"Borsa Seçimi"}),s.jsxs("select",{value:l,onChange:O=>{c(O.target.value),b("")},disabled:S,className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl px-4 py-3 text-sm text-white font-medium outline-none transition-all disabled:opacity-50",children:[s.jsx("option",{value:"binance",children:"Binance"}),s.jsx("option",{value:"okx",children:"OKX"}),s.jsx("option",{value:"bitget",children:"Bitget"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Key (Erişim Anahtarı)"}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(sp,{size:16})}),s.jsx("input",{type:"text",value:d,onChange:O=>h(O.target.value),disabled:S,placeholder:"Örn: 4bc8f9a2e37...",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:!0})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Secret (Gizli Anahtar)"}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(rp,{size:16})}),s.jsx("input",{type:"password",value:p,onChange:O=>f(O.target.value),disabled:S,placeholder:"••••••••••••••••••••••••••••••••",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:!0})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Parolası / Passphrase"}),s.jsx("span",{className:"text-[9px] text-zinc-500 font-medium tracking-wide block uppercase",children:l==="okx"?"OKX için Zorunlu":"Opsiyonel"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(cv,{size:16})}),s.jsx("input",{type:"password",value:m,onChange:O=>b(O.target.value),disabled:S,placeholder:l==="okx"?"OKX API Parolası":"Gerekirse şifre / parola",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:l==="okx"})]})]})]}):s.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-emerald-500/10 bg-gradient-to-br from-zinc-900/60 via-zinc-950/80 to-[#0c0f18]/90 backdrop-blur-xl p-6 flex flex-col items-center gap-4 my-2",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-500/5 via-transparent to-cyan-500/5 pointer-events-none"}),s.jsx("div",{className:"absolute -top-10 -right-10 w-32 h-32 bg-emerald-500/10 rounded-full blur-3xl pointer-events-none"}),s.jsx("div",{className:"absolute -bottom-10 -left-10 w-28 h-28 bg-cyan-500/8 rounded-full blur-3xl pointer-events-none"}),s.jsx("div",{className:"relative z-10 w-14 h-14 rounded-2xl bg-gradient-to-br from-emerald-500/20 to-cyan-500/10 border border-emerald-500/20 flex items-center justify-center shadow-xl shadow-emerald-500/5 mt-2",children:s.jsx("svg",{className:"w-7 h-7 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.955 11.955 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.249-8.25-3.286Z"})})}),s.jsxs("div",{className:"relative z-10 flex items-center gap-1.5 bg-emerald-500/10 border border-emerald-500/20 rounded-full px-3 py-1",children:[s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),s.jsx("span",{className:"text-[10px] font-bold text-emerald-400 uppercase tracking-widest",children:"Çok Yakında"})]}),s.jsxs("div",{className:"relative z-10 text-center space-y-2 pb-2",children:[s.jsx("h3",{className:"text-sm font-bold text-white",children:"Yerel MetaTrader 4/5 Entegrasyonu"}),s.jsx("p",{className:"text-[11px] text-zinc-400 leading-relaxed max-w-[260px]",children:"Doğrudan aracı kurum bağlantısı ile MT4/MT5 hesaplarınızı Must-b yapay zeka motoruna bağlayın."})]}),s.jsx("ul",{className:"relative z-10 space-y-2 w-full text-[11px] text-zinc-500 pb-1",children:["FBS, IC Markets, Pepperstone desteği","Gerçek zamanlı Lot execution","Uyuyan Dev AI stratejisi entegrasyonu"].map(O=>s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-4 h-4 rounded-full border border-emerald-500/20 bg-emerald-500/5 flex items-center justify-center shrink-0",children:s.jsx("div",{className:"w-1 h-1 rounded-full bg-emerald-500/60"})}),O]},O))})]}),s.jsx("button",{type:"submit",disabled:S||i==="tradfi",className:`w-full flex items-center justify-center gap-2.5 py-3.5 px-6 mt-6 rounded-xl font-bold text-sm text-white transition-all relative overflow-hidden shadow-lg ${i==="tradfi"?"bg-zinc-800 opacity-50 cursor-not-allowed shadow-none":"bg-emerald-600 hover:bg-emerald-500 active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed shadow-emerald-500/10"}`,children:S?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:16,className:"animate-spin text-white"}),s.jsx("span",{children:"Doğrulanıyor..."})]}):i==="tradfi"?s.jsx("span",{children:"Çok Yakında"}):s.jsx("span",{children:"Güvenli Bağlantı Kur"})})]}),s.jsx("p",{className:"text-[10px] text-zinc-600 mt-6 text-center leading-relaxed",children:"Must-b.os, API anahtarlarınızı tamamen yerel cihazınızda AES-256 algoritmasıyla şifreler."})]})]})}function HP(){const e=gt(),{accounts:t,removeAccount:n,connectedExchange:r,selectedTemplate:a}=_i(),[i,o]=u.useState(""),[l,c]=u.useState([{id:"rsi-scalper",name:"RSI Scalper AI",desc:"Fast scalping crossovers",active:!1},{id:"grid-trader",name:"Grid Trader AI",desc:"Sideways market grid",active:!1},{id:"macd-reversal",name:"MACD Reversal AI",desc:"Trend reversal detector",active:!1}]),[d,h]=u.useState(!0),[p,f]=u.useState(null),[m,b]=u.useState([]),[y,v]=u.useState({}),[x,g]=u.useState({"rsi-scalper":3e5,"grid-trader":3e5,"macd-reversal":3e5});u.useEffect(()=>{t&&t.length>0&&!i&&o(t[0].id)},[t,i]),u.useEffect(()=>{!r&&(!t||t.length===0)&&e("/app/trader/connect")},[r,t]);const w=async S=>{var L;const T=S||i||t&&((L=t[0])==null?void 0:L.id)||"";if(!T){h(!1);return}try{const O=`/api/trader/balance?exchangeId=${T}`,z=`/api/trader/history?exchangeId=${T}`,[$,R,M]=await Promise.all([fetch(O),fetch(z),fetch("/api/bot/status")]);if($.ok){const P=await $.json();f(P)}else f(null);if(R.ok){const P=await R.json();b(P.trades||[])}else b([]);if(M.ok){const P=await M.json();P.active&&(v(P.active),c(E=>E.map(_=>({..._,active:P.active[_.id]!==void 0}))),g(E=>{const _={...E};for(const I in P.active)_[I]=P.active[I];return _}))}}catch{se.error("Borsa verileri yüklenemedi.")}finally{h(!1)}};u.useEffect(()=>{i&&w(i)},[i]);const j=async(S,T,L)=>{const O=!L,z=x[S]||3e5,$=se.loading(O?`${T} başlatılıyor...`:`${T} durduruluyor...`);try{if(O){if(!(await fetch("/api/bot/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botId:S,pair:"BTC/USDT",intervalMs:z})})).ok)throw new Error("Bot başlatılamadı.");v(M=>({...M,[S]:z})),c(M=>M.map(P=>P.id===S?{...P,active:!0}:P)),se.success(`${T} başarıyla başlatıldı!`,{id:$})}else{if(!(await fetch("/api/bot/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botId:S})})).ok)throw new Error("Bot durdurulamadı.");v(M=>{const P={...M};return delete P[S],P}),c(M=>M.map(P=>P.id===S?{...P,active:!1}:P)),se.error(`${T} durduruldu.`,{id:$})}}catch(R){se.error(R.message||"İşlem başarısız.",{id:$})}},k=async(S,T)=>{if(window.confirm(`${T} bağlantısını kesmek ve hesabı kaldırmak istediğinize emin misiniz?`))try{const L=await fetch("/api/trader/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({exchangeId:S})});if(!L.ok){const z=await L.json().catch(()=>({}));throw new Error(z.error||"Bağlantı kesilemedi.")}n(S),se.success(`${T} başarıyla kaldırıldı.`);const O=t.filter(z=>z.id!==S);O.length>0?o(O[0].id):e("/app/trader/connect")}catch(L){se.error(L.message||"Bir hata oluştu.")}},N=S=>{const T=t.find(z=>z.id===i),L=T?T.name:r,O=L==="Binance"?"https://www.binance.com":L==="OKX"?"https://www.okx.com":"https://www.bitget.com";se.info("Yasal işlemler için ilgili borsaya yönlendiriliyorsunuz..."),setTimeout(()=>{window.open(O,"_blank")},800)};if(d)return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[s.jsxs("div",{className:"space-y-2 animate-pulse",children:[s.jsx("div",{className:"h-6 w-48 bg-white/5 rounded-lg"}),s.jsx("div",{className:"h-4 w-32 bg-white/5 rounded-lg"})]}),s.jsxs("div",{className:"flex items-center gap-2 animate-pulse",children:[s.jsx("div",{className:"h-8 w-24 bg-white/5 rounded-lg"}),s.jsx("div",{className:"h-8 w-24 bg-white/5 rounded-lg"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 animate-pulse",children:[s.jsxs("div",{className:"md:col-span-1 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 h-[250px] space-y-4",children:[s.jsx("div",{className:"h-4 w-24 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"})]}),s.jsxs("div",{className:"md:col-span-2 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 h-[250px] space-y-4",children:[s.jsx("div",{className:"h-4 w-24 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-32 bg-white/5 rounded-xl"})]})]})]});const C=t.find(S=>S.id===i),A=(C==null?void 0:C.type)==="tradfi";return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-black text-white/95 leading-none",children:"Trader Dashboard"}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1 flex items-center gap-1.5",children:["Aktif Hesap: ",s.jsx("span",{className:"text-emerald-400 font-semibold",children:(p==null?void 0:p.exchange)||(C==null?void 0:C.name)||r||"Bağlı Değil"})," · ","Şablon: ",s.jsx("span",{className:"text-cyan-400 font-semibold",children:a||"Varsayılan"})]})]}),!A&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>N(),className:"flex items-center gap-1 px-4 py-2 rounded-xl text-xs font-bold text-white bg-emerald-600 hover:bg-emerald-500 transition-all active:scale-[0.98]",children:[s.jsx("span",{children:"Para Yatır"}),s.jsx(Kr,{size:12})]}),s.jsxs("button",{onClick:()=>N(),className:"flex items-center gap-1 px-4 py-2 rounded-xl text-xs font-bold text-white bg-white/5 border border-white/8 hover:bg-white/8 hover:border-white/12 transition-all active:scale-[0.98]",children:[s.jsx("span",{children:"Para Çek"}),s.jsx(Kr,{size:12})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 flex flex-col justify-between h-[130px] relative overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Toplam Varlık / Total Balance"}),s.jsxs("div",{className:"flex items-center gap-2",children:[((p==null?void 0:p.isTestnet)||(C==null?void 0:C.isTestnet))&&s.jsx("span",{className:"px-2 py-0.5 rounded bg-amber-500/10 border border-amber-500/25 text-amber-400 font-bold uppercase tracking-wider text-[8px] animate-pulse",children:"DEMO ACTIVE"}),s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse"})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("p",{className:"text-2xl font-black text-white/90 font-mono",children:[(p==null?void 0:p.displayAsset)==="USDT"||(p==null?void 0:p.displayAsset)==="USD"?"$":"",p?p.total.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"0.00"," ",(p==null?void 0:p.displayAsset)!=="USDT"&&(p==null?void 0:p.displayAsset)!=="USD"?p==null?void 0:p.displayAsset:""]}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"Son güncelleme: Az önce"})]})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 flex flex-col justify-between h-[130px]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Kullanılabilir Bakiye / Free Balance"}),s.jsx(yv,{size:14,className:"text-emerald-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("p",{className:"text-2xl font-black text-emerald-400 font-mono",children:[(p==null?void 0:p.displayAsset)==="USDT"||(p==null?void 0:p.displayAsset)==="USD"?"$":"",p?p.free.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"0.00"," ",(p==null?void 0:p.displayAsset)!=="USDT"&&(p==null?void 0:p.displayAsset)!=="USD"?p==null?void 0:p.displayAsset:""]}),s.jsxs("p",{className:"text-[10px] text-emerald-500/80 font-semibold mt-1 flex items-center gap-0.5",children:[s.jsx(nv,{size:10})," Bloke / Used: ",p?p.used.toFixed(2):"0.00"," ",p==null?void 0:p.displayAsset]})]})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-5 flex flex-col justify-between h-[130px] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-white/5 pb-2 mb-2",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Bağlı Hesaplar"}),s.jsx("button",{onClick:()=>e("/app/trader/connect"),className:"text-[10px] font-bold text-emerald-400 hover:text-emerald-300 hover:underline",children:"+ Yeni Ekle"})]}),s.jsxs("div",{className:"space-y-1.5 flex-1 pr-1 scrollbar-thin",children:[t&&t.map(S=>s.jsxs("div",{onClick:()=>o(S.id),className:`flex items-center justify-between p-1.5 rounded-lg border cursor-pointer transition-all ${i===S.id?"bg-emerald-500/10 border-emerald-500/30 text-white font-bold":"bg-white/3 border-white/5 text-zinc-400 hover:bg-white/5 hover:text-white"}`,children:[s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${i===S.id?"bg-emerald-400":"bg-zinc-600"}`}),s.jsxs("span",{className:"text-[11px] truncate",children:[S.name," ",S.isTestnet?"(Demo)":""]})]}),s.jsx("button",{onClick:T=>{T.stopPropagation(),k(S.id,S.name)},className:"text-[9px] font-semibold text-red-400 hover:text-red-300 hover:underline px-1 py-0.5 rounded hover:bg-red-500/10 transition-all shrink-0",children:"Kaldır"})]},S.id)),(!t||t.length===0)&&s.jsx("p",{className:"text-[10px] text-zinc-500 italic text-center py-2",children:"Bağlı hesap bulunamadı."})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"md:col-span-1 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-white/5 pb-3",children:[s.jsx(Wr,{size:16,className:"text-emerald-400"}),s.jsx("h2",{className:"text-sm font-bold text-white",children:"Aktif Robotlar / Bots"})]}),s.jsx("div",{className:"space-y-3",children:l.map(S=>s.jsxs("div",{className:`p-3.5 rounded-xl border flex flex-col gap-3 transition-all ${S.active?"bg-emerald-500/5 border-emerald-500/25":"bg-white/3 border-white/6"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[S.active&&s.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse shrink-0"}),s.jsxs("div",{className:"truncate",children:[s.jsx("p",{className:"text-xs font-bold text-white/90",children:S.name}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5 truncate",children:S.desc})]})]}),s.jsx("button",{onClick:()=>j(S.id,S.name,S.active),className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 transition-all ${S.active?"bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20":"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20"}`,children:S.active?s.jsx(Bl,{size:10,fill:"currentColor"}):s.jsx(gs,{size:10,fill:"currentColor"})})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2.5 border-t border-white/5",children:[s.jsx("span",{className:"text-[9px] text-zinc-500 font-bold uppercase tracking-wider",children:"Periyot / Interval"}),s.jsxs("select",{value:x[S.id]||3e5,onChange:T=>{const L=parseInt(T.target.value);g(O=>({...O,[S.id]:L}))},disabled:S.active,className:"bg-zinc-950 border border-zinc-800 text-[10px] text-zinc-300 font-semibold rounded-lg px-2 py-1 focus:outline-none focus:border-emerald-500/40 cursor-pointer disabled:opacity-40",children:[s.jsx("option",{value:6e4,children:"1 Dakika"}),s.jsx("option",{value:3e5,children:"5 Dakika"}),s.jsx("option",{value:9e5,children:"15 Dakika"}),s.jsx("option",{value:36e5,children:"1 Saat"})]})]})]},S.id))})]}),s.jsxs("div",{className:"md:col-span-2 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-white/5 pb-3",children:[s.jsx(b3,{size:16,className:"text-cyan-400"}),s.jsx("h2",{className:"text-sm font-bold text-white",children:"İşlem Geçmişi / Trade History"})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-left text-xs text-gray-400",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-white/5 text-gray-600 font-bold uppercase tracking-wider text-[10px]",children:[s.jsx("th",{className:"py-2.5",children:"Parite / Pair"}),s.jsx("th",{className:"py-2.5",children:"Yön / Side"}),s.jsx("th",{className:"py-2.5",children:"Tarih / Date"}),s.jsx("th",{className:"py-2.5 text-right",children:"Miktar / Amount"})]})}),s.jsx("tbody",{className:"divide-y divide-white/5 font-mono text-[11px]",children:m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:4,className:"py-6 text-center text-zinc-600 italic",children:"İşlem geçmişi bulunamadı."})}):m.map(S=>{const T=String(S.side).toUpperCase()==="BUY",L=new Date(S.datetime).toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})+" "+new Date(S.datetime).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1});return s.jsxs("tr",{className:"hover:bg-white/2 transition-colors",children:[s.jsx("td",{className:"py-3 font-semibold text-white/80",children:S.symbol}),s.jsx("td",{className:"py-3",children:s.jsx("span",{className:`px-1.5 py-0.5 rounded-md font-bold text-[9px] ${T?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20":"bg-red-500/10 text-red-400 border border-red-500/20"}`,children:S.side.toUpperCase()})}),s.jsx("td",{className:"py-3 text-gray-500",children:L}),s.jsxs("td",{className:`py-3 text-right font-bold ${T?"text-emerald-400":"text-red-400"}`,children:[T?"+":"-",S.amount.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:6})]})]},S.id)})})]})})]})]})]})}function X0(e){return e>=90?"#ef4444":e>=70?"#f97316":"#22c55e"}function ma(e){return e==="critical"?"#ef4444":e==="warning"?"#f97316":"#60a5fa"}function WP(){const{t:e,locale:t}=yt(),n=e.systemHealth,[r,a]=u.useState(null),[i,o]=u.useState(null),[l,c]=u.useState(!1),d=u.useCallback(()=>o(null),[]);u.useEffect(()=>{window.dispatchEvent(new CustomEvent("mustb:safeMode",{detail:{active:(r==null?void 0:r.safeMode)??!1}}))},[r==null?void 0:r.safeMode]),u.useEffect(()=>{const f=pe();return f.on("systemStats",m=>a(m)),f.on("systemHealth",m=>{if(o(m),c(!0),m.level!=="critical"){const b=m.level==="info"?6e3:12e3;setTimeout(()=>o(null),b)}}),()=>{f.off("systemStats"),f.off("systemHealth")}},[]);const h=(r==null?void 0:r.cpu)??0,p=(r==null?void 0:r.ram)??0;return s.jsxs("div",{className:"relative flex items-center",children:[s.jsxs("button",{onClick:()=>i&&c(f=>!f),className:"flex items-center gap-1.5 select-none transition-all rounded-md",style:{cursor:i?"pointer":"default"},title:i?i.message:n.title,children:[i?s.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0 animate-pulse",style:{background:ma(i.level)}}):s.jsx(tn,{size:12,className:"text-orange-400/70"}),r&&s.jsxs("span",{className:"hidden sm:flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[10px] font-semibold text-white/45",children:"CPU"}),s.jsx("span",{className:"w-9 h-1 rounded-full bg-white/10 overflow-hidden flex-shrink-0",children:s.jsx("span",{className:"h-full rounded-full block transition-all duration-700",style:{width:`${h}%`,background:X0(h)}})}),s.jsxs("span",{className:"text-[9px] font-mono text-white/40 w-6 text-right",children:[h,"%"]}),s.jsx("span",{className:"w-px h-3 bg-white/10"}),s.jsx("span",{className:"text-[10px] font-semibold text-white/45",children:"RAM"}),s.jsx("span",{className:"w-9 h-1 rounded-full bg-white/10 overflow-hidden flex-shrink-0",children:s.jsx("span",{className:"h-full rounded-full block transition-all duration-700",style:{width:`${p}%`,background:X0(p)}})}),s.jsxs("span",{className:"text-[9px] font-mono text-white/40 w-6 text-right",children:[p,"%"]}),r.liteMode&&!r.safeMode&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded bg-orange-500/20 text-orange-400 ml-0.5",children:n.lite}),r.safeMode&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded bg-red-500/20 text-red-400 ml-0.5",children:n.safe})]}),!r&&s.jsx("span",{className:"text-[10px] font-semibold hidden sm:inline text-white/35",children:n.title})]}),s.jsx(ae,{children:l&&i&&s.jsxs(V.div,{initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.96},transition:{duration:.2,ease:"easeOut"},className:"absolute top-full right-0 mt-2 w-72 z-[200] rounded-2xl overflow-hidden",style:{background:"rgba(20,8,2,0.88)",border:`1px solid ${ma(i.level)}44`,backdropFilter:"blur(20px)",boxShadow:`0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px ${ma(i.level)}22`},children:[s.jsxs("div",{className:"flex items-start justify-between px-4 pt-3 pb-2",style:{borderBottom:`1px solid ${ma(i.level)}22`},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hs,{size:13,style:{color:ma(i.level)}}),s.jsxs("span",{className:"text-[12px] font-bold text-white/90 capitalize",children:[n[i.level]??i.level," — ",n.kinds[i.kind]??i.kind]})]}),s.jsx("button",{onClick:d,className:"text-white/30 hover:text-white/70 transition-colors",children:s.jsx(Ie,{size:13})})]}),s.jsxs("div",{className:"px-4 py-3 space-y-2",children:[s.jsx("p",{className:"text-[13px] text-white/80 leading-relaxed",children:n.alerts[i.kind]??i.message}),s.jsx("p",{className:"text-[11px] text-white/45 leading-relaxed italic",children:n.recommendations[i.kind]??i.recommendation})]}),s.jsx("div",{className:"px-4 pb-3",children:s.jsx("span",{className:"text-[10px] text-white/25 font-mono",children:new Date(i.ts).toLocaleTimeString()})})]},"health-popover")})]})}function KP(e){return`${Math.round(e*100)}%`}const Q0={skill:{label:"Skill",icon:Ue,color:"text-orange-400"},conversation:{label:"Conversation",icon:Us,color:"text-blue-400"},workspace:{label:"Workspace",icon:Ln,color:"text-green-400"},custom:{label:"Custom",icon:nn,color:"text-gray-400"}};function GP(){const{t:e}=yt(),t=e.panels.memory,[n,r]=u.useState(""),[a,i]=u.useState([]),[o,l]=u.useState(null),[c,d]=u.useState(!1),[h,p]=u.useState(null),[f,m]=u.useState(null),[b,y]=u.useState(!1),v=u.useRef(null),x=u.useCallback(async k=>{const N=k.trim();if(N){d(!0),i([]);try{const C=await U(`/api/memory/search?q=${encodeURIComponent(N)}&limit=10`);if(C.ok){const A=await C.json();i(A.results??[])}}catch{}d(!1)}},[]),g=k=>{k.key==="Enter"&&x(n)},w=u.useCallback(async()=>{try{const k=await U("/api/memory/stats");k.ok&&l(await k.json())}catch{}},[]),j=async k=>{p(k),m(null);try{const N=k==="clear"?await U("/api/memory/clear-index",{method:"DELETE"}):await U(`/api/memory/index-${k}`,{method:"POST"});if(N.ok){const C=await N.json(),A=k==="clear"?t.indexCleared:`${t.indexed} ${C.indexed??0} ${k==="skills"?t.skills:t.files}`;m({ok:!0,msg:A}),w(),k==="clear"&&i([])}else m({ok:!1,msg:t.opFailed})}catch{m({ok:!1,msg:t.reqError})}p(null),setTimeout(()=>m(null),4e3)};return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zt,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title}),o&&s.jsxs("span",{className:"text-[10px] text-gray-600 bg-white/5 px-2 py-0.5 rounded-full font-mono",children:[o.items.toLocaleString()," ",t.vectors]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>{y(k=>!k),o||w()},className:`text-gray-600 hover:text-gray-400 transition-colors ${b?"text-orange-400":""}`,title:t.indexControls,children:s.jsx(F3,{size:13})}),s.jsx("button",{onClick:w,className:"text-gray-600 hover:text-gray-400 transition-colors",title:t.refreshStats,children:s.jsx(ge,{size:13})})]})]}),s.jsx(ae,{children:b&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-b border-white/5 bg-white/2 overflow-hidden shrink-0",children:[s.jsxs("div",{className:"px-6 py-3 flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 uppercase tracking-widest font-bold shrink-0",children:t.indexLabel}),["skills","workspace"].map(k=>s.jsxs("button",{onClick:()=>j(k),disabled:h!==null,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-white/4 border border-white/6 text-[11px] text-gray-400 hover:text-gray-200 hover:bg-white/8 transition-all disabled:opacity-40 capitalize",children:[h===k?s.jsx(ne,{size:10,className:"animate-spin"}):k==="skills"?s.jsx(Ue,{size:10}):s.jsx(Ln,{size:10}),k]},k)),s.jsxs("button",{onClick:()=>j("clear"),disabled:h!==null,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-red-500/8 border border-red-500/15 text-[11px] text-red-400 hover:bg-red-500/15 transition-all disabled:opacity-40 ml-auto",children:[h==="clear"?s.jsx(ne,{size:10,className:"animate-spin"}):s.jsx(ys,{size:10}),t.clearIndex]})]}),s.jsx(ae,{children:f&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 px-6 pb-3 text-[11px] font-medium ${f.ok?"text-green-400":"text-red-400"}`,children:[f.ok?s.jsx(Fe,{size:11}):s.jsx(Ke,{size:11}),f.msg]})})]})}),s.jsxs("div",{className:"px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl bg-white/4 border border-white/8 focus-within:border-orange-500/30 transition-colors",children:[s.jsx(fn,{size:13,className:"text-gray-600 shrink-0"}),s.jsx("input",{ref:v,value:n,onChange:k=>r(k.target.value),onKeyDown:g,placeholder:t.searchPlaceholder,className:"flex-1 bg-transparent text-[13px] text-gray-200 outline-none placeholder-gray-700"}),c?s.jsx(ne,{size:13,className:"text-orange-400 animate-spin shrink-0"}):s.jsx("button",{onClick:()=>x(n),disabled:!n.trim(),className:"text-[10px] px-2 py-0.5 rounded-lg bg-orange-500/12 text-orange-400 font-semibold hover:bg-orange-500/22 border border-orange-500/20 transition-all disabled:opacity-30",children:"⌘↵"})]}),s.jsx("p",{className:"text-[10px] text-gray-700 mt-1.5 ml-1",children:t.searchHint})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-3",children:[a.length===0&&!c&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(Zt,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:n.trim()?t.emptyNoResults:t.emptyTitle}),s.jsx("p",{className:"text-xs text-gray-700 mt-1 max-w-xs leading-relaxed",children:n.trim()?t.emptyNoResultsHint:t.emptyHint})]}),a.map((k,N)=>{const C=Q0[k.metadata.source]??Q0.custom,A=C.icon;return s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:N*.04},className:"rounded-2xl border border-white/6 bg-[#0c0f18] p-4 hover:border-white/12 transition-all",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(A,{size:11,className:`${C.color} shrink-0`}),s.jsx("p",{className:"text-[12px] font-semibold text-gray-300 truncate",children:k.metadata.title})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full border ${k.score>=.85?"bg-green-500/10 border-green-500/20 text-green-400":k.score>=.65?"bg-orange-500/10 border-orange-500/20 text-orange-400":"bg-white/4 border-white/6 text-gray-500"}`,children:KP(k.score)}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-white/4 border border-white/6 font-medium ${C.color}`,children:C.label})]})]}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed line-clamp-3 mb-2",children:k.text}),k.metadata.tags&&k.metadata.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:k.metadata.tags.map((S,T)=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:S},T))}),s.jsx("div",{className:"mt-2 h-0.5 bg-white/4 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-orange-600 to-amber-400",style:{width:`${k.score*100}%`}})})]},N)})]})]})}const qP={node:en,python:wn},YP={node:"text-green-400",python:"text-blue-400"};function XP(){const{t:e}=yt(),t=e.panels.plugins,[n,r]=u.useState([]),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(null),[h,p]=u.useState(!1),[f,m]=u.useState(""),[b,y]=u.useState(""),[v,x]=u.useState("node"),[g,w]=u.useState(""),[j,k]=u.useState(!1),N=(T,L)=>{d({ok:T,msg:L}),setTimeout(()=>d(null),4e3)},C=u.useCallback(async()=>{i(!0);try{const T=await U("/api/plugins/list");if(T.ok){const L=await T.json();r(L.plugins??[])}}catch{}i(!1)},[]);u.useEffect(()=>{C()},[C]);const A=async(T,L)=>{l(T);try{(await U(L?"/api/plugins/stop":"/api/plugins/run",{method:"POST",body:JSON.stringify({name:T})})).ok?(N(!0,L?`${T} stopped`:`${T} launched`),await C()):N(!1,t.opFailed)}catch{N(!1,t.reqError)}l(null)},S=async()=>{if(!(!f.trim()||!b.trim())){k(!0);try{(await U("/api/plugins/build",{method:"POST",body:JSON.stringify({name:f.trim(),goal:b.trim(),lang:v,context:g.trim()||void 0})})).ok?(N(!0,`Plugin "${f}" created`),m(""),y(""),w(""),p(!1),await C()):N(!1,t.buildFailed)}catch{N(!1,t.reqError)}k(!1)}};return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qr,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title}),s.jsxs("span",{className:"text-[10px] text-gray-600 bg-white/5 px-2 py-0.5 rounded-full font-mono",children:[n.length," ",t.installed]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:C,className:"text-gray-600 hover:text-gray-400 transition-colors",title:t.refresh,children:s.jsx(ge,{size:13,className:a?"animate-spin":""})}),s.jsxs("button",{onClick:()=>p(T=>!T),className:`flex items-center gap-1 text-[10px] px-2.5 py-1 rounded-lg border font-semibold transition-all ${h?"bg-orange-500/15 border-orange-500/25 text-orange-400":"bg-white/4 border-white/8 text-gray-500 hover:text-gray-300"}`,children:[s.jsx(Dl,{size:10}),t.newPlugin]})]})]}),s.jsx(ae,{children:c&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 px-6 py-2 text-[11px] font-medium shrink-0 ${c.ok?"text-green-400":"text-red-400"}`,children:[c.ok?s.jsx(Fe,{size:11}):s.jsx(Ke,{size:11}),c.msg]})}),s.jsx(ae,{children:h&&s.jsx(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-b border-white/5 bg-white/2 overflow-hidden shrink-0",children:s.jsxs("div",{className:"px-6 py-4 space-y-3",children:[s.jsx("p",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-widest",children:t.buildTitle}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx("input",{value:f,onChange:T=>m(T.target.value),placeholder:t.namePlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("input",{value:b,onChange:T=>y(T.target.value),placeholder:t.goalPlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("input",{value:g,onChange:T=>w(T.target.value),placeholder:t.contextPlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("div",{className:"flex gap-2",children:["node","python"].map(T=>s.jsx("button",{onClick:()=>x(T),className:`flex-1 py-1.5 rounded-lg border text-[11px] font-semibold transition-all capitalize ${v===T?"bg-orange-500/15 border-orange-500/25 text-orange-400":"bg-white/4 border-white/8 text-gray-500"}`,children:T},T))}),s.jsxs("button",{onClick:S,disabled:j||!f.trim()||!b.trim(),className:"flex items-center justify-center gap-1.5 py-2 rounded-lg bg-orange-500/12 border border-orange-500/20 text-orange-400 text-[11px] font-bold hover:bg-orange-500/20 transition-all disabled:opacity-40",children:[j?s.jsx(ne,{size:11,className:"animate-spin"}):s.jsx(Ue,{size:11}),t.generatePlugin]})]})]})})}),s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-2",children:[n.length===0&&!a&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(qr,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:t.emptyTitle}),s.jsx("p",{className:"text-xs text-gray-700 mt-1",children:t.emptyHint})]}),n.map((T,L)=>{const O=qP[T.lang]??en,z=o===T.name;return s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:L*.04},className:`flex items-center gap-3 p-3 rounded-2xl border transition-all ${T.running?"bg-green-500/5 border-green-500/15 hover:border-green-500/25":"bg-[#0c0f18] border-white/6 hover:border-white/12"}`,children:[s.jsx(O,{size:13,className:YP[T.lang]??"text-gray-400"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[12px] font-semibold text-gray-300 truncate",children:T.name}),s.jsx("p",{className:"text-[10px] text-gray-600 font-mono",children:T.filename})]}),T.running&&s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-green-500/12 border border-green-500/20 text-green-400 font-bold",children:t.running}),s.jsxs("button",{disabled:z,onClick:()=>A(T.name,T.running),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-lg border text-[10px] font-bold transition-all disabled:opacity-40 ${T.running?"bg-red-500/8 border-red-500/15 text-red-400 hover:bg-red-500/15":"bg-green-500/8 border-green-500/15 text-green-400 hover:bg-green-500/15"}`,children:[z?s.jsx(ne,{size:10,className:"animate-spin"}):T.running?s.jsx(Bl,{size:10}):s.jsx(gs,{size:10}),T.running?t.stop:t.run]})]},T.name)})]})]})}function QP(e){if(!e)return"Never";try{return new Date(e).toLocaleString("en-US",{dateStyle:"short",timeStyle:"short"})}catch{return e}}function JP(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function ZP({skill:e}){const[t,n]=u.useState(!1),[r,a]=u.useState(!1),[i,o]=u.useState(""),[l,c]=u.useState(!1),d=async()=>{if(!l){c(!0);return}if(i.trim()){n(!0);try{await U("/api/v1/skills/invoke",{method:"POST",body:JSON.stringify({skill:e.id,params:{goal:i.trim(),_autoRun:!0}})}),a(!0),c(!1),o(""),setTimeout(()=>a(!1),3e3)}catch{}n(!1)}},h=(e.requires.bins??[]).length>0,p=(e.requires.config??[]).length>0;return s.jsx(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"rounded-2xl border border-white/6 bg-[#0c0f18] hover:border-white/12 transition-all",children:s.jsxs("div",{className:"p-3",children:[s.jsxs("div",{className:"flex items-start gap-2 mb-1.5",children:[s.jsx("span",{className:"text-base leading-none mt-0.5 shrink-0",children:e.emoji??"⚡"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-[12px] font-bold text-gray-200 truncate capitalize",children:e.name})}),e.hasScripts&&s.jsx(Mn,{size:10,className:"text-gray-700 shrink-0 mt-0.5"})]}),s.jsx("p",{className:"text-[10px] text-gray-500 leading-relaxed line-clamp-2 mb-2 ml-6",children:e.description}),(h||p)&&s.jsxs("div",{className:"flex flex-wrap gap-1 mb-2 ml-6",children:[(e.requires.bins??[]).map(f=>s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-blue-500/8 border border-blue-500/15 text-blue-400 font-mono",children:["bin:",f]},f)),(e.requires.config??[]).map(f=>s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-purple-500/8 border border-purple-500/15 text-purple-400 font-mono",children:["cfg:",f]},f))]}),s.jsx(ae,{children:l&&s.jsx(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden mb-2",children:s.jsx("input",{autoFocus:!0,value:i,onChange:f=>o(f.target.value),onKeyDown:f=>{f.key==="Enter"&&d(),f.key==="Escape"&&(c(!1),o(""))},placeholder:`Goal for ${e.name}…`,className:"w-full px-2.5 py-1.5 rounded-lg bg-white/4 border border-white/10 text-[11px] text-gray-200 placeholder-gray-700 outline-none focus:border-orange-500/30 transition-colors"})})}),s.jsxs("div",{className:"flex items-center justify-end gap-1 ml-6",children:[l&&s.jsx("button",{onClick:()=>{c(!1),o("")},className:"text-[10px] px-2 py-1 rounded-lg bg-white/4 text-gray-600 hover:text-gray-400 transition-colors",children:"Cancel"}),s.jsx("button",{onClick:d,disabled:t||l&&!i.trim(),className:`flex items-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-semibold border transition-all disabled:opacity-40 ${r?"bg-green-500/10 border-green-500/20 text-green-400":"bg-orange-500/8 border-orange-500/15 text-orange-400 hover:bg-orange-500/15"}`,children:t?s.jsx(ne,{size:9,className:"animate-spin"}):r?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:9})," Sent"]}):l?s.jsxs(s.Fragment,{children:[s.jsx(gn,{size:9})," Run"]}):s.jsxs(s.Fragment,{children:[s.jsx(D3,{size:9})," Use"]})})]})]})})}function e6(){const{t:e}=yt(),t=e.panels.skills,[n,r]=u.useState("saved"),[a,i]=u.useState([]),[o,l]=u.useState(!1),[c,d]=u.useState(null),[h,p]=u.useState("idle"),[f,m]=u.useState(null),[b,y]=u.useState(null),[v,x]=u.useState([]),[g,w]=u.useState(!1),[j,k]=u.useState(""),N=u.useCallback(async()=>{l(!0);try{const L=await U("/api/skills/list");if(L.ok){const O=await L.json();i(O.skills??[])}}catch{}l(!1)},[]),C=u.useCallback(async()=>{w(!0);try{const L=await U("/api/skills/catalog");if(L.ok){const O=await L.json();x(O.skills??[])}}catch{}w(!1)},[]);u.useEffect(()=>{N()},[N]),u.useEffect(()=>{n==="library"&&v.length===0&&C()},[n,v.length,C]),u.useEffect(()=>{const L=pe(),O=z=>{z.type==="skillRunStart"&&z.skillId&&(d(z.skillId),p("running")),z.type==="planFinish"&&(p("done"),d(null),N(),setTimeout(()=>p("idle"),2500))};return L.on("agentUpdate",O),()=>{L.off("agentUpdate",O)}},[N]);const A=async L=>{if(!c){d(L.id),p("running");try{const O=await U("/api/skills/run",{method:"POST",body:JSON.stringify({id:L.id})});if(!O.ok)throw new Error(`HTTP ${O.status}`)}catch{p("error"),d(null),setTimeout(()=>p("idle"),3e3)}}},S=async L=>{m(L);try{await U(`/api/skills/${L}`,{method:"DELETE"}),i(O=>O.filter(z=>z.id!==L))}catch{}m(null),y(null)},T=j.trim()?v.filter(L=>L.name.toLowerCase().includes(j.toLowerCase())||L.description.toLowerCase().includes(j.toLowerCase())):v;return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Il,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-white/4 rounded-lg p-0.5",children:[s.jsxs("button",{onClick:()=>r("saved"),className:`flex items-center gap-1 px-2.5 py-1 rounded-md text-[10px] font-semibold transition-all ${n==="saved"?"bg-orange-500/15 text-orange-400":"text-gray-600 hover:text-gray-400"}`,children:[s.jsx(Ue,{size:9}),"Saved",a.length>0&&s.jsx("span",{className:"text-[9px] font-mono text-gray-600",children:a.length})]}),s.jsxs("button",{onClick:()=>r("library"),className:`flex items-center gap-1 px-2.5 py-1 rounded-md text-[10px] font-semibold transition-all ${n==="library"?"bg-orange-500/15 text-orange-400":"text-gray-600 hover:text-gray-400"}`,children:[s.jsx(zc,{size:9}),"Library",v.length>0&&s.jsx("span",{className:"text-[9px] font-mono text-gray-600",children:v.length})]})]}),s.jsx("button",{onClick:n==="saved"?N:C,disabled:n==="saved"?o:g,className:"text-gray-600 hover:text-gray-400 transition-colors",title:"Refresh",children:s.jsx(ge,{size:13,className:(n==="saved"?o:g)?"animate-spin":""})})]}),n==="saved"&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{children:h!=="idle"&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:`px-6 py-2 border-b flex items-center gap-2 text-xs font-medium ${h==="running"?"bg-orange-500/8 border-orange-500/15 text-orange-400":h==="done"?"bg-green-500/8 border-green-500/15 text-green-400":"bg-red-500/8 border-red-500/15 text-red-400"}`,children:[h==="running"&&s.jsx(ne,{size:12,className:"animate-spin"}),h==="done"&&s.jsx(Fe,{size:12}),h==="error"&&s.jsx(Ke,{size:12}),h==="running"?t.runningStatus:h==="done"?t.completedStatus:t.failedStatus]})}),s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-3",children:o&&a.length===0?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-700 text-xs gap-2",children:[s.jsx(ne,{size:13,className:"animate-spin"})," ",t.loading]}):a.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(Ue,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:t.emptyTitle}),s.jsxs("p",{className:"text-xs text-gray-700 mt-1 max-w-xs",children:[t.emptyHint," ",s.jsx("span",{className:"text-orange-400 font-medium",children:t.saveAsSkill})," ",t.emptyHint2]}),s.jsxs("button",{onClick:()=>r("library"),className:"mt-4 flex items-center gap-1.5 text-[11px] text-orange-400 hover:text-orange-300 transition-colors",children:[s.jsx(zc,{size:11})," Browse skill library"]})]}):a.map((L,O)=>{const z=c===L.id&&h==="running",$=c===L.id&&h==="done",R=f===L.id;return s.jsx(V.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:O*.04},className:`rounded-2xl border bg-[#0c0f18] transition-all ${z?"border-orange-500/30 shadow-[0_0_12px_rgba(234,88,12,0.12)]":$?"border-green-500/20":"border-white/6 hover:border-white/12"}`,children:s.jsxs("div",{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Ue,{size:13,className:"text-orange-400 shrink-0 mt-0.5"}),s.jsx("p",{className:"text-[13px] font-bold text-white truncate",children:L.name})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-gray-600 shrink-0 font-mono",children:[s.jsx(rv,{size:9}),L.runCount,"×"]})]}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed mb-2 line-clamp-2",children:L.goal}),L.steps.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[L.steps.slice(0,4).map((M,P)=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:M.tool??"step"},P)),L.steps.length>4&&s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:["+",L.steps.length-4," more"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-700",children:[s.jsx(Lt,{size:9}),s.jsx("span",{children:JP(L.savedAt)}),L.lastRunAt&&s.jsxs("span",{className:"text-gray-800",children:["· ",t.lastRun," ",QP(L.lastRunAt)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[b===L.id?s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-[10px] text-red-400",children:t.deleteConfirm}),s.jsx("button",{onClick:()=>S(L.id),disabled:R,className:"text-[10px] px-2 py-0.5 rounded bg-red-500/15 text-red-400 hover:bg-red-500/25 transition-colors",children:R?"…":t.yes}),s.jsx("button",{onClick:()=>y(null),className:"text-[10px] px-2 py-0.5 rounded bg-white/5 text-gray-500 hover:bg-white/8",children:t.no})]}):s.jsx("button",{onClick:()=>y(L.id),className:"p-1.5 rounded-lg text-gray-700 hover:text-red-400 hover:bg-red-500/8 transition-all",title:"Delete skill",children:s.jsx(ys,{size:12})}),s.jsx("button",{onClick:()=>A(L),disabled:!!c,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold transition-all ${z?"bg-orange-500/15 text-orange-400 border border-orange-500/25 cursor-not-allowed":$?"bg-green-500/12 text-green-400 border border-green-500/20":"bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border border-orange-500/20 hover:border-orange-500/35 disabled:opacity-40 disabled:cursor-not-allowed"}`,children:z?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:11,className:"animate-spin"})," ",t.runningBtn]}):$?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:11})," ",t.doneBtn]}):s.jsxs(s.Fragment,{children:[s.jsx(gs,{size:11})," ",t.runBtn]})})]})]})]})},L.id)})})]}),n==="library"&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-4 py-2.5 border-b border-white/5 shrink-0",children:s.jsx("input",{value:j,onChange:L=>k(L.target.value),placeholder:"Search skills…",className:"w-full px-3 py-1.5 rounded-lg bg-white/4 border border-white/8 text-[11px] text-gray-300 placeholder-gray-700 outline-none focus:border-orange-500/25 transition-colors"})}),s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-3 grid grid-cols-1 gap-2",children:g&&v.length===0?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-700 text-xs gap-2 col-span-1",children:[s.jsx(ne,{size:13,className:"animate-spin"})," Loading skill library…"]}):T.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center col-span-1",children:[s.jsx(zc,{size:36,className:"text-gray-700 mb-3"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:"No skills found"}),j&&s.jsx("button",{onClick:()=>k(""),className:"mt-2 text-[11px] text-orange-400 hover:text-orange-300",children:"Clear filter"})]}):T.map((L,O)=>s.jsx(V.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:Math.min(O*.02,.4)},children:s.jsx(ZP,{skill:L})},L.id))}),v.length>0&&s.jsx("div",{className:"px-4 py-2 border-t border-white/5 shrink-0 flex items-center gap-1.5",children:s.jsxs("span",{className:"text-[10px] text-gray-700 font-mono",children:[T.length," / ",v.length," skills"]})})]})]})}const t6={html:i0,htm:i0,json:wn,js:wn,ts:wn,tsx:wn,jsx:wn};function n6(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function s6(e){try{return new Date(e).toLocaleString("en-US",{dateStyle:"short",timeStyle:"short"})}catch{return e}}function r6(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,t=>{let n="color:#86efac";return/^"/.test(t)&&(n=/:$/.test(t)?"color:#93c5fd":"color:#fca5a5"),/true|false/.test(t)&&(n="color:#f97316"),/null/.test(t)&&(n="color:#6b7280"),`<span style="${n}">${t}</span>`})}function a6(){const[e,t]=u.useState([]),[n,r]=u.useState(null),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(null),[h,p]=u.useState(!1),f=u.useCallback(async()=>{p(!0);try{const v=await U("/api/workspace/files");if(v.ok){const x=await v.json();t(x.files??[])}}catch{}p(!1)},[]);u.useEffect(()=>{f()},[f]);const m=async v=>{r(v),i(null),d(null),l(!0);try{const x=await U(`/api/workspace/file?p=${encodeURIComponent(v.rel)}`);if(!x.ok)throw new Error(`HTTP ${x.status}`);const g=await x.json();i(g.content+(g.truncated?`
|
|
839
|
+
For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return u.useEffect(()=>{e&&(document.getElementById(e)||console.error(n))},[n,e]),null},kP="DialogDescriptionWarning",jP=({contentRef:e,descriptionId:t})=>{const r=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${hb(kP).contentName}}.`;return u.useEffect(()=>{var i;const a=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");t&&a&&(document.getElementById(t)||console.warn(r))},[r,e,t]),null},NP=Zv,SP=nb,CP=sb,EP=rb,_P=ib,TP=lb,G0=db;const q0=e=>{let t;const n=new Set,r=(d,h)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const f=t;t=h??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(m=>m(t,f))}},a=()=>t,l={setState:r,getState:a,getInitialState:()=>c,subscribe:d=>(n.add(d),()=>n.delete(d))},c=t=e(r,a,l);return l},PP=e=>e?q0(e):q0,AP=e=>e;function MP(e,t=AP){const n=Y.useSyncExternalStore(e.subscribe,Y.useCallback(()=>t(e.getState()),[e,t]),Y.useCallback(()=>t(e.getInitialState()),[e,t]));return Y.useDebugValue(n),n}const Y0=e=>{const t=PP(e),n=r=>MP(t,r);return Object.assign(n,t),n},zP=e=>e?Y0(e):Y0,_i=zP(e=>{let t=!1,n=null,r=null,a=!1,i=null,o=[];try{t=localStorage.getItem("mustb_trader_installed")==="true",n=localStorage.getItem("mustb_trader_template");const l=localStorage.getItem("mustb_trader_accounts");if(l&&(o=JSON.parse(l)),r=localStorage.getItem("mustb_trader_exchange"),a=localStorage.getItem("mustb_trader_testnet")==="true",i=localStorage.getItem("mustb_trader_account_type"),o.length===0&&r)o=[{id:r.toLowerCase().trim(),name:r,type:i||"crypto",isTestnet:a}],localStorage.setItem("mustb_trader_accounts",JSON.stringify(o));else if(o.length>0&&!r){const c=o[0];r=c.name,i=c.type,a=c.isTestnet,localStorage.setItem("mustb_trader_exchange",c.name),localStorage.setItem("mustb_trader_account_type",c.type),localStorage.setItem("mustb_trader_testnet",String(c.isTestnet))}}catch{}return{isTradingPackageInstalled:t,selectedTemplate:n,accounts:o,connectedExchange:r,isTestnet:a,accountType:i,setTradingPackageInstalled:l=>{e({isTradingPackageInstalled:l});try{localStorage.setItem("mustb_trader_installed",String(l))}catch{}},setSelectedTemplate:l=>{e({selectedTemplate:l});try{l?localStorage.setItem("mustb_trader_template",l):localStorage.removeItem("mustb_trader_template")}catch{}},setConnectedExchange:l=>{e({connectedExchange:l});try{l?localStorage.setItem("mustb_trader_exchange",l):localStorage.removeItem("mustb_trader_exchange")}catch{}},setTestnet:l=>{e({isTestnet:l});try{localStorage.setItem("mustb_trader_testnet",String(l))}catch{}},setAccountType:l=>{e({accountType:l});try{l?localStorage.setItem("mustb_trader_account_type",l):localStorage.removeItem("mustb_trader_account_type")}catch{}},addAccount:l=>{e(c=>{const h=c.accounts.some(f=>f.id===l.id)?c.accounts.map(f=>f.id===l.id?l:f):[...c.accounts,l];try{localStorage.setItem("mustb_trader_accounts",JSON.stringify(h))}catch{}const p=h[0];if(p){try{localStorage.setItem("mustb_trader_exchange",p.name),localStorage.setItem("mustb_trader_account_type",p.type),localStorage.setItem("mustb_trader_testnet",String(p.isTestnet))}catch{}return{accounts:h,connectedExchange:p.name,accountType:p.type,isTestnet:p.isTestnet}}return{accounts:h}})},removeAccount:l=>{e(c=>{const d=c.accounts.filter(p=>p.id!==l);try{localStorage.setItem("mustb_trader_accounts",JSON.stringify(d))}catch{}const h=d[0];if(h){try{localStorage.setItem("mustb_trader_exchange",h.name),localStorage.setItem("mustb_trader_account_type",h.type),localStorage.setItem("mustb_trader_testnet",String(h.isTestnet))}catch{}return{accounts:d,connectedExchange:h.name,accountType:h.type,isTestnet:h.isTestnet}}else{try{localStorage.removeItem("mustb_trader_exchange"),localStorage.removeItem("mustb_trader_account_type"),localStorage.removeItem("mustb_trader_testnet")}catch{}return{accounts:[],connectedExchange:null,accountType:null,isTestnet:!1}}})}}}),RP={Messaging:{icon:"💬",accent:"text-blue-300",border:"border-blue-500/20",bg:"bg-blue-500/10",iconBg:"bg-blue-500/10"},Finance:{icon:"📈",accent:"text-emerald-300",border:"border-emerald-500/20",bg:"bg-emerald-500/10",iconBg:"bg-emerald-500/10"},System:{icon:"âš™ï¸",accent:"text-orange-300",border:"border-orange-500/20",bg:"bg-orange-500/10",iconBg:"bg-orange-500/10"}};function LP(e){return RP[e]??{icon:"🔌",accent:"text-white/60",border:"border-white/10",bg:"bg-white/5",iconBg:"bg-white/5"}}function OP({name:e}){return s.jsx("span",{className:"inline-block px-2 py-0.5 rounded-md text-[10px] font-mono bg-white/5 text-white/40 border border-white/8",children:e})}function IP({pack:e,installing:t,installLog:n,onInstall:r,onConfigure:a}){const[i,o]=u.useState(!1),l=LP(e.category),c=e.extensions.length===0;return s.jsxs("div",{className:"flex flex-col bg-white/5 border border-white/8 rounded-2xl p-5 gap-3 hover:bg-white/[0.07] hover:border-white/12 transition-all duration-200",children:[s.jsxs("div",{className:"flex items-start gap-3",children:[s.jsx("div",{className:`w-12 h-12 rounded-xl ${l.iconBg} flex items-center justify-center text-[24px] shrink-0 select-none border ${l.border}`,children:l.icon}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:e.name}),s.jsx(Er,{size:14,className:`text-emerald-400 shrink-0 transition-opacity duration-200 ${e.installed?"opacity-100":"opacity-0 pointer-events-none"}`})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.jsx("span",{className:`text-[10px] font-bold uppercase tracking-widest ${l.accent}`,children:e.category}),s.jsxs("span",{className:`text-[10px] text-white/30 ${c?"hidden":"inline"}`,children:[e.extensions.length," extension",e.extensions.length!==1?"s":""]}),s.jsx("span",{className:`text-[10px] px-1.5 py-0.5 rounded-md bg-yellow-500/10 text-yellow-400 border border-yellow-500/20 font-medium ${c?"inline":"hidden"}`,children:"Coming Soon"})]})]})]}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed",children:e.description}),s.jsx("p",{className:"text-[11px] font-mono text-white/25",children:e.npmPackage}),s.jsxs("div",{className:`${e.extensions.length>0?"block":"hidden"}`,children:[s.jsxs("button",{onClick:()=>o(d=>!d),className:"flex items-center gap-1 text-[11px] text-white/30 hover:text-white/60 transition-colors mb-2",children:[s.jsx(Ys,{size:12,className:`transition-transform duration-200 ${i?"rotate-180":"rotate-0"}`}),s.jsx("span",{children:"Show included extensions"})]}),s.jsx("div",{className:`flex flex-wrap gap-1.5 transition-all duration-200 overflow-hidden ${i?"max-h-[300px] opacity-100 mt-2":"max-h-0 opacity-0"}`,children:e.extensions.map(d=>s.jsx(OP,{name:d},d))})]}),s.jsx("pre",{className:`text-[10px] text-white/40 bg-black/40 rounded-xl p-2.5 max-h-[72px] overflow-y-auto font-mono whitespace-pre-wrap break-all border border-white/6 transition-all duration-200 ${t&&n?"block opacity-100 mt-2":"hidden opacity-0"}`,children:n}),s.jsxs("div",{className:"mt-auto pt-1",children:[s.jsx("div",{className:`w-full py-2 rounded-xl text-[12px] font-medium text-center bg-white/4 text-white/25 border border-white/8 cursor-default select-none ${c?"block":"hidden"}`,children:"Not yet available"}),s.jsx("button",{onClick:a,className:`w-full py-2 rounded-xl text-[12px] font-medium bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 hover:bg-emerald-500/15 hover:border-emerald-500/30 transition-colors ${!c&&e.installed?"block":"hidden"}`,children:"Installed — Configure Keys"}),s.jsxs("button",{onClick:r,disabled:t,className:`w-full flex items-center justify-center gap-2 py-2 rounded-xl text-[12px] font-semibold ${l.bg} ${l.accent} border ${l.border} hover:brightness-125 disabled:opacity-50 disabled:cursor-not-allowed transition-all ${!c&&!e.installed?"flex":"hidden"}`,children:[s.jsx(ne,{size:13,className:`animate-spin shrink-0 ${t?"inline-block":"hidden"}`}),s.jsx(Xs,{size:13,className:`shrink-0 ${t?"hidden":"inline-block"}`}),s.jsx("span",{children:t?"Installing…":"Install Pack"})]})]})]})}function DP({pack:e,onClose:t}){const[n,r]=u.useState({}),[a,i]=u.useState(!1);u.useEffect(()=>{e&&r({})},[e]);const o=async()=>{if(e){i(!0);try{if(!(await U("/api/store/configure",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({keys:n})})).ok)throw new Error("Configure request failed");se.success(`${e.name} configured — keys saved to .env`),t()}catch(c){se.error(c instanceof Error?c.message:"Configure failed")}finally{i(!1)}}},l={};for(const c of(e==null?void 0:e.requiredKeys)??[]){const d=c.forExtension??"general";(l[d]??(l[d]=[])).push(c)}return s.jsx(NP,{open:!!e,onOpenChange:c=>{c||t()},children:s.jsxs(SP,{children:[s.jsx(CP,{className:"fixed inset-0 z-50 bg-black/70 backdrop-blur-sm"}),s.jsxs(EP,{className:"fixed z-50 left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-full max-w-[460px] mx-4 bg-[#0d0f14] border border-white/10 rounded-2xl p-6 shadow-2xl max-h-[85vh] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between mb-1",children:[s.jsxs(_P,{className:"text-white/90 font-semibold text-[15px]",children:["Configure ",e==null?void 0:e.name]}),s.jsx(G0,{className:"w-7 h-7 flex items-center justify-center rounded-lg text-white/30 hover:text-white/70 hover:bg-white/6 transition-colors",children:s.jsx(Ie,{size:15})})]}),s.jsxs(TP,{className:"text-white/40 text-[12px] mb-5 leading-relaxed",children:["Fill in the keys for the extensions you want to use. Leave others blank — they can be added later. Keys are saved to your local"," ",s.jsx("code",{className:"font-mono text-white/60 bg-white/8 px-1 rounded",children:".env"})," file."]}),s.jsx("div",{className:"space-y-5",children:Object.entries(l).map(([c,d])=>s.jsxs("div",{children:[s.jsx("p",{className:"text-[10px] font-bold uppercase tracking-widest text-white/30 mb-2.5",children:c}),s.jsx("div",{className:"space-y-3",children:d.map(h=>s.jsxs("div",{children:[s.jsx("label",{className:"block text-[12px] font-medium text-white/70 mb-1",children:h.label}),h.hint&&s.jsx("p",{className:"text-[11px] text-white/35 mb-1.5",children:h.hint}),s.jsx("input",{type:"password",autoComplete:"off",value:n[h.env]??"",onChange:p=>r(f=>({...f,[h.env]:p.target.value})),className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2.5 text-sm text-white/80 placeholder-white/20 focus:outline-none focus:border-orange-500/40 focus:bg-white/[0.07] transition-colors font-mono",placeholder:`Enter ${h.label}`})]},h.env))})]},c))}),s.jsxs("div",{className:"flex items-center gap-3 mt-6",children:[s.jsxs("button",{onClick:o,disabled:a,className:"flex-1 flex items-center justify-center gap-2 bg-orange-500/20 hover:bg-orange-500/30 border border-orange-500/30 hover:border-orange-500/50 disabled:opacity-60 text-orange-300 rounded-xl py-2.5 text-[13px] font-semibold transition-all active:scale-[0.97]",children:[a?s.jsx(ne,{size:14,className:"animate-spin"}):s.jsx(Er,{size:14}),"Save & Activate"]}),s.jsx(G0,{className:"px-4 py-2.5 text-[13px] text-white/35 hover:text-white/60 transition-colors rounded-xl hover:bg-white/5",children:"Skip"})]})]})]})})}const BP=12e4;function FP(){const{isTradingPackageInstalled:e,setTradingPackageInstalled:t}=_i(),[n,r]=u.useState([]),[a,i]=u.useState(!0),[o,l]=u.useState(null),[c,d]=u.useState({}),[h,p]=u.useState(null),f=u.useRef(null),[m,b]=u.useState(!1),[y,v]=u.useState(!1),[x,g]=u.useState(""),[w,j]=u.useState(!1),[k,N]=u.useState(""),C=u.useCallback(async()=>{try{const O=await U("/api/web3/vault");if(O.ok){const z=await O.json();b(z.configured)}}catch{}},[]),A=u.useCallback(async()=>{if(!x||x.trim().length<10){const O="Lütfen geçerli bir Web3 cüzdan gizli anahtarı (Private Key) girin.";N(O),window.alert(O);return}j(!0),N("");try{const O=await U("/api/web3/vault",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({walletPrivateKey:x.trim()})}),z=await O.json();if(!O.ok||!z.ok)throw new Error(z.error||"Web3 cüzdan anahtarı kaydedilemedi.");window.alert("Polymarket AI Oracle başarıyla kuruldu ve anahtarınız ~/.must-b/ klasöründe şifrelendi!"),v(!1),g(""),C()}catch(O){const z=O instanceof Error?O.message:"Kurulum başarısız oldu.";N(z),window.alert(z)}finally{j(!1)}},[x,C]),S=u.useCallback(async()=>{i(!0);try{const O=await U("/api/store/extensions");O.ok&&r(await O.json())}catch{}finally{i(!1)}},[]);u.useEffect(()=>{S(),C()},[S,C]);const T=u.useCallback(async O=>{var R;(R=f.current)==null||R.abort();const z=new AbortController;f.current=z,l(O.id),d(M=>({...M,[O.id]:""}));const $=setTimeout(()=>{z.abort()},BP);try{const M=await U("/api/store/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:O.id}),signal:z.signal},{retries:1,retryDelay:0});if(!M.body)throw new Error("No response stream");const P=M.body.getReader(),E=new TextDecoder;let _="";for(;;){const{done:I,value:W}=await P.read();if(I)break;const B=E.decode(W,{stream:!0});_+=B,d(G=>({...G,[O.id]:_}))}if(_.includes("__MUSTB_INSTALL_OK__")){se.success(`${O.name} installed!`);try{r(I=>I.map(W=>W.id===O.id?{...W,installed:!0}:W)),O.requiredKeys.length>0&&p(O)}catch(I){console.error("Defensive UI update error caught:",I)}}else _.includes("__MUSTB_INSTALL_FAILED__")?se.error(`${O.name} installation failed — check the log above.`):se.error(`${O.name} installation failed.`)}catch(M){M.name==="AbortError"?se.error(`Install timed out — is ${O.npmPackage} published to npm?`):se.error(M instanceof Error?M.message:"Install failed")}finally{clearTimeout($),l(null)}},[S]),L=n.filter(O=>O.installed).length;return s.jsxs("div",{className:"min-h-screen bg-transparent pt-4 pb-10 px-4 sm:px-6 max-w-5xl mx-auto",children:[s.jsxs("div",{className:"flex items-start justify-between gap-4 mb-3",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-3 mb-2",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl bg-orange-500/10 border border-orange-500/20 flex items-center justify-center shrink-0",children:s.jsx(xv,{size:18,className:"text-orange-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-[22px] font-black text-white/95 leading-none",children:"Extension Store"}),s.jsxs("span",{className:`text-[11px] text-emerald-400/80 font-medium ${L>0?"inline-block":"hidden"}`,children:[L," pack",L!==1?"s":""," installed"]})]})]}),s.jsxs("p",{className:"text-white/40 text-[13px] leading-relaxed max-w-2xl mt-1",children:["Extensions are grouped into themed packs."," ","Install one pack to get all its integrations — fetched directly from npm into"," ",s.jsx("code",{className:"font-mono text-white/60 bg-white/5 px-1.5 py-0.5 rounded text-[11px] border border-white/8",children:"~/.must-b/extensions/"})]})]}),s.jsx("button",{onClick:S,title:"Refresh",className:"p-2.5 rounded-xl text-white/30 hover:text-white/70 hover:bg-white/6 border border-white/8 transition-all shrink-0",children:s.jsx(ge,{size:15})})]}),s.jsxs("div",{className:"mb-8 px-3 py-2.5 rounded-xl bg-white/5 border border-white/8 flex items-center gap-3",children:[s.jsx("code",{className:"text-[11px] font-mono text-white/30 shrink-0",children:"CLI:"}),s.jsxs("code",{className:"text-[12px] font-mono text-white/50",children:[s.jsx("span",{className:"text-orange-400",children:"must-b ext list"})," · ",s.jsx("span",{className:"text-orange-400",children:"must-b ext install channels"})," · ",s.jsx("span",{className:"text-orange-400",children:"must-b ext install system"})]})]}),s.jsxs("div",{className:`flex flex-col items-center justify-center py-24 gap-3 ${a?"flex":"hidden"}`,children:[s.jsx(ne,{size:22,className:"animate-spin text-orange-400"}),s.jsx("p",{className:"text-white/35 text-[13px]",children:"Loading extension store…"})]}),s.jsxs("div",{className:`flex flex-col items-center justify-center py-24 gap-3 ${!a&&n.length===0?"flex":"hidden"}`,children:[s.jsx(Xs,{size:28,className:"text-white/20"}),s.jsx("p",{className:"text-white/35 text-[13px]",children:"No packs available — backend may not be running."}),s.jsx("button",{onClick:S,className:"mt-1 px-4 py-2 rounded-xl bg-orange-500/10 border border-orange-500/20 text-orange-400 text-[12px] font-medium hover:bg-orange-500/20 transition-colors",children:"Retry"})]}),s.jsxs("div",{className:`grid grid-cols-1 lg:grid-cols-3 gap-5 ${!a&&n.length>0?"grid":"hidden"}`,children:[s.jsxs("div",{className:"flex flex-col bg-gradient-to-b from-[#131d27]/70 to-[#0c0f18]/70 border border-emerald-500/20 rounded-2xl p-5 gap-4 shadow-xl hover:border-emerald-500/35 transition-all duration-200 justify-between",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-bold text-emerald-400 bg-emerald-500/10 border border-emerald-500/20 px-2 py-0.5 rounded-full uppercase tracking-widest",children:"Premium Algorithmic Package"}),s.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:"Borsa & Otomasyon Paketi"}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed mt-2",children:"Binance, OKX ve Bitget borsaları ile doÄŸrudan bütünleÅŸik, geliÅŸmiÅŸ RSI ve Grid trading bot arayüzünü içerir."})]})]}),s.jsxs("div",{className:"pt-4 border-t border-white/5 flex items-center justify-between mt-auto",children:[s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wider font-semibold",children:"Durum / Status"}),s.jsxs("p",{className:`text-xs font-bold ${e?"text-emerald-400":"text-gray-400"}`,children:[s.jsx("span",{className:e?"inline":"hidden",children:"Kuruldu / Installed"}),s.jsx("span",{className:e?"hidden":"inline",children:"Kurulmadı / Available"})]})]}),s.jsxs("button",{onClick:()=>{t(!0),se.success("Borsa & Botlar paketi baÅŸarıyla kuruldu!")},disabled:e,className:`px-5 py-2 rounded-xl text-xs font-bold transition-all shadow-md active:scale-[0.98] ${e?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 cursor-default":"bg-emerald-600 text-white hover:bg-emerald-500 shadow-emerald-500/10"}`,children:[s.jsx("span",{className:e?"inline":"hidden",children:"Kuruldu"}),s.jsx("span",{className:e?"hidden":"inline",children:"Paketi Kur"})]})]})]}),s.jsxs("div",{className:"flex flex-col bg-gradient-to-b from-[#1c1a2e]/70 to-[#0e0c18]/70 border border-purple-500/20 rounded-2xl p-5 gap-4 shadow-xl hover:border-purple-500/35 transition-all duration-200 justify-between",children:[s.jsxs("div",{className:"space-y-3",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[9px] font-bold text-purple-400 bg-purple-500/10 border border-purple-500/20 px-2 py-0.5 rounded-full uppercase tracking-widest",children:"Web3 & Prediction Markets"}),s.jsx("div",{className:`w-2 h-2 rounded-full ${m?"bg-purple-400 animate-pulse":"bg-purple-800"}`})]}),s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-[15px] leading-snug",children:"Polymarket AI Oracle"}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed mt-2",children:"Polymarket tahmin piyasalarında otomatik iÅŸlem yapmayı saÄŸlayan, yapay zeka destekli oracle ve iÅŸlem modülü."})]})]}),s.jsxs("div",{className:`mt-2 space-y-3 border-t border-white/5 pt-3 transition-all ${y?"block":"hidden"}`,children:[s.jsx("label",{className:"block text-[11px] font-medium text-white/60",children:"Web3 Cüzdan Gizli Anahtarı (Private Key)"}),s.jsx("input",{type:"password",autoComplete:"off",value:x,onChange:O=>g(O.target.value),className:"w-full bg-white/5 border border-white/8 rounded-xl px-3 py-2 text-xs text-white/80 placeholder-white/20 focus:outline-none focus:border-purple-500/40 focus:bg-white/[0.07] font-mono",placeholder:"0x..."}),k&&s.jsx("p",{className:"text-[10px] text-red-400 font-medium leading-relaxed",children:k}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:A,disabled:w,className:"flex-1 py-1.5 rounded-lg text-[11px] font-semibold bg-purple-600 text-white hover:bg-purple-500 disabled:opacity-50 transition-colors",children:w?"Kaydediliyor...":"Kaydet"}),s.jsx("button",{onClick:()=>{v(!1),N("")},disabled:w,className:"px-3 py-1.5 rounded-lg text-[11px] text-white/40 hover:text-white/70 hover:bg-white/5 transition-all",children:"İptal"})]})]}),s.jsxs("div",{className:`pt-4 border-t border-white/5 flex items-center justify-between mt-auto ${y?"hidden":"flex"}`,children:[s.jsxs("div",{className:"text-left",children:[s.jsx("p",{className:"text-[9px] text-gray-500 uppercase tracking-wider font-semibold",children:"Durum / Status"}),s.jsxs("p",{className:`text-xs font-bold ${m?"text-purple-400":"text-gray-400"}`,children:[s.jsx("span",{className:m?"inline":"hidden",children:"Kuruldu / Configured"}),s.jsx("span",{className:m?"hidden":"inline",children:"Kurulmadı / Available"})]})]}),s.jsxs("button",{onClick:()=>v(!0),className:`px-5 py-2 rounded-xl text-xs font-bold transition-all shadow-md active:scale-[0.98] ${m?"bg-purple-500/10 text-purple-400 border border-purple-500/20 hover:bg-purple-500/20 cursor-pointer":"bg-purple-600 text-white hover:bg-purple-500 shadow-purple-500/10"}`,children:[s.jsx("span",{className:m?"inline":"hidden",children:"Yapılandır"}),s.jsx("span",{className:m?"hidden":"inline",children:"Kur / Configure"})]})]})]}),n.map(O=>s.jsx(IP,{pack:O,installing:o===O.id,installLog:c[O.id]??"",onInstall:()=>T(O),onConfigure:()=>p(O)},O.id))]}),s.jsxs("p",{className:"text-center text-white/20 text-[11px] mt-12",children:["Packs are built with"," ",s.jsx("code",{className:"font-mono bg-white/5 px-1 rounded border border-white/8",children:"npm run build:packs"})," ","and published to npm. Run"," ",s.jsx("code",{className:"font-mono bg-white/5 px-1 rounded border border-white/8",children:"must-b ext list"})," ","for the CLI interface."]}),s.jsx(DP,{pack:h,onClose:()=>p(null)})]})}const $P=[{id:"grid-trading",name:"Grid Trading Bot",desc:"Grid strategy for sideways markets."},{id:"rsi-scalper",name:"RSI Scalper Dashboard",desc:"Fast scalping layout based on RSI crossovers."},{id:"arbitrage",name:"Cross-Exchange Arbitrage",desc:"Arbitrage monitoring dashboard."},{id:"dca-accumulator",name:"DCA Accumulator",desc:"Dollar-cost averaging dashboard."},{id:"portfolio-rebalance",name:"Portfolio Auto-Rebalancer",desc:"Dynamic asset weights management layout."}];function VP(){const e=gt(),{selectedTemplate:t,setSelectedTemplate:n}=_i(),r=(a,i)=>{n(a),se.success(`Şablon seçildi: ${i}`),e("/app/trader/connect")};return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto",children:[s.jsxs("div",{className:"mb-10 text-center sm:text-left",children:[s.jsxs("div",{className:"flex items-center gap-3 justify-center sm:justify-start mb-2",children:[s.jsx("div",{className:"w-10 h-10 rounded-2xl bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shrink-0",children:s.jsx(A3,{size:18,className:"text-emerald-400"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-black text-white/95 leading-none",children:"Kontrol Paneli Şablonları"}),s.jsx("p",{className:"text-[11px] text-emerald-400/80 font-medium mt-1",children:"Lütfen bir işlem arayüzü şablonu seçin"})]})]}),s.jsx("p",{className:"text-white/45 text-[13px] leading-relaxed max-w-xl mt-2",children:"İşlem botlarınızın ve portföyünüzün performansını izlemek için optimize edilmiş minimal şablon yapıları."})]}),s.jsx("div",{className:"grid grid-cols-1 md:grid-cols-5 gap-4",children:$P.map(a=>s.jsxs("div",{className:`flex flex-col bg-white/3 border rounded-2xl p-4 gap-4 hover:bg-white/5 hover:border-white/20 transition-all duration-200 justify-between ${t===a.id?"border-emerald-500/50":"border-white/8"}`,children:[s.jsxs("div",{className:"space-y-2 bg-black/40 border border-white/6 rounded-xl p-3 h-[140px] flex flex-col justify-between",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("div",{className:"w-8 h-2.5 rounded bg-white/10"}),s.jsx("div",{className:"w-3 h-3 rounded-full bg-white/10"})]}),s.jsxs("div",{className:"space-y-1.5 flex-1 flex flex-col justify-center",children:[s.jsx("div",{className:"w-full h-4 rounded bg-white/5 border border-white/8"}),s.jsx("div",{className:"w-3/4 h-2.5 rounded bg-white/5"}),s.jsx("div",{className:"w-1/2 h-2 rounded bg-white/5"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("div",{className:"w-6 h-3 rounded bg-white/10"}),s.jsx("div",{className:"w-8 h-3 rounded bg-white/10"})]})]}),s.jsxs("div",{className:"flex-1 flex flex-col justify-between",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-white/90 font-bold text-sm leading-snug mt-2",children:a.name}),s.jsx("p",{className:"text-white/35 text-[11px] leading-relaxed mt-1",children:a.desc})]}),s.jsx("button",{onClick:()=>r(a.id,a.name),className:`w-full flex items-center justify-center gap-1.5 py-2 mt-4 rounded-xl text-[11px] font-bold border transition-all ${t===a.id?"bg-emerald-500/10 text-emerald-400 border-emerald-500/30":"bg-white/5 text-white/60 border-white/10 hover:border-white/25"}`,children:t===a.id?s.jsxs(s.Fragment,{children:[s.jsx(it,{size:12}),s.jsx("span",{children:"Seçildi"})]}):s.jsxs(s.Fragment,{children:[s.jsx(mn,{size:12}),s.jsx("span",{children:"Şablonu Kaydet"})]})})]})]},a.id))})]})}function UP(){const e=gt(),{setConnectedExchange:t,setTestnet:n,setAccountType:r,addAccount:a}=_i(),[i,o]=u.useState("crypto"),[l,c]=u.useState("binance"),[d,h]=u.useState(""),[p,f]=u.useState(""),[m,b]=u.useState(""),[y,v]=u.useState("FBS"),[x,g]=u.useState(""),[w,j]=u.useState("FBS-Real"),[k,N]=u.useState(""),[C,A]=u.useState(!1),[S,T]=u.useState(!1),L=async O=>{if(O.preventDefault(),i==="crypto"){if(!d.trim()||!p.trim()){se.error("API Anahtarı ve Secret alanları boş bırakılamaz.");return}if(l==="okx"&&!m.trim()){se.error("OKX bağlantısı için API parolası (Passphrase) gereklidir.");return}}else{if(!y.trim()||!x.trim()||!m.trim()||!w.trim()){se.error("Broker, Login, Şifre ve Sunucu alanları boş bırakılamaz.");return}if(!k.trim()){se.error("MetaApi Token alanı boş bırakılamaz. MetaApi Cloud hesabınızdan token alın.");return}}T(!0);const z=i==="crypto"?l.toUpperCase():y,$=se.loading(`${z} ${C?"(Testnet) ":""}bağlantısı doğrulanıyor...`);try{const R=i==="crypto"?{accountType:"crypto",exchangeId:l,apiKey:d.trim(),secret:p.trim(),password:m.trim()||void 0,isTestnet:C}:{accountType:"tradfi",broker:y.trim(),login:x.trim(),password:m.trim(),server:w.trim(),apiKey:k.trim(),isTestnet:C},M=await fetch("/api/trader/connect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)}),P=await M.json();if(!M.ok)throw new Error(P.error||"Bağlantı doğrulanamadı.");se.success(`${z} ${C?"(Testnet) ":""}başarıyla bağlandı!`,{id:$});const E=i==="crypto"?l==="binance"?"Binance":l==="okx"?"OKX":"Bitget":y;t(E),n(C),r(i);const _=i==="crypto"?l.toLowerCase():y.toLowerCase();a({id:_,name:E,type:i,isTestnet:C}),e("/app/trader/dashboard")}catch(R){se.error(R.message||"Bağlantı hatası oluştu.",{id:$})}finally{T(!1)}};return s.jsxs("div",{className:"min-h-[80vh] flex items-center justify-center px-4 relative overflow-hidden",children:[s.jsx("div",{className:"absolute top-1/4 left-1/2 -translate-x-1/2 -translate-y-1/2 w-[400px] h-[400px] bg-emerald-500/10 rounded-full blur-[120px] pointer-events-none"}),s.jsx("div",{className:"absolute bottom-1/4 left-1/3 w-[300px] h-[300px] bg-amber-500/5 rounded-full blur-[100px] pointer-events-none"}),s.jsxs("div",{className:"w-full max-w-lg bg-gradient-to-b from-[#131d27]/90 to-[#0c0f18]/90 border border-emerald-500/20 rounded-3xl p-8 shadow-2xl backdrop-blur-md relative z-10",children:[s.jsx("div",{className:"flex justify-center mb-5",children:s.jsx("div",{className:"w-14 h-14 rounded-full bg-emerald-500/10 border border-emerald-500/20 flex items-center justify-center shadow-lg shadow-emerald-500/5",children:s.jsx(cp,{size:26,className:"text-emerald-400"})})}),s.jsxs("div",{className:"text-center mb-6",children:[s.jsx("h1",{className:"text-xl font-bold text-white tracking-tight",children:"Güvenli İşlem Bağlantısı"}),s.jsx("p",{className:"text-xs text-gray-400 mt-1 max-w-xs mx-auto leading-relaxed",children:"API anahtarlarınızı veya aracı kurum bilgilerinizi kullanarak bağlantı kurun ve otomatik işlemleri başlatın."})]}),s.jsxs("div",{className:"bg-amber-500/10 border border-amber-500/20 rounded-2xl p-4 mb-6 flex items-start gap-3",children:[s.jsx(Hs,{size:18,className:"text-amber-400 shrink-0 mt-0.5"}),s.jsxs("div",{className:"space-y-1",children:[s.jsx("h4",{className:"text-xs font-semibold text-amber-300",children:"Önemli Güvenlik Uyarısı"}),s.jsxs("p",{className:"text-[11px] text-amber-200/90 leading-relaxed",children:["API anahtarlarınızda veya kurum hesap yetkilerinizde ",s.jsx("strong",{children:"PARA ÇEKME (Withdraw)"})," yetkisinin KAPALI olduğundan emin olun. Verileriniz cihazınızda şifrelenerek saklanır, buluta gönderilmez."]})]})]}),s.jsxs("form",{onSubmit:L,className:"space-y-4",children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"Hesap Tipi"}),s.jsxs("div",{className:"grid grid-cols-2 gap-2 bg-zinc-950/40 p-1 border border-zinc-800 rounded-xl",children:[s.jsx("button",{type:"button",onClick:()=>o("crypto"),className:`py-2 text-xs font-bold rounded-lg transition-all ${i==="crypto"?"bg-emerald-600/20 border border-emerald-500/30 text-emerald-400 shadow-md":"text-zinc-400 hover:text-white"}`,children:"Kripto Borsası"}),s.jsx("button",{type:"button",onClick:()=>o("tradfi"),className:`py-2 text-xs font-bold rounded-lg transition-all ${i==="tradfi"?"bg-emerald-600/20 border border-emerald-500/30 text-emerald-400 shadow-md":"text-zinc-400 hover:text-white"}`,children:"Aracı Kurum (TradFi)"})]})]}),s.jsxs("div",{className:"bg-zinc-950/40 border border-zinc-800 rounded-xl p-3.5 flex items-center justify-between gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-[12px] font-semibold text-white block",children:"Demo Modu (Testnet)"}),s.jsx("span",{className:"text-[10px] text-zinc-500 mt-0.5 block leading-tight",children:"Gerçek para riske atmadan, sanal bakiye ile stratejilerinizi test edin."})]}),s.jsx("button",{type:"button",onClick:()=>A(!C),disabled:S,className:`w-10 h-6 shrink-0 rounded-full p-1 transition-all duration-300 relative outline-none ${C?"bg-amber-500":"bg-zinc-800"}`,children:s.jsx("div",{className:`w-4 h-4 rounded-full bg-white shadow-md transform transition-all duration-300 ${C?"translate-x-4":"translate-x-0"}`})})]}),i==="crypto"?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"Borsa Seçimi"}),s.jsxs("select",{value:l,onChange:O=>{c(O.target.value),b("")},disabled:S,className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl px-4 py-3 text-sm text-white font-medium outline-none transition-all disabled:opacity-50",children:[s.jsx("option",{value:"binance",children:"Binance"}),s.jsx("option",{value:"okx",children:"OKX"}),s.jsx("option",{value:"bitget",children:"Bitget"})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Key (Erişim Anahtarı)"}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(sp,{size:16})}),s.jsx("input",{type:"text",value:d,onChange:O=>h(O.target.value),disabled:S,placeholder:"Örn: 4bc8f9a2e37...",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:!0})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Secret (Gizli Anahtar)"}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(rp,{size:16})}),s.jsx("input",{type:"password",value:p,onChange:O=>f(O.target.value),disabled:S,placeholder:"••••••••••••••••••••••••••••••••",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:!0})]})]}),s.jsxs("div",{className:"space-y-1.5",children:[s.jsxs("div",{className:"flex justify-between items-center",children:[s.jsx("label",{className:"text-[11px] font-semibold text-zinc-400 uppercase tracking-wider block",children:"API Parolası / Passphrase"}),s.jsx("span",{className:"text-[9px] text-zinc-500 font-medium tracking-wide block uppercase",children:l==="okx"?"OKX için Zorunlu":"Opsiyonel"})]}),s.jsxs("div",{className:"relative",children:[s.jsx("span",{className:"absolute inset-y-0 left-0 pl-3.5 flex items-center text-zinc-500",children:s.jsx(cv,{size:16})}),s.jsx("input",{type:"password",value:m,onChange:O=>b(O.target.value),disabled:S,placeholder:l==="okx"?"OKX API Parolası":"Gerekirse şifre / parola",className:"w-full bg-zinc-950/60 border border-zinc-800 hover:border-zinc-700 focus:border-emerald-500/60 focus:ring-1 focus:ring-emerald-500/20 rounded-xl pl-10 pr-4 py-3 text-sm text-white placeholder-zinc-600 outline-none transition-all disabled:opacity-50 font-mono",required:l==="okx"})]})]})]}):s.jsxs("div",{className:"relative overflow-hidden rounded-2xl border border-emerald-500/10 bg-gradient-to-br from-zinc-900/60 via-zinc-950/80 to-[#0c0f18]/90 backdrop-blur-xl p-6 flex flex-col items-center gap-4 my-2",children:[s.jsx("div",{className:"absolute inset-0 bg-gradient-to-br from-emerald-500/5 via-transparent to-cyan-500/5 pointer-events-none"}),s.jsx("div",{className:"absolute -top-10 -right-10 w-32 h-32 bg-emerald-500/10 rounded-full blur-3xl pointer-events-none"}),s.jsx("div",{className:"absolute -bottom-10 -left-10 w-28 h-28 bg-cyan-500/8 rounded-full blur-3xl pointer-events-none"}),s.jsx("div",{className:"relative z-10 w-14 h-14 rounded-2xl bg-gradient-to-br from-emerald-500/20 to-cyan-500/10 border border-emerald-500/20 flex items-center justify-center shadow-xl shadow-emerald-500/5 mt-2",children:s.jsx("svg",{className:"w-7 h-7 text-emerald-400",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",strokeWidth:1.5,children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 12.75L11.25 15 15 9.75m-3-7.036A11.959 11.959 0 0 1 3.598 6 11.955 11.955 0 0 0 3 9.749c0 5.592 3.824 10.29 9 11.623 5.176-1.332 9-6.03 9-11.622 0-1.31-.21-2.571-.598-3.751h-.152c-3.196 0-6.1-1.249-8.25-3.286Z"})})}),s.jsxs("div",{className:"relative z-10 flex items-center gap-1.5 bg-emerald-500/10 border border-emerald-500/20 rounded-full px-3 py-1",children:[s.jsx("div",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),s.jsx("span",{className:"text-[10px] font-bold text-emerald-400 uppercase tracking-widest",children:"Çok Yakında"})]}),s.jsxs("div",{className:"relative z-10 text-center space-y-2 pb-2",children:[s.jsx("h3",{className:"text-sm font-bold text-white",children:"Yerel MetaTrader 4/5 Entegrasyonu"}),s.jsx("p",{className:"text-[11px] text-zinc-400 leading-relaxed max-w-[260px]",children:"Doğrudan aracı kurum bağlantısı ile MT4/MT5 hesaplarınızı Must-b yapay zeka motoruna bağlayın."})]}),s.jsx("ul",{className:"relative z-10 space-y-2 w-full text-[11px] text-zinc-500 pb-1",children:["FBS, IC Markets, Pepperstone desteği","Gerçek zamanlı Lot execution","Uyuyan Dev AI stratejisi entegrasyonu"].map(O=>s.jsxs("li",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-4 h-4 rounded-full border border-emerald-500/20 bg-emerald-500/5 flex items-center justify-center shrink-0",children:s.jsx("div",{className:"w-1 h-1 rounded-full bg-emerald-500/60"})}),O]},O))})]}),s.jsx("button",{type:"submit",disabled:S||i==="tradfi",className:`w-full flex items-center justify-center gap-2.5 py-3.5 px-6 mt-6 rounded-xl font-bold text-sm text-white transition-all relative overflow-hidden shadow-lg ${i==="tradfi"?"bg-zinc-800 opacity-50 cursor-not-allowed shadow-none":"bg-emerald-600 hover:bg-emerald-500 active:scale-[0.98] disabled:opacity-50 disabled:cursor-not-allowed shadow-emerald-500/10"}`,children:S?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:16,className:"animate-spin text-white"}),s.jsx("span",{children:"Doğrulanıyor..."})]}):i==="tradfi"?s.jsx("span",{children:"Çok Yakında"}):s.jsx("span",{children:"Güvenli Bağlantı Kur"})})]}),s.jsx("p",{className:"text-[10px] text-zinc-600 mt-6 text-center leading-relaxed",children:"Must-b.os, API anahtarlarınızı tamamen yerel cihazınızda AES-256 algoritmasıyla şifreler."})]})]})}function HP(){const e=gt(),{accounts:t,removeAccount:n,connectedExchange:r,selectedTemplate:a}=_i(),[i,o]=u.useState(""),[l,c]=u.useState([{id:"rsi-scalper",name:"RSI Scalper AI",desc:"Fast scalping crossovers",active:!1},{id:"grid-trader",name:"Grid Trader AI",desc:"Sideways market grid",active:!1},{id:"macd-reversal",name:"MACD Reversal AI",desc:"Trend reversal detector",active:!1}]),[d,h]=u.useState(!0),[p,f]=u.useState(null),[m,b]=u.useState([]),[y,v]=u.useState({}),[x,g]=u.useState({"rsi-scalper":3e5,"grid-trader":3e5,"macd-reversal":3e5});u.useEffect(()=>{t&&t.length>0&&!i&&o(t[0].id)},[t,i]),u.useEffect(()=>{!r&&(!t||t.length===0)&&e("/app/trader/connect")},[r,t]);const w=async S=>{var L;const T=S||i||t&&((L=t[0])==null?void 0:L.id)||"";if(!T){h(!1);return}try{const O=`/api/trader/balance?exchangeId=${T}`,z=`/api/trader/history?exchangeId=${T}`,[$,R,M]=await Promise.all([fetch(O),fetch(z),fetch("/api/bot/status")]);if($.ok){const P=await $.json();f(P)}else f(null);if(R.ok){const P=await R.json();b(P.trades||[])}else b([]);if(M.ok){const P=await M.json();P.active&&(v(P.active),c(E=>E.map(_=>({..._,active:P.active[_.id]!==void 0}))),g(E=>{const _={...E};for(const I in P.active)_[I]=P.active[I];return _}))}}catch{se.error("Borsa verileri yüklenemedi.")}finally{h(!1)}};u.useEffect(()=>{i&&w(i)},[i]);const j=async(S,T,L)=>{const O=!L,z=x[S]||3e5,$=se.loading(O?`${T} başlatılıyor...`:`${T} durduruluyor...`);try{if(O){if(!(await fetch("/api/bot/start",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botId:S,pair:"BTC/USDT",intervalMs:z})})).ok)throw new Error("Bot başlatılamadı.");v(M=>({...M,[S]:z})),c(M=>M.map(P=>P.id===S?{...P,active:!0}:P)),se.success(`${T} başarıyla başlatıldı!`,{id:$})}else{if(!(await fetch("/api/bot/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({botId:S})})).ok)throw new Error("Bot durdurulamadı.");v(M=>{const P={...M};return delete P[S],P}),c(M=>M.map(P=>P.id===S?{...P,active:!1}:P)),se.error(`${T} durduruldu.`,{id:$})}}catch(R){se.error(R.message||"İşlem başarısız.",{id:$})}},k=async(S,T)=>{if(window.confirm(`${T} bağlantısını kesmek ve hesabı kaldırmak istediğinize emin misiniz?`))try{const L=await fetch("/api/trader/disconnect",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({exchangeId:S})});if(!L.ok){const z=await L.json().catch(()=>({}));throw new Error(z.error||"Bağlantı kesilemedi.")}n(S),se.success(`${T} başarıyla kaldırıldı.`);const O=t.filter(z=>z.id!==S);O.length>0?o(O[0].id):e("/app/trader/connect")}catch(L){se.error(L.message||"Bir hata oluştu.")}},N=S=>{const T=t.find(z=>z.id===i),L=T?T.name:r,O=L==="Binance"?"https://www.binance.com":L==="OKX"?"https://www.okx.com":"https://www.bitget.com";se.info("Yasal işlemler için ilgili borsaya yönlendiriliyorsunuz..."),setTimeout(()=>{window.open(O,"_blank")},800)};if(d)return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[s.jsxs("div",{className:"space-y-2 animate-pulse",children:[s.jsx("div",{className:"h-6 w-48 bg-white/5 rounded-lg"}),s.jsx("div",{className:"h-4 w-32 bg-white/5 rounded-lg"})]}),s.jsxs("div",{className:"flex items-center gap-2 animate-pulse",children:[s.jsx("div",{className:"h-8 w-24 bg-white/5 rounded-lg"}),s.jsx("div",{className:"h-8 w-24 bg-white/5 rounded-lg"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 h-[130px] animate-pulse space-y-4",children:[s.jsx("div",{className:"h-4 w-28 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-8 w-36 bg-white/5 rounded-md"})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6 animate-pulse",children:[s.jsxs("div",{className:"md:col-span-1 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 h-[250px] space-y-4",children:[s.jsx("div",{className:"h-4 w-24 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"}),s.jsx("div",{className:"h-10 bg-white/5 rounded-xl"})]}),s.jsxs("div",{className:"md:col-span-2 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 h-[250px] space-y-4",children:[s.jsx("div",{className:"h-4 w-24 bg-white/5 rounded-md"}),s.jsx("div",{className:"h-32 bg-white/5 rounded-xl"})]})]})]});const C=t.find(S=>S.id===i),A=(C==null?void 0:C.type)==="tradfi";return s.jsxs("div",{className:"min-h-screen bg-transparent pt-6 pb-12 px-6 max-w-5xl mx-auto space-y-6",children:[s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[s.jsxs("div",{children:[s.jsx("h1",{className:"text-2xl font-black text-white/95 leading-none",children:"Trader Dashboard"}),s.jsxs("p",{className:"text-xs text-gray-500 mt-1 flex items-center gap-1.5",children:["Aktif Hesap: ",s.jsx("span",{className:"text-emerald-400 font-semibold",children:(p==null?void 0:p.exchange)||(C==null?void 0:C.name)||r||"Bağlı Değil"})," · ","Şablon: ",s.jsx("span",{className:"text-cyan-400 font-semibold",children:a||"Varsayılan"})]})]}),!A&&s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("button",{onClick:()=>N(),className:"flex items-center gap-1 px-4 py-2 rounded-xl text-xs font-bold text-white bg-emerald-600 hover:bg-emerald-500 transition-all active:scale-[0.98]",children:[s.jsx("span",{children:"Para Yatır"}),s.jsx(Kr,{size:12})]}),s.jsxs("button",{onClick:()=>N(),className:"flex items-center gap-1 px-4 py-2 rounded-xl text-xs font-bold text-white bg-white/5 border border-white/8 hover:bg-white/8 hover:border-white/12 transition-all active:scale-[0.98]",children:[s.jsx("span",{children:"Para Çek"}),s.jsx(Kr,{size:12})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-5",children:[s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 flex flex-col justify-between h-[130px] relative overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Toplam Varlık / Total Balance"}),s.jsxs("div",{className:"flex items-center gap-2",children:[((p==null?void 0:p.isTestnet)||(C==null?void 0:C.isTestnet))&&s.jsx("span",{className:"px-2 py-0.5 rounded bg-amber-500/10 border border-amber-500/25 text-amber-400 font-bold uppercase tracking-wider text-[8px] animate-pulse",children:"DEMO ACTIVE"}),s.jsx("div",{className:"w-2.5 h-2.5 rounded-full bg-emerald-500 animate-pulse"})]})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("p",{className:"text-2xl font-black text-white/90 font-mono",children:[(p==null?void 0:p.displayAsset)==="USDT"||(p==null?void 0:p.displayAsset)==="USD"?"$":"",p?p.total.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"0.00"," ",(p==null?void 0:p.displayAsset)!=="USDT"&&(p==null?void 0:p.displayAsset)!=="USD"?p==null?void 0:p.displayAsset:""]}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-1",children:"Son güncelleme: Az önce"})]})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-6 flex flex-col justify-between h-[130px]",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Kullanılabilir Bakiye / Free Balance"}),s.jsx(yv,{size:14,className:"text-emerald-400"})]}),s.jsxs("div",{className:"mt-2",children:[s.jsxs("p",{className:"text-2xl font-black text-emerald-400 font-mono",children:[(p==null?void 0:p.displayAsset)==="USDT"||(p==null?void 0:p.displayAsset)==="USD"?"$":"",p?p.free.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:4}):"0.00"," ",(p==null?void 0:p.displayAsset)!=="USDT"&&(p==null?void 0:p.displayAsset)!=="USD"?p==null?void 0:p.displayAsset:""]}),s.jsxs("p",{className:"text-[10px] text-emerald-500/80 font-semibold mt-1 flex items-center gap-0.5",children:[s.jsx(nv,{size:10})," Bloke / Used: ",p?p.used.toFixed(2):"0.00"," ",p==null?void 0:p.displayAsset]})]})]}),s.jsxs("div",{className:"bg-[#131d27]/40 border border-white/6 rounded-2xl p-5 flex flex-col justify-between h-[130px] overflow-y-auto",children:[s.jsxs("div",{className:"flex items-center justify-between border-b border-white/5 pb-2 mb-2",children:[s.jsx("span",{className:"text-[11px] font-bold text-gray-500 uppercase tracking-wider",children:"Bağlı Hesaplar"}),s.jsx("button",{onClick:()=>e("/app/trader/connect"),className:"text-[10px] font-bold text-emerald-400 hover:text-emerald-300 hover:underline",children:"+ Yeni Ekle"})]}),s.jsxs("div",{className:"space-y-1.5 flex-1 pr-1 scrollbar-thin",children:[t&&t.map(S=>s.jsxs("div",{onClick:()=>o(S.id),className:`flex items-center justify-between p-1.5 rounded-lg border cursor-pointer transition-all ${i===S.id?"bg-emerald-500/10 border-emerald-500/30 text-white font-bold":"bg-white/3 border-white/5 text-zinc-400 hover:bg-white/5 hover:text-white"}`,children:[s.jsxs("div",{className:"flex items-center gap-1.5 truncate",children:[s.jsx("span",{className:`w-1.5 h-1.5 rounded-full shrink-0 ${i===S.id?"bg-emerald-400":"bg-zinc-600"}`}),s.jsxs("span",{className:"text-[11px] truncate",children:[S.name," ",S.isTestnet?"(Demo)":""]})]}),s.jsx("button",{onClick:T=>{T.stopPropagation(),k(S.id,S.name)},className:"text-[9px] font-semibold text-red-400 hover:text-red-300 hover:underline px-1 py-0.5 rounded hover:bg-red-500/10 transition-all shrink-0",children:"Kaldır"})]},S.id)),(!t||t.length===0)&&s.jsx("p",{className:"text-[10px] text-zinc-500 italic text-center py-2",children:"Bağlı hesap bulunamadı."})]})]})]}),s.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[s.jsxs("div",{className:"md:col-span-1 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-white/5 pb-3",children:[s.jsx(Wr,{size:16,className:"text-emerald-400"}),s.jsx("h2",{className:"text-sm font-bold text-white",children:"Aktif Robotlar / Bots"})]}),s.jsx("div",{className:"space-y-3",children:l.map(S=>s.jsxs("div",{className:`p-3.5 rounded-xl border flex flex-col gap-3 transition-all ${S.active?"bg-emerald-500/5 border-emerald-500/25":"bg-white/3 border-white/6"}`,children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[S.active&&s.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-500 animate-pulse shrink-0"}),s.jsxs("div",{className:"truncate",children:[s.jsx("p",{className:"text-xs font-bold text-white/90",children:S.name}),s.jsx("p",{className:"text-[10px] text-gray-500 mt-0.5 truncate",children:S.desc})]})]}),s.jsx("button",{onClick:()=>j(S.id,S.name,S.active),className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 transition-all ${S.active?"bg-red-500/10 border border-red-500/20 text-red-400 hover:bg-red-500/20":"bg-emerald-500/10 border border-emerald-500/20 text-emerald-400 hover:bg-emerald-500/20"}`,children:S.active?s.jsx(Bl,{size:10,fill:"currentColor"}):s.jsx(gs,{size:10,fill:"currentColor"})})]}),s.jsxs("div",{className:"flex items-center justify-between pt-2.5 border-t border-white/5",children:[s.jsx("span",{className:"text-[9px] text-zinc-500 font-bold uppercase tracking-wider",children:"Periyot / Interval"}),s.jsxs("select",{value:x[S.id]||3e5,onChange:T=>{const L=parseInt(T.target.value);g(O=>({...O,[S.id]:L}))},disabled:S.active,className:"bg-zinc-950 border border-zinc-800 text-[10px] text-zinc-300 font-semibold rounded-lg px-2 py-1 focus:outline-none focus:border-emerald-500/40 cursor-pointer disabled:opacity-40",children:[s.jsx("option",{value:6e4,children:"1 Dakika"}),s.jsx("option",{value:3e5,children:"5 Dakika"}),s.jsx("option",{value:9e5,children:"15 Dakika"}),s.jsx("option",{value:36e5,children:"1 Saat"})]})]})]},S.id))})]}),s.jsxs("div",{className:"md:col-span-2 bg-[#0c0f18]/60 border border-white/6 rounded-2xl p-5 space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 border-b border-white/5 pb-3",children:[s.jsx(b3,{size:16,className:"text-cyan-400"}),s.jsx("h2",{className:"text-sm font-bold text-white",children:"İşlem Geçmişi / Trade History"})]}),s.jsx("div",{className:"overflow-x-auto",children:s.jsxs("table",{className:"w-full text-left text-xs text-gray-400",children:[s.jsx("thead",{children:s.jsxs("tr",{className:"border-b border-white/5 text-gray-600 font-bold uppercase tracking-wider text-[10px]",children:[s.jsx("th",{className:"py-2.5",children:"Parite / Pair"}),s.jsx("th",{className:"py-2.5",children:"Yön / Side"}),s.jsx("th",{className:"py-2.5",children:"Tarih / Date"}),s.jsx("th",{className:"py-2.5 text-right",children:"Miktar / Amount"})]})}),s.jsx("tbody",{className:"divide-y divide-white/5 font-mono text-[11px]",children:m.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:4,className:"py-6 text-center text-zinc-600 italic",children:"İşlem geçmişi bulunamadı."})}):m.map(S=>{const T=String(S.side).toUpperCase()==="BUY",L=new Date(S.datetime).toLocaleDateString(void 0,{month:"2-digit",day:"2-digit"})+" "+new Date(S.datetime).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",hour12:!1});return s.jsxs("tr",{className:"hover:bg-white/2 transition-colors",children:[s.jsx("td",{className:"py-3 font-semibold text-white/80",children:S.symbol}),s.jsx("td",{className:"py-3",children:s.jsx("span",{className:`px-1.5 py-0.5 rounded-md font-bold text-[9px] ${T?"bg-emerald-500/10 text-emerald-400 border border-emerald-500/20":"bg-red-500/10 text-red-400 border border-red-500/20"}`,children:S.side.toUpperCase()})}),s.jsx("td",{className:"py-3 text-gray-500",children:L}),s.jsxs("td",{className:`py-3 text-right font-bold ${T?"text-emerald-400":"text-red-400"}`,children:[T?"+":"-",S.amount.toLocaleString(void 0,{minimumFractionDigits:2,maximumFractionDigits:6})]})]},S.id)})})]})})]})]})]})}function X0(e){return e>=90?"#ef4444":e>=70?"#f97316":"#22c55e"}function ma(e){return e==="critical"?"#ef4444":e==="warning"?"#f97316":"#60a5fa"}function WP(){const{t:e,locale:t}=yt(),n=e.systemHealth,[r,a]=u.useState(null),[i,o]=u.useState(null),[l,c]=u.useState(!1),d=u.useCallback(()=>o(null),[]);u.useEffect(()=>{window.dispatchEvent(new CustomEvent("mustb:safeMode",{detail:{active:(r==null?void 0:r.safeMode)??!1}}))},[r==null?void 0:r.safeMode]),u.useEffect(()=>{const f=pe();return f.on("systemStats",m=>a(m)),f.on("systemHealth",m=>{if(o(m),c(!0),m.level!=="critical"){const b=m.level==="info"?6e3:12e3;setTimeout(()=>o(null),b)}}),()=>{f.off("systemStats"),f.off("systemHealth")}},[]);const h=(r==null?void 0:r.cpu)??0,p=(r==null?void 0:r.ram)??0;return s.jsxs("div",{className:"relative flex items-center",children:[s.jsxs("button",{onClick:()=>i&&c(f=>!f),className:"flex items-center gap-1.5 select-none transition-all rounded-md",style:{cursor:i?"pointer":"default"},title:i?i.message:n.title,children:[i?s.jsx("span",{className:"w-2 h-2 rounded-full flex-shrink-0 animate-pulse",style:{background:ma(i.level)}}):s.jsx(tn,{size:12,className:"text-orange-400/70"}),r&&s.jsxs("span",{className:"hidden sm:flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[10px] font-semibold text-white/45",children:"CPU"}),s.jsx("span",{className:"w-9 h-1 rounded-full bg-white/10 overflow-hidden flex-shrink-0",children:s.jsx("span",{className:"h-full rounded-full block transition-all duration-700",style:{width:`${h}%`,background:X0(h)}})}),s.jsxs("span",{className:"text-[9px] font-mono text-white/40 w-6 text-right",children:[h,"%"]}),s.jsx("span",{className:"w-px h-3 bg-white/10"}),s.jsx("span",{className:"text-[10px] font-semibold text-white/45",children:"RAM"}),s.jsx("span",{className:"w-9 h-1 rounded-full bg-white/10 overflow-hidden flex-shrink-0",children:s.jsx("span",{className:"h-full rounded-full block transition-all duration-700",style:{width:`${p}%`,background:X0(p)}})}),s.jsxs("span",{className:"text-[9px] font-mono text-white/40 w-6 text-right",children:[p,"%"]}),r.liteMode&&!r.safeMode&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded bg-orange-500/20 text-orange-400 ml-0.5",children:n.lite}),r.safeMode&&s.jsx("span",{className:"text-[8px] font-bold px-1 py-0.5 rounded bg-red-500/20 text-red-400 ml-0.5",children:n.safe})]}),!r&&s.jsx("span",{className:"text-[10px] font-semibold hidden sm:inline text-white/35",children:n.title})]}),s.jsx(ae,{children:l&&i&&s.jsxs(V.div,{initial:{opacity:0,y:8,scale:.96},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:8,scale:.96},transition:{duration:.2,ease:"easeOut"},className:"absolute top-full right-0 mt-2 w-72 z-[200] rounded-2xl overflow-hidden",style:{background:"rgba(20,8,2,0.88)",border:`1px solid ${ma(i.level)}44`,backdropFilter:"blur(20px)",boxShadow:`0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px ${ma(i.level)}22`},children:[s.jsxs("div",{className:"flex items-start justify-between px-4 pt-3 pb-2",style:{borderBottom:`1px solid ${ma(i.level)}22`},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Hs,{size:13,style:{color:ma(i.level)}}),s.jsxs("span",{className:"text-[12px] font-bold text-white/90 capitalize",children:[n[i.level]??i.level," — ",n.kinds[i.kind]??i.kind]})]}),s.jsx("button",{onClick:d,className:"text-white/30 hover:text-white/70 transition-colors",children:s.jsx(Ie,{size:13})})]}),s.jsxs("div",{className:"px-4 py-3 space-y-2",children:[s.jsx("p",{className:"text-[13px] text-white/80 leading-relaxed",children:n.alerts[i.kind]??i.message}),s.jsx("p",{className:"text-[11px] text-white/45 leading-relaxed italic",children:n.recommendations[i.kind]??i.recommendation})]}),s.jsx("div",{className:"px-4 pb-3",children:s.jsx("span",{className:"text-[10px] text-white/25 font-mono",children:new Date(i.ts).toLocaleTimeString()})})]},"health-popover")})]})}function KP(e){return`${Math.round(e*100)}%`}const Q0={skill:{label:"Skill",icon:Ue,color:"text-orange-400"},conversation:{label:"Conversation",icon:Us,color:"text-blue-400"},workspace:{label:"Workspace",icon:Ln,color:"text-green-400"},custom:{label:"Custom",icon:nn,color:"text-gray-400"}};function GP(){const{t:e}=yt(),t=e.panels.memory,[n,r]=u.useState(""),[a,i]=u.useState([]),[o,l]=u.useState(null),[c,d]=u.useState(!1),[h,p]=u.useState(null),[f,m]=u.useState(null),[b,y]=u.useState(!1),v=u.useRef(null),x=u.useCallback(async k=>{const N=k.trim();if(N){d(!0),i([]);try{const C=await U(`/api/memory/search?q=${encodeURIComponent(N)}&limit=10`);if(C.ok){const A=await C.json();i(A.results??[])}}catch{}d(!1)}},[]),g=k=>{k.key==="Enter"&&x(n)},w=u.useCallback(async()=>{try{const k=await U("/api/memory/stats");k.ok&&l(await k.json())}catch{}},[]),j=async k=>{p(k),m(null);try{const N=k==="clear"?await U("/api/memory/clear-index",{method:"DELETE"}):await U(`/api/memory/index-${k}`,{method:"POST"});if(N.ok){const C=await N.json(),A=k==="clear"?t.indexCleared:`${t.indexed} ${C.indexed??0} ${k==="skills"?t.skills:t.files}`;m({ok:!0,msg:A}),w(),k==="clear"&&i([])}else m({ok:!1,msg:t.opFailed})}catch{m({ok:!1,msg:t.reqError})}p(null),setTimeout(()=>m(null),4e3)};return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Zt,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title}),o&&s.jsxs("span",{className:"text-[10px] text-gray-600 bg-white/5 px-2 py-0.5 rounded-full font-mono",children:[o.items.toLocaleString()," ",t.vectors]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:()=>{y(k=>!k),o||w()},className:`text-gray-600 hover:text-gray-400 transition-colors ${b?"text-orange-400":""}`,title:t.indexControls,children:s.jsx(F3,{size:13})}),s.jsx("button",{onClick:w,className:"text-gray-600 hover:text-gray-400 transition-colors",title:t.refreshStats,children:s.jsx(ge,{size:13})})]})]}),s.jsx(ae,{children:b&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-b border-white/5 bg-white/2 overflow-hidden shrink-0",children:[s.jsxs("div",{className:"px-6 py-3 flex flex-wrap items-center gap-2",children:[s.jsx("span",{className:"text-[10px] text-gray-600 uppercase tracking-widest font-bold shrink-0",children:t.indexLabel}),["skills","workspace"].map(k=>s.jsxs("button",{onClick:()=>j(k),disabled:h!==null,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-white/4 border border-white/6 text-[11px] text-gray-400 hover:text-gray-200 hover:bg-white/8 transition-all disabled:opacity-40 capitalize",children:[h===k?s.jsx(ne,{size:10,className:"animate-spin"}):k==="skills"?s.jsx(Ue,{size:10}):s.jsx(Ln,{size:10}),k]},k)),s.jsxs("button",{onClick:()=>j("clear"),disabled:h!==null,className:"flex items-center gap-1 px-2.5 py-1 rounded-lg bg-red-500/8 border border-red-500/15 text-[11px] text-red-400 hover:bg-red-500/15 transition-all disabled:opacity-40 ml-auto",children:[h==="clear"?s.jsx(ne,{size:10,className:"animate-spin"}):s.jsx(ys,{size:10}),t.clearIndex]})]}),s.jsx(ae,{children:f&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 px-6 pb-3 text-[11px] font-medium ${f.ok?"text-green-400":"text-red-400"}`,children:[f.ok?s.jsx(Fe,{size:11}):s.jsx(Ke,{size:11}),f.msg]})})]})}),s.jsxs("div",{className:"px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-xl bg-white/4 border border-white/8 focus-within:border-orange-500/30 transition-colors",children:[s.jsx(fn,{size:13,className:"text-gray-600 shrink-0"}),s.jsx("input",{ref:v,value:n,onChange:k=>r(k.target.value),onKeyDown:g,placeholder:t.searchPlaceholder,className:"flex-1 bg-transparent text-[13px] text-gray-200 outline-none placeholder-gray-700"}),c?s.jsx(ne,{size:13,className:"text-orange-400 animate-spin shrink-0"}):s.jsx("button",{onClick:()=>x(n),disabled:!n.trim(),className:"text-[10px] px-2 py-0.5 rounded-lg bg-orange-500/12 text-orange-400 font-semibold hover:bg-orange-500/22 border border-orange-500/20 transition-all disabled:opacity-30",children:"⌘↵"})]}),s.jsx("p",{className:"text-[10px] text-gray-700 mt-1.5 ml-1",children:t.searchHint})]}),s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-3",children:[a.length===0&&!c&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(Zt,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:n.trim()?t.emptyNoResults:t.emptyTitle}),s.jsx("p",{className:"text-xs text-gray-700 mt-1 max-w-xs leading-relaxed",children:n.trim()?t.emptyNoResultsHint:t.emptyHint})]}),a.map((k,N)=>{const C=Q0[k.metadata.source]??Q0.custom,A=C.icon;return s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:N*.04},className:"rounded-2xl border border-white/6 bg-[#0c0f18] p-4 hover:border-white/12 transition-all",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-1.5 min-w-0",children:[s.jsx(A,{size:11,className:`${C.color} shrink-0`}),s.jsx("p",{className:"text-[12px] font-semibold text-gray-300 truncate",children:k.metadata.title})]}),s.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[s.jsx("span",{className:`text-[9px] font-bold px-1.5 py-0.5 rounded-full border ${k.score>=.85?"bg-green-500/10 border-green-500/20 text-green-400":k.score>=.65?"bg-orange-500/10 border-orange-500/20 text-orange-400":"bg-white/4 border-white/6 text-gray-500"}`,children:KP(k.score)}),s.jsx("span",{className:`text-[9px] px-1.5 py-0.5 rounded-full bg-white/4 border border-white/6 font-medium ${C.color}`,children:C.label})]})]}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed line-clamp-3 mb-2",children:k.text}),k.metadata.tags&&k.metadata.tags.length>0&&s.jsx("div",{className:"flex flex-wrap gap-1",children:k.metadata.tags.map((S,T)=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:S},T))}),s.jsx("div",{className:"mt-2 h-0.5 bg-white/4 rounded-full overflow-hidden",children:s.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-orange-600 to-amber-400",style:{width:`${k.score*100}%`}})})]},N)})]})]})}const qP={node:en,python:wn},YP={node:"text-green-400",python:"text-blue-400"};function XP(){const{t:e}=yt(),t=e.panels.plugins,[n,r]=u.useState([]),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(null),[h,p]=u.useState(!1),[f,m]=u.useState(""),[b,y]=u.useState(""),[v,x]=u.useState("node"),[g,w]=u.useState(""),[j,k]=u.useState(!1),N=(T,L)=>{d({ok:T,msg:L}),setTimeout(()=>d(null),4e3)},C=u.useCallback(async()=>{i(!0);try{const T=await U("/api/plugins/list");if(T.ok){const L=await T.json();r(L.plugins??[])}}catch{}i(!1)},[]);u.useEffect(()=>{C()},[C]);const A=async(T,L)=>{l(T);try{(await U(L?"/api/plugins/stop":"/api/plugins/run",{method:"POST",body:JSON.stringify({name:T})})).ok?(N(!0,L?`${T} stopped`:`${T} launched`),await C()):N(!1,t.opFailed)}catch{N(!1,t.reqError)}l(null)},S=async()=>{if(!(!f.trim()||!b.trim())){k(!0);try{(await U("/api/plugins/build",{method:"POST",body:JSON.stringify({name:f.trim(),goal:b.trim(),lang:v,context:g.trim()||void 0})})).ok?(N(!0,`Plugin "${f}" created`),m(""),y(""),w(""),p(!1),await C()):N(!1,t.buildFailed)}catch{N(!1,t.reqError)}k(!1)}};return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(qr,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title}),s.jsxs("span",{className:"text-[10px] text-gray-600 bg-white/5 px-2 py-0.5 rounded-full font-mono",children:[n.length," ",t.installed]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("button",{onClick:C,className:"text-gray-600 hover:text-gray-400 transition-colors",title:t.refresh,children:s.jsx(ge,{size:13,className:a?"animate-spin":""})}),s.jsxs("button",{onClick:()=>p(T=>!T),className:`flex items-center gap-1 text-[10px] px-2.5 py-1 rounded-lg border font-semibold transition-all ${h?"bg-orange-500/15 border-orange-500/25 text-orange-400":"bg-white/4 border-white/8 text-gray-500 hover:text-gray-300"}`,children:[s.jsx(Dl,{size:10}),t.newPlugin]})]})]}),s.jsx(ae,{children:c&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},exit:{opacity:0},className:`flex items-center gap-1.5 px-6 py-2 text-[11px] font-medium shrink-0 ${c.ok?"text-green-400":"text-red-400"}`,children:[c.ok?s.jsx(Fe,{size:11}):s.jsx(Ke,{size:11}),c.msg]})}),s.jsx(ae,{children:h&&s.jsx(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"border-b border-white/5 bg-white/2 overflow-hidden shrink-0",children:s.jsxs("div",{className:"px-6 py-4 space-y-3",children:[s.jsx("p",{className:"text-[10px] font-bold text-gray-500 uppercase tracking-widest",children:t.buildTitle}),s.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[s.jsx("input",{value:f,onChange:T=>m(T.target.value),placeholder:t.namePlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("input",{value:b,onChange:T=>y(T.target.value),placeholder:t.goalPlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("input",{value:g,onChange:T=>w(T.target.value),placeholder:t.contextPlaceholder,className:"col-span-2 px-3 py-2 rounded-lg bg-white/4 border border-white/8 text-[12px] text-gray-200 outline-none placeholder-gray-700 focus:border-orange-500/30 transition-colors"}),s.jsx("div",{className:"flex gap-2",children:["node","python"].map(T=>s.jsx("button",{onClick:()=>x(T),className:`flex-1 py-1.5 rounded-lg border text-[11px] font-semibold transition-all capitalize ${v===T?"bg-orange-500/15 border-orange-500/25 text-orange-400":"bg-white/4 border-white/8 text-gray-500"}`,children:T},T))}),s.jsxs("button",{onClick:S,disabled:j||!f.trim()||!b.trim(),className:"flex items-center justify-center gap-1.5 py-2 rounded-lg bg-orange-500/12 border border-orange-500/20 text-orange-400 text-[11px] font-bold hover:bg-orange-500/20 transition-all disabled:opacity-40",children:[j?s.jsx(ne,{size:11,className:"animate-spin"}):s.jsx(Ue,{size:11}),t.generatePlugin]})]})]})})}),s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-2",children:[n.length===0&&!a&&s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(qr,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:t.emptyTitle}),s.jsx("p",{className:"text-xs text-gray-700 mt-1",children:t.emptyHint})]}),n.map((T,L)=>{const O=qP[T.lang]??en,z=o===T.name;return s.jsxs(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},transition:{delay:L*.04},className:`flex items-center gap-3 p-3 rounded-2xl border transition-all ${T.running?"bg-green-500/5 border-green-500/15 hover:border-green-500/25":"bg-[#0c0f18] border-white/6 hover:border-white/12"}`,children:[s.jsx(O,{size:13,className:YP[T.lang]??"text-gray-400"}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("p",{className:"text-[12px] font-semibold text-gray-300 truncate",children:T.name}),s.jsx("p",{className:"text-[10px] text-gray-600 font-mono",children:T.filename})]}),T.running&&s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-full bg-green-500/12 border border-green-500/20 text-green-400 font-bold",children:t.running}),s.jsxs("button",{disabled:z,onClick:()=>A(T.name,T.running),className:`flex items-center gap-1 px-2.5 py-1.5 rounded-lg border text-[10px] font-bold transition-all disabled:opacity-40 ${T.running?"bg-red-500/8 border-red-500/15 text-red-400 hover:bg-red-500/15":"bg-green-500/8 border-green-500/15 text-green-400 hover:bg-green-500/15"}`,children:[z?s.jsx(ne,{size:10,className:"animate-spin"}):T.running?s.jsx(Bl,{size:10}):s.jsx(gs,{size:10}),T.running?t.stop:t.run]})]},T.name)})]})]})}function QP(e){if(!e)return"Never";try{return new Date(e).toLocaleString("en-US",{dateStyle:"short",timeStyle:"short"})}catch{return e}}function JP(e){const t=Date.now()-new Date(e).getTime(),n=Math.floor(t/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function ZP({skill:e}){const[t,n]=u.useState(!1),[r,a]=u.useState(!1),[i,o]=u.useState(""),[l,c]=u.useState(!1),d=async()=>{if(!l){c(!0);return}if(i.trim()){n(!0);try{await U("/api/v1/skills/invoke",{method:"POST",body:JSON.stringify({skill:e.id,params:{goal:i.trim(),_autoRun:!0}})}),a(!0),c(!1),o(""),setTimeout(()=>a(!1),3e3)}catch{}n(!1)}},h=(e.requires.bins??[]).length>0,p=(e.requires.config??[]).length>0;return s.jsx(V.div,{initial:{opacity:0,y:8},animate:{opacity:1,y:0},className:"rounded-2xl border border-white/6 bg-[#0c0f18] hover:border-white/12 transition-all",children:s.jsxs("div",{className:"p-3",children:[s.jsxs("div",{className:"flex items-start gap-2 mb-1.5",children:[s.jsx("span",{className:"text-base leading-none mt-0.5 shrink-0",children:e.emoji??"⚡"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-[12px] font-bold text-gray-200 truncate capitalize",children:e.name})}),e.hasScripts&&s.jsx(Mn,{size:10,className:"text-gray-700 shrink-0 mt-0.5"})]}),s.jsx("p",{className:"text-[10px] text-gray-500 leading-relaxed line-clamp-2 mb-2 ml-6",children:e.description}),(h||p)&&s.jsxs("div",{className:"flex flex-wrap gap-1 mb-2 ml-6",children:[(e.requires.bins??[]).map(f=>s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-blue-500/8 border border-blue-500/15 text-blue-400 font-mono",children:["bin:",f]},f)),(e.requires.config??[]).map(f=>s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded bg-purple-500/8 border border-purple-500/15 text-purple-400 font-mono",children:["cfg:",f]},f))]}),s.jsx(ae,{children:l&&s.jsx(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:"overflow-hidden mb-2",children:s.jsx("input",{autoFocus:!0,value:i,onChange:f=>o(f.target.value),onKeyDown:f=>{f.key==="Enter"&&d(),f.key==="Escape"&&(c(!1),o(""))},placeholder:`Goal for ${e.name}…`,className:"w-full px-2.5 py-1.5 rounded-lg bg-white/4 border border-white/10 text-[11px] text-gray-200 placeholder-gray-700 outline-none focus:border-orange-500/30 transition-colors"})})}),s.jsxs("div",{className:"flex items-center justify-end gap-1 ml-6",children:[l&&s.jsx("button",{onClick:()=>{c(!1),o("")},className:"text-[10px] px-2 py-1 rounded-lg bg-white/4 text-gray-600 hover:text-gray-400 transition-colors",children:"Cancel"}),s.jsx("button",{onClick:d,disabled:t||l&&!i.trim(),className:`flex items-center gap-1 px-2.5 py-1 rounded-lg text-[10px] font-semibold border transition-all disabled:opacity-40 ${r?"bg-green-500/10 border-green-500/20 text-green-400":"bg-orange-500/8 border-orange-500/15 text-orange-400 hover:bg-orange-500/15"}`,children:t?s.jsx(ne,{size:9,className:"animate-spin"}):r?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:9})," Sent"]}):l?s.jsxs(s.Fragment,{children:[s.jsx(gn,{size:9})," Run"]}):s.jsxs(s.Fragment,{children:[s.jsx(D3,{size:9})," Use"]})})]})]})})}function e6(){const{t:e}=yt(),t=e.panels.skills,[n,r]=u.useState("saved"),[a,i]=u.useState([]),[o,l]=u.useState(!1),[c,d]=u.useState(null),[h,p]=u.useState("idle"),[f,m]=u.useState(null),[b,y]=u.useState(null),[v,x]=u.useState([]),[g,w]=u.useState(!1),[j,k]=u.useState(""),N=u.useCallback(async()=>{l(!0);try{const L=await U("/api/skills/list");if(L.ok){const O=await L.json();i(O.skills??[])}}catch{}l(!1)},[]),C=u.useCallback(async()=>{w(!0);try{const L=await U("/api/skills/catalog");if(L.ok){const O=await L.json();x(O.skills??[])}}catch{}w(!1)},[]);u.useEffect(()=>{N()},[N]),u.useEffect(()=>{n==="library"&&v.length===0&&C()},[n,v.length,C]),u.useEffect(()=>{const L=pe(),O=z=>{z.type==="skillRunStart"&&z.skillId&&(d(z.skillId),p("running")),z.type==="planFinish"&&(p("done"),d(null),N(),setTimeout(()=>p("idle"),2500))};return L.on("agentUpdate",O),()=>{L.off("agentUpdate",O)}},[N]);const A=async L=>{if(!c){d(L.id),p("running");try{const O=await U("/api/skills/run",{method:"POST",body:JSON.stringify({id:L.id})});if(!O.ok)throw new Error(`HTTP ${O.status}`)}catch{p("error"),d(null),setTimeout(()=>p("idle"),3e3)}}},S=async L=>{m(L);try{await U(`/api/skills/${L}`,{method:"DELETE"}),i(O=>O.filter(z=>z.id!==L))}catch{}m(null),y(null)},T=j.trim()?v.filter(L=>L.name.toLowerCase().includes(j.toLowerCase())||L.description.toLowerCase().includes(j.toLowerCase())):v;return s.jsxs("div",{className:"h-full flex flex-col overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"flex items-center justify-between px-6 py-3 border-b border-white/5 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Il,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-[13px] font-bold text-gray-300",children:t.title})]}),s.jsxs("div",{className:"flex items-center gap-1 bg-white/4 rounded-lg p-0.5",children:[s.jsxs("button",{onClick:()=>r("saved"),className:`flex items-center gap-1 px-2.5 py-1 rounded-md text-[10px] font-semibold transition-all ${n==="saved"?"bg-orange-500/15 text-orange-400":"text-gray-600 hover:text-gray-400"}`,children:[s.jsx(Ue,{size:9}),"Saved",a.length>0&&s.jsx("span",{className:"text-[9px] font-mono text-gray-600",children:a.length})]}),s.jsxs("button",{onClick:()=>r("library"),className:`flex items-center gap-1 px-2.5 py-1 rounded-md text-[10px] font-semibold transition-all ${n==="library"?"bg-orange-500/15 text-orange-400":"text-gray-600 hover:text-gray-400"}`,children:[s.jsx(zc,{size:9}),"Library",v.length>0&&s.jsx("span",{className:"text-[9px] font-mono text-gray-600",children:v.length})]})]}),s.jsx("button",{onClick:n==="saved"?N:C,disabled:n==="saved"?o:g,className:"text-gray-600 hover:text-gray-400 transition-colors",title:"Refresh",children:s.jsx(ge,{size:13,className:(n==="saved"?o:g)?"animate-spin":""})})]}),n==="saved"&&s.jsxs(s.Fragment,{children:[s.jsx(ae,{children:h!=="idle"&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},className:`px-6 py-2 border-b flex items-center gap-2 text-xs font-medium ${h==="running"?"bg-orange-500/8 border-orange-500/15 text-orange-400":h==="done"?"bg-green-500/8 border-green-500/15 text-green-400":"bg-red-500/8 border-red-500/15 text-red-400"}`,children:[h==="running"&&s.jsx(ne,{size:12,className:"animate-spin"}),h==="done"&&s.jsx(Fe,{size:12}),h==="error"&&s.jsx(Ke,{size:12}),h==="running"?t.runningStatus:h==="done"?t.completedStatus:t.failedStatus]})}),s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-4 space-y-3",children:o&&a.length===0?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-700 text-xs gap-2",children:[s.jsx(ne,{size:13,className:"animate-spin"})," ",t.loading]}):a.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx(Ue,{size:36,className:"text-gray-700 mb-4"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:t.emptyTitle}),s.jsxs("p",{className:"text-xs text-gray-700 mt-1 max-w-xs",children:[t.emptyHint," ",s.jsx("span",{className:"text-orange-400 font-medium",children:t.saveAsSkill})," ",t.emptyHint2]}),s.jsxs("button",{onClick:()=>r("library"),className:"mt-4 flex items-center gap-1.5 text-[11px] text-orange-400 hover:text-orange-300 transition-colors",children:[s.jsx(zc,{size:11})," Browse skill library"]})]}):a.map((L,O)=>{const z=c===L.id&&h==="running",$=c===L.id&&h==="done",R=f===L.id;return s.jsx(V.div,{initial:{opacity:0,y:10},animate:{opacity:1,y:0},transition:{delay:O*.04},className:`rounded-2xl border bg-[#0c0f18] transition-all ${z?"border-orange-500/30 shadow-[0_0_12px_rgba(234,88,12,0.12)]":$?"border-green-500/20":"border-white/6 hover:border-white/12"}`,children:s.jsxs("div",{className:"p-4",children:[s.jsxs("div",{className:"flex items-start justify-between gap-2 mb-2",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(Ue,{size:13,className:"text-orange-400 shrink-0 mt-0.5"}),s.jsx("p",{className:"text-[13px] font-bold text-white truncate",children:L.name})]}),s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] text-gray-600 shrink-0 font-mono",children:[s.jsx(rv,{size:9}),L.runCount,"×"]})]}),s.jsx("p",{className:"text-[11px] text-gray-500 leading-relaxed mb-2 line-clamp-2",children:L.goal}),L.steps.length>0&&s.jsxs("div",{className:"flex flex-wrap gap-1 mb-3",children:[L.steps.slice(0,4).map((M,P)=>s.jsx("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:M.tool??"step"},P)),L.steps.length>4&&s.jsxs("span",{className:"text-[9px] px-1.5 py-0.5 rounded-md bg-white/4 text-gray-600 font-mono",children:["+",L.steps.length-4," more"]})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-1 text-[10px] text-gray-700",children:[s.jsx(Lt,{size:9}),s.jsx("span",{children:JP(L.savedAt)}),L.lastRunAt&&s.jsxs("span",{className:"text-gray-800",children:["· ",t.lastRun," ",QP(L.lastRunAt)]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[b===L.id?s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("span",{className:"text-[10px] text-red-400",children:t.deleteConfirm}),s.jsx("button",{onClick:()=>S(L.id),disabled:R,className:"text-[10px] px-2 py-0.5 rounded bg-red-500/15 text-red-400 hover:bg-red-500/25 transition-colors",children:R?"…":t.yes}),s.jsx("button",{onClick:()=>y(null),className:"text-[10px] px-2 py-0.5 rounded bg-white/5 text-gray-500 hover:bg-white/8",children:t.no})]}):s.jsx("button",{onClick:()=>y(L.id),className:"p-1.5 rounded-lg text-gray-700 hover:text-red-400 hover:bg-red-500/8 transition-all",title:"Delete skill",children:s.jsx(ys,{size:12})}),s.jsx("button",{onClick:()=>A(L),disabled:!!c,className:`flex items-center gap-1.5 px-3 py-1.5 rounded-xl text-[11px] font-semibold transition-all ${z?"bg-orange-500/15 text-orange-400 border border-orange-500/25 cursor-not-allowed":$?"bg-green-500/12 text-green-400 border border-green-500/20":"bg-orange-500/10 hover:bg-orange-500/20 text-orange-400 border border-orange-500/20 hover:border-orange-500/35 disabled:opacity-40 disabled:cursor-not-allowed"}`,children:z?s.jsxs(s.Fragment,{children:[s.jsx(ne,{size:11,className:"animate-spin"})," ",t.runningBtn]}):$?s.jsxs(s.Fragment,{children:[s.jsx(Fe,{size:11})," ",t.doneBtn]}):s.jsxs(s.Fragment,{children:[s.jsx(gs,{size:11})," ",t.runBtn]})})]})]})]})},L.id)})})]}),n==="library"&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-4 py-2.5 border-b border-white/5 shrink-0",children:s.jsx("input",{value:j,onChange:L=>k(L.target.value),placeholder:"Search skills…",className:"w-full px-3 py-1.5 rounded-lg bg-white/4 border border-white/8 text-[11px] text-gray-300 placeholder-gray-700 outline-none focus:border-orange-500/25 transition-colors"})}),s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-hide p-3 grid grid-cols-1 gap-2",children:g&&v.length===0?s.jsxs("div",{className:"flex items-center justify-center py-16 text-gray-700 text-xs gap-2 col-span-1",children:[s.jsx(ne,{size:13,className:"animate-spin"})," Loading skill library…"]}):T.length===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center col-span-1",children:[s.jsx(zc,{size:36,className:"text-gray-700 mb-3"}),s.jsx("p",{className:"text-sm font-semibold text-gray-500",children:"No skills found"}),j&&s.jsx("button",{onClick:()=>k(""),className:"mt-2 text-[11px] text-orange-400 hover:text-orange-300",children:"Clear filter"})]}):T.map((L,O)=>s.jsx(V.div,{initial:{opacity:0,y:6},animate:{opacity:1,y:0},transition:{delay:Math.min(O*.02,.4)},children:s.jsx(ZP,{skill:L})},L.id))}),v.length>0&&s.jsx("div",{className:"px-4 py-2 border-t border-white/5 shrink-0 flex items-center gap-1.5",children:s.jsxs("span",{className:"text-[10px] text-gray-700 font-mono",children:[T.length," / ",v.length," skills"]})})]})]})}const t6={html:i0,htm:i0,json:wn,js:wn,ts:wn,tsx:wn,jsx:wn};function n6(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function s6(e){try{return new Date(e).toLocaleString("en-US",{dateStyle:"short",timeStyle:"short"})}catch{return e}}function r6(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g,t=>{let n="color:#86efac";return/^"/.test(t)&&(n=/:$/.test(t)?"color:#93c5fd":"color:#fca5a5"),/true|false/.test(t)&&(n="color:#f97316"),/null/.test(t)&&(n="color:#6b7280"),`<span style="${n}">${t}</span>`})}function a6(){const[e,t]=u.useState([]),[n,r]=u.useState(null),[a,i]=u.useState(null),[o,l]=u.useState(!1),[c,d]=u.useState(null),[h,p]=u.useState(!1),f=u.useCallback(async()=>{p(!0);try{const v=await U("/api/workspace/files");if(v.ok){const x=await v.json();t(x.files??[])}}catch{}p(!1)},[]);u.useEffect(()=>{f()},[f]);const m=async v=>{r(v),i(null),d(null),l(!0);try{const x=await U(`/api/workspace/file?p=${encodeURIComponent(v.rel)}`);if(!x.ok)throw new Error(`HTTP ${x.status}`);const g=await x.json();i(g.content+(g.truncated?`
|
|
840
840
|
|
|
841
841
|
[… file truncated at 1.5 MB …]`:""))}catch(x){d(x instanceof Error?x.message:"Failed to load file")}l(!1)},b=v=>{const x=t6[v]??nn;return s.jsx(x,{size:12,className:"shrink-0 text-gray-500"})},y=()=>{if(o)return s.jsxs("div",{className:"flex items-center justify-center h-full text-gray-600 text-xs gap-2",children:[s.jsx(ge,{size:14,className:"animate-spin"})," Loading…"]});if(c)return s.jsxs("div",{className:"flex items-center justify-center h-full gap-2 text-red-400 text-xs",children:[s.jsx(Ke,{size:14})," ",c]});if(!a)return s.jsx("div",{className:"flex items-center justify-center h-full text-gray-700 text-xs",children:"Select a file to preview"});const v=(n==null?void 0:n.ext)??"";if(v==="html"||v==="htm")return s.jsx("iframe",{srcDoc:a,sandbox:"allow-scripts",className:"w-full h-full border-0 bg-white",title:"workspace-preview"});const x=v==="json"?r6(a):a.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">");return s.jsx("pre",{className:"w-full h-full overflow-auto p-4 text-[11px] font-mono text-gray-300 leading-relaxed whitespace-pre-wrap break-words bg-transparent",dangerouslySetInnerHTML:{__html:x}})};return s.jsxs("div",{className:"flex h-full overflow-hidden bg-[#080b12]",children:[s.jsxs("div",{className:"w-52 shrink-0 border-r border-white/5 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-b border-white/5",children:[s.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-bold text-gray-500 uppercase tracking-widest",children:[s.jsx(Ln,{size:11,className:"text-orange-400"}),"Workspace"]}),s.jsx("button",{onClick:f,disabled:h,className:"text-gray-700 hover:text-gray-400 transition-colors",title:"Refresh",children:s.jsx(ge,{size:11,className:h?"animate-spin":""})})]}),s.jsx("div",{className:"flex-1 overflow-y-auto py-1 scrollbar-hide",children:e.length===0?s.jsx("p",{className:"text-[10px] text-gray-700 text-center py-6",children:"No files in workspace yet"}):e.map(v=>s.jsxs("button",{onClick:()=>m(v),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors group ${(n==null?void 0:n.rel)===v.rel?"bg-orange-500/10 text-orange-300":"text-gray-500 hover:text-gray-300 hover:bg-white/3"}`,children:[b(v.ext),s.jsx("span",{className:"text-[11px] truncate flex-1",children:v.name}),s.jsx(gn,{size:10,className:`shrink-0 opacity-0 group-hover:opacity-100 transition-opacity ${(n==null?void 0:n.rel)===v.rel?"opacity-100 text-orange-400":""}`})]},v.rel))})]}),s.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-2 border-b border-white/5 bg-white/[0.015] shrink-0",children:[s.jsx(ae,{mode:"wait",children:n?s.jsxs(V.div,{initial:{opacity:0,x:-8},animate:{opacity:1,x:0},exit:{opacity:0},className:"flex items-center gap-2 min-w-0",children:[s.jsx("span",{className:"text-[11px] font-mono text-gray-400 truncate",children:n.rel}),s.jsxs("span",{className:"text-[9px] text-gray-700 shrink-0",children:[n6(n.size)," · ",s6(n.mtime)]})]},n.rel):s.jsx("span",{className:"text-[11px] text-gray-700",children:"No file selected"})}),n&&(n.ext==="html"||n.ext==="htm")&&s.jsx("button",{onClick:()=>window.open(`/api/workspace/file?p=${encodeURIComponent(n.rel)}&raw=1`,"_blank"),className:"text-gray-600 hover:text-gray-300 transition-colors shrink-0 ml-2",title:"Open in new tab",children:s.jsx(Kr,{size:12})})]}),s.jsx("div",{className:"flex-1 overflow-hidden relative",children:y()})]})]})}const co={button:"rgba(234,88,12,0.7)",input:"rgba(59,130,246,0.7)",image:"rgba(168,85,247,0.6)",unknown:"rgba(255,255,255,0.3)"};function i6(){const[e,t]=u.useState(!1),[n,r]=u.useState(null),[a,i]=u.useState(null),[o,l]=u.useState(!1),c=u.useRef(null);u.useEffect(()=>{if(!n||!c.current)return;const h=c.current,p=h.getContext("2d");if(!p)return;const f=new Image;f.onload=()=>{var m;if(h.width=f.width,h.height=f.height,p.drawImage(f,0,0),(m=n.elements)!=null&&m.length)for(const b of n.elements)p.strokeStyle=co[b.type]??co.unknown,p.lineWidth=Math.max(2,Math.round(f.width/400)),p.strokeRect(b.x,b.y,b.width,b.height),p.fillStyle=co[b.type]??co.unknown,p.font=`${Math.max(10,Math.round(f.width/120))}px monospace`,p.fillText(b.type,b.x+4,b.y+14)},f.src=`data:image/png;base64,${n.base64}`},[n]),u.useEffect(()=>{const h=pe();return h.on("agentUpdate",p=>{p.type==="SCREEN_CAPTURE_START"?t(!0):p.type==="SCREEN_CAPTURED"&&(t(!1),r({base64:p.base64,width:p.width,height:p.height,source:p.source,elements:p.elements}))}),()=>{h.off("agentUpdate")}},[]);const d=async()=>{if(!e){try{const h=await U("/api/system/vision-guidance");if(h.ok){const p=await h.json();p.warn&&p.message&&i(p.message)}}catch{}await U("/api/system/screenshot",{method:"POST",body:JSON.stringify({detect:!0})}).catch(()=>{})}};return s.jsxs("div",{className:"border border-white/5 rounded-2xl bg-[#0a0d16]/60 overflow-hidden",children:[s.jsxs("div",{className:"flex items-center justify-between px-4 py-3 border-b border-white/5",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(Vs,{size:14,className:"text-orange-400"}),s.jsx("span",{className:"text-xs font-bold text-gray-400 tracking-widest uppercase",children:"Live Sight"}),n&&s.jsxs("span",{className:"text-[10px] text-gray-600 font-mono",children:[n.width,"×",n.height," · ",n.source]})]}),s.jsxs("div",{className:"flex items-center gap-2",children:[n&&s.jsx("button",{onClick:()=>l(h=>!h),className:"text-gray-600 hover:text-gray-300 transition-colors",title:o?"Collapse":"Expand",children:o?s.jsx(tp,{size:13}):s.jsx(Vs,{size:13})}),s.jsxs("button",{onClick:d,disabled:e,className:`flex items-center gap-1.5 px-3 py-1 rounded-lg text-xs font-medium transition-all ${e?"text-orange-400 bg-orange-500/10 animate-pulse cursor-not-allowed":"text-gray-500 hover:text-orange-400 hover:bg-orange-500/10 border border-white/5"}`,children:[s.jsx(ui,{size:11}),e?"Scanning…":"Capture"]})]})]}),s.jsx(ae,{children:a&&s.jsxs(V.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},className:"px-4 py-3 bg-amber-500/8 border-b border-amber-500/15",children:[s.jsx("p",{className:"text-[11px] text-amber-400 leading-relaxed",children:a}),s.jsx("button",{onClick:()=>i(null),className:"text-[10px] text-amber-600 hover:text-amber-400 mt-1 transition-colors",children:"Dismiss"})]})}),s.jsx(ae,{children:n&&s.jsxs(V.div,{initial:{opacity:0},animate:{opacity:1},className:`relative overflow-hidden transition-all duration-300 ${o?"max-h-[500px]":"max-h-[140px]"}`,children:[s.jsx("canvas",{ref:c,className:"w-full object-contain",style:{imageRendering:"auto"}}),n.elements&&n.elements.length>0&&s.jsxs("div",{className:"absolute bottom-2 right-2 px-2 py-0.5 bg-black/70 rounded-md text-[10px] font-mono text-orange-400 border border-orange-500/20",children:[n.elements.length," elements"]})]})}),!n&&!e&&s.jsx("div",{className:"flex items-center justify-center py-8 text-gray-700 text-xs",children:"Press Capture to see what Must-b sees"}),e&&s.jsxs("div",{className:"flex items-center justify-center gap-2 py-8 text-orange-400 text-xs animate-pulse",children:[s.jsx(ui,{size:14,className:"animate-spin"}),"Scanning screen…"]})]})}const o6=4,J0=1e4;function l6(){const[e,t]=u.useState([]),n=u.useId(),r=u.useCallback(a=>{t(i=>i.filter(o=>o.id!==a))},[]);return u.useEffect(()=>{const a=pe();return a.on("projectInsight",i=>{const o={id:`${n}-${i.ts}-${Math.random().toString(36).slice(2,7)}`,message:i.message,filePath:i.filePath,ts:i.ts};t(l=>[o,...l].slice(0,o6)),setTimeout(()=>r(o.id),J0)}),()=>{a.off("projectInsight")}},[r,n]),e.length===0?null:s.jsx("div",{className:"fixed bottom-6 right-5 z-[150] flex flex-col gap-2.5 items-end",style:{maxWidth:"340px",pointerEvents:"none"},children:s.jsx(ae,{mode:"popLayout",children:e.map((a,i)=>s.jsx(V.div,{layout:!0,initial:{opacity:0,x:60,scale:.94},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:60,scale:.92},transition:{type:"spring",stiffness:340,damping:28},style:{pointerEvents:"auto",opacity:i===0?1:1-i*.12},className:"w-full",children:s.jsxs("div",{className:"rounded-2xl overflow-hidden",style:{background:"rgba(15,6,1,0.82)",border:"1px solid rgba(249,115,22,0.28)",backdropFilter:"blur(24px)",boxShadow:"0 8px 32px rgba(0,0,0,0.55), 0 0 0 1px rgba(249,115,22,0.08), inset 0 1px 0 rgba(255,255,255,0.04)"},children:[s.jsxs("div",{className:"flex items-center justify-between px-4 pt-3 pb-2",style:{borderBottom:"1px solid rgba(249,115,22,0.12)"},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"w-5 h-5 rounded-full flex items-center justify-center flex-shrink-0",style:{background:"rgba(249,115,22,0.18)",border:"1px solid rgba(249,115,22,0.30)"},children:s.jsx(mn,{size:10,className:"text-orange-400"})}),s.jsx("span",{className:"text-[11px] font-semibold text-orange-300/80 tracking-wide uppercase",children:"Must-b fısıldıyor"})]}),s.jsx("button",{onClick:()=>r(a.id),className:"text-white/25 hover:text-white/60 transition-colors",children:s.jsx(Ie,{size:12})})]}),s.jsxs("div",{className:"px-4 py-3 space-y-2",children:[s.jsx("p",{className:"text-[13px] text-white/80 leading-relaxed",children:a.message}),a.filePath&&s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx(nn,{size:10,className:"text-white/25 flex-shrink-0"}),s.jsx("span",{className:"text-[10px] font-mono text-white/35 truncate",children:a.filePath.replace(/\\/g,"/")})]})]}),s.jsx("div",{className:"h-px w-full",style:{background:"rgba(249,115,22,0.10)"},children:s.jsx(V.div,{className:"h-full",style:{background:"rgba(249,115,22,0.45)"},initial:{width:"100%"},animate:{width:"0%"},transition:{duration:J0/1e3,ease:"linear"}})})]})},a.id))})})}const c6=6e3,d6=/https?:\/\/[^\s"'>)]+/,u6=new Set(["browser_navigate","browser_click","browser_type","browser_scroll","browser_wait","browser_perceive","browser_extract","browser_snapshot","browser_screenshot","web_fetch","web-fetch","web-search"]);function h6(e){const t=e.match(d6);return t?t[0].replace(/[.,;)]+$/,""):null}function p6(e,t=52){try{const n=new URL(e),r=n.hostname.replace(/^www\./,""),a=n.pathname.length>1?n.pathname:"",i=r+a;return i.length>t?i.slice(0,t-1)+"…":i}catch{return e.length>t?e.slice(0,t-1)+"…":e}}function f6(){const[e,t]=u.useState(null),[n,r]=u.useState(!1),[a,i]=u.useState(!1),[o,l]=u.useState(null),[c,d]=u.useState(null),[h,p]=u.useState(!1),f=u.useRef(null),m=u.useRef(!1),b=u.useCallback(()=>{f.current&&clearTimeout(f.current),f.current=setTimeout(()=>{r(!1),t(null),l(null),d(null),m.current=!1},c6)},[]);return u.useEffect(()=>{const y=pe(),v=x=>{if(x.type==="shadowFrame"&&typeof x.slot!="number"||x.type==="ghostFrame"){const g=x.base64;if(!g)return;t(g),p(!1),m.current||(m.current=!0,r(!0),i(!1)),b();return}if(x.type==="shadowToggle"){!x.enabled&&typeof x.slot!="number"?(r(!1),t(null),l(null),d(null),m.current=!1,f.current&&clearTimeout(f.current)):x.enabled&&typeof x.slot!="number"&&(p(!0),r(!0),i(!1),m.current=!0);return}if(x.type==="ghostNav"){const g=x.url;g&&g!=="about:blank"&&l(g);return}if(x.type==="stepStart"){const g=x.step,w=(g==null?void 0:g.description)??"",j=(g==null?void 0:g.tool)??"";if(u6.has(j)||/navigate|click|type|browse|fetch|search/i.test(w)){const k=w.length>72?w.slice(0,71)+"…":w;d(k);const N=h6(w);N&&l(N)}return}if(x.type==="stepFinish"){d(null);return}if(x.type==="planFinish"){d(null),b();return}};return y.on("agentUpdate",v),()=>{y.off("agentUpdate",v),f.current&&clearTimeout(f.current)}},[b]),s.jsx(ae,{children:n&&s.jsx(V.div,{initial:{opacity:0,y:24,scale:.94},animate:{opacity:1,y:0,scale:1},exit:{opacity:0,y:16,scale:.92},transition:{type:"spring",stiffness:340,damping:30},className:"fixed bottom-6 left-5 z-[140] flex flex-col",style:{width:a?"auto":"320px",pointerEvents:"auto"},children:s.jsxs("div",{className:"rounded-2xl overflow-hidden flex flex-col",style:{background:"rgba(10,4,1,0.88)",border:"1px solid rgba(249,115,22,0.28)",backdropFilter:"blur(24px) saturate(180%)",boxShadow:"0 12px 40px rgba(0,0,0,0.65), 0 0 0 1px rgba(249,115,22,0.08), inset 0 1px 0 rgba(255,255,255,0.04)"},children:[s.jsxs("div",{className:"flex items-center justify-between px-3 py-2 select-none flex-shrink-0",style:{borderBottom:a?"none":"1px solid rgba(249,115,22,0.12)"},children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs("span",{className:"relative flex-shrink-0",children:[s.jsx("span",{className:"block w-2 h-2 rounded-full bg-orange-500"}),s.jsx("span",{className:"absolute inset-0 rounded-full bg-orange-500 animate-ping opacity-60"})]}),s.jsx(Ge,{size:11,className:"text-orange-400/70"}),s.jsx("span",{className:"text-[11px] font-semibold text-white/70 tracking-wide",children:"Live Browser"})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{onClick:()=>i(y=>!y),className:"w-5 h-5 rounded-full flex items-center justify-center text-white/25 hover:text-white/60 hover:bg-white/8 transition-all",title:a?"Expand":"Minimize",children:a?s.jsx(S3,{size:10}):s.jsx(_3,{size:10})}),s.jsx("button",{onClick:()=>{r(!1),m.current=!1},className:"w-5 h-5 rounded-full flex items-center justify-center text-white/25 hover:text-white/60 hover:bg-white/8 transition-all",title:"Close",children:s.jsx(Ie,{size:10})})]})]}),s.jsx(ae,{children:!a&&s.jsxs(V.div,{initial:{height:0,opacity:0},animate:{height:"auto",opacity:1},exit:{height:0,opacity:0},transition:{duration:.22},className:"overflow-hidden",children:[s.jsxs("div",{className:"relative w-full overflow-hidden",style:{aspectRatio:"16 / 10",background:"#08030100"},children:[h&&!e?s.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:s.jsx(ne,{size:20,className:"text-orange-400/50 animate-spin"})}):e?s.jsx("img",{src:`data:image/jpeg;base64,${e}`,alt:"Browser preview",className:"w-full h-full object-cover",style:{imageRendering:"auto"}}):s.jsxs("div",{className:"absolute inset-0 flex flex-col items-center justify-center gap-2",children:[s.jsx(Ge,{size:22,className:"text-orange-400/20"}),s.jsx("span",{className:"text-[11px] text-white/20",children:"Browser waiting…"})]}),e&&s.jsx("div",{className:"absolute inset-0 pointer-events-none",style:{background:"repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0,0,0,0.04) 2px, rgba(0,0,0,0.04) 4px)"}})]}),o&&s.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5",style:{borderTop:"1px solid rgba(249,115,22,0.10)"},children:[s.jsx(Ge,{size:9,className:"text-orange-400/40 flex-shrink-0"}),s.jsx("span",{className:"text-[10px] font-mono text-white/40 truncate flex-1",children:p6(o)})]}),s.jsx(ae,{children:c&&s.jsxs(V.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.18},className:"px-3 py-2 flex items-start gap-2",style:{borderTop:"1px solid rgba(249,115,22,0.08)"},children:[s.jsx("div",{className:"flex items-center gap-0.5 mt-1 flex-shrink-0",children:[0,1,2].map(y=>s.jsx("span",{className:"block w-1 h-1 rounded-full bg-orange-400/60 animate-bounce",style:{animationDelay:`${y*.15}s`}},y))}),s.jsx("p",{className:"text-[10.5px] text-white/50 leading-snug line-clamp-2",children:c})]},"action-bar")})]},"pip-content")})]})},"live-browser-pip")})}function m6({url:e}){const[t,n]=u.useState(!1),r=u.useCallback(()=>{navigator.clipboard.writeText(e).then(()=>{n(!0),setTimeout(()=>n(!1),2e3)}).catch(()=>{})},[e]);return s.jsxs("button",{onClick:r,title:"Copy login URL to clipboard",className:`flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-[11px] font-semibold
|
|
842
842
|
transition-all duration-150 shrink-0
|
package/dist/public/index.html
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<meta property="og:type" content="website" />
|
|
12
12
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
13
13
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
14
|
-
<script type="module" crossorigin src="/assets/index-
|
|
14
|
+
<script type="module" crossorigin src="/assets/index-CJIStJI4.js"></script>
|
|
15
15
|
<link rel="stylesheet" crossorigin href="/assets/index-DHxSGn6Q.css">
|
|
16
16
|
</head>
|
|
17
17
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@must-b/must-b",
|
|
3
|
-
"version": "1.74.
|
|
3
|
+
"version": "1.74.45",
|
|
4
4
|
"description": "Must-b v1.74.37 — UX & CONNECTIVITY OVERHAUL: Resolve OpenRouter 405 error, implement dependent dropdown selects for traditional brokers, design robust multi-account state structures, and harden Ollama & Binance connections.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"author": "Must-b Inc.",
|