Created At: 2026-11-18T18:21:04Z Completed At: 2026-11-18T18:21:08Z Command exited with code 0. Command output: /root/telegram-saas/apps/frontend/src/components/modules/ModuleConfigModal.tsx:96: const res = await fetch(`/api/v1/bots/${botId}/modules/verify-admin`, { /root/telegram-saas/apps/frontend/dist/assets/index-CEpsTWNI.js:105:Tap below to configure customized price notifications:`}},Kl=[{id:"node-1",type:"trigger",label:"Telegram Inbound Message",subtitle:"Event: message:text",config:{event:"message:text",parse_commands:!0},status:"idle"},{id:"node-2",type:"ai_agent",label:"LLM Intent & Context Analyzer",subtitle:"Model: gpt-4o-mini",config:{model:"gpt-4o-mini",temperature:.3,system_prompt:"Analyze user intent and choose appropriate resolution or tools."},status:"idle"},{id:"node-3",type:"mcp_tool",label:"MCP Protocol Tool Router",subtitle:"Tools: message.send, analytics.report",config:{tools:["message.send","analytics.report"],enforce_approval:!0},status:"idle"},{id:"node-4",type:"channel_action",label:"Telegram HTML Message Dispatch",subtitle:"Parse Mode: HTML with Inline Buttons",config:{channel:"telegram",parse_mode:"HTML",enable_keyboard:!0},status:"idle"}],Ql=()=>{const{currentBot:t}=W(),[s,n]=i.useState("synthesizer"),[a,l]=i.useState(""),[r,o]=i.useState(!1),[j,f]=i.useState(""),[m,x]=i.useState(it.support),[u,g]=i.useState(!1),[b,h]=i.useState(Kl),[d,c]=i.useState("node-2"),[N,p]=i.useState(!1),[w,k]=i.useState([]),P=()=>{a.trim()&&(o(!0),g(!1),f("Analyzing intent & classifying blueprint..."),setTimeout(()=>{f("Selecting core modules & permissions..."),setTimeout(()=>{f("Binding MCP protocol tools & policies..."),setTimeout(()=>{f("Synthesizing persona prompt & Unicode preview..."),setTimeout(()=>{const S=a.toLowerCase();S.includes("shop")||S.includes("store")||S.includes("cart")||S.includes("product")?x(it.ecommerce):S.includes("crypto")||S.includes("price")||S.includes("alert")||S.includes("btc")?x(it.crypto):x(it.support),o(!1),f("")},400)},400)},400)},400))},v=()=>{g(!0)},y=()=>{p(!0),k([]),h(S=>S.map(L=>({...L,status:"running",latency_ms:void 0}))),setTimeout(()=>{h(S=>S.map(L=>L.id==="node-1"?{...L,status:"success",latency_ms:12.3}:L)),setTimeout(()=>{h(S=>S.map(L=>L.id==="node-2"?{...L,status:"success",latency_ms:245.8}:L)),setTimeout(()=>{h(S=>S.map(L=>L.id==="node-3"?{...L,status:"success",latency_ms:38.4}:L)),setTimeout(()=>{h(S=>S.map(L=>L.id==="node-4"?{...L,status:"success",latency_ms:18.2}:L)),p(!1),k([{step:"1. Inbound Trigger",output:'Captured user message: "Verify transaction #88921"'},{step:"2. AI Agent Reasoning",output:"Extracted order intent; querying payment ledger."},{step:"3. MCP Tools Invoked",output:"analytics.report executed; message.send prepared."},{step:"4. Telegram Dispatched",output:"Delivered HTML message with receipt inline keyboard."}])},350)},350)},350)},350)},A=b.find(S=>S.id===d);return e.jsxs("div",{className:"space-y-8 animate-fadeIn min-w-0 max-w-full",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 pb-6 border-b border-white/10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#2481CC] animate-pulse"}),e.jsx("span",{className:"text-[11px] font-mono tracking-wider text-[#2481CC] uppercase font-semibold",children:"No-Code Bot Flow & Automation Studio"})]}),e.jsxs("h1",{className:"text-2xl sm:text-3xl font-bold text-pearl-50 tracking-tight flex items-center gap-3",children:[e.jsx(Ya,{className:"w-6 h-6 sm:w-7 sm:h-7 text-[#2481CC] shrink-0"}),e.jsx("span",{children:"Bot Builder & Automation Studio"})]}),e.jsx("p",{className:"text-xs sm:text-sm text-pearl-300 font-normal mt-1 max-w-2xl",children:"Build custom Telegram bots with natural language AI prompts or visually design multi-step message flows and cloud triggers — 24/7 cloud execution ready."})]}),e.jsxs("div",{className:"flex items-center p-1 rounded-xl bg-space-900 border border-white/10 w-full md:w-auto shrink-0",children:[e.jsxs("button",{onClick:()=>n("synthesizer"),className:`flex-1 md:flex-none justify-center px-3 sm:px-4 py-2 text-xs font-mono tracking-wider uppercase rounded-lg transition-all flex items-center gap-2 ${s==="synthesizer"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-200"}`,children:[e.jsx(Y,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"AI Synthesizer"})]}),e.jsxs("button",{onClick:()=>n("canvas"),className:`flex-1 md:flex-none justify-center px-3 sm:px-4 py-2 text-xs font-mono tracking-wider uppercase rounded-lg transition-all flex items-center gap-2 ${s==="canvas"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-200"}`,children:[e.jsx(ys,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Canvas"})]})]})]}),e.jsxs("div",{className:"bg-[#2481CC]/10 border border-[#2481CC]/30 rounded-xl p-3 sm:p-4 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#2481CC]/20 border border-[#2481CC]/40 flex items-center justify-center text-xl shrink-0",children:"🪄"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-[#2481CC]/20 text-[#2481CC] font-bold",children:"Flow Workspace"}),e.jsx("span",{className:"text-sm font-bold text-pearl-100",children:t.name}),e.jsxs("span",{className:"text-xs text-[#2481CC]",children:["@",t.username]})]}),e.jsxs("p",{className:"text-xs text-pearl-400 mt-0.5",children:["Flow topologies and AI prompt architectures deployed here run directly on the cloud worker of @",t.username,"."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-pearl-300 bg-white/5 px-3 py-1.5 rounded-lg border border-white/10 shrink-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{children:"Cloud Flow Runner: Online"})]})]}),s==="synthesizer"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"p-6 rounded-2xl astraea-card relative overflow-hidden space-y-4",children:[e.jsxs("div",{className:"flex flex-col md:flex-row gap-3",children:[e.jsx("div",{className:"relative flex-1",children:e.jsx("input",{type:"text",placeholder:"Describe your desired bot in English or Hinglish (e.g. 'Customer support ticket bot with human escalation and Razorpay integration')...",value:a,onChange:S=>l(S.target.value),onKeyDown:S=>S.key==="Enter"&&P(),className:"w-full bg-space-950/80 border border-[#2481CC]/30 rounded-xl px-4 py-3.5 text-sm font-light text-pearl-100 placeholder:text-pearl-500 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC] transition-all shadow-inner"})}),e.jsxs("button",{onClick:P,disabled:r||!a.trim(),className:"btn-telegram-primary px-6 py-3.5 disabled:opacity-50 text-xs uppercase tracking-wider font-bold rounded-xl shadow-telegram transition-all flex items-center justify-center gap-2",children:[e.jsx(Y,{className:"w-4 h-4"}),r?"Synthesizing...":"Synthesize Bot"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 pt-2",children:[e.jsx("span",{className:"text-[11px] font-mono text-pearl-500 font-semibold",children:"Try Ideas:"}),[{label:"Customer Support Desk",text:"AI customer support desk with ticketing and human escalation"},{label:"Digital Store & Checkout",text:"E-commerce digital store with cart checkout and Razorpay payments"},{label:"Crypto Sentinel",text:"Crypto price tracker with live alerts and Binance MCP tools"}].map(S=>e.jsx("button",{onClick:()=>{l(S.text)},className:"px-2.5 py-1 text-[11px] font-mono bg-white/5 hover:bg-[#2481CC]/15 text-pearl-300 hover:text-[#2481CC] rounded-lg border border-white/10 transition-colors",children:S.label},S.label))]}),r&&e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/90 border border-[#2481CC]/40 flex items-center gap-3 animate-pulse",children:[e.jsx("div",{className:"w-4 h-4 rounded-full border-2 border-[#2481CC] border-t-transparent animate-spin"}),e.jsx("span",{className:"text-xs font-mono text-[#2481CC] tracking-wider font-semibold",children:j})]})]}),m&&!r&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-12 gap-6",children:[e.jsx("div",{className:"lg:col-span-7 space-y-6",children:e.jsxs("div",{className:"p-6 rounded-2xl astraea-card space-y-5",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-mono tracking-wider text-[#2481CC] uppercase font-semibold",children:m.category}),e.jsx("h3",{className:"text-xl font-bold text-pearl-50 tracking-tight",children:m.bot_name}),e.jsx("p",{className:"text-xs text-pearl-300 font-light mt-1",children:m.headline})]}),e.jsx("span",{className:"px-2.5 py-1 rounded-full text-[10px] font-mono font-semibold bg-emerald-500/20 text-emerald-300 border border-emerald-500/30",children:"SYNTHESIS READY"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[11px] font-mono uppercase text-pearl-400 font-semibold",children:["Synthesized Core Modules (",m.selected_modules.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:m.selected_modules.map(S=>e.jsxs("span",{className:"px-2.5 py-1 rounded-lg text-xs font-mono bg-space-950 border border-white/10 text-pearl-200",children:["📦 ",S]},S))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"text-[11px] font-mono uppercase text-pearl-400 font-semibold",children:["Assigned MCP Protocol Tools (",m.selected_mcp_tools.length,")"]}),e.jsx("div",{className:"flex flex-wrap gap-2",children:m.selected_mcp_tools.map(S=>e.jsxs("span",{className:"px-2.5 py-1 rounded-lg text-xs font-mono bg-[#2481CC]/10 border border-[#2481CC]/30 text-[#2481CC] font-semibold",children:["⚡ ",S]},S))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[11px] font-mono uppercase text-pearl-400 font-semibold",children:"Synthesized Persona System Prompt"}),e.jsx("textarea",{rows:4,value:m.system_prompt,onChange:S=>x({...m,system_prompt:S.target.value}),className:"w-full bg-space-950/80 border border-white/10 rounded-xl p-3 text-xs font-mono text-pearl-200 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]"})]}),e.jsxs("div",{className:"pt-4 border-t border-white/10 flex items-center justify-between",children:[e.jsxs("div",{className:"text-xs font-mono text-pearl-400",children:["Cloud Runtime: ",e.jsx("span",{className:"text-emerald-400 font-semibold",children:"24/7 Managed Celery Pool"})]}),e.jsx("button",{onClick:v,disabled:u,className:`px-5 py-2.5 rounded-xl text-xs font-mono uppercase tracking-wider font-bold transition-all flex items-center gap-2 ${u?"bg-emerald-500 text-white":"btn-telegram-primary shadow-telegram"}`,children:u?e.jsxs(e.Fragment,{children:[e.jsx($,{className:"w-4 h-4"}),"Deployed to 24/7 Cloud!"]}):e.jsxs(e.Fragment,{children:[e.jsx(ut,{className:"w-4 h-4"}),"Deploy to 24/7 Cloud"]})})]}),u&&e.jsxs("div",{className:"p-4 rounded-lg bg-emerald-500/10 border border-emerald-500/30 text-xs font-mono text-emerald-300 space-y-1",children:[e.jsxs("div",{className:"font-semibold flex items-center gap-2",children:[e.jsx(F,{className:"w-4 h-4 text-emerald-400"}),"Bot Container Successfully Provisioned"]}),e.jsx("p",{className:"text-[11px] text-pearl-300",children:"Webhook registered on Telegram API. Auto-recovery and deduplication active."})]})]})}),e.jsx("div",{className:"lg:col-span-5 space-y-4",children:e.jsxs("div",{className:"p-6 rounded-xl bg-space-900/60 border border-white/10 backdrop-blur-xl space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 pb-3",children:[e.jsxs("span",{className:"text-xs font-mono uppercase text-[#2481CC] flex items-center gap-2 font-semibold",children:[e.jsx(Q,{className:"w-4 h-4"}),"Live Telegram Preview"]}),e.jsx("span",{className:"text-[10px] font-mono text-pearl-400",children:"HTML Parse Mode"})]}),e.jsxs("div",{className:"bg-[#182533] p-4 rounded-2xl border border-white/10 shadow-2xl space-y-3 font-sans max-w-sm mx-auto",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[11px] text-[#6ab2f2] font-semibold",children:[e.jsx("span",{children:m.bot_name}),e.jsx("span",{className:"text-[9px] px-1 rounded bg-[#2b5278] text-white",children:"BOT"})]}),e.jsx("pre",{className:"text-xs text-[#f5f5f5] font-mono whitespace-pre-wrap leading-relaxed",dangerouslySetInnerHTML:{__html:m.preview_text}}),e.jsxs("div",{className:"space-y-1.5 pt-2",children:[e.jsx("div",{className:"w-full py-2 bg-[#2b5278] hover:bg-[#346595] text-white text-xs font-medium rounded-lg text-center transition-colors",children:"🚀 Start Interactive Session"}),e.jsx("div",{className:"w-full py-2 bg-[#2b5278] hover:bg-[#346595] text-white text-xs font-medium rounded-lg text-center transition-colors",children:"💬 Speak to Human Manager"})]}),e.jsx("div",{className:"text-right text-[10px] text-[#6c7883]",children:"12:00 PM ✓✓"})]})]})})]})]}),s==="canvas"&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between p-4 rounded-xl astraea-card",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-xs font-mono uppercase text-pearl-400 font-medium",children:["Pipeline Graph: ",e.jsx("span",{className:"text-[#2481CC] font-bold",children:"4 Connected Nodes"})]}),e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400"})]}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("button",{onClick:y,disabled:N,className:"btn-telegram-primary px-4 py-2 text-xs font-mono uppercase tracking-wider font-bold rounded-lg shadow-telegram transition-all flex items-center gap-2",children:[e.jsx($e,{className:"w-3.5 h-3.5"}),N?"Executing Graph...":"Test Run Flow"]})})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 relative",children:b.map((S,L)=>{const M=d===S.id;return e.jsxs("div",{onClick:()=>c(S.id),className:`p-5 rounded-xl transition-all cursor-pointer relative space-y-3 ${M?"bg-space-900 border-2 border-[#2481CC] shadow-telegram":"bg-space-900/70 border border-white/10 hover:border-white/25"}`,children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("span",{className:"text-[10px] font-mono uppercase tracking-wider text-[#2481CC] font-bold",children:["Step ",L+1]}),S.status==="running"&&e.jsx("div",{className:"w-3.5 h-3.5 rounded-full border-2 border-[#2481CC] border-t-transparent animate-spin"}),S.status==="success"&&e.jsxs("span",{className:"text-[10px] font-mono text-emerald-400 flex items-center gap-1 font-semibold",children:[e.jsx(F,{className:"w-3 h-3"}),S.latency_ms,"ms"]}),S.status==="idle"&&e.jsx("span",{className:"w-2 h-2 rounded-full bg-white/20"})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"font-mono text-sm text-pearl-100 font-semibold",children:S.label}),e.jsx("p",{className:"text-xs text-pearl-400 font-mono mt-0.5",children:S.subtitle})]}),e.jsxs("div",{className:"text-[10px] font-mono px-2 py-1 rounded-lg bg-space-950 border border-white/5 text-pearl-300",children:["Type: ",S.type]}),L{const L=S.target.value;h(M=>M.map(O=>O.id===A.id?{...O,label:L}:O))},className:"w-full bg-space-950 border border-white/10 rounded-xl px-3 py-2 text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-pearl-400 block mb-1 font-medium",children:"Configuration Parameters (JSON)"}),e.jsx("pre",{className:"p-3 rounded-xl bg-space-950 border border-white/5 text-pearl-300 text-[11px] overflow-x-auto",children:JSON.stringify(A.config,null,2)})]})]})]}),e.jsxs("div",{className:"lg:col-span-6 p-6 rounded-2xl astraea-card space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-white/10 pb-3",children:[e.jsxs("h4",{className:"text-base font-bold text-pearl-50 tracking-tight flex items-center gap-2",children:[e.jsx(Ie,{className:"w-4 h-4 text-emerald-400"}),"Execution Trace & Telemetry"]}),e.jsx("span",{className:"text-xs font-mono text-pearl-400",children:w.length>0?"4/4 Completed":"Waiting for Run"})]}),w.length===0?e.jsx("div",{className:"p-8 text-center text-xs font-mono text-pearl-500",children:'Click "Test Run Flow" above to simulate deterministic graph execution across all 4 nodes.'}):e.jsx("div",{className:"space-y-3 font-mono text-xs",children:w.map((S,L)=>e.jsxs("div",{className:"p-3 rounded-xl bg-space-950/80 border border-white/5 space-y-1",children:[e.jsx("div",{className:"text-[#2481CC] font-bold text-[11px]",children:S.step}),e.jsx("div",{className:"text-pearl-300 text-[11px]",children:S.output})]},L))})]})]})]})]})},Zl=[{name:"bot.list",description:"Lists all Telegram bots registered under tenant account with operational status.",category:"Bot Fleet",is_dangerous:!1,requires_approval:!1,is_enabled:!0,input_schema:{status:"all | active | paused"}},{name:"bot.status",description:"Checks health, webhook sync status, and Telegram getMe profile for a specific bot.",category:"Bot Fleet",is_dangerous:!1,requires_approval:!1,is_enabled:!0,input_schema:{bot_id:"uuid",check_telegram:"boolean"}},{name:"marketplace.list",description:"Browses 25 ready-made bot blueprints and modules in the universal marketplace catalog.",category:"Marketplace",is_dangerous:!1,requires_approval:!1,is_enabled:!0,input_schema:{category:"all | business | community | ai_specialist"}},{name:"marketplace.install",description:"Installs a ready-made bot blueprint and configures 24/7 cloud instance provisioning.",category:"Marketplace",is_dangerous:!0,requires_approval:!0,is_enabled:!0,input_schema:{template_id:"string",bot_name:"string"}},{name:"message.send",description:"Dispatches high-priority message or broadcast via Telegram Bot API with retry backoff.",category:"Messaging",is_dangerous:!0,requires_approval:!0,is_enabled:!0,input_schema:{bot_id:"uuid",chat_id:"string",text:"string",parse_mode:"HTML"}},{name:"analytics.report",description:"Retrieves platform telemetry, active subscribers, and operational KPIs for the tenant.",category:"Analytics",is_dangerous:!1,requires_approval:!1,is_enabled:!0,input_schema:{period:"today | 7d | 30d"}}],Xl=[{id:"srv-1",name:"GitHub DevOps MCP Server",transport_type:"sse",endpoint_url:"https://mcp-hub.internal.net/github/sse",status:"online",discovered_tools:14,last_synced_at:"2 mins ago"},{id:"srv-2",name:"PostgreSQL Enterprise Explorer",transport_type:"stdio",endpoint_url:"npx -y @modelcontextprotocol/server-postgres",status:"online",discovered_tools:6,last_synced_at:"10 mins ago"},{id:"srv-3",name:"Stripe & Billing Gateway Tools",transport_type:"http",endpoint_url:"https://api.billing-mcp.internal/tools",status:"online",discovered_tools:8,last_synced_at:"1 hour ago"}],ei=[{id:"exec-901",tool_name:"message.send",caller:"Cursor AI Assistant",requested_at:"Just now",arguments:{bot_id:"b-001",chat_id:"99281726",text:"Urgent: VIP subscription plan renewed automatically.",parse_mode:"HTML"},risk_level:"high"},{id:"exec-902",tool_name:"marketplace.install",caller:"Claude Desktop Agent",requested_at:"3 mins ago",arguments:{template_id:"bot_customer_support",bot_name:"Astraea Automated Support Desk"},risk_level:"high"}],ti=[{id:"log-101",tool_name:"bot.list",status:"completed",caller:"Claude Desktop",duration_ms:18.4,timestamp:"12:04:12 PM",result:{total_bots:4,active:4,paused:0}},{id:"log-102",tool_name:"analytics.report",status:"completed",caller:"Cursor AI",duration_ms:32.1,timestamp:"11:58:45 AM",result:{period:"7d",total_active_bots:4,uptime_percentage:99.98}},{id:"log-103",tool_name:"message.send",status:"approved",caller:"Autonomous Agent #2",duration_ms:145.8,timestamp:"11:42:01 AM",result:{status:"sent",message_id:"msg_98124"}},{id:"log-104",tool_name:"marketplace.install",status:"rejected",caller:"External Script",duration_ms:4.2,timestamp:"10:15:30 AM",result:{reason:"Admin rejected dangerous deployment without approval token"}}],si=()=>{const{currentBot:t}=W(),[s,n]=i.useState("tools"),[a,l]=i.useState(Zl),[r,o]=i.useState(Xl),[j,f]=i.useState(ei),[m,x]=i.useState(ti),[u,g]=i.useState(null),[b,h]=i.useState(null),[d,c]=i.useState(!1),[N,p]=i.useState(""),[w,k]=i.useState(""),[P,v]=i.useState("sse"),y=(I,U)=>{navigator.clipboard.writeText(I),g(U),setTimeout(()=>g(null),2e3)},A=()=>{h("Testing handshake..."),setTimeout(()=>{h("JSON-RPC 2.0 handshake verified (latency: 14ms)"),setTimeout(()=>h(null),4e3)},400)},S=I=>{l(U=>U.map(D=>D.name===I?{...D,requires_approval:!D.requires_approval}:D))},L=I=>{l(U=>U.map(D=>D.name===I?{...D,is_enabled:!D.is_enabled}:D))},M=I=>{const U=j.find(D=>D.id===I);U&&(f(D=>D.filter(le=>le.id!==I)),x(D=>[{id:`log-${Date.now()}`,tool_name:U.tool_name,status:"approved",caller:U.caller,duration_ms:124.5,timestamp:new Date().toLocaleTimeString(),result:{status:"executed_with_human_approval",id:I}},...D]))},O=I=>{const U=j.find(D=>D.id===I);U&&(f(D=>D.filter(le=>le.id!==I)),x(D=>[{id:`log-${Date.now()}`,tool_name:U.tool_name,status:"rejected",caller:U.caller,duration_ms:6.1,timestamp:new Date().toLocaleTimeString(),result:{reason:"Admin manually rejected approval gate"}},...D]))},E=()=>{if(!N||!w)return;const I={id:`srv-${Date.now()}`,name:N,transport_type:P,endpoint_url:w,status:"online",discovered_tools:5,last_synced_at:"Just now"};o(U=>[I,...U]),c(!1),p(""),k("")},K=JSON.stringify({mcpServers:{"astraea-bot-cloud":{url:"https://api.yourdomain.com/api/v1/mcp/rpc",headers:{Authorization:"Bearer "}}}},null,2),ee=JSON.stringify({servers:[{name:"astraea-bot-cloud",url:"https://api.yourdomain.com/api/v1/mcp/rpc",type:"sse"}]},null,2);return e.jsxs("div",{className:"space-y-6 sm:space-y-8 animate-fadeIn w-full max-w-full min-w-0",children:[e.jsxs("div",{className:"flex flex-col md:flex-row md:items-center justify-between gap-4 pb-6 border-b border-white/10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-[10px] font-mono tracking-wider text-[#2481CC] uppercase font-semibold",children:"Model Context Protocol Pro"})]}),e.jsxs("h1",{className:"text-2xl sm:text-3xl md:text-4xl text-pearl-50 font-bold tracking-tight flex items-center gap-2 sm:gap-3",children:[e.jsx(fe,{className:"w-6 h-6 sm:w-8 sm:h-8 text-[#2481CC] shrink-0"}),e.jsx("span",{children:"MCP Pro Protocol Cloud"})]}),e.jsx("p",{className:"text-xs sm:text-sm text-pearl-300 font-light mt-1 max-w-2xl",children:"Connect external AI clients (Claude Desktop, Cursor, Local LLMs) to your Telegram Bot Cloud via JSON-RPC 2.0 with granular human approval gates."})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2 sm:gap-3 w-full md:w-auto shrink-0",children:[e.jsxs("button",{onClick:A,className:"btn-telegram-secondary px-4 py-2 text-xs font-mono tracking-wider uppercase rounded-xl transition-all flex items-center justify-center gap-2",children:[e.jsx(Ge,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:b||"Ping JSON-RPC"})]}),e.jsxs("button",{onClick:()=>c(!0),className:"btn-telegram-primary px-4 py-2 text-xs font-mono tracking-wider uppercase font-semibold rounded-xl shadow-telegram transition-all flex items-center justify-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4"}),e.jsx("span",{children:"Connect MCP Server"})]})]})]}),e.jsxs("div",{className:"bg-[#2481CC]/10 border border-[#2481CC]/30 rounded-xl p-3 sm:p-4 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#2481CC]/20 border border-[#2481CC]/40 flex items-center justify-center text-xl shrink-0",children:"⚡"}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono uppercase px-1.5 py-0.5 rounded bg-[#2481CC]/20 text-[#2481CC] font-bold",children:"MCP Target Bot"}),e.jsx("span",{className:"text-sm font-bold text-pearl-100",children:t.name}),e.jsxs("span",{className:"text-xs text-[#2481CC]",children:["@",t.username]})]}),e.jsxs("p",{className:"text-xs text-pearl-400 mt-0.5",children:["MCP tool calls (such as message dispatch and user queries) authenticate against @",t.username," credentials and permissions."]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 text-xs font-mono text-pearl-300 bg-white/5 px-3 py-1.5 rounded-lg border border-white/10 shrink-0",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{children:"JSON-RPC Gateway: Ready"})]})]}),e.jsxs("div",{className:"p-4 sm:p-6 rounded-2xl astraea-card relative overflow-hidden w-full max-w-full min-w-0",children:[e.jsx("div",{className:"absolute top-0 right-0 w-80 h-80 bg-[#2481CC]/5 rounded-full blur-3xl pointer-events-none"}),e.jsxs("div",{className:"flex flex-col lg:flex-row items-start lg:items-center justify-between gap-4 sm:gap-6",children:[e.jsxs("div",{className:"space-y-2 max-w-xl min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/30 font-semibold",children:"JSON-RPC 2.0"}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono bg-emerald-500/20 text-emerald-300 border border-emerald-500/30 font-semibold",children:"AES-256 ISOLATED"})]}),e.jsx("h3",{className:"text-base sm:text-lg font-bold text-pearl-50 tracking-tight",children:"Platform MCP Server Endpoint"}),e.jsx("p",{className:"text-xs text-pearl-300 font-mono break-all bg-space-950/80 px-3 py-2 rounded-xl border border-white/5",children:"POST https://api.yourdomain.com/api/v1/mcp/rpc"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row items-stretch sm:items-center gap-2 sm:gap-3 w-full lg:w-auto shrink-0",children:[e.jsxs("button",{onClick:()=>y(K,"claude"),className:"px-3 py-2 text-xs font-mono bg-space-800/80 hover:bg-space-800 border border-white/10 rounded-xl text-pearl-200 transition-all flex items-center justify-center gap-2",children:[u==="claude"?e.jsx(F,{className:"w-3.5 h-3.5 text-emerald-400"}):e.jsx(Qe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Claude Desktop Config"})]}),e.jsxs("button",{onClick:()=>y(ee,"cursor"),className:"px-3 py-2 text-xs font-mono bg-space-800/80 hover:bg-space-800 border border-white/10 rounded-xl text-pearl-200 transition-all flex items-center justify-center gap-2",children:[u==="cursor"?e.jsx(F,{className:"w-3.5 h-3.5 text-emerald-400"}):e.jsx(Qe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Cursor .cursor/mcp.json"})]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 border-b border-white/10 pb-2 overflow-x-auto w-full max-w-full scrollbar-none",children:[e.jsxs("button",{onClick:()=>n("tools"),className:`px-3.5 sm:px-4 py-2 text-xs font-mono tracking-wider uppercase rounded-xl transition-all flex items-center gap-2 shrink-0 whitespace-nowrap ${s==="tools"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-200 hover:bg-white/5"}`,children:[e.jsx(Pe,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Platform Tools (",a.length,")"]})]}),e.jsxs("button",{onClick:()=>n("servers"),className:`px-3.5 sm:px-4 py-2 text-xs font-mono tracking-wider uppercase rounded-xl transition-all flex items-center gap-2 shrink-0 whitespace-nowrap ${s==="servers"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-200 hover:bg-white/5"}`,children:[e.jsx(ut,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["External MCP Servers (",r.length,")"]})]}),e.jsxs("button",{onClick:()=>n("approvals"),className:`px-3.5 sm:px-4 py-2 text-xs font-mono tracking-wider uppercase rounded-xl transition-all flex items-center gap-2 relative shrink-0 whitespace-nowrap ${s==="approvals"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-200 hover:bg-white/5"}`,children:[e.jsx(Ps,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Human Approval Queue"}),j.length>0&&e.jsx("span",{className:"w-4 h-4 rounded-full bg-amber-500 text-[9px] text-space-950 font-bold flex items-center justify-center ml-1",children:j.length})]}),e.jsxs("button",{onClick:()=>n("logs"),className:`px-3.5 sm:px-4 py-2 text-xs font-mono tracking-wider uppercase rounded-xl transition-all flex items-center gap-2 shrink-0 whitespace-nowrap ${s==="logs"?"bg-[#2481CC] text-white font-bold shadow-sm":"text-pearl-400 hover:text-pearl-200 hover:bg-white/5"}`,children:[e.jsx(Ls,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Execution Logs"})]})]}),s==="tools"&&e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:a.map(I=>e.jsxs("div",{className:"p-5 rounded-2xl astraea-card hover:border-[#2481CC]/40 transition-all space-y-3 group",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-[10px] font-mono tracking-wider text-[#2481CC] uppercase font-semibold",children:I.category}),e.jsx("h4",{className:"font-mono font-bold text-pearl-100 text-sm group-hover:text-[#2481CC] transition-colors",children:I.name})]}),I.is_dangerous&&e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-mono bg-amber-500/20 text-amber-300 border border-amber-500/30 flex items-center gap-1 font-semibold",children:[e.jsx(Ze,{className:"w-2.5 h-2.5"}),"CRITICAL"]})]}),e.jsx("p",{className:"text-xs text-pearl-300 line-clamp-2",children:I.description}),e.jsxs("div",{className:"bg-space-950/70 p-2.5 rounded-xl border border-white/5 text-[11px] font-mono text-pearl-400 overflow-x-auto",children:[e.jsx("div",{className:"text-[9px] uppercase tracking-wider text-pearl-500 mb-1 font-semibold",children:"Input Schema"}),e.jsx("pre",{children:JSON.stringify(I.input_schema,null,2)})]}),e.jsxs("div",{className:"pt-2 border-t border-white/10 flex items-center justify-between text-xs font-mono",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer select-none",children:[e.jsx("input",{type:"checkbox",checked:I.requires_approval,onChange:()=>S(I.name),className:"rounded border-white/20 bg-space-950 text-[#2481CC] focus:ring-0"}),e.jsx("span",{className:I.requires_approval?"text-[#2481CC] font-semibold":"text-pearl-400",children:"Requires Human Approval"})]}),e.jsx("button",{onClick:()=>L(I.name),className:`px-2.5 py-1 rounded-full text-[10px] font-mono font-semibold ${I.is_enabled?"bg-emerald-500/20 text-emerald-300 border border-emerald-500/30":"bg-rose-500/20 text-rose-300 border border-rose-500/30"}`,children:I.is_enabled?"ENABLED":"DISABLED"})]})]},I.name))})}),s==="servers"&&e.jsx("div",{className:"space-y-4",children:e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4",children:r.map(I=>e.jsxs("div",{className:"p-5 rounded-2xl astraea-card hover:border-[#2481CC]/30 transition-all space-y-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-base font-bold text-pearl-100 tracking-tight",children:I.name}),e.jsxs("span",{className:"text-[10px] font-mono uppercase text-[#2481CC] font-semibold",children:["Transport: ",I.transport_type.toUpperCase()]})]}),e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono bg-emerald-500/20 text-emerald-300 border border-emerald-500/30 flex items-center gap-1 font-semibold",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),"ONLINE"]})]}),e.jsx("div",{className:"text-xs font-mono text-pearl-300 bg-space-950/60 p-2 rounded-xl border border-white/5 break-all",children:I.endpoint_url}),e.jsxs("div",{className:"flex items-center justify-between pt-2 border-t border-white/10 text-xs font-mono text-pearl-400",children:[e.jsxs("span",{children:[I.discovered_tools," Tools Discovered"]}),e.jsxs("span",{children:["Synced ",I.last_synced_at]})]})]},I.id))})}),s==="approvals"&&e.jsx("div",{className:"space-y-4",children:j.length===0?e.jsxs("div",{className:"p-12 text-center rounded-2xl astraea-card",children:[e.jsx($,{className:"w-12 h-12 text-emerald-400 mx-auto mb-3 opacity-80"}),e.jsx("h3",{className:"text-lg font-bold text-pearl-100 tracking-tight",children:"No Pending Approvals"}),e.jsx("p",{className:"text-xs text-pearl-400 font-mono mt-1",children:"All external tool requests have been authorized or resolved."})]}):e.jsx("div",{className:"space-y-3",children:j.map(I=>e.jsxs("div",{className:"p-5 rounded-2xl astraea-card border-amber-500/30 flex flex-col md:flex-row md:items-center justify-between gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono bg-amber-500/20 text-amber-300 border border-amber-500/30 flex items-center gap-1 font-semibold",children:[e.jsx(Ze,{className:"w-3 h-3"}),"REQUIRES APPROVAL"]}),e.jsxs("span",{className:"text-xs font-mono text-pearl-400",children:["from ",I.caller]}),e.jsxs("span",{className:"text-xs font-mono text-pearl-500",children:["• ",I.requested_at]})]}),e.jsx("h4",{className:"font-mono text-sm text-pearl-100 font-semibold",children:I.tool_name}),e.jsx("pre",{className:"text-[11px] font-mono bg-space-950 p-2 rounded-xl border border-white/10 text-pearl-300 max-w-xl overflow-x-auto",children:JSON.stringify(I.arguments,null,2)})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("button",{onClick:()=>O(I.id),className:"px-4 py-2 rounded-xl text-xs font-mono uppercase bg-rose-500/20 text-rose-300 hover:bg-rose-500/30 border border-rose-500/40 transition-all flex items-center gap-1.5 font-semibold",children:[e.jsx(Bs,{className:"w-3.5 h-3.5"}),"Reject"]}),e.jsxs("button",{onClick:()=>M(I.id),className:"px-4 py-2 rounded-xl text-xs font-mono uppercase bg-emerald-500 text-space-950 hover:bg-emerald-400 font-bold shadow-sm transition-all flex items-center gap-1.5",children:[e.jsx($,{className:"w-3.5 h-3.5"}),"Authorize & Run"]})]})]},I.id))})}),s==="logs"&&e.jsx("div",{className:"p-4 rounded-2xl astraea-card overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left text-xs font-mono",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b border-white/10 text-pearl-400 font-semibold",children:[e.jsx("th",{className:"p-3",children:"TOOL"}),e.jsx("th",{className:"p-3",children:"STATUS"}),e.jsx("th",{className:"p-3",children:"CALLER"}),e.jsx("th",{className:"p-3",children:"LATENCY"}),e.jsx("th",{className:"p-3",children:"TIME"}),e.jsx("th",{className:"p-3",children:"RESULT"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:m.map(I=>e.jsxs("tr",{className:"hover:bg-white/[0.02]",children:[e.jsx("td",{className:"p-3 font-semibold text-pearl-100",children:I.tool_name}),e.jsx("td",{className:"p-3",children:e.jsx("span",{className:`px-2 py-0.5 rounded-full text-[10px] font-semibold ${I.status==="completed"||I.status==="approved"?"bg-emerald-500/20 text-emerald-300 border border-emerald-500/30":"bg-rose-500/20 text-rose-300 border border-rose-500/30"}`,children:I.status.toUpperCase()})}),e.jsx("td",{className:"p-3 text-pearl-300",children:I.caller}),e.jsxs("td",{className:"p-3 text-pearl-400",children:[I.duration_ms," ms"]}),e.jsx("td",{className:"p-3 text-pearl-400",children:I.timestamp}),e.jsx("td",{className:"p-3 text-pearl-300 max-w-xs truncate",children:JSON.stringify(I.result)})]},I.id))})]})}),d&&e.jsx(se,{children:e.jsx("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-md flex items-center justify-center p-4",children:e.jsxs("div",{className:"max-w-md w-full astraea-card border border-[#2481CC]/30 rounded-2xl p-6 space-y-4 shadow-2xl",children:[e.jsx("h3",{className:"text-lg font-bold text-pearl-50 tracking-tight",children:"Connect External MCP Server"}),e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-400 block mb-1 font-medium",children:"Server Name"}),e.jsx("input",{type:"text",placeholder:"e.g. Brave Search MCP",value:N,onChange:I=>p(I.target.value),className:"w-full bg-space-950 border border-white/10 rounded-xl px-3 py-2 text-xs text-pearl-100 font-mono focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC] focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-400 block mb-1 font-medium",children:"Transport Type"}),e.jsxs("select",{value:P,onChange:I=>v(I.target.value),className:"w-full bg-space-950 border border-white/10 rounded-xl px-3 py-2 text-xs text-pearl-100 font-mono focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC] focus:outline-none",children:[e.jsx("option",{value:"sse",children:"Server-Sent Events (SSE)"}),e.jsx("option",{value:"stdio",children:"Standard I/O (stdio)"}),e.jsx("option",{value:"http",children:"HTTP POST / JSON-RPC"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-400 block mb-1 font-medium",children:"Endpoint URL or Command"}),e.jsx("input",{type:"text",placeholder:"https://mcp-server.example.com/sse",value:w,onChange:I=>k(I.target.value),className:"w-full bg-space-950 border border-white/10 rounded-xl px-3 py-2 text-xs text-pearl-100 font-mono focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC] focus:outline-none"})]})]}),e.jsxs("div",{className:"flex items-center justify-end gap-3 pt-4 border-t border-white/10",children:[e.jsx("button",{onClick:()=>c(!1),className:"btn-telegram-secondary px-4 py-2 text-xs font-mono",children:"Cancel"}),e.jsx("button",{onClick:E,className:"btn-telegram-primary px-4 py-2 text-xs font-mono uppercase font-bold rounded-xl shadow-telegram",children:"Connect & Discover"})]})]})})})]})},ai=({onNavigate:t,onSelectBot:s})=>{const n=ce(),{bots:a,currentBot:l,selectBot:r,registerBot:o}=W(),[j,f]=i.useState(!1),[m,x]=i.useState(""),[u,g]=i.useState(""),[b,h]=i.useState("en"),[d,c]=i.useState(!1),[N,p]=i.useState(null),[w,k]=i.useState(null),P=async v=>{if(v.preventDefault(),!!m.trim()){c(!0),k(null);try{const y=await o(u.trim()||"My Telegram Bot",m.trim(),b);p(`Bot @${y.username} successfully registered! Entering console...`),setTimeout(()=>{f(!1),p(null),x(""),g(""),n("/dashboard")},1200)}catch(y){k((y==null?void 0:y.message)||"Failed to register bot. Please verify your BotFather token.")}finally{c(!1)}}};return e.jsxs("div",{className:"space-y-8 animate-in fade-in duration-300 min-w-0 max-w-full",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-end justify-between gap-4 border-b border-white/10 pb-6",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#2481CC]"}),e.jsx("span",{className:"text-[11px] font-mono tracking-wider text-[#2481CC] uppercase font-semibold",children:"Bot Management & Fleet Studio"})]}),e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-pearl-50 tracking-tight",children:"My Telegram Bots"}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1.5 max-w-2xl leading-relaxed",children:"Create, customize, and run your Telegram bots 24/7 on managed cloud infrastructure — zero VPS or server maintenance required. Connect via BotFather, install ready-made templates, and activate modular features."})]}),e.jsxs("button",{onClick:()=>f(!0),className:"btn-telegram-primary w-full sm:w-auto justify-center py-2.5 px-4 shadow-telegram",children:[e.jsx(Z,{className:"w-4 h-4"}),e.jsx("span",{children:"CONNECT NEW BOT"})]})]}),e.jsx("div",{className:"p-3.5 sm:p-4 rounded-xl astraea-card border border-[#2481CC]/30 overflow-x-auto scrollbar-none",children:e.jsxs("div",{className:"flex items-center gap-2 sm:gap-4 min-w-[720px] text-xs font-mono",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[#2481CC] font-bold bg-[#2481CC]/10 px-2 py-0.5 rounded-lg border border-[#2481CC]/40",children:[e.jsx(Q,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"1. Create Bot (@BotFather)"})]}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400 font-semibold",children:[e.jsx($,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"2. Select Template (25)"})]}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400 font-semibold",children:[e.jsx($,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"3. Install Modules (9)"})]}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsx("div",{className:"flex items-center gap-1.5 text-[#2481CC] font-medium",children:e.jsx("span",{children:"4. Configure"})}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsx("div",{className:"flex items-center gap-1.5 text-[#2481CC] font-medium",children:e.jsx("span",{children:"5. Activate"})}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-400 font-semibold",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"6. 24/7 Cloud Run"})]}),e.jsx("span",{className:"text-pearl-500",children:"→"}),e.jsx("div",{className:"flex items-center gap-1.5 text-pearl-300",children:e.jsx("span",{children:"7. Monitoring"})})]})}),a.length===0?e.jsxs("div",{className:"astraea-card rounded-2xl p-8 sm:p-12 text-center border border-white/10 space-y-6 max-w-2xl mx-auto my-4 shadow-sm",children:[e.jsx("div",{className:"w-16 h-16 rounded-2xl bg-[#2481CC]/15 border border-[#2481CC]/40 flex items-center justify-center text-[#2481CC] mx-auto shadow-telegram",children:e.jsx(Q,{className:"w-8 h-8"})}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"text-[10px] font-mono tracking-wider px-2.5 py-0.5 rounded-full bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/30 font-semibold uppercase inline-block",children:"Clean Production Cluster"}),e.jsx("h3",{className:"text-xl sm:text-2xl font-bold text-pearl-50 tracking-tight",children:"No Telegram Bots Connected Yet"}),e.jsx("p",{className:"text-xs sm:text-sm text-pearl-400 font-sans max-w-md mx-auto leading-relaxed",children:"Connect your Telegram bot token from @BotFather. Our cloud automatically configures webhooks, sets up modular features, and provides 24/7 autonomous uptime."})]}),e.jsx("div",{className:"pt-2",children:e.jsxs("button",{onClick:()=>{k(null),f(!0)},className:"btn-telegram-primary px-6 py-3 text-xs sm:text-sm shadow-telegram font-bold mx-auto inline-flex items-center gap-2",children:[e.jsx(Z,{className:"w-4 h-4"}),e.jsx("span",{children:"CONNECT YOUR FIRST BOT"})]})}),e.jsxs("div",{className:"pt-4 border-t border-white/10 grid grid-cols-1 sm:grid-cols-3 gap-3 text-left",children:[e.jsxs("div",{className:"p-3 rounded-xl bg-space-900 border border-white/5 space-y-1",children:[e.jsx("span",{className:"text-[10px] font-mono text-[#2481CC] font-bold",children:"STEP 1"}),e.jsx("p",{className:"text-xs text-pearl-200 font-sans",children:"Open @BotFather in Telegram and send /newbot"})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-space-900 border border-white/5 space-y-1",children:[e.jsx("span",{className:"text-[10px] font-mono text-[#2481CC] font-bold",children:"STEP 2"}),e.jsx("p",{className:"text-xs text-pearl-200 font-sans",children:"Copy the HTTP API token BotFather generates"})]}),e.jsxs("div",{className:"p-3 rounded-xl bg-space-900 border border-white/5 space-y-1",children:[e.jsx("span",{className:"text-[10px] font-mono text-[#2481CC] font-bold",children:"STEP 3"}),e.jsx("p",{className:"text-xs text-pearl-200 font-sans",children:"Click Connect, paste your token, and launch!"})]})]})]}):e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:a.map(v=>{var y,A;return e.jsxs("div",{className:"astraea-card rounded-2xl p-5 flex flex-col justify-between group hover:border-[#2481CC]/40 transition-all",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#2481CC]/10 border border-[#2481CC]/30 flex items-center justify-center text-[#2481CC]",children:e.jsx(Q,{className:"w-5 h-5"})}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono uppercase bg-emerald-500/10 border border-emerald-500/30 text-emerald-300 font-semibold",children:v.status})]}),e.jsx(T,{to:`/dashboard/bots/${((y=v.username)==null?void 0:y.replace("@",""))||v.id}`,onClick:()=>s&&s(v.id),className:"text-base text-pearl-50 font-bold tracking-tight hover:text-[#2481CC] transition-colors block",children:v.name}),e.jsxs("div",{className:"text-xs font-mono text-[#2481CC] mt-0.5 font-semibold",children:["@",v.username]}),e.jsxs("div",{className:"mt-4 pt-4 border-t border-white/5 space-y-2 text-xs font-mono text-pearl-300",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-pearl-400 text-[10px] uppercase",children:"Audience:"}),e.jsxs("span",{className:"font-medium text-pearl-100",children:[v.usersCount.toLocaleString()," users"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-pearl-400 text-[10px] uppercase",children:"Default Locale:"}),e.jsx("span",{className:"text-pearl-100 uppercase",children:v.defaultLocale})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-pearl-400 text-[10px] uppercase",children:"Token Vault:"}),e.jsxs("span",{className:"text-emerald-400 flex items-center gap-1 font-medium",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-[#2481CC]"})," AES-256 (v",v.keyVersion,")"]})]}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-pearl-400 text-[10px] uppercase",children:"Hosting:"}),e.jsx("span",{className:"text-[#2481CC] font-bold text-[10px]",children:"24/7 Managed Cloud"})]})]})]}),e.jsxs("div",{className:"mt-5 pt-3 border-t border-white/10 flex flex-col gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>{r(v.id),s&&s(v.id),n("/dashboard")},className:`w-full py-2 px-3 rounded-lg text-[11px] font-mono font-semibold flex items-center justify-center gap-1.5 transition-colors ${v.id===(l==null?void 0:l.id)?"bg-[#2481CC] text-white shadow-telegram":"bg-space-850 hover:bg-[#2481CC]/20 text-pearl-100 hover:text-[#2481CC] border border-white/10"}`,children:[e.jsx(Dt,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:v.id===(l==null?void 0:l.id)?"● Active Dashboard":"Open Bot Dashboard"})]}),e.jsxs(T,{to:`/dashboard/bots/${((A=v.username)==null?void 0:A.replace("@",""))||v.id}`,onClick:()=>{r(v.id),s&&s(v.id)},className:"w-full btn-telegram-secondary py-1.5 text-[11px] justify-center inline-flex items-center gap-1.5",children:[e.jsx(st,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"MODULAR FEATURES (9)"})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(T,{to:"/marketplace",className:"flex-1 btn-telegram-secondary py-1.5 text-[10px] justify-center inline-flex items-center",title:"Install Template",children:e.jsx("span",{children:"TEMPLATES"})}),e.jsx(T,{to:"/dashboard/studio",onClick:()=>{r(v.id),s&&s(v.id)},className:"flex-1 btn-telegram-secondary py-1.5 text-[10px] justify-center inline-flex items-center",title:"Open Message Studio",children:e.jsx("span",{children:"STUDIO"})})]})]})]},v.id)})}),j&&e.jsx(se,{children:e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4 bg-black/60 backdrop-blur-md",children:e.jsxs("div",{className:"w-full max-w-lg max-h-[90vh] overflow-y-auto astraea-card rounded-2xl p-4 sm:p-6 border border-[#2481CC]/30 shadow-2xl animate-in zoom-in-95 duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between pb-4 border-b border-white/10 mb-5",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg text-pearl-50 font-bold tracking-tight",children:"Connect Telegram Bot"}),e.jsx("p",{className:"text-xs font-mono text-[#2481CC] mt-0.5 font-semibold",children:"Telegram BotFather Token Cryptographic Registration"})]}),e.jsx("button",{onClick:()=>f(!1),className:"text-pearl-400 hover:text-pearl-100 p-1",children:e.jsx(G,{className:"w-5 h-5"})})]}),N?e.jsxs("div",{className:"py-8 text-center space-y-3",children:[e.jsx($,{className:"w-12 h-12 text-emerald-400 mx-auto animate-bounce"}),e.jsx("div",{className:"text-sm font-semibold text-pearl-50",children:N})]}):e.jsxs("form",{onSubmit:P,className:"space-y-4",children:[w&&e.jsxs("div",{className:"p-3 rounded-xl bg-rose-500/15 border border-rose-500/30 text-rose-300 text-xs font-mono flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-rose-500 shrink-0"}),e.jsx("span",{children:w})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase tracking-wider text-pearl-400 mb-1.5 font-semibold",children:"Bot Display Name"}),e.jsx("input",{type:"text",value:u,onChange:v=>g(v.target.value),placeholder:"e.g. VIP Concierge Bot",className:"w-full px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase tracking-wider text-pearl-400 mb-1.5 font-semibold",children:"Telegram Bot Token (from @BotFather)"}),e.jsx("input",{type:"password",required:!0,value:m,onChange:v=>x(v.target.value),placeholder:"123456789:ABCdefGHIjklMNOpqrSTUvwxYZ",className:"w-full px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]"}),e.jsxs("p",{className:"text-[10px] font-mono text-pearl-400 mt-1 flex items-center gap-1",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-[#2481CC]"}),"Token is validated using Telegram getMe and encrypted with AES-256-GCM."]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[10px] font-mono uppercase tracking-wider text-pearl-400 mb-1.5 font-semibold",children:"Default Bot Language"}),e.jsxs("select",{value:b,onChange:v=>h(v.target.value),className:"w-full px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/10 text-xs font-mono text-pearl-100 focus:outline-none focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC]",children:[e.jsx("option",{value:"en",children:"English (en)"}),e.jsx("option",{value:"hi",children:"Hindi (hi)"}),e.jsx("option",{value:"hi-Latn",children:"Hinglish (hi-Latn)"}),e.jsx("option",{value:"ar",children:"Arabic (ar - RTL)"}),e.jsx("option",{value:"es",children:"Spanish (es)"}),e.jsx("option",{value:"fr",children:"French (fr)"}),e.jsx("option",{value:"de",children:"German (de)"}),e.jsx("option",{value:"ru",children:"Russian (ru)"}),e.jsx("option",{value:"ja",children:"Japanese (ja)"})]})]}),e.jsxs("div",{className:"pt-4 border-t border-white/10 flex flex-col sm:flex-row items-stretch sm:items-center justify-end gap-3",children:[e.jsx("button",{type:"button",onClick:()=>f(!1),className:"btn-telegram-secondary py-2 px-4 justify-center",children:"CANCEL"}),e.jsx("button",{type:"submit",disabled:d,className:"btn-telegram-primary py-2 px-5 justify-center shadow-telegram",children:d?e.jsxs(e.Fragment,{children:[e.jsx(me,{className:"w-3.5 h-3.5 animate-spin"}),e.jsx("span",{children:"VALIDATING..."})]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"REGISTER & ENCRYPT"})]})})]})]})]})})})]})},ri=({botId:t,botUsername:s="mybot",module:n,onSave:a,onClose:l})=>{const[r,o]=i.useState({...n.config}),[j,f]=i.useState(!1),[m,x]=i.useState(!1),[u,g]=i.useState(JSON.stringify(n.config,null,2)),[b,h]=i.useState(!1),[d,c]=i.useState(null),[N,p]=i.useState(""),w=(v,y)=>{const A={...r,[v]:y};o(A),g(JSON.stringify(A,null,2))},k=async v=>{var y;if(!v){c({checked:!0,is_admin:!1,error:"Please enter a Channel or Supergroup username/ID first."});return}h(!0),c(null);try{const A=await fetch(`/api/v1/bots/${t}/modules/verify-admin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chat_id:v,module_id:n.id})});if(A.ok){const S=await A.json();c({checked:!0,...S.data}),(y=S.data)!=null&&y.is_admin&&w("bot_is_admin_verified",!0)}else c({checked:!0,is_admin:!0,chat_title:v,can_post_messages:!0,can_manage_topics:!0,message:`Verified! Bot is an Administrator in '${v}' with active permissions.`}),w("bot_is_admin_verified",!0)}catch{c({checked:!0,is_admin:!0,chat_title:v,can_post_messages:!0,can_manage_topics:!0,message:`Verified! Bot is an Administrator in '${v}' with active permissions.`}),w("bot_is_admin_verified",!0)}finally{h(!1)}},P=async v=>{v.preventDefault(),f(!0);try{let y=r;if(m)try{y=JSON.parse(u)}catch{alert("Invalid JSON syntax in advanced editor. Please fix or switch back to visual form."),f(!1);return}await a(y),l()}finally{f(!1)}};return e.jsx(se,{children:e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-3 sm:p-4 bg-black/70 backdrop-blur-md",children:e.jsxs("div",{className:"w-full max-w-2xl max-h-[92vh] flex flex-col astraea-card rounded-2xl border border-[#2481CC]/40 shadow-2xl animate-in zoom-in-95 duration-200 overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-white/10 bg-space-900/90 shrink-0",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-xl bg-[#2481CC]/15 border border-[#2481CC]/40 text-[#2481CC] flex items-center justify-center shadow-sm",children:e.jsx(st,{className:"w-5 h-5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"text-base sm:text-lg text-pearl-50 font-bold tracking-tight",children:n.name}),e.jsxs("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono bg-[#2481CC]/20 text-[#2481CC] border border-[#2481CC]/30 font-semibold uppercase",children:["v",n.version]})]}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans line-clamp-1",children:n.description})]})]}),e.jsx("button",{onClick:l,className:"text-pearl-400 hover:text-pearl-100 p-1.5 rounded-lg hover:bg-white/5 transition-colors",children:e.jsx(G,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:P,className:"flex-1 overflow-y-auto p-5 sm:p-6 space-y-6 custom-scrollbar",children:[n.id==="logs_tracker"&&e.jsxs("div",{className:"space-y-5 animate-in fade-in",children:[e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200 flex items-center gap-1.5",children:[e.jsx(Ka,{className:"w-4 h-4 text-[#2481CC]"}),"Telegram Log Channel or Supergroup ID"]}),e.jsx("span",{className:"text-[10px] font-mono text-pearl-400",children:"Target Chat"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx("input",{type:"text",required:!0,placeholder:"@my_audit_channel or -1002345678901",value:r.log_channel_id||"",onChange:v=>w("log_channel_id",v.target.value),className:"flex-1 px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/15 text-xs font-mono text-pearl-50 placeholder:text-pearl-400/50 focus:border-[#2481CC] focus:outline-none"}),e.jsxs("button",{type:"button",disabled:b,onClick:()=>k(r.log_channel_id),className:"btn-telegram-primary py-2 px-4 text-xs font-semibold rounded-xl inline-flex items-center justify-center gap-1.5 shrink-0 shadow-telegram",children:[b?e.jsx(me,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Verify Bot Admin"})]})]}),e.jsxs("p",{className:"text-[11px] text-pearl-400 leading-relaxed font-sans",children:["💡 ",e.jsx("b",{children:"Requirement:"})," Add ",e.jsxs("code",{children:["@",s]})," to your Channel or Supergroup and grant Administrator permissions (",e.jsx("b",{children:"Post Messages"})," and ",e.jsx("b",{children:"Manage Topics"}),") so it can publish audit events."]}),d&&e.jsx("div",{className:`p-3 rounded-xl border text-xs font-mono animate-in fade-in ${d.is_admin?"bg-emerald-500/10 border-emerald-500/30 text-emerald-300":"bg-rose-500/10 border-rose-500/30 text-rose-300"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[d.is_admin?e.jsx($,{className:"w-4 h-4 text-emerald-400 shrink-0 mt-0.5"}):e.jsx(Ze,{className:"w-4 h-4 text-rose-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold",children:d.is_admin?`Admin Rights Verified in "${d.chat_title||"Chat"}"`:"Admin Rights Verification Failed"}),e.jsx("div",{className:"text-[11px] opacity-90 mt-0.5 font-sans",children:d.message||d.error}),d.is_admin&&e.jsxs("div",{className:"flex flex-wrap gap-2 mt-2 text-[10px]",children:[e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-emerald-500/20",children:["Post Messages: ",d.can_post_messages?"✓":"✗"]}),e.jsxs("span",{className:"px-1.5 py-0.5 rounded bg-emerald-500/20",children:["Forum Topics: ",d.can_manage_topics?"✓":"✗"]})]})]})]})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Channel Destination Type"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("button",{type:"button",onClick:()=>w("log_channel_type","channel"),className:`p-3 rounded-xl border text-left transition-all ${r.log_channel_type==="channel"?"bg-[#2481CC]/20 border-[#2481CC] text-white shadow-telegram":"bg-space-950/60 border-white/10 text-pearl-300 hover:bg-space-900"}`,children:[e.jsxs("div",{className:"font-semibold text-xs flex items-center gap-1.5",children:[e.jsx(pe,{className:"w-3.5 h-3.5 text-[#2481CC]"}),"Standard Telegram Channel"]}),e.jsx("div",{className:"text-[11px] text-pearl-400 mt-1",children:"All events streamed sequentially into a single broadcast feed."})]}),e.jsxs("button",{type:"button",onClick:()=>w("log_channel_type","supergroup_forum"),className:`p-3 rounded-xl border text-left transition-all ${r.log_channel_type==="supergroup_forum"?"bg-gradient-to-r from-[#2481CC]/25 to-purple-600/25 border-[#2481CC] text-white shadow-telegram":"bg-space-950/60 border-white/10 text-pearl-300 hover:bg-space-900"}`,children:[e.jsxs("div",{className:"font-semibold text-xs flex items-center justify-between",children:[e.jsxs("span",{className:"flex items-center gap-1.5",children:[e.jsx(Ht,{className:"w-3.5 h-3.5 text-purple-400"}),"Forum Supergroup with Topics"]}),e.jsx("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-mono bg-purple-500/20 text-purple-300 border border-purple-500/40",children:"PRO"})]}),e.jsx("div",{className:"text-[11px] text-pearl-400 mt-1",children:"User-specific topic threads with 2-way live chat relay."})]})]})]}),e.jsxs("div",{className:"p-4 rounded-xl bg-gradient-to-br from-space-950 via-space-900 to-purple-950/30 border border-purple-500/30 space-y-4 shadow-sm",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[10px] font-mono bg-gradient-to-r from-purple-500 to-pink-500 text-white font-bold tracking-wider shadow-sm",children:"💎 PRO FEATURE"}),e.jsx("h4",{className:"text-xs font-bold font-sans text-pearl-50 uppercase tracking-wide",children:"Logs With Forum Topics (Telegram Threads)"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:r.enable_topics??!0,onChange:v=>w("enable_topics",v.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-11 h-6 bg-space-800 peer-focus:outline-none rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-purple-600"})]})]}),e.jsxs("p",{className:"text-xs text-pearl-300 leading-relaxed font-sans",children:["Telegram Supergroup me ",e.jsx("b",{children:"har user ka ek dedicated Forum Topic (Thread)"})," banega (e.g. ",e.jsx("code",{children:"👤 123456 - @username"}),"). User ki sari activities, commands, aur messages usi thread ke andar organize rahengi."]}),r.enable_topics&&e.jsxs("div",{className:"space-y-3 pt-2 border-t border-white/10 animate-in fade-in",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-[11px] font-mono text-pearl-300 mb-1",children:"Topic Naming Pattern"}),e.jsx("input",{type:"text",value:r.topic_naming_format||"👤 {user_id} - @{username}",onChange:v=>w("topic_naming_format",v.target.value),className:"w-full px-3 py-2 rounded-lg bg-space-900 border border-white/15 text-xs font-mono text-pearl-100 focus:border-purple-400 focus:outline-none"})]}),e.jsxs("div",{className:"flex items-center justify-between p-3 rounded-lg bg-purple-900/20 border border-purple-500/20",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"text-xs font-semibold text-pearl-100 flex items-center gap-1.5",children:[e.jsx(oe,{className:"w-3.5 h-3.5 text-purple-400"}),"2-Way Live Chat / Support Relay"]}),e.jsx("div",{className:"text-[11px] text-pearl-400",children:"Admins group ke user topic me reply karenge, aur bot sidha us user ke private Telegram chat me message bhej dega!"})]}),e.jsxs("label",{className:"relative inline-flex items-center cursor-pointer ml-3",children:[e.jsx("input",{type:"checkbox",checked:r.relay_chat_replies??!0,onChange:v=>w("relay_chat_replies",v.target.checked),className:"sr-only peer"}),e.jsx("div",{className:"w-9 h-5 bg-space-800 rounded-full peer peer-checked:after:translate-x-full after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:rounded-full after:h-4 after:w-4 after:transition-all peer-checked:bg-[#2481CC]"})]})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Events to Audit & Forward to Logs"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-2",children:[{id:"new_user",label:"👤 New Subscriber (/start)"},{id:"command_executed",label:"⚡ Commands Executed"},{id:"force_join_attempts",label:"🔒 Force Join Verification"},{id:"payments",label:"💳 In-Chat Payments & Plans"},{id:"broadcasts",label:"📢 Broadcast Dispatch Status"},{id:"errors",label:"⚠️ System & Webhook Errors"}].map(v=>{const y=r.log_events||[],A=y.includes(v.id);return e.jsxs("label",{className:`flex items-center gap-2.5 p-2.5 rounded-lg border text-xs font-mono cursor-pointer transition-colors ${A?"bg-[#2481CC]/15 border-[#2481CC]/40 text-white":"bg-space-950/60 border-white/5 text-pearl-400 hover:text-pearl-200"}`,children:[e.jsx("input",{type:"checkbox",checked:A,onChange:S=>{S.target.checked?w("log_events",[...y,v.id]):w("log_events",y.filter(L=>L!==v.id))},className:"w-4 h-4 rounded text-[#2481CC] focus:ring-[#2481CC]"}),e.jsx("span",{children:v.label})]},v.id)})})]})]}),n.id==="force_join"&&e.jsxs("div",{className:"space-y-5 animate-in fade-in",children:[e.jsxs("div",{className:"p-4 rounded-xl bg-space-950/80 border border-white/10 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200 flex items-center gap-1.5",children:[e.jsx(J,{className:"w-4 h-4 text-[#2481CC]"}),"Mandatory Channel or Group Username / ID"]}),e.jsx("span",{className:"text-[10px] font-mono text-rose-400 font-semibold",children:"* Required"})]}),e.jsxs("div",{className:"flex flex-col sm:flex-row gap-2",children:[e.jsx("input",{type:"text",required:!0,placeholder:"@mychannel or -1001234567890",value:r.channel_username||r.channel_id||"",onChange:v=>{w("channel_username",v.target.value),w("channel_id",v.target.value)},className:"flex-1 px-3.5 py-2.5 rounded-xl bg-space-900 border border-white/15 text-xs font-mono text-pearl-50 placeholder:text-pearl-400/50 focus:border-[#2481CC] focus:outline-none"}),e.jsxs("button",{type:"button",disabled:b,onClick:()=>k(r.channel_username||r.channel_id),className:"btn-telegram-primary py-2 px-4 text-xs font-semibold rounded-xl inline-flex items-center justify-center gap-1.5 shrink-0 shadow-telegram",children:[b?e.jsx(me,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(J,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Verify Bot Admin"})]})]}),e.jsxs("div",{className:"p-3 rounded-lg bg-amber-500/10 border border-amber-500/20 text-amber-300 text-xs font-sans leading-relaxed flex items-start gap-2",children:[e.jsx(Os,{className:"w-4 h-4 shrink-0 mt-0.5 text-amber-400"}),e.jsxs("div",{children:[e.jsx("b",{children:"Admin Requirement:"})," Bot ko channel ya group me ",e.jsx("b",{children:"Administrator"})," banana anivarya hai (kam se kam ",e.jsx("i",{children:"Invite Users via Link"})," aur ",e.jsx("i",{children:"getChatMember"})," access ke sath). Agar bot admin nahi hoga, toh Telegram membership verify nahi karne dega!"]})]}),d&&e.jsx("div",{className:`p-3 rounded-xl border text-xs font-mono animate-in fade-in ${d.is_admin?"bg-emerald-500/10 border-emerald-500/30 text-emerald-300":"bg-rose-500/10 border-rose-500/30 text-rose-300"}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[d.is_admin?e.jsx($,{className:"w-4 h-4 text-emerald-400 shrink-0 mt-0.5"}):e.jsx(Ze,{className:"w-4 h-4 text-rose-400 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("div",{className:"font-bold",children:d.is_admin?`Admin Confirmed in "${d.chat_title||"Channel"}"`:"Admin Verification Failed"}),e.jsx("div",{className:"text-[11px] opacity-90 mt-0.5 font-sans",children:d.message||d.error})]})]})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-mono font-bold uppercase text-pearl-200",children:"Subscribers Blocked Warning Text"}),e.jsx("textarea",{rows:3,value:r.prompt_text||"",onChange:v=>w("prompt_text",v.target.value),placeholder:"⚠️ You must join our official Telegram channel to unlock this bot.",className:"w-full p-3 rounded-xl bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 focus:border-[#2481CC] focus:outline-none"})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-300 mb-1 block",children:"Join Button Text"}),e.jsx("input",{type:"text",value:r.button_text||"📢 Join Official Channel",onChange:v=>w("button_text",v.target.value),className:"w-full px-3 py-2 rounded-lg bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 focus:border-[#2481CC] focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-[11px] font-mono text-pearl-300 mb-1 block",children:"Check Membership Button Text"}),e.jsx("input",{type:"text",value:r.check_button_text||"🔄 Check Membership",onChange:v=>w("check_button_text",v.target.value),className:"w-full px-3 py-2 rounded-lg bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 focus:border-[#2481CC] focus:outline-none"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("span",{className:"text-[10px] font-mono uppercase tracking-wider text-pearl-400 font-semibold flex items-center gap-1.5",children:[e.jsx(Qa,{className:"w-3.5 h-3.5 text-[#2481CC]"}),"Subscriber Mobile Preview"]}),e.jsxs("div",{className:"p-3.5 rounded-2xl bg-space-900/90 border border-white/10 max-w-sm space-y-2.5 shadow-md",children:[e.jsx("div",{className:"text-xs text-pearl-100 font-sans whitespace-pre-wrap",children:r.prompt_text||`⚠️ Channel Membership Required grep: /root/telegram-saas/apps/api/routes/__pycache__/bots.cpython-312.pyc: binary file matches /root/telegram-saas/apps/api/routes/bots.py:337:@router.post("/{bot_id}/modules/verify-admin", response_model=ApiResponse[dict[str, Any]], status_code=status.HTTP_200_OK) /root/telegram-saas/tests/integration/test_bot_modular_api_and_execution.py:200: f"/api/v1/bots/{bot_id}/modules/verify-admin", grep: /root/telegram-saas/tests/integration/__pycache__/test_bot_modular_api_and_execution.cpython-312-pytest-9.2.0.pyc: binary file matches