@serve.zone/dcrouter 13.35.0 → 13.36.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -42939,7 +42939,7 @@ Customer Support Team`}};async onActivate(b){this.appui=b.appui,this.appui.setCo
42939
42939
  <dees-appui></dees-appui>
42940
42940
  `}async firstUpdated(){let n=this.shadowRoot?.querySelector("dees-appui");n&&(n.configure({branding:{logoIcon:"lucide:Box",logoText:"serve.zone"},appBar:{showSearch:!0,breadcrumbs:"serve.zone",menuItems:[{name:"File",action:i(async()=>{},"action"),submenu:[{name:"New Service",shortcut:"Cmd+N",action:i(async()=>{console.log("New Service")},"action")},{name:"Import Configuration",action:i(async()=>{console.log("Import")},"action")},{name:"Export Configuration",action:i(async()=>{console.log("Export")},"action")},{divider:!0},{name:"Preferences",shortcut:"Cmd+,",action:i(async()=>{n.navigateToView("settings")},"action")}]},{name:"View",action:i(async()=>{},"action"),submenu:[{name:"Dashboard",shortcut:"Cmd+1",action:i(async()=>{n.navigateToView("dashboard")},"action")},{name:"Services",shortcut:"Cmd+2",action:i(async()=>{n.navigateToView("services")},"action")},{name:"Network",shortcut:"Cmd+3",action:i(async()=>{n.navigateToView("network")},"action")},{divider:!0},{name:"Activity Log",shortcut:"Cmd+Shift+A",action:i(async()=>{n.toggleActivityLog()},"action")},{name:"Toggle Sidebar",shortcut:"Cmd+B",action:i(async()=>{n.setMainMenuCollapsed(!n.mainmenuCollapsed)},"action")}]},{name:"Services",action:i(async()=>{},"action"),submenu:[{name:"Deploy New Service",action:i(async()=>{console.log("Deploy")},"action")},{name:"Start All",action:i(async()=>{console.log("Start all")},"action")},{name:"Stop All",action:i(async()=>{console.log("Stop all")},"action")},{divider:!0},{name:"Garbage Collect",action:i(async()=>{console.log("GC")},"action")}]},{name:"Help",action:i(async()=>{},"action"),submenu:[{name:"Documentation",action:i(async()=>{window.open("https://docs.serve.zone","_blank")},"action")},{name:"Release Notes",action:i(async()=>{console.log("Release notes")},"action")},{divider:!0},{name:"About serve.zone",action:i(async()=>{console.log("About")},"action")}]}]},views:[{id:"dashboard",name:"Dashboard",iconName:"lucide:LayoutDashboard",content:"sz-demo-view-dashboard"},{id:"services",name:"Services",iconName:"lucide:Server",content:"sz-demo-view-services"},{id:"network",name:"Network",iconName:"lucide:Network",content:"sz-demo-view-network"},{id:"registries",name:"Registries",iconName:"lucide:Archive",content:"sz-demo-view-registries"},{id:"tokens",name:"Tokens",iconName:"lucide:Key",content:"sz-demo-view-tokens"},{id:"mta",name:"Email / MTA",iconName:"lucide:Mail",content:"sz-demo-view-mta"},{id:"routes",name:"Routes",iconName:"lucide:Route",content:"sz-demo-view-routes"},{id:"settings",name:"Settings",iconName:"lucide:Settings",content:"sz-demo-view-settings"}],mainMenu:{sections:[{name:"Overview",views:["dashboard"]},{name:"Infrastructure",views:["services","network","registries","mta","routes"]},{name:"Administration",views:["tokens","settings"]}]},defaultView:"dashboard",onViewChange:i((l,c)=>{console.log("View changed to:",l,c)},"onViewChange")}),n.setUser({name:"Admin User",email:"admin@serve.zone",status:"online"}),n.setProfileMenuItems([{name:"Profile",iconName:"lucide:User",action:i(async()=>{console.log("Profile")},"action")},{name:"Preferences",iconName:"lucide:SlidersHorizontal",action:i(async()=>{console.log("Preferences")},"action")},{divider:!0},{name:"Sign Out",iconName:"lucide:LogOut",action:i(async()=>{console.log("Sign Out")},"action")}]))}static{TBa(r,t)}};return o=r})();var r9={};ht(r9,{TypedSocket:()=>bat});var Ktt={};ht(Ktt,{sha256FromString:()=>DBa});var FK={};ht(FK,{Smartenv:()=>Gtt});var Wtt=eo(Tha(),1);var Gtt=class{static{i(this,"Smartenv")}constructor(){this.loadedScripts=[]}async getEnvAwareModule(e){if(this.isNode)return await this.getSafeNodeModule(e.nodeModuleName);if(this.isBrowser)return await this.getSafeWebModule(e.webUrlArg,e.getFunction);console.error("platform for loading not supported by smartenv")}async getSafeNodeModule(e){if(!this.isNode){console.error(`You tried to load a node module in a wrong context: ${e}`);return}return new Function(`return import('${e}')`)()}async getSafeWebModule(e,t){if(!this.isBrowser){console.error("You tried to load a web module in a wrong context");return}if(this.loadedScripts.includes(e))return t();this.loadedScripts.push(e);let r=Wtt.defer();if(globalThis.importScripts)globalThis.importScripts(e),r.resolve();else{let s=document.createElement("script");s.onload=()=>{r.resolve()},s.src=e,document.head.appendChild(s)}return await r.promise,t()}get runtimeEnv(){return typeof process<"u"?"node":"browser"}get isBrowser(){return!this.isNode}get userAgent(){return this.isBrowser?navigator.userAgent:"undefined"}get isNode(){return this.runtimeEnv==="node"}get nodeVersion(){return process.version}get isCI(){return this.isNode?!!process.env.CI:!1}async isMacAsync(){return this.isNode?(await this.getSafeNodeModule("os")).platform()==="darwin":!1}async isWindowsAsync(){return this.isNode?(await this.getSafeNodeModule("os")).platform()==="win32":!1}async isLinuxAsync(){return this.isNode?(await this.getSafeNodeModule("os")).platform()==="linux":!1}async printEnv(){this.isNode?(console.log("running on NODE"),console.log("node version is "+this.nodeVersion)):(console.log("running on BROWSER"),console.log("browser is "+this.userAgent))}};var $Ba=i(a=>{let e=[],t=new DataView(a);for(let r=0;r<t.byteLength;r+=4){let o=t.getUint32(r).toString(16),n="00000000",l=(n+o).slice(-n.length);e.push(l)}return e.join("")},"hex"),DBa=i(async a=>{let e=new FK.Smartenv;if(e.isBrowser){let t=new TextEncoder().encode(a),r=await crypto.subtle.digest("SHA-256",t);return $Ba(r)}else if(e.isNode)return await(await e.getSafeNodeModule("@pushrocks/smarthash")).sha256FromString(a)},"sha256FromString");var wl={};ht(wl,{Smartjson:()=>mat,deepEqualJsonLStrings:()=>vHa,deepEqualObjects:()=>y5a,foldDec:()=>bHa,parse:()=>Goe,parseBase64:()=>gHa,parseJsonL:()=>hat,stableOneWayStringify:()=>fHa,stringify:()=>h5,stringifyBase64:()=>mHa,stringifyJsonL:()=>pHa,stringifyPretty:()=>hHa});var Ztt={};ht(Ztt,{Smartenv:()=>Ytt});Ti();var Ytt=class{static{i(this,"Smartenv")}constructor(){this.loadedScripts=[]}async getEnvAwareModule(e){if(this.isNode)return await this.getSafeNodeModule(e.nodeModuleName);if(this.isBrowser)return await this.getSafeWebModule(e.webUrlArg,e.getFunction);console.error("platform for loading not supported by smartenv")}async getSafeNodeModule(e,t){if(!this.isNode){console.error(`You tried to load a node module in a wrong context: ${e}. This does not throw.`);return}let r=await new Function(`return import('${e}')`)();return t&&await t(r),r}async getSafeWebModule(e,t){if(!this.isBrowser){console.error("You tried to load a web module in a wrong context");return}if(this.loadedScripts.includes(e))return t();this.loadedScripts.push(e);let r=ut.defer();if(globalThis.importScripts)globalThis.importScripts(e),r.resolve();else{let s=document.createElement("script");s.onload=()=>{r.resolve()},s.src=e,document.head.appendChild(s)}return await r.promise,t()}get runtimeEnv(){return typeof process<"u"?"node":"browser"}get isBrowser(){return!this.isNode}get userAgent(){return this.isBrowser?navigator.userAgent:"undefined"}get isNode(){return this.runtimeEnv==="node"}get nodeVersion(){return process.version}get isCI(){return this.isNode?!!process.env.CI:!1}async isMacAsync(){return this.isNode?(await this.getSafeNodeModule("os")).platform()==="darwin":!1}async isWindowsAsync(){return this.isNode?(await this.getSafeNodeModule("os")).platform()==="win32":!1}async isLinuxAsync(){return this.isNode?(await this.getSafeNodeModule("os")).platform()==="linux":!1}async printEnv(){this.isNode?(console.log("running on NODE"),console.log("node version is "+this.nodeVersion)):(console.log("running on BROWSER"),console.log("browser is "+this.userAgent))}};L8();var joe=eo(m5a(),1),g5a=eo(O0e(),1),Uoe=g5a.default;function nHa(a){return typeof Buffer<"u"?Buffer.from(a).toString("base64"):btoa(String.fromCharCode(...a))}i(nHa,"base64Encode");function lHa(a){if(typeof Buffer<"u"){let e=Buffer.from(a,"base64");return new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}return new Uint8Array(Array.from(atob(a)).map(e=>e.charCodeAt(0)))}i(lHa,"base64Decode");function pat(a,e){return JSON.stringify(a,Woe,e)}i(pat,"stringify");function fat(a){return JSON.parse(a,b5a)}i(fat,"parse");var Woe=i((a,e)=>{if(dHa(e)){let t;if("data"in e&&v5a(e.data))t=new Uint8Array(e.data);else if(e instanceof Uint8Array)t=e;else return e;return{type:"EncodedBuffer",data:"base64:"+nHa(t)}}return e},"replacer"),b5a=i((a,e)=>{if(cHa(e)&&uat(e.data)&&e.data.startsWith("base64:")){let t=e.data.slice(7);return lHa(t)}return e},"reviver");function cHa(a){return x5a(a)&&a.type==="EncodedBuffer"&&uat(a.data)}i(cHa,"isEncodedBuffer");function dHa(a){return x5a(a)&&a.type==="Buffer"&&(v5a(a.data)||uat(a.data))||a instanceof Uint8Array}i(dHa,"isBufferLike");function v5a(a){return Array.isArray(a)}i(v5a,"isArray");function uat(a){return typeof a=="string"}i(uat,"isString");function x5a(a){return typeof a=="object"&&a!==null}i(x5a,"isObject");var Goe=fat,hat=i(a=>a.split(`
42941
42941
  `).reduce((r,s)=>{let o=s.trim();return o.length>0&&r.push(Goe(o)),r},[]),"parseJsonL"),pHa=i(a=>a.map(e=>h5(e)).join(`
42942
- `),"stringifyJsonL"),fHa=i((a,e,t={})=>{let r=new WeakSet,s=i(l=>{if(l===null||typeof l!="object")return l;let c=Woe("",l);if(c&&c.type==="EncodedBuffer"&&typeof c.data=="string")return c;if(r.has(l))return"__cycle__";if(r.add(l),Array.isArray(l))return l.map(p=>s(p));let d={};for(let p of Object.keys(l))try{d[p]=s(l[p])}catch{d[p]="__unserializable__"}return d},"sanitize"),o=s(a),n={...t,cycles:!0};if(e&&!n.cmp){let l=new Map;e.forEach((c,d)=>l.set(c,d)),n.cmp=(c,d)=>{let p=l.has(c.key)?l.get(c.key):Number.POSITIVE_INFINITY,u=l.has(d.key)?l.get(d.key):Number.POSITIVE_INFINITY;return p!==u?p-u:c.key<d.key?-1:c.key>d.key?1:0}}return Uoe(o,n)},"stableOneWayStringify"),h5=i((a,e,t={})=>{let r=pat(a);a=JSON.parse(r);let s={...t};if(e&&!s.cmp){let n=new Map;e.forEach((l,c)=>n.set(l,c)),s.cmp=(l,c)=>{let d=n.has(l.key)?n.get(l.key):Number.POSITIVE_INFINITY,p=n.has(c.key)?n.get(c.key):Number.POSITIVE_INFINITY;return d!==p?d-p:l.key<c.key?-1:l.key>c.key?1:0}}return Uoe(a,s)},"stringify"),hHa=i(a=>{let e=h5(a),t=JSON.parse(e);return JSON.stringify(t,null,2)},"stringifyPretty"),mHa=i((...a)=>{let e=h5(...a);return xs.base64.encodeUri(e)},"stringifyBase64"),gHa=i(a=>{let e=xs.base64,r=(e.decodeUri||e.decode)(a);return Goe(r)},"parseBase64"),mat=class a{static{i(this,"Smartjson")}static enfoldFromObject(e){let t=new this,r=t.saveableProperties||[];for(let s in e)r.indexOf(s)!==-1&&(t[s]=e[s]);return t}static enfoldFromJson(e){let t=Goe(e);return this.enfoldFromObject(t)}foldToObject(){let e=new Set;return e.add(this),this.foldToObjectInternal(e)}foldToObjectInternal(e){let t={},r=i(o=>{if(o instanceof a){if(e.has(o))throw new Error("cycle detected");return e.add(o),o.foldToObjectInternal(e)}return Array.isArray(o)?o.map(n=>r(n)):joe.default(o)},"foldValue"),s=this.saveableProperties||[];for(let o of s){let n=this[o];t[o]=r(n)}return t}foldToJson(){let e=this.foldToObject();return h5(e)}},bHa=i(()=>(a,e)=>{a.saveableProperties||(a.saveableProperties=[]),a.saveableProperties.push(e)},"foldDec"),y5a=i((a,e)=>{let t=h5(a),r=h5(e);return t===r},"deepEqualObjects"),vHa=i((a,e)=>{let t=hat(a),r=hat(e);return y5a(t,r)},"deepEqualJsonLStrings");rb();Vd();v0();Ti();S2();L8();Bpe();var gat="__typedsocket_tag__";function yHa(a){return{peer:a,async getTagById(e){if(!a.tags.has(e))return;let t=a.data.get(`${gat}${e}`);return{id:e,payload:t}}}}i(yHa,"wrapSmartServePeer");var bat=class a{static{i(this,"TypedSocket")}static async createClient(e,t,r={}){let o={...{autoReconnect:!0,maxRetries:100,initialBackoffMs:1e3,maxBackoffMs:6e4},...r},n=new a("client",e);return n.clientOptions=o,n.serverUrl=t,n.currentBackoff=o.initialBackoffMs,await n.connect(),n}static{this.useWindowLocationOriginUrl=()=>E1.Smarturl.createFromUrl(globalThis.location.origin).toString()}static fromSmartServe(e,t){let r=new Map;a.registerTagHandlers(t);let s=new a("server",t);return s.smartServeRef=e,s.smartServeConnectionWrappers=r,s}static registerTagHandlers(e){e.addTypedHandler(new ts.TypedHandler("__typedsocket_setTag",async(t,r)=>{let s=r?.localData?.peer;return s?(s.tags.add(t.name),s.data.set(`${gat}${t.name}`,t.payload),{success:!0}):(console.warn("setTag: No peer found in request context"),{success:!1})})),e.addTypedHandler(new ts.TypedHandler("__typedsocket_removeTag",async(t,r)=>{let s=r?.localData?.peer;return s?(s.tags.delete(t.name),s.data.delete(`${gat}${t.name}`),{success:!0}):(console.warn("removeTag: No peer found in request context"),{success:!1})}))}constructor(e,t){this.statusSubject=new Aa.rxjs.Subject,this.connectionStatus="new",this.websocket=null,this.clientOptions=null,this.serverUrl="",this.retryCount=0,this.currentBackoff=1e3,this.pendingRequests=new Map,this.smartServeRef=null,this.smartServeConnectionWrappers=new Map,this.side=e,this.typedrouter=t}async connect(){let e=ut.defer();this.updateStatus("connecting");let t=this.toWebSocketUrl(this.serverUrl);console.log(`TypedSocket connecting to ${t}...`),this.websocket=new WebSocket(t);let r=setTimeout(()=>{this.connectionStatus!=="connected"&&(console.warn("TypedSocket connection timeout"),this.websocket?.close(),e.reject(new Error("Connection timeout")))},1e4);this.websocket.onopen=()=>{clearTimeout(r),console.log("TypedSocket connected!"),this.updateStatus("connected"),this.retryCount=0,this.currentBackoff=this.clientOptions?.initialBackoffMs??1e3,e.resolve()},this.websocket.onmessage=async s=>{await this.handleMessage(s.data)},this.websocket.onclose=()=>{clearTimeout(r),this.handleDisconnect()},this.websocket.onerror=s=>{console.error("TypedSocket WebSocket error:",s)};try{await e.promise}catch(s){if(clearTimeout(r),this.clientOptions?.autoReconnect)await this.scheduleReconnect();else throw s}}toWebSocketUrl(e){let t=new URL(e);return`${t.protocol==="https:"?"wss:":"ws:"}//${t.host}${t.pathname}`}async handleMessage(e){try{let t=typeof e=="string"?e:new TextDecoder().decode(e),r=wl.parse(t);if(r.correlation?.id&&this.pendingRequests.has(r.correlation.id)){let o=this.pendingRequests.get(r.correlation.id);this.pendingRequests.delete(r.correlation.id),o.resolve(r);return}let s=await this.typedrouter.routeAndAddResponse(r);s&&this.websocket?.readyState===WebSocket.OPEN&&this.websocket.send(wl.stringify(s))}catch(t){console.error("TypedSocket failed to process message:",t)}}handleDisconnect(){if(this.connectionStatus!=="disconnected"){this.updateStatus("disconnected");for(let[e,t]of this.pendingRequests)t.reject(new Error("TypedSocket disconnected"));this.pendingRequests.clear(),this.clientOptions?.autoReconnect&&this.retryCount<this.clientOptions.maxRetries&&this.scheduleReconnect()}}async scheduleReconnect(){if(!this.clientOptions)return;this.updateStatus("reconnecting"),this.retryCount++;let e=this.currentBackoff*.2*(Math.random()*2-1),t=Math.min(this.currentBackoff+e,this.clientOptions.maxBackoffMs);console.log(`TypedSocket reconnecting in ${Math.round(t)}ms (attempt ${this.retryCount}/${this.clientOptions.maxRetries})`),await Zt.delayFor(t),this.currentBackoff=Math.min(this.currentBackoff*2,this.clientOptions.maxBackoffMs);try{await this.connect()}catch(r){console.error("TypedSocket reconnection failed:",r)}}updateStatus(e){this.connectionStatus!==e&&(this.connectionStatus=e,this.statusSubject.next(e))}async sendRequest(e){if(!this.websocket||this.websocket.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");e.correlation||={id:xs.create.createCryptoRandomString(),phase:"request"};let t=e.correlation.id;return new Promise((r,s)=>{let o=setTimeout(()=>{this.pendingRequests.delete(t),s(new Error("Request timeout"))},3e4);this.pendingRequests.set(t,{resolve:i(n=>{clearTimeout(o),r(n)},"resolve"),reject:i(n=>{clearTimeout(o),s(n)},"reject")}),this.websocket.send(wl.stringify(e))})}createTypedRequest(e,t){let r=i(async s=>{if(this.side==="client")return this.sendRequest(s);if(!this.smartServeRef)throw new Error("Server not initialized");let o=t;if(!o){let l=this.smartServeRef.getWebSocketConnections();if(l.length===1){let c=l[0];o=this.getOrCreateWrapper(c)}else throw l.length===0?new Error("No WebSocket connections available"):new Error("Multiple connections available - specify targetConnection")}let n=await this.typedrouter.fireEventInterestMap.addInterest(s.correlation.id,s);return o.peer.send(wl.stringify(s)),await n.interestFullfilled},"postMethod");return new ts.TypedRequest(new ts.TypedTarget({postMethod:r}),e)}getStatus(){return this.connectionStatus}async stop(){this.side==="client"?(this.clientOptions&&(this.clientOptions.autoReconnect=!1),this.websocket&&(this.websocket.close(),this.websocket=null),this.pendingRequests.clear()):this.smartServeConnectionWrappers.clear()}async setTag(e,t){if(this.side!=="client")throw new Error("setTag is only available on clients");if(!(await this.createTypedRequest("__typedsocket_setTag").fire({name:e,payload:t})).success)throw new Error("Failed to set tag on server")}async removeTag(e){if(this.side!=="client")throw new Error("removeTag is only available on clients");if(!(await this.createTypedRequest("__typedsocket_removeTag").fire({name:e})).success)throw new Error("Failed to remove tag on server")}getOrCreateWrapper(e){let t=this.smartServeConnectionWrappers.get(e.id);return t||(t=yHa(e),this.smartServeConnectionWrappers.set(e.id,t)),t}async findAllTargetConnections(e){if(this.side!=="server"||!this.smartServeRef)throw new Error("findAllTargetConnections is only available on servers");let t=[];for(let r of this.smartServeRef.getWebSocketConnections()){let s=this.getOrCreateWrapper(r);await e(s)&&t.push(s)}return t}async findTargetConnection(e){return(await this.findAllTargetConnections(e))[0]}async findAllTargetConnectionsByTag(e,t){if(this.side!=="server"||!this.smartServeRef)throw new Error("findAllTargetConnectionsByTag is only available on servers");let r=this.smartServeRef.getWebSocketConnectionsByTag(e),s=[];for(let o of r){let n=this.getOrCreateWrapper(o);if(t!==void 0){let l=await n.getTagById(e);if(wl.stringify(l?.payload)!==wl.stringify(t))continue}s.push(n)}return s}async findTargetConnectionByTag(e,t){return(await this.findAllTargetConnectionsByTag(e,t))[0]}};le();at();var ine=eo(y8a(),1),Ve=Rt;Vd();var qat={};ht(qat,{DCROUTER_BUILTIN_PROVIDER_ID:()=>mVa,apiTokenScopes:()=>hVa,dnsProviderTypeDescriptors:()=>w8a,getDnsProviderTypeDescriptor:()=>gVa});var hVa=["*","routes:read","routes:write","config:read","stats:read","logs:read","security:read","security:write","emails:read","emails:write","certificates:read","certificates:write","tokens:read","tokens:manage","users:read","users:manage","source-profiles:read","source-profiles:write","target-profiles:read","target-profiles:write","targets:read","targets:write","dns-providers:read","dns-providers:write","domains:read","domains:write","dns-records:read","dns-records:write","acme-config:read","acme-config:write","email-domains:read","email-domains:write","remote-ingress:read","remote-ingress:write","vpn:read","vpn:write","radius:read","radius:write","gateway-clients:read","gateway-clients:write","workhosters:read","workhosters:write"];var mVa="__dcrouter__",w8a=[{type:"dcrouter",displayName:"DcRouter (built-in)",description:"Built-in authoritative DNS. Records are served directly by dcrouter \u2014 delegate the domain's NS records to make this effective.",credentialFields:[]},{type:"cloudflare",displayName:"Cloudflare",description:"External DNS provider. The provider stays authoritative; dcrouter pushes record changes via its API.",credentialFields:[{key:"apiToken",label:"API Token",helpText:"A Cloudflare API token with Zone:Read and DNS:Edit permissions for the target zones.",required:!0,secret:!0}]}];function gVa(a){return w8a.find(e=>e.type===a)}i(gVa,"getDnsProviderTypeDescriptor");var k8a={};var ci=new Ve.plugins.smartstate.Smartstate,Ia=await ci.getStatePart("login",{identity:null,isLoggedIn:!1},"persistent"),$r=await ci.getStatePart("stats",{serverStats:null,emailStats:null,dnsStats:null,securityMetrics:null,radiusStats:null,vpnStats:null,lastUpdated:0,isLoading:!1,error:null},"soft"),fd=await ci.getStatePart("config",{config:null,isLoading:!1,error:null}),bVa=i(()=>{let a=typeof window<"u"?window.location.pathname:"/",e=["overview","network","email","logs","access","security","domains"],r=a.split("/").filter(Boolean)[0];return e.includes(r)?r:"overview"},"getInitialView"),vVa=i(()=>(typeof window<"u"?window.location.pathname:"/").split("/").filter(Boolean)[1]??null,"getInitialSubview"),Xi=await ci.getStatePart("ui",{activeView:bVa(),activeSubview:vVa(),sidebarCollapsed:!1,autoRefresh:!0,refreshInterval:1e3,theme:"light"}),a0=await ci.getStatePart("logs",{recentLogs:[],isStreaming:!1,filters:{}},"soft"),o1=await ci.getStatePart("network",{connections:[],connectionsByIP:{},throughputRate:{bytesInPerSecond:0,bytesOutPerSecond:0},totalBytes:{in:0,out:0},topIPs:[],topIPsByBandwidth:[],throughputByIP:[],ipIntelligence:[],domainActivity:[],throughputHistory:[],requestsPerSecond:0,requestsTotal:0,backends:[],frontendProtocols:null,backendProtocols:null,lastUpdated:0,isLoading:!1,error:null},"soft"),ms=await ci.getStatePart("securityPolicy",{rules:[],ipIntelligence:[],compiledPolicy:null,auditEvents:[],isLoading:!1,error:null,lastUpdated:0},"soft"),nne=await ci.getStatePart("emailOps",{emails:[],isLoading:!1,error:null,lastUpdated:0},"soft"),Zo=await ci.getStatePart("certificates",{certificates:[],summary:{total:0,valid:0,expiring:0,expired:0,failed:0,unknown:0},isLoading:!1,error:null,lastUpdated:0},"soft"),z5=await ci.getStatePart("acmeConfig",{config:null,isLoading:!1,error:null,lastUpdated:0},"soft"),Ys=await ci.getStatePart("remoteIngress",{edges:[],statuses:[],selectedEdgeId:null,newEdgeId:null,isLoading:!1,error:null,lastUpdated:0},"soft"),ra=await ci.getStatePart("routeManagement",{mergedRoutes:[],warnings:[],apiTokens:[],gatewayClients:[],isLoading:!1,error:null,lastUpdated:0},"soft"),Sn=await ci.getStatePart("users",{users:[],isLoading:!1,error:null,lastUpdated:0},"soft"),tt=i(()=>{let a=Ia.getState().identity;return a&&a.expiresAt&&a.expiresAt<Date.now()?{identity:null}:{identity:a}},"getActionContext"),L8a=Ia.createAction(async(a,e)=>{let t=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","adminLoginWithUsernameAndPassword");try{let r=await t.fire({username:e.username,password:e.password,authSource:e.authSource});return r.identity?{identity:r.identity,isLoggedIn:!0}:a.getState()}catch(r){return console.error("Login failed:",r),a.getState()}});async function $8a(){return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getAdminBootstrapStatus").fire({})}i($8a,"getAdminBootstrapStatus");async function D8a(a){let e=tt();if(!e.identity)throw new Error("No identity available for admin bootstrap");let r=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createInitialAdminUser").fire({identity:e.identity,email:a.email,name:a.name,password:a.password,enableIdpGlobalAuth:a.enableIdpGlobalAuth});return r.identity&&Ia.setState({identity:r.identity,isLoggedIn:!0}),r}i(D8a,"createInitialAdminUser");var u9=Ia.createAction(async a=>{let e=tt();if(e.identity){let t=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","adminLogout");try{await t.fire({identity:e.identity})}catch(r){console.error("Logout error:",r)}}return{identity:null,isLoggedIn:!1}}),p9=$r.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getCombinedMetrics").fire({identity:e.identity,sections:{server:!0,email:!0,dns:!0,security:!0,network:!1,radius:!0,vpn:!0}});return{serverStats:s.metrics.server||t.serverStats,emailStats:s.metrics.email||t.emailStats,dnsStats:s.metrics.dns||t.dnsStats,securityMetrics:s.metrics.security||t.securityMetrics,radiusStats:s.metrics.radius||t.radiusStats,vpnStats:s.metrics.vpn||t.vpnStats,lastUpdated:Date.now(),isLoading:!1,error:null}}catch(r){return{...t,isLoading:!1,error:r.message||"Failed to fetch statistics"}}}),lne=fd.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{return{config:(await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getConfiguration").fire({identity:e.identity})).config,isLoading:!1,error:null}}catch(r){return{...t,isLoading:!1,error:r.message||"Failed to fetch configuration"}}}),cne=a0.createAction(async(a,e)=>{let t=tt();if(!t.identity)return a.getState();let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getRecentLogs").fire({identity:t.identity,limit:e.limit||100,level:e.level,category:e.category});return{...a.getState(),recentLogs:s.logs}}),Bbo=Xi.createAction(async a=>{let e=a.getState();return{...e,autoRefresh:!e.autoRefresh}}),qbo=Xi.createAction(async(a,e)=>{let t=a.getState();return e==="network"&&t.activeView!=="network"&&setTimeout(()=>{o1.dispatchAction(XK,null)},100),e==="domains"&&t.activeView!=="domains"&&setTimeout(()=>{Zo.dispatchAction(pd,null)},100),{...t,activeView:e}}),Hat=new Set;function c9(a,e,t){Hat.has(a)||(Hat.add(a),t().catch(r=>console.error(e,r)).finally(()=>Hat.delete(a)))}i(c9,"runBackgroundRefresh");function M8a(a,e){let t=[...new Set(e.filter(Boolean))].slice(0,100);t.length!==0&&c9("networkIpIntelligence","IP intelligence refresh failed:",async()=>{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listIpIntelligence").fire({identity:a,ipAddresses:t,limit:Math.max(100,t.length)});o1.setState({...o1.getState(),ipIntelligence:s.records||[]})})}i(M8a,"refreshNetworkIpIntelligence");function xVa(a){c9("securityIpIntelligence","Security IP intelligence refresh failed:",async()=>{let t=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listIpIntelligence").fire({identity:a,limit:500});ms.setState({...ms.getState(),ipIntelligence:t.records||[]})})}i(xVa,"refreshSecurityIpIntelligence");var XK=o1.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getNetworkStats").fire({identity:e.identity}),o={},n=new Map;for(let c of s.throughputByIP||[])n.set(c.ip,{in:c.in,out:c.out});s.connectionsByIP&&Array.isArray(s.connectionsByIP)&&s.connectionsByIP.forEach(c=>{o[c.ip]=c.count});let l=Object.entries(o).map(([c,d])=>{let p=n.get(c);return{id:`ip-${c}`,remoteAddress:c,localAddress:"server",startTime:0,protocol:"https",state:"connected",bytesReceived:p?.in||0,bytesSent:p?.out||0,connectionCount:d}});return M8a(e.identity,[...Object.keys(o),...(s.topIPs||[]).map(c=>c.ip),...(s.topIPsByBandwidth||[]).map(c=>c.ip)]),{connections:l,connectionsByIP:o,throughputRate:s.throughputRate||{bytesInPerSecond:0,bytesOutPerSecond:0},totalBytes:s.totalDataTransferred?{in:s.totalDataTransferred.bytesIn,out:s.totalDataTransferred.bytesOut}:{in:0,out:0},topIPs:s.topIPs||[],topIPsByBandwidth:s.topIPsByBandwidth||[],throughputByIP:s.throughputByIP||[],ipIntelligence:t.ipIntelligence,domainActivity:s.domainActivity||[],throughputHistory:s.throughputHistory||[],requestsPerSecond:s.requestsPerSecond||0,requestsTotal:s.requestsTotal||0,backends:s.backends||[],frontendProtocols:s.frontendProtocols||null,backendProtocols:s.backendProtocols||null,lastUpdated:Date.now(),isLoading:!1,error:null}}catch(r){return console.error("Failed to fetch network stats:",r),{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch network stats"}}}),k5=ms.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let r=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listSecurityBlockRules"),s=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getCompiledSecurityPolicy"),o=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listSecurityPolicyAudit"),[n,l,c]=await Promise.all([r.fire({identity:e.identity}),s.fire({identity:e.identity}),o.fire({identity:e.identity,limit:100})]);return xVa(e.identity),{rules:n.rules||[],ipIntelligence:t.ipIntelligence,compiledPolicy:l.policy,auditEvents:c.events||[],isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch security policy"}}}),dne=ms.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createSecurityBlockRule").fire({identity:r.identity,type:e.type,value:e.value,matchMode:e.matchMode,reason:e.reason,enabled:e.enabled});return n.success?await t.dispatch(k5,null):{...s,error:n.message||"Failed to create security block rule"}}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to create security block rule"}}}),une=ms.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateSecurityBlockRule").fire({identity:r.identity,id:e.id,value:e.value,matchMode:e.matchMode,reason:e.reason,enabled:e.enabled});return n.success?await t.dispatch(k5,null):{...s,error:n.message||"Failed to update security block rule"}}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to update security block rule"}}}),I8a=ms.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteSecurityBlockRule").fire({identity:r.identity,id:e});return n.success?await t.dispatch(k5,null):{...s,error:n.message||"Failed to delete security block rule"}}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete security block rule"}}}),pne=ms.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","refreshIpIntelligence").fire({identity:r.identity,ipAddress:e});if(!n.success)return{...s,error:n.message||"Failed to refresh IP intelligence"};let l=await t.dispatch(k5,null);return n.record?{...l,ipIntelligence:[n.record,...l.ipIntelligence.filter(c=>c.ipAddress!==n.record.ipAddress)]}:l}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to refresh IP intelligence"}}}),A8a=nne.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{return{emails:(await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getAllEmails").fire({identity:e.identity})).emails,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch emails"}}}),pd=Zo.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getCertificateOverview").fire({identity:e.identity});return{certificates:s.certificates,summary:s.summary,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch certificate overview"}}}),P8a=Zo.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","reprovisionCertificateDomain").fire({identity:r.identity,domain:e.domain,forceRenew:e.forceRenew}),await t.dispatch(pd,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to reprovision certificate"}}}),E8a=Zo.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteCertificate").fire({identity:r.identity,domain:e}),await t.dispatch(pd,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete certificate"}}}),N8a=Zo.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","importCertificate").fire({identity:r.identity,cert:e}),await t.dispatch(pd,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to import certificate"}}});async function R8a(a){let e=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","exportCertificate").fire({identity:e.identity,domain:a})}i(R8a,"fetchCertificateExport");async function Gat(a){let e=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getRemoteIngressConnectionToken").fire({identity:e.identity,edgeId:a})}i(Gat,"fetchConnectionToken");var M5=Ys.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let r=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getRemoteIngresses"),s=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getRemoteIngressStatus"),[o,n]=await Promise.all([r.fire({identity:e.identity}),s.fire({identity:e.identity})]);return{...t,edges:o.edges,statuses:n.statuses,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch remote ingress data"}}}),O8a=Ys.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createRemoteIngress").fire({identity:r.identity,name:e.name,listenPorts:e.listenPorts,autoDerivePorts:e.autoDerivePorts,tags:e.tags});return n.success?(await t.dispatch(M5,null),{...a.getState(),newEdgeId:n.edge.id}):s}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to create edge"}}}),F8a=Ys.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteRemoteIngress").fire({identity:r.identity,id:e}),await t.dispatch(M5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete edge"}}}),B8a=Ys.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateRemoteIngress").fire({identity:r.identity,id:e.id,name:e.name,listenPorts:e.listenPorts,autoDerivePorts:e.autoDerivePorts,tags:e.tags}),await t.dispatch(M5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to update edge"}}}),q8a=Ys.createAction(async(a,e)=>{let t=tt(),r=a.getState();try{return(await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","regenerateRemoteIngressSecret").fire({identity:t.identity,id:e})).success?{...r,newEdgeId:e}:r}catch(s){return{...r,error:s instanceof Error?s.message:"Failed to regenerate secret"}}}),H8a=Ys.createAction(async a=>({...a.getState(),newEdgeId:null})),Kat=Ys.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateRemoteIngress").fire({identity:r.identity,id:e.id,enabled:e.enabled}),await t.dispatch(M5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to toggle edge"}}}),Zs=await ci.getStatePart("vpn",{clients:[],connectedClients:[],status:null,isLoading:!1,error:null,lastUpdated:0,newClientConfig:null},"soft"),S5=Zs.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let r=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getVpnClients"),s=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getVpnStatus"),o=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getVpnConnectedClients"),[n,l,c]=await Promise.all([r.fire({identity:e.identity}),s.fire({identity:e.identity}),o.fire({identity:e.identity})]);return{...t,clients:n.clients,connectedClients:c.connectedClients,status:l.status,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch VPN data"}}}),V8a=Zs.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createVpnClient").fire({identity:r.identity,clientId:e.clientId,targetProfileIds:e.targetProfileIds,description:e.description,destinationAllowList:e.destinationAllowList,destinationBlockList:e.destinationBlockList,useHostIp:e.useHostIp,useDhcp:e.useDhcp,staticIp:e.staticIp,forceVlan:e.forceVlan,vlanId:e.vlanId});return n.success?{...await t.dispatch(S5,null),newClientConfig:n.wireguardConfig||null}:{...s,error:n.message||"Failed to create client"}}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to create VPN client"}}}),j8a=Zs.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteVpnClient").fire({identity:r.identity,clientId:e}),await t.dispatch(S5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete VPN client"}}}),Yat=Zs.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let o=e.enabled?"enableVpnClient":"disableVpnClient";return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest",o).fire({identity:r.identity,clientId:e.clientId}),await t.dispatch(S5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to toggle VPN client"}}}),U8a=Zs.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateVpnClient").fire({identity:r.identity,clientId:e.clientId,description:e.description,targetProfileIds:e.targetProfileIds,destinationAllowList:e.destinationAllowList,destinationBlockList:e.destinationBlockList,useHostIp:e.useHostIp,useDhcp:e.useDhcp,staticIp:e.staticIp,forceVlan:e.forceVlan,vlanId:e.vlanId});return n.success?await t.dispatch(S5,null):{...s,error:n.message||"Failed to update client"}}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to update VPN client"}}}),W8a=Zs.createAction(async a=>({...a.getState(),newClientConfig:null})),Xs=await ci.getStatePart("targetProfiles",{profiles:[],isLoading:!1,error:null,lastUpdated:0},"soft"),r0=Xs.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{return{profiles:(await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getTargetProfiles").fire({identity:e.identity})).profiles,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch target profiles"}}}),G8a=Xs.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createTargetProfile").fire({identity:r.identity,name:e.name,description:e.description,domains:e.domains,targets:e.targets,routeRefs:e.routeRefs,allowRoutesByClientSourceIp:e.allowRoutesByClientSourceIp});return o.success?await t.dispatch(r0,null):{...a.getState(),error:o.message||"Failed to create target profile"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create target profile"}}}),K8a=Xs.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateTargetProfile").fire({identity:r.identity,id:e.id,name:e.name,description:e.description,domains:e.domains,targets:e.targets,routeRefs:e.routeRefs,allowRoutesByClientSourceIp:e.allowRoutesByClientSourceIp});return o.success?await t.dispatch(r0,null):{...a.getState(),error:o.message||"Failed to update target profile"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update target profile"}}}),Zat=Xs.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteTargetProfile").fire({identity:r.identity,id:e.id,force:e.force});return o.success?await t.dispatch(r0,null):{...a.getState(),error:o.message||"Failed to delete target profile"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete target profile"}}}),Qa=await ci.getStatePart("profilesTargets",{profiles:[],targets:[],isLoading:!1,error:null,lastUpdated:0},"soft"),Xo=Qa.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let r=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getSourceProfiles"),s=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getNetworkTargets"),[o,n]=await Promise.all([r.fire({identity:e.identity}),s.fire({identity:e.identity})]);return{profiles:o.profiles,targets:n.targets,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch profiles/targets"}}}),Y8a=Qa.createAction(async(a,e,t)=>{let r=tt();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createSourceProfile").fire({identity:r.identity,name:e.name,description:e.description,security:e.security,extendsProfiles:e.extendsProfiles}),await t.dispatch(Xo,null)}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create profile"}}}),Z8a=Qa.createAction(async(a,e,t)=>{let r=tt();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateSourceProfile").fire({identity:r.identity,id:e.id,name:e.name,description:e.description,security:e.security,extendsProfiles:e.extendsProfiles}),await t.dispatch(Xo,null)}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update profile"}}}),Xat=Qa.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteSourceProfile").fire({identity:r.identity,id:e.id,force:e.force});return o.success?await t.dispatch(Xo,null):{...a.getState(),error:o.message||"Failed to delete profile"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete profile"}}}),X8a=Qa.createAction(async(a,e,t)=>{let r=tt();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createNetworkTarget").fire({identity:r.identity,name:e.name,description:e.description,host:e.host,port:e.port}),await t.dispatch(Xo,null)}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create target"}}}),Q8a=Qa.createAction(async(a,e,t)=>{let r=tt();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateNetworkTarget").fire({identity:r.identity,id:e.id,name:e.name,description:e.description,host:e.host,port:e.port}),await t.dispatch(Xo,null)}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update target"}}}),Qat=Qa.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteNetworkTarget").fire({identity:r.identity,id:e.id,force:e.force});return o.success?await t.dispatch(Xo,null):{...a.getState(),error:o.message||"Failed to delete target"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete target"}}}),Ot=await ci.getStatePart("domains",{providers:[],domains:[],records:[],selectedDomainId:null,isLoading:!1,error:null,lastUpdated:0},"soft"),hs=Ot.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let r=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getDnsProviders"),s=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getDomains"),[o,n]=await Promise.all([r.fire({identity:e.identity}),s.fire({identity:e.identity})]);return{...t,providers:o.providers,domains:n.domains,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch domains/providers"}}}),s0=Ot.createAction(async(a,e)=>{let t=tt(),r=a.getState();if(!t.identity)return r;try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getDnsRecords").fire({identity:t.identity,domainId:e.domainId});return{...r,records:o.records,selectedDomainId:e.domainId,error:null}}catch(s){return{...r,error:s instanceof Error?s.message:"Failed to fetch DNS records"}}}),J8a=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createDnsProvider").fire({identity:r.identity,name:e.name,type:e.type,credentials:e.credentials});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to create provider"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create provider"}}}),ema=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateDnsProvider").fire({identity:r.identity,id:e.id,name:e.name,credentials:e.credentials});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to update provider"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update provider"}}}),tma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteDnsProvider").fire({identity:r.identity,id:e.id,force:e.force});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to delete provider"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete provider"}}}),ama=Ot.createAction(async(a,e,t)=>{let r=tt();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","testDnsProvider").fire({identity:r.identity,id:e.id}),await t.dispatch(hs,null)}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to test provider"}}});async function rma(a){let e=tt();return e.identity?await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listProviderDomains").fire({identity:e.identity,providerId:a}):{success:!1,message:"Not authenticated"}}i(rma,"fetchProviderDomains");var sma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createDomain").fire({identity:r.identity,name:e.name,description:e.description});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to create domain"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create domain"}}}),ima=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","importDomain").fire({identity:r.identity,providerId:e.providerId,domainNames:e.domainNames});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to import domains"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to import domains"}}}),oma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteDomain").fire({identity:r.identity,id:e.id});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to delete domain"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete domain"}}}),nma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","syncDomain").fire({identity:r.identity,id:e.id});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to sync domain"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to sync domain"}}}),lma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","migrateDomain").fire({identity:r.identity,...e});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Migration failed"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Migration failed"}}}),cma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createDnsRecord").fire({identity:r.identity,domainId:e.domainId,name:e.name,type:e.type,value:e.value,ttl:e.ttl,proxied:e.proxied});return o.success?await t.dispatch(s0,{domainId:e.domainId}):{...a.getState(),error:o.message||"Failed to create record"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create record"}}}),dma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateDnsRecord").fire({identity:r.identity,id:e.id,name:e.name,value:e.value,ttl:e.ttl,proxied:e.proxied});return o.success?await t.dispatch(s0,{domainId:e.domainId}):{...a.getState(),error:o.message||"Failed to update record"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update record"}}}),uma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteDnsRecord").fire({identity:r.identity,id:e.id});return o.success?await t.dispatch(s0,{domainId:e.domainId}):{...a.getState(),error:o.message||"Failed to delete record"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete record"}}}),Jat=z5.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{return{config:(await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getAcmeConfig").fire({identity:e.identity})).config,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch ACME config"}}}),pma=z5.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateAcmeConfig").fire({identity:r.identity,accountEmail:e.accountEmail,enabled:e.enabled,useProduction:e.useProduction,autoRenew:e.autoRenew,renewThresholdDays:e.renewThresholdDays});return o.success?await t.dispatch(Jat,null):{...a.getState(),error:o.message||"Failed to update ACME config"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update ACME config"}}}),kl=ra.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getMergedRoutes").fire({identity:e.identity});return{...t,mergedRoutes:s.routes,warnings:s.warnings,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch routes"}}}),fma=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createRoute").fire({identity:r.identity,route:e.route,enabled:e.enabled,metadata:e.metadata}),await t.dispatch(kl,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to create route"}}}),hma=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateRoute").fire({identity:r.identity,id:e.id,route:e.route,enabled:e.enabled,metadata:e.metadata});if(!n.success)throw new Error(n.message||"Failed to update route");return await t.dispatch(kl,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to update route"}}}),ert=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteRoute").fire({identity:r.identity,id:e});if(!n.success)throw new Error(n.message||"Failed to delete route");return await t.dispatch(kl,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete route"}}}),mma=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","toggleRoute").fire({identity:r.identity,id:e.id,enabled:e.enabled});if(!n.success)throw new Error(n.message||"Failed to toggle route");return await t.dispatch(kl,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to toggle route"}}}),T5=ra.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listApiTokens").fire({identity:e.identity});return{...t,apiTokens:s.tokens}}catch(r){return{...t,error:r instanceof Error?r.message:"Failed to fetch tokens"}}}),d9=ra.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listGatewayClients").fire({identity:e.identity});return{...t,gatewayClients:s.gatewayClients,error:null,lastUpdated:Date.now()}}catch(r){return{...t,error:r instanceof Error?r.message:"Failed to fetch gateway clients"}}});async function gma(a){let e=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createGatewayClient").fire({identity:e.identity,capabilities:{readDomains:!0,readDnsRecords:!0,syncRoutes:!0,syncDnsRecords:!1,requestCertificates:!1},...a})}i(gma,"createGatewayClient");var trt=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateGatewayClient").fire({identity:r.identity,...e}),await t.dispatch(d9,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to update gateway client"}}}),bma=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteGatewayClient").fire({identity:r.identity,id:e}),await t.dispatch(d9,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete gateway client"}}});async function vma(a,e,t){let r=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createGatewayClientToken").fire({identity:r.identity,gatewayClientId:a,name:e,expiresInDays:t})}i(vma,"createGatewayClientToken");var _5=Sn.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listUsers").fire({identity:e.identity});return{...t,users:s.users,error:null,lastUpdated:Date.now()}}catch(r){return{...t,error:r instanceof Error?r.message:"Failed to fetch users"}}}),xma=Sn.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createUser").fire({identity:r.identity,email:e.email,name:e.name,role:e.role,password:e.password,enableIdpGlobalAuth:e.enableIdpGlobalAuth});if(!n.success)throw new Error(n.message||"Failed to create user");return await t.dispatch(_5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to create user"}}}),yma=Sn.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteUser").fire({identity:r.identity,id:e});if(!n.success)throw new Error(n.message||"Failed to delete user");return await t.dispatch(_5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete user"}}});async function wma(a,e,t,r){let s=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createApiToken").fire({identity:s.identity,name:a,scopes:e,policy:r,expiresInDays:t})}i(wma,"createApiToken");async function kma(a){let e=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","rollApiToken").fire({identity:e.identity,id:a})}i(kma,"rollApiToken");var Mma=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","revokeApiToken").fire({identity:r.identity,id:e}),await t.dispatch(T5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to revoke token"}}}),art=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","toggleApiToken").fire({identity:r.identity,id:e.id,enabled:e.enabled}),await t.dispatch(T5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to toggle token"}}}),To=await ci.getStatePart("emailDomains",{domains:[],isLoading:!1,lastUpdated:0},"soft"),C5=To.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getEmailDomains").fire({identity:e.identity});return{...t,domains:s.domains,isLoading:!1,lastUpdated:Date.now()}}catch{return{...t,isLoading:!1}}}),Sma=To.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createEmailDomain").fire({identity:r.identity,...e}),await t.dispatch(C5,null)}catch{return s}}),Cma=To.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteEmailDomain").fire({identity:r.identity,id:e}),await t.dispatch(C5,null)}catch{return s}}),zma=To.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","validateEmailDomain").fire({identity:r.identity,id:e}),await t.dispatch(C5,null)}catch{return s}}),rrt=To.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","provisionEmailDomainDns").fire({identity:r.identity,id:e}),await t.dispatch(C5,null)}catch{return s}});async function Tma(a){let e=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getEmailDomainDnsRecords").fire({identity:e.identity,id:a})}i(Tma,"fetchEmailDomainDnsRecords");var y5=null,S8a=new Ve.plugins.typedrequest.TypedRouter,one=[],Vat=!1;function yVa(){if(Vat=!1,one.length===0)return;let a=a0.getState(),e=[...a.recentLogs,...one];one=[],e.length>2e3&&e.splice(0,e.length-2e3),a0.setState({...a,recentLogs:e})}i(yVa,"flushLogEntries"),S8a.addTypedHandler(new Ve.plugins.typedrequest.TypedHandler("pushLogEntry",async a=>(one.push(a.entry),Vat||(Vat=!0,requestAnimationFrame(yVa)),{})));async function jat(){if(!y5)try{y5=await r9.TypedSocket.createClient(S8a,r9.TypedSocket.useWindowLocationOriginUrl()),await y5.setTag("role","ops_dashboard")}catch(a){console.error("TypedSocket connection failed:",a),y5=null}}i(jat,"connectSocket");async function C8a(){if(y5){try{await y5.stop()}catch{}y5=null}}i(C8a,"disconnectSocket");var Uat=!1;async function wVa(){if(!Uat){Uat=!0;try{await kVa()}finally{Uat=!1}}}i(wVa,"dispatchCombinedRefreshAction");async function kVa(){let a=tt();if(!a.identity)return;let e=Xi.getState().activeView,t=Xi.getState().activeSubview;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getCombinedMetrics").fire({identity:a.identity,sections:{server:!0,email:!0,dns:!0,security:!0,network:e==="network"&&t==="activity",radius:!0,vpn:!0}}),o=$r.getState();if($r.setState({...o,serverStats:s.metrics.server||o.serverStats,emailStats:s.metrics.email||o.emailStats,dnsStats:s.metrics.dns||o.dnsStats,securityMetrics:s.metrics.security||o.securityMetrics,radiusStats:s.metrics.radius||o.radiusStats,vpnStats:s.metrics.vpn||o.vpnStats,lastUpdated:Date.now(),isLoading:!1,error:null}),s.metrics.network&&e==="network"){let n=s.metrics.network,l={};n.connectionDetails.forEach(d=>{l[d.remoteAddress]=(l[d.remoteAddress]||0)+(d.connectionCount||1)});let c=n.connectionDetails.map((d,p)=>({id:`ip-${d.remoteAddress}`,remoteAddress:d.remoteAddress,localAddress:"server",startTime:d.startTime,protocol:d.protocol,state:d.state,bytesReceived:d.bytesIn,bytesSent:d.bytesOut,connectionCount:d.connectionCount}));o1.setState({...o1.getState(),connections:c,connectionsByIP:l,throughputRate:{bytesInPerSecond:n.totalBandwidth.in,bytesOutPerSecond:n.totalBandwidth.out},totalBytes:n.totalBytes||{in:0,out:0},topIPs:n.topEndpoints.map(d=>({ip:d.endpoint,count:d.connections})),topIPsByBandwidth:(n.topEndpointsByBandwidth||[]).map(d=>({ip:d.endpoint,count:d.connections,bwIn:d.bandwidth?.in||0,bwOut:d.bandwidth?.out||0})),throughputByIP:n.topEndpoints.map(d=>({ip:d.endpoint,in:d.bandwidth?.in||0,out:d.bandwidth?.out||0})),domainActivity:n.domainActivity||[],throughputHistory:n.throughputHistory||[],requestsPerSecond:n.requestsPerSecond||0,requestsTotal:n.requestsTotal||0,backends:n.backends||[],frontendProtocols:n.frontendProtocols||null,backendProtocols:n.backendProtocols||null,lastUpdated:Date.now(),isLoading:!1,error:null}),M8a(a.identity,[...n.connectionDetails.map(d=>d.remoteAddress),...n.topEndpoints.map(d=>d.endpoint),...(n.topEndpointsByBandwidth||[]).map(d=>d.endpoint)])}e==="security"&&c9("securityPolicy","Security policy refresh failed:",async()=>{await ms.dispatchAction(k5,null)}),e==="domains"&&t==="certificates"&&c9("certificates","Certificate refresh failed:",async()=>{await Zo.dispatchAction(pd,null)}),e==="network"&&t==="remoteingress"&&c9("remoteIngress","Remote ingress refresh failed:",async()=>{await Ys.dispatchAction(M5,null)}),e==="network"&&t==="vpn"&&c9("vpn","VPN refresh failed:",async()=>{await Zs.dispatchAction(S5,null)})}catch(r){console.error("Combined refresh failed:",r);let s=String(r);(s.includes("invalid")||s.includes("unauthorized")||s.includes("401"))&&(await Ia.dispatchAction(u9,null),window.location.reload())}}i(kVa,"dispatchCombinedRefreshActionInner");var MVa=$r.createAction(async a=>(await wVa(),a.getState())),w5=null,Wat=i(()=>{let a=Xi.getState(),e=Ia.getState();a.autoRefresh&&e.isLoggedIn?(w5&&(w5.dispose(),w5=null),w5=$r.createScheduledAction({action:MVa,payload:void 0,intervalMs:a.refreshInterval,autoPause:"visibility"})):w5&&(w5.dispose(),w5=null)},"startAutoRefresh"),z8a=Xi.getState().autoRefresh,T8a=Xi.getState().refreshInterval,_8a=Ia.getState().isLoggedIn;Xi.select(a=>({autoRefresh:a.autoRefresh,refreshInterval:a.refreshInterval})).subscribe(a=>{(a.autoRefresh!==z8a||a.refreshInterval!==T8a)&&(z8a=a.autoRefresh,T8a=a.refreshInterval,Wat())}),Ia.select(a=>a.isLoggedIn).subscribe(a=>{a!==_8a&&(_8a=a,Wat(),a?jat():C8a())}),document.addEventListener("visibilitychange",()=>{document.hidden?C8a():Ia.getState().isLoggedIn&&jat()}),Wat(),Ia.getState().isLoggedIn&&jat();Vd();var n1={};ht(n1,{DCROUTER_BUILTIN_PROVIDER_ID:()=>CVa,apiTokenScopes:()=>SVa,dnsProviderTypeDescriptors:()=>_ma,getDnsProviderTypeDescriptor:()=>zVa});var SVa=["*","routes:read","routes:write","config:read","stats:read","logs:read","security:read","security:write","emails:read","emails:write","certificates:read","certificates:write","tokens:read","tokens:manage","users:read","users:manage","source-profiles:read","source-profiles:write","target-profiles:read","target-profiles:write","targets:read","targets:write","dns-providers:read","dns-providers:write","domains:read","domains:write","dns-records:read","dns-records:write","acme-config:read","acme-config:write","email-domains:read","email-domains:write","remote-ingress:read","remote-ingress:write","vpn:read","vpn:write","radius:read","radius:write","gateway-clients:read","gateway-clients:write","workhosters:read","workhosters:write"];var CVa="__dcrouter__",_ma=[{type:"dcrouter",displayName:"DcRouter (built-in)",description:"Built-in authoritative DNS. Records are served directly by dcrouter \u2014 delegate the domain's NS records to make this effective.",credentialFields:[]},{type:"cloudflare",displayName:"Cloudflare",description:"External DNS provider. The provider stays authoritative; dcrouter pushes record changes via its API.",credentialFields:[{key:"apiToken",label:"API Token",helpText:"A Cloudflare API token with Zone:Read and DNS:Edit permissions for the target zones.",required:!0,secret:!0}]}];function zVa(a){return _ma.find(e=>e.type===a)}i(zVa,"getDnsProviderTypeDescriptor");var Lma={};var TVa=Ve.plugins.smartrouter.SmartRouter,$ma=["logs"],f9={overview:["stats","configuration"],network:["activity","routes","sourceprofiles","networktargets","targetprofiles","remoteingress","vpn"],email:["log","security","domains"],access:["gatewayclients","apitokens","users"],security:["overview","blocked","authentication"],domains:["providers","domains","dns","certificates"]},irt={overview:"stats",network:"activity",email:"log",access:"gatewayclients",security:"overview",domains:"domains"},_Va=[...$ma,...Object.keys(f9)];function Dma(a){return _Va.includes(a)}i(Dma,"isValidView");function Ima(a,e){return f9[a]?.includes(e)??!1}i(Ima,"isValidSubview");var ort=class{static{i(this,"AppRouter")}router;initialized=!1;suppressStateUpdate=!1;constructor(){this.router=new TVa({debug:!1})}init(){this.initialized||(this.setupRoutes(),this.setupStateSync(),this.handleInitialRoute(),this.initialized=!0)}setupRoutes(){for(let e of $ma)this.router.on(`/${e}`,async()=>{this.updateViewState(e,null)});for(let e of Object.keys(f9)){this.router.on(`/${e}`,async()=>{this.navigateTo(`/${e}/${irt[e]}`)});for(let t of f9[e])this.router.on(`/${e}/${t}`,async()=>{this.updateViewState(e,t)})}this.router.on("/",async()=>{this.navigateTo("/overview")})}setupStateSync(){Xi.select().subscribe(e=>{if(this.suppressStateUpdate)return;let t=window.location.pathname,r=e.activeSubview?`/${e.activeView}/${e.activeSubview}`:`/${e.activeView}`;t!==r&&(this.suppressStateUpdate=!0,this.router.pushUrl(r),this.suppressStateUpdate=!1)})}handleInitialRoute(){let e=window.location.pathname;if(!e||e==="/"){this.router.pushUrl("/overview");return}let t=e.split("/").filter(Boolean),r=t[0],s=t[1];if(!Dma(r)){this.router.pushUrl("/overview");return}f9[r]?s&&Ima(r,s)?this.updateViewState(r,s):this.router.pushUrl(`/${r}/${irt[r]}`):this.updateViewState(r,null)}updateViewState(e,t){this.suppressStateUpdate=!0;let r=Xi.getState();(r.activeView!==e||r.activeSubview!==t)&&Xi.setState({...r,activeView:e,activeSubview:t}),this.suppressStateUpdate=!1}navigateTo(e){this.router.pushUrl(e)}navigateToView(e,t){if(!Dma(e)){this.navigateTo("/overview");return}t&&Ima(e,t)?this.navigateTo(`/${e}/${t}`):f9[e]?this.navigateTo(`/${e}/${irt[e]}`):this.navigateTo(`/${e}`)}getCurrentView(){return Xi.getState().activeView}destroy(){this.router.destroy(),this.initialized=!1}},l1=new ort;le();var jt=Y`
42942
+ `),"stringifyJsonL"),fHa=i((a,e,t={})=>{let r=new WeakSet,s=i(l=>{if(l===null||typeof l!="object")return l;let c=Woe("",l);if(c&&c.type==="EncodedBuffer"&&typeof c.data=="string")return c;if(r.has(l))return"__cycle__";if(r.add(l),Array.isArray(l))return l.map(p=>s(p));let d={};for(let p of Object.keys(l))try{d[p]=s(l[p])}catch{d[p]="__unserializable__"}return d},"sanitize"),o=s(a),n={...t,cycles:!0};if(e&&!n.cmp){let l=new Map;e.forEach((c,d)=>l.set(c,d)),n.cmp=(c,d)=>{let p=l.has(c.key)?l.get(c.key):Number.POSITIVE_INFINITY,u=l.has(d.key)?l.get(d.key):Number.POSITIVE_INFINITY;return p!==u?p-u:c.key<d.key?-1:c.key>d.key?1:0}}return Uoe(o,n)},"stableOneWayStringify"),h5=i((a,e,t={})=>{let r=pat(a);a=JSON.parse(r);let s={...t};if(e&&!s.cmp){let n=new Map;e.forEach((l,c)=>n.set(l,c)),s.cmp=(l,c)=>{let d=n.has(l.key)?n.get(l.key):Number.POSITIVE_INFINITY,p=n.has(c.key)?n.get(c.key):Number.POSITIVE_INFINITY;return d!==p?d-p:l.key<c.key?-1:l.key>c.key?1:0}}return Uoe(a,s)},"stringify"),hHa=i(a=>{let e=h5(a),t=JSON.parse(e);return JSON.stringify(t,null,2)},"stringifyPretty"),mHa=i((...a)=>{let e=h5(...a);return xs.base64.encodeUri(e)},"stringifyBase64"),gHa=i(a=>{let e=xs.base64,r=(e.decodeUri||e.decode)(a);return Goe(r)},"parseBase64"),mat=class a{static{i(this,"Smartjson")}static enfoldFromObject(e){let t=new this,r=t.saveableProperties||[];for(let s in e)r.indexOf(s)!==-1&&(t[s]=e[s]);return t}static enfoldFromJson(e){let t=Goe(e);return this.enfoldFromObject(t)}foldToObject(){let e=new Set;return e.add(this),this.foldToObjectInternal(e)}foldToObjectInternal(e){let t={},r=i(o=>{if(o instanceof a){if(e.has(o))throw new Error("cycle detected");return e.add(o),o.foldToObjectInternal(e)}return Array.isArray(o)?o.map(n=>r(n)):joe.default(o)},"foldValue"),s=this.saveableProperties||[];for(let o of s){let n=this[o];t[o]=r(n)}return t}foldToJson(){let e=this.foldToObject();return h5(e)}},bHa=i(()=>(a,e)=>{a.saveableProperties||(a.saveableProperties=[]),a.saveableProperties.push(e)},"foldDec"),y5a=i((a,e)=>{let t=h5(a),r=h5(e);return t===r},"deepEqualObjects"),vHa=i((a,e)=>{let t=hat(a),r=hat(e);return y5a(t,r)},"deepEqualJsonLStrings");rb();Vd();v0();Ti();S2();L8();Bpe();var gat="__typedsocket_tag__";function yHa(a){return{peer:a,async getTagById(e){if(!a.tags.has(e))return;let t=a.data.get(`${gat}${e}`);return{id:e,payload:t}}}}i(yHa,"wrapSmartServePeer");var bat=class a{static{i(this,"TypedSocket")}static async createClient(e,t,r={}){let o={...{autoReconnect:!0,maxRetries:100,initialBackoffMs:1e3,maxBackoffMs:6e4},...r},n=new a("client",e);return n.clientOptions=o,n.serverUrl=t,n.currentBackoff=o.initialBackoffMs,await n.connect(),n}static{this.useWindowLocationOriginUrl=()=>E1.Smarturl.createFromUrl(globalThis.location.origin).toString()}static fromSmartServe(e,t){let r=new Map;a.registerTagHandlers(t);let s=new a("server",t);return s.smartServeRef=e,s.smartServeConnectionWrappers=r,s}static registerTagHandlers(e){e.addTypedHandler(new ts.TypedHandler("__typedsocket_setTag",async(t,r)=>{let s=r?.localData?.peer;return s?(s.tags.add(t.name),s.data.set(`${gat}${t.name}`,t.payload),{success:!0}):(console.warn("setTag: No peer found in request context"),{success:!1})})),e.addTypedHandler(new ts.TypedHandler("__typedsocket_removeTag",async(t,r)=>{let s=r?.localData?.peer;return s?(s.tags.delete(t.name),s.data.delete(`${gat}${t.name}`),{success:!0}):(console.warn("removeTag: No peer found in request context"),{success:!1})}))}constructor(e,t){this.statusSubject=new Aa.rxjs.Subject,this.connectionStatus="new",this.websocket=null,this.clientOptions=null,this.serverUrl="",this.retryCount=0,this.currentBackoff=1e3,this.pendingRequests=new Map,this.smartServeRef=null,this.smartServeConnectionWrappers=new Map,this.side=e,this.typedrouter=t}async connect(){let e=ut.defer();this.updateStatus("connecting");let t=this.toWebSocketUrl(this.serverUrl);console.log(`TypedSocket connecting to ${t}...`),this.websocket=new WebSocket(t);let r=setTimeout(()=>{this.connectionStatus!=="connected"&&(console.warn("TypedSocket connection timeout"),this.websocket?.close(),e.reject(new Error("Connection timeout")))},1e4);this.websocket.onopen=()=>{clearTimeout(r),console.log("TypedSocket connected!"),this.updateStatus("connected"),this.retryCount=0,this.currentBackoff=this.clientOptions?.initialBackoffMs??1e3,e.resolve()},this.websocket.onmessage=async s=>{await this.handleMessage(s.data)},this.websocket.onclose=()=>{clearTimeout(r),this.handleDisconnect()},this.websocket.onerror=s=>{console.error("TypedSocket WebSocket error:",s)};try{await e.promise}catch(s){if(clearTimeout(r),this.clientOptions?.autoReconnect)await this.scheduleReconnect();else throw s}}toWebSocketUrl(e){let t=new URL(e);return`${t.protocol==="https:"?"wss:":"ws:"}//${t.host}${t.pathname}`}async handleMessage(e){try{let t=typeof e=="string"?e:new TextDecoder().decode(e),r=wl.parse(t);if(r.correlation?.id&&this.pendingRequests.has(r.correlation.id)){let o=this.pendingRequests.get(r.correlation.id);this.pendingRequests.delete(r.correlation.id),o.resolve(r);return}let s=await this.typedrouter.routeAndAddResponse(r);s&&this.websocket?.readyState===WebSocket.OPEN&&this.websocket.send(wl.stringify(s))}catch(t){console.error("TypedSocket failed to process message:",t)}}handleDisconnect(){if(this.connectionStatus!=="disconnected"){this.updateStatus("disconnected");for(let[e,t]of this.pendingRequests)t.reject(new Error("TypedSocket disconnected"));this.pendingRequests.clear(),this.clientOptions?.autoReconnect&&this.retryCount<this.clientOptions.maxRetries&&this.scheduleReconnect()}}async scheduleReconnect(){if(!this.clientOptions)return;this.updateStatus("reconnecting"),this.retryCount++;let e=this.currentBackoff*.2*(Math.random()*2-1),t=Math.min(this.currentBackoff+e,this.clientOptions.maxBackoffMs);console.log(`TypedSocket reconnecting in ${Math.round(t)}ms (attempt ${this.retryCount}/${this.clientOptions.maxRetries})`),await Zt.delayFor(t),this.currentBackoff=Math.min(this.currentBackoff*2,this.clientOptions.maxBackoffMs);try{await this.connect()}catch(r){console.error("TypedSocket reconnection failed:",r)}}updateStatus(e){this.connectionStatus!==e&&(this.connectionStatus=e,this.statusSubject.next(e))}async sendRequest(e){if(!this.websocket||this.websocket.readyState!==WebSocket.OPEN)throw new Error("WebSocket not connected");e.correlation||={id:xs.create.createCryptoRandomString(),phase:"request"};let t=e.correlation.id;return new Promise((r,s)=>{let o=setTimeout(()=>{this.pendingRequests.delete(t),s(new Error("Request timeout"))},3e4);this.pendingRequests.set(t,{resolve:i(n=>{clearTimeout(o),r(n)},"resolve"),reject:i(n=>{clearTimeout(o),s(n)},"reject")}),this.websocket.send(wl.stringify(e))})}createTypedRequest(e,t){let r=i(async s=>{if(this.side==="client")return this.sendRequest(s);if(!this.smartServeRef)throw new Error("Server not initialized");let o=t;if(!o){let l=this.smartServeRef.getWebSocketConnections();if(l.length===1){let c=l[0];o=this.getOrCreateWrapper(c)}else throw l.length===0?new Error("No WebSocket connections available"):new Error("Multiple connections available - specify targetConnection")}let n=await this.typedrouter.fireEventInterestMap.addInterest(s.correlation.id,s);return o.peer.send(wl.stringify(s)),await n.interestFullfilled},"postMethod");return new ts.TypedRequest(new ts.TypedTarget({postMethod:r}),e)}getStatus(){return this.connectionStatus}async stop(){this.side==="client"?(this.clientOptions&&(this.clientOptions.autoReconnect=!1),this.websocket&&(this.websocket.close(),this.websocket=null),this.pendingRequests.clear()):this.smartServeConnectionWrappers.clear()}async setTag(e,t){if(this.side!=="client")throw new Error("setTag is only available on clients");if(!(await this.createTypedRequest("__typedsocket_setTag").fire({name:e,payload:t})).success)throw new Error("Failed to set tag on server")}async removeTag(e){if(this.side!=="client")throw new Error("removeTag is only available on clients");if(!(await this.createTypedRequest("__typedsocket_removeTag").fire({name:e})).success)throw new Error("Failed to remove tag on server")}getOrCreateWrapper(e){let t=this.smartServeConnectionWrappers.get(e.id);return t||(t=yHa(e),this.smartServeConnectionWrappers.set(e.id,t)),t}async findAllTargetConnections(e){if(this.side!=="server"||!this.smartServeRef)throw new Error("findAllTargetConnections is only available on servers");let t=[];for(let r of this.smartServeRef.getWebSocketConnections()){let s=this.getOrCreateWrapper(r);await e(s)&&t.push(s)}return t}async findTargetConnection(e){return(await this.findAllTargetConnections(e))[0]}async findAllTargetConnectionsByTag(e,t){if(this.side!=="server"||!this.smartServeRef)throw new Error("findAllTargetConnectionsByTag is only available on servers");let r=this.smartServeRef.getWebSocketConnectionsByTag(e),s=[];for(let o of r){let n=this.getOrCreateWrapper(o);if(t!==void 0){let l=await n.getTagById(e);if(wl.stringify(l?.payload)!==wl.stringify(t))continue}s.push(n)}return s}async findTargetConnectionByTag(e,t){return(await this.findAllTargetConnectionsByTag(e,t))[0]}};le();at();var ine=eo(y8a(),1),Ve=Rt;Vd();var qat={};ht(qat,{DCROUTER_BUILTIN_PROVIDER_ID:()=>mVa,apiTokenScopes:()=>hVa,dnsProviderTypeDescriptors:()=>w8a,getDnsProviderTypeDescriptor:()=>gVa});var hVa=["*","routes:read","routes:write","config:read","stats:read","logs:read","security:read","security:write","emails:read","emails:write","certificates:read","certificates:write","tokens:read","tokens:manage","users:read","users:manage","source-profiles:read","source-profiles:write","target-profiles:read","target-profiles:write","targets:read","targets:write","dns-providers:read","dns-providers:write","domains:read","domains:write","dns-records:read","dns-records:write","acme-config:read","acme-config:write","email-domains:read","email-domains:write","remote-ingress:read","remote-ingress:write","vpn:read","vpn:write","radius:read","radius:write","gateway-clients:read","gateway-clients:write","workhosters:read","workhosters:write"];var mVa="__dcrouter__",w8a=[{type:"dcrouter",displayName:"DcRouter (built-in)",description:"Built-in authoritative DNS. Records are served directly by dcrouter \u2014 delegate the domain's NS records to make this effective.",credentialFields:[]},{type:"cloudflare",displayName:"Cloudflare",description:"External DNS provider. The provider stays authoritative; dcrouter pushes record changes via its API.",credentialFields:[{key:"apiToken",label:"API Token",helpText:"A Cloudflare API token with Zone:Read and DNS:Edit permissions for the target zones.",required:!0,secret:!0}]}];function gVa(a){return w8a.find(e=>e.type===a)}i(gVa,"getDnsProviderTypeDescriptor");var k8a={};var ci=new Ve.plugins.smartstate.Smartstate,Ia=await ci.getStatePart("login",{identity:null,isLoggedIn:!1},"persistent"),$r=await ci.getStatePart("stats",{serverStats:null,emailStats:null,dnsStats:null,securityMetrics:null,radiusStats:null,vpnStats:null,lastUpdated:0,isLoading:!1,error:null},"soft"),fd=await ci.getStatePart("config",{config:null,isLoading:!1,error:null}),bVa=i(()=>{let a=typeof window<"u"?window.location.pathname:"/",e=["overview","network","email","logs","access","security","domains"],r=a.split("/").filter(Boolean)[0];return e.includes(r)?r:"overview"},"getInitialView"),vVa=i(()=>(typeof window<"u"?window.location.pathname:"/").split("/").filter(Boolean)[1]??null,"getInitialSubview"),Xi=await ci.getStatePart("ui",{activeView:bVa(),activeSubview:vVa(),sidebarCollapsed:!1,autoRefresh:!0,refreshInterval:1e3,theme:"light"}),a0=await ci.getStatePart("logs",{recentLogs:[],isStreaming:!1,filters:{}},"soft"),o1=await ci.getStatePart("network",{connections:[],connectionsByIP:{},throughputRate:{bytesInPerSecond:0,bytesOutPerSecond:0},totalBytes:{in:0,out:0},topIPs:[],topIPsByBandwidth:[],topASNs:[],throughputByIP:[],ipIntelligence:[],domainActivity:[],throughputHistory:[],requestsPerSecond:0,requestsTotal:0,backends:[],frontendProtocols:null,backendProtocols:null,lastUpdated:0,isLoading:!1,error:null},"soft"),ms=await ci.getStatePart("securityPolicy",{rules:[],ipIntelligence:[],compiledPolicy:null,auditEvents:[],isLoading:!1,error:null,lastUpdated:0},"soft"),nne=await ci.getStatePart("emailOps",{emails:[],isLoading:!1,error:null,lastUpdated:0},"soft"),Zo=await ci.getStatePart("certificates",{certificates:[],summary:{total:0,valid:0,expiring:0,expired:0,failed:0,unknown:0},isLoading:!1,error:null,lastUpdated:0},"soft"),z5=await ci.getStatePart("acmeConfig",{config:null,isLoading:!1,error:null,lastUpdated:0},"soft"),Ys=await ci.getStatePart("remoteIngress",{edges:[],statuses:[],selectedEdgeId:null,newEdgeId:null,isLoading:!1,error:null,lastUpdated:0},"soft"),ra=await ci.getStatePart("routeManagement",{mergedRoutes:[],warnings:[],apiTokens:[],gatewayClients:[],isLoading:!1,error:null,lastUpdated:0},"soft"),Sn=await ci.getStatePart("users",{users:[],isLoading:!1,error:null,lastUpdated:0},"soft"),tt=i(()=>{let a=Ia.getState().identity;return a&&a.expiresAt&&a.expiresAt<Date.now()?{identity:null}:{identity:a}},"getActionContext"),L8a=Ia.createAction(async(a,e)=>{let t=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","adminLoginWithUsernameAndPassword");try{let r=await t.fire({username:e.username,password:e.password,authSource:e.authSource});return r.identity?{identity:r.identity,isLoggedIn:!0}:a.getState()}catch(r){return console.error("Login failed:",r),a.getState()}});async function $8a(){return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getAdminBootstrapStatus").fire({})}i($8a,"getAdminBootstrapStatus");async function D8a(a){let e=tt();if(!e.identity)throw new Error("No identity available for admin bootstrap");let r=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createInitialAdminUser").fire({identity:e.identity,email:a.email,name:a.name,password:a.password,enableIdpGlobalAuth:a.enableIdpGlobalAuth});return r.identity&&Ia.setState({identity:r.identity,isLoggedIn:!0}),r}i(D8a,"createInitialAdminUser");var u9=Ia.createAction(async a=>{let e=tt();if(e.identity){let t=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","adminLogout");try{await t.fire({identity:e.identity})}catch(r){console.error("Logout error:",r)}}return{identity:null,isLoggedIn:!1}}),p9=$r.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getCombinedMetrics").fire({identity:e.identity,sections:{server:!0,email:!0,dns:!0,security:!0,network:!1,radius:!0,vpn:!0}});return{serverStats:s.metrics.server||t.serverStats,emailStats:s.metrics.email||t.emailStats,dnsStats:s.metrics.dns||t.dnsStats,securityMetrics:s.metrics.security||t.securityMetrics,radiusStats:s.metrics.radius||t.radiusStats,vpnStats:s.metrics.vpn||t.vpnStats,lastUpdated:Date.now(),isLoading:!1,error:null}}catch(r){return{...t,isLoading:!1,error:r.message||"Failed to fetch statistics"}}}),lne=fd.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{return{config:(await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getConfiguration").fire({identity:e.identity})).config,isLoading:!1,error:null}}catch(r){return{...t,isLoading:!1,error:r.message||"Failed to fetch configuration"}}}),cne=a0.createAction(async(a,e)=>{let t=tt();if(!t.identity)return a.getState();let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getRecentLogs").fire({identity:t.identity,limit:e.limit||100,level:e.level,category:e.category});return{...a.getState(),recentLogs:s.logs}}),Bbo=Xi.createAction(async a=>{let e=a.getState();return{...e,autoRefresh:!e.autoRefresh}}),qbo=Xi.createAction(async(a,e)=>{let t=a.getState();return e==="network"&&t.activeView!=="network"&&setTimeout(()=>{o1.dispatchAction(XK,null)},100),e==="domains"&&t.activeView!=="domains"&&setTimeout(()=>{Zo.dispatchAction(pd,null)},100),{...t,activeView:e}}),Hat=new Set;function c9(a,e,t){Hat.has(a)||(Hat.add(a),t().catch(r=>console.error(e,r)).finally(()=>Hat.delete(a)))}i(c9,"runBackgroundRefresh");function M8a(a,e){let t=[...new Set(e.filter(Boolean))].slice(0,100);t.length!==0&&c9("networkIpIntelligence","IP intelligence refresh failed:",async()=>{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listIpIntelligence").fire({identity:a,ipAddresses:t,limit:Math.max(100,t.length)});o1.setState({...o1.getState(),ipIntelligence:s.records||[]})})}i(M8a,"refreshNetworkIpIntelligence");function xVa(a){c9("securityIpIntelligence","Security IP intelligence refresh failed:",async()=>{let t=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listIpIntelligence").fire({identity:a,limit:500});ms.setState({...ms.getState(),ipIntelligence:t.records||[]})})}i(xVa,"refreshSecurityIpIntelligence");var XK=o1.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getNetworkStats").fire({identity:e.identity}),o={},n=new Map;for(let c of s.throughputByIP||[])n.set(c.ip,{in:c.in,out:c.out});s.connectionsByIP&&Array.isArray(s.connectionsByIP)&&s.connectionsByIP.forEach(c=>{o[c.ip]=c.count});let l=Object.entries(o).map(([c,d])=>{let p=n.get(c);return{id:`ip-${c}`,remoteAddress:c,localAddress:"server",startTime:0,protocol:"https",state:"connected",bytesReceived:p?.in||0,bytesSent:p?.out||0,connectionCount:d}});return M8a(e.identity,[...Object.keys(o),...(s.topIPs||[]).map(c=>c.ip),...(s.topIPsByBandwidth||[]).map(c=>c.ip)]),{connections:l,connectionsByIP:o,throughputRate:s.throughputRate||{bytesInPerSecond:0,bytesOutPerSecond:0},totalBytes:s.totalDataTransferred?{in:s.totalDataTransferred.bytesIn,out:s.totalDataTransferred.bytesOut}:{in:0,out:0},topIPs:s.topIPs||[],topIPsByBandwidth:s.topIPsByBandwidth||[],topASNs:s.topASNs||[],throughputByIP:s.throughputByIP||[],ipIntelligence:t.ipIntelligence,domainActivity:s.domainActivity||[],throughputHistory:s.throughputHistory||[],requestsPerSecond:s.requestsPerSecond||0,requestsTotal:s.requestsTotal||0,backends:s.backends||[],frontendProtocols:s.frontendProtocols||null,backendProtocols:s.backendProtocols||null,lastUpdated:Date.now(),isLoading:!1,error:null}}catch(r){return console.error("Failed to fetch network stats:",r),{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch network stats"}}}),k5=ms.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let r=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listSecurityBlockRules"),s=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getCompiledSecurityPolicy"),o=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listSecurityPolicyAudit"),[n,l,c]=await Promise.all([r.fire({identity:e.identity}),s.fire({identity:e.identity}),o.fire({identity:e.identity,limit:100})]);return xVa(e.identity),{rules:n.rules||[],ipIntelligence:t.ipIntelligence,compiledPolicy:l.policy,auditEvents:c.events||[],isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch security policy"}}}),dne=ms.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createSecurityBlockRule").fire({identity:r.identity,type:e.type,value:e.value,matchMode:e.matchMode,reason:e.reason,enabled:e.enabled});return n.success?await t.dispatch(k5,null):{...s,error:n.message||"Failed to create security block rule"}}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to create security block rule"}}}),une=ms.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateSecurityBlockRule").fire({identity:r.identity,id:e.id,value:e.value,matchMode:e.matchMode,reason:e.reason,enabled:e.enabled});return n.success?await t.dispatch(k5,null):{...s,error:n.message||"Failed to update security block rule"}}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to update security block rule"}}}),I8a=ms.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteSecurityBlockRule").fire({identity:r.identity,id:e});return n.success?await t.dispatch(k5,null):{...s,error:n.message||"Failed to delete security block rule"}}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete security block rule"}}}),pne=ms.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","refreshIpIntelligence").fire({identity:r.identity,ipAddress:e});if(!n.success)return{...s,error:n.message||"Failed to refresh IP intelligence"};let l=await t.dispatch(k5,null);return n.record?{...l,ipIntelligence:[n.record,...l.ipIntelligence.filter(c=>c.ipAddress!==n.record.ipAddress)]}:l}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to refresh IP intelligence"}}}),A8a=nne.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{return{emails:(await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getAllEmails").fire({identity:e.identity})).emails,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch emails"}}}),pd=Zo.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getCertificateOverview").fire({identity:e.identity});return{certificates:s.certificates,summary:s.summary,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch certificate overview"}}}),P8a=Zo.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","reprovisionCertificateDomain").fire({identity:r.identity,domain:e.domain,forceRenew:e.forceRenew}),await t.dispatch(pd,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to reprovision certificate"}}}),E8a=Zo.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteCertificate").fire({identity:r.identity,domain:e}),await t.dispatch(pd,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete certificate"}}}),N8a=Zo.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","importCertificate").fire({identity:r.identity,cert:e}),await t.dispatch(pd,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to import certificate"}}});async function R8a(a){let e=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","exportCertificate").fire({identity:e.identity,domain:a})}i(R8a,"fetchCertificateExport");async function Gat(a){let e=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getRemoteIngressConnectionToken").fire({identity:e.identity,edgeId:a})}i(Gat,"fetchConnectionToken");var M5=Ys.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let r=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getRemoteIngresses"),s=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getRemoteIngressStatus"),[o,n]=await Promise.all([r.fire({identity:e.identity}),s.fire({identity:e.identity})]);return{...t,edges:o.edges,statuses:n.statuses,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch remote ingress data"}}}),O8a=Ys.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createRemoteIngress").fire({identity:r.identity,name:e.name,listenPorts:e.listenPorts,autoDerivePorts:e.autoDerivePorts,tags:e.tags});return n.success?(await t.dispatch(M5,null),{...a.getState(),newEdgeId:n.edge.id}):s}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to create edge"}}}),F8a=Ys.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteRemoteIngress").fire({identity:r.identity,id:e}),await t.dispatch(M5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete edge"}}}),B8a=Ys.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateRemoteIngress").fire({identity:r.identity,id:e.id,name:e.name,listenPorts:e.listenPorts,autoDerivePorts:e.autoDerivePorts,tags:e.tags}),await t.dispatch(M5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to update edge"}}}),q8a=Ys.createAction(async(a,e)=>{let t=tt(),r=a.getState();try{return(await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","regenerateRemoteIngressSecret").fire({identity:t.identity,id:e})).success?{...r,newEdgeId:e}:r}catch(s){return{...r,error:s instanceof Error?s.message:"Failed to regenerate secret"}}}),H8a=Ys.createAction(async a=>({...a.getState(),newEdgeId:null})),Kat=Ys.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateRemoteIngress").fire({identity:r.identity,id:e.id,enabled:e.enabled}),await t.dispatch(M5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to toggle edge"}}}),Zs=await ci.getStatePart("vpn",{clients:[],connectedClients:[],status:null,isLoading:!1,error:null,lastUpdated:0,newClientConfig:null},"soft"),S5=Zs.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let r=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getVpnClients"),s=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getVpnStatus"),o=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getVpnConnectedClients"),[n,l,c]=await Promise.all([r.fire({identity:e.identity}),s.fire({identity:e.identity}),o.fire({identity:e.identity})]);return{...t,clients:n.clients,connectedClients:c.connectedClients,status:l.status,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch VPN data"}}}),V8a=Zs.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createVpnClient").fire({identity:r.identity,clientId:e.clientId,targetProfileIds:e.targetProfileIds,description:e.description,destinationAllowList:e.destinationAllowList,destinationBlockList:e.destinationBlockList,useHostIp:e.useHostIp,useDhcp:e.useDhcp,staticIp:e.staticIp,forceVlan:e.forceVlan,vlanId:e.vlanId});return n.success?{...await t.dispatch(S5,null),newClientConfig:n.wireguardConfig||null}:{...s,error:n.message||"Failed to create client"}}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to create VPN client"}}}),j8a=Zs.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteVpnClient").fire({identity:r.identity,clientId:e}),await t.dispatch(S5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete VPN client"}}}),Yat=Zs.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let o=e.enabled?"enableVpnClient":"disableVpnClient";return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest",o).fire({identity:r.identity,clientId:e.clientId}),await t.dispatch(S5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to toggle VPN client"}}}),U8a=Zs.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateVpnClient").fire({identity:r.identity,clientId:e.clientId,description:e.description,targetProfileIds:e.targetProfileIds,destinationAllowList:e.destinationAllowList,destinationBlockList:e.destinationBlockList,useHostIp:e.useHostIp,useDhcp:e.useDhcp,staticIp:e.staticIp,forceVlan:e.forceVlan,vlanId:e.vlanId});return n.success?await t.dispatch(S5,null):{...s,error:n.message||"Failed to update client"}}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to update VPN client"}}}),W8a=Zs.createAction(async a=>({...a.getState(),newClientConfig:null})),Xs=await ci.getStatePart("targetProfiles",{profiles:[],isLoading:!1,error:null,lastUpdated:0},"soft"),r0=Xs.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{return{profiles:(await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getTargetProfiles").fire({identity:e.identity})).profiles,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch target profiles"}}}),G8a=Xs.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createTargetProfile").fire({identity:r.identity,name:e.name,description:e.description,domains:e.domains,targets:e.targets,routeRefs:e.routeRefs,allowRoutesByClientSourceIp:e.allowRoutesByClientSourceIp});return o.success?await t.dispatch(r0,null):{...a.getState(),error:o.message||"Failed to create target profile"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create target profile"}}}),K8a=Xs.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateTargetProfile").fire({identity:r.identity,id:e.id,name:e.name,description:e.description,domains:e.domains,targets:e.targets,routeRefs:e.routeRefs,allowRoutesByClientSourceIp:e.allowRoutesByClientSourceIp});return o.success?await t.dispatch(r0,null):{...a.getState(),error:o.message||"Failed to update target profile"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update target profile"}}}),Zat=Xs.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteTargetProfile").fire({identity:r.identity,id:e.id,force:e.force});return o.success?await t.dispatch(r0,null):{...a.getState(),error:o.message||"Failed to delete target profile"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete target profile"}}}),Qa=await ci.getStatePart("profilesTargets",{profiles:[],targets:[],isLoading:!1,error:null,lastUpdated:0},"soft"),Xo=Qa.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let r=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getSourceProfiles"),s=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getNetworkTargets"),[o,n]=await Promise.all([r.fire({identity:e.identity}),s.fire({identity:e.identity})]);return{profiles:o.profiles,targets:n.targets,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch profiles/targets"}}}),Y8a=Qa.createAction(async(a,e,t)=>{let r=tt();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createSourceProfile").fire({identity:r.identity,name:e.name,description:e.description,security:e.security,extendsProfiles:e.extendsProfiles}),await t.dispatch(Xo,null)}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create profile"}}}),Z8a=Qa.createAction(async(a,e,t)=>{let r=tt();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateSourceProfile").fire({identity:r.identity,id:e.id,name:e.name,description:e.description,security:e.security,extendsProfiles:e.extendsProfiles}),await t.dispatch(Xo,null)}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update profile"}}}),Xat=Qa.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteSourceProfile").fire({identity:r.identity,id:e.id,force:e.force});return o.success?await t.dispatch(Xo,null):{...a.getState(),error:o.message||"Failed to delete profile"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete profile"}}}),X8a=Qa.createAction(async(a,e,t)=>{let r=tt();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createNetworkTarget").fire({identity:r.identity,name:e.name,description:e.description,host:e.host,port:e.port}),await t.dispatch(Xo,null)}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create target"}}}),Q8a=Qa.createAction(async(a,e,t)=>{let r=tt();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateNetworkTarget").fire({identity:r.identity,id:e.id,name:e.name,description:e.description,host:e.host,port:e.port}),await t.dispatch(Xo,null)}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update target"}}}),Qat=Qa.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteNetworkTarget").fire({identity:r.identity,id:e.id,force:e.force});return o.success?await t.dispatch(Xo,null):{...a.getState(),error:o.message||"Failed to delete target"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete target"}}}),Ot=await ci.getStatePart("domains",{providers:[],domains:[],records:[],selectedDomainId:null,isLoading:!1,error:null,lastUpdated:0},"soft"),hs=Ot.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let r=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getDnsProviders"),s=new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getDomains"),[o,n]=await Promise.all([r.fire({identity:e.identity}),s.fire({identity:e.identity})]);return{...t,providers:o.providers,domains:n.domains,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch domains/providers"}}}),s0=Ot.createAction(async(a,e)=>{let t=tt(),r=a.getState();if(!t.identity)return r;try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getDnsRecords").fire({identity:t.identity,domainId:e.domainId});return{...r,records:o.records,selectedDomainId:e.domainId,error:null}}catch(s){return{...r,error:s instanceof Error?s.message:"Failed to fetch DNS records"}}}),J8a=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createDnsProvider").fire({identity:r.identity,name:e.name,type:e.type,credentials:e.credentials});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to create provider"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create provider"}}}),ema=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateDnsProvider").fire({identity:r.identity,id:e.id,name:e.name,credentials:e.credentials});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to update provider"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update provider"}}}),tma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteDnsProvider").fire({identity:r.identity,id:e.id,force:e.force});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to delete provider"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete provider"}}}),ama=Ot.createAction(async(a,e,t)=>{let r=tt();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","testDnsProvider").fire({identity:r.identity,id:e.id}),await t.dispatch(hs,null)}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to test provider"}}});async function rma(a){let e=tt();return e.identity?await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listProviderDomains").fire({identity:e.identity,providerId:a}):{success:!1,message:"Not authenticated"}}i(rma,"fetchProviderDomains");var sma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createDomain").fire({identity:r.identity,name:e.name,description:e.description});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to create domain"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create domain"}}}),ima=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","importDomain").fire({identity:r.identity,providerId:e.providerId,domainNames:e.domainNames});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to import domains"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to import domains"}}}),oma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteDomain").fire({identity:r.identity,id:e.id});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to delete domain"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete domain"}}}),nma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","syncDomain").fire({identity:r.identity,id:e.id});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Failed to sync domain"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to sync domain"}}}),lma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","migrateDomain").fire({identity:r.identity,...e});return o.success?await t.dispatch(hs,null):{...a.getState(),error:o.message||"Migration failed"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Migration failed"}}}),cma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createDnsRecord").fire({identity:r.identity,domainId:e.domainId,name:e.name,type:e.type,value:e.value,ttl:e.ttl,proxied:e.proxied});return o.success?await t.dispatch(s0,{domainId:e.domainId}):{...a.getState(),error:o.message||"Failed to create record"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to create record"}}}),dma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateDnsRecord").fire({identity:r.identity,id:e.id,name:e.name,value:e.value,ttl:e.ttl,proxied:e.proxied});return o.success?await t.dispatch(s0,{domainId:e.domainId}):{...a.getState(),error:o.message||"Failed to update record"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update record"}}}),uma=Ot.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteDnsRecord").fire({identity:r.identity,id:e.id});return o.success?await t.dispatch(s0,{domainId:e.domainId}):{...a.getState(),error:o.message||"Failed to delete record"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to delete record"}}}),Jat=z5.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{return{config:(await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getAcmeConfig").fire({identity:e.identity})).config,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch ACME config"}}}),pma=z5.createAction(async(a,e,t)=>{let r=tt();try{let o=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateAcmeConfig").fire({identity:r.identity,accountEmail:e.accountEmail,enabled:e.enabled,useProduction:e.useProduction,autoRenew:e.autoRenew,renewThresholdDays:e.renewThresholdDays});return o.success?await t.dispatch(Jat,null):{...a.getState(),error:o.message||"Failed to update ACME config"}}catch(s){return{...a.getState(),error:s instanceof Error?s.message:"Failed to update ACME config"}}}),kl=ra.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getMergedRoutes").fire({identity:e.identity});return{...t,mergedRoutes:s.routes,warnings:s.warnings,isLoading:!1,error:null,lastUpdated:Date.now()}}catch(r){return{...t,isLoading:!1,error:r instanceof Error?r.message:"Failed to fetch routes"}}}),fma=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createRoute").fire({identity:r.identity,route:e.route,enabled:e.enabled,metadata:e.metadata}),await t.dispatch(kl,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to create route"}}}),hma=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateRoute").fire({identity:r.identity,id:e.id,route:e.route,enabled:e.enabled,metadata:e.metadata});if(!n.success)throw new Error(n.message||"Failed to update route");return await t.dispatch(kl,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to update route"}}}),ert=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteRoute").fire({identity:r.identity,id:e});if(!n.success)throw new Error(n.message||"Failed to delete route");return await t.dispatch(kl,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete route"}}}),mma=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","toggleRoute").fire({identity:r.identity,id:e.id,enabled:e.enabled});if(!n.success)throw new Error(n.message||"Failed to toggle route");return await t.dispatch(kl,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to toggle route"}}}),T5=ra.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listApiTokens").fire({identity:e.identity});return{...t,apiTokens:s.tokens}}catch(r){return{...t,error:r instanceof Error?r.message:"Failed to fetch tokens"}}}),d9=ra.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listGatewayClients").fire({identity:e.identity});return{...t,gatewayClients:s.gatewayClients,error:null,lastUpdated:Date.now()}}catch(r){return{...t,error:r instanceof Error?r.message:"Failed to fetch gateway clients"}}});async function gma(a){let e=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createGatewayClient").fire({identity:e.identity,capabilities:{readDomains:!0,readDnsRecords:!0,syncRoutes:!0,syncDnsRecords:!1,requestCertificates:!1},...a})}i(gma,"createGatewayClient");var trt=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","updateGatewayClient").fire({identity:r.identity,...e}),await t.dispatch(d9,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to update gateway client"}}}),bma=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteGatewayClient").fire({identity:r.identity,id:e}),await t.dispatch(d9,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete gateway client"}}});async function vma(a,e,t){let r=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createGatewayClientToken").fire({identity:r.identity,gatewayClientId:a,name:e,expiresInDays:t})}i(vma,"createGatewayClientToken");var _5=Sn.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","listUsers").fire({identity:e.identity});return{...t,users:s.users,error:null,lastUpdated:Date.now()}}catch(r){return{...t,error:r instanceof Error?r.message:"Failed to fetch users"}}}),xma=Sn.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createUser").fire({identity:r.identity,email:e.email,name:e.name,role:e.role,password:e.password,enableIdpGlobalAuth:e.enableIdpGlobalAuth});if(!n.success)throw new Error(n.message||"Failed to create user");return await t.dispatch(_5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to create user"}}}),yma=Sn.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();if(!r.identity)return s;try{let n=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteUser").fire({identity:r.identity,id:e});if(!n.success)throw new Error(n.message||"Failed to delete user");return await t.dispatch(_5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to delete user"}}});async function wma(a,e,t,r){let s=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createApiToken").fire({identity:s.identity,name:a,scopes:e,policy:r,expiresInDays:t})}i(wma,"createApiToken");async function kma(a){let e=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","rollApiToken").fire({identity:e.identity,id:a})}i(kma,"rollApiToken");var Mma=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","revokeApiToken").fire({identity:r.identity,id:e}),await t.dispatch(T5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to revoke token"}}}),art=ra.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","toggleApiToken").fire({identity:r.identity,id:e.id,enabled:e.enabled}),await t.dispatch(T5,null)}catch(o){return{...s,error:o instanceof Error?o.message:"Failed to toggle token"}}}),To=await ci.getStatePart("emailDomains",{domains:[],isLoading:!1,lastUpdated:0},"soft"),C5=To.createAction(async a=>{let e=tt(),t=a.getState();if(!e.identity)return t;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getEmailDomains").fire({identity:e.identity});return{...t,domains:s.domains,isLoading:!1,lastUpdated:Date.now()}}catch{return{...t,isLoading:!1}}}),Sma=To.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","createEmailDomain").fire({identity:r.identity,...e}),await t.dispatch(C5,null)}catch{return s}}),Cma=To.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","deleteEmailDomain").fire({identity:r.identity,id:e}),await t.dispatch(C5,null)}catch{return s}}),zma=To.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","validateEmailDomain").fire({identity:r.identity,id:e}),await t.dispatch(C5,null)}catch{return s}}),rrt=To.createAction(async(a,e,t)=>{let r=tt(),s=a.getState();try{return await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","provisionEmailDomainDns").fire({identity:r.identity,id:e}),await t.dispatch(C5,null)}catch{return s}});async function Tma(a){let e=tt();return new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getEmailDomainDnsRecords").fire({identity:e.identity,id:a})}i(Tma,"fetchEmailDomainDnsRecords");var y5=null,S8a=new Ve.plugins.typedrequest.TypedRouter,one=[],Vat=!1;function yVa(){if(Vat=!1,one.length===0)return;let a=a0.getState(),e=[...a.recentLogs,...one];one=[],e.length>2e3&&e.splice(0,e.length-2e3),a0.setState({...a,recentLogs:e})}i(yVa,"flushLogEntries"),S8a.addTypedHandler(new Ve.plugins.typedrequest.TypedHandler("pushLogEntry",async a=>(one.push(a.entry),Vat||(Vat=!0,requestAnimationFrame(yVa)),{})));async function jat(){if(!y5)try{y5=await r9.TypedSocket.createClient(S8a,r9.TypedSocket.useWindowLocationOriginUrl()),await y5.setTag("role","ops_dashboard")}catch(a){console.error("TypedSocket connection failed:",a),y5=null}}i(jat,"connectSocket");async function C8a(){if(y5){try{await y5.stop()}catch{}y5=null}}i(C8a,"disconnectSocket");var Uat=!1;async function wVa(){if(!Uat){Uat=!0;try{await kVa()}finally{Uat=!1}}}i(wVa,"dispatchCombinedRefreshAction");async function kVa(){let a=tt();if(!a.identity)return;let e=Xi.getState().activeView,t=Xi.getState().activeSubview;try{let s=await new Ve.plugins.typedrequest.TypedRequest("/typedrequest","getCombinedMetrics").fire({identity:a.identity,sections:{server:!0,email:!0,dns:!0,security:!0,network:e==="network"&&t==="activity",radius:!0,vpn:!0}}),o=$r.getState();if($r.setState({...o,serverStats:s.metrics.server||o.serverStats,emailStats:s.metrics.email||o.emailStats,dnsStats:s.metrics.dns||o.dnsStats,securityMetrics:s.metrics.security||o.securityMetrics,radiusStats:s.metrics.radius||o.radiusStats,vpnStats:s.metrics.vpn||o.vpnStats,lastUpdated:Date.now(),isLoading:!1,error:null}),s.metrics.network&&e==="network"){let n=s.metrics.network,l={};n.connectionDetails.forEach(d=>{l[d.remoteAddress]=(l[d.remoteAddress]||0)+(d.connectionCount||1)});let c=n.connectionDetails.map((d,p)=>({id:`ip-${d.remoteAddress}`,remoteAddress:d.remoteAddress,localAddress:"server",startTime:d.startTime,protocol:d.protocol,state:d.state,bytesReceived:d.bytesIn,bytesSent:d.bytesOut,connectionCount:d.connectionCount}));o1.setState({...o1.getState(),connections:c,connectionsByIP:l,throughputRate:{bytesInPerSecond:n.totalBandwidth.in,bytesOutPerSecond:n.totalBandwidth.out},totalBytes:n.totalBytes||{in:0,out:0},topIPs:n.topEndpoints.map(d=>({ip:d.endpoint,count:d.connections})),topIPsByBandwidth:(n.topEndpointsByBandwidth||[]).map(d=>({ip:d.endpoint,count:d.connections,bwIn:d.bandwidth?.in||0,bwOut:d.bandwidth?.out||0})),topASNs:n.topASNs||[],throughputByIP:n.topEndpoints.map(d=>({ip:d.endpoint,in:d.bandwidth?.in||0,out:d.bandwidth?.out||0})),domainActivity:n.domainActivity||[],throughputHistory:n.throughputHistory||[],requestsPerSecond:n.requestsPerSecond||0,requestsTotal:n.requestsTotal||0,backends:n.backends||[],frontendProtocols:n.frontendProtocols||null,backendProtocols:n.backendProtocols||null,lastUpdated:Date.now(),isLoading:!1,error:null}),M8a(a.identity,[...n.connectionDetails.map(d=>d.remoteAddress),...n.topEndpoints.map(d=>d.endpoint),...(n.topEndpointsByBandwidth||[]).map(d=>d.endpoint)])}e==="security"&&c9("securityPolicy","Security policy refresh failed:",async()=>{await ms.dispatchAction(k5,null)}),e==="domains"&&t==="certificates"&&c9("certificates","Certificate refresh failed:",async()=>{await Zo.dispatchAction(pd,null)}),e==="network"&&t==="remoteingress"&&c9("remoteIngress","Remote ingress refresh failed:",async()=>{await Ys.dispatchAction(M5,null)}),e==="network"&&t==="vpn"&&c9("vpn","VPN refresh failed:",async()=>{await Zs.dispatchAction(S5,null)})}catch(r){console.error("Combined refresh failed:",r);let s=String(r);(s.includes("invalid")||s.includes("unauthorized")||s.includes("401"))&&(await Ia.dispatchAction(u9,null),window.location.reload())}}i(kVa,"dispatchCombinedRefreshActionInner");var MVa=$r.createAction(async a=>(await wVa(),a.getState())),w5=null,Wat=i(()=>{let a=Xi.getState(),e=Ia.getState();a.autoRefresh&&e.isLoggedIn?(w5&&(w5.dispose(),w5=null),w5=$r.createScheduledAction({action:MVa,payload:void 0,intervalMs:a.refreshInterval,autoPause:"visibility"})):w5&&(w5.dispose(),w5=null)},"startAutoRefresh"),z8a=Xi.getState().autoRefresh,T8a=Xi.getState().refreshInterval,_8a=Ia.getState().isLoggedIn;Xi.select(a=>({autoRefresh:a.autoRefresh,refreshInterval:a.refreshInterval})).subscribe(a=>{(a.autoRefresh!==z8a||a.refreshInterval!==T8a)&&(z8a=a.autoRefresh,T8a=a.refreshInterval,Wat())}),Ia.select(a=>a.isLoggedIn).subscribe(a=>{a!==_8a&&(_8a=a,Wat(),a?jat():C8a())}),document.addEventListener("visibilitychange",()=>{document.hidden?C8a():Ia.getState().isLoggedIn&&jat()}),Wat(),Ia.getState().isLoggedIn&&jat();Vd();var n1={};ht(n1,{DCROUTER_BUILTIN_PROVIDER_ID:()=>CVa,apiTokenScopes:()=>SVa,dnsProviderTypeDescriptors:()=>_ma,getDnsProviderTypeDescriptor:()=>zVa});var SVa=["*","routes:read","routes:write","config:read","stats:read","logs:read","security:read","security:write","emails:read","emails:write","certificates:read","certificates:write","tokens:read","tokens:manage","users:read","users:manage","source-profiles:read","source-profiles:write","target-profiles:read","target-profiles:write","targets:read","targets:write","dns-providers:read","dns-providers:write","domains:read","domains:write","dns-records:read","dns-records:write","acme-config:read","acme-config:write","email-domains:read","email-domains:write","remote-ingress:read","remote-ingress:write","vpn:read","vpn:write","radius:read","radius:write","gateway-clients:read","gateway-clients:write","workhosters:read","workhosters:write"];var CVa="__dcrouter__",_ma=[{type:"dcrouter",displayName:"DcRouter (built-in)",description:"Built-in authoritative DNS. Records are served directly by dcrouter \u2014 delegate the domain's NS records to make this effective.",credentialFields:[]},{type:"cloudflare",displayName:"Cloudflare",description:"External DNS provider. The provider stays authoritative; dcrouter pushes record changes via its API.",credentialFields:[{key:"apiToken",label:"API Token",helpText:"A Cloudflare API token with Zone:Read and DNS:Edit permissions for the target zones.",required:!0,secret:!0}]}];function zVa(a){return _ma.find(e=>e.type===a)}i(zVa,"getDnsProviderTypeDescriptor");var Lma={};var TVa=Ve.plugins.smartrouter.SmartRouter,$ma=["logs"],f9={overview:["stats","configuration"],network:["activity","routes","sourceprofiles","networktargets","targetprofiles","remoteingress","vpn"],email:["log","security","domains"],access:["gatewayclients","apitokens","users"],security:["overview","blocked","authentication"],domains:["providers","domains","dns","certificates"]},irt={overview:"stats",network:"activity",email:"log",access:"gatewayclients",security:"overview",domains:"domains"},_Va=[...$ma,...Object.keys(f9)];function Dma(a){return _Va.includes(a)}i(Dma,"isValidView");function Ima(a,e){return f9[a]?.includes(e)??!1}i(Ima,"isValidSubview");var ort=class{static{i(this,"AppRouter")}router;initialized=!1;suppressStateUpdate=!1;constructor(){this.router=new TVa({debug:!1})}init(){this.initialized||(this.setupRoutes(),this.setupStateSync(),this.handleInitialRoute(),this.initialized=!0)}setupRoutes(){for(let e of $ma)this.router.on(`/${e}`,async()=>{this.updateViewState(e,null)});for(let e of Object.keys(f9)){this.router.on(`/${e}`,async()=>{this.navigateTo(`/${e}/${irt[e]}`)});for(let t of f9[e])this.router.on(`/${e}/${t}`,async()=>{this.updateViewState(e,t)})}this.router.on("/",async()=>{this.navigateTo("/overview")})}setupStateSync(){Xi.select().subscribe(e=>{if(this.suppressStateUpdate)return;let t=window.location.pathname,r=e.activeSubview?`/${e.activeView}/${e.activeSubview}`:`/${e.activeView}`;t!==r&&(this.suppressStateUpdate=!0,this.router.pushUrl(r),this.suppressStateUpdate=!1)})}handleInitialRoute(){let e=window.location.pathname;if(!e||e==="/"){this.router.pushUrl("/overview");return}let t=e.split("/").filter(Boolean),r=t[0],s=t[1];if(!Dma(r)){this.router.pushUrl("/overview");return}f9[r]?s&&Ima(r,s)?this.updateViewState(r,s):this.router.pushUrl(`/${r}/${irt[r]}`):this.updateViewState(r,null)}updateViewState(e,t){this.suppressStateUpdate=!0;let r=Xi.getState();(r.activeView!==e||r.activeSubview!==t)&&Xi.setState({...r,activeView:e,activeSubview:t}),this.suppressStateUpdate=!1}navigateTo(e){this.router.pushUrl(e)}navigateToView(e,t){if(!Dma(e)){this.navigateTo("/overview");return}t&&Ima(e,t)?this.navigateTo(`/${e}/${t}`):f9[e]?this.navigateTo(`/${e}/${irt[e]}`):this.navigateTo(`/${e}`)}getCurrentView(){return Xi.getState().activeView}destroy(){this.router.destroy(),this.initialized=!1}},l1=new ort;le();var jt=Y`
42943
42943
  :host {
42944
42944
  display: block;
42945
42945
  margin: auto;
@@ -43179,6 +43179,9 @@ Customer Support Team`}};async onActivate(b){this.appui=b.appui,this.appui.setCo
43179
43179
  <!-- Top IPs by Connection Count -->
43180
43180
  ${this.renderTopIPs()}
43181
43181
 
43182
+ <!-- Top ASNs by Connection Count -->
43183
+ ${this.renderTopASNs()}
43184
+
43182
43185
  <!-- Top IPs by Bandwidth -->
43183
43186
  ${this.renderTopIPsByBandwidth()}
43184
43187
 
@@ -43188,7 +43191,7 @@ Customer Support Team`}};async onActivate(b){this.appui=b.appui,this.appui.setCo
43188
43191
  <!-- Backend Protocols Section -->
43189
43192
  ${this.renderBackendProtocols()}
43190
43193
  </div>
43191
- `}formatNumber(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toFixed(0)}formatBytes(t){let r=["B","KB","MB","GB"],s=t,o=0;for(;s>=1024&&o<r.length-1;)s/=1024,o++;return`${s.toFixed(1)} ${r[o]}`}formatBitsPerSecond(t){let r=t*8,s=["bit/s","kbit/s","Mbit/s","Gbit/s"],o=r,n=0;for(;o>=1e3&&n<s.length-1;)o/=1e3,n++;return`${o.toFixed(1)} ${s[n]}`}formatOptional(t){return t==null||t===""?"-":String(t)}formatDateTime(t){return t?new Date(t).toLocaleString():"-"}getIpIntelligence(t){return this.networkState.ipIntelligence?.find(r=>r.ipAddress===t)}getIpOrganization(t){return t?.asnOrg||t?.registrantOrg||""}getIpIntelligenceColumns(t){let r=this.getIpIntelligence(t),s=this.getIpOrganization(r);return{Intelligence:r?w`<span class="intelligenceBadge">${this.formatOptional(s||r.countryCode||"Known")}</span>`:w`<span class="statusBadge warning">Enriching...</span>`,ASN:r?.asn?`AS${r.asn}`:"-",Organization:this.formatOptional(s),Country:this.formatOptional(r?.countryCode||r?.country),"Network Range":this.formatOptional(r?.networkRange),"Last Seen":this.formatDateTime(r?.lastSeenAt)}}getIpDataActions(){return[{name:"Refresh Intelligence",iconName:"lucide:refresh-cw",type:["inRow","contextmenu"],actionFunc:i(async t=>{let r=t.item.ip;await ms.dispatchAction(pne,r),await o1.dispatchAction(XK,null)},"actionFunc")},{name:"Block IP",iconName:"lucide:shield-ban",type:["inRow","contextmenu"],actionFunc:i(async t=>{await this.createBlockRuleDialog("ip",t.item.ip,"Blocked from Network Activity")},"actionFunc")},{name:"Block Network Range",iconName:"lucide:network",type:["contextmenu"],actionRelevancyCheckFunc:i(t=>!!this.getIpIntelligence(t.item.ip)?.networkRange,"actionRelevancyCheckFunc"),actionFunc:i(async t=>{let r=this.getIpIntelligence(t.item.ip);await this.createBlockRuleDialog("cidr",r.networkRange,"Blocked network range from Network Activity")},"actionFunc")},{name:"Block ASN",iconName:"lucide:radio-tower",type:["contextmenu"],actionRelevancyCheckFunc:i(t=>!!this.getIpIntelligence(t.item.ip)?.asn,"actionRelevancyCheckFunc"),actionFunc:i(async t=>{let r=this.getIpIntelligence(t.item.ip);await this.createBlockRuleDialog("asn",String(r.asn),"Blocked ASN from Network Activity")},"actionFunc")},{name:"Block Organization",iconName:"lucide:building-2",type:["contextmenu"],actionRelevancyCheckFunc:i(t=>!!this.getIpOrganization(this.getIpIntelligence(t.item.ip)),"actionRelevancyCheckFunc"),actionFunc:i(async t=>{let r=this.getIpIntelligence(t.item.ip);await this.createBlockRuleDialog("organization",this.getIpOrganization(r),"Blocked organization from Network Activity")},"actionFunc")},{name:"View Intelligence",iconName:"lucide:info",type:["doubleClick","contextmenu"],actionRelevancyCheckFunc:i(t=>!!this.getIpIntelligence(t.item.ip),"actionRelevancyCheckFunc"),actionFunc:i(async t=>{await this.showIpIntelligenceDetails(t.item.ip)},"actionFunc")}]}calculateThroughput(){return{in:this.networkState.throughputRate.bytesInPerSecond,out:this.networkState.throughputRate.bytesOutPerSecond}}renderNetworkStats(){let t=this.networkState.requestsPerSecond||0,r=this.calculateThroughput(),s=this.statsState.serverStats?.activeConnections||0,o=[...this.requestsPerSecHistory];for(;o.length<20;)o.unshift(0);let n=[{id:"connections",title:"Active Connections",value:s,type:"number",icon:"lucide:Plug",color:s>100?"#f59e0b":"#22c55e",description:`Total: ${this.formatNumber(this.statsState.serverStats?.totalConnections||0)} connections`,actions:[{name:"View Details",iconName:"fa:magnifyingGlass",action:i(async()=>{},"action")}]},{id:"requests",title:"Requests/sec",value:t,type:"trend",icon:"lucide:ChartLine",color:"#3b82f6",trendData:o,description:`Total: ${this.formatNumber(this.networkState.requestsTotal||0)} requests`},{id:"throughputIn",title:"Throughput In",value:this.formatBitsPerSecond(r.in),unit:"",type:"number",icon:"lucide:Download",color:"#22c55e",description:`Total: ${this.formatBytes(this.networkState.totalBytes?.in||0)}`},{id:"throughputOut",title:"Throughput Out",value:this.formatBitsPerSecond(r.out),unit:"",type:"number",icon:"lucide:Upload",color:"#8b5cf6",description:`Total: ${this.formatBytes(this.networkState.totalBytes?.out||0)}`}];return w`
43194
+ `}formatNumber(t){return t>=1e6?(t/1e6).toFixed(1)+"M":t>=1e3?(t/1e3).toFixed(1)+"K":t.toFixed(0)}formatBytes(t){let r=["B","KB","MB","GB"],s=t,o=0;for(;s>=1024&&o<r.length-1;)s/=1024,o++;return`${s.toFixed(1)} ${r[o]}`}formatBitsPerSecond(t){let r=t*8,s=["bit/s","kbit/s","Mbit/s","Gbit/s"],o=r,n=0;for(;o>=1e3&&n<s.length-1;)o/=1e3,n++;return`${o.toFixed(1)} ${s[n]}`}formatOptional(t){return t==null||t===""?"-":String(t)}formatDateTime(t){return t?new Date(t).toLocaleString():"-"}getIpIntelligence(t){return this.networkState.ipIntelligence?.find(r=>r.ipAddress===t)}getIpOrganization(t){return t?.asnOrg||t?.registrantOrg||""}getIpIntelligenceColumns(t){let r=this.getIpIntelligence(t),s=this.getIpOrganization(r);return{Intelligence:r?w`<span class="intelligenceBadge">${this.formatOptional(s||r.countryCode||"Known")}</span>`:w`<span class="statusBadge warning">Enriching...</span>`,ASN:r?.asn?`AS${r.asn}`:"-",Organization:this.formatOptional(s),Country:this.formatOptional(r?.countryCode||r?.country),"Network Range":this.formatOptional(r?.networkRange),"Last Seen":this.formatDateTime(r?.lastSeenAt)}}getIpDataActions(){return[{name:"Refresh Intelligence",iconName:"lucide:refresh-cw",type:["inRow","contextmenu"],actionFunc:i(async t=>{let r=t.item.ip;await ms.dispatchAction(pne,r),await o1.dispatchAction(XK,null)},"actionFunc")},{name:"Block IP",iconName:"lucide:shield-ban",type:["inRow","contextmenu"],actionFunc:i(async t=>{await this.createBlockRuleDialog("ip",t.item.ip,"Blocked from Network Activity")},"actionFunc")},{name:"Block Network Range",iconName:"lucide:network",type:["contextmenu"],actionRelevancyCheckFunc:i(t=>!!this.getIpIntelligence(t.item.ip)?.networkRange,"actionRelevancyCheckFunc"),actionFunc:i(async t=>{let r=this.getIpIntelligence(t.item.ip);await this.createBlockRuleDialog("cidr",r.networkRange,"Blocked network range from Network Activity")},"actionFunc")},{name:"Block ASN",iconName:"lucide:radio-tower",type:["contextmenu"],actionRelevancyCheckFunc:i(t=>!!this.getIpIntelligence(t.item.ip)?.asn,"actionRelevancyCheckFunc"),actionFunc:i(async t=>{let r=this.getIpIntelligence(t.item.ip);await this.createBlockRuleDialog("asn",String(r.asn),"Blocked ASN from Network Activity")},"actionFunc")},{name:"Block Organization",iconName:"lucide:building-2",type:["contextmenu"],actionRelevancyCheckFunc:i(t=>!!this.getIpOrganization(this.getIpIntelligence(t.item.ip)),"actionRelevancyCheckFunc"),actionFunc:i(async t=>{let r=this.getIpIntelligence(t.item.ip);await this.createBlockRuleDialog("organization",this.getIpOrganization(r),"Blocked organization from Network Activity")},"actionFunc")},{name:"View Intelligence",iconName:"lucide:info",type:["doubleClick","contextmenu"],actionRelevancyCheckFunc:i(t=>!!this.getIpIntelligence(t.item.ip),"actionRelevancyCheckFunc"),actionFunc:i(async t=>{await this.showIpIntelligenceDetails(t.item.ip)},"actionFunc")}]}getAsnDataActions(){return[{name:"Block ASN",iconName:"lucide:radio-tower",type:["inRow","contextmenu"],actionFunc:i(async t=>{await this.createBlockRuleDialog("asn",String(t.item.asn),"Blocked ASN from Network Activity")},"actionFunc")},{name:"Block Organization",iconName:"lucide:building-2",type:["contextmenu"],actionRelevancyCheckFunc:i(t=>!!t.item.organization,"actionRelevancyCheckFunc"),actionFunc:i(async t=>{await this.createBlockRuleDialog("organization",t.item.organization,"Blocked organization from Network Activity")},"actionFunc")}]}calculateThroughput(){return{in:this.networkState.throughputRate.bytesInPerSecond,out:this.networkState.throughputRate.bytesOutPerSecond}}renderNetworkStats(){let t=this.networkState.requestsPerSecond||0,r=this.calculateThroughput(),s=this.statsState.serverStats?.activeConnections||0,o=[...this.requestsPerSecHistory];for(;o.length<20;)o.unshift(0);let n=[{id:"connections",title:"Active Connections",value:s,type:"number",icon:"lucide:Plug",color:s>100?"#f59e0b":"#22c55e",description:`Total: ${this.formatNumber(this.statsState.serverStats?.totalConnections||0)} connections`,actions:[{name:"View Details",iconName:"fa:magnifyingGlass",action:i(async()=>{},"action")}]},{id:"requests",title:"Requests/sec",value:t,type:"trend",icon:"lucide:ChartLine",color:"#3b82f6",trendData:o,description:`Total: ${this.formatNumber(this.networkState.requestsTotal||0)} requests`},{id:"throughputIn",title:"Throughput In",value:this.formatBitsPerSecond(r.in),unit:"",type:"number",icon:"lucide:Download",color:"#22c55e",description:`Total: ${this.formatBytes(this.networkState.totalBytes?.in||0)}`},{id:"throughputOut",title:"Throughput Out",value:this.formatBitsPerSecond(r.out),unit:"",type:"number",icon:"lucide:Upload",color:"#8b5cf6",description:`Total: ${this.formatBytes(this.networkState.totalBytes?.out||0)}`}];return w`
43192
43195
  <dees-statsgrid
43193
43196
  .tiles=${n}
43194
43197
  .minTileWidth=${200}
@@ -43226,6 +43229,20 @@ Customer Support Team`}};async onActivate(b){this.appui=b.appui,this.appui.setCo
43226
43229
  .pagination=${!1}
43227
43230
  dataName="ip"
43228
43231
  ></dees-table>
43232
+ `}renderTopASNs(){return!this.networkState.topASNs||this.networkState.topASNs.length===0?w``:w`
43233
+ <dees-table
43234
+ .data=${this.networkState.topASNs}
43235
+ .rowKey=${"asn"}
43236
+ .highlightUpdates=${"flash"}
43237
+ .displayFunction=${t=>({ASN:`AS${t.asn}`,Organization:this.formatOptional(t.organization),Connections:t.activeConnections,IPs:t.ipCount,"Bandwidth In":this.formatBitsPerSecond(t.bytesInPerSecond),"Bandwidth Out":this.formatBitsPerSecond(t.bytesOutPerSecond),"Total Bandwidth":this.formatBitsPerSecond(t.bytesInPerSecond+t.bytesOutPerSecond),Country:this.formatOptional(t.country),"Sample IPs":t.sampleIps.join(", ")})}
43238
+ .dataActions=${this.getAsnDataActions()}
43239
+ heading1="Top Connected ASNs"
43240
+ heading2="Organizations causing the most active connections across observed IPs"
43241
+ searchable
43242
+ .showColumnFilters=${!0}
43243
+ .pagination=${!1}
43244
+ dataName="ASN"
43245
+ ></dees-table>
43229
43246
  `}renderTopIPsByBandwidth(){return!this.networkState.topIPsByBandwidth||this.networkState.topIPsByBandwidth.length===0?w``:w`
43230
43247
  <dees-table
43231
43248
  .data=${this.networkState.topIPsByBandwidth}
@@ -3,7 +3,7 @@
3
3
  */
4
4
  export const commitinfo = {
5
5
  name: '@serve.zone/dcrouter',
6
- version: '13.35.0',
6
+ version: '13.36.1',
7
7
  description: 'A multifaceted routing service handling mail and SMS delivery functions.'
8
8
  };
9
9
  //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxzQkFBc0I7SUFDNUIsT0FBTyxFQUFFLFNBQVM7SUFDbEIsV0FBVyxFQUFFLDBFQUEwRTtDQUN4RixDQUFBIn0=
@@ -1,4 +1,5 @@
1
1
  import { DcRouter } from '../classes.dcrouter.js';
2
+ import type { IAsnActivity } from '../../dist_ts_interfaces/data/stats.js';
2
3
  export declare class MetricsManager {
3
4
  private metricsLogger;
4
5
  private smartMetrics;
@@ -131,6 +132,7 @@ export declare class MetricsManager {
131
132
  bwIn: number;
132
133
  bwOut: number;
133
134
  }>;
135
+ topASNs: IAsnActivity[];
134
136
  totalDataTransferred: {
135
137
  bytesIn: number;
136
138
  bytesOut: number;
@@ -175,6 +177,7 @@ export declare class MetricsManager {
175
177
  bwIn: number;
176
178
  bwOut: number;
177
179
  }[];
180
+ topASNs: IAsnActivity[];
178
181
  totalDataTransferred: {
179
182
  bytesIn: number;
180
183
  bytesOut: number;
@@ -197,6 +200,7 @@ export declare class MetricsManager {
197
200
  requestsLastMinute: number;
198
201
  }[];
199
202
  }>;
203
+ private buildTopASNs;
200
204
  private static minuteKey;
201
205
  private incrementEmailBucket;
202
206
  private incrementDnsBucket;