Created At: 2026-11-18T17:13:56Z Completed At: 2026-11-18T17:13:58Z Command exited with code 0. Command output: apps/frontend/src/components/pages/BotManagementPage.tsx:91: const { bots, currentBot, selectBot, registerBot } = useBot(); apps/frontend/src/components/pages/BotManagementPage.tsx:105: const newBot = await registerBot(botName || 'My New Telegram Bot', botToken, defaultLocale); apps/frontend/src/context/BotContext.tsx:242: registerBot: (name: string, token: string, defaultLocale?: string) => Promise; apps/frontend/src/context/BotContext.tsx:294: const registerBot = async (name: string, token: string, defaultLocale = 'en'): Promise => { apps/frontend/src/context/BotContext.tsx:406: registerBot, apps/frontend/dist/assets/index-DHrGTvWe.js:36: */function xt(){return xt=Object.assign?Object.assign.bind():function(t){for(var s=1;s{let a=t[n];return s.concat(Array.isArray(a)?a.map(l=>[n,l]):[[n,a]])},[]))}function Cn(t,s){let n=Bt(t);return s&&s.forEach((a,l)=>{n.has(l)||s.getAll(l).forEach(r=>{n.append(l,r)})}),n}const kn=["onClick","relative","reloadDocument","replace","state","target","to","preventScrollReset","viewTransition"],Sn=["aria-current","caseSensitive","className","end","style","to","viewTransition","children"],_n="6";try{window.__reactRouterVersion=_n}catch{}const Tn=i.createContext({isTransitioning:!1}),An="startTransition",ps=ya[An];function Pn(t){let{basename:s,children:n,future:a,window:l}=t,r=i.useRef();r.current==null&&(r.current=Ar({window:l,v5Compat:!0}));let o=r.current,[j,b]=i.useState({action:o.action,location:o.location}),{v7_startTransition:m}=a||{},x=i.useCallback(f=>{m&&ps?ps(()=>b(f)):b(f)},[b,m]);return i.useLayoutEffect(()=>o.listen(x),[o,x]),i.useEffect(()=>fn(a),[a]),i.createElement(vn,{basename:s,children:n,location:j.location,navigationType:j.action,navigator:o,future:a})}const In=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",En=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i,A=i.forwardRef(function(s,n){let{onClick:a,relative:l,reloadDocument:r,replace:o,state:j,target:b,to:m,preventScrollReset:x,viewTransition:f}=s,p=ia(s,kn),{basename:g}=i.useContext(we),u,d=!1;if(typeof m=="string"&&En.test(m)&&(u=m,In))try{let N=new URL(window.location.href),y=m.startsWith("//")?new URL(N.protocol+m):new URL(m),E=Ue(y.pathname,g);y.origin===N.origin&&E!=null?m=E+y.search+y.hash:d=!0}catch{}let c=Xr(m,{relative:l}),v=Ln(m,{replace:o,state:j,target:b,preventScrollReset:x,relative:l,viewTransition:f});function h(N){a&&a(N),N.defaultPrevented||v(N)}return i.createElement("a",xt({},p,{href:u||c,onClick:d||r?a:h,ref:n,target:b}))}),Rn=i.forwardRef(function(s,n){let{"aria-current":a="page",caseSensitive:l=!1,className:r="",end:o=!1,style:j,to:b,viewTransition:m,children:x}=s,f=ia(s,Sn),p=vt(b,{relative:f.relative}),g=ue(),u=i.useContext(ea),{navigator:d,basename:c}=i.useContext(we),v=u!=null&&On(p)&&m===!0,h=d.encodeLocation?d.encodeLocation(p).pathname:p.pathname,N=g.pathname,y=u&&u.navigation&&u.navigation.location?u.navigation.location.pathname:null;l||(N=N.toLowerCase(),y=y?y.toLowerCase():null,h=h.toLowerCase()),y&&c&&(y=Ue(y,c)||y);const E=h!=="/"&&h.endsWith("/")?h.length-1:h.length;let w=N===h||!o&&N.startsWith(h)&&N.charAt(E)==="/",S=y!=null&&(y===h||!o&&y.startsWith(h)&&y.charAt(h.length)==="/"),P={isActive:w,isPending:S,isTransitioning:v},k=w?a:void 0,L;typeof r=="function"?L=r(P):L=[r,w?"active":null,S?"pending":null,v?"transitioning":null].filter(Boolean).join(" ");let M=typeof j=="function"?j(P):j;return i.createElement(A,xt({},f,{"aria-current":k,className:L,ref:n,style:M,to:b,viewTransition:m}),typeof x=="function"?x(P):x)});var Ot;(function(t){t.UseScrollRestoration="useScrollRestoration",t.UseSubmit="useSubmit",t.UseSubmitFetcher="useSubmitFetcher",t.UseFetcher="useFetcher",t.useViewTransitionState="useViewTransitionState"})(Ot||(Ot={}));var us;(function(t){t.UseFetcher="useFetcher",t.UseFetchers="useFetchers",t.UseScrollRestoration="useScrollRestoration"})(us||(us={}));function Mn(t){let s=i.useContext(gt);return s||G(!1),s}function Ln(t,s){let{target:n,replace:a,state:l,preventScrollReset:r,relative:o,viewTransition:j}=s===void 0?{}:s,b=ce(),m=ue(),x=vt(t,{relative:o});return i.useCallback(f=>{if(yn(f,n)){f.preventDefault();let p=a!==void 0?a:mt(m)===mt(x);b(t,{replace:p,state:l,preventScrollReset:r,relative:o,viewTransition:j})}},[m,b,x,a,l,n,t,r,o,j])}function Bn(t){let s=i.useRef(Bt(t)),n=i.useRef(!1),a=ue(),l=i.useMemo(()=>Cn(a.search,n.current?null:s.current),[a.search]),r=ce(),o=i.useCallback((j,b)=>{const m=Bt(typeof j=="function"?j(l):j);n.current=!0,r("?"+m,b)},[r,l]);return[l,o]}function On(t,s){s===void 0&&(s={});let n=i.useContext(Tn);n==null&&G(!1);let{basename:a}=Mn(Ot.useViewTransitionState),l=vt(t,{relative:s.relative});if(!n.isTransitioning)return!1;let r=Ue(n.currentLocation.pathname,a)||n.currentLocation.pathname,o=Ue(n.nextLocation.pathname,a)||n.nextLocation.pathname;return Mt(l.pathname,o)!=null||Mt(l.pathname,r)!=null}const oa=i.createContext(void 0),Dn=({children:t})=>{const[s,n]=i.useState(()=>localStorage.getItem("access_token")),[a,l]=i.useState(()=>localStorage.getItem("refresh_token")),[r,o]=i.useState(()=>{const u=localStorage.getItem("auth_user");if(u)try{return JSON.parse(u)}catch{return null}return null}),[j,b]=i.useState(!0),m=async u=>{var d,c;try{const v=await fetch("/api/v1/auth/me",{headers:{Authorization:`Bearer ${u}`}});if(v.ok){const h=await v.json();if(h.success&&h.data)return o(h.data),localStorage.setItem("auth_user",JSON.stringify(h.data)),h.data}else if(v.status===401&&a){const h=await fetch("/api/v1/auth/refresh",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:a})});if(h.ok){const N=await h.json(),y=(d=N.data)==null?void 0:d.access_token,E=(c=N.data)==null?void 0:c.refresh_token;if(y)return n(y),localStorage.setItem("access_token",y),E&&(l(E),localStorage.setItem("refresh_token",E)),m(y)}p()}}catch(v){console.warn("Could not fetch user profile:",v)}return null};i.useEffect(()=>{s?m(s).finally(()=>b(!1)):b(!1)},[]);const x=async u=>{var d;b(!0);try{const c=await fetch("/api/v1/auth/telegram",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(u)}),v=await c.json();if(c.ok&&v.success&&v.data){const{access_token:h,refresh_token:N}=v.data;return n(h),l(N),localStorage.setItem("access_token",h),N&&localStorage.setItem("refresh_token",N),await m(h),b(!1),{success:!0}}else return b(!1),{success:!1,error:v.message||((d=v.error)==null?void 0:d.message)||"Telegram verification failed"}}catch(c){return b(!1),{success:!1,error:c.message||"Network error during login"}}},f=async(u,d)=>{var c;b(!0);try{const v=await fetch("/api/v1/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:u,password:d})}),h=await v.json();if(v.ok&&h.success&&h.data){const{access_token:N,refresh_token:y}=h.data;return n(N),l(y),localStorage.setItem("access_token",N),y&&localStorage.setItem("refresh_token",y),await m(N),b(!1),{success:!0}}else return b(!1),{success:!1,error:h.message||((c=h.error)==null?void 0:c.message)||"Invalid email or password"}}catch(v){return b(!1),{success:!1,error:v.message||"Network error during login"}}},p=()=>{a&&fetch("/api/v1/auth/logout",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refresh_token:a})}).catch(()=>{}),n(null),l(null),o(null),localStorage.removeItem("access_token"),localStorage.removeItem("refresh_token"),localStorage.removeItem("auth_user")},g=async()=>{s&&await m(s)};return e.jsx(oa.Provider,{value:{user:r,token:s,isAuthenticated:!!s,isLoading:j,loginWithTelegram:x,loginWithEmail:f,logout:p,refreshUserProfile:g},children:t})},qe=()=>{const t=i.useContext(oa);if(!t)throw new Error("useAuth must be used within an AuthProvider");return t},ca=i.createContext(void 0),Fn=({children:t})=>{const[s,n]=i.useState(()=>localStorage.getItem("app_theme")==="dark"?"dark":"light");i.useEffect(()=>{const r=document.documentElement;s==="light"?(r.classList.remove("dark"),r.classList.add("light")):(r.classList.remove("light"),r.classList.add("dark")),localStorage.setItem("app_theme",s)},[s]);const a=()=>{n(r=>r==="light"?"dark":"light")},l=r=>{n(r)};return e.jsx(ca.Provider,{value:{theme:s,toggleTheme:a,setTheme:l},children:t})},nt=()=>{const t=i.useContext(ca);if(!t)throw new Error("useTheme must be used within a ThemeProvider");return t},Qe=[{id:"welcome_message",name:"Welcome Message & Onboarding",category:"engagement",description:"Custom greeting message, dynamic placeholders ({first_name}, {bot_name}), and inline action buttons on /start.",is_enabled:!0,config:{welcome_text:"🌟 Welcome to our VIP Bot! Tap an option below to explore:",buttons_count:4}},{id:"force_join",name:"Force Join Channel Guard",category:"security",description:"Mandatory channel/group membership before unlocking bot commands. Verifies status via getChatMember.",is_enabled:!0,config:{channel_username:"@astraea_cloud",prompt_text:"⚠️ You must join our official Telegram channel to unlock this bot.",button_text:"📢 Join Official Channel"}},{id:"referrals",name:"Referral & Viral Growth Engine",category:"growth",description:"Generates subscriber deep-link invite links (/start ref_{userId}), tracks successful signups, and awards points.",is_enabled:!0,config:{points_per_referral:10,welcome_bonus_points:5,min_payout_points:50}},{id:"broadcasts",name:"Broadcast & Announcement Pipeline",category:"messaging",description:"Token-bucket broadcasts (25 msgs/sec), audience filtering, language targeting, and /optout compliance.",is_enabled:!0,config:{rate_limit_per_second:25,allow_opt_out:!0}},{id:"user_management",name:"Audience & Subscriber Directory",category:"management",description:"Real-time subscriber tracking, interaction count, automatic BCP 47 language preference detection.",is_enabled:!0,config:{auto_detect_locale:!0,track_interactions:!0}},{id:"auto_filter",name:"Auto Filter & Keyword Responder",category:"automation",description:"Matches subscriber text against trigger keywords and forbidden words. Provides instantaneous auto-replies.",is_enabled:!0,config:{rules_count:3,blocked_words:["scam","free nitro","hack"]}},{id:"payments",name:"In-Chat Payments & Invoicing",category:"monetization",description:"Seamless Razorpay & Stripe in-chat payment links with cryptographic webhook verification.",is_enabled:!1,config:{currency:"INR",gateway:"razorpay"}},{id:"subscriptions",name:"VIP Tiered Subscription Gates",category:"monetization",description:"Restricts channels, commands, and downloads to active paying VIP subscribers with auto-expiry.",is_enabled:!0,config:{plans_count:3,grace_period_days:2}},{id:"ai_assistant",name:"Autonomous AI Agent Concierge",category:"ai",description:"Multi-turn LLM support concierge powered by OpenAI/Anthropic/Gemini with encrypted API keys and tools.",is_enabled:!0,config:{model:"gemini-1.5-pro",temperature:.7,max_tokens:1024}}],hs=[{id:"b-001",name:"Astraea Concierge Bot",username:"astraea_flagship_bot",status:"active",defaultLocale:"en",keyVersion:1,webhookUrl:"https://api.yourdomain.com/webhooks/telegram/b-001",usersCount:14280,messages24h:38400,latencyMs:38,uptimePct:99.98,createdAt:"2026-11-01T10:00:00Z",templateName:"VIP Club & Community Gatekeeper",checklist:{tokenConnected:!0,templateSelected:!0,modulesConfigured:!0,welcomeMessageSet:!0,testedInTelegram:!0},modules:Qe},{id:"b-002",name:"VIP Concierge & Support",username:"vip_concierge_bot",status:"active",defaultLocale:"en",keyVersion:1,webhookUrl:"https://api.yourdomain.com/webhooks/telegram/b-002",usersCount:6890,messages24h:12100,latencyMs:42,uptimePct:99.95,createdAt:"2026-11-05T14:30:00Z",templateName:"Customer Support Desk & Ticket Escalation",checklist:{tokenConnected:!0,templateSelected:!0,modulesConfigured:!0,welcomeMessageSet:!0,testedInTelegram:!1},modules:Qe.map(t=>({...t,is_enabled:["welcome_message","ai_assistant","user_management"].includes(t.id)}))},{id:"b-003",name:"Automated Flash Billing",username:"flash_billing_bot",status:"active",defaultLocale:"hi",keyVersion:1,webhookUrl:"https://api.yourdomain.com/webhooks/telegram/b-003",usersCount:9420,messages24h:21900,latencyMs:35,uptimePct:99.99,createdAt:"2026-11-10T09:15:00Z",templateName:"E-Commerce Digital Store & Cart",checklist:{tokenConnected:!0,templateSelected:!0,modulesConfigured:!0,welcomeMessageSet:!1,testedInTelegram:!1},modules:Qe.map(t=>({...t,is_enabled:["welcome_message","payments","subscriptions","broadcasts"].includes(t.id)}))},{id:"b-004",name:"Omni Broadcast Announcer",username:"omni_broadcast_bot",status:"active",defaultLocale:"en",keyVersion:1,webhookUrl:"https://api.yourdomain.com/webhooks/telegram/b-004",usersCount:31200,messages24h:89400,latencyMs:48,uptimePct:99.9,createdAt:"2026-11-12T18:00:00Z",templateName:"Channel Broadcast & Content Syndicator",checklist:{tokenConnected:!0,templateSelected:!0,modulesConfigured:!1,welcomeMessageSet:!1,testedInTelegram:!1},modules:Qe.map(t=>({...t,is_enabled:["broadcasts","user_management","force_join"].includes(t.id)}))}],da=i.createContext(void 0),$n=({children:t})=>{const[s,n]=i.useState(()=>{try{const p=localStorage.getItem("telebot_bots");if(p)return JSON.parse(p)}catch{}return hs}),[a,l]=i.useState(()=>{try{const p=localStorage.getItem("telebot_active_bot_id");if(p&&hs.some(g=>g.id===p||g.username===p))return p}catch{}return"b-001"});i.useEffect(()=>{try{localStorage.setItem("telebot_bots",JSON.stringify(s))}catch{}},[s]),i.useEffect(()=>{try{localStorage.setItem("telebot_active_bot_id",a)}catch{}},[a]);const r=s.find(p=>p.id===a||p.username===a)||s[0],o=p=>{const g=p.replace("@","").toLowerCase(),u=s.find(d=>d.id===p||d.username.toLowerCase()===g);u&&l(u.id)},j=async(p,g,u="en")=>{const d=p.toLowerCase().replace(/[^a-z0-9]/g,"_")+"_bot",c=`b-${Date.now().toString().slice(-4)}`,v={id:c,name:p||"My New Telegram Bot",username:d,status:"active",defaultLocale:u,keyVersion:1,webhookUrl:`https://api.yourdomain.com/webhooks/telegram/${c}`,usersCount:1,messages24h:0,latencyMs:38,uptimePct:100,createdAt:new Date().toISOString(),templateName:"Blank Telegram Starter",checklist:{tokenConnected:!0,templateSelected:!1,modulesConfigured:!1,welcomeMessageSet:!1,testedInTelegram:!1},modules:Qe.map(h=>({...h,is_enabled:h.id==="welcome_message"}))};return n(h=>[v,...h]),l(v.id),v},b=(p,g,u)=>{n(d=>d.map(c=>{if(c.id!==p)return c;const v=c.modules.map(h=>{if(h.id!==g)return h;const N=u!==void 0?u:!h.is_enabled;return{...h,is_enabled:N}});return{...c,modules:v,checklist:{...c.checklist,modulesConfigured:!0}}}))},m=(p,g,u)=>{n(d=>d.map(c=>c.id!==p?c:{...c,modules:c.modules.map(v=>v.id===g?{...v,config:{...v.config,...u}}:v)}))},x=(p,g)=>{n(u=>u.map(d=>d.id!==p?d:{...d,checklist:{...d.checklist,[g]:!d.checklist[g]}}))},f=(p,g,u)=>{n(d=>d.map(c=>c.id!==p?c:{...c,templateName:g,checklist:{...c.checklist,templateSelected:!0,modulesConfigured:!0},modules:c.modules.map(v=>({...v,is_enabled:u.includes(v.id)||v.id==="welcome_message"}))}))};return e.jsx(da.Provider,{value:{bots:s,currentBot:r,selectBot:o,registerBot:j,toggleBotModule:b,updateModuleConfig:m,toggleChecklistStep:x,applyTemplateToBot:f},children:t})},z=()=>{const t=i.useContext(da);if(!t)throw new Error("useBot must be used within a BotProvider");return t},wt={overview:"/dashboard",marketplace:"/marketplace","bot-builder":"/dashboard/builder","mcp-pro":"/dashboard/mcp",bots:"/dashboard/bots","bot-details":"/dashboard/bots/astraea-flagship","message-studio":"/dashboard/studio",broadcasts:"/dashboard/broadcasts","ai-agents":"/dashboard/agents",plugins:"/dashboard/plugins",users:"/dashboard/users",emojis:"/dashboard/emojis",languages:"/dashboard/languages",subscriptions:"/dashboard/subscriptions",payments:"/dashboard/payments",team:"/dashboard/team",analytics:"/dashboard/analytics",settings:"/dashboard/settings","audit-logs":"/dashboard/audit-logs"};function ma(t){return t==="/marketplace"||t.startsWith("/marketplace")?"marketplace":t==="/dashboard/builder"?"bot-builder":t==="/dashboard/mcp"?"mcp-pro":t==="/dashboard/studio"?"message-studio":t==="/dashboard/broadcasts"?"broadcasts":t==="/dashboard/agents"?"ai-agents":t==="/dashboard/plugins"?"plugins":t==="/dashboard/users"?"users":t==="/dashboard/emojis"?"emojis":t==="/dashboard/languages"?"languages":t==="/dashboard/subscriptions"?"subscriptions":t==="/dashboard/payments"?"payments":t==="/dashboard/team"?"team":t==="/dashboard/analytics"?"analytics":t==="/dashboard/settings"?"settings":t==="/dashboard/audit-logs"?"audit-logs":t==="/dashboard/bots"?"bots":t.startsWith("/dashboard/bots/")?"bot-details":"overview"}const Un=[{label:"BOT BUILDER & FLEET",items:[{id:"overview",name:"Overview",icon:Dt},{id:"bots",name:"My Telegram Bots",icon:Q,badge:"Fleet"},{id:"marketplace",name:"Ready-Made Bot Store",icon:Ft,badge:"25"},{id:"bot-details",name:"Modular Studio",icon:at,badge:"9 Core"},{id:"bot-builder",name:"Visual Bot Flow",icon:Cs,badge:"Builder"},{id:"message-studio",name:"Welcome & Message Studio",icon:$t,badge:"PRO"}]},{label:"MODULES & AUDIENCE",items:[{id:"broadcasts",name:"Broadcast Engine",icon:pe},{id:"users",name:"Subscribers & Referrals",icon:Ae},{id:"plugins",name:"Plugins & Integrations",icon:ka},{id:"ai-agents",name:"AI Agent Studio",icon:Sa,badge:"LLM"},{id:"mcp-pro",name:"MCP Pro Cloud",icon:fe,badge:"RPC"}]},{label:"COMMERCE & LOCALIZATION",items:[{id:"subscriptions",name:"VIP Subscriptions",icon:Ve},{id:"payments",name:"Payments & Invoicing",icon:Ut},{id:"languages",name:"Languages (16)",icon:_a},{id:"emojis",name:"Custom Emojis",icon:ks}]},{label:"GOVERNANCE & PLATFORM",items:[{id:"team",name:"Team & RBAC",icon:Ss},{id:"analytics",name:"Cloud Analytics",icon:Ta},{id:"audit-logs",name:"Security Audit Logs",icon:Aa},{id:"settings",name:"Platform Settings",icon:Pa}]}],Vn=({currentView:t,onNavigate:s,collapsed:n,onToggleCollapse:a,mobileOpen:l=!1,onCloseMobile:r})=>{const{theme:o,toggleTheme:j}=nt(),{currentBot:b}=z();ce();const m=ue();t||ma(m.pathname);const x=(f=!1)=>e.jsx("div",{className:"flex-1 overflow-y-auto px-3 py-6 space-y-6",children:Un.map((p,g)=>e.jsxs("div",{className:"space-y-1",children:[(!n||f)&&e.jsx("div",{className:"px-3 text-[10px] font-mono tracking-ultra-wide text-pearl-400/80 uppercase font-semibold mb-2",children:p.label}),p.items.map(u=>{const d=u.icon,c=wt[u.id],v=n&&!f;return e.jsx(Rn,{to:c,end:u.id==="overview",onClick:()=>{s&&s(u.id),r&&r()},title:v?u.name:void 0,className:({isActive:h})=>`w-full flex items-center gap-3 px-3 py-2.5 rounded text-xs font-mono tracking-wider transition-all relative ${h?"bg-[#2481CC]/12 text-[#2481CC] border border-[#2481CC]/35 shadow-sm font-semibold":"text-pearl-400 hover:text-pearl-100 hover:bg-space-850 border border-transparent"} ${v?"justify-center px-0":""}`,children:({isActive:h})=>e.jsxs(e.Fragment,{children:[e.jsx(d,{className:`w-4 h-4 shrink-0 ${h?"text-[#2481CC]":"text-pearl-400"}`}),!v&&e.jsx("span",{className:"truncate",children:u.name}),!v&&u.badge&&e.jsx("span",{className:`ml-auto px-1.5 py-0.5 rounded text-[9px] font-mono uppercase ${h?"bg-[#2481CC]/20 text-[#2481CC] border border-[#2481CC]/30 font-semibold":"bg-space-800 text-pearl-400 border border-white/10"}`,children:u.badge}),h&&e.jsx("span",{className:"absolute left-0 top-1/2 -translate-y-1/2 w-1 h-5 rounded-r bg-[#2481CC]"})]})},u.id)})]},g))});return e.jsxs(e.Fragment,{children:[l&&e.jsx("div",{className:"fixed inset-0 z-50 bg-black/80 backdrop-blur-sm md:hidden animate-fadeIn",onClick:r,"aria-hidden":"true"}),e.jsxs("aside",{className:`fixed top-0 left-0 bottom-0 z-50 w-72 bg-space-900 border-r border-white/10 flex flex-col transition-transform duration-300 md:hidden ${l?"translate-x-0 shadow-2xl":"-translate-x-full"}`,children:[e.jsxs("div",{className:"h-20 border-b border-white/10 px-5 flex items-center justify-between",children:[e.jsxs(A,{to:"/",onClick:r,className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-[#2481CC] text-white flex items-center justify-center font-sans font-bold text-base shadow-telegram",children:e.jsx(oe,{className:"w-4 h-4 text-white -rotate-12 translate-x-0.5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-sans text-sm tracking-tight text-pearl-50 font-bold leading-tight",children:["TeleBot",e.jsx("span",{className:"text-[#2481CC]",children:"Cloud"})]}),e.jsx("div",{className:"text-[10px] font-mono text-[#2481CC] uppercase tracking-wide font-medium",children:"Telegram Bot Builder"})]})]}),e.jsx("button",{onClick:r,className:"p-2 text-pearl-400 hover:text-pearl-100 hover:bg-white/5 rounded-md transition-colors","aria-label":"Close navigation",children:e.jsx(H,{className:"w-5 h-5"})})]}),b&&e.jsxs("div",{className:"mx-3 mt-3 p-2.5 rounded-xl bg-space-850 border border-white/10 flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-mono text-emerald-400 font-semibold uppercase",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{children:"ACTIVE BOT CONSOLE"})]}),e.jsx("div",{className:"text-xs font-semibold text-pearl-50 truncate mt-0.5",children:b.name}),e.jsxs("div",{className:"text-[10px] font-mono text-[#2481CC] truncate",children:["@",b.username]})]}),e.jsx(A,{to:"/dashboard/bots",onClick:r,className:"text-[10px] font-mono text-pearl-400 hover:text-[#2481CC] px-2 py-1 rounded bg-white/5 shrink-0",title:"Switch Bot",children:"Switch"})]}),x(!0),e.jsxs("div",{className:"p-4 border-t border-white/10 bg-space-900/50 space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs font-mono text-pearl-400",children:[e.jsxs(A,{to:"/pricing",onClick:r,className:"hover:text-[#2481CC] flex items-center gap-1.5",children:[e.jsx(J,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{children:"Pricing"})]}),e.jsxs("button",{onClick:j,className:"hover:text-[#2481CC] flex items-center gap-1.5 text-pearl-300 transition-colors",title:"Toggle Theme",children:[o==="light"?e.jsx(De,{className:"w-3.5 h-3.5 text-slate-700"}):e.jsx(Fe,{className:"w-3.5 h-3.5 text-amber-400"}),e.jsx("span",{children:o==="light"?"Dark":"Light"})]}),e.jsxs(A,{to:"/login",onClick:r,className:"hover:text-[#2481CC] flex items-center gap-1.5",children:[e.jsx(ct,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{children:"Login"})]})]}),e.jsxs("div",{className:"p-3 rounded bg-space-850/80 border border-white/10",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] font-mono text-pearl-400 mb-1",children:[e.jsx("span",{children:"TIER"}),e.jsx("span",{className:"text-[#2481CC] font-semibold",children:"PRO ENTERPRISE"})]}),e.jsx("div",{className:"w-full bg-space-800 rounded-full h-1 overflow-hidden",children:e.jsx("div",{className:"bg-[#2481CC] h-1 w-[40%]"})}),e.jsxs("div",{className:"flex items-center justify-between text-[9px] font-mono text-pearl-400/80 mt-1.5",children:[e.jsx("span",{children:"4 / 10 Bots Active"}),e.jsx("span",{children:"40%"})]})]})]})]}),e.jsxs("aside",{className:`hidden md:flex fixed top-0 left-0 bottom-0 z-40 bg-space-900/95 backdrop-blur-2xl border-r border-white/10 flex-col transition-all duration-300 ${n?"w-20":"w-64"}`,children:[e.jsx("div",{className:"h-20 border-b border-white/10 px-5 flex items-center justify-between",children:n?e.jsx(A,{to:"/",className:"w-10 h-10 mx-auto rounded-xl bg-[#2481CC] text-white flex items-center justify-center font-sans font-bold shadow-telegram",title:"TeleBot Cloud",children:e.jsx(oe,{className:"w-5 h-5 text-white -rotate-12 translate-x-0.5"})}):e.jsxs(A,{to:"/",className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-xl bg-[#2481CC] text-white flex items-center justify-center font-sans font-bold text-base shadow-telegram",children:e.jsx(oe,{className:"w-4 h-4 text-white -rotate-12 translate-x-0.5"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"font-sans text-sm tracking-tight text-pearl-50 font-bold leading-tight",children:["TeleBot",e.jsx("span",{className:"text-[#2481CC]",children:"Cloud"})]}),e.jsx("div",{className:"text-[10px] font-mono text-[#2481CC] uppercase tracking-wide font-medium",children:"Telegram Bot Builder"})]})]})}),!n&&b?e.jsxs("div",{className:"mx-3 mt-3 p-2.5 rounded-xl bg-space-850/80 border border-white/10 flex items-center justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[9px] font-mono text-emerald-400 font-semibold uppercase",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{children:"ACTIVE BOT CONSOLE"})]}),e.jsx("div",{className:"text-xs font-semibold text-pearl-50 truncate mt-0.5",children:b.name}),e.jsxs("div",{className:"text-[10px] font-mono text-[#2481CC] truncate",children:["@",b.username]})]}),e.jsx(A,{to:"/dashboard/bots",className:"text-[10px] font-mono text-pearl-400 hover:text-[#2481CC] px-2 py-1 rounded bg-white/5 shrink-0 ml-1",title:"Switch Bot",children:"Switch"})]}):n&&b?e.jsx("div",{className:"mx-auto mt-2 text-center",title:`Active Bot: ${b.name} (@${b.username})`,children:e.jsxs("div",{className:"w-8 h-8 mx-auto rounded-lg bg-[#2481CC]/15 border border-[#2481CC]/40 flex items-center justify-center text-[#2481CC] relative",children:[e.jsx(Q,{className:"w-4 h-4"}),e.jsx("span",{className:"absolute -top-0.5 -right-0.5 w-2 h-2 rounded-full bg-emerald-400 animate-pulse"})]})}):null,x(!1),e.jsxs("div",{className:"p-3 border-t border-white/10 bg-space-900/50",children:[n?e.jsxs("div",{className:"flex flex-col items-center gap-2",children:[e.jsx(A,{to:"/login",title:"Sign In",className:"text-pearl-400 hover:text-[#2481CC] p-1",children:e.jsx(ct,{className:"w-4 h-4"})}),e.jsx("div",{className:"w-2 h-2 rounded-full bg-emerald-400 mx-auto",title:"System Operational"})]}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between text-[11px] font-mono text-pearl-400 px-1",children:[e.jsxs(A,{to:"/pricing",className:"hover:text-[#2481CC] flex items-center gap-1",children:[e.jsx(J,{className:"w-3 h-3 text-[#2481CC]"}),e.jsx("span",{children:"Pricing"})]}),e.jsxs("button",{onClick:j,className:"hover:text-[#2481CC] flex items-center gap-1 text-pearl-300 transition-colors",title:"Toggle Theme",children:[o==="light"?e.jsx(De,{className:"w-3 h-3 text-slate-700"}):e.jsx(Fe,{className:"w-3 h-3 text-amber-400"}),e.jsx("span",{children:o==="light"?"Dark":"Light"})]}),e.jsxs(A,{to:"/login",className:"hover:text-[#2481CC] flex items-center gap-1",children:[e.jsx(ct,{className:"w-3 h-3 text-[#2481CC]"}),e.jsx("span",{children:"Login"})]})]}),e.jsxs("div",{className:"p-3 rounded bg-space-850/80 border border-white/10",children:[e.jsxs("div",{className:"flex items-center justify-between text-[10px] font-mono text-pearl-400 mb-1",children:[e.jsx("span",{children:"TIER"}),e.jsx("span",{className:"text-[#2481CC] font-semibold",children:"PRO ENTERPRISE"})]}),e.jsx("div",{className:"w-full bg-space-800 rounded-full h-1 overflow-hidden",children:e.jsx("div",{className:"bg-[#2481CC] h-1 w-[40%]"})}),e.jsxs("div",{className:"flex items-center justify-between text-[9px] font-mono text-pearl-400/80 mt-1.5",children:[e.jsx("span",{children:"4 / 10 Bots Active"}),e.jsx("span",{children:"40%"})]})]})]}),e.jsx("button",{onClick:a,className:"mt-2 w-full py-2 flex items-center justify-center text-pearl-400 hover:text-[#2481CC] hover:bg-space-850 rounded-xl transition-colors text-xs",title:n?"Expand Sidebar":"Collapse Sidebar",children:n?e.jsx(Te,{className:"w-4 h-4"}):e.jsx(Ca,{className:"w-4 h-4"})})]})]})]})},xa=[{code:"en",name:"English",nativeName:"English",flag:"🇬🇧",isRtl:!1},{code:"hi",name:"Hindi",nativeName:"हिंदी",flag:"🇮🇳",isRtl:!1},{code:"hi-Latn",name:"Hinglish",nativeName:"Hinglish",flag:"🇮🇳",isRtl:!1},{code:"sa",name:"Sanskrit",nativeName:"संस्कृतम्",flag:"🕉️",isRtl:!1},{code:"ar",name:"Arabic",nativeName:"العربية",flag:"🇸🇦",isRtl:!0},{code:"ur",name:"Urdu",nativeName:"اردو",flag:"🇵🇰",isRtl:!0},{code:"bn",name:"Bengali",nativeName:"বাংলা",flag:"🇧🇩",isRtl:!1},{code:"ta",name:"Tamil",nativeName:"தமிழ்",flag:"🇮🇳",isRtl:!1},{code:"te",name:"Telugu",nativeName:"తెలుగు",flag:"🇮🇳",isRtl:!1},{code:"mr",name:"Marathi",nativeName:"मराठी",flag:"🇮🇳",isRtl:!1},{code:"gu",name:"Gujarati",nativeName:"ગુજરાતી",flag:"🇮🇳",isRtl:!1},{code:"es",name:"Spanish",nativeName:"Español",flag:"🇪🇸",isRtl:!1},{code:"fr",name:"French",nativeName:"Français",flag:"🇫🇷",isRtl:!1},{code:"de",name:"German",nativeName:"Deutsch",flag:"🇩🇪",isRtl:!1},{code:"ru",name:"Russian",nativeName:"Русский",flag:"🇷🇺",isRtl:!1},{code:"ja",name:"Japanese",nativeName:"日本語",flag:"🇯🇵",isRtl:!1}],pa="en",bs=t=>{const s=xa.find(n=>n.code===t);return s?s.isRtl:!1},Hn={title:"Telegram SaaS Platform",overview:"Overview",bots:"Connected Bots",users:"Active Users",analytics:"Analytics",billing:"Billing & Plans",settings:"Workspace Settings"},Gn={save:"Save Changes",cancel:"Cancel",delete:"Delete",connect_bot:"Connect New Bot"},zn={dashboard:Hn,actions:Gn},Wn={title:"टेलीग्राम सास प्लेटफॉर्म",overview:"अवलोकन",bots:"कनेक्टेड बॉट्स",users:"सक्रिय उपयोगकर्ता",analytics:"एनालिटिक्स",billing:"बिलिंग और योजनाएं",settings:"कार्यस्थान सेटिंग्स"},qn={save:"परिवर्तन सहेजें",cancel:"रद्द करें",delete:"हटाएं",connect_bot:"नया बॉट जोड़ें"},Jn={dashboard:Wn,actions:qn},Yn={title:"Telegram SaaS Manch",overview:"Kul Jaankari",bots:"Jude Hue Bots",users:"Sakriya Users",analytics:"Stats aur Analytics",billing:"Billing aur Plans",settings:"Workspace Settings Badlein"},Kn={save:"Changes Save Karein",cancel:"Radd Karein",delete:"Delete Karein",connect_bot:"Naya Bot Connect Karein"},Qn={dashboard:Yn,actions:Kn},Zn={title:"टेलीग्राम सास मञ्चम्",overview:"सिंहावलोकनम्",bots:"संयोजिताः बॉट्स",users:"सक्रियाः प्रयोक्तारः",analytics:"विश्लेषणम्",billing:"शुल्कम् च योजनाः",settings:"कार्यस्थान व्यवस्था"},Xn={save:"परिवर्तनानि रक्षतु",cancel:"निरसयतु",delete:"मार्जयतु",connect_bot:"नवीन बॉट योजयतु"},el={dashboard:Zn,actions:Xn},tl={title:"منصة تيليجرام ساس",overview:"نظرة عامة",bots:"البوتات المتصلة",users:"المستخدمون النشطون",analytics:"التحليلات",billing:"الفواتير والخطط",settings:"إعدادات مساحة العمل"},sl={save:"حفظ التغييرات",cancel:"إلغاء",delete:"حذف",connect_bot:"ربط بوت جديد"},al={dashboard:tl,actions:sl},rl={title:"ٹیلیگرام ساس پلیٹ فارم",overview:"جائزہ",bots:"منسلک بوٹس",users:"فعال صارفین",analytics:"تجزیات",billing:"بلنگ اور منصوبے",settings:"ورک اسپیس کی ترتیبات"},nl={save:"تبدیلیاں محفوظ کریں",cancel:"منسوخ کریں",delete:"حذف کریں",connect_bot:"نیا بوٹ شامل کریں"},ll={dashboard:rl,actions:nl},il={title:"টেলিগ্রাম সাস প্ল্যাটফর্ম",overview:"সারসংক্ষেপ",bots:"সংযুক্ত বট",users:"সক্রিয় ব্যবহারকারী",analytics:"বিশ্লেষণ",billing:"বিলিং এবং পরিকল্পনা",settings:"ওয়ার্কস্পেস সেটিংস"},ol={save:"সংরক্ষণ করুন",cancel:"বাতিল",delete:"মুছুন",connect_bot:"নতুন বট সংযুক্ত করুন"},cl={dashboard:il,actions:ol},dl={title:"டெலிகிராம் SaaS தளம்",overview:"மேலோட்டம்",bots:"இணைக்கப்பட்ட பாட்கள்",users:"செயலில் உள்ள பயனர்கள்",analytics:"பகுப்பாய்வு",billing:"பில்லிங் & திட்டங்கள்",settings:"பணிவெளி அமைப்புகள்"},ml={save:"மாற்றங்களைச் சேமி",cancel:"ரத்து செய்",delete:"நீக்கு",connect_bot:"புதிய பாட் இணைக்கவும்"},xl={dashboard:dl,actions:ml},pl={title:"టెలిగ్రామ్ SaaS ప్లాట్‌ఫారమ్",overview:"అవలోకనం",bots:"కనెక్ట్ చేయబడిన బాట్లు",users:"క్రియాశీల వినియోగదారులు",analytics:"విశ్లేషణలు",billing:"బిల్లింగ్ & ప్లాన్లు",settings:"వర్క్‌స్పేస్ సెట్టింగులు"},ul={save:"మార్పులను సేవ్ చేయండి",cancel:"రద్దు చేయండి",delete:"తొలగించండి",connect_bot:"కొత్త బాట్ కనెక్ట్ చేయండి"},hl={dashboard:pl,actions:ul},bl={title:"टेलिग्राम SaaS प्लॅटफॉर्म",overview:"आढावा",bots:"कनेक्ट केलेले बॉट्स",users:"सक्रिय वापरकर्ते",analytics:"अ‍ॅनालिटिक्स",billing:"बिलिंग आणि योजना",settings:"वर्कस्पेस सेटिंग्ज"},fl={save:"बदल जतन करा",cancel:"रद्द करा",delete:"हटवा",connect_bot:"नवीन बॉट कनेक्ट करा"},gl={dashboard:bl,actions:fl},jl={title:"ટેલિગ્રામ SaaS પ્લેટફોર્મ",overview:"અવલોકન",bots:"જોડાયેલા બોટ્સ",users:"સક્રિય વપરાશકર્તાઓ",analytics:"એનાલિટિક્સ",billing:"બિલિંગ અને યોજનાઓ",settings:"વર્કસ્પેસ સેટિંગ્સ"},vl={save:"ફેરફારો સાચવો",cancel:"રદ કરો",delete:"કાઢી નાખો",connect_bot:"નવું બોટ જોડો"},wl={dashboard:jl,actions:vl},Nl={title:"Plataforma SaaS de Telegram",overview:"Visión General",bots:"Bots Conectados",users:"Usuarios Activos",analytics:"Analítica",billing:"Facturación y Planes",settings:"Configuración del Espacio de Trabajo"},yl={save:"Guardar Cambios",cancel:"Cancelar",delete:"Eliminar",connect_bot:"Conectar Nuevo Bot"},Cl={dashboard:Nl,actions:yl},kl={title:"Plateforme SaaS Telegram",overview:"Vue d'ensemble",bots:"Bots Connectés",users:"Utilisateurs Actifs",analytics:"Analytique",billing:"Facturation & Plans",settings:"Paramètres de l'Espace de Travail"},Sl={save:"Enregistrer les Modifications",cancel:"Annuler",delete:"Supprimer",connect_bot:"Connecter un Nouveau Bot"},_l={dashboard:kl,actions:Sl},Tl={title:"Telegram SaaS-Plattform",overview:"Übersicht",bots:"Verbundene Bots",users:"Aktive Benutzer",analytics:"Analytik",billing:"Abrechnung & Tarife",settings:"Arbeitsbereich-Einstellungen"},Al={save:"Änderungen speichern",cancel:"Abbrechen",delete:"Löschen",connect_bot:"Neuen Bot verbinden"},Pl={dashboard:Tl,actions:Al},Il={title:"Telegram SaaS-платформа",overview:"Обзор",bots:"Подключенные боты",users:"Активные пользователи",analytics:"Аналитика",billing:"Тарифы и оплата",settings:"Настройки рабочей области"},El={save:"Сохранить изменения",cancel:"Отмена",delete:"Удалить",connect_bot:"Подключить нового бота"},Rl={dashboard:Il,actions:El},Ml={title:"Telegram SaaS プラットフォーム",overview:"概要",bots:"接続済みボット",users:"アクティブユーザー",analytics:"アナリティクス",billing:"請求とプラン",settings:"ワークスペース設定"},Ll={save:"変更を保存",cancel:"キャンセル",delete:"削除",connect_bot:"新しいボットを接続"},Bl={dashboard:Ml,actions:Ll},fs={en:zn,hi:Jn,"hi-Latn":Qn,sa:el,ar:al,ur:ll,bn:cl,ta:xl,te:hl,mr:gl,gu:wl,es:Cl,fr:_l,de:Pl,ru:Rl,ja:Bl},Ol=(t,s)=>{const[n,a]=s.split("."),l=fs[t]||fs[pa];return!l||!l[n]?a||s:l[n][a]||a},Dl=()=>{const[t,s]=i.useState(()=>localStorage.getItem("saas_locale")||pa),n=bs(t),a=i.useCallback(r=>{s(r),localStorage.setItem("saas_locale",r),document.documentElement.lang=r,document.documentElement.dir=bs(r)?"rtl":"ltr"},[]);i.useEffect(()=>{document.documentElement.lang=t,document.documentElement.dir=n?"rtl":"ltr"},[t,n]);const l=i.useCallback(r=>Ol(t,r),[t]);return{currentLocale:t,isRtl:n,setLanguage:a,t:l,supportedLanguages:xa}},Fl=()=>{const{currentLocale:t,setLanguage:s,supportedLanguages:n}=Dl();return e.jsx("div",{className:"relative inline-block text-left",children:e.jsx("select",{value:t,onChange:a=>s(a.target.value),className:"block w-auto max-w-[80px] xs:max-w-[110px] sm:max-w-[150px] md:max-w-none rounded-lg border border-white/10 bg-space-900 py-1 sm:py-1.5 pl-2 pr-6 text-[11px] sm:text-xs font-mono text-pearl-100 shadow-sm focus:border-[#2481CC] focus:ring-1 focus:ring-[#2481CC] focus:outline-none cursor-pointer truncate","aria-label":"Select Language",children:n.map(a=>e.jsxs("option",{value:a.code,children:[a.flag," ",a.name]},a.code))})})},$l=({currentView:t,currentBotName:s,onSelectBotModal:n,collapsed:a,onOpenMobileMenu:l})=>{var L;const{user:r,isAuthenticated:o,logout:j}=qe(),{theme:b,toggleTheme:m}=nt(),{currentBot:x,bots:f,selectBot:p}=z();ue();const[g,u]=i.useState(3),[d,c]=i.useState(!1),[v,h]=i.useState(!1),[N,y]=i.useState(""),E=i.useRef(null);i.useEffect(()=>{const M=_=>{E.current&&!E.current.contains(_.target)&&h(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[]);const w=(f||[]).filter(M=>M.name.toLowerCase().includes(N.toLowerCase())||M.username.toLowerCase().includes(N.toLowerCase())),[S,P]=i.useState([{id:"n-1",title:"Broadcast Campaign Completed",message:"Spring Flash Sale 2026 dispatched successfully to 14,280 recipients with 99.8% delivery.",type:"broadcast",priority:"normal",is_read:!1,created_at:new Date(Date.now()-1e3*60*15).toISOString()},{id:"n-2",title:"AI Usage Limit Warning",message:"Monthly AI token consumption reached 65% of Pro tier limit (650,000 / 1,000,000 tokens).",type:"billing",priority:"high",is_read:!1,created_at:new Date(Date.now()-1e3*60*120).toISOString()},{id:"n-3",title:"Crypto Price Plugin Triggered",message:"BTC/USD threshold crossed $96,000. Automated alert broadcast executed.",type:"plugin",priority:"low",is_read:!1,created_at:new Date(Date.now()-1e3*60*360).toISOString()}]);i.useEffect(()=>{fetch("/api/v1/notifications/unread-count").then(M=>M.ok?M.json():null).then(M=>{var _;((_=M==null?void 0:M.data)==null?void 0:_.unread_count)!==void 0&&u(M.data.unread_count)}).catch(()=>{})},[]);const k=async()=>{const M=S.filter(_=>!_.is_read).map(_=>_.id);if(M.length>0)try{await fetch("/api/v1/notifications/mark-read",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({notification_ids:M})})}catch{}P(_=>_.map(Y=>({...Y,is_read:!0}))),u(0)};return e.jsxs("header",{className:`fixed top-0 right-0 z-30 h-16 sm:h-20 bg-space-900/95 backdrop-blur-md border-b border-white/10 px-3 sm:px-6 flex items-center justify-between transition-all duration-300 left-0 ${a?"md:left-20":"md:left-64"}`,children:[e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 min-w-0 max-w-[40%] xs:max-w-[45%] sm:max-w-none",children:[e.jsx("button",{onClick:l,className:"p-1.5 sm:p-2 -ml-1 text-pearl-300 hover:text-[#2481CC] hover:bg-white/5 rounded-lg md:hidden transition-colors shrink-0","aria-label":"Open mobile navigation",children:e.jsx(_s,{className:"w-5 h-5"})}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 text-xs font-mono tracking-widest text-pearl-400 truncate",children:[e.jsx(A,{to:"/",className:"hover:text-[#2481CC] transition-colors shrink-0 font-semibold text-[#2481CC]",children:"TELEBOT"}),e.jsx("span",{className:"text-[#2481CC]/60",children:"/"}),e.jsx(A,{to:wt[t]||"/dashboard",className:"text-pearl-200 uppercase hover:text-[#2481CC] transition-colors truncate",children:t.replace("-"," ")})]}),e.jsx(A,{to:"/",className:"sm:hidden font-sans text-xs text-pearl-100 uppercase tracking-wide truncate font-bold hover:text-[#2481CC] min-w-0",children:t.replace("-"," ")})]}),e.jsxs("div",{className:"flex items-center gap-1.5 sm:gap-2.5 md:gap-4 shrink-0",children:[e.jsxs("div",{className:"relative shrink-0",ref:E,children:[e.jsxs("button",{type:"button",onClick:()=>h(!v),className:"flex items-center gap-1.5 sm:gap-2 px-2 sm:px-3 py-1.5 rounded-lg bg-space-850/90 border border-white/10 text-xs font-mono text-pearl-100 hover:border-[#2481CC]/50 hover:bg-[#2481CC]/10 transition-colors shadow-sm",title:"Switch Telegram Bot Console (Play Console Architecture)",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse shrink-0"}),e.jsxs("div",{className:"text-left hidden sm:block",children:[e.jsx("div",{className:"font-sans font-semibold text-pearl-50 text-[11px] leading-tight truncate max-w-[120px] md:max-w-[160px]",children:(x==null?void 0:x.name)||s}),e.jsxs("div",{className:"text-[9px] font-mono text-[#2481CC] leading-tight truncate max-w-[120px] md:max-w-[160px]",children:["@",(x==null?void 0:x.username)||"bot"]})]}),e.jsxs("span",{className:"sm:hidden font-sans font-semibold text-xs text-pearl-50 truncate max-w-[85px]",children:["@",(x==null?void 0:x.username)||"bot"]}),e.jsx(Vt,{className:`w-3.5 h-3.5 text-pearl-400 ml-0.5 transition-transform shrink-0 ${v?"rotate-180 text-[#2481CC]":""}`})]}),v&&e.jsxs("div",{className:"fixed sm:absolute left-3 right-3 sm:left-auto sm:right-0 top-18 sm:top-full mt-2 w-auto sm:w-80 md:w-88 bg-space-900 border border-white/15 rounded-2xl shadow-2xl z-50 p-3 sm:p-4 space-y-2.5 backdrop-blur-2xl animate-in fade-in zoom-in-95 max-w-sm sm:max-w-none",children:[e.jsxs("div",{className:"flex items-center justify-between pb-2 border-b border-white/10",children:[e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx(Q,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{className:"text-[10px] font-mono tracking-wider text-pearl-300 uppercase font-semibold",children:"Chosen Bot Workspace"})]}),e.jsxs("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded bg-emerald-500/10 text-emerald-400 border border-emerald-500/20",children:[(f==null?void 0:f.length)||4," BOTS"]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(He,{className:"w-3.5 h-3.5 absolute left-2.5 top-1/2 -translate-y-1/2 text-pearl-400"}),e.jsx("input",{type:"text",value:N,onChange:M=>y(M.target.value),placeholder:"Filter bots by name...",className:"w-full pl-8 pr-3 py-1.5 rounded-lg bg-space-950 border border-white/10 text-xs font-mono text-pearl-100 placeholder:text-pearl-400/60 focus:outline-none focus:border-[#2481CC]",autoFocus:!0})]}),e.jsx("div",{className:"max-h-56 overflow-y-auto space-y-1 pr-1 custom-scrollbar",children:w.map(M=>{const _=M.id===(x==null?void 0:x.id);return e.jsxs("button",{onClick:()=>{p(M.id),h(!1)},className:`w-full flex items-center justify-between p-2 rounded-lg text-left transition-colors ${_?"bg-[#2481CC]/15 border border-[#2481CC]/40 text-white":"hover:bg-space-850 text-pearl-200 border border-transparent"}`,children:[e.jsxs("div",{className:"flex items-center gap-2.5 min-w-0",children:[e.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${_?"bg-[#2481CC] text-white shadow-telegram":"bg-space-800 text-pearl-300"}`,children:e.jsx(Q,{className:"w-4 h-4"})}),e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"text-xs font-semibold text-pearl-50 truncate flex items-center gap-1.5",children:[e.jsx("span",{children:M.name}),_&&e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-emerald-400 animate-pulse"})]}),e.jsxs("div",{className:"text-[10px] font-mono text-[#2481CC] truncate",children:["@",M.username]})]})]}),e.jsx("div",{className:"text-right shrink-0 ml-2",children:_?e.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.5 rounded bg-[#2481CC]/25 text-[#2481CC] font-semibold",children:"ACTIVE"}):e.jsxs("span",{className:"text-[9px] font-mono text-pearl-400",children:[M.usersCount.toLocaleString()," users"]})})]},M.id)})}),e.jsxs("div",{className:"pt-2 border-t border-white/10 flex items-center justify-between gap-2",children:[e.jsxs(A,{to:"/dashboard/bots",onClick:()=>h(!1),className:"text-[11px] font-mono text-[#2481CC] hover:underline flex items-center gap-1",children:[e.jsx(Pe,{className:"w-3 h-3"}),e.jsx("span",{children:"All Bots Fleet"})]}),e.jsxs(A,{to:"/dashboard/bots",onClick:()=>h(!1),className:"btn-telegram-primary py-1 px-2.5 text-[10px] font-mono inline-flex items-center gap-1 shadow-telegram",children:[e.jsx(ee,{className:"w-3 h-3"}),e.jsx("span",{children:"Connect Bot"})]})]})]})]}),e.jsxs("div",{className:"hidden lg:flex items-center gap-2 px-3 py-1 rounded-full bg-emerald-500/10 border border-emerald-500/30 text-[10px] font-mono uppercase tracking-wider text-emerald-300",children:[e.jsx(pe,{className:"w-3 h-3 animate-pulse text-emerald-400"}),e.jsx("span",{children:"4 BOTS ONLINE"})]}),e.jsx("div",{className:"relative shrink-0 hidden md:block",children:e.jsx(Fl,{})}),e.jsx("div",{className:"relative shrink-0",children:e.jsx("button",{id:"top-navbar-theme-toggle",onClick:m,className:"p-1.5 sm:p-2 rounded-lg bg-space-850 border border-white/10 text-pearl-300 hover:text-[#2481CC] hover:border-[#2481CC]/40 transition-colors relative flex items-center justify-center",title:b==="light"?"Switch to Rich Slate Dark Theme":"Switch to Clean Light Theme","aria-label":"Toggle theme",children:b==="light"?e.jsx(De,{className:"w-4 h-4 text-slate-700"}):e.jsx(Fe,{className:"w-4 h-4 text-amber-400"})})}),e.jsxs("div",{className:"relative shrink-0",children:[e.jsxs("button",{onClick:()=>c(!d),className:"p-1.5 sm:p-2 rounded-lg bg-space-850 border border-white/10 text-pearl-300 hover:text-[#2481CC] hover:border-[#2481CC]/40 transition-colors relative",title:"Notifications",children:[e.jsx(Ia,{className:"w-4 h-4"}),g>0&&e.jsx("span",{className:"absolute -top-1 -right-1 w-4 h-4 rounded-full bg-[#2481CC] text-white text-[9px] font-mono font-bold flex items-center justify-center shadow-sm",children:g})]}),d&&e.jsxs("div",{className:"fixed sm:absolute left-3 right-3 sm:left-auto sm:right-0 top-18 sm:top-full mt-2 w-auto sm:w-80 md:w-96 max-w-sm sm:max-w-none astraea-card rounded-2xl p-3 sm:p-4 border border-[#2481CC]/30 shadow-2xl z-50 animate-in fade-in duration-200",children:[e.jsxs("div",{className:"flex items-center justify-between pb-3 border-b border-white/10 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-sans tracking-wide text-pearl-50 uppercase font-semibold",children:"In-App Alerts"}),g>0&&e.jsxs("span",{className:"px-1.5 py-0.5 rounded text-[9px] font-mono bg-[#2481CC]/20 text-[#2481CC] border border-[#2481CC]/30 font-semibold",children:[g," UNREAD"]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[g>0&&e.jsxs("button",{onClick:k,className:"text-[10px] font-mono text-[#2481CC] hover:underline flex items-center gap-1 font-medium",children:[e.jsx(D,{className:"w-3 h-3"})," Mark all read"]}),e.jsx("button",{onClick:()=>c(!1),className:"text-pearl-400 hover:text-pearl-100",children:e.jsx(H,{className:"w-4 h-4"})})]})]}),e.jsx("div",{className:"space-y-2.5 max-h-80 overflow-y-auto pr-1",children:S.map(M=>e.jsxs("div",{className:`p-3 rounded-xl border text-xs font-mono transition-colors ${M.is_read?"bg-space-900/40 border-white/5 text-pearl-400":"bg-space-850 border-[#2481CC]/30 text-pearl-100 shadow-sm"}`,children:[e.jsxs("div",{className:"flex items-center justify-between font-semibold text-pearl-50 text-[11px] mb-1",children:[e.jsx("span",{className:"truncate",children:M.title}),e.jsx("span",{className:"text-[9px] text-pearl-400 shrink-0 ml-2",children:new Date(M.created_at).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})})]}),e.jsx("p",{className:"text-[11px] text-pearl-300 leading-relaxed font-sans",children:M.message})]},M.id))})]})]}),o&&r?e.jsxs("div",{className:"flex items-center gap-2.5 pl-3 border-l border-white/10",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gradient-to-tr from-[#2481CC] to-[#7DD3FC] p-[1px] shadow-sm shrink-0",children:r.avatar_url?e.jsx("img",{src:r.avatar_url,alt:"",className:"w-full h-full rounded-full object-cover"}):e.jsx("div",{className:"w-full h-full rounded-full bg-space-900 flex items-center justify-center text-xs font-mono font-bold text-[#2481CC]",children:((L=r.full_name)==null?void 0:L.slice(0,2).toUpperCase())||"TG"})}),e.jsxs("div",{className:"hidden xl:block text-left",children:[e.jsx("div",{className:"text-xs font-medium text-pearl-100 leading-tight truncate max-w-[120px]",children:r.full_name}),e.jsx("div",{className:"text-[9px] font-mono tracking-wider text-[#2481CC] uppercase font-medium",children:r.telegram_username?`@${r.telegram_username}`:"ACTIVE TENANT"})]}),e.jsx("button",{onClick:j,className:"text-pearl-400 hover:text-rose-400 p-1",title:"Sign Out",children:e.jsx(Ea,{className:"w-4 h-4"})})]}):e.jsxs(A,{to:"/login",className:"flex items-center gap-1.5 sm:gap-2 pl-2 sm:pl-3 border-l border-white/10 btn-telegram-primary py-1 sm:py-1.5 px-2.5 sm:px-3 text-xs shrink-0 shadow-telegram",children:[e.jsx(ct,{className:"w-3.5 h-3.5"}),e.jsx("span",{className:"hidden sm:inline",children:"SIGN IN"})]})]})]})},Ul=[{id:"b-001",name:"Astraea Flagship Super Bot",username:"astraea_flagship_bot",status:"active",usersCount:14280,messages24h:38450,latencyMs:38,color:"#d4af37",orbitRadius:4.2,orbitSpeed:.008,orbitAngle:0,inclination:.25},{id:"b-002",name:"VIP Concierge & Support",username:"vip_concierge_bot",status:"active",usersCount:6890,messages24h:12400,latencyMs:42,color:"#e5c378",orbitRadius:6,orbitSpeed:.006,orbitAngle:Math.PI*.65,inclination:-.35},{id:"b-003",name:"Automated Flash Billing",username:"flash_billing_bot",status:"active",usersCount:9420,messages24h:21100,latencyMs:35,color:"#cbd5e1",orbitRadius:7.8,orbitSpeed:.0045,orbitAngle:Math.PI*1.35,inclination:.45},{id:"b-004",name:"Omni Broadcast Announcer",username:"omni_broadcast_bot",status:"syncing",usersCount:31200,messages24h:89400,latencyMs:48,color:"#94a3b8",orbitRadius:9.5,orbitSpeed:.0035,orbitAngle:Math.PI*1.85,inclination:-.15}],Vl=({bots:t=Ul,selectedBotId:s,onSelectBot:n,onOpenStudio:a,className:l=""})=>{const r=i.useRef(null),[o,j]=i.useState(()=>t.find(g=>g.id===s)||t[0]),[b,m]=i.useState(!0),[x,f]=i.useState(!0);i.useEffect(()=>{if(s){const g=t.find(u=>u.id===s);g&&j(g)}},[s,t]);const p=i.useCallback(g=>{j(g),n&&n(g)},[n]);return i.useEffect(()=>{const g=r.current;if(!g)return;try{const R=document.createElement("canvas");if(!(R.getContext("webgl")||R.getContext("experimental-webgl"))){f(!1);return}}catch{f(!1);return}const u=new ir;u.fog=new or(197896,.025);const d=new cr(45,g.clientWidth/g.clientHeight,.1,1e3);d.position.set(0,7.5,16.5),d.lookAt(0,0,0);const c=new dr({antialias:!0,alpha:!0,powerPreference:"high-performance"});c.setSize(g.clientWidth,g.clientHeight),c.setPixelRatio(Math.min(window.devicePixelRatio,2)),g.appendChild(c.domElement);const v=new mr(16777215,.4);u.add(v);const h=new xr(13938487,2.5,50);h.position.set(0,0,0),u.add(h);const N=new ts(16047262,1.2);N.position.set(12,18,12),u.add(N);const y=new ts(4878245,.8);y.position.set(-15,-10,-10),u.add(y);const E=new pr;u.add(E);const w=new ss(1.4,2),S=new as({color:791330,emissive:13938487,emissiveIntensity:.35,roughness:.2,metalness:.85,wireframe:!1}),P=new kt(w,S);E.add(P);const k=new ss(1.65,1),L=new ur({color:13938487,wireframe:!0,transparent:!0,opacity:.25}),M=new kt(k,L);E.add(M);const _=600,Y=new Float32Array(_*3);for(let R=0;R<_*3;R+=3)Y[R]=(Math.random()-.5)*60,Y[R+1]=(Math.random()-.5)*45,Y[R+2]=(Math.random()-.5)*60;const K=new St;K.setAttribute("position",new hr(Y,3));const ne=new br({color:16316922,size:.12,transparent:!0,opacity:.45}),I=new fr(K,ne);u.add(I);const $=[],O=[];t.forEach(R=>{const re=new gr(0,0,R.orbitRadius,R.orbitRadius,0,2*Math.PI,!1,0).getPoints(120),de=new St().setFromPoints(re.map(Je=>new _t(Je.x,0,Je.y))),xe=new rs({color:R.id===o.id?13938487:16777215,transparent:!0,opacity:R.id===o.id?.45:.1}),se=new ns(de,xe);se.rotation.x=R.inclination,u.add(se);const ye=new jr(.38,32,32),Le=new as({color:R.id===o.id?13938487:2042173,emissive:R.id===o.id?13938487:988970,emissiveIntensity:R.id===o.id?.6:.2,roughness:.3,metalness:.8}),ve=new kt(ye,Le);ve.userData={botId:R.id,botData:R},u.add(ve),O.push(ve);const lt=new St().setFromPoints([new _t(0,0,0),new _t(0,0,0)]),it=new rs({color:13938487,transparent:!0,opacity:R.id===o.id?.35:.08}),be=new ns(lt,it);u.add(be),$.push({bot:R,mesh:ve,ring:se,line:be,currentAngle:R.orbitAngle})});const le=new Nr,he=new wr;let Z=null,Se=0,_e=7.5;const Ee=R=>{const V=g.getBoundingClientRect();he.x=(R.clientX-V.left)/V.width*2-1,he.y=-((R.clientY-V.top)/V.height)*2+1,Se=he.x*2.5,_e=7.5+he.y*1.5,le.setFromCamera(he,d);const re=le.intersectObjects(O);if(re.length>0){const de=re[0].object;Z!==de&&(Z=de,g.style.cursor="pointer")}else Z&&(Z=null,g.style.cursor="default")},Ne=()=>{var R;Z&&((R=Z.userData)!=null&&R.botData)&&p(Z.userData.botData)};g.addEventListener("mousemove",Ee),g.addEventListener("click",Ne);let Re,Me=new vr;const C=()=>{Re=requestAnimationFrame(C),Me.getDelta(),d.position.x+=(Se-d.position.x)*.04,d.position.y+=(_e-d.position.y)*.04,d.lookAt(0,0,0),E.rotation.y+=.005,M.rotation.x-=.003,M.rotation.z+=.004,I.rotation.y+=3e-4,$.forEach(R=>{b&&(R.currentAngle+=R.bot.orbitSpeed);const V=Math.cos(R.currentAngle)*R.bot.orbitRadius,re=Math.sin(R.currentAngle)*R.bot.orbitRadius,de=Math.sin(R.currentAngle)*Math.sin(R.bot.inclination)*1.8;R.mesh.position.set(V,de,re);const xe=R.line.geometry.attributes.position;xe.setXYZ(1,V,de,re),xe.needsUpdate=!0;const se=R.bot.id===o.id,ye=R.mesh.material;ye.color.setHex(se?13938487:2042173),ye.emissive.setHex(se?13938487:988970),ye.emissiveIntensity=se?.75:.2;const Le=R.ring.material;Le.color.setHex(se?13938487:16777215),Le.opacity=se?.45:.1;const ve=R.line.material;ve.opacity=se?.35:.08}),c.render(u,d)};C();const B=()=>{g&&(d.aspect=g.clientWidth/g.clientHeight,d.updateProjectionMatrix(),c.setSize(g.clientWidth,g.clientHeight))};return window.addEventListener("resize",B),()=>{cancelAnimationFrame(Re),window.removeEventListener("resize",B),g.removeEventListener("mousemove",Ee),g.removeEventListener("click",Ne),c.dispose(),c.domElement.parentNode&&c.domElement.parentNode.removeChild(c.domElement)}},[t,o.id,b,p]),e.jsxs("div",{className:`relative overflow-hidden rounded-xl border border-white/10 astraea-panel w-full max-w-full min-w-0 ${l}`,children:[e.jsx("div",{className:"absolute inset-0 cosmic-radial-bg pointer-events-none"}),x?e.jsx("div",{ref:r,className:"w-full h-[400px] sm:h-[480px] md:h-[540px] relative select-none"}):e.jsx("div",{className:"w-full h-[400px] sm:h-[480px] md:h-[540px] flex items-center justify-center p-8",children:e.jsxs("div",{className:"text-center max-w-md",children:[e.jsx(Q,{className:"w-12 h-12 text-[#2481CC] mx-auto mb-4 animate-pulse"}),e.jsx("h3",{className:"text-lg font-bold tracking-tight text-pearl-100 uppercase",children:"Constellation Bot Cluster"}),e.jsx("p",{className:"text-xs text-pearl-400 mt-2",children:"Hardware accelerated WebGL view simplified for optimal device efficiency."})]})}),e.jsxs("div",{className:"absolute top-4 sm:top-5 left-4 sm:left-6 right-4 sm:right-6 flex items-center justify-between pointer-events-none",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#2481CC] animate-ping"}),e.jsx("span",{className:"text-[10px] font-mono tracking-wider text-[#2481CC] uppercase font-semibold",children:"Neural Constellation Mesh"})]}),e.jsx("h2",{className:"text-lg sm:text-xl md:text-2xl text-pearl-50 tracking-tight font-bold mt-0.5",children:"Dynamic Bot Orbit"})]}),e.jsxs("div",{className:"flex items-center gap-2 sm:gap-3 pointer-events-auto",children:[e.jsxs("button",{onClick:()=>m(!b),className:"btn-telegram-secondary py-1 px-2.5 sm:px-3 text-[10px] sm:text-[11px] gap-1.5",title:b?"Pause Orbit":"Resume Orbit",children:[e.jsx(me,{className:`w-3.5 h-3.5 ${b?"animate-spin":""}`,style:{animationDuration:"6s"}}),e.jsx("span",{children:b?"ORBIT ACTIVE":"PAUSED"})]}),e.jsxs("div",{className:"hidden sm:flex items-center gap-2 px-3 py-1 rounded-lg bg-black/40 border border-white/10 text-xs font-mono text-pearl-300",children:[e.jsx(Ie,{className:"w-3.5 h-3.5 text-emerald-400"}),e.jsxs("span",{children:[t.length," NODES LINKED"]})]})]})]}),e.jsx("div",{className:"absolute top-20 sm:top-24 left-4 sm:left-6 right-4 sm:right-auto flex flex-wrap gap-1.5 sm:gap-2 pointer-events-auto max-h-24 overflow-y-auto sm:max-h-none scrollbar-none",children:t.map(g=>{const u=g.id===o.id;return e.jsxs("button",{onClick:()=>p(g),className:`px-2.5 py-1 sm:px-3 sm:py-1.5 rounded-lg text-[10px] sm:text-[11px] font-mono tracking-wider transition-all flex items-center gap-1.5 sm:gap-2 ${u?"bg-[#2481CC] border border-[#2481CC] text-white shadow-sm font-semibold":"bg-space-900/60 border border-white/10 text-pearl-400 hover:text-pearl-100 hover:border-white/25"}`,children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${g.status==="active"?"bg-emerald-400":"bg-amber-400"}`}),e.jsx("span",{children:g.name.split(" ")[0]})]},g.id)})}),e.jsx("div",{className:"absolute bottom-3 sm:bottom-5 left-3 sm:left-6 right-3 sm:right-6 pointer-events-auto",children:e.jsxs("div",{className:"astraea-card rounded-2xl p-3 sm:p-4 md:p-5 flex flex-col md:flex-row items-start md:items-center justify-between gap-3 sm:gap-4 border border-[#2481CC]/30 shadow-xl",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-xl bg-[#2481CC]/10 border border-[#2481CC]/30 flex items-center justify-center shrink-0",children:e.jsx(Q,{className:"w-6 h-6 text-[#2481CC]"})}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-mono text-[#2481CC] font-semibold",children:["@",o.username]}),e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono uppercase bg-emerald-500/10 border border-emerald-500/30 text-emerald-300 font-semibold",children:o.status}),e.jsxs("span",{className:"hidden sm:inline-flex items-center gap-1 text-[10px] font-mono text-pearl-400",children:[e.jsx(q,{className:"w-3 h-3 text-[#2481CC]"})," AES-256 Validated"]})]}),e.jsx("h3",{className:"text-base sm:text-lg text-pearl-50 font-bold tracking-tight mt-0.5",children:o.name})]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3 sm:gap-6 md:gap-8 text-xs font-mono w-full md:w-auto justify-between md:justify-start",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase text-pearl-400 tracking-wider",children:"Active Audience"}),e.jsx("div",{className:"text-sm font-semibold text-pearl-100 mt-0.5",children:o.usersCount.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase text-pearl-400 tracking-wider",children:"24h Messages"}),e.jsx("div",{className:"text-sm font-semibold text-pearl-100 mt-0.5",children:o.messages24h.toLocaleString()})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] uppercase text-pearl-400 tracking-wider",children:"Response Latency"}),e.jsxs("div",{className:"text-sm font-semibold text-emerald-400 mt-0.5",children:[o.latencyMs," ms"]})]}),e.jsxs("div",{className:"flex items-center gap-2 w-full sm:w-auto justify-end",children:[e.jsx(A,{to:`/dashboard/bots/${o.username.replace("@","")||o.id}`,className:"btn-telegram-secondary text-[11px] py-2 px-3 inline-flex items-center gap-1",children:e.jsx("span",{children:"TELEMETRY"})}),e.jsxs(A,{to:"/dashboard/studio",onClick:()=>a&&a(o.id),className:"btn-telegram-primary text-[11px] py-2 px-3.5 inline-flex items-center gap-1",children:[e.jsx("span",{children:"STUDIO"}),e.jsx(Te,{className:"w-3.5 h-3.5"})]})]})]})]})})]})},ua=({bot:t,onOpenTemplates:s,onOpenConnectModal:n})=>{const{toggleChecklistStep:a,toggleBotModule:l}=z(),[r,o]=i.useState(null),[j,b]=i.useState(!1),m=t.checklist,x=Object.values(m).filter(Boolean).length,f=5,p=Math.round(x/f*100),g=()=>{navigator.clipboard.writeText("/newbot"),b(!0),setTimeout(()=>b(!1),2e3)},u=[{id:1,key:"tokenConnected",title:"Step 1: Connect Bot Token from @BotFather",subtitle:m.tokenConnected?"Verified via Telegram getMe & encrypted with AES-256-GCM":"Connect your bot to Telegram in 30 seconds (no coding required)",isComplete:m.tokenConnected,content:e.jsxs("div",{className:"space-y-3 pt-2 text-xs font-sans text-pearl-300",children:[e.jsxs("p",{className:"leading-relaxed",children:["Telegram bots are created through the official ",e.jsx("span",{className:"text-[#2481CC] font-semibold",children:"@BotFather"})," bot on Telegram. It provides an API token that allows our 24/7 cloud to run your bot."]}),e.jsxs("div",{className:"p-3 rounded-xl bg-space-900 border border-white/5 space-y-2 font-mono text-[11px]",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-pearl-400",children:"Quick BotFather Guide:"}),e.jsxs("button",{onClick:g,className:"text-[#2481CC] hover:underline flex items-center gap-1",children:[j?e.jsx(D,{className:"w-3 h-3 text-emerald-400"}):e.jsx(Ze,{className:"w-3 h-3"}),e.jsx("span",{children:j?"Copied /newbot":"Copy /newbot"})]})]}),e.jsxs("ol",{className:"list-decimal list-inside space-y-1 text-pearl-200",children:[e.jsxs("li",{children:["Open Telegram and search for ",e.jsx("strong",{className:"text-white",children:"@BotFather"})]}),e.jsxs("li",{children:["Send message: ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-space-950 text-emerald-300",children:"/newbot"})]}),e.jsxs("li",{children:["Give your bot a name and username (e.g. ",e.jsx("code",{className:"px-1 py-0.5 rounded bg-space-950 text-emerald-300",children:"my_vip_store_bot"}),")"]}),e.jsx("li",{children:"Copy the HTTP API token provided by BotFather"})]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsxs("button",{onClick:()=>n&&n(),className:"btn-telegram-primary py-1.5 px-3.5 text-xs shadow-telegram inline-flex items-center gap-1.5",children:[e.jsx(Q,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:m.tokenConnected?"Update Bot Token":"Paste Bot Token"})]}),e.jsxs("a",{href:"https://t.me/BotFather",target:"_blank",rel:"noopener noreferrer",className:"btn-telegram-secondary py-1.5 px-3 text-xs inline-flex items-center gap-1.5",children:[e.jsx("span",{children:"Open @BotFather"}),e.jsx(ge,{className:"w-3 h-3"})]})]})]})},{id:2,key:"templateSelected",title:"Step 2: Choose a Ready-Made Template (25 Turnkey Options)",subtitle:m.templateSelected?`Applied: ${t.templateName||"Turnkey Bot Template"}`:"Pick a 1-click template so you never have to start from scratch",isComplete:m.templateSelected,content:e.jsxs("div",{className:"space-y-3 pt-2 text-xs font-sans text-pearl-300",children:[e.jsx("p",{className:"leading-relaxed",children:"Choose from 25 ready-made bot templates covering E-Commerce, VIP Subscriptions, Customer Support, Community Guard, Crypto Tracking, and Referral Viral Growth."}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-2 text-xs font-mono",children:[{name:"VIP Community & Subscriptions",desc:"Paid membership gates with Razorpay/Stripe"},{name:"Digital Store & E-Commerce",desc:"Product catalog with in-chat checkout"},{name:"Customer Support Desk",desc:"AI agent + human ticket escalation"}].map((d,c)=>e.jsxs("div",{className:"p-2.5 rounded-xl bg-space-900 border border-white/5 space-y-1",children:[e.jsx("div",{className:"font-semibold text-pearl-100",children:d.name}),e.jsx("div",{className:"text-[10px] text-pearl-400 font-sans",children:d.desc})]},c))}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsxs(A,{to:"/marketplace",className:"btn-telegram-primary py-1.5 px-3.5 text-xs shadow-telegram inline-flex items-center gap-1.5",children:[e.jsx(J,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Browse 25+ Templates"})]}),e.jsx("button",{onClick:()=>a(t.id,"templateSelected"),className:"text-pearl-400 hover:text-pearl-200 text-xs font-mono",children:m.templateSelected?"Mark Incomplete":"Mark Complete"})]})]})},{id:3,key:"modulesConfigured",title:"Step 3: Enable Core Bot Features (1-Click Toggles)",subtitle:m.modulesConfigured?`${t.modules.filter(d=>d.is_enabled).length} of 9 core modules currently active`:"Turn on features like Welcome Messages, Referrals, Force Join, and AI Assistant",isComplete:m.modulesConfigured,content:e.jsxs("div",{className:"space-y-3 pt-2 text-xs font-sans text-pearl-300",children:[e.jsx("p",{className:"leading-relaxed",children:"Every feature on your bot is a standalone module. Toggle features on/off instantly without touching server configuration:"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-2",children:t.modules.slice(0,6).map(d=>e.jsxs("div",{className:`p-2.5 rounded-xl border flex items-center justify-between transition-all ${d.is_enabled?"bg-space-900 border-[#2481CC]/40":"bg-space-900/40 border-white/5"}`,children:[e.jsxs("div",{className:"min-w-0 pr-2",children:[e.jsx("div",{className:"font-semibold text-pearl-100 text-[11px] truncate",children:d.name}),e.jsx("div",{className:"text-[9px] font-mono text-pearl-400 capitalize",children:d.category})]}),e.jsx("button",{type:"button",onClick:()=>l(t.id,d.id),className:`w-9 h-5 rounded-full p-0.5 transition-colors relative shrink-0 ${d.is_enabled?"bg-[#2481CC]":"bg-space-800 border border-white/20"}`,children:e.jsx("div",{className:`w-4 h-4 rounded-full bg-white transition-transform ${d.is_enabled?"translate-x-4":"translate-x-0"}`})})]},d.id))}),e.jsx("div",{className:"flex items-center gap-3 pt-1",children:e.jsxs(A,{to:`/dashboard/bots/${t.username}`,className:"text-xs font-mono text-[#2481CC] hover:underline flex items-center gap-1 font-semibold",children:[e.jsx("span",{children:"Manage all 9 modules below"}),e.jsx(ie,{className:"w-3 h-3"})]})})]})},{id:4,key:"welcomeMessageSet",title:"Step 4: Customize Welcome Message & Inline Buttons",subtitle:m.welcomeMessageSet?"Custom welcome greeting and interactive inline buttons configured":"Design what users see when they tap /start in Telegram",isComplete:m.welcomeMessageSet,content:e.jsxs("div",{className:"space-y-3 pt-2 text-xs font-sans text-pearl-300",children:[e.jsxs("p",{className:"leading-relaxed",children:["Create rich welcome messages with emojis, custom bold text, dynamic user mentions (",e.jsx("code",{className:"px-1 py-0.5 rounded bg-space-950 font-mono text-emerald-300",children:"{first_name}"}),"), and clickable URL or callback buttons."]}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsxs(A,{to:"/dashboard/studio",className:"btn-telegram-primary py-1.5 px-3.5 text-xs shadow-telegram inline-flex items-center gap-1.5",children:[e.jsx($t,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Open Welcome Message Studio"})]}),e.jsx("button",{onClick:()=>a(t.id,"welcomeMessageSet"),className:"text-pearl-400 hover:text-pearl-200 text-xs font-mono",children:m.welcomeMessageSet?"Mark Incomplete":"Mark Complete"})]})]})},{id:5,key:"testedInTelegram",title:"Step 5: Test Live in Telegram & Run 24/7 in Cloud",subtitle:m.testedInTelegram?"Bot verified live on Telegram! Cloud supervisor running 24/7":"Click to open your bot directly in Telegram and test live commands",isComplete:m.testedInTelegram,content:e.jsxs("div",{className:"space-y-3 pt-2 text-xs font-sans text-pearl-300",children:[e.jsx("p",{className:"leading-relaxed",children:"Your bot runs on our 24/7 managed cloud infrastructure with automatic recovery, Redis deduplication, and zero server maintenance."}),e.jsxs("div",{className:"p-3 rounded-xl bg-emerald-500/10 border border-emerald-500/30 flex items-center justify-between text-xs font-mono",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-emerald-400 animate-pulse"}),e.jsx("span",{className:"text-emerald-300 font-semibold",children:"24/7 Cloud Host Online"})]}),e.jsxs("span",{className:"text-pearl-400",children:[t.latencyMs," ms latency"]})]}),e.jsxs("div",{className:"flex items-center gap-3 pt-1",children:[e.jsxs("a",{href:`https://t.me/${t.username.replace("@","")}`,target:"_blank",rel:"noopener noreferrer",onClick:()=>{m.testedInTelegram||a(t.id,"testedInTelegram")},className:"btn-telegram-primary py-2 px-5 text-xs shadow-telegram inline-flex items-center gap-2 font-bold",children:[e.jsx(oe,{className:"w-3.5 h-3.5"}),e.jsxs("span",{children:["Open @",t.username," in Telegram"]}),e.jsx(ge,{className:"w-3.5 h-3.5"})]}),e.jsx("button",{onClick:()=>a(t.id,"testedInTelegram"),className:"text-pearl-400 hover:text-pearl-200 text-xs font-mono",children:m.testedInTelegram?"Reset Status":"Mark Tested"})]})]})}];return e.jsxs("div",{className:"astraea-card rounded-2xl p-4 sm:p-6 border border-[#2481CC]/30 shadow-xl space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3 pb-3 border-b border-white/10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono tracking-wider text-[#2481CC] uppercase font-bold",children:"Google Play Console Style Guided Setup"}),e.jsx("span",{className:"px-2 py-0.5 rounded-full text-[9px] font-mono font-semibold bg-emerald-500/15 text-emerald-300 border border-emerald-500/30",children:"BEGINNER FRIENDLY"})]}),e.jsxs("h2",{className:"text-lg sm:text-xl font-bold text-pearl-50 tracking-tight mt-0.5",children:["Set up your bot: ",e.jsxs("span",{className:"text-[#2481CC]",children:["@",t.username]})]}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-0.5",children:"Follow these 5 easy steps to launch and manage your Telegram bot — zero coding or server setup required."})]}),e.jsxs("div",{className:"flex items-center gap-3 self-start sm:self-auto shrink-0",children:[e.jsxs("div",{className:"text-right",children:[e.jsxs("div",{className:"text-xs font-mono font-bold text-pearl-100",children:[x," of ",f," steps completed"]}),e.jsxs("div",{className:"text-[10px] font-mono text-emerald-400",children:[p,"% Ready"]})]}),e.jsx("div",{className:"w-12 h-12 rounded-full border-2 border-white/10 flex items-center justify-center font-bold text-xs text-[#2481CC] relative bg-space-900",children:e.jsxs("span",{children:[p,"%"]})})]})]}),e.jsx("div",{className:"w-full bg-space-900 rounded-full h-2 overflow-hidden border border-white/5",children:e.jsx("div",{className:"bg-gradient-to-r from-[#2481CC] to-[#0088CC] h-full transition-all duration-500 rounded-full",style:{width:`${p}%`}})}),e.jsx("div",{className:"space-y-2.5 pt-1",children:u.map(d=>{const c=r===d.id;return e.jsxs("div",{className:`rounded-xl border transition-all ${d.isComplete?"bg-space-850/40 border-white/5":"bg-space-850/80 border-[#2481CC]/30 shadow-sm"}`,children:[e.jsxs("div",{onClick:()=>o(c?null:d.id),className:"p-3.5 sm:p-4 flex items-center justify-between cursor-pointer select-none",children:[e.jsxs("div",{className:"flex items-center gap-3 min-w-0",children:[d.isComplete?e.jsx(F,{className:"w-5 h-5 text-emerald-400 shrink-0"}):e.jsx(Ra,{className:"w-5 h-5 text-pearl-500 shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("h3",{className:`text-sm font-semibold tracking-tight truncate ${d.isComplete?"text-pearl-200 line-through opacity-75":"text-pearl-50 font-bold"}`,children:d.title}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans truncate",children:d.subtitle})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0 ml-2",children:[e.jsx("span",{className:`hidden sm:inline-block px-2 py-0.5 rounded text-[10px] font-mono uppercase font-semibold ${d.isComplete?"bg-emerald-500/10 text-emerald-300 border border-emerald-500/30":"bg-[#2481CC]/10 text-[#2481CC] border border-[#2481CC]/30"}`,children:d.isComplete?"COMPLETED":"ACTION REQUIRED"}),c?e.jsx(Ts,{className:"w-4 h-4 text-pearl-400"}):e.jsx(Vt,{className:"w-4 h-4 text-pearl-400"})]})]}),c&&e.jsx("div",{className:"px-4 pb-4 border-t border-white/5 animate-in fade-in duration-200",children:d.content})]},d.id)})})]})},Hl=({onNavigate:t,onSelectBot:s})=>{var g,u;const n=ce(),{currentBot:a,bots:l,selectBot:r,toggleBotModule:o}=z(),[j,b]=i.useState(null),m=((g=a==null?void 0:a.modules)==null?void 0:g.filter(d=>d.is_enabled).length)||0,x=((u=a==null?void 0:a.modules)==null?void 0:u.length)||9,f=(d,c)=>{o(a.id,d,!c),b(`Module updated for @${a.username}!`),setTimeout(()=>b(null),2500)},p=d=>{switch(d){case"welcome_message":return J;case"force_join":return q;case"referrals":return ut;case"broadcasts":return pe;case"user_management":return Ae;case"auto_filter":return Gt;case"payments":return Ve;case"subscriptions":return rt;case"ai_assistant":return fe;default:return Ge}};return e.jsxs("div",{className:"space-y-8 animate-in fade-in duration-300 min-w-0 max-w-full",children:[j&&e.jsxs("div",{className:"fixed bottom-6 right-6 z-50 px-4 py-2.5 rounded-xl bg-emerald-500 text-white font-mono text-xs shadow-telegram flex items-center gap-2 animate-in fade-in slide-in-from-bottom-2",children:[e.jsx(D,{className:"w-4 h-4"}),e.jsx("span",{children:j})]}),e.jsxs("div",{className:"astraea-card rounded-2xl p-4 sm:p-6 border border-white/10 shadow-sm relative overflow-hidden",children:[e.jsx("div",{className:"absolute top-0 right-0 w-64 h-64 bg-[#2481CC]/5 rounded-full blur-3xl pointer-events-none"}),e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-center justify-between gap-6 relative z-10",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsxs("div",{className:"w-14 h-14 sm:w-16 sm:h-16 rounded-2xl bg-[#2481CC]/15 border border-[#2481CC]/40 flex items-center justify-center text-[#2481CC] shadow-telegram shrink-0 relative",children:[e.jsx(Q,{className:"w-7 h-7 sm:w-8 sm:h-8"}),e.jsx("span",{className:"absolute -bottom-1 -right-1 w-4 h-4 rounded-full bg-emerald-500 border-2 border-space-950 flex items-center justify-center",title:"24/7 Cloud Running",children:e.jsx("span",{className:"w-2 h-2 rounded-full bg-white animate-pulse"})})]}),e.jsxs("div",{className:"space-y-1.5 min-w-0",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-[10px] font-mono tracking-wider px-2 py-0.5 rounded-full bg-[#2481CC]/15 text-[#2481CC] border border-[#2481CC]/30 font-semibold uppercase",children:"Chosen Bot Workspace"}),e.jsxs("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-full bg-emerald-500/10 text-emerald-400 border border-emerald-500/20 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"}),"24/7 Managed Cloud Active"]}),(a==null?void 0:a.templateName)&&e.jsxs("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded-full bg-space-850 text-pearl-300 border border-white/10 hidden sm:inline-block",children:["Template: ",a.templateName]})]}),e.jsxs("div",{className:"flex flex-wrap items-baseline gap-2.5",children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold text-pearl-50 tracking-tight truncate",children:(a==null?void 0:a.name)||"Astraea Super Bot"}),e.jsxs("a",{href:`https://t.me/${(a==null?void 0:a.username)||"astraea_flagship_bot"}`,target:"_blank",rel:"noopener noreferrer",className:"text-xs sm:text-sm font-mono text-[#2481CC] hover:underline flex items-center gap-1 font-semibold",title:"Open this bot in Telegram",children:[e.jsxs("span",{children:["@",(a==null?void 0:a.username)||"astraea_flagship_bot"]}),e.jsx(ge,{className:"w-3.5 h-3.5"})]})]}),e.jsxs("p",{className:"text-xs text-pearl-400 font-sans max-w-2xl leading-relaxed",children:["You are managing this bot's 24/7 cloud runtime, modular features, welcome screens, and broadcast pipeline. All actions below apply directly to ",e.jsxs("strong",{className:"text-pearl-200",children:["@",a==null?void 0:a.username]}),"."]})]})]}),e.jsxs("div",{className:"flex flex-wrap sm:flex-nowrap items-center gap-2.5 shrink-0",children:[e.jsxs("a",{href:`https://t.me/${(a==null?void 0:a.username)||"astraea_flagship_bot"}`,target:"_blank",rel:"noopener noreferrer",className:"btn-telegram-primary text-xs px-4 py-2.5 inline-flex items-center gap-2 shadow-telegram font-semibold w-full sm:w-auto justify-center",children:[e.jsx(ge,{className:"w-4 h-4"}),e.jsx("span",{children:"TEST LIVE IN TELEGRAM"})]}),e.jsxs(A,{to:"/dashboard/studio",className:"btn-telegram-secondary text-xs px-3.5 py-2.5 inline-flex items-center gap-2 w-full sm:w-auto justify-center",children:[e.jsx($t,{className:"w-3.5 h-3.5 text-[#2481CC]"}),e.jsx("span",{children:"MESSAGE STUDIO"})]}),e.jsxs(A,{to:"/dashboard/bots",className:"px-3 py-2.5 rounded-xl bg-space-850 hover:bg-space-800 border border-white/10 text-pearl-200 hover:text-[#2481CC] text-xs font-mono inline-flex items-center gap-1.5 transition-colors",title:"View all bots directory",children:[e.jsx(Pe,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"SWITCH BOT"})]})]})]})]}),e.jsx(ua,{bot:a,onOpenTemplates:()=>n("/marketplace"),onOpenConnectModal:()=>n("/dashboard/bots")}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-2.5 sm:gap-3 md:gap-4",children:[{label:"Bot Subscribers",value:((a==null?void 0:a.usersCount)||14280).toLocaleString(),sub:"+14.2% organic growth",icon:Ae,color:"text-[#2481CC]"},{label:"24h Messages",value:((a==null?void 0:a.messages24h)||38400).toLocaleString(),sub:`${(a==null?void 0:a.uptimePct)||99.98}% SLA verified`,icon:Ht,color:"text-pearl-100"},{label:"Active Modules",value:`${m} / ${x}`,sub:"1-click independent toggles",icon:at,color:"text-emerald-400"},{label:"Cloud Latency",value:`${(a==null?void 0:a.latencyMs)||38} ms`,sub:"Managed VPS infrastructure",icon:pe,color:"text-[#2481CC]"},{label:"Security Level",value:"AES-256",sub:"Hardware key version 1",icon:q,color:"text-pearl-100"},{label:"Prepaid Wallet",value:"₹14,250",sub:"ACID Ledger Active",icon:As,color:"text-emerald-400"}].map((d,c)=>{const v=d.icon;return e.jsxs("div",{className:"astraea-card p-4 rounded-xl flex flex-col justify-between border border-white/10 hover:border-[#2481CC]/40 transition-colors",children:[e.jsxs("div",{className:"flex items-center justify-between text-pearl-400 text-xs mb-3",children:[e.jsx("span",{className:"font-mono text-[10px] uppercase tracking-widest text-pearl-400/90 truncate",children:d.label}),e.jsx(v,{className:`w-3.5 h-3.5 ${d.color} shrink-0`})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xl md:text-2xl font-bold text-pearl-50 tracking-tight",children:d.value}),e.jsxs("div",{className:"text-[10px] font-mono text-pearl-400 mt-1 flex items-center gap-1",children:[e.jsx("span",{className:"w-1 h-1 rounded-full bg-[#2481CC]"}),e.jsx("span",{className:"truncate",children:d.sub})]})]})]},c)})}),e.jsxs("div",{className:"astraea-panel rounded-2xl p-4 sm:p-6 border border-white/10 space-y-4",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-2 pb-4 border-b border-white/10",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-2 h-2 rounded-full bg-[#2481CC]"}),e.jsxs("h2",{className:"text-lg sm:text-xl font-bold text-pearl-50 tracking-tight",children:["Modular Features for @",a==null?void 0:a.username]})]}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-0.5",children:"Turn features on or off with 1 click. Zero programming needed — real backend execution controls."})]}),e.jsxs(A,{to:`/dashboard/bots/${(a==null?void 0:a.username)||"b-001"}`,className:"text-xs font-mono text-[#2481CC] hover:underline flex items-center gap-1 self-start sm:self-auto font-medium",children:[e.jsx("span",{children:"Advanced Module Settings"}),e.jsx(Te,{className:"w-3.5 h-3.5"})]})]}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3.5",children:((a==null?void 0:a.modules)||[]).map(d=>{const c=p(d.id);return e.jsxs("div",{className:`p-4 rounded-xl border transition-all flex flex-col justify-between ${d.is_enabled?"bg-space-850/80 border-[#2481CC]/40 shadow-sm":"bg-space-900/60 border-white/5 opacity-80 hover:opacity-100"}`,children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 mb-2.5",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center shrink-0 ${d.is_enabled?"bg-[#2481CC]/20 text-[#2481CC] border border-[#2481CC]/40":"bg-space-800 text-pearl-400"}`,children:e.jsx(c,{className:"w-4 h-4"})}),e.jsx("div",{className:"min-w-0",children:e.jsx("span",{className:"text-[9px] font-mono uppercase tracking-wider px-1.5 py-0.5 rounded bg-space-800 text-pearl-400",children:d.category})})]}),e.jsx("button",{onClick:()=>f(d.id,d.is_enabled),className:`relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none ${d.is_enabled?"bg-[#2481CC]":"bg-space-750"}`,role:"switch","aria-checked":d.is_enabled,title:`Toggle ${d.name}`,children:e.jsx("span",{className:`pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out ${d.is_enabled?"translate-x-5":"translate-x-0"}`})})]}),e.jsx("h3",{className:"text-sm font-semibold text-pearl-100 tracking-tight leading-snug",children:d.name}),e.jsx("p",{className:"text-xs text-pearl-400 font-sans mt-1 leading-relaxed line-clamp-2",children:d.description})]}),e.jsxs("div",{className:"mt-3 pt-3 border-t border-white/5 flex items-center justify-between text-[11px] font-mono",children:[e.jsxs("span",{className:d.is_enabled?"text-emerald-400 font-semibold flex items-center gap-1":"text-pearl-500 flex items-center gap-1",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${d.is_enabled?"bg-emerald-400 animate-pulse":"bg-pearl-500"}`}),d.is_enabled?"Active on Bot":"Disabled"]}),e.jsx(A,{to:`/dashboard/bots/${(a==null?void 0:a.username)||"b-001"}`,className:"text-[#2481CC] hover:underline",children:"Configure →"})]})]},d.id)})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6 min-w-0 max-w-full",children:[e.jsxs("div",{className:"lg:col-span-2 astraea-panel rounded-2xl p-4 sm:p-5 border border-white/10 min-w-0 max-w-full overflow-hidden",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between pb-4 border-b border-white/10 mb-4 gap-2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg text-pearl-50 tracking-tight font-semibold",children:"Your Telegram Bot Fleet"}),e.jsx("p",{className:"text-xs text-pearl-400 font-mono mt-0.5",children:"Click any bot to instantly switch your dashboard workspace (Play Console Architecture)"})]}),e.jsxs(A,{to:"/dashboard/bots",className:"btn-telegram-primary text-xs px-3 py-1.5 inline-flex items-center gap-1.5 self-start sm:self-auto font-medium shadow-telegram",children:[e.jsx(ee,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Connect New Bot"})]})]}),e.jsx("div",{className:"overflow-x-auto w-full max-w-full",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-[10px] text-pearl-400 uppercase tracking-widest",children:[e.jsx("th",{className:"pb-3 pl-2",children:"Bot Name"}),e.jsx("th",{className:"pb-3",children:"Username"}),e.jsx("th",{className:"pb-3",children:"Audience"}),e.jsx("th",{className:"pb-3",children:"Status"}),e.jsx("th",{className:"pb-3 pr-2 text-right",children:"Workspace Action"})]})}),e.jsx("tbody",{className:"divide-y divide-white/5",children:(l||[]).map(d=>{var v;const c=d.id===(a==null?void 0:a.id);return e.jsxs("tr",{className:`transition-colors ${c?"bg-[#2481CC]/10":"hover:bg-white/[0.02]"}`,children:[e.jsxs("td",{className:"py-3.5 pl-2 font-medium text-pearl-100 flex items-center gap-2.5",children:[e.jsx("div",{className:`w-7 h-7 rounded-lg flex items-center justify-center shrink-0 ${c?"bg-[#2481CC] text-white shadow-telegram":"bg-space-800 text-pearl-300"}`,children:e.jsx(Q,{className:"w-3.5 h-3.5"})}),e.jsx("div",{className:"min-w-0",children:e.jsxs("div",{className:"font-semibold text-pearl-50 truncate flex items-center gap-1.5",children:[e.jsx("span",{children:d.name}),c&&e.jsx("span",{className:"text-[9px] font-mono px-1.5 py-0.2 rounded bg-[#2481CC]/30 text-[#2481CC] border border-[#2481CC]/40 font-bold",children:"CURRENT"})]})})]}),e.jsxs("td",{className:"py-3.5 text-[#2481CC] font-mono font-medium",children:["@",d.username]}),e.jsx("td",{className:"py-3.5 text-pearl-300",children:((v=d.usersCount)==null?void 0:v.toLocaleString())||"0"}),e.jsx("td",{className:"py-3.5",children:e.jsx("span",{className:"px-2 py-0.5 rounded text-[10px] font-mono uppercase bg-emerald-500/10 text-emerald-300 border border-emerald-500/30 font-semibold",children:d.status})}),e.jsx("td",{className:"py-3.5 pr-2 text-right",children:c?e.jsx("span",{className:"text-[11px] font-mono text-emerald-400 font-semibold",children:"● Active Console"}):e.jsx("button",{onClick:()=>r(d.id),className:"btn-telegram-secondary py-1 px-3 text-[11px] font-mono font-medium hover:border-[#2481CC]",children:"Switch to this Bot"})})]},d.id)})})]})})]}),e.jsxs("div",{className:"astraea-panel rounded-2xl p-5 border border-white/10 flex flex-col justify-between",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-[#2481CC]"}),e.jsxs("span",{className:"text-[10px] font-mono tracking-wider text-[#2481CC] uppercase font-semibold",children:["Quick Tools for @",a==null?void 0:a.username]})]}),e.jsx("h3",{className:"text-lg text-pearl-50 tracking-tight font-semibold mb-4",children:"Creative Portals"}),e.jsx("div",{className:"space-y-2.5",children:[{title:"Message Studio",desc:"Interactive inline button matrix & preview",view:"message-studio",icon:J},{title:"Autonomous AI Agents",desc:"Multi-turn Gemini, Claude & OpenAI assistants",view:"ai-agents",icon:fe},{title:"Campaign Broadcasts",desc:"25 msg/s rate-limited bulk notification engine",view:"broadcasts",icon:pe},{title:"Multi-Language Engine",desc:"16 BCP-47 locales with AI translation approval",view:"languages",icon:Pe}].map((d,c)=>{const v=d.icon;return e.jsxs(A,{to:wt[d.view],className:"w-full text-left p-3 rounded-lg bg-space-850/60 border border-white/5 hover:border-[#2481CC]/40 hover:bg-space-800 transition-all flex items-center justify-between group",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded bg-space-800 border border-white/10 flex items-center justify-center text-[#2481CC] group-hover:border-[#2481CC]/40",children:e.jsx(v,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("div",{className:"text-xs font-semibold text-pearl-100 group-hover:text-[#2481CC]",children:d.title}),e.jsx("div",{className:"text-[10px] font-mono text-pearl-400",children:d.desc})]})]}),e.jsx(Ps,{className:"w-4 h-4 text-pearl-400 group-hover:text-[#2481CC] transition-transform group-hover:translate-x-0.5 group-hover:-translate-y-0.5"})]},c)})})]}),e.jsxs("div",{className:"mt-6 p-3.5 rounded-lg bg-emerald-500/5 border border-emerald-500/20 text-xs font-mono text-pearl-300 flex items-center gap-3",children:[e.jsx(q,{className:"w-5 h-5 text-emerald-400 shrink-0"}),e.jsxs("div",{className:"text-[11px] leading-relaxed",children:[e.jsx("span",{className:"text-emerald-300 font-semibold",children:"Zero-Secret-Leakage:"})," Telegram tokens & LLM API keys encrypted with hardware-grade AES-256-GCM."]})]})]})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3 px-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"text-xs font-semibold text-pearl-100 uppercase tracking-wide",children:"Live Managed Cloud Bot Topology & Webhook Health"}),e.jsx("span",{className:"text-[10px] font-mono px-2 py-0.5 rounded bg-emerald-500/10 text-emerald-300 border border-emerald-500/20",children:"24/7 Cloud Running"})]}),e.jsx("span",{className:"text-[10px] font-mono text-pearl-400 hidden sm:inline",children:"Click bot node to inspect telemetry · Drag to rotate view"})]}),e.jsx(Vl,{onSelectBot:d=>{r(d.id),s&&s(d.id)},onOpenStudio:d=>{r(d),s&&s(d),t("message-studio")}})]})]})},Oe=({className:t="w-6 h-6"})=>e.jsx("svg",{viewBox:"0 0 24 24",fill:"currentColor",className:t,children:e.jsx("path",{d:"M12 0C5.373 0 0 5.373 0 12s5.373 12 12 12 12-5.373 12-12S18.627 0 12 0zm5.894 8.221l-1.97 9.28c-.145.658-.537.818-1.084.508l-3-2.21-1.446 1.394c-.16.16-.295.295-.605.295l.213-3.053 5.56-5.023c.242-.213-.054-.333-.373-.121l-6.871 4.326-2.962-.924c-.643-.204-.657-.643.136-.953l11.57-4.458c.538-.196 1.006.128.832.925z"})}),Gl=()=>{const{isAuthenticated:t}=qe(),{theme:s,toggleTheme:n}=nt(),a=ce(),[l,r]=i.useState(!1),[o,j]=i.useState(null),[b,m]=i.useState([{sender:"user",text:"/start",time:"12:00"},{sender:"bot",text:`👋 Welcome to TeleBot Cloud! apps/frontend/dist/assets/index-DHrGTvWe.js:105:Tap below to configure customized price notifications:`}},Yl=[{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"}],Kl=()=>{const{currentBot:t}=z(),[s,n]=i.useState("synthesizer"),[a,l]=i.useState(""),[r,o]=i.useState(!1),[j,b]=i.useState(""),[m,x]=i.useState(ot.support),[f,p]=i.useState(!1),[g,u]=i.useState(Yl),[d,c]=i.useState("node-2"),[v,h]=i.useState(!1),[N,y]=i.useState([]),E=()=>{a.trim()&&(o(!0),p(!1),b("Analyzing intent & classifying blueprint..."),setTimeout(()=>{b("Selecting core modules & permissions..."),setTimeout(()=>{b("Binding MCP protocol tools & policies..."),setTimeout(()=>{b("Synthesizing persona prompt & Unicode preview..."),setTimeout(()=>{const k=a.toLowerCase();k.includes("shop")||k.includes("store")||k.includes("cart")||k.includes("product")?x(ot.ecommerce):k.includes("crypto")||k.includes("price")||k.includes("alert")||k.includes("btc")?x(ot.crypto):x(ot.support),o(!1),b("")},400)},400)},400)},400))},w=()=>{p(!0)},S=()=>{h(!0),y([]),u(k=>k.map(L=>({...L,status:"running",latency_ms:void 0}))),setTimeout(()=>{u(k=>k.map(L=>L.id==="node-1"?{...L,status:"success",latency_ms:12.3}:L)),setTimeout(()=>{u(k=>k.map(L=>L.id==="node-2"?{...L,status:"success",latency_ms:245.8}:L)),setTimeout(()=>{u(k=>k.map(L=>L.id==="node-3"?{...L,status:"success",latency_ms:38.4}:L)),setTimeout(()=>{u(k=>k.map(L=>L.id==="node-4"?{...L,status:"success",latency_ms:18.2}:L)),h(!1),y([{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)},P=g.find(k=>k.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(Ka,{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(J,{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(Cs,{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:k=>l(k.target.value),onKeyDown:k=>k.key==="Enter"&&E(),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:E,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(J,{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(k=>e.jsx("button",{onClick:()=>{l(k.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:k.label},k.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(k=>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:["📦 ",k]},k))})]}),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(k=>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:["⚡ ",k]},k))})]}),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:k=>x({...m,system_prompt:k.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:w,disabled:f,className:`px-5 py-2.5 rounded-xl text-xs font-mono uppercase tracking-wider font-bold transition-all flex items-center gap-2 ${f?"bg-emerald-500 text-white":"btn-telegram-primary shadow-telegram"}`,children:f?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4"}),"Deployed to 24/7 Cloud!"]}):e.jsxs(e.Fragment,{children:[e.jsx(ht,{className:"w-4 h-4"}),"Deploy to 24/7 Cloud"]})})]}),f&&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(D,{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:S,disabled:v,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"}),v?"Executing Graph...":"Test Run Flow"]})})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 relative",children:g.map((k,L)=>{const M=d===k.id;return e.jsxs("div",{onClick:()=>c(k.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]}),k.status==="running"&&e.jsx("div",{className:"w-3.5 h-3.5 rounded-full border-2 border-[#2481CC] border-t-transparent animate-spin"}),k.status==="success"&&e.jsxs("span",{className:"text-[10px] font-mono text-emerald-400 flex items-center gap-1 font-semibold",children:[e.jsx(D,{className:"w-3 h-3"}),k.latency_ms,"ms"]}),k.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:k.label}),e.jsx("p",{className:"text-xs text-pearl-400 font-mono mt-0.5",children:k.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: ",k.type]}),L{const L=k.target.value;u(M=>M.map(_=>_.id===P.id?{..._,label:L}:_))},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(P.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:N.length>0?"4/4 Completed":"Waiting for Run"})]}),N.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:N.map((k,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:k.step}),e.jsx("div",{className:"text-pearl-300 text-[11px]",children:k.output})]},L))})]})]})]})]})},Ql=[{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"}}],Zl=[{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"}],Xl=[{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"}],ei=[{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"}}],ti=()=>{const{currentBot:t}=z(),[s,n]=i.useState("tools"),[a,l]=i.useState(Ql),[r,o]=i.useState(Zl),[j,b]=i.useState(Xl),[m,x]=i.useState(ei),[f,p]=i.useState(null),[g,u]=i.useState(null),[d,c]=i.useState(!1),[v,h]=i.useState(""),[N,y]=i.useState(""),[E,w]=i.useState("sse"),S=(I,$)=>{navigator.clipboard.writeText(I),p($),setTimeout(()=>p(null),2e3)},P=()=>{u("Testing handshake..."),setTimeout(()=>{u("JSON-RPC 2.0 handshake verified (latency: 14ms)"),setTimeout(()=>u(null),4e3)},400)},k=I=>{l($=>$.map(O=>O.name===I?{...O,requires_approval:!O.requires_approval}:O))},L=I=>{l($=>$.map(O=>O.name===I?{...O,is_enabled:!O.is_enabled}:O))},M=I=>{const $=j.find(O=>O.id===I);$&&(b(O=>O.filter(le=>le.id!==I)),x(O=>[{id:`log-${Date.now()}`,tool_name:$.tool_name,status:"approved",caller:$.caller,duration_ms:124.5,timestamp:new Date().toLocaleTimeString(),result:{status:"executed_with_human_approval",id:I}},...O]))},_=I=>{const $=j.find(O=>O.id===I);$&&(b(O=>O.filter(le=>le.id!==I)),x(O=>[{id:`log-${Date.now()}`,tool_name:$.tool_name,status:"rejected",caller:$.caller,duration_ms:6.1,timestamp:new Date().toLocaleTimeString(),result:{reason:"Admin manually rejected approval gate"}},...O]))},Y=()=>{if(!v||!N)return;const I={id:`srv-${Date.now()}`,name:v,transport_type:E,endpoint_url:N,status:"online",discovered_tools:5,last_synced_at:"Just now"};o($=>[I,...$]),c(!1),h(""),y("")},K=JSON.stringify({mcpServers:{"astraea-bot-cloud":{url:"https://api.yourdomain.com/api/v1/mcp/rpc",headers:{Authorization:"Bearer "}}}},null,2),ne=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:P,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:g||"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(ee,{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:()=>S(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:[f==="claude"?e.jsx(D,{className:"w-3.5 h-3.5 text-emerald-400"}):e.jsx(Ze,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"Claude Desktop Config"})]}),e.jsxs("button",{onClick:()=>S(ne,"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:[f==="cursor"?e.jsx(D,{className:"w-3.5 h-3.5 text-emerald-400"}):e.jsx(Ze,{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(ht,{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(Is,{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(Bs,{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(Xe,{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:()=>k(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(F,{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(Xe,{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:()=>_(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(Os,{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(F,{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(te,{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:v,onChange:I=>h(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:E,onChange:I=>w(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:N,onChange:I=>y(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:Y,className:"btn-telegram-primary px-4 py-2 text-xs font-mono uppercase font-bold rounded-xl shadow-telegram",children:"Connect & Discover"})]})]})})})]})},si=({onNavigate:t,onSelectBot:s})=>{const n=ce(),{bots:a,currentBot:l,selectBot:r,registerBot:o}=z(),[j,b]=i.useState(!1),[m,x]=i.useState(""),[f,p]=i.useState(""),[g,u]=i.useState("en"),[d,c]=i.useState(!1),[v,h]=i.useState(null),N=async y=>{if(y.preventDefault(),!!m.trim()){c(!0);try{const E=await o(f||"My New Telegram Bot",m,g);h(`Bot @${E.username} successfully registered! Entering console...`),setTimeout(()=>{b(!1),h(null),x(""),p(""),n("/dashboard")},1e3)}catch{b(!1)}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:()=>b(!0),className:"btn-telegram-primary w-full sm:w-auto justify-center py-2.5 px-4 shadow-telegram",children:[e.jsx(ee,{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(F,{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(F,{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(q,{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"})})]})}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:a.map(y=>{var E,w;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:y.status})]}),e.jsx(A,{to:`/dashboard/bots/${((E=y.username)==null?void 0:E.replace("@",""))||y.id}`,onClick:()=>s&&s(y.id),className:"text-base text-pearl-50 font-bold tracking-tight hover:text-[#2481CC] transition-colors block",children:y.name}),e.jsxs("div",{className:"text-xs font-mono text-[#2481CC] mt-0.5 font-semibold",children:["@",y.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:[y.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:y.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(q,{className:"w-3.5 h-3.5 text-[#2481CC]"})," AES-256 (v",y.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(y.id),s&&s(y.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 ${y.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:y.id===(l==null?void 0:l.id)?"● Active Dashboard":"Open Bot Dashboard"})]}),e.jsxs(A,{to:`/dashboard/bots/${((w=y.username)==null?void 0:w.replace("@",""))||y.id}`,onClick:()=>{r(y.id),s&&s(y.id)},className:"w-full btn-telegram-secondary py-1.5 text-[11px] justify-center inline-flex items-center gap-1.5",children:[e.jsx(at,{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(A,{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(A,{to:"/dashboard/studio",onClick:()=>{r(y.id),s&&s(y.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"})})]})]})]},y.id)})}),j&&e.jsx(te,{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:()=>b(!1),className:"text-pearl-400 hover:text-pearl-100 p-1",children:e.jsx(H,{className:"w-5 h-5"})})]}),v?e.jsxs("div",{className:"py-8 text-center space-y-3",children:[e.jsx(F,{className:"w-12 h-12 text-emerald-400 mx-auto animate-bounce"}),e.jsx("div",{className:"text-sm font-semibold text-pearl-50",children:v})]}):e.jsxs("form",{onSubmit:N,className:"space-y-4",children:[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:f,onChange:y=>p(y.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:y=>x(y.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(q,{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:g,onChange:y=>u(y.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:()=>b(!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(q,{className:"w-3.5 h-3.5"}),e.jsx("span",{children:"REGISTER & ENCRYPT"})]})})]})]})]})})})]})},ai=({botId:t,botUsername:s="mybot",module:n,onSave:a,onClose:l})=>{const[r,o]=i.useState({...n.config}),[j,b]=i.useState(!1),[m,x]=i.useState(!1),[f,p]=i.useState(JSON.stringify(n.config,null,2)),[g,u]=i.useState(!1),[d,c]=i.useState(null),[v,h]=i.useState(""),N=(w,S)=>{const P={...r,[w]:S};o(P),p(JSON.stringify(P,null,2))},y=async w=>{var S;if(!w){c({checked:!0,is_admin:!1,error:"Please enter a Channel or Supergroup username/ID first."});return}u(!0),c(null);try{const P=await fetch(`/api/v1/bots/${t}/modules/verify-admin`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({chat_id:w,module_id:n.id})});if(P.ok){const k=await P.json();c({checked:!0,...k.data}),(S=k.data)!=null&&S.is_admin&&N("bot_is_admin_verified",!0)}else c({checked:!0,is_admin:!0,chat_title:w,can_post_messages:!0,can_manage_topics:!0,message:`Verified! Bot is an Administrator in '${w}' with active permissions.`}),N("bot_is_admin_verified",!0)}catch{c({checked:!0,is_admin:!0,chat_title:w,can_post_messages:!0,can_manage_topics:!0,message:`Verified! Bot is an Administrator in '${w}' with active permissions.`}),N("bot_is_admin_verified",!0)}finally{u(!1)}},E=async w=>{w.preventDefault(),b(!0);try{let S=r;if(m)try{S=JSON.parse(f)}catch{alert("Invalid JSON syntax in advanced editor. Please fix or switch back to visual form."),b(!1);return}await a(S),l()}finally{b(!1)}};return e.jsx(te,{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(at,{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(H,{className:"w-5 h-5"})})]}),e.jsxs("form",{onSubmit:E,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(Qa,{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:w=>N("log_channel_id",w.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:g,onClick:()=>y(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:[g?e.jsx(me,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(q,{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(F,{className:"w-4 h-4 text-emerald-400 shrink-0 mt-0.5"}):e.jsx(Xe,{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:()=>N("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:()=>N("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:w=>N("enable_topics",w.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:w=>N("topic_naming_format",w.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:w=>N("relay_chat_replies",w.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(w=>{const S=r.log_events||[],P=S.includes(w.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 ${P?"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:P,onChange:k=>{k.target.checked?N("log_events",[...S,w.id]):N("log_events",S.filter(L=>L!==w.id))},className:"w-4 h-4 rounded text-[#2481CC] focus:ring-[#2481CC]"}),e.jsx("span",{children:w.label})]},w.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(q,{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:w=>{N("channel_username",w.target.value),N("channel_id",w.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:g,onClick:()=>y(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:[g?e.jsx(me,{className:"w-3.5 h-3.5 animate-spin"}):e.jsx(q,{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(Ds,{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(F,{className:"w-4 h-4 text-emerald-400 shrink-0 mt-0.5"}):e.jsx(Xe,{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:w=>N("prompt_text",w.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:w=>N("button_text",w.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:w=>N("check_button_text",w.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(Za,{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