diff --git a/README.md b/README.md index 0212983..77d7070 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ limits, live traffic and a LuCI admin that follows a modern design. sums up the rules and "Check access" walks them step by step for a device and an address. - **Limits.** End dates (pause, keep, or remove devices when they pass), monthly - or total data limits, allowed hours, pause one person or everyone. Devices + or total data limits, allowed hours, pause anyone. Devices drop off the tunnel at once (`awg syncconf`, no interface restart). - **Disguise presets** for AmneziaWG obfuscation (junk packets, header and padding parameters), with what each preset needs from the apps. diff --git a/install.sh b/install.sh index cd704f7..c6d11a1 100755 --- a/install.sh +++ b/install.sh @@ -779,8 +779,11 @@ select_release() { } _tags="$(jsonfilter -i "$_rl" -e '@[@.draft=false && @.prerelease=false].tag_name' 2>/dev/null)" [ -n "$_tags" ] || _tags="$(jsonfilter -i "$_rl" -e '@[*].tag_name' 2>/dev/null)" + # Newest first. BusyBox sort ignores -t/-k numeric keys here (falls back to + # an ascending string sort), so pad each part and reverse-sort as strings. _tags="$(printf '%s\n' "$_tags" | sed 's/^v//' | grep -E '^[0-9]+\.[0-9]+\.[0-9]+$' | - sort -t. -k1,1nr -k2,2nr -k3,3nr | uniq | head -n 10)" + awk -F. '{ printf "%06d%06d%06d %s\n", $1, $2, $3, $0 }' | sort -r | cut -d' ' -f2 | + uniq | head -n 10)" _count=0 for _t in $_tags; do _count=$((_count + 1)); done [ "$_count" -gt 1 ] || return 0 @@ -1133,6 +1136,22 @@ install_awg() { ok "AmneziaWG $(pkg_version amneziawg-tools) installed" } +# netifd reads its protocol handlers only when it starts: a network that was +# up before AmneziaWG was installed doesn't know the amneziawg protocol, and no +# tunnel can come up. Restarted detached and last, so an SSH session dropping +# with it can't cut the install short. +awg_netifd_restart() { + [ "$AWG_ACTION" != skip ] && [ -x /lib/netifd/proto/amneziawg.sh ] || return 0 + ubus call network get_proto_handlers 2>/dev/null | grep -q '"amneziawg"' && return 0 + msg "Restarting the network so it knows AmneziaWG (connections drop for a few seconds)" + log_line "INFO network restart: netifd has no amneziawg protocol handler" + ( + trap '' HUP + sleep 2 + /etc/init.d/network restart + ) /dev/null 2>&1 & +} + install_dawnline() { _force=0 case "$MODE" in reinstall | downgrade) _force=1 ;; esac @@ -1350,6 +1369,7 @@ main() { msg "Open LuCI → Network → Dawnline:" fi msg " $(lan_url)" + awg_netifd_restart } main "$@" diff --git a/package/luci-app-dawnline/Makefile b/package/luci-app-dawnline/Makefile index 40d71d6..d4ce74c 100644 --- a/package/luci-app-dawnline/Makefile +++ b/package/luci-app-dawnline/Makefile @@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-dawnline -PKG_VERSION:=0.4.2 +PKG_VERSION:=0.5.0 PKG_RELEASE:=1 PKG_LICENSE:=MIT diff --git a/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js b/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js index 2e158f2..488811f 100644 --- a/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js +++ b/package/luci-app-dawnline/htdocs/luci-static/resources/dawnline/app.js @@ -5,25 +5,25 @@ 'require poll'; 'require rpc'; 'require ui'; -var Oa=Object.create;var Gn=Object.defineProperty;var ja=Object.getOwnPropertyDescriptor;var Ua=Object.getOwnPropertyNames;var Wa=Object.getPrototypeOf,Ga=Object.prototype.hasOwnProperty;var qa=(n,t)=>()=>(t||n((t={exports:{}}).exports,t),t.exports);var Fa=(n,t,o,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of Ua(t))!Ga.call(n,r)&&r!==o&&Gn(n,r,{get:()=>t[r],enumerable:!(a=ja(t,r))||a.enumerable});return n};var Ka=(n,t,o)=>(o=n!=null?Oa(Wa(n)):{},Fa(t||!n||!n.__esModule?Gn(o,"default",{value:n,enumerable:!0}):o,n));var eo=qa((Zn,Xn)=>{"use strict";var Qn=(function(){var n=function(w,I){var C=236,T=17,b=w,A=o[I],u=null,f=0,N=null,P=[],H={},J=function(M,E){f=b*4+17,u=(function(k){for(var z=new Array(k),y=0;y=7&&q(M),N==null&&(N=me(b,A,P)),O(N,E)},W=function(M,E){for(var k=-1;k<=7;k+=1)if(!(M+k<=-1||f<=M+k))for(var z=-1;z<=7;z+=1)E+z<=-1||f<=E+z||(0<=k&&k<=6&&(z==0||z==6)||0<=z&&z<=6&&(k==0||k==6)||2<=k&&k<=4&&2<=z&&z<=4?u[M+k][E+z]=!0:u[M+k][E+z]=!1)},te=function(){for(var M=0,E=0,k=0;k<8;k+=1){J(!0,k);var z=r.getLostPoint(H);(k==0||M>z)&&(M=z,E=k)}return E},$=function(){for(var M=8;M>k&1)==1;u[Math.floor(k/3)][k%3+f-8-3]=z}for(var k=0;k<18;k+=1){var z=!M&&(E>>k&1)==1;u[k%3+f-8-3][Math.floor(k/3)]=z}},oe=function(M,E){for(var k=A<<3|E,z=r.getBCHTypeInfo(k),y=0;y<15;y+=1){var B=!M&&(z>>y&1)==1;y<6?u[y][8]=B:y<8?u[y+1][8]=B:u[f-15+y][8]=B}for(var y=0;y<15;y+=1){var B=!M&&(z>>y&1)==1;y<8?u[8][f-y-1]=B:y<9?u[8][15-y-1+1]=B:u[8][15-y-1]=B}u[f-8][8]=!M},O=function(M,E){for(var k=-1,z=f-1,y=7,B=0,Y=r.getMaskFunction(E),V=f-1;V>0;V-=2)for(V==6&&(V-=1);;){for(var ce=0;ce<2;ce+=1)if(u[z][V-ce]==null){var be=!1;B>>y&1)==1);var X=Y(z,V-ce);X&&(be=!be),u[z][V-ce]=be,y-=1,y==-1&&(B+=1,y=7)}if(z+=k,z<0||f<=z){z-=k,k=-k;break}}},F=function(M,E){for(var k=0,z=0,y=0,B=new Array(E.length),Y=new Array(E.length),V=0;V=0?jn.getAt(Un):0}}for(var Wn=0,X=0;XV*8)throw"code length overflow. ("+y.getLengthInBits()+">"+V*8+")";for(y.getLengthInBits()+4<=V*8&&y.put(0,4);y.getLengthInBits()%8!=0;)y.putBit(!1);for(;!(y.getLengthInBits()>=V*8||(y.put(C,8),y.getLengthInBits()>=V*8));)y.put(T,8);return F(y,z)};H.addData=function(M,E){E=E||"Byte";var k=null;switch(E){case"Numeric":k=p(M);break;case"Alphanumeric":k=c(M);break;case"Byte":k=m(M);break;case"Kanji":k=v(M);break;default:throw"mode:"+E}P.push(k),N=null},H.isDark=function(M,E){if(M<0||f<=M||E<0||f<=E)throw M+","+E;return u[M][E]},H.getModuleCount=function(){return f},H.make=function(){if(b<1){for(var M=1;M<40;M++){for(var E=l.getRSBlocks(M,A),k=d(),z=0;z"u"?M*4:E;var k="";k+='";for(var y=0;y';k+=""}return k+="",k+="
",k},H.createSvgTag=function(M,E,k,z){var y={};typeof arguments[0]=="object"&&(y=arguments[0],M=y.cellSize,E=y.margin,k=y.alt,z=y.title),M=M||2,E=typeof E>"u"?M*4:E,k=typeof k=="string"?{text:k}:k||{},k.text=k.text||null,k.id=k.text?k.id||"qrcode-description":null,z=typeof z=="string"?{text:z}:z||{},z.text=z.text||null,z.id=z.text?z.id||"qrcode-title":null;var B=H.getModuleCount()*M+E*2,Y,V,ce,be,X="",Se;for(Se="l"+M+",0 0,"+M+" -"+M+",0 0,-"+M+"z ",X+=''+ie(z.text)+"":"",X+=k.text?''+ie(k.text)+"":"",X+='',X+='"u"?M*4:E;var k=H.getModuleCount()*M+E*2,z=E,y=k-E;return j(k,k,function(B,Y){if(z<=B&&B"u"?M*4:E;var z=H.getModuleCount()*M+E*2,y="";return y+="",y};var ie=function(M){for(var E="",k=0;k":E+=">";break;case"&":E+="&";break;case'"':E+=""";break;default:E+=z;break}}return E},ge=function(M){var E=1;M=typeof M>"u"?E*2:M;var k=H.getModuleCount()*E+M*2,z=M,y=k-M,B,Y,V,ce,be,X={"██":"█","█ ":"▀"," █":"▄"," ":" "},Se={"██":"▀","█ ":"▀"," █":" "," ":" "},Ce="";for(B=0;B=y?Se[be]:X[be];Ce+=` -`}return k%2&&M>0?Ce.substring(0,Ce.length-k-1)+Array(k+1).join("▀"):Ce.substring(0,Ce.length-1)};return H.createASCII=function(M,E){if(M=M||1,M<2)return ge(E);M-=1,E=typeof E>"u"?M*2:E;var k=H.getModuleCount()*M+E*2,z=E,y=k-E,B,Y,V,ce,be=Array(M+1).join("██"),X=Array(M+1).join(" "),Se="",Ce="";for(B=0;B>>8),A.push(N&255)):A.push(T)}}return A}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=(function(){var w=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],I=1335,C=7973,T=21522,b={},A=function(u){for(var f=0;u!=0;)f+=1,u>>>=1;return f};return b.getBCHTypeInfo=function(u){for(var f=u<<10;A(f)-A(I)>=0;)f^=I<=0;)f^=C<5&&(N+=3+J-5)}for(var P=0;P=256;)b-=255;return w[b]},T})();function s(w,I){if(typeof w.length>"u")throw w.length+"/"+I;var C=(function(){for(var b=0;b"u")throw"bad rs block @ typeNumber:"+b+"/errorCorrectionLevel:"+A;for(var f=u.length/3,N=[],P=0;P>>7-T%8&1)==1},C.put=function(T,b){for(var A=0;A>>b-A-1&1)==1)},C.getLengthInBits=function(){return I},C.putBit=function(T){var b=Math.floor(I/8);w.length<=b&&w.push(0),T&&(w[b]|=128>>>I%8),I+=1},C},p=function(w){var I=t.MODE_NUMBER,C=w,T={};T.getMode=function(){return I},T.getLength=function(u){return C.length},T.write=function(u){for(var f=C,N=0;N+2>>8&255)*192+(P&255),u.put(P,13),N+=2}if(N>>8)},I.writeBytes=function(C,T,b){T=T||0,b=b||C.length;for(var A=0;A0&&(C+=","),C+=w[T];return C+="]",C},I},x=function(){var w=0,I=0,C=0,T="",b={},A=function(f){T+=String.fromCharCode(u(f&63))},u=function(f){if(!(f<0)){if(f<26)return 65+f;if(f<52)return 97+(f-26);if(f<62)return 48+(f-52);if(f==62)return 43;if(f==63)return 47}throw"n:"+f};return b.writeByte=function(f){for(w=w<<8|f&255,I+=8,C+=1;I>=6;)A(w>>>I-6),I-=6},b.flush=function(){if(I>0&&(A(w<<6-I),w=0,I=0),C%3!=0)for(var f=3-C%3,N=0;N=I.length){if(b==0)return-1;throw"unexpected end of file./"+b}var f=I.charAt(C);if(C+=1,f=="=")return b=0,-1;if(f.match(/^\s$/))continue;T=T<<6|u(f.charCodeAt(0)),b+=6}var N=T>>>b-8&255;return b-=8,N};var u=function(f){if(65<=f&&f<=90)return f-65;if(97<=f&&f<=122)return f-97+26;if(48<=f&&f<=57)return f-48+52;if(f==43)return 62;if(f==47)return 63;throw"c:"+f};return A},_=function(w,I){var C=w,T=I,b=new Array(w*I),A={};A.setPixel=function(P,H,J){b[H*C+P]=J},A.write=function(P){P.writeString("GIF87a"),P.writeShort(C),P.writeShort(T),P.writeByte(128),P.writeByte(0),P.writeByte(0),P.writeByte(0),P.writeByte(0),P.writeByte(0),P.writeByte(255),P.writeByte(255),P.writeByte(255),P.writeString(","),P.writeShort(0),P.writeShort(0),P.writeShort(C),P.writeShort(T),P.writeByte(0);var H=2,J=f(H);P.writeByte(H);for(var W=0;J.length-W>255;)P.writeByte(255),P.writeBytes(J,W,255),W+=255;P.writeByte(J.length-W),P.writeBytes(J,W,J.length-W),P.writeByte(0),P.writeString(";")};var u=function(P){var H=P,J=0,W=0,te={};return te.write=function($,G){if($>>>G)throw"length over";for(;J+G>=8;)H.writeByte(255&($<>>=8-J,W=0,J=0;W=$<0&&H.writeByte(W)},te},f=function(P){for(var H=1<>6,128|i&63):i<55296||i>=57344?a.push(224|i>>12,128|i>>6&63,128|i&63):(r++,i=65536+((i&1023)<<10|o.charCodeAt(r)&1023),a.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return a}return t(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof Zn=="object"&&(Xn.exports=n())})(function(){return Qn})});function vn(n,t){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(o=>vn(o,t)):t.push(n instanceof Node?n:String(n))),t}function e(n,t,o){let a=window.E,r=t!=null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof Node);return!r&&o===void 0?a(n,{},vn(t,[])):a(n,r?t:{},vn(o,[]))}function K(n,t=[]){let o=rpc.declare({object:"luci.dawnline",method:n,params:t});return async(...a)=>{let r=await o(...a);if(r&&typeof r=="object"&&typeof r.error=="string")throw new Error(r.error);return r}}var Ja=K("logs_clear",["person","device","category","older_days"]),Va=(n={})=>Ja(n.person??"",n.device??"",n.category??"",n.older_days??""),Ya=rpc.declare({object:"luci.dawnline",method:"person_update",params:["id","name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode","paused","services","circle","home_nets"]});async function Qa(n,t){let a=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(i=>t[i]),t.paused,t.services,t.circle,t.home_nets],r=await Ya(...a);if(r&&typeof r.error=="string")throw new Error(r.error);return r}var Za=K("status",["days"]),S={rev:K("rev"),personUpdate:Qa,settingsGet:K("settings_get"),portalInfo:K("portal_info"),settingsUpdate:K("settings_update",["values"]),serviceSet:K("service_set",["id","name","address","ports"]),serviceDelete:K("service_delete",["id"]),geoClear:K("geo_clear"),events:K("events",["limit"]),logsClear:Va,interfaces:K("interfaces",["id"]),serverInterfaces:K("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:K("circle_set",["id","server","name","color","members"]),circleDelete:K("circle_delete",["id"]),accessCheck:K("access_check",["from","to"]),homeHosts:K("home_hosts",["id"]),usageClear:K("usage_clear",["scope","id"]),uninstall:K("uninstall",["confirm"]),status:Za,setupDefaults:K("setup_defaults"),serverCreate:K("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:K("server_obfuscation",["id","preset"]),serverUpdate:K("server_update",["id","values"]),serverDelete:K("server_delete",["id"]),personLinks:K("person_links",["id"]),personCreate:K("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:K("person_pause",["id","paused"]),personRegen:K("person_regen",["id"]),personDelete:K("person_delete",["id"]),personUsage:K("person_usage",["id","days"]),pauseAll:K("pause_all",["paused"]),deviceCreate:K("device_create",["person","name","kind"]),deviceConfig:K("device_config",["id"]),deviceUpdate:K("device_update",["id","name","disabled"]),deviceDelete:K("device_delete",["id"]),deviceRotate:K("device_rotate",["id"]),apply:K("apply"),health:K("health"),healthFix:K("health_fix",["id"]),serviceLog:K("service_log"),serviceLogClear:K("service_log_clear",["older_days"]),backupList:K("backup_list"),backupCreate:K("backup_create"),backupRestore:K("backup_restore",["name"]),backupDelete:K("backup_delete",["name"]),backupRead:K("backup_read",["name"]),backupUpload:K("backup_upload",["data"]),exportJson:K("export"),importJson:K("import",["data"]),updatesStatus:K("updates_status"),updatesRun:K("updates_run",["what"]),updatesReleases:K("updates_releases",["page"]),updatesNotes:K("updates_notes",["component","tag","build"]),updatesChanges:K("updates_changes",["from","to"])};var qn={phone:'',computer:'',tablet:'',router:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function bn(n,t="dl-icon"){let o=qn[n]??qn.phone;return``}function g(n,t="dl-icon"){let o=document.createElement("span");return o.className="dl-icon-wrap",o.innerHTML=bn(n,t),o}function Q(n,t="info",o=0){let a=document.querySelector(".dl-toasts");a||(a=e("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(a));let r=t==="error"?"x":t==="warning"?"alert":t==="success"?"check":null,i=()=>{s.classList.remove("show"),setTimeout(()=>s.remove(),200)},s=e("div",{class:`dl-toast ${t}`},[r?g(r):"",e("span",{},n),t==="error"?e("button",{type:"button","aria-label":"Close",click:i},g("x")):""]);a.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),setTimeout(i,o||(t==="error"?8e3:t==="warning"?5e3:2600))}function ve(n){return n instanceof Error?n.message:String(n)}async function U(n,t){try{let o=await n();return t&&Q(t,"success",3500),o}catch(o){Q(ve(o),"error",1e4);return}}function Fn(n){try{let t=n();t&&typeof t.then=="function"&&t.catch(o=>Q(ve(o),"error"))}catch(t){Q(ve(t),"error")}}function D(n,t,o="neutral",a={}){let{disabled:r,...i}=a,s=e("button",{class:`cbi-button cbi-button-${o}`,type:"button",...i,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!s.disabled){s.disabled=!0,s.classList.add("spinning");try{await t(l)}catch(d){Q(ve(d),"error")}finally{s.disabled=!1,s.classList.remove("spinning")}}}},n);return s.disabled=!!r,s}function ye(n,t,o,a="neutral",r=""){return D([g(n),e("span",{class:"dl-btn-label"},t)],o,a,{title:t,class:`cbi-button cbi-button-${a} dl-icon-btn ${r}`.trim()})}function Ge(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var it=null;function xn(n=!1){let t=it;it=null,t?.(n)}function ae(n,t,o,a=""){xn(),ui.showModal(n,[e("div",{class:`dl-modal ${a}`},t),e("div",{class:"button-row"},o)])}function le(){xn(),ui.hideModal()}function se(n="Cancel",t=!1){return e("button",{class:`cbi-button ${t?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:le},n)}function ne(n,t,o="Confirm",a=!1){return new Promise(r=>{ae(n,t,[se()," ",e("button",{class:`cbi-button ${a?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let i=it;it=null,ui.hideModal(),i?.(!0)}},o)]),it=r})}Ge(()=>{it&&(xn(),ui.hideModal())});async function pe(n,t="Copied to clipboard"){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let o=e("textarea",{style:"position:fixed;opacity:0"},n);document.body.appendChild(o),o.select();let a=document.execCommand("copy");if(o.remove(),!a)throw new Error("Copying is blocked here. Select the text and copy it by hand.")}Q(t,"success",2500)}catch(o){Q(ve(o),"error")}}function $e(n,t,o="text/plain"){let a=globalThis,r=typeof t=="string"?new a.Blob([t],{type:o}):t,i=URL.createObjectURL(r),s=e("a",{href:i,download:n,style:"display:none"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(i),s.remove()},1e3)}function wn(n,t){return new Promise(o=>{let a=e("input",{type:"file",accept:n,style:"display:none"});a.addEventListener("cancel",()=>{a.remove(),o(null)}),a.addEventListener("change",()=>{let r=a.files?.[0];if(a.remove(),!r)return o(null);let i=new FileReader;i.onload=()=>{let s=String(i.result??"");o({name:r.name,data:t==="base64"?s.replace(/^data:[^,]*,/,""):s})},i.onerror=()=>o(null),t==="base64"?i.readAsDataURL(r):i.readAsText(r)}),document.body.appendChild(a),a.click()})}function we(n,t){let o=document.querySelector(".dl-dd");if(o&&(o.dlClose?o.dlClose():o.remove(),o.dlAnchor===n))return;let a=e("div",{class:"dl-dd dl-root",role:"menu"},t.map(m=>m?e("button",{type:"button",role:"menuitem",class:m.danger?"danger":m.warn?"warn":"",click:()=>{c(),Fn(m.run)}},[m.icon??"",e("span",{},m.label)]):e("hr")));document.body.appendChild(a);let r=n.getBoundingClientRect(),i=a.offsetWidth,s=a.offsetHeight;a.style.top=`${r.bottom+6+s>window.innerHeight-8&&r.top-6-s>8?r.top-6-s:r.bottom+6}px`,a.style.left=`${Math.max(8,Math.min(r.right-i,window.innerWidth-i-8))}px`;let l=m=>{!a.contains(m.target)&&!n.contains(m.target)&&c()},d=m=>{m.key==="Escape"&&c()},p=Ge(c);a.dlAnchor=n,a.dlClose=c;function c(){a.remove(),p(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",c,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",c,!0)}),a.querySelector("button")?.focus({preventScroll:!0})}var Ze=null,yn=null,kn=0;function $n(){Ze&&(Ze.style.display="none"),yn=null,clearInterval(kn),kn=0}function ue(n,t){let o=a=>{Ze??(Ze=document.body.appendChild(e("div",{class:"dl-tip dl-tip-float dl-root"}))),Ze.replaceChildren(...t().map(r=>typeof r=="string"?document.createTextNode(r):r)),Ze.style.display="",Ze.style.left=`${a.clientX}px`,Ze.style.top=`${a.clientY-10}px`,yn=n,kn||(kn=window.setInterval(()=>{yn?.isConnected||$n()},400))};n.addEventListener("mouseenter",o),n.addEventListener("mousemove",o),n.addEventListener("mouseleave",$n)}Ge($n);function ee(n){if(!n||n<0)return"0 B";let t=["B","KB","MB","GB","TB"],o=0,a=n;for(;a>=1024&&o=100||o===0?Math.round(a):a.toFixed(1)} ${t[o]}`}function Pe(n){let t=n*8;return t<1e3?`${Math.round(t)} bit/s`:t<1e6?`${(t/1e3).toFixed(t<1e4?1:0)} kbit/s`:t<1e9?`${(t/1e6).toFixed(t<1e7?1:0)} Mbit/s`:`${(t/1e9).toFixed(1)} Gbit/s`}function de(n,t=Date.now()/1e3){if(!n)return"never";let o=Math.max(0,Math.round(t-n));return o<60?"just now":o<3600?`${Math.floor(o/60)} min ago`:o<86400?`${Math.floor(o/3600)} h ago`:o<86400*30?`${Math.floor(o/86400)} d ago`:new Date(n*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function st(n){if(!n||n<0)return"—";let t=Math.floor(n/86400),o=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return t?`${t}d ${o}h`:o?`${o}h ${a}m`:`${a}m`}function wt(n){let t=new Date(n*1e3),o=new Date,a=t.toDateString()===o.toDateString(),r=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return a?r:`${t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${r}`}function De(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function lt(n){let[t,o,a]=n.split("-").map(Number);return new Date(t,(o||1)-1,a||1,12)}function Ae(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?lt(n):new Date(n):n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ze(n){return n?Ae(n):""}function _n(n,t){let o=a=>{let[r,i,s]=a.split("-").map(Number);return Date.UTC(r,i-1,s)};return Math.round((o(n)-o(t))/864e5)}function bt(n,t){let o=lt(n);return o.setDate(o.getDate()+t),De(o)}function xt(n,t){let[o,a,r]=n.split("-").map(Number),i=new Date(o,a-1+t,1,12),s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(r,s)),De(i)}function Ne(n){return n?.length?n[n.length-1].day:De(new Date)}function Kn(n,t,o,a,r=30){let i=n||a;return t==="day"?bt(i,o):t==="week"?bt(i,7*o):t==="month"?xt(i,o):t==="year"?xt(i,12*o):bt(i,r*o)}function Xe(n,t=Date.now()){if(!n)return null;let o=typeof t=="number"?De(new Date(t)):t,a=_n(n,o);return a>=0?a+1:a}function Rt(n,t,o=`${t}s`){return`${n.toLocaleString("en-GB")} ${n===1?t:o}`}function yt(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(n<10240?1:0)} KB`:`${(n/1048576).toFixed(1)} MB`}var et={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var Jn=["computer","phone","tablet","router","other"],Be={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},En={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Oe(n){let t=n.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let o=t[0][0]??"",a=t.length>1?t[t.length-1][0]??"":t[0][1]??"";return(o+a).toUpperCase()}function Ht(n){let t=o=>o.disabled?3:o.online?0:o.handshake?1:2;return n.map((o,a)=>[o,a]).sort((o,a)=>t(o[0])-t(a[0])||o[1]-a[1]).map(([o])=>o)}function ke(n,t,o){return e("span",{class:`dl-pill ${n}`,title:o??null},t)}var Xa={active:"",paused:"pause",paused_all:"pause",expired:"calendar",quota:"chart",hours:"clock",no_server:"alert"};function er(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function It(n){if(n.state==="active")return"";let t=e("span",{class:`dl-ibadge ${er(n)}`,"aria-label":En[n.state]},g(Xa[n.state]||"alert"));return ue(t,()=>[e("div",{class:"dl-tip-title"},En[n.state])]),t}function Vn(n){let t=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],o=e("span",{class:"dl-access","aria-label":et[n.access]},t.map(a=>e("span",{class:`dl-ibadge ${a}`},g(a==="lan"?"home":"globe"))));return ue(o,()=>[e("div",{class:"dl-tip-title"},et[n.access]),n.access==="lan"&&n.services?.length?e("div",{class:"dl-muted"},`${n.services.length} home service${n.services.length===1?"":"s"} only`):""]),o}function Bt(n,t,o="Not set up yet"){return n.disabled?e("span",{class:"dl-dstat"},"Disabled"):n.online?e("span",{class:"dl-dstat ok"},"Connected"):n.handshake?e("span",{class:"dl-dstat"},`Last seen ${de(n.handshake,t)}`):e("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},o)}var Ot=null;function Yn(n,t,o,a){Ot?.close();let r=e("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[e("div",{class:"dl-drawer-head"},[n,e("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>p()},g("x"))]),e("div",{class:"dl-drawer-body"},t),o?e("div",{class:"dl-drawer-foot"},o):""]),i=e("div",{class:"dl-drawer-overlay dl-root",click:m=>{m.target===i&&p()}},r),s=m=>{m.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&p()},l=!1,d=Ge(()=>p());function p(){l||(l=!0,d(),document.removeEventListener("keydown",s),i.classList.remove("open"),setTimeout(()=>i.remove(),220),Ot===c&&(Ot=null),a())}let c={close:p,panel:r};return document.addEventListener("keydown",s),document.body.appendChild(i),requestAnimationFrame(()=>i.classList.add("open")),Ot=c,c}function Z(n,t,o){return e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},n),o?e("span",{class:"dl-sub"},o):""]),e("div",{class:"dl-setrow-ctl"},t)])}function kt(n,t,o,a=""){return e("section",{class:`dl-setsec ${a}`},[e("div",{class:"dl-setsec-body"},[n?e("h3",{},n):"",...t]),o.length?e("div",{class:"dl-setsec-foot"},o):""])}function he(n,t,o,a){return e("div",{class:"dl-group"},[e("div",{class:"dl-group-head"},[e("span",{class:"dl-group-ic"},g(n)),e("span",{class:"dl-stack"},[e("b",{},t),o?e("span",{class:"dl-sub"},o):""])]),e("div",{class:"dl-group-body"},a.filter(r=>r!==""))])}function tt(n,t,o,a,r){return e("div",{class:`dl-row dl-need-row ${t}`},[t?e("span",{class:"dl-need-ic"},g(n)):g(n),e("span",{class:"dl-row-main dl-stack"},[e("b",{},o),e("span",{class:"dl-sub"},a)]),r])}function dt(n,t){let o={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return e("div",{class:`alert-message ${o}`},t)}function qe(n,t=""){let o=e("div",{class:t});return o.innerHTML=n,o}var to=Ka(eo(),1),tr='';function ct(n,t=3,o=!0){let a=(0,to.default)(0,n.length>300?"Q":"H");a.addData(n,"Byte"),a.make();let r=a.getModuleCount(),i=r+t*2,s=o?Math.round(r*.22):0;s&&(r-s)%2&&s++;let l=(r-s)/2,d=l+s,p=(v,h)=>s>0&&v>=l&&v=l&&h${tr}`}return`${m}`}var nr={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",paused_all:"people",resumed_all:"people",portal_blocked:"problems"},pt=["connections","people","problems"],nt={connections:"Connections",people:"People",problems:"Problems"},no={connections:"Connects, disconnects and IP changes",people:"People and their devices added, changed, paused, removed",problems:"Blocked portal sign-ins (tunnels and services are in the service log)"},$t=n=>nr[n]??"problems",_t={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"},or=["person_added","person_removed","person_changed","paused_all","resumed_all"];function Le(n){return n.by?n.by:or.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function oo(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var jt=n=>n.sys?["error","repair","down"].includes(n.sys.level):$t(n.ev.type)==="problems";function Ut(n){let t=n.keep_days>0?`${n.keep_days} day${n.keep_days===1?"":"s"}`:"no age limit",o=n.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${n.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${t}, up to ${n.max.toLocaleString("en-GB")} events, ${o}.`}function ao(n,t=120,o=26,a=De(new Date)){let r=Math.max(1,...n),i=e("div",{class:"dl-spark"});return i.style.width=`${t}px`,i.style.height=`${o}px`,n.forEach((s,l)=>{let d=e("i");d.style.height=`${Math.max(6,s/r*100)}%`,s||d.classList.add("zero");let p=n.length-1-l;ue(d,()=>[e("div",{class:"dl-tip-title"},p===0?"Today":p===1?"Yesterday":lt(bt(a,-p)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),e("div",{class:"dl-muted"},ee(s))]),i.appendChild(d)}),i}function ar(n){let t=n==null?"":String(n);return/^[=+\-@\t\r]/.test(t)&&(t=`'${t}`),/[",\r\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}function ro(n,t){return[n.join(","),...t.map(o=>n.map(a=>ar(o[a])).join(","))].join(` -`)}function rr(n){let t=new Map(n.people.map(a=>[a.id,a.name])),o=new Map(n.people.flatMap(a=>a.devices.map(r=>[r.id,r.name])));return{people:t,devices:o}}function je(n,t,o,a="",r=[]){let i=rr(n),s=[...t.map(c=>({ts:c.ts,category:$t(c.type),type:c.type,person:c.person?i.people.get(c.person)??c.pname??c.person:"",device:c.device?i.devices.get(c.device)??c.dname??c.device:"",detail:c.detail??"",where:c.where??"",by:Le(c)??""})),...r.map(c=>({ts:c.ts,category:"system",type:`${c.src}.${c.level}`,person:"",device:"",detail:`${c.who?`${c.who} `:""}${c.msg}${c.detail?` -${c.detail}`:""}`,where:_t[c.src]??c.src,by:""}))].sort((c,m)=>c.ts-m.ts).map(({ts:c,...m})=>({time:new Date(c*1e3).toISOString(),...m})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${a?`-${a}`:""}-${l}.${o}`;if(o==="json"){$e(d,JSON.stringify(s,null,2),"application/json");return}$e(d,ro(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var ir=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],io=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function Fe(n,t,o,a,r,i=!1){let s=e("select",{class:"cbi-input-select"},[e("option",{value:""},"All categories"),...pt.map(d=>e("option",{value:d,selected:d===r?"selected":null},nt[d])),i?e("option",{value:"system",selected:r==="system"?"selected":null},"System"):""]),l=e("select",{class:"cbi-input-select"},ir.map(([d,p])=>e("option",{value:d},p)));ae(n,[e("p",{class:"dl-muted"},`${t} This cannot be undone; export first if you want a copy.`),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Category"),s]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Which events"),l])],[se()," ",D("Clear",async()=>{let d=0;if(s.value!=="system")try{d+=(await S.logsClear({...o,category:s.value,older_days:l.value})).removed}catch(p){Q(ve(p),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{d+=(await S.serviceLogClear(l.value)).removed}catch(p){le(),Q(`${s.value==="system"?"":`Activity: ${io(d).toLowerCase()}. `}The service log was not cleared: ${ve(p)}`,"error",1e4),a();return}le(),Q(io(d),"success",3e3),a()},"negative")])}function ut(n,t,o,a){let r=n==="device"?`Clears ${o}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:n==="person"?`Clears ${o}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";ae(n==="all"?"Reset all traffic history?":`Reset traffic history for ${o}?`,[e("p",{class:"dl-muted"},r)],[se()," ",D("Reset",async()=>{await U(()=>S.usageClear(n,t),"Traffic history reset")&&(le(),a())},"negative")])}function fe(n,t,o){let a=e("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":t,click:()=>{let r=!a.classList.contains("on");Sn(a,r),o?.(r)}},e("i"));return a}function Sn(n,t){n.classList.toggle("on",t),n.setAttribute("aria-checked",t?"true":"false")}var Ee=n=>n.classList.contains("on");function xe(n,t,o={}){n.some(([i])=>i===t)||(n=[...n,[t,t]]);let a=e("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":t}),r=()=>a.querySelectorAll(":scope > button").forEach(i=>{let s=i.dataset.v===a.dataset.value;i.classList.toggle("on",s),i.setAttribute("aria-checked",s?"true":"false")});for(let[i,s]of n)a.appendChild(e("button",{type:"button",role:"radio","data-v":i,click:()=>{i!==a.dataset.value&&(o.optimistic!==!1&&(a.dataset.value=i,r()),o.onChange?.(i))}},s));return r(),a}function Ue(n,t,o,a={}){return e("button",{type:"button",...a,class:`dl-chipbtn${t?" on":""}${a.class?` ${a.class}`:""}`,"aria-pressed":t?"true":"false",click:o},n)}function Wt(n,t){n.classList.toggle("on",t),n.setAttribute("aria-pressed",t?"true":"false")}function re(n,t={}){return e("input",{type:"text",class:"cbi-input-text",value:n,...t})}var sr={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},lr={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function dr(n){let t={};for(let[o,a]of Object.entries(lr))n[o]!=null&&n[o]!==""&&(t[a]=String(n[o]));return t}function cr(n,t){let o=n.amnezia,a=o.obfuscation??{},r=d=>a[d]!=null&&a[d]!==""?String(a[d]):sr[d],i=o.host.replace(/^\[(.*)\]$/,"$1"),s={H1:r("h1"),H2:r("h2"),H3:r("h3"),H4:r("h4"),I1:r("i1"),I2:r("i2"),I3:r("i3"),I4:r("i4"),I5:r("i5"),Jc:r("jc"),Jmin:r("jmin"),Jmax:r("jmax"),S1:r("s1"),S2:r("s2"),S3:r("s3"),S4:r("s4"),...dr(a),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r -`),hostName:i,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(o.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:i};return o.dns[0]&&(l.dns1=o.dns[0]),o.dns[1]&&(l.dns2=o.dns[1]),l}function pr(n){let t="";for(let o=0;o"u")return null;try{let o=new t.Blob([n]).stream().pipeThrough(new t.CompressionStream("deflate")),a=new Uint8Array(await new t.Response(o).arrayBuffer()),r=new Uint8Array(4+a.length);return new DataView(r.buffer).setUint32(0,n.length,!1),r.set(a,4),r}catch{return null}}async function Cn(n,t,o=!0){let a=new TextEncoder().encode(JSON.stringify(cr(n,t))),r=o?await ur(a):null;return`vpn://${pr(r??a)}`}var lo=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"standard",title:"Standard",ic:"shield",stealth:2,speed:4,text:"Junk packets and random headers. Gets through most VPN blocking with no speed cost.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"strong",title:"Strong",ic:"shieldplus",stealth:3,speed:3,text:"More and larger junk packets for networks that block VPNs aggressively. Connects a little slower.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],Et=n=>lo.find(t=>t.id===n),mr={v2:"Needs AmneziaWG 1.5 or newer on the router.",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},hr={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function so(n,t){return e("span",{class:"dl-dots",title:`${t}: ${n} of 4`},[e("span",{class:"dl-dots-label"},t),e("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>e("i",{class:odom.content(i,lo.map(l=>{let d=!l.needs||n[l.needs],p=l.id===t;return e("button",{type:"button",role:"radio","aria-checked":p?"true":"false","aria-disabled":d?null:"true",class:`dl-method${p?" on":""}${d?"":" off"}`,click:()=>{!d||p||(t=l.id,s(),o(l.id))}},[e("div",{class:"dl-method-head"},[e("span",{class:"dl-method-ic"},g(l.ic)),e("b",{},l.title),l.id===a?e("span",{class:"dl-pill ok"},"Current"):""]),e("p",{},l.text),e("div",{class:"dl-method-meters"},[so(l.stealth,"Stealth"),so(l.speed,"Speed")]),e("div",{class:"dl-method-foot"},d?[g("phone"),e("span",{},l.apps)]:[g("alert"),e("span",{},(r?mr:hr)[l.needs])])])}));return s(),i}function co(n,t,o,a){return e("div",{class:"dl-corehead"},[e("h3",{},n),e("span",{class:`dl-pill ${t}`},o),a?e("span",{class:"dl-sub"},a):""])}var po=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function fr(n){let t=p=>n[p]!=null&&n[p]!=="",o=po.filter(([p])=>t(p));if(!o.length)return null;let a=(p,c)=>e("span",{class:"dl-pv"},[e("i",{},c),e("b",{},p==="header_protection_key"?`${n[p].slice(0,6)}••••`:n[p])]),r=(p,c,m,v)=>{let h=po.filter(([x])=>v.includes(x)&&t(x));return h.length?e("div",{class:"dl-pgroup"},[e("div",{class:"dl-pgroup-head"},[g(c),e("b",{},p)]),e("p",{},m),e("div",{class:"dl-pvals"},h.map(([x,R])=>a(x,R)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=o.map(([p,c])=>`${c} = ${n[p]}`).join(` -`),d=e("div",{class:"dl-pgrid"},[r("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),r("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),r("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),r("Signatures","globe",s,["i1","i2","i3","i4","i5"]),r("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),r("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return e("details",{class:"dl-params"},[e("summary",{},[g("chevron"),e("span",{},"Current parameters"),e("span",{class:"dl-pcount"},String(o.length)),e("span",{class:"dl-spacer"}),e("button",{type:"button",class:"dl-linkbtn",click:p=>{p.preventDefault(),pe(l,"Parameters copied")}},"Copy as config")]),d])}function uo(n,t){if(/^\s*\[.+\]\s*$/.test(n))return e("span",{class:"dl-conf-sec"},n);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!o)return document.createTextNode(n);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return e("span",{},[e("span",{class:"dl-conf-k"},o[1])," ",a&&!t?e("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function gr(n){let t=!1,o=e("pre",{class:"dl-conf"}),a=()=>dom.content(o,n.conf.split(` -`).flatMap((s,l)=>l?[` -`,uo(s,t)]:[uo(s,t)])),r=e("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),t=!t,dom.content(r,[g(t?"x":"key"),t?"Hide key":"Show key"]),a()}},[g("key"),"Show key"]);a();let i=new Blob([n.conf]).size;return e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-filecard"},[e("span",{class:"dl-filecard-ic"},".conf"),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono dl-ellipsis"},n.filename),e("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),D([g("download")," Download"],()=>$e(n.filename,n.conf,"application/octet-stream"),"positive")]),e("details",{class:"dl-params"},[e("summary",{},[g("chevron"),e("span",{},"Configuration"),e("span",{class:"dl-spacer"}),r,e("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),pe(n.conf,"Configuration copied")}},[g("copy"),"Copy"])]),o])])}async function vr(n,t="file"){if(!n.has_private_key)return e("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let o=await Cn(n,`${n.server} · ${n.person} · ${n.name}`),a={qr:()=>e("div",{class:"dl-qr-pane"},[qe(ct(n.conf),"dl-qr"),e("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-linkbox"},[e("span",{class:"dl-mono"},o),D("Copy",()=>pe(o,"Key copied"))]),e("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>gr(n)},r=e("div",{class:"dl-connect-body"}),i=e("div",{class:"dl-seg"}),s=l=>{i.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(r,a[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(e("button",{type:"button","data-id":l,click:()=>s(l)},d));return s(t),e("div",{class:"dl-stack gap12"},[i,r])}async function br(n,t,o,a){let r=Et(o),s=n.st.people.filter(d=>d.server===t.id).reduce((d,p)=>d+p.devices.length,0);await ne(a?"Generate new disguise values?":`Switch to ${r.title}?`,`${s} AmneziaWG device${s===1?"":"s"} stop connecting until they import their configuration again (from their personal link or from you).${o==="max"?" They need an app with AmneziaWG 3.1.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await U(()=>S.serverObfuscation(t.id,o),a?"New values applied":`${r.title} applied`)&&(Q("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function xr(n,t){let o=n.st,a=re(String(t.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=re(String(t.mtu??""),{placeholder:"1380",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=re(String(t.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),s=Et(t.preset)?t.preset:void 0,l=s??"standard",d=D("",()=>br(n,t,l,l===s),"neutral"),p=()=>dom.content(d,l===s?[g("reset")," Generate new values"]:[`Switch to ${Et(l).title}`]);p();let c=o.people.filter(v=>v.server===t.id).reduce((v,h)=>v+h.devices.length,0),m=o.awg_state?.tools!==!1;return kt("",[co("AmneziaWG",t.up?"ok":"bad",t.up?"Running":"Not running",`${t.ifname} · ${c} device${c===1?"":"s"}`),he("globe","Listening","Where devices reach this core from the internet",[Z("UDP port",a,"Opened on the WAN firewall automatically.")]),he("file","In every device configuration","Changing these marks devices “Update config” until they import again",[Z("MTU",r,"Lower it if some sites hang on mobile networks."),Z("Keep-alive",i,"Seconds between packets devices send to keep NAT open. 0 = off.")]),he("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Gt(o.awg,l,v=>{l=v,p()},s,m),m&&!o.awg.v3?dt("info",["This router runs an older AmneziaWG. ",e("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",fr(t.obf??{})??"",e("div",{class:"dl-row-end"},[e("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),d])]),e("details",{class:"dl-params"},[e("summary",{},[g("chevron"),e("span",{},"Tunnel"),e("span",{class:"dl-pcount"},"3")]),e("div",{class:"dl-params-body"},[Z("Interface",e("span",{class:"dl-mono"},`${t.ifname} · router ${t.address}`)),Z("Tunnel subnet",e("span",{class:"dl-mono"},t.subnet),"Device addresses come from it."),Z("Server public key",e("span",{class:"dl-keyrow"},[e("code",{class:"dl-mono"},t.public_key),D([g("copy")],()=>pe(t.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[e("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),D("Save",()=>n.save({port:a.value,mtu:r.value,keepalive:i.value},"AmneziaWG saved"),"positive")])}function wr(n){let t=Et(n.preset),o=n.obf??{},a=(s,l)=>e("span",{class:`dl-segs ${l}`},[0,1,2,3].map(d=>e("i",{class:d+o[s]).map(s=>`${s.toUpperCase()} ${o[s]}`);return i.length&&r.push(i.slice(0,2).join(" · ")+(i.length>2?` +${i.length-2}`:"")),["h1","h2","h3","h4"].some(s=>o[s]&&o[s]!==String(["h1","h2","h3","h4"].indexOf(s)+1))&&r.push("H1–H4 random"),o.i1&&r.push(o.i1.includes("0x8580")?"DNS-like first packet":"Signature packets"),o.header_protection_key&&r.push("Encrypted headers"),r.length||r.push(t?.id==="off"?"Plain WireGuard":"No values yet"),e("div",{class:"dl-bento-tile dl-disg"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Disguise"),e("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},"Change")]),e("div",{class:"dl-disg-id"},[e("span",{class:"dl-disg-ic"},g(t?.ic??"shield")),e("span",{class:"dl-stack"},[e("b",{},t?t.title:"Custom"),e("span",{class:"dl-sub"},t?t.short:"Set by hand")])]),t?e("div",{class:"dl-disg-meters"},[e("span",{},"Stealth"),a(t.stealth,"acc"),e("span",{},"Speed"),a(t.speed,"ok")]):"",e("div",{class:"dl-disg-chips"},r.map(s=>e("span",{},s)))])}var Ln={id:"awg",label:"AmneziaWG",settingsCard:xr,overviewTile:wr,connectBlock:vr,qrText:n=>n.conf,appKey:{label:"Copy AmneziaVPN key",make:n=>Cn(n,`${n.server} · ${n.person} · ${n.name}`)},file:{label:"Download .conf",make:n=>({name:n.filename,text:n.conf})}};var yr={awg:Ln};function Re(n){return yr[n?.core||"awg"]??Ln}function mt(n,t){return Re(n.find(o=>o.id===t))}var kr=2,qt=new Set,Tn=null,mo=!1;async function $r(){if(document.visibilityState!=="visible"||!qt.size)return;let n=await S.rev().catch(()=>null);if(!n)return;let t=Tn!=null&&n.rev!==Tn;Tn=n.rev,t&&qt.forEach(o=>o())}function Ft(n){return qt.add(n),mo||(mo=!0,poll.add($r,kr)),()=>qt.delete(n)}function _r(n){return n?new Date(n*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function ho(n,t,o=!1){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},n),e("button",{type:"button",class:`dl-kvrow-v copy${o?" dl-mono":""}`,title:"Copy",click:()=>pe(t,`${n} copied`)},[e("span",{},t),g("copy")])])}function Kt(n,t){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},n),e("span",{class:"dl-kvrow-v"},t)])}var fo={connect:["ok","Connected","plug"],disconnect:["","Went offline","plug"],roam:["","Changed network","network"],device_added:["ok","Added","plus"],device_removed:["","Removed","trash"],device_keys:["","New keys","reset"]};function Er(n,t,o){let a=n.filter(r=>r.device===t&&fo[r.type]).reverse().slice(0,12);return a.length?e("div",{class:"dl-dev-log"},a.map(r=>{let[i,s,l]=fo[r.type],d=r.type==="connect"?[r.detail?e("span",{class:"dl-muted"},` from ${r.detail}`):"",r.where?e("span",{class:"dl-muted"},` · ${r.where}`):""]:r.type==="roam"?[e("span",{class:"dl-muted"},` · ${r.detail??""}`)]:r.type==="device_added"||r.type==="device_removed"||r.type==="device_keys"?[e("span",{class:"dl-muted"},Le(r)==="portal"?" on the portal":Le(r)==="admin"?" by you":"")]:[],p=new Date(r.ts*1e3);return e("div",{class:`dl-dev-log-row${Le(r)==="admin"?" dl-ev-by-admin":""}`},[Le(r)==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):e("span",{class:`dl-ev-tile ev ${i}`},g(l)),e("span",{class:"dl-row-main"},[e("span",{},s),...d]),e("span",{class:"dl-faint dl-nowrap",title:p.toLocaleString()},de(r.ts,o))])})):e("div",{class:"dl-sub"},"No activity yet.")}async function go(n,t,o){let a=await S.status(1).catch(()=>null),r=a?.people.find(s=>s.id===n),i=r?.devices.find(s=>s.id===t);a&&r&&i&&He(r,i,{...o,geo:a.geo,now:a.now,today:Ne(a.series),core:mt(a.servers,r.server)})}async function He(n,t,o){let a=await U(()=>S.deviceConfig(t.id));if(!a)return;let r=o.core??Re(null),i=t,s=n,l=o.geo,d=o.now,p=o.today??De(new Date),c=await r.connectBlock(a),m=e("div",{class:"dl-drawer-title"}),v=e("div",{}),h=e("div",{}),x=e("div",{},e("div",{class:"dl-sub"},"Loading…")),R=[],_=$=>{R=$.filter(G=>G.device===i.id),dom.content(x,Er($,i.id,d))},j=async($=!1)=>{let G=o.events?.();if(G&&!$)return _(G);let q=await S.events(5e3).catch(()=>null);q&&_(q.events)},w=()=>{let $=l?.points.find(q=>q.device===i.id&&q.ip===i.endpoint);dom.content(m,[e("span",{class:`dl-dcard-ic${i.online?" on":""}`},g(i.kind)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h3",{},i.name),D([g("edit")],()=>T(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),e("span",{class:"dl-sub"},`${s.name} · ${Be[i.kind]}`)])]);let G=i.spark.reduce((q,oe)=>q+oe,0);dom.content(v,e("div",{class:"dl-dstats"},[e("div",{class:"dl-dstats-cell wide"},[e("span",{class:"dl-metric-label"},"Status"),Bt(i,d,"Waiting for the first connection")]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"This month"),e("b",{},ee(i.month[0]+i.month[1])),e("span",{class:"dl-sub dl-mono"},`↓ ${ee(i.month[1])} ↑ ${ee(i.month[0])}`)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"Last 7 days"),e("b",{},ee(G)),ao(i.spark,120,22,p)])])),dom.content(h,e("div",{class:"dl-kv2"},[ho("Tunnel address",i.address),i.hostname&&s.access!=="internet"?ho("Local address",i.hostname):"",i.endpoint?Kt("Client IP",e("span",{},[i.endpoint,$?e("span",{class:"dl-muted"},` · ${[$.city,$.org].filter(Boolean).join(" · ")}`):""])):"",Kt("Total",e("span",{class:"dl-kv-act"},[`↓ ${ee(i.total[1])} · ↑ ${ee(i.total[0])}`,e("button",{type:"button",class:"dl-linkbtn danger",click:()=>ut("device",i.id,i.name,()=>setTimeout(C,300))},"Reset")])),Kt("Added",`${_r(i.created)} · ${i.created_by==="portal"?"from the portal":"by you"}`),Kt("Public key",e("span",{class:"dl-mono dl-faint"},a.amnezia.client_pub_key?`${a.amnezia.client_pub_key.slice(0,16)}…`:"—"))])),dom.content(b,[D([g(i.disabled?"play":"pause"),i.disabled?" Enable":" Disable"],async()=>{await U(()=>S.deviceUpdate(i.id,void 0,!i.disabled),i.disabled?"Device enabled":"Device disabled")&&await C()},"neutral",i.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),D([g("key")," New keys"],async()=>{if(!await ne("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;await U(()=>S.deviceRotate(i.id),"New keys generated")&&(o.refresh(),te.close(),await go(s.id,i.id,o))}),e("span",{class:"dl-spacer"}),D([g("trash")," Remove"],async()=>{await ne(`Remove ${i.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await U(()=>S.deviceDelete(i.id),"Device removed")&&(te.close(),o.refresh())},"negative")])},I=async()=>{let $=await S.status(1).catch(()=>null),G=$?.people.find(oe=>oe.id===s.id),q=G?.devices.find(oe=>oe.id===i.id);!$||!G||!q||(s=G,i=q,l=$.geo,d=$.now,p=Ne($.series),w())},C=async()=>{await I(),o.refresh()},T=()=>{let $=e("input",{type:"text",class:"cbi-input-text",value:i.name,maxlength:48});ae(`Rename ${i.name}`,[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},$)])],[se()," ",D("Save",async()=>{await U(()=>S.deviceUpdate(i.id,$.value,void 0),"Renamed")&&(le(),await C())},"positive")]),setTimeout(()=>$.select(),50)},b=e("div",{class:"dl-drawer-actions"}),A=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Connect")]),i.config_stale?e("div",{class:"dl-note warn"},[g("alert"),e("span",{},"This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")]):"",c]),u=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Activity"),e("div",{class:"dl-dsec-actions"},[e("button",{type:"button",class:"dl-linkbtn",click:()=>je({people:[s]},R,"csv",i.id)},"Export"),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Fe(`Clear ${i.name}'s activity`,`Removes events about ${i.name}.`,{device:i.id},()=>{j(!0),o.refresh()})},"Clear"),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),x]),f=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},e("h4",{},"Details")),h]),N=!i.handshake||i.config_stale,P=e("div",{class:"dl-stack gap16"},N?[v,A,f,u]:[v,f,u,A]);j();let H=()=>{I(),j()},J=Ft(H),W=window.setInterval(H,3e4),te=Yn(m,P,b,()=>{clearInterval(W),J()});w()}function vo(n,t,o,a){let r=a.core??Re(null),i=()=>U(()=>S.deviceConfig(o.id)),s=[{label:"Show QR code",icon:g("qr"),run:async()=>{let l=await i();l&&ae(`${o.name} · QR code`,e("div",{class:"dl-qr-pane"},[qe(ct(r.qrText(l)),"dl-qr"),e("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),se("Close"))}},{label:r.file.label,icon:g("download"),run:async()=>{let l=await i();if(!l)return;let d=r.file.make(l);$e(d.name,d.text,"application/octet-stream")}},r.appKey?{label:r.appKey.label,icon:g("copy"),run:async()=>{let l=await i();l&&pe(await r.appKey.make(l),"Key copied")}}:null,null,{label:"Rename",icon:g("edit"),run:()=>He(t,o,a)},{label:"New keys",icon:g("key"),run:async()=>{await ne("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0)&&await U(()=>S.deviceRotate(o.id),"New keys generated")&&a.refresh()}},{label:o.disabled?"Enable":"Disable",icon:g(o.disabled?"play":"pause"),warn:!o.disabled,run:async()=>{await U(()=>S.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&a.refresh()}},{label:"Delete",icon:g("trash"),danger:!0,run:async()=>{await ne(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await U(()=>S.deviceDelete(o.id),"Device removed")&&a.refresh()}}];we(n,s)}function ot(n,t){let o=e("input",{type:"text",class:"cbi-input-text",placeholder:Be.phone,maxlength:48}),a="phone",r=e("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},Jn.map(s=>e("button",{type:"button",role:"radio",class:s===a?"on":"","aria-checked":s===a?"true":"false","data-kind":s,click:()=>{a=s,r.querySelectorAll("button").forEach(l=>{let d=l.dataset.kind===s;l.classList.toggle("on",d),l.setAttribute("aria-checked",d?"true":"false")}),o.placeholder=Be[s]}},[g(s),e("span",{},Be[s])]))),i=n.devices.length>=n.device_limit;ae(`Add a device for ${n.name}`,[i?e("p",{class:"dl-hint"},`${n.name} already has ${n.devices.length} of ${n.device_limit} devices. As admin you can still add one.`):"",e("div",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Type"),r]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Name"),o])],[se()," ",D("Add device",async()=>{let s=o.value.trim()||o.placeholder.replace(/^e\.g\. /,""),l=await U(()=>S.deviceCreate(n.id,s,a));l&&(le(),Q(`${s} added`,"success",3e3),t.refresh(),await go(n.id,l.id,t))},"positive")]),setTimeout(()=>o.focus(),50)}var We=1080,Ct=1512,Ie=96,Sr="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Cr="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",St=n=>n.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function Lr(n,t,o){let a=new URL(o),r=a.pathname.slice(1),i=Math.min(92,Math.floor((We-2*Ie)/(.58*(4+n.name.length)))),s=We-2*Ie,l=392,d=40,p=ct(o,2).replace("`${R}`;return``+c(Ie+82,Ie+42,36,"#a3a3a3",St(t))+c(Ie,276,i,"#ffffff",`Hi, ${St(n.name)}`,'font-weight="600"')+c(Ie,340,40,"#8a8a8a",`Scan to connect to ${St(t)}`)+``+p+`${St(r)}`+c(We/2,l+s+156,34,"#737373",St(a.host),'text-anchor="middle"')+""}async function Tr(n){let t=new Image;t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await t.decode();let o=document.createElement("canvas");return o.width=We,o.height=Ct,o.getContext("2d").drawImage(t,0,0,We,Ct),new Promise((a,r)=>o.toBlob(i=>i?a(i):r(new Error("Could not draw the card")),"image/png"))}async function bo(n){let t=await U(()=>S.personLinks(n));return t?t.link?{link:t.link,links:t.links??[]}:(Q("The personal portal is off. Turn it on in Settings.","warning"),null):null}async function Jt(n){let t=await bo(n);t&&await pe(t.link,"Personal link copied")}async function Lt(n,t,o={}){let a=n.link,r=n.links;if(a===void 0){let h=await bo(n.id);if(!h)return;a=h.link,r=h.links}if(!a){Q("The personal portal is off. Turn it on in Settings.","warning");return}let i=a,s=await U(()=>Tr(Lr(n,t,i)));if(!s)return;let l=new File([s],`${n.id}-invite.png`,{type:"image/png"}),d=URL.createObjectURL(s),p=navigator,c=!!p.canShare?.({files:[l]}),m=()=>{URL.revokeObjectURL(d),le()},v=c?D([g("link")," Share card"],async()=>{try{await p.share({files:[l],title:`Invite ${n.name}`})}catch{}},"positive"):D([g("download")," Download card"],()=>$e(l.name,s),"positive");ae(o.title??`Invite ${n.name}`,e("div",{class:"dl-invite"},[e("img",{src:d,alt:`Invite card for ${n.name}`}),e("div",{class:"dl-invite-side"},[e("p",{class:"dl-muted"},o.lead??`Send ${n.name} the card or the link. They open it, add their devices and connect — no account needed.`),e("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>pe(i,"Personal link copied")},[e("span",{},i.replace(/^https:\/\//,"")),g("copy")]),...(r??[]).filter(h=>h!==i).map(h=>e("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>pe(h,"Link copied")},[e("span",{},h.replace(/^https?:\/\//,"")),e("span",{class:`dl-pill ${h.startsWith("http:")?"warn":""}`},h.startsWith("http:")?"HTTP":"Also"),g("copy")])),e("ol",{class:"dl-invite-steps"},[e("li",{},["Install ",e("b",{},"AmneziaVPN")," on the device"]),e("li",{},"Open the link or scan the code"),e("li",{},"Add the device and connect")]),e("div",{class:"dl-invite-actions"},[v,D([g("copy")," Copy link"],()=>pe(i,"Personal link copied"))])])]),[e("button",{class:"cbi-button cbi-button-neutral",click:m},"Done")],"wide")}function ht(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function Te(n,t){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${t?`&device=${encodeURIComponent(t)}`:""}`}function Tt(n,t){let o=n.servers.find(d=>d.id===t)??n.servers[0],a=n.people.filter(d=>d.server===o.id),r=new Set(a.map(d=>d.id)),i=a.flatMap(d=>d.devices),s=d=>a.reduce((p,c)=>{let m=d(c);return[p[0]+m[0],p[1]+m[1]]},[0,0]),l=o.series?.[o.series.length-1];return{...n,servers:[o],people:a,series:o.series??n.series,events:n.events.filter(d=>d.person?r.has(d.person):!0),geo:{...n.geo,points:n.geo.points.filter(d=>r.has(d.person))},totals:{people:a.length,devices:i.length,online:i.filter(d=>d.online).length,active:a.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:s(d=>d.month)}}}var Mn=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(t){return t{let d=t.next(),p=await n.fetch(l).catch(()=>null);return p==null||!t.take(d)?null:(n.apply(p,s),p)},a=(s=!1)=>o(s,!1),r=()=>n.active?.()??!0?o(!0,!1):Promise.resolve(null);poll.add(r,n.every);let i=n.live?Ft(()=>void((n.active?.()??!0)&&o(!0,!0))):null;return{refresh:a,claim:()=>t.claim(),stop:()=>{poll.remove(r),i?.()}}}function ft(n){let t=document.activeElement;return!!n&&!!t&&t!==document.body&&n.contains(t)}function _e(n,t,o=!1){return o&&ft(n)?!1:(dom.content(n,t),!0)}function xo(n,t){let o=n,r=e("div",{class:"dl-choices"},[{v:"internet",ic:"globe",text:"Browse the internet through your router. No access to devices at home."},{v:"lan",ic:"home",text:"Reach devices at home (NAS, printer, cameras). Internet stays on their own connection."},{v:"both",ic:"shield",text:"Home devices and the internet, all through your router."}].map(i=>e("button",{type:"button",class:`dl-choice${i.v===o?" selected":""}`,"data-v":i.v,click:()=>{o=i.v,r.querySelectorAll(".dl-choice").forEach(s=>s.classList.toggle("selected",s.dataset.v===i.v)),t?.(i.v)}},[e("span",{class:"dl-choice-title"},[g(i.ic),et[i.v]]),e("span",{class:"dl-choice-text"},i.text)])));return{el:r,get:()=>o}}function Mr(n){let t=n.devices.length,o=Math.max(1,n.device_limit,t),a=Math.min(160,o*22+(o-1)*3);return e("div",{class:"dl-slotbar",title:`${t} of ${n.device_limit} devices`},[e("span",{class:"dl-slotbar-segs",style:`width: ${a}px`},Array.from({length:o},(r,i)=>e("i",{class:i>=n.device_limit?"over":i=n.quota_limit*.9}function Dr(n,t){return xt(n&&_n(n,t)>=0?n:t,1)}var wo=n=>n.people.map(t=>t.id).sort().join(" "),yo=!1,at=class{constructor(){this.list=e("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(t=>t===new URLSearchParams(location.search).get("filter"))??"all";this.sort="seen";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return S.status(30)}scope(t){return this.serverId?Tt(t,this.serverId):t}embed(t,o){return this.serverId=o,this.render(t)}person(t){return this.st.people.find(o=>o.id===t)}get today(){return Ne(this.st.series)}deviceOpts(t){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:mt(this.st.servers,t.server)}}take(t,o){let a=this.scope(t),r=wo(a)!==wo(this.st);this.st=a,r?this.rebuild():(this.paintCards(o),this.decorate(o))}async update(){await this.poller?.refresh()}async refresh(){this.poller?.claim();let t=await S.status(30).catch(()=>null);t&&(this.st=this.scope(t),this.rebuild())}rebuild(){let t=new Map;for(let a of Array.from(this.list.children))a.dataset.sid&&t.set(a.dataset.sid,a);let o=this.st.people.map(a=>{let r=t.get(a.id)??e("div",{class:"dl-card",role:"listitem","data-sid":a.id});return this.renderCard(r,a.id)});dom.content(this.list,o.length?o:e("div",{class:"dl-plist-none"},this.st.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people.")),this.decorate()}paintCards(t=!1){for(let o of this.st.people){let a=this.card(o.id);a&&!(t&&ft(a))&&this.renderCard(a,o.id)}}card(t){return this.list.querySelector(`[data-sid="${CSS.escape(t)}"]`)}render(t){let o=this.scope(t);this.st=o;let a=this,r=e("select",{class:"dl-select","aria-label":"Sort",change:s=>{a.sort=s.target.value,a.decorate()}},[e("option",{value:"seen"},"Last seen"),e("option",{value:"name"},"Name"),e("option",{value:"usage"},"Usage")]),i=e("div",{class:"dl-root"},[a.serverId?"":e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"People"),e("span",{class:"dl-muted dl-people-count"},this.countText())]),o.servers.length?D([g("plus")," Add person"],()=>a.openCreate(),"add"):""]),o.servers.length?"":e("div",{class:"alert-message warning"},["No server yet. ",e("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),e("div",{class:"dl-toolbar"},[e("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),e("div",{class:"dl-toolbar-end"},[r,a.serverId?D([g("plus")," Add person"],()=>a.openCreate(),"add"):""])]),this.list]);return this.el=i,this.rebuild(),this.poller??(this.poller=Ke({fetch:()=>S.status(30),every:30,live:!0,active:()=>!!a.el?.isConnected,apply:(s,l)=>a.take(s,l)})),!yo&&new URLSearchParams(location.search).get("add")&&(yo=!0,setTimeout(()=>a.openCreate(),100)),Promise.resolve(i)}countText(){let t=this.st.totals;return`${t.people} ${t.people===1?"person":"people"} · ${t.devices} device${t.devices===1?"":"s"} · ${t.online} online`}decorate(t=!1){let o=this.el?.querySelector(".dl-people-count");o&&(o.textContent=this.countText());let a=this.st.people,r=this.today,i=v=>Pr(v,r),s={all:a.length,online:a.filter(v=>v.online>0).length,attention:a.filter(i).length,paused:a.filter(v=>v.state!=="active"&&v.state!=="quota"&&v.state!=="expired").length},l=this.el?.querySelector(".dl-people-tabs");if(l&&!(t&&ft(l))){let v={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(l,Object.keys(v).map(h=>e("button",{type:"button",role:"tab",class:h===this.filter?"on":"",click:()=>{this.filter=h,this.decorate()}},[v[h],e("b",{class:h==="attention"&&s[h]?"warn":""},String(s[h]))])))}let d=v=>!(this.filter==="online"&&!v.online||this.filter==="attention"&&!i(v)||this.filter==="paused"&&!(v.state!=="active"&&v.state!=="quota"&&v.state!=="expired")),p=[...a].sort((v,h)=>this.sort==="name"?v.name.localeCompare(h.name):this.sort==="usage"?h.month[0]+h.month[1]-(v.month[0]+v.month[1]):h.online-v.online||h.last_seen-v.last_seen),c=0;for(let v of p){let h=this.card(v.id);if(!h)continue;this.list.appendChild(h),h.classList.toggle("dl-off",v.state!=="active"),h.classList.toggle("dl-attn-row",v.state==="quota"||v.state==="expired");let x=d(v);h.classList.toggle("dl-filtered",!x),x&&c++}let m=this.el?.querySelector(".dl-people-none")??null;a.length&&!c?(m??(m=e("div",{class:"dl-empty dl-people-none"},e("p",{},"No one here right now."))),m.previousElementSibling!==this.list&&this.list.after(m)):m?.remove()}async quick(t,o,a){await U(()=>S.personUpdate(t.id,o),a)&&await this.update()}renderCard(t,o){let a=this.person(o);if(!a)return dom.content(t,e("em",{},"This person was just removed.")),t;let r=this.today,i=Xe(a.expires,r),s=Math.max(0,a.device_limit-a.devices.length),l=a.has_link??this.st.settings.portal_enabled,d=[];if(a.expires){let h=i!=null&&i>=0&&i<=Math.max(a.expire_warn,3),x=i!=null&&i<0;d.push(e("span",{class:`dl-pill-ic${x?" bad":h?" warn":""}`,title:`Access ends ${ze(a.expires)}`},[g("calendar"),x?`ended ${ze(a.expires)}`:h?`ends in ${i} day${i===1?"":"s"}`:`until ${ze(a.expires)}`]))}a.hours&&d.push(e("span",{class:"dl-pill-ic",title:"Allowed hours"},[g("clock"),a.hours.replace("-","–")]));let p=Ht(a.devices).map(h=>e("button",{type:"button",class:`dl-chip${h.disabled?" disabled":""}${h.online?" live":""}`,title:`${Be[h.kind]} · ${h.address}${h.online?` · online from ${h.endpoint}`:h.handshake?` · seen ${de(h.handshake,this.st.now)}`:""}`,click:x=>{x.preventDefault(),He(a,h,this.deviceOpts(a))}},[g(h.kind),e("span",{class:"dl-chip-name"},h.name),!h.handshake&&!h.disabled?e("span",{class:"dl-chip-tag"},"not set up"):""]));p.push(e("button",{type:"button",class:"dl-chip add","aria-label":"Add device",title:s>0?"Add device":"Add device · over the limit, admins can still add",click:h=>{h.preventDefault(),ot(a,this.deviceOpts(a))}},g("plus")));let c=[];a.state==="quota"&&a.quota_period==="month"&&c.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{bonus_gb:String((a.bonus_gb||0)+10)},"+10 GB this month")},"+10 GB this month")),a.expires&&i!=null&&i<=Math.max(a.expire_warn,3)&&c.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{expires:Dr(a.expires,r)},"Extended by 1 month")},"Extend 1 month"));let m=ye("more","More",h=>we(h.currentTarget,[{label:"Open",icon:g("open"),run:()=>{location.href=Te(a.id)}},l?{label:"Invite card",icon:g("qr"),run:()=>Lt(a,this.st.servers.find(x=>x.id===a.server)?.name??"Home")}:null,s>0?{label:"Add device",icon:g("plus"),run:()=>ot(a,this.deviceOpts(a))}:null,null,{label:a.paused?"Resume":"Pause",icon:g(a.paused?"play":"pause"),warn:!a.paused,run:()=>this.togglePause(a)},{label:"Delete",icon:g("trash"),danger:!0,run:()=>this.remove(a.id)}].filter((x,R,_)=>x||R>0&&_[R-1])),"neutral","dl-icon-only"),v=e("div",{class:"dl-pcard-actions"},[l?ye("link","Copy link",()=>Jt(a.id),"neutral","dl-icon-only"):"",m]);return dom.content(t,e("div",{class:"dl-pcard"},[e("div",{class:"dl-pcard-main"},[e("div",{class:"dl-pcard-top"},[e("span",{class:`dl-avatar${a.online?" online":""}`},Oe(a.name)),e("div",{class:"dl-pcard-who"},[e("div",{class:"dl-card-head"},[e("a",{class:"dl-card-name",href:Te(a.id)},a.name),It(a),Vn(a),...d]),Mr(a)])]),e("div",{class:"dl-chips"},p),c.length?e("div",{class:"dl-fixes"},c):""]),this.usageSide(a,v)])),t}usageSide(t,o){let a=t.quota_used||t.month[0]+t.month[1],r=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,i=t.devices.reduce((c,m)=>c+(m.spark[m.spark.length-1]??0),0),s=t.rate?.[t.rate.length-1],l=t.online&&s&&this.st.now-s[0]<180,d=e("div",{class:`dl-usebar${r>=100?" bad":r>=90?" warn":""}`});if(t.quota_limit){let c=e("i",{class:"fill"});c.style.width=`${r}%`,d.appendChild(c),ue(d,()=>[e("div",{class:"dl-tip-title"},`${r.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${ee(t.quota_used)} of ${ee(t.quota_limit)} · ${ee(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},t.quota_period==="total"?"In total":`This month${t.bonus_gb?` · includes +${t.bonus_gb} GB extra`:""}`)])}else{let c=t.devices.map(m=>({d:m,v:m.month[0]+m.month[1]})).filter(m=>m.v>0).sort((m,v)=>v.v-m.v);c.forEach((m,v)=>{let h=e("i",{class:`c${Math.min(v,4)}`});h.style.flexGrow=String(m.v),d.appendChild(h)}),c.length&&ue(d,()=>[e("div",{class:"dl-tip-title"},"This month by device"),...c.map((m,v)=>e("div",{class:"dl-tip-row"},[e("span",{class:`dl-swatch c${Math.min(v,4)}`}),e("span",{},m.d.name),e("b",{},ee(m.v))]))])}let p=t.quota_limit?`${ee(Math.max(0,t.quota_limit-t.quota_used))} left`:"no limit";return e("div",{class:"dl-pside"},[e("div",{class:"dl-pside-top"},[l?e("span",{class:"dl-pside-state live"},"Online"):e("span",{class:"dl-pside-state"},t.online?"Online":t.last_seen?"Offline":"Never connected"),o]),e("div",{class:"dl-use-num"},[e("b",{class:a?"":"dl-faint"},ee(a)),e("span",{class:"dl-faint"},t.quota_limit?`of ${ee(t.quota_limit)}`:t.quota_period==="total"&&t.quota_gb?"in total":"this month")]),d,l?e("div",{class:"dl-use-live",title:"Right now"},[`↓ ${Pe(s[2])}`,e("span",{class:"dl-faint"},`↑ ${Pe(s[1])}`)]):e("div",{class:"dl-faint dl-pside-foot"},i?`today ${ee(i)} · ${p}`:p)])}async togglePause(t){await U(()=>S.personPause(t.id,!t.paused),t.paused?`${t.name} resumed`:`${t.name} paused`)&&await this.refresh()}async remove(t){let o=this.person(t);await ne(`Remove ${o?.name??t}?`,`All ${o?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await U(()=>S.personDelete(t),"Person removed")&&await this.refresh()}openCreate(){let t=this.st;if(!t.servers.length){Q("Set up the server first.","warning");return}let o=e("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),a=xo("internet"),r=e("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:t.settings.default_device_limit}),i=e("input",{type:"date",class:"cbi-input-text"}),s=e("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited"}),l=(m,v)=>e("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{i.value=v?xt(Ne(t.series),v):""}},m),d=t.servers[0],p=!this.serverId&&t.servers.length>1?e("select",{class:"cbi-input-select"},t.servers.map(m=>e("option",{value:m.id},m.name))):null,c=(m,v,h)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},m),e("div",{class:"cbi-value-field"},[v,h?e("div",{class:"cbi-value-description"},h):""])]);ae("Add person",[c("Name",o),p?c("Server",p):"",e("div",{class:"cbi-value dl-block"},[e("label",{class:"cbi-value-title"},"Access"),e("div",{class:"cbi-value-field"},a.el)]),c("Devices",r,"How many devices they can add themselves."),c("End date",e("div",{class:"dl-actions"},[i,l("1 month",1),l("3 months",3),l("1 year",12),l("None",0)]),"Optional."),c("Monthly data (GB)",s,"Optional. They are paused when it runs out and resumed next month.")],[se()," ",D("Create and copy link",async()=>{let m=await U(()=>S.personCreate(o.value.trim(),"",p?.value??d.id,a.get(),String(Number(r.value)||t.settings.default_device_limit),i.value,s.value.trim(),"month"));m&&(m.link&&await pe(m.link,"Personal link copied"),this.showCreated(m.id,o.value.trim(),m.link,t.servers.find(v=>v.id===(p?.value??d.id))?.name??d.name),await this.refresh())},"positive")]),setTimeout(()=>o.focus(),50)}showCreated(t,o,a,r){if(a){Lt({id:t,name:o,link:a},r,{title:`${o} is ready`,lead:`Send ${o} the card or the link. They open it, add their devices and connect — no account needed.`});return}ae(`${o} is ready`,[e("p",{},"Created. Turn on the personal portal in Settings to get a link, or add devices for them here.")],[e("button",{class:"cbi-button cbi-button-positive",click:le},"Done")])}};var Vt=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],Pn=n=>e("i",{class:"dl-circle-dot",style:`background:${Vt[n?.color??0]??Vt[0]}`}),Je=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function ko(n,t,o){let a=re(n?.name??t.name??"",{placeholder:"NAS"}),r=re(n?.address??t.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),i=re((n?.ports??t.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),s=(l,d)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},l),e("div",{class:"cbi-value-field"},d)]);ae(n?`Edit ${n.name}`:"Add service",[s("Name",a),s("Address",r),s("Ports",i)],[se()," ",D("Save",async()=>{let l=i.value.split(/[ ,]+/).filter(Boolean);await U(()=>S.serviceSet(n?.id??"",a.value,r.value,l),"Saved")&&(le(),o())},"positive")])}var Ar={_smb:"SMB",_afpovertcp:"AFP",_http:"Web",_https:"Web",_ssh:"SSH",_sftp:"SFTP","_sftp-ssh":"SFTP",_ipp:"Printer",_ipps:"Printer",_printer:"Printer","_pdl-datastream":"Printer",_airplay:"AirPlay",_raop:"AirPlay",_rfb:"Screen sharing",_googlecast:"Cast",_hap:"HomeKit",_rdp:"Remote desktop",_ftp:"FTP"},zr=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function Nr(n){let t=new Map;for(let o of n.services){let a=Ar[o.type.split(".")[0]];!a||!o.port||(t.get(a)??t.set(a,new Set).get(a)).add(String(o.port))}return t.size?[...t].map(([o,a])=>[o,[...a].sort((r,i)=>+r-+i)]):zr}function $o(n,t,o){let a=n,r=null,i=!1,s=null,l=new Set,d=e("div",{class:"dl-list"}),p=e("div",{class:"dl-stack gap8"},e("span",{class:"dl-sub"},"Looking for devices at home…")),c=()=>{let R=a.services;dom.content(d,R.length?R.map(_=>e("div",{class:"dl-row"},[g("home"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},_.name),e("span",{class:"dl-mono dl-faint"},`${_.address}${_.ports.length?` · ports ${_.ports.join(", ")}`:" · all ports"}`)]),D("Edit",()=>ko(_,{},o)),D([g("trash")],async()=>{await ne(`Remove ${_.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await U(()=>S.serviceDelete(_.id),"Removed")&&await o()},"neutral",{title:"Remove","aria-label":`Remove ${_.name}`})])):[e("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")])};async function m(R,_){if(!l.has(R.address)){l.add(R.address),h();try{let j=a.services.find(I=>I.address===R.address);(_===null?j&&await U(()=>S.serviceDelete(j.id),`${j.name} removed`):await U(()=>S.serviceSet(j?.id??"",j?.name??(R.name||R.address),R.address,_),j?`${j.name} updated`:`${R.name||R.address} added`))&&await o()}finally{l.delete(R.address),h()}}}function v(R){let _=a.services.find(T=>T.address===R.address),j=!!_&&!_.ports.length,w=new Set(_?.ports??[]),I=l.has(R.address),C=(T,b,A)=>Ue(T,b,A,{disabled:I?"disabled":null,"aria-busy":I?"true":null});return e("div",{class:"dl-row"},[g(R.services.some(T=>T.type.startsWith("_ipp")||T.type.startsWith("_printer"))?"file":"computer"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},R.name||R.address),e("span",{class:"dl-mono dl-faint"},R.address)]),e("div",{class:"dl-chips-row dl-host-ports"},[C("All ports",j,()=>m(R,j?null:[])),...Nr(R).map(([T,b])=>{let A=!j&&b.every(u=>w.has(u));return C(`${T} ${b.join(", ")}`,A,()=>{let u=new Set(j?[]:w);for(let f of b)A?u.delete(f):u.add(f);m(R,u.size?[...u]:null)})})])])}function h(){if(i)return dom.content(p,e("span",{class:"dl-sub"},"Couldn't read the devices at home."));if(!r)return;let R=r;if(!R.hosts.length)return dom.content(p,e("span",{class:"dl-sub"},"No devices found in the home network right now."));let _=e("details",{class:"dl-params",open:s??!a.services.length?"":null},[e("summary",{},[g("chevron"),e("span",{},"Add from devices at home"),e("span",{class:"dl-pcount"},String(R.hosts.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},R.mdns?"Ports they announce over Bonjour. Pick what to open, or all ports.":"Devices that got an address from this router. Pick the ports to open, or all ports."),e("div",{class:"dl-list"},R.hosts.map(v))])]);_.addEventListener("toggle",()=>s=_.open),dom.content(p,_)}return S.homeHosts(t).then(R=>{r=R,h()}).catch(()=>{i=!0,h()}),c(),{el:e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-iflead"},[e("div",{class:"dl-iflead-row"},[e("b",{},"Home services"),D([g("plus")," Add service"],()=>ko(null,{},o))]),e("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),d,p]),update(R){a=R,c(),h()}}}function Yt(n,t,o,a){let r=new Set(n.circles.filter(h=>h.server===t).map(h=>h.color)),i=o?.color??Vt.findIndex((h,x)=>!r.has(x));i<0&&(i=0);let s=re(o?.name??"",{placeholder:"Family"}),l=n.people.filter(h=>h.server===t).sort((h,x)=>h.name.localeCompare(x.name)),d=new Set(l.filter(h=>o&&h.circle===o.id).map(h=>h.id)),p=e("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),c=()=>dom.content(p,Vt.map((h,x)=>e("button",{type:"button",role:"radio",class:`dl-swatch${x===i?" on":""}`,style:`--sw:${h}`,"aria-checked":x===i?"true":"false","aria-label":`Colour ${x+1}`,click:()=>{i=x,c()}})));c();let m=e("div",{class:"dl-chips-row"},l.map(h=>{let x=h.circle&&h.circle!==o?.id?n.circles.find(R=>R.id===h.circle):void 0;return e("button",{type:"button",class:`dl-chipbtn${d.has(h.id)?" on":""}`,title:Je(h)?x?`Now in ${x.name}`:"":`${h.name} has no home access: their devices aren't reachable anyway`,click:R=>{d.delete(h.id)||d.add(h.id),R.currentTarget.classList.toggle("on",d.has(h.id))}},[h.name,Je(h)?x?e("b",{},x.name):"":e("b",{},"internet")])})),v=(h,x)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},h),e("div",{class:"cbi-value-field"},x)]);ae(o?`Edit ${o.name}`:"New circle",[v("Name",s),v("Colour",p),v("People",m),e("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[o?D("Delete",async()=>{await U(()=>S.circleDelete(o.id),`${o.name} deleted`)&&(le(),a())},"negative"):"",e("span",{class:"dl-spacer"}),se()," ",D("Save",async()=>{await U(()=>S.circleSet(o?.id??"",t,s.value,i,[...d]),"Saved")&&(le(),a())},"positive")],"dl-circle-modal")}function _o(n,t,o){let a=n.circles.filter(r=>r.server===t);return e("div",{class:"dl-chips-row dl-circles"},[...a.map(r=>{let i=n.people.filter(s=>s.circle===r.id).map(s=>s.name);return e("button",{type:"button",class:"dl-chip",title:`Edit ${r.name}`,click:()=>Yt(n,t,r,o)},[Pn(r),e("b",{},r.name),e("span",{class:"dl-faint"},i.length?i.join(", "):"nobody yet")])}),e("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>Yt(n,t,null,o)},g("plus"))])}function Dn(n,t){let o=n.people.filter(c=>c.server===t.id),a=(c="")=>e("span",{class:"dl-yes"},[g("check"),c]),r=()=>e("span",{class:"dl-faint"},"—"),i=c=>{let m=new Set(c.map(v=>v.access==="lan"&&v.services?.length?"services":v.home_nets?.length?"some":"all"));return m.size||m.add("all"),a([...m].map(v=>({all:"all networks",some:"their networks",services:"services"})[v]).join(" / "))},s=()=>t.mesh==="off"?r():t.mesh==="circles"?a("circle"):a(),l=t.lan_like?"like home":"direct",d=(c,m,v)=>e("tr",{},[e("td",{},[e("b",{},c),e("div",{class:"dl-sub"},`${m.length} ${m.length===1?"person":"people"}`)]),...v.map(h=>e("td",{},h))]),p=c=>o.filter(m=>m.access===c);return e("section",{class:"dl-setsec"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Who reaches what"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"From the rules on this server")]),e("div",{class:"dl-reach-wrap"},e("table",{class:"dl-table dl-reach"},[e("tr",{},["","Internet","Home","This router","Each other"].map(c=>e("th",{},c))),d("Internet",p("internet"),[a(l),r(),e("span",{class:"dl-faint"},"DNS"),r()]),d("Home",p("lan"),[e("span",{class:"dl-faint"},"their own"),i(p("lan")),a(),s()]),d("Both",p("both"),[a(l),i(p("both")),a(),s()])])),e("p",{class:"dl-sub"},"Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing.")])])}function Eo(n,t){let o=n.people.filter(p=>p.server===t.id).flatMap(p=>p.devices.map(c=>({id:c.id,label:`${p.name} · ${c.name}`}))).sort((p,c)=>p.label.localeCompare(c.label)),a="@addr",r=(p,c)=>{let m=e("select",{class:"cbi-input-select","aria-label":p},[...o.map(R=>e("option",{value:R.id,selected:R.id===c?"selected":null},R.label)),e("option",{value:a,selected:c===a?"selected":null},"Address")]),v=re("",{placeholder:p,class:"cbi-input-text dl-mono"}),h=e("div",{class:"dl-check-end"},[m,v]),x=()=>v.hidden=m.value!==a;return m.addEventListener("change",x),x(),{el:h,value:()=>m.value===a?v.value.trim():m.value}},i=r("10.0.1.11",o[0]?.id??a),s=r("10.0.1.20:445",a),l=e("div",{class:"dl-stack gap8"}),d=async()=>{let p=await U(()=>S.accessCheck(i.value(),s.value()));if(!p)return;let c=p.steps.findIndex(m=>!m.ok);dom.content(l,[e("div",{class:`dl-verdict ${p.ok?"ok":"bad"}`},[e("b",{},p.ok?"Allowed":"Blocked"),e("span",{class:"dl-sub"},p.ok?"Every step lets it through":`Stops at step ${c+1} of ${p.steps.length}`)]),e("ul",{class:"dl-checks"},p.steps.map(m=>e("li",{},[e("span",{class:`dl-check-icon ${m.ok?"ok":"error"}`},g(m.ok?"check":"x")),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},m.title),m.detail?e("div",{class:"dl-check-detail"},m.detail):""])])))])};return e("section",{class:"dl-setsec"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Check access"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"Why something does or does not connect")]),e("div",{class:"dl-check-form"},[i.el,e("span",{class:"dl-faint"},"→"),s.el,D("Check",d)]),l])])}var Qt={app:"Dawnline",amneziawg:"AmneziaWG",packages:"System packages",pkgs:"System packages"};function Ve(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function Zt(n){return Ve(n.action==="check"?`check:${n.component??""}`:n.component??"")}function So(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function Co(n,t){return!n?.from&&!n?.to?t:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??t}function Lo(n,t){let o=n.check?.components??{},a=t==="all"?["app","amneziawg","packages"]:[t],r=[],i;for(let l of a){let d=o[l];if(d){if(d.error)return{tone:"warn",text:d.error};l==="packages"&&d.updates?r.push(`${d.updates} system package${d.updates===1?"":"s"}`):l!=="packages"&&d.update&&d.installed&&d.latest&&(r.push(`${Qt[l]} ${d.latest}`),t!=="all"&&(i=d.latest))}}if(r.length)return{tone:"acc",text:`Update available: ${r.join(", ")}`,update:i};let s=a.length===1?o[a[0]]:null;return s?.status==="dev"?{tone:"acc",text:`Installed version is newer than the release (${s.latest})`}:s?.note?{tone:"warn",text:s.note}:{tone:"ok",text:a.length>1?"Everything is up to date":"Latest version is installed"}}function To(n,t,o,a){return t?n.id===t:o&&n.id===o?!1:n.state==="running"||a>0&&n.started>=a}var Mo=n=>new Promise(t=>setTimeout(t,n));async function Mt(n,t,o){let a=o?Zt(o):Ve(n),r=o?o.action==="check":n.startsWith("check"),i=Date.now(),s=e("b",{},Qt[a]??(a==="all"?"All components":"Dawnline")),l=e("span",{class:"dl-pill dl-mono"},t.version??""),d=e("span",{class:"dl-pill info",hidden:!0}),p=e("span",{},"0:00"),c=e("pre",{class:"dl-log"},"Operation started. Waiting for log output…"),m=e("div",{}),v=e("div",{class:"dl-op-actions"}),h=[],x=u=>dom.content(v,u),R=(u=!1)=>se("Close",u);ae(t.title,e("div",{class:"dl-op"},[e("div",{class:"dl-op-head"},[s,t.version?l:"",d,e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint dl-op-timer"},[g("clock"),p])]),e("div",{class:"dl-op-loghead"},[e("b",{},"Operation log"),ye("copy","Copy log",()=>pe(h.join(` -`),"Log copied"))]),c,m]),[v],"wide"),x([e("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?"Checking…":"Working…")]);let _=o??null,j=o?.id,w,I=0,C=u=>{j!==u.id&&(j=u.id,t.onJob?.(u))};if(o)t.onJob?.(o);else try{let u=await S.updatesStatus().catch(()=>null);w=u?.job?.id,I=u?.now??0;let f=await S.updatesRun(n);f.job&&f.job.state==="running"&&f.job.id!==w&&(_=f.job,C(f.job))}catch(u){return h=[ve(u)],c.textContent=h[0],dom.content(m,e("div",{class:"dl-comp-status warn"},[g("alert"),e("span",{},ve(u))])),x([R(!0)]),Q(ve(u),"error"),null}let T=null,b=0;for(;;){if(await Mo(1e3),T=await S.updatesStatus().catch(()=>null),!T){if(++b>60)break;continue}b=0;let u=T.job;if(!u||!To(u,j,w,I)){if(Date.now()-i>15e3)break;continue}if(C(u),_=u,u.log.length){h=u.log;let f=c.scrollTop+c.clientHeight>=c.scrollHeight-8;c.textContent=h.join(` -`),f&&(c.scrollTop=c.scrollHeight)}if(l.textContent=Co(u,t.version??""),!l.isConnected&&l.textContent&&s.after(l),p.textContent=So((u.finished??T.now)-u.started),u.state==="running"){d.hidden=!u.phase,d.textContent=u.phase;continue}break}if(c.scrollTop=c.scrollHeight,d.hidden=!1,!_||_.state==="running")return d.className="dl-pill warn",d.textContent="No answer",dom.content(m,e("div",{class:"dl-comp-status warn"},[g("alert"),e("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),x([R()]),t.onDone?.(T),_;if(_.state==="failed")return d.className="dl-pill bad",d.textContent="Failed",dom.content(m,e("div",{class:"dl-comp-status bad"},[g("x"),e("span",{},[e("b",{},_.error??"Operation failed"),r?"":". Nothing else was changed."])])),x([D("Copy log",()=>pe(h.join(` -`),"Log copied")),R(!0)]),Q(`${Qt[a]??"Update"}: ${_.error??"failed"}`,"error"),t.onDone?.(T),_;if(d.className="dl-pill ok",d.textContent="Finished",r&&T){let u=Lo(T,a);if(dom.content(m,e("div",{class:`dl-comp-status ${u.tone}`},[g(u.tone==="ok"?"check":u.tone==="warn"?"alert":"download"),e("span",{},u.text)])),Q(u.text,u.tone==="warn"?"warning":"success"),t.onDone?.(T),u.update&&t.onUpdate){let f=T;x([R(),D(`Update to ${u.update}`,()=>t.onUpdate(f),"positive")])}else x([R()]),u.tone==="ok"&&setTimeout(()=>m.isConnected&&le(),1200);return _}if(a==="app"&&_.to){let u=_.to,f=e("span",{},"Waiting for the router to restart its services…");dom.content(m,e("div",{class:"dl-comp-status ok"},[g("check"),e("span",{},[e("b",{},`Dawnline ${u} is installed. `),f])]));let N=()=>{ui.menu?.flushCache(),location.reload()};x([R(),D("Reload now",N,"positive")]),Q(`Dawnline updated to ${u}`,"success",6e3);for(let P=1;P<=30;P++)if(f.textContent=`Waiting for the router to restart its services (${P} of 30)…`,await Mo(1500),(await S.updatesStatus().catch(()=>null))?.version===u)return f.textContent="Services are back. Reloading…",setTimeout(N,800),_;return f.textContent="Services restarted. Reload the page to use the new version.",_}let A=a==="pkgs"?`Updated ${[..._.result?.pkgs?.updated??[],..._.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:a==="amneziawg"?`AmneziaWG${_.to?` ${_.to}`:""} is installed`:"Operation completed";return dom.content(m,e("div",{class:"dl-comp-status ok"},[g("check"),e("span",{},A)])),x([R()]),Q(A,"success"),t.onDone?.(T),_}var Rr={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function Po(n,t,o,a){return!await ne(`Install ${t}?`,o,"Install")||(await Mt(n,{title:`Installing ${t}`}))?.state!=="done"?!1:(setTimeout(()=>a?.(),4e3),!0)}function Xt(n){return Po("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Pt(n,t,o){return n==="awg"?Xt(o):t.length?Po(`pkgs:${t.join(",")}`,Rr[n],`${t.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,o):!0}async function Do(n,t){if(n==="awg")return Xt(t);let o=await U(()=>S.updatesStatus());return o?Pt(n,o.needs?.[n]??[],t):!1}var Hr=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],Ir={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function Ao(n,t,o){let a=n.id,r=t,i=e("div",{class:"dl-stack gap16"},e("section",{class:"dl-setsec"},e("div",{class:"dl-setsec-body"},e("p",{class:"dl-muted"},"Loading interfaces…")))),s,l=!0,d="",p=!0,c=!0,m="all",v=!1,h=$o(r,a,o),x=new Set,R="",_=()=>JSON.stringify([c,l,l?"":d,p,[...x].sort()]),j=()=>s.detected.lan||s.saved.lan||"",w=()=>(l?s.detected.wan||s.saved.wan:d)||"",I=()=>new Map(s.devices.map($=>[$.name,$])),C=()=>{let $=I();return[...p&&j()?[j()]:[],...[...x].filter(q=>q!==j())].filter(q=>q!==w()).map(q=>$.get(q)??{name:q,nets:[],missing:!0})},T=($,G)=>{s=$,G&&(l=$.config.auto_wan,d=$.config.wan_device||$.detected.wan||$.saved.wan||"",p=$.config.auto_lan,c=$.config.lan_like,m=$.config.mesh??($.config.device_mesh?"all":"off"),x=new Set($.config.lan_devices),R=_()),W()},b=async $=>{let G=await S.interfaces(a).catch(q=>(Q(q.message,"error"),null));G&&T(G,$)};function A($){let G=p&&$.name===j(),q=!!$.own||!!$.master||$.name===w()||G;return G||x.has($.name)||!q&&($.nets.length>0||!!$.missing)}function u($){let G=p&&$.name===j(),q=$.name===w(),oe=!G&&x.has($.name),F=!(!!$.own||!!$.master||q||G)&&($.nets.length>0||oe||!!$.missing),me=(oe||G)&&!$.zone&&!$.missing,ie=$.missing?"Not present right now":$.own?"This server":$.master?`Port of ${$.master}`:q?`Internet${$.zone?` · zone ${$.zone}`:""}`:$.nets.length?$.nets.join(", "):"No IPv4 network",ge=e("button",{type:"button",class:`dl-if${oe?" sel":""}${G?" auto":""}${!F&&!oe&&!G?" off":""}${me?" warn":""}`,"aria-pressed":oe||G?"true":"false","aria-disabled":F?null:"true",click:()=>{F&&(x.has($.name)?x.delete($.name):x.add($.name),W())}},[e("span",{class:"dl-if-ic"},g(Ir[$.kind]??"link")),e("span",{class:"dl-if-main"},[e("span",{class:"dl-if-name"},$.name),e("span",{class:"dl-if-sub"},ie)]),G?e("span",{class:"dl-if-badge ok"},"Auto"):oe?e("span",{class:"dl-if-check"},g("check")):""]);return ue(ge,()=>[e("div",{class:"dl-tip-title"},$.name),e("div",{class:"dl-muted"},[$.logical?`Interface ${$.logical}`:"No netifd interface",$.zone?` · zone ${$.zone}`:" · no firewall zone"]),$.members.length?e("div",{class:"dl-muted"},`Ports: ${$.members.join(", ")}`):"",$.nets.length?e("div",{class:"dl-mono"},$.nets.join(", ")):"",me?e("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",$.master?e("div",{class:"dl-muted"},`Choose ${$.master} to include it.`):""]),ge}function f(){let $=s.like_home;return!c||!s.config.lan_like?"":!s.needs?.length&&$.active&&$.bridged?"ok":"warn"}function N(){let $=s.like_home;return c?s.needs?.length?[e("span",{class:"dl-warn"},`Needs ${s.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:s.config.lan_like?$.active&&$.bridged?["Internet traffic enters ",e("span",{class:"dl-mono"},$.dev??"")," as ",e("span",{class:"dl-mono"},$.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[e("span",{class:"dl-warn"},`Not working: ${$.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on."]:["Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router."]}let P={off:"Devices of different people never reach each other; a person's own devices don't either.",all:"Devices of people with home access reach each other, like home devices do. Internet-only people never.",circles:"Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never."};function H($,G,q,oe,O="",F){return e("div",{class:F?"dl-setrow head":"dl-setrow"},[e("div",{class:"dl-lh-main"},[e("span",{class:`dl-need-ic ${O}`},g($)),e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},G),e("span",{class:"dl-sub"},q),F??""])]),e("div",{class:"dl-setrow-ctl"},oe)])}let J=($,G)=>{let q=oe=>e("span",{class:"dl-mono"},oe);return $?e("span",{},[" Now: ",q($),...G&&G!==$?[", was ",q(G)]:[],"."]):e("span",{},G?[" Not found now: using ",q(G),"."]:[" Not found."])};function W(){let $=e("select",{class:"cbi-input-select","aria-label":"Internet interface",change:y=>{d=y.target.value,W()}},s.devices.filter(y=>!y.own&&!y.master&&y.zone&&!y.missing).map(y=>e("option",{value:y.name,selected:y.name===d?"selected":null},`${y.name} · zone ${y.zone}`))),q=C().flatMap(y=>y.nets.map(B=>[B,y.name])),oe=JSON.parse(_()),O=JSON.parse(R),F=(...y)=>y.some(B=>JSON.stringify(oe[B])!==JSON.stringify(O[B])),me=F(0,1,2),ie=F(3,4),ge=y=>D("Save",async()=>{let B=await U(()=>S.serverInterfaces(a,l,l?"":d,p,[...x],c,m!=="off",m),"Access saved");B&&(T(B,!0),B.nets_changed&&B.lan_only&&Q(`${B.lan_only} ${B.lan_only===1?"person has":"people have"} Home-only access: their devices need the configuration again to reach the new networks.`,"warning",1e4))},"positive",{disabled:!y}),M=e("section",{class:"dl-setsec dl-ifcard"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Internet"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"People with Internet or Both")]),H("home","Internet like a home device",N(),[c&&s.needs?.length?D("Install",()=>Pt("home",s.needs,()=>b(!1)),"positive"):"",fe(c,"Internet like a home device",y=>{c=y,W()})],f()),H("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",J(s.detected.wan,s.saved.wan)],[l?"":$,fe(l,"Auto-detect WAN",y=>{l=y,W()})])]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},c?["Internet like a home device",w()?[" · leaves through ",e("span",{class:"dl-mono"},w())]:""]:w()?["Internet straight to ",e("span",{class:"dl-mono"},w())]:"No WAN found"),ge(me)])]),E=xe([["off","Off"],["all","Everyone"],["circles","Circles"]],m,{label:"Devices reach each other",cls:"sm",optimistic:!1,onChange:async y=>{let B={off:"Off",all:"Everyone",circles:"Circles"}[y];await U(()=>S.serverUpdate(a,{mesh:y}),`Devices reach each other: ${B}`)&&(m=y,s.config.mesh=y,W(),await o())}}),k=e("section",{class:"dl-setsec dl-ifcard"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Home network"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-sub"},"People with Home or Both"),D([g("reset")," Rescan"],()=>b(!1),"neutral",{title:"Read the interfaces again"})]),H("network","Networks","Everyone with home access reaches these, unless their page leaves one out; their devices can be reached from here too. Click one to add or remove it.","","",te()),H("link","Devices reach each other",P[m],E,"",m==="circles"?_o(r,a,o):void 0),h.el]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub dl-if-summary"},q.length?["Home access reaches ",...q.flatMap(([y,B],Y)=>[Y?", ":"",e("span",{class:"dl-mono"},y),` (${B})`])]:"No home network: Home access reaches nothing but this router."),ge(ie)])]),z=window.scrollY;i.style.minHeight=`${i.offsetHeight}px`,dom.content(i,[M,k]),i.style.minHeight="",window.scrollTo({top:z})}function te(){let $=s.devices.filter(A),G=s.devices.filter(q=>!A(q));return e("div",{class:"dl-stack gap8 dl-netpick"},[$.length?e("div",{class:"dl-ifgrid"},$.map(u)):e("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),e("label",{class:"dl-boxrow"},[e("span",{class:"dl-stack"},[e("span",{},"Auto-detect LAN"),e("span",{class:"dl-sub"},["Adds the LAN this router uses.",J(s.detected.lan,s.saved.lan)])]),fe(p,"Auto-detect LAN",q=>{p=q,W()})]),G.length?e("details",{class:"dl-params",open:v?"":null,toggle:q=>v=q.currentTarget.open},[e("summary",{},[g("chevron"),e("span",{},"Other interfaces"),e("span",{class:"dl-pcount"},String(G.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},"The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network."),...Hr.map(([q,oe])=>{let O=G.filter(F=>F.category===q);return O.length?e("div",{class:"dl-ifgroup"},[e("h4",{},oe),e("div",{class:"dl-ifgrid"},O.map(u))]):""})])]):""])}return b(!0),{el:i,update($){r=$,h.update($),s&&W()}}}var zo="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl",Br="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",Or="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",jr={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Dt=null;function Ur(n){let t=window;return n.appendChild(e("link",{rel:"stylesheet",href:`${zo}.css`})),t.maplibregl?Promise.resolve(t.maplibregl):Dt||(Dt=new Promise((o,a)=>{let r=e("script",{src:`${zo}.js`});r.onload=()=>t.maplibregl?o(t.maplibregl):a(new Error("MapLibre failed to load")),r.onerror=()=>{Dt=null,a(new Error("Could not load the map library (no internet access from this browser?)"))},n.appendChild(r)}),Dt)}function en(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}function Wr(n,t,o=48){let a=(n[0]+t[0])/2,r=(n[1]+t[1])/2,i=t[0]-n[0],s=t[1]-n[1],l=Math.hypot(i,s)||1,d=Math.min(.25*l,12),p=a-s/l*d,c=r+i/l*d,m=[];for(let v=0;v<=o;v++){let h=v/o,x=1-h;m.push([x*x*n[0]+2*x*h*p+h*h*t[0],x*x*n[1]+2*x*h*c+h*h*t[1]])}return m}function Gr(n,t){let o=new Map;for(let a of n.geo.points){if(n.person&&a.person!==n.person||(t==="online"?!a.online:n.now-a.ts>jr[t]))continue;let r=o.get(a.device);(!r||a.online&&!r.online||a.online===r.online&&a.ts>r.ts)&&o.set(a.device,a)}return[...o.values()]}var gt=class{constructor(t,o="online",a=380){this.cb=t;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.anim=0;this.data=null;this.fitted=!1;this.range=o,this.status=e("div",{class:"dl-map-status"}),this.el=e("div",{class:"dl-geomap",style:`height:${a}px`},this.status)}async mount(t){this.data=t;try{this.gl=await Ur(this.el)}catch(o){this.status.textContent=o.message;return}this.map=new this.gl.Map({container:this.el,style:en()?Br:Or,center:[t.geo.home?.lon??20,t.geo.home?.lat??50],zoom:3,attributionControl:{compact:!0},dragRotate:!1,pitchWithRotate:!1,cooperativeGestures:!0}),this.map.addControl(new this.gl.NavigationControl({showCompass:!1}),"bottom-right"),this.map.on("load",()=>{this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],"#40c977",en()?"#ededed":"#0d0d0d"],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],"#40c977",en()?"#ededed":"#0d0d0d"],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],!1],layout:{"line-cap":"round"},paint:{"line-color":en()?"#ededed":"#0d0d0d","line-opacity":.35,"line-width":1.5,"line-dasharray":[2,3]}}),this.map.addLayer({id:"dl-arc-glow",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#40c977","line-opacity":.18,"line-width":7}}),this.map.addLayer({id:"dl-arc-live",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#40c977","line-width":2}}),this.map.addLayer({id:"dl-arc-flow",type:"line",source:"dl-arcs",filter:["==",["get","online"],!0],layout:{"line-cap":"round"},paint:{"line-color":"#ffffff","line-width":2,"line-opacity":.8,"line-dasharray":[0,4,3]}}),this.animate(),this.draw()})}setRange(t){this.range=t,this.fitted=!1,this.draw()}update(t){this.data=t,this.draw()}destroy(){cancelAnimationFrame(this.anim),this.map?.remove(),this.map=null}animate(){let t=[[0,4,3],[.5,4,2.5],[1,4,2],[1.5,4,1.5],[2,4,1],[2.5,4,.5],[3,4,0],[0,.5,3,3.5],[0,1,3,3],[0,1.5,3,2.5],[0,2,3,2],[0,2.5,3,1.5],[0,3,3,1],[0,3.5,3,.5]],o=-1,a=0,r=i=>{this.map&&(i-a>70&&(a=i,o=(o+1)%t.length,this.map.getLayer("dl-arc-flow")&&this.map.setPaintProperty("dl-arc-flow","line-dasharray",t[o])),this.anim=requestAnimationFrame(r))};this.anim=requestAnimationFrame(r)}groups(t){let o=new Map;for(let a of t){let r=`${a.asn||a.org||a.ip}|${a.city}|${a.cc}`,i=o.get(r);i||(i={key:r,lat:a.lat,lon:a.lon,city:a.city,country:a.country,cc:a.cc,asn:a.asn,org:a.org,online:!1,ts:0,points:[]},o.set(r,i)),i.points.push(a),i.online||(i.online=a.online),i.ts=Math.max(i.ts,a.ts)}return[...o.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let t=this.data,o=this.groups(Gr(t,this.range)),a=t.geo.home;for(let s of this.markers)s.remove();this.markers=[];let r=new Map,i=o.map(s=>{let l=`${s.lat.toFixed(2)},${s.lon.toFixed(2)}`,d=r.get(l)??0;return r.set(l,d+1),{g:s,at:[s.lon+d*.25,s.lat]}});if(this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:i.map(({g:s,at:l})=>({type:"Feature",properties:{online:s.online},geometry:{type:"Point",coordinates:l}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:a?i.map(({g:s,at:l})=>({type:"Feature",properties:{online:s.online},geometry:{type:"LineString",coordinates:Wr([a.lon,a.lat],l)}})):[]}),a){let s=e("div",{class:"dl-mk-home",title:`Home router${a.city?` · ${a.city}`:""}${a.org?` · ${a.org}`:""}`});s.innerHTML=bn("home","dl-mk-home-ic"),this.markers.push(new this.gl.Marker({element:s}).setLngLat([a.lon,a.lat]).addTo(this.map))}for(let{g:s,at:l}of i){let d=s.points.length,p=e("button",{type:"button",class:`dl-mk${s.online?" online":""}${d>1?" multi":""}`,"aria-label":`${d} device${d===1?"":"s"} via ${s.org||"unknown network"} in ${s.city||"unknown city"}`},d>1?e("span",{class:"dl-mk-count"},String(d)):e("span",{class:"dl-mk-dot"})),m=!!a&&Math.abs(l[0]-a.lon)<.02&&Math.abs(l[1]-a.lat)<.02?[22,-16]:[0,0];p.addEventListener("click",v=>{v.stopPropagation(),this.openPopup(s,l,m)}),this.markers.push(new this.gl.Marker({element:p,offset:m}).setLngLat(l).addTo(this.map))}if(!this.fitted){let s=i.map(l=>l.at);a&&(s.length===0||this.range!=="online"||i.some(l=>l.g.online))&&s.push([a.lon,a.lat]),this.fit(s),this.fitted=!0}this.status.textContent=i.length||a?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none"}fit(t){if(!t.length)return;let o=(d,p)=>{let c=Math.PI/180,m=(p[1]-d[1])*c,v=(p[0]-d[0])*c,h=Math.sin(m/2)**2+Math.cos(d[1]*c)*Math.cos(p[1]*c)*Math.sin(v/2)**2;return 12742*Math.asin(Math.sqrt(h))},a=[t.reduce((d,p)=>d+p[0],0)/t.length,t.reduce((d,p)=>d+p[1],0)/t.length],r=t;if(t.length>=5){let d=[...t].sort((p,c)=>o(a,p)-o(a,c));r=d.slice(0,Math.ceil(d.length*.9))}if(Math.max(...r.map(d=>o(a,d)))<25){this.map.jumpTo({center:a,zoom:9.5});return}let s=new this.gl.LngLatBounds(r[0],r[0]);r.forEach(d=>s.extend(d));let l=this.el.clientHeight||380;this.map.fitBounds(s,{padding:{top:Math.min(90,l/4),bottom:Math.min(70,l/5),left:60,right:60},maxZoom:9,duration:0})}openPopup(t,o,a=[0,0]){let r=this.data;this.popup?.remove();let i=[t.city,t.cc||t.country].filter(Boolean).join(", "),s=[...new Set(t.points.map(c=>c.person))],l=t.points.sort((c,m)=>Number(m.online)-Number(c.online)||m.ts-c.ts).map(c=>{let m=r.people.find(h=>h.id===c.person),v=m?.devices.find(h=>h.id===c.device);return e("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(c.person,c.device)},[e("span",{class:`dl-pop-dot${c.online?" on":""}`}),e("span",{class:"dl-pop-name"},[e("b",{},m?.name??c.person),` · ${v?.name??"device"}`]),e("span",{class:"dl-faint dl-nowrap"},c.online?"now":de(c.ts,r.now))])}),d=e("div",{class:"dl-pop"},[e("div",{class:"dl-pop-head"},[e("span",{class:"dl-pop-net"},g("globe")),e("div",{class:"dl-stack"},[e("strong",{},t.org||"Unknown network"),e("span",{class:"dl-faint"},[t.asn?`AS${t.asn} · `:"",i?`${i} · approximate`:"approximate location"])])]),e("div",{class:"dl-pop-list"},l),s.length===1?e("div",{class:"dl-pop-actions"},[e("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(s[0])},`Open ${r.people.find(c=>c.id===s[0])?.name??"person"}`)]):""]),p=this.el.clientHeight||380;this.map.easeTo({center:o,offset:[0,Math.min(140,p*.32)],duration:300}),this.popup=new this.gl.Popup({offset:[a[0],a[1]-18],anchor:"bottom",closeButton:!1,focusAfterOpen:!1,maxWidth:"300px",className:"dl-popup"}).setLngLat(o).setDOMContent(d).addTo(this.map)}};function tn(n,t,o=!0){let a=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],r=e("div",{class:"dl-seg",role:"tablist"});for(let[i,s]of a)i==="online"&&!o||r.appendChild(e("button",{type:"button",role:"tab",class:i===n?"on":"","data-v":i,click:()=>{r.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===i)),t(i)}},s));return r}var qr={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",paused_all:"warn",resumed_all:"ok",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},Fr={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play",paused_all:"pause",resumed_all:"play"};function Kr(n,t){return t.device?n.people.flatMap(a=>a.devices).find(a=>a.id===t.device)?.kind??t.dkind??"other":Fr[t.type]??"activity"}function An(n,t){let o=n.people.find(x=>x.id===t.person),a=o?.name??t.pname??t.person??"",r=o?.devices.find(x=>x.id===t.device)?.name??t.dname??"",i=x=>e("b",{},x),s=x=>e("span",{class:"dl-muted"},x),l=x=>e("span",{class:"dl-mono"},x),d=x=>t.hosts?.[x]?[e("span",{class:"dl-ev-host"},[e("b",{},t.hosts[x]),e("span",{class:"dl-faint"},` (${x})`)])]:[l(x)],p=x=>e("span",{class:"dl-ev-kind"},`${x} `),c=r?`${a} · ${r}`:a,m=oo(t),v=m||r||"a device",h=x=>[e("span",{class:"dl-you"},"You"),s(` ${x} `)];if(Le(t)==="admin")switch(t.type){case"device_added":return[...h("added"),p("device"),i(v),s(" for "),i(a)];case"device_removed":return[...h("removed"),p("device"),i(v),s(" from "),i(a)];case"paused":return[...h("paused"),p("person"),i(a)];case"resumed":return[...h("resumed"),p("person"),i(a)];case"device_changed":{let x=m.startsWith("renamed from ");return[...h(x?"renamed":m),p("device"),i(r||"a device"),s(" of "),i(a),...x?[s(` · was ${m.slice(13)}`)]:[]]}case"device_keys":return[...h("issued new keys for"),p("device"),i(v),s(" of "),i(a),s(" · it needs its new configuration")];case"link_changed":return[...h("issued a new link for"),p("person"),i(a),s(" · the old link stopped working")];case"paused_all":return[e("span",{class:"dl-you"},"You"),s(" paused everyone")];case"resumed_all":return[e("span",{class:"dl-you"},"You"),s(" resumed everyone")]}switch(t.type){case"connect":return[p("Device"),i(c),s(" connected"),...t.detail?[s(" from "),...d(t.detail)]:[],...t.where?[s(` · ${t.where}`)]:[]];case"disconnect":return[p("Device"),i(c),s(" went offline")];case"roam":return[p("Device"),i(c),s(" changed network "),...(t.detail??"").split(" → ").flatMap((x,R)=>R?[s(" → "),...d(x)]:d(x))];case"device_added":return[p("Person"),i(a),s(" added "),p("device"),i(v),...Le(t)==="portal"?[s(" on their portal")]:[]];case"device_removed":return[p("Person"),i(a),s(" removed "),p("device"),i(v),...Le(t)==="portal"?[s(" on their portal")]:[]];case"device_keys":return[p("Person"),i(a),s(" issued new keys for "),p("device"),i(v),s(" on their portal")];case"person_added":return[...h("added"),p("person"),i(t.detail??a)];case"person_removed":return[...h("removed"),p("person"),i(t.detail??a)];case"person_changed":return[...h("changed"),p("person"),i(a),...m?[s(` · ${m.replace(/_/g," ")}`)]:[]];case"paused":return[p("Person"),i(a),s(` paused — ${t.detail??""}`)];case"resumed":return[p("Person"),i(a),s(" resumed"),...t.detail&&t.detail!=="active"?[s(` — ${t.detail}`)]:[]];case"paused_all":return[s("Everyone paused")];case"resumed_all":return[s("Everyone resumed")];case"portal_blocked":return[e("b",{class:"dl-sys-src"},"Personal portal"),s(" blocked "),l(t.detail??""),s(" for 15 min after too many wrong codes")];case"devices_removed":return[p("Person"),i(a),s(" — all devices removed, end date reached")];default:return[s(`${t.type}${t.detail?`: ${t.detail}`:""}`)]}}var Jr={portal_blocked:["globe","bad"]};function Vr(n,t){if(n.servers.length<2||!t.person)return"";let o=n.people.find(r=>r.id===t.person),a=o&&n.servers.find(r=>r.id===o.server);return a?e("span",{class:"dl-ev-srv",title:"Server"},a.name):""}function Ye(n,t,o={}){let a=Jr[t.type],r=Le(t);return e("div",{class:`dl-row${r==="admin"?" dl-ev-by-admin":a?` dl-ev-by-system ${a[1]}`:""}`},[r==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):a?e("span",{class:"dl-ev-tile sys"},g(a[0])):e("span",{class:`dl-ev-tile ev ${qr[t.type]??""}`},g(Kr(n,t))),e("span",{class:"dl-row-main"},An(n,t)),o.server===!1?"":Vr(n,t),e("span",{class:"dl-faint dl-nowrap",title:new Date(t.ts*1e3).toLocaleString()},o.time??de(t.ts,n.now))])}var Yr={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},Qr={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function nn(n,t,o,a){let r=n.by==="admin",i=e("div",{class:`dl-row dl-slog-row ${r?"dl-ev-by-admin":`dl-ev-by-system ${Yr[n.level]??""}`}${n.detail?" has-detail":""}`},[r?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):e("span",{class:"dl-ev-tile sys",title:n.level},g(Qr[n.src]??"zap")),e("span",{class:"dl-row-main"},r?[e("span",{class:"dl-you"},"You"),e("span",{class:"dl-muted"},` ${n.msg} `),n.kind?e("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?e("b",{},n.who):"",n.note?e("span",{class:"dl-muted"},` · ${n.note}`):"",n.detail?e("span",{class:`dl-slog-more${t?" open":""}`},g("chevron")):"",n.detail&&t?e("pre",{class:"dl-slog-detail"},n.detail):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?e("span",{class:"dl-ev-kind"},"Server "):"",e("b",{class:"dl-sys-src",title:_t[n.src]??n.src},n.who??_t[n.src]??n.src)," ",e("span",{class:"dl-muted"},n.msg),n.detail?e("span",{class:`dl-slog-more${t?" open":""}`},g("chevron")):"",n.detail&&t?e("pre",{class:"dl-slog-detail"},n.detail):""]),e("span",{class:"dl-faint dl-nowrap",title:new Date(n.ts*1e3).toLocaleString()},a)]);return n.detail&&i.addEventListener("click",s=>{s.target.closest("pre")||o()}),i}function No(n){let t=new Date(n*1e3),o=new Date,a=new Date;return a.setDate(o.getDate()-1),t.toDateString()===o.toDateString()?"Today":t.toDateString()===a.toDateString()?"Yesterday":t.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}var vt=n=>lt(n).toLocaleDateString("en-GB",{day:"numeric",month:"short"});function on(n,t,o){let a=n.slice(-15),r=a[a.length-1],i=r&&t-r[0]<180,s=i?r[2]:0,l=i?r[1]:0,[d,p]=o,c=200,m=40,v=Math.max(1,...a.map(w=>Math.max(w[1],w[2]))),h=w=>a.map((I,C)=>`${a.length>1?C/(a.length-1)*c:c},${m-2-I[w]/v*(m-6)}`),x=h(2),R=h(1),_=a.length>1?qe(``):e("div",{class:"dl-speed-wait"},[e("i"),e("span",{},"Collecting… 1 point a minute")]),j=(w,I,C,T)=>e("div",{class:"dl-speed-col"},[e("span",{class:"dl-sub"},[e("span",{class:C},I),` ${w}`]),e("span",{class:"dl-speed-val"},Pe(T))]);return a.length>1&&ue(_,()=>{let w=a[a.length-1];return[e("div",{class:"dl-tip-title"},new Date(w[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),e("div",{},`↓ ${Pe(w[2])} · ↑ ${Pe(w[1])}`)]}),e("div",{class:"dl-bento-tile"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Speed now"),e("span",{class:"dl-sub"},"last 15 min")]),e("div",{class:"dl-speed-cols"},[j("Download","↓","dl-dn",s),j("Upload","↑","dl-up",l)]),_,e("div",{class:"dl-speed-today"},[e("span",{},["Today ",e("b",{},ee(d+p))]),e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${ee(p)} `,e("span",{class:"dl-up"},"↑"),` ${ee(d)}`])])])}function an(n,t){let o=n.slice(-30),a=o.map(d=>d.rx+d.tx),r=Math.max(1,...a),i=a.reduce((d,p)=>d+p,0),s=a.reduce((d,p,c)=>p>a[d]?c:d,0),l=e("div",{class:"dl-bento-bars"},o.map((d,p)=>{let c=a[p],m=e("i",{class:p===o.length-1?"hi":"",style:`height:${Math.max(4,c/r*100)}%`});return ue(m,()=>[e("div",{class:"dl-tip-title"},p===o.length-1?`Today · ${vt(d.day)}`:vt(d.day)),e("div",{},ee(c)),e("div",{class:"dl-muted dl-mono"},`↓ ${ee(d.tx)} ↑ ${ee(d.rx)}`)]),m}));return e("div",{class:"dl-bento-tile month"},[e("div",{class:"dl-bento-head"},[e("span",{},[e("span",{class:"dl-metric-label"},"Last 30 days"),e("b",{class:"dl-bento-total"},ee(i))]),a[s]>0?e("span",{class:"dl-sub"},`peak ${ee(a[s])} · ${vt(o[s].day)}`):""]),o.length?l:e("p",{class:"dl-muted"},"No traffic yet."),e("div",{class:"dl-bento-head"},[e("span",{class:"dl-sub"},o.length?vt(o[0].day):""),e("span",{class:"dl-sub"},t),e("span",{class:"dl-sub"},"today")])])}function Ro(n){let t=n.slice(-30),o=t.map(r=>r.rx+r.tx),a=Math.max(1,...o);return e("div",{class:"dl-dbars"},t.map((r,i)=>{let s=e("i",{class:`${o[i]?"":"zero"}${i===t.length-1?" hi":""}`});return s.style.height=`${Math.max(8,o[i]/a*100)}%`,ue(s,()=>[e("div",{class:"dl-tip-title"},i===t.length-1?`Today · ${vt(r.day)}`:vt(r.day)),e("div",{},ee(o[i]))]),s}))}var Ho={apply:"Repair",sync:"Reload devices",restart:"Restart service",netrestart:"Restart network",updates:"Open Components"};async function rn(n){return n==="netrestart"&&!await ne("Restart the network?","Every interface restarts. Connections drop for a few seconds.","Restart network")?null:await U(()=>S.healthFix(n),"Done")??null}function zn(n,t,o,a="action"){let r=n.fix;return r?r.startsWith("install:")?D("Install",()=>Do(r.slice(8),o),a):r==="updates"?e("a",{class:`cbi-button cbi-button-${a}`,href:L.url("admin/network/dawnline/updates")},Ho.updates):D(Ho[r]??"Fix",()=>t(r),a):""}function Zr(n){return/^(awg|up_|peers_|fw_|reply_|port_|subnet_)/.test(n)?"shield":/^(portal|cert)/.test(n)?"link":/^(ep_|home_|resolver)/.test(n)?"globe":n==="clock"?"clock":n==="agent"?"activity":n==="nft"?"lock":"alert"}function Io(n,t,o,a=3){let r=n.filter(s=>s.status==="error"||s.status==="warn").sort((s,l)=>s.status===l.status?0:s.status==="error"?-1:1);if(!r.length)return"";let i=r.length-a;return e("div",{class:"dl-list dl-notices"},[...r.slice(0,a).map(s=>tt(Zr(s.id),s.status==="error"?"bad":"warn",s.problem??s.title,s.detail,zn(s,t,o,s.status==="error"?"positive":"neutral"))),i>0?e("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[`${i} more in Diagnostics`,e("span",{class:"dl-spacer"}),"→"]):""])}function Xr(n){let t=[],o=(s,l)=>e("a",{href:s},l),a=Ne(n.series),r=!!n.awg_state&&!n.awg_state.ok;for(let s of n.servers)s.enabled&&s.blocked?t.push({tone:"bad",text:[`${s.name} ${s.blocked}. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]}):s.enabled&&!s.up&&!r&&t.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});n.settings.paused_all&&t.push({tone:"warn",text:["Everyone is paused."]});for(let s of n.people)if(s.state==="quota")t.push({tone:"warn",text:[o(Te(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")t.push({tone:"warn",text:[o(Te(s.id),s.name),"’s access has ended."]});else{let l=Xe(s.expires,a);l!=null&&l>=0&&l<=Math.max(s.expire_warn,3)&&t.push({tone:"",text:[o(Te(s.id),s.name),`’s access ends in ${l} day${l===1?"":"s"}.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&t.push({tone:"",text:[o(Te(s.id),s.name)," has used 90% of the data limit."]})}let i=n.people.flatMap(s=>s.devices.filter(l=>l.config_stale).map(l=>[s,l]));return i.length&&t.push({tone:"warn",text:i.length===1?[o(Te(i[0][0].id,i[0][1].id),`${i[0][0].name} · ${i[0][1].name}`)," needs its configuration again."]:[`${i.length} devices need their configuration again (networks or DNS changed).`]}),n.servers.some(s=>s.lan_like)&&n.like_home.error&&t.push({tone:"warn",text:[`Internet through the LAN is off: ${n.like_home.error} `,o(L.url("admin/network/dawnline/diagnostics"),"Details")]}),n.settings.portal_enabled||t.push({tone:"",text:["The personal portal is off. ",o(L.url("admin/network/dawnline/settings"),"Turn on")]}),t}var sn=class{constructor(t,o){this.srvId=t;this.go=o;this.el=e("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(t){this.st=Tt(t,this.srvId);for(let o of["health","bento","side","activity"])this.parts[o]=e("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.mapCard(),e("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(t,o=!1){this.st=Tt(t,this.srvId),this.paint(o),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let t=await S.health().catch(()=>null);if(!t)return;let o=()=>void this.loadHealth(),a=async r=>{await rn(r)&&(o(),r==="netrestart"&&setTimeout(o,5e3))};_e(this.parts.health,Io(t.checks,r=>void a(r),o),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let t=this.st,o=e("div",{class:"dl-panel-head pad"},[e("div",{class:"dl-stack"},[e("h3",{},"Where people connect from"),e("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),e("span",{class:"dl-spacer"}),tn(this.range,i=>{this.range=i,this.map?.setRange(i)})]);if(!t.geo.enabled)return e("div",{class:"dl-panel flush"},[o,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);this.map=new gt({openPerson:i=>location.href=Te(i),openDevice:(i,s)=>location.href=Te(i,s)},this.range);let a=e("div",{class:"dl-map-legend"},[e("span",{},[e("i",{class:"dot ok"}),"Online"]),e("span",{},[e("i",{class:"dot"}),"Seen recently"]),e("span",{},[e("i",{class:"line"}),"Live tunnel"])]),r=e("div",{class:"dl-map-wrap"},[this.map.el,a]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[o,r])}paint(t=!1){let o=this.st,a=o.servers[0],r=o.people.reduce((l,d)=>l+Math.max(0,d.device_limit-d.devices.length),0);_e(this.parts.bento,e("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Re(a).overviewTile(a),this.monthTile(r)]),t);let i=Xr(o);_e(this.parts.side,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Needs attention"),e("span",{class:"dl-spacer"}),e("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),i.length?i.slice(0,8).map(l=>e("div",{class:"dl-attn-item dl-row"},[e("span",{class:`dl-ev-dot ${l.tone}`}),e("span",{},l.text),l.action??""])):e("div",{class:"dl-row dl-muted"},[g("check"),"All good. Nothing needs you right now."])]),t);let s=[...o.events].reverse().slice(0,8);_e(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-spacer"}),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),s.length?s.map(l=>Ye(o,l)):e("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]),t)}onlineTile(){let t=this.st,o=12,a=_=>_.spark[_.spark.length-1]??0,r=_=>t.geo.points.find(j=>j.device===_.id&&j.city)?.city,i=_=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(_.endpoint??""),s=_=>(i(_)?"home":r(_))??"",l=_=>[...t.events].reverse().find(j=>j.type==="connect"&&j.device===_.id)?.ts??0,d=t.people.map(_=>({p:_,devs:_.devices.filter(j=>j.online).sort((j,w)=>a(w)-a(j))})).filter(_=>_.devs.length).sort((_,j)=>j.devs.reduce((w,I)=>w+a(I),0)-_.devs.reduce((w,I)=>w+a(I),0)),p=d.length<=2,c=({p:_,devs:j})=>{let w=j.map(l).filter(Boolean),I=w.length?Math.min(...w):0,C=(_.rate??[]).slice(-15),T=C[C.length-1],b=T&&t.now-T[0]<180?T:null,A=200,u=30,f=Math.max(1,...C.map(W=>Math.max(W[1],W[2]))),N=W=>C.map((te,$)=>`${C.length>1?$/(C.length-1)*A:A},${u-2-te[W]/f*(u-6)}`),P=C.length>1?qe(``):"",H=!b||b[1]<64&&b[2]<64,J=_.access==="both"?["home","globe"]:_.access==="lan"?["home"]:["globe"];return[e("div",{class:"dl-hc"},[e("div",{class:"dl-hc-head"},[e("span",{class:"dl-onl-av sm"},Oe(_.name)),e("span",{class:"dl-stack"},[e("b",{},_.name),e("span",{class:"dl-hc-since"},I?`online for ${de(I,t.now).replace(" ago","")}`:"online")]),e("span",{class:"dl-hc-reach"},J.map(W=>e("span",{class:`dl-ibadge ${W==="home"?"lan":"inet"}`},g(W))))]),e("div",{class:"dl-hc-speed"},[e("div",{class:"dl-hc-speed-row"},H?[e("span",{class:"dl-faint"},"Idle right now")]:[e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${Pe(b[2])}`]),e("span",{},[e("span",{class:"dl-up"},"↑"),` ${Pe(b[1])}`]),e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint"},"15 min")]),P]),e("div",{class:"dl-hc-devs"},j.map(W=>e("span",{class:"dl-hc-dev"},[g(W.kind),[W.name,s(W)].filter(Boolean).join(" · ")]))),e("div",{class:"dl-hc-foot"},[e("span",{class:"dl-faint"},`${ee(j.reduce((W,te)=>W+a(te),0))} today · ${ee(_.month[0]+_.month[1])} this month`)])])]},m=_=>{let{p:j,devs:w}=_,I=e("span",{class:"dl-onl-dev"},w.length>1?String(w.length):g(w[0].kind)),C=e("a",{class:`dl-onl-p${p?"":" sm"}`,href:Te(j.id),"aria-label":`${j.name}, online`},[e("span",{class:"dl-onl-av"},[Oe(j.name),I]),p?e("span",{class:"dl-onl-name"},j.name):"",p?e("span",{class:"dl-onl-meta"},[...w.slice(0,3).map(T=>g(T.kind)),w.length>3?`+${w.length-3}`:"",s(w[0])?e("span",{},` · ${s(w[0])}`):""]):""]);return ue(C,()=>c(_)),C},v=e("b",{class:`dl-onl-count${d.length?"":" none"}`},String(d.length)),h=d.reduce((_,j)=>_+j.devs.length,0);d.length&&ue(v,()=>[`${d.length} ${d.length===1?"person":"people"} · ${h} device${h===1?"":"s"}`]);let x=d.length>o?d.slice(0,o-1):d,R=t.people.flatMap(_=>_.devices.map(j=>({p:_,d:j}))).filter(_=>_.d.handshake).sort((_,j)=>j.d.handshake-_.d.handshake)[0];return e("div",{class:"dl-bento-tile online"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Online"),v]),d.length?e("div",{class:`dl-onl-row${p?"":" grid"}`},[...x.map(m),d.length>o?e("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:"Everyone online",click:_=>{this.go&&(_.preventDefault(),this.go("people","online"))}},[e("span",{class:"dl-onl-av"},`+${d.length-x.length}`)]):""]):e("div",{class:"dl-onl-empty"},[e("span",{},"Nobody is connected"),R?e("span",{class:"dl-sub"},`Last: ${R.p.name}, ${de(R.d.handshake,t.now)}`):e("span",{class:"dl-sub"},"No device has connected yet")])])}speedTile(){return on(this.st.servers[0]?.rate??[],this.st.now,this.st.totals.today)}monthTile(t){let o=this.st.totals,a=this.st.people.filter(r=>r.state!=="active").length;return an(this.st.series,`${o.people} ${o.people===1?"person":"people"}${a?` · ${a} paused`:""} · ${t} device slot${t===1?"":"s"} free`)}};var Bo=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["awg",""]],ei={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},Nn=(n,t)=>{let o=new URLSearchParams;n&&o.set("server",n),t&&t!=="overview"&&o.set("section",t);let a=o.toString();return`${L.url("admin/network/dawnline/server")}${a?`?${a}`:""}`},At=class{constructor(){this.noFooter=!0;this.root=e("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=e("div",{});this.headEl=e("div",{});this.secEl=e("div",{});this.bodyEl=e("div",{class:"dl-srvbody"})}async load(){let t=await S.status(31),o=t.servers.length?null:await S.setupDefaults();return[t,o]}render([t,o]){if(this.st=t,!t.servers.length&&o)return this.wizard(o);let a=new URLSearchParams(location.search),r=a.get("section")??"",i=ei[r]??r;return Bo.some(([s])=>s===i)&&(this.section=i),this.srvId=(t.servers.find(s=>s.id===a.get("server"))??t.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller=Ke({fetch:()=>S.status(31),every:30,live:!0,active:()=>this.section==="overview"&&this.root.isConnected,apply:(s,l)=>{s.servers.length&&(this.st=s,this.paintHead(l),this.ov[this.current().id]?.update(s,l))}}),this.root}paintHead(t=!1){_e(this.headEl,this.head(this.current()),t),(!t||!ft(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let t=await S.status(31).catch(()=>null);return t?.servers.length?(this.st=t,this.paintHead(),t):null}current(){return this.st.servers.find(t=>t.id===this.srvId)??this.st.servers[0]}async refresh(){let t=await S.status(31).catch(()=>null);t&&(this.st=t,t.servers.length?this.paint():location.href=Nn())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let t=this.current();dom.content(this.tabsEl,e("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(o=>e("button",{type:"button",role:"tab",class:`dl-srvtab${o.id===t.id?" on":""}`,"aria-selected":o.id===t.id?"true":"false",click:()=>{o.id!==this.srvId&&(this.srvId=o.id,this.paint())}},[e("i",{class:`dot ${o.up?"ok":"bad"}`}),e("b",{},o.name)])),e("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[g("plus"),"Add server"])]))}paintSections(){let t=Re(this.current());dom.content(this.secEl,e("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},Bo.map(([o,a])=>e("button",{type:"button",role:"tab","data-section":o,class:o===this.section?"on":"","aria-selected":o===this.section?"true":"false",click:()=>this.showSection(o)},o==="awg"?t.label:a))))}go(t,o){let a=this.pp[this.current().id];if(o&&a)a.filter=o,a.el&&a.decorate();else if(o){let r=this.pp[this.current().id]=new at;r.filter=o}this.showSection(t),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let t=[...Object.values(this.ov).map(o=>o.el),...Object.values(this.pp).map(o=>o.el)];for(let o of t)o&&this.bodyEl.contains(o)&&o.remove()}showSection(t){this.section=t,this.secEl.querySelectorAll("[data-section]").forEach(s=>{let l=s.dataset.section===t;s.classList.toggle("on",l),s.setAttribute("aria-selected",l?"true":"false")});let o=this.st,a=this.current(),i={overview:()=>{let s=this.ov[a.id];return s?(s.update(o),s.el):(this.ov[a.id]=new sn(a.id,(l,d)=>this.go(l,d))).mount(o)},people:()=>{var p,c;let s=this.pp[a.id];if(s?.el)return s.update(),s.el;let l=e("div",{},e("p",{class:"dl-muted"},"Loading people…"));return((p=this.pp)[c=a.id]??(p[c]=new at)).embed(o,a.id).then(m=>{l.isConnected?dom.content(l,m):l.replaceChildren(m)}).catch(m=>{delete this.pp[a.id],dom.content(l,e("p",{class:"dl-muted"},`Couldn't show people: ${ve(m)}`))}),l},connection:()=>this.connection(a),access:()=>this.access(a),awg:()=>this.awg(a)}[t]();this.detachKept(),dom.content(this.bodyEl,i)}head(t){let o=this.st,a=(l,d)=>e("span",{class:"dl-addrbar-seg"},[g(l),...d]),r=t.endpoint||"—",i=!t.enabled||o.settings.paused_all,s=e("div",{class:"dl-actions"},[i?D([g("play")," Turn on"],async()=>{o.settings.paused_all&&!await U(()=>S.pauseAll(!1))||(t.enabled?await this.refresh():await this.save(t,{enabled:"1"},"Server turned on"))},"positive"):""]);return e("div",{class:"dl-srvpagehead"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),e("span",{class:`dl-pill ${t.enabled?t.up?"ok":"bad":"off"}`},t.enabled?t.up?"Running":t.blocked?"Can’t start":"Not running":"Turned off"),o.settings.paused_all&&t.enabled?e("span",{class:"dl-pill warn"},"Off"):"",e("span",{class:"dl-spacer"}),s]),e("div",{class:"dl-addrbar"},[e("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address",click:()=>pe(r,"Address copied")},[g("globe"),e("span",{class:"dl-mono"},r),g("copy")]),a("tunnel",[e("span",{class:"dl-mono"},`${Re(t).label} :${t.port}`)]),t.up?a("clock",[`up ${st(t.uptime)}`]):""]),t.blocked?e("div",{class:"dl-note warn"},[g("alert"),e("span",{},`${t.name} ${t.blocked}.`)]):""])}async save(t,o,a="Saved"){await U(()=>S.serverUpdate(t.id,o),a)&&await this.refresh()}connection(t){let o=re(t.name,{placeholder:"Home"}),a=re(t.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),r=re(t.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),i=this.st.people.filter(l=>l.server===t.id).length,s=D(t.enabled?"Turn off":"Turn on",async()=>{t.enabled&&!await ne(`Turn off ${t.name}?`,`The tunnel stops and ${i} ${i===1?"person is":"people are"} disconnected until you turn it back on. Nothing is deleted.`,"Turn off",!0)||await this.save(t,{enabled:t.enabled?"0":"1"},t.enabled?"Server turned off":"Server turned on")},t.enabled?"negative":"positive");return e("div",{class:"dl-stack gap16"},[kt("Connection",[e("p",{class:"dl-muted"},"The name people see, where devices find the router, and DNS. The port is on AmneziaWG."),he("router","Server","What people see",[Z("Name",o,"Shown to people in their portal and apps.")]),he("globe","Devices connect to","Where the router answers from the internet",[Z("Public address",a,"Hostname or IP of the router on the internet. A DDNS name keeps links working when your IP changes. It must not go through Cloudflare: use a DNS-only name or an IP.")]),he("file","For every device","Changing it marks devices “Update config” until they import again",[Z("DNS for devices",r,"Empty = this router, which sends each query where your home network would.")])],[e("span"),D("Save",()=>this.save(t,{name:o.value,endpoint:a.value,dns:r.value}),"positive")]),kt("Danger zone",[e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},t.enabled?"Turn off this server":"This server is off"),e("span",{class:"dl-sub"},t.enabled?"Stops the tunnel and disconnects everyone on it. Settings and people are kept.":"Nobody can connect. Turn it on to bring the tunnel back.")]),e("div",{class:"dl-setrow-ctl"},s)]),e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},"Remove server"),e("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${i} ${i===1?"person":"people"} with all their devices. A backup is made first.`)]),e("div",{class:"dl-setrow-ctl"},D([g("trash")," Remove"],()=>this.remove(t),"negative"))])],[],"danger")])}access(t){let o=Dn(this.st,t),a=Ao(t,this.st,async()=>{let r=await this.refreshStatus();if(!r)return;let i=r.servers.find(l=>l.id===t.id)??t;a.update(r);let s=Dn(r,i);o.replaceWith(s),o=s});return e("div",{class:"dl-stack gap16"},[a.el,e("div",{class:"dl-health-cols"},[o,Eo(this.st,t)])])}awg(t){let o={st:this.st,save:(a,r)=>this.save(t,a,r),refresh:()=>this.refresh()};return e("div",{class:"dl-stack gap16"},[Re(t).settingsCard(o,t)])}async addServer(){let t=await U(()=>S.setupDefaults());t&&dom.content(this.root,this.wizard(t,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async remove(t){let o=this.st.people.filter(a=>a.server===t.id);ae(`Remove ${t.name}?`,[e("p",{},`This removes the tunnel, its firewall rules and ${o.length} ${o.length===1?"person":"people"} with all their devices. A backup is made first.`)],[se()," ",D("Remove",async()=>{le(),await U(()=>S.serverDelete(t.id),"Server removed")&&setTimeout(()=>{location.href=Nn()},800)},"negative")])}wizard(t,o=!1,a){let r={id:t.id,name:t.name,endpoint:t.endpoint,port:t.port,subnet:t.subnet,preset:"standard",portal:!1,portal_port:t.portal_port||8443,lan_like:!0,lan_zone:t.lan_zone,wan_zone:t.wan_zone},i=0,s=e("div",{class:"dl-wizard"}),l=(_,j={})=>{let w=re(String(r[_]),j);return w.addEventListener("input",()=>{r[_]=_==="port"||_==="portal_port"?Number(w.value):w.value.trim()}),w},d={id:"server",title:"Server",render:()=>e("div",{class:"dl-wizard-groups"},[e("p",{class:"dl-muted"},"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),he("router","Server","What people see",[Z("Name",l("name"),"Shown to people in their portal and apps.")]),he("globe","Devices connect to","Where the router answers from the internet",[Z("Public address",l("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),"Hostname or IP address of your router on the internet. Not through Cloudflare: use a DNS-only name or an IP.")])]),check:()=>r.endpoint?null:"Fill in the public address."},p={id:"awg",title:"AmneziaWG",render:()=>e("div",{class:"dl-wizard-groups"},[he("globe","Listening","Where devices reach AmneziaWG from the internet",[Z("UDP port",l("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),"Opened on the WAN firewall automatically. A random high port is fine.")]),he("network","Tunnel network","Addresses devices get inside the tunnel",[Z("Tunnel subnet",l("subnet",{class:"cbi-input-text dl-mono"}),`Must not overlap your networks (${t.taken.join(", ")||"none found"}).`)]),he("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Gt(t.awg,r.preset,_=>r.preset=_,void 0,t.awg_state?.tools!==!1)])]),check:()=>!r.port||!r.subnet?"Fill in the UDP port and subnet.":null},c={id:"portal",title:"Portal",render:()=>{let _=l("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),j=Z("Listening port",_,"TCP port on WAN for the portal; the whole port belongs to it.");j.hidden=!r.portal;let w=xe([["off","Off"],["on","On"]],r.portal?"on":"off",{label:"Personal portal",onChange:I=>{r.portal=I==="on",j.hidden=!r.portal}});return e("div",{class:"dl-wizard-groups"},[he("home","Internet like a home device","How devices reach the internet",[Z("Through the home network",fe(r.lan_like,"Internet like a home device",I=>r.lan_like=I),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),he("link","Personal portal","A page where each person adds their own devices with their personal link",[Z("Portal",w,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),j])])}},m=()=>[d,p,o?null:c].filter(_=>_!=null),v=t.awg_state,h=v?.missing??[],x=h.length?e("div",{class:"dl-list dl-notices"},[tt("shield","bad","AmneziaWG isn’t installed",`The tunnel needs ${h.join(" and ")}. Install the build made for this firmware, then create the server.`,D("Install",()=>Xt(()=>location.reload()),"positive"))]):v&&!v.loaded?e("div",{class:"dl-list dl-notices"},[tt("shield","warn","AmneziaWG’s kernel module doesn’t load on this firmware","Try another build in Components, or update OpenWrt. The server can’t start until it loads.",e("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},"Open Components"))]):"",R=()=>{let _=m();i>=_.length&&(i=_.length-1),dom.content(s,[e("h2",{},o?"Add a server":"Set up Dawnline"),x,e("div",{class:"dl-steps"},_.map((j,w)=>e("span",{class:`dl-step${w===i?" current":w0?D("Back",()=>{i--,R()}):a?D("Cancel",a):"",e("span",{class:"dl-spacer"}),i<_.length-1?D("Next",()=>{let j=_[i].check?.();if(j){Q(j,"warning");return}i++,R()},"positive"):D("Create server",async()=>{for(let w of _){let I=w.check?.();if(I){Q(I,"warning");return}}let j=await U(()=>S.serverCreate(r.id,r.name,t.ifname,r.port,r.subnet,r.endpoint,t.mtu,r.preset,r.lan_zone,r.wan_zone,r.lan_like,o?void 0:r.portal,o?void 0:r.portal_port),"Server created");j&&setTimeout(()=>{location.href=Nn(j.id)},1500)},"positive",{disabled:h.length>0,title:h.length?"Install AmneziaWG first":null})])])};return R(),s}};function Qe(n){let t={el:n(),refresh(){let o=n();t.el.replaceWith(o),t.el=o}};return t}function Me(n,t,o,a,r="",i=[]){return e("section",{class:`dl-setsec ${r}`,id:`dl-set-${n}`},[e("div",{class:"dl-setsec-body"},[i.length?e("div",{class:"dl-setsec-head"},[e("h3",{},t),e("span",{class:"dl-spacer"}),...i]):e("h3",{},t),...o]),a.length?e("div",{class:"dl-setsec-foot"},a):""])}function Oo(n){let t=n.filter(r=>r.status!=="skip"),o=t.filter(r=>r.status==="error"||r.status==="warn"),a=t.some(r=>r.status==="error")?"error":o.length?"warn":"ok";return{bad:o,worst:a}}function jo(n){let t=n.d.settings,o=n.d.effective,a=n.d.cert,r=fe(o.portal_enabled,"Enable portal"),i=re(t.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),s=re(t.portal_title,{placeholder:"Dawnline"}),l=re(t.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),d=re("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),p=O=>/^\d{1,3}(\.\d{1,3}){3}$/.test(O),c=[o.portal_host,...o.portal_alt??[]].filter((O,F,me)=>O&&me.indexOf(O)===F),m=!!n.portal,v=[],h=O=>{O&&!v.some(F=>F.host===O)&&v.push({host:O,kind:p(O)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},x=O=>{v=[...O,...v.filter(F=>!O.some(me=>me.host===F.host))],!c.length&&O[0]&&(c=[O[0].host])};n.portal&&x(n.portal.candidates),c.forEach(h);let R=O=>O.kind==="ip"?e("span",{class:"dl-addr-warn"},[g("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):e("span",{class:"dl-sub"},O.cloudflare?"Behind Cloudflare · often stalls in Russia":O.ips.length?O.here?`Points at this router${O.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${O.ips.join(", ")}, not this router`:m?"Your address":"Checking where it points…"),_=e("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),j=O=>{c.includes(O)?c.length>1&&(c=c.filter(F=>F!==O)):c=[...c,O],w(),C()},w=()=>dom.content(_,[...v.map(O=>{let F=c.includes(O.host),me=c[0]===O.host;return e("div",{class:`dl-addr-opt${F?" on":""}`,role:"checkbox","aria-checked":F?"true":"false",tabindex:"0",click:()=>j(O.host),keydown:ie=>{(ie.key===" "||ie.key==="Enter")&&(ie.preventDefault(),j(O.host))}},[e("i",{class:"dl-addr-check"},F?g("check"):""),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono"},O.host),R(O)]),me?e("span",{class:"dl-pill info"},"Main"):F?e("button",{type:"button",class:"dl-linkbtn",click:ie=>{ie.stopPropagation(),c=[O.host,...c.filter(ge=>ge!==O.host)],w(),C()}},"Make main"):O.cloudflare?e("span",{class:"dl-pill warn"},"Cloudflare"):O.kind==="ip"?e("span",{class:"dl-pill"},"IP"):O.here&&O.cert?e("span",{class:"dl-pill ok"},"Recommended"):""])}),e("div",{class:"dl-addr-opt other"},[e("i",{class:"dl-addr-check"},g("plus")),d,D("Add",()=>{let O=d.value.trim().toLowerCase();O&&(h(O),c.includes(O)||(c=[...c,O]),d.value="",w(),C())})])]);d.addEventListener("keydown",O=>{O.key==="Enter"&&(O.preventDefault(),d.nextElementSibling?.click())});let I=e("div",{class:"dl-links"}),C=()=>{let O=Number(i.value)||o.portal_port;dom.content(I,c.map((F,me)=>{let ie=p(F),ge=ie?O+1:O,M=`${ie?"http":"https"}://${F}${ge===(ie?80:443)?"":`:${ge}`}/`;return e("div",{class:"dl-link-row"},[e("span",{class:`dl-link-ic ${ie?"warn":"ok"}`},g(ie?"alert":"lock")),e("span",{class:"dl-mono dl-link-url"},[M,e("b",{},"kamiro-telosu-bavine")]),me===0?e("span",{class:"dl-pill info"},"Main"):ie?e("span",{class:"dl-pill warn"},"HTTP"):""])}))};w(),C(),i.addEventListener("input",()=>C());let T={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_http:"Plain HTTP",cert:"Certificate"},b=n.d.needs??{https:[],acme:[],home:[]},A=O=>{if(!o.portal_enabled)return e("div",{hidden:!0});if(!O)return he("check","Ready to share","The portal’s checks from Health",[e("p",{class:"dl-muted dl-loading"},"Running checks…")]);let F=O.filter(E=>E.status!=="skip");if(!F.length)return e("div",{hidden:!0});let{bad:me,worst:ie}=Oo(O),ge=e("div",{class:"dl-ready-details",hidden:!0},F.map(E=>e("div",{class:`dl-ready-item ${E.status}`},[g(E.status==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("span",{},E.title),e("span",{class:"dl-sub"},E.detail)])]))),M=e("div",{class:"dl-stack gap8"},[e("div",{class:`dl-ready-sum ${ie}`},[g(ie==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("b",{},ie==="ok"?`All ${F.length} checks passed`:`${F.length-me.length} of ${F.length} checks passed`),me.length?e("span",{class:"dl-sub"},me.map(E=>E.detail).join(" ")):e("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),e("button",{type:"button",class:"dl-linkbtn",click:E=>{ge.hidden=!ge.hidden,E.currentTarget.textContent=ge.hidden?"Details":"Hide"}},"Details")]),e("div",{class:"dl-chips-row"},F.map(E=>e("span",{class:`dl-check-chip ${E.status}`,title:E.detail},[g(E.status==="ok"?"check":"alert"),T[E.id]??E.title]))),ge]);return he("check","Ready to share","The portal’s checks from Health",[M])},u=O=>{if(!o.portal_enabled||!O&&!b.https.length)return e("span",{hidden:!0});if(b.https.length)return e("span",{class:"dl-pill bad"},"Can’t start");let{worst:F}=Oo(O);return e("span",{class:`dl-pill ${F==="ok"?"ok":F==="error"?"bad":"warn"}`},F==="error"?"Needs attention":"Ready")},f=A(n.portal?.checks??null),N=u(n.portal?.checks??null);n.portalFill=O=>{m=!0,x(O.candidates),w(),C();let F=A(O.checks);f.replaceWith(F),f=F;let me=u(O.checks);N.replaceWith(me),N=me};let P=a&&!a.self_signed&&a.expires?Ae(a.expires):"",H=Z("Listening port",i,n.d.port_owners.length?`Port ${o.portal_port} is used by ${n.d.port_owners.join(", ")}.`:`Where the portal runs on the router: HTTPS here, plain HTTP for IP addresses on ${o.portal_port+1}.`),J=!!(t.portal_cert&&t.portal_key),W=a?J?"Your files":a.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",te=()=>{let O=re(t.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),F=re(t.portal_key,{placeholder:"/etc/ssl/…/key"});ae("Use your own certificate",[e("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),Z("Certificate file",O),Z("Key file",F)],[se()," ",D("Save",()=>{le(),n.save({portal_cert:O.value.trim(),portal_key:F.value.trim()},"Certificate saved","portal")},"positive")])},$=(O,F,me,ie,ge,M)=>tt(O,F,me,ie,D(M,()=>Pt(ge,b[ge],()=>n.reload("portal")),"positive")),G=b.https.length?$("lock","bad","HTTPS isn’t available on this router",`The portal needs ${b.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",q=b.acme.length&&(!a||a.self_signed)?$("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${t.portal_host?` for ${t.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",oe=[e("div",{class:"dl-row"},[g("lock"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},[W,P?e("span",{class:"dl-faint"},` · until ${P}`):""]),e("span",{class:"dl-sub dl-ellipsis",title:a?.path??""},a?a.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${J?"Your files":"Found automatically"} · ${a.path}`:"Turn the portal on to see its certificate.")])]),e("div",{class:"dl-row"},[g("file"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},"Your own files"),e("span",{class:"dl-sub"},J?`${t.portal_cert} · ${t.portal_key}`:"Not set: the certificate is picked automatically.")]),J?D("Reset",()=>n.save({portal_cert:"",portal_key:""},"Automatic certificate","portal"),"negative"):"",D(J?"Change":"Use files",te)]),q];return Me("portal","Personal portal",[e("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),G?e("div",{class:"dl-list"},[G]):"",he("network","Port","How the portal listens (80 and 443 stay free)",[H]),he("edit","Appearance","What people see",[Z("Title",s,"Shown at the top of the portal."),Z("Unknown links",l,"Where a wrong or old link goes, for example your website. Empty shows a plain “Not found”.")]),he("link","Addresses","Pick one or more; the first is the main link",[_,e("div",{class:"dl-stack gap8"},[I,e("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),he("lock","Certificate","Used for HTTPS links",oe),f],[e("span"),D("Save",()=>n.save({portal_enabled:Ee(r)?"1":"0",portal_host:c[0]??"",portal_alt:c.slice(1),portal_port:i.value,portal_title:s.value,portal_redirect:l.value.trim()},"Saved","portal"),"positive")],"",[N,r])}function Uo(n){let t=n.d.settings,o=n.d.effective,a=re(t.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),r=fe(o.hostnames,"Device hostnames"),i=re(t.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),s=re(t.home_dns_fallback==="none"?"":t.home_dns_fallback||o.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"});return Me("defaults","Defaults",[Z("Devices per person",a,"Pre-filled when you add someone."),Z("Device hostnames",e("div",{class:"dl-hostport"},[r,e("span",{class:"dl-faint dl-mono"},"phone.myata."),i]),"Name devices in your home DNS."),Z("Fallback DNS",s,"For Home-only devices using home names: the second DNS server, used by the device when the tunnel is down. Empty = none.")],[e("span"),D("Save",()=>n.save({default_device_limit:a.value,hostnames:Ee(r)?"1":"0",domain:i.value,home_dns_fallback:s.value},"Saved","defaults"),"positive")])}function Wo(n){let t=n.d.effective,o=fe(t.geo_enabled,"Locations"),a=e("select",{class:"cbi-input-select"},[e("option",{value:"ipwho.is",selected:t.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),e("option",{value:"ipapi.co",selected:t.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]);return Me("map","Map & locations",[e("div",{class:"dl-setrow head"},[e("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),o]),Z("Provider",a)],[e("span",{class:"dl-sub"},"The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map."),D("Save",()=>n.save({geo_enabled:Ee(o)?"1":"0",geo_provider:a.value},"Saved","map"),"positive")])}var ti=[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages","System packages"]];function Go(n){let t=n.d.effective.updates,o=fe(t.check,"Check automatically",x=>h(x,Ee(r))),a=xe([["6h","Every 6 h"],["12h","Every 12 h"],["1d","Daily"],["7d","Weekly"]],t.interval,{label:"How often",cls:"sm"}),r=fe(t.auto,"Install automatically",x=>h(Ee(o),x)),i=re(t.time,{placeholder:"04:00",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono","aria-label":"Time"}),s=xe([["scheduled","At a set time"],["immediate","As soon as found"]],t.mode,{label:"When",cls:"sm",onChange:x=>i.hidden=x!=="scheduled"});i.hidden=t.mode!=="scheduled";let l=new Set(t.targets),d=e("div",{class:"dl-chips-row"},ti.map(([x,R])=>{let _=Ue(R,l.has(x),()=>{l.delete(x)||l.add(x),Wt(_,l.has(x))});return _})),p=fe(t.keep,"Keep the previous version"),c=fe(t.mirrors,"GitHub mirrors"),m=Z("How often",a),v=[Z("When",e("div",{class:"dl-hostport"},[s,i]),"A set time keeps tunnel restarts out of the evening; the run happens within an hour of it."),Z("Components",d,"AmneziaWG is off by default: a new kernel module restarts every tunnel.")],h=(x,R)=>{m.hidden=!x;for(let _ of v)_.hidden=!R};return h(t.check,t.auto),Me("updates","Updates",[e("span",{class:"dl-muted"},"How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first."),Z("Check automatically",o,"Looks for new versions in the background; Components shows what it found and the service log names it."),m,Z("Install automatically",r,"Downloads and installs new versions of the components below."),...v,Z("Keep the previous version",p,"Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB."),Z("GitHub mirrors",c,"When GitHub is unreachable, download through mirrors. Checksums are still verified.")],[e("span",{class:"dl-sub"},"Run a check or an update by hand in Components."),D("Save",()=>n.save({update_check:Ee(o)?"1":"0",update_interval:a.dataset.value,update_auto:Ee(r)?"1":"0",update_mode:s.dataset.value,update_time:i.value.trim(),update_targets:[...l],update_keep:Ee(p)?"1":"0",update_mirrors:Ee(c)?"1":"0"},"Saved","updates"),"positive")])}function qo(n){let t=n.d.logs,o=t.policy,a=xe([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(o.keep_days),{label:"Keep activity",cls:"sm"}),r=xe([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(o.max),{label:"Maximum events",cls:"sm"}),i=xe([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],o.persist,{label:"Save to flash",cls:"sm"}),s=xe([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(o.usage_days),{label:"Daily traffic",cls:"sm"}),l=xe([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(o.usage_months),{label:"Monthly traffic",cls:"sm"}),d=new Set(o.categories),p=e("div",{class:"dl-chips-row"},pt.map(h=>{let x=Ue([nt[h],e("b",{},String(t.by_category[h]??0))],d.has(h),()=>{d.delete(h)||d.add(h),Wt(x,d.has(h))},{title:no[h]});return x})),c=t.oldest?Ae(new Date(t.oldest*1e3)):"",m=(h,x,R,_)=>e("div",{class:"dl-row"},[g(h),e("span",{class:"dl-row-main dl-stack"},[e("b",{},x),e("span",{class:"dl-sub"},R)]),..._]),v=h=>D(h.toUpperCase(),async()=>{let[x,R]=await Promise.all([S.status(1),S.events(2e4)]);je(x,R.events,h)},"neutral",{title:`Download the log as ${h.toUpperCase()}`});return Me("logs","Logs & history",[e("p",{class:"dl-muted"},Ut(o)),Z("Keep activity",a,"Older events are removed automatically."),Z("Maximum size",r,"Newest events are kept when the log is full."),Z("Record",p,"Switched-off categories are not logged from now on."),Z("Save to flash",i,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),Z("Daily traffic",s,"Per-day history behind the charts."),Z("Monthly traffic",l,"Per-month totals; data limits use the current month."),e("h4",{class:"dl-setsub"},"Stored data"),e("div",{class:"dl-list"},[m("activity","Activity log",t.events?`${Rt(t.events,"event")} since ${c} · ${yt(t.log_ram)} in memory${o.persist==="off"?"":`, ${yt(t.log_flash)} on flash`}`:"Empty",[v("csv"),v("json"),D("Clear",()=>Fe("Clear activity","Removes events from the log on the router.",{},()=>n.reload("logs")),"negative")]),m("chart","Traffic history",t.usage_days?`${Rt(t.usage_days,"day")} since ${Ae(t.usage_since)} · ${yt(t.usage_flash)} on flash`:"Empty",[D("Reset",()=>ut("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),m("pin","Location cache",`${Rt(n.d.geo_cached,"address","addresses")} · ${yt(t.geo_flash)} on flash`,[D("Clear",async()=>{await U(()=>S.geoClear(),"Location cache cleared")&&await n.reload("logs")},"negative")])])],[e("span",{class:"dl-sub"},"Clear one person or device from their own page."),D("Save",()=>n.save({log_keep_days:a.dataset.value,log_max:r.dataset.value,log_persist:i.dataset.value,usage_keep_days:s.dataset.value,usage_keep_months:l.dataset.value,log_category:[...d]},"Saved","logs"),"positive")])}var ni={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},Fo=3;function Rn(n){let t=new Date(n*1e3),o=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),a=Math.round((new Date(new Date().toDateString()).getTime()-new Date(t.toDateString()).getTime())/864e5);return`${a===0?"Today":a===1?"Yesterday":t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${o}`}async function oi(n){let t=await U(()=>S.backupRead(n.name));if(!t)return;let o=atob(t.data),a=new Uint8Array(o.length);for(let i=0;ioi(n),"neutral","dl-icon-only"),ye("more","More",o=>we(o.currentTarget,[{label:"Restore",icon:g("reset"),run:async()=>{await ne("Restore this backup?",`Everything returns to ${Rn(n.created)}. The current state is backed up first.`,"Restore",!0)&&await U(()=>S.backupRestore(n.name),"Restored")&&t(!0)}},{label:"Delete",icon:g("trash"),danger:!0,run:async()=>{await ne("Delete this backup?",`The backup from ${Rn(n.created)} is removed from the router.`,"Delete",!0)&&await U(()=>S.backupDelete(n.name),"Backup deleted")&&t()}}]),"neutral","dl-icon-only")])])}function Jo(n,t){let o=n.slice(0,Fo).map(d=>Ko(d,t)),a=n.slice(Fo),r=n.length?e("div",{class:"dl-list"},[...o,a.length?e("details",{class:"dl-bk-older"},[e("summary",{},[g("chevron"),`${a.length} older backup${a.length===1?"":"s"}`]),...a.map(d=>Ko(d,t))]):""]):e("div",{class:"dl-list"},[e("div",{class:"dl-row dl-muted"},"No backups yet.")]),i=D("Restore from file",async()=>{let d=await wn(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await ne("Restore from file?",`Replace the current Dawnline configuration with ${d.name}? The current state is backed up first.`,"Restore",!0)&&await U(()=>S.backupUpload(d.data),"Restored")&&t(!0)}),s=D("Export JSON",async()=>{let d=await U(()=>S.exportJson());d&&$e(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=D("Import JSON",async()=>{let d=await wn(".json,application/json","text");if(!d)return;let p;try{p=JSON.parse(d.data)}catch{Q("Not a JSON file.","error");return}await ne("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await U(()=>S.importJson(p),"Imported")&&t(!0)});return e("section",{class:"dl-setsec",id:"dl-set-backups"},[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-setsec-head"},[e("div",{class:"dl-stack"},[e("h3",{},"Backups"),e("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),e("span",{class:"dl-spacer"}),D([g("plus")," Back up now"],async()=>{await U(()=>S.backupCreate(),"Backup created")&&t()},"positive")]),r]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),e("span",{class:"dl-row-actions dl-bk-actions"},[i,s,l])])])}function ai(){let n=re("",{placeholder:"remove"});ae("Remove Dawnline?",[e("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),n],[se()," ",D("Remove Dawnline",async()=>{await U(()=>S.uninstall(n.value.trim()),"Dawnline removed")&&(le(),setTimeout(()=>location.reload(),800))},"negative")])}function Vo(){return Me("danger","Remove Dawnline from this router",[e("p",{class:"dl-muted"},"Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup.")],[e("span"),D("Remove",()=>ai(),"negative")],"danger")}var ln=class{constructor(){this.root=e("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return S.settingsGet()}render(t){this.d=t,this.cards={portal:Qe(()=>jo(this)),defaults:Qe(()=>Uo(this)),map:Qe(()=>Wo(this)),updates:Qe(()=>Go(this)),logs:Qe(()=>qo(this)),backups:Qe(()=>Jo(this.backups,r=>this.loadBackups(r))),danger:Qe(()=>Vo())};let o=["portal","defaults","map","updates","logs","backups","danger"];dom.content(this.root,o.map(r=>this.cards[r].el)),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),this.loadPortal();let a=new URLSearchParams(location.search).get("section");return a&&a!=="backups"&&requestAnimationFrame(()=>document.getElementById(`dl-set-${a}`)?.scrollIntoView({block:"start"})),e("div",{},[e("div",{class:"dl-pagehead"},[e("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(t,o,a){let r=await U(()=>S.settingsUpdate(t),o);r&&(this.d=r,this.cards[a].refresh(),a==="portal"&&this.loadPortal())}async loadPortal(){let t=++this.portalSeq,o=await S.portalInfo().catch(()=>null);t===this.portalSeq&&(this.portal=o??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(t=!1){t&&await this.reload();let o=await S.backupList().catch(()=>null);o&&(this.backups=o.backups,this.cards.backups?.refresh())}async reload(t){let o=await S.settingsGet().catch(()=>null);if(o){if(this.d=o,t)this.cards[t].refresh();else for(let a of Object.values(this.cards))a.refresh();(!t||t==="portal")&&this.loadPortal()}}};function Yo(n,t=!1){return n&&(t?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function Qo(n){let t=[],o=l=>{let d=[],p=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,c=0;for(let m;m=p.exec(l);)m.index>c&&d.push(l.slice(c,m.index)),m[1]?d.push(e("code",{},m[1].slice(1,-1))):m[2]?d.push(e("b",{},m[2].slice(2,-2))):m[3]?d.push(e("a",{href:m[4],target:"_blank",rel:"noopener"},m[3].replace(/^\[|\]\(.*$/g,""))):m[5]&&d.push(e("a",{href:m[5],target:"_blank",rel:"noopener"},m[5].replace(/^https?:\/\/(github\.com\/)?/,""))),c=m.index+m[0].length;return c{r.length&&t.push(e("p",{},o(r.join(" ")))),r=[],a=null};for(let l of n.replace(/\r/g,"").split(` -`)){let d=l.trimEnd();if(i){/^```/.test(d.trim())?(t.push(e("pre",{},i.join(` -`))),i=null):i.push(l);continue}if(/^```/.test(d.trim())){s(),i=[];continue}let p=/^(#{1,6})\s+(.*)$/.exec(d),c=/^\s*[-*+]\s+(.*)$/.exec(d)??/^\s*\d+[.)]\s+(.*)$/.exec(d);p?(s(),t.push(e("h5",{},o(p[2])))):c?(r.length&&s(),a||(a=e("ul",{}),t.push(a)),a.appendChild(e("li",{},o(c[1])))):d.trim()?(a&&(a=null),r.push(d.trim())):s()}return i&&t.push(e("pre",{},i.join(` -`))),s(),t}function Zo(n){let t=[],o=!1;for(let a of n.replace(/\r/g,"").split(` -`)){let r=/^#{1,6}\s+(.*)$/.exec(a);if(r){if(o=/^install\b/i.test(r[1].trim()),/^what.s new$/i.test(r[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(a)&&(o=!1);o||t.push(a)}return t.join(` +var ir=Object.create;var eo=Object.defineProperty;var sr=Object.getOwnPropertyDescriptor;var lr=Object.getOwnPropertyNames;var dr=Object.getPrototypeOf,cr=Object.prototype.hasOwnProperty;var pr=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var ur=(n,e,o,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of lr(e))!cr.call(n,r)&&r!==o&&eo(n,r,{get:()=>e[r],enumerable:!(a=sr(e,r))||a.enumerable});return n};var mr=(n,e,o)=>(o=n!=null?ir(dr(n)):{},ur(e||!n||!n.__esModule?eo(o,"default",{value:n,enumerable:!0}):o,n));var mo=pr((po,uo)=>{"use strict";var co=(function(){var n=function(E,T){var w=236,v=17,x=E,$=o[T],m=null,h=0,N=null,C=[],R={},Z=function(_,A){h=x*4+17,m=(function(y){for(var H=new Array(y),S=0;S=7&&X(_),N==null&&(N=U(x,$,C)),fe(N,A)},G=function(_,A){for(var y=-1;y<=7;y+=1)if(!(_+y<=-1||h<=_+y))for(var H=-1;H<=7;H+=1)A+H<=-1||h<=A+H||(0<=y&&y<=6&&(H==0||H==6)||0<=H&&H<=6&&(y==0||y==6)||2<=y&&y<=4&&2<=H&&H<=4?m[_+y][A+H]=!0:m[_+y][A+H]=!1)},V=function(){for(var _=0,A=0,y=0;y<8;y+=1){Z(!0,y);var H=r.getLostPoint(R);(y==0||_>H)&&(_=H,A=y)}return A},z=function(){for(var _=8;_>y&1)==1;m[Math.floor(y/3)][y%3+h-8-3]=H}for(var y=0;y<18;y+=1){var H=!_&&(A>>y&1)==1;m[y%3+h-8-3][Math.floor(y/3)]=H}},de=function(_,A){for(var y=$<<3|A,H=r.getBCHTypeInfo(y),S=0;S<15;S+=1){var O=!_&&(H>>S&1)==1;S<6?m[S][8]=O:S<8?m[S+1][8]=O:m[h-15+S][8]=O}for(var S=0;S<15;S+=1){var O=!_&&(H>>S&1)==1;S<8?m[8][h-S-1]=O:S<9?m[8][15-S-1+1]=O:m[8][15-S-1]=O}m[h-8][8]=!_},fe=function(_,A){for(var y=-1,H=h-1,S=7,O=0,Y=r.getMaskFunction(A),J=h-1;J>0;J-=2)for(J==6&&(J-=1);;){for(var pe=0;pe<2;pe+=1)if(m[H][J-pe]==null){var be=!1;O<_.length&&(be=(_[O]>>>S&1)==1);var ee=Y(H,J-pe);ee&&(be=!be),m[H][J-pe]=be,S-=1,S==-1&&(O+=1,S=7)}if(H+=y,H<0||h<=H){H-=y,y=-y;break}}},B=function(_,A){for(var y=0,H=0,S=0,O=new Array(A.length),Y=new Array(A.length),J=0;J=0?Zn.getAt(Qn):0}}for(var Xn=0,ee=0;eeJ*8)throw"code length overflow. ("+S.getLengthInBits()+">"+J*8+")";for(S.getLengthInBits()+4<=J*8&&S.put(0,4);S.getLengthInBits()%8!=0;)S.putBit(!1);for(;!(S.getLengthInBits()>=J*8||(S.put(w,8),S.getLengthInBits()>=J*8));)S.put(v,8);return B(S,H)};R.addData=function(_,A){A=A||"Byte";var y=null;switch(A){case"Numeric":y=c(_);break;case"Alphanumeric":y=p(_);break;case"Byte":y=u(_);break;case"Kanji":y=k(_);break;default:throw"mode:"+A}C.push(y),N=null},R.isDark=function(_,A){if(_<0||h<=_||A<0||h<=A)throw _+","+A;return m[_][A]},R.getModuleCount=function(){return h},R.make=function(){if(x<1){for(var _=1;_<40;_++){for(var A=d.getRSBlocks(_,$),y=l(),H=0;H"u"?_*4:A;var y="";y+='";for(var S=0;S';y+=""}return y+="",y+="
",y},R.createSvgTag=function(_,A,y,H){var S={};typeof arguments[0]=="object"&&(S=arguments[0],_=S.cellSize,A=S.margin,y=S.alt,H=S.title),_=_||2,A=typeof A>"u"?_*4:A,y=typeof y=="string"?{text:y}:y||{},y.text=y.text||null,y.id=y.text?y.id||"qrcode-description":null,H=typeof H=="string"?{text:H}:H||{},H.text=H.text||null,H.id=H.text?H.id||"qrcode-title":null;var O=R.getModuleCount()*_+A*2,Y,J,pe,be,ee="",Se;for(Se="l"+_+",0 0,"+_+" -"+_+",0 0,-"+_+"z ",ee+=''+q(H.text)+"":"",ee+=y.text?''+q(y.text)+"":"",ee+='',ee+='"u"?_*4:A;var y=R.getModuleCount()*_+A*2,H=A,S=y-A;return I(y,y,function(O,Y){if(H<=O&&O"u"?_*4:A;var H=R.getModuleCount()*_+A*2,S="";return S+="",S};var q=function(_){for(var A="",y=0;y<_.length;y+=1){var H=_.charAt(y);switch(H){case"<":A+="<";break;case">":A+=">";break;case"&":A+="&";break;case'"':A+=""";break;default:A+=H;break}}return A},oe=function(_){var A=1;_=typeof _>"u"?A*2:_;var y=R.getModuleCount()*A+_*2,H=_,S=y-_,O,Y,J,pe,be,ee={"██":"█","█ ":"▀"," █":"▄"," ":" "},Se={"██":"▀","█ ":"▀"," █":" "," ":" "},Me="";for(O=0;O=S?Se[be]:ee[be];Me+=` +`}return y%2&&_>0?Me.substring(0,Me.length-y-1)+Array(y+1).join("▀"):Me.substring(0,Me.length-1)};return R.createASCII=function(_,A){if(_=_||1,_<2)return oe(A);_-=1,A=typeof A>"u"?_*2:A;var y=R.getModuleCount()*_+A*2,H=A,S=y-A,O,Y,J,pe,be=Array(_+1).join("██"),ee=Array(_+1).join(" "),Se="",Me="";for(O=0;O>>8),$.push(N&255)):$.push(v)}}return $}};var e={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},o={L:1,M:0,Q:3,H:2},a={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},r=(function(){var E=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],T=1335,w=7973,v=21522,x={},$=function(m){for(var h=0;m!=0;)h+=1,m>>>=1;return h};return x.getBCHTypeInfo=function(m){for(var h=m<<10;$(h)-$(T)>=0;)h^=T<<$(h)-$(T);return(m<<10|h)^v},x.getBCHTypeNumber=function(m){for(var h=m<<12;$(h)-$(w)>=0;)h^=w<<$(h)-$(w);return m<<12|h},x.getPatternPosition=function(m){return E[m-1]},x.getMaskFunction=function(m){switch(m){case a.PATTERN000:return function(h,N){return(h+N)%2==0};case a.PATTERN001:return function(h,N){return h%2==0};case a.PATTERN010:return function(h,N){return N%3==0};case a.PATTERN011:return function(h,N){return(h+N)%3==0};case a.PATTERN100:return function(h,N){return(Math.floor(h/2)+Math.floor(N/3))%2==0};case a.PATTERN101:return function(h,N){return h*N%2+h*N%3==0};case a.PATTERN110:return function(h,N){return(h*N%2+h*N%3)%2==0};case a.PATTERN111:return function(h,N){return(h*N%3+(h+N)%2)%2==0};default:throw"bad maskPattern:"+m}},x.getErrorCorrectPolynomial=function(m){for(var h=s([1],0),N=0;N5&&(N+=3+Z-5)}for(var C=0;C=256;)x-=255;return E[x]},v})();function s(E,T){if(typeof E.length>"u")throw E.length+"/"+T;var w=(function(){for(var x=0;x"u")throw"bad rs block @ typeNumber:"+x+"/errorCorrectionLevel:"+$;for(var h=m.length/3,N=[],C=0;C>>7-v%8&1)==1},w.put=function(v,x){for(var $=0;$>>x-$-1&1)==1)},w.getLengthInBits=function(){return T},w.putBit=function(v){var x=Math.floor(T/8);E.length<=x&&E.push(0),v&&(E[x]|=128>>>T%8),T+=1},w},c=function(E){var T=e.MODE_NUMBER,w=E,v={};v.getMode=function(){return T},v.getLength=function(m){return w.length},v.write=function(m){for(var h=w,N=0;N+2>>8&255)*192+(C&255),m.put(C,13),N+=2}if(N>>8)},T.writeBytes=function(w,v,x){v=v||0,x=x||w.length;for(var $=0;$0&&(w+=","),w+=E[v];return w+="]",w},T},b=function(){var E=0,T=0,w=0,v="",x={},$=function(h){v+=String.fromCharCode(m(h&63))},m=function(h){if(!(h<0)){if(h<26)return 65+h;if(h<52)return 97+(h-26);if(h<62)return 48+(h-52);if(h==62)return 43;if(h==63)return 47}throw"n:"+h};return x.writeByte=function(h){for(E=E<<8|h&255,T+=8,w+=1;T>=6;)$(E>>>T-6),T-=6},x.flush=function(){if(T>0&&($(E<<6-T),E=0,T=0),w%3!=0)for(var h=3-w%3,N=0;N=T.length){if(x==0)return-1;throw"unexpected end of file./"+x}var h=T.charAt(w);if(w+=1,h=="=")return x=0,-1;if(h.match(/^\s$/))continue;v=v<<6|m(h.charCodeAt(0)),x+=6}var N=v>>>x-8&255;return x-=8,N};var m=function(h){if(65<=h&&h<=90)return h-65;if(97<=h&&h<=122)return h-97+26;if(48<=h&&h<=57)return h-48+52;if(h==43)return 62;if(h==47)return 63;throw"c:"+h};return $},j=function(E,T){var w=E,v=T,x=new Array(E*T),$={};$.setPixel=function(C,R,Z){x[R*w+C]=Z},$.write=function(C){C.writeString("GIF87a"),C.writeShort(w),C.writeShort(v),C.writeByte(128),C.writeByte(0),C.writeByte(0),C.writeByte(0),C.writeByte(0),C.writeByte(0),C.writeByte(255),C.writeByte(255),C.writeByte(255),C.writeString(","),C.writeShort(0),C.writeShort(0),C.writeShort(w),C.writeShort(v),C.writeByte(0);var R=2,Z=h(R);C.writeByte(R);for(var G=0;Z.length-G>255;)C.writeByte(255),C.writeBytes(Z,G,255),G+=255;C.writeByte(Z.length-G),C.writeBytes(Z,G,Z.length-G),C.writeByte(0),C.writeString(";")};var m=function(C){var R=C,Z=0,G=0,V={};return V.write=function(z,F){if(z>>>F)throw"length over";for(;Z+F>=8;)R.writeByte(255&(z<>>=8-Z,G=0,Z=0;G=z<0&&R.writeByte(G)},V},h=function(C){for(var R=1<>6,128|i&63):i<55296||i>=57344?a.push(224|i>>12,128|i>>6&63,128|i&63):(r++,i=65536+((i&1023)<<10|o.charCodeAt(r)&1023),a.push(240|i>>18,128|i>>12&63,128|i>>6&63,128|i&63))}return a}return e(n)}})();(function(n){typeof define=="function"&&define.amd?define([],n):typeof po=="object"&&(uo.exports=n())})(function(){return co})});function $n(n,e){return n==null||n===!1||n===""||(Array.isArray(n)?n.forEach(o=>$n(o,e)):e.push(n instanceof Node?n:String(n))),e}function t(n,e,o){let a=window.E,r=e!=null&&typeof e=="object"&&!Array.isArray(e)&&!(e instanceof Node);return!r&&o===void 0?a(n,{},$n(e,[])):a(n,r?e:{},$n(o,[]))}function K(n,e=[]){let o=rpc.declare({object:"luci.dawnline",method:n,params:e});return async(...a)=>{let r=await o(...a);if(r&&typeof r=="object"&&typeof r.error=="string")throw new Error(r.error);return r}}var hr=K("logs_clear",["person","device","category","older_days"]),fr=(n={})=>hr(n.person??"",n.device??"",n.category??"",n.older_days??""),gr=rpc.declare({object:"luci.dawnline",method:"person_update",params:["id","name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode","paused","services","circle","home_nets"]});async function vr(n,e){let a=[n,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(i=>e[i]),e.paused,e.services,e.circle,e.home_nets],r=await gr(...a);if(r&&typeof r.error=="string")throw new Error(r.error);return r}var br=K("status",["days"]),P={rev:K("rev"),personUpdate:vr,settingsGet:K("settings_get"),portalInfo:K("portal_info"),settingsUpdate:K("settings_update",["values"]),serviceSet:K("service_set",["id","name","address","ports"]),serviceDelete:K("service_delete",["id"]),geoClear:K("geo_clear"),events:K("events",["limit"]),logsClear:fr,interfaces:K("interfaces",["id"]),serverInterfaces:K("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:K("circle_set",["id","server","name","color","members"]),circleDelete:K("circle_delete",["id"]),accessCheck:K("access_check",["from","to"]),homeHosts:K("home_hosts",["id"]),usageClear:K("usage_clear",["scope","id"]),uninstall:K("uninstall",["confirm"]),status:br,setupDefaults:K("setup_defaults"),serverCreate:K("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:K("server_obfuscation",["id","preset"]),serverUpdate:K("server_update",["id","values"]),serverDelete:K("server_delete",["id"]),personLinks:K("person_links",["id"]),personCreate:K("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:K("person_pause",["id","paused"]),personRegen:K("person_regen",["id"]),personDelete:K("person_delete",["id"]),personUsage:K("person_usage",["id","days"]),deviceCreate:K("device_create",["person","name","kind"]),deviceConfig:K("device_config",["id"]),deviceUpdate:K("device_update",["id","name","disabled"]),deviceDelete:K("device_delete",["id"]),deviceRotate:K("device_rotate",["id"]),apply:K("apply"),health:K("health"),healthFix:K("health_fix",["id"]),serviceLog:K("service_log"),serviceLogClear:K("service_log_clear",["older_days"]),backupList:K("backup_list"),backupCreate:K("backup_create"),backupRestore:K("backup_restore",["name"]),backupDelete:K("backup_delete",["name"]),backupRead:K("backup_read",["name"]),backupUpload:K("backup_upload",["data"]),exportJson:K("export"),importJson:K("import",["data"]),updatesStatus:K("updates_status"),updatesRun:K("updates_run",["what"]),updatesReleases:K("updates_releases",["page"]),updatesNotes:K("updates_notes",["component","tag","build"]),updatesChanges:K("updates_changes",["from","to"])};var to={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function kt(n,e="dl-icon"){let o=to[n]??to.phone;return``}function g(n,e="dl-icon"){let o=document.createElement("span");return o.className="dl-icon-wrap",o.innerHTML=kt(n,e),o}function Q(n,e="info",o=0){let a=document.querySelector(".dl-toasts");a||(a=t("div",{class:"dl-toasts dl-root",role:"status","aria-live":"polite"}),document.body.appendChild(a));let r=e==="error"?"x":e==="warning"?"alert":e==="success"?"check":null,i=()=>{s.classList.remove("show"),setTimeout(()=>s.remove(),200)},s=t("div",{class:`dl-toast ${e}`},[r?g(r):"",t("span",{},n),e==="error"?t("button",{type:"button","aria-label":"Close",click:i},g("x")):""]);a.appendChild(s),requestAnimationFrame(()=>s.classList.add("show")),setTimeout(i,o||(e==="error"?8e3:e==="warning"?5e3:2600))}function ve(n){return n instanceof Error?n.message:String(n)}async function W(n,e){try{let o=await n();return e&&Q(e,"success",3500),o}catch(o){Q(ve(o),"error",1e4);return}}function no(n){try{let e=n();e&&typeof e.then=="function"&&e.catch(o=>Q(ve(o),"error"))}catch(e){Q(ve(e),"error")}}function D(n,e,o="neutral",a={}){let{disabled:r,...i}=a,s=t("button",{class:`cbi-button cbi-button-${o}`,type:"button",...i,click:async d=>{if(d.preventDefault(),d.stopPropagation(),!s.disabled){s.disabled=!0,s.classList.add("spinning");try{await e(d)}catch(l){Q(ve(l),"error")}finally{s.disabled=!1,s.classList.remove("spinning")}}}},n);return s.disabled=!!r,s}function $e(n,e,o,a="neutral",r=""){return D([g(n),t("span",{class:"dl-btn-label"},e)],o,a,{title:e,class:`cbi-button cbi-button-${a} dl-icon-btn ${r}`.trim()})}function Ae(n){return document.addEventListener("luci-navigate",n),()=>document.removeEventListener("luci-navigate",n)}var lt=null;function En(n=!1){let e=lt;lt=null,e?.(n)}function re(n,e,o,a=""){En(),ui.showModal(n,[t("div",{class:`dl-modal ${a}`},e),t("div",{class:"button-row"},o)])}function ce(){En(),ui.hideModal()}function le(n="Cancel",e=!1){return t("button",{class:`cbi-button ${e?"cbi-button-negative":"cbi-button-neutral"}`,type:"button",click:ce},n)}function ae(n,e,o="Confirm",a=!1){return new Promise(r=>{re(n,e,[le()," ",t("button",{class:`cbi-button ${a?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{let i=lt;lt=null,ui.hideModal(),i?.(!0)}},o)]),lt=r})}Ae(()=>{lt&&(En(),ui.hideModal())});async function ue(n,e="Copied to clipboard"){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(n);else{let o=t("textarea",{style:"position:fixed;opacity:0"},n);document.body.appendChild(o),o.select();let a=document.execCommand("copy");if(o.remove(),!a)throw new Error("Copying is blocked here. Select the text and copy it by hand.")}Q(e,"success",2500)}catch(o){Q(ve(o),"error")}}function Ee(n,e,o="text/plain"){let a=globalThis,r=typeof e=="string"?new a.Blob([e],{type:o}):e,i=URL.createObjectURL(r),s=t("a",{href:i,download:n,style:"display:none"});document.body.appendChild(s),s.click(),setTimeout(()=>{URL.revokeObjectURL(i),s.remove()},1e3)}function Ln(n,e){return new Promise(o=>{let a=t("input",{type:"file",accept:n,style:"display:none"});a.addEventListener("cancel",()=>{a.remove(),o(null)}),a.addEventListener("change",()=>{let r=a.files?.[0];if(a.remove(),!r)return o(null);let i=new FileReader;i.onload=()=>{let s=String(i.result??"");o({name:r.name,data:e==="base64"?s.replace(/^data:[^,]*,/,""):s})},i.onerror=()=>o(null),e==="base64"?i.readAsDataURL(r):i.readAsText(r)}),document.body.appendChild(a),a.click()})}function we(n,e){let o=document.querySelector(".dl-dd");if(o&&(o.dlClose?o.dlClose():o.remove(),o.dlAnchor===n))return;let a=t("div",{class:"dl-dd dl-root",role:"menu"},e.map(u=>u?t("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),no(u.run)}},[u.icon??"",t("span",{},u.label)]):t("hr")));document.body.appendChild(a);let r=n.getBoundingClientRect(),i=a.offsetWidth,s=a.offsetHeight;a.style.top=`${r.bottom+6+s>window.innerHeight-8&&r.top-6-s>8?r.top-6-s:r.bottom+6}px`,a.style.left=`${Math.max(8,Math.min(r.right-i,window.innerWidth-i-8))}px`;let d=u=>{!a.contains(u.target)&&!n.contains(u.target)&&p()},l=u=>{u.key==="Escape"&&p()},c=Ae(p);a.dlAnchor=n,a.dlClose=p;function p(){a.remove(),c(),document.removeEventListener("mousedown",d,!0),document.removeEventListener("keydown",l,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",d,!0),document.addEventListener("keydown",l,!0),window.addEventListener("scroll",p,!0)}),a.querySelector("button")?.focus({preventScroll:!0})}var Xe=null,et=null,_n=0;function $t(){Xe&&(Xe.style.display="none"),et=null,clearInterval(_n),_n=0}function me(n,e){let o=a=>{Xe??(Xe=document.body.appendChild(t("div",{class:"dl-tip dl-tip-float dl-root"}))),Xe.replaceChildren(...e().map(r=>typeof r=="string"?document.createTextNode(r):r)),Xe.style.display="",Xe.style.left=`${a.clientX}px`,Xe.style.top=`${a.clientY-10}px`,et=n,_n||(_n=window.setInterval(()=>{(!et?.isConnected||!et.getClientRects().length)&&$t()},400))};n.addEventListener("mouseenter",o),n.addEventListener("mousemove",o),n.addEventListener("mouseleave",$t)}Ae($t);window.addEventListener("scroll",()=>et&&$t(),{capture:!0,passive:!0});document.addEventListener("pointerdown",n=>{et&&!et.contains(n.target)&&$t()},!0);function te(n){if(!n||n<0)return"0 B";let e=["B","KB","MB","GB","TB"],o=0,a=n;for(;a>=1024&&o=100||o===0?Math.round(a):a.toFixed(1)} ${e[o]}`}function ze(n){let e=n*8;return e<1e3?`${Math.round(e)} bit/s`:e<1e6?`${(e/1e3).toFixed(e<1e4?1:0)} kbit/s`:e<1e9?`${(e/1e6).toFixed(e<1e7?1:0)} Mbit/s`:`${(e/1e9).toFixed(1)} Gbit/s`}function ie(n,e=Date.now()/1e3){if(!n)return"never";let o=Math.max(0,Math.round(e-n));return o<60?"just now":o<3600?`${Math.floor(o/60)} min ago`:o<86400?`${Math.floor(o/3600)} h ago`:o<86400*30?`${Math.floor(o/86400)} d ago`:new Date(n*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ct(n){if(!n||n<0)return"—";let e=Math.floor(n/86400),o=Math.floor(n%86400/3600),a=Math.floor(n%3600/60);return e?`${e}d ${o}h`:o?`${o}h ${a}m`:`${a}m`}function Lt(n){let e=new Date(n*1e3),o=new Date,a=e.toDateString()===o.toDateString(),r=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return a?r:`${e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${r}`}function Ne(n){return`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}-${String(n.getDate()).padStart(2,"0")}`}function pt(n){let[e,o,a]=n.split("-").map(Number);return new Date(e,(o||1)-1,a||1,12)}function He(n){return(typeof n=="string"?/^\d{4}-\d{2}-\d{2}$/.test(n)?pt(n):new Date(n):n).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Ce(n){return n?He(n):""}function Sn(n,e){let o=a=>{let[r,i,s]=a.split("-").map(Number);return Date.UTC(r,i-1,s)};return Math.round((o(n)-o(e))/864e5)}function Et(n,e){let o=pt(n);return o.setDate(o.getDate()+e),Ne(o)}function dt(n,e){let[o,a,r]=n.split("-").map(Number),i=new Date(o,a-1+e,1,12),s=new Date(i.getFullYear(),i.getMonth()+1,0).getDate();return i.setDate(Math.min(r,s)),Ne(i)}function Re(n){return n?.length?n[n.length-1].day:Ne(new Date)}function oo(n,e,o,a,r=30){let i=n||a;return e==="day"?Et(i,o):e==="week"?Et(i,7*o):e==="month"?dt(i,o):e==="year"?dt(i,12*o):Et(i,r*o)}function tt(n,e=Date.now()){if(!n)return null;let o=typeof e=="number"?Ne(new Date(e)):e,a=Sn(n,o);return a>=0?a+1:a}function jt(n,e,o=`${e}s`){return`${n.toLocaleString("en-GB")} ${n===1?e:o}`}function _t(n){return n<1024?`${n} B`:n<1048576?`${(n/1024).toFixed(n<10240?1:0)} KB`:`${(n/1048576).toFixed(1)} MB`}var nt={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var ao=["computer","phone","tablet","router","other"],je={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},ro={active:"Active",paused:"Paused",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server",server_off:"Server is turned off"};function De(n){let e=n.trim().split(/\s+/).filter(Boolean);if(!e.length)return"?";let o=e[0][0]??"",a=e.length>1?e[e.length-1][0]??"":e[0][1]??"";return(o+a).toUpperCase()}function Ut(n){let e=o=>o.disabled?3:o.online?0:o.handshake?1:2;return n.map((o,a)=>[o,a]).sort((o,a)=>e(o[0])-e(a[0])||o[1]-a[1]).map(([o])=>o)}function ye(n,e,o){return t("span",{class:`dl-pill ${n}`,title:o??null},e)}function xr(n){return n.state==="active"?"ok":n.state==="quota"||n.state==="expired"?"bad":"warn"}function wr(n){return n.state==="server_off"&&n.paused?"paused":n.state}function io(n){let e=wr(n);return e==="active"||e==="server_off"?"":ye(xr({...n,state:e}),ro[e])}function so(n){let e=n.access==="both"?["lan","inet"]:n.access==="lan"?["lan"]:["inet"],o=t("span",{class:"dl-access","aria-label":nt[n.access]},e.map(a=>t("span",{class:`dl-ibadge ${a}`},g(a==="lan"?"home":"globe"))));return me(o,()=>[t("div",{class:"dl-tip-title"},nt[n.access]),n.access==="lan"&&n.services?.length?t("div",{class:"dl-muted"},`${n.services.length} home service${n.services.length===1?"":"s"} only`):""]),o}function Wt(n,e,o="Not set up yet"){return n.disabled?t("span",{class:"dl-dstat"},"Disabled"):n.online?t("span",{class:"dl-dstat ok"},"Connected"):n.handshake?t("span",{class:"dl-dstat"},`Last seen ${ie(n.handshake,e)}`):t("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},o)}var Gt=null;function lo(n,e,o,a){Gt?.close();let r=t("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[t("div",{class:"dl-drawer-head"},[n,t("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>c()},g("x"))]),t("div",{class:"dl-drawer-body"},e),o?t("div",{class:"dl-drawer-foot"},o):""]),i=t("div",{class:"dl-drawer-overlay dl-root",click:u=>{u.target===i&&c()}},r),s=u=>{u.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&c()},d=!1,l=Ae(()=>c());function c(){d||(d=!0,l(),document.removeEventListener("keydown",s),i.classList.remove("open"),setTimeout(()=>i.remove(),220),Gt===p&&(Gt=null),a())}let p={close:c,panel:r};return document.addEventListener("keydown",s),document.body.appendChild(i),requestAnimationFrame(()=>i.classList.add("open")),Gt=p,p}function ne(n,e,o){return t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},n),o?t("span",{class:"dl-sub"},o):""]),t("div",{class:"dl-setrow-ctl"},e)])}function ut(n,e,o,a=e){let r=ne(n,a," "),i=r.querySelector(".dl-sub"),s=()=>{let d=o();i.textContent=d.text,i.classList.toggle("bad",d.bad),e.classList.toggle("cbi-input-invalid",d.bad)};return e.addEventListener("input",s),r.refresh=s,s(),r}function St(n,e,o,a=""){return t("section",{class:`dl-setsec ${a}`},[t("div",{class:"dl-setsec-body"},[n?t("h3",{},n):"",...e]),o.length?t("div",{class:"dl-setsec-foot"},o):""])}function he(n,e,o,a){return t("div",{class:"dl-group"},[t("div",{class:"dl-group-head"},[t("span",{class:"dl-group-ic"},g(n)),t("span",{class:"dl-stack"},[t("b",{},e),o?t("span",{class:"dl-sub"},o):""])]),t("div",{class:"dl-group-body"},a.filter(r=>r!==""))])}function ot(n,e,o,a,r){return t("div",{class:`dl-row dl-need-row ${e}`},[e?t("span",{class:"dl-need-ic"},g(n)):g(n),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-sub"},a)]),r])}function mt(n,e){let o={ok:"success",warn:"warning",error:"error",info:"notice"}[n];return t("div",{class:`alert-message ${o}`},e)}function qe(n,e=""){let o=t("div",{class:e});return o.innerHTML=n,o}var ho=mr(mo(),1),yr='';function ht(n,e=3,o=!0){let a=(0,ho.default)(0,n.length>300?"Q":"H");a.addData(n,"Byte"),a.make();let r=a.getModuleCount(),i=r+e*2,s=o?Math.round(r*.22):0;s&&(r-s)%2&&s++;let d=(r-s)/2,l=d+s,c=(k,f)=>s>0&&k>=d&&k=d&&f${yr}`}return`${u}`}var kr={connect:"connections",disconnect:"connections",roam:"connections",device_added:"people",device_removed:"people",devices_removed:"people",device_changed:"people",device_keys:"people",link_changed:"people",person_added:"people",person_removed:"people",person_changed:"people",paused:"people",resumed:"people",portal_blocked:"problems"},ft=["connections","people","problems"],at={connections:"Connections",people:"People",problems:"Problems"},fo={connections:"Connects, disconnects and IP changes",people:"People and their devices added, changed, paused, removed",problems:"Blocked portal sign-ins (tunnels and services are in the service log)"},Mt=n=>kr[n]??"problems",Ct={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"},$r=["person_added","person_removed","person_changed"];function Te(n){return n.by?n.by:$r.includes(n.type)||n.detail==="by admin"||n.detail?.endsWith(" (admin)")?"admin":n.detail?.endsWith(" (portal)")?"portal":null}function go(n){return(n.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}var qt=n=>n.sys?["error","repair","down"].includes(n.sys.level):Mt(n.ev.type)==="problems";function Ft(n){let e=n.keep_days>0?`${n.keep_days} day${n.keep_days===1?"":"s"}`:"no age limit",o=n.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${n.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${e}, up to ${n.max.toLocaleString("en-GB")} events, ${o}.`}function vo(n,e=120,o=26,a=Ne(new Date)){let r=Math.max(1,...n),i=t("div",{class:"dl-spark"});return i.style.width=`${e}px`,i.style.height=`${o}px`,n.forEach((s,d)=>{let l=t("i");l.style.height=`${Math.max(6,s/r*100)}%`,s||l.classList.add("zero");let c=n.length-1-d;me(l,()=>[t("div",{class:"dl-tip-title"},c===0?"Today":c===1?"Yesterday":pt(Et(a,-c)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),t("div",{class:"dl-muted"},te(s))]),i.appendChild(l)}),i}function Er(n){let e=n==null?"":String(n);return/^[=+\-@\t\r]/.test(e)&&(e=`'${e}`),/[",\r\n]/.test(e)?`"${e.replace(/"/g,'""')}"`:e}function bo(n,e){return[n.join(","),...e.map(o=>n.map(a=>Er(o[a])).join(","))].join(` +`)}function Lr(n){let e=new Map(n.people.map(a=>[a.id,a.name])),o=new Map(n.people.flatMap(a=>a.devices.map(r=>[r.id,r.name])));return{people:e,devices:o}}function Ue(n,e,o,a="",r=[]){let i=Lr(n),s=[...e.map(p=>({ts:p.ts,category:Mt(p.type),type:p.type,person:p.person?i.people.get(p.person)??p.pname??p.person:"",device:p.device?i.devices.get(p.device)??p.dname??p.device:"",detail:p.detail??"",where:p.where??"",by:Te(p)??""})),...r.map(p=>({ts:p.ts,category:"system",type:`${p.src}.${p.level}`,person:"",device:"",detail:`${p.who?`${p.who} `:""}${p.msg}${p.detail?` +${p.detail}`:""}`,where:Ct[p.src]??p.src,by:""}))].sort((p,u)=>p.ts-u.ts).map(({ts:p,...u})=>({time:new Date(p*1e3).toISOString(),...u})),d=new Date().toISOString().slice(0,10),l=`dawnline-activity${a?`-${a}`:""}-${d}.${o}`;if(o==="json"){Ee(l,JSON.stringify(s,null,2),"application/json");return}Ee(l,bo(["time","category","type","person","device","detail","where","by"],s),"text/csv")}var _r=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]],xo=n=>n?`${n} event${n===1?"":"s"} removed`:"Nothing matched";function Fe(n,e,o,a,r,i=!1){let s=t("select",{class:"cbi-input-select"},[t("option",{value:""},"All categories"),...ft.map(l=>t("option",{value:l,selected:l===r?"selected":null},at[l])),i?t("option",{value:"system",selected:r==="system"?"selected":null},"System"):""]),d=t("select",{class:"cbi-input-select"},_r.map(([l,c])=>t("option",{value:l},c)));re(n,[t("p",{class:"dl-muted"},`${e} This cannot be undone; export first if you want a copy.`),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Category"),s]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Which events"),d])],[le()," ",D("Clear",async()=>{let l=0;if(s.value!=="system")try{l+=(await P.logsClear({...o,category:s.value,older_days:d.value})).removed}catch(c){Q(ve(c),"error",1e4);return}if(i&&(s.value==="system"||s.value===""))try{l+=(await P.serviceLogClear(d.value)).removed}catch(c){ce(),Q(`${s.value==="system"?"":`Activity: ${xo(l).toLowerCase()}. `}The service log was not cleared: ${ve(c)}`,"error",1e4),a();return}ce(),Q(xo(l),"success",3e3),a()},"negative")])}function gt(n,e,o,a){let r=n==="device"?`Clears ${o}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:n==="person"?`Clears ${o}'s traffic history and that of their devices. Their data limit starts again from zero.`:"Clears traffic history for everyone. Data limits start again from zero.";re(n==="all"?"Reset all traffic history?":`Reset traffic history for ${o}?`,[t("p",{class:"dl-muted"},r)],[le()," ",D("Reset",async()=>{await W(()=>P.usageClear(n,e),"Traffic history reset")&&(ce(),a())},"negative")])}function ge(n,e,o){let a=t("button",{type:"button",role:"switch",class:`dl-switch${n?" on":""}`,"aria-checked":n?"true":"false","aria-label":e,click:()=>{let r=!a.classList.contains("on");Mn(a,r),o?.(r)}},t("i"));return a}function Mn(n,e){n.classList.toggle("on",e),n.setAttribute("aria-checked",e?"true":"false")}var _e=n=>n.classList.contains("on");function xe(n,e,o={}){n.some(([i])=>i===e)||(n=[...n,[e,e]]);let a=t("div",{class:`dl-seg${o.cls?` ${o.cls}`:""}`,role:"radiogroup","aria-label":o.label??null,"data-value":e}),r=()=>a.querySelectorAll(":scope > button").forEach(i=>{let s=i.dataset.v===a.dataset.value;i.classList.toggle("on",s),i.setAttribute("aria-checked",s?"true":"false")});for(let[i,s]of n)a.appendChild(t("button",{type:"button",role:"radio","data-v":i,click:()=>{i!==a.dataset.value&&(o.optimistic!==!1&&(a.dataset.value=i,r()),o.onChange?.(i))}},s));return r(),a}function We(n,e,o,a={}){return t("button",{type:"button",...a,class:`dl-chipbtn${e?" on":""}${a.class?` ${a.class}`:""}`,"aria-pressed":e?"true":"false",click:o},n)}function Kt(n,e){n.classList.toggle("on",e),n.setAttribute("aria-pressed",e?"true":"false")}function se(n,e={}){return t("input",{type:"text",class:"cbi-input-text",value:n,...e})}var Sr={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},Mr={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function Cr(n){let e={};for(let[o,a]of Object.entries(Mr))n[o]!=null&&n[o]!==""&&(e[a]=String(n[o]));return e}function Tr(n,e){let o=n.amnezia,a=o.obfuscation??{},r=l=>a[l]!=null&&a[l]!==""?String(a[l]):Sr[l],i=o.host.replace(/^\[(.*)\]$/,"$1"),s={H1:r("h1"),H2:r("h2"),H3:r("h3"),H4:r("h4"),I1:r("i1"),I2:r("i2"),I3:r("i3"),I4:r("i4"),I5:r("i5"),Jc:r("jc"),Jmin:r("jmin"),Jmax:r("jmax"),S1:r("s1"),S2:r("s2"),S3:r("s3"),S4:r("s4"),...Cr(a),allowed_ips:o.allowed_ips,client_ip:o.client_ip,client_priv_key:o.client_priv_key,client_pub_key:o.client_pub_key,config:n.conf.replace(/\r?\n/g,`\r +`),hostName:i,mtu:o.mtu,persistent_keep_alive:o.persistent_keep_alive,port:Number(o.port),psk_key:o.psk_key,server_pub_key:o.server_pub_key},d={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(s),port:String(o.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:e,hostName:i};return o.dns[0]&&(d.dns1=o.dns[0]),o.dns[1]&&(d.dns2=o.dns[1]),d}function Pr(n){let e="";for(let o=0;o"u")return null;try{let o=new e.Blob([n]).stream().pipeThrough(new e.CompressionStream("deflate")),a=new Uint8Array(await new e.Response(o).arrayBuffer()),r=new Uint8Array(4+a.length);return new DataView(r.buffer).setUint32(0,n.length,!1),r.set(a,4),r}catch{return null}}async function Cn(n,e,o=!0){let a=new TextEncoder().encode(JSON.stringify(Tr(n,e))),r=o?await Dr(a):null;return`vpn://${Pr(r??a)}`}var yo=[{id:"off",title:"Off",ic:"zap",stealth:0,speed:4,text:"Plain WireGuard-compatible traffic. Fastest, but easy to recognise and block.",apps:"Any WireGuard app",short:"Any WireGuard app"},{id:"standard",title:"Standard",ic:"shield",stealth:2,speed:4,text:"Junk packets and random headers. Gets through most VPN blocking with no speed cost.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"strong",title:"Strong",ic:"shieldplus",stealth:3,speed:3,text:"More and larger junk packets for networks that block VPNs aggressively. Connects a little slower.",apps:"Every AmneziaWG and AmneziaVPN app",short:"Any AmneziaWG app"},{id:"max",title:"Maximum",ic:"lock",stealth:4,speed:3,needs:"v3",text:"AmneziaWG 3.1: encrypted packet headers, random tails and sizes, jittered timing, and a first packet that looks like DNS.",apps:"Apps with AmneziaWG 3.1 (current AmneziaVPN)",short:"AmneziaWG 3.1 apps"}],Tt=n=>yo.find(e=>e.id===n),Ar={v2:"Needs AmneziaWG 1.5 or newer on the router.",v3:"Needs AmneziaWG 3.1 on the router (kmod-amneziawg and amneziawg-tools 3.1)."},zr={v2:"Needs AmneziaWG on the router.",v3:"Needs AmneziaWG 3.1 on the router: install it first."};function wo(n,e){return t("span",{class:"dl-dots",title:`${e}: ${n} of 4`},[t("span",{class:"dl-dots-label"},e),t("span",{class:"dl-dots-row"},[0,1,2,3].map(o=>t("i",{class:odom.content(i,yo.map(d=>{let l=!d.needs||n[d.needs],c=d.id===e;return t("button",{type:"button",role:"radio","aria-checked":c?"true":"false","aria-disabled":l?null:"true",class:`dl-method${c?" on":""}${l?"":" off"}`,click:()=>{!l||c||(e=d.id,s(),o(d.id))}},[t("div",{class:"dl-method-head"},[t("span",{class:"dl-method-ic"},g(d.ic)),t("b",{},d.title),d.id===a?t("span",{class:"dl-pill ok"},"Current"):""]),t("p",{},d.text),t("div",{class:"dl-method-meters"},[wo(d.stealth,"Stealth"),wo(d.speed,"Speed")]),t("div",{class:"dl-method-foot"},l?[g("phone"),t("span",{},d.apps)]:[g("alert"),t("span",{},(r?Ar:zr)[d.needs])])])}));return s(),i}function ko(n,e){return t("div",{class:"dl-corehead"},[t("h3",{},n),e?t("span",{class:"dl-sub"},e):""])}var $o=[["jc","Jc"],["jmin","Jmin"],["jmax","Jmax"],["s1","S1"],["s2","S2"],["s3","S3"],["s4","S4"],["h1","H1"],["h2","H2"],["h3","H3"],["h4","H4"],["i1","I1"],["i2","I2"],["i3","I3"],["i4","I4"],["i5","I5"],["header_protection_key","HeaderProtectionKey"],["content_padding_addition","ContentPaddingAddition"],["rekey_after_time","RekeyAfterTime"],["rekey_timeout","RekeyTimeout"],["reject_after_time","RejectAfterTime"],["keepalive_timeout","KeepaliveTimeout"],["max_handshake_attempts","MaxHandshakeAttempts"],["random_trailers","RandomTrailers"],["disable_cookies","DisableCookies"]];function Nr(n){let e=c=>n[c]!=null&&n[c]!=="",o=$o.filter(([c])=>e(c));if(!o.length)return null;let a=(c,p)=>t("span",{class:"dl-pv"},[t("i",{},p),t("b",{},c==="header_protection_key"?`${n[c].slice(0,6)}••••`:n[c])]),r=(c,p,u,k)=>{let f=$o.filter(([b])=>k.includes(b)&&e(b));return f.length?t("div",{class:"dl-pgroup"},[t("div",{class:"dl-pgroup-head"},[g(p),t("b",{},c)]),t("p",{},u),t("div",{class:"dl-pvals"},f.map(([b,M])=>a(b,M)))]):""},i=Number(n.jc||0),s=(n.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",d=o.map(([c,p])=>`${p} = ${n[c]}`).join(` +`),l=t("div",{class:"dl-pgrid"},[r("Junk packets","zap",i?`${i} random packet${i===1?"":"s"} of ${n.jmin}–${n.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),r("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),r("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),r("Signatures","globe",s,["i1","i2","i3","i4","i5"]),r("Protection","lock","AmneziaWG 3.1: encrypted headers, random tails and extra padding on data packets.",["header_protection_key","content_padding_addition","random_trailers","disable_cookies"]),r("Timing","clock","Handshake and key timers vary within these ranges instead of WireGuard’s fixed values.",["rekey_after_time","rekey_timeout","reject_after_time","keepalive_timeout","max_handshake_attempts"])]);return t("details",{class:"dl-params"},[t("summary",{},[g("chevron"),t("span",{},"Current parameters"),t("span",{class:"dl-pcount"},String(o.length)),t("span",{class:"dl-spacer"}),t("button",{type:"button",class:"dl-linkbtn",click:c=>{c.preventDefault(),ue(d,"Parameters copied")}},"Copy as config")]),l])}function Eo(n,e){if(/^\s*\[.+\]\s*$/.test(n))return t("span",{class:"dl-conf-sec"},n);let o=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(n);if(!o)return document.createTextNode(n);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(n);return t("span",{},[t("span",{class:"dl-conf-k"},o[1])," ",a&&!e?t("span",{class:"dl-conf-mask"},"••••••••••••••••"):o[2]])}function Hr(n){let e=!1,o=t("pre",{class:"dl-conf"}),a=()=>dom.content(o,n.conf.split(` +`).flatMap((s,d)=>d?[` +`,Eo(s,e)]:[Eo(s,e)])),r=t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),e=!e,dom.content(r,[g(e?"x":"key"),e?"Hide key":"Show key"]),a()}},[g("key"),"Show key"]);a();let i=new Blob([n.conf]).size;return t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-filecard"},[t("span",{class:"dl-filecard-ic"},".conf"),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono dl-ellipsis"},n.filename),t("span",{class:"dl-sub"},`AmneziaWG · ${i} bytes · import it in the app`)]),D([g("download")," Download"],()=>Ee(n.filename,n.conf,"application/octet-stream"),"positive")]),t("details",{class:"dl-params"},[t("summary",{},[g("chevron"),t("span",{},"Configuration"),t("span",{class:"dl-spacer"}),r,t("button",{type:"button",class:"dl-chipbtn",click:s=>{s.preventDefault(),ue(n.conf,"Configuration copied")}},[g("copy"),"Copy"])]),o])])}async function Rr(n,e="file"){if(!n.has_private_key)return t("div",{class:"dl-hint"},"This device generated its own keys in the browser, so its full configuration only exists on that device.");let o=await Cn(n,`${n.server} · ${n.person} · ${n.name}`),a={qr:()=>t("div",{class:"dl-qr-pane"},[qe(ht(n.conf),"dl-qr"),t("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),key:()=>t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-linkbox"},[t("span",{class:"dl-mono"},o),D("Copy",()=>ue(o,"Key copied"))]),t("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>Hr(n)},r=t("div",{class:"dl-connect-body"}),i=t("div",{class:"dl-seg"}),s=d=>{i.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.id===d)),dom.content(r,a[d]())};for(let[d,l]of[["file","File"],["key","Key"],["qr","QR code"]])i.appendChild(t("button",{type:"button","data-id":d,click:()=>s(d)},l));return s(e),t("div",{class:"dl-stack gap12"},[i,r])}async function Ir(n,e,o,a){let r=Tt(o),s=n.st.people.filter(l=>l.server===e.id).reduce((l,c)=>l+c.devices.length,0);await ae(a?"Generate new disguise values?":`Switch to ${r.title}?`,`${s} AmneziaWG device${s===1?"":"s"} stop connecting until they import their configuration again (from their personal link or from you).${o==="max"?" They need an app with AmneziaWG 3.1.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await W(()=>P.serverObfuscation(e.id,o),a?"New values applied":`${r.title} applied`)&&(Q("Devices are marked “Update config” until they import again.","info",6e3),await n.refresh())}function Br(n,e){let o=n.st,a=se(String(e.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),r=se(e.mtu?String(e.mtu):"",{placeholder:"Auto",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),i=`${e.mtus.computer} for computers and routers, ${e.mtus.phone} for phones and tablets`,s=e.mtu?`Now ${i}. Empty = automatic.`:`Automatic by device type and disguise: now ${i}. Lower it if some sites hang.`,d=se(String(e.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),l=Tt(e.preset)?e.preset:void 0,c=l??"standard",p=D("",()=>Ir(n,e,c,c===l),"neutral"),u=()=>dom.content(p,c===l?[g("reset")," Generate new values"]:[`Switch to ${Tt(c).title}`]);u();let k=o.awg_state?.tools!==!1;return St("",[ko("AmneziaWG",e.ifname),he("globe","Listening","Where devices reach this core from the internet",[ne("UDP port",a,"Opened on the WAN firewall automatically.")]),he("file","In every device configuration","Changing these marks devices “Update config” until they import again",[ne("MTU",r,s),ne("Keep-alive",d,"Seconds between packets devices send to keep NAT open. 0 = off.")]),he("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Jt(o.awg,c,f=>{c=f,u()},l,k),k&&!o.awg.v3?mt("info",["This router runs an older AmneziaWG. ",t("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]):"",Nr(e.obf??{})??"",t("div",{class:"dl-row-end"},[t("span",{class:"dl-sub"},"Applies at once: every AmneziaWG device imports its configuration again."),p])]),t("details",{class:"dl-params"},[t("summary",{},[g("chevron"),t("span",{},"Tunnel"),t("span",{class:"dl-pcount"},"3")]),t("div",{class:"dl-params-body"},[ne("Interface",t("span",{class:"dl-mono"},`${e.ifname} · router ${e.address}`)),ne("Tunnel subnet",t("span",{class:"dl-mono"},e.subnet),"Device addresses come from it."),ne("Server public key",t("span",{class:"dl-keyrow"},[t("code",{class:"dl-mono"},e.public_key),D([g("copy")],()=>ue(e.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))])])],[t("span",{class:"dl-sub"},"Port, MTU and keep-alive apply at once."),D("Save",()=>n.save({port:a.value,mtu:r.value,keepalive:d.value},"AmneziaWG saved"),"positive")])}function Or(n){let e=Tt(n.preset),o=n.obf??{},a=(s,d)=>t("span",{class:`dl-segs ${d}`},[0,1,2,3].map(l=>t("i",{class:l+o[s]).map(s=>`${s.toUpperCase()} ${o[s]}`);return i.length&&r.push(i.slice(0,2).join(" · ")+(i.length>2?` +${i.length-2}`:"")),["h1","h2","h3","h4"].some(s=>o[s]&&o[s]!==String(["h1","h2","h3","h4"].indexOf(s)+1))&&r.push("H1–H4 random"),o.i1&&r.push(o.i1.includes("0x8580")?"DNS-like first packet":"Signature packets"),o.header_protection_key&&r.push("Encrypted headers"),r.length||r.push(e?.id==="off"?"Plain WireGuard":"No values yet"),t("div",{class:"dl-bento-tile dl-disg"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Disguise"),t("a",{href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(n.id)}§ion=awg`},"Change")]),t("div",{class:"dl-disg-id"},[t("span",{class:"dl-disg-ic"},g(e?.ic??"shield")),t("span",{class:"dl-stack"},[t("b",{},e?e.title:"Custom"),t("span",{class:"dl-sub"},e?e.short:"Set by hand")])]),e?t("div",{class:"dl-disg-meters"},[t("span",{},"Stealth"),a(e.stealth,"acc"),t("span",{},"Speed"),a(e.speed,"ok")]):"",t("div",{class:"dl-disg-chips"},r.map(s=>t("span",{},s)))])}var Tn={id:"awg",label:"AmneziaWG",settingsCard:Br,overviewTile:Or,connectBlock:Rr,qrText:n=>n.conf,appKey:{label:"Copy AmneziaVPN key",make:n=>Cn(n,`${n.server} · ${n.person} · ${n.name}`)},file:{label:"Download .conf",make:n=>({name:n.filename,text:n.conf})}};var jr={awg:Tn};function Ie(n){return jr[n?.core||"awg"]??Tn}function vt(n,e){return Ie(n.find(o=>o.id===e))}var Ur=2,Vt=new Set,Pn=null,Lo=!1;async function Wr(){if(document.visibilityState!=="visible"||!Vt.size)return;let n=await P.rev().catch(()=>null);if(!n)return;let e=Pn!=null&&n.rev!==Pn;Pn=n.rev,e&&Vt.forEach(o=>o())}function Yt(n){return Vt.add(n),Lo||(Lo=!0,poll.add(Wr,Ur)),()=>Vt.delete(n)}var Dn="https://unpkg.com/maplibre-gl@6.14.0/dist",_o="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",So="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",Gr={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Pt=null;function qr(n){return n.appendChild(t("link",{rel:"stylesheet",href:`${Dn}/maplibre-gl.css`})),Pt||(Pt=import(`${Dn}/maplibre-gl.mjs`).then(o=>(o.getWorkerUrl()||o.setWorkerUrl(`${Dn}/maplibre-gl-worker.mjs`),o),()=>{throw Pt=null,new Error("Could not load the map library (no internet access from this browser?)")}),Pt)}function Zt(){let n=document.documentElement.getAttribute("data-darkmode");return n!=null?n==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}var Mo=10,An="#3b82f6",Qt="#8a8a8a";function Co(n,e,o=.2,a=64){let[r,i]=n,[s,d]=e,l=s-r,c=l>180?s-360:l<-180?s+360:s,p=c-r,u=d-i,k=Math.hypot(p,u);if(k===0||o===0)return[n,[c,d]];let f=-u/k,b=p/k,M=k*o,j=(r+c)/2+f*M,I=(i+d)/2+b*M,E=[],T=Math.max(2,Math.floor(a));for(let w=0;w<=T;w+=1){let v=w/T,x=1-v;E.push([x*x*r+2*x*v*j+v*v*c,x*x*i+2*x*v*I+v*v*d])}return E}function zn(n,e){let o=new Map;for(let a of n.geo.points){if(n.person&&a.person!==n.person||n.device&&a.device!==n.device||(e==="online"?!a.online:n.now-a.ts>Gr[e]))continue;let r=n.device?`${a.city}|${a.cc}`:n.person?`${a.device}|${a.city}|${a.cc}`:a.device,i=o.get(r);(!i||a.online&&!i.online||a.online===i.online&&a.ts>i.ts)&&o.set(r,a)}return[...o.values()]}function Nn(n,e){let o=0;return zn(n,e).sort((a,r)=>Number(r.online)-Number(a.online)||r.ts-a.ts).map(a=>({...a,n:a.online?0:++o}))}var Ke=class{constructor(e,o="online",a=380){this.cb=e;this.map=null;this.gl=null;this.markers=[];this.popup=null;this.theme=null;this.resize=null;this.fitBlind=!1;this.data=null;this.fitted=!1;this.fitKey=null;this.people=[];this.slots=[];this.merged=[];this.foldedKeys=new Set;this.targetZoom=null;this.before=null;this.hiddenKey="";this.focused=null;this.range=o,this.status=t("div",{class:"dl-map-status"}),this.card=t("div",{class:"dl-map-card","aria-live":"polite"}),this.el=t("div",{class:"dl-geomap",style:`height:${a}px`},[this.status,this.card])}async mount(e){this.data=e;try{this.gl=await qr(this.el)}catch(a){this.status.textContent=a.message;return}this.map=new this.gl.Map({container:this.el,style:Zt()?_o:So,center:[e.geo.home?.lon??20,e.geo.home?.lat??50],zoom:1,renderWorldCopies:!1,attributionControl:{compact:!0},minZoom:1}),this.map.on("style.load",()=>this.layers()),this.map.on("move",()=>this.declutter()),this.map.once("idle",()=>{let a=this.el.querySelector(".maplibregl-ctrl-attrib");a?.classList.remove("maplibregl-compact-show"),a?.removeAttribute("open")}),this.resize=new ResizeObserver(()=>{!this.map||!this.el.clientWidth||!this.el.clientHeight||(this.map.resize(),this.fitBlind&&(this.fitKey=null,this.draw()))}),this.resize.observe(this.el);let o=Zt();this.theme=new MutationObserver(()=>{!this.map||Zt()===o||(o=Zt(),this.map.setStyle(o?_o:So))}),this.theme.observe(document.documentElement,{attributes:!0,attributeFilter:["data-darkmode"]})}layers(){if(this.map){this.hiddenKey="",this.map.setProjection({type:"globe"}),this.map.addSource("dl-areas",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-area",type:"circle",source:"dl-areas",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],2,6,6,26,9,140,12,900],"circle-color":["case",["get","online"],An,Qt],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],An,Qt],"circle-stroke-opacity":["case",["get","online"],.35,.15]}}),this.map.addSource("dl-trail",{type:"geojson",data:{type:"FeatureCollection",features:[]}}),this.map.addLayer({id:"dl-trail",type:"line",source:"dl-trail",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":Qt,"line-width":1.5,"line-opacity":.85,"line-dasharray":[0,2.5]}}),this.map.addSource("dl-arcs",{type:"geojson",data:{type:"FeatureCollection",features:[]}});for(let e of[!1,!0])this.map.addLayer({id:e?"dl-arc-live":"dl-arc-recent",type:"line",source:"dl-arcs",filter:["==",["get","online"],e],layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":e?An:Qt,"line-width":2,"line-opacity":.85,"line-dasharray":[2,2]}});this.draw()}}setRange(e){this.range=e,this.fitKey=null,this.draw()}update(e){this.data=e,this.draw()}destroy(){this.dropCard(),this.theme?.disconnect(),this.resize?.disconnect(),this.map?.remove(),this.map=null}groups(e){let o=new Map;for(let a of e){let r=`${a.person}|${a.city||`${a.lat.toFixed(1)},${a.lon.toFixed(1)}`}|${a.cc}`,i=o.get(r);i||(i={key:r,person:a.person,lat:a.lat,lon:a.lon,city:a.city,country:a.country,cc:a.cc,asn:a.asn,org:a.org,online:!1,ts:0,points:[]},o.set(r,i)),i.points.push(a),i.online||(i.online=a.online),i.ts=Math.max(i.ts,a.ts)}return[...o.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let e=this.data,o=this.groups(zn(e,this.range)),a=e.person||e.device?null:e.geo.home;for(let l of this.markers)l.remove();this.markers=[];let r=o.map(l=>({g:l,at:[l.lon,l.lat]}));if(this.slots=[],this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:r.map(({g:l,at:c})=>({type:"Feature",properties:{online:l.online,key:l.key},geometry:{type:"Point",coordinates:c}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:a?r.map(({g:l,at:c})=>({type:"Feature",properties:{online:l.online,person:l.person,key:l.key},geometry:{type:"LineString",coordinates:Co([a.lon,a.lat],c)}})):[]}),a){let l=t("span",{class:"dl-mk-host"});l.innerHTML=`${kt("server","dl-mk-host-ic")}`;let c=t("div",{class:"dl-mk-hub",title:`Home router${a.city?` · ${a.city}`:""}${a.org?` · ${a.org}`:""}`},[l,t("span",{class:"dl-mk-label chip"},a.city||"Home")]);c.addEventListener("mouseenter",()=>this.showMerged(a.city||"the server")),c.addEventListener("mouseleave",()=>this.focus(this.focused)),c.addEventListener("click",()=>this.zoomToMerged()),this.add(c,[a.lon,a.lat],!0)}let i=e.device?[...r].sort((l,c)=>Number(l.g.online)-Number(c.g.online)||l.g.ts-c.g.ts):[];this.map.getSource("dl-trail")?.setData({type:"FeatureCollection",features:i.length>1?[{type:"Feature",properties:{},geometry:{type:"LineString",coordinates:i.slice(1).flatMap((l,c)=>Co(i[c].at,l.at))}}]:[]});let s=new Map(e.device?Nn(e,this.range).map(l=>[`${l.city}|${l.cc}`,l.n]):[]);this.people=[];for(let{g:l,at:c}of r){let p=l.points.length,u=e.people.find(M=>M.id===l.person);if(e.person){let M=e.device?this.stepMarker(l,c,u,s.get(`${l.points[0].city}|${l.points[0].cc}`)??0):this.placeMarker(l,c,u);this.add(M,c);continue}let k=l.points.map(M=>u?.devices.find(j=>j.id===M.device)?.kind??"other"),f=t("span",{class:"dl-mk-badge"});f.innerHTML=p<=2?k.map(M=>kt(M,"dl-mk-badge-ic")).join(""):String(p);let b=t("button",{type:"button",class:`dl-mk${l.online?" online":""}`,"aria-label":`${u?.name??"Someone"}: ${p} device${p===1?"":"s"} in ${l.city||"an unknown city"}`},[t("span",{class:"dl-mk-av"},[De(u?.name??"?"),f]),t("span",{class:"dl-mk-label below"},l.city||l.cc||"?")]);b.addEventListener("mouseenter",()=>this.focus(l.person)),b.addEventListener("mouseleave",()=>this.focus(null)),this.people.push({el:b,person:l.person}),b.addEventListener("click",M=>{M.stopPropagation(),this.openPopup(l,c,b)}),this.add(b,c,!1,u?.name??"Someone",`${l.city||l.cc||"?"} · ${l.online?"now":ie(l.ts,e.now)}`,l.key)}this.declutter();let d=r.map(l=>l.g.key).sort().join(";");if(d!==this.fitKey&&!this.popup){let l=this.fitted&&!this.fitBlind;if(this.fitBlind=!this.el.clientWidth||!this.el.clientHeight,this.fitKey=d,this.fitted=!0,a&&!r.length){let c={center:[a.lon,a.lat],zoom:12};l?this.glide(12,()=>this.map.flyTo({...c,duration:1200})):this.map.jumpTo(c)}else{let c=r.map(p=>p.at);a&&(c.length===0||this.range!=="online"||r.some(p=>p.g.online))&&c.push([a.lon,a.lat]),this.fit(c,l)}}this.status.textContent=r.length||a?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none",this.focus(this.focused&&this.people.some(l=>l.person===this.focused)?this.focused:null)}add(e,o,a=!1,r,i,s){s&&this.foldedKeys.has(s)&&e.classList.add("merged"),e.dataset.key=s??"",e.classList.add("dl-mk-new"),requestAnimationFrame(()=>requestAnimationFrame(()=>e.classList.remove("dl-mk-new")));let d=new this.gl.Marker({element:e}).setLngLat(o).addTo(this.map);this.markers.push(d),this.slots.push({marker:d,el:e,at:o,fixed:a,who:r,where:i})}declutter(){if(!this.map)return;let e=this.slots.map(s=>{let d=this.map.project(s.at),l=s.el.querySelector(":scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile");return{x:d.x,y:d.y,r:(l?.offsetWidth||24)/2+3,fixed:s.fixed}}),o=e.filter(s=>s.fixed);this.merged=[],this.foldedKeys.clear();let a=this.targetZoom==null?1:Math.min(1,2**(this.targetZoom-this.map.getZoom()));e.forEach((s,d)=>{if(s.fixed)return;let l=this.slots[d],c=l.el.classList.contains("merged")?12:6,p=o.find(k=>Math.hypot(k.x-s.x,k.y-s.y)*as.fixed)?.el.querySelector(".dl-mk-host-n");i&&(i.textContent=this.merged.length?String(this.merged.length):"",i.classList.toggle("on",this.merged.length>0)),Fr(e).forEach(([s,d],l)=>{let c=this.slots[l];c.fixed||(e[l].fixed&&([s,d]=[0,0]),c.marker.setOffset([s,d]),Kr(c.el,s,d))})}closePopup(e=!1){let o=this.popup;if(!o||o.card.classList.contains("leaving"))return;o.card.classList.add("leaving"),setTimeout(()=>{this.popup===o&&this.dropCard()},140);let a=this.before;if(this.before=null,!a)return;let r=()=>this.map?.flyTo({...a,duration:800});if(!e)return r();let i=!1,s=()=>{i||(i=!0,window.removeEventListener("pointerup",s,!0),window.removeEventListener("pointercancel",s,!0),setTimeout(r,0))};window.addEventListener("pointerup",s,!0),window.addEventListener("pointercancel",s,!0),setTimeout(s,1500)}dropCard(){this.popup?.off(),this.popup?.card.remove(),this.popup=null}showMerged(e){this.merged.length&&(dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},`Near ${e}`)," · zoom in to see them"]),...this.merged.map(o=>t("div",{class:"dl-map-card-row"},[t("span",{},o.who),t("span",{class:"dl-faint"},o.where)]))]),this.card.classList.add("on"))}zoomToMerged(){if(!this.map||!this.merged.length)return;let e=Math.log2(Math.max(...this.merged.map(r=>r.need)))+.3,o=[this.slots.find(r=>r.fixed).at,...this.merged.map(r=>r.at)],a=[o.reduce((r,i)=>r+i[0],0)/o.length,o.reduce((r,i)=>r+i[1],0)/o.length];this.map.flyTo({center:a,zoom:Math.min(12,this.map.getZoom()+e),duration:900})}placeMarker(e,o,a){let r=this.data.now,i=[...e.points].sort((u,k)=>Number(k.online)-Number(u.online)||k.ts-u.ts)[0],s=a?.devices.find(u=>u.id===i.device)?.kind??"other",d=e.points.length,l=t("span",{class:"dl-mk-tile"});l.innerHTML=kt(s,"dl-mk-tile-ic")+(d>1?`${d}`:"");let c=e.online?"now":ie(e.ts,r),p=t("button",{type:"button",class:`dl-mk place${e.online?" online":""}`,style:e.online?null:`--dl-mk-fade:${Math.max(.4,1-.6*(r-e.ts)/(30*86400)).toFixed(2)}`,"aria-label":`${d} device${d===1?"":"s"} in ${e.city||"an unknown city"}, ${c}`},[l,t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",t("span",{class:"dl-mk-when"},c)])]);return p.addEventListener("click",u=>{u.stopPropagation(),this.openPopup(e,o,p)}),p}stepMarker(e,o,a,r){if(e.online)return this.placeMarker(e,o,a);let i=ie(e.ts,this.data.now),s=t("button",{type:"button",class:"dl-mk place step","aria-label":`${r}: ${e.city||"an unknown city"}, ${i}`},[t("span",{class:"dl-mk-tile sm"},String(r)),t("span",{class:"dl-mk-label below"},[e.city||e.cc||"?",` · ${i}`])]);return s.addEventListener("click",d=>{d.stopPropagation(),this.openPopup(e,o,s)}),s}focus(e){this.focused=e;for(let s of this.people)s.el.classList.toggle("dim",!!e&&s.person!==e),s.el.classList.toggle("hl",s.person===e);let o=e?["case",["==",["get","person"],e],.85,.15]:.85;for(let s of["dl-arc-live","dl-arc-recent"])this.map?.getLayer(s)&&this.map.setPaintProperty(s,"line-opacity",o);if(this.card.classList.toggle("on",!!e),!e||!this.data)return;let a=this.data,r=a.people.find(s=>s.id===e),i=zn(a,this.range).filter(s=>s.person===e).sort((s,d)=>Number(d.online)-Number(s.online)||d.ts-s.ts);dom.content(this.card,[t("div",{class:"dl-map-card-head"},[t("b",{},r?.name??e),` · ${i.length} device${i.length===1?"":"s"}`]),...i.map(s=>t("div",{class:"dl-map-card-row"},[t("span",{},r?.devices.find(d=>d.id===s.device)?.name??"Device"),t("span",{class:"dl-faint"},`${s.city||s.cc||"?"} · ${s.online?"now":ie(s.ts,a.now)}`)]))])}fit(e,o=!1){if(!e.length)return;let a=(c,p)=>{let u=Math.PI/180,k=(p[1]-c[1])*u,f=(p[0]-c[0])*u,b=Math.sin(k/2)**2+Math.cos(c[1]*u)*Math.cos(p[1]*u)*Math.sin(f/2)**2;return 12742*Math.asin(Math.sqrt(b))},r=[e.reduce((c,p)=>c+p[0],0)/e.length,e.reduce((c,p)=>c+p[1],0)/e.length],i=e;if(e.length>=5){let c=[...e].sort((p,u)=>a(r,p)-a(r,u));i=c.slice(0,Math.ceil(c.length*.9))}let s=new this.gl.LngLatBounds(i[0],i[0]);i.forEach(c=>s.extend(c));let d=this.el.clientHeight||380,l={padding:{top:Math.min(60,d/5),bottom:Math.min(40,d/8),left:48,right:48},maxZoom:this.data?.person?11:12};o?this.glide(this.map.cameraForBounds(s,l)?.zoom??null,()=>this.map.fitBounds(s,{...l,duration:1200})):this.map.fitBounds(s,{...l,duration:0})}glide(e,o){this.targetZoom=e,this.declutter(),this.map.once("moveend",()=>{this.targetZoom=null,this.declutter()}),o()}openPopup(e,o,a){let r=this.data,i=[e.city,e.cc||e.country].filter(Boolean).join(", "),s=[...new Set(e.points.map(w=>w.person))],d=e.points.sort((w,v)=>Number(v.online)-Number(w.online)||v.ts-w.ts).map(w=>{let v=r.people.find($=>$.id===w.person),x=v?.devices.find($=>$.id===w.device);return t("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(w.person,w.device)},[t("span",{class:`dl-pop-dot${w.online?" on":""}`}),t("span",{class:"dl-pop-name"},[t("b",{},v?.name??w.person),` · ${x?.name??"device"}`]),t("span",{class:"dl-faint dl-nowrap"},w.online?"now":ie(w.ts,r.now))])}),l=t("div",{class:"dl-pop"},[t("div",{class:"dl-pop-head"},[t("span",{class:"dl-pop-net"},g("globe")),t("div",{class:"dl-stack"},[t("strong",{},e.org||"Unknown network"),t("span",{class:"dl-faint"},[e.asn?`AS${e.asn} · `:"",i?`${i} · approximate`:"approximate location"])])]),t("div",{class:"dl-pop-list"},d),s.length===1?t("div",{class:"dl-pop-actions"},[t("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(s[0])},`Open ${r.people.find(w=>w.id===s[0])?.name??"person"}`)]):""]),c=this.map.getZoom();c{if(!k)return;let w=k.getBoundingClientRect(),v=u.getBoundingClientRect(),x=w.left+w.width/2,$=w.top+w.height/2;p.classList.toggle("away",xv.right||$v.bottom);let m=p.offsetWidth,h=p.offsetHeight,N=w.top-h-12>=8||w.top>window.innerHeight-w.bottom,C=Math.min(Math.max(8,x-m/2),window.innerWidth-m-8);p.classList.toggle("above",N),p.classList.toggle("below",!N),p.style.left=`${C}px`,p.style.top=`${N?w.top-h-12:w.bottom+12}px`,p.style.setProperty("--tip-x",`${x-C}px`)},b=w=>{w.target?.closest(".dl-popcard, .maplibregl-marker")||this.closePopup(!0)},M=w=>{w.key==="Escape"&&this.closePopup()},j=w=>{w.target instanceof Element&&w.target.closest(".dl-popcard")||this.closePopup()},I=()=>this.closePopup();this.map.on("move",f),window.addEventListener("scroll",j,{capture:!0,passive:!0}),window.addEventListener("resize",f),document.addEventListener("pointerdown",b,!0),document.addEventListener("keydown",M);let E=Ae(I);window.addEventListener("pagehide",I),this.popup={card:p,off:()=>{this.map?.off("move",f),window.removeEventListener("scroll",j,!0),window.removeEventListener("resize",f),document.removeEventListener("pointerdown",b,!0),document.removeEventListener("keydown",M),E(),window.removeEventListener("pagehide",I)}};let T=window.setInterval(()=>{if(this.popup?.card!==p)return clearInterval(T);(!u.isConnected||!u.getClientRects().length)&&this.dropCard()},400);f()}};function Fr(n,e=6){let o=n.map(a=>({x:a.x,y:a.y}));for(let a=0;a<16;a++){let r=!1;for(let i=0;i[a.x-n[r].x,a.y-n[r].y])}function Kr(n,e,o){let a=n.querySelector(":scope > .dl-mk-ptr"),r=Math.hypot(e,o);if(r<1){a?.remove();return}a||(a=t("span",{class:"dl-mk-ptr"},[t("i",{class:"line"}),t("i",{class:"spot"})]),n.prepend(a));let i=a.firstElementChild,s=a.lastElementChild;i.style.width=`${r}px`,i.style.transform=`rotate(${Math.atan2(-o,-e)}rad)`,s.style.transform=`translate(${-e}px, ${-o}px)`}function bt(n,e,o=!0){let a=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],r=t("div",{class:"dl-seg",role:"tablist"});for(let[i,s]of a)i==="online"&&!o||r.appendChild(t("button",{type:"button",role:"tab",class:i===n?"on":"","data-v":i,click:()=>{r.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.v===i)),e(i)}},s));return r}function xt(n){return`${L.url("admin/network/dawnline/server")}?${n?`server=${encodeURIComponent(n)}&`:""}section=people`}function ke(n,e){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(n)}${e?`&device=${encodeURIComponent(e)}`:""}`}function Jr(n){return n?new Date(n*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function To(n,e,o=!1){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("button",{type:"button",class:`dl-kvrow-v copy${o?" dl-mono":""}`,title:"Copy",click:()=>ue(e,`${n} copied`)},[t("span",{},e),g("copy")])])}function Xt(n,e){return t("div",{class:"dl-kvrow"},[t("span",{class:"dl-kvrow-k"},n),t("span",{class:"dl-kvrow-v"},e)])}var Po={connect:["ok","Connected","plug"],disconnect:["","Went offline","plug"],roam:["","Changed network","network"],device_added:["ok","Added","plus"],device_removed:["","Removed","trash"],device_keys:["","New keys","reset"]};function Vr(n,e,o){let a=n.filter(r=>r.device===e&&Po[r.type]).reverse().slice(0,12);return a.length?t("div",{class:"dl-dev-log"},a.map(r=>{let[i,s,d]=Po[r.type],l=r.type==="connect"?[r.detail?t("span",{class:"dl-muted"},` from ${r.detail}`):"",r.where?t("span",{class:"dl-muted"},` · ${r.where}`):""]:r.type==="roam"?[t("span",{class:"dl-muted"},` · ${r.detail??""}`)]:r.type==="device_added"||r.type==="device_removed"||r.type==="device_keys"?[t("span",{class:"dl-muted"},Te(r)==="portal"?" on the portal":Te(r)==="admin"?" by you":"")]:[],c=new Date(r.ts*1e3);return t("div",{class:`dl-dev-log-row${Te(r)==="admin"?" dl-ev-by-admin":""}`},[Te(r)==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):t("span",{class:`dl-ev-tile ev ${i}`},g(d)),t("span",{class:"dl-row-main"},[t("span",{},s),...l]),t("span",{class:"dl-faint dl-nowrap",title:c.toLocaleString()},ie(r.ts,o))])})):t("div",{class:"dl-sub"},"No activity yet.")}async function Do(n,e,o){let a=await P.status(1).catch(()=>null),r=a?.people.find(s=>s.id===n),i=r?.devices.find(s=>s.id===e);a&&r&&i&&Be(r,i,{...o,geo:a.geo,now:a.now,today:Re(a.series),core:vt(a.servers,r.server)})}async function Be(n,e,o){let a=await W(()=>P.deviceConfig(e.id));if(!a)return;let r=o.core??Ie(null),i=e,s=n,d=o.geo,l=o.now,c=o.today??Ne(new Date),p=await r.connectBlock(a),u=t("div",{class:"dl-drawer-title"}),k=t("div",{}),f=t("div",{}),b=t("div",{},t("div",{class:"dl-sub"},"Loading…")),M=[],j=U=>{M=U.filter(q=>q.device===i.id),dom.content(b,Vr(U,i.id,l))},I=async(U=!1)=>{let q=o.events?.();if(q&&!U)return j(q);let oe=await P.events(5e3).catch(()=>null);oe&&j(oe.events)},E="30d",T=null,w=t("div",{class:"dl-dplaces"}),v=()=>({geo:d,people:[s],now:l??Date.now()/1e3,person:s.id,device:i.id}),x=()=>{if(!d?.enabled)return;let U=Nn(v(),E);dom.content(w,U.length?U.map(q=>t("div",{class:"dl-dplace-row"},[t("span",{class:`dl-dplace-n${q.online?" live":""}`},q.online?g(i.kind):String(q.n)),t("span",{class:"dl-row-main dl-stack"},[t("span",{},[q.city||q.cc||"Unknown city",q.org?t("span",{class:"dl-muted"},` · ${q.org}`):""]),t("span",{class:"dl-mono dl-faint"},q.ip)]),t("span",{class:q.online?"dl-dplace-now":"dl-faint dl-nowrap"},q.online?"now":ie(q.ts,l))])):t("div",{class:"dl-sub"},"No locations in this period."))},$=()=>{dom.content(u,[t("span",{class:`dl-dcard-ic${i.online?" on":""}`},g(i.kind)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h3",{},i.name),D([g("edit")],()=>N(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),t("span",{class:"dl-sub"},`${s.name} · ${je[i.kind]}`)])]);let U=i.spark.reduce((q,oe)=>q+oe,0);dom.content(k,t("div",{class:"dl-dstats"},[t("div",{class:"dl-dstats-cell wide"},[t("span",{class:"dl-metric-label"},"Status"),Wt(i,l,"Waiting for the first connection")]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"This month"),t("b",{},te(i.month[0]+i.month[1])),t("span",{class:"dl-sub dl-mono"},`↓ ${te(i.month[1])} ↑ ${te(i.month[0])}`)]),t("div",{class:"dl-dstats-cell"},[t("span",{class:"dl-metric-label"},"Last 7 days"),t("b",{},te(U)),vo(i.spark,120,22,c)])])),dom.content(f,t("div",{class:"dl-kv2"},[To("Tunnel address",i.address),i.hostname&&s.access!=="internet"?To("Local address",i.hostname):"",i.endpoint&&!d?.points.some(q=>q.device===i.id&&q.ip===i.endpoint)?Xt("Client IP",i.endpoint):"",Xt("Total",t("span",{class:"dl-kv-act"},[`↓ ${te(i.total[1])} · ↑ ${te(i.total[0])}`,t("button",{type:"button",class:"dl-linkbtn danger",click:()=>gt("device",i.id,i.name,()=>setTimeout(h,300))},"Reset")])),Xt("Added",`${Jr(i.created)} · ${i.created_by==="portal"?"from the portal":"by you"}`),Xt("Public key",t("span",{class:"dl-mono dl-faint"},a.amnezia.client_pub_key?`${a.amnezia.client_pub_key.slice(0,16)}…`:"—"))])),dom.content(C,[D([g(i.disabled?"play":"pause"),i.disabled?" Enable":" Disable"],async()=>{await W(()=>P.deviceUpdate(i.id,void 0,!i.disabled),i.disabled?"Device enabled":"Device disabled")&&await h()},"neutral",i.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),D([g("key")," New keys"],async()=>{if(!await ae("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;await W(()=>P.deviceRotate(i.id),"New keys generated")&&(o.refresh(),B.close(),await Do(s.id,i.id,o))}),t("span",{class:"dl-spacer"}),D([g("trash")," Remove"],async()=>{await ae(`Remove ${i.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await W(()=>P.deviceDelete(i.id),"Device removed")&&(B.close(),o.refresh())},"negative")])},m=async()=>{let U=await P.status(1).catch(()=>null),q=U?.people.find(_=>_.id===s.id),oe=q?.devices.find(_=>_.id===i.id);!U||!q||!oe||(s=q,i=oe,d=U.geo,l=U.now,c=Re(U.series),$(),T?.update(v()),x())},h=async()=>{await m(),o.refresh()},N=()=>{let U=t("input",{type:"text",class:"cbi-input-text",value:i.name,maxlength:48});re(`Rename ${i.name}`,[t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},"Name"),t("div",{class:"cbi-value-field"},U)])],[le()," ",D("Save",async()=>{await W(()=>P.deviceUpdate(i.id,U.value,void 0),"Renamed")&&(ce(),await h())},"positive")]),setTimeout(()=>U.select(),50)},C=t("div",{class:"dl-drawer-actions"}),R=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Connect")]),i.config_stale?t("div",{class:"dl-note warn"},[g("alert"),t("span",{},"This device has an older configuration: networks or DNS changed since it was set up. Import it again with the QR code, key or file below.")]):"",p]),Z=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Activity"),t("div",{class:"dl-dsec-actions"},[t("button",{type:"button",class:"dl-linkbtn",click:()=>Ue({people:[s]},M,"csv",i.id)},"Export"),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>Fe(`Clear ${i.name}'s activity`,`Removes events about ${i.name}.`,{device:i.id},()=>{I(!0),o.refresh()})},"Clear"),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),b]),G=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},t("h4",{},"Details")),f]),V="";d?.enabled&&(T=new Ke({openPerson:U=>location.href=ke(U),openDevice:(U,q)=>location.href=ke(U,q)},E,220),V=t("section",{class:"dl-dsec"},[t("div",{class:"dl-dsec-head"},[t("h4",{},"Locations"),bt(E,U=>{E=U,T?.setRange(U),x()},!1)]),t("div",{class:"dl-dmap"},T.el),w]),x());let z=!i.handshake||i.config_stale,F=t("div",{class:"dl-stack gap16"},z?[k,R,G,V,Z]:[k,G,V,Z,R]);I();let X=()=>{m(),I()},de=Yt(X),fe=window.setInterval(X,3e4),B=lo(u,F,C,()=>{clearInterval(fe),de(),T?.destroy()});$(),T&&requestAnimationFrame(()=>T?.mount(v()))}function Ao(n,e,o,a){let r=a.core??Ie(null),i=()=>W(()=>P.deviceConfig(o.id)),s=[{label:"Show QR code",icon:g("qr"),run:async()=>{let d=await i();d&&re(`${o.name} · QR code`,t("div",{class:"dl-qr-pane"},[qe(ht(r.qrText(d)),"dl-qr"),t("span",{class:"dl-sub"},"Scan with AmneziaVPN or AmneziaWG on the device.")]),le("Close"))}},{label:r.file.label,icon:g("download"),run:async()=>{let d=await i();if(!d)return;let l=r.file.make(d);Ee(l.name,l.text,"application/octet-stream")}},r.appKey?{label:r.appKey.label,icon:g("copy"),run:async()=>{let d=await i();d&&ue(await r.appKey.make(d),"Key copied")}}:null,null,{label:"Rename",icon:g("edit"),run:()=>Be(e,o,a)},{label:"New keys",icon:g("key"),run:async()=>{await ae("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0)&&await W(()=>P.deviceRotate(o.id),"New keys generated")&&a.refresh()}},{label:o.disabled?"Enable":"Disable",icon:g(o.disabled?"play":"pause"),warn:!o.disabled,run:async()=>{await W(()=>P.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&a.refresh()}},{label:"Delete",icon:g("trash"),danger:!0,run:async()=>{await ae(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await W(()=>P.deviceDelete(o.id),"Device removed")&&a.refresh()}}];we(n,s)}function rt(n,e){let o=t("input",{type:"text",class:"cbi-input-text",placeholder:je.phone,maxlength:48}),a="phone",r=t("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},ao.map(s=>t("button",{type:"button",role:"radio",class:s===a?"on":"","aria-checked":s===a?"true":"false","data-kind":s,click:()=>{a=s,r.querySelectorAll("button").forEach(d=>{let l=d.dataset.kind===s;d.classList.toggle("on",l),d.setAttribute("aria-checked",l?"true":"false")}),o.placeholder=je[s]}},[g(s),t("span",{},je[s])]))),i=n.devices.length>=n.device_limit;re(`Add a device for ${n.name}`,[i?t("p",{class:"dl-hint"},`${n.name} already has ${n.devices.length} of ${n.device_limit} devices. As admin you can still add one.`):"",t("div",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Type"),r]),t("label",{class:"dl-fld"},[t("span",{class:"dl-fld-label"},"Name"),o])],[le()," ",D("Add device",async()=>{let s=o.value.trim()||o.placeholder.replace(/^e\.g\. /,""),d=await W(()=>P.deviceCreate(n.id,s,a));d&&(ce(),Q(`${s} added`,"success",3e3),e.refresh(),await Do(n.id,d.id,e))},"positive")]),setTimeout(()=>o.focus(),50)}var Ge=1080,At=1512,Oe=96,Yr="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Zr="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Dt=n=>n.replace(/[&<>"']/g,e=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[e]);function Qr(n,e,o){let a=new URL(o),r=a.pathname.slice(1),i=Math.min(92,Math.floor((Ge-2*Oe)/(.58*(4+n.name.length)))),s=Ge-2*Oe,d=392,l=40,c=ht(o,2).replace("`${M}`;return``+p(Oe+82,Oe+42,36,"#a3a3a3",Dt(e))+p(Oe,276,i,"#ffffff",`Hi, ${Dt(n.name)}`,'font-weight="600"')+p(Oe,340,40,"#8a8a8a",`Scan to connect to ${Dt(e)}`)+``+c+`${Dt(r)}`+p(Ge/2,d+s+156,34,"#737373",Dt(a.host),'text-anchor="middle"')+""}async function Xr(n){let e=new Image;e.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`,await e.decode();let o=document.createElement("canvas");return o.width=Ge,o.height=At,o.getContext("2d").drawImage(e,0,0,Ge,At),new Promise((a,r)=>o.toBlob(i=>i?a(i):r(new Error("Could not draw the card")),"image/png"))}async function zo(n){let e=await W(()=>P.personLinks(n));return e?e.link?{link:e.link,links:e.links??[]}:(Q("The personal portal is off. Turn it on in Settings.","warning"),null):null}async function en(n){let e=await zo(n);e&&await ue(e.link,"Personal link copied")}async function zt(n,e,o={}){let a=n.link,r=n.links;if(a===void 0){let f=await zo(n.id);if(!f)return;a=f.link,r=f.links}if(!a){Q("The personal portal is off. Turn it on in Settings.","warning");return}let i=a,s=await W(()=>Xr(Qr(n,e,i)));if(!s)return;let d=new File([s],`${n.id}-invite.png`,{type:"image/png"}),l=URL.createObjectURL(s),c=navigator,p=!!c.canShare?.({files:[d]}),u=()=>{URL.revokeObjectURL(l),ce()},k=p?D([g("link")," Share card"],async()=>{try{await c.share({files:[d],title:`Invite ${n.name}`})}catch{}},"positive"):D([g("download")," Download card"],()=>Ee(d.name,s),"positive");re(o.title??`Invite ${n.name}`,t("div",{class:"dl-invite"},[t("img",{src:l,alt:`Invite card for ${n.name}`}),t("div",{class:"dl-invite-side"},[t("p",{class:"dl-muted"},o.lead??`Send ${n.name} the card or the link. They open it, add their devices and connect — no account needed.`),t("button",{type:"button",class:"dl-invite-link",title:"Copy link",click:()=>ue(i,"Personal link copied")},[t("span",{},i.replace(/^https:\/\//,"")),g("copy")]),...(r??[]).filter(f=>f!==i).map(f=>t("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>ue(f,"Link copied")},[t("span",{},f.replace(/^https?:\/\//,"")),t("span",{class:`dl-pill ${f.startsWith("http:")?"warn":""}`},f.startsWith("http:")?"HTTP":"Also"),g("copy")])),t("ol",{class:"dl-invite-steps"},[t("li",{},["Install ",t("b",{},"AmneziaVPN")," on the device"]),t("li",{},"Open the link or scan the code"),t("li",{},"Add the device and connect")]),t("div",{class:"dl-invite-actions"},[k,D([g("copy")," Copy link"],()=>ue(i,"Personal link copied"))])])]),[t("button",{class:"cbi-button cbi-button-neutral",click:u},"Done")],"wide")}function Nt(n,e){let o=n.servers.find(l=>l.id===e)??n.servers[0],a=n.people.filter(l=>l.server===o.id),r=new Set(a.map(l=>l.id)),i=a.flatMap(l=>l.devices),s=l=>a.reduce((c,p)=>{let u=l(p);return[c[0]+u[0],c[1]+u[1]]},[0,0]),d=o.series?.[o.series.length-1];return{...n,servers:[o],people:a,series:o.series??n.series,events:n.events.filter(l=>l.person?r.has(l.person):!0),geo:{...n.geo,points:n.geo.points.filter(l=>r.has(l.person))},totals:{people:a.length,devices:i.length,online:i.filter(l=>l.online).length,active:a.filter(l=>l.state==="active").length,today:d?[d.rx,d.tx]:[0,0],month:s(l=>l.month)}}}var Hn=class{constructor(){this.n=0;this.shown=0}next(){return++this.n}take(e){return e{let l=e.next(),c=await n.fetch(d).catch(()=>null);return c==null||!e.take(l)?null:(n.apply(c,s),c)},a=(s=!1)=>o(s,!1),r=()=>n.active?.()??!0?o(!0,!1):Promise.resolve(null);poll.add(r,n.every);let i=n.live?Yt(()=>void((n.active?.()??!0)&&o(!0,!0))):null;return{refresh:a,claim:()=>e.claim(),stop:()=>{poll.remove(r),i?.()}}}function wt(n){let e=document.activeElement;return!!n&&!!e&&e!==document.body&&n.contains(e)}function Le(n,e,o=!1){return o&&wt(n)?!1:(dom.content(n,e),!0)}function No(n,e){let o=n,r=t("div",{class:"dl-choices"},[{v:"internet",ic:"globe",text:"Browse the internet through your router. No access to devices at home."},{v:"lan",ic:"home",text:"Reach devices at home (NAS, printer, cameras). Internet stays on their own connection."},{v:"both",ic:"shield",text:"Home devices and the internet, all through your router."}].map(i=>t("button",{type:"button",class:`dl-choice${i.v===o?" selected":""}`,"data-v":i.v,click:()=>{o=i.v,r.querySelectorAll(".dl-choice").forEach(s=>s.classList.toggle("selected",s.dataset.v===i.v)),e?.(i.v)}},[t("span",{class:"dl-choice-title"},[g(i.ic),nt[i.v]]),t("span",{class:"dl-choice-text"},i.text)])));return{el:r,get:()=>o}}function ei(n){let e=n.devices.length,o=Math.max(1,n.device_limit,e),a=Math.min(160,o*22+(o-1)*3);return t("div",{class:"dl-slotbar",title:`${e} of ${n.device_limit} devices`},[t("span",{class:"dl-slotbar-segs",style:`width: ${a}px`},Array.from({length:o},(r,i)=>t("i",{class:i>=n.device_limit?"over":in.state==="server_off"?n.paused:!["active","quota","expired"].includes(n.state),Rn=n=>n.state==="server_off"?n.paused:n.state!=="active",Ro=n=>Rn(n)?n.state==="server_off"?"paused":n.state:null;function ti(n,e){let o=tt(n.expires,e);return n.state==="quota"||n.state==="expired"||o!=null&&o<=Math.max(n.expire_warn,3)||!!n.quota_limit&&n.quota_used>=n.quota_limit*.9}function Io(n,e){return dt(n&&Sn(n,e)>=0?n:e,1)}var Bo=n=>n.people.map(e=>e.id).sort().join(" "),Oo=!1,it=class{constructor(){this.list=t("div",{class:"dl-plist",role:"list"});this.filter=["all","online","attention","paused"].find(e=>e===new URLSearchParams(location.search).get("filter"))??"all";this.sort="seen";this.noFooter=!0;this.serverId=null;this.el=null}async load(){return P.status(30)}scope(e){return this.serverId?Nt(e,this.serverId):e}embed(e,o){return this.serverId=o,this.render(e)}person(e){return this.st.people.find(o=>o.id===e)}get today(){return Re(this.st.series)}deviceOpts(e){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:vt(this.st.servers,e.server)}}take(e,o){let a=this.scope(e),r=Bo(a)!==Bo(this.st);this.st=a,r?this.rebuild():(this.paintCards(o),this.decorate(o))}async update(){await this.poller?.refresh()}async refresh(){this.poller?.claim();let e=await P.status(30).catch(()=>null);e&&(this.st=this.scope(e),this.rebuild())}rebuild(){let e=new Map;for(let a of Array.from(this.list.children))a.dataset.sid&&e.set(a.dataset.sid,a);let o=this.st.people.map(a=>{let r=e.get(a.id)??t("div",{class:"dl-card",role:"listitem","data-sid":a.id});return this.renderCard(r,a.id)});dom.content(this.list,o.length?o:t("div",{class:"dl-plist-none"},this.st.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people.")),this.decorate()}paintCards(e=!1){for(let o of this.st.people){let a=this.card(o.id);a&&!(e&&wt(a))&&this.renderCard(a,o.id)}}card(e){return this.list.querySelector(`[data-sid="${CSS.escape(e)}"]`)}render(e){let o=this.scope(e);this.st=o;let a=this,r=t("select",{class:"dl-select","aria-label":"Sort",change:s=>{a.sort=s.target.value,a.decorate()}},[t("option",{value:"seen"},"Last seen"),t("option",{value:"name"},"Name"),t("option",{value:"usage"},"Usage")]),i=t("div",{class:"dl-root"},[a.serverId?"":t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"People"),t("span",{class:"dl-muted dl-people-count"},this.countText())]),o.servers.length?D([g("plus")," Add person"],()=>a.openCreate(),"add"):""]),o.servers.length?"":t("div",{class:"alert-message warning"},["No server yet. ",t("a",{href:L.url("admin/network/dawnline/server")},"Run the setup wizard")," before adding people."]),t("div",{class:"dl-toolbar"},[t("div",{class:"dl-seg dl-people-tabs",role:"tablist"}),t("div",{class:"dl-toolbar-end"},[r,a.serverId?D([g("plus")," Add person"],()=>a.openCreate(),"add"):""])]),this.list]);return this.el=i,this.rebuild(),this.poller??(this.poller=Je({fetch:()=>P.status(30),every:30,live:!0,active:()=>!!a.el?.isConnected,apply:(s,d)=>a.take(s,d)})),!Oo&&new URLSearchParams(location.search).get("add")&&(Oo=!0,setTimeout(()=>a.openCreate(),100)),Promise.resolve(i)}countText(){let e=this.st.totals;return`${e.people} ${e.people===1?"person":"people"} · ${e.devices} device${e.devices===1?"":"s"} · ${e.online} online`}decorate(e=!1){let o=this.el?.querySelector(".dl-people-count");o&&(o.textContent=this.countText());let a=this.st.people,r=this.today,i=f=>ti(f,r),s={all:a.length,online:a.filter(f=>f.online>0).length,attention:a.filter(i).length,paused:a.filter(f=>Ho(f)).length},d=this.el?.querySelector(".dl-people-tabs");if(d&&!(e&&wt(d))){let f={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(d,Object.keys(f).map(b=>t("button",{type:"button",role:"tab",class:b===this.filter?"on":"",click:()=>{this.filter=b,this.decorate()}},[f[b],t("b",{class:b==="attention"&&s[b]?"warn":""},String(s[b]))])))}let l=f=>!(this.filter==="online"&&!f.online||this.filter==="attention"&&!i(f)||this.filter==="paused"&&!Ho(f)),c=f=>Ro(f)==="paused"?2:Rn(f)?1:0,p=[...a].sort((f,b)=>c(f)-c(b)||(this.sort==="name"?f.name.localeCompare(b.name):this.sort==="usage"?b.month[0]+b.month[1]-(f.month[0]+f.month[1]):b.online-f.online||b.last_seen-f.last_seen)),u=0;for(let f of p){let b=this.card(f.id);if(!b)continue;this.list.appendChild(b),b.classList.toggle("dl-off",Rn(f));let M=l(f);b.classList.toggle("dl-filtered",!M),M&&u++}let k=this.el?.querySelector(".dl-people-none")??null;a.length&&!u?(k??(k=t("div",{class:"dl-empty dl-people-none"},t("p",{},"No one here right now."))),k.previousElementSibling!==this.list&&this.list.after(k)):k?.remove()}async quick(e,o,a){await W(()=>P.personUpdate(e.id,o),a)&&await this.update()}renderCard(e,o){let a=this.person(o);if(!a)return dom.content(e,t("em",{},"This person was just removed.")),e;let r=this.today,i=tt(a.expires,r),s=Math.max(0,a.device_limit-a.devices.length),d=a.has_link??this.st.settings.portal_enabled,l=[],c=Ro(a);if(a.expires&&c!=="expired"){let b=i!=null&&i>=0&&i<=Math.max(a.expire_warn,3),M=i!=null&&i<0;l.push(t("span",{class:`dl-pill-ic${M?" bad":b?" warn":""}`,title:`Access ends ${Ce(a.expires)}`},[g("calendar"),M?`ended ${Ce(a.expires)}`:b?`ends in ${i} day${i===1?"":"s"}`:`until ${Ce(a.expires)}`]))}a.hours&&c!=="hours"&&l.push(t("span",{class:"dl-pill-ic",title:"Allowed hours"},[g("clock"),a.hours.replace("-","–")]));let p=Ut(a.devices).map(b=>t("button",{type:"button",class:`dl-chip${b.disabled?" disabled":""}${b.online?" live":""}`,title:`${je[b.kind]} · ${b.address}${b.online?` · online from ${b.endpoint}`:b.handshake?` · seen ${ie(b.handshake,this.st.now)}`:""}`,click:M=>{M.preventDefault(),Be(a,b,this.deviceOpts(a))}},[g(b.kind),t("span",{class:"dl-chip-name"},b.name),!b.handshake&&!b.disabled?t("span",{class:"dl-chip-tag"},"not set up"):""]));p.push(t("button",{type:"button",class:"dl-chip add","aria-label":"Add device",title:s>0?"Add device":"Add device · over the limit, admins can still add",click:b=>{b.preventDefault(),rt(a,this.deviceOpts(a))}},g("plus")));let u=[];a.expires&&i!=null&&i<=Math.max(a.expire_warn,3)&&c!=="expired"&&u.push(t("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{expires:Io(a.expires,r)},"Extended by 1 month")},"Extend 1 month"));let k=$e("more","More",b=>we(b.currentTarget,[{label:"Open",icon:g("open"),run:()=>{location.href=ke(a.id)}},d?{label:"Invite card",icon:g("qr"),run:()=>zt(a,this.st.servers.find(M=>M.id===a.server)?.name??"Home")}:null,s>0?{label:"Add device",icon:g("plus"),run:()=>rt(a,this.deviceOpts(a))}:null,null,{label:a.paused?"Resume":"Pause",icon:g(a.paused?"play":"pause"),warn:!a.paused,run:()=>this.togglePause(a)},{label:"Delete",icon:g("trash"),danger:!0,run:()=>this.remove(a.id)}].filter((M,j,I)=>M||j>0&&I[j-1])),"neutral","dl-icon-only"),f=t("div",{class:"dl-pcard-actions"},[d?$e("link","Copy link",()=>en(a.id),"neutral","dl-icon-only"):"",k]);return dom.content(e,t("div",{class:"dl-pcard"},[t("div",{class:"dl-pcard-main"},[t("div",{class:"dl-pcard-top"},[t("span",{class:`dl-avatar${a.online?" online":""}`},De(a.name)),t("div",{class:"dl-pcard-who"},[t("div",{class:"dl-card-head"},[t("a",{class:"dl-card-name",href:ke(a.id)},a.name),so(a),...l]),ei(a)])]),t("div",{class:"dl-chips"},p),u.length?t("div",{class:"dl-fixes"},u):""]),this.usageSide(a,f),c?this.stopStrip(a,c):""])),e}stopStrip(e,o){let a=this.today,r=dt(`${a.slice(0,8)}01`,1),i=()=>this.quick(e,{bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month"),s={paused:["pause","warn","Paused","Devices can’t connect until you resume",["play","Resume",()=>this.togglePause(e)]],quota:e.quota_period==="month"?["chart","bad","Data limit reached",`Paused until it resets on ${Ce(r)}`,["plus","+10 GB this month",i]]:["chart","bad","Data limit reached","Paused until the limit is raised",["edit","Change limit",()=>location.href=ke(e.id)]],expired:["calendar","bad",`Access ended ${Ce(e.expires)}`,"Devices can’t connect",["calendar","Extend 1 month",()=>this.quick(e,{expires:Io(e.expires,a)},"Extended by 1 month")]],hours:["clock","warn","Outside allowed hours",`Access ${e.hours.replace("-","–")} (router time)`,null],no_server:["alert","warn","No server","Choose a server on their page",null]},[d,l,c,p,u]=s[o];return t("div",{class:`dl-pstrip ${l}`},[t("span",{class:`dl-need-ic ${l}`},g(d)),t("span",{class:"dl-pstrip-text"},[t("b",{},c),t("span",{class:"dl-faint"},p)]),u?D([g(u[0]),` ${u[1]}`],u[2]):""])}usageSide(e,o){let a=e.quota_used||e.month[0]+e.month[1],r=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,i=e.devices.reduce((p,u)=>p+(u.spark[u.spark.length-1]??0),0),s=e.rate?.[e.rate.length-1],d=e.online&&s&&this.st.now-s[0]<180,l=t("div",{class:`dl-usebar${r>=100?" bad":r>=90?" warn":""}`});if(e.quota_limit){let p=t("i",{class:"fill"});p.style.width=`${r}%`,l.appendChild(p),me(l,()=>[t("div",{class:"dl-tip-title"},`${r.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${te(e.quota_used)} of ${te(e.quota_limit)} · ${te(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},e.quota_period==="total"?"In total":`This month${e.bonus_gb?` · includes +${e.bonus_gb} GB extra`:""}`)])}else{let p=e.devices.map(u=>({d:u,v:u.month[0]+u.month[1]})).filter(u=>u.v>0).sort((u,k)=>k.v-u.v);p.forEach((u,k)=>{let f=t("i",{class:`c${Math.min(k,4)}`});f.style.flexGrow=String(u.v),l.appendChild(f)}),p.length&&me(l,()=>[t("div",{class:"dl-tip-title"},"This month by device"),...p.map((u,k)=>t("div",{class:"dl-tip-row"},[t("span",{class:`dl-swatch c${Math.min(k,4)}`}),t("span",{},u.d.name),t("b",{},te(u.v))]))])}let c=e.quota_limit?`${te(Math.max(0,e.quota_limit-e.quota_used))} left`:"no limit";return t("div",{class:"dl-pside"},[t("div",{class:"dl-pside-top"},[d?t("span",{class:"dl-pside-state live"},"Online"):t("span",{class:"dl-pside-state"},e.online?"Online":e.last_seen?"Offline":"Never connected"),o]),t("div",{class:"dl-use-num"},[t("b",{class:a?"":"dl-faint"},te(a)),t("span",{class:"dl-faint"},e.quota_limit?`of ${te(e.quota_limit)}`:e.quota_period==="total"&&e.quota_gb?"in total":"this month")]),l,d?t("div",{class:"dl-use-live",title:"Right now"},[`↓ ${ze(s[2])}`,t("span",{class:"dl-faint"},`↑ ${ze(s[1])}`)]):t("div",{class:"dl-faint dl-pside-foot"},i?`today ${te(i)} · ${c}`:c)])}async togglePause(e){await W(()=>P.personPause(e.id,!e.paused),e.paused?`${e.name} resumed`:`${e.name} paused`)&&await this.refresh()}async remove(e){let o=this.person(e);await ae(`Remove ${o?.name??e}?`,`All ${o?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await W(()=>P.personDelete(e),"Person removed")&&await this.refresh()}openCreate(){let e=this.st;if(!e.servers.length){Q("Set up the server first.","warning");return}let o=t("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),a=No("internet"),r=t("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:e.settings.default_device_limit}),i=t("input",{type:"date",class:"cbi-input-text"}),s=t("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited"}),d=(u,k)=>t("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{i.value=k?dt(Re(e.series),k):""}},u),l=e.servers[0],c=!this.serverId&&e.servers.length>1?t("select",{class:"cbi-input-select"},e.servers.map(u=>t("option",{value:u.id},u.name))):null,p=(u,k,f)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},u),t("div",{class:"cbi-value-field"},[k,f?t("div",{class:"cbi-value-description"},f):""])]);re("Add person",[p("Name",o),c?p("Server",c):"",t("div",{class:"cbi-value dl-block"},[t("label",{class:"cbi-value-title"},"Access"),t("div",{class:"cbi-value-field"},a.el)]),p("Devices",r,"How many devices they can add themselves."),p("End date",t("div",{class:"dl-actions"},[i,d("1 month",1),d("3 months",3),d("1 year",12),d("None",0)]),"Optional."),p("Monthly data (GB)",s,"Optional. They are paused when it runs out and resumed next month.")],[le()," ",D("Create and copy link",async()=>{let u=await W(()=>P.personCreate(o.value.trim(),"",c?.value??l.id,a.get(),String(Number(r.value)||e.settings.default_device_limit),i.value,s.value.trim(),"month"));u&&(u.link&&await ue(u.link,"Personal link copied"),this.showCreated(u.id,o.value.trim(),u.link,e.servers.find(k=>k.id===(c?.value??l.id))?.name??l.name),await this.refresh())},"positive")]),setTimeout(()=>o.focus(),50)}showCreated(e,o,a,r){if(a){zt({id:e,name:o,link:a},r,{title:`${o} is ready`,lead:`Send ${o} the card or the link. They open it, add their devices and connect — no account needed.`});return}re(`${o} is ready`,[t("p",{},"Created. Turn on the personal portal in Settings to get a link, or add devices for them here.")],[t("button",{class:"cbi-button cbi-button-positive",click:ce},"Done")])}};function In(n){let e=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(n.trim());if(!e)return null;let[o,a,r,i]=e.slice(1,5).map(Number),s=Number(e[5]);if([o,a,r,i].some(c=>c>255)||s<8||s>30)return null;let d=o*2**24+a*2**16+r*2**8+i,l=2**(32-s);return{net:d-d%l,size:l}}var ni=(n,e)=>n.netIn(n));function tn(n){return n.split("/")[0].split(".").slice(0,3).join(".")}function Bn(n){return`${n.trim()}.0/24`}function jo(n,e,o){let a=n.trim(),r=/^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(a)?In(Bn(a)):null;if(!r)return{text:"Three numbers, like 10.77.0.",bad:!0};if(!oi.some(s=>r.net>=s.net&&r.net+r.size<=s.net+s.size))return{text:"Use a private range: 10.x.x, 172.16–31.x or 192.168.x.",bad:!0};let i=e.find(s=>{let d=In(s.cidr);return d!=null&&ni(r,d)});if(i){let s=i.cidr.endsWith("/24")?`${tn(i.cidr)}.x`:i.cidr,d=o&&o!==a?` Try ${o}.`:"";return{text:`${i.name} already uses ${s}.${d}`,bad:!0}}return{text:`Devices get ${a}.2 – ${a}.254, the router ${a}.1.`,bad:!1}}var Uo=(n,e)=>e.find(o=>o.from<=n&&n<=o.to)?.who??null,ai=n=>Number.isInteger(n)&&n>=1&&n<=65535;function On(n,e,o){if(!ai(n))return{text:"Use a port from 1 to 65535.",bad:!0};let a=Uo(n,e);return a?{text:`Used by ${a}. Choose another port.`,bad:!0}:{text:o,bad:!1}}function nn(n,e,o){let a=o?`HTTPS here, plain HTTP for links on IP addresses on ${n+1}.`:"HTTPS on this port, opened on WAN.",r=On(n,e,a);if(r.bad||!o)return r;if(n===65535)return{text:"Links on IP addresses also need the next port: choose a lower one.",bad:!0};let i=Uo(n+1,e);return i?{text:`Links on IP addresses also need ${n+1}, used by ${i}. Choose another port.`,bad:!0}:r}var on=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],jn=n=>t("i",{class:"dl-circle-dot",style:`background:${on[n?.color??0]??on[0]}`}),Ve=n=>n.access==="both"||n.access==="lan"&&!n.services?.length;function Wo(n,e,o){let a=se(n?.name??e.name??"",{placeholder:"NAS"}),r=se(n?.address??e.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),i=se((n?.ports??e.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),s=(d,l)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},d),t("div",{class:"cbi-value-field"},l)]);re(n?`Edit ${n.name}`:"Add service",[s("Name",a),s("Address",r),s("Ports",i)],[le()," ",D("Save",async()=>{let d=i.value.split(/[ ,]+/).filter(Boolean);await W(()=>P.serviceSet(n?.id??"",a.value,r.value,d),"Saved")&&(ce(),o())},"positive")])}var ri={_smb:"SMB",_afpovertcp:"AFP",_http:"Web",_https:"Web",_ssh:"SSH",_sftp:"SFTP","_sftp-ssh":"SFTP",_ipp:"Printer",_ipps:"Printer",_printer:"Printer","_pdl-datastream":"Printer",_airplay:"AirPlay",_raop:"AirPlay",_rfb:"Screen sharing",_googlecast:"Cast",_hap:"HomeKit",_rdp:"Remote desktop",_ftp:"FTP"},ii=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function si(n){let e=new Map;for(let o of n.services){let a=ri[o.type.split(".")[0]];!a||!o.port||(e.get(a)??e.set(a,new Set).get(a)).add(String(o.port))}return e.size?[...e].map(([o,a])=>[o,[...a].sort((r,i)=>+r-+i)]):ii}function Go(n,e,o){let a=n,r=null,i=!1,s=null,d=new Set,l=t("div",{class:"dl-list"}),c=t("div",{class:"dl-stack gap8"},t("span",{class:"dl-sub"},"Looking for devices at home…")),p=()=>{let M=a.services;dom.content(l,M.length?M.map(j=>t("div",{class:"dl-row"},[g("home"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},j.name),t("span",{class:"dl-mono dl-faint"},`${j.address}${j.ports.length?` · ports ${j.ports.join(", ")}`:" · all ports"}`)]),D("Edit",()=>Wo(j,{},o)),D([g("trash")],async()=>{await ae(`Remove ${j.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await W(()=>P.serviceDelete(j.id),"Removed")&&await o()},"neutral",{title:"Remove","aria-label":`Remove ${j.name}`})])):[t("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")])};async function u(M,j){if(!d.has(M.address)){d.add(M.address),f();try{let I=a.services.find(T=>T.address===M.address);(j===null?I&&await W(()=>P.serviceDelete(I.id),`${I.name} removed`):await W(()=>P.serviceSet(I?.id??"",I?.name??(M.name||M.address),M.address,j),I?`${I.name} updated`:`${M.name||M.address} added`))&&await o()}finally{d.delete(M.address),f()}}}function k(M){let j=a.services.find(v=>v.address===M.address),I=!!j&&!j.ports.length,E=new Set(j?.ports??[]),T=d.has(M.address),w=(v,x,$)=>We(v,x,$,{disabled:T?"disabled":null,"aria-busy":T?"true":null});return t("div",{class:"dl-row"},[g(M.services.some(v=>v.type.startsWith("_ipp")||v.type.startsWith("_printer"))?"file":"computer"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},M.name||M.address),t("span",{class:"dl-mono dl-faint"},M.address)]),t("div",{class:"dl-chips-row dl-host-ports"},[w("All ports",I,()=>u(M,I?null:[])),...si(M).map(([v,x])=>{let $=!I&&x.every(m=>E.has(m));return w(`${v} ${x.join(", ")}`,$,()=>{let m=new Set(I?[]:E);for(let h of x)$?m.delete(h):m.add(h);u(M,m.size?[...m]:null)})})])])}function f(){if(i)return dom.content(c,t("span",{class:"dl-sub"},"Couldn't read the devices at home."));if(!r)return;let M=r;if(!M.hosts.length)return dom.content(c,t("span",{class:"dl-sub"},"No devices found in the home network right now."));let j=t("details",{class:"dl-params",open:s??!a.services.length?"":null},[t("summary",{},[g("chevron"),t("span",{},"Add from devices at home"),t("span",{class:"dl-pcount"},String(M.hosts.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},M.mdns?"Ports they announce over Bonjour. Pick what to open, or all ports.":"Devices that got an address from this router. Pick the ports to open, or all ports."),t("div",{class:"dl-list"},M.hosts.map(k))])]);j.addEventListener("toggle",()=>s=j.open),dom.content(c,j)}return P.homeHosts(e).then(M=>{r=M,f()}).catch(()=>{i=!0,f()}),p(),{el:t("div",{class:"dl-stack gap8"},[t("div",{class:"dl-iflead"},[t("div",{class:"dl-iflead-row"},[t("b",{},"Home services"),D([g("plus")," Add service"],()=>Wo(null,{},o))]),t("span",{class:"dl-sub"},"Home-only people can be limited to these instead of whole networks (chosen on their page). Shared by all servers.")]),l,c]),update(M){a=M,p(),f()}}}function an(n,e,o,a){let r=new Set(n.circles.filter(f=>f.server===e).map(f=>f.color)),i=o?.color??on.findIndex((f,b)=>!r.has(b));i<0&&(i=0);let s=se(o?.name??"",{placeholder:"Family"}),d=n.people.filter(f=>f.server===e).sort((f,b)=>f.name.localeCompare(b.name)),l=new Set(d.filter(f=>o&&f.circle===o.id).map(f=>f.id)),c=t("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),p=()=>dom.content(c,on.map((f,b)=>t("button",{type:"button",role:"radio",class:`dl-swatch${b===i?" on":""}`,style:`--sw:${f}`,"aria-checked":b===i?"true":"false","aria-label":`Colour ${b+1}`,click:()=>{i=b,p()}})));p();let u=t("div",{class:"dl-chips-row"},d.map(f=>{let b=f.circle&&f.circle!==o?.id?n.circles.find(M=>M.id===f.circle):void 0;return t("button",{type:"button",class:`dl-chipbtn${l.has(f.id)?" on":""}`,title:Ve(f)?b?`Now in ${b.name}`:"":`${f.name} has no home access: their devices aren't reachable anyway`,click:M=>{l.delete(f.id)||l.add(f.id),M.currentTarget.classList.toggle("on",l.has(f.id))}},[f.name,Ve(f)?b?t("b",{},b.name):"":t("b",{},"internet")])})),k=(f,b)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},f),t("div",{class:"cbi-value-field"},b)]);re(o?`Edit ${o.name}`:"New circle",[k("Name",s),k("Colour",c),k("People",u),t("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[o?D("Delete",async()=>{await W(()=>P.circleDelete(o.id),`${o.name} deleted`)&&(ce(),a())},"negative"):"",t("span",{class:"dl-spacer"}),le()," ",D("Save",async()=>{await W(()=>P.circleSet(o?.id??"",e,s.value,i,[...l]),"Saved")&&(ce(),a())},"positive")],"dl-circle-modal")}function qo(n,e,o){let a=n.circles.filter(r=>r.server===e);return t("div",{class:"dl-chips-row dl-circles"},[...a.map(r=>{let i=n.people.filter(s=>s.circle===r.id).map(s=>s.name);return t("button",{type:"button",class:"dl-chip",title:`Edit ${r.name}`,click:()=>an(n,e,r,o)},[jn(r),t("b",{},r.name),t("span",{class:"dl-faint"},i.length?i.join(", "):"nobody yet")])}),t("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>an(n,e,null,o)},g("plus"))])}function Un(n,e){let o=n.people.filter(p=>p.server===e.id),a=(p="")=>t("span",{class:"dl-yes"},[g("check"),p]),r=()=>t("span",{class:"dl-faint"},"—"),i=p=>{let u=new Set(p.map(k=>k.access==="lan"&&k.services?.length?"services":k.home_nets?.length?"some":"all"));return u.size||u.add("all"),a([...u].map(k=>({all:"all networks",some:"their networks",services:"services"})[k]).join(" / "))},s=()=>e.mesh==="off"?r():e.mesh==="circles"?a("circle"):a(),d=e.lan_like?"like home":"direct",l=(p,u,k)=>t("tr",{},[t("td",{},[t("b",{},p),t("div",{class:"dl-sub"},`${u.length} ${u.length===1?"person":"people"}`)]),...k.map(f=>t("td",{},f))]),c=p=>o.filter(u=>u.access===p);return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Who reaches what"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"From the rules on this server")]),t("div",{class:"dl-reach-wrap"},t("table",{class:"dl-table dl-reach"},[t("tr",{},["","Internet","Home","This router","Each other"].map(p=>t("th",{},p))),l("Internet",c("internet"),[a(d),r(),t("span",{class:"dl-faint"},"DNS"),r()]),l("Home",c("lan"),[t("span",{class:"dl-faint"},"their own"),i(c("lan")),a(),s()]),l("Both",c("both"),[a(d),i(c("both")),a(),s()])])),t("p",{class:"dl-sub"},"Home devices reach the devices of people with home access, on the networks those people reach. Paused, ended and over-the-limit people reach nothing.")])])}function Fo(n,e){let o=n.people.filter(c=>c.server===e.id).flatMap(c=>c.devices.map(p=>({id:p.id,label:`${c.name} · ${p.name}`}))).sort((c,p)=>c.label.localeCompare(p.label)),a="@addr",r=(c,p)=>{let u=t("select",{class:"cbi-input-select","aria-label":c},[...o.map(M=>t("option",{value:M.id,selected:M.id===p?"selected":null},M.label)),t("option",{value:a,selected:p===a?"selected":null},"Address")]),k=se("",{placeholder:c,class:"cbi-input-text dl-mono"}),f=t("div",{class:"dl-check-end"},[u,k]),b=()=>k.hidden=u.value!==a;return u.addEventListener("change",b),b(),{el:f,value:()=>u.value===a?k.value.trim():u.value}},i=r("10.0.1.11",o[0]?.id??a),s=r("10.0.1.20:445",a),d=t("div",{class:"dl-stack gap8"}),l=async()=>{let c=await W(()=>P.accessCheck(i.value(),s.value()));if(!c)return;let p=c.steps.findIndex(u=>!u.ok);dom.content(d,[t("div",{class:`dl-verdict ${c.ok?"ok":"bad"}`},[t("b",{},c.ok?"Allowed":"Blocked"),t("span",{class:"dl-sub"},c.ok?"Every step lets it through":`Stops at step ${p+1} of ${c.steps.length}`)]),t("ul",{class:"dl-checks"},c.steps.map(u=>t("li",{},[t("span",{class:`dl-check-icon ${u.ok?"ok":"error"}`},g(u.ok?"check":"x")),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},u.title),u.detail?t("div",{class:"dl-check-detail"},u.detail):""])])))])};return t("section",{class:"dl-setsec"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Check access"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"Why something does or does not connect")]),t("div",{class:"dl-check-form"},[i.el,t("span",{class:"dl-faint"},"→"),s.el,D("Check",l)]),d])])}var rn={app:"Dawnline",amneziawg:"AmneziaWG",packages:"System packages",pkgs:"System packages"};function Ye(n){return(n.startsWith("check")?n.slice(6)||"all":n).split(/[:@ ]/)[0]}function sn(n){return Ye(n.action==="check"?`check:${n.component??""}`:n.component??"")}function Ko(n){return n=Math.max(0,Math.floor(n)),`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function Jo(n,e){return!n?.from&&!n?.to?e:n.from&&n.to&&n.from!==n.to?`${n.from} → ${n.to}`:n.to??n.from??e}function Vo(n,e){let o=n.check?.components??{},a=e==="all"?["app","amneziawg","packages"]:[e],r=[],i;for(let d of a){let l=o[d];if(l){if(l.error)return{tone:"warn",text:l.error};d==="packages"&&l.updates?r.push(`${l.updates} system package${l.updates===1?"":"s"}`):d!=="packages"&&l.update&&l.installed&&l.latest&&(r.push(`${rn[d]} ${l.latest}`),e!=="all"&&(i=l.latest))}}if(r.length)return{tone:"acc",text:`Update available: ${r.join(", ")}`,update:i};let s=a.length===1?o[a[0]]:null;return s?.status==="dev"?{tone:"acc",text:`Installed version is newer than the release (${s.latest})`}:s?.note?{tone:"warn",text:s.note}:{tone:"ok",text:a.length>1?"Everything is up to date":"Latest version is installed"}}function Yo(n,e,o,a){return e?n.id===e:o&&n.id===o?!1:n.state==="running"||a>0&&n.started>=a}var Zo=n=>new Promise(e=>setTimeout(e,n));async function Ht(n,e,o){let a=o?sn(o):Ye(n),r=o?o.action==="check":n.startsWith("check"),i=Date.now(),s=t("b",{},rn[a]??(a==="all"?"All components":"Dawnline")),d=t("span",{class:"dl-pill dl-mono"},e.version??""),l=t("span",{class:"dl-pill info",hidden:!0}),c=t("span",{},"0:00"),p=t("pre",{class:"dl-log"},"Operation started. Waiting for log output…"),u=t("div",{}),k=t("div",{class:"dl-op-actions"}),f=[],b=m=>dom.content(k,m),M=(m=!1)=>le("Close",m);re(e.title,t("div",{class:"dl-op"},[t("div",{class:"dl-op-head"},[s,e.version?d:"",l,t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-op-timer"},[g("clock"),c])]),t("div",{class:"dl-op-loghead"},[t("b",{},"Operation log"),$e("copy","Copy log",()=>ue(f.join(` +`),"Log copied"))]),p,u]),[k],"wide"),b([t("button",{class:"cbi-button cbi-button-neutral spinning",type:"button",disabled:"disabled"},r?"Checking…":"Working…")]);let j=o??null,I=o?.id,E,T=0,w=m=>{I!==m.id&&(I=m.id,e.onJob?.(m))};if(o)e.onJob?.(o);else try{let m=await P.updatesStatus().catch(()=>null);E=m?.job?.id,T=m?.now??0;let h=await P.updatesRun(n);h.job&&h.job.state==="running"&&h.job.id!==E&&(j=h.job,w(h.job))}catch(m){return f=[ve(m)],p.textContent=f[0],dom.content(u,t("div",{class:"dl-comp-status warn"},[g("alert"),t("span",{},ve(m))])),b([M(!0)]),Q(ve(m),"error"),null}let v=null,x=0;for(;;){if(await Zo(1e3),v=await P.updatesStatus().catch(()=>null),!v){if(++x>60)break;continue}x=0;let m=v.job;if(!m||!Yo(m,I,E,T)){if(Date.now()-i>15e3)break;continue}if(w(m),j=m,m.log.length){f=m.log;let h=p.scrollTop+p.clientHeight>=p.scrollHeight-8;p.textContent=f.join(` +`),h&&(p.scrollTop=p.scrollHeight)}if(d.textContent=Jo(m,e.version??""),!d.isConnected&&d.textContent&&s.after(d),c.textContent=Ko((m.finished??v.now)-m.started),m.state==="running"){l.hidden=!m.phase,l.textContent=m.phase;continue}break}if(p.scrollTop=p.scrollHeight,l.hidden=!1,!j||j.state==="running")return l.className="dl-pill warn",l.textContent="No answer",dom.content(u,t("div",{class:"dl-comp-status warn"},[g("alert"),t("span",{},"The router stopped answering. The job may still finish: reopen Components in a minute.")])),b([M()]),e.onDone?.(v),j;if(j.state==="failed")return l.className="dl-pill bad",l.textContent="Failed",dom.content(u,t("div",{class:"dl-comp-status bad"},[g("x"),t("span",{},[t("b",{},j.error??"Operation failed"),r?"":". Nothing else was changed."])])),b([D("Copy log",()=>ue(f.join(` +`),"Log copied")),M(!0)]),Q(`${rn[a]??"Update"}: ${j.error??"failed"}`,"error"),e.onDone?.(v),j;if(l.className="dl-pill ok",l.textContent="Finished",r&&v){let m=Vo(v,a);if(dom.content(u,t("div",{class:`dl-comp-status ${m.tone}`},[g(m.tone==="ok"?"check":m.tone==="warn"?"alert":"download"),t("span",{},m.text)])),Q(m.text,m.tone==="warn"?"warning":"success"),e.onDone?.(v),m.update&&e.onUpdate){let h=v;b([M(),D(`Update to ${m.update}`,()=>e.onUpdate(h),"positive")])}else b([M()]),m.tone==="ok"&&setTimeout(()=>u.isConnected&&ce(),1200);return j}if(a==="app"&&j.to){let m=j.to,h=t("span",{},"Waiting for the router to restart its services…");dom.content(u,t("div",{class:"dl-comp-status ok"},[g("check"),t("span",{},[t("b",{},`Dawnline ${m} is installed. `),h])]));let N=()=>{ui.menu?.flushCache(),location.reload()};b([M(),D("Reload now",N,"positive")]),Q(`Dawnline updated to ${m}`,"success",6e3);for(let C=1;C<=30;C++)if(h.textContent=`Waiting for the router to restart its services (${C} of 30)…`,await Zo(1500),(await P.updatesStatus().catch(()=>null))?.version===m)return h.textContent="Services are back. Reloading…",setTimeout(N,800),j;return h.textContent="Services restarted. Reload the page to use the new version.",j}let $=a==="pkgs"?`Updated ${[...j.result?.pkgs?.updated??[],...j.result?.pkgs?.installed??[]].join(", ")||"system packages"}`:a==="amneziawg"?`AmneziaWG${j.to?` ${j.to}`:""} is installed`:"Operation completed";return dom.content(u,t("div",{class:"dl-comp-status ok"},[g("check"),t("span",{},$)])),b([M()]),Q($,"success"),e.onDone?.(v),j}var li={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",awg:"AmneziaWG"};async function Qo(n,e,o,a){return!await ae(`Install ${e}?`,o,"Install")||(await Ht(n,{title:`Installing ${e}`}))?.state!=="done"?!1:(setTimeout(()=>a?.(),4e3),!0)}function ln(n){return Qo("amneziawg:auto","AmneziaWG","Dawnline installs the AmneziaWG build made for this firmware and loads it. If the network service has to restart to learn it, connections drop for a few seconds.",n)}async function Rt(n,e,o){return n==="awg"?ln(o):e.length?Qo(`pkgs:${e.join(",")}`,li[n],`${e.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,o):!0}async function Xo(n,e){if(n==="awg")return ln(e);let o=await W(()=>P.updatesStatus());return o?Rt(n,o.needs?.[n]??[],e):!1}var di=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],ci={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function ea(n,e,o){let a=n.id,r=e,i=t("div",{class:"dl-stack gap16"},t("section",{class:"dl-setsec"},t("div",{class:"dl-setsec-body"},t("p",{class:"dl-muted"},"Loading interfaces…")))),s,d=!0,l="",c=!0,p=!0,u="all",k=!1,f=Go(r,a,o),b=new Set,M="",j=()=>JSON.stringify([p,d,d?"":l,c,[...b].sort()]),I=()=>s.detected.lan||s.saved.lan||"",E=()=>(d?s.detected.wan||s.saved.wan:l)||"",T=()=>new Map(s.devices.map(z=>[z.name,z])),w=()=>{let z=T();return[...c&&I()?[I()]:[],...[...b].filter(X=>X!==I())].filter(X=>X!==E()).map(X=>z.get(X)??{name:X,nets:[],missing:!0})},v=(z,F)=>{s=z,F&&(d=z.config.auto_wan,l=z.config.wan_device||z.detected.wan||z.saved.wan||"",c=z.config.auto_lan,p=z.config.lan_like,u=z.config.mesh??(z.config.device_mesh?"all":"off"),b=new Set(z.config.lan_devices),M=j()),G()},x=async z=>{let F=await P.interfaces(a).catch(X=>(Q(X.message,"error"),null));F&&v(F,z)};function $(z){let F=c&&z.name===I(),X=!!z.own||!!z.master||z.name===E()||F;return F||b.has(z.name)||!X&&(z.nets.length>0||!!z.missing)}function m(z){let F=c&&z.name===I(),X=z.name===E(),de=!F&&b.has(z.name),B=!(!!z.own||!!z.master||X||F)&&(z.nets.length>0||de||!!z.missing),U=(de||F)&&!z.zone&&!z.missing,q=z.missing?"Not present right now":z.own?"This server":z.master?`Port of ${z.master}`:X?`Internet${z.zone?` · zone ${z.zone}`:""}`:z.nets.length?z.nets.join(", "):"No IPv4 network",oe=t("button",{type:"button",class:`dl-if${de?" sel":""}${F?" auto":""}${!B&&!de&&!F?" off":""}${U?" warn":""}`,"aria-pressed":de||F?"true":"false","aria-disabled":B?null:"true",click:()=>{B&&(b.has(z.name)?b.delete(z.name):b.add(z.name),G())}},[t("span",{class:"dl-if-ic"},g(ci[z.kind]??"link")),t("span",{class:"dl-if-main"},[t("span",{class:"dl-if-name"},z.name),t("span",{class:"dl-if-sub"},q)]),F?t("span",{class:"dl-if-badge ok"},"Auto"):de?t("span",{class:"dl-if-check"},g("check")):""]);return me(oe,()=>[t("div",{class:"dl-tip-title"},z.name),t("div",{class:"dl-muted"},[z.logical?`Interface ${z.logical}`:"No netifd interface",z.zone?` · zone ${z.zone}`:" · no firewall zone"]),z.members.length?t("div",{class:"dl-muted"},`Ports: ${z.members.join(", ")}`):"",z.nets.length?t("div",{class:"dl-mono"},z.nets.join(", ")):"",U?t("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",z.master?t("div",{class:"dl-muted"},`Choose ${z.master} to include it.`):""]),oe}function h(){let z=s.like_home;return!p||!s.config.lan_like||!n.enabled?"":!s.needs?.length&&z.active&&z.bridged?"ok":"warn"}function N(){let z=s.like_home;return p?s.needs?.length?[t("span",{class:"dl-warn"},`Needs ${s.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:s.config.lan_like?n.enabled?z.active&&z.bridged?["Internet traffic enters ",t("span",{class:"dl-mono"},z.dev??"")," as ",t("span",{class:"dl-mono"},z.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[t("span",{class:"dl-warn"},`Not working: ${z.error??"the link is down"}`)," Internet traffic goes straight to the WAN for now."]:["Internet traffic enters the router from your LAN, so whatever handles home traffic (proxies, filters, DNS) handles it too."]:["Internet traffic will enter the router from your LAN, so it is handled like any home device. Save to turn on."]:["Off: internet traffic goes straight to the WAN, past whatever handles home traffic on this router."]}let C={off:"Devices of different people never reach each other; a person's own devices don't either.",all:"Devices of people with home access reach each other, like home devices do. Internet-only people never.",circles:"Within a circle: family sees family, guests see guests. Everyone reaches their own devices. Internet-only people never."};function R(z,F,X,de,fe="",B){return t("div",{class:B?"dl-setrow head":"dl-setrow"},[t("div",{class:"dl-lh-main"},[t("span",{class:`dl-need-ic ${fe}`},g(z)),t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},F),t("span",{class:"dl-sub"},X),B??""])]),t("div",{class:"dl-setrow-ctl"},de)])}let Z=(z,F)=>{let X=de=>t("span",{class:"dl-mono"},de);return z?t("span",{},[" Now: ",X(z),...F&&F!==z?[", was ",X(F)]:[],"."]):t("span",{},F?[" Not found now: using ",X(F),"."]:[" Not found."])};function G(){let z=t("select",{class:"cbi-input-select","aria-label":"Internet interface",change:S=>{l=S.target.value,G()}},s.devices.filter(S=>!S.own&&!S.master&&S.zone&&!S.missing).map(S=>t("option",{value:S.name,selected:S.name===l?"selected":null},`${S.name} · zone ${S.zone}`))),X=w().flatMap(S=>S.nets.map(O=>[O,S.name])),de=JSON.parse(j()),fe=JSON.parse(M),B=(...S)=>S.some(O=>JSON.stringify(de[O])!==JSON.stringify(fe[O])),U=B(0,1,2),q=B(3,4),oe=S=>D("Save",async()=>{let O=await W(()=>P.serverInterfaces(a,d,d?"":l,c,[...b],p,u!=="off",u),"Access saved");O&&(v(O,!0),O.nets_changed&&O.lan_only&&Q(`${O.lan_only} ${O.lan_only===1?"person has":"people have"} Home-only access: their devices need the configuration again to reach the new networks.`,"warning",1e4))},"positive",{disabled:!S}),_=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Internet"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Internet or Both")]),R("home","Internet like a home device",N(),[p&&s.needs?.length?D("Install",()=>Rt("home",s.needs,()=>x(!1)),"positive"):"",ge(p,"Internet like a home device",S=>{p=S,G()})],h()),R("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",Z(s.detected.wan,s.saved.wan)],[d?"":z,ge(d,"Auto-detect WAN",S=>{d=S,G()})])]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},p?["Internet like a home device",E()?[" · leaves through ",t("span",{class:"dl-mono"},E())]:""]:E()?["Internet straight to ",t("span",{class:"dl-mono"},E())]:"No WAN found"),oe(U)])]),A=xe([["off","Off"],["all","Everyone"],["circles","Circles"]],u,{label:"Devices reach each other",cls:"sm",optimistic:!1,onChange:async S=>{let O={off:"Off",all:"Everyone",circles:"Circles"}[S];await W(()=>P.serverUpdate(a,{mesh:S}),`Devices reach each other: ${O}`)&&(u=S,s.config.mesh=S,G(),await o())}}),y=t("section",{class:"dl-setsec dl-ifcard"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Home network"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-sub"},"People with Home or Both"),D([g("reset")," Rescan"],()=>x(!1),"neutral",{title:"Read the interfaces again"})]),R("network","Networks","Everyone with home access reaches these, unless their page leaves one out; their devices can be reached from here too. Click one to add or remove it.","","",V()),R("link","Devices reach each other",C[u],A,"",u==="circles"?qo(r,a,o):void 0),f.el]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub dl-if-summary"},X.length?["Home access reaches ",...X.flatMap(([S,O],Y)=>[Y?", ":"",t("span",{class:"dl-mono"},S),` (${O})`])]:"No home network: Home access reaches nothing but this router."),oe(q)])]),H=window.scrollY;i.style.minHeight=`${i.offsetHeight}px`,dom.content(i,[_,y]),i.style.minHeight="",window.scrollTo({top:H})}function V(){let z=s.devices.filter($),F=s.devices.filter(X=>!$(X));return t("div",{class:"dl-stack gap8 dl-netpick"},[z.length?t("div",{class:"dl-ifgrid"},z.map(m)):t("span",{class:"dl-warn"},"No home network: Home access reaches nothing but this router."),t("label",{class:"dl-boxrow"},[t("span",{class:"dl-stack"},[t("span",{},"Auto-detect LAN"),t("span",{class:"dl-sub"},["Adds the LAN this router uses.",Z(s.detected.lan,s.saved.lan)])]),ge(c,"Auto-detect LAN",X=>{c=X,G()})]),F.length?t("details",{class:"dl-params",open:k?"":null,toggle:X=>k=X.currentTarget.open},[t("summary",{},[g("chevron"),t("span",{},"Other interfaces"),t("span",{class:"dl-pcount"},String(F.length))]),t("div",{class:"dl-params-body"},[t("span",{class:"dl-sub"},"The WAN, this server, ports and Wi-Fi of a bridge (they come with it) and interfaces without an IPv4 network."),...di.map(([X,de])=>{let fe=F.filter(B=>B.category===X);return fe.length?t("div",{class:"dl-ifgroup"},[t("h4",{},de),t("div",{class:"dl-ifgrid"},fe.map(m))]):""})])]):""])}return x(!0),{el:i,update(z){r=z,f.update(z),s&&G()}}}var pi={connect:"ok",disconnect:"",roam:"",device_added:"ok",device_removed:"",person_added:"",person_removed:"",paused:"warn",resumed:"ok",portal_blocked:"bad",person_changed:"",devices_removed:"warn"},mi={devices_removed:"trash",link_changed:"link",person_added:"plus",person_removed:"trash",person_changed:"edit",paused:"pause",resumed:"play"};function hi(n,e){return e.device?n.people.flatMap(a=>a.devices).find(a=>a.id===e.device)?.kind??e.dkind??"other":mi[e.type]??"activity"}function Wn(n,e){let o=n.people.find(b=>b.id===e.person),a=o?.name??e.pname??e.person??"",r=o?.devices.find(b=>b.id===e.device)?.name??e.dname??"",i=b=>t("b",{},b),s=b=>t("span",{class:"dl-muted"},b),d=b=>t("span",{class:"dl-mono"},b),l=b=>e.hosts?.[b]?[t("span",{class:"dl-ev-host"},[t("b",{},e.hosts[b]),t("span",{class:"dl-faint"},` (${b})`)])]:[d(b)],c=b=>t("span",{class:"dl-ev-kind"},`${b} `),p=r?`${a} · ${r}`:a,u=go(e),k=u||r||"a device",f=b=>[t("span",{class:"dl-you"},"You"),s(` ${b} `)];if(Te(e)==="admin")switch(e.type){case"device_added":return[...f("added"),c("device"),i(k),s(" for "),i(a)];case"device_removed":return[...f("removed"),c("device"),i(k),s(" from "),i(a)];case"paused":return[...f("paused"),c("person"),i(a)];case"resumed":return[...f("resumed"),c("person"),i(a)];case"device_changed":{let b=u.startsWith("renamed from ");return[...f(b?"renamed":u),c("device"),i(r||"a device"),s(" of "),i(a),...b?[s(` · was ${u.slice(13)}`)]:[]]}case"device_keys":return[...f("issued new keys for"),c("device"),i(k),s(" of "),i(a),s(" · it needs its new configuration")];case"link_changed":return[...f("issued a new link for"),c("person"),i(a),s(" · the old link stopped working")]}switch(e.type){case"connect":return[c("Device"),i(p),s(" connected"),...e.detail?[s(" from "),...l(e.detail)]:[],...e.where?[s(` · ${e.where}`)]:[]];case"disconnect":return[c("Device"),i(p),s(" went offline")];case"roam":return[c("Device"),i(p),s(" changed network "),...(e.detail??"").split(" → ").flatMap((b,M)=>M?[s(" → "),...l(b)]:l(b))];case"device_added":return[c("Person"),i(a),s(" added "),c("device"),i(k),...Te(e)==="portal"?[s(" on their portal")]:[]];case"device_removed":return[c("Person"),i(a),s(" removed "),c("device"),i(k),...Te(e)==="portal"?[s(" on their portal")]:[]];case"device_keys":return[c("Person"),i(a),s(" issued new keys for "),c("device"),i(k),s(" on their portal")];case"person_added":return[...f("added"),c("person"),i(e.detail??a)];case"person_removed":return[...f("removed"),c("person"),i(e.detail??a)];case"person_changed":return[...f("changed"),c("person"),i(a),...u?[s(` · ${u.replace(/_/g," ")}`)]:[]];case"paused":return[c("Person"),i(a),s(` paused — ${e.detail??""}`)];case"resumed":return[c("Person"),i(a),s(" resumed"),...e.detail&&e.detail!=="active"?[s(` — ${e.detail}`)]:[]];case"portal_blocked":return[t("b",{class:"dl-sys-src"},"Personal portal"),s(" blocked "),d(e.detail??""),s(" for 15 min after too many wrong codes")];case"devices_removed":return[c("Person"),i(a),s(" — all devices removed, end date reached")];default:return[s(`${e.type}${e.detail?`: ${e.detail}`:""}`)]}}var fi={portal_blocked:["globe","bad"]};function gi(n,e){if(n.servers.length<2||!e.person)return"";let o=n.people.find(r=>r.id===e.person),a=o&&n.servers.find(r=>r.id===o.server);return a?t("span",{class:"dl-ev-srv",title:"Server"},a.name):""}function Ze(n,e,o={}){let a=fi[e.type],r=Te(e);return t("div",{class:`dl-row${r==="admin"?" dl-ev-by-admin":a?` dl-ev-by-system ${a[1]}`:""}`},[r==="admin"?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):a?t("span",{class:"dl-ev-tile sys"},g(a[0])):t("span",{class:`dl-ev-tile ev ${pi[e.type]??""}`},g(hi(n,e))),t("span",{class:"dl-row-main"},Wn(n,e)),o.server===!1?"":gi(n,e),t("span",{class:"dl-faint dl-nowrap",title:new Date(e.ts*1e3).toLocaleString()},o.time??ie(e.ts,n.now))])}var vi={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},bi={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function dn(n,e,o,a){let r=n.by==="admin",i=t("div",{class:`dl-row dl-slog-row ${r?"dl-ev-by-admin":`dl-ev-by-system ${vi[n.level]??""}`}${n.detail?" has-detail":""}`},[r?t("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},g("admin")):t("span",{class:"dl-ev-tile sys",title:n.level},g(bi[n.src]??"zap")),t("span",{class:"dl-row-main"},r?[t("span",{class:"dl-you"},"You"),t("span",{class:"dl-muted"},` ${n.msg} `),n.kind?t("span",{class:"dl-ev-kind"},`${n.kind} `):"",n.who?t("b",{},n.who):"",n.note?t("span",{class:"dl-muted"},` · ${n.note}`):"",n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},g("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]:[n.src==="awg"&&n.who&&n.who!=="AmneziaWG"?t("span",{class:"dl-ev-kind"},"Server "):"",t("b",{class:"dl-sys-src",title:Ct[n.src]??n.src},n.who??Ct[n.src]??n.src)," ",t("span",{class:"dl-muted"},n.msg),n.detail?t("span",{class:`dl-slog-more${e?" open":""}`},g("chevron")):"",n.detail&&e?t("pre",{class:"dl-slog-detail"},n.detail):""]),t("span",{class:"dl-faint dl-nowrap",title:new Date(n.ts*1e3).toLocaleString()},a)]);return n.detail&&i.addEventListener("click",s=>{s.target.closest("pre")||o()}),i}function ta(n){let e=new Date(n*1e3),o=new Date,a=new Date;return a.setDate(o.getDate()-1),e.toDateString()===o.toDateString()?"Today":e.toDateString()===a.toDateString()?"Yesterday":e.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}var yt=n=>pt(n).toLocaleDateString("en-GB",{day:"numeric",month:"short"});function cn(n,e,o,a=!1){let r=n.slice(-15),i=r[r.length-1],s=i&&e-i[0]<180,d=s?i[2]:0,l=s?i[1]:0,[c,p]=o,u=200,k=40,f=Math.max(1,...r.map(T=>Math.max(T[1],T[2]))),b=T=>r.map((w,v)=>`${r.length>1?v/(r.length-1)*u:u},${k-2-w[T]/f*(k-6)}`),M=b(2),j=b(1),I=r.length>1&&!a?qe(``):t("div",{class:"dl-speed-wait"},[t("i"),a?"":t("span",{},"Collecting… 1 point a minute")]),E=(T,w,v,x)=>t("div",{class:"dl-speed-col"},[t("span",{class:"dl-sub"},[t("span",{class:v},w),` ${T}`]),a?t("span",{class:"dl-speed-val off"},"—"):t("span",{class:"dl-speed-val"},ze(x))]);return r.length>1&&!a&&me(I,()=>{let T=r[r.length-1];return[t("div",{class:"dl-tip-title"},new Date(T[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),t("div",{},`↓ ${ze(T[2])} · ↑ ${ze(T[1])}`)]}),t("div",{class:"dl-bento-tile"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Speed now"),a?"":t("span",{class:"dl-sub"},"last 15 min")]),t("div",{class:"dl-speed-cols"},[E("Download","↓","dl-dn",d),E("Upload","↑","dl-up",l)]),I,t("div",{class:"dl-speed-today"},[t("span",{},["Today ",t("b",{},te(c+p))]),t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${te(p)} `,t("span",{class:"dl-up"},"↑"),` ${te(c)}`])])])}function pn(n,e){let o=n.slice(-30),a=o.map(l=>l.rx+l.tx),r=Math.max(1,...a),i=a.reduce((l,c)=>l+c,0),s=a.reduce((l,c,p)=>c>a[l]?p:l,0),d=t("div",{class:"dl-bento-bars"},o.map((l,c)=>{let p=a[c],u=t("i",{class:c===o.length-1?"hi":"",style:`height:${Math.max(4,p/r*100)}%`});return me(u,()=>[t("div",{class:"dl-tip-title"},c===o.length-1?`Today · ${yt(l.day)}`:yt(l.day)),t("div",{},te(p)),t("div",{class:"dl-muted dl-mono"},`↓ ${te(l.tx)} ↑ ${te(l.rx)}`)]),u}));return t("div",{class:"dl-bento-tile month"},[t("div",{class:"dl-bento-head"},[t("span",{},[t("span",{class:"dl-metric-label"},"Last 30 days"),t("b",{class:"dl-bento-total"},te(i))]),a[s]>0?t("span",{class:"dl-sub"},`peak ${te(a[s])} · ${yt(o[s].day)}`):""]),o.length?d:t("p",{class:"dl-muted"},"No traffic yet."),t("div",{class:"dl-bento-head"},[t("span",{class:"dl-sub"},o.length?yt(o[0].day):""),t("span",{class:"dl-sub"},e),t("span",{class:"dl-sub"},"today")])])}function na(n){let e=n.slice(-30),o=e.map(r=>r.rx+r.tx),a=Math.max(1,...o);return t("div",{class:"dl-dbars"},e.map((r,i)=>{let s=t("i",{class:`${o[i]?"":"zero"}${i===e.length-1?" hi":""}`});return s.style.height=`${Math.max(8,o[i]/a*100)}%`,me(s,()=>[t("div",{class:"dl-tip-title"},i===e.length-1?`Today · ${yt(r.day)}`:yt(r.day)),t("div",{},te(o[i]))]),s}))}var oa={apply:"Repair",sync:"Reload devices",restart:"Restart service",netrestart:"Restart network",updates:"Open Components"};async function un(n){return n==="netrestart"&&!await ae("Restart the network?","Every interface restarts. Connections drop for a few seconds.","Restart network")?null:await W(()=>P.healthFix(n),"Done")??null}function Gn(n,e,o,a="action"){let r=n.fix;return r?r.startsWith("install:")?D("Install",()=>Xo(r.slice(8),o),a):r==="updates"?t("a",{class:`cbi-button cbi-button-${a}`,href:L.url("admin/network/dawnline/updates")},oa.updates):D(oa[r]??"Fix",()=>e(r),a):""}function xi(n){return/^(awg|up_|peers_|fw_|reply_|port_|subnet_)/.test(n)?"shield":/^(portal|cert)/.test(n)?"link":/^(ep_|home_|resolver)/.test(n)?"globe":n==="clock"?"clock":n==="agent"?"activity":n==="nft"?"lock":"alert"}function aa(n,e,o,a=3){let r=n.filter(s=>s.status==="error"||s.status==="warn").sort((s,d)=>s.status===d.status?0:s.status==="error"?-1:1);if(!r.length)return"";let i=r.length-a;return t("div",{class:"dl-list dl-notices"},[...r.slice(0,a).map(s=>ot(xi(s.id),s.status==="error"?"bad":"warn",s.problem??s.title,s.detail,Gn(s,e,o,s.status==="error"?"positive":"neutral"))),i>0?t("a",{class:"dl-row dl-notices-more",href:L.url("admin/network/dawnline/diagnostics")},[`${i} more in Diagnostics`,t("span",{class:"dl-spacer"}),"→"]):""])}function wi(n){let e=[],o=(s,d)=>t("a",{href:s},d),a=Re(n.series),r=!!n.awg_state&&!n.awg_state.ok;for(let s of n.servers)s.enabled&&s.blocked?e.push({tone:"bad",text:[`${s.name} ${s.blocked}. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]}):s.enabled&&!s.up&&!r&&e.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,o(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});for(let s of n.people)if(s.state==="quota")e.push({tone:"warn",text:[o(ke(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")e.push({tone:"warn",text:[o(ke(s.id),s.name),"’s access has ended."]});else{let d=tt(s.expires,a);d!=null&&d>=0&&d<=Math.max(s.expire_warn,3)&&e.push({tone:"",text:[o(ke(s.id),s.name),`’s access ends in ${d} day${d===1?"":"s"}.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&e.push({tone:"",text:[o(ke(s.id),s.name)," has used 90% of the data limit."]})}let i=n.people.flatMap(s=>s.devices.filter(d=>d.config_stale).map(d=>[s,d]));return i.length&&e.push({tone:"warn",text:i.length===1?[o(ke(i[0][0].id,i[0][1].id),`${i[0][0].name} · ${i[0][1].name}`)," needs its configuration again."]:[`${i.length} devices need their configuration again (networks or DNS changed).`]}),n.servers.some(s=>s.lan_like)&&n.like_home.error&&e.push({tone:"warn",text:[`Internet through the LAN is off: ${n.like_home.error} `,o(L.url("admin/network/dawnline/diagnostics"),"Details")]}),n.settings.portal_enabled||e.push({tone:"",text:["The personal portal is off. ",o(L.url("admin/network/dawnline/settings"),"Turn on")]}),e}var mn=class{constructor(e,o){this.srvId=e;this.go=o;this.el=t("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(e){this.st=Nt(e,this.srvId);for(let o of["health","bento","side","activity"])this.parts[o]=t("div",{});return dom.content(this.el,[this.parts.health,this.parts.bento,this.mapCard(),t("div",{class:"dl-grid2"},[this.parts.activity,this.parts.side])]),this.paint(),this.loadHealth(),this.el}update(e,o=!1){this.st=Nt(e,this.srvId),this.paint(o),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let e=await P.health().catch(()=>null);if(!e)return;let o=()=>void this.loadHealth(),a=async r=>{await un(r)&&(o(),r==="netrestart"&&setTimeout(o,5e3))};Le(this.parts.health,aa(e.checks,r=>void a(r),o),!0)}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let e=this.st,o=t("div",{class:"dl-panel-head pad"},[t("div",{class:"dl-stack"},[t("h3",{},"Where people connect from"),t("span",{class:"dl-sub"},"City-level, from the client IP · locations cached on the router")]),t("span",{class:"dl-spacer"}),bt(this.range,i=>{this.range=i,this.map?.setRange(i)})]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);this.map=new Ke({openPerson:i=>location.href=ke(i),openDevice:(i,s)=>location.href=ke(i,s)},this.range);let a=t("div",{class:"dl-map-legend"},[t("span",{},[t("i",{class:"line live"}),"Live tunnel"]),t("span",{},[t("i",{class:"line"}),"Seen recently"])]),r=t("div",{class:"dl-map-wrap"},[this.map.el,a]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),t("div",{class:"dl-panel flush"},[o,r])}paint(e=!1){let o=this.st,a=o.servers[0];Le(this.parts.bento,t("div",{class:"dl-bento"},[this.onlineTile(),this.speedTile(),Ie(a).overviewTile(a),this.monthTile()]),e);let r=wi(o);Le(this.parts.side,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Needs attention"),t("span",{class:"dl-spacer"}),t("a",{href:L.url("admin/network/dawnline/diagnostics")},"Health")]),r.length?r.slice(0,8).map(s=>t("div",{class:"dl-attn-item dl-row"},[t("span",{class:`dl-ev-dot ${s.tone}`}),t("span",{},s.text),s.action??""])):t("div",{class:"dl-row dl-muted"},[g("check"),"All good. Nothing needs you right now."])]),e);let i=[...o.events].reverse().slice(0,8);Le(this.parts.activity,t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"View all")]),i.length?i.map(s=>Ze(o,s)):t("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]),e)}onlineTile(){let e=this.st,o=e.servers[0]?!e.servers[0].enabled:!1,a=12,r=I=>I.spark[I.spark.length-1]??0,i=I=>e.geo.points.find(E=>E.device===I.id&&E.city)?.city,s=I=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(I.endpoint??""),d=(I,E=!1)=>s(I)?E&&I.endpoint?`LAN · ${I.endpoint}`:"LAN":i(I)??"",l=I=>[...e.events].reverse().find(E=>E.type==="connect"&&E.device===I.id)?.ts??0,c=e.people.map(I=>({p:I,devs:I.devices.filter(E=>E.online).sort((E,T)=>r(T)-r(E))})).filter(I=>I.devs.length).sort((I,E)=>E.devs.reduce((T,w)=>T+r(w),0)-I.devs.reduce((T,w)=>T+r(w),0)),p=c.length<=2,u=({p:I,devs:E})=>{let T=E.map(l).filter(Boolean),w=T.length?Math.min(...T):0,v=(I.rate??[]).slice(-15),x=v[v.length-1],$=x&&e.now-x[0]<180?x:null,m=200,h=30,N=Math.max(1,...v.map(V=>Math.max(V[1],V[2]))),C=V=>v.map((z,F)=>`${v.length>1?F/(v.length-1)*m:m},${h-2-z[V]/N*(h-6)}`),R=v.length>1?qe(``):"",Z=!$||$[1]<64&&$[2]<64,G=I.access==="both"?["home","globe"]:I.access==="lan"?["home"]:["globe"];return[t("div",{class:"dl-hc"},[t("div",{class:"dl-hc-head"},[t("span",{class:"dl-onl-av sm"},De(I.name)),t("span",{class:"dl-stack"},[t("b",{},I.name),t("span",{class:"dl-hc-since"},w?`online for ${ie(w,e.now).replace(" ago","")}`:"online")]),t("span",{class:"dl-hc-reach"},G.map(V=>t("span",{class:`dl-ibadge ${V==="home"?"lan":"inet"}`},g(V))))]),t("div",{class:"dl-hc-speed"},[t("div",{class:"dl-hc-speed-row"},Z?[t("span",{class:"dl-faint"},"Idle right now")]:[t("span",{},[t("span",{class:"dl-dn"},"↓"),` ${ze($[2])}`]),t("span",{},[t("span",{class:"dl-up"},"↑"),` ${ze($[1])}`]),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint"},"15 min")]),R]),t("div",{class:"dl-hc-devs"},E.map(V=>t("span",{class:"dl-hc-dev"},[g(V.kind),V.name,d(V)?[" · ",d(V,!0)]:""]))),t("div",{class:"dl-hc-foot"},[t("span",{class:"dl-faint"},`${te(E.reduce((V,z)=>V+r(z),0))} today · ${te(I.month[0]+I.month[1])} this month`)])])]},k=I=>{let{p:E,devs:T}=I,w=t("span",{class:"dl-onl-dev"},T.length>1?String(T.length):g(T[0].kind)),v=t("a",{class:`dl-onl-p${p?"":" sm"}`,href:ke(E.id),"aria-label":`${E.name}, online`},[t("span",{class:"dl-onl-av"},[De(E.name),w]),p?t("span",{class:"dl-onl-name"},E.name):"",p?t("span",{class:"dl-onl-meta"},[...T.slice(0,3).map(x=>g(x.kind)),T.length>3?`+${T.length-3}`:"",d(T[0])?t("span",{},[" · ",d(T[0])]):""]):""]);return me(v,()=>u(I)),v},f=t("b",{class:`dl-onl-count${c.length?"":" none"}`},String(c.length)),b=c.reduce((I,E)=>I+E.devs.length,0);c.length&&me(f,()=>[`${c.length} ${c.length===1?"person":"people"} · ${b} device${b===1?"":"s"}`]);let M=c.length>a?c.slice(0,a-1):c,j=e.people.flatMap(I=>I.devices.map(E=>({p:I,d:E}))).filter(I=>I.d.handshake).sort((I,E)=>E.d.handshake-I.d.handshake)[0];return t("div",{class:"dl-bento-tile online"},[t("div",{class:"dl-bento-head"},[t("span",{class:"dl-metric-label"},"Online"),f]),c.length?t("div",{class:`dl-onl-row${p?"":" grid"}`},[...M.map(k),c.length>a?t("a",{class:"dl-onl-p sm more",href:`${L.url("admin/network/dawnline/server")}?server=${encodeURIComponent(this.srvId)}§ion=people&filter=online`,title:"Everyone online",click:I=>{this.go&&(I.preventDefault(),this.go("people","online"))}},[t("span",{class:"dl-onl-av"},`+${c.length-M.length}`)]):""]):t("div",{class:"dl-onl-empty"},[t("span",{},o?"The server is turned off":"Nobody is connected"),j?t("span",{class:"dl-sub"},`Last: ${j.p.name}, ${ie(j.d.handshake,e.now)}`):t("span",{class:"dl-sub"},o?"Devices connect once it is on":"No device has connected yet")])])}speedTile(){let e=this.st.servers[0];return cn(e?.rate??[],this.st.now,this.st.totals.today,e?!e.enabled:!1)}monthTile(){return pn(this.st.series,"")}};var ra=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["awg",""]],yi={general:"connection",network:"connection",interfaces:"access",advanced:"awg",disguise:"awg",tunnel:"awg",core:"awg"},qn=(n,e)=>{let o=new URLSearchParams;n&&o.set("server",n),e&&e!=="overview"&&o.set("section",e);let a=o.toString();return`${L.url("admin/network/dawnline/server")}${a?`?${a}`:""}`},It=class{constructor(){this.noFooter=!0;this.root=t("div",{class:"dl-root"});this.section="overview";this.srvId="";this.ov={};this.pp={};this.tabsEl=t("div",{});this.headEl=t("div",{});this.secEl=t("div",{});this.bodyEl=t("div",{class:"dl-srvbody"})}async load(){let e=await P.status(31),o=e.servers.length?null:await P.setupDefaults();return[e,o]}render([e,o]){if(this.st=e,!e.servers.length&&o)return this.wizard(o);let a=new URLSearchParams(location.search),r=a.get("section")??"",i=yi[r]??r;return ra.some(([s])=>s===i)&&(this.section=i),this.srvId=(e.servers.find(s=>s.id===a.get("server"))??e.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),this.poller=Je({fetch:()=>P.status(31),every:30,live:!0,active:()=>this.section==="overview"&&this.root.isConnected,apply:(s,d)=>{s.servers.length&&(this.st=s,this.paintHead(d),this.ov[this.current().id]?.update(s,d))}}),this.root}paintHead(e=!1){Le(this.headEl,this.head(this.current()),e),(!e||!wt(this.tabsEl))&&this.paintTabs()}async refreshStatus(){let e=await P.status(31).catch(()=>null);return e?.servers.length?(this.st=e,this.paintHead(),e):null}current(){return this.st.servers.find(e=>e.id===this.srvId)??this.st.servers[0]}async refresh(){let e=await P.status(31).catch(()=>null);e&&(this.st=e,e.servers.length?this.paint():location.href=qn())}paint(){this.paintTabs(),dom.content(this.headEl,this.head(this.current())),this.paintSections(),this.showSection(this.section)}paintTabs(){let e=this.current();dom.content(this.tabsEl,t("div",{class:"dl-srvtabs",role:"tablist","aria-label":"Servers"},[...this.st.servers.map(o=>t("button",{type:"button",role:"tab",class:`dl-srvtab${o.id===e.id?" on":""}`,"aria-selected":o.id===e.id?"true":"false",click:()=>{o.id!==this.srvId&&(this.srvId=o.id,this.paint())}},[t("i",{class:`dot ${o.enabled?o.up?"ok":"bad":"warn"}`}),t("b",{},o.name)])),t("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[g("plus"),"Add server"])]))}paintSections(){let e=Ie(this.current());dom.content(this.secEl,t("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},ra.map(([o,a])=>t("button",{type:"button",role:"tab","data-section":o,class:o===this.section?"on":"","aria-selected":o===this.section?"true":"false",click:()=>this.showSection(o)},o==="awg"?e.label:a))))}go(e,o){let a=this.pp[this.current().id];if(o&&a)a.filter=o,a.el&&a.decorate();else if(o){let r=this.pp[this.current().id]=new it;r.filter=o}this.showSection(e),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let e=[...Object.values(this.ov).map(o=>o.el),...Object.values(this.pp).map(o=>o.el)];for(let o of e)o&&this.bodyEl.contains(o)&&o.remove()}showSection(e){this.section=e,this.secEl.querySelectorAll("[data-section]").forEach(s=>{let d=s.dataset.section===e;s.classList.toggle("on",d),s.setAttribute("aria-selected",d?"true":"false")});let o=this.st,a=this.current(),i={overview:()=>{let s=this.ov[a.id];return s?(s.update(o),s.el):(this.ov[a.id]=new mn(a.id,(d,l)=>this.go(d,l))).mount(o)},people:()=>{var c,p;let s=this.pp[a.id];if(s?.el)return s.update(),s.el;let d=t("div",{},t("p",{class:"dl-muted"},"Loading people…"));return((c=this.pp)[p=a.id]??(c[p]=new it)).embed(o,a.id).then(u=>{d.isConnected?dom.content(d,u):d.replaceChildren(u)}).catch(u=>{delete this.pp[a.id],dom.content(d,t("p",{class:"dl-muted"},`Couldn't show people: ${ve(u)}`))}),d},connection:()=>this.connection(a),access:()=>this.access(a),awg:()=>this.awg(a)}[e]();this.detachKept(),dom.content(this.bodyEl,i)}head(e){let o=(i,s)=>t("span",{class:"dl-addrbar-seg"},[g(i),...s]),a=e.endpoint||"—",r=t("div",{class:"dl-actions"},[e.enabled?"":D([g("play")," Turn on"],()=>this.save(e,{enabled:"1"},"Server turned on"),"add")]);return t("div",{class:"dl-srvpagehead"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),t("span",{class:`dl-pill ${e.enabled?e.up?"ok":"bad":"warn"}`},e.enabled?e.up?"Running":e.blocked?"Can’t start":"Not running":"Turned off"),t("span",{class:"dl-spacer"}),r]),t("div",{class:"dl-addrbar"},[t("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address",click:()=>ue(a,"Address copied")},[g("globe"),t("span",{class:"dl-mono"},a),g("copy")]),o("tunnel",[t("span",{class:"dl-mono"},`${Ie(e).label} :${e.port}`)]),e.up?o("clock",[`up ${ct(e.uptime)}`]):""]),e.blocked?t("div",{class:"dl-note warn"},[g("alert"),t("span",{},`${e.name} ${e.blocked}.`)]):""])}async save(e,o,a="Saved"){await W(()=>P.serverUpdate(e.id,o),a)&&await this.refresh()}connection(e){let o=se(e.name,{placeholder:"Home"}),a=se(e.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),r=se(e.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),i=this.st.people.filter(d=>d.server===e.id).length,s=D(e.enabled?"Turn off":"Turn on",async()=>{e.enabled&&!await ae(`Turn off ${e.name}?`,`The tunnel stops and ${i} ${i===1?"person is":"people are"} disconnected until you turn it back on. Nothing is deleted.`,"Turn off",!0)||await this.save(e,{enabled:e.enabled?"0":"1"},e.enabled?"Server turned off":"Server turned on")},e.enabled?"negative":"positive");return t("div",{class:"dl-stack gap16"},[St("Connection",[t("p",{class:"dl-muted"},"The name people see, where devices find the router, and DNS. The port is on AmneziaWG."),he("router","Server","What people see",[ne("Name",o,"Shown to people in their portal and apps.")]),he("globe","Devices connect to","Where the router answers from the internet",[ne("Public address",a,"Hostname or IP of the router on the internet. A DDNS name keeps links working when your IP changes. It must not go through Cloudflare: use a DNS-only name or an IP.")]),he("file","For every device","Changing it marks devices “Update config” until they import again",[ne("DNS for devices",r,"Empty = this router, which sends each query where your home network would.")])],[t("span"),D("Save",()=>this.save(e,{name:o.value,endpoint:a.value,dns:r.value}),"positive")]),St("Danger zone",[t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},e.enabled?"Turn off this server":"This server is off"),t("span",{class:"dl-sub"},e.enabled?"Stops the tunnel and disconnects everyone on it. Settings and people are kept.":"Nobody can connect. Turn it on to bring the tunnel back.")]),t("div",{class:"dl-setrow-ctl"},s)]),t("div",{class:"dl-setrow"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-setrow-label"},"Remove server"),t("span",{class:"dl-sub"},`Removes the tunnel, its firewall rules and ${i} ${i===1?"person":"people"} with all their devices. A backup is made first.`)]),t("div",{class:"dl-setrow-ctl"},D([g("trash")," Remove"],()=>this.remove(e),"negative"))])],[],"danger")])}access(e){let o=Un(this.st,e),a=ea(e,this.st,async()=>{let r=await this.refreshStatus();if(!r)return;let i=r.servers.find(d=>d.id===e.id)??e;a.update(r);let s=Un(r,i);o.replaceWith(s),o=s});return t("div",{class:"dl-stack gap16"},[a.el,t("div",{class:"dl-health-cols"},[o,Fo(this.st,e)])])}awg(e){let o={st:this.st,save:(a,r)=>this.save(e,a,r),refresh:()=>this.refresh()};return t("div",{class:"dl-stack gap16"},[Ie(e).settingsCard(o,e)])}async addServer(){let e=await W(()=>P.setupDefaults());e&&dom.content(this.root,this.wizard(e,!0,()=>{dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint()}))}async remove(e){let o=this.st.people.filter(a=>a.server===e.id);re(`Remove ${e.name}?`,[t("p",{},`This removes the tunnel, its firewall rules and ${o.length} ${o.length===1?"person":"people"} with all their devices. A backup is made first.`)],[le()," ",D("Remove",async()=>{ce(),await W(()=>P.serverDelete(e.id),"Server removed")&&setTimeout(()=>{location.href=qn()},800)},"negative")])}wizard(e,o=!1,a){let r={id:e.id,name:e.name,endpoint:e.endpoint,port:e.port,range:tn(e.subnet),preset:"standard",portal:!1,portal_port:e.portal_port||8443,lan_like:!0,lan_zone:e.lan_zone,wan_zone:e.wan_zone},i=0,s=!o&&r.portal_port===r.port,d=()=>/^\d{1,3}(\.\d{1,3}){3}$/.test(r.endpoint),l=()=>On(r.port,e.udp_taken??[],"Opened on the WAN firewall automatically."),c=()=>jo(r.range,e.networks??[],tn(e.subnet)),p=()=>nn(r.portal_port,e.tcp_taken??[],d()),u=t("div",{class:"dl-wizard"}),k=(v,x={})=>{let $=se(String(r[v]),x);return $.addEventListener("input",()=>{v==="port"||v==="portal_port"?r[v]=$.value.trim()===""?0:Number($.value):r[v]=$.value.trim(),v==="port"&&s&&(r.portal_port=r.port),v==="portal_port"&&(s=r.portal_port===r.port)}),$},f={id:"server",title:"Server",render:()=>t("div",{class:"dl-wizard-groups"},[t("p",{class:"dl-muted"},"Where devices connect to. A hostname that always points at your router (DDNS) keeps links working when your IP changes."),he("router","Server","What people see",[ne("Name",k("name"),"Shown to people in their portal and apps.")]),he("globe","Devices connect to","Where the router answers from the internet",[ne("Public address",k("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),"Hostname or IP address of your router on the internet. Not through Cloudflare: use a DNS-only name or an IP.")])]),check:()=>r.endpoint?null:"Fill in the public address."},b={id:"awg",title:"AmneziaWG",render:()=>t("div",{class:"dl-wizard-groups"},[he("globe","Listening","Where devices reach AmneziaWG from the internet",[ut("UDP port",k("port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),l)]),he("network","Tunnel network","Addresses devices get inside the tunnel",[(()=>{let v=k("range",{class:"cbi-input-text dl-w-range dl-mono","aria-label":"First three numbers of the device addresses"});return ut("Device addresses",v,c,t("span",{class:"dl-suffixed"},[v,t("span",{class:"dl-mono"},".x")]))})()]),he("shield","Disguise","So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard",[Jt(e.awg,r.preset,v=>r.preset=v,void 0,e.awg_state?.tools!==!1)])]),check:()=>{let v=l();if(v.bad)return`UDP port: ${v.text}`;let x=c();return x.bad?`Device addresses: ${x.text}`:null}},M={id:"portal",title:"Portal",render:()=>{let v=k("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),x=ut("Listening port",v,p);x.hidden=!r.portal;let $=xe([["off","Off"],["on","On"]],r.portal?"on":"off",{label:"Personal portal",onChange:m=>{r.portal=m==="on",x.hidden=!r.portal}});return t("div",{class:"dl-wizard-groups"},[he("home","Internet like a home device","How devices reach the internet",[ne("Through the home network",ge(r.lan_like,"Internet like a home device",m=>r.lan_like=m),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),he("link","Personal portal","A page where each person adds their own devices with their personal link",[ne("Portal",$,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),x])])},check:()=>{if(!r.portal)return null;let v=p();return v.bad?`Portal port: ${v.text}`:null}},j=()=>[f,b,o?null:M].filter(v=>v!=null),I=e.awg_state,E=I?.missing??[],T=E.length?t("div",{class:"dl-list dl-notices"},[ot("shield","bad","AmneziaWG isn’t installed",`The tunnel needs ${E.join(" and ")}. Install the build made for this firmware, then create the server.`,D("Install",()=>ln(()=>location.reload()),"positive"))]):I&&!I.loaded?t("div",{class:"dl-list dl-notices"},[ot("shield","warn","AmneziaWG’s kernel module doesn’t load on this firmware","Try another build in Components, or update OpenWrt. The server can’t start until it loads.",t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/updates")},"Open Components"))]):"",w=()=>{let v=j();i>=v.length&&(i=v.length-1),dom.content(u,[t("h2",{},o?"Add a server":"Set up Dawnline"),T,t("div",{class:"dl-steps"},v.map((x,$)=>t("span",{class:`dl-step${$===i?" current":$0?D("Back",()=>{i--,w()}):a?D("Cancel",a):"",t("span",{class:"dl-spacer"}),i{let x=v[i].check?.();if(x){Q(x,"warning");return}i++,w()},"positive"):D("Create server",async()=>{for(let $ of v){let m=$.check?.();if(m){Q(m,"warning");return}}let x=await W(()=>P.serverCreate(r.id,r.name,e.ifname,r.port,Bn(r.range),r.endpoint,e.mtu,r.preset,r.lan_zone,r.wan_zone,r.lan_like,o?void 0:r.portal,o?void 0:r.portal_port),"Server created");x&&(x.network_restart&&Q("Restarting the network so it knows AmneziaWG: back in a few seconds"),setTimeout(()=>{location.href=qn(x.id)},x.network_restart?1e4:1500))},"positive",{disabled:E.length>0,title:E.length?"Install AmneziaWG first":null})])])};return w(),u}};function Qe(n){let e={el:n(),refresh(){let o=n();e.el.replaceWith(o),e.el=o}};return e}function Pe(n,e,o,a,r="",i=[]){return t("section",{class:`dl-setsec ${r}`,id:`dl-set-${n}`},[t("div",{class:"dl-setsec-body"},[i.length?t("div",{class:"dl-setsec-head"},[t("h3",{},e),t("span",{class:"dl-spacer"}),...i]):t("h3",{},e),...o]),a.length?t("div",{class:"dl-setsec-foot"},a):""])}function ia(n){let e=n.filter(r=>r.status!=="skip"),o=e.filter(r=>r.status==="error"||r.status==="warn"),a=e.some(r=>r.status==="error")?"error":o.length?"warn":"ok";return{bad:o,worst:a}}function sa(n){let e=n.d.settings,o=n.d.effective,a=n.d.cert,r=ge(o.portal_enabled,"Enable portal"),i=se(e.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),s=se(e.portal_title,{placeholder:"Dawnline"}),d=se(e.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),l=se("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),c=B=>/^\d{1,3}(\.\d{1,3}){3}$/.test(B),p=[o.portal_host,...o.portal_alt??[]].filter((B,U,q)=>B&&q.indexOf(B)===U),u=!!n.portal,k=[],f=B=>{B&&!k.some(U=>U.host===B)&&k.push({host:B,kind:c(B)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})},b=B=>{k=[...B,...k.filter(U=>!B.some(q=>q.host===U.host))],!p.length&&B[0]&&(p=[B[0].host])};n.portal&&b(n.portal.candidates),p.forEach(f);let M=B=>B.kind==="ip"?t("span",{class:"dl-addr-warn"},[g("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):t("span",{class:"dl-sub"},B.cloudflare?"Behind Cloudflare · often stalls in Russia":B.ips.length?B.here?`Points at this router${B.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${B.ips.join(", ")}, not this router`:u?"Your address":"Checking where it points…"),j=t("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),I=B=>{p.includes(B)?p.length>1&&(p=p.filter(U=>U!==B)):p=[...p,B],E(),v()},E=()=>dom.content(j,[...k.map(B=>{let U=p.includes(B.host),q=p[0]===B.host;return t("div",{class:`dl-addr-opt${U?" on":""}`,role:"checkbox","aria-checked":U?"true":"false",tabindex:"0",click:()=>I(B.host),keydown:oe=>{(oe.key===" "||oe.key==="Enter")&&(oe.preventDefault(),I(B.host))}},[t("i",{class:"dl-addr-check"},U?g("check"):""),t("span",{class:"dl-stack"},[t("span",{class:"dl-mono"},B.host),M(B)]),q?t("span",{class:"dl-pill info"},"Main"):U?t("button",{type:"button",class:"dl-linkbtn",click:oe=>{oe.stopPropagation(),p=[B.host,...p.filter(_=>_!==B.host)],E(),v()}},"Make main"):B.cloudflare?t("span",{class:"dl-pill warn"},"Cloudflare"):B.kind==="ip"?t("span",{class:"dl-pill"},"IP"):B.here&&B.cert?t("span",{class:"dl-pill ok"},"Recommended"):""])}),t("div",{class:"dl-addr-opt other"},[t("i",{class:"dl-addr-check"},g("plus")),l,D("Add",()=>{let B=l.value.trim().toLowerCase();B&&(f(B),p.includes(B)||(p=[...p,B]),l.value="",E(),v())})])]);l.addEventListener("keydown",B=>{B.key==="Enter"&&(B.preventDefault(),l.nextElementSibling?.click())});let T=t("div",{class:"dl-links"}),w=()=>{},v=()=>{w();let B=Number(i.value)||o.portal_port;dom.content(T,p.map((U,q)=>{let oe=c(U),_=oe?B+1:B,A=`${oe?"http":"https"}://${U}${_===(oe?80:443)?"":`:${_}`}/`;return t("div",{class:"dl-link-row"},[t("span",{class:`dl-link-ic ${oe?"warn":"ok"}`},g(oe?"alert":"lock")),t("span",{class:"dl-mono dl-link-url"},[A,t("b",{},"kamiro-telosu-bavine")]),q===0?t("span",{class:"dl-pill info"},"Main"):oe?t("span",{class:"dl-pill warn"},"HTTP"):""])}))};E(),v(),i.addEventListener("input",()=>v());let x={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_http:"Plain HTTP",cert:"Certificate"},$=n.d.needs??{https:[],acme:[],home:[]},m=B=>{if(!o.portal_enabled)return t("div",{hidden:!0});if(!B)return he("check","Ready to share","The portal’s checks from Health",[t("p",{class:"dl-muted dl-loading"},"Running checks…")]);let U=B.filter(y=>y.status!=="skip");if(!U.length)return t("div",{hidden:!0});let{bad:q,worst:oe}=ia(B),_=t("div",{class:"dl-ready-details",hidden:!0},U.map(y=>t("div",{class:`dl-ready-item ${y.status}`},[g(y.status==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("span",{},y.title),t("span",{class:"dl-sub"},y.detail)])]))),A=t("div",{class:"dl-stack gap8"},[t("div",{class:`dl-ready-sum ${oe}`},[g(oe==="ok"?"check":"alert"),t("span",{class:"dl-stack"},[t("b",{},oe==="ok"?`All ${U.length} checks passed`:`${U.length-q.length} of ${U.length} checks passed`),q.length?t("span",{class:"dl-sub"},q.map(y=>y.detail).join(" ")):t("span",{class:"dl-sub"},"Links will open for the people you send them to.")]),t("button",{type:"button",class:"dl-linkbtn",click:y=>{_.hidden=!_.hidden,y.currentTarget.textContent=_.hidden?"Details":"Hide"}},"Details")]),t("div",{class:"dl-chips-row"},U.map(y=>t("span",{class:`dl-check-chip ${y.status}`,title:y.detail},[g(y.status==="ok"?"check":"alert"),x[y.id]??y.title]))),_]);return he("check","Ready to share","The portal’s checks from Health",[A])},h=B=>{if(!o.portal_enabled||!B&&!$.https.length)return t("span",{hidden:!0});if($.https.length)return t("span",{class:"dl-pill bad"},"Can’t start");let{worst:U}=ia(B);return t("span",{class:`dl-pill ${U==="ok"?"ok":U==="error"?"bad":"warn"}`},U==="error"?"Needs attention":"Ready")},N=m(n.portal?.checks??null),C=h(n.portal?.checks??null);n.portalFill=B=>{u=!0,b(B.candidates),E(),v();let U=m(B.checks);N.replaceWith(U),N=U;let q=h(B.checks);C.replaceWith(q),C=q};let R=a&&!a.self_signed&&a.expires?He(a.expires):"",Z=ut("Listening port",i,()=>nn(i.value.trim()===""?o.portal_port:Number(i.value),n.d.tcp_taken??[],p.some(c)));w=Z.refresh;let G=!!(e.portal_cert&&e.portal_key),V=a?G?"Your files":a.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",z=()=>{let B=se(e.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),U=se(e.portal_key,{placeholder:"/etc/ssl/…/key"});re("Use your own certificate",[t("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),ne("Certificate file",B),ne("Key file",U)],[le()," ",D("Save",()=>{ce(),n.save({portal_cert:B.value.trim(),portal_key:U.value.trim()},"Certificate saved","portal")},"positive")])},F=(B,U,q,oe,_,A)=>ot(B,U,q,oe,D(A,()=>Rt(_,$[_],()=>n.reload("portal")),"positive")),X=$.https.length?F("lock","bad","HTTPS isn’t available on this router",`The portal needs ${$.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",de=$.acme.length&&(!a||a.self_signed)?F("lock","","Free certificate from Let’s Encrypt",`ACME isn’t installed. With it the router gets a certificate${e.portal_host?` for ${e.portal_host}`:""} and browsers stop warning.`,"acme","Install ACME"):"",fe=[t("div",{class:"dl-row"},[g("lock"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},[V,R?t("span",{class:"dl-faint"},` · until ${R}`):""]),t("span",{class:"dl-sub dl-ellipsis",title:a?.path??""},a?a.self_signed?"Made by the router: browsers warn until a certificate covers the address.":`${G?"Your files":"Found automatically"} · ${a.path}`:"Turn the portal on to see its certificate.")])]),t("div",{class:"dl-row"},[g("file"),t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Your own files"),t("span",{class:"dl-sub"},G?`${e.portal_cert} · ${e.portal_key}`:"Not set: the certificate is picked automatically.")]),G?D("Reset",()=>n.save({portal_cert:"",portal_key:""},"Automatic certificate","portal"),"negative"):"",D(G?"Change":"Use files",z)]),de];return Pe("portal","Personal portal",[t("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),X?t("div",{class:"dl-list"},[X]):"",he("network","Port","How the portal listens (80 and 443 stay free)",[Z]),he("edit","Appearance","What people see",[ne("Title",s,"Shown at the top of the portal."),ne("Unknown links",d,"Where a wrong or old link goes, for example your website. Empty shows a plain “Not found”.")]),he("link","Addresses","Pick one or more; the first is the main link",[j,t("div",{class:"dl-stack gap8"},[T,t("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),he("lock","Certificate","Used for HTTPS links",fe),N],[t("span"),D("Save",()=>n.save({portal_enabled:_e(r)?"1":"0",portal_host:p[0]??"",portal_alt:p.slice(1),portal_port:i.value,portal_title:s.value,portal_redirect:d.value.trim()},"Saved","portal"),"positive")],"",[C,r])}function la(n){let e=n.d.settings,o=n.d.effective,a=se(e.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),r=ge(o.hostnames,"Device hostnames"),i=se(e.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),s=se(e.home_dns_fallback==="none"?"":e.home_dns_fallback||o.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"});return Pe("defaults","Defaults",[ne("Devices per person",a,"Pre-filled when you add someone."),ne("Device hostnames",t("div",{class:"dl-hostport"},[r,t("span",{class:"dl-faint dl-mono"},"phone.myata."),i]),"Name devices in your home DNS."),ne("Fallback DNS",s,"For Home-only devices using home names: the second DNS server, used by the device when the tunnel is down. Empty = none.")],[t("span"),D("Save",()=>n.save({default_device_limit:a.value,hostnames:_e(r)?"1":"0",domain:i.value,home_dns_fallback:s.value},"Saved","defaults"),"positive")])}function da(n){let e=n.d.effective,o=ge(e.geo_enabled,"Locations"),a=t("select",{class:"cbi-input-select"},[t("option",{value:"ipwho.is",selected:e.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),t("option",{value:"ipapi.co",selected:e.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]);return Pe("map","Map & locations",[t("div",{class:"dl-setrow head"},[t("span",{class:"dl-muted"},"Show where people connect from on the Overview and person pages, at city level."),o]),ne("Provider",a)],[t("span",{class:"dl-sub"},"The router sends each new client IP to the provider once and caches the city. Map tiles load in your browser from CARTO; people never see the map."),D("Save",()=>n.save({geo_enabled:_e(o)?"1":"0",geo_provider:a.value},"Saved","map"),"positive")])}var ki=[["app","Dawnline"],["amneziawg","AmneziaWG"],["packages","System packages"]];function ca(n){let e=n.d.effective.updates,o=ge(e.check,"Check automatically",b=>f(b,_e(r))),a=xe([["6h","Every 6 h"],["12h","Every 12 h"],["1d","Daily"],["7d","Weekly"]],e.interval,{label:"How often",cls:"sm"}),r=ge(e.auto,"Install automatically",b=>f(_e(o),b)),i=se(e.time,{placeholder:"04:00",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono","aria-label":"Time"}),s=xe([["scheduled","At a set time"],["immediate","As soon as found"]],e.mode,{label:"When",cls:"sm",onChange:b=>i.hidden=b!=="scheduled"});i.hidden=e.mode!=="scheduled";let d=new Set(e.targets),l=t("div",{class:"dl-chips-row"},ki.map(([b,M])=>{let j=We(M,d.has(b),()=>{d.delete(b)||d.add(b),Kt(j,d.has(b))});return j})),c=ge(e.keep,"Keep the previous version"),p=ge(e.mirrors,"GitHub mirrors"),u=ne("How often",a),k=[ne("When",t("div",{class:"dl-hostport"},[s,i]),"A set time keeps tunnel restarts out of the evening; the run happens within an hour of it."),ne("Components",l,"AmneziaWG is off by default: a new kernel module restarts every tunnel.")],f=(b,M)=>{u.hidden=!b;for(let j of k)j.hidden=!M};return f(e.check,e.auto),Pe("updates","Updates",[t("span",{class:"dl-muted"},"How Dawnline keeps its components current. Every Dawnline update makes a backup of the settings first."),ne("Check automatically",o,"Looks for new versions in the background; Components shows what it found and the service log names it."),u,ne("Install automatically",r,"Downloads and installs new versions of the components below."),...k,ne("Keep the previous version",c,"Saves the replaced Dawnline or AmneziaWG package on flash, so Roll back works without internet. Under 1 MB."),ne("GitHub mirrors",p,"When GitHub is unreachable, download through mirrors. Checksums are still verified.")],[t("span",{class:"dl-sub"},"Run a check or an update by hand in Components."),D("Save",()=>n.save({update_check:_e(o)?"1":"0",update_interval:a.dataset.value,update_auto:_e(r)?"1":"0",update_mode:s.dataset.value,update_time:i.value.trim(),update_targets:[...d],update_keep:_e(c)?"1":"0",update_mirrors:_e(p)?"1":"0"},"Saved","updates"),"positive")])}function pa(n){let e=n.d.logs,o=e.policy,a=xe([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(o.keep_days),{label:"Keep activity",cls:"sm"}),r=xe([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(o.max),{label:"Maximum events",cls:"sm"}),i=xe([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],o.persist,{label:"Save to flash",cls:"sm"}),s=xe([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(o.usage_days),{label:"Daily traffic",cls:"sm"}),d=xe([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(o.usage_months),{label:"Monthly traffic",cls:"sm"}),l=new Set(o.categories),c=t("div",{class:"dl-chips-row"},ft.map(f=>{let b=We([at[f],t("b",{},String(e.by_category[f]??0))],l.has(f),()=>{l.delete(f)||l.add(f),Kt(b,l.has(f))},{title:fo[f]});return b})),p=e.oldest?He(new Date(e.oldest*1e3)):"",u=(f,b,M,j)=>t("div",{class:"dl-row"},[g(f),t("span",{class:"dl-row-main dl-stack"},[t("b",{},b),t("span",{class:"dl-sub"},M)]),...j]),k=f=>D(f.toUpperCase(),async()=>{let[b,M]=await Promise.all([P.status(1),P.events(2e4)]);Ue(b,M.events,f)},"neutral",{title:`Download the log as ${f.toUpperCase()}`});return Pe("logs","Logs & history",[t("p",{class:"dl-muted"},Ft(o)),ne("Keep activity",a,"Older events are removed automatically."),ne("Maximum size",r,"Newest events are kept when the log is full."),ne("Record",c,"Switched-off categories are not logged from now on."),ne("Save to flash",i,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),ne("Daily traffic",s,"Per-day history behind the charts."),ne("Monthly traffic",d,"Per-month totals; data limits use the current month."),t("h4",{class:"dl-setsub"},"Stored data"),t("div",{class:"dl-list"},[u("activity","Activity log",e.events?`${jt(e.events,"event")} since ${p} · ${_t(e.log_ram)} in memory${o.persist==="off"?"":`, ${_t(e.log_flash)} on flash`}`:"Empty",[k("csv"),k("json"),D("Clear",()=>Fe("Clear activity","Removes events from the log on the router.",{},()=>n.reload("logs")),"negative")]),u("chart","Traffic history",e.usage_days?`${jt(e.usage_days,"day")} since ${He(e.usage_since)} · ${_t(e.usage_flash)} on flash`:"Empty",[D("Reset",()=>gt("all","","",()=>setTimeout(()=>n.reload("logs"),300)),"negative")]),u("pin","Location cache",`${jt(n.d.geo_cached,"address","addresses")} · ${_t(e.geo_flash)} on flash`,[D("Clear",async()=>{await W(()=>P.geoClear(),"Location cache cleared")&&await n.reload("logs")},"negative")])])],[t("span",{class:"dl-sub"},"Clear one person or device from their own page."),D("Save",()=>n.save({log_keep_days:a.dataset.value,log_max:r.dataset.value,log_persist:i.dataset.value,usage_keep_days:s.dataset.value,usage_keep_months:d.dataset.value,log_category:[...l]},"Saved","logs"),"positive")])}var $i={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},ua=3;function Fn(n){let e=new Date(n*1e3),o=e.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"}),a=Math.round((new Date(new Date().toDateString()).getTime()-new Date(e.toDateString()).getTime())/864e5);return`${a===0?"Today":a===1?"Yesterday":e.toLocaleDateString("en-GB",{day:"numeric",month:"short"})}, ${o}`}async function Ei(n){let e=await W(()=>P.backupRead(n.name));if(!e)return;let o=atob(e.data),a=new Uint8Array(o.length);for(let i=0;iEi(n),"neutral","dl-icon-only"),$e("more","More",o=>we(o.currentTarget,[{label:"Restore",icon:g("reset"),run:async()=>{await ae("Restore this backup?",`Everything returns to ${Fn(n.created)}. The current state is backed up first.`,"Restore",!0)&&await W(()=>P.backupRestore(n.name),"Restored")&&e(!0)}},{label:"Delete",icon:g("trash"),danger:!0,run:async()=>{await ae("Delete this backup?",`The backup from ${Fn(n.created)} is removed from the router.`,"Delete",!0)&&await W(()=>P.backupDelete(n.name),"Backup deleted")&&e()}}]),"neutral","dl-icon-only")])])}function ha(n,e){let o=n.slice(0,ua).map(l=>ma(l,e)),a=n.slice(ua),r=n.length?t("div",{class:"dl-list"},[...o,a.length?t("details",{class:"dl-bk-older"},[t("summary",{},[g("chevron"),`${a.length} older backup${a.length===1?"":"s"}`]),...a.map(l=>ma(l,e))]):""]):t("div",{class:"dl-list"},[t("div",{class:"dl-row dl-muted"},"No backups yet.")]),i=D("Restore from file",async()=>{let l=await Ln(".tar.gz,.tgz,application/gzip","base64");if(!l)return;await ae("Restore from file?",`Replace the current Dawnline configuration with ${l.name}? The current state is backed up first.`,"Restore",!0)&&await W(()=>P.backupUpload(l.data),"Restored")&&e(!0)}),s=D("Export JSON",async()=>{let l=await W(()=>P.exportJson());l&&Ee(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(l,null,2),"application/json")}),d=D("Import JSON",async()=>{let l=await Ln(".json,application/json","text");if(!l)return;let c;try{c=JSON.parse(l.data)}catch{Q("Not a JSON file.","error");return}await ae("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await W(()=>P.importJson(c),"Imported")&&e(!0)});return t("section",{class:"dl-setsec",id:"dl-set-backups"},[t("div",{class:"dl-setsec-body"},[t("div",{class:"dl-setsec-head"},[t("div",{class:"dl-stack"},[t("h3",{},"Backups"),t("span",{class:"dl-sub"},"Nightly when something changed, and before every restore, import or update. The last 10 are kept.")]),t("span",{class:"dl-spacer"}),D([g("plus")," Back up now"],async()=>{await W(()=>P.backupCreate(),"Backup created")&&e()},"positive")]),r]),t("div",{class:"dl-setsec-foot"},[t("span",{class:"dl-sub"},"Backups contain private keys: keep downloads safe. JSON moves everything except usage history to another router."),t("span",{class:"dl-row-actions dl-bk-actions"},[i,s,d])])])}function Li(){let n=se("",{placeholder:"remove"});re("Remove Dawnline?",[t("p",{},"Everyone is disconnected and the tunnel, firewall rules and portal are removed. A backup is made first. Type “remove” to confirm."),n],[le()," ",D("Remove Dawnline",async()=>{await W(()=>P.uninstall(n.value.trim()),"Dawnline removed")&&(ce(),setTimeout(()=>location.reload(),800))},"negative")])}function fa(){return Pe("danger","Remove Dawnline from this router",[t("p",{class:"dl-muted"},"Deletes the tunnel, firewall rules, access table and hostnames Dawnline created, and stops the service. People and keys are kept in a backup.")],[t("span"),D("Remove",()=>Li(),"negative")],"danger")}var hn=class{constructor(){this.root=t("div",{class:"dl-settings-main"});this.backups=[];this.portal=null;this.portalSeq=0;this.cards={}}load(){return P.settingsGet()}render(e){this.d=e,this.cards={portal:Qe(()=>sa(this)),defaults:Qe(()=>la(this)),map:Qe(()=>da(this)),updates:Qe(()=>ca(this)),logs:Qe(()=>pa(this)),backups:Qe(()=>ha(this.backups,r=>this.loadBackups(r))),danger:Qe(()=>fa())};let o=["portal","defaults","map","updates","logs","backups","danger"];dom.content(this.root,o.map(r=>this.cards[r].el)),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),this.loadPortal();let a=new URLSearchParams(location.search).get("section");return a&&a!=="backups"&&requestAnimationFrame(()=>document.getElementById(`dl-set-${a}`)?.scrollIntoView({block:"start"})),t("div",{},[t("div",{class:"dl-pagehead"},[t("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(e,o,a){let r=await W(()=>P.settingsUpdate(e),o);r&&(this.d=r,this.cards[a].refresh(),a==="portal"&&this.loadPortal())}async loadPortal(){let e=++this.portalSeq,o=await P.portalInfo().catch(()=>null);e===this.portalSeq&&(this.portal=o??this.portal??{candidates:[],checks:[]},this.portalFill?.(this.portal))}async loadBackups(e=!1){e&&await this.reload();let o=await P.backupList().catch(()=>null);o&&(this.backups=o.backups,this.cards.backups?.refresh())}async reload(e){let o=await P.settingsGet().catch(()=>null);if(o){if(this.d=o,e)this.cards[e].refresh();else for(let a of Object.values(this.cards))a.refresh();(!e||e==="portal")&&this.loadPortal()}}};function ga(n,e=!1){return n&&(e?/^https?:\/\//i:/^https:\/\//i).test(n)?n:null}function va(n){let e=[],o=d=>{let l=[],c=/(`[^`]+`)|(\*\*[^*]+\*\*)|(\[[^\]]+\]\((https?:\/\/[^)\s]+)\))|(https?:\/\/[^\s<>()]+[^\s<>().,;:!?])/g,p=0;for(let u;u=c.exec(d);)u.index>p&&l.push(d.slice(p,u.index)),u[1]?l.push(t("code",{},u[1].slice(1,-1))):u[2]?l.push(t("b",{},u[2].slice(2,-2))):u[3]?l.push(t("a",{href:u[4],target:"_blank",rel:"noopener"},u[3].replace(/^\[|\]\(.*$/g,""))):u[5]&&l.push(t("a",{href:u[5],target:"_blank",rel:"noopener"},u[5].replace(/^https?:\/\/(github\.com\/)?/,""))),p=u.index+u[0].length;return p{r.length&&e.push(t("p",{},o(r.join(" ")))),r=[],a=null};for(let d of n.replace(/\r/g,"").split(` +`)){let l=d.trimEnd();if(i){/^```/.test(l.trim())?(e.push(t("pre",{},i.join(` +`))),i=null):i.push(d);continue}if(/^```/.test(l.trim())){s(),i=[];continue}let c=/^(#{1,6})\s+(.*)$/.exec(l),p=/^\s*[-*+]\s+(.*)$/.exec(l)??/^\s*\d+[.)]\s+(.*)$/.exec(l);c?(s(),e.push(t("h5",{},o(c[2])))):p?(r.length&&s(),a||(a=t("ul",{}),e.push(a)),a.appendChild(t("li",{},o(p[1])))):l.trim()?(a&&(a=null),r.push(l.trim())):s()}return i&&e.push(t("pre",{},i.join(` +`))),s(),e}function ba(n){let e=[],o=!1;for(let a of n.replace(/\r/g,"").split(` +`)){let r=/^#{1,6}\s+(.*)$/.exec(a);if(r){if(o=/^install\b/i.test(r[1].trim()),/^what.s new$/i.test(r[1].trim()))continue}else/^\*\*Full Changelog\*\*/.test(a)&&(o=!1);o||e.push(a)}return e.join(` `).replace(/\n{3,}/g,` -`).trim()}async function zt(n,t,o,a){let r=e("div",{class:"dl-notes"},e("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=e("div",{class:"dl-op-head"}),s="";ae(o,[i,r],[D([g("copy")," Copy"],()=>pe(s,"Release notes copied"))," ",se("Close")],"wide");try{let l=await S.updatesNotes(n,t,a??"");s=Zo(l.body||"");let d=Yo(l.url);dom.content(i,[l.published?e("span",{class:"dl-pill"},Ae(l.published)):"",l.prerelease?e("span",{class:"dl-pill warn"},"Pre-release"):"",e("span",{class:"dl-spacer"}),d?e("a",{href:d,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",g("open")]):""]),dom.content(r,s.trim()?Qo(s):e("p",{class:"dl-muted"},"This release has no notes."))}catch(l){dom.content(r,e("p",{class:"dl-muted"},ve(l)))}}var Xo={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},Hn=n=>n?Ae(n):"";function ri(n){let t=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return t||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function ta(n,t){let o=n.st,a=o.policy,r=o.kept?.app,i=t?.update&&t.tag?t.tag:o.version,s=v=>()=>zt("app",v,`What’s new in Dawnline ${v.replace(/^v/,"")}`),l=t?.tag&&(t.update||t.status==="latest")?ii(n,t.tag,t.update?o.version:""):null,d=t?.tag??i,p=a.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[a.interval]??24)*3600:0,c=(v,h)=>e("div",{class:"dl-stack gap4"},[e("span",{class:"dl-metric-label"},v),e("span",{class:"dl-comp-side-v"},h)]),m=[{label:"What’s new",ic:"file",run:s(i)},{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:`Reinstall ${o.version}`,ic:"reset",warn:!0,run:()=>n.op("app:reinstall","Reinstalling Dawnline",o.version)},r?{label:`Roll back to ${r.version}`,ic:"archive",warn:!0,run:async()=>{await ne(`Roll back to Dawnline ${r.version}?`,`The copy kept on the router replaces ${o.version}. A backup of the settings is made first.`,"Roll back")&&n.op("app:rollback","Rolling back Dawnline",o.version)}}:null];return e("section",{class:"dl-panel flush dl-comp-hero"},[e("div",{class:"dl-comp-hero-main"},[e("div",{class:"dl-comp-hero-head"},[e("span",{class:"dl-group-ic"},g("sunrise")),e("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",t,t?.latest??""),e("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",o.version),m,!0)]),e("div",{class:"dl-comp-verrow"},[e("div",{class:"dl-stack"},[e("div",{class:"dl-comp-big"},[o.version,t?.update?e("small",{},`→ ${t.latest}`):t?.status==="dev"&&t.latest?e("small",{class:"dl-faint"},`release ${t.latest}`):""]),e("span",{class:"dl-faint dl-comp-meta"},t?.error?"":t?.update?t.published?`released ${Hn(t.published)}`:"":t?.status==="dev"?"ahead of the latest release":t?`latest release${t.published?` · released ${Hn(t.published)}`:""}`:"not checked yet")])]),l?.items.length?e("div",{class:"dl-stack gap4"},[e("ul",{class:"dl-comp-bullets"},l.items.map(v=>e("li",{},v))),l.total>l.items.length?e("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(d)},`+${l.total-l.items.length} more in What’s new`):""]):"",t?.error?e("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},t.error):"",t?.update?e("div",{class:"dl-comp-btns"},[D("Update now",()=>n.op("app","Updating Dawnline",o.version),"positive",{disabled:n.busy}),D("What’s new",s(i))]):"",si(n)]),e("div",{class:"dl-comp-hero-side"},[c("Source",[g("globe"),e("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),c("Auto-update",[a.auto?ke("ok","On"):ke("","Off"),e("span",{class:"dl-muted"},a.auto?a.mode==="immediate"?"as soon as found":`${Xo[a.interval]==="weekly"?"weekly":"daily"} at ${a.time}`:a.check?`checks ${Xo[a.interval]}`:"checks off")]),c("Last check",o.check?[de(o.check.time,o.now),p>o.now?e("span",{class:"dl-faint"},`· next in ${st(p-o.now)}`):""]:["Never"]),c("Rollback",r?[e("span",{class:"dl-mono"},r.version),e("span",{class:"dl-faint"},"kept on flash")]:[e("span",{class:"dl-muted"},a.keep?"Kept after the next update":"Off")])])])}function ii(n,t,o){if(n.notes.has(t))return n.notes.get(t)??null;n.notes.set(t,null);let a=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await S.updatesNotes("app",t,"").catch(()=>null))?.body??"").split(` -`).map(l=>/^\s*[-*+]\s+(.*)$/.exec(l)?.[1]).filter(l=>!!l);i.length||(i=(await S.updatesChanges(o,t).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(l=>ri(a(l))),total:i.length};n.notes.set(t,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function si(n){let t=e("div",{class:"dl-params-body"}),o=e("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[e("summary",{},[g("chevron"),e("span",{},"Versions"),e("span",{class:"dl-sub"},"install any release")]),t]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&dn(n,t)}),n.versOpen&&dn(n,t),o}async function dn(n,t){let o=re("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),a=c=>{if(c=c.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(c))return Q("Enter a release tag like 0.3.1","warning");ea(n,c)};o.addEventListener("keydown",c=>{c.key==="Enter"&&(c.preventDefault(),a(o.value))});let r=e("div",{class:"dl-comp-tag"},[o,D("Install",()=>a(o.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=c=>{n.versPage=Math.max(1,n.versPage+c),dn(n,t)},l=c=>e("div",{class:"dl-comp-pager"},[e("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),e("span",{class:"dl-faint"},`Page ${i}`),e("button",{type:"button",class:"dl-linkbtn",disabled:c?null:"disabled",click:()=>s(1)},"Older →")]),d=n.versCache.get(i);if(!d){dom.content(t,[r,e("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{d=(await S.updatesReleases(i)).releases}catch(c){if(i!==n.versPage||!t.isConnected)return;dom.content(t,[r,e("div",{class:"dl-row-actions"},[e("span",{class:"dl-muted"},`Failed to load versions: ${ve(c)}`),D("Try again",()=>dn(n,t))]),l(!1)]);return}if(n.versCache.set(i,d),i!==n.versPage||!t.isConnected)return}if(!d.length)return dom.content(t,[r,e("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),l(!1)]);let p=n.st.version;dom.content(t,[r,...d.map(c=>{let m=c.tag.replace(/^v/,"");return e("div",{class:"dl-comp-ver"},[e("span",{class:"dl-mono"},m),e("span",{class:"dl-sub"},Hn(c.published)),c.prerelease?ke("warn","Pre-release"):"",e("span",{class:"dl-comp-ic"},ye("file","What’s new",()=>zt("app",c.tag,`What’s new in Dawnline ${m}`))),m===p?ke("ok","Installed"):D("Install",()=>ea(n,c.tag),"neutral",{disabled:n.busy})])}),l(d.length>=5)])}async function ea(n,t){let o=t.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await ne(`Install Dawnline ${o}?`,`It is older than ${n.st.version}. A backup of the settings is made first; restore it from Settings if something looks wrong.`,"Install")||n.op(`app@${t}`,`Installing Dawnline ${o}`,n.st.version)}function na(n,t){let o=n.st,a=o.kept?.amneziawg,r=t?.sources??{},i=Object.keys(r),s=t?.current??null,l=s?r[s]:void 0,d=!!t?.ru,p=o.needs?.awg??[],c=p.length?null:t?.installed??null,m=[];s&&c&&m.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Reinstalling AmneziaWG",c)}),a&&m.push({label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await ne(`Roll back AmneziaWG to ${a.version}?`,"The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds.","Roll back")&&n.op("amneziawg:rollback","Rolling back AmneziaWG",c??void 0)}});let v=[t?.release?{label:"What’s new",ic:"file",run:()=>zt("amneziawg",t.release,`What’s new in the ${l?.label??"AmneziaWG"} build`,s??"slava")}:null,{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${l?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...m.length?[null,...m]:[]].filter((u,f,N)=>u!==null||f>0&&N[f-1]!==null),h=o.tunnels??[],x=h.length?`Switching restarts ${h.length===1?"the tunnel":`${h.length} tunnels`} for a few seconds: ${h.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",R=h.length>1?`${h.slice(0,-1).join(", ")} and ${h[h.length-1]}`:h[0],_=h.length?`Switching restarts ${R} for a few seconds.`:"Switching takes a few seconds.",j=async u=>{let f=r[u];await ne(c?`Switch to AmneziaWG ${f.gen}?`:`Install AmneziaWG ${f.gen}?`,`The ${f.label} build, ${f.version}. ${x}${f.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,c?"Switch":"Install")&&n.op(`amneziawg:${u}${d?":ru":""}`,c?`Switching to AmneziaWG ${f.gen}`:"Installing AmneziaWG",c??void 0)},w=u=>{let f=r[u],N=s===u&&!!c;return e("div",{class:"dl-row"},[e("span",{class:"dl-row-main dl-stack"},[e("b",{},f.gen?`AmneziaWG ${f.gen}`:"AmneziaWG"),e("span",{class:"dl-sub"},`${f.label} · ${f.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),e("span",{class:"dl-mono dl-faint dl-comp-bver"},f.version??"none yet"),e("span",{class:"dl-comp-bact"},N?ke("ok","Active"):f.version?D(c?"Switch":"Install",()=>j(u),c?"neutral":"positive",{disabled:n.busy}):ke("","No build"))])},I=i.map(u=>r[u]?.newer?`${r[u].label} moves to ${r[u].newer.gen} with OpenWrt ${r[u].newer.tag.replace(/^v/,"")}.`:"").filter(Boolean),C=fe(d,"Russian translation",u=>{s&&n.op(`amneziawg:${s}${u?":ru":""}`,u?"Adding the Russian translation":"Removing the Russian translation",c??void 0)});C.disabled=!s||!c||n.busy;let T=n.awgOpen??!c,b=e("details",{class:"dl-params dl-comp-fold",open:T?"open":null},[e("summary",{},[g("chevron"),e("span",{},"Build and translation")]),e("div",{class:"dl-params-body"},[e("div",{class:"dl-list"},[...i.length?i.map(w):[e("div",{class:"dl-row"},e("span",{class:"dl-sub"},"Check for updates to see the builds for this router."))],e("div",{class:"dl-row"},[e("span",{class:"dl-row-main dl-stack"},[e("b",{},"Russian translation"),e("span",{class:"dl-sub"},"LuCI pages for AmneziaWG")]),e("span",{class:"dl-comp-bact"},C)])]),c&&i.length||I.length?e("div",{class:`dl-comp-status ${c&&i.length?"warn":"acc"}`},[g(c&&i.length?"alert":"download"),e("span",{},[c&&i.length?e("b",{},_):"",...I.map(u=>` ${u}`)])]):""])]);b.addEventListener("toggle",()=>n.awgOpen=b.open);let A=[];return t?.update&&c&&s?A.push(D(`Update to ${t.latest}`,()=>n.op(`amneziawg:${s}${d?":ru":""}`,"Updating AmneziaWG",c),"neutral",{disabled:n.busy})):A.push((t||p.length)&&!c?ke("warn","Not installed"):n.state("amneziawg",t,t?.latest??"")),A.push(n.round(()=>n.op("check:amneziawg","Checking AmneziaWG",c??void 0),v)),[n.row("shield","AmneziaWG",[c?`${c}${t?.release?` · ${t.release} build`:""}`:p.length?`missing ${p.join(", ")}`:t?"not installed":"version not checked"],A),e("div",{class:"dl-comp-foldwrap"},b)]}var li=[{title:"Home-like link",sub:"Policy routing and the veth pair",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"HTTPS for the portal",sub:"OpenSSL for uhttpd",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"Certificates (ACME)",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],In={home:"network",https:"lock",acme:"file"};function oa(n,t){let o=n.st,a=t?.pkgs??{},r=li.filter(p=>p.feature==="home"?o.home:o.portal),i=async(p,c,m=p)=>{await ne(`Update ${c}?`,`${m.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&n.op(`pkgs:${p.join(",")}`,`Updating ${c}`)},s=[{label:"Check system packages",ic:"refresh",run:()=>n.op("check:packages","Checking system packages")},{label:"Open the OpenWrt package list",ic:"globe",run:()=>window.open("https://openwrt.org/packages/start","_blank","noopener")}],l=0;return{rows:r.map(p=>{let c=p.pkgs.filter(R=>a[R]?.installed),m=[...new Set(c.flatMap(R=>[...a[R]?.latest?[R]:[],...a[R]?.with??[]]))],v=o.needs?.[p.feature]??p.pkgs.filter(R=>!a[R]?.installed),h=c.find(R=>a[R]?.latest),x=c.map(R=>`${R} ${a[R]?.installed??""}`).join(", ");return v.length?n.row(In[p.feature],p.title,[`${p.optional?"not installed":`missing ${v.join(", ")}`}`],[D("Install",()=>n.op(`pkgs:${v.join(",")}`,`Installing ${p.title}`),p.optional?"neutral":"positive",{disabled:n.busy}),e("span",{class:"dl-comp-ic"},n.more(s))]):t&&m.length?(l++,n.row(In[p.feature],p.title,h?[`${a[h].installed} → ${a[h].latest}`,m.length>1?` · +${m.length-1}`:""]:[m.join(", ")],[D("Update",()=>i(c.filter(R=>a[R]?.latest||a[R]?.with?.length),p.title,m),"neutral",{disabled:n.busy}),e("span",{class:"dl-comp-ic"},n.more(s))])):n.row(In[p.feature],p.title,[x||p.sub],[n.state("pkgs",t,""),e("span",{class:"dl-comp-ic"},n.more(s))])}),updates:l,total:r.length}}var di={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"System packages",all:"Components"};function aa(n){let t=n.st,o=r=>{let i=Ve(r.component??"app"),s=di[i]??"Components",l=r.auto?"automatically":"by you",d="ok",p="check",c;if(r.kind==="found")d="accent",p="download",c=[e("b",{},(r.items??[]).join(", ")),` found by ${r.auto?"the automatic check":"a check"}`];else if(r.state==="failed")d="bad",p="x",c=[e("b",{},s),` ${r.kind==="install"?"update":"check"} failed${r.error?` · ${r.error}`:""}`];else{let m=r.from&&r.to&&r.from!==r.to?` ${r.from} → ${r.to}`:r.to?` ${r.to}`:"";c=[e("b",{},s),`${m} ${m?"":"updated "}${l}${r.took?` · ${st(r.took)}`:""}`.replace(/\s+/g," ")]}return e("div",{class:"dl-row"},[e("span",{class:`dl-ev-tile ev ${d}`},g(p)),e("span",{class:"dl-row-main"},c),e("span",{class:"dl-faint dl-nowrap",title:new Date(r.ts*1e3).toLocaleString()},de(r.ts,t.now))])},a=t.history??[];return e("section",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-spacer"}),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All in Log →")]),a.length?e("div",{},a.slice(0,8).map(o)):e("p",{class:"dl-sub dl-comp-empty"},"Updates, and checks that found something, show up here.")])}var cn=class{constructor(){this.root=e("div",{class:"dl-upd"});this.following=null;this.versOpen=!1;this.versPage=1;this.versCache=new Map;this.notes=new Map;this.awgOpen=null}load(){return S.updatesStatus()}render(t){return this.st=t,this.paint(),t.job?.state==="running"&&this.follow(t.job),poll.add(async()=>{if(!this.root.isConnected)return;let o=await S.updatesStatus().catch(()=>null);if(!o)return;let a=this.st;this.st=o,o.job?.state==="running"&&this.following!=="starting"&&o.job.id!==this.following&&this.follow(o.job),(o.job?.id!==a.job?.id||o.job?.state!==a.job?.state||o.job?.phase!==a.job?.phase||o.check?.time!==a.check?.time)&&this.paint()},5),this.root}get busy(){return this.st.job?.state==="running"}async refresh(t){this.st=t??await S.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(t,o,a){if(this.busy||this.following==="starting"){Q("Another component action is already running","warning");return}this.following="starting",this.paint();let r=Ve(t),i=await Mt(t,{title:o,version:a,onJob:s=>this.following=s.id,onDone:s=>this.refresh(s),onUpdate:s=>{let l=s.check?.components??{};r==="amneziawg"&&l.amneziawg?.current?this.op(`amneziawg:${l.amneziawg.current}${l.amneziawg.ru?":ru":""}`,"Updating AmneziaWG",l.amneziawg.installed??void 0):this.op("app","Updating Dawnline",this.st.version)}});this.following==="starting"&&(this.following=i?.id??null),this.refresh()}async follow(t){this.following=t.id;let o=Zt(t),a={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"system packages",all:"components"}[o]??"components";await Mt(null,{title:`${t.action==="check"?"Checking":t.auto?"Automatic update:":"Updating"} ${a}`,onDone:r=>this.refresh(r)},t)}paint(){let t=this.st,o=t.check?.components??{},a=t.firmware,r=oa(this,o.packages),i=(t.needs?.awg??[]).length>0,l=(!i&&o.amneziawg?.update&&o.amneziawg.installed?1:0)+r.updates;dom.content(this.root,[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Components"),e("span",{class:"dl-faint"},[a?.version?`OpenWrt ${a.version} · ${a.target}`:"",t.check?`checked ${de(t.check.time,t.now)}`:"not checked yet"].filter(Boolean).join(" · "))]),e("div",{class:"dl-row-actions"},[e("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[g("edit")," Settings"]),D([g("refresh")," Check all"],()=>this.op("check","Checking all components"),"neutral",{disabled:this.busy})])]),ta(this,o.app),e("div",{class:"dl-comp-cols"},[e("section",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Components"),e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint dl-comp-count"},i?l?`AmneziaWG not installed · ${l} update${l===1?"":"s"}`:"AmneziaWG not installed":!o.amneziawg&&!o.packages?"":l?`${l} of ${1+r.total} need${l===1?"s":""} an update`:"Everything is up to date")]),e("div",{},[...na(this,o.amneziawg),...r.rows])]),aa(this)])])}state(t,o,a){let r=this.st.job;if(r?.state==="running"){let i=l=>l==="packages"?"pkgs":l,s=r.action==="check"?[i(r.component||"all")]:(r.component??"").split(" ").map(l=>i(Ve(l)));if(s.includes(t)||s.includes("all"))return e("button",{type:"button",class:"dl-pill info dl-comp-run",title:"Show progress",click:()=>this.follow(r)},[r.action==="check"?"Checking":"Updating","…"])}return o?o.error?ke("warn","Check failed",o.error):o.update?ke("info","Update available"):o.status==="dev"?ke("info","Newer than release",`The latest release is ${a}`):ke("ok","Up to date"):ke("","Not checked")}more(t){let o=D([g("more")],()=>we(o,t.filter((a,r,i)=>a!==null||r>0&&ra?{label:a.label,icon:g(a.ic),warn:a.warn,run:a.run}:null)),"neutral",{title:"More","aria-label":"More"});return o}round(t,o,a=!1){let r=this.busy?" is-busy":"",i;return a?i=D([g("refresh")," Check"],t,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${r}`,"aria-label":"Check for updates"}):(i=ye("refresh","Check for updates",t,"neutral",r.trim()),i.removeAttribute("title"),i.setAttribute("aria-label","Check for updates"),ue(i,()=>["Check for updates"])),e("span",{class:"dl-comp-ic"},[i,this.more(o)])}row(t,o,a,r){return e("div",{class:"dl-row"},[e("span",{class:"dl-group-ic"},g(t)),e("span",{class:"dl-row-main dl-stack"},[e("b",{},o),e("span",{class:"dl-mono dl-faint dl-comp-sub"},a)]),...r])}};var ra=(n,t)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},n),e("div",{class:"cbi-value-field"},t)]);function ia(n){let t=n.st.servers.find(o=>o.id===n.p.server)?.name??"Home";Lt(n.p,t)}async function sa(n){let t=n.p;if(!await ne("Create a new link?","The old link stops working right away.","Create new link",!0))return;let o=await U(()=>S.personRegen(t.id),"New link created");o?.link&&await pe(o.link,"New link copied")}function Bn(n){let t=e("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},n.p.note??"");ae("Note",[t],[se()," ",D("Save",async()=>{le(),await n.patch({note:t.value.trim()},t.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>t.focus(),50)}function la(n){let t=n.p,o=e("select",{class:"cbi-input-select"},[e("option",{value:"pause",selected:t.expire_action==="pause"?"selected":null},"Pause access"),e("option",{value:"notify",selected:t.expire_action==="notify"?"selected":null},"Keep access"),e("option",{value:"remove",selected:t.expire_action==="remove"?"selected":null},"Remove their devices")]),a=e("select",{class:"cbi-input-select"},[0,1,3,7,14].map(r=>e("option",{value:r,selected:t.expire_warn===r?"selected":null},r?`${r} day${r===1?"":"s"} before`:"Don’t warn")));ae("When access ends",[ra("Then",o),e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Warn"),e("div",{class:"cbi-value-field"},[a,e("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[se()," ",D("Save",async()=>{le(),await n.patch({expire_action:o.value,expire_warn:a.value},"Saved")},"positive")])}function da(n){let t=e("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48});ae("Rename",[ra("Name",t)],[se()," ",D("Save",async()=>{le(),await n.patch({name:t.value},"Renamed")},"positive")]),setTimeout(()=>t.select(),50)}async function ca(n){let t=n.p;await ne(`Delete ${t.name}?`,`All ${t.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await U(()=>S.personDelete(t.id),"Deleted")&&(location.href=ht(t.server))}function pa(n){let t=n.p,o=n.st,a=t.online?"online now":t.last_seen?`last seen ${de(t.last_seen,o.now)}`:"never connected",r=t.created?`Added ${ze(De(new Date(t.created*1e3)))}`:"",i=t.has_link??o.settings.portal_enabled,s=[{label:"Rename",icon:g("edit"),run:()=>da(n)},{label:t.note?"Edit note":"Add note",icon:g("file"),run:()=>Bn(n)},...i?[null,{label:"Invite card",icon:g("qr"),run:()=>ia(n)},{label:"New link",icon:g("key"),run:()=>sa(n)}]:[],null,{label:t.paused?"Resume":"Pause",icon:g(t.paused?"play":"pause"),warn:!t.paused,run:()=>n.patch({paused:!t.paused},t.paused?"Resumed":"Paused")},{label:"Delete",icon:g("trash"),danger:!0,run:()=>ca(n)}];return e("div",{class:"dl-person-head"},[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-person-id"},[e("span",{class:`dl-avatar lg${t.online?" online":""}`},Oe(t.name)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),It(t)]),e("span",{class:"dl-faint",title:r},`${t.devices.length} of ${t.device_limit} devices · ${a}`)])]),e("div",{class:"dl-pcard-actions"},[i?ye("link","Copy link",()=>Jt(t.id),"neutral","dl-icon-only"):"",ye("more","More",l=>we(l.currentTarget,s),"neutral","dl-icon-only")])]),t.note?e("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>Bn(n)},[g("file"),e("span",{},t.note)]):""])}function ua(n){let t=n.p,o=n.series[n.series.length-1];return e("div",{class:`dl-person-live${t.online?"":" solo"}`},[t.online?on(t.rate??[],n.st.now,o?[o.rx,o.tx]:[0,0]):"",an(n.series,`${ee(t.month[0]+t.month[1])} this month`)])}async function ci(n,t){let o=await U(()=>S.deviceConfig(t.id));o&&ae(`Set up ${t.name}`,[await n.core.connectBlock(o,"qr")],[se("Close")])}async function pi(n,t){let o=await U(()=>S.deviceConfig(t.id));if(!o)return;if(!o.has_private_key){Q("This device made its own keys in the browser; its configuration only exists there.","warning");return}let a=n.core.file.make(o);$e(a.name,a.text,"application/octet-stream")}function ma(n){let t=n.p,o=n.st.now,a=d=>He(t,d,n.deviceOpts()),r=d=>p=>{p.target.closest("button:not(.dl-dcard-title), a")||a(d)},i=d=>D([g("more")],p=>vo(p.currentTarget,t,d,n.deviceOpts()),"neutral",{title:"QR, file, key, rename, new keys, remove",class:"cbi-button cbi-button-neutral dl-icon-only"}),s=Ht(t.devices).map(d=>{let p=e("div",{class:"dl-dcard-head"},[e("span",{class:"dl-dcard-ic"},g(d.kind)),e("button",{type:"button",class:"dl-dcard-title",click:()=>a(d)},[e("b",{},d.name),Bt(d,o),d.config_stale?e("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),i(d)]),c=e("div",{class:"dl-dcard-trend"},[e("div",{class:"dl-stack"},[e("b",{},ee(d.month[0]+d.month[1])),e("span",{class:"dl-sub"},"this month")]),Ro(n.devSeries[d.id]??[])]);return e("article",{class:`dl-dcard clickable${d.online?" online":""}${d.disabled?" off":""}`,click:r(d)},[p,d.handshake?c:d.disabled?e("div",{class:"dl-sub"},`${Be[d.kind]} · created ${de(d.created,o)} ${d.created_by==="portal"?"in the portal":"by you"}.`):e("div",{class:"dl-chips-row"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>ci(n,d)},[g("qr"),"Show QR"]),e("button",{type:"button",class:"dl-chipbtn",click:()=>pi(n,d)},[g("download"),"Config"])])])}),l=t.devices.length>=t.device_limit;return s.push(e("button",{type:"button",class:"dl-dslot add",click:()=>ot(t,n.deviceOpts())},[e("span",{class:"dl-dslot-ic"},g("plus")),e("span",{class:"dl-stack"},[e("b",{},"Add device"),e("span",{class:"dl-sub"},l?`Over the limit · ${t.devices.length} of ${t.device_limit}`:`${t.devices.length} of ${t.device_limit}`)])])),e("section",{class:"dl-devsec"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Devices"),e("span",{class:"dl-sub"},`${t.online} online`)]),e("div",{class:"dl-dgrid"},s)])}function ha(n){let t=n.p,o=xe([["device","Device’s own DNS"],["home","Home names"]],t.dns_mode,{label:"DNS",cls:"sm",optimistic:!1,onChange:r=>n.patch({dns_mode:r},r==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")}),a=n.st.settings.home_dns_fallback;return e("div",{class:"dl-stack gap4 dl-dnspick"},[e("div",{class:"dl-row-actions"},[e("span",{class:"dl-sub"},"DNS"),o]),e("span",{class:"dl-sub"},t.dns_mode==="home"?["Names like ",e("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",a?[" (",e("span",{class:"dl-mono"},a)," takes over when it is down)."]:" — with no fallback set, they stop when it is down."]:"Internet keeps working exactly as without the VPN. Reach home devices by IP address.")])}function fa(n){let t=n.p,a=n.st.servers.find(i=>i.id===t.server)?.home??[];if(a.length<2)return"";let r=new Set(t.home_nets?.length?t.home_nets:a.map(i=>i.dev));return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},a.map(i=>Ue(i.dev,r.has(i.dev),()=>{let s=new Set(r);if(s.delete(i.dev)||s.add(i.dev),!s.size)return Q("Keep at least one network, or choose Internet only.","warning",5e3);let l=s.size===a.length?[]:[...s];n.patch({home_nets:l},l.length?`${t.name} reaches ${l.join(", ")}`:`${t.name} reaches every home network`)},{title:i.nets.join(", ")}))),e("span",{class:"dl-sub"},t.home_nets?.length?`Home networks ${t.name} reaches. Networks added to the server later stay out.`:`Home networks ${t.name} reaches: all of them. Untick one to keep ${t.name} out of it.`)])}function ga(n){let t=new Set(n.p.services??[]);return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},n.st.services.map(o=>Ue(o.name,t.has(o.id),()=>{let a=new Set(t);a.delete(o.id)||a.add(o.id),n.patch({services:[...a]},a.size?"Home services updated":"Whole home network")},{title:`${o.address}${o.ports.length?` · ${o.ports.join(", ")}`:""}`}))),e("span",{class:"dl-sub"},t.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}function va(n){let t=n.p,o=n.st;if(o.servers.find(p=>p.id===t.server)?.mesh!=="circles"||!Je(t))return"";let r=o.circles.filter(p=>p.server===t.server),i=r.find(p=>p.id===t.circle),s=i?o.people.filter(p=>p.id!==t.id&&p.circle===i.id&&Je(p)).map(p=>p.name):[],l=e("button",{type:"button",class:"dl-chipbtn",click:()=>we(l,[...r.map(p=>({label:p.name,icon:Pn(p),run:()=>p.id!==t.circle&&n.patch({circle:p.id},`${t.name} is in ${p.name}`)})),t.circle?{label:"No circle",icon:g("x"),run:()=>n.patch({circle:""},`${t.name} is in no circle`)}:null,{label:"New circle",icon:g("plus"),run:()=>Yt(o,t.server,null,()=>n.refresh())}])},"Change"),d=i?o.people.filter(p=>p.circle===i.id&&Je(p)):[t];return e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Devices see each other"),l]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},i?i.name:"No circle"),e("span",{class:"dl-avstack",title:d.map(p=>p.name).join(", ")},d.slice(0,5).map(p=>e("span",{class:"dl-avatar sm"},Oe(p.name))))]),e("span",{class:"dl-sub"},i?s.length?[t.name,...s].join(", "):`Nobody else in ${i.name} yet`:`Only ${t.name}'s own devices`)])}function ba(n){let t=n.p,o=n.st.now,a=e("div",{class:"dl-slots"});for(let s=0;s=t.device_limit,p=e("i",{class:d?"over":l?"used":""});ue(p,()=>[e("div",{class:"dl-tip-title"},l?`${l.name}${d?" · over the limit":""}`:"Free slot"),e("div",{class:"dl-muted"},l?l.online?"Connected":l.handshake?`Last seen ${de(l.handshake,o)}`:"Not set up yet":"They can add a device here")]),a.appendChild(p)}let r=Math.max(1,t.devices.length),i=e("button",{type:"button","aria-label":"Allow fewer devices",disabled:t.device_limit<=r?"disabled":null,click:()=>n.patch({device_limit:String(t.device_limit-1)})},"−");return t.device_limit<=r&&t.devices.length>1&&ue(i,()=>[e("div",{class:"dl-tip-title"},`${t.devices.length} devices in use`),e("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},"Devices"),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[String(t.devices.length),e("span",{class:"dl-faint"},` / ${t.device_limit}`)]),e("div",{class:"dl-stepper"},[i,e("button",{type:"button","aria-label":"Allow more devices",disabled:t.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(t.device_limit+1)})},"+")])]),a])}var mi={internet:"Browse the internet through your router. No access to devices at home, and home cannot reach theirs.",lan:"Reach devices at home, and home reaches theirs. Internet stays on their own connection.",both:"Home devices and the internet, all through your router. Home reaches their devices too."},xa=/^([01]\d|2[0-3]):[0-5]\d$/;function hi(n){let t=n.p,o=n.today,a=Xe(t.expires,o),r=e("input",{type:"date",class:"dl-date-hidden",value:t.expires,tabindex:"-1","aria-hidden":"true"});r.addEventListener("change",()=>r.value&&n.patch({expires:r.value},`Access until ${ze(r.value)}`));let i=(p,c)=>{let m=Kn(t.expires&&(a??-1)>=0?t.expires:"",p,c,o);n.patch({expires:m},`Access until ${ze(m)}`)},s=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([p,c,m])=>e("button",{type:"button",class:"dl-chipbtn",click:()=>i(p,c)},m)),l=e("span",{class:"dl-datechip"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>{r.focus({preventScroll:!0});try{r.showPicker()}catch{}}},[g("calendar"),t.expires?ze(t.expires):"Date"]),r]),d={pause:"pause access",notify:"keep access",remove:"remove their devices"}[t.expire_action];return e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Access ends"),t.expires?e("span",{class:a!=null&&a<0?"dl-bad":a!=null&&a<=t.expire_warn?"dl-warn":"dl-ok"},a!=null&&a<0?"ended":`${a} day${a===1?"":"s"} left`):e("span",{class:"dl-faint"},"no end date")]),e("div",{class:"dl-chips-row"},[...s,l,t.expires?e("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},"No end date")},"No end"):""]),e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},`When it ends: ${d}${t.expire_warn?`, warn ${t.expire_warn} day${t.expire_warn===1?"":"s"} before`:""}`),e("a",{href:"#",click:p=>{p.preventDefault(),la(n)}},"Change")])])}function fi(n){let t=n.p,o=t.quota_used||t.month[0]+t.month[1],a=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,r=e("div",{class:`dl-meter${a>=100?" bad":a>=90?" warn":""}`},[e("i"),t.quota_limit?e("span",{class:"mark",title:"Alert at 90%"}):""]);r.firstChild.style.width=`${a}%`,t.quota_limit&&ue(r,()=>[e("div",{class:"dl-tip-title"},`${a.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${ee(t.quota_used)} of ${ee(t.quota_limit)} · ${ee(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},"Alert at 90%")]);let i=xe([["month","Monthly"],["total","Total"]],t.quota_period,{label:"Data limit period",cls:"sm",optimistic:!1,onChange:l=>n.patch({quota_period:l})}),s=[10,50,100].map(l=>e("button",{type:"button",class:`dl-chipbtn${t.quota_gb===l?" on":""}`,click:()=>n.patch({quota_gb:String(l)},`Data limit ${l} GB`)},`${l} GB`));return s.push(e("button",{type:"button",class:`dl-chipbtn${t.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},"No data limit")},"Unlimited")),s.push(e("button",{type:"button",class:"dl-chipbtn",click:()=>{let l=prompt("Data limit in GB",t.quota_gb?String(t.quota_gb):"");l!=null&&l.trim()!==""&&Number(l)>0&&n.patch({quota_gb:l.trim()},`Data limit ${l.trim()} GB`)}},"Custom")),e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Data"),i]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[ee(o),t.quota_limit?e("span",{class:"dl-faint"},` of ${ee(t.quota_limit)}`):e("span",{class:"dl-faint"}," · no limit")]),t.quota_period==="month"?e("span",{class:"dl-sub"},"resets on the 1st"):""]),t.quota_limit?r:"",e("div",{class:"dl-chips-row"},s),t.quota_gb&&t.quota_period==="month"?e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},t.bonus_gb?`Includes +${t.bonus_gb} GB extra this month`:"Need a little more this month?"),e("a",{href:"#",click:l=>{l.preventDefault(),n.patch({bonus_gb:String((t.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",e("div",{class:"dl-tile2-foot"},[e("span",{class:"dl-muted"},`${ee(t.total[0]+t.total[1])} in total`),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>ut("person",t.id,t.name,()=>setTimeout(()=>n.refresh(),300))},"Reset usage")])])}function gi(n){let t=n.p,o=!!t.hours,[a,r]=(t.hours||"07:00-23:00").split("-"),i=e("input",{type:"time",class:"cbi-input-text",value:a,"aria-label":"From"}),s=e("input",{type:"time",class:"cbi-input-text",value:r,"aria-label":"To"}),l=e("div",{class:"dl-tile2-row"},[i,e("span",{class:"dl-faint"},"to"),s]),d=()=>{let c=`${i.value}-${s.value}`;if(c!==t.hours){if(!xa.test(i.value)||!xa.test(s.value))return Q("Enter both times, like 07:00 and 23:00.","warning");if(i.value===s.value)return Q("The start and the end must differ.","warning");n.patch({hours:c},`Allowed ${i.value}–${s.value}`)}};l.addEventListener("focusout",c=>{l.contains(c.relatedTarget)||d()});for(let c of[i,s])c.addEventListener("keydown",m=>{m.key==="Enter"&&(m.preventDefault(),d())});let p=e("button",{type:"button",role:"switch","aria-checked":o?"true":"false",class:`dl-switch${o?" on":""}`,"aria-label":"Limit hours",click:()=>n.patch({hours:o?"":"07:00-23:00"},o?"Any time":"Allowed 07:00–23:00")},e("i"));return e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-row"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-tile2-label"},"Allowed hours"),e("span",{},o?`${a} – ${r} (router time)`:"Any time")]),p]),o?l:""])}function wa(n){let t=n.p,o=xe(["internet","lan","both"].map(a=>[a,[g(a==="internet"?"globe":a==="lan"?"home":"shield"),a==="internet"?"Internet":a==="lan"?"Home":"Both"]]),t.access,{label:"Access",cls:"wide",optimistic:!1,onChange:a=>n.patch({access:a},`Access: ${et[a]}`)});return e("section",{class:"dl-devsec","aria-label":"Access and limits"},[e("div",{class:"dl-panel-head"},[e("h3",{},"Access & limits")]),e("div",{class:"dl-panel"},[e("div",{class:"dl-stack gap8"},[e("span",{class:"dl-tile2-label"},"Can reach"),o,e("span",{class:"dl-sub"},mi[t.access]),t.access==="lan"&&n.st.services.length?ga(n):"",Je(t)?fa(n):"",t.access==="lan"?ha(n):""]),e("div",{class:"dl-tiles2"},[ba(n),va(n),hi(n),fi(n),gi(n)])])])}function vi(n){let t=n.st,o=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Locations"),e("span",{class:"dl-spacer"}),t.geo.enabled?tn("30d",r=>n.map?.setRange(r),!1):"",D("Hide",()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!t.geo.enabled)return e("div",{class:"dl-panel flush"},[o,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let a=new gt({openPerson:()=>{},openDevice:(r,i)=>{let s=n.p.devices.find(l=>l.id===i);s&&He(n.p,s,n.deviceOpts())}},"30d",280);return n.map=a,requestAnimationFrame(()=>a.mount(n.mapData())),e("div",{class:"dl-panel flush"},[o,a.el])}function ya(n){let t=n.st;if(!t.geo.enabled)return e("div",{class:"dl-places"},[g("pin"),e("div",{class:"dl-stack"},[e("span",{},"Locations are off"),e("span",{class:"dl-sub"},"City-level, from the client IP")]),e("span",{class:"dl-spacer"}),e("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:vi(n);let o=t.now-30*86400,a=t.geo.points.filter(s=>s.person===n.p.id&&s.ts>=o).sort((s,l)=>l.ts-s.ts),r=[...new Set(a.map(s=>s.city||s.country).filter(Boolean))],i=a[0];return e("div",{class:"dl-places"},[g("pin"),e("div",{class:"dl-stack"},[e("span",{},i?i.city||i.country:"No locations yet"),e("span",{class:"dl-sub"},i?`${r.length} place${r.length===1?"":"s"} in 30 days${i.org?` · ${i.org}`:""}`:"Shown after a device connects")]),e("span",{class:"dl-spacer"}),a.length?D("Show map",()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function ka(n){let t=n.p,o=n.st,a=n.events.filter(l=>l.person===t.id),r=[],i=[...a].reverse();for(let l=0;l1){let m=c.querySelector(".dl-row-main");dom.content(m,[...An(o,d).slice(0,3),e("span",{class:"dl-muted"},`${p} times`)]),m.title=i.slice(l,l+p).map(v=>v.detail??"").join(` -`)}r.push(c),l+=p-1}let s=D([g("more")],()=>we(s,[{label:"Export CSV",icon:g("download"),run:()=>je(o,a,"csv",t.id)},{label:"Export JSON",icon:g("download"),run:()=>je(o,a,"json",t.id)},null,{label:`Clear ${t.name}'s activity`,icon:g("trash"),danger:!0,run:()=>Fe(`Clear ${t.name}'s activity`,`Removes events about ${t.name} and their devices.`,{person:t.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-sub"},a.length>10?`latest 10 of ${a.length}`:""),e("span",{class:"dl-spacer"}),s]),r.length?r:e("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var pn=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(t){let[o,a,r]=await Promise.all([S.status(30),t?S.events(5e3).catch(()=>null):Promise.resolve(null),t?S.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:a?.events??null,use:r}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(t){this.take(t);let o=this.st.people.find(s=>s.id===this.id);if(!o)return e("div",{class:"dl-empty"},[e("h3",{},"Person not found"),e("p",{},"They may have been removed."),e("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=o;for(let s of["head","devices","traffic","places","activity","limits"])this.parts[s]=e("div",{});this.parts.devices.className="dl-person-devices";let a=e("div",{},[e("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[e("a",{href:ht(o.server)},this.st.servers.find(s=>s.id===o.server)?.name??"Servers"),e("span",{},"/"),e("a",{href:ht(o.server)},"People"),e("span",{},"/"),e("span",{},o.name)]),this.parts.head,e("div",{class:"dl-grid-person"},[e("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),e("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),i=r.get("device")&&o.devices.find(s=>s.id===r.get("device"));return i?setTimeout(()=>He(this.p,i,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>ot(this.p,this.deviceOpts()),50),this.poller=Ke({fetch:s=>{let l=s||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(l)},every:15,live:!0,active:()=>a.isConnected,apply:(s,l)=>this.apply(s,l)}),a}take(t){this.st=t.st,t.ev&&(this.events=t.ev),t.use&&(this.series=t.use.person,this.devSeries=t.use.devices)}apply(t,o){this.take(t);let a=this.st.people.find(r=>r.id===this.id);if(!a){o||(location.href=ht(this.p?.server));return}this.p=a,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(t,o){var i;this.poller?.claim();let a=await U(()=>S.personUpdate(this.p.id,t),o);if(!a)return;this.poller?.claim();let r=this.st.people.findIndex(s=>s.id===this.p.id);(i=a.person).rate??(i.rate=this.p.rate),r>=0&&(this.st.people[r]=a.person),this.p=a.person,this.paint()}get today(){return Ne(this.series.length?this.series:this.st.series)}get core(){return mt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}paint(t=!1){_e(this.parts.head,pa(this),t),_e(this.parts.traffic,ua(this),t),_e(this.parts.devices,ma(this),t),_e(this.parts.limits,wa(this),t),this.paintPlaces(t),_e(this.parts.activity,ka(this),t)}paintPlaces(t=!1){let o=ya(this);o&&_e(this.parts.places,o,t&&!this.mapOpen)}};var bi={ok:"check",warn:"alert",error:"x",skip:"pause"},un=class{constructor(t,o,a,r){this.el=e("div",{});this.wdEl=e("div",{});this.checksEl=e("div",{class:"dl-panel"});this.recentEl=e("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=e("div",{});this.open=new Set;this.st=t,this.sl=o,this.events=a,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,e("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,a)}async run(t){let o=t?await rn(t):await S.health().catch(()=>null);o&&(this.take(o),t==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(t){this.checks=t.checks,this.paintChecks(),this.paintLive(t,this.events)}paintChecks(){let t=this.checks;if(!t){dom.content(this.summary,""),dom.content(this.checksEl,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks")]),e("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let o=t.filter(s=>s.status==="error").length,a=t.filter(s=>s.status==="warn").length;dom.content(this.summary,o?dt("error",`${o} problem${o>1?"s":""} need attention.`):a?dt("warn",`${a} warning${a>1?"s":""}.`):dt("ok","All checks passed."));let r=new Map;for(let s of this.sl.watchdog.repairs)r.set(s.id,Math.max(r.get(s.id)??0,s.ts));let i=()=>this.run();dom.content(this.checksEl,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks"),e("span",{class:"dl-spacer"}),D("Run again",i)]),e("ul",{class:"dl-checks"},t.map(s=>e("li",{},[e("span",{class:`dl-check-icon ${s.status}`},g(bi[s.status])),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},s.title),e("div",{class:"dl-check-detail"},s.detail),r.has(s.id)?e("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${wt(r.get(s.id))}`):""]),zn(s,l=>void this.run(l),i)])))])}paintLive(t,o){this.sl=t,this.events=o;let a=t.watchdog,r=a.beat!=null&&a.now-a.beat>180,i=a.repairs.filter(d=>a.now-d.ts<86400),s=i[i.length-1],l=fe(a.enabled,"Watchdog repairs",async d=>{await U(()=>S.settingsUpdate({watchdog:d?"1":"0"}),d?"Watchdog on":"Watchdog off")||Sn(l,!d);let c=await S.serviceLog().catch(()=>null);c&&this.paintLive(c,this.events)});dom.content(this.wdEl,e("div",{class:"dl-panel dl-wd"},[e("div",{class:"dl-wd-head"},[e("span",{class:`dl-wd-tile${a.enabled?"":" off"}`},g("shield")),e("div",{class:"dl-stack"},[e("span",{class:"dl-wd-title"},"Watchdog"),e("span",{class:"dl-sub"},a.enabled?"Every minute it checks the tunnels and services and repairs what it can on its own.":"Off: problems are only written to the log. Nothing is repaired on its own.")]),e("span",{class:"dl-spacer"}),l]),e("div",{class:"dl-wd-foot"},[e("div",{class:"dl-wd-chips"},a.targets.map(d=>e("span",{class:`dl-check-chip${d.ok?"":" error"}`,title:d.ok?"OK":`Not working${d.tries?` · ${d.tries} repair${d.tries>1?"s":""}`:""}`},[g(d.ok?"check":"x"),d.name]))),e("span",{class:`dl-sub${r?" dl-warn-text":""}`},r?`The agent has not checked in for ${Math.round((a.now-a.beat)/60)} min; cron restarts it after 5.`:[a.last?`Looked ${de(a.last,a.now)}`:"Starts within a minute"," · ",i.length?`${i.length} repair${i.length>1?"s":""} today, last ${s.name} at ${wt(s.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let t=(this.sl.watchdog.now||Date.now()/1e3)-604800,o=[...this.events.map(r=>({ts:r.ts,ev:r})),...this.sl.log.map(r=>({ts:r.ts,sys:r}))].filter(r=>r.ts>=t&&jt(r)).sort((r,i)=>i.ts-r.ts),a=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Recent problems"),e("span",{class:"dl-spacer"}),o.length?e("a",{href:"#",click:r=>(r.preventDefault(),this.toLog())},"All in Log →"):""]);if(!o.length){dom.content(this.recentEl,[a,e("div",{class:"dl-recent-empty"},[e("span",{class:"dl-check-icon ok"},g("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[a,...o.slice(0,8).map(r=>{if(r.sys){let i=r.sys,s=`${i.ts}|${i.msg}`;return nn(i,this.open.has(s),()=>{this.open.delete(s)||this.open.add(s),this.paintRecent()},wt(i.ts))}return Ye(this.st,r.ev,{time:wt(r.ts)})})])}};var mn=300,xi=["all","connections","people","system","problems"],hn=class{constructor(t,o,a){this.events=[];this.system=[];this.kind="all";this.shown=mn;this.open=new Set;this.list=e("div",{});this.sub="";this.tabs=e("div",{class:"dl-seg",role:"tablist"});this.st=t,this.take(o),this.system=a,this.el=e("div",{},[e("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let t=()=>this.kind==="all"?"":this.kind,o=i=>()=>{let s=this.filtered().reverse();je(this.st,s.filter(l=>l.ev).map(l=>l.ev),i,t(),s.filter(l=>l.sys).map(l=>l.sys))},a=D([g("download")," Export"],()=>we(a,[{label:"CSV (spreadsheet)",icon:g("download"),run:o("csv")},{label:"JSON",icon:g("download"),run:o("json")}])),r=D([g("trash")," Clear"],()=>Fe("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[a,r]}take(t){this.events=t.events,this.policy=t.policy;let o=pt.filter(a=>!t.policy.categories.includes(a));this.sub=`${Ut(t.policy)}${o.length?` Not recorded: ${o.map(a=>nt[a].toLowerCase()).join(", ")}.`:""}`}async reload(){let[t,o]=await Promise.all([S.events(2e4).catch(()=>null),S.serviceLog().catch(()=>null)]);t&&this.take(t),o&&(this.system=o.log),this.paint()}items(){return[...this.events.map(t=>({ts:t.ts,ev:t})),...this.system.map(t=>({ts:t.ts,sys:t}))].sort((t,o)=>o.ts-t.ts)}matches(t,o){return o==="all"?!0:o==="problems"?jt(t):o==="system"?!!t.sys:!!t.ev&&$t(t.ev.type)===o}filtered(){return this.items().filter(t=>this.matches(t,this.kind))}paintTabs(t){dom.content(this.tabs,xi.map(o=>e("button",{type:"button",role:"tab",class:o===this.kind?"on":"","aria-selected":o===this.kind?"true":"false",click:()=>this.show(o)},[o==="all"?"All":o==="system"?"System":nt[o],e("b",{},String(t.filter(a=>this.matches(a,o)).length))])))}show(t){this.kind=t,this.shown=mn,this.paint()}paint(){this.paintTabs(this.items());let t=this.filtered();if(!t.length){dom.content(this.list,e("div",{class:"dl-empty"},[e("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let o=[],a="",r=null;for(let i of t.slice(0,this.shown)){let s=No(i.ts);s!==a&&(a=s,r=e("div",{class:"dl-panel flush"},e("div",{class:"dl-panel-head pad"},e("h3",{},s))),o.push(r));let l=new Date(i.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(i.sys){let d=`${i.sys.ts}|${i.sys.msg}`;r.appendChild(nn(i.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else r.appendChild(Ye(this.st,i.ev,{time:l}))}t.length>this.shown&&o.push(e("div",{class:"dl-more-row"},D(`Show ${Math.min(mn,t.length-this.shown)} more of ${t.length-this.shown}`,()=>{this.shown+=mn,this.paint()}))),dom.content(this.list,o)}};var wi=[["health","Health"],["log","Log"]],On=2e4,fn=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=e("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=e("span",{class:"dl-muted"});this.actionsEl=e("div",{class:"dl-row-actions"});this.bodyEl=e("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([S.status(1),S.events(On),S.serviceLog()])}render([t,o,a]){return this.log=new hn(t,o,a.log),this.health=new un(t,a,o.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),Ke({fetch:async()=>{let r=this.tab==="log",[i,s]=await Promise.all([S.serviceLog().catch(()=>null),r?S.events(On).catch(()=>null):Promise.resolve(null)]);return i||s?{n:i,e:s}:null},every:10,active:()=>this.bodyEl.isConnected,apply:({n:r,e:i})=>this.take(r,i)}),e("div",{},[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(t,o){o&&(this.log.take(o),this.eventsAt=Date.now()),t&&(this.log.system=t.log),t&&this.health.paintLive(t,o?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(t){this.tab=t,dom.content(this.segEl,wi.map(([o,a])=>e("button",{type:"button",role:"tab",class:o===t?"on":"","aria-selected":o===t?"true":"false",click:()=>o!==this.tab&&this.show(o)},a))),this.bodyEl.replaceChildren(t==="log"?this.log.el:this.health.el),this.subEl.textContent=t==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,t==="log"?this.log.actions():""),t==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&S.events(On).then(o=>this.take(null,o)).catch(()=>null)):this.health.checks||this.health.run()}};var $a=":root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));--dl-fg: var(--foreground, var(--text-color-highest, inherit));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));--dl-info: var(--info, #2c67c5);--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, #00a240);--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, #0d0d0d);--dl-primary-fg: var(--primary-foreground, #fff);--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}";var _a='.dl-plist{display:block}.dl-plist>.dl-card{display:block;margin:0 0 12px;padding:16px;min-width:0;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);box-shadow:var(--dl-shadow)}.dl-plist>.dl-card.dl-filtered{display:none}.dl-plist>.dl-card.dl-off .dl-card-name,.dl-plist>.dl-card.dl-off .dl-avatar{opacity:.6}.dl-plist-none{color:var(--dl-fg-muted);text-align:center;padding:28px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}.dl-avatar{flex:0 0 auto;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;color:var(--dl-fg);background:var(--dl-soft);position:relative;margin-right:4px;letter-spacing:.02em}.dl-avatar.online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:var(--dl-ok);box-shadow:0 0 0 2px var(--dl-card)}.dl-card-name{font-size:16px;line-height:24px;font-weight:500}.dl-card-slug{font-size:13px;color:var(--dl-fg-faint);font-family:var(--dl-mono)}.dl-quota{margin:8px 0 0 44px;max-width:320px;height:6px;border-radius:999px;background:var(--dl-track);overflow:hidden}.dl-quota>i{display:block;height:100%;background:var(--dl-accent);border-radius:999px}.dl-quota.warn>i{background:var(--dl-warn)}.dl-quota.bad>i{background:var(--dl-bad)}.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 0 44px}.dl-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;max-width:240px;height:28px;padding:0 12px 0 10px;border-radius:999px;font-size:13px;background:var(--dl-soft);color:var(--dl-fg);transition:background .15s}.dl-chip:hover{background:var(--dl-soft-hover)}.dl-chip:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-chip .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-chip.add{background:transparent;box-shadow:inset 0 0 0 1px var(--dl-line);color:var(--dl-fg-muted);aspect-ratio:1;padding:0;justify-content:center}.dl-chip.add:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-chip.disabled .dl-chip-name{text-decoration:line-through;color:var(--dl-fg-faint)}.dl-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);opacity:.6}.dl-dot.online{background:var(--dl-ok);opacity:1;box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-empty{text-align:center;padding:40px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-empty .dl-icon-wrap{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);margin-bottom:12px}.dl-empty .dl-icon{width:20px;height:20px}.dl-empty h3{margin:0 0 4px!important;font-size:16px;font-weight:500}.dl-empty p{margin:0 0 16px;color:var(--dl-fg-muted);font-size:14px}.dl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 16px}.dl-toolbar .dl-muted{font-size:13px}@media(max-width:640px){.dl-slotbar,.dl-chips,.dl-quota{margin-left:0}.dl-btn-label{display:none}}.cbi-value.dl-block{display:block!important}.cbi-value.dl-block>.cbi-value-title{display:block;width:auto;float:none;text-align:left;padding:0 0 8px}.cbi-value.dl-block>.cbi-value-field{display:block;width:100%;margin:0}';var Ea="#modal_overlay{z-index:1100!important}.dl-dd{position:fixed;z-index:1200;min-width:200px;padding:4px;border-radius:12px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:0 12px 32px #0000004d;display:flex;flex-direction:column}.dl-dd button{all:unset;cursor:pointer;display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;font-size:13px;color:var(--dl-fg)}.dl-dd button .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-dd button:hover,.dl-dd button:focus-visible{background:var(--dl-soft)}.dl-dd button.danger,.dl-dd button.danger .dl-icon{color:var(--dl-bad, #e5484d)}.dl-dd button.warn,.dl-dd button.warn .dl-icon{color:var(--dl-warn)}.dl-dd hr{border:0;border-top:1px solid var(--dl-line);margin:4px 0}.dl-chipbtn b{font-weight:500;font-size:11px;margin-left:6px;opacity:.6}.dl-setsub{margin:20px 0 8px!important;font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-row-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.dl-more-row{display:flex;justify-content:center;padding:8px 0 16px}.dl-dsec-actions{display:flex;align-items:center;gap:12px}.dl-kv-act{display:inline-flex;align-items:center;gap:12px;flex-wrap:wrap}.dl-linkbtn,.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 9px;margin:-4px -6px;border-radius:8px;font-size:12px;font-weight:500;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap;transition:background .12s,color .12s}.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{color:var(--dl-accent)}.dl-linkbtn:hover,.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:var(--dl-soft);color:var(--dl-fg);text-decoration:none!important}.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-linkbtn:focus-visible,.dl-bento-head a:focus-visible,.dl-bento-foot a:focus-visible,.dl-panel-head a:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-linkbtn.danger:hover{color:var(--dl-bad);background:var(--dl-bad-wash)}.dl-ifcards{display:flex;flex-direction:column;gap:20px;margin:24px 0}.dl-ifcard .dl-setsec-body{gap:14px}.dl-iflead{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-iflead b{font-size:14px;font-weight:500}.dl-ifgroup h4{margin:0 0 8px!important;padding:0!important;font-size:11px!important;font-weight:500!important;letter-spacing:.06em;text-transform:uppercase;color:var(--dl-fg-muted);border:0!important;background:none!important}.dl-ifgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}.dl-if{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 12px 8px 10px;min-width:0;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);transition:background .15s,border-color .15s}.dl-if:hover{background:var(--dl-soft)}.dl-if:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-if-ic{width:30px;height:30px;border-radius:8px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-if-ic .dl-icon{width:16px;height:16px}.dl-if-main{display:flex;flex-direction:column;min-width:0;flex:1}.dl-if-name{font-size:13.5px;font-weight:500;color:var(--dl-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if-sub{font:11px/16px var(--dl-mono);color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if.sel{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 9%,transparent)}.dl-if.sel .dl-if-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-if-check{color:var(--dl-accent);display:inline-flex}.dl-if-check .dl-icon{width:16px;height:16px}.dl-if.auto{border-color:color-mix(in srgb,var(--dl-ok) 55%,transparent);background:var(--dl-ok-wash);cursor:default}.dl-if.auto .dl-if-ic{background:color-mix(in srgb,var(--dl-ok) 18%,transparent);color:var(--dl-ok)}.dl-if-badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;flex:0 0 auto}.dl-if-badge.ok{color:var(--dl-ok)}.dl-if.off{cursor:default;opacity:.5}.dl-if.off:hover{background:var(--dl-card)}.dl-if.warn{border-color:color-mix(in srgb,var(--dl-warn) 60%,transparent)}.dl-if-wanctl{gap:10px;align-items:center}.dl-if-wanctl select{max-width:240px}.dl-if-summary{min-width:0;line-height:18px}.dl-warn{color:var(--dl-warn)}.dl-w-ip{width:160px}.dl-dnspick{padding-top:8px;border-top:1px solid var(--dl-line)}.dl-dnspick .dl-row-actions{gap:10px}.dl-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:18px;margin:0 0 10px;background:var(--dl-soft)}.dl-note.warn{background:var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent))}.dl-note .dl-icon{width:15px;height:15px;flex:0 0 auto;margin-top:1px;color:var(--dl-warn)}.dl-stale{align-self:flex-start;margin-top:4px;font-size:10.5px}.dl-root .cbi-button.dl-btn-warn,.dl-btn-warn.cbi-button{background:var(--dl-warn-wash)!important;color:var(--dl-warn)!important;border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}.dl-root .cbi-button.dl-btn-warn:hover,.dl-btn-warn.cbi-button:hover{background:color-mix(in srgb,var(--dl-warn) 24%,transparent)!important}.dl-btn-warn .dl-icon{color:var(--dl-warn)}.dl-srvtabs{display:flex;flex-wrap:wrap;gap:6px;padding:4px;margin:0 0 20px;border-radius:12px;background:var(--dl-soft);width:fit-content;max-width:100%}.dl-srvtab{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;border-radius:9px;font-size:13px;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap}.dl-srvtab b{font-weight:500}.dl-srvtab i.dot{width:7px;height:7px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-srvtab i.dot.ok{background:var(--dl-ok);animation:dl-srv-pulse 2s ease-out infinite}.dl-srvtab i.dot.bad{background:var(--dl-bad)}@keyframes dl-srv-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--dl-ok) 55%,transparent)}70%,to{box-shadow:0 0 0 6px transparent}}@media(prefers-reduced-motion:reduce){.dl-srvtab i.dot.ok{animation:none}}.dl-srvtab:hover{color:var(--dl-fg);background:var(--dl-soft-hover)}.dl-srvtab.on{background:var(--dl-card);color:var(--dl-fg);box-shadow:0 1px 2px #0000002e,inset 0 0 0 1px var(--dl-line)}.dl-srvtab:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-srvtab.add{color:var(--dl-fg-muted)}.dl-srvtab.add .dl-icon{width:14px;height:14px}.dl-srvhead{display:flex;flex-direction:column;gap:14px;margin:0 0 20px}.dl-srvhead .dl-title-row{display:flex;align-items:center;gap:10px}.dl-srvhead .dl-h1{margin:0!important}.dl-metrics.compact .dl-metric{padding:14px 18px}.dl-metrics.compact .dl-metric-value{display:flex;align-items:center;gap:6px;font-size:18px;line-height:26px;min-width:0}.dl-metrics.compact .dl-metric-value>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-metrics.compact .dl-metric-value .dl-mono{font-size:15px}.dl-metrics.compact .cbi-button{flex:0 0 auto}.dl-srvsections{margin:0 0 16px}.dl-srvbody>.dl-setsec,.dl-srvbody>.dl-ifcards{margin:0}.dl-srvbody .dl-ifcards{margin:0}.dl-metric-ic{display:inline-flex;align-items:center;gap:8px;font-size:16px}.dl-metric-ic .dl-icon{width:18px;height:18px;color:var(--dl-accent)}.dl-keyrow{display:inline-flex;align-items:center;gap:8px;min-width:0}.dl-keyrow code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;background:none;padding:0}.dl-params{border:1px solid var(--dl-line);border-radius:12px;background:var(--dl-card)}.dl-params>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;color:var(--dl-fg);user-select:none}.dl-params>summary::-webkit-details-marker{display:none}.dl-params>summary>.dl-icon-wrap{display:inline-flex;color:var(--dl-fg-muted);transition:transform .15s}.dl-params>summary>.dl-icon-wrap .dl-icon{width:15px;height:15px}.dl-params[open]>summary>.dl-icon-wrap{transform:rotate(90deg)}.dl-params>summary:focus{outline:none}.dl-params>summary:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px;border-radius:12px}.dl-params>summary:hover{background:var(--dl-soft);border-radius:12px}.dl-pcount{font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:4px 14px 14px}.dl-pgroup{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-pgroup-head{display:flex;align-items:center;gap:8px;font-size:13px}.dl-pgroup-head b{font-weight:500}.dl-pgroup-head .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-pgroup p{margin:0!important;font-size:12px;line-height:17px;color:var(--dl-fg-muted)}.dl-pvals{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}.dl-pv{display:inline-flex;align-items:stretch;max-width:100%;border-radius:6px;overflow:hidden;font:500 11.5px/22px var(--dl-mono);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pv i{font-style:normal;padding:0 6px;background:var(--dl-card);color:var(--dl-fg-faint)}.dl-pv b{font-weight:500;padding:0 7px;color:var(--dl-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}";var Sa=".dl-methods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}.dl-method{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;border:1px solid var(--dl-line);background:var(--dl-card);transition:border-color .15s,background .15s;min-width:0}.dl-method:hover{background:var(--dl-soft)}.dl-method:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-method.on{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 8%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-method.off{cursor:not-allowed;opacity:.55}.dl-method.off:hover{background:var(--dl-card)}.dl-method-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-method-head .dl-pill{flex:none}.dl-method-head b{font-weight:500;font-size:14.5px;flex:1}.dl-method-ic{width:32px;height:32px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);flex:0 0 auto}.dl-method-ic .dl-icon{width:17px;height:17px}.dl-method.on .dl-method-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-method p{margin:0!important;font-size:12.5px;line-height:18px;color:var(--dl-fg-muted);flex:1}.dl-method-meters{display:flex;gap:16px}.dl-dots{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-dots-row{display:inline-flex;gap:3px}.dl-dots-row i{width:6px;height:6px;border-radius:50%;background:var(--dl-line)}.dl-dots-row i.on{background:var(--dl-fg-muted)}.dl-method.on .dl-dots-row i.on{background:var(--dl-accent)}.dl-method-foot{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dl-fg-faint);padding-top:8px;border-top:1px solid var(--dl-line)}.dl-method-foot .dl-icon{width:13px;height:13px;flex:0 0 auto}.dl-method.off .dl-method-foot{color:var(--dl-warn)}.dl-ibadge{display:inline-flex;align-items:center;gap:3px;height:22px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);flex:0 0 auto}.dl-ibadge .dl-icon{width:13px;height:13px}.dl-ibadge.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ibadge.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-access{display:inline-flex;gap:4px;flex:0 0 auto}.dl-ibadge.lan{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ibadge.inet{background:var(--dl-ok-wash);color:var(--dl-ok)}";var Ca=".dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;gap:2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars i:hover{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-5px;bottom:-5px;width:20px;height:20px;border-radius:7px;background:var(--dl-card);box-shadow:0 0 0 1.5px var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;gap:3px;height:54px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars i:hover{background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-notices{margin:0 0 16px}.dl-notices .dl-need-row .dl-sub{overflow-wrap:anywhere}.dl-notices-more{font-size:13px;color:var(--dl-fg-muted);text-decoration:none}.dl-notices-more:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-speed-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.dl-speed-col{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-speed-val{font-size:20px;line-height:26px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-speed-today{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.dl-speed-today b{font-weight:500;color:var(--dl-fg)}.dl-speed-chart{display:block;width:100%;height:44px}.dl-speed-chart .area{fill:color-mix(in srgb,var(--dl-accent) 16%,transparent)}.dl-speed-chart .line{fill:none;stroke:var(--dl-accent);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-speed-chart .line.up{stroke:var(--dl-ok);stroke-width:1.2;opacity:.85}.dl-speed-wait{height:44px;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-speed-wait i{display:block;height:1px;background:var(--dl-line);order:2}.dl-fld{display:flex;flex-direction:column;gap:8px;margin:0 0 16px}.dl-fld-label{font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-fld .cbi-input-text{width:100%;box-sizing:border-box}.dl-kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.dl-kinds button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;border-radius:10px;border:1px solid var(--dl-line);color:var(--dl-fg-muted);font-size:12px;font-weight:500;text-align:center;min-width:0}.dl-kinds button .dl-icon{width:20px;height:20px}.dl-kinds button:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-kinds button:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-kinds button.on{border-color:var(--dl-accent);color:var(--dl-fg);background:color-mix(in srgb,var(--dl-accent) 10%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-kinds button.on .dl-icon{color:var(--dl-accent)}.dl-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.dl-choice{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:4px;padding:12px 14px;border-radius:12px;background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line);transition:background .15s,box-shadow .15s}.dl-choice:hover{background:var(--dl-soft)}.dl-choice:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-choice.selected{box-shadow:inset 0 0 0 2px var(--dl-accent);background:var(--accent-a10, color-mix(in srgb, var(--dl-accent) 8%, transparent))}.dl-choice-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg)}.dl-choice-text{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-attn-item>.cbi-button{margin-left:auto;flex:none;align-self:center}";var La='.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}';var Ta=".dl-setblock{display:flex;flex-direction:column;gap:8px;margin:0}.dl-addr-opts{display:flex;flex-direction:column;gap:6px}.dl-addr-opt{all:unset;box-sizing:border-box;cursor:pointer;display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line);min-width:0}.dl-addr-opt:hover{background:var(--dl-soft)}.dl-addr-opt.on{box-shadow:inset 0 0 0 1.5px var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 7%,transparent)}.dl-addr-opt .dl-mono{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-addr-opt .dl-stack{min-width:0}.dl-addr-opt input{width:100%}.dl-addr-opt.other{cursor:default}.dl-addr-opt.other:hover{background:none}.dl-addr-opt.other input{width:100%}.dl-addr-check{width:16px;height:16px;border-radius:5px;box-shadow:inset 0 0 0 1.5px var(--dl-fg-faint);display:inline-flex;align-items:center;justify-content:center}.dl-addr-check .dl-icon-wrap{display:inline-flex}.dl-addr-check .dl-icon{width:12px;height:12px}.dl-addr-opt.on .dl-addr-check{background:var(--dl-accent);box-shadow:none;color:#fff}.dl-addr-opt.other .dl-addr-check{box-shadow:none;color:var(--dl-fg-muted)}.dl-addr-warn{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:17px;color:var(--dl-warn)}.dl-addr-warn .dl-icon-wrap{display:inline-flex}.dl-addr-warn .dl-icon{width:13px;height:13px}.dl-pill.info{background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-links{border-radius:12px;background:var(--dl-soft);overflow:hidden}.dl-link-row{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 14px}.dl-link-row+.dl-link-row{border-top:1px solid var(--dl-line)}.dl-link-ic{display:inline-flex}.dl-link-ic .dl-icon{width:15px;height:15px}.dl-link-ic.ok .dl-icon{color:var(--dl-ok)}.dl-link-ic.warn .dl-icon{color:var(--dl-warn)}.dl-link-url{font-size:13px;color:var(--dl-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-link-url b{font-weight:500;color:var(--dl-accent)}@media(max-width:640px){.dl-link-url,.dl-addr-opt .dl-mono,.dl-filecard .dl-ellipsis,.dl-invite-link>span:first-child{white-space:normal;overflow-wrap:anywhere}}.dl-ready-sum{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px}.dl-ready-sum>.dl-icon-wrap{display:inline-flex}.dl-ready-sum>.dl-icon-wrap .dl-icon{width:18px;height:18px}.dl-ready-sum .dl-stack{flex:1;min-width:0}.dl-ready-sum b{font-weight:500;font-size:13px}.dl-ready-sum.ok{background:var(--dl-ok-wash)}.dl-ready-sum.ok b,.dl-ready-sum.ok .dl-icon{color:var(--dl-ok)}.dl-ready-sum.warn{background:var(--dl-warn-wash)}.dl-ready-sum.warn b,.dl-ready-sum.warn .dl-icon{color:var(--dl-warn)}.dl-ready-sum.error{background:var(--dl-bad-wash)}.dl-ready-sum.error b,.dl-ready-sum.error .dl-icon{color:var(--dl-bad)}.dl-check-chip{display:inline-flex;align-items:center;gap:5px;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;color:var(--dl-fg-muted)}.dl-check-chip .dl-icon-wrap{display:inline-flex}.dl-check-chip .dl-icon{width:13px;height:13px;color:var(--dl-ok)}.dl-check-chip.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-chip.warn .dl-icon{color:var(--dl-warn)}.dl-check-chip.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-ready-details{display:flex;flex-direction:column;gap:8px;padding:4px 2px}.dl-ready-details[hidden]{display:none}.dl-ready-item{display:flex;align-items:flex-start;gap:8px;font-size:13px;line-height:18px;min-width:0}.dl-ready-item .dl-icon-wrap{display:inline-flex;margin-top:1px}.dl-ready-item .dl-icon{width:15px;height:15px}.dl-ready-item.ok .dl-icon{color:var(--dl-ok)}.dl-ready-item.warn .dl-icon{color:var(--dl-warn)}.dl-ready-item.error .dl-icon{color:var(--dl-bad)}.dl-params-body{display:flex;flex-direction:column;gap:14px;padding:6px 14px 14px}.dl-params-body>.dl-setrow{margin:0;padding:0}.dl-pgrid.flush{padding:0;grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:640px){.dl-pgrid.flush{grid-template-columns:minmax(0,1fr)}}.dl-qr-pane{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.dl-qr{width:min(280px,72vw);aspect-ratio:1;background:#fff;padding:8px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-qr svg{display:block;width:100%;height:100%}.dl-filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--dl-soft);min-width:0}.dl-filecard>.dl-stack{flex:1;min-width:0}.dl-filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--dl-mono);color:var(--dl-fg-muted);background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-params>.dl-conf{margin:0;border-top:1px solid var(--dl-line);border-radius:0 0 12px 12px;background:none}.dl-conf-sec{color:var(--dl-accent)}.dl-conf-k{color:var(--dl-fg-faint)}.dl-conf-mask{padding:0 6px;border-radius:4px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-params>summary .dl-chipbtn{height:26px;font-size:12px}.dl-conf{white-space:pre-wrap;word-break:break-all;max-height:22em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:0;padding:12px;border-radius:12px;background:var(--dl-soft)}.dl-key{width:100%;box-sizing:border-box;font-family:var(--dl-mono);font-size:12px;word-break:break-all;min-height:7em}.dl-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:12px 0 0}.dl-link-box{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.dl-link-box input{flex:1 1 18em;min-width:0;font-family:var(--dl-mono);font-size:12px}.dl-hint{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin:8px 0}.dl-divider{border:0;border-top:1px solid var(--dl-line);margin:16px 0}";var Ma=".dl-checks{list-style:none;margin:0;padding:0}.dl-checks li{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--dl-line)}.dl-checks li:first-child{border-top:0;padding-top:0}.dl-checks li:last-child{padding-bottom:0}.dl-check-icon{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}.dl-check-icon .dl-icon{width:14px;height:14px}.dl-check-icon.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-check-icon.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-icon.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-icon.skip{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-check-body{flex:1;min-width:0}.dl-check-title{font-size:14px;line-height:20px;font-weight:500}.dl-check-detail{font-size:12px;line-height:16px;color:var(--dl-fg-muted);overflow-wrap:anywhere}.dl-check-repaired{margin-top:2px;font-size:12px;line-height:16px;color:var(--dl-warn)}.dl-wd{margin:0 0 16px;display:flex;flex-direction:column;gap:14px}.dl-wd-head{display:flex;align-items:center;gap:12px;min-width:0}.dl-wd-head>.dl-stack{min-width:0}.dl-wd-title{font-size:16px;line-height:24px;font-weight:500}.dl-wd-tile{flex:none;width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-wd-tile.off{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-wd-tile .dl-icon{width:18px;height:18px}.dl-wd-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-wd-chips{display:flex;flex-wrap:wrap;gap:6px;flex:1 1 auto;min-width:0}.dl-wd-chips .dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-warn-text{color:var(--dl-warn)!important}.dl-health-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(440px,100%),1fr));gap:16px;align-items:start}.dl-health-cols>.dl-panel{margin:0;min-width:0}.dl-recent{display:flex;flex-direction:column}.dl-recent .dl-panel-head a{font-size:13px}.dl-recent-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 16px;color:var(--dl-fg-muted);font-size:13px;border-top:1px solid var(--dl-line)}.dl-loading{margin:0;font-size:13px}.dl-diag-tabs{margin:0 0 16px}.dl-row.dl-slog-row{align-items:baseline}.dl-slog-row .dl-ev-tile{align-self:flex-start;margin-top:-1px}.dl-slog-row.has-detail{cursor:pointer}.dl-row.dl-slog-row.has-detail:hover{background:color-mix(in srgb,var(--sys) 11%,transparent)}.dl-slog-more{display:inline-flex;vertical-align:-2px;margin-left:6px;color:var(--dl-fg-faint);transform:rotate(90deg);transition:transform .15s}.dl-slog-more .dl-icon{width:14px;height:14px}.dl-slog-more.open{transform:rotate(-90deg)}.dl-slog-detail{margin:8px 0 2px;padding:8px 10px;border-radius:8px;background:var(--dl-soft);font-family:var(--dl-mono);font-size:12px;line-height:17px;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dl-fg-muted);cursor:text}.dl-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}.dl-table th{text-align:left;font-weight:500;color:var(--dl-fg-faint);padding:0 8px 8px;border-bottom:1px solid var(--dl-line)}.dl-table td{padding:10px 8px;border-bottom:1px solid var(--dl-line);vertical-align:middle}.dl-table th:first-child,.dl-table td:first-child{padding-left:0}.dl-table th:last-child,.dl-table td:last-child{padding-right:0}.dl-table tr:last-child td{border-bottom:0}.dl-table .dl-right{text-align:right;white-space:nowrap}.dl-log{max-height:18em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:8px 0 0;padding:12px;white-space:pre-wrap;border-radius:12px;background:var(--dl-soft)}";var Pa=".dl-pagehead{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 0 20px}.dl-h1{margin:0!important;padding:0!important;font-size:24px!important;line-height:32px!important;font-weight:500!important;border:0!important}.dl-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.dl-stack{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-stack.gap4{gap:4px}.dl-stack.gap8{gap:8px}.dl-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-ok{color:var(--dl-ok)}.dl-warn{color:var(--dl-warn)}.dl-bad{color:var(--dl-bad)}.dl-icon-only{width:auto!important;min-width:0!important;aspect-ratio:1 / 1;padding:0!important;justify-content:center;display:inline-flex!important;align-items:center;border-radius:999px!important}.dl-panel.flush{padding:0;overflow:hidden}.dl-panel-head.pad{padding:16px 16px 12px;margin:0}.dl-col{display:flex;flex-direction:column;gap:16px;min-width:0}.dl-col>.dl-panel,.dl-col>section.dl-panel{margin:0}.dl-crumbs{display:flex;gap:8px;align-items:center;font-size:14px;margin:0 0 16px;color:var(--dl-fg-faint)}.dl-crumbs a{color:var(--dl-fg-faint)}.dl-crumbs a:hover{color:var(--dl-fg)}.dl-crumbs span:last-child{color:var(--dl-fg)}.dl-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);margin:0 0 16px;box-shadow:var(--dl-shadow)}.dl-metric{display:flex;flex-direction:column;gap:4px;padding:16px 20px;min-width:0}.dl-metric+.dl-metric{border-left:1px solid var(--dl-line)}.dl-metric-label{font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-metric-value{font-size:28px;line-height:36px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-metric-value .dl-faint{font-size:16px}.dl-metric-sub{font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:900px){.dl-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.dl-metric:nth-child(3){border-left:0}.dl-metric:nth-child(n+3){border-top:1px solid var(--dl-line)}}.dl-seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--dl-soft);flex-wrap:wrap}.dl-seg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:500;color:var(--dl-fg-muted);white-space:nowrap}.dl-seg button:hover{color:var(--dl-fg)}.dl-seg button.on{background:var(--dl-soft-hover);color:var(--dl-fg)}.dl-seg.dl-srvsections{flex-wrap:nowrap;max-width:100%;overflow-x:auto;scrollbar-width:none}.dl-seg.dl-srvsections::-webkit-scrollbar{display:none}.dl-seg.dl-srvsections button{flex:none;white-space:nowrap}.dl-seg button:focus-visible{outline:2px solid var(--dl-ring)}.dl-seg button b{font-weight:500;font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft)}.dl-seg button b.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-seg.sm button{padding:2px 9px;font-size:11px}.dl-seg.wide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-radius:12px;padding:4px}.dl-seg.wide button{flex-direction:column;justify-content:center;padding:8px 6px;border-radius:9px;gap:3px}.dl-seg.wide button.on{background:var(--dl-primary);color:var(--dl-primary-fg)}";var Da='.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.dot{width:8px;height:8px;border-radius:50%;background:var(--dl-fg-faint)}.dl-map-legend i.dot.ok{background:var(--dl-ok)}.dl-map-legend i.line{width:14px;height:2px;border-radius:2px;background:var(--dl-ok)}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;width:18px;height:18px;display:inline-flex;align-items:center;justify-content:center;position:relative}.dl-mk-dot{width:12px;height:12px;border-radius:50%;background:#8f8f8f;box-shadow:0 0 0 3px #0000008c}.dl-mk.online .dl-mk-dot{width:14px;height:14px;background:#40c977}.dl-mk.online:before{content:"";position:absolute;inset:-9px;border-radius:50%;background:#40c97747;animation:dl-pulse 2s ease-out infinite}@keyframes dl-pulse{0%{transform:scale(.5);opacity:1}to{transform:scale(1.4);opacity:0}}@media(prefers-reduced-motion:reduce){.dl-mk.online:before{animation:none}}.dl-mk-home{width:22px;height:22px;border-radius:7px;background:#ededed;display:flex;align-items:center;justify-content:center;box-shadow:0 0 0 4px #ededed2e,0 2px 6px #00000080;color:#131313}.dl-mk-home-ic{width:13px;height:13px}.dl-popup{z-index:4}.dl-popup .maplibregl-popup-content{background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);border-radius:12px;padding:12px;box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));font:inherit}.dl-popup .maplibregl-popup-tip{border-top-color:var(--dl-elevated)!important;border-bottom-color:var(--dl-elevated)!important}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-mk.multi{width:26px;height:26px}.dl-mk-count{min-width:22px;height:22px;padding:0 6px;border-radius:999px;background:#8f8f8f;color:#0a0a0a;font:600 11px/22px var(--dl-mono);text-align:center;box-shadow:0 0 0 3px #0000008c;box-sizing:border-box}.dl-mk.online .dl-mk-count{background:#40c977}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px -4px 0}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:5px 4px;border-radius:6px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.maplibregl-ctrl-attrib{font-size:10px}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-spark i:hover{opacity:1;filter:brightness(1.25)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;gap:2px;flex:0 0 auto}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}';var Aa=`.dl-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-row.link{color:inherit;text-decoration:none}.dl-row.link:hover{background:var(--dl-soft)}.dl-row-main{flex:1;min-width:0;overflow-wrap:anywhere}.dl-row-main b{font-weight:500}.dl-attn{display:flex;flex-direction:column;gap:10px;padding:16px;border-top:1px solid var(--dl-line)}.dl-attn-item{display:flex;gap:10px;align-items:baseline;font-size:13px;color:var(--dl-fg-muted)}.dl-avatar.sm{width:26px;height:26px;font-size:10px;margin:0}.dl-avatar.lg{width:48px;height:48px;font-size:15px;margin:0}.dl-avatar.lg.online:after{width:12px;height:12px}.dl-list{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-list>.dl-row:first-child{border-top:0}.dl-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-row-main.dl-stack{min-width:0}.dl-person-id{display:flex;align-items:center;gap:14px;min-width:0}.dl-grid-person{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:16px;align-items:start}@media(max-width:1000px){.dl-grid-person{grid-template-columns:minmax(0,1fr)}}.dl-devsec{display:flex;flex-direction:column;gap:12px}.dl-devsec .dl-panel-head{margin:0}.dl-dgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.dl-dcard>.dl-dcard-head+*{margin-top:auto}@media(max-width:700px){.dl-dgrid{grid-template-columns:minmax(0,1fr)}}.dl-dgrid>.dl-dslot.add:only-child{grid-column:1 / -1}.dl-dcard{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--dl-shadow)}.dl-dcard.online{border-color:color-mix(in srgb,var(--dl-ok) 35%,transparent)}.dl-dcard.off{opacity:.7}.dl-dcard-head{display:flex;align-items:center;gap:12px}.dl-dcard-ic{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dcard-ic .dl-icon{width:20px;height:20px}.dl-dcard.online .dl-dcard-ic{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-dcard-title{all:unset;cursor:pointer;flex:1;min-width:0;display:flex;flex-direction:column}.dl-dcard-title b{font-weight:500;font-size:15px}.dl-dstat{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;min-width:0}.dl-dstat i.dot{flex:none}.dl-dstat.ok{color:var(--dl-ok)}.dl-dstat.warn{color:var(--dl-warn)}.dl-dstat i.dot,.dl-savebar i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint)}.dl-dstat i.dot.ok{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-dstat i.dot.warn{background:var(--dl-warn)}.dl-dcard-use{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.dl-dcard-foot{padding-top:10px;border-top:1px solid var(--dl-line);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-dslot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:14px;min-height:0;border:1px dashed color-mix(in srgb,currentColor 18%,transparent);border-radius:14px;text-align:center;color:var(--dl-fg-muted);transition:background .15s,border-color .15s,color .15s}.dl-dslot.add .dl-stack{align-items:center}.dl-dslot.add:hover{border-color:color-mix(in srgb,currentColor 35%,transparent);color:var(--dl-fg)}.dl-dslot.add:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-dslot.add b{font-weight:500}.dl-dslot.add:hover{background:var(--dl-soft)}.dl-dslot-ic{width:36px;height:36px;border-radius:999px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dslot.add:hover .dl-dslot-ic{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-tiles2{display:grid;gap:10px;margin-top:16px}.dl-tile2{border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:10px;min-width:0}.dl-tile2-label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile2-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.dl-tile2-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.dl-tile2-value .dl-faint{font-size:14px;font-weight:400}.dl-tile2-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-stepper{display:inline-flex;align-items:stretch;height:32px;border:1px solid var(--input, var(--dl-line));border-radius:8px;overflow:hidden}.dl-stepper button{all:unset;cursor:pointer;width:32px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;color:var(--dl-fg)}.dl-stepper button:hover{background:var(--dl-soft)}.dl-stepper button[disabled]{opacity:.35;cursor:not-allowed}.dl-stepper+.dl-stepper{margin-left:4px}.dl-step-select{border:0!important;border-left:1px solid var(--input, var(--dl-line))!important;border-right:1px solid var(--input, var(--dl-line))!important;border-radius:0!important;background:transparent!important;color:inherit;font:500 13px inherit;padding:0 10px!important;height:100%!important;min-width:0!important}.dl-slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.dl-slots i{height:4px;border-radius:999px;background:var(--dl-track);display:block}.dl-slots i.used{background:var(--dl-fg)}.dl-slots i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-date{display:flex;align-items:center;gap:8px;flex:1 1 150px;min-width:0;box-sizing:border-box;height:34px;padding:0 10px;border:1px solid var(--input, var(--dl-line));border-radius:8px;color:var(--dl-fg-faint)}.dl-date input{border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:32px!important;color:var(--dl-fg);flex:1;min-width:0!important;width:100%!important}.dl-meter{position:relative;height:6px;border-radius:999px;background:var(--dl-track)}.dl-meter>i{display:block;height:100%;border-radius:999px;background:var(--dl-accent)}.dl-meter.warn>i{background:var(--dl-warn)}.dl-meter.bad>i{background:var(--dl-bad)}.dl-meter .mark{position:absolute;left:90%;top:-3px;width:1px;height:12px;background:var(--dl-warn)}.dl-meter.sm{height:4px}.dl-chips-row{display:flex;flex-wrap:wrap;gap:4px}.dl-chipbtn{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-chipbtn:hover{background:var(--dl-soft-hover)}.dl-chipbtn.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-switch{all:unset;cursor:pointer;position:relative;width:32px;height:20px;border-radius:999px;background:var(--switch-off, var(--dl-track));flex:0 0 auto;transition:background .15s}.dl-switch i{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px #0000004d}.dl-switch.on{background:var(--dl-accent)}.dl-switch.on i{left:14px}.dl-switch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-linkbox{display:flex;align-items:center;gap:8px;height:36px;padding:0 4px 0 12px;border:1px solid var(--input, var(--dl-line));border-radius:8px;background:var(--input-bg, transparent)}.dl-linkbox .dl-mono{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dl-fg-muted)}.dl-linkbox .cbi-button{height:28px!important}.dl-pcard{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:20px;align-items:stretch;min-width:0}.dl-pcard-main{min-width:0}.dl-pcard-top{display:flex;align-items:center;gap:12px;min-width:0}.dl-pcard-top .dl-avatar{margin-right:0}.dl-pcard-who{flex:1;min-width:0}.dl-pcard-who .dl-slotbar{margin:3px 0 0}.dl-pside{display:flex;flex-direction:column;justify-content:space-between;gap:8px;padding-left:20px;border-left:1px solid var(--dl-line);min-width:0}.dl-pside-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.dl-pside-state{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--dl-fg-muted)}.dl-pside-state.live{color:var(--dl-ok)}.dl-pside-foot{font-size:12px}.dl-pside .dl-use-num b{font-size:20px}.dl-none{display:none!important}.dl-pcard-actions{display:flex;gap:6px;flex:0 0 auto}.dl-pcard-actions .cbi-button{height:32px!important}.dl-icon-only .dl-btn-label{display:none}.dl-pill-ic{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:999px;font-size:12px;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill-ic .dl-icon{width:12px;height:12px}.dl-pill-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-use-num{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.dl-use-num b{font-size:15px;font-weight:500}.dl-use-live{display:flex;align-items:center;gap:8px;font-size:12px;font-variant-numeric:tabular-nums}.dl-usebar{display:flex;gap:2px;height:6px;border-radius:999px;overflow:hidden;background:var(--dl-track)}.dl-usebar i{display:block;height:100%;min-width:3px;flex:0 1 0}.dl-usebar i.fill{flex:none;min-width:0;border-radius:999px;background:var(--dl-accent)}.dl-usebar.warn i.fill{background:var(--dl-warn)}.dl-usebar.bad i.fill{background:var(--dl-bad)}.dl-usebar .c0,.dl-swatch.c0{background:var(--dl-chart-1)}.dl-usebar .c1,.dl-swatch.c1{background:#8b7cf6}.dl-usebar .c2,.dl-swatch.c2{background:#2fb889}.dl-usebar .c3,.dl-swatch.c3{background:#d9a03f}.dl-usebar .c4,.dl-swatch.c4{background:var(--dl-fg-faint)}.dl-tip-row{display:flex;align-items:center;gap:8px;min-width:160px}.dl-tip-row b{margin-left:auto;font-weight:500}.dl-swatch{width:8px;height:8px;border-radius:2px;flex:none}.dl-card-name{color:var(--dl-fg)!important;text-decoration:none}.dl-card-name:hover{text-decoration:underline}.dl-chip-tag{font-size:11px;line-height:18px;padding:0 6px;border-radius:999px;background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-chip.live{background:var(--dl-ok-wash);color:color-mix(in srgb,var(--dl-ok) 35%,var(--dl-fg))}.dl-chip.live:hover{background:color-mix(in srgb,var(--dl-ok) 22%,transparent)}.dl-chip.live .dl-icon{color:var(--dl-ok)}.dl-fixes{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 0 44px}.dl-fix{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-info-wash);color:var(--dl-info);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-fix:hover{filter:brightness(1.15)}.dl-plist>.dl-card.dl-attn-row{border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)}@media(max-width:760px){.dl-pcard{grid-template-columns:1fr}.dl-pside{padding:12px 0 0;border-left:0;border-top:1px solid var(--dl-line)}.dl-fixes{margin-left:0}}.dl-select{height:34px!important;border-radius:999px!important;min-width:136px!important;width:auto!important;padding:0 34px 0 14px!important;appearance:none!important;-webkit-appearance:none!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 12px center!important;background-size:14px!important}.dl-savebar{position:fixed;left:50%;bottom:24px;transform:translate(-50%,160%);opacity:0;transition:transform .25s cubic-bezier(.2,.8,.2,1),opacity .2s;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 18px;border-radius:999px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, 0 16px 32px -8px rgba(0,0,0,.5));z-index:60;pointer-events:none}.dl-savebar.show{transform:translate(-50%);opacity:1;pointer-events:auto}.dl-savebar-text{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500}`;var za=".dl-toast strong{display:block;font-weight:500}.dl-toast div{opacity:.8;font-size:13px}.dl-drawer-overlay{position:fixed;inset:0;z-index:900;display:flex;justify-content:flex-end;background:transparent;transition:background .2s}.dl-drawer-overlay.open{background:var(--scrim, rgba(0,0,0,.45))}.dl-drawer{width:min(520px,100%);height:100%;display:flex;flex-direction:column;background:var(--dialog-bg, var(--dl-elevated));color:var(--dl-fg);border-left:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5));transform:translate(100%);transition:transform .22s cubic-bezier(.2,.8,.2,1)}.dl-drawer-overlay.open .dl-drawer{transform:none}.dl-drawer-head{display:flex;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--dl-line)}.dl-drawer-title{flex:1;min-width:0;display:flex;align-items:center;gap:12px}.dl-drawer-title h3{margin:0!important;padding:0!important;border:0!important;font-size:18px!important;line-height:26px;font-weight:500!important}.dl-drawer-x{all:unset;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted)}.dl-drawer-x:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-drawer-body{flex:1;overflow:auto;padding:20px}.dl-drawer-foot{padding:12px 20px;border-top:1px solid var(--dl-line)}.dl-drawer-actions{display:flex;align-items:center;gap:8px}.dl-dcard-ic.on{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-icon-only.sm{width:28px;height:28px!important}.dl-stack.gap12{gap:12px}.dl-stack.gap16{gap:16px}.dl-dstats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--dl-line);border-radius:14px;overflow:hidden}.dl-dstats-cell{display:flex;flex-direction:column;gap:4px;padding:12px 14px;min-width:0}.dl-dstats-cell.wide{grid-column:span 2;border-bottom:1px solid var(--dl-line)}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:1px solid var(--dl-line)}.dl-dstats-cell b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dstats-cell .dl-dstat{font-size:14px}.dl-dsec{border:1px solid var(--dl-line);border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:12px}.dl-dsec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-dsec-head h4{margin:0!important;padding:0!important;font-size:14px!important;font-weight:500!important;border:0!important}.dl-dstat i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);display:inline-block}.dl-connect-body{min-height:60px}.dl-connect-body .dl-qr{width:min(240px,70vw)}.dl-kv2{display:flex;flex-direction:column}.dl-kvrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;border-top:1px solid var(--dl-line);font-size:13px;min-width:0}.dl-kvrow:first-child{border-top:0;padding-top:0}.dl-kvrow-k{color:var(--dl-fg-muted);flex:0 0 auto}.dl-kvrow-v{min-width:0;text-align:right;overflow-wrap:anywhere}.dl-kvrow-v.copy{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dl-fg)}.dl-kvrow-v.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-kvrow-v.copy .dl-icon{width:13px;height:13px;color:var(--dl-fg-faint)}.dl-kvrow-v.copy:hover .dl-icon{color:var(--dl-fg)}@media(max-width:560px){.dl-drawer{width:100%}.dl-dstats{grid-template-columns:minmax(0,1fr)}.dl-dstats-cell.wide{grid-column:auto}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:0;border-top:1px solid var(--dl-line)}}.dl-dev-log{display:flex;flex-direction:column}.dl-dev-log-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--dl-line);font-size:13px;line-height:20px;min-width:0}.dl-dev-log-row:first-child{border-top:0;padding-top:0}.dl-dev-log-row .dl-row-main{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";var Na=".dl-settings-main{min-width:0;display:flex;flex-direction:column;gap:20px}.dl-setsec{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);overflow:hidden;scroll-margin-top:88px;box-shadow:var(--dl-shadow)}.dl-setsec-body{padding:20px;display:flex;flex-direction:column;gap:14px}.dl-setsec-body h3{margin:0!important;padding:0!important;font-size:18px!important;line-height:26px;font-weight:500!important;border:0!important}.dl-setsec-body p{margin:0}.dl-setsec-head{display:flex;align-items:center;gap:10px}.dl-group{border:1px solid var(--dl-line);border-radius:14px;padding:2px 16px}.dl-group-head{display:flex;align-items:center;gap:12px;padding:14px 0 10px}.dl-group-head b{font-size:15px;font-weight:500}.dl-group-ic{width:32px;height:32px;border-radius:10px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-group-ic .dl-icon-wrap{display:inline-flex}.dl-group-ic .dl-icon{width:16px;height:16px}.dl-group-body>*{padding:12px 0;margin:0!important}.dl-group-body>*+*:not(.alert-message):not(.dl-params){border-top:1px solid var(--dl-line)}.dl-group-body>.alert-message,.dl-group-body>.dl-params{margin:12px 0!important}.dl-group-body>.alert-message{padding:10px 14px}.dl-group-body>.dl-params{padding:0}.dl-group-body>.alert-message+*,.dl-group-body>.dl-params+*{border-top:0}.dl-group-body>.dl-row{border-left:0;border-right:0;border-bottom:0;padding-left:0;padding-right:0;background:none}.dl-group-body>.dl-row:first-child{border-top:0}.dl-setsec-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;padding:12px 20px;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-setsec.danger{border-color:color-mix(in srgb,var(--dl-bad) 40%,transparent)}.dl-setsec.danger .dl-setsec-foot{background:color-mix(in srgb,var(--dl-bad) 6%,transparent)}.dl-setrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,420px);align-items:center;gap:8px 24px}.dl-setrow.head{display:flex;justify-content:space-between;gap:16px}.dl-setrow-label{font-size:14px;font-weight:500}.dl-setrow-ctl{display:flex;justify-content:flex-end;min-width:0}.dl-setrow-ctl .dl-chips-row{justify-content:flex-end}.dl-setrow-ctl>input{width:100%}.dl-hostport{display:flex;align-items:center;gap:8px;flex:1;min-width:0;justify-content:flex-end}.dl-hostport input{flex:1;min-width:0}.dl-root input.dl-w-port,.dl-hostport input.dl-w-port{flex:0 0 90px;width:90px}.dl-more summary{cursor:pointer;color:var(--dl-fg-muted);font-size:13px;margin-bottom:10px}.dl-more .dl-setrow+.dl-setrow{margin-top:10px}@media(max-width:760px){.dl-setrow:not(.head){grid-template-columns:minmax(0,1fr)}.dl-setrow-ctl,.dl-setrow-ctl .dl-chips-row{justify-content:flex-start}}.dl-need-ic{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-need-ic .dl-icon-wrap{display:inline-flex}.dl-need-ic .dl-icon{width:15px;height:15px}.dl-need-row.bad .dl-need-ic,.dl-need-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-need-row.warn .dl-need-ic,.dl-need-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-need-ic.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-lh-main{display:flex;align-items:flex-start;gap:12px;min-width:0}.dl-lh-main>.dl-need-ic{margin-top:1px}.dl-sub .dl-mono{font-size:.92em}.dl-need-row>.cbi-button{flex:none}.dl-bk-row .dl-group-ic{width:30px;height:30px}.dl-bk-older>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:11px 16px;border-top:1px solid var(--dl-line);font-size:13px;color:var(--dl-fg-muted);user-select:none}.dl-bk-older>summary::-webkit-details-marker{display:none}.dl-bk-older>summary:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-bk-older>summary .dl-icon-wrap{display:inline-flex;transition:transform .15s}.dl-bk-older>summary .dl-icon{width:14px;height:14px}.dl-bk-older[open]>summary .dl-icon-wrap{transform:rotate(90deg)}#dl-set-backups .dl-setsec-head h3+.dl-sub{margin-top:2px}#dl-set-backups .dl-setsec-foot>.dl-sub{flex:1 1 260px}.dl-bk-actions{flex:0 1 auto;justify-content:flex-end}@media(max-width:640px){#dl-set-backups .dl-setsec-foot>.dl-sub{flex-basis:100%}.dl-bk-actions{justify-content:flex-start}}.dl-upd{display:flex;flex-direction:column;gap:16px}.dl-upd>.dl-pagehead{margin:0 0 4px}.dl-upd-bad{color:var(--dl-bad)}";var Ra=".dl-comp-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}.dl-comp-hero-main{padding:20px;display:flex;flex-direction:column;gap:12px;min-width:0}.dl-comp-hero-side{padding:20px;border-left:1px solid var(--dl-line);display:flex;flex-direction:column;gap:14px;min-width:0}.dl-comp-name{font-size:16px;font-weight:500}.dl-comp-hero-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.dl-comp-hero-head .dl-spacer{flex:1}.dl-comp-big{font-family:var(--dl-mono);font-size:26px;line-height:34px;letter-spacing:-.02em;display:flex;align-items:baseline;gap:10px}.dl-comp-big small{font-size:14px;color:var(--dl-accent)}.dl-comp-big small.dl-faint{color:var(--dl-fg-faint)}.dl-comp-verrow{display:flex;align-items:center;gap:4px 12px;flex-wrap:wrap;min-width:0}.dl-comp-verrow .dl-spacer{flex:1}.dl-comp-meta{font-size:13px}.dl-comp-bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;color:var(--dl-fg-muted);font-size:13px}.dl-comp-bullets li{list-style:disc}.dl-comp-lead{margin:0}.dl-comp-more{align-self:flex-start;font-size:12px;color:var(--dl-fg-faint);margin-left:18px;padding:0!important}.dl-comp-more:hover{color:var(--dl-accent);background:none!important;text-decoration:underline;text-underline-offset:2px}.dl-comp-hero-main>.dl-comp-vers{margin-top:auto}.dl-comp-btns{display:flex;gap:8px;flex-wrap:nowrap;align-items:center;flex:none}.dl-comp-side-v{display:flex;align-items:center;gap:8px;font-size:14px;min-width:0;flex-wrap:wrap}.dl-comp-side-v .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-comp-side-v a{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-side-v a:hover{color:var(--dl-accent)}.dl-comp-cols{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:16px;align-items:start}.dl-comp-cols>.dl-panel>div>.dl-row:first-child{border-top:1px solid var(--dl-line)}.dl-comp-count{font-size:13px}.dl-comp-sub{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-ic{display:inline-flex;gap:4px;flex:none}.dl-comp-ic .cbi-button{width:30px;height:30px;padding:0!important;justify-content:center;border-radius:999px!important}.dl-comp-ic .dl-btn-label{display:none}.dl-comp-ic .dl-icon{width:14px;height:14px}.dl-comp-ic .is-busy{pointer-events:none;opacity:.5}.dl-comp-ic .cbi-button.dl-comp-check{width:auto;padding:0 12px 0 10px!important;gap:6px;display:inline-flex;align-items:center;font-size:13px}.dl-row>.dl-pill,.dl-row>.cbi-button,.dl-row>.dl-comp-ic{flex:none}button.dl-pill.dl-comp-run{all:unset;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;font-size:12px;cursor:pointer;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-comp-foldwrap{padding:0 16px 14px 60px}.dl-comp-fold .dl-params-body{gap:12px}.dl-comp-fold .dl-list>.dl-row{padding:10px 14px}.dl-comp-bver{font-size:12px;width:130px;text-align:right;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-bact{width:84px;flex:none;display:flex;justify-content:flex-end}.dl-comp-warn{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:18px;color:var(--dl-fg-muted)}.dl-comp-warn .dl-icon-wrap{display:inline-flex;flex:none;margin-top:2px}.dl-comp-warn .dl-icon{width:14px;height:14px;color:var(--dl-warn)}.dl-comp-empty{margin:0;padding:4px 16px 16px}@media(max-width:760px){.dl-comp-hero,.dl-comp-cols{grid-template-columns:minmax(0,1fr)}.dl-comp-hero-side{border-left:0;border-top:1px solid var(--dl-line)}.dl-comp-foldwrap{padding-left:16px}.dl-comp-bver{display:none}}.dl-comp-status{display:flex;align-items:center;gap:8px;font-size:13px;padding:9px 12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-comp-status>.dl-icon-wrap{display:inline-flex;flex:none}.dl-comp-status .dl-icon{width:15px;height:15px}.dl-comp-status.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-comp-status.acc{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-comp-status.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-comp-status.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-comp-status b{font-weight:600}.dl-comp-vers .dl-params-body{gap:0;padding:4px 14px 12px}.dl-comp-tag{display:flex;gap:6px;padding:6px 0 10px}.dl-comp-tag input{flex:1;min-width:0}.dl-comp-ver{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--dl-line);font-size:13px}.dl-comp-ver .dl-mono{min-width:52px}.dl-comp-ver .dl-sub{flex:1}.dl-comp-ver .cbi-button:not(.dl-icon-btn){height:26px!important;font-size:12px!important}.dl-comp-pager{display:flex;align-items:center;justify-content:space-between;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-comp-pager .dl-linkbtn[disabled]{opacity:.4;cursor:default}.dl-comp-vers .dl-loading,.dl-comp-vers .dl-params-body>p{padding:6px 0 10px}.dl-op-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}.dl-op-head .dl-spacer{flex:1}.dl-op-timer{display:inline-flex;align-items:center;gap:5px;font-variant-numeric:tabular-nums}.dl-op-timer .dl-icon,.dl-op-head .dl-linkbtn .dl-icon{width:14px;height:14px}.dl-op-loghead{display:flex;align-items:center;justify-content:space-between}.dl-op-loghead b{font-weight:500;font-size:13px}.dl-op .dl-log{max-height:16em;min-height:12em;margin-top:8px}.dl-op .dl-comp-status{margin:14px 0 0}.dl-op-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;width:100%}.dl-notes{max-height:55vh;overflow:auto;border-radius:12px;background:var(--dl-soft);padding:14px 16px;font-size:13px;line-height:20px;overflow-wrap:anywhere}.dl-notes h5{margin:10px 0 6px;font-size:14px;font-weight:500}.dl-notes h5:first-child{margin-top:0}.dl-notes p{margin:0 0 8px}.dl-notes ul{margin:0 0 10px;padding-left:18px}.dl-notes li{list-style:disc}.dl-notes code{font-family:var(--dl-mono);font-size:12px;padding:1px 5px;border-radius:6px;background:var(--dl-soft-hover)}.dl-notes pre{font-family:var(--dl-mono);font-size:12px;padding:10px;border-radius:8px;background:var(--dl-soft-hover);white-space:pre-wrap;margin:0 0 10px}.dl-notes a{color:var(--dl-accent)}";var Ha=".dl-chip.static{cursor:default}.dl-chip.static:hover{background:var(--dl-soft)}.dl-chip.static .dl-chip-name{font-weight:500}.dl-setrow.head .dl-chips-row{margin-top:8px}.dl-setrow.head>.dl-lh-main,.dl-setrow.head>.dl-lh-main>.dl-stack{flex:1 1 auto;min-width:0}.dl-setrow.head>.dl-setrow-ctl:empty{display:none}.dl-setrow.head:has(>.dl-lh-main){align-items:flex-start}.dl-setrow.head>.dl-setrow-ctl{align-items:center;min-height:30px}.dl-netpick{margin-top:10px}.dl-boxrow{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0;padding:10px 14px;border:1px solid var(--dl-line);border-radius:12px;font-size:13px;cursor:pointer}.dl-boxrow>.dl-switch{flex:none}.dl-ifpick{display:flex;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--dl-line);border-radius:14px}.dl-iflead-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-host-ports{justify-content:flex-end}@media(max-width:760px){.dl-host-ports{justify-content:flex-start}}.dl-circle-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}.dl-circles .dl-chip b{font-weight:500}.dl-circle-name{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:500}.dl-w400{font-weight:400}.dl-swatches{display:flex;flex-wrap:wrap;gap:8px}.dl-swatch{all:unset;cursor:pointer;width:22px;height:22px;border-radius:50%;background:var(--sw);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dl-fg) 12%,transparent)}.dl-swatch.on{box-shadow:0 0 0 2px var(--dl-card),0 0 0 4px var(--sw)}.dl-swatch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:3px}.dl-circle-modal .dl-chipbtn b{margin-left:6px;font-weight:500;font-size:11px;opacity:.6}.dl-reach td:first-child b{font-weight:500}.dl-ev-host{white-space:nowrap}.dl-ev-host b{font-weight:500;color:var(--dl-fg)}.dl-reach{font-size:13px}.dl-reach th,.dl-reach td{white-space:nowrap;padding-left:6px;padding-right:6px}.dl-reach-wrap{overflow-x:auto}.dl-yes{display:inline-flex;align-items:center;gap:4px;color:var(--dl-ok)}.dl-yes .dl-icon-wrap{display:inline-flex}.dl-yes .dl-icon{width:14px;height:14px}.dl-check-form{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;align-items:start;gap:8px}.dl-check-form>.dl-faint{line-height:36px}.dl-check-end{display:flex;flex-direction:column;gap:6px;min-width:0}.dl-check-end>*{width:100%!important;min-width:0}@media(max-width:560px){.dl-check-form{grid-template-columns:minmax(0,1fr)}.dl-check-form>.dl-faint{display:none}}.dl-verdict{display:flex;align-items:baseline;gap:10px;padding:10px 12px;border-radius:12px}.dl-verdict b{font-weight:500}.dl-verdict.ok{background:var(--dl-ok-wash)}.dl-verdict.ok b{color:var(--dl-ok)}.dl-verdict.bad{background:var(--dl-bad-wash)}.dl-verdict.bad b{color:var(--dl-bad)}.dl-corehead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 4px}.dl-corehead h3{margin:0!important}.dl-row-end{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dl-dcard.clickable{cursor:pointer}.dl-dcard.clickable:hover{border-color:color-mix(in srgb,var(--dl-fg) 22%,transparent)}";var Ri=[$a,_a,Ea,Sa,Ca,La,Ta,Ma,Pa,Da,Aa,za,Na,Ra,Ha].join(` -`);function Ia(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=Ri,n}function rt(n){return()=>{let t=new n;return Object.assign({load:()=>t.load(),render:async a=>{let r=await t.render(a),i=document.createElement("div");return i.className="dl-root",i.append(Ia(),r),i},addFooter(){return t.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var Uf=rt(At),Wf=rt(at),Gf=rt(At),qf=rt(ln),Ff=rt(pn),Kf=rt(fn),Jf=rt(cn);function Ba(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var Vf=Ba(""),Yf=Ba("log");return baseclass.extend({ activity: Yf, diagnostics: Kf, health: Vf, overview: Uf, people: Wf, person: Ff, server: Gf, settings: qf, updates: Jf }); +`).trim()}async function Bt(n,e,o,a){let r=t("div",{class:"dl-notes"},t("p",{class:"dl-muted dl-loading"},"Loading release notes…")),i=t("div",{class:"dl-op-head"}),s="";re(o,[i,r],[D([g("copy")," Copy"],()=>ue(s,"Release notes copied"))," ",le("Close")],"wide");try{let d=await P.updatesNotes(n,e,a??"");s=ba(d.body||"");let l=ga(d.url);dom.content(i,[d.published?t("span",{class:"dl-pill"},He(d.published)):"",d.prerelease?t("span",{class:"dl-pill warn"},"Pre-release"):"",t("span",{class:"dl-spacer"}),l?t("a",{href:l,target:"_blank",rel:"noopener",class:"dl-linkbtn"},["On GitHub ",g("open")]):""]),dom.content(r,s.trim()?va(s):t("p",{class:"dl-muted"},"This release has no notes."))}catch(d){dom.content(r,t("p",{class:"dl-muted"},ve(d)))}}var xa={"6h":"every 6 h","12h":"every 12 h","1d":"daily","7d":"weekly"},Kn=n=>n?He(n):"";function _i(n){let e=/^(.{20,}?)(?:;\s|:\s)/.exec(n)?.[1];return e||(n.length<=90?n:`${n.slice(0,90).replace(/[\s,;:]+\S*$/,"")}…`)}function ya(n,e){let o=n.st,a=o.policy,r=o.kept?.app,i=e?.update&&e.tag?e.tag:o.version,s=k=>()=>Bt("app",k,`What’s new in Dawnline ${k.replace(/^v/,"")}`),d=e?.tag&&(e.update||e.status==="latest")?Si(n,e.tag,e.update?o.version:""):null,l=e?.tag??i,c=a.check&&o.auto?.check?o.auto.check+({"6h":6,"12h":12,"1d":24,"7d":168}[a.interval]??24)*3600:0,p=(k,f)=>t("div",{class:"dl-stack gap4"},[t("span",{class:"dl-metric-label"},k),t("span",{class:"dl-comp-side-v"},f)]),u=[{label:"What’s new",ic:"file",run:s(i)},{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${o.repo}`,"_blank","noopener")},null,{label:`Reinstall ${o.version}`,ic:"reset",warn:!0,run:()=>n.op("app:reinstall","Reinstalling Dawnline",o.version)},r?{label:`Roll back to ${r.version}`,ic:"archive",warn:!0,run:async()=>{await ae(`Roll back to Dawnline ${r.version}?`,`The copy kept on the router replaces ${o.version}. A backup of the settings is made first.`,"Roll back")&&n.op("app:rollback","Rolling back Dawnline",o.version)}}:null];return t("section",{class:"dl-panel flush dl-comp-hero"},[t("div",{class:"dl-comp-hero-main"},[t("div",{class:"dl-comp-hero-head"},[t("span",{class:"dl-group-ic"},g("sunrise")),t("b",{class:"dl-comp-name"},"Dawnline"),n.state("app",e,e?.latest??""),t("span",{class:"dl-spacer"}),n.round(()=>n.op("check:app","Checking Dawnline",o.version),u,!0)]),t("div",{class:"dl-comp-verrow"},[t("div",{class:"dl-stack"},[t("div",{class:"dl-comp-big"},[o.version,e?.update?t("small",{},`→ ${e.latest}`):e?.status==="dev"&&e.latest?t("small",{class:"dl-faint"},`release ${e.latest}`):""]),t("span",{class:"dl-faint dl-comp-meta"},e?.error?"":e?.update?e.published?`released ${Kn(e.published)}`:"":e?.status==="dev"?"ahead of the latest release":e?`latest release${e.published?` · released ${Kn(e.published)}`:""}`:"not checked yet")])]),d?.items.length?t("div",{class:"dl-stack gap4"},[t("ul",{class:"dl-comp-bullets"},d.items.map(k=>t("li",{},k))),d.total>d.items.length?t("button",{type:"button",class:"dl-linkbtn dl-comp-more",click:s(l)},`+${d.total-d.items.length} more in What’s new`):""]):"",e?.error?t("p",{class:"dl-sub dl-comp-lead dl-upd-bad"},e.error):"",e?.update?t("div",{class:"dl-comp-btns"},[D("Update now",()=>n.op("app","Updating Dawnline",o.version),"positive",{disabled:n.busy}),D("What’s new",s(i))]):"",Mi(n)]),t("div",{class:"dl-comp-hero-side"},[p("Source",[g("globe"),t("a",{href:`https://github.com/${o.repo}`,target:"_blank",rel:"noopener"},o.repo)]),p("Auto-update",[a.auto?ye("ok","On"):ye("","Off"),t("span",{class:"dl-muted"},a.auto?a.mode==="immediate"?"as soon as found":`${xa[a.interval]==="weekly"?"weekly":"daily"} at ${a.time}`:a.check?`checks ${xa[a.interval]}`:"checks off")]),p("Last check",o.check?[ie(o.check.time,o.now),c>o.now?t("span",{class:"dl-faint"},`· next in ${ct(c-o.now)}`):""]:["Never"]),p("Rollback",r?[t("span",{class:"dl-mono"},r.version),t("span",{class:"dl-faint"},"kept on flash")]:[t("span",{class:"dl-muted"},a.keep?"Kept after the next update":"Off")])])])}function Si(n,e,o){if(n.notes.has(e))return n.notes.get(e)??null;n.notes.set(e,null);let a=r=>r.replace(/\*\*|`|\[([^\]]+)\]\([^)]*\)/g,(i,s)=>s??"").trim();return(async()=>{let i=((await P.updatesNotes("app",e,"").catch(()=>null))?.body??"").split(` +`).map(d=>/^\s*[-*+]\s+(.*)$/.exec(d)?.[1]).filter(d=>!!d);i.length||(i=(await P.updatesChanges(o,e).catch(()=>null))?.items??[]);let s={items:i.slice(0,3).map(d=>_i(a(d))),total:i.length};n.notes.set(e,s),s.items.length&&n.root.isConnected&&n.paint()})(),null}function Mi(n){let e=t("div",{class:"dl-params-body"}),o=t("details",{class:"dl-params dl-comp-vers",open:n.versOpen?"open":null},[t("summary",{},[g("chevron"),t("span",{},"Versions"),t("span",{class:"dl-sub"},"install any release")]),e]);return o.addEventListener("toggle",()=>{n.versOpen=o.open,n.versOpen&&fn(n,e)}),n.versOpen&&fn(n,e),o}async function fn(n,e){let o=se("",{placeholder:"Tag, e.g. 0.3.1",class:"cbi-input-text dl-mono","aria-label":"Release tag"}),a=p=>{if(p=p.trim(),!/^v?[0-9][0-9A-Za-z.+~-]{0,40}$/.test(p))return Q("Enter a release tag like 0.3.1","warning");wa(n,p)};o.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),a(o.value))});let r=t("div",{class:"dl-comp-tag"},[o,D("Install",()=>a(o.value),"neutral",{disabled:n.busy})]),i=n.versPage,s=p=>{n.versPage=Math.max(1,n.versPage+p),fn(n,e)},d=p=>t("div",{class:"dl-comp-pager"},[t("button",{type:"button",class:"dl-linkbtn",disabled:i<=1?"disabled":null,click:()=>s(-1)},"← Newer"),t("span",{class:"dl-faint"},`Page ${i}`),t("button",{type:"button",class:"dl-linkbtn",disabled:p?null:"disabled",click:()=>s(1)},"Older →")]),l=n.versCache.get(i);if(!l){dom.content(e,[r,t("p",{class:"dl-muted dl-loading"},"Loading versions…")]);try{l=(await P.updatesReleases(i)).releases}catch(p){if(i!==n.versPage||!e.isConnected)return;dom.content(e,[r,t("div",{class:"dl-row-actions"},[t("span",{class:"dl-muted"},`Failed to load versions: ${ve(p)}`),D("Try again",()=>fn(n,e))]),d(!1)]);return}if(n.versCache.set(i,l),i!==n.versPage||!e.isConnected)return}if(!l.length)return dom.content(e,[r,t("p",{class:"dl-muted"},i>1?"No more versions.":"No versions found."),d(!1)]);let c=n.st.version;dom.content(e,[r,...l.map(p=>{let u=p.tag.replace(/^v/,"");return t("div",{class:"dl-comp-ver"},[t("span",{class:"dl-mono"},u),t("span",{class:"dl-sub"},Kn(p.published)),p.prerelease?ye("warn","Pre-release"):"",t("span",{class:"dl-comp-ic"},$e("file","What’s new",()=>Bt("app",p.tag,`What’s new in Dawnline ${u}`))),u===c?ye("ok","Installed"):D("Install",()=>wa(n,p.tag),"neutral",{disabled:n.busy})])}),d(l.length>=5)])}async function wa(n,e){let o=e.replace(/^v/,"");o.localeCompare(n.st.version,void 0,{numeric:!0})<0&&!await ae(`Install Dawnline ${o}?`,`It is older than ${n.st.version}. A backup of the settings is made first; restore it from Settings if something looks wrong.`,"Install")||n.op(`app@${e}`,`Installing Dawnline ${o}`,n.st.version)}function ka(n,e){let o=n.st,a=o.kept?.amneziawg,r=e?.sources??{},i=Object.keys(r),s=e?.current??null,d=s?r[s]:void 0,l=!!e?.ru,c=o.needs?.awg??[],p=c.length?null:e?.installed??null,u=[];s&&p&&u.push({label:"Reinstall this build",warn:!0,ic:"reset",run:()=>n.op(`amneziawg:${s}${l?":ru":""}`,"Reinstalling AmneziaWG",p)}),a&&u.push({label:`Roll back to ${a.version}`,ic:"archive",warn:!0,run:async()=>{await ae(`Roll back AmneziaWG to ${a.version}?`,"The build kept on the router is installed again. Every AmneziaWG tunnel restarts for a few seconds.","Roll back")&&n.op("amneziawg:rollback","Rolling back AmneziaWG",p??void 0)}});let k=[e?.release?{label:"What’s new",ic:"file",run:()=>Bt("amneziawg",e.release,`What’s new in the ${d?.label??"AmneziaWG"} build`,s??"slava")}:null,{label:"Open on GitHub",ic:"globe",run:()=>window.open(`https://github.com/${d?.repo??"Slava-Shchipunov/awg-openwrt"}`,"_blank","noopener")},...u.length?[null,...u]:[]].filter((m,h,N)=>m!==null||h>0&&N[h-1]!==null),f=o.tunnels??[],b=f.length?`Switching restarts ${f.length===1?"the tunnel":`${f.length} tunnels`} for a few seconds: ${f.join(", ")}. Devices keep their configurations.`:"Switching takes a few seconds. Devices keep their configurations.",M=f.length>1?`${f.slice(0,-1).join(", ")} and ${f[f.length-1]}`:f[0],j=f.length?`Switching restarts ${M} for a few seconds.`:"Switching takes a few seconds.",I=async m=>{let h=r[m];await ae(p?`Switch to AmneziaWG ${h.gen}?`:`Install AmneziaWG ${h.gen}?`,`The ${h.label} build, ${h.version}. ${b}${h.gen==="3.1"?" Devices need AmneziaVPN 3.1 or newer.":""}`,p?"Switch":"Install")&&n.op(`amneziawg:${m}${l?":ru":""}`,p?`Switching to AmneziaWG ${h.gen}`:"Installing AmneziaWG",p??void 0)},E=m=>{let h=r[m],N=s===m&&!!p;return t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},h.gen?`AmneziaWG ${h.gen}`:"AmneziaWG"),t("span",{class:"dl-sub"},`${h.label} · ${h.gen==="3.1"?"AmneziaVPN 3.1+":"every app"}`)]),t("span",{class:"dl-mono dl-faint dl-comp-bver"},h.version??"none yet"),t("span",{class:"dl-comp-bact"},N?ye("ok","Active"):h.version?D(p?"Switch":"Install",()=>I(m),p?"neutral":"positive",{disabled:n.busy}):ye("","No build"))])},T=i.map(m=>r[m]?.newer?`${r[m].label} moves to ${r[m].newer.gen} with OpenWrt ${r[m].newer.tag.replace(/^v/,"")}.`:"").filter(Boolean),w=ge(l,"Russian translation",m=>{s&&n.op(`amneziawg:${s}${m?":ru":""}`,m?"Adding the Russian translation":"Removing the Russian translation",p??void 0)});w.disabled=!s||!p||n.busy;let v=n.awgOpen??!p,x=t("details",{class:"dl-params dl-comp-fold",open:v?"open":null},[t("summary",{},[g("chevron"),t("span",{},"Build and translation")]),t("div",{class:"dl-params-body"},[t("div",{class:"dl-list"},[...i.length?i.map(E):[t("div",{class:"dl-row"},t("span",{class:"dl-sub"},"Check for updates to see the builds for this router."))],t("div",{class:"dl-row"},[t("span",{class:"dl-row-main dl-stack"},[t("b",{},"Russian translation"),t("span",{class:"dl-sub"},"LuCI pages for AmneziaWG")]),t("span",{class:"dl-comp-bact"},w)])]),p&&i.length||T.length?t("div",{class:`dl-comp-status ${p&&i.length?"warn":"acc"}`},[g(p&&i.length?"alert":"download"),t("span",{},[p&&i.length?t("b",{},j):"",...T.map(m=>` ${m}`)])]):""])]);x.addEventListener("toggle",()=>n.awgOpen=x.open);let $=[];return e?.update&&p&&s?$.push(D(`Update to ${e.latest}`,()=>n.op(`amneziawg:${s}${l?":ru":""}`,"Updating AmneziaWG",p),"neutral",{disabled:n.busy})):$.push((e||c.length)&&!p?ye("warn","Not installed"):n.state("amneziawg",e,e?.latest??"")),$.push(n.round(()=>n.op("check:amneziawg","Checking AmneziaWG",p??void 0),k)),[n.row("shield","AmneziaWG",[p?`${p}${e?.release?` · ${e.release} build`:""}`:c.length?`missing ${c.join(", ")}`:e?"not installed":"version not checked"],$),t("div",{class:"dl-comp-foldwrap"},x)]}var Ci=[{title:"Home-like link",sub:"Policy routing and the veth pair",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"HTTPS for the portal",sub:"OpenSSL for uhttpd",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"Certificates (ACME)",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],Jn={home:"network",https:"lock",acme:"file"};function $a(n,e){let o=n.st,a=e?.pkgs??{},r=Ci.filter(c=>c.feature==="home"?o.home:o.portal),i=async(c,p,u=c)=>{await ae(`Update ${p}?`,`${u.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&n.op(`pkgs:${c.join(",")}`,`Updating ${p}`)},s=[{label:"Check system packages",ic:"refresh",run:()=>n.op("check:packages","Checking system packages")},{label:"Open the OpenWrt package list",ic:"globe",run:()=>window.open("https://openwrt.org/packages/start","_blank","noopener")}],d=0;return{rows:r.map(c=>{let p=c.pkgs.filter(M=>a[M]?.installed),u=[...new Set(p.flatMap(M=>[...a[M]?.latest?[M]:[],...a[M]?.with??[]]))],k=o.needs?.[c.feature]??c.pkgs.filter(M=>!a[M]?.installed),f=p.find(M=>a[M]?.latest),b=p.map(M=>`${M} ${a[M]?.installed??""}`).join(", ");return k.length?n.row(Jn[c.feature],c.title,[`${c.optional?"not installed":`missing ${k.join(", ")}`}`],[D("Install",()=>n.op(`pkgs:${k.join(",")}`,`Installing ${c.title}`),c.optional?"neutral":"positive",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))]):e&&u.length?(d++,n.row(Jn[c.feature],c.title,f?[`${a[f].installed} → ${a[f].latest}`,u.length>1?` · +${u.length-1}`:""]:[u.join(", ")],[D("Update",()=>i(p.filter(M=>a[M]?.latest||a[M]?.with?.length),c.title,u),"neutral",{disabled:n.busy}),t("span",{class:"dl-comp-ic"},n.more(s))])):n.row(Jn[c.feature],c.title,[b||c.sub],[n.state("pkgs",e,""),t("span",{class:"dl-comp-ic"},n.more(s))])}),updates:d,total:r.length}}var Ti={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"System packages",all:"Components"};function Ea(n){let e=n.st,o=r=>{let i=Ye(r.component??"app"),s=Ti[i]??"Components",d=r.auto?"automatically":"by you",l="ok",c="check",p;if(r.kind==="found")l="accent",c="download",p=[t("b",{},(r.items??[]).join(", ")),` found by ${r.auto?"the automatic check":"a check"}`];else if(r.state==="failed")l="bad",c="x",p=[t("b",{},s),` ${r.kind==="install"?"update":"check"} failed${r.error?` · ${r.error}`:""}`];else{let u=r.from&&r.to&&r.from!==r.to?` ${r.from} → ${r.to}`:r.to?` ${r.to}`:"";p=[t("b",{},s),`${u} ${u?"":"updated "}${d}${r.took?` · ${ct(r.took)}`:""}`.replace(/\s+/g," ")]}return t("div",{class:"dl-row"},[t("span",{class:`dl-ev-tile ev ${l}`},g(c)),t("span",{class:"dl-row-main"},p),t("span",{class:"dl-faint dl-nowrap",title:new Date(r.ts*1e3).toLocaleString()},ie(r.ts,e.now))])},a=e.history??[];return t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-spacer"}),t("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All in Log →")]),a.length?t("div",{},a.slice(0,8).map(o)):t("p",{class:"dl-sub dl-comp-empty"},"Updates, and checks that found something, show up here.")])}var gn=class{constructor(){this.root=t("div",{class:"dl-upd"});this.following=null;this.versOpen=!1;this.versPage=1;this.versCache=new Map;this.notes=new Map;this.awgOpen=null}load(){return P.updatesStatus()}render(e){return this.st=e,this.paint(),e.job?.state==="running"&&this.follow(e.job),poll.add(async()=>{if(!this.root.isConnected)return;let o=await P.updatesStatus().catch(()=>null);if(!o)return;let a=this.st;this.st=o,o.job?.state==="running"&&this.following!=="starting"&&o.job.id!==this.following&&this.follow(o.job),(o.job?.id!==a.job?.id||o.job?.state!==a.job?.state||o.job?.phase!==a.job?.phase||o.check?.time!==a.check?.time)&&this.paint()},5),this.root}get busy(){return this.st.job?.state==="running"}async refresh(e){this.st=e??await P.updatesStatus().catch(()=>null)??this.st,this.paint()}async op(e,o,a){if(this.busy||this.following==="starting"){Q("Another component action is already running","warning");return}this.following="starting",this.paint();let r=Ye(e),i=await Ht(e,{title:o,version:a,onJob:s=>this.following=s.id,onDone:s=>this.refresh(s),onUpdate:s=>{let d=s.check?.components??{};r==="amneziawg"&&d.amneziawg?.current?this.op(`amneziawg:${d.amneziawg.current}${d.amneziawg.ru?":ru":""}`,"Updating AmneziaWG",d.amneziawg.installed??void 0):this.op("app","Updating Dawnline",this.st.version)}});this.following==="starting"&&(this.following=i?.id??null),this.refresh()}async follow(e){this.following=e.id;let o=sn(e),a={app:"Dawnline",amneziawg:"AmneziaWG",pkgs:"system packages",all:"components"}[o]??"components";await Ht(null,{title:`${e.action==="check"?"Checking":e.auto?"Automatic update:":"Updating"} ${a}`,onDone:r=>this.refresh(r)},e)}paint(){let e=this.st,o=e.check?.components??{},a=e.firmware,r=$a(this,o.packages),i=(e.needs?.awg??[]).length>0,d=(!i&&o.amneziawg?.update&&o.amneziawg.installed?1:0)+r.updates;dom.content(this.root,[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Components"),t("span",{class:"dl-faint"},[a?.version?`OpenWrt ${a.version} · ${a.target}`:"",e.check?`checked ${ie(e.check.time,e.now)}`:"not checked yet"].filter(Boolean).join(" · "))]),t("div",{class:"dl-row-actions"},[t("a",{class:"cbi-button cbi-button-neutral dl-icon-btn",href:`${L.url("admin/network/dawnline/settings")}?section=updates`},[g("edit")," Settings"]),D([g("refresh")," Check all"],()=>this.op("check","Checking all components"),"neutral",{disabled:this.busy})])]),ya(this,o.app),t("div",{class:"dl-comp-cols"},[t("section",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Components"),t("span",{class:"dl-spacer"}),t("span",{class:"dl-faint dl-comp-count"},i?d?`AmneziaWG not installed · ${d} update${d===1?"":"s"}`:"AmneziaWG not installed":!o.amneziawg&&!o.packages?"":d?`${d} of ${1+r.total} need${d===1?"s":""} an update`:"Everything is up to date")]),t("div",{},[...ka(this,o.amneziawg),...r.rows])]),Ea(this)])])}state(e,o,a){let r=this.st.job;if(r?.state==="running"){let i=d=>d==="packages"?"pkgs":d,s=r.action==="check"?[i(r.component||"all")]:(r.component??"").split(" ").map(d=>i(Ye(d)));if(s.includes(e)||s.includes("all"))return t("button",{type:"button",class:"dl-pill info dl-comp-run",title:"Show progress",click:()=>this.follow(r)},[r.action==="check"?"Checking":"Updating","…"])}return o?o.error?ye("warn","Check failed",o.error):o.update?ye("info","Update available"):o.status==="dev"?ye("info","Newer than release",`The latest release is ${a}`):ye("ok","Up to date"):ye("","Not checked")}more(e){let o=D([g("more")],()=>we(o,e.filter((a,r,i)=>a!==null||r>0&&ra?{label:a.label,icon:g(a.ic),warn:a.warn,run:a.run}:null)),"neutral",{title:"More","aria-label":"More"});return o}round(e,o,a=!1){let r=this.busy?" is-busy":"",i;return a?i=D([g("refresh")," Check"],e,"neutral",{class:`cbi-button cbi-button-neutral dl-comp-check${r}`,"aria-label":"Check for updates"}):(i=$e("refresh","Check for updates",e,"neutral",r.trim()),i.removeAttribute("title"),i.setAttribute("aria-label","Check for updates"),me(i,()=>["Check for updates"])),t("span",{class:"dl-comp-ic"},[i,this.more(o)])}row(e,o,a,r){return t("div",{class:"dl-row"},[t("span",{class:"dl-group-ic"},g(e)),t("span",{class:"dl-row-main dl-stack"},[t("b",{},o),t("span",{class:"dl-mono dl-faint dl-comp-sub"},a)]),...r])}};var La=(n,e)=>t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},n),t("div",{class:"cbi-value-field"},e)]);function _a(n){let e=n.st.servers.find(o=>o.id===n.p.server)?.name??"Home";zt(n.p,e)}async function Sa(n){let e=n.p;if(!await ae("Create a new link?","The old link stops working right away.","Create new link",!0))return;let o=await W(()=>P.personRegen(e.id),"New link created");o?.link&&await ue(o.link,"New link copied")}function Vn(n){let e=t("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},n.p.note??"");re("Note",[e],[le()," ",D("Save",async()=>{ce(),await n.patch({note:e.value.trim()},e.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>e.focus(),50)}function Ma(n){let e=n.p,o=t("select",{class:"cbi-input-select"},[t("option",{value:"pause",selected:e.expire_action==="pause"?"selected":null},"Pause access"),t("option",{value:"notify",selected:e.expire_action==="notify"?"selected":null},"Keep access"),t("option",{value:"remove",selected:e.expire_action==="remove"?"selected":null},"Remove their devices")]),a=t("select",{class:"cbi-input-select"},[0,1,3,7,14].map(r=>t("option",{value:r,selected:e.expire_warn===r?"selected":null},r?`${r} day${r===1?"":"s"} before`:"Don’t warn")));re("When access ends",[La("Then",o),t("div",{class:"cbi-value"},[t("label",{class:"cbi-value-title"},"Warn"),t("div",{class:"cbi-value-field"},[a,t("div",{class:"cbi-value-description"},"Shown in their portal and on the Overview.")])])],[le()," ",D("Save",async()=>{ce(),await n.patch({expire_action:o.value,expire_warn:a.value},"Saved")},"positive")])}function Ca(n){let e=t("input",{type:"text",class:"cbi-input-text",value:n.p.name,maxlength:48});re("Rename",[La("Name",e)],[le()," ",D("Save",async()=>{ce(),await n.patch({name:e.value},"Renamed")},"positive")]),setTimeout(()=>e.select(),50)}async function Ta(n){let e=n.p;await ae(`Delete ${e.name}?`,`All ${e.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await W(()=>P.personDelete(e.id),"Deleted")&&(location.href=xt(e.server))}function Pa(n){let e=n.p,o=n.st,a=e.online?"online now":e.last_seen?`last seen ${ie(e.last_seen,o.now)}`:"never connected",r=e.created?`Added ${Ce(Ne(new Date(e.created*1e3)))}`:"",i=e.has_link??o.settings.portal_enabled,s=[{label:"Rename",icon:g("edit"),run:()=>Ca(n)},{label:e.note?"Edit note":"Add note",icon:g("file"),run:()=>Vn(n)},...i?[null,{label:"Invite card",icon:g("qr"),run:()=>_a(n)},{label:"New link",icon:g("key"),run:()=>Sa(n)}]:[],null,...e.paused?[]:[{label:"Pause",icon:g("pause"),warn:!0,run:()=>n.patch({paused:!0},"Paused")}],{label:"Delete",icon:g("trash"),danger:!0,run:()=>Ta(n)}];return t("div",{class:"dl-person-head"},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-person-id"},[t("span",{class:`dl-avatar lg${e.online?" online":""}`},De(e.name)),t("div",{class:"dl-stack"},[t("div",{class:"dl-title-row"},[t("h2",{class:"dl-h1"},e.name),io(e)]),t("span",{class:"dl-faint",title:r},`${e.devices.length} of ${e.device_limit} devices · ${a}`)])]),t("div",{class:"dl-pcard-actions"},[e.paused?D([g("play")," Resume"],()=>n.patch({paused:!1},"Resumed"),"add"):"",i?$e("link","Copy link",()=>en(e.id),"neutral","dl-icon-only"):"",$e("more","More",d=>we(d.currentTarget,s),"neutral","dl-icon-only")])]),e.note?t("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>Vn(n)},[g("file"),t("span",{},e.note)]):""])}function Da(n){let e=n.p,o=n.series[n.series.length-1];return t("div",{class:`dl-person-live${e.online?"":" solo"}`},[e.online?cn(e.rate??[],n.st.now,o?[o.rx,o.tx]:[0,0]):"",pn(n.series,`${te(e.month[0]+e.month[1])} this month`)])}async function Pi(n,e){let o=await W(()=>P.deviceConfig(e.id));o&&re(`Set up ${e.name}`,[await n.core.connectBlock(o,"qr")],[le("Close")])}async function Di(n,e){let o=await W(()=>P.deviceConfig(e.id));if(!o)return;if(!o.has_private_key){Q("This device made its own keys in the browser; its configuration only exists there.","warning");return}let a=n.core.file.make(o);Ee(a.name,a.text,"application/octet-stream")}function Aa(n){let e=n.p,o=n.st.now,a=l=>Be(e,l,n.deviceOpts()),r=l=>c=>{c.target.closest("button:not(.dl-dcard-title), a")||a(l)},i=l=>D([g("more")],c=>Ao(c.currentTarget,e,l,n.deviceOpts()),"neutral",{title:"QR, file, key, rename, new keys, remove",class:"cbi-button cbi-button-neutral dl-icon-only"}),s=Ut(e.devices).map(l=>{let c=t("div",{class:"dl-dcard-head"},[t("span",{class:"dl-dcard-ic"},g(l.kind)),t("button",{type:"button",class:"dl-dcard-title",click:()=>a(l)},[t("b",{},l.name),Wt(l,o),l.config_stale?t("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),i(l)]),p=t("div",{class:"dl-dcard-trend"},[t("div",{class:"dl-stack"},[t("b",{},te(l.month[0]+l.month[1])),t("span",{class:"dl-sub"},"this month")]),na(n.devSeries[l.id]??[])]);return t("article",{class:`dl-dcard clickable${l.online?" online":""}${l.disabled?" off":""}`,click:r(l)},[c,l.handshake?p:l.disabled?t("div",{class:"dl-sub"},`${je[l.kind]} · created ${ie(l.created,o)} ${l.created_by==="portal"?"in the portal":"by you"}.`):t("div",{class:"dl-chips-row"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>Pi(n,l)},[g("qr"),"Show QR"]),t("button",{type:"button",class:"dl-chipbtn",click:()=>Di(n,l)},[g("download"),"Config"])])])}),d=e.devices.length>=e.device_limit;return s.push(t("button",{type:"button",class:"dl-dslot add",click:()=>rt(e,n.deviceOpts())},[t("span",{class:"dl-dslot-ic"},g("plus")),t("span",{class:"dl-stack"},[t("b",{},"Add device"),t("span",{class:"dl-sub"},d?`Over the limit · ${e.devices.length} of ${e.device_limit}`:`${e.devices.length} of ${e.device_limit}`)])])),t("section",{class:"dl-devsec"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Devices"),t("span",{class:"dl-sub"},`${e.online} online`)]),t("div",{class:"dl-dgrid"},s)])}function za(n){let e=n.p,o=xe([["device","Device’s own DNS"],["home","Home names"]],e.dns_mode,{label:"DNS",cls:"sm",optimistic:!1,onChange:r=>n.patch({dns_mode:r},r==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")}),a=n.st.settings.home_dns_fallback;return t("div",{class:"dl-stack gap4 dl-dnspick"},[t("div",{class:"dl-row-actions"},[t("span",{class:"dl-sub"},"DNS"),o]),t("span",{class:"dl-sub"},e.dns_mode==="home"?["Names like ",t("span",{class:"dl-mono"},`nas.${n.st.settings.domain}`)," work. Internet names are resolved at home, so they depend on the tunnel",a?[" (",t("span",{class:"dl-mono"},a)," takes over when it is down)."]:" — with no fallback set, they stop when it is down."]:"Internet keeps working exactly as without the VPN. Reach home devices by IP address.")])}function Na(n){let e=n.p,a=n.st.servers.find(i=>i.id===e.server)?.home??[];if(a.length<2)return"";let r=new Set(e.home_nets?.length?e.home_nets:a.map(i=>i.dev));return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},a.map(i=>We(i.dev,r.has(i.dev),()=>{let s=new Set(r);if(s.delete(i.dev)||s.add(i.dev),!s.size)return Q("Keep at least one network, or choose Internet only.","warning",5e3);let d=s.size===a.length?[]:[...s];n.patch({home_nets:d},d.length?`${e.name} reaches ${d.join(", ")}`:`${e.name} reaches every home network`)},{title:i.nets.join(", ")}))),t("span",{class:"dl-sub"},e.home_nets?.length?`Home networks ${e.name} reaches. Networks added to the server later stay out.`:`Home networks ${e.name} reaches: all of them. Untick one to keep ${e.name} out of it.`)])}function Ha(n){let e=new Set(n.p.services??[]);return t("div",{class:"dl-stack gap4"},[t("div",{class:"dl-chips-row"},n.st.services.map(o=>We(o.name,e.has(o.id),()=>{let a=new Set(e);a.delete(o.id)||a.add(o.id),n.patch({services:[...a]},a.size?"Home services updated":"Whole home network")},{title:`${o.address}${o.ports.length?` · ${o.ports.join(", ")}`:""}`}))),t("span",{class:"dl-sub"},e.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}function Ra(n){let e=n.p,o=n.st;if(o.servers.find(c=>c.id===e.server)?.mesh!=="circles"||!Ve(e))return"";let r=o.circles.filter(c=>c.server===e.server),i=r.find(c=>c.id===e.circle),s=i?o.people.filter(c=>c.id!==e.id&&c.circle===i.id&&Ve(c)).map(c=>c.name):[],d=t("button",{type:"button",class:"dl-chipbtn",click:()=>we(d,[...r.map(c=>({label:c.name,icon:jn(c),run:()=>c.id!==e.circle&&n.patch({circle:c.id},`${e.name} is in ${c.name}`)})),e.circle?{label:"No circle",icon:g("x"),run:()=>n.patch({circle:""},`${e.name} is in no circle`)}:null,{label:"New circle",icon:g("plus"),run:()=>an(o,e.server,null,()=>n.refresh())}])},"Change"),l=i?o.people.filter(c=>c.circle===i.id&&Ve(c)):[e];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Devices see each other"),d]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},i?i.name:"No circle"),t("span",{class:"dl-avstack",title:l.map(c=>c.name).join(", ")},l.slice(0,5).map(c=>t("span",{class:"dl-avatar sm"},De(c.name))))]),t("span",{class:"dl-sub"},i?s.length?[e.name,...s].join(", "):`Nobody else in ${i.name} yet`:`Only ${e.name}'s own devices`)])}function Ia(n){let e=n.p,o=n.st.now,a=t("div",{class:"dl-slots"});for(let s=0;s=e.device_limit,c=t("i",{class:l?"over":d?"used":""});me(c,()=>[t("div",{class:"dl-tip-title"},d?`${d.name}${l?" · over the limit":""}`:"Free slot"),t("div",{class:"dl-muted"},d?d.online?"Connected":d.handshake?`Last seen ${ie(d.handshake,o)}`:"Not set up yet":"They can add a device here")]),a.appendChild(c)}let r=Math.max(1,e.devices.length),i=t("button",{type:"button","aria-label":"Allow fewer devices",disabled:e.device_limit<=r?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit-1)})},"−");return e.device_limit<=r&&e.devices.length>1&&me(i,()=>[t("div",{class:"dl-tip-title"},`${e.devices.length} devices in use`),t("div",{class:"dl-muted"},"Remove a device first to lower the limit")]),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},"Devices"),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[String(e.devices.length),t("span",{class:"dl-faint"},` / ${e.device_limit}`)]),t("div",{class:"dl-stepper"},[i,t("button",{type:"button","aria-label":"Allow more devices",disabled:e.device_limit>=32?"disabled":null,click:()=>n.patch({device_limit:String(e.device_limit+1)})},"+")])]),a])}var Ai={internet:"Browse the internet through your router. No access to devices at home, and home cannot reach theirs.",lan:"Reach devices at home, and home reaches theirs. Internet stays on their own connection.",both:"Home devices and the internet, all through your router. Home reaches their devices too."},Ba=/^([01]\d|2[0-3]):[0-5]\d$/;function zi(n){let e=n.p,o=n.today,a=tt(e.expires,o),r=t("input",{type:"date",class:"dl-date-hidden",value:e.expires,tabindex:"-1","aria-hidden":"true"});r.addEventListener("change",()=>r.value&&n.patch({expires:r.value},`Access until ${Ce(r.value)}`));let i=(c,p)=>{let u=oo(e.expires&&(a??-1)>=0?e.expires:"",c,p,o);n.patch({expires:u},`Access until ${Ce(u)}`)},s=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([c,p,u])=>t("button",{type:"button",class:"dl-chipbtn",click:()=>i(c,p)},u)),d=t("span",{class:"dl-datechip"},[t("button",{type:"button",class:"dl-chipbtn",click:()=>{r.focus({preventScroll:!0});try{r.showPicker()}catch{}}},[g("calendar"),e.expires?Ce(e.expires):"Date"]),r]),l={pause:"pause access",notify:"keep access",remove:"remove their devices"}[e.expire_action];return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Access ends"),e.expires?t("span",{class:a!=null&&a<0?"dl-bad":a!=null&&a<=e.expire_warn?"dl-warn":"dl-ok"},a!=null&&a<0?"ended":`${a} day${a===1?"":"s"} left`):t("span",{class:"dl-faint"},"no end date")]),t("div",{class:"dl-chips-row"},[...s,d,e.expires?t("button",{type:"button",class:"dl-chipbtn",click:()=>n.patch({expires:""},"No end date")},"No end"):""]),t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`When it ends: ${l}${e.expire_warn?`, warn ${e.expire_warn} day${e.expire_warn===1?"":"s"} before`:""}`),t("a",{href:"#",click:c=>{c.preventDefault(),Ma(n)}},"Change")])])}function Ni(n){let e=n.p,o=e.quota_used||e.month[0]+e.month[1],a=e.quota_limit?Math.min(100,e.quota_used/e.quota_limit*100):0,r=t("div",{class:`dl-meter${a>=100?" bad":a>=90?" warn":""}`},[t("i"),e.quota_limit?t("span",{class:"mark",title:"Alert at 90%"}):""]);r.firstChild.style.width=`${a}%`,e.quota_limit&&me(r,()=>[t("div",{class:"dl-tip-title"},`${a.toFixed(1)}% used`),t("div",{class:"dl-muted"},`${te(e.quota_used)} of ${te(e.quota_limit)} · ${te(Math.max(0,e.quota_limit-e.quota_used))} left`),t("div",{class:"dl-faint"},"Alert at 90%")]);let i=xe([["month","Monthly"],["total","Total"]],e.quota_period,{label:"Data limit period",cls:"sm",optimistic:!1,onChange:d=>n.patch({quota_period:d})}),s=[10,50,100].map(d=>t("button",{type:"button",class:`dl-chipbtn${e.quota_gb===d?" on":""}`,click:()=>n.patch({quota_gb:String(d)},`Data limit ${d} GB`)},`${d} GB`));return s.push(t("button",{type:"button",class:`dl-chipbtn${e.quota_gb?"":" on"}`,click:()=>n.patch({quota_gb:""},"No data limit")},"Unlimited")),s.push(t("button",{type:"button",class:"dl-chipbtn",click:()=>{let d=prompt("Data limit in GB",e.quota_gb?String(e.quota_gb):"");d!=null&&d.trim()!==""&&Number(d)>0&&n.patch({quota_gb:d.trim()},`Data limit ${d.trim()} GB`)}},"Custom")),t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-label"},[t("span",{},"Data"),i]),t("div",{class:"dl-tile2-row"},[t("span",{class:"dl-tile2-value"},[te(o),e.quota_limit?t("span",{class:"dl-faint"},` of ${te(e.quota_limit)}`):t("span",{class:"dl-faint"}," · no limit")]),e.quota_period==="month"?t("span",{class:"dl-sub"},"resets on the 1st"):""]),e.quota_limit?r:"",t("div",{class:"dl-chips-row"},s),e.quota_gb&&e.quota_period==="month"?t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},e.bonus_gb?`Includes +${e.bonus_gb} GB extra this month`:"Need a little more this month?"),t("a",{href:"#",click:d=>{d.preventDefault(),n.patch({bonus_gb:String((e.bonus_gb||0)+10)},"+10 GB this month")}},"+10 GB this month")]):"",t("div",{class:"dl-tile2-foot"},[t("span",{class:"dl-muted"},`${te(e.total[0]+e.total[1])} in total`),t("button",{type:"button",class:"dl-linkbtn danger",click:()=>gt("person",e.id,e.name,()=>setTimeout(()=>n.refresh(),300))},"Reset usage")])])}function Hi(n){let e=n.p,o=!!e.hours,[a,r]=(e.hours||"07:00-23:00").split("-"),i=t("input",{type:"time",class:"cbi-input-text",value:a,"aria-label":"From"}),s=t("input",{type:"time",class:"cbi-input-text",value:r,"aria-label":"To"}),d=t("div",{class:"dl-tile2-row"},[i,t("span",{class:"dl-faint"},"to"),s]),l=()=>{let p=`${i.value}-${s.value}`;if(p!==e.hours){if(!Ba.test(i.value)||!Ba.test(s.value))return Q("Enter both times, like 07:00 and 23:00.","warning");if(i.value===s.value)return Q("The start and the end must differ.","warning");n.patch({hours:p},`Allowed ${i.value}–${s.value}`)}};d.addEventListener("focusout",p=>{d.contains(p.relatedTarget)||l()});for(let p of[i,s])p.addEventListener("keydown",u=>{u.key==="Enter"&&(u.preventDefault(),l())});let c=t("button",{type:"button",role:"switch","aria-checked":o?"true":"false",class:`dl-switch${o?" on":""}`,"aria-label":"Limit hours",click:()=>n.patch({hours:o?"":"07:00-23:00"},o?"Any time":"Allowed 07:00–23:00")},t("i"));return t("div",{class:"dl-tile2"},[t("div",{class:"dl-tile2-row"},[t("div",{class:"dl-stack"},[t("span",{class:"dl-tile2-label"},"Allowed hours"),t("span",{},o?`${a} – ${r} (router time)`:"Any time")]),c]),o?d:""])}function Oa(n){let e=n.p,o=xe(["internet","lan","both"].map(a=>[a,[g(a==="internet"?"globe":a==="lan"?"home":"shield"),a==="internet"?"Internet":a==="lan"?"Home":"Both"]]),e.access,{label:"Access",cls:"wide",optimistic:!1,onChange:a=>n.patch({access:a},`Access: ${nt[a]}`)});return t("section",{class:"dl-devsec","aria-label":"Access and limits"},[t("div",{class:"dl-panel-head"},[t("h3",{},"Access & limits")]),t("div",{class:"dl-panel"},[t("div",{class:"dl-stack gap8"},[t("span",{class:"dl-tile2-label"},"Can reach"),o,t("span",{class:"dl-sub"},Ai[e.access]),e.access==="lan"&&n.st.services.length?Ha(n):"",Ve(e)?Na(n):"",e.access==="lan"?za(n):""]),t("div",{class:"dl-tiles2"},[Ia(n),Ra(n),zi(n),Ni(n),Hi(n)])])])}function Ri(n){let e=n.st,o=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Locations"),t("span",{class:"dl-spacer"}),e.geo.enabled?bt("30d",r=>n.map?.setRange(r),!1):"",D("Hide",()=>{n.mapOpen=!1,n.map?.destroy(),n.map=null,n.paintPlaces()},"neutral")]);if(!e.geo.enabled)return t("div",{class:"dl-panel flush"},[o,t("div",{class:"dl-map-off"},["Locations are off. ",t("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])]);let a=new Ke({openPerson:()=>{},openDevice:(r,i)=>{let s=n.p.devices.find(d=>d.id===i);s&&Be(n.p,s,n.deviceOpts())}},"30d",280);return n.map=a,requestAnimationFrame(()=>a.mount(n.mapData())),t("div",{class:"dl-panel flush"},[o,a.el])}function ja(n){let e=n.st;if(!e.geo.enabled)return t("div",{class:"dl-places"},[g("pin"),t("div",{class:"dl-stack"},[t("span",{},"Locations are off"),t("span",{class:"dl-sub"},"City-level, from the client IP")]),t("span",{class:"dl-spacer"}),t("a",{class:"cbi-button cbi-button-neutral",href:L.url("admin/network/dawnline/settings")},"Turn on")]);if(n.mapOpen)return n.map&&n.parts.places.contains(n.map.el)?null:Ri(n);let o=e.now-30*86400,a=e.geo.points.filter(s=>s.person===n.p.id&&s.ts>=o).sort((s,d)=>d.ts-s.ts),r=[...new Set(a.map(s=>s.city||s.country).filter(Boolean))],i=a[0];return t("div",{class:"dl-places"},[g("pin"),t("div",{class:"dl-stack"},[t("span",{},i?i.city||i.country:"No locations yet"),t("span",{class:"dl-sub"},i?`${r.length} place${r.length===1?"":"s"} in 30 days${i.org?` · ${i.org}`:""}`:"Shown after a device connects")]),t("span",{class:"dl-spacer"}),a.length?D("Show map",()=>{n.mapOpen=!0,n.paintPlaces()},"neutral"):""])}function Ua(n){let e=n.p,o=n.st,a=n.events.filter(d=>d.person===e.id),r=[],i=[...a].reverse();for(let d=0;d1){let u=p.querySelector(".dl-row-main");dom.content(u,[...Wn(o,l).slice(0,3),t("span",{class:"dl-muted"},`${c} times`)]),u.title=i.slice(d,d+c).map(k=>k.detail??"").join(` +`)}r.push(p),d+=c-1}let s=D([g("more")],()=>we(s,[{label:"Export CSV",icon:g("download"),run:()=>Ue(o,a,"csv",e.id)},{label:"Export JSON",icon:g("download"),run:()=>Ue(o,a,"json",e.id)},null,{label:`Clear ${e.name}'s activity`,icon:g("trash"),danger:!0,run:()=>Fe(`Clear ${e.name}'s activity`,`Removes events about ${e.name} and their devices.`,{person:e.id},()=>n.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});return t("div",{class:"dl-panel flush"},[t("div",{class:"dl-panel-head pad"},[t("h3",{},"Activity"),t("span",{class:"dl-sub"},a.length>10?`latest 10 of ${a.length}`:""),t("span",{class:"dl-spacer"}),s]),r.length?r:t("div",{class:"dl-row dl-muted"},"Nothing yet.")])}var vn=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.ticks=0;this.fullNext=!1}async fetch(e){let[o,a,r]=await Promise.all([P.status(30),e?P.events(5e3).catch(()=>null):Promise.resolve(null),e?P.personUsage(this.id,30).catch(()=>null):Promise.resolve(null)]);return{st:o,ev:a?.events??null,use:r}}async load(){return this.id=new URLSearchParams(location.search).get("id")??"",this.fetch(!0)}render(e){this.take(e);let o=this.st.people.find(s=>s.id===this.id);if(!o)return t("div",{class:"dl-empty"},[t("h3",{},"Person not found"),t("p",{},"They may have been removed."),t("a",{class:"cbi-button",href:L.url("admin/network/dawnline/server")},"Back to Servers")]);this.p=o;for(let s of["head","devices","traffic","places","activity","limits"])this.parts[s]=t("div",{});this.parts.devices.className="dl-person-devices";let a=t("div",{},[t("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[t("a",{href:xt(o.server)},this.st.servers.find(s=>s.id===o.server)?.name??"Servers"),t("span",{},"/"),t("a",{href:xt(o.server)},"People"),t("span",{},"/"),t("span",{},o.name)]),this.parts.head,t("div",{class:"dl-grid-person"},[t("div",{class:"dl-col"},[this.parts.devices,this.parts.traffic,this.parts.places,this.parts.activity]),t("div",{class:"dl-col"},[this.parts.limits])])]);this.paint();let r=new URLSearchParams(location.search),i=r.get("device")&&o.devices.find(s=>s.id===r.get("device"));return i?setTimeout(()=>Be(this.p,i,this.deviceOpts()),50):r.get("add")&&setTimeout(()=>rt(this.p,this.deviceOpts()),50),this.poller=Je({fetch:s=>{let d=s||this.fullNext||++this.ticks%4===0;return this.fullNext=!1,this.fetch(d)},every:15,live:!0,active:()=>a.isConnected,apply:(s,d)=>this.apply(s,d)}),a}take(e){this.st=e.st,e.ev&&(this.events=e.ev),e.use&&(this.series=e.use.person,this.devSeries=e.use.devices)}apply(e,o){this.take(e);let a=this.st.people.find(r=>r.id===this.id);if(!a){o||(location.href=xt(this.p?.server));return}this.p=a,this.paint(o),this.map?.update(this.mapData())}async refresh(){this.fullNext=!0,await this.poller?.refresh()}async patch(e,o){var i;this.poller?.claim();let a=await W(()=>P.personUpdate(this.p.id,e),o);if(!a)return;this.poller?.claim();let r=this.st.people.findIndex(s=>s.id===this.p.id);(i=a.person).rate??(i.rate=this.p.rate),r>=0&&(this.st.people[r]=a.person),this.p=a.person,this.paint()}get today(){return Re(this.series.length?this.series:this.st.series)}get core(){return vt(this.st.servers,this.p.server)}deviceOpts(){return{refresh:()=>this.refresh(),geo:this.st.geo,now:this.st.now,today:this.today,core:this.core,events:()=>this.events}}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}paint(e=!1){Le(this.parts.head,Pa(this),e),Le(this.parts.traffic,Da(this),e),Le(this.parts.devices,Aa(this),e),Le(this.parts.limits,Oa(this),e),this.paintPlaces(e),Le(this.parts.activity,Ua(this),e)}paintPlaces(e=!1){let o=ja(this);o&&Le(this.parts.places,o,e&&!this.mapOpen)}};var Ii={ok:"check",warn:"alert",error:"x",skip:"pause"},bn=class{constructor(e,o,a,r){this.el=t("div",{});this.wdEl=t("div",{});this.checksEl=t("div",{class:"dl-panel"});this.recentEl=t("div",{class:"dl-panel flush dl-recent"});this.checks=null;this.summary=t("div",{});this.open=new Set;this.st=e,this.sl=o,this.events=a,this.toLog=r,dom.content(this.el,[this.summary,this.wdEl,t("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(o,a)}async run(e){let o=e?await un(e):await P.health().catch(()=>null);o&&(this.take(o),e==="netrestart"&&setTimeout(()=>this.el.isConnected&&void this.run(),5e3))}take(e){this.checks=e.checks,this.paintChecks(),this.paintLive(e,this.events)}paintChecks(){let e=this.checks;if(!e){dom.content(this.summary,""),dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks")]),t("p",{class:"dl-muted dl-loading"},"Running checks…")]);return}let o=e.filter(s=>s.status==="error").length,a=e.filter(s=>s.status==="warn").length;dom.content(this.summary,o?mt("error",`${o} problem${o>1?"s":""} need attention.`):a?mt("warn",`${a} warning${a>1?"s":""}.`):mt("ok","All checks passed."));let r=new Map;for(let s of this.sl.watchdog.repairs)r.set(s.id,Math.max(r.get(s.id)??0,s.ts));let i=()=>this.run();dom.content(this.checksEl,[t("div",{class:"dl-panel-head"},[t("h3",{},"Checks"),t("span",{class:"dl-spacer"}),D("Run again",i)]),t("ul",{class:"dl-checks"},e.map(s=>t("li",{},[t("span",{class:`dl-check-icon ${s.status}`},g(Ii[s.status])),t("div",{class:"dl-check-body"},[t("div",{class:"dl-check-title"},s.title),t("div",{class:"dl-check-detail"},s.detail),r.has(s.id)?t("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${Lt(r.get(s.id))}`):""]),Gn(s,d=>void this.run(d),i)])))])}paintLive(e,o){this.sl=e,this.events=o;let a=e.watchdog,r=a.beat!=null&&a.now-a.beat>180,i=a.repairs.filter(l=>a.now-l.ts<86400),s=i[i.length-1],d=ge(a.enabled,"Watchdog repairs",async l=>{await W(()=>P.settingsUpdate({watchdog:l?"1":"0"}),l?"Watchdog on":"Watchdog off")||Mn(d,!l);let p=await P.serviceLog().catch(()=>null);p&&this.paintLive(p,this.events)});dom.content(this.wdEl,t("div",{class:"dl-panel dl-wd"},[t("div",{class:"dl-wd-head"},[t("span",{class:`dl-wd-tile${a.enabled?"":" off"}`},g("shield")),t("div",{class:"dl-stack"},[t("span",{class:"dl-wd-title"},"Watchdog"),t("span",{class:"dl-sub"},a.enabled?"Every minute it checks the tunnels and services and repairs what it can on its own.":"Off: problems are only written to the log. Nothing is repaired on its own.")]),t("span",{class:"dl-spacer"}),d]),t("div",{class:"dl-wd-foot"},[t("div",{class:"dl-wd-chips"},a.targets.map(l=>t("span",{class:`dl-check-chip${l.ok?"":" error"}`,title:l.ok?"OK":`Not working${l.tries?` · ${l.tries} repair${l.tries>1?"s":""}`:""}`},[g(l.ok?"check":"x"),l.name]))),t("span",{class:`dl-sub${r?" dl-warn-text":""}`},r?`The agent has not checked in for ${Math.round((a.now-a.beat)/60)} min; cron restarts it after 5.`:[a.last?`Looked ${ie(a.last,a.now)}`:"Starts within a minute"," · ",i.length?`${i.length} repair${i.length>1?"s":""} today, last ${s.name} at ${Lt(s.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let e=(this.sl.watchdog.now||Date.now()/1e3)-604800,o=[...this.events.map(r=>({ts:r.ts,ev:r})),...this.sl.log.map(r=>({ts:r.ts,sys:r}))].filter(r=>r.ts>=e&&qt(r)).sort((r,i)=>i.ts-r.ts),a=t("div",{class:"dl-panel-head pad"},[t("h3",{},"Recent problems"),t("span",{class:"dl-spacer"}),o.length?t("a",{href:"#",click:r=>(r.preventDefault(),this.toLog())},"All in Log →"):""]);if(!o.length){dom.content(this.recentEl,[a,t("div",{class:"dl-recent-empty"},[t("span",{class:"dl-check-icon ok"},g("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[a,...o.slice(0,8).map(r=>{if(r.sys){let i=r.sys,s=`${i.ts}|${i.msg}`;return dn(i,this.open.has(s),()=>{this.open.delete(s)||this.open.add(s),this.paintRecent()},Lt(i.ts))}return Ze(this.st,r.ev,{time:Lt(r.ts)})})])}};var xn=300,Bi=["all","connections","people","system","problems"],wn=class{constructor(e,o,a){this.events=[];this.system=[];this.kind="all";this.shown=xn;this.open=new Set;this.list=t("div",{});this.sub="";this.tabs=t("div",{class:"dl-seg",role:"tablist"});this.st=e,this.take(o),this.system=a,this.el=t("div",{},[t("div",{class:"dl-toolbar"},[this.tabs]),this.list]),this.paint()}actions(){let e=()=>this.kind==="all"?"":this.kind,o=i=>()=>{let s=this.filtered().reverse();Ue(this.st,s.filter(d=>d.ev).map(d=>d.ev),i,e(),s.filter(d=>d.sys).map(d=>d.sys))},a=D([g("download")," Export"],()=>we(a,[{label:"CSV (spreadsheet)",icon:g("download"),run:o("csv")},{label:"JSON",icon:g("download"),run:o("json")}])),r=D([g("trash")," Clear"],()=>Fe("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[a,r]}take(e){this.events=e.events,this.policy=e.policy;let o=ft.filter(a=>!e.policy.categories.includes(a));this.sub=`${Ft(e.policy)}${o.length?` Not recorded: ${o.map(a=>at[a].toLowerCase()).join(", ")}.`:""}`}async reload(){let[e,o]=await Promise.all([P.events(2e4).catch(()=>null),P.serviceLog().catch(()=>null)]);e&&this.take(e),o&&(this.system=o.log),this.paint()}items(){return[...this.events.map(e=>({ts:e.ts,ev:e})),...this.system.map(e=>({ts:e.ts,sys:e}))].sort((e,o)=>o.ts-e.ts)}matches(e,o){return o==="all"?!0:o==="problems"?qt(e):o==="system"?!!e.sys:!!e.ev&&Mt(e.ev.type)===o}filtered(){return this.items().filter(e=>this.matches(e,this.kind))}paintTabs(e){dom.content(this.tabs,Bi.map(o=>t("button",{type:"button",role:"tab",class:o===this.kind?"on":"","aria-selected":o===this.kind?"true":"false",click:()=>this.show(o)},[o==="all"?"All":o==="system"?"System":at[o],t("b",{},String(e.filter(a=>this.matches(a,o)).length))])))}show(e){this.kind=e,this.shown=xn,this.paint()}paint(){this.paintTabs(this.items());let e=this.filtered();if(!e.length){dom.content(this.list,t("div",{class:"dl-empty"},[t("p",{},this.events.length||this.system.length?"No events match.":"The log is empty.")]));return}let o=[],a="",r=null;for(let i of e.slice(0,this.shown)){let s=ta(i.ts);s!==a&&(a=s,r=t("div",{class:"dl-panel flush"},t("div",{class:"dl-panel-head pad"},t("h3",{},s))),o.push(r));let d=new Date(i.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(i.sys){let l=`${i.sys.ts}|${i.sys.msg}`;r.appendChild(dn(i.sys,this.open.has(l),()=>{this.open.delete(l)||this.open.add(l),this.paint()},d))}else r.appendChild(Ze(this.st,i.ev,{time:d}))}e.length>this.shown&&o.push(t("div",{class:"dl-more-row"},D(`Show ${Math.min(xn,e.length-this.shown)} more of ${e.length-this.shown}`,()=>{this.shown+=xn,this.paint()}))),dom.content(this.list,o)}};var Oi=[["health","Health"],["log","Log"]],Yn=2e4,yn=class{constructor(){this.tab=new URLSearchParams(location.search).get("tab")==="log"?"log":"health";this.segEl=t("div",{class:"dl-seg dl-srvsections dl-diag-tabs",role:"tablist","aria-label":"Diagnostics"});this.subEl=t("span",{class:"dl-muted"});this.actionsEl=t("div",{class:"dl-row-actions"});this.bodyEl=t("div",{});this.eventsAt=0}load(){return this.eventsAt=Date.now(),Promise.all([P.status(1),P.events(Yn),P.serviceLog()])}render([e,o,a]){return this.log=new wn(e,o,a.log),this.health=new bn(e,a,o.events,()=>{this.show("log"),this.log.show("problems")}),this.show(this.tab),Je({fetch:async()=>{let r=this.tab==="log",[i,s]=await Promise.all([P.serviceLog().catch(()=>null),r?P.events(Yn).catch(()=>null):Promise.resolve(null)]);return i||s?{n:i,e:s}:null},every:10,active:()=>this.bodyEl.isConnected,apply:({n:r,e:i})=>this.take(r,i)}),t("div",{},[t("div",{class:"dl-pagehead"},[t("div",{class:"dl-stack"},[t("h2",{class:"dl-h1"},"Diagnostics"),this.subEl]),this.actionsEl]),this.segEl,this.bodyEl])}take(e,o){o&&(this.log.take(o),this.eventsAt=Date.now()),e&&(this.log.system=e.log),e&&this.health.paintLive(e,o?.events??this.health.events),this.tab==="log"&&this.log.paint()}show(e){this.tab=e,dom.content(this.segEl,Oi.map(([o,a])=>t("button",{type:"button",role:"tab",class:o===e?"on":"","aria-selected":o===e?"true":"false",click:()=>o!==this.tab&&this.show(o)},a))),this.bodyEl.replaceChildren(e==="log"?this.log.el:this.health.el),this.subEl.textContent=e==="log"?this.log.sub:"Everything Dawnline depends on, checked live. The watchdog repairs what it can on its own.",dom.content(this.actionsEl,e==="log"?this.log.actions():""),e==="log"?(this.log.paint(),Date.now()-this.eventsAt>1e4&&P.events(Yn).then(o=>this.take(null,o)).catch(()=>null)):this.health.checks||this.health.run()}};var Wa=":root{--dl-card: var(--panel-bg, var(--background-color-high, transparent));--dl-elevated: var(--elevated, var(--background-color-high, Canvas));--dl-line: var(--border, var(--border-color-medium, color-mix(in srgb, currentColor 14%, transparent)));--dl-soft: var(--muted, color-mix(in srgb, currentColor 5%, transparent));--dl-soft-hover: var(--soft-hover, color-mix(in srgb, currentColor 10%, transparent));--dl-fg: var(--foreground, var(--text-color-highest, inherit));--dl-fg-muted: var(--muted-foreground, color-mix(in srgb, currentColor 65%, transparent));--dl-fg-faint: var(--text-tertiary, color-mix(in srgb, currentColor 50%, transparent));--dl-accent: var(--accent, #3a83f7);--dl-ok: var(--success, #00a240);--dl-warn: var(--warning, #e25507);--dl-bad: var(--danger, #e02e2a);--dl-ok-wash: var(--success-a15, color-mix(in srgb, #00a240 15%, transparent));--dl-warn-wash: var(--warning-a15, color-mix(in srgb, #e25507 15%, transparent));--dl-bad-wash: var(--destructive-a15, color-mix(in srgb, #e02e2a 15%, transparent));--dl-info-wash: var(--info-a15, color-mix(in srgb, #3a83f7 15%, transparent));--dl-info: var(--info, #2c67c5);--dl-track: var(--foreground-a10, color-mix(in srgb, currentColor 10%, transparent));--dl-chart-1: var(--chart-blue, #3a83f7);--dl-chart-2: var(--chart-green, #00a240);--dl-ring: var(--ring, #3a83f7);--dl-primary: var(--primary, #0d0d0d);--dl-primary-fg: var(--primary-foreground, #fff);--dl-mono: var(--font-mono, ui-monospace, Menlo, Consolas, monospace);--dl-shadow: var(--shadow-sm, none);--dl-radius: 16px}.dl-root,.dl-modal{cursor:default}:is(.dl-root,.dl-modal) :is(input:not([type=checkbox],[type=radio],[type=range],[type=button],[type=submit]),textarea,[contenteditable=true]){cursor:text}.dl-icon-wrap{display:inline-flex;align-items:center;justify-content:center;line-height:0}.dl-icon{width:16px;height:16px}.dl-icon-btn{display:inline-flex!important;align-items:center;gap:6px}.dl-muted{color:var(--dl-fg-muted)}.dl-faint,.dl-sep{color:var(--dl-fg-faint)}.dl-nowrap{white-space:nowrap}.dl-mono{font-family:var(--dl-mono);font-size:13px}.dl-spacer{flex:1}.dl-pill{display:inline-flex;align-items:center;gap:4px;height:20px;padding:0 8px;border-radius:999px;font-size:12px;line-height:20px;font-weight:500;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-pill.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-pill.accent{background:var(--dl-info-wash);color:var(--dl-info)}.dl-pill.off{opacity:.75}.dl-panel{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:16px;margin:0 0 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-panel-head{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 0 12px}.dl-panel-head h3{margin:0!important;padding:0;font-size:16px;line-height:24px;font-weight:500;border:0;background:none}.dl-tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px;margin:0 0 16px}.dl-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;min-width:0;box-shadow:var(--dl-shadow)}.dl-tile-label{font-size:12px;line-height:16px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile-value{font-size:24px;line-height:32px;font-weight:500;margin-top:4px;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;letter-spacing:-.01em}.dl-tile-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin-top:2px;font-variant-numeric:tabular-nums}.dl-grid2{display:grid;grid-template-columns:minmax(0,1.45fr) minmax(0,1fr);gap:0 16px}@media(max-width:960px){.dl-grid2{grid-template-columns:minmax(0,1fr)}}.dl-chart{display:block;width:100%;height:120px}.dl-bar-down{fill:var(--dl-chart-1)}.dl-bar-up{fill:var(--dl-chart-2);opacity:.8}.dl-legend{display:flex;gap:16px;font-size:12px;color:var(--dl-fg-muted);margin-top:8px}.dl-legend i{display:inline-block;width:8px;height:8px;border-radius:999px;margin-right:6px;vertical-align:0}.dl-legend .down{background:var(--dl-chart-1)}.dl-legend .up{background:var(--dl-chart-2)}.dl-events{list-style:none;margin:0;padding:0}.dl-events li{display:flex;gap:12px;align-items:baseline;padding:8px 0;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-events li:first-child{border-top:0;padding-top:0}.dl-ev-time{flex:0 0 88px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums;white-space:nowrap;font-size:13px}.dl-ev-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);transform:translateY(-2px)}.dl-ev-dot.ok{background:var(--dl-ok)}.dl-ev-dot.warn{background:var(--dl-warn)}.dl-ev-dot.bad{background:var(--dl-bad)}.dl-ev-dot.accent{background:var(--dl-accent)}.dl-row>.dl-ev-dot,.dl-dev-log-row>.dl-ev-dot{margin:0 4px}.dl-ev-tile{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;margin:-2px -4px;border-radius:7px;background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent);align-self:center}.dl-ev-tile .dl-icon-wrap{display:inline-flex}.dl-ev-tile .dl-icon{width:14px;height:14px}.dl-row.dl-ev-by-admin{background:color-mix(in srgb,var(--dl-accent) 6%,transparent)}.dl-you{color:var(--dl-accent);font-weight:500}.dl-ev-kind{color:var(--dl-fg-faint)}.dl-slotbar{display:flex;align-items:center;gap:8px;margin:8px 0 0 44px}.dl-slotbar-segs{display:flex;gap:3px;flex:none;max-width:100%}.dl-slotbar-segs i{flex:1;min-width:2px;display:block;height:4px;border-radius:2px;background:var(--dl-soft-hover)}.dl-slotbar-segs i.used{background:var(--dl-fg-muted)}.dl-slotbar-text{font-size:12px;color:var(--dl-fg-faint);font-variant-numeric:tabular-nums}.dl-slotbar-segs i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-ev-srv{flex:none;font-size:11px;line-height:18px;padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-ev-by-system{--sys: var(--dl-fg-muted)}.dl-ev-by-system.ok{--sys: var(--dl-ok)}.dl-ev-by-system.warn{--sys: var(--dl-warn)}.dl-ev-by-system.bad{--sys: var(--dl-bad)}.dl-ev-tile.ev{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-ev-tile.ev.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-ev-tile.ev.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ev-tile.ev.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-ev-tile.ev.accent{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ev-tile.sys{background:color-mix(in srgb,var(--sys) 16%,transparent);color:var(--sys)}.dl-row.dl-ev-by-system{background:color-mix(in srgb,var(--sys) 6%,transparent)}.dl-sys-src{color:var(--sys)}.dl-ev-by-system:not(.ok):not(.warn):not(.bad) .dl-sys-src{color:var(--dl-fg)}.dl-ev-text{min-width:0;overflow-wrap:anywhere}.dl-server{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-server-name{font-size:16px;line-height:24px;font-weight:500}.dl-kv{display:grid;grid-template-columns:max-content minmax(0,1fr);gap:6px 24px;margin:12px 0 0;font-size:14px;line-height:20px}.dl-kv dt{color:var(--dl-fg-muted);font-weight:400;margin:0}.dl-kv dd{margin:0;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}";var Ga='.dl-plist{display:block}.dl-plist>.dl-card{display:block;margin:0 0 12px;padding:16px;min-width:0;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);box-shadow:var(--dl-shadow)}.dl-plist>.dl-card.dl-filtered{display:none}.dl-plist>.dl-card.dl-off :is(.dl-card-name,.dl-avatar,.dl-access,.dl-slotbar,.dl-chips,.dl-pill-ic,.dl-use-num,.dl-pside-foot,.dl-pside-state){opacity:.45}.dl-plist>.dl-card.dl-off .dl-usebar i{background:var(--dl-fg-faint)}.dl-plist>.dl-card.dl-off .dl-chip-tag{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pcard:has(>.dl-pstrip){row-gap:14px}.dl-pstrip{grid-column:1 / -1;display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin:0 -16px -16px;padding:10px 16px;border-top:1px solid var(--dl-line);border-radius:0 0 var(--dl-radius) var(--dl-radius);font-size:14px;line-height:20px}.dl-pstrip.warn{background:color-mix(in srgb,var(--dl-warn) 7%,transparent)}.dl-pstrip.bad{background:color-mix(in srgb,var(--dl-bad) 7%,transparent)}.dl-pstrip-text{flex:1;min-width:0;display:flex;flex-wrap:wrap;align-items:baseline;gap:0 8px}.dl-pstrip-text b{font-weight:500}.dl-pstrip>.cbi-button{flex:none;height:32px!important}.dl-plist-none{color:var(--dl-fg-muted);text-align:center;padding:28px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-card-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 8px}.dl-avatar{flex:0 0 auto;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;font-size:12px;font-weight:600;color:var(--dl-fg);background:var(--dl-soft);position:relative;margin-right:4px;letter-spacing:.02em}.dl-avatar.online:after{content:"";position:absolute;right:-1px;bottom:-1px;width:9px;height:9px;border-radius:50%;background:var(--dl-ok);box-shadow:0 0 0 2px var(--dl-card)}.dl-card-name{font-size:16px;line-height:24px;font-weight:500}.dl-card-slug{font-size:13px;color:var(--dl-fg-faint);font-family:var(--dl-mono)}.dl-quota{margin:8px 0 0 44px;max-width:320px;height:6px;border-radius:999px;background:var(--dl-track);overflow:hidden}.dl-quota>i{display:block;height:100%;background:var(--dl-accent);border-radius:999px}.dl-quota.warn>i{background:var(--dl-warn)}.dl-quota.bad>i{background:var(--dl-bad)}.dl-chips{display:flex;flex-wrap:wrap;gap:6px;margin:12px 0 0 44px}.dl-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;max-width:240px;height:28px;padding:0 12px 0 10px;border-radius:999px;font-size:13px;background:var(--dl-soft);color:var(--dl-fg);transition:background .15s}.dl-chip:hover{background:var(--dl-soft-hover)}.dl-chip:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-chip .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-chip.add{background:transparent;box-shadow:inset 0 0 0 1px var(--dl-line);color:var(--dl-fg-muted);aspect-ratio:1;padding:0;justify-content:center}.dl-chip.add:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-chip.disabled .dl-chip-name{text-decoration:line-through;color:var(--dl-fg-faint)}.dl-chip-name{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-dot{flex:0 0 auto;width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);opacity:.6}.dl-dot.online{background:var(--dl-ok);opacity:1;box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-empty{text-align:center;padding:40px 16px;background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius)}.dl-empty .dl-icon-wrap{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);margin-bottom:12px}.dl-empty .dl-icon{width:20px;height:20px}.dl-empty h3{margin:0 0 4px!important;font-size:16px;font-weight:500}.dl-empty p{margin:0 0 16px;color:var(--dl-fg-muted);font-size:14px}.dl-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;margin:0 0 16px}.dl-toolbar .dl-muted{font-size:13px}@media(max-width:640px){.dl-slotbar,.dl-chips,.dl-quota{margin-left:0}.dl-btn-label{display:none}}.cbi-value.dl-block{display:block!important}.cbi-value.dl-block>.cbi-value-title{display:block;width:auto;float:none;text-align:left;padding:0 0 8px}.cbi-value.dl-block>.cbi-value-field{display:block;width:100%;margin:0}';var qa="#modal_overlay{z-index:1100!important}.dl-dd{position:fixed;z-index:1200;min-width:200px;padding:4px;border-radius:12px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:0 12px 32px #0000004d;display:flex;flex-direction:column}.dl-dd button{all:unset;cursor:pointer;display:flex;align-items:center;gap:10px;padding:7px 10px;border-radius:8px;font-size:13px;color:var(--dl-fg)}.dl-dd button .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-dd button:hover,.dl-dd button:focus-visible{background:var(--dl-soft)}.dl-dd button.danger,.dl-dd button.danger .dl-icon{color:var(--dl-bad, #e5484d)}.dl-dd button.warn,.dl-dd button.warn .dl-icon{color:var(--dl-warn)}.dl-dd hr{border:0;border-top:1px solid var(--dl-line);margin:4px 0}.dl-chipbtn b{font-weight:500;font-size:11px;margin-left:6px;opacity:.6}.dl-setsub{margin:20px 0 8px!important;font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-row-actions{display:flex;flex-wrap:wrap;gap:8px;align-items:center}.dl-more-row{display:flex;justify-content:center;padding:8px 0 16px}.dl-dsec-actions{display:flex;align-items:center;gap:12px}.dl-kv-act{display:inline-flex;align-items:center;gap:12px;flex-wrap:wrap}.dl-linkbtn,.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:4px;height:26px;padding:0 9px;margin:-4px -6px;border-radius:8px;font-size:12px;font-weight:500;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap;transition:background .12s,color .12s}.dl-bento-head a,.dl-bento-foot a,.dl-panel-head a,.dl-dsec-head a,.dl-tile2-foot a{color:var(--dl-accent)}.dl-linkbtn:hover,.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:var(--dl-soft);color:var(--dl-fg);text-decoration:none!important}.dl-bento-head a:hover,.dl-bento-foot a:hover,.dl-panel-head a:hover,.dl-dsec-head a:hover,.dl-tile2-foot a:hover{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-linkbtn:focus-visible,.dl-bento-head a:focus-visible,.dl-bento-foot a:focus-visible,.dl-panel-head a:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-linkbtn.danger:hover{color:var(--dl-bad);background:var(--dl-bad-wash)}.dl-ifcards{display:flex;flex-direction:column;gap:20px;margin:24px 0}.dl-ifcard .dl-setsec-body{gap:14px}.dl-iflead{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-iflead b{font-size:14px;font-weight:500}.dl-ifgroup h4{margin:0 0 8px!important;padding:0!important;font-size:11px!important;font-weight:500!important;letter-spacing:.06em;text-transform:uppercase;color:var(--dl-fg-muted);border:0!important;background:none!important}.dl-ifgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(210px,1fr));gap:8px}.dl-if{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-height:52px;padding:8px 12px 8px 10px;min-width:0;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);transition:background .15s,border-color .15s}.dl-if:hover{background:var(--dl-soft)}.dl-if:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-if-ic{width:30px;height:30px;border-radius:8px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-if-ic .dl-icon{width:16px;height:16px}.dl-if-main{display:flex;flex-direction:column;min-width:0;flex:1}.dl-if-name{font-size:13.5px;font-weight:500;color:var(--dl-fg);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if-sub{font:11px/16px var(--dl-mono);color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-if.sel{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 9%,transparent)}.dl-if.sel .dl-if-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-if-check{color:var(--dl-accent);display:inline-flex}.dl-if-check .dl-icon{width:16px;height:16px}.dl-if.auto{border-color:color-mix(in srgb,var(--dl-ok) 55%,transparent);background:var(--dl-ok-wash);cursor:default}.dl-if.auto .dl-if-ic{background:color-mix(in srgb,var(--dl-ok) 18%,transparent);color:var(--dl-ok)}.dl-if-badge{display:inline-flex;align-items:center;gap:5px;font-size:10.5px;font-weight:600;letter-spacing:.05em;text-transform:uppercase;flex:0 0 auto}.dl-if-badge.ok{color:var(--dl-ok)}.dl-if.off{cursor:default;opacity:.5}.dl-if.off:hover{background:var(--dl-card)}.dl-if.warn{border-color:color-mix(in srgb,var(--dl-warn) 60%,transparent)}.dl-if-wanctl{gap:10px;align-items:center}.dl-if-wanctl select{max-width:240px}.dl-if-summary{min-width:0;line-height:18px}.dl-warn{color:var(--dl-warn)}.dl-w-ip{width:160px}.dl-dnspick{padding-top:8px;border-top:1px solid var(--dl-line)}.dl-dnspick .dl-row-actions{gap:10px}.dl-note{display:flex;gap:8px;align-items:flex-start;padding:10px 12px;border-radius:10px;font-size:12.5px;line-height:18px;margin:0 0 10px;background:var(--dl-soft)}.dl-note.warn{background:var(--dl-warn-wash, color-mix(in srgb, var(--dl-warn) 14%, transparent))}.dl-note .dl-icon{width:15px;height:15px;flex:0 0 auto;margin-top:1px;color:var(--dl-warn)}.dl-stale{align-self:flex-start;margin-top:4px;font-size:10.5px}.dl-root .cbi-button.dl-btn-warn,.dl-btn-warn.cbi-button{background:var(--dl-warn-wash)!important;color:var(--dl-warn)!important;border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}.dl-root .cbi-button.dl-btn-warn:hover,.dl-btn-warn.cbi-button:hover{background:color-mix(in srgb,var(--dl-warn) 24%,transparent)!important}.dl-btn-warn .dl-icon{color:var(--dl-warn)}.dl-srvtabs{display:flex;flex-wrap:wrap;gap:6px;padding:4px;margin:0 0 20px;border-radius:12px;background:var(--dl-soft);width:fit-content;max-width:100%}.dl-srvtab{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:8px;height:34px;padding:0 14px;border-radius:9px;font-size:13px;color:var(--dl-fg-muted);text-decoration:none!important;white-space:nowrap}.dl-srvtab b{font-weight:500}.dl-srvtab i.dot{width:7px;height:7px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-srvtab i.dot.ok{background:var(--dl-ok);animation:dl-srv-pulse 2s ease-out infinite}.dl-srvtab i.dot.bad{background:var(--dl-bad)}.dl-srvtab i.dot.warn{background:var(--dl-warn)}@keyframes dl-srv-pulse{0%{box-shadow:0 0 color-mix(in srgb,var(--dl-ok) 55%,transparent)}70%,to{box-shadow:0 0 0 6px transparent}}@media(prefers-reduced-motion:reduce){.dl-srvtab i.dot.ok{animation:none}}.dl-srvtab:hover{color:var(--dl-fg);background:var(--dl-soft-hover)}.dl-srvtab.on{background:var(--dl-card);color:var(--dl-fg);box-shadow:0 1px 2px #0000002e,inset 0 0 0 1px var(--dl-line)}.dl-srvtab:focus-visible{outline:2px solid var(--dl-ring);outline-offset:1px}.dl-srvtab.add{color:var(--dl-fg-muted)}.dl-srvtab.add .dl-icon{width:14px;height:14px}.dl-srvhead{display:flex;flex-direction:column;gap:14px;margin:0 0 20px}.dl-srvhead .dl-title-row{display:flex;align-items:center;gap:10px}.dl-srvhead .dl-h1{margin:0!important}.dl-metrics.compact .dl-metric{padding:14px 18px}.dl-metrics.compact .dl-metric-value{display:flex;align-items:center;gap:6px;font-size:18px;line-height:26px;min-width:0}.dl-metrics.compact .dl-metric-value>span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-metrics.compact .dl-metric-value .dl-mono{font-size:15px}.dl-metrics.compact .cbi-button{flex:0 0 auto}.dl-srvsections{margin:0 0 16px}.dl-srvbody>.dl-setsec,.dl-srvbody>.dl-ifcards{margin:0}.dl-srvbody .dl-ifcards{margin:0}.dl-metric-ic{display:inline-flex;align-items:center;gap:8px;font-size:16px}.dl-metric-ic .dl-icon{width:18px;height:18px;color:var(--dl-accent)}.dl-keyrow{display:inline-flex;align-items:center;gap:8px;min-width:0}.dl-keyrow code{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:12px;background:none;padding:0}.dl-params{border:1px solid var(--dl-line);border-radius:12px;background:var(--dl-card)}.dl-params>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:10px 14px;font-size:13px;color:var(--dl-fg);user-select:none}.dl-params>summary::-webkit-details-marker{display:none}.dl-params>summary>.dl-icon-wrap{display:inline-flex;color:var(--dl-fg-muted);transition:transform .15s}.dl-params>summary>.dl-icon-wrap .dl-icon{width:15px;height:15px}.dl-params[open]>summary>.dl-icon-wrap{transform:rotate(90deg)}.dl-params>summary:focus{outline:none}.dl-params>summary:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px;border-radius:12px}.dl-params>summary:hover{background:var(--dl-soft);border-radius:12px}.dl-pcount{font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:10px;padding:4px 14px 14px}.dl-pgroup{display:flex;flex-direction:column;gap:6px;padding:12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-pgroup-head{display:flex;align-items:center;gap:8px;font-size:13px}.dl-pgroup-head b{font-weight:500}.dl-pgroup-head .dl-icon{width:14px;height:14px;color:var(--dl-fg-muted)}.dl-pgroup p{margin:0!important;font-size:12px;line-height:17px;color:var(--dl-fg-muted)}.dl-pvals{display:flex;flex-wrap:wrap;gap:4px;margin-top:2px}.dl-pv{display:inline-flex;align-items:stretch;max-width:100%;border-radius:6px;overflow:hidden;font:500 11.5px/22px var(--dl-mono);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pv i{font-style:normal;padding:0 6px;background:var(--dl-card);color:var(--dl-fg-faint)}.dl-pv b{font-weight:500;padding:0 7px;color:var(--dl-fg);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}";var Fa=".dl-methods{display:grid;grid-template-columns:repeat(auto-fit,minmax(210px,1fr));gap:10px}.dl-method{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:10px;padding:14px;border-radius:12px;border:1px solid var(--dl-line);background:var(--dl-card);transition:border-color .15s,background .15s;min-width:0}.dl-method:hover{background:var(--dl-soft)}.dl-method:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-method.on{border-color:var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 8%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-method.off{cursor:not-allowed;opacity:.55}.dl-method.off:hover{background:var(--dl-card)}.dl-method-head{display:flex;flex-wrap:wrap;align-items:center;gap:8px 10px}.dl-method-head .dl-pill{flex:none}.dl-method-head b{font-weight:500;font-size:14.5px;flex:1}.dl-method-ic{width:32px;height:32px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);flex:0 0 auto}.dl-method-ic .dl-icon{width:17px;height:17px}.dl-method.on .dl-method-ic{background:color-mix(in srgb,var(--dl-accent) 18%,transparent);color:var(--dl-accent)}.dl-method p{margin:0!important;font-size:12.5px;line-height:18px;color:var(--dl-fg-muted);flex:1}.dl-method-meters{display:flex;gap:16px}.dl-dots{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-dots-row{display:inline-flex;gap:3px}.dl-dots-row i{width:6px;height:6px;border-radius:50%;background:var(--dl-line)}.dl-dots-row i.on{background:var(--dl-fg-muted)}.dl-method.on .dl-dots-row i.on{background:var(--dl-accent)}.dl-method-foot{display:flex;align-items:center;gap:6px;font-size:11.5px;color:var(--dl-fg-faint);padding-top:8px;border-top:1px solid var(--dl-line)}.dl-method-foot .dl-icon{width:13px;height:13px;flex:0 0 auto}.dl-method.off .dl-method-foot{color:var(--dl-warn)}.dl-ibadge{display:inline-flex;align-items:center;gap:3px;height:22px;padding:0 6px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);flex:0 0 auto}.dl-ibadge .dl-icon{width:13px;height:13px}.dl-ibadge.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-ibadge.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-access{display:inline-flex;gap:4px;flex:0 0 auto}.dl-ibadge.lan{background:color-mix(in srgb,var(--dl-accent) 16%,transparent);color:var(--dl-accent)}.dl-ibadge.inet{background:var(--dl-ok-wash);color:var(--dl-ok)}";var Ka=".dl-addrbar{display:inline-flex;align-items:stretch;flex-wrap:nowrap;max-width:100%;margin-top:4px;border:1px solid var(--dl-line);border-radius:10px;background:var(--dl-card);overflow:hidden}.dl-addrbar-seg{all:unset;box-sizing:border-box;display:inline-flex;align-items:center;gap:7px;padding:6px 12px;font-size:13px;color:var(--dl-fg-muted);border-left:1px solid var(--dl-line);white-space:nowrap;min-width:0}.dl-addrbar-seg:first-child{border-left:0}.dl-addrbar-seg .dl-icon{width:14px;height:14px;color:var(--dl-fg-faint);flex:0 0 auto}.dl-addrbar-seg .dl-mono{font-size:12.5px}.dl-addrbar-seg.main{cursor:pointer;color:var(--dl-fg)}.dl-addrbar-seg.main:hover{background:var(--dl-soft)}.dl-addrbar-seg.main:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-addrbar-seg.main>.dl-icon-wrap:last-child .dl-icon{opacity:.7}.dl-bento{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));grid-template-rows:auto auto;gap:10px;margin:0 0 20px}.dl-person-devices{margin-bottom:16px}.dl-person-head{display:flex;flex-direction:column;margin:0 0 20px}.dl-person-head>.dl-pagehead{margin-bottom:0;align-items:flex-start}.dl-pnote{all:unset;box-sizing:border-box;cursor:pointer;align-self:flex-start;display:inline-flex;align-items:flex-start;gap:6px;margin:10px 0 0 62px;max-width:60ch;padding:6px 12px 6px 10px;border-radius:10px;font-size:13px;line-height:18px;white-space:pre-line;background:var(--dl-soft);color:var(--dl-fg);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-pnote:hover{background:var(--dl-soft-hover)}.dl-pnote .dl-icon{width:14px;height:14px;flex:none;margin-top:2px;color:var(--dl-fg-muted)}.dl-note-input{width:100%;box-sizing:border-box;min-height:80px;resize:vertical}.dl-dcard-trend{display:flex;align-items:flex-end;gap:12px;min-width:0}.dl-dcard-trend>.dl-stack{flex:none}.dl-dcard-trend b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dbars{flex:1;min-width:0;height:32px;display:flex;align-items:flex-end;gap:2px}.dl-dbars i{flex:1;min-width:0;border-radius:2px;background:var(--dl-chart-1);opacity:.55}.dl-dbars i.zero{background:var(--dl-track);opacity:1}.dl-dbars i.hi{opacity:1}.dl-dbars i:hover{opacity:1;filter:brightness(1.2)}.dl-datechip{position:relative;display:inline-flex}.dl-date-hidden{position:absolute!important;left:0;bottom:0;width:1px!important;min-width:0!important;height:1px!important;opacity:0;pointer-events:none;border:0!important;padding:0!important;margin:0!important}.dl-chipbtn .dl-icon{width:13px;height:13px}.dl-chipbtn:has(.dl-icon){display:inline-flex;align-items:center;gap:5px}.dl-places{display:flex;align-items:center;gap:12px;padding:12px 16px;border:1px solid var(--dl-line);border-radius:var(--dl-radius);background:var(--dl-card);font-size:14px}.dl-places>.dl-icon{width:18px;height:18px;color:var(--dl-fg-muted);flex:none}.dl-person-live{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:10px}.dl-person-live .dl-bento-head{flex-wrap:nowrap;white-space:nowrap;min-width:0}.dl-person-live .dl-bento-head>*{min-width:0;overflow:hidden;text-overflow:ellipsis}.dl-person-live .dl-bento-head>:first-child{flex:none}.dl-person-live.solo{grid-template-columns:minmax(0,1fr)}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child{flex-wrap:wrap;row-gap:2px}.dl-person-live:not(.solo) .dl-bento-tile.month>.dl-bento-head:first-child>.dl-sub{flex-basis:100%}.dl-person-live>.dl-bento-tile,.dl-person-live>.dl-bento-tile.month{grid-column:auto;grid-row:auto}@media(max-width:760px){.dl-person-live{grid-template-columns:minmax(0,1fr)}}.dl-bento-tile{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);padding:14px 16px;display:flex;flex-direction:column;gap:10px;min-width:0;box-shadow:var(--dl-shadow)}.dl-bento-tile.month{grid-column:1 / -1}.dl-onl-count{font-size:13px;line-height:22px;min-width:22px;padding:0 8px;border-radius:999px;background:var(--dl-soft);text-align:center;font-weight:500;font-variant-numeric:tabular-nums}.dl-onl-count.none{color:var(--dl-fg-faint)}.dl-onl-row{flex:1;display:flex;align-items:center;justify-content:center;gap:12px;min-width:0}.dl-onl-p{display:flex;flex-direction:column;align-items:center;gap:5px;width:104px;min-width:0;padding:6px 2px;border-radius:12px;color:var(--dl-fg)!important;text-decoration:none!important}.dl-onl-p:hover{background:var(--dl-soft)}.dl-onl-av{position:relative;width:42px;height:42px;border-radius:50%;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;font-size:13px;font-weight:500;box-shadow:0 0 0 2px var(--dl-ok)}.dl-onl-p.more .dl-onl-av{box-shadow:0 0 0 1px var(--dl-line);color:var(--dl-fg-muted)}.dl-onl-dev{position:absolute;right:-5px;bottom:-5px;width:20px;height:20px;border-radius:7px;background:var(--dl-card);box-shadow:0 0 0 1.5px var(--dl-card);display:inline-flex;align-items:center;justify-content:center;font-size:10px;color:var(--dl-fg-muted)}.dl-onl-dev .dl-icon-wrap{display:inline-flex}.dl-onl-dev .dl-icon{width:12px;height:12px}.dl-onl-name{font-size:12.5px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-p .dl-sub{font-size:11px;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-onl-row.grid{flex-wrap:wrap;align-content:center;gap:10px 8px;max-height:108px;overflow:hidden}.dl-onl-p.sm{width:auto;padding:4px}.dl-onl-p.sm .dl-onl-av{width:36px;height:36px;font-size:11.5px}.dl-onl-meta{display:inline-flex;align-items:center;gap:3px;font-size:11px;color:var(--dl-fg-faint);max-width:100%;white-space:nowrap;overflow:hidden}.dl-onl-meta .dl-icon-wrap{display:inline-flex}.dl-onl-meta .dl-icon{width:12px;height:12px}.dl-onl-av.sm{width:34px;height:34px;font-size:11.5px}.dl-tip-float:has(.dl-hc){padding:0;white-space:normal;border-radius:16px}.dl-hc{width:280px;padding:14px;display:flex;flex-direction:column;gap:10px}.dl-hc-head{display:flex;align-items:center;gap:10px}.dl-hc-head .dl-stack{flex:1;min-width:0}.dl-hc-head b{font-size:14px;font-weight:500}.dl-hc-since{font-size:11.5px;color:var(--dl-ok)}.dl-hc-reach{display:inline-flex;gap:4px}.dl-hc-speed{border-radius:12px;background:var(--dl-soft);padding:10px 12px;display:flex;flex-direction:column;gap:6px}.dl-hc-speed-row{display:flex;align-items:baseline;gap:12px;font-size:13px;font-variant-numeric:tabular-nums}.dl-hc-chart{display:block;width:100%;height:30px}.dl-hc-chart .area{fill:color-mix(in srgb,var(--dl-chart-1) 16%,transparent)}.dl-hc-chart .dn{fill:none;stroke:var(--dl-chart-1);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-hc-chart .up{fill:none;stroke:var(--dl-ok);stroke-width:1.2;vector-effect:non-scaling-stroke}.dl-hc-devs{display:flex;flex-wrap:wrap;gap:6px}.dl-hc-dev{display:inline-flex;align-items:center;gap:5px;height:24px;padding:0 9px;border-radius:999px;background:var(--dl-soft);font-size:11.5px}.dl-hc-dev .dl-icon-wrap{display:inline-flex}.dl-hc-dev .dl-icon{width:12px;height:12px;color:var(--dl-fg-muted)}.dl-hc-foot{display:flex;align-items:center;gap:8px;font-size:11.5px}.dl-disg-id{display:flex;align-items:center;gap:10px}.dl-disg-id b{font-size:16px;font-weight:500}.dl-disg-ic{width:36px;height:36px;border-radius:11px;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-disg-ic .dl-icon-wrap{display:inline-flex}.dl-disg-ic .dl-icon{width:18px;height:18px}.dl-disg-meters{display:grid;grid-template-columns:auto 1fr;gap:6px 10px;align-items:center;font-size:12px;color:var(--dl-fg-muted)}.dl-segs{display:inline-flex;gap:3px}.dl-segs i{width:18px;height:5px;border-radius:3px;background:var(--dl-track)}.dl-segs.acc i.on{background:var(--dl-accent)}.dl-segs.ok i.on{background:var(--dl-ok)}.dl-disg-chips{margin-top:auto;display:flex;flex-wrap:wrap;gap:5px}.dl-disg-chips span{font:11px/20px var(--dl-mono);padding:0 8px;border-radius:999px;background:var(--dl-soft);color:var(--dl-fg-muted);white-space:nowrap}.dl-onl-empty{flex:1;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:4px;font-size:13px;text-align:center}.dl-bento-head{display:flex;align-items:center;justify-content:space-between;gap:10px;min-width:0}.dl-bento-head.start{justify-content:flex-start}.dl-bento-big{font-family:inherit;font-size:28px;line-height:34px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-bento-big small{font-size:13px;font-weight:400;color:var(--dl-fg-faint);letter-spacing:0}.dl-avstack{display:inline-flex}.dl-avstack .dl-avatar{margin-left:-7px;box-shadow:0 0 0 2px var(--dl-card)}.dl-avstack .dl-avatar:first-child{margin-left:0}.dl-avatar.more{background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-bento-list{display:flex;flex-direction:column;gap:2px}.dl-bento-row{display:flex;align-items:center;gap:10px;padding:8px;margin:0 -8px;border-radius:10px;color:var(--dl-fg)!important;text-decoration:none!important;min-width:0;transition:background .12s}.dl-bento-row:hover{background:var(--dl-soft)}.dl-bento-row:hover b{text-decoration:none}.dl-bento-row:focus-visible{outline:2px solid var(--dl-ring);outline-offset:-2px}.dl-bento-row-main{display:flex;flex-direction:column;gap:1px;flex:1;min-width:0}.dl-bento-row-main b{font-weight:500;font-size:13.5px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row-main .dl-sub{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-bento-row.off b{color:var(--dl-fg-muted);font-weight:400}.dl-bento-row-val{display:flex;flex-direction:column;align-items:flex-end;font-size:13px;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-bento-row-val small{font-size:11px;color:var(--dl-fg-faint)}.dl-bento-sep{font-size:11px;color:var(--dl-fg-faint);padding:12px 0 4px}.dl-bento-devs{display:inline-flex;gap:3px;color:var(--dl-fg-faint)}.dl-bento-devs .dl-icon{width:13px;height:13px}.dl-bento-devs .on{color:var(--dl-ok)}.dl-bento-foot{display:flex;align-items:center;gap:10px;margin-top:auto;padding-top:10px;border-top:1px solid var(--dl-line);color:var(--dl-fg)!important;text-decoration:none!important}.dl-bento-foot.split,.dl-bento-foot.end{justify-content:space-between}.dl-bento-foot.end>a:only-child{margin-left:auto}.dl-bento-empty{display:flex;align-items:center;gap:10px;padding:14px 0;font-size:13.5px;color:var(--dl-fg-muted)}.dl-bento-empty .dl-icon{width:18px;height:18px}.dl-split{display:flex;height:6px;border-radius:3px;overflow:hidden;background:var(--dl-soft)}.dl-split i{display:block;height:100%}.dl-split i.dn{background:var(--dl-accent)}.dl-split i.up{background:var(--dl-ok)}.dl-dn{color:var(--dl-accent)}.dl-up{color:var(--dl-ok)}.dl-bento-method{display:flex;align-items:center;gap:8px;font-size:18px;font-weight:500}.dl-bento-method .dl-icon{width:20px;height:20px;color:var(--dl-accent)}.dl-meter{display:inline-flex;gap:3px}.dl-meter i{width:16px;height:4px;border-radius:2px;background:var(--dl-line)}.dl-meter i.on{background:var(--dl-accent)}.dl-bento-total{font-size:16px;font-weight:500;margin-left:8px}.dl-bento-bars{display:flex;align-items:flex-end;gap:3px;height:54px}.dl-bento-bars i{flex:1;min-width:0;border-radius:3px 3px 0 0;background:var(--dl-soft-hover);transition:background .15s}.dl-bento-bars i.future{height:4px;background:var(--dl-soft)}.dl-bento-bars i:hover{background:var(--dl-fg-faint)}.dl-bento-bars i.hi{background:var(--dl-accent)}@media(max-width:700px){.dl-addrbar{flex-wrap:wrap}}@media(max-width:900px){.dl-bento{grid-template-columns:minmax(0,1fr) minmax(0,1fr)}.dl-bento-tile.online{grid-column:span 2}}@media(max-width:560px){.dl-bento{grid-template-columns:minmax(0,1fr)}.dl-bento-tile.online,.dl-bento-tile.month{grid-column:auto}}.dl-srvpagehead{display:flex;flex-direction:column;align-items:flex-start;gap:10px;margin:0 0 20px}.dl-srvpagehead>.dl-title-row{display:flex;align-items:center;gap:10px;width:100%;flex-wrap:wrap}.dl-srvpagehead .dl-actions{margin:0;flex-wrap:wrap}.dl-toolbar-end{display:flex;align-items:center;gap:8px;margin-left:auto;flex-wrap:nowrap;min-width:0}@media(max-width:640px){.dl-toolbar-end{flex-wrap:wrap;width:100%}}.dl-notices{margin:0 0 16px}.dl-notices .dl-need-row .dl-sub{overflow-wrap:anywhere}.dl-notices-more{font-size:13px;color:var(--dl-fg-muted);text-decoration:none}.dl-notices-more:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-speed-cols{display:grid;grid-template-columns:1fr 1fr;gap:12px}.dl-speed-col{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-speed-val{font-size:20px;line-height:26px;font-weight:500;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-speed-today{display:flex;justify-content:space-between;gap:10px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;font-variant-numeric:tabular-nums}.dl-speed-today b{font-weight:500;color:var(--dl-fg)}.dl-speed-chart{display:block;width:100%;height:44px}.dl-speed-chart .area{fill:color-mix(in srgb,var(--dl-accent) 16%,transparent)}.dl-speed-chart .line{fill:none;stroke:var(--dl-accent);stroke-width:1.5;vector-effect:non-scaling-stroke}.dl-speed-chart .line.up{stroke:var(--dl-ok);stroke-width:1.2;opacity:.85}.dl-speed-wait{height:44px;display:flex;flex-direction:column;justify-content:flex-end;gap:6px;font-size:11px;color:var(--dl-fg-faint)}.dl-speed-wait i{display:block;height:1px;background:var(--dl-line);order:2}.dl-speed-val.off{color:var(--dl-fg-faint)}.dl-fld{display:flex;flex-direction:column;gap:8px;margin:0 0 16px}.dl-fld-label{font-size:13px;font-weight:500;color:var(--dl-fg)}.dl-fld .cbi-input-text{width:100%;box-sizing:border-box}.dl-kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.dl-kinds button{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;border-radius:10px;border:1px solid var(--dl-line);color:var(--dl-fg-muted);font-size:12px;font-weight:500;text-align:center;min-width:0}.dl-kinds button .dl-icon{width:20px;height:20px}.dl-kinds button:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-kinds button:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-kinds button.on{border-color:var(--dl-accent);color:var(--dl-fg);background:color-mix(in srgb,var(--dl-accent) 10%,transparent);box-shadow:inset 0 0 0 1px var(--dl-accent)}.dl-kinds button.on .dl-icon{color:var(--dl-accent)}.dl-choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:8px}.dl-choice{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;gap:4px;padding:12px 14px;border-radius:12px;background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line);transition:background .15s,box-shadow .15s}.dl-choice:hover{background:var(--dl-soft)}.dl-choice:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-choice.selected{box-shadow:inset 0 0 0 2px var(--dl-accent);background:var(--accent-a10, color-mix(in srgb, var(--dl-accent) 8%, transparent))}.dl-choice-title{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg)}.dl-choice-text{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-attn-item>.cbi-button{margin-left:auto;flex:none;align-self:center}";var Ja='.dl-steps{display:flex;align-items:center;gap:8px;margin:0 0 16px;flex-wrap:wrap}.dl-step{display:flex;align-items:center;gap:8px;font-size:14px;font-weight:500;color:var(--dl-fg-faint)}.dl-step b{display:inline-flex;width:24px;height:24px;align-items:center;justify-content:center;border-radius:50%;background:var(--dl-soft);font-size:12px;font-weight:600}.dl-step.current{color:var(--dl-fg)}.dl-step.current b{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-step.done{color:var(--dl-fg-muted)}.dl-step.done b{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-step+.dl-step:before{content:"";width:24px;height:1px;background:var(--dl-line)}.dl-wizard .dl-panel>div{display:flex;flex-direction:column;gap:16px}.dl-wizard .dl-panel>div>p{margin:0!important;color:var(--dl-fg-muted)}.dl-wizard .dl-panel>div>.cbi-value{margin:0}.dl-wizard h4{font-size:14px;font-weight:500;margin:8px 0 -6px!important}.dl-wizard h4:first-child{margin-top:0!important}.dl-modal .cbi-tabmenu{margin-bottom:16px}.dl-invite{display:grid;grid-template-columns:250px minmax(0,1fr);gap:22px;align-items:start}.dl-invite img{display:block;width:100%;border-radius:18px;box-shadow:0 0 0 1px var(--dl-line)}.dl-invite-side{display:flex;flex-direction:column;gap:14px;min-width:0}.dl-invite-side>p{margin:0!important}.dl-invite-link{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;min-width:0;padding:11px 14px;border-radius:12px;background:var(--dl-soft);font:13px/18px var(--dl-mono);color:var(--dl-fg)}.dl-invite-link>span:first-child{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-invite-link>.dl-icon-wrap{flex:none;display:inline-flex}.dl-invite-link .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted);flex:none}.dl-invite-link:hover{background:var(--dl-soft-hover)}.dl-invite-link.alt{padding:8px 14px;font-size:12px;color:var(--dl-fg-muted)}.dl-invite-link>.dl-pill{flex:none}.dl-invite-steps{margin:0;padding-left:20px;list-style:decimal!important;font-size:13px;line-height:24px;color:var(--dl-fg-muted)}.dl-invite-steps b{color:var(--dl-fg);font-weight:500}.dl-invite-steps li{display:list-item!important;list-style:inherit!important;padding-left:4px}.dl-invite-actions{display:flex;gap:8px;flex-wrap:wrap}.modal:has(.dl-modal.wide){max-width:min(760px,94vw)!important;width:100%!important}@media(max-width:640px){.dl-invite{grid-template-columns:minmax(0,1fr)}.dl-invite img{max-width:260px;margin:0 auto}}.dl-toasts{position:fixed;left:50%;bottom:max(24px,env(safe-area-inset-bottom));transform:translate(-50%);z-index:100000;display:flex;flex-direction:column;align-items:center;gap:8px;pointer-events:none}.dl-toast{pointer-events:auto;display:inline-flex;align-items:center;gap:8px;max-width:min(520px,92vw);padding:10px 16px;border-radius:999px;background:var(--dl-fg);color:var(--dl-card);font-size:13px;line-height:18px;box-shadow:0 10px 30px #0000004d;opacity:0;transform:translateY(12px);transition:opacity .18s,transform .18s}.dl-toast.show{opacity:1;transform:none}.dl-toast .dl-icon-wrap{display:inline-flex}.dl-toast .dl-icon{width:15px;height:15px}.dl-toast.success .dl-icon{color:var(--dl-ok)}.dl-toast.error{background:var(--dl-bad);color:#fff}.dl-toast.error .dl-icon{color:#fff}.dl-toast.warning{background:var(--dl-warn);color:#111}.dl-toast.warning .dl-icon{color:#111}.dl-toast button{all:unset;cursor:pointer;display:inline-flex;margin-left:4px;opacity:.8}.dl-toast button:hover{opacity:1}';var Va=".dl-setblock{display:flex;flex-direction:column;gap:8px;margin:0}.dl-addr-opts{display:flex;flex-direction:column;gap:6px}.dl-addr-opt{all:unset;box-sizing:border-box;cursor:pointer;display:grid;grid-template-columns:16px minmax(0,1fr) auto;gap:12px;align-items:center;padding:10px 14px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line);min-width:0}.dl-addr-opt:hover{background:var(--dl-soft)}.dl-addr-opt.on{box-shadow:inset 0 0 0 1.5px var(--dl-accent);background:color-mix(in srgb,var(--dl-accent) 7%,transparent)}.dl-addr-opt .dl-mono{font-size:13px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-addr-opt .dl-stack{min-width:0}.dl-addr-opt input{width:100%}.dl-addr-opt.other{cursor:default}.dl-addr-opt.other:hover{background:none}.dl-addr-opt.other input{width:100%}.dl-addr-check{width:16px;height:16px;border-radius:5px;box-shadow:inset 0 0 0 1.5px var(--dl-fg-faint);display:inline-flex;align-items:center;justify-content:center}.dl-addr-check .dl-icon-wrap{display:inline-flex}.dl-addr-check .dl-icon{width:12px;height:12px}.dl-addr-opt.on .dl-addr-check{background:var(--dl-accent);box-shadow:none;color:#fff}.dl-addr-opt.other .dl-addr-check{box-shadow:none;color:var(--dl-fg-muted)}.dl-addr-warn{display:inline-flex;align-items:center;gap:5px;font-size:12px;line-height:17px;color:var(--dl-warn)}.dl-addr-warn .dl-icon-wrap{display:inline-flex}.dl-addr-warn .dl-icon{width:13px;height:13px}.dl-pill.info{background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-links{border-radius:12px;background:var(--dl-soft);overflow:hidden}.dl-link-row{display:grid;grid-template-columns:18px minmax(0,1fr) auto;gap:10px;align-items:center;padding:11px 14px}.dl-link-row+.dl-link-row{border-top:1px solid var(--dl-line)}.dl-link-ic{display:inline-flex}.dl-link-ic .dl-icon{width:15px;height:15px}.dl-link-ic.ok .dl-icon{color:var(--dl-ok)}.dl-link-ic.warn .dl-icon{color:var(--dl-warn)}.dl-link-url{font-size:13px;color:var(--dl-fg-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-link-url b{font-weight:500;color:var(--dl-accent)}@media(max-width:640px){.dl-link-url,.dl-addr-opt .dl-mono,.dl-filecard .dl-ellipsis,.dl-invite-link>span:first-child{white-space:normal;overflow-wrap:anywhere}}.dl-ready-sum{display:flex;align-items:center;gap:12px;padding:12px 14px;border-radius:12px}.dl-ready-sum>.dl-icon-wrap{display:inline-flex}.dl-ready-sum>.dl-icon-wrap .dl-icon{width:18px;height:18px}.dl-ready-sum .dl-stack{flex:1;min-width:0}.dl-ready-sum b{font-weight:500;font-size:13px}.dl-ready-sum.ok{background:var(--dl-ok-wash)}.dl-ready-sum.ok b,.dl-ready-sum.ok .dl-icon{color:var(--dl-ok)}.dl-ready-sum.warn{background:var(--dl-warn-wash)}.dl-ready-sum.warn b,.dl-ready-sum.warn .dl-icon{color:var(--dl-warn)}.dl-ready-sum.error{background:var(--dl-bad-wash)}.dl-ready-sum.error b,.dl-ready-sum.error .dl-icon{color:var(--dl-bad)}.dl-check-chip{display:inline-flex;align-items:center;gap:5px;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;color:var(--dl-fg-muted)}.dl-check-chip .dl-icon-wrap{display:inline-flex}.dl-check-chip .dl-icon{width:13px;height:13px;color:var(--dl-ok)}.dl-check-chip.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-chip.warn .dl-icon{color:var(--dl-warn)}.dl-check-chip.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-ready-details{display:flex;flex-direction:column;gap:8px;padding:4px 2px}.dl-ready-details[hidden]{display:none}.dl-ready-item{display:flex;align-items:flex-start;gap:8px;font-size:13px;line-height:18px;min-width:0}.dl-ready-item .dl-icon-wrap{display:inline-flex;margin-top:1px}.dl-ready-item .dl-icon{width:15px;height:15px}.dl-ready-item.ok .dl-icon{color:var(--dl-ok)}.dl-ready-item.warn .dl-icon{color:var(--dl-warn)}.dl-ready-item.error .dl-icon{color:var(--dl-bad)}.dl-params-body{display:flex;flex-direction:column;gap:14px;padding:6px 14px 14px}.dl-params-body>.dl-setrow{margin:0;padding:0}.dl-pgrid.flush{padding:0;grid-template-columns:repeat(2,minmax(0,1fr))}@media(max-width:640px){.dl-pgrid.flush{grid-template-columns:minmax(0,1fr)}}.dl-qr-pane{display:flex;flex-direction:column;align-items:center;gap:8px;text-align:center}.dl-qr{width:min(280px,72vw);aspect-ratio:1;background:#fff;padding:8px;border-radius:12px;box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-qr svg{display:block;width:100%;height:100%}.dl-filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--dl-soft);min-width:0}.dl-filecard>.dl-stack{flex:1;min-width:0}.dl-filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--dl-mono);color:var(--dl-fg-muted);background:var(--dl-card);box-shadow:inset 0 0 0 1px var(--dl-line)}.dl-params>.dl-conf{margin:0;border-top:1px solid var(--dl-line);border-radius:0 0 12px 12px;background:none}.dl-conf-sec{color:var(--dl-accent)}.dl-conf-k{color:var(--dl-fg-faint)}.dl-conf-mask{padding:0 6px;border-radius:4px;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-params>summary .dl-chipbtn{height:26px;font-size:12px}.dl-conf{white-space:pre-wrap;word-break:break-all;max-height:22em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:0;padding:12px;border-radius:12px;background:var(--dl-soft)}.dl-key{width:100%;box-sizing:border-box;font-family:var(--dl-mono);font-size:12px;word-break:break-all;min-height:7em}.dl-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin:12px 0 0}.dl-link-box{display:flex;gap:6px;align-items:center;flex-wrap:wrap}.dl-link-box input{flex:1 1 18em;min-width:0;font-family:var(--dl-mono);font-size:12px}.dl-hint{font-size:12px;line-height:16px;color:var(--dl-fg-muted);margin:8px 0}.dl-divider{border:0;border-top:1px solid var(--dl-line);margin:16px 0}";var Ya=".dl-checks{list-style:none;margin:0;padding:0}.dl-checks li{display:flex;align-items:center;gap:12px;padding:12px 0;border-top:1px solid var(--dl-line)}.dl-checks li:first-child{border-top:0;padding-top:0}.dl-checks li:last-child{padding-bottom:0}.dl-check-icon{flex:0 0 auto;width:28px;height:28px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center}.dl-check-icon .dl-icon{width:14px;height:14px}.dl-check-icon.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-check-icon.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-check-icon.error{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-check-icon.skip{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-check-body{flex:1;min-width:0}.dl-check-title{font-size:14px;line-height:20px;font-weight:500}.dl-check-detail{font-size:12px;line-height:16px;color:var(--dl-fg-muted);overflow-wrap:anywhere}.dl-check-repaired{margin-top:2px;font-size:12px;line-height:16px;color:var(--dl-warn)}.dl-wd{margin:0 0 16px;display:flex;flex-direction:column;gap:14px}.dl-wd-head{display:flex;align-items:center;gap:12px;min-width:0}.dl-wd-head>.dl-stack{min-width:0}.dl-wd-title{font-size:16px;line-height:24px;font-weight:500}.dl-wd-tile{flex:none;width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-wd-tile.off{background:var(--dl-soft);color:var(--dl-fg-faint)}.dl-wd-tile .dl-icon{width:18px;height:18px}.dl-wd-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 16px;padding-top:14px;border-top:1px solid var(--dl-line)}.dl-wd-chips{display:flex;flex-wrap:wrap;gap:6px;flex:1 1 auto;min-width:0}.dl-wd-chips .dl-check-chip.error .dl-icon{color:var(--dl-bad)}.dl-warn-text{color:var(--dl-warn)!important}.dl-health-cols{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(440px,100%),1fr));gap:16px;align-items:start}.dl-health-cols>.dl-panel{margin:0;min-width:0}.dl-recent{display:flex;flex-direction:column}.dl-recent .dl-panel-head a{font-size:13px}.dl-recent-empty{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:32px 16px;color:var(--dl-fg-muted);font-size:13px;border-top:1px solid var(--dl-line)}.dl-loading{margin:0;font-size:13px}.dl-diag-tabs{margin:0 0 16px}.dl-row.dl-slog-row{align-items:baseline}.dl-slog-row .dl-ev-tile{align-self:flex-start;margin-top:-1px}.dl-slog-row.has-detail{cursor:pointer}.dl-row.dl-slog-row.has-detail:hover{background:color-mix(in srgb,var(--sys) 11%,transparent)}.dl-slog-more{display:inline-flex;vertical-align:-2px;margin-left:6px;color:var(--dl-fg-faint);transform:rotate(90deg);transition:transform .15s}.dl-slog-more .dl-icon{width:14px;height:14px}.dl-slog-more.open{transform:rotate(-90deg)}.dl-slog-detail{margin:8px 0 2px;padding:8px 10px;border-radius:8px;background:var(--dl-soft);font-family:var(--dl-mono);font-size:12px;line-height:17px;white-space:pre-wrap;overflow-wrap:anywhere;color:var(--dl-fg-muted);cursor:text}.dl-table{width:100%;border-collapse:collapse;font-size:14px;line-height:20px}.dl-table th{text-align:left;font-weight:500;color:var(--dl-fg-faint);padding:0 8px 8px;border-bottom:1px solid var(--dl-line)}.dl-table td{padding:10px 8px;border-bottom:1px solid var(--dl-line);vertical-align:middle}.dl-table th:first-child,.dl-table td:first-child{padding-left:0}.dl-table th:last-child,.dl-table td:last-child{padding-right:0}.dl-table tr:last-child td{border-bottom:0}.dl-table .dl-right{text-align:right;white-space:nowrap}.dl-log{max-height:18em;overflow:auto;font-family:var(--dl-mono);font-size:12px;line-height:18px;margin:8px 0 0;padding:12px;white-space:pre-wrap;border-radius:12px;background:var(--dl-soft)}";var Za=".dl-pagehead{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap;margin:0 0 20px}.dl-h1{margin:0!important;padding:0!important;font-size:24px!important;line-height:32px!important;font-weight:500!important;border:0!important}.dl-title-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}.dl-stack{display:flex;flex-direction:column;gap:2px;min-width:0}.dl-stack.gap4{gap:4px}.dl-stack.gap8{gap:8px}.dl-sub{font-size:12px;line-height:16px;color:var(--dl-fg-muted)}.dl-ok{color:var(--dl-ok)}.dl-warn{color:var(--dl-warn)}.dl-bad{color:var(--dl-bad)}.dl-icon-only{width:auto!important;min-width:0!important;aspect-ratio:1 / 1;padding:0!important;justify-content:center;display:inline-flex!important;align-items:center;border-radius:999px!important}.dl-panel.flush{padding:0;overflow:hidden}.dl-panel-head.pad{padding:16px 16px 12px;margin:0}.dl-col{display:flex;flex-direction:column;gap:16px;min-width:0}.dl-col>.dl-panel,.dl-col>section.dl-panel{margin:0}.dl-crumbs{display:flex;gap:8px;align-items:center;font-size:14px;margin:0 0 16px;color:var(--dl-fg-faint)}.dl-crumbs a{color:var(--dl-fg-faint)}.dl-crumbs a:hover{color:var(--dl-fg)}.dl-crumbs span:last-child{color:var(--dl-fg)}.dl-metrics{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);margin:0 0 16px;box-shadow:var(--dl-shadow)}.dl-metric{display:flex;flex-direction:column;gap:4px;padding:16px 20px;min-width:0}.dl-metric+.dl-metric{border-left:1px solid var(--dl-line)}.dl-metric-label{font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-metric-value{font-size:28px;line-height:36px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums;white-space:nowrap}.dl-metric-value .dl-faint{font-size:16px}.dl-metric-sub{font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}@media(max-width:900px){.dl-metrics{grid-template-columns:repeat(2,minmax(0,1fr))}.dl-metric:nth-child(3){border-left:0}.dl-metric:nth-child(n+3){border-top:1px solid var(--dl-line)}}.dl-seg{display:inline-flex;gap:2px;padding:3px;border-radius:999px;background:var(--dl-soft);flex-wrap:wrap}.dl-seg button{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;padding:4px 12px;border-radius:999px;font-size:13px;font-weight:500;color:var(--dl-fg-muted);white-space:nowrap}.dl-seg button:hover{color:var(--dl-fg)}.dl-seg button.on{background:var(--dl-soft-hover);color:var(--dl-fg)}.dl-seg.dl-srvsections{flex-wrap:nowrap;max-width:100%;overflow-x:auto;scrollbar-width:none}.dl-seg.dl-srvsections::-webkit-scrollbar{display:none}.dl-seg.dl-srvsections button{flex:none;white-space:nowrap}.dl-seg button:focus-visible{outline:2px solid var(--dl-ring)}.dl-seg button b{font-weight:500;font-size:11px;padding:0 6px;border-radius:999px;background:var(--dl-soft)}.dl-seg button b.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-seg.sm button{padding:2px 9px;font-size:11px}.dl-seg.wide{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));border-radius:12px;padding:4px}.dl-seg.wide button{flex-direction:column;justify-content:center;padding:8px 6px;border-radius:9px;gap:3px}.dl-seg.wide button.on{background:var(--dl-primary);color:var(--dl-primary-fg)}";var Qa=`.dl-geomap{position:relative;border-top:1px solid var(--dl-line);background:transparent}.dl-map-status{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;color:var(--dl-fg-muted);font-size:13px;z-index:1;pointer-events:none}.dl-map-wrap{position:relative}.dl-map-legend{position:absolute;left:12px;bottom:12px;display:flex;gap:12px;align-items:center;padding:6px 12px;border-radius:999px;font-size:12px;background:color-mix(in srgb,var(--dl-card) 88%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);z-index:2}.dl-map-legend span{display:inline-flex;align-items:center;gap:6px;color:var(--dl-fg-muted)}.dl-map-legend i.line{width:14px;height:0;border-top:2px dashed #8a8a8a}.dl-map-legend i.line.live{border-top-color:#3b82f6}.dl-map-off{padding:32px 16px;text-align:center;color:var(--dl-fg-muted);border-top:1px solid var(--dl-line)}.dl-mk{all:unset;cursor:pointer;position:relative;display:flex;align-items:center;justify-content:center;transition:opacity .2s}.dl-mk-hub{position:relative;display:flex;align-items:center;justify-content:center}.dl-mk-host{box-sizing:border-box;width:40px;height:40px;border-radius:11px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-elevated) 60%,transparent);border:1px solid var(--dl-line);backdrop-filter:blur(6px);box-shadow:0 6px 16px #00000059}.dl-mk-host-tile{width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:var(--dl-fg);color:var(--background, var(--dl-elevated))}.dl-mk-host-ic{width:14px;height:14px}.dl-mk-av{position:relative;box-sizing:border-box;width:28px;height:28px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:500;line-height:1;border:2px solid #8a8a8a;background:var(--dl-elevated);color:var(--dl-fg-muted);transition:box-shadow .2s}.dl-mk.online .dl-mk-av{border-color:#3b82f6;background:color-mix(in srgb,#3b82f6 22%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk-badge{position:absolute;left:16px;bottom:-6px;height:16px;min-width:16px;padding:0 3px;border-radius:8px;border:2px solid var(--dl-elevated);background:#6b6b6b;color:#fff;display:flex;align-items:center;justify-content:center;gap:1px;font-size:9px;font-weight:600;white-space:nowrap;box-sizing:content-box}.dl-mk.online .dl-mk-badge{background:#3b82f6}.dl-mk-badge-ic{width:10px;height:10px;stroke-width:2.2}.dl-mk-tile{position:relative;width:26px;height:26px;border-radius:7px;display:flex;align-items:center;justify-content:center;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-mk.place.online .dl-mk-tile{background:#3b82f6;color:#fff;box-shadow:0 2px 8px #3b82f659}.dl-mk-tile-ic{width:14px;height:14px}.dl-mk-tile-n{position:absolute;right:-5px;top:-5px;min-width:14px;height:14px;padding:0 3px;box-sizing:border-box;border-radius:7px;background:var(--dl-fg);color:var(--dl-elevated);font-size:9px;font-weight:600;line-height:14px;text-align:center}.dl-mk-when{display:block;text-align:center;color:var(--dl-fg-faint);font-weight:400}.dl-mk.place.online .dl-mk-when{color:#3b82f6}.dl-mk-tile.sm{width:18px;height:18px;border-radius:5px;font-size:9px;font-weight:600}.dl-dmap{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-dmap .dl-geomap{border-top:0}.dl-dplaces{display:flex;flex-direction:column;margin-top:4px}.dl-dplace-row{display:flex;align-items:center;gap:10px;padding:9px 2px;border-top:1px solid var(--dl-line);font-size:13px}.dl-dplace-row:first-child{border-top:0}.dl-dplace-n{flex:0 0 auto;width:20px;height:20px;border-radius:5px;display:flex;align-items:center;justify-content:center;font-size:10px;font-weight:600;background:color-mix(in srgb,var(--dl-fg) 18%,var(--dl-elevated));color:var(--dl-fg)}.dl-dplace-n.live{background:#3b82f6;color:#fff}.dl-dplace-n .dl-icon{width:12px;height:12px}.dl-dplace-now{color:#3b82f6}.dl-mk>*{transition:opacity .15s;opacity:var(--dl-mk-fade, 1)}.dl-mk.merged{pointer-events:none}.dl-mk.dl-mk-new>*{transition:none}.dl-mk.merged>*{opacity:0}.dl-mk-hub{cursor:default}.dl-mk-host{position:relative}.dl-mk-host-n{position:absolute;right:-7px;top:-7px;min-width:18px;height:18px;padding:0 5px;box-sizing:border-box;border-radius:9px;border:2px solid var(--dl-elevated);background:#3b82f6;color:#fff;font-size:10px;font-weight:600;line-height:14px;text-align:center;opacity:0;transform:scale(.5);transition:opacity .15s,transform .15s;pointer-events:none}.dl-mk-host-n.on{opacity:1;transform:none}.dl-mk-hub:has(.dl-mk-host-n.on){cursor:zoom-in}.dl-mk-ptr{position:absolute;left:50%;top:50%;width:0;height:0;z-index:-1;pointer-events:none}.dl-mk-ptr .line{position:absolute;left:0;top:-.5px;height:1px;background:var(--dl-fg-faint);transform-origin:0 50%}.dl-mk-ptr .spot{position:absolute;left:-3.5px;top:-3.5px;width:7px;height:7px;border-radius:50%;box-sizing:border-box;border:1.5px solid #fff;background:#8a8a8a}.dl-mk.online .dl-mk-ptr .spot,.dl-mk.place.online .dl-mk-ptr .spot{background:#3b82f6}.dl-mk.dim>*{opacity:.18}.dl-mk.hl .dl-mk-av{box-shadow:0 0 0 4px #3b82f640}.dl-mk-label{position:absolute;left:50%;bottom:100%;margin-bottom:4px;transform:translate(-50%);white-space:nowrap;pointer-events:none;font-size:10px;line-height:14px;font-weight:500;color:var(--dl-fg)}.dl-mk-label.below{bottom:auto;top:100%;margin:4px 0 0}.dl-mk-label.chip{padding:2px 6px;border-radius:4px;font-size:11px;line-height:16px;font-weight:600;background:color-mix(in srgb,var(--background, var(--dl-card)) 80%,transparent);backdrop-filter:blur(8px)}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact{margin:0 10px 10px 0;min-height:28px;padding:0;border-radius:8px;background:var(--dl-elevated);border:1px solid var(--dl-line);color:var(--dl-fg-muted);box-shadow:none;font-size:11px;line-height:26px}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show){width:28px;height:28px;box-sizing:border-box}.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show{padding:0 32px 0 10px}.dl-geomap .maplibregl-ctrl-attrib a{color:var(--dl-fg-muted)}.dl-geomap .maplibregl-ctrl-attrib-button{top:0;right:0;width:26px;height:26px;margin:0;border-radius:8px;background:none}.dl-geomap .maplibregl-ctrl-attrib-button:after{content:"";position:absolute;inset:5px;background:var(--dl-fg);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat}.dl-geomap .maplibregl-ctrl-attrib-button:focus{outline:none;box-shadow:none}.dl-geomap .maplibregl-ctrl-attrib-button:focus-visible{outline:2px solid var(--dl-ring)}.dl-map-card{position:absolute;right:12px;top:12px;z-index:3;min-width:200px;max-width:260px;padding:10px 12px;border-radius:10px;font-size:12px;line-height:20px;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));opacity:0;transition:opacity .2s;pointer-events:none}.dl-map-card.on{opacity:1}.dl-map-card-head b{font-weight:500}.dl-map-card-row{display:flex;justify-content:space-between;gap:12px;white-space:nowrap}.dl-popcard{position:fixed;z-index:2100;width:max-content;max-width:300px;padding:12px;border-radius:12px;box-sizing:border-box;background:var(--dl-elevated);color:var(--dl-fg);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4))}.dl-popcard.away{visibility:hidden}.dl-popcard.leaving{pointer-events:none}.dl-popcard-tip{position:absolute;left:var(--tip-x, 50%);width:10px;height:10px;margin-left:-6px;box-sizing:border-box;background:var(--dl-elevated);border:solid var(--dl-line);transform:rotate(45deg)}.dl-popcard.above .dl-popcard-tip{bottom:-6px;border-width:0 1px 1px 0}.dl-popcard.below .dl-popcard-tip{top:-6px;border-width:1px 0 0 1px}.dl-popcard.above{transform-origin:var(--tip-x, 50%) 100%}.dl-popcard.below{transform-origin:var(--tip-x, 50%) 0}@media(prefers-reduced-motion:no-preference){.dl-popcard{animation:dl-pop-in .16s ease-out}.dl-popcard.leaving{animation:dl-pop-out .14s ease-in forwards}}@keyframes dl-pop-in{0%{opacity:0;transform:scale(.94)}to{opacity:1;transform:none}}@keyframes dl-pop-out{0%{opacity:1;transform:none}to{opacity:0;transform:scale(.94)}}.dl-pop{display:flex;flex-direction:column;gap:4px;font-size:12px;line-height:18px;min-width:210px}.dl-pop-head{display:flex;align-items:center;gap:8px;font-size:13px;margin-bottom:2px}.dl-pop-net{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-pop-list{display:flex;flex-direction:column;margin:6px 0 0;max-height:116px;overflow-y:auto}.dl-pop-row{all:unset;cursor:pointer;display:flex;align-items:center;gap:8px;padding:6px 8px;border-radius:8px}.dl-pop-row:hover{background:var(--dl-soft)}.dl-pop-row:focus{outline:none}.dl-pop-row:focus-visible{outline:2px solid var(--dl-ring)}.dl-pop-name{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-pop-name b{font-weight:500}.dl-pop-dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);flex:0 0 auto}.dl-pop-dot.on{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-pop-actions{display:flex;gap:6px;margin-top:8px;padding-top:8px;border-top:1px solid var(--dl-line)}.dl-pop-actions .cbi-button{flex:1;height:28px!important;font-size:12px!important;justify-content:center}.dl-chartbox{position:relative}.dl-bars{display:flex;align-items:flex-end;gap:4px;border-bottom:1px solid var(--dl-line)}.dl-bar{flex:1;height:100%;display:flex;flex-direction:column-reverse;gap:1px;cursor:default;min-width:3px}.dl-bar i{display:block;border-radius:3px 3px 0 0}.dl-bar i.down{background:var(--dl-chart-1)}.dl-bar i.up{background:var(--dl-chart-2);opacity:.75;border-radius:3px 3px 0 0}.dl-bar:hover i{filter:brightness(1.25)}.dl-bar.empty{background:linear-gradient(to top,var(--dl-line) 2px,transparent 2px)}.dl-tip{position:absolute;top:-8px;transform:translate(-50%,-100%);padding:8px 10px;border-radius:10px;font-size:12px;line-height:18px;white-space:nowrap;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4));pointer-events:none;z-index:3}.dl-tip-title{font-weight:500}.dl-tip-float{position:fixed;z-index:2000;color:var(--dl-fg)}.dl-spark i:hover{opacity:1;filter:brightness(1.25)}.dl-meter,.dl-slots{cursor:default}.dl-axis{display:flex;justify-content:space-between;font-size:12px;color:var(--dl-fg-faint);margin-top:6px}.dl-legend i.down{background:var(--dl-chart-1)}.dl-legend i.up{background:var(--dl-chart-2)}.dl-spark{display:flex;align-items:flex-end;gap:2px;flex:0 0 auto}.dl-spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--dl-chart-1);opacity:.85}.dl-spark i.zero{opacity:.22}`;var Xa=`.dl-row{display:flex;align-items:center;gap:12px;padding:12px 16px;border-top:1px solid var(--dl-line);font-size:14px;line-height:20px;min-width:0}.dl-row.link{color:inherit;text-decoration:none}.dl-row.link:hover{background:var(--dl-soft)}.dl-row-main{flex:1;min-width:0;overflow-wrap:anywhere}.dl-row-main b{font-weight:500}.dl-attn{display:flex;flex-direction:column;gap:10px;padding:16px;border-top:1px solid var(--dl-line)}.dl-attn-item{display:flex;gap:10px;align-items:baseline;font-size:13px;color:var(--dl-fg-muted)}.dl-avatar.sm{width:26px;height:26px;font-size:10px;margin:0}.dl-avatar.lg{width:48px;height:48px;font-size:15px;margin:0}.dl-avatar.lg.online:after{width:12px;height:12px}.dl-list{border:1px solid var(--dl-line);border-radius:12px;overflow:hidden}.dl-list>.dl-row:first-child{border-top:0}.dl-ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.dl-row-main.dl-stack{min-width:0}.dl-person-id{display:flex;align-items:center;gap:14px;min-width:0}.dl-grid-person{display:grid;grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);gap:16px;align-items:start}@media(max-width:1000px){.dl-grid-person{grid-template-columns:minmax(0,1fr)}}.dl-devsec{display:flex;flex-direction:column;gap:12px}.dl-devsec .dl-panel-head{margin:0}.dl-dgrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}.dl-dcard>.dl-dcard-head+*{margin-top:auto}@media(max-width:700px){.dl-dgrid{grid-template-columns:minmax(0,1fr)}}.dl-dgrid>.dl-dslot.add:only-child{grid-column:1 / -1}.dl-dcard{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--dl-shadow)}.dl-dcard.online{border-color:color-mix(in srgb,var(--dl-ok) 35%,transparent)}.dl-dcard.off{opacity:.7}.dl-dcard-head{display:flex;align-items:center;gap:12px}.dl-dcard-ic{width:40px;height:40px;border-radius:12px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dcard-ic .dl-icon{width:20px;height:20px}.dl-dcard.online .dl-dcard-ic{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-dcard-title{all:unset;cursor:pointer;flex:1;min-width:0;display:flex;flex-direction:column}.dl-dcard-title b{font-weight:500;font-size:15px}.dl-dstat{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var(--dl-fg-muted);white-space:nowrap;min-width:0}.dl-dstat i.dot{flex:none}.dl-dstat.ok{color:var(--dl-ok)}.dl-dstat.warn{color:var(--dl-warn)}.dl-dstat i.dot,.dl-savebar i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint)}.dl-dstat i.dot.ok{background:var(--dl-ok);box-shadow:0 0 0 3px var(--dl-ok-wash)}.dl-dstat i.dot.warn{background:var(--dl-warn)}.dl-dcard-use{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.dl-dcard-foot{padding-top:10px;border-top:1px solid var(--dl-line);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dl-dslot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:10px;padding:14px;min-height:0;border:1px dashed color-mix(in srgb,currentColor 18%,transparent);border-radius:14px;text-align:center;color:var(--dl-fg-muted);transition:background .15s,border-color .15s,color .15s}.dl-dslot.add .dl-stack{align-items:center}.dl-dslot.add:hover{border-color:color-mix(in srgb,currentColor 35%,transparent);color:var(--dl-fg)}.dl-dslot.add:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-dslot.add b{font-weight:500}.dl-dslot.add:hover{background:var(--dl-soft)}.dl-dslot-ic{width:36px;height:36px;border-radius:999px;background:var(--dl-soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--dl-fg-muted)}.dl-dslot.add:hover .dl-dslot-ic{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-tiles2{display:grid;gap:10px;margin-top:16px}.dl-tile2{border:1px solid var(--dl-line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:10px;min-width:0}.dl-tile2-label{display:flex;align-items:center;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--dl-fg-faint)}.dl-tile2-row{display:flex;align-items:center;justify-content:space-between;gap:10px;flex-wrap:wrap}.dl-tile2-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.dl-tile2-value .dl-faint{font-size:14px;font-weight:400}.dl-tile2-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-stepper{display:inline-flex;align-items:stretch;height:32px;border:1px solid var(--input, var(--dl-line));border-radius:8px;overflow:hidden}.dl-stepper button{all:unset;cursor:pointer;width:32px;display:inline-flex;align-items:center;justify-content:center;font-size:16px;color:var(--dl-fg)}.dl-stepper button:hover{background:var(--dl-soft)}.dl-stepper button[disabled]{opacity:.35;cursor:not-allowed}.dl-stepper+.dl-stepper{margin-left:4px}.dl-step-select{border:0!important;border-left:1px solid var(--input, var(--dl-line))!important;border-right:1px solid var(--input, var(--dl-line))!important;border-radius:0!important;background:transparent!important;color:inherit;font:500 13px inherit;padding:0 10px!important;height:100%!important;min-width:0!important}.dl-slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.dl-slots i{height:4px;border-radius:999px;background:var(--dl-track);display:block}.dl-slots i.used{background:var(--dl-fg)}.dl-slots i.over{background:color-mix(in srgb,var(--dl-warn) 80%,transparent)}.dl-date{display:flex;align-items:center;gap:8px;flex:1 1 150px;min-width:0;box-sizing:border-box;height:34px;padding:0 10px;border:1px solid var(--input, var(--dl-line));border-radius:8px;color:var(--dl-fg-faint)}.dl-date input{border:0!important;background:transparent!important;box-shadow:none!important;padding:0!important;height:32px!important;color:var(--dl-fg);flex:1;min-width:0!important;width:100%!important}.dl-meter{position:relative;height:6px;border-radius:999px;background:var(--dl-track)}.dl-meter>i{display:block;height:100%;border-radius:999px;background:var(--dl-accent)}.dl-meter.warn>i{background:var(--dl-warn)}.dl-meter.bad>i{background:var(--dl-bad)}.dl-meter .mark{position:absolute;left:90%;top:-3px;width:1px;height:12px;background:var(--dl-warn)}.dl-meter.sm{height:4px}.dl-chips-row{display:flex;flex-wrap:wrap;gap:4px}.dl-chipbtn{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-soft);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-chipbtn:hover{background:var(--dl-soft-hover)}.dl-chipbtn.on{background:var(--dl-primary);color:var(--dl-primary-fg)}.dl-switch{all:unset;cursor:pointer;position:relative;width:32px;height:20px;border-radius:999px;background:var(--switch-off, var(--dl-track));flex:0 0 auto;transition:background .15s}.dl-switch i{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:#fff;transition:left .15s;box-shadow:0 1px 2px #0000004d}.dl-switch.on{background:var(--dl-accent)}.dl-switch.on i{left:14px}.dl-switch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:2px}.dl-linkbox{display:flex;align-items:center;gap:8px;height:36px;padding:0 4px 0 12px;border:1px solid var(--input, var(--dl-line));border-radius:8px;background:var(--input-bg, transparent)}.dl-linkbox .dl-mono{flex:1;min-width:0;font-size:12px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--dl-fg-muted)}.dl-linkbox .cbi-button{height:28px!important}.dl-pcard{display:grid;grid-template-columns:minmax(0,1fr) 260px;gap:20px;align-items:stretch;min-width:0}.dl-pcard-main{min-width:0}.dl-pcard-top{display:flex;align-items:center;gap:12px;min-width:0}.dl-pcard-top .dl-avatar{margin-right:0}.dl-pcard-who{flex:1;min-width:0}.dl-pcard-who .dl-slotbar{margin:3px 0 0}.dl-pside{display:flex;flex-direction:column;justify-content:space-between;gap:8px;padding-left:20px;border-left:1px solid var(--dl-line);min-width:0}.dl-pside-top{display:flex;align-items:center;justify-content:space-between;gap:8px}.dl-pside-state{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--dl-fg-muted)}.dl-pside-state.live{color:var(--dl-ok)}.dl-pside-foot{font-size:12px}.dl-pside .dl-use-num b{font-size:20px}.dl-none{display:none!important}.dl-pcard-actions{display:flex;gap:6px;flex:0 0 auto}.dl-pcard-actions .cbi-button{height:32px!important}.dl-icon-only .dl-btn-label{display:none}.dl-pill-ic{display:inline-flex;align-items:center;gap:4px;height:22px;padding:0 8px;border-radius:999px;font-size:12px;white-space:nowrap;background:var(--dl-soft);color:var(--dl-fg-muted)}.dl-pill-ic .dl-icon{width:12px;height:12px}.dl-pill-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-pill-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-use-num{display:flex;align-items:baseline;gap:6px;white-space:nowrap}.dl-use-num b{font-size:15px;font-weight:500}.dl-use-live{display:flex;align-items:center;gap:8px;font-size:12px;font-variant-numeric:tabular-nums}.dl-usebar{display:flex;gap:2px;height:6px;border-radius:999px;overflow:hidden;background:var(--dl-track)}.dl-usebar i{display:block;height:100%;min-width:3px;flex:0 1 0}.dl-usebar i.fill{flex:none;min-width:0;border-radius:999px;background:var(--dl-accent)}.dl-usebar.warn i.fill{background:var(--dl-warn)}.dl-usebar.bad i.fill{background:var(--dl-bad)}.dl-usebar .c0,.dl-swatch.c0{background:var(--dl-chart-1)}.dl-usebar .c1,.dl-swatch.c1{background:#8b7cf6}.dl-usebar .c2,.dl-swatch.c2{background:#2fb889}.dl-usebar .c3,.dl-swatch.c3{background:#d9a03f}.dl-usebar .c4,.dl-swatch.c4{background:var(--dl-fg-faint)}.dl-tip-row{display:flex;align-items:center;gap:8px;min-width:160px}.dl-tip-row b{margin-left:auto;font-weight:500}.dl-swatch{width:8px;height:8px;border-radius:2px;flex:none}.dl-card-name{color:var(--dl-fg)!important;text-decoration:none}.dl-card-name:hover{text-decoration:underline}.dl-chip-tag{font-size:11px;line-height:18px;padding:0 6px;border-radius:999px;background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-chip.live{background:var(--dl-ok-wash);color:color-mix(in srgb,var(--dl-ok) 35%,var(--dl-fg))}.dl-chip.live:hover{background:color-mix(in srgb,var(--dl-ok) 22%,transparent)}.dl-chip.live .dl-icon{color:var(--dl-ok)}.dl-fixes{display:flex;gap:6px;flex-wrap:wrap;margin:10px 0 0 44px}.dl-fix{all:unset;cursor:pointer;height:26px;padding:0 10px;border-radius:999px;background:var(--dl-info-wash);color:var(--dl-info);font-size:12px;font-weight:500;display:inline-flex;align-items:center}.dl-fix:hover{filter:brightness(1.15)}@media(max-width:760px){.dl-pcard{grid-template-columns:1fr}.dl-pside{padding:12px 0 0;border-left:0;border-top:1px solid var(--dl-line)}.dl-fixes{margin-left:0}}.dl-select{height:34px!important;border-radius:999px!important;min-width:136px!important;width:auto!important;padding:0 34px 0 14px!important;appearance:none!important;-webkit-appearance:none!important;background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E")!important;background-repeat:no-repeat!important;background-position:right 12px center!important;background-size:14px!important}.dl-savebar{position:fixed;left:50%;bottom:24px;transform:translate(-50%,160%);opacity:0;transition:transform .25s cubic-bezier(.2,.8,.2,1),opacity .2s;display:flex;align-items:center;gap:10px;padding:8px 8px 8px 18px;border-radius:999px;background:var(--dl-elevated);border:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, 0 16px 32px -8px rgba(0,0,0,.5));z-index:60;pointer-events:none}.dl-savebar.show{transform:translate(-50%);opacity:1;pointer-events:auto}.dl-savebar-text{display:inline-flex;align-items:center;gap:8px;font-size:13px;font-weight:500}`;var er=".dl-toast strong{display:block;font-weight:500}.dl-toast div{opacity:.8;font-size:13px}.dl-drawer-overlay{position:fixed;inset:0;z-index:900;display:flex;justify-content:flex-end;background:transparent;transition:background .2s}.dl-drawer-overlay.open{background:var(--scrim, rgba(0,0,0,.45))}.dl-drawer{width:min(520px,100%);height:100%;display:flex;flex-direction:column;background:var(--dialog-bg, var(--dl-elevated));color:var(--dl-fg);border-left:1px solid var(--dl-line);box-shadow:var(--shadow-2xl, -16px 0 32px -8px rgba(0,0,0,.5));transform:translate(100%);transition:transform .22s cubic-bezier(.2,.8,.2,1)}.dl-drawer-overlay.open .dl-drawer{transform:none}.dl-drawer-head{display:flex;align-items:center;gap:12px;padding:16px 20px;border-bottom:1px solid var(--dl-line)}.dl-drawer-title{flex:1;min-width:0;display:flex;align-items:center;gap:12px}.dl-drawer-title h3{margin:0!important;padding:0!important;border:0!important;font-size:18px!important;line-height:26px;font-weight:500!important}.dl-drawer-x{all:unset;cursor:pointer;width:32px;height:32px;border-radius:50%;display:inline-flex;align-items:center;justify-content:center;color:var(--dl-fg-muted)}.dl-drawer-x:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-drawer-body{flex:1;overflow:auto;padding:20px}.dl-drawer-foot{padding:12px 20px;border-top:1px solid var(--dl-line)}.dl-drawer-actions{display:flex;align-items:center;gap:8px}.dl-dcard-ic.on{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-icon-only.sm{width:28px;height:28px!important}.dl-stack.gap12{gap:12px}.dl-stack.gap16{gap:16px}.dl-dstats{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));border:1px solid var(--dl-line);border-radius:14px;overflow:hidden}.dl-dstats-cell{display:flex;flex-direction:column;gap:4px;padding:12px 14px;min-width:0}.dl-dstats-cell.wide{grid-column:span 2;border-bottom:1px solid var(--dl-line)}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:1px solid var(--dl-line)}.dl-dstats-cell b{font-size:16px;font-weight:500;font-variant-numeric:tabular-nums}.dl-dstats-cell .dl-dstat{font-size:14px}.dl-dsec{border:1px solid var(--dl-line);border-radius:14px;padding:16px;display:flex;flex-direction:column;gap:12px}.dl-dsec-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-dsec-head h4{margin:0!important;padding:0!important;font-size:14px!important;font-weight:500!important;border:0!important}.dl-dstat i.dot{width:6px;height:6px;border-radius:50%;background:var(--dl-fg-faint);display:inline-block}.dl-connect-body{min-height:60px}.dl-connect-body .dl-qr{width:min(240px,70vw)}.dl-kv2{display:flex;flex-direction:column}.dl-kvrow{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:9px 0;border-top:1px solid var(--dl-line);font-size:13px;min-width:0}.dl-kvrow:first-child{border-top:0;padding-top:0}.dl-kvrow-k{color:var(--dl-fg-muted);flex:0 0 auto}.dl-kvrow-v{min-width:0;text-align:right;overflow-wrap:anywhere}.dl-kvrow-v.copy{all:unset;cursor:pointer;display:inline-flex;align-items:center;gap:6px;min-width:0;color:var(--dl-fg)}.dl-kvrow-v.copy span{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-kvrow-v.copy .dl-icon{width:13px;height:13px;color:var(--dl-fg-faint)}.dl-kvrow-v.copy:hover .dl-icon{color:var(--dl-fg)}@media(max-width:560px){.dl-drawer{width:100%}.dl-dstats{grid-template-columns:minmax(0,1fr)}.dl-dstats-cell.wide{grid-column:auto}.dl-dstats-cell+.dl-dstats-cell:not(.wide):last-child{border-left:0;border-top:1px solid var(--dl-line)}}.dl-dev-log{display:flex;flex-direction:column}.dl-dev-log-row{display:flex;align-items:center;gap:10px;padding:8px 0;border-top:1px solid var(--dl-line);font-size:13px;line-height:20px;min-width:0}.dl-dev-log-row:first-child{border-top:0;padding-top:0}.dl-dev-log-row .dl-row-main{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}";var tr=".dl-settings-main{min-width:0;display:flex;flex-direction:column;gap:20px}.dl-setsec{background:var(--dl-card);border:1px solid var(--dl-line);border-radius:var(--dl-radius);overflow:hidden;scroll-margin-top:88px;box-shadow:var(--dl-shadow)}.dl-setsec-body{padding:20px;display:flex;flex-direction:column;gap:14px}.dl-setsec-body h3{margin:0!important;padding:0!important;font-size:18px!important;line-height:26px;font-weight:500!important;border:0!important}.dl-setsec-body p{margin:0}.dl-setsec-head{display:flex;align-items:center;gap:10px}.dl-group{border:1px solid var(--dl-line);border-radius:14px;padding:2px 16px}.dl-group-head{display:flex;align-items:center;gap:12px;padding:14px 0 10px}.dl-group-head b{font-size:15px;font-weight:500}.dl-group-ic{width:32px;height:32px;border-radius:10px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-group-ic .dl-icon-wrap{display:inline-flex}.dl-group-ic .dl-icon{width:16px;height:16px}.dl-group-body>*{padding:12px 0;margin:0!important}.dl-group-body>*+*:not(.alert-message):not(.dl-params){border-top:1px solid var(--dl-line)}.dl-group-body>.alert-message,.dl-group-body>.dl-params{margin:12px 0!important}.dl-group-body>.alert-message{padding:10px 14px}.dl-group-body>.dl-params{padding:0}.dl-group-body>.alert-message+*,.dl-group-body>.dl-params+*{border-top:0}.dl-group-body>.dl-row{border-left:0;border-right:0;border-bottom:0;padding-left:0;padding-right:0;background:none}.dl-group-body>.dl-row:first-child{border-top:0}.dl-setsec-foot{display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:10px 16px;padding:12px 20px;border-top:1px solid var(--dl-line);background:var(--dl-soft)}.dl-setsec.danger{border-color:color-mix(in srgb,var(--dl-bad) 40%,transparent)}.dl-setsec.danger .dl-setsec-foot{background:color-mix(in srgb,var(--dl-bad) 6%,transparent)}.dl-setrow{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,420px);align-items:center;gap:8px 24px}.dl-setrow.head{display:flex;justify-content:space-between;gap:16px}.dl-setrow-label{font-size:14px;font-weight:500}.dl-setrow-ctl{display:flex;justify-content:flex-end;min-width:0}.dl-setrow-ctl .dl-chips-row{justify-content:flex-end}.dl-setrow-ctl>input{width:100%}.dl-hostport{display:flex;align-items:center;gap:8px;flex:1;min-width:0;justify-content:flex-end}.dl-hostport input{flex:1;min-width:0}.dl-root input.dl-w-port,.dl-hostport input.dl-w-port{flex:0 0 90px;width:90px}.dl-root input.dl-w-range{flex:0 0 130px;width:130px}.dl-setrow .dl-sub.bad{color:var(--dl-bad)}.dl-suffixed{display:inline-flex;align-items:center;gap:6px}.dl-suffixed>span{color:var(--dl-fg-muted)}.dl-more summary{cursor:pointer;color:var(--dl-fg-muted);font-size:13px;margin-bottom:10px}.dl-more .dl-setrow+.dl-setrow{margin-top:10px}@media(max-width:760px){.dl-setrow:not(.head){grid-template-columns:minmax(0,1fr)}.dl-setrow-ctl,.dl-setrow-ctl .dl-chips-row{justify-content:flex-start}}.dl-need-ic{width:30px;height:30px;border-radius:9px;background:var(--dl-soft);color:var(--dl-fg-muted);display:inline-flex;align-items:center;justify-content:center;flex:none}.dl-need-ic .dl-icon-wrap{display:inline-flex}.dl-need-ic .dl-icon{width:15px;height:15px}.dl-need-row.bad .dl-need-ic,.dl-need-ic.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-need-row.warn .dl-need-ic,.dl-need-ic.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-need-ic.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-lh-main{display:flex;align-items:flex-start;gap:12px;min-width:0}.dl-lh-main>.dl-need-ic{margin-top:1px}.dl-sub .dl-mono{font-size:.92em}.dl-need-row>.cbi-button{flex:none}.dl-bk-row .dl-group-ic{width:30px;height:30px}.dl-bk-older>summary{list-style:none;cursor:pointer;display:flex;align-items:center;gap:8px;padding:11px 16px;border-top:1px solid var(--dl-line);font-size:13px;color:var(--dl-fg-muted);user-select:none}.dl-bk-older>summary::-webkit-details-marker{display:none}.dl-bk-older>summary:hover{background:var(--dl-soft);color:var(--dl-fg)}.dl-bk-older>summary .dl-icon-wrap{display:inline-flex;transition:transform .15s}.dl-bk-older>summary .dl-icon{width:14px;height:14px}.dl-bk-older[open]>summary .dl-icon-wrap{transform:rotate(90deg)}#dl-set-backups .dl-setsec-head h3+.dl-sub{margin-top:2px}#dl-set-backups .dl-setsec-foot>.dl-sub{flex:1 1 260px}.dl-bk-actions{flex:0 1 auto;justify-content:flex-end}@media(max-width:640px){#dl-set-backups .dl-setsec-foot>.dl-sub{flex-basis:100%}.dl-bk-actions{justify-content:flex-start}}.dl-upd{display:flex;flex-direction:column;gap:16px}.dl-upd>.dl-pagehead{margin:0 0 4px}.dl-upd-bad{color:var(--dl-bad)}";var nr=".dl-comp-hero{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr)}.dl-comp-hero-main{padding:20px;display:flex;flex-direction:column;gap:12px;min-width:0}.dl-comp-hero-side{padding:20px;border-left:1px solid var(--dl-line);display:flex;flex-direction:column;gap:14px;min-width:0}.dl-comp-name{font-size:16px;font-weight:500}.dl-comp-hero-head{display:flex;align-items:center;gap:10px;flex-wrap:wrap;min-width:0}.dl-comp-hero-head .dl-spacer{flex:1}.dl-comp-big{font-family:var(--dl-mono);font-size:26px;line-height:34px;letter-spacing:-.02em;display:flex;align-items:baseline;gap:10px}.dl-comp-big small{font-size:14px;color:var(--dl-accent)}.dl-comp-big small.dl-faint{color:var(--dl-fg-faint)}.dl-comp-verrow{display:flex;align-items:center;gap:4px 12px;flex-wrap:wrap;min-width:0}.dl-comp-verrow .dl-spacer{flex:1}.dl-comp-meta{font-size:13px}.dl-comp-bullets{margin:0;padding-left:18px;display:flex;flex-direction:column;gap:4px;color:var(--dl-fg-muted);font-size:13px}.dl-comp-bullets li{list-style:disc}.dl-comp-lead{margin:0}.dl-comp-more{align-self:flex-start;font-size:12px;color:var(--dl-fg-faint);margin-left:18px;padding:0!important}.dl-comp-more:hover{color:var(--dl-accent);background:none!important;text-decoration:underline;text-underline-offset:2px}.dl-comp-hero-main>.dl-comp-vers{margin-top:auto}.dl-comp-btns{display:flex;gap:8px;flex-wrap:nowrap;align-items:center;flex:none}.dl-comp-side-v{display:flex;align-items:center;gap:8px;font-size:14px;min-width:0;flex-wrap:wrap}.dl-comp-side-v .dl-icon{width:15px;height:15px;color:var(--dl-fg-muted)}.dl-comp-side-v a{color:inherit;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-side-v a:hover{color:var(--dl-accent)}.dl-comp-cols{display:grid;grid-template-columns:minmax(0,1.5fr) minmax(0,1fr);gap:16px;align-items:start}.dl-comp-cols>.dl-panel>div>.dl-row:first-child{border-top:1px solid var(--dl-line)}.dl-comp-count{font-size:13px}.dl-comp-sub{font-size:11px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-ic{display:inline-flex;gap:4px;flex:none}.dl-comp-ic .cbi-button{width:30px;height:30px;padding:0!important;justify-content:center;border-radius:999px!important}.dl-comp-ic .dl-btn-label{display:none}.dl-comp-ic .dl-icon{width:14px;height:14px}.dl-comp-ic .is-busy{pointer-events:none;opacity:.5}.dl-comp-ic .cbi-button.dl-comp-check{width:auto;padding:0 12px 0 10px!important;gap:6px;display:inline-flex;align-items:center;font-size:13px}.dl-row>.dl-pill,.dl-row>.cbi-button,.dl-row>.dl-comp-ic{flex:none}button.dl-pill.dl-comp-run{all:unset;display:inline-flex;align-items:center;height:20px;padding:0 8px;border-radius:999px;font-size:12px;cursor:pointer;background:color-mix(in srgb,var(--dl-accent) 14%,transparent);color:var(--dl-accent)}.dl-comp-foldwrap{padding:0 16px 14px 60px}.dl-comp-fold .dl-params-body{gap:12px}.dl-comp-fold .dl-list>.dl-row{padding:10px 14px}.dl-comp-bver{font-size:12px;width:130px;text-align:right;flex:none;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.dl-comp-bact{width:84px;flex:none;display:flex;justify-content:flex-end}.dl-comp-warn{display:flex;align-items:flex-start;gap:8px;font-size:12px;line-height:18px;color:var(--dl-fg-muted)}.dl-comp-warn .dl-icon-wrap{display:inline-flex;flex:none;margin-top:2px}.dl-comp-warn .dl-icon{width:14px;height:14px;color:var(--dl-warn)}.dl-comp-empty{margin:0;padding:4px 16px 16px}@media(max-width:760px){.dl-comp-hero,.dl-comp-cols{grid-template-columns:minmax(0,1fr)}.dl-comp-hero-side{border-left:0;border-top:1px solid var(--dl-line)}.dl-comp-foldwrap{padding-left:16px}.dl-comp-bver{display:none}}.dl-comp-status{display:flex;align-items:center;gap:8px;font-size:13px;padding:9px 12px;border-radius:10px;background:var(--dl-soft);min-width:0}.dl-comp-status>.dl-icon-wrap{display:inline-flex;flex:none}.dl-comp-status .dl-icon{width:15px;height:15px}.dl-comp-status.ok{background:var(--dl-ok-wash);color:var(--dl-ok)}.dl-comp-status.acc{background:color-mix(in srgb,var(--dl-accent) 12%,transparent);color:var(--dl-accent)}.dl-comp-status.warn{background:var(--dl-warn-wash);color:var(--dl-warn)}.dl-comp-status.bad{background:var(--dl-bad-wash);color:var(--dl-bad)}.dl-comp-status b{font-weight:600}.dl-comp-vers .dl-params-body{gap:0;padding:4px 14px 12px}.dl-comp-tag{display:flex;gap:6px;padding:6px 0 10px}.dl-comp-tag input{flex:1;min-width:0}.dl-comp-ver{display:flex;align-items:center;gap:8px;padding:7px 0;border-top:1px solid var(--dl-line);font-size:13px}.dl-comp-ver .dl-mono{min-width:52px}.dl-comp-ver .dl-sub{flex:1}.dl-comp-ver .cbi-button:not(.dl-icon-btn){height:26px!important;font-size:12px!important}.dl-comp-pager{display:flex;align-items:center;justify-content:space-between;padding-top:10px;border-top:1px solid var(--dl-line);font-size:12px}.dl-comp-pager .dl-linkbtn[disabled]{opacity:.4;cursor:default}.dl-comp-vers .dl-loading,.dl-comp-vers .dl-params-body>p{padding:6px 0 10px}.dl-op-head{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-bottom:14px}.dl-op-head .dl-spacer{flex:1}.dl-op-timer{display:inline-flex;align-items:center;gap:5px;font-variant-numeric:tabular-nums}.dl-op-timer .dl-icon,.dl-op-head .dl-linkbtn .dl-icon{width:14px;height:14px}.dl-op-loghead{display:flex;align-items:center;justify-content:space-between}.dl-op-loghead b{font-weight:500;font-size:13px}.dl-op .dl-log{max-height:16em;min-height:12em;margin-top:8px}.dl-op .dl-comp-status{margin:14px 0 0}.dl-op-actions{display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;width:100%}.dl-notes{max-height:55vh;overflow:auto;border-radius:12px;background:var(--dl-soft);padding:14px 16px;font-size:13px;line-height:20px;overflow-wrap:anywhere}.dl-notes h5{margin:10px 0 6px;font-size:14px;font-weight:500}.dl-notes h5:first-child{margin-top:0}.dl-notes p{margin:0 0 8px}.dl-notes ul{margin:0 0 10px;padding-left:18px}.dl-notes li{list-style:disc}.dl-notes code{font-family:var(--dl-mono);font-size:12px;padding:1px 5px;border-radius:6px;background:var(--dl-soft-hover)}.dl-notes pre{font-family:var(--dl-mono);font-size:12px;padding:10px;border-radius:8px;background:var(--dl-soft-hover);white-space:pre-wrap;margin:0 0 10px}.dl-notes a{color:var(--dl-accent)}";var or=".dl-chip.static{cursor:default}.dl-chip.static:hover{background:var(--dl-soft)}.dl-chip.static .dl-chip-name{font-weight:500}.dl-setrow.head .dl-chips-row{margin-top:8px}.dl-setrow.head>.dl-lh-main,.dl-setrow.head>.dl-lh-main>.dl-stack{flex:1 1 auto;min-width:0}.dl-setrow.head>.dl-setrow-ctl:empty{display:none}.dl-setrow.head:has(>.dl-lh-main){align-items:flex-start}.dl-setrow.head>.dl-setrow-ctl{align-items:center;min-height:30px}.dl-netpick{margin-top:10px}.dl-boxrow{display:flex;align-items:center;justify-content:space-between;gap:16px;margin:0;padding:10px 14px;border:1px solid var(--dl-line);border-radius:12px;font-size:13px;cursor:pointer}.dl-boxrow>.dl-switch{flex:none}.dl-ifpick{display:flex;flex-direction:column;gap:12px;padding:14px;border:1px solid var(--dl-line);border-radius:14px}.dl-iflead-row{display:flex;align-items:center;justify-content:space-between;gap:12px}.dl-host-ports{justify-content:flex-end}@media(max-width:760px){.dl-host-ports{justify-content:flex-start}}.dl-circle-dot{display:inline-block;width:8px;height:8px;border-radius:50%;flex:none}.dl-circles .dl-chip b{font-weight:500}.dl-circle-name{display:inline-flex;align-items:center;gap:8px;font-size:14px;font-weight:500}.dl-w400{font-weight:400}.dl-swatches{display:flex;flex-wrap:wrap;gap:8px}.dl-swatch{all:unset;cursor:pointer;width:22px;height:22px;border-radius:50%;background:var(--sw);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dl-fg) 12%,transparent)}.dl-swatch.on{box-shadow:0 0 0 2px var(--dl-card),0 0 0 4px var(--sw)}.dl-swatch:focus-visible{outline:2px solid var(--dl-ring);outline-offset:3px}.dl-circle-modal .dl-chipbtn b{margin-left:6px;font-weight:500;font-size:11px;opacity:.6}.dl-reach td:first-child b{font-weight:500}.dl-ev-host{white-space:nowrap}.dl-ev-host b{font-weight:500;color:var(--dl-fg)}.dl-reach{font-size:13px}.dl-reach th,.dl-reach td{white-space:nowrap;padding-left:6px;padding-right:6px}.dl-reach-wrap{overflow-x:auto}.dl-yes{display:inline-flex;align-items:center;gap:4px;color:var(--dl-ok)}.dl-yes .dl-icon-wrap{display:inline-flex}.dl-yes .dl-icon{width:14px;height:14px}.dl-check-form{display:grid;grid-template-columns:minmax(0,1fr) auto minmax(0,1fr) auto;align-items:start;gap:8px}.dl-check-form>.dl-faint{line-height:36px}.dl-check-end{display:flex;flex-direction:column;gap:6px;min-width:0}.dl-check-end>*{width:100%!important;min-width:0}@media(max-width:560px){.dl-check-form{grid-template-columns:minmax(0,1fr)}.dl-check-form>.dl-faint{display:none}}.dl-verdict{display:flex;align-items:baseline;gap:10px;padding:10px 12px;border-radius:12px}.dl-verdict b{font-weight:500}.dl-verdict.ok{background:var(--dl-ok-wash)}.dl-verdict.ok b{color:var(--dl-ok)}.dl-verdict.bad{background:var(--dl-bad-wash)}.dl-verdict.bad b{color:var(--dl-bad)}.dl-corehead{display:flex;align-items:center;gap:10px;flex-wrap:wrap;margin:0 0 4px}.dl-corehead h3{margin:0!important}.dl-row-end{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}.dl-dcard.clickable{cursor:pointer}.dl-dcard.clickable:hover{border-color:color-mix(in srgb,var(--dl-fg) 22%,transparent)}";var ns=[Wa,Ga,qa,Fa,Ka,Ja,Va,Ya,Za,Qa,Xa,er,tr,nr,or].join(` +`);function ar(){let n=document.createElement("style");return n.dataset.dawnline="1",n.textContent=ns,n}function st(n){return()=>{let e=new n;return Object.assign({load:()=>e.load(),render:async a=>{let r=await e.render(a),i=document.createElement("div");return i.className="dl-root",i.append(ar(),r),i},addFooter(){return e.noFooter?document.createElement("div"):this.super("addFooter",[])}},{handleSave:null,handleSaveApply:null,handleReset:null})}}var hg=st(It),fg=st(it),gg=st(It),vg=st(hn),bg=st(vn),xg=st(yn),wg=st(gn);function rr(n){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${n?`?tab=${n}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var yg=rr(""),kg=rr("log");return baseclass.extend({ activity: kg, diagnostics: xg, health: yg, overview: hg, people: fg, person: bg, server: gg, settings: vg, updates: wg }); diff --git a/package/luci-app-dawnline/root/etc/init.d/dawnline b/package/luci-app-dawnline/root/etc/init.d/dawnline index 2466623..e339fc2 100755 --- a/package/luci-app-dawnline/root/etc/init.d/dawnline +++ b/package/luci-app-dawnline/root/etc/init.d/dawnline @@ -36,7 +36,8 @@ start_resolver() { procd_open_instance dns procd_set_param command /usr/libexec/dawnline/resolver procd_set_param file /var/etc/dawnline-dns.conf - procd_set_param respawn 3600 5 0 + # A new config kills it (dawnline.resolver): back within a second, not five. + procd_set_param respawn 3600 1 0 procd_close_instance } @@ -59,6 +60,8 @@ start_service() { stop_service() { mkdir -p /var/run/dawnline date +%s > /var/run/dawnline/agent.stopped + # Copies procd doesn't know about (started by hand, or left by an older version) go too. + pgrep -f '^/usr/bin/ucode /usr/libexec/dawnline/agent' | xargs -r kill 2>/dev/null } reload_service() { diff --git a/package/luci-app-dawnline/root/etc/uci-defaults/90_dawnline b/package/luci-app-dawnline/root/etc/uci-defaults/90_dawnline index ada7f88..e665754 100755 --- a/package/luci-app-dawnline/root/etc/uci-defaults/90_dawnline +++ b/package/luci-app-dawnline/root/etc/uci-defaults/90_dawnline @@ -17,6 +17,13 @@ uci -q commit dawnline rm -f /etc/dawnline/alerts.json # Backups moved into Settings. rm -f /www/luci-static/resources/view/dawnline/backups.js +# "Pause everyone" is gone: turning a server off does the same, so a +# router left paused keeps its servers off instead of letting everyone in. +if [ "$(uci -q get dawnline.settings.paused_all)" = 1 ]; then + for s in $(uci -q show dawnline | sed -n 's/^dawnline\.\([^.=]*\)=server$/\1/p'); do uci -q set "dawnline.$s.enabled=0"; done +fi +uci -q delete dawnline.settings.paused_all +uci -q commit dawnline # Portal assets moved out of the web root (served only with a valid code). rm -rf /usr/share/dawnline/portal/www/assets diff --git a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent index f681d2c..78428c0 100755 --- a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent +++ b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent @@ -11,7 +11,7 @@ 'use strict'; import * as uloop from 'uloop'; -import { readfile, writefile, stat, unlink } from 'fs'; +import { open, readfile, writefile, stat, unlink } from 'fs'; import { read_json, write_json, ensure_dir, sh_out, q, uniq, slog, slog_trim, slog_restore, DATA_DIR, RUN_DIR, VERSION } from 'dawnline.util'; @@ -34,6 +34,21 @@ const LOG_FLUSH = { '10min': 600, hourly: 3600 }; const RESYNC_EVERY = 600; const CONFIG_FILE = '/etc/config/dawnline'; +// One agent, procd's. A second copy would run forever beside it with the code +// it started with: its own events (pauses and resumes from stale states), its +// own counters and syncs. It takes no arguments: the commands are `dawnline`'s. +if (length(ARGV)) { + warn(`The agent takes no arguments (procd runs it). For commands use: dawnline ${join(' ', ARGV)}\n`); + exit(2); +} +ensure_dir(RUN_DIR); +// Held as long as the process lives; close-on-exec, so children don't keep it. +let instance = open(`${RUN_DIR}/agent.lock`, 'we'); +if (!instance?.lock('xn')) { + warn(`The agent is already running (${RUN_DIR}/agent.lock is held). Use /etc/init.d/dawnline restart.\n`); + exit(1); +} + let usage = live.load_usage(); let last_states = null; // Who was online, kept in tmpfs so an agent restart (update, reload) does not @@ -111,17 +126,19 @@ let conf_mtime = null; let cert_mtime = null; const REASON = { - paused: 'paused by admin', paused_all: 'everyone paused', expired: 'end date reached', - quota: 'data limit reached', hours: 'outside allowed hours', no_server: 'no server', active: 'active', + paused: 'paused by admin', expired: 'end date reached', + quota: 'data limit reached', hours: 'outside allowed hours', no_server: 'no server', server_off: 'server turned off', + active: 'active', }; function check_people(m, states, events) { let ts = time(); for (let id, p in m.people) { let st = states[id], prev = last_states?.[id]; - // The admin's own pauses are logged by rpcd when they happen; here only - // what changes on its own (end date, data limit, allowed hours). - let by_admin = (x) => x == 'paused' || x == 'paused_all'; + // The admin's own pauses (and turning a server off or on) are logged by + // rpcd when they happen; here only what changes on its own (end date, + // data limit, allowed hours). + let by_admin = (x) => x == 'paused' || x == 'server_off'; if (prev != null && prev != st && !by_admin(prev) && !by_admin(st)) push(events, { type: st == 'active' ? 'resumed' : 'paused', person: id, detail: REASON[st] ?? st }); // "Remove their devices" when the end date passes. @@ -220,6 +237,10 @@ function watch() { last_hs[id] = max(last_hs[id] ?? 0, peer.handshake); ep = live.endpoint_ip(peer.endpoint); } + // Not in the tunnel (turned off, paused, out of time or data): offline now, and online + // again only with a new handshake, not the one remembered from before. + else + last_hs[id] = 0; let on = last_hs[id] > 0 && now - last_hs[id] < live.ONLINE_WINDOW; let was = last_online[id]; if (on && !was) { diff --git a/package/luci-app-dawnline/root/usr/libexec/dawnline/heartbeat b/package/luci-app-dawnline/root/usr/libexec/dawnline/heartbeat index 9578c41..a72c3d1 100755 --- a/package/luci-app-dawnline/root/usr/libexec/dawnline/heartbeat +++ b/package/luci-app-dawnline/root/usr/libexec/dawnline/heartbeat @@ -1,9 +1,17 @@ #!/bin/sh # Cron, every 5 minutes: the watchdog lives in the agent, so this looks after -# the agent itself and kills it when it runs but has stopped ticking (procd -# starts it again). Off with the watchdog (Health → Watchdog). -[ "$(uci -q get dawnline.settings.watchdog)" = 0 ] && exit 0 +# the agent itself: ends any copy that isn't procd's, and kills procd's when it +# runs but has stopped ticking (procd starts it again; that part is off with +# the watchdog, Health → Watchdog). pid="$(ubus call service list '{"name":"dawnline"}' 2>/dev/null | jsonfilter -q -e '@.dawnline.instances.agent.pid')" + +# Only procd's agent: any other copy (started by hand, or left by an older version that let +# it start) runs stale code beside it, with its own events and syncs. Always ended. +for p in $(pgrep -f '^/usr/bin/ucode /usr/libexec/dawnline/agent'); do + [ "$p" = "$pid" ] || kill -9 "$p" 2>/dev/null +done + +[ "$(uci -q get dawnline.settings.watchdog)" = 0 ] && exit 0 [ -n "$pid" ] && [ -r "/proc/$pid/stat" ] || exit 0 now="$(date +%s)" diff --git a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css index a50c2ab..fd0ae0a 100644 --- a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css +++ b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.css @@ -1 +1 @@ -@font-face{font-family:Geist;src:url(geist-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2190-21FF,U+2212,U+2215}@font-face{font-family:Geist;src:url(geist-cyrillic-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono;src:url(geist-mono-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}:root{--bg: #fcfcfc;--card: #ffffff;--elevated: #ffffff;--text: #0d0d0d;--muted: #5d5d5d;--faint: #8f8f8f;--line: #0000001a;--input: #00000026;--soft: #0d0d0d0d;--soft-hover: #0d0d0d1a;--primary: #0d0d0d;--primary-fg: #ffffff;--accent: #3a83f7;--info: #2c67c5;--ok: #00a240;--ok-wash: #00a24026;--warn: #e25507;--warn-wash: #e2550726;--bad: #e02e2a;--bad-wash: #e02e2a1f;--chart: #3a83f7;--track: #0d0d0d1a;--scrim: #00000040;--shadow: 0 1px 2px -1px #00000014;--shadow-xl: 0 8px 16px -4px #0000001f;--radius: 16px;--mono: "Geist Mono", ui-monospace, Menlo, monospace;color-scheme:light dark}@media(prefers-color-scheme:dark){:root{--bg: #000000;--card: #0a0a0a;--elevated: #131313;--text: #ededed;--muted: #edededa6;--faint: #ededed78;--line: #ededed13;--input: #ededed24;--soft: #ededed0d;--soft-hover: #ededed1a;--primary: #ededed;--primary-fg: #131313;--accent: #006efe;--info: #5ba2fe;--ok: #40c977;--ok-wash: #40c97726;--warn: #ff8549;--warn-wash: #ff854926;--bad: #ff6764;--bad-wash: #ff676422;--chart: #3a83f7;--track: #ededed1a;--scrim: #00000099;--shadow: none;--shadow-xl: 0 8px 16px -4px #00000080}}*{box-sizing:border-box}html,body{margin:0}body{background:var(--bg);color:var(--text);font:400 15px/22px Geist,-apple-system,system-ui,Segoe UI,sans-serif;-webkit-font-smoothing:antialiased;min-height:100vh;min-height:100dvh}body.locked{overflow:hidden}a{color:var(--info);text-decoration:none}a:hover{text-decoration:underline}h1,h2{margin:0;font-weight:500;letter-spacing:-.01em}h1{font-size:24px;line-height:32px}h2{font-size:16px;line-height:24px}.muted{color:var(--muted)}.faint{color:var(--faint)}.s{font-size:13px;line-height:18px}.ok{color:var(--ok)}.warn{color:var(--warn)}.strong{font-weight:500}.center{text-align:center}.mono{font-family:var(--mono);font-size:12px}.stack{display:flex;flex-direction:column;gap:2px;min-width:0}.stack.gap{gap:10px}.grow{flex:1}.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.row.gap{gap:8px;flex-wrap:nowrap}.row-baseline{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}.offscreen{position:fixed;left:-9999px;opacity:0}.top{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:max(12px,env(safe-area-inset-top)) 16px 12px;border-bottom:1px solid var(--line);position:sticky;top:0;background:color-mix(in srgb,var(--bg) 85%,transparent);backdrop-filter:saturate(180%) blur(12px);z-index:5}.brand{display:flex;align-items:center;gap:8px;font-weight:500;min-width:0}.brand .faint{font-weight:400}.logo{display:inline-flex;width:22px;height:22px;color:var(--text)}.logo svg{width:100%;height:100%}.wrap{width:100%;max-width:1048px;margin:0 auto;padding:20px 16px max(32px,env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:20px}.hello{display:flex;align-items:center;gap:12px}.avatar{width:44px;height:44px;border-radius:50%;background:var(--soft-hover);display:inline-flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;position:relative;flex:0 0 auto}.avatar.online:after{content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 3px var(--bg)}.pill{display:inline-flex;align-items:center;height:22px;padding:0 9px;border-radius:999px;font-size:12px;font-weight:500;background:var(--soft);color:var(--muted)}.pill.ok{background:var(--ok-wash);color:var(--ok)}.pill.warn{background:var(--warn-wash);color:var(--warn)}.pill.bad{background:var(--bad-wash);color:var(--bad)}.notice{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:12px;background:var(--warn-wash);font-size:14px}.notice.bad{background:var(--bad-wash)}.notice .ic{color:var(--warn)}.notice.bad .ic{color:var(--bad)}.layout{display:grid;grid-template-columns:minmax(0,1fr);gap:20px;grid-template-areas:"access" "devices"}.access{grid-area:access}.devices{grid-area:devices;display:flex;flex-direction:column;gap:12px;min-width:0}.desktop-only{display:none!important}@media(min-width:960px){.top{padding-left:max(16px,calc((100vw - 1048px)/2 + 16px));padding-right:max(16px,calc((100vw - 1048px)/2 + 16px))}.layout{grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);grid-template-areas:"devices access";align-items:start;gap:16px}.desktop-only{display:inline-flex!important}.wrap{padding-top:28px}}.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:16px;box-shadow:var(--shadow);min-width:0}.card-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.access{display:flex;flex-direction:column;gap:12px;min-width:0}.access-card{display:flex;flex-direction:column;gap:12px}.reach{display:flex;align-items:center;gap:12px;padding:12px;border-radius:12px;background:var(--soft)}.reach-ic{width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}.tile{border:1px solid var(--line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:8px;min-width:0}.tiles2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.tile-label{display:flex;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--faint)}.tile-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.tile-value.sm{font-size:16px}.tile-value .faint{font-size:14px;font-weight:400}.meter{position:relative;height:6px;border-radius:999px;background:var(--track);cursor:default}.meter i{display:block;height:100%;border-radius:999px;background:var(--accent)}.meter.warn i{background:var(--warn)}.meter.bad i{background:var(--bad)}.slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.slots i{display:block;height:4px;border-radius:999px;background:var(--track)}.slots i.used{background:var(--text)}.slots i.over{background:color-mix(in srgb,var(--warn) 80%,transparent)}.dgrid{display:grid;grid-template-columns:minmax(0,1fr);gap:10px}@media(min-width:640px){.dgrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}}.dgrid>.slot.add:only-child{grid-column:1 / -1}.dcard{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--shadow)}.dcard.online{border-color:color-mix(in srgb,var(--ok) 35%,transparent)}.dcard.off{opacity:.7}.dhead{display:flex;align-items:center;gap:12px}.dic{width:40px;height:40px;border-radius:12px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--muted)}.dic .ic-svg{width:20px;height:20px}.dcard.online .dic{background:var(--ok-wash);color:var(--ok)}.dcard.here{border:1.5px dotted color-mix(in srgb,var(--accent) 80%,transparent)}.dcard.here .dic{background:color-mix(in srgb,var(--accent) 16%,transparent);color:var(--info)}.dstat.here{color:var(--info)}.dot.here{background:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 22%,transparent)}.dname{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dstat{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--muted)}.dstat.ok{color:var(--ok)}.dstat.warn{color:var(--warn)}.dot{width:6px;height:6px;border-radius:50%;background:var(--faint);display:inline-block;flex:0 0 auto}.dot.ok{background:var(--ok);box-shadow:0 0 0 3px var(--ok-wash)}.dot.warn{background:var(--warn)}.dot.pulse{animation:pulse 1.6s ease-in-out infinite}@keyframes pulse{0%,to{box-shadow:0 0 0 0 var(--warn-wash)}50%{box-shadow:0 0 0 6px transparent}}.duse{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.spark{display:flex;align-items:flex-end;gap:3px;height:26px;width:128px}.spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--chart);opacity:.85;cursor:default}.spark i.zero{opacity:.22}.spark i:hover{opacity:1;filter:brightness(1.2)}.names{display:flex;flex-direction:column;gap:10px;padding:12px;border-radius:12px;border:1px solid var(--line)}.names-head{display:flex;gap:10px;align-items:flex-start}.names-ic{width:28px;height:28px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;flex:none;background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}.names-ic .ic-svg{width:15px;height:15px}.names-list{display:flex;flex-wrap:wrap;gap:6px}.name-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;height:28px;max-width:100%;padding:0 9px 0 10px;border-radius:999px;background:var(--soft)}.name-chip:hover{background:var(--soft-hover)}.name-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.name-chip .mono{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.name-chip .ic-svg{width:13px;height:13px;color:var(--faint)}.slot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:14px;padding:16px;min-height:72px;border:1px dashed var(--input);border-radius:var(--radius);color:var(--text);text-align:left;transition:background .15s,border-color .15s}.slot.add:hover{background:var(--soft);border-color:color-mix(in srgb,var(--text) 30%,transparent)}.slot-ic{width:40px;height:40px;border-radius:12px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--muted)}.slot.add:hover .slot-ic{background:var(--primary);color:var(--primary-fg)}.slot.add:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(min-width:960px){.slot.add{flex-direction:column;justify-content:center;gap:10px;min-height:140px;text-align:center;color:var(--muted)}.slot.add .stack{align-items:center}.slot.add .strong{color:var(--text)}.slot.add .slot-ic{border-radius:999px;width:36px;height:36px}}.ic{display:inline-flex;line-height:0}.ic-svg{width:16px;height:16px}.btn{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 16px;border-radius:999px;font-size:14px;font-weight:500;background:var(--soft);color:var(--text);-webkit-tap-highlight-color:transparent;white-space:nowrap}.btn:hover{background:var(--soft-hover)}.btn.primary{background:var(--primary);color:var(--primary-fg)}.btn.primary:hover{opacity:.9}.btn.danger-solid{background:var(--bad);color:#fff}.btn.small{height:32px;padding:0 12px;font-size:13px}.btn.big{height:48px;font-size:15px}.btn.block{display:flex;width:100%}.btn[disabled]{opacity:.45;cursor:not-allowed}.btn:focus-visible,.kind:focus-visible,.icon-btn:focus-visible,.slot:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.icon-btn{all:unset;cursor:pointer;width:36px;height:36px;display:inline-flex;align-items:center;justify-content:center;border-radius:50%;color:var(--muted);flex:0 0 auto}.icon-btn:hover{background:var(--soft);color:var(--text)}.icon-btn.soft{background:var(--soft)}@media(pointer:coarse){.icon-btn{width:40px;height:40px}}input[type=text]{width:100%;font:inherit;color:var(--text);background:var(--card);border:1px solid var(--input);border-radius:10px;padding:0 12px;height:44px}input[type=text]:focus{outline:2px solid color-mix(in srgb,var(--accent) 60%,transparent);outline-offset:0;border-color:transparent}.lbl{display:block;font-size:13px;font-weight:500;color:var(--muted);margin:14px 2px 6px}.err{color:var(--bad);min-height:1.2em;margin:8px 2px;font-size:14px}.kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.kind{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;min-width:0;border-radius:12px;box-shadow:inset 0 0 0 1px var(--line);color:var(--muted);font-size:12.5px;font-weight:500;text-align:center}.kind .ic-svg{width:20px;height:20px}.kind:hover{color:var(--text);background:color-mix(in srgb,var(--text) 4%,transparent)}.kind.on{box-shadow:inset 0 0 0 1.5px var(--accent);color:var(--text);background:color-mix(in srgb,var(--accent) 10%,transparent)}.kind.on .ic{color:var(--accent)}.signin{text-align:center;max-width:420px;margin:8vh auto 0;width:100%;padding:28px 20px;display:flex;flex-direction:column;gap:10px}.hero-ic{width:52px;height:52px;margin:0 auto 6px;border-radius:16px;display:grid;place-items:center;background:var(--primary);color:var(--primary-fg)}.hero-ic .ic-svg{width:24px;height:24px}.signin input{text-align:center;margin-top:8px}.menu{position:absolute;z-index:30;width:230px;padding:4px;border-radius:14px;background:var(--elevated);border:1px solid var(--line);box-shadow:var(--shadow-xl)}.menu-item{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;width:100%;height:40px;padding:0 12px;border-radius:10px;font-size:14px}.menu-item:hover,.menu-item:focus-visible{background:var(--soft-hover)}.menu-item .ic{color:var(--muted)}.menu-item.danger,.menu-item.danger .ic{color:var(--bad)}.menu-sep{height:1px;background:var(--line);margin:4px 8px}@media(pointer:coarse){.menu-item{height:44px}}.sheet{position:fixed;inset:0;z-index:20;display:flex;align-items:flex-end;justify-content:center;background:transparent;transition:background .2s}.sheet.open{background:var(--scrim)}.sheet-panel{width:100%;max-width:520px;max-height:92vh;max-height:92dvh;overflow:auto;background:var(--elevated);border-radius:20px 20px 0 0;border:1px solid var(--line);border-bottom:0;padding:6px 16px max(20px,env(safe-area-inset-bottom));transform:translateY(100%);transition:transform .25s cubic-bezier(.2,.8,.2,1)}.sheet.open .sheet-panel{transform:none}.grab{width:36px;height:4px;border-radius:999px;background:var(--input);margin:4px auto 8px}.sheet-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;padding:4px 0 12px}.sheet-head h2{font-size:20px;line-height:28px;font-weight:600}.sheet-body{display:flex;flex-direction:column;gap:14px}@media(min-width:640px){.sheet{align-items:center}.sheet-panel{border-radius:16px;border-bottom:1px solid var(--line);padding:20px;max-width:480px;transform:scale(.97);opacity:0;transition:transform .18s ease,opacity .18s ease}.sheet.open .sheet-panel{transform:none;opacity:1}.grab{display:none}}.tabs{display:flex;gap:4px;padding:4px;background:var(--soft);border-radius:999px}.tabs button{all:unset;cursor:pointer;flex:1 1 auto;white-space:nowrap;text-align:center;padding:7px 10px;border-radius:999px;font-weight:500;font-size:13px;color:var(--muted)}.tabs button.on{background:var(--soft-hover);color:var(--text)}.pane{display:flex;flex-direction:column;gap:10px}.pane.center{align-items:center;text-align:center}.qr{width:min(240px,70vw);aspect-ratio:1;background:#fff;border-radius:12px;padding:10px;box-shadow:inset 0 0 0 1px var(--line)}.qr svg{display:block;width:100%;height:100%}.steps{margin:4px 0 0;padding:14px 16px 14px 34px;border-radius:14px;border:1px solid var(--line);background:var(--card);display:flex;flex-direction:column;gap:8px;font-size:14px}.keybox{display:flex;align-items:center;gap:8px;height:44px;padding:0 6px 0 12px;border:1px solid var(--input);border-radius:10px}.keybox .mono{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--muted)}.filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--soft);min-width:0}.filecard>.stack{flex:1;min-width:0}.filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--mono);color:var(--muted);background:var(--card);box-shadow:inset 0 0 0 1px var(--line)}.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}@media(max-width:480px){.filecard .ellipsis{white-space:normal;overflow-wrap:anywhere}}.confbox{border:1px solid var(--line);border-radius:12px}.confbox>summary{list-style:none;display:flex;align-items:center;gap:8px;padding:8px 10px 8px 12px;color:var(--text)}.confbox>summary::-webkit-details-marker{display:none}.confbox>summary>.ic:first-child{transition:transform .15s;color:var(--muted)}.confbox[open]>summary>.ic:first-child{transform:rotate(90deg)}.confbox .grow{flex:1}.confbox>.conf{margin:0;border-top:1px solid var(--line);border-radius:0 0 12px 12px;background:none}.conf-sec{color:var(--accent, var(--info))}.conf-k{color:var(--faint)}.conf-mask{padding:0 6px;border-radius:4px;background:var(--soft);color:var(--muted)}.conf{white-space:pre-wrap;word-break:break-all;font:12px/18px var(--mono);background:var(--soft);border-radius:10px;padding:12px;max-height:16rem;overflow:auto}details>summary{cursor:pointer;color:var(--muted);font-size:13px;font-weight:500}.waiting{display:flex;align-items:center;gap:10px;padding:12px 14px;border-radius:12px;background:var(--soft);font-size:14px}.tip{position:fixed;z-index:50;transform:translate(-50%,-100%);padding:6px 10px;border-radius:10px;font-size:12px;line-height:17px;white-space:nowrap;background:var(--elevated);border:1px solid var(--line);box-shadow:var(--shadow-xl);pointer-events:none}.tip-title{font-weight:500}.toast{position:fixed;left:50%;bottom:max(20px,env(safe-area-inset-bottom));transform:translate(-50%,20px);opacity:0;z-index:60;background:var(--primary);color:var(--primary-fg);padding:10px 16px;border-radius:999px;font-weight:500;font-size:14px;transition:all .25s;max-width:90vw}.toast.show{opacity:1;transform:translate(-50%)}.toast.bad{background:var(--bad);color:#fff}@media(prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}} +@font-face{font-family:Geist;src:url(geist-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+2000-206F,U+20AC,U+2122,U+2190-21FF,U+2212,U+2215}@font-face{font-family:Geist;src:url(geist-cyrillic-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap;unicode-range:U+0301,U+0400-045F,U+0490-0491,U+04B0-04B1,U+2116}@font-face{font-family:Geist Mono;src:url(geist-mono-latin-wght-normal.woff2) format("woff2");font-weight:100 900;font-display:swap}:root{--bg: #fcfcfc;--card: #ffffff;--elevated: #ffffff;--text: #0d0d0d;--muted: #5d5d5d;--faint: #8f8f8f;--line: #0000001a;--input: #00000026;--soft: #0d0d0d0d;--soft-hover: #0d0d0d1a;--primary: #0d0d0d;--primary-fg: #ffffff;--accent: #3a83f7;--info: #2c67c5;--ok: #00a240;--ok-wash: #00a24026;--warn: #e25507;--warn-wash: #e2550726;--bad: #e02e2a;--bad-wash: #e02e2a1f;--chart: #3a83f7;--track: #0d0d0d1a;--scrim: #00000040;--shadow: 0 1px 2px -1px #00000014;--shadow-xl: 0 8px 16px -4px #0000001f;--radius: 16px;--mono: "Geist Mono", ui-monospace, Menlo, monospace;color-scheme:light dark}@media(prefers-color-scheme:dark){:root{--bg: #000000;--card: #0a0a0a;--elevated: #131313;--text: #ededed;--muted: #edededa6;--faint: #ededed78;--line: #ededed13;--input: #ededed24;--soft: #ededed0d;--soft-hover: #ededed1a;--primary: #ededed;--primary-fg: #131313;--accent: #006efe;--info: #5ba2fe;--ok: #40c977;--ok-wash: #40c97726;--warn: #ff8549;--warn-wash: #ff854926;--bad: #ff6764;--bad-wash: #ff676422;--chart: #3a83f7;--track: #ededed1a;--scrim: #00000099;--shadow: none;--shadow-xl: 0 8px 16px -4px #00000080}}*{box-sizing:border-box}html,body{margin:0}body{background:var(--bg);color:var(--text);font:400 15px/22px Geist,-apple-system,system-ui,Segoe UI,sans-serif;-webkit-font-smoothing:antialiased;min-height:100vh;min-height:100dvh}body.locked{overflow:hidden}a{color:var(--info);text-decoration:none}a:hover{text-decoration:underline}h1,h2{margin:0;font-weight:500;letter-spacing:-.01em}h1{font-size:24px;line-height:32px}h2{font-size:16px;line-height:24px}.muted{color:var(--muted)}.faint{color:var(--faint)}.s{font-size:13px;line-height:18px}.ok{color:var(--ok)}.warn{color:var(--warn)}.strong{font-weight:500}.center{text-align:center}.mono{font-family:var(--mono);font-size:12px}.stack{display:flex;flex-direction:column;gap:2px;min-width:0}.stack.gap{gap:10px}.grow{flex:1}.row{display:flex;align-items:center;gap:8px;flex-wrap:wrap}.row.gap{gap:8px;flex-wrap:nowrap}.row-baseline{display:flex;align-items:baseline;gap:10px;flex-wrap:wrap}.offscreen{position:fixed;left:-9999px;opacity:0}.top{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:max(12px,env(safe-area-inset-top)) 16px 12px;border-bottom:1px solid var(--line);position:sticky;top:0;background:color-mix(in srgb,var(--bg) 85%,transparent);backdrop-filter:saturate(180%) blur(12px);z-index:5}.brand{display:flex;align-items:center;gap:8px;font-weight:500;min-width:0}.brand .faint{font-weight:400}.logo{display:inline-flex;width:22px;height:22px;color:var(--text)}.logo svg{width:100%;height:100%}.wrap{width:100%;max-width:1048px;margin:0 auto;padding:20px 16px max(32px,env(safe-area-inset-bottom));display:flex;flex-direction:column;gap:20px}.hello{display:flex;align-items:center;gap:12px}.avatar{width:44px;height:44px;border-radius:50%;background:var(--soft-hover);display:inline-flex;align-items:center;justify-content:center;font-size:14px;font-weight:600;position:relative;flex:0 0 auto}.avatar.online:after{content:"";position:absolute;right:0;bottom:0;width:10px;height:10px;border-radius:50%;background:var(--ok);box-shadow:0 0 0 3px var(--bg)}.notice{display:flex;gap:10px;align-items:flex-start;padding:12px 14px;border-radius:12px;background:var(--warn-wash);font-size:14px}.notice.bad{background:var(--bad-wash)}.notice .ic{color:var(--warn)}.notice.bad .ic{color:var(--bad)}.alert{display:flex;gap:12px;align-items:center;padding:12px 16px;border:1px solid var(--line);border-radius:12px;background:var(--card);font-size:14px;line-height:20px}.alert-ic{width:30px;height:30px;border-radius:9px;display:inline-flex;align-items:center;justify-content:center;flex:none;background:var(--warn-wash);color:var(--warn)}.alert-ic.bad{background:var(--bad-wash);color:var(--bad)}.alert-ic .ic-svg{width:15px;height:15px}.layout{display:grid;grid-template-columns:minmax(0,1fr);gap:20px;grid-template-areas:"access" "devices"}.access{grid-area:access}.devices{grid-area:devices;display:flex;flex-direction:column;gap:12px;min-width:0}.desktop-only{display:none!important}@media(min-width:960px){.top{padding-left:max(16px,calc((100vw - 1048px)/2 + 16px));padding-right:max(16px,calc((100vw - 1048px)/2 + 16px))}.layout{grid-template-columns:minmax(0,1.7fr) minmax(0,1fr);grid-template-areas:"devices access";align-items:start;gap:16px}.desktop-only{display:inline-flex!important}.wrap{padding-top:28px}}.card{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:16px;box-shadow:var(--shadow);min-width:0}.card-head{display:flex;align-items:center;justify-content:space-between;gap:12px}.access{display:flex;flex-direction:column;gap:12px;min-width:0}.access-card{display:flex;flex-direction:column;gap:12px}.reach{display:flex;align-items:center;gap:12px;padding:12px;border-radius:12px;background:var(--soft)}.reach-ic{width:36px;height:36px;border-radius:10px;display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}.tile{border:1px solid var(--line);border-radius:14px;padding:14px;display:flex;flex-direction:column;gap:8px;min-width:0}.tiles2{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.tile-label{display:flex;justify-content:space-between;gap:8px;font-size:12px;font-weight:500;color:var(--faint)}.tile-value{font-size:20px;line-height:28px;font-weight:500;letter-spacing:-.01em;font-variant-numeric:tabular-nums}.tile-value.sm{font-size:16px}.tile-value .faint{font-size:14px;font-weight:400}.meter{position:relative;height:6px;border-radius:999px;background:var(--track);cursor:default}.meter i{display:block;height:100%;border-radius:999px;background:var(--accent)}.meter.warn i{background:var(--warn)}.meter.bad i{background:var(--bad)}.slots{display:grid;grid-auto-flow:column;grid-auto-columns:minmax(0,1fr);gap:3px}.slots i{display:block;height:4px;border-radius:999px;background:var(--track)}.slots i.used{background:var(--text)}.slots i.over{background:color-mix(in srgb,var(--warn) 80%,transparent)}.dgrid{display:grid;grid-template-columns:minmax(0,1fr);gap:10px}@media(min-width:640px){.dgrid{grid-template-columns:repeat(2,minmax(0,1fr));gap:12px}}.dgrid>.slot.add:only-child{grid-column:1 / -1}.dcard{background:var(--card);border:1px solid var(--line);border-radius:var(--radius);padding:14px;display:flex;flex-direction:column;gap:12px;min-width:0;box-shadow:var(--shadow)}.dcard.online{border-color:color-mix(in srgb,var(--ok) 35%,transparent)}.dcard.off{opacity:.7}.dhead{display:flex;align-items:center;gap:12px}.dic{width:40px;height:40px;border-radius:12px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--muted)}.dic .ic-svg{width:20px;height:20px}.dcard.online .dic{background:var(--ok-wash);color:var(--ok)}.dcard.here{border:1.5px dotted color-mix(in srgb,var(--accent) 80%,transparent)}.dcard.here .dic{background:color-mix(in srgb,var(--accent) 16%,transparent);color:var(--info)}.dstat.here{color:var(--info)}.dot.here{background:var(--accent);box-shadow:0 0 0 3px color-mix(in srgb,var(--accent) 22%,transparent)}.dname{font-weight:500;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.dstat{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var(--muted)}.dstat.ok{color:var(--ok)}.dstat.warn{color:var(--warn)}.dot{width:6px;height:6px;border-radius:50%;background:var(--faint);display:inline-block;flex:0 0 auto}.dot.ok{background:var(--ok);box-shadow:0 0 0 3px var(--ok-wash)}.dot.warn{background:var(--warn)}.dot.pulse{animation:pulse 1.6s ease-in-out infinite}@keyframes pulse{0%,to{box-shadow:0 0 0 0 var(--warn-wash)}50%{box-shadow:0 0 0 6px transparent}}.duse{display:flex;align-items:flex-end;justify-content:space-between;gap:12px}.spark{display:flex;align-items:flex-end;gap:3px;height:26px;width:128px}.spark i{flex:1;display:block;border-radius:2px 2px 0 0;background:var(--chart);opacity:.85;cursor:default}.spark i.zero{opacity:.22}.spark i:hover{opacity:1;filter:brightness(1.2)}.names{display:flex;flex-direction:column;gap:10px;padding:12px;border-radius:12px;border:1px solid var(--line)}.names-head{display:flex;gap:10px;align-items:flex-start}.names-ic{width:28px;height:28px;border-radius:8px;display:inline-flex;align-items:center;justify-content:center;flex:none;background:color-mix(in srgb,var(--info) 14%,transparent);color:var(--info)}.names-ic .ic-svg{width:15px;height:15px}.names-list{display:flex;flex-wrap:wrap;gap:6px}.name-chip{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;gap:6px;height:28px;max-width:100%;padding:0 9px 0 10px;border-radius:999px;background:var(--soft)}.name-chip:hover{background:var(--soft-hover)}.name-chip:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.name-chip .mono{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}.name-chip .ic-svg{width:13px;height:13px;color:var(--faint)}.slot.add{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:14px;padding:16px;min-height:72px;border:1px dashed var(--input);border-radius:var(--radius);color:var(--text);text-align:left;transition:background .15s,border-color .15s}.slot.add:hover{background:var(--soft);border-color:color-mix(in srgb,var(--text) 30%,transparent)}.slot-ic{width:40px;height:40px;border-radius:12px;background:var(--soft);display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--muted)}.slot.add:hover .slot-ic{background:var(--primary);color:var(--primary-fg)}.slot.add:focus-visible{outline:2px solid var(--accent);outline-offset:2px}@media(min-width:960px){.slot.add{flex-direction:column;justify-content:center;gap:10px;min-height:140px;text-align:center;color:var(--muted)}.slot.add .stack{align-items:center}.slot.add .strong{color:var(--text)}.slot.add .slot-ic{border-radius:999px;width:36px;height:36px}}.ic{display:inline-flex;line-height:0}.ic-svg{width:16px;height:16px}.btn{all:unset;box-sizing:border-box;cursor:pointer;display:inline-flex;align-items:center;justify-content:center;gap:8px;height:40px;padding:0 16px;border-radius:999px;font-size:14px;font-weight:500;background:var(--soft);color:var(--text);-webkit-tap-highlight-color:transparent;white-space:nowrap}.btn:hover{background:var(--soft-hover)}.btn.primary{background:var(--primary);color:var(--primary-fg)}.btn.primary:hover{opacity:.9}.btn.danger-solid{background:var(--bad);color:#fff}.btn.small{height:32px;padding:0 12px;font-size:13px}.btn.big{height:48px;font-size:15px}.btn.block{display:flex;width:100%}.btn[disabled]{opacity:.45;cursor:not-allowed}.btn:focus-visible,.kind:focus-visible,.icon-btn:focus-visible,.slot:focus-visible{outline:2px solid var(--accent);outline-offset:2px}.icon-btn{all:unset;cursor:pointer;width:36px;height:36px;display:inline-flex;align-items:center;justify-content:center;border-radius:50%;color:var(--muted);flex:0 0 auto}.icon-btn:hover{background:var(--soft);color:var(--text)}.icon-btn.soft{background:var(--soft)}@media(pointer:coarse){.icon-btn{width:40px;height:40px}}input[type=text]{width:100%;font:inherit;color:var(--text);background:var(--card);border:1px solid var(--input);border-radius:10px;padding:0 12px;height:44px}input[type=text]:focus{outline:2px solid color-mix(in srgb,var(--accent) 60%,transparent);outline-offset:0;border-color:transparent}.lbl{display:block;font-size:13px;font-weight:500;color:var(--muted);margin:14px 2px 6px}.err{color:var(--bad);min-height:1.2em;margin:8px 2px;font-size:14px}.kinds{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:6px}.kind{all:unset;box-sizing:border-box;cursor:pointer;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;height:68px;min-width:0;border-radius:12px;box-shadow:inset 0 0 0 1px var(--line);color:var(--muted);font-size:12.5px;font-weight:500;text-align:center}.kind .ic-svg{width:20px;height:20px}.kind:hover{color:var(--text);background:color-mix(in srgb,var(--text) 4%,transparent)}.kind.on{box-shadow:inset 0 0 0 1.5px var(--accent);color:var(--text);background:color-mix(in srgb,var(--accent) 10%,transparent)}.kind.on .ic{color:var(--accent)}.signin{text-align:center;max-width:420px;margin:8vh auto 0;width:100%;padding:28px 20px;display:flex;flex-direction:column;gap:10px}.hero-ic{width:52px;height:52px;margin:0 auto 6px;border-radius:16px;display:grid;place-items:center;background:var(--primary);color:var(--primary-fg)}.hero-ic .ic-svg{width:24px;height:24px}.signin input{text-align:center;margin-top:8px}.menu{position:absolute;z-index:30;width:230px;padding:4px;border-radius:14px;background:var(--elevated);border:1px solid var(--line);box-shadow:var(--shadow-xl)}.menu-item{all:unset;box-sizing:border-box;cursor:pointer;display:flex;align-items:center;gap:10px;width:100%;height:40px;padding:0 12px;border-radius:10px;font-size:14px}.menu-item:hover,.menu-item:focus-visible{background:var(--soft-hover)}.menu-item .ic{color:var(--muted)}.menu-item.danger,.menu-item.danger .ic{color:var(--bad)}.menu-sep{height:1px;background:var(--line);margin:4px 8px}@media(pointer:coarse){.menu-item{height:44px}}.sheet{position:fixed;inset:0;z-index:20;display:flex;align-items:flex-end;justify-content:center;background:transparent;transition:background .2s}.sheet.open{background:var(--scrim)}.sheet-panel{width:100%;max-width:520px;max-height:92vh;max-height:92dvh;overflow:auto;background:var(--elevated);border-radius:20px 20px 0 0;border:1px solid var(--line);border-bottom:0;padding:6px 16px max(20px,env(safe-area-inset-bottom));transform:translateY(100%);transition:transform .25s cubic-bezier(.2,.8,.2,1)}.sheet.open .sheet-panel{transform:none}.grab{width:36px;height:4px;border-radius:999px;background:var(--input);margin:4px auto 8px}.sheet-head{display:flex;align-items:flex-start;justify-content:space-between;gap:8px;padding:4px 0 12px}.sheet-head h2{font-size:20px;line-height:28px;font-weight:600}.sheet-body{display:flex;flex-direction:column;gap:14px}@media(min-width:640px){.sheet{align-items:center}.sheet-panel{border-radius:16px;border-bottom:1px solid var(--line);padding:20px;max-width:480px;transform:scale(.97);opacity:0;transition:transform .18s ease,opacity .18s ease}.sheet.open .sheet-panel{transform:none;opacity:1}.grab{display:none}}.tabs{display:flex;gap:4px;padding:4px;background:var(--soft);border-radius:999px}.tabs button{all:unset;cursor:pointer;flex:1 1 auto;white-space:nowrap;text-align:center;padding:7px 10px;border-radius:999px;font-weight:500;font-size:13px;color:var(--muted)}.tabs button.on{background:var(--soft-hover);color:var(--text)}.pane{display:flex;flex-direction:column;gap:10px}.pane.center{align-items:center;text-align:center}.qr{width:min(240px,70vw);aspect-ratio:1;background:#fff;border-radius:12px;padding:10px;box-shadow:inset 0 0 0 1px var(--line)}.qr svg{display:block;width:100%;height:100%}.steps{margin:4px 0 0;padding:14px 16px 14px 34px;border-radius:14px;border:1px solid var(--line);background:var(--card);display:flex;flex-direction:column;gap:8px;font-size:14px}.keybox{display:flex;align-items:center;gap:8px;height:44px;padding:0 6px 0 12px;border:1px solid var(--input);border-radius:10px}.keybox .mono{flex:1;min-width:0;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:var(--muted)}.filecard{display:flex;align-items:center;gap:12px;padding:12px;border-radius:14px;background:var(--soft);min-width:0}.filecard>.stack{flex:1;min-width:0}.filecard-ic{width:40px;height:46px;border-radius:8px;flex:none;display:inline-flex;align-items:center;justify-content:center;font:10px var(--mono);color:var(--muted);background:var(--card);box-shadow:inset 0 0 0 1px var(--line)}.ellipsis{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0}@media(max-width:480px){.filecard .ellipsis{white-space:normal;overflow-wrap:anywhere}}.confbox{border:1px solid var(--line);border-radius:12px}.confbox>summary{list-style:none;display:flex;align-items:center;gap:8px;padding:8px 10px 8px 12px;color:var(--text)}.confbox>summary::-webkit-details-marker{display:none}.confbox>summary>.ic:first-child{transition:transform .15s;color:var(--muted)}.confbox[open]>summary>.ic:first-child{transform:rotate(90deg)}.confbox .grow{flex:1}.confbox>.conf{margin:0;border-top:1px solid var(--line);border-radius:0 0 12px 12px;background:none}.conf-sec{color:var(--accent, var(--info))}.conf-k{color:var(--faint)}.conf-mask{padding:0 6px;border-radius:4px;background:var(--soft);color:var(--muted)}.conf{white-space:pre-wrap;word-break:break-all;font:12px/18px var(--mono);background:var(--soft);border-radius:10px;padding:12px;max-height:16rem;overflow:auto}details>summary{cursor:pointer;color:var(--muted);font-size:13px;font-weight:500}.waiting{display:flex;align-items:center;gap:10px;padding:12px 14px;border-radius:12px;background:var(--soft);font-size:14px}.tip{position:fixed;z-index:50;transform:translate(-50%,-100%);padding:6px 10px;border-radius:10px;font-size:12px;line-height:17px;white-space:nowrap;background:var(--elevated);border:1px solid var(--line);box-shadow:var(--shadow-xl);pointer-events:none}.tip-title{font-weight:500}.toast{position:fixed;left:50%;bottom:max(20px,env(safe-area-inset-bottom));transform:translate(-50%,20px);opacity:0;z-index:60;background:var(--primary);color:var(--primary-fg);padding:10px 16px;border-radius:999px;font-weight:500;font-size:14px;transition:all .25s;max-width:90vw}.toast.show{opacity:1;transform:translate(-50%)}.toast.bad{background:var(--bad);color:#fff}@media(prefers-reduced-motion:reduce){*{transition:none!important;animation:none!important}} diff --git a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js index ed4736f..3ba64e8 100644 --- a/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js +++ b/package/luci-app-dawnline/root/usr/share/dawnline/portal/assets/portal.js @@ -1,6 +1,6 @@ -"use strict";(()=>{var it=Object.create;var He=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var ft=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var dt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ct(t))!ut.call(e,u)&&u!==r&&He(e,u,{get:()=>t[u],enumerable:!(i=ot(t,u))||i.enumerable});return e};var ht=(e,t,r)=>(r=e!=null?it(lt(e)):{},dt(t||!e||!e.__esModule?He(r,"default",{value:e,enumerable:!0}):r,e));var je=ft((Ve,Ye)=>{"use strict";var qe=(function(){var e=function(M,A){var b=236,x=17,c=M,m=r[A],s=null,a=0,y=null,d=[],g={},T=function(l,f){a=c*4+17,s=(function(o){for(var h=new Array(o),v=0;v=7&&z(l),y==null&&(y=at(c,m,d)),W(y,f)},D=function(l,f){for(var o=-1;o<=7;o+=1)if(!(l+o<=-1||a<=l+o))for(var h=-1;h<=7;h+=1)f+h<=-1||a<=f+h||(0<=o&&o<=6&&(h==0||h==6)||0<=h&&h<=6&&(o==0||o==6)||2<=o&&o<=4&&2<=h&&h<=4?s[l+o][f+h]=!0:s[l+o][f+h]=!1)},P=function(){for(var l=0,f=0,o=0;o<8;o+=1){T(!0,o);var h=u.getLostPoint(g);(o==0||l>h)&&(l=h,f=o)}return f},I=function(){for(var l=8;l>o&1)==1;s[Math.floor(o/3)][o%3+a-8-3]=h}for(var o=0;o<18;o+=1){var h=!l&&(f>>o&1)==1;s[o%3+a-8-3][Math.floor(o/3)]=h}},Q=function(l,f){for(var o=m<<3|f,h=u.getBCHTypeInfo(o),v=0;v<15;v+=1){var w=!l&&(h>>v&1)==1;v<6?s[v][8]=w:v<8?s[v+1][8]=w:s[a-15+v][8]=w}for(var v=0;v<15;v+=1){var w=!l&&(h>>v&1)==1;v<8?s[8][a-v-1]=w:v<9?s[8][15-v-1+1]=w:s[8][15-v-1]=w}s[a-8][8]=!l},W=function(l,f){for(var o=-1,h=a-1,v=7,w=0,C=u.getMaskFunction(f),_=a-1;_>0;_-=2)for(_==6&&(_-=1);;){for(var N=0;N<2;N+=1)if(s[h][_-N]==null){var K=!1;w>>v&1)==1);var L=C(h,_-N);L&&(K=!K),s[h][_-N]=K,v-=1,v==-1&&(w+=1,v=7)}if(h+=o,h<0||a<=h){h-=o,o=-o;break}}},ae=function(l,f){for(var o=0,h=0,v=0,w=new Array(f.length),C=new Array(f.length),_=0;_=0?Pe.getAt(Ne):0}}for(var Re=0,L=0;L_*8)throw"code length overflow. ("+v.getLengthInBits()+">"+_*8+")";for(v.getLengthInBits()+4<=_*8&&v.put(0,4);v.getLengthInBits()%8!=0;)v.putBit(!1);for(;!(v.getLengthInBits()>=_*8||(v.put(b,8),v.getLengthInBits()>=_*8));)v.put(x,8);return ae(v,h)};g.addData=function(l,f){f=f||"Byte";var o=null;switch(f){case"Numeric":o=B(l);break;case"Alphanumeric":o=q(l);break;case"Byte":o=J(l);break;case"Kanji":o=U(l);break;default:throw"mode:"+f}d.push(o),y=null},g.isDark=function(l,f){if(l<0||a<=l||f<0||a<=f)throw l+","+f;return s[l][f]},g.getModuleCount=function(){return a},g.make=function(){if(c<1){for(var l=1;l<40;l++){for(var f=$.getRSBlocks(l,m),o=E(),h=0;h";for(var v=0;v';o+=""}return o+="",o+="",o},g.createSvgTag=function(l,f,o,h){var v={};typeof arguments[0]=="object"&&(v=arguments[0],l=v.cellSize,f=v.margin,o=v.alt,h=v.title),l=l||2,f=typeof f=="undefined"?l*4:f,o=typeof o=="string"?{text:o}:o||{},o.text=o.text||null,o.id=o.text?o.id||"qrcode-description":null,h=typeof h=="string"?{text:h}:h||{},h.text=h.text||null,h.id=h.text?h.id||"qrcode-title":null;var w=g.getModuleCount()*l+f*2,C,_,N,K,L="",Y;for(Y="l"+l+",0 0,"+l+" -"+l+",0 0,-"+l+"z ",L+=''+se(h.text)+"":"",L+=o.text?''+se(o.text)+"":"",L+='',L+='":f+=">";break;case"&":f+="&";break;case'"':f+=""";break;default:f+=h;break}}return f},st=function(l){var f=1;l=typeof l=="undefined"?f*2:l;var o=g.getModuleCount()*f+l*2,h=l,v=o-l,w,C,_,N,K,L={"██":"█","█ ":"▀"," █":"▄"," ":" "},Y={"██":"▀","█ ":"▀"," █":" "," ":" "},j="";for(w=0;w=v?Y[K]:L[K];j+=` -`}return o%2&&l>0?j.substring(0,j.length-o-1)+Array(o+1).join("▀"):j.substring(0,j.length-1)};return g.createASCII=function(l,f){if(l=l||1,l<2)return st(f);l-=1,f=typeof f=="undefined"?l*2:f;var o=g.getModuleCount()*l+f*2,h=f,v=o-f,w,C,_,N,K=Array(l+1).join("██"),L=Array(l+1).join(" "),Y="",j="";for(w=0;w>>8),m.push(y&255)):m.push(x)}}return m}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},r={L:1,M:0,Q:3,H:2},i={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},u=(function(){var M=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],A=1335,b=7973,x=21522,c={},m=function(s){for(var a=0;s!=0;)a+=1,s>>>=1;return a};return c.getBCHTypeInfo=function(s){for(var a=s<<10;m(a)-m(A)>=0;)a^=A<=0;)a^=b<5&&(y+=3+T-5)}for(var d=0;d=256;)c-=255;return M[c]},x})();function k(M,A){if(typeof M.length=="undefined")throw M.length+"/"+A;var b=(function(){for(var c=0;c>>7-x%8&1)==1},b.put=function(x,c){for(var m=0;m>>c-m-1&1)==1)},b.getLengthInBits=function(){return A},b.putBit=function(x){var c=Math.floor(A/8);M.length<=c&&M.push(0),x&&(M[c]|=128>>>A%8),A+=1},b},B=function(M){var A=t.MODE_NUMBER,b=M,x={};x.getMode=function(){return A},x.getLength=function(s){return b.length},x.write=function(s){for(var a=b,y=0;y+2>>8&255)*192+(d&255),s.put(d,13),y+=2}if(y>>8)},A.writeBytes=function(b,x,c){x=x||0,c=c||b.length;for(var m=0;m0&&(b+=","),b+=M[x];return b+="]",b},A},F=function(){var M=0,A=0,b=0,x="",c={},m=function(a){x+=String.fromCharCode(s(a&63))},s=function(a){if(!(a<0)){if(a<26)return 65+a;if(a<52)return 97+(a-26);if(a<62)return 48+(a-52);if(a==62)return 43;if(a==63)return 47}throw"n:"+a};return c.writeByte=function(a){for(M=M<<8|a&255,A+=8,b+=1;A>=6;)m(M>>>A-6),A-=6},c.flush=function(){if(A>0&&(m(M<<6-A),M=0,A=0),b%3!=0)for(var a=3-b%3,y=0;y=A.length){if(c==0)return-1;throw"unexpected end of file./"+c}var a=A.charAt(b);if(b+=1,a=="=")return c=0,-1;if(a.match(/^\s$/))continue;x=x<<6|s(a.charCodeAt(0)),c+=6}var y=x>>>c-8&255;return c-=8,y};var s=function(a){if(65<=a&&a<=90)return a-65;if(97<=a&&a<=122)return a-97+26;if(48<=a&&a<=57)return a-48+52;if(a==43)return 62;if(a==47)return 63;throw"c:"+a};return m},re=function(M,A){var b=M,x=A,c=new Array(M*A),m={};m.setPixel=function(d,g,T){c[g*b+d]=T},m.write=function(d){d.writeString("GIF87a"),d.writeShort(b),d.writeShort(x),d.writeByte(128),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(255),d.writeByte(255),d.writeByte(255),d.writeString(","),d.writeShort(0),d.writeShort(0),d.writeShort(b),d.writeShort(x),d.writeByte(0);var g=2,T=a(g);d.writeByte(g);for(var D=0;T.length-D>255;)d.writeByte(255),d.writeBytes(T,D,255),D+=255;d.writeByte(T.length-D),d.writeBytes(T,D,T.length-D),d.writeByte(0),d.writeString(";")};var s=function(d){var g=d,T=0,D=0,P={};return P.write=function(I,G){if(I>>>G)throw"length over";for(;T+G>=8;)g.writeByte(255&(I<>>=8-T,D=0,T=0;D=I<0&&g.writeByte(D)},P},a=function(d){for(var g=1<>6,128|p&63):p<55296||p>=57344?i.push(224|p>>12,128|p>>6&63,128|p&63):(u++,p=65536+((p&1023)<<10|r.charCodeAt(u)&1023),i.push(240|p>>18,128|p>>12&63,128|p>>6&63,128|p&63))}return i}return t(e)}})();(function(e){typeof define=="function"&&define.amd?define([],e):typeof Ve=="object"&&(Ye.exports=e())})(function(){return qe})});function ie(e){if(!e||e<0)return"0 B";let t=["B","KB","MB","GB","TB"],r=0,i=e;for(;i>=1024&&r=100||r===0?Math.round(i):i.toFixed(1)} ${t[r]}`}function xe(e,t=Date.now()/1e3){if(!e)return"never";let r=Math.max(0,Math.round(t-e));return r<60?"just now":r<3600?`${Math.floor(r/60)} min ago`:r<86400?`${Math.floor(r/3600)} h ago`:r<86400*30?`${Math.floor(r/86400)} d ago`:new Date(e*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function pe(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function ve(e){let[t,r,i]=e.split("-").map(Number);return new Date(t,(r||1)-1,i||1,12)}function pt(e){return(typeof e=="string"?/^\d{4}-\d{2}-\d{2}$/.test(e)?ve(e):new Date(e):e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function we(e){return e?pt(e):""}function vt(e,t){let r=i=>{let[u,p,k]=i.split("-").map(Number);return Date.UTC(u,p-1,k)};return Math.round((r(e)-r(t))/864e5)}function Ie(e,t){let r=ve(e);return r.setDate(r.getDate()+t),pe(r)}function Me(e,t=Date.now()){if(!e)return null;let r=typeof t=="number"?pe(new Date(t)):t,i=vt(e,r);return i>=0?i+1:i}var Oe={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var ge={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Ke={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Ue(e){var u,p,k;let t=e.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let r=(u=t[0][0])!=null?u:"",i=t.length>1?(p=t[t.length-1][0])!=null?p:"":(k=t[0][1])!=null?k:"";return(r+i).toUpperCase()}function ke(e){let t=r=>r.disabled?3:r.online?0:r.handshake?1:2;return e.map((r,i)=>[r,i]).sort((r,i)=>t(r[0])-t(i[0])||r[1]-i[1]).map(([r])=>r)}var Fe={phone:'',computer:'',tablet:'',router:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function Ge(e,t="dl-icon"){var i;let r=(i=Fe[e])!=null?i:Fe.phone;return``}var ze=ht(je(),1),gt='';function Je(e,t=3,r=!0){let i=(0,ze.default)(0,e.length>300?"Q":"H");i.addData(e,"Byte"),i.make();let u=i.getModuleCount(),p=u+t*2,k=r?Math.round(u*.22):0;k&&(u-k)%2&&k++;let $=(u-k)/2,E=$+k,B=(U,R)=>k>0&&U>=$&&U=$&&R${gt}`}return`${J}`}var mt={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},yt={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function bt(e){let t={};for(let[r,i]of Object.entries(yt))e[r]!=null&&e[r]!==""&&(t[i]=String(e[r]));return t}function xt(e,t){var E;let r=e.amnezia,i=(E=r.obfuscation)!=null?E:{},u=B=>i[B]!=null&&i[B]!==""?String(i[B]):mt[B],p=r.host.replace(/^\[(.*)\]$/,"$1"),k={H1:u("h1"),H2:u("h2"),H3:u("h3"),H4:u("h4"),I1:u("i1"),I2:u("i2"),I3:u("i3"),I4:u("i4"),I5:u("i5"),Jc:u("jc"),Jmin:u("jmin"),Jmax:u("jmax"),S1:u("s1"),S2:u("s2"),S3:u("s3"),S4:u("s4"),...bt(i),allowed_ips:r.allowed_ips,client_ip:r.client_ip,client_priv_key:r.client_priv_key,client_pub_key:r.client_pub_key,config:e.conf.replace(/\r?\n/g,`\r -`),hostName:p,mtu:r.mtu,persistent_keep_alive:r.persistent_keep_alive,port:Number(r.port),psk_key:r.psk_key,server_pub_key:r.server_pub_key},$={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(k),port:String(r.port),protocol_version:i.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:p};return r.dns[0]&&($.dns1=r.dns[0]),r.dns[1]&&($.dns2=r.dns[1]),$}function wt(e){let t="";for(let r=0;r{var e;return(e=S==null?void 0:S.today)!=null?e:pe(new Date)};function n(e,t={},...r){let i=document.createElement(e);for(let[p,k]of Object.entries(t))k==null||k===!1||(p.startsWith("on")&&typeof k=="function"?i.addEventListener(p.slice(2),k):p==="class"?i.className=String(k):k===!0?i.setAttribute(p,""):i.setAttribute(p,String(k)));let u=p=>{p==null||p===!1||(Array.isArray(p)?p.forEach(u):i.appendChild(typeof p=="string"?document.createTextNode(p):p))};return r.forEach(u),i}function O(e){let t=n("span",{class:"ic"});return t.innerHTML=Ge(e,"ic-svg"),t}var kt='',Ee=document.getElementById("app"),We,me=(We=Ee.dataset.base)!=null?We:"",At=Ee.dataset.title||"Dawnline",Ce=()=>window.matchMedia("(max-width: 959px)").matches||/Android|iPhone|iPad/.test(navigator.userAgent),S=null,_t=/^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(me)?me.slice(1):"",Le=class extends Error{constructor(r,i){super(i);this.status=r}};async function ne(e,t){var u;let r=await fetch(`${me}/api/${e}`,{method:t===void 0?"GET":"POST",credentials:"omit",headers:t===void 0?{}:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t),cache:"no-store"}),i=null;try{i=await r.json()}catch{}if(!r.ok)throw new Le(r.status,(u=i==null?void 0:i.error)!=null?u:`Request failed (${r.status})`);return i}function te(e,t=!1){let r=n("div",{class:`toast${t?" bad":""}`,role:"status"},e);document.body.appendChild(r),requestAnimationFrame(()=>r.classList.add("show")),setTimeout(()=>{r.classList.remove("show"),setTimeout(()=>r.remove(),300)},2600)}async function ce(e,t="Copied"){try{await navigator.clipboard.writeText(e)}catch{let r=n("textarea",{class:"offscreen"},e);document.body.appendChild(r),r.select();let i=document.execCommand("copy");if(r.remove(),!i)return te("Copying is blocked here. Select the text and copy it by hand.",!0)}te(t)}function Ze(e,t){let r=URL.createObjectURL(new Blob([t],{type:"application/octet-stream"})),i=n("a",{href:r,download:e,class:"offscreen"});document.body.appendChild(i),i.click(),setTimeout(()=>{URL.revokeObjectURL(r),i.remove()},1e3)}var Z=null;function Xe(e,t){let r=i=>{Z!=null||(Z=document.body.appendChild(n("div",{class:"tip"}))),Z.replaceChildren(...t().map((u,p)=>n("div",{class:p?"muted":"tip-title"},u))),Z.style.display="",Z.style.left=`${i.clientX}px`,Z.style.top=`${i.clientY-10}px`};e.addEventListener("mouseenter",r),e.addEventListener("mousemove",r),e.addEventListener("mouseleave",()=>Z&&(Z.style.display="none"))}function Ct(e){let t=Math.max(1,...e),r=n("div",{class:"spark"});return e.forEach((i,u)=>{let p=n("i",{class:i?"":"zero"});p.style.height=`${Math.max(8,i/t*100)}%`;let k=e.length-1-u;Xe(p,()=>[k===0?"Today":k===1?"Yesterday":ve(Ie(De(),-k)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),ie(i)]),r.appendChild(p)}),r}async function Be(e,t){if(!e.disabled){e.disabled=!0;try{await t()}finally{e.disabled=!1}}}var oe=null,le=null;function ee(e=!1){if(!oe)return;let t=oe;if(oe=null,document.body.classList.remove("locked"),le==null||le(),le=null,e){t.remove();return}t.classList.remove("open"),setTimeout(()=>t.remove(),250)}function fe(e,t,...r){let i=!!oe;ee(!0);let u=n("div",{class:"sheet-panel",role:"dialog","aria-modal":"true","aria-label":e},n("div",{class:"grab"}),n("div",{class:"sheet-head"},n("div",{class:"stack"},n("h2",{},e),t?n("span",{class:"muted s"},t):null),n("button",{class:"icon-btn","aria-label":"Close",onclick:()=>ee()},O("x"))),n("div",{class:"sheet-body"},...r)),p=n("div",{class:"sheet",onclick:k=>{k.target===p&&ee()}},u);return document.body.appendChild(p),document.body.classList.add("locked"),i?p.classList.add("open"):requestAnimationFrame(()=>p.classList.add("open")),oe=p,u}document.addEventListener("keydown",e=>{e.key==="Escape"&&(ye(),ee())});var X=null;function ye(){X==null||X.remove(),X=null}document.addEventListener("click",e=>{X&&!X.contains(e.target)&&ye()});function Lt(e,t){ye();let r=t.filter((k,$)=>k||$>0&&t[$-1]&&t.slice($+1).some(Boolean)),i=n("div",{class:"menu",role:"menu"},r.map(k=>k?n("button",{type:"button",role:"menuitem",class:`menu-item${k.danger?" danger":""}`,onclick:()=>{ye(),k.run()}},O(k.icon),n("span",{},k.label)):n("div",{class:"menu-sep"})));document.body.appendChild(i);let u=e.getBoundingClientRect(),p=230;i.style.left=`${Math.max(8,Math.min(window.innerWidth-p-8,u.right-p))}px`,i.style.top=`${u.bottom+6+window.scrollY}px`,X=i}function $e(...e){Ee.replaceChildren(n("header",{class:"top"},n("div",{class:"brand"},(()=>{let t=n("span",{class:"logo"});return t.innerHTML=kt,t})(),n("span",{},(S==null?void 0:S.server.name)||At),n("span",{class:"faint"},"· Dawnline"))),n("main",{class:"wrap"},...e))}function et(){$e(n("div",{class:"card signin"},n("div",{class:"hero-ic"},O("key")),n("h1",{},"This link no longer works"),n("p",{class:"muted"},"Ask for a new personal link.")))}function Tt(e){return e.state==="active"?"ok":e.state==="quota"||e.state==="expired"?"bad":"warn"}var Dt={internet:"The internet, through the router",lan:"Devices at home",both:"Devices at home and the internet, through the router"};function Et(e){let t=e.person,r=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,i=n("div",{class:`meter${r>=100?" bad":r>=90?" warn":""}`},n("i"));i.firstChild.style.width=`${r}%`,t.quota_limit&&Xe(i,()=>[`${r.toFixed(1)}% used`,`${ie(Math.max(0,t.quota_limit-t.quota_used))} left`]);let u=Me(t.expires,De()),p=n("div",{class:"slots"});for(let E=0;E=t.device_limit?"over":E=0?`${u} day${u===1?"":"s"} left`:"ended"):null)),n("span",{class:"faint s"},t.hours?`Available ${t.hours.replace("-","–")} (router time). Need a change? Ask the admin.`:"Need a change? Ask the admin.")))}function Bt(e){return e.disabled?n("span",{class:"dstat"},"Disabled by the admin"):e.online?n("span",{class:"dstat ok"},"Connected"):e.handshake?n("span",{class:"dstat"},`Last connected ${xe(e.handshake)}`):n("span",{class:"dstat warn"},"Not set up yet")}function tt(e,t){return e.access!=="internet"&&e.state==="active"&&!t.disabled}function $t(e,t){let r=ke(e.devices).filter(p=>p.hostname&&tt(e,p));if(!r.length)return null;let i=r[0].hostname,u=i.slice(i.indexOf("."));return n("div",{class:"names"},n("div",{class:"names-head"},n("span",{class:"names-ic"},O("home")),n("div",{class:"stack"},n("span",{class:"strong s"},"Names at home"),n("span",{class:"faint s"},t?"Devices at home and on this VPN reach yours as ":"Other devices at home reach yours as ",n("span",{class:"mono"},`name${u}`)))),n("div",{class:"names-list"},r.map(p=>{let k=p.hostname.indexOf(".");return n("button",{type:"button",class:"name-chip",title:p.name,"aria-label":`Copy ${p.hostname}`,onclick:()=>ce(p.hostname,"Address copied")},n("span",{class:"mono"},k>0?[p.hostname.slice(0,k),n("span",{class:"faint"},p.hostname.slice(k))]:p.hostname),O("copy"))})))}function St(e,t){let r=n("button",{type:"button",class:"icon-btn soft","aria-label":`${e.name} options`},O("more"));r.addEventListener("click",k=>{k.stopPropagation(),Lt(r,[{label:"Show QR code",icon:"qr",run:()=>ue(e,"qr")},{label:"Copy AmneziaVPN key",icon:"key",run:()=>Pt(e)},{label:"Download .conf",icon:"download",run:()=>Nt(e)},null,...tt(t.person,e)?[{label:"Copy IP address",icon:"copy",run:()=>ce(e.address,"IP address copied")},...e.hostname?[{label:"Copy local address",icon:"home",run:()=>ce(e.hostname,"Address copied")}]:[],null]:[],...e.disabled?[]:[{label:"Rename",icon:"edit",run:()=>Ht(e)},{label:"New keys",icon:"reset",run:()=>It(e,t)},{label:"Remove",icon:"trash",danger:!0,run:()=>Ot(e)}]])});let i=e.spark.reduce((k,$)=>k+$,0),u=!e.handshake&&!e.disabled,p=t.here===e.id;return n("article",{class:`dcard${e.online?" online":""}${e.disabled?" off":""}${p?" here":""}`},n("div",{class:"dhead"},n("span",{class:"dic"},O(e.kind)),n("div",{class:"stack grow"},n("span",{class:"dname"},e.name),p?n("span",{class:"dstat here"},"This device"):Bt(e)),r),u?[n("button",{type:"button",class:"btn primary block",onclick:()=>ue(e)},O(Ce()?"open":"qr"),n("span",{},Ce()?"Open in AmneziaVPN":"Connect this device"))]:n("div",{class:"duse"},n("div",{class:"stack"},n("span",{class:"faint s"},"Last 7 days"),n("span",{class:"mono"},ie(i))),Ct(e.spark)),e.config_stale&&!u?n("div",{class:"notice"},O("alert"),n("span",{class:"grow"},"Connection settings changed. Update this device to keep everything working."),n("button",{type:"button",class:"btn small",onclick:()=>ue(e)},"Update")):null)}function de(e){let t=e.person,r=Me(t.expires,De()),i=t.state!=="active"?n("div",{class:"notice bad"},O("alert"),n("span",{},t.state==="quota"?"You have used all your data for this period. Your devices are paused until it resets.":t.state==="expired"?"Your access has ended. Ask the admin to extend it.":t.state==="hours"?`Access is available ${t.hours.replace("-","–")} (router time).`:"Your access is paused by the admin.")):r!=null&&r>=0&&r<=Math.max(t.expire_warn,1)?n("div",{class:"notice"},O("alert"),n("span",{},`Your access ends ${r===0?"today":`in ${r} day${r===1?"":"s"}`} (${we(t.expires)}).`)):null,p=ke(t.devices).sort((E,B)=>+(B.id===e.here)-+(E.id===e.here)).map(E=>St(E,e));Math.max(0,t.device_limit-t.devices.length)&&p.push(n("button",{type:"button",class:"slot add",onclick:Gt},n("span",{class:"slot-ic"},O("plus")),n("span",{class:"strong"},"Add device")));let $=n("section",{class:"devices","aria-label":"Your devices"},n("div",{class:"card-head"},n("div",{class:"row-baseline"},n("h2",{},"Your devices"))),n("div",{class:"dgrid"},p),e.can_add?null:n("span",{class:"faint s"},`You have reached your limit of ${t.device_limit} devices. Remove one or ask the admin for more.`),n("span",{class:"faint s"},"New device? Install ",n("a",{href:"https://amnezia.org/downloads",target:"_blank",rel:"noopener noreferrer"},"AmneziaVPN")," on it first."));$e(n("div",{class:"hello"},n("span",{class:`avatar${t.online?" online":""}`},Ue(t.name)),n("div",{class:"stack"},n("div",{class:"row"},n("h1",{},`Hi, ${t.name}`),t.state==="active"?null:n("span",{class:`pill ${Tt(t)}`},Ke[t.state])))),i,n("div",{class:"layout"},Et(e),$))}async function Se(e){try{return await ne(`devices/${e.id}/config`)}catch(t){return te(t.message,!0),null}}async function Pt(e){let t=await Se(e);t&&ce(await Ae(t,`${t.server} · ${t.name}`),"Key copied")}async function Nt(e){let t=await Se(e);t&&Ze(t.filename,t.conf)}function Qe(e,t){if(/^\s*\[.+\]\s*$/.test(e))return n("span",{class:"conf-sec"},e);let r=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(e);if(!r)return document.createTextNode(e);let i=/^(\s*)(PrivateKey|PresharedKey)\b/.test(e);return n("span",{},n("span",{class:"conf-k"},r[1])," ",i&&!t?n("span",{class:"conf-mask"},"••••••••••••••••"):r[2])}function Rt(e){let t=!1,r=n("pre",{class:"conf"}),i=()=>r.replaceChildren(...e.conf.split(` -`).flatMap((p,k)=>k?[` -`,Qe(p,t)]:[Qe(p,t)])),u=n("button",{class:"btn small",onclick:p=>{p.preventDefault(),t=!t,u.replaceChildren(O(t?"x":"key"),n("span",{},t?"Hide key":"Show key")),i()}},O("key"),n("span",{},"Show key"));return i(),n("div",{class:"pane"},n("div",{class:"filecard"},n("span",{class:"filecard-ic"},".conf"),n("span",{class:"stack"},n("span",{class:"mono ellipsis"},e.filename),n("span",{class:"faint s"},"For computers and routers: import it in AmneziaWG or AmneziaVPN")),n("button",{class:"btn primary",onclick:()=>Ze(e.filename,e.conf)},O("download"),n("span",{},"Download"))),n("details",{class:"confbox"},n("summary",{},O("chevron"),n("span",{},"Configuration"),n("span",{class:"grow"}),u,n("button",{class:"btn small",onclick:p=>{p.preventDefault(),ce(e.conf,"Configuration copied")}},O("copy"),n("span",{},"Copy"))),r))}async function ue(e,t,r){let i=r!=null?r:await Se(e);if(!i)return;let u=await Ae(i,`${i.server} · ${i.name}`),p=Ce(),k={app:()=>n("div",{class:"pane"},n("a",{class:"btn primary block big",href:u},O("open"),n("span",{},"Open in AmneziaVPN")),n("ol",{class:"steps"},n("li",{},"No AmneziaVPN yet? ",n("a",{href:"https://amnezia.org/downloads",target:"_blank",rel:"noopener noreferrer"},"Get it here"),"."),n("li",{},"Tap ",n("b",{},"Open in AmneziaVPN")," and confirm the import."),n("li",{},"Turn the connection on — this page shows ",n("span",{class:"ok"},"Connected")," within a minute."))),qr:()=>{let H=n("div",{class:"qr"});return H.innerHTML=Je(i.conf),n("div",{class:"pane center"},H,n("p",{class:"muted s"},"Scan with the phone’s camera or AmneziaVPN / AmneziaWG."))},key:()=>n("div",{class:"pane"},n("p",{class:"muted s"},"In AmneziaVPN choose “Add server → Insert key”."),n("div",{class:"keybox"},n("span",{class:"mono"},u),n("button",{class:"btn small",onclick:()=>ce(u,"Key copied")},"Copy")),n("p",{class:"faint s"},"Keep it private: anyone with the key can use your connection.")),file:()=>Rt(i)},$=p?["app","qr","key","file"]:["qr","key","file"],E={app:"Open in app",qr:"QR code",key:"Key",file:"File"},B=n("div",{class:"tab-body"}),q=n("div",{class:"tabs",role:"tablist"}),J=H=>{q.querySelectorAll("button").forEach(re=>re.classList.toggle("on",re.dataset.id===H)),B.replaceChildren(k[H]())};for(let H of $)q.appendChild(n("button",{role:"tab","data-id":H,onclick:()=>J(H)},E[H]));J(t&&$.includes(t)?t:$[0]);let U=n("div",{class:"waiting"}),R=H=>{H!=null&&H.online?U.replaceChildren(n("span",{class:"ok"},`${e.name} is connected`)):H!=null&&H.handshake?U.replaceChildren(n("span",{class:"muted"},`Last connected ${xe(H.handshake)}`)):U.replaceChildren(n("span",{class:"warn"},"Waiting for the first connection…"))};R(e);let F=window.setInterval(async()=>{try{let H=await ne("state");S=H,R(H.person.devices.find(re=>re.id===e.id))}catch{}},5e3);fe(e.handshake?`Connect ${e.name}`:`${e.name} is ready`,p?"Add it to AmneziaVPN on this phone":"Scan with the phone’s camera or AmneziaVPN",q,B,U),le=()=>{clearInterval(F),S&&de(S)}}function Ht(e){let t=n("input",{type:"text",value:e.name,maxlength:48,"aria-label":"Device name"}),r=n("button",{class:"btn primary block",type:"submit"},"Save");fe(`Rename ${e.name}`,null,n("form",{class:"stack gap",onsubmit:i=>{i.preventDefault(),Be(r,async()=>{try{S=(await ne(`devices/${e.id}`,{action:"rename",name:t.value})).state,ee(),de(S),te("Renamed")}catch(u){te(u.message,!0)}})}},t,r)),setTimeout(()=>t.select(),50)}function It(e,t){let r=t.here===e.id;fe(`New keys for ${e.name}?`,null,n("p",{class:"muted"},r?"This device is connected through the configuration it has now: it disconnects a few seconds after you confirm. Import the new configuration that opens next.":"Its current configuration stops working. Set the device up again with the new one that opens next."),n("div",{class:"row gap"},n("button",{class:"btn block",onclick:()=>ee()},"Cancel"),n("button",{class:"btn primary block",onclick:i=>Be(i.currentTarget,async()=>{try{let u=await ne(`devices/${e.id}`,{action:"rotate"});S=u.state,de(S),await ue(e,void 0,u.config)}catch(u){te(u.message,!0)}})},"New keys")))}function Ot(e){fe(`Remove ${e.name}?`,null,n("p",{class:"muted"},"Its connection stops working immediately. You can add it again later."),n("div",{class:"row gap"},n("button",{class:"btn block",onclick:()=>ee()},"Cancel"),n("button",{class:"btn danger-solid block",onclick:t=>Be(t.currentTarget,async()=>{try{S=(await ne(`devices/${e.id}`,{action:"delete"})).state,ee(),de(S),te("Device removed")}catch(r){te(r.message,!0)}})},"Remove")))}var V=navigator.userAgent,nt=/iPad/.test(V)||/Macintosh/.test(V)&&navigator.maxTouchPoints>1;function _e(){return nt||/Tablet/i.test(V)||/Android/.test(V)&&!/Mobile/.test(V)?"tablet":/Android|iPhone|Mobile/i.test(V)?"phone":"computer"}var Kt=[[/^SM-S93/,"Galaxy S25"],[/^SM-S92/,"Galaxy S24"],[/^SM-S91/,"Galaxy S23"],[/^SM-S90/,"Galaxy S22"],[/^SM-G99/,"Galaxy S21"],[/^SM-F9/,"Galaxy Z Fold"],[/^SM-F7/,"Galaxy Z Flip"],[/^SM-A5/,"Galaxy A5x"],[/^SM-A3/,"Galaxy A3x"],[/^SM-X/,"Galaxy Tab"]],Te="",Ut=(async()=>{var t;let e=navigator.userAgentData;if(!e||!/Android/.test(V))return"";try{let r=((t=(await e.getHighEntropyValues(["model"])).model)!=null?t:"").trim();if(!r||r==="K")return"";let i=Kt.find(([u])=>u.test(r));Te=i?`${i[1]} (${r})`:/^SM-/.test(r)?`Galaxy ${r}`:r}catch{}return Te})();function Ft(e){return/iPhone/.test(V)?"iPhone":nt?"iPad":/Android/.test(V)?Te||(e==="tablet"?"Android tablet":"Android phone"):/CrOS/.test(V)?"Chromebook":/Mac OS X/.test(V)?"Mac":/Windows/.test(V)?"Windows PC":/Linux/.test(V)?"Linux PC":ge[e]}function Gt(){if(!S)return;let e=_e(),t=new Set(S.person.devices.map(E=>E.name.toLowerCase())),r=E=>{let B=E===_e()?Ft(E):ge[E];if(!t.has(B.toLowerCase()))return B;for(let q=2;q<20;q++)if(!t.has(`${B} ${q}`.toLowerCase()))return`${B} ${q}`;return B},i=n("input",{type:"text",value:r(e),maxlength:48,"aria-label":"Device name",required:!0}),u=!1;i.addEventListener("input",()=>u=!0),Ut.then(()=>{!u&&e===_e()&&(i.value=r(e))});let p=n("div",{class:"kinds"},S.kinds.map(E=>n("button",{type:"button",class:`kind${E===e?" on":""}`,"data-k":E,onclick:()=>{e=E,p.querySelectorAll(".kind").forEach(B=>B.classList.toggle("on",B.dataset.k===E)),u||(i.value=r(E))}},O(E),n("span",{},ge[E])))),k=n("p",{class:"err"}),$=n("button",{class:"btn primary block",type:"submit"},"Create connection");fe("Add a device",`${S.person.device_limit-S.person.devices.length} of ${S.person.device_limit} slots free`,n("form",{class:"add",onsubmit:async E=>{E.preventDefault(),$.disabled=!0,k.textContent="";try{let B=await ne("devices",{name:i.value.trim(),kind:e});S=B.state;let q=B.state.person.devices.find(J=>J.id===B.id);await ue(q,void 0,B.config)}catch(B){k.textContent=B.message,$.disabled=!1}}},n("label",{class:"lbl"},"What is it?"),p,n("label",{class:"lbl"},"Name"),i,k,$))}async function qt(){try{S=await ne("state"),document.title=`${S.person.name} · ${S.title}`,!oe&&!X&&de(S)}catch(e){let t=e;t.status===404||t.status===401?(S=null,et()):S||$e(n("div",{class:"card"},n("p",{},t.message)))}}!me||!_t?et():qt();})(); +"use strict";(()=>{var it=Object.create;var He=Object.defineProperty;var ot=Object.getOwnPropertyDescriptor;var ct=Object.getOwnPropertyNames;var lt=Object.getPrototypeOf,ut=Object.prototype.hasOwnProperty;var ft=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var dt=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let u of ct(t))!ut.call(e,u)&&u!==r&&He(e,u,{get:()=>t[u],enumerable:!(i=ot(t,u))||i.enumerable});return e};var ht=(e,t,r)=>(r=e!=null?it(lt(e)):{},dt(t||!e||!e.__esModule?He(r,"default",{value:e,enumerable:!0}):r,e));var Ye=ft((qe,Ve)=>{"use strict";var Ge=(function(){var e=function(M,A){var b=236,x=17,c=M,m=r[A],s=null,a=0,y=null,d=[],g={},L=function(l,f){a=c*4+17,s=(function(o){for(var h=new Array(o),p=0;p=7&&z(l),y==null&&(y=at(c,m,d)),W(y,f)},E=function(l,f){for(var o=-1;o<=7;o+=1)if(!(l+o<=-1||a<=l+o))for(var h=-1;h<=7;h+=1)f+h<=-1||a<=f+h||(0<=o&&o<=6&&(h==0||h==6)||0<=h&&h<=6&&(o==0||o==6)||2<=o&&o<=4&&2<=h&&h<=4?s[l+o][f+h]=!0:s[l+o][f+h]=!1)},P=function(){for(var l=0,f=0,o=0;o<8;o+=1){L(!0,o);var h=u.getLostPoint(g);(o==0||l>h)&&(l=h,f=o)}return f},I=function(){for(var l=8;l>o&1)==1;s[Math.floor(o/3)][o%3+a-8-3]=h}for(var o=0;o<18;o+=1){var h=!l&&(f>>o&1)==1;s[o%3+a-8-3][Math.floor(o/3)]=h}},Q=function(l,f){for(var o=m<<3|f,h=u.getBCHTypeInfo(o),p=0;p<15;p+=1){var w=!l&&(h>>p&1)==1;p<6?s[p][8]=w:p<8?s[p+1][8]=w:s[a-15+p][8]=w}for(var p=0;p<15;p+=1){var w=!l&&(h>>p&1)==1;p<8?s[8][a-p-1]=w:p<9?s[8][15-p-1+1]=w:s[8][15-p-1]=w}s[a-8][8]=!l},W=function(l,f){for(var o=-1,h=a-1,p=7,w=0,C=u.getMaskFunction(f),_=a-1;_>0;_-=2)for(_==6&&(_-=1);;){for(var N=0;N<2;N+=1)if(s[h][_-N]==null){var O=!1;w>>p&1)==1);var T=C(h,_-N);T&&(O=!O),s[h][_-N]=O,p-=1,p==-1&&(w+=1,p=7)}if(h+=o,h<0||a<=h){h-=o,o=-o;break}}},ae=function(l,f){for(var o=0,h=0,p=0,w=new Array(f.length),C=new Array(f.length),_=0;_=0?Pe.getAt(Ne):0}}for(var Re=0,T=0;T_*8)throw"code length overflow. ("+p.getLengthInBits()+">"+_*8+")";for(p.getLengthInBits()+4<=_*8&&p.put(0,4);p.getLengthInBits()%8!=0;)p.putBit(!1);for(;!(p.getLengthInBits()>=_*8||(p.put(b,8),p.getLengthInBits()>=_*8));)p.put(x,8);return ae(p,h)};g.addData=function(l,f){f=f||"Byte";var o=null;switch(f){case"Numeric":o=$(l);break;case"Alphanumeric":o=q(l);break;case"Byte":o=J(l);break;case"Kanji":o=U(l);break;default:throw"mode:"+f}d.push(o),y=null},g.isDark=function(l,f){if(l<0||a<=l||f<0||a<=f)throw l+","+f;return s[l][f]},g.getModuleCount=function(){return a},g.make=function(){if(c<1){for(var l=1;l<40;l++){for(var f=B.getRSBlocks(l,m),o=D(),h=0;h";for(var p=0;p';o+=""}return o+="",o+="",o},g.createSvgTag=function(l,f,o,h){var p={};typeof arguments[0]=="object"&&(p=arguments[0],l=p.cellSize,f=p.margin,o=p.alt,h=p.title),l=l||2,f=typeof f=="undefined"?l*4:f,o=typeof o=="string"?{text:o}:o||{},o.text=o.text||null,o.id=o.text?o.id||"qrcode-description":null,h=typeof h=="string"?{text:h}:h||{},h.text=h.text||null,h.id=h.text?h.id||"qrcode-title":null;var w=g.getModuleCount()*l+f*2,C,_,N,O,T="",Y;for(Y="l"+l+",0 0,"+l+" -"+l+",0 0,-"+l+"z ",T+=''+se(h.text)+"":"",T+=o.text?''+se(o.text)+"":"",T+='',T+='":f+=">";break;case"&":f+="&";break;case'"':f+=""";break;default:f+=h;break}}return f},st=function(l){var f=1;l=typeof l=="undefined"?f*2:l;var o=g.getModuleCount()*f+l*2,h=l,p=o-l,w,C,_,N,O,T={"██":"█","█ ":"▀"," █":"▄"," ":" "},Y={"██":"▀","█ ":"▀"," █":" "," ":" "},j="";for(w=0;w=p?Y[O]:T[O];j+=` +`}return o%2&&l>0?j.substring(0,j.length-o-1)+Array(o+1).join("▀"):j.substring(0,j.length-1)};return g.createASCII=function(l,f){if(l=l||1,l<2)return st(f);l-=1,f=typeof f=="undefined"?l*2:f;var o=g.getModuleCount()*l+f*2,h=f,p=o-f,w,C,_,N,O=Array(l+1).join("██"),T=Array(l+1).join(" "),Y="",j="";for(w=0;w>>8),m.push(y&255)):m.push(x)}}return m}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},r={L:1,M:0,Q:3,H:2},i={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7},u=(function(){var M=[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],A=1335,b=7973,x=21522,c={},m=function(s){for(var a=0;s!=0;)a+=1,s>>>=1;return a};return c.getBCHTypeInfo=function(s){for(var a=s<<10;m(a)-m(A)>=0;)a^=A<=0;)a^=b<5&&(y+=3+L-5)}for(var d=0;d=256;)c-=255;return M[c]},x})();function k(M,A){if(typeof M.length=="undefined")throw M.length+"/"+A;var b=(function(){for(var c=0;c>>7-x%8&1)==1},b.put=function(x,c){for(var m=0;m>>c-m-1&1)==1)},b.getLengthInBits=function(){return A},b.putBit=function(x){var c=Math.floor(A/8);M.length<=c&&M.push(0),x&&(M[c]|=128>>>A%8),A+=1},b},$=function(M){var A=t.MODE_NUMBER,b=M,x={};x.getMode=function(){return A},x.getLength=function(s){return b.length},x.write=function(s){for(var a=b,y=0;y+2>>8&255)*192+(d&255),s.put(d,13),y+=2}if(y>>8)},A.writeBytes=function(b,x,c){x=x||0,c=c||b.length;for(var m=0;m0&&(b+=","),b+=M[x];return b+="]",b},A},F=function(){var M=0,A=0,b=0,x="",c={},m=function(a){x+=String.fromCharCode(s(a&63))},s=function(a){if(!(a<0)){if(a<26)return 65+a;if(a<52)return 97+(a-26);if(a<62)return 48+(a-52);if(a==62)return 43;if(a==63)return 47}throw"n:"+a};return c.writeByte=function(a){for(M=M<<8|a&255,A+=8,b+=1;A>=6;)m(M>>>A-6),A-=6},c.flush=function(){if(A>0&&(m(M<<6-A),M=0,A=0),b%3!=0)for(var a=3-b%3,y=0;y=A.length){if(c==0)return-1;throw"unexpected end of file./"+c}var a=A.charAt(b);if(b+=1,a=="=")return c=0,-1;if(a.match(/^\s$/))continue;x=x<<6|s(a.charCodeAt(0)),c+=6}var y=x>>>c-8&255;return c-=8,y};var s=function(a){if(65<=a&&a<=90)return a-65;if(97<=a&&a<=122)return a-97+26;if(48<=a&&a<=57)return a-48+52;if(a==43)return 62;if(a==47)return 63;throw"c:"+a};return m},re=function(M,A){var b=M,x=A,c=new Array(M*A),m={};m.setPixel=function(d,g,L){c[g*b+d]=L},m.write=function(d){d.writeString("GIF87a"),d.writeShort(b),d.writeShort(x),d.writeByte(128),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(0),d.writeByte(255),d.writeByte(255),d.writeByte(255),d.writeString(","),d.writeShort(0),d.writeShort(0),d.writeShort(b),d.writeShort(x),d.writeByte(0);var g=2,L=a(g);d.writeByte(g);for(var E=0;L.length-E>255;)d.writeByte(255),d.writeBytes(L,E,255),E+=255;d.writeByte(L.length-E),d.writeBytes(L,E,L.length-E),d.writeByte(0),d.writeString(";")};var s=function(d){var g=d,L=0,E=0,P={};return P.write=function(I,G){if(I>>>G)throw"length over";for(;L+G>=8;)g.writeByte(255&(I<>>=8-L,E=0,L=0;E=I<0&&g.writeByte(E)},P},a=function(d){for(var g=1<>6,128|v&63):v<55296||v>=57344?i.push(224|v>>12,128|v>>6&63,128|v&63):(u++,v=65536+((v&1023)<<10|r.charCodeAt(u)&1023),i.push(240|v>>18,128|v>>12&63,128|v>>6&63,128|v&63))}return i}return t(e)}})();(function(e){typeof define=="function"&&define.amd?define([],e):typeof qe=="object"&&(Ve.exports=e())})(function(){return Ge})});function ie(e){if(!e||e<0)return"0 B";let t=["B","KB","MB","GB","TB"],r=0,i=e;for(;i>=1024&&r=100||r===0?Math.round(i):i.toFixed(1)} ${t[r]}`}function xe(e,t=Date.now()/1e3){if(!e)return"never";let r=Math.max(0,Math.round(t-e));return r<60?"just now":r<3600?`${Math.floor(r/60)} min ago`:r<86400?`${Math.floor(r/3600)} h ago`:r<86400*30?`${Math.floor(r/86400)} d ago`:new Date(e*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ve(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function pe(e){let[t,r,i]=e.split("-").map(Number);return new Date(t,(r||1)-1,i||1,12)}function vt(e){return(typeof e=="string"?/^\d{4}-\d{2}-\d{2}$/.test(e)?pe(e):new Date(e):e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function we(e){return e?vt(e):""}function pt(e,t){let r=i=>{let[u,v,k]=i.split("-").map(Number);return Date.UTC(u,v-1,k)};return Math.round((r(e)-r(t))/864e5)}function Ie(e,t){let r=pe(e);return r.setDate(r.getDate()+t),ve(r)}function Me(e,t=Date.now()){if(!e)return null;let r=typeof t=="number"?ve(new Date(t)):t,i=pt(e,r);return i>=0?i+1:i}var Oe={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var ge={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"};function Ke(e){var u,v,k;let t=e.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let r=(u=t[0][0])!=null?u:"",i=t.length>1?(v=t[t.length-1][0])!=null?v:"":(k=t[0][1])!=null?k:"";return(r+i).toUpperCase()}function ke(e){let t=r=>r.disabled?3:r.online?0:r.handshake?1:2;return e.map((r,i)=>[r,i]).sort((r,i)=>t(r[0])-t(i[0])||r[1]-i[1]).map(([r])=>r)}var Ue={phone:'',computer:'',tablet:'',router:'',server:'',other:'',ethernet:'',bridge:'',wifi:'',tunnel:'',plus:'',chart:'',reset:'',package:'',code:'',plug:'',sunrise:'',refresh:'',archive:'',qr:'',copy:'',download:'',link:'',trash:'',edit:'',pause:'',play:'',key:'',out:'',admin:'',shield:'',shieldplus:'',lock:'',zap:'',check:'',alert:'',x:'',globe:'',home:'',open:'',file:'',network:'',moon:'',chevron:'',clock:'',calendar:'',minus:'',more:'',pin:'',activity:''};function Fe(e,t="dl-icon"){var i;let r=(i=Ue[e])!=null?i:Ue.phone;return``}var je=ht(Ye(),1),gt='';function ze(e,t=3,r=!0){let i=(0,je.default)(0,e.length>300?"Q":"H");i.addData(e,"Byte"),i.make();let u=i.getModuleCount(),v=u+t*2,k=r?Math.round(u*.22):0;k&&(u-k)%2&&k++;let B=(u-k)/2,D=B+k,$=(U,R)=>k>0&&U>=B&&U=B&&R${gt}`}return`${J}`}var mt={jc:"0",jmin:"0",jmax:"0",s1:"0",s2:"0",s3:"0",s4:"0",h1:"1",h2:"2",h3:"3",h4:"4",i1:"",i2:"",i3:"",i4:"",i5:""},yt={header_protection_key:"HeaderProtectionKey",content_padding_addition:"ContentPaddingAddition",rekey_after_time:"RekeyAfterTime",rekey_timeout:"RekeyTimeout",reject_after_time:"RejectAfterTime",keepalive_timeout:"KeepaliveTimeout",max_handshake_attempts:"MaxHandshakeAttempts",random_trailers:"RandomTrailers",disable_cookies:"DisableCookies"};function bt(e){let t={};for(let[r,i]of Object.entries(yt))e[r]!=null&&e[r]!==""&&(t[i]=String(e[r]));return t}function xt(e,t){var D;let r=e.amnezia,i=(D=r.obfuscation)!=null?D:{},u=$=>i[$]!=null&&i[$]!==""?String(i[$]):mt[$],v=r.host.replace(/^\[(.*)\]$/,"$1"),k={H1:u("h1"),H2:u("h2"),H3:u("h3"),H4:u("h4"),I1:u("i1"),I2:u("i2"),I3:u("i3"),I4:u("i4"),I5:u("i5"),Jc:u("jc"),Jmin:u("jmin"),Jmax:u("jmax"),S1:u("s1"),S2:u("s2"),S3:u("s3"),S4:u("s4"),...bt(i),allowed_ips:r.allowed_ips,client_ip:r.client_ip,client_priv_key:r.client_priv_key,client_pub_key:r.client_pub_key,config:e.conf.replace(/\r?\n/g,`\r +`),hostName:v,mtu:r.mtu,persistent_keep_alive:r.persistent_keep_alive,port:Number(r.port),psk_key:r.psk_key,server_pub_key:r.server_pub_key},B={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(k),port:String(r.port),protocol_version:i.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:v};return r.dns[0]&&(B.dns1=r.dns[0]),r.dns[1]&&(B.dns2=r.dns[1]),B}function wt(e){let t="";for(let r=0;r{var e;return(e=S==null?void 0:S.today)!=null?e:ve(new Date)};function n(e,t={},...r){let i=document.createElement(e);for(let[v,k]of Object.entries(t))k==null||k===!1||(v.startsWith("on")&&typeof k=="function"?i.addEventListener(v.slice(2),k):v==="class"?i.className=String(k):k===!0?i.setAttribute(v,""):i.setAttribute(v,String(k)));let u=v=>{v==null||v===!1||(Array.isArray(v)?v.forEach(u):i.appendChild(typeof v=="string"?document.createTextNode(v):v))};return r.forEach(u),i}function K(e){let t=n("span",{class:"ic"});return t.innerHTML=Fe(e,"ic-svg"),t}var kt='',Ee=document.getElementById("app"),We,me=(We=Ee.dataset.base)!=null?We:"",At=Ee.dataset.title||"Dawnline",Ce=()=>window.matchMedia("(max-width: 959px)").matches||/Android|iPhone|iPad/.test(navigator.userAgent),S=null,_t=/^\/[a-z]{6}-[a-z]{6}-[a-z]{6}$/.test(me)?me.slice(1):"",Te=class extends Error{constructor(r,i){super(i);this.status=r}};async function ne(e,t){var u;let r=await fetch(`${me}/api/${e}`,{method:t===void 0?"GET":"POST",credentials:"omit",headers:t===void 0?{}:{"Content-Type":"application/json"},body:t===void 0?void 0:JSON.stringify(t),cache:"no-store"}),i=null;try{i=await r.json()}catch{}if(!r.ok)throw new Te(r.status,(u=i==null?void 0:i.error)!=null?u:`Request failed (${r.status})`);return i}function te(e,t=!1){let r=n("div",{class:`toast${t?" bad":""}`,role:"status"},e);document.body.appendChild(r),requestAnimationFrame(()=>r.classList.add("show")),setTimeout(()=>{r.classList.remove("show"),setTimeout(()=>r.remove(),300)},2600)}async function ce(e,t="Copied"){try{await navigator.clipboard.writeText(e)}catch{let r=n("textarea",{class:"offscreen"},e);document.body.appendChild(r),r.select();let i=document.execCommand("copy");if(r.remove(),!i)return te("Copying is blocked here. Select the text and copy it by hand.",!0)}te(t)}function Ze(e,t){let r=URL.createObjectURL(new Blob([t],{type:"application/octet-stream"})),i=n("a",{href:r,download:e,class:"offscreen"});document.body.appendChild(i),i.click(),setTimeout(()=>{URL.revokeObjectURL(r),i.remove()},1e3)}var Z=null;function Xe(e,t){let r=i=>{Z!=null||(Z=document.body.appendChild(n("div",{class:"tip"}))),Z.replaceChildren(...t().map((u,v)=>n("div",{class:v?"muted":"tip-title"},u))),Z.style.display="",Z.style.left=`${i.clientX}px`,Z.style.top=`${i.clientY-10}px`};e.addEventListener("mouseenter",r),e.addEventListener("mousemove",r),e.addEventListener("mouseleave",()=>Z&&(Z.style.display="none"))}function Ct(e){let t=Math.max(1,...e),r=n("div",{class:"spark"});return e.forEach((i,u)=>{let v=n("i",{class:i?"":"zero"});v.style.height=`${Math.max(8,i/t*100)}%`;let k=e.length-1-u;Xe(v,()=>[k===0?"Today":k===1?"Yesterday":pe(Ie(De(),-k)).toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"}),ie(i)]),r.appendChild(v)}),r}async function Be(e,t){if(!e.disabled){e.disabled=!0;try{await t()}finally{e.disabled=!1}}}var oe=null,le=null;function ee(e=!1){if(!oe)return;let t=oe;if(oe=null,document.body.classList.remove("locked"),le==null||le(),le=null,e){t.remove();return}t.classList.remove("open"),setTimeout(()=>t.remove(),250)}function fe(e,t,...r){let i=!!oe;ee(!0);let u=n("div",{class:"sheet-panel",role:"dialog","aria-modal":"true","aria-label":e},n("div",{class:"grab"}),n("div",{class:"sheet-head"},n("div",{class:"stack"},n("h2",{},e),t?n("span",{class:"muted s"},t):null),n("button",{class:"icon-btn","aria-label":"Close",onclick:()=>ee()},K("x"))),n("div",{class:"sheet-body"},...r)),v=n("div",{class:"sheet",onclick:k=>{k.target===v&&ee()}},u);return document.body.appendChild(v),document.body.classList.add("locked"),i?v.classList.add("open"):requestAnimationFrame(()=>v.classList.add("open")),oe=v,u}document.addEventListener("keydown",e=>{e.key==="Escape"&&(ye(),ee())});var X=null;function ye(){X==null||X.remove(),X=null}document.addEventListener("click",e=>{X&&!X.contains(e.target)&&ye()});function Tt(e,t){ye();let r=t.filter((k,B)=>k||B>0&&t[B-1]&&t.slice(B+1).some(Boolean)),i=n("div",{class:"menu",role:"menu"},r.map(k=>k?n("button",{type:"button",role:"menuitem",class:`menu-item${k.danger?" danger":""}`,onclick:()=>{ye(),k.run()}},K(k.icon),n("span",{},k.label)):n("div",{class:"menu-sep"})));document.body.appendChild(i);let u=e.getBoundingClientRect(),v=230;i.style.left=`${Math.max(8,Math.min(window.innerWidth-v-8,u.right-v))}px`,i.style.top=`${u.bottom+6+window.scrollY}px`,X=i}function $e(...e){Ee.replaceChildren(n("header",{class:"top"},n("div",{class:"brand"},(()=>{let t=n("span",{class:"logo"});return t.innerHTML=kt,t})(),n("span",{},(S==null?void 0:S.server.name)||At),n("span",{class:"faint"},"· Dawnline"))),n("main",{class:"wrap"},...e))}function et(){$e(n("div",{class:"card signin"},n("div",{class:"hero-ic"},K("key")),n("h1",{},"This link no longer works"),n("p",{class:"muted"},"Ask for a new personal link.")))}function Lt(e){switch(e.state){case"server_off":return["server","The server is turned off","Your devices can’t connect until the admin turns it on again."];case"no_server":return["server","No server yet","Ask the admin to add you to a server."];case"quota":return["chart","You have used all your data","Your devices are paused until it resets."];case"expired":return["calendar","Your access has ended","Ask the admin to extend it."];case"hours":return["clock","Outside your hours",`Access is available ${e.hours.replace("-","–")} (router time).`];default:return["pause","Your access is paused by the admin","Your devices can’t connect until the admin resumes it."]}}function Je(e,t,r,i){return n("div",{class:"alert"},n("span",{class:`alert-ic ${e}`},K(t)),n("div",{class:"stack"},n("span",{class:"strong"},r),n("span",{class:"muted s"},i)))}function Dt(e){return e.state==="active"?"ok":e.state==="quota"||e.state==="expired"?"bad":"warn"}var Et={internet:"The internet, through the router",lan:"Devices at home",both:"Devices at home and the internet, through the router"};function Bt(e){let t=e.person,r=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,i=n("div",{class:`meter${r>=100?" bad":r>=90?" warn":""}`},n("i"));i.firstChild.style.width=`${r}%`,t.quota_limit&&Xe(i,()=>[`${r.toFixed(1)}% used`,`${ie(Math.max(0,t.quota_limit-t.quota_used))} left`]);let u=Me(t.expires,De()),v=n("div",{class:"slots"});for(let D=0;D=t.device_limit?"over":D=0?`${u} day${u===1?"":"s"} left`:"ended"):null)),n("span",{class:"faint s"},t.hours?`Available ${t.hours.replace("-","–")} (router time). Need a change? Ask the admin.`:"Need a change? Ask the admin.")))}function $t(e){return e.disabled?n("span",{class:"dstat"},"Disabled by the admin"):e.online?n("span",{class:"dstat ok"},"Connected"):e.handshake?n("span",{class:"dstat"},`Last connected ${xe(e.handshake)}`):n("span",{class:"dstat warn"},"Not set up yet")}function tt(e,t){return e.access!=="internet"&&e.state==="active"&&!t.disabled}function St(e,t){let r=ke(e.devices).filter(v=>v.hostname&&tt(e,v));if(!r.length)return null;let i=r[0].hostname,u=i.slice(i.indexOf("."));return n("div",{class:"names"},n("div",{class:"names-head"},n("span",{class:"names-ic"},K("home")),n("div",{class:"stack"},n("span",{class:"strong s"},"Names at home"),n("span",{class:"faint s"},t?"Devices at home and on this VPN reach yours as ":"Other devices at home reach yours as ",n("span",{class:"mono"},`name${u}`)))),n("div",{class:"names-list"},r.map(v=>{let k=v.hostname.indexOf(".");return n("button",{type:"button",class:"name-chip",title:v.name,"aria-label":`Copy ${v.hostname}`,onclick:()=>ce(v.hostname,"Address copied")},n("span",{class:"mono"},k>0?[v.hostname.slice(0,k),n("span",{class:"faint"},v.hostname.slice(k))]:v.hostname),K("copy"))})))}function Pt(e,t){let r=n("button",{type:"button",class:"icon-btn soft","aria-label":`${e.name} options`},K("more"));r.addEventListener("click",B=>{B.stopPropagation(),Tt(r,[{label:"Show QR code",icon:"qr",run:()=>ue(e,"qr")},{label:"Copy AmneziaVPN key",icon:"key",run:()=>Nt(e)},{label:"Download .conf",icon:"download",run:()=>Rt(e)},null,...tt(t.person,e)?[{label:"Copy IP address",icon:"copy",run:()=>ce(e.address,"IP address copied")},...e.hostname?[{label:"Copy local address",icon:"home",run:()=>ce(e.hostname,"Address copied")}]:[],null]:[],...e.disabled?[]:[{label:"Rename",icon:"edit",run:()=>It(e)},{label:"New keys",icon:"reset",run:()=>Ot(e,t)},{label:"Remove",icon:"trash",danger:!0,run:()=>Kt(e)}]])});let i=e.spark.reduce((B,D)=>B+D,0),u=!e.handshake&&!e.disabled,v=!!t.locked,k=t.here===e.id;return n("article",{class:`dcard${e.online?" online":""}${e.disabled?" off":""}${k?" here":""}`},n("div",{class:"dhead"},n("span",{class:"dic"},K(e.kind)),n("div",{class:"stack grow"},n("span",{class:"dname"},e.name),k?n("span",{class:"dstat here"},"This device"):$t(e)),v?null:r),u&&v?null:u?[n("button",{type:"button",class:"btn primary block",onclick:()=>ue(e)},K(Ce()?"open":"qr"),n("span",{},Ce()?"Open in AmneziaVPN":"Connect this device"))]:n("div",{class:"duse"},n("div",{class:"stack"},n("span",{class:"faint s"},"Last 7 days"),n("span",{class:"mono"},ie(i))),Ct(e.spark)),e.config_stale&&!u&&!v?n("div",{class:"notice"},K("alert"),n("span",{class:"grow"},"Connection settings changed. Update this device to keep everything working."),n("button",{type:"button",class:"btn small",onclick:()=>ue(e)},"Update")):null)}function de(e){let t=e.person,r=Me(t.expires,De()),i=t.state!=="active"?Je(Dt(t),...Lt(t)):r!=null&&r>=0&&r<=Math.max(t.expire_warn,1)?Je("warn","calendar",`Your access ends ${r===0?"today":`in ${r} day${r===1?"":"s"}`}`,`On ${we(t.expires)}. Ask the admin to extend it.`):null,v=ke(t.devices).sort((D,$)=>+($.id===e.here)-+(D.id===e.here)).map(D=>Pt(D,e));(e.locked?0:Math.max(0,t.device_limit-t.devices.length))&&v.push(n("button",{type:"button",class:"slot add",onclick:qt},n("span",{class:"slot-ic"},K("plus")),n("span",{class:"strong"},"Add device")));let B=n("section",{class:"devices","aria-label":"Your devices"},n("div",{class:"card-head"},n("div",{class:"row-baseline"},n("h2",{},"Your devices"))),n("div",{class:"dgrid"},v),e.locked?null:[e.can_add?null:n("span",{class:"faint s"},`You have reached your limit of ${t.device_limit} devices. Remove one or ask the admin for more.`),n("span",{class:"faint s"},"New device? Install ",n("a",{href:"https://amnezia.org/downloads",target:"_blank",rel:"noopener noreferrer"},"AmneziaVPN")," on it first.")]);$e(i,n("div",{class:"hello"},n("span",{class:`avatar${t.online?" online":""}`},Ke(t.name)),n("h1",{},`Hi, ${t.name}`)),n("div",{class:"layout"},Bt(e),B))}async function Se(e){try{return await ne(`devices/${e.id}/config`)}catch(t){return te(t.message,!0),null}}async function Nt(e){let t=await Se(e);t&&ce(await Ae(t,`${t.server} · ${t.name}`),"Key copied")}async function Rt(e){let t=await Se(e);t&&Ze(t.filename,t.conf)}function Qe(e,t){if(/^\s*\[.+\]\s*$/.test(e))return n("span",{class:"conf-sec"},e);let r=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(e);if(!r)return document.createTextNode(e);let i=/^(\s*)(PrivateKey|PresharedKey)\b/.test(e);return n("span",{},n("span",{class:"conf-k"},r[1])," ",i&&!t?n("span",{class:"conf-mask"},"••••••••••••••••"):r[2])}function Ht(e){let t=!1,r=n("pre",{class:"conf"}),i=()=>r.replaceChildren(...e.conf.split(` +`).flatMap((v,k)=>k?[` +`,Qe(v,t)]:[Qe(v,t)])),u=n("button",{class:"btn small",onclick:v=>{v.preventDefault(),t=!t,u.replaceChildren(K(t?"x":"key"),n("span",{},t?"Hide key":"Show key")),i()}},K("key"),n("span",{},"Show key"));return i(),n("div",{class:"pane"},n("div",{class:"filecard"},n("span",{class:"filecard-ic"},".conf"),n("span",{class:"stack"},n("span",{class:"mono ellipsis"},e.filename),n("span",{class:"faint s"},"For computers and routers: import it in AmneziaWG or AmneziaVPN")),n("button",{class:"btn primary",onclick:()=>Ze(e.filename,e.conf)},K("download"),n("span",{},"Download"))),n("details",{class:"confbox"},n("summary",{},K("chevron"),n("span",{},"Configuration"),n("span",{class:"grow"}),u,n("button",{class:"btn small",onclick:v=>{v.preventDefault(),ce(e.conf,"Configuration copied")}},K("copy"),n("span",{},"Copy"))),r))}async function ue(e,t,r){let i=r!=null?r:await Se(e);if(!i)return;let u=await Ae(i,`${i.server} · ${i.name}`),v=Ce(),k={app:()=>n("div",{class:"pane"},n("a",{class:"btn primary block big",href:u},K("open"),n("span",{},"Open in AmneziaVPN")),n("ol",{class:"steps"},n("li",{},"No AmneziaVPN yet? ",n("a",{href:"https://amnezia.org/downloads",target:"_blank",rel:"noopener noreferrer"},"Get it here"),"."),n("li",{},"Tap ",n("b",{},"Open in AmneziaVPN")," and confirm the import."),n("li",{},"Turn the connection on — this page shows ",n("span",{class:"ok"},"Connected")," within a minute."))),qr:()=>{let H=n("div",{class:"qr"});return H.innerHTML=ze(i.conf),n("div",{class:"pane center"},H,n("p",{class:"muted s"},"Scan with the phone’s camera or AmneziaVPN / AmneziaWG."))},key:()=>n("div",{class:"pane"},n("p",{class:"muted s"},"In AmneziaVPN choose “Add server → Insert key”."),n("div",{class:"keybox"},n("span",{class:"mono"},u),n("button",{class:"btn small",onclick:()=>ce(u,"Key copied")},"Copy")),n("p",{class:"faint s"},"Keep it private: anyone with the key can use your connection.")),file:()=>Ht(i)},B=v?["app","qr","key","file"]:["qr","key","file"],D={app:"Open in app",qr:"QR code",key:"Key",file:"File"},$=n("div",{class:"tab-body"}),q=n("div",{class:"tabs",role:"tablist"}),J=H=>{q.querySelectorAll("button").forEach(re=>re.classList.toggle("on",re.dataset.id===H)),$.replaceChildren(k[H]())};for(let H of B)q.appendChild(n("button",{role:"tab","data-id":H,onclick:()=>J(H)},D[H]));J(t&&B.includes(t)?t:B[0]);let U=n("div",{class:"waiting"}),R=H=>{H!=null&&H.online?U.replaceChildren(n("span",{class:"ok"},`${e.name} is connected`)):H!=null&&H.handshake?U.replaceChildren(n("span",{class:"muted"},`Last connected ${xe(H.handshake)}`)):U.replaceChildren(n("span",{class:"warn"},"Waiting for the first connection…"))};R(e);let F=window.setInterval(async()=>{try{let H=await ne("state");S=H,R(H.person.devices.find(re=>re.id===e.id))}catch{}},5e3);fe(e.handshake?`Connect ${e.name}`:`${e.name} is ready`,v?"Add it to AmneziaVPN on this phone":"Scan with the phone’s camera or AmneziaVPN",q,$,U),le=()=>{clearInterval(F),S&&de(S)}}function It(e){let t=n("input",{type:"text",value:e.name,maxlength:48,"aria-label":"Device name"}),r=n("button",{class:"btn primary block",type:"submit"},"Save");fe(`Rename ${e.name}`,null,n("form",{class:"stack gap",onsubmit:i=>{i.preventDefault(),Be(r,async()=>{try{S=(await ne(`devices/${e.id}`,{action:"rename",name:t.value})).state,ee(),de(S),te("Renamed")}catch(u){te(u.message,!0)}})}},t,r)),setTimeout(()=>t.select(),50)}function Ot(e,t){let r=t.here===e.id;fe(`New keys for ${e.name}?`,null,n("p",{class:"muted"},r?"This device is connected through the configuration it has now: it disconnects a few seconds after you confirm. Import the new configuration that opens next.":"Its current configuration stops working. Set the device up again with the new one that opens next."),n("div",{class:"row gap"},n("button",{class:"btn block",onclick:()=>ee()},"Cancel"),n("button",{class:"btn primary block",onclick:i=>Be(i.currentTarget,async()=>{try{let u=await ne(`devices/${e.id}`,{action:"rotate"});S=u.state,de(S),await ue(e,void 0,u.config)}catch(u){te(u.message,!0)}})},"New keys")))}function Kt(e){fe(`Remove ${e.name}?`,null,n("p",{class:"muted"},"Its connection stops working immediately. You can add it again later."),n("div",{class:"row gap"},n("button",{class:"btn block",onclick:()=>ee()},"Cancel"),n("button",{class:"btn danger-solid block",onclick:t=>Be(t.currentTarget,async()=>{try{S=(await ne(`devices/${e.id}`,{action:"delete"})).state,ee(),de(S),te("Device removed")}catch(r){te(r.message,!0)}})},"Remove")))}var V=navigator.userAgent,nt=/iPad/.test(V)||/Macintosh/.test(V)&&navigator.maxTouchPoints>1;function _e(){return nt||/Tablet/i.test(V)||/Android/.test(V)&&!/Mobile/.test(V)?"tablet":/Android|iPhone|Mobile/i.test(V)?"phone":"computer"}var Ut=[[/^SM-S93/,"Galaxy S25"],[/^SM-S92/,"Galaxy S24"],[/^SM-S91/,"Galaxy S23"],[/^SM-S90/,"Galaxy S22"],[/^SM-G99/,"Galaxy S21"],[/^SM-F9/,"Galaxy Z Fold"],[/^SM-F7/,"Galaxy Z Flip"],[/^SM-A5/,"Galaxy A5x"],[/^SM-A3/,"Galaxy A3x"],[/^SM-X/,"Galaxy Tab"]],Le="",Ft=(async()=>{var t;let e=navigator.userAgentData;if(!e||!/Android/.test(V))return"";try{let r=((t=(await e.getHighEntropyValues(["model"])).model)!=null?t:"").trim();if(!r||r==="K")return"";let i=Ut.find(([u])=>u.test(r));Le=i?`${i[1]} (${r})`:/^SM-/.test(r)?`Galaxy ${r}`:r}catch{}return Le})();function Gt(e){return/iPhone/.test(V)?"iPhone":nt?"iPad":/Android/.test(V)?Le||(e==="tablet"?"Android tablet":"Android phone"):/CrOS/.test(V)?"Chromebook":/Mac OS X/.test(V)?"Mac":/Windows/.test(V)?"Windows PC":/Linux/.test(V)?"Linux PC":ge[e]}function qt(){if(!S)return;let e=_e(),t=new Set(S.person.devices.map(D=>D.name.toLowerCase())),r=D=>{let $=D===_e()?Gt(D):ge[D];if(!t.has($.toLowerCase()))return $;for(let q=2;q<20;q++)if(!t.has(`${$} ${q}`.toLowerCase()))return`${$} ${q}`;return $},i=n("input",{type:"text",value:r(e),maxlength:48,"aria-label":"Device name",required:!0}),u=!1;i.addEventListener("input",()=>u=!0),Ft.then(()=>{!u&&e===_e()&&(i.value=r(e))});let v=n("div",{class:"kinds"},S.kinds.map(D=>n("button",{type:"button",class:`kind${D===e?" on":""}`,"data-k":D,onclick:()=>{e=D,v.querySelectorAll(".kind").forEach($=>$.classList.toggle("on",$.dataset.k===D)),u||(i.value=r(D))}},K(D),n("span",{},ge[D])))),k=n("p",{class:"err"}),B=n("button",{class:"btn primary block",type:"submit"},"Create connection");fe("Add a device",`${S.person.device_limit-S.person.devices.length} of ${S.person.device_limit} slots free`,n("form",{class:"add",onsubmit:async D=>{D.preventDefault(),B.disabled=!0,k.textContent="";try{let $=await ne("devices",{name:i.value.trim(),kind:e});S=$.state;let q=$.state.person.devices.find(J=>J.id===$.id);await ue(q,void 0,$.config)}catch($){k.textContent=$.message,B.disabled=!1}}},n("label",{class:"lbl"},"What is it?"),v,n("label",{class:"lbl"},"Name"),i,k,B))}async function Vt(){try{S=await ne("state"),document.title=`${S.person.name} · ${S.title}`,!oe&&!X&&de(S)}catch(e){let t=e;t.status===404||t.status===401?(S=null,et()):S||$e(n("div",{class:"card"},n("p",{},t.message)))}}!me||!_t?et():Vt();})(); diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc index 45ee7b1..902875a 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc @@ -11,9 +11,9 @@ import * as view from 'dawnline.view'; import * as awg from 'dawnline.awg'; const STATE_TEXT = { - no_server: 'their server is turned off', + no_server: 'they have no server', + server_off: 'their server is turned off', paused: 'they are paused', - paused_all: 'everyone is paused', expired: 'their access has ended', quota: 'they used up their data', hours: 'it is outside their allowed hours', diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc index c4e365b..c1f0215 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/awg.uc @@ -54,6 +54,18 @@ export function state() { return { tools, kmod, loaded, handler, missing, ok: !length(missing) && loaded && handler }; }; +/** + * state(), after loading an installed module that isn't loaded yet: nothing loads + * it before the first tunnel comes up, so "not loaded" alone is no fault. + */ +export function load() { + let s = state(); + if (!s.kmod || s.loaded) + return s; + system('modprobe amneziawg >/dev/null 2>&1'); + return state(); +}; + /** The kernel module and the awg tool are on the router. */ export function installed() { let s = state(); @@ -249,12 +261,13 @@ export function client_config(m, dev) { let ep = match(host, /:/) && !match(host, /^\[/) ? `[${host}]` : host; let allowed = allowed_ips(m, srv, p); let dns = core.client_dns(m, srv, p); + let mtu = core.device_mtu(srv, dev); let lines = [ '[Interface]' ]; push(lines, `PrivateKey = ${dev.private_key || ''}`); push(lines, `Address = ${dev.address}/32`); if (length(dns)) push(lines, `DNS = ${join(', ', dns)}`); - push(lines, `MTU = ${srv.mtu}`); + push(lines, `MTU = ${mtu}`); // "Off" is plain WireGuard: neutral values (no junk, H1-H4 = 1-4) are left // out, so any WireGuard app accepts the file. if (!obf_neutral(srv.obf)) @@ -279,7 +292,7 @@ export function client_config(m, dev) { amnezia: { host, port: srv.port, - mtu: `${srv.mtu}`, + mtu: `${mtu}`, dns, allowed_ips: allowed, client_ip: dev.address, @@ -307,7 +320,7 @@ export function netifd_options(srv) { private_key: srv.private_key, listen_port: srv.port, addresses: [ `${addr}/${prefix}` ], - mtu: srv.mtu, + mtu: core.tunnel_mtu(srv), }; for (let k in core.OBF_KEYS) o[`awg_${k}`] = srv.obf[k]; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc index 9f48802..84924ad 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/core.uc @@ -20,6 +20,8 @@ export const CONFIG = 'dawnline'; export const BLOCKED = `${RUN_DIR}/netifd-blocked.json`; export const ACCESS = [ 'lan', 'internet', 'both' ]; export const KINDS = [ 'computer', 'phone', 'tablet', 'router', 'other' ]; +/** Kinds that mostly live on mobile networks: their configurations carry a smaller MTU. */ +export const MOBILE_KINDS = [ 'phone', 'tablet' ]; /** Devices of different people reaching each other: never, everyone with home access, or within a circle. */ export const MESH = [ 'off', 'all', 'circles' ]; /** Circle colours (index into the admin palette). */ @@ -78,7 +80,6 @@ export function load(c) { portal_title: s.portal_title ?? 'Dawnline', // Where unknown portal links go instead of a bare 404 (empty = 404). portal_redirect: s.portal_redirect ?? '', - paused_all: bool(s.paused_all, false), default_device_limit: toint(s.default_device_limit, 3), geo_enabled: bool(s.geo_enabled, true), geo_provider: s.geo_provider == 'ipapi.co' ? 'ipapi.co' : 'ipwho.is', @@ -115,7 +116,8 @@ export function load(c) { port: toint(r.port, 51820), subnet: r.subnet ?? '', endpoint: r.endpoint ?? '', - mtu: toint(r.mtu, 1380), + // 0 = automatic (tunnel_mtu, device_mtu). + mtu: toint(r.mtu, 0), dns: list(r.dns), keepalive: toint(r.keepalive, 25), private_key: r.private_key ?? '', @@ -262,19 +264,11 @@ export function person_expired(p, ts) { return end != null && (ts ?? time()) > end; }; -/** - * Effective state of a person: 'active', or why they are off: - * 'paused' (admin), 'paused_all', 'expired', 'quota', 'hours', 'no_server'. - */ -export function person_state(m, p, usage, ts) { +/** The person's state whatever their server is doing (paused, expired, …, or 'active'). */ +export function own_state(m, p, usage, ts) { ts ??= time(); - let srv = m.servers[p.server]; - if (!srv || !srv.enabled) - return 'no_server'; if (p.paused) return 'paused'; - if (m.settings.paused_all) - return 'paused_all'; // "notify" keeps access after the end date (shown in Overview and People). if (person_expired(p, ts) && p.expire_action != 'notify') return 'expired'; @@ -287,6 +281,20 @@ export function person_state(m, p, usage, ts) { return 'active'; }; +/** + * Effective state of a person: 'active', or why they are off: + * 'paused' (admin), 'expired', 'quota', 'hours', 'no_server', + * 'server_off' (their server is turned off: about the server, not the person). + */ +export function person_state(m, p, usage, ts) { + let srv = m.servers[p.server]; + if (!srv) + return 'no_server'; + if (!srv.enabled) + return 'server_off'; + return own_state(m, p, usage, ts); +}; + export function load_usage() { return read_json(`${RUN_DIR}/usage.json`, null) ?? read_json(`${DATA_DIR}/usage.json`, { devices: {}, people: {} }); }; @@ -344,6 +352,27 @@ export function alloc_address(m, srv) { /* ---------- what clients get ---------- */ +/* + * Automatic MTU. A path is assumed to carry 1460 bytes (1500 less PPPoE, + * 464XLAT or DS-Lite), the tunnel's own headers take 80 over IPv6, and + * AmneziaWG's S4 adds its bytes to every data packet (its padding and random + * trailers stay within the largest packet already seen, so they cost + * nothing). Phones and tablets get 1280, the IPv6 minimum: mobile paths vary. + */ +const AUTO_MTU = 1380; +const MOBILE_MTU = 1280; + +/** The server's tunnel MTU: the one set, or automatic for its disguise. */ +export function tunnel_mtu(srv) { + return srv.mtu || max(MOBILE_MTU, AUTO_MTU - toint(srv.obf?.s4, 0)); +}; + +/** The MTU a device's configuration carries: the tunnel's, at most 1280 for phones and tablets. */ +export function device_mtu(srv, dev) { + let mtu = tunnel_mtu(srv); + return index(MOBILE_KINDS, dev.kind) >= 0 ? min(mtu, MOBILE_MTU) : mtu; +}; + export function endpoint_host(m, srv) { return srv.endpoint || m.settings.portal_host || ''; }; @@ -690,6 +719,16 @@ export function delete_person(c, m, id) { c.delete(CONFIG, id); }; +const PRIVATE_NETS = map([ '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16' ], parse_cidr); + +/** The parsed subnet lies inside one of the private ranges. */ +export function private_cidr(c) { + for (let p in PRIVATE_NETS) + if (c.net >= p.net && c.net + c.size <= p.net + p.size) + return true; + return false; +}; + /** Validate a server definition (as loaded) against the rest of the router. */ export function server_errors(m, srv, others_subnets) { let errs = []; @@ -711,21 +750,28 @@ export function server_errors(m, srv, others_subnets) { return errs; }; -/** Someone else already forwards this TCP port from outside (a port forward we must not take over). */ -export function wan_port_taken(port) { +/** + * Port forwards from `zone` for `proto` that aren't Dawnline's: [{ from, to, name }]. + * A forwarded port never reaches the router itself, so nothing here can listen on it. + */ +export function wan_forwards(zone, proto) { let c = cursor(); c.load('firewall'); - let taken = false; + let out = []; c.foreach('firewall', 'redirect', (r) => { - if (match(r['.name'], /^dawnline_/) || r.enabled == '0' || (r.target ?? 'DNAT') != 'DNAT') + if (match(r['.name'], /^dawnline_/) || r.enabled == '0' || (r.target ?? 'DNAT') != 'DNAT' || r.src != zone) + return; + // fw4's default is "tcp udp". + let protos = split(type(r.proto) == 'array' ? join(' ', r.proto) : r.proto ?? 'tcp udp', /[ ,]+/); + if (index(protos, proto) < 0 && index(protos, 'all') < 0 && index(protos, 'any') < 0) return; for (let p in split(`${r.src_dport ?? ''}`, /[ ,]+/)) { let m = match(p, /^(\d+)([-:](\d+))?$/); - if (m && +m[1] <= port && port <= +(m[3] || m[1])) - taken = true; + if (m) + push(out, { from: +m[1], to: +(m[3] || m[1]), name: r.name ?? r['.name'] }); } }); - return taken; + return out; }; /** Every address the links use, the main one first. */ diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc index e65fae4..821fd46 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/health.uc @@ -42,12 +42,51 @@ export function needs() { }; }; -export function udp_listening(port) { - let hex = sprintf(':%04X ', port); +/** UDP ports an unconnected socket is bound to (IPv4 and IPv6): nothing else can listen there. */ +export function udp_bound() { + let out = {}; for (let f in [ '/proc/net/udp', '/proc/net/udp6' ]) - if (index(readfile(f) ?? '', hex) >= 0) - return true; - return false; + for (let line in split(readfile(f) ?? '', '\n')) { + // " 12: 00000000:1194 00000000:0000 07 …": local address, then the remote one (none). + let m = match(line, /^ *[0-9]+: [0-9A-F]+:([0-9A-F]{4}) [0-9A-F]+:0000 /); + if (m) + out[hex(m[1])] = true; + } + return map(keys(out), (k) => +k); +}; + +/** + * Programs on 'tcp' or 'udp' ports, our portal left out: { port: "dnsmasq" }. + * Kernel sockets (a tunnel's) have no name. + */ +function port_programs(proto) { + let out = {}; + for (let line in split(sh_out(`netstat -ln${proto == 'tcp' ? 't' : 'u'}p 2>/dev/null`) ?? '', '\n')) { + let f = split(trim(line), /[ \t]+/); + if (f[0] != proto && f[0] != `${proto}6`) + continue; + let m = match(f[3] ?? '', /:([0-9]+)$/); + let owner = split(f[length(f) - 1], '/'); + if (!m || !owner[1] || out[m[1]]) + continue; + // Our own portal runs as a dedicated uhttpd instance. + if (index(readfile(`/proc/${+owner[0]}/cmdline`) ?? '', '/usr/share/dawnline/portal') >= 0) + continue; + out[m[1]] = owner[1]; + } + return out; +} + +export function udp_port_programs() { + return port_programs('udp'); +}; + +export function tcp_port_programs() { + return port_programs('tcp'); +}; + +export function udp_listening(port) { + return index(udp_bound(), +port) >= 0; }; export function tcp_listening(port) { @@ -116,6 +155,11 @@ function other_subnets(srv_id) { }; /** Subnets in use on the router except the given server's (null: all of them). */ +/** The router's IPv4 networks, Dawnline's tunnels included: [{ iface, cidr }]. */ +export function networks() { + return other_subnets(null); +}; + export function used_subnets(except_srv) { return map(other_subnets(except_srv), (x) => x.cidr); }; @@ -211,12 +255,13 @@ const NO_PROTO = "netifd doesn't know the amneziawg protocol (AmneziaWG missing, /** Is AmneziaWG there and usable: packages, kernel module, netifd's protocol handler. */ function awg_check() { - let st = awg.state(); + let st = awg.load(); let title = 'AmneziaWG installed'; if (length(st.missing ?? [])) return check('awg', title, 'error', `${join(' and ', st.missing)} ${length(st.missing) == 1 ? 'is' : 'are'} missing.`, 'install:awg', 'AmneziaWG isn’t installed'); if (!st.loaded) { + // load() tried it: the second modprobe only repeats why. let why = trim(sh('modprobe amneziawg 2>&1; dmesg | grep -i amneziawg | tail -n 3').out); return check('awg', title, 'error', `The kernel module doesn't load${why ? `: ${why}` : '.'} Reinstall a build for this kernel in Components.`, 'updates', @@ -385,10 +430,16 @@ export function health(m) { } } - if (length(filter(values(m.servers), (x) => x.private_key))) { + // While every server is off the resolver only idles on loopback: nothing to check. + if (length(filter(values(m.servers), (x) => x.enabled && x.private_key))) { let rt = loop.resolver_target(); - let ok = stat(loop.RESOLVER.conf) != null && loop.resolver_running(); + let conf = stat(loop.RESOLVER.conf); + let running = conf != null && loop.resolver_running(); + // A new config (a server turned on, the home link up) restarts it: give it a few seconds. + let restarting = !running && conf != null && time() - conf.mtime < 10; + let ok = running || restarting; push(out, check('resolver', 'DNS for Home-only devices', ok ? 'ok' : 'warn', + restarting ? 'Restarting with the new settings.' : ok ? (rt.mode == 'ns' ? `Plain resolver running next to the LAN (${rt.address}).` : `Plain resolver on port ${rt.port}.`) : 'The resolver is not running; Home-only devices cannot resolve names.', ok ? null : 'apply')); } diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc index 9e3998b..a72b29f 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/live.uc @@ -29,7 +29,7 @@ export const CATEGORY = { device_added: 'people', device_removed: 'people', devices_removed: 'people', device_changed: 'people', device_keys: 'people', link_changed: 'people', person_added: 'people', person_removed: 'people', person_changed: 'people', - paused: 'people', resumed: 'people', paused_all: 'people', resumed_all: 'people', + paused: 'people', resumed: 'people', server_down: 'problems', server_up: 'problems', portal_blocked: 'problems', }; export const CATEGORIES = [ 'connections', 'people', 'problems' ]; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/lookup.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/lookup.uc index 0182eec..108beca 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/lookup.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/lookup.uc @@ -55,7 +55,8 @@ export function resolve_all(hosts) { let cmds = []; for (let i = 0; i < length(todo); i++) for (let j = 0; j < length(SERVERS); j++) - push(cmds, `( timeout ${TIMEOUT} nslookup ${q(todo[i])} ${SERVERS[j]} 2>/dev/null | awk '/^Address/ && NR>2 {print $NF}' > ${dir}/${i}.${j} ) &`); + // nslookup's own timeout: some firmware builds BusyBox without `timeout`. + push(cmds, `( nslookup -type=a -timeout=${TIMEOUT} -retry=1 ${q(todo[i])} ${SERVERS[j]} 2>/dev/null | awk '/^Address/ && NR>2 {print $NF}' > ${dir}/${i}.${j} ) &`); sh(`mkdir -p ${dir}; ${join(' ', cmds)} wait`); for (let i = 0; i < length(todo); i++) { let ips = []; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/migrate.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/migrate.uc index d4424f8..36cbf9e 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/migrate.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/migrate.uc @@ -57,8 +57,29 @@ export function uhttpd() { store.transact((w, m) => w.delete('dawnline', 'settings', 'portal_443')); }; +/** 1380 was every server's stored MTU before it became automatic (by device type and disguise). */ +function auto_mtu() { + let c = cursor(); + c.load('dawnline'); + let any = false; + c.foreach('dawnline', 'server', (s) => { + if (s.mtu == '1380') + any = true; + }); + if (!any) + return; + store.transact((w, m) => { + w.foreach('dawnline', 'server', (s) => { + if (s.mtu == '1380') + w.delete('dawnline', s['.name'], 'mtu'); + }); + }); + slog('dawnline', 'info', 'MTU is now automatic', null, 'Servers'); +} + /** All of them, in order. */ export function run() { word_codes(); uhttpd(); + auto_mtu(); }; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc index 13fafd4..6c5d0e9 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/portal.uc @@ -54,6 +54,12 @@ const SECURITY_HEADERS = { const NOT_READY = "Adding devices isn't available right now: the VPN server isn't ready. Ask whoever sent you this link."; +// States the admin stopped the person in: the portal only shows, it changes nothing. +const LOCKED = { + paused: 'Your access is paused by the admin.', + expired: 'Your access has ended. Ask the admin to extend it.', +}; + function html_escape(s) { return replace(`${s}`, /[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]); } @@ -263,11 +269,38 @@ function reload(r) { not_found(r); } +/** + * The person's state for the page: a stop by the admin (pause, end of access) + * wins over their server being off, so they learn that their access is stopped. + */ +function person_state(m, p, usage) { + let st = core.person_state(m, p, usage); + if (st == 'server_off') { + let own = core.own_state(m, p, usage); + if (LOCKED[own]) + return own; + } + return st; +} + +/** Why the person can't change anything right now, or null. */ +function locked(r) { + return LOCKED[person_state(r.m, r.person, core.load_usage())] ?? null; +} + +/** Refuses a change (or a config) while the person is stopped. */ +function need_open(r) { + let why = locked(r); + if (why) + fail(r, '403 Forbidden', why); +} + /** Everything the page shows. */ function state(r) { let m = r.m, person = r.person; let usage = core.load_usage(); let v = view.person_view(m, person, usage, live.dump(m), view.states(m, usage)); + v.state = person_state(m, person, usage); let srv = m.servers[person.server]; // The device this page was opened from, when it came through the tunnel. let here = null; @@ -284,6 +317,7 @@ function state(r) { awg_disguise: srv ? !awg.obf_neutral(srv.obf) : false, }, can_add: length(person.devices) < person.device_limit, + locked: LOCKED[v.state] != null, kinds: core.KINDS, // The router's day: access ends and usage days follow its clock, not the browser's. today: today(), @@ -304,6 +338,7 @@ function api_state(r) { } function api_add(r) { + need_open(r); let b = body(r); if (!devices.ready()) fail(r, '503 Service Unavailable', NOT_READY); @@ -314,6 +349,7 @@ function api_add(r) { function api_config(r, id) { let d = own_device(r, id); + need_open(r); awg.mark_issued(r.m, d.id); send_json(r, '200 OK', awg.client_config(r.m, d)); } @@ -338,6 +374,7 @@ const ACTIONS = { function api_device(r, id) { let d = own_device(r, id); + need_open(r); let b = body(r); let act = ACTIONS[b.action]; if (!act) diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/resolver.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/resolver.uc index efa416c..169e14b 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/resolver.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/resolver.uc @@ -54,10 +54,12 @@ export function running() { */ export function sync(m, target, lan) { ensure_dir('/var/etc'); + // Servers that are on: with none, the resolver idles on loopback. let ifs = []; for (let id, s in m.servers) - for (let t in core.tunnels(s)) - push(ifs, t.ifname); + if (s.enabled) + for (let t in core.tunnels(s)) + push(ifs, t.ifname); let lines = [ `# mode=${target.mode}`, '# Generated by Dawnline: plain DNS for Home-only tunnel clients.', @@ -76,7 +78,7 @@ export function sync(m, target, lan) { push(lines, `server=${a}@${target.address}`); } else { - // No tunnel yet: loopback only (without any interface= line dnsmasq would answer everywhere). + // No tunnel on: loopback only (without any interface= line dnsmasq would answer everywhere). push(lines, 'bind-dynamic', ...(length(ifs) ? map(ifs, (i) => `interface=${i}`) : [ 'listen-address=127.0.0.1' ]), `resolv-file=${RESOLV}`); let resolv = join('', map(wan_dns(), (a) => `nameserver ${a}\n`)); if ((readfile(RESOLV) ?? '') != resolv) { diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/common.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/common.uc index 453fda9..431b961 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/common.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/common.uc @@ -5,6 +5,7 @@ import * as core from 'dawnline.core'; import * as awg from 'dawnline.awg'; import * as health from 'dawnline.health'; import * as schema from 'dawnline.schema'; +import { uniq } from 'dawnline.util'; /** * An rpcd handler from fn(args): an object result is passed on, anything else @@ -52,6 +53,36 @@ export function check_method(name) { * addresses use plain HTTP, the next port too — both get a WAN ACCEPT rule. * Neither may be 22, 53, 80 or 443, beyond 65535, or taken by another program. */ +/** TCP port forwards from the servers' WAN zones: [{ from, to, name }]. */ +function tcp_forwards(m) { + let out = []; + for (let z in uniq([ 'wan', ...map(values(m.servers), (s) => s.wan_zone) ])) + push(out, ...core.wan_forwards(z, 'tcp')); + return out; +} + +/** + * TCP ports the portal can't take, and who holds them: [{ from, to, who }]. + * The router's own (22, 53, 80, 443), other programs and port forwards from WAN. + */ +export function tcp_taken(m) { + let out = []; + let held = {}; + let hold = (p, who) => { + if (!held[p]) { + held[p] = true; + push(out, { from: p, to: p, who }); + } + }; + for (let p in schema.RESERVED_PORTS) + hold(p, 'the router itself'); + for (let p, name in health.tcp_port_programs()) + hold(+p, `${name} on this router`); + for (let f in tcp_forwards(m)) + push(out, { from: f.from, to: f.to, who: `port forward “${f.name}”` }); + return out; +}; + export function check_portal(m, was) { let s = m.settings; if (!s.portal_enabled) @@ -80,4 +111,9 @@ export function check_portal(m, was) { if (length(owners)) die(`TCP ${p} is already used by ${join(', ', owners)}.${p != port ? ' Links on IP addresses use plain HTTP on the port after the portal\'s.' : ''} Choose another portal port.`); } + // A forwarded port never reaches the router: the portal would be unreachable. + for (let p in ports) + for (let f in tcp_forwards(m)) + if (f.from <= p && p <= f.to) + die(`TCP ${p} is sent on by port forward “${f.name}”. Choose another portal port.`); }; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc index 450b39e..9dcd0e6 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/people.uc @@ -111,15 +111,6 @@ function person_usage(a) { return { person: live.series([ usage.people?.[a.id] ], days), devices: devs }; } -function pause_all(a) { - store.transact((c, m) => { - c.set(core.CONFIG, 'settings', 'settings'); - c.set(core.CONFIG, 'settings', 'paused_all', a.paused ? '1' : '0'); - }); - live.add_event({ type: a.paused ? 'paused_all' : 'resumed_all', by: 'admin' }); - return apply.sync(); -} - /* ---------- devices ---------- */ function device_create(a) { @@ -155,7 +146,6 @@ export const methods = { person_links: { args: { id: '' }, call: wrap(person_links) }, person_delete: { args: { id: '' }, call: wrap(person_delete) }, person_usage: { args: { id: '', days: 30 }, call: wrap(person_usage) }, - pause_all: { args: { paused: false }, call: wrap(pause_all) }, device_create: { args: { person: '', name: '', kind: '' }, call: wrap(device_create) }, device_config: { args: { id: '' }, call: wrap(device_config) }, device_update: { args: { id: '', name: '', disabled: false }, call: wrap(device_update) }, diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc index e4c46d6..af60798 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/servers.uc @@ -14,7 +14,7 @@ import * as schema from 'dawnline.schema'; import * as health from 'dawnline.health'; import * as backup from 'dawnline.backup'; import * as devices from 'dawnline.devices'; -import { wrap, str, check_method, check_portal } from 'dawnline.rpc.common'; +import { wrap, str, check_method, check_portal, tcp_taken } from 'dawnline.rpc.common'; /** Server ids that would shadow a portal path. */ const PORTAL_PATHS = [ 'api', 'assets', 'cgi-bin' ]; @@ -23,19 +23,54 @@ const MESH_WORDS = { off: 'devices kept apart', all: 'devices reach each other', /* ---------- free names, ports and subnets ---------- */ -function free_port(m) { - let used = {}; +/** + * UDP ports a server can't listen on, and who holds them: [{ from, to, who }]. + * Other servers, tunnel interfaces, programs on the router and port forwards + * from its WAN zone. `srv` is the server being edited: its own port isn't counted. + */ +function udp_taken(m, srv, wan_zone) { + let out = []; + let held = {}; + let hold = (p, who) => { + if (p > 0 && !held[p]) { + held[p] = true; + push(out, { from: p, to: p, who }); + } + }; + for (let id, o in m.servers) + if (id != srv?.id) + hold(o.port, `server “${o.name}”`); let nc = cursor(); nc.load('network'); nc.foreach('network', 'interface', (s) => { - if (s.listen_port) - used[+s.listen_port] = true; + if (s.listen_port && s['.name'] != srv?.ifname) + hold(+s.listen_port, `interface ${s['.name']}`); }); - for (let id, srv in m.servers) - used[srv.port] = true; + let progs = health.udp_port_programs(); + for (let p in health.udp_bound()) + if (p != srv?.port) + hold(p, progs[`${p}`] ? `${progs[`${p}`]} on this router` : 'another program on this router'); + for (let f in core.wan_forwards(wan_zone, 'udp')) + push(out, { from: f.from, to: f.to, who: `port forward “${f.name}”` }); + return out; +} + +function check_udp_port(port, taken) { + for (let t in taken) + if (t.from <= port && port <= t.to) + die(`UDP ${port} is used by ${t.who}. Choose another port.`); +} + +/** The usual AmneziaWG port when free, otherwise a random high one. */ +const DEFAULT_PORT = 4500; + +function free_port(taken) { + let used = (p) => length(filter(taken, (t) => t.from <= p && p <= t.to)) > 0; + if (!used(DEFAULT_PORT)) + return DEFAULT_PORT; for (let i = 0; i < 50; i++) { let p = rand_int(40000, 60000); - if (!used[p]) + if (!used(p)) return p; } return 51830; @@ -58,9 +93,14 @@ function free_subnet(taken) { return '10.77.0.0/24'; } -function free_portal_port(cur) { - for (let p in uniq([ cur || 8443, 8443, 9443, 10443, 7443, 4443 ])) - if (!length(health.tcp_port_owners(p)) && !length(health.tcp_port_owners(p + 1))) +/** + * A portal port free together with the next one (plain HTTP for IP links): + * `first` (the server's UDP number, TCP is another port) before the usual ones. + */ +function free_portal_port(first, cur, taken) { + let used = (p) => length(filter(taken, (t) => t.from <= p && p <= t.to)) > 0; + for (let p in uniq([ first, cur || 8443, 8443, 9443, 10443, 7443, 4443 ])) + if (!used(p) && !used(p + 1)) return p; return 9443; } @@ -97,19 +137,29 @@ function free_server_id(m) { return `server${n}`; } -/** Subnets a new server must not overlap: the router's networks and the other servers. */ -function taken_subnets(m) { - let taken = health.used_subnets(null); +/** Networks a new server must not overlap, by name: the router's and the other servers'. */ +function taken_networks(m) { + let out = []; + let seen = {}; + let add = (name, cidr) => { + let c = parse_cidr(cidr); + if (c && !seen[cidr_str(c)]) { + seen[cidr_str(c)] = true; + push(out, { name, cidr: cidr_str(c) }); + } + }; + for (let n in health.networks()) + add(n.iface, n.cidr); for (let id, s in m.servers) - push(taken, s.subnet); - return taken; + add(s.name, s.subnet); + return out; } /* ---------- setup ---------- */ function setup_defaults(a) { let m = core.load(); - let taken = taken_subnets(m); + let networks = taken_networks(m); let zones = []; let fc = cursor(); fc.load('firewall'); @@ -128,35 +178,40 @@ function setup_defaults(a) { if (!host) host = live.iface_status('wan')?.['ipv4-address']?.[0]?.address ?? ''; } + let wan_zone = index(zones, 'wan') >= 0 ? 'wan' : zones[1]; + let udp = udp_taken(m, null, wan_zone); + let tcp = tcp_taken(m); + let port = free_port(udp); return { id: free_server_id(m), name: length(m.servers) ? `Server ${length(m.servers) + 1}` : 'Home', ifname: free_ifname(m), - port: free_port(m), - subnet: free_subnet(taken), + port, + subnet: free_subnet(map(networks, (n) => n.cidr)), endpoint: host, - mtu: 1380, + // Automatic. + mtu: 0, zones, lan_zone: index(zones, 'lan') >= 0 ? 'lan' : zones[0], - wan_zone: index(zones, 'wan') >= 0 ? 'wan' : zones[1], - portal_port: free_portal_port(m.settings.portal_port), + wan_zone, + // A portal already on keeps its port; a new one takes the server's number when it can. + portal_port: m.settings.portal_enabled ? m.settings.portal_port : free_portal_port(port, m.settings.portal_port, tcp), awg: awg.caps(), - awg_state: awg.state(), - taken, + awg_state: awg.load(), + networks, + udp_taken: udp, + tcp_taken: tcp, }; } /** AmneziaWG can run a server: installed, and its kernel module loads. */ function need_awg_loaded() { devices.need_awg(); - if (awg.state().loaded) - return; - system('modprobe amneziawg >/dev/null 2>&1'); - if (!awg.state().loaded) + if (!awg.load().loaded) die("AmneziaWG's kernel module doesn't load on this firmware: reinstall a build for this kernel in Components."); } -/** An MTU as typed: '' (the default) or 1280-1500. */ +/** An MTU as typed: '' (automatic) or 1280-1500. */ function check_mtu(v) { let s = str(v); if (s != '' && (!match(s, /^[0-9]{1,4}$/) || +s < 1280 || +s > 1500)) @@ -180,21 +235,24 @@ function server_create(a) { let ifname = str(a.ifname) || free_ifname(m); if (!ifname_free(m, nc, ifname)) die(`Network interface ${ifname} already exists.`); - let port = free_port(m); + let udp = udp_taken(m, null, str(a.wan_zone) || 'wan'); + let port = free_port(udp); if (a.port != null && str(a.port) != '' && str(a.port) != '0') { if (!schema.valid_port(a.port)) die('UDP port must be 1-65535.'); port = +str(a.port); } - for (let sid, o in m.servers) - if (o.port == port) - die(`UDP ${port} is used by ${o.name}.`); - let mtu = check_mtu(a.mtu == 0 ? '' : a.mtu) || '1380'; + check_udp_port(port, udp); + let mtu = check_mtu(a.mtu == 0 ? '' : a.mtu); let preset = str(a.preset) || 'standard'; let srv = { id, ifname, port, subnet: str(a.subnet), endpoint: str(a.endpoint), obf: awg.obf_preset(check_method(preset)) }; let pc = parse_cidr(srv.subnet); if (pc) srv.subnet = cidr_str(pc); + // Public addresses inside the tunnel would hide the real hosts behind them. + // New servers only: a restored backup keeps what it had. + if (pc && !core.private_cidr(pc)) + die('Use a private range: 10.x.x.x, 172.16–31.x.x or 192.168.x.x.'); let taken = [ ...router_subnets ]; for (let sid, o in m.servers) push(taken, o.subnet); @@ -212,7 +270,8 @@ function server_create(a) { set('subnet', srv.subnet); if (srv.endpoint) set('endpoint', srv.endpoint); - set('mtu', mtu); + if (mtu) + set('mtu', mtu); set('keepalive', '25'); let kp = awg.server_keys(); set('private_key', kp.private_key); @@ -249,8 +308,11 @@ function server_create(a) { system('/etc/init.d/dawnline enabled || /etc/init.d/dawnline enable'); let made = core.load().servers[id]; admin_log('dawnline', 'created', 'server', made?.name ?? id, made ? `UDP ${made.port}` : null); - sh_bg('/etc/init.d/dawnline restart'); - return { id, applied: r }; + // netifd reads its protocol handlers when it starts: AmneziaWG installed + // after that (by hand, or by an older installer) needs a network restart. + let network_restart = !awg.state().handler; + sh_bg(network_restart ? '/etc/init.d/network restart; /etc/init.d/dawnline restart' : '/etc/init.d/dawnline restart'); + return { id, applied: r, network_restart }; } /* ---------- interfaces ---------- */ @@ -416,9 +478,8 @@ function server_update(a) { if (!schema.valid_port(v.port)) die('UDP port must be 1-65535.'); let n = +str(v.port); - for (let id, o in m.servers) - if (id != srv.id && o.port == n) - die(`UDP ${n} is used by ${o.name}.`); + if (n != srv.port) + check_udp_port(n, udp_taken(m, srv, srv.wan_zone)); set('port', `${n}`); } if (v.enabled != null) @@ -451,7 +512,7 @@ function server_update(a) { for (let k, label in labels) { if (v[k] == null) continue; - let was = k == 'dns' ? join(' ', srv.dns ?? []) : `${srv[k] ?? ''}`; + let was = k == 'dns' ? join(' ', srv.dns ?? []) : k == 'mtu' && !srv.mtu ? '' : `${srv[k] ?? ''}`; let now = k == 'dns' ? join(' ', dns_list(v.dns)) : str(v[k]); if (trim(was) != trim(now)) push(what, label); diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/settings.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/settings.uc index 7d01cd4..2a66420 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/settings.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/settings.uc @@ -11,7 +11,7 @@ import * as store from 'dawnline.store'; import * as schema from 'dawnline.schema'; import * as health from 'dawnline.health'; import * as pc from 'dawnline.portalcert'; -import { wrap, check_portal } from 'dawnline.rpc.common'; +import { wrap, check_portal, tcp_taken } from 'dawnline.rpc.common'; /** The portal's own checks from Health, shown next to its settings. */ const PORTAL_CHECKS = [ 'portal', 'portal_dns', 'portal_reply', 'portal_http', 'cert' ]; @@ -65,7 +65,7 @@ function settings_get(a) { services: values(m.services), cert: cert ? { path: cert.cert, self_signed: cert.self_signed, expires: sh_out(`openssl x509 -enddate -noout -in ${q(cert.cert)} 2>/dev/null | cut -d= -f2`) } : null, - port_owners: m.settings.portal_enabled ? [] : health.tcp_port_owners(m.settings.portal_port), + tcp_taken: tcp_taken(m), portal_public_port: core.portal_public_port(m), geo_cached: length(keys(geo.load().ips)), logs: logs_info(m), diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/status.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/status.uc index cac2eb9..265dc63 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/status.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/rpc/status.uc @@ -10,6 +10,7 @@ import * as geo from 'dawnline.geo'; import * as net from 'dawnline.net'; import * as loop from 'dawnline.loop'; import * as awg from 'dawnline.awg'; +import * as lookup from 'dawnline.lookup'; import { wrap, clamp_days } from 'dawnline.rpc.common'; /** Router location plus one point per (device, recent client address). */ @@ -19,14 +20,25 @@ function geo_view(m, usage, dmp) { let cache = geo.load(); let points = []; let now = time(); + // The router's own public addresses: a device at home that reaches the server through the + // WAN address (NAT loopback) shows up from there. Home is not a place people connect from. + let own = {}; + for (let id, srv in m.servers) { + let a = net.wan_address(srv) ?? lookup.wan_ipv4(srv.wan_zone); + if (a) + own[a] = true; + } + let wan = lookup.wan_ipv4('wan'); + if (wan) + own[wan] = true; for (let id, d in m.devices) { let rec = usage.devices?.[id]; let peer = dmp.peers[d.public_key]; let cur = live.endpoint_ip(peer?.endpoint); let online = live.online(dmp, id, peer); for (let ip, ts in rec?.ips ?? {}) { - // Local (LAN / CGNAT) client addresses are not shown on the map. - let pl = geo.is_public(ip) ? geo.place(cache, ip) : null; + // Local (LAN / CGNAT) client addresses and the router's own are not shown on the map. + let pl = geo.is_public(ip) && !own[ip] ? geo.place(cache, ip) : null; if (!pl) continue; push(points, { @@ -76,6 +88,8 @@ function server_view(m, srv, usage, dmp, rates, days) { id: srv.id, name: srv.name, ifname: srv.ifname, port: srv.port, subnet: srv.subnet, endpoint: core.endpoint_host(m, srv), public_key: srv.public_key, enabled: srv.enabled, lan_like: srv.lan_like, device_mesh: srv.device_mesh, mesh: srv.mesh, preset: srv.preset, mtu: srv.mtu, keepalive: srv.keepalive, dns: srv.dns, + // What devices get now, by kind (mtu 0 = automatic). + mtus: { computer: core.device_mtu(srv, { kind: 'computer' }), phone: core.device_mtu(srv, { kind: 'phone' }) }, address: core.server_address(srv), up: !!st.up, uptime: st.uptime ?? 0, // Why the tunnel cannot run (its interface name belongs to another network section), or null. blocked: srv.blocked ?? null, @@ -142,7 +156,7 @@ function status(a) { settings: { portal_enabled: s.portal_enabled, portal_port: s.portal_port, portal_host: s.portal_host, portal_public_port: core.portal_public_port(m), - paused_all: s.paused_all, default_device_limit: s.default_device_limit, domain: s.domain, + default_device_limit: s.default_device_limit, domain: s.domain, hostnames: s.hostnames, geo_enabled: s.geo_enabled, home_dns_fallback: s.home_dns_fallback, }, servers, diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc index 790fbfe..1bed114 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/util.uc @@ -4,7 +4,7 @@ import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs'; -export const VERSION = '0.4.2'; +export const VERSION = '0.5.0'; /** GitHub repository with Dawnline releases (updates and the installer). */ export const REPO = 'tickcount/luci-app-dawnline'; export const RUN_DIR = '/var/run/dawnline'; @@ -273,19 +273,31 @@ const INTENT = `${RUN_DIR}/iface-intent.json`; export function iface_intent(ifname, reason, name) { let all = read_json(INTENT, {}); - all[ifname] = { reason, name, ts: time() }; + let now = time(); + for (let k, v in all) + if (now - v.ts >= 120) + delete all[k]; + all[ifname] = { reason, name, ts: now }; ensure_dir(RUN_DIR); write_json(INTENT, all, 0o600); }; +/** + * The note for a stop of `ifname`, or null. netifd may report one stop more + * than once (the interface, then its device): the note covers every report + * within 15 s of the first, then it is spent. + */ export function take_iface_intent(ifname) { let all = read_json(INTENT, {}); let it = all[ifname]; - if (!it) + let now = time(); + if (!it || now - it.ts >= 120 || (it.used && now - it.used >= 15)) return null; - delete all[ifname]; - write_json(INTENT, all, 0o600); - return time() - it.ts < 120 ? it : null; + if (!it.used) { + it.used = now; + write_json(INTENT, all, 0o600); + } + return it; }; /** Newest first. */ diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc index ed69f80..9aeaa9c 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/watchdog.uc @@ -65,7 +65,8 @@ function probes(m) { repair: { what: 'restarting it', run: restart_services }, }); - if (stat(loop.RESOLVER.conf)) + // Only while a server is on: with all of them off it idles on loopback. + if (stat(loop.RESOLVER.conf) && length(filter(values(m.servers), (x) => x.enabled && x.private_key))) push(out, { id: 'resolver', src: 'dawnline', name: 'Resolver', who: 'DNS for Home-only devices', ok: loop.resolver_running(), problem: "isn't running", back: 'runs again', diff --git a/web/package-lock.json b/web/package-lock.json index ec32c52..0780144 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "dawnline-web", - "version": "0.4.2", + "version": "0.5.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dawnline-web", - "version": "0.4.2", + "version": "0.5.0", "license": "MIT", "dependencies": { "qrcode-generator": "1.4.4" diff --git a/web/package.json b/web/package.json index aa8a299..25a764e 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "dawnline-web", - "version": "0.4.2", + "version": "0.5.0", "private": true, "license": "MIT", "type": "module", diff --git a/web/src/admin/api.ts b/web/src/admin/api.ts index 94f77c2..2cc429d 100644 --- a/web/src/admin/api.ts +++ b/web/src/admin/api.ts @@ -1,5 +1,6 @@ // luci.dawnline RPC bindings. The backend reports failures as { error }. +import type { Network, PortHold } from './netcheck'; import type { AwgCaps, AwgState, Circle, ClientConfig, DayUsage, HealthCheck, LogEvent, MeshMode, Person, Status } from '../shared/types'; function call(method: string, params: string[] = []) { @@ -23,7 +24,11 @@ export interface SetupDefaults { lan_zone: string; wan_zone: string; portal_port: number; - taken: string[]; + /** Networks the tunnel must not overlap: the router's and the other servers'. */ + networks: Network[]; + /** UDP ports the server can't take, TCP ports the portal can't. */ + udp_taken: PortHold[]; + tcp_taken: PortHold[]; awg: AwgCaps; awg_state?: AwgState; } @@ -176,7 +181,8 @@ export interface SettingsData { effective: Record; services: { id: string; name: string; address: string; ports: string[] }[]; cert: { path: string; self_signed: boolean; expires: string | null } | null; - port_owners: string[]; + /** TCP ports the portal can't take. */ + tcp_taken: PortHold[]; wan443_taken?: boolean; portal_public_port?: number; geo_cached: number; @@ -422,7 +428,7 @@ export const api = { uninstall: call('uninstall', ['confirm']), status, setupDefaults: call('setup_defaults'), - serverCreate: call<{ id: string }>('server_create', [ + serverCreate: call<{ id: string; network_restart?: boolean }>('server_create', [ 'id', 'name', 'ifname', @@ -456,7 +462,6 @@ export const api = { personRegen: call<{ link: string | null }>('person_regen', ['id']), personDelete: call('person_delete', ['id']), personUsage: call<{ person: DayUsage[]; devices: Record }>('person_usage', ['id', 'days']), - pauseAll: call('pause_all', ['paused']), deviceCreate: call<{ id: string; config: ClientConfig }>('device_create', ['person', 'name', 'kind']), deviceConfig: call('device_config', ['id']), deviceUpdate: call('device_update', ['id', 'name', 'disabled']), diff --git a/web/src/admin/cores/awg.ts b/web/src/admin/cores/awg.ts index 2773299..94de6f8 100644 --- a/web/src/admin/cores/awg.ts +++ b/web/src/admin/cores/awg.ts @@ -258,7 +258,15 @@ async function applyDisguise(ctx: CoreCtx, srv: Server, m: Method, same: boolean export function settingsCard(ctx: CoreCtx, srv: Server): HTMLElement { const st: Status = ctx.st; const port = input(String(srv.port), { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' }); - const mtu = input(String(srv.mtu ?? ''), { placeholder: '1380', inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' }); + const mtu = input(srv.mtu ? String(srv.mtu) : '', { + placeholder: 'Auto', + inputmode: 'numeric', + class: 'cbi-input-text dl-w-port dl-mono', + }); + const now = `${srv.mtus.computer} for computers and routers, ${srv.mtus.phone} for phones and tablets`; + const mtuHint = srv.mtu + ? `Now ${now}. Empty = automatic.` + : `Automatic by device type and disguise: now ${now}. Lower it if some sites hang.`; const ka = input(String(srv.keepalive ?? ''), { placeholder: '25', inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' }); const current = methodInfo(srv.preset) ? (srv.preset as Method) : undefined; let selected: Method = current ?? 'standard'; @@ -266,22 +274,16 @@ export function settingsCard(ctx: CoreCtx, srv: Server): HTMLElement { const label = () => dom.content(apply, selected === current ? [icon('reset'), ' Generate new values'] : [`Switch to ${methodInfo(selected)!.title}`]); label(); - const devs = st.people.filter((p) => p.server === srv.id).reduce((n, p) => n + p.devices.length, 0); const tools = st.awg_state?.tools !== false; return card( '', [ - coreHead( - 'AmneziaWG', - srv.up ? 'ok' : 'bad', - srv.up ? 'Running' : 'Not running', - `${srv.ifname} · ${devs} device${devs === 1 ? '' : 's'}`, - ), + coreHead('AmneziaWG', srv.ifname), group('globe', 'Listening', 'Where devices reach this core from the internet', [ row('UDP port', port, 'Opened on the WAN firewall automatically.'), ]), group('file', 'In every device configuration', 'Changing these marks devices “Update config” until they import again', [ - row('MTU', mtu, 'Lower it if some sites hang on mobile networks.'), + row('MTU', mtu, mtuHint), row('Keep-alive', ka, 'Seconds between packets devices send to keep NAT open. 0 = off.'), ]), group('shield', 'Disguise', 'So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard', [ diff --git a/web/src/admin/cores/common.ts b/web/src/admin/cores/common.ts index 10ac6e7..86f7e5c 100644 --- a/web/src/admin/cores/common.ts +++ b/web/src/admin/cores/common.ts @@ -31,11 +31,7 @@ export interface Core { file: { label: string; make(cfg: ClientConfig): { name: string; text: string } }; } -/** Name, state pill and a short line: the head of a core's settings card. */ -export function coreHead(title: string, tone: 'ok' | 'bad' | 'off' | '', state: string, sub: string): HTMLElement { - return E('div', { class: 'dl-corehead' }, [ - E('h3', {}, title), - E('span', { class: `dl-pill ${tone}` }, state), - sub ? E('span', { class: 'dl-sub' }, sub) : '', - ]); +/** Name and a short line: the head of a core's settings card (the server's header already says whether it runs). */ +export function coreHead(title: string, sub: string): HTMLElement { + return E('div', { class: 'dl-corehead' }, [E('h3', {}, title), sub ? E('span', { class: 'dl-sub' }, sub) : '']); } diff --git a/web/src/admin/device.ts b/web/src/admin/device.ts index d12bff2..3f0a453 100644 --- a/web/src/admin/device.ts +++ b/web/src/admin/device.ts @@ -21,6 +21,8 @@ import { spark } from './widgets/spark'; import { clearLogDialog, exportEvents, resetUsageDialog } from './logs'; import { coreFor, coreOf, type Core } from './cores'; import { onLiveChange } from './state/live'; +import { ConnectionMap, devicePlaces, rangeControl, type MapData, type Range } from './map'; +import { personUrl } from './urls'; /** What the page that opens a device hands over. */ export interface DeviceOpts { @@ -139,8 +141,32 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { if (ev) showLog(ev.events); }; + // Where this device connected from, in time order (option B): a map with its trail and the list. + let range: Range = '30d'; + let map: ConnectionMap | null = null; + const places = E('div', { class: 'dl-dplaces' }); + const mapData = (): MapData => ({ geo: geo!, people: [p], now: now ?? Date.now() / 1000, person: p.id, device: d.id }); + const paintPlaces = () => { + if (!geo?.enabled) return; + const list = devicePlaces(mapData(), range); + dom.content( + places, + list.length + ? list.map((x) => + E('div', { class: 'dl-dplace-row' }, [ + E('span', { class: `dl-dplace-n${x.online ? ' live' : ''}` }, x.online ? icon(d.kind) : String(x.n)), + E('span', { class: 'dl-row-main dl-stack' }, [ + E('span', {}, [x.city || x.cc || 'Unknown city', x.org ? E('span', { class: 'dl-muted' }, ` · ${x.org}`) : '']), + E('span', { class: 'dl-mono dl-faint' }, x.ip), + ]), + E('span', { class: x.online ? 'dl-dplace-now' : 'dl-faint dl-nowrap' }, x.online ? 'now' : ago(x.ts, now)), + ]), + ) + : E('div', { class: 'dl-sub' }, 'No locations in this period.'), + ); + }; + const paint = () => { - const place = geo?.points.find((x) => x.device === d.id && x.ip === d.endpoint); dom.content(titleEl, [ E('span', { class: `dl-dcard-ic${d.online ? ' on' : ''}` }, icon(d.kind)), E('div', { class: 'dl-stack' }, [ @@ -176,15 +202,9 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { E('div', { class: 'dl-kv2' }, [ copyRow('Tunnel address', d.address), d.hostname && p.access !== 'internet' ? copyRow('Local address', d.hostname) : '', - d.endpoint - ? row( - 'Client IP', - E('span', {}, [ - d.endpoint, - place ? E('span', { class: 'dl-muted' }, ` · ${[place.city, place.org].filter(Boolean).join(' · ')}`) : '', - ]), - ) - : '', + // Where it connects from is under Locations (with the place and network); from home + // (not on the map) or without locations, here. + d.endpoint && !geo?.points.some((x) => x.device === d.id && x.ip === d.endpoint) ? row('Client IP', d.endpoint) : '', row( 'Total', E('span', { class: 'dl-kv-act' }, [ @@ -269,6 +289,8 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { now = st.now; today = todayOf(st.series); paint(); + map?.update(mapData()); + paintPlaces(); }; /** After a change made here: this drawer and the page. */ const changed = async () => { @@ -339,13 +361,38 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { log, ]); const detailsSec = E('section', { class: 'dl-dsec' }, [E('div', { class: 'dl-dsec-head' }, E('h4', {}, 'Details')), details]); + let locationsSec: HTMLElement | '' = ''; + if (geo?.enabled) { + map = new ConnectionMap( + { openPerson: (id) => (location.href = personUrl(id)), openDevice: (id, dev) => (location.href = personUrl(id, dev)) }, + range, + 220, + ); + locationsSec = E('section', { class: 'dl-dsec' }, [ + E('div', { class: 'dl-dsec-head' }, [ + E('h4', {}, 'Locations'), + rangeControl( + range, + (r) => { + range = r; + map?.setRange(r); + paintPlaces(); + }, + false, + ), + ]), + E('div', { class: 'dl-dmap' }, map.el), + places, + ]); + paintPlaces(); + } // Connecting is what the drawer is for until the device is set up (or its configuration is old); // after that it goes to the bottom. const setUp = !d.handshake || d.config_stale; const body = E( 'div', { class: 'dl-stack gap16' }, - setUp ? [stats, connectSec, detailsSec, activitySec] : [stats, detailsSec, activitySec, connectSec], + setUp ? [stats, connectSec, detailsSec, locationsSec, activitySec] : [stats, detailsSec, locationsSec, activitySec, connectSec], ); void loadLog(); // Live status and log: at once when something happens (state/live.ts), and every 30 s anyway. @@ -358,8 +405,10 @@ export async function openDevice(person: Person, dev: Device, o: DeviceOpts) { const handle = drawer(titleEl, body, foot, () => { clearInterval(watch); off(); + map?.destroy(); }); paint(); + if (map) requestAnimationFrame(() => map?.mount(mapData())); } /** ⋯ on a device card: quick actions (everything else is in the panel; click the card). */ diff --git a/web/src/admin/events/model.ts b/web/src/admin/events/model.ts index ee011b3..70afb87 100644 --- a/web/src/admin/events/model.ts +++ b/web/src/admin/events/model.ts @@ -20,8 +20,6 @@ const CATEGORY: Record = { person_changed: 'people', paused: 'people', resumed: 'people', - paused_all: 'people', - resumed_all: 'people', portal_blocked: 'problems', }; @@ -43,7 +41,7 @@ export const categoryOf = (type: string): LogCategory => CATEGORY[type] ?? 'prob export const SYSTEM_SOURCE: Record = { awg: 'AmneziaWG', dawnline: 'Dawnline', portal: 'Portal' }; -const ADMIN_TYPES = ['person_added', 'person_removed', 'person_changed', 'paused_all', 'resumed_all']; +const ADMIN_TYPES = ['person_added', 'person_removed', 'person_changed']; /** Who did it. Older events have no `by`: LuCI and the portal marked it in the detail. */ export function eventBy(e: LogEvent): 'admin' | 'portal' | null { diff --git a/web/src/admin/events/render.ts b/web/src/admin/events/render.ts index ade6497..58c3942 100644 --- a/web/src/admin/events/render.ts +++ b/web/src/admin/events/render.ts @@ -21,8 +21,6 @@ const EVENT_TONE: Record = { person_removed: '', paused: 'warn', resumed: 'ok', - paused_all: 'warn', - resumed_all: 'ok', portal_blocked: 'bad', person_changed: '', devices_removed: 'warn', @@ -37,8 +35,6 @@ const EVENT_ICON: Record = { person_changed: 'edit', paused: 'pause', resumed: 'play', - paused_all: 'pause', - resumed_all: 'play', }; function eventIcon(st: Names, e: LogEvent): string { @@ -93,10 +89,6 @@ export function eventText(st: Pick, e: LogEvent): Node[] { return [...you('issued new keys for'), kind('device'), b(devName), m(' of '), b(who), m(' · it needs its new configuration')]; case 'link_changed': return [...you('issued a new link for'), kind('person'), b(who), m(' · the old link stopped working')]; - case 'paused_all': - return [E('span', { class: 'dl-you' }, 'You'), m(' paused everyone')]; - case 'resumed_all': - return [E('span', { class: 'dl-you' }, 'You'), m(' resumed everyone')]; } switch (e.type) { case 'connect': @@ -147,10 +139,6 @@ export function eventText(st: Pick, e: LogEvent): Node[] { return [kind('Person'), b(who), m(` paused — ${e.detail ?? ''}`)]; case 'resumed': return [kind('Person'), b(who), m(' resumed'), ...(e.detail && e.detail !== 'active' ? [m(` — ${e.detail}`)] : [])]; - case 'paused_all': - return [m('Everyone paused')]; - case 'resumed_all': - return [m('Everyone resumed')]; case 'portal_blocked': return [ E('b', { class: 'dl-sys-src' }, 'Personal portal'), diff --git a/web/src/admin/interfaces.ts b/web/src/admin/interfaces.ts index 076b60c..baeafd2 100644 --- a/web/src/admin/interfaces.ts +++ b/web/src/admin/interfaces.ts @@ -160,7 +160,8 @@ export function accessCards(srv: Server, first: Status, refresh: () => Promise Promise = { online: 0, '24h': 86400, '7d': 7 * 86400 let loading: Promise | null = null; /** - * Load MapLibre once; tags go inside `host` so Outline's router is not - * disturbed. The stylesheet goes into every map's own container: Outline - * drops the previous page's DOM on navigation (and with it a shared link), - * and without it HTML markers lose their positioning and vanish. + * Load MapLibre once. The stylesheet goes into every map's own container: + * Outline drops the previous page's DOM on navigation (and with it a shared + * link), and without it HTML markers lose their positioning and vanish. + * Since 6 it is an ES module: imported (the URL in a variable, so the bundler + * leaves it alone), with the worker URL set as mapcn does. */ function loadMapLibre(host: HTMLElement): Promise { - const w = window as any; - host.appendChild(E('link', { rel: 'stylesheet', href: `${MAPLIBRE}.css` })); - if (w.maplibregl) return Promise.resolve(w.maplibregl); + host.appendChild(E('link', { rel: 'stylesheet', href: `${MAPLIBRE}/maplibre-gl.css` })); if (loading) return loading; - loading = new Promise((resolve, reject) => { - const s = E('script', { src: `${MAPLIBRE}.js` }) as HTMLScriptElement; - s.onload = () => (w.maplibregl ? resolve(w.maplibregl) : reject(new Error('MapLibre failed to load'))); - s.onerror = () => { + const url = `${MAPLIBRE}/maplibre-gl.mjs`; + loading = import(/* @vite-ignore */ url).then( + (gl) => { + if (!gl.getWorkerUrl()) gl.setWorkerUrl(`${MAPLIBRE}/maplibre-gl-worker.mjs`); + return gl; + }, + () => { loading = null; - reject(new Error('Could not load the map library (no internet access from this browser?)')); - }; - host.appendChild(s); - }); + throw new Error('Could not load the map library (no internet access from this browser?)'); + }, + ); return loading; } @@ -46,24 +51,41 @@ function isDark(): boolean { return window.matchMedia?.('(prefers-color-scheme: dark)').matches ?? false; } -/** A gentle arc between two [lng, lat] points (quadratic Bézier in map space). */ -function arc(a: [number, number], b: [number, number], steps = 48): [number, number][] { - const mx = (a[0] + b[0]) / 2; - const my = (a[1] + b[1]) / 2; - const dx = b[0] - a[0]; - const dy = b[1] - a[1]; - const len = Math.hypot(dx, dy) || 1; - // Bend to the left of the direction of travel, proportional to distance. - const k = Math.min(0.25 * len, 12); - const cx = mx - (dy / len) * k; - const cy = my + (dx / len) * k; - const out: [number, number][] = []; - for (let i = 0; i <= steps; i++) { - const t = i / steps; - const u = 1 - t; - out.push([u * u * a[0] + 2 * u * t * cx + t * t * b[0], u * u * a[1] + 2 * u * t * cy + t * t * b[1]]); +/** A click on a marker brings the map at least this close (a city). */ +const CLICK_ZOOM = 10; + +/** mapcn's arc colours: its default blue for live tunnels, a neutral gray for recently seen. */ +const LIVE = '#3b82f6'; +const RECENT = '#8a8a8a'; + +/** + * mapcn's arc (buildArcCoordinates): a quadratic Bézier between two + * [lng, lat] points bent by `curvature` of their distance, `samples` steps. + * The destination is unwrapped so |dx| <= 180: arcs across the antimeridian + * take the short way (MapLibre draws longitudes past ±180 on the globe). + */ +export function arc(from: [number, number], to: [number, number], curvature = 0.2, samples = 64): [number, number][] { + const [x0, y0] = from; + const [xTo, y2] = to; + const rawDx = xTo - x0; + const x2 = rawDx > 180 ? xTo - 360 : rawDx < -180 ? xTo + 360 : xTo; + const dx = x2 - x0; + const dy = y2 - y0; + const distance = Math.hypot(dx, dy); + if (distance === 0 || curvature === 0) return [from, [x2, y2]]; + const nx = -dy / distance; + const ny = dx / distance; + const offset = distance * curvature; + const cx = (x0 + x2) / 2 + nx * offset; + const cy = (y0 + y2) / 2 + ny * offset; + const points: [number, number][] = []; + const segments = Math.max(2, Math.floor(samples)); + for (let i = 0; i <= segments; i += 1) { + const t = i / segments; + const inv = 1 - t; + points.push([inv * inv * x0 + 2 * inv * t * cx + t * t * x2, inv * inv * y0 + 2 * inv * t * cy + t * t * y2]); } - return out; + return points; } export interface MapCallbacks { @@ -77,29 +99,67 @@ export interface MapData { now: number; /** Restrict to one person (person page). */ person?: string; + /** Restrict to one of their devices (device window): its places in time order. */ + device?: string; } -/** Latest point per device inside the time window. */ +/** + * The latest point per device inside the time window: per device and city on a + * person's page, per city in a device's window. + */ export function visiblePoints(data: MapData, range: Range): GeoPoint[] { const best = new Map(); for (const p of data.geo.points) { if (data.person && p.person !== data.person) continue; + if (data.device && p.device !== data.device) continue; if (range === 'online' ? !p.online : data.now - p.ts > WINDOW[range]) continue; - const cur = best.get(p.device); - if (!cur || (p.online && !cur.online) || (p.online === cur.online && p.ts > cur.ts)) best.set(p.device, p); + // Where people are: each device once. A person's page: every city each device was in. + const key = data.device ? `${p.city}|${p.cc}` : data.person ? `${p.device}|${p.city}|${p.cc}` : p.device; + const cur = best.get(key); + if (!cur || (p.online && !cur.online) || (p.online === cur.online && p.ts > cur.ts)) best.set(key, p); } return [...best.values()]; } +/** A device's places, live first, then newest: `n` numbers the past ones (1 = most recent). */ +export function devicePlaces(data: MapData, range: Range): (GeoPoint & { n: number })[] { + let i = 0; + return visiblePoints(data, range) + .sort((a, b) => Number(b.online) - Number(a.online) || b.ts - a.ts) + .map((p) => ({ ...p, n: p.online ? 0 : ++i })); +} + export class ConnectionMap { private map: any = null; private gl: any = null; private markers: any[] = []; - private popup: any = null; - private anim = 0; + /** The open card: it floats over the page (not clipped by the map), pinned to its marker. */ + private popup: { card: HTMLElement; off: () => void } | null = null; + private theme: MutationObserver | null = null; + private resize: ResizeObserver | null = null; + /** The last fit ran while the map had no size (a folded card): it is redone once it has one. */ + private fitBlind = false; private data: MapData | null = null; private range: Range; private fitted = false; + /** The places the view was last fitted to: a change (someone came online or left) refits. */ + private fitKey: string | null = null; + /** People's markers, for the hover highlight; the person in focus, kept across redraws. */ + private people: { el: HTMLElement; person: string }[] = []; + /** Markers on the map: the server stays put (`fixed`), the others move aside when crowded. */ + private slots: { marker: any; el: HTMLElement; at: [number, number]; fixed: boolean; who?: string; where?: string }[] = []; + /** People folded into the server while they would sit on top of it (their marker hidden). */ + private merged: { at: [number, number]; who: string; where: string; need: number }[] = []; + /** Which markers were folded at the last redraw (by place key): a new marker starts that way. */ + private foldedKeys = new Set(); + /** The zoom a programmatic zoom-out is heading for: markers fold for it at once, not on the way. */ + private targetZoom: number | null = null; + /** The view before a click zoomed in on a marker: closing its popup goes back to it. */ + private before: { center: [number, number]; zoom: number } | null = null; + /** The folded keys the layers were last filtered for (a filter only changes when they do). */ + private hiddenKey = ''; + private focused: string | null = null; + private card: HTMLElement; readonly el: HTMLElement; private status: HTMLElement; @@ -110,7 +170,8 @@ export class ConnectionMap { ) { this.range = range; this.status = E('div', { class: 'dl-map-status' }); - this.el = E('div', { class: 'dl-geomap', style: `height:${height}px` }, this.status); + this.card = E('div', { class: 'dl-map-card', 'aria-live': 'polite' }); + this.el = E('div', { class: 'dl-geomap', style: `height:${height}px` }, [this.status, this.card]); } async mount(data: MapData) { @@ -125,70 +186,91 @@ export class ConnectionMap { container: this.el, style: isDark() ? STYLE_DARK : STYLE_LIGHT, center: [data.geo.home?.lon ?? 20, data.geo.home?.lat ?? 50], - zoom: 3, + zoom: 1, + // mapcn's Map: MapLibre's own gestures (scroll zooms, drag spins the globe), no zoom buttons, + // one world, the attribution behind its "i" (styled as mapcn's site, map.css). + renderWorldCopies: false, attributionControl: { compact: true }, - dragRotate: false, - pitchWithRotate: false, - cooperativeGestures: true, + // No further out than the whole globe filling the map. + minZoom: 1, }); - this.map.addControl(new this.gl.NavigationControl({ showCompass: false }), 'bottom-right'); - this.map.on('load', () => { - // City-level accuracy: a soft zone instead of a precise pin. - this.map.addSource('dl-areas', { type: 'geojson', data: { type: 'FeatureCollection', features: [] } }); - this.map.addLayer({ - id: 'dl-area', - type: 'circle', - source: 'dl-areas', - paint: { - 'circle-radius': ['interpolate', ['exponential', 2], ['zoom'], 2, 6, 6, 26, 9, 140, 12, 900], - 'circle-color': ['case', ['get', 'online'], '#40c977', isDark() ? '#ededed' : '#0d0d0d'], - 'circle-opacity': ['case', ['get', 'online'], 0.12, 0.06], - 'circle-stroke-width': 1, - 'circle-stroke-color': ['case', ['get', 'online'], '#40c977', isDark() ? '#ededed' : '#0d0d0d'], - 'circle-stroke-opacity': ['case', ['get', 'online'], 0.35, 0.15], - }, - }); - this.map.addSource('dl-arcs', { type: 'geojson', data: { type: 'FeatureCollection', features: [] } }); - this.map.addLayer({ - id: 'dl-arc-recent', - type: 'line', - source: 'dl-arcs', - filter: ['==', ['get', 'online'], false], - layout: { 'line-cap': 'round' }, - paint: { 'line-color': isDark() ? '#ededed' : '#0d0d0d', 'line-opacity': 0.35, 'line-width': 1.5, 'line-dasharray': [2, 3] }, - }); - this.map.addLayer({ - id: 'dl-arc-glow', - type: 'line', - source: 'dl-arcs', - filter: ['==', ['get', 'online'], true], - layout: { 'line-cap': 'round' }, - paint: { 'line-color': '#40c977', 'line-opacity': 0.18, 'line-width': 7 }, - }); - this.map.addLayer({ - id: 'dl-arc-live', - type: 'line', - source: 'dl-arcs', - filter: ['==', ['get', 'online'], true], - layout: { 'line-cap': 'round' }, - paint: { 'line-color': '#40c977', 'line-width': 2 }, - }); - this.map.addLayer({ - id: 'dl-arc-flow', - type: 'line', - source: 'dl-arcs', - filter: ['==', ['get', 'online'], true], - layout: { 'line-cap': 'round' }, - paint: { 'line-color': '#ffffff', 'line-width': 2, 'line-opacity': 0.8, 'line-dasharray': [0, 4, 3] }, - }); - this.animate(); - this.draw(); + // Every style load (the first, and each theme switch) starts bare: the globe and our layers again. + this.map.on('style.load', () => this.layers()); + // Crowded markers spread and come back together as the map zooms and pans. + this.map.on('move', () => this.declutter()); + // MapLibre opens the credits once the sources have them: fold them away when the map is drawn. + this.map.once('idle', () => { + const attrib = this.el.querySelector('.maplibregl-ctrl-attrib'); + attrib?.classList.remove('maplibregl-compact-show'); + attrib?.removeAttribute('open'); }); + // MapLibre follows the window, not its container (a card unfolding, the page reflowing). + this.resize = new ResizeObserver(() => { + if (!this.map || !this.el.clientWidth || !this.el.clientHeight) return; + this.map.resize(); + if (this.fitBlind) { + this.fitKey = null; + this.draw(); + } + }); + this.resize.observe(this.el); + // Outline switches light and dark in place (html[data-darkmode]): the basemap follows. + let dark = isDark(); + this.theme = new MutationObserver(() => { + if (!this.map || isDark() === dark) return; + dark = isDark(); + this.map.setStyle(dark ? STYLE_DARK : STYLE_LIGHT); + }); + this.theme.observe(document.documentElement, { attributes: true, attributeFilter: ['data-darkmode'] }); + } + + /** The globe (as mapcn's examples: projection={{ type: "globe" }}), accuracy zones and arcs. */ + private layers() { + if (!this.map) return; + this.hiddenKey = ''; + this.map.setProjection({ type: 'globe' }); + // City-level accuracy: a soft zone instead of a precise pin. + this.map.addSource('dl-areas', { type: 'geojson', data: { type: 'FeatureCollection', features: [] } }); + this.map.addLayer({ + id: 'dl-area', + type: 'circle', + source: 'dl-areas', + paint: { + 'circle-radius': ['interpolate', ['exponential', 2], ['zoom'], 2, 6, 6, 26, 9, 140, 12, 900], + 'circle-color': ['case', ['get', 'online'], LIVE, RECENT], + 'circle-opacity': ['case', ['get', 'online'], 0.12, 0.06], + 'circle-stroke-width': 1, + 'circle-stroke-color': ['case', ['get', 'online'], LIVE, RECENT], + 'circle-stroke-opacity': ['case', ['get', 'online'], 0.35, 0.15], + }, + }); + // A device's trail through its places in time order (its window): fine gray dots. + this.map.addSource('dl-trail', { type: 'geojson', data: { type: 'FeatureCollection', features: [] } }); + this.map.addLayer({ + id: 'dl-trail', + type: 'line', + source: 'dl-trail', + layout: { 'line-join': 'round', 'line-cap': 'round' }, + paint: { 'line-color': RECENT, 'line-width': 1.5, 'line-opacity': 0.85, 'line-dasharray': [0, 2.5] }, + }); + // mapcn's MapArc paint (width 2, opacity 0.85, rounded) with the Basic Arc example's dashes; + // recent arcs under live ones. + this.map.addSource('dl-arcs', { type: 'geojson', data: { type: 'FeatureCollection', features: [] } }); + for (const live of [false, true]) + this.map.addLayer({ + id: live ? 'dl-arc-live' : 'dl-arc-recent', + type: 'line', + source: 'dl-arcs', + filter: ['==', ['get', 'online'], live], + layout: { 'line-join': 'round', 'line-cap': 'round' }, + paint: { 'line-color': live ? LIVE : RECENT, 'line-width': 2, 'line-opacity': 0.85, 'line-dasharray': [2, 2] }, + }); + this.draw(); } setRange(r: Range) { this.range = r; - this.fitted = false; + this.fitKey = null; this.draw(); } @@ -198,52 +280,23 @@ export class ConnectionMap { } destroy() { - cancelAnimationFrame(this.anim); + this.dropCard(); + this.theme?.disconnect(); + this.resize?.disconnect(); this.map?.remove(); this.map = null; } - /** Moving highlight along live arcs (MapLibre "animated line" technique). */ - private animate() { - const seq = [ - [0, 4, 3], - [0.5, 4, 2.5], - [1, 4, 2], - [1.5, 4, 1.5], - [2, 4, 1], - [2.5, 4, 0.5], - [3, 4, 0], - [0, 0.5, 3, 3.5], - [0, 1, 3, 3], - [0, 1.5, 3, 2.5], - [0, 2, 3, 2], - [0, 2.5, 3, 1.5], - [0, 3, 3, 1], - [0, 3.5, 3, 0.5], - ]; - let step = -1; - let last = 0; - const tick = (t: number) => { - if (!this.map) return; - if (t - last > 70) { - last = t; - step = (step + 1) % seq.length; - if (this.map.getLayer('dl-arc-flow')) this.map.setPaintProperty('dl-arc-flow', 'line-dasharray', seq[step]); - } - this.anim = requestAnimationFrame(tick); - }; - this.anim = requestAnimationFrame(tick); - } - - /** Devices grouped by network operator and city: one marker per group. */ + /** A person's devices grouped by city: one marker per person and place. */ private groups(pts: GeoPoint[]): Group[] { const map = new Map(); for (const p of pts) { - const key = `${p.asn || p.org || p.ip}|${p.city}|${p.cc}`; + const key = `${p.person}|${p.city || `${p.lat.toFixed(1)},${p.lon.toFixed(1)}`}|${p.cc}`; let g = map.get(key); if (!g) { g = { key, + person: p.person, lat: p.lat, lon: p.lon, city: p.city, @@ -268,24 +321,20 @@ export class ConnectionMap { if (!this.map || !this.data || !this.map.getSource('dl-arcs')) return; const data = this.data; const groups = this.groups(visiblePoints(data, this.range)); - const home = data.geo.home; + // A person's page and a device's window are about their places alone: no server, no arcs to it. + const home = data.person || data.device ? null : data.geo.home; for (const m of this.markers) m.remove(); this.markers = []; - // Operators in the same city sit side by side so every marker stays clickable. - const perCity = new Map(); - const placed = groups.map((g) => { - const c = `${g.lat.toFixed(2)},${g.lon.toFixed(2)}`; - const n = perCity.get(c) ?? 0; - perCity.set(c, n + 1); - return { g, at: [g.lon + n * 0.25, g.lat] as [number, number] }; - }); + // Every marker at its real place; ones that would cover each other move aside on screen (declutter). + const placed = groups.map((g) => ({ g, at: [g.lon, g.lat] as [number, number] })); + this.slots = []; this.map.getSource('dl-areas').setData({ type: 'FeatureCollection', features: placed.map(({ g, at }) => ({ type: 'Feature', - properties: { online: g.online }, + properties: { online: g.online, key: g.key }, geometry: { type: 'Point', coordinates: at }, })), }); @@ -294,57 +343,322 @@ export class ConnectionMap { features: home ? placed.map(({ g, at }) => ({ type: 'Feature', - properties: { online: g.online }, + properties: { online: g.online, person: g.person, key: g.key }, geometry: { type: 'LineString', coordinates: arc([home.lon, home.lat], at) }, })) : [], }); + // The server, where every arc starts: a tile in the theme's inverse colours (as the white + // main buttons) on a frosted plate, its city on a blurred chip. People are round: who (their + // initials) and from what (a device badge), blue while live, gray when seen recently. if (home) { - const el = E('div', { - class: 'dl-mk-home', - title: `Home router${home.city ? ` · ${home.city}` : ''}${home.org ? ` · ${home.org}` : ''}`, - }); - el.innerHTML = iconSvg('home', 'dl-mk-home-ic'); - this.markers.push(new this.gl.Marker({ element: el }).setLngLat([home.lon, home.lat]).addTo(this.map)); + const host = E('span', { class: 'dl-mk-host' }); + host.innerHTML = `${iconSvg('server', 'dl-mk-host-ic')}`; + const el = E( + 'div', + { class: 'dl-mk-hub', title: `Home router${home.city ? ` · ${home.city}` : ''}${home.org ? ` · ${home.org}` : ''}` }, + [host, E('span', { class: 'dl-mk-label chip' }, home.city || 'Home')], + ); + // Who is folded in here: listed on hover; a click zooms in until they stand apart. + el.addEventListener('mouseenter', () => this.showMerged(home.city || 'the server')); + el.addEventListener('mouseleave', () => this.focus(this.focused)); + el.addEventListener('click', () => this.zoomToMerged()); + this.add(el, [home.lon, home.lat], true); } + // A device's places joined oldest to newest, each step bowed like an arc. + const steps = data.device ? [...placed].sort((a, b) => Number(a.g.online) - Number(b.g.online) || a.g.ts - b.g.ts) : []; + this.map.getSource('dl-trail')?.setData({ + type: 'FeatureCollection', + features: + steps.length > 1 + ? [ + { + type: 'Feature', + properties: {}, + geometry: { type: 'LineString', coordinates: steps.slice(1).flatMap((x, i) => arc(steps[i].at, x.at)) }, + }, + ] + : [], + }); + const numbers = new Map(data.device ? devicePlaces(data, this.range).map((p) => [`${p.city}|${p.cc}`, p.n]) : []); + + this.people = []; for (const { g, at } of placed) { const n = g.points.length; + const person = data.people.find((x) => x.id === g.person); + if (data.person) { + const el = data.device + ? this.stepMarker(g, at, person, numbers.get(`${g.points[0].city}|${g.points[0].cc}`) ?? 0) + : this.placeMarker(g, at, person); + this.add(el, at); + continue; + } + const kinds = g.points.map((p) => person?.devices.find((d) => d.id === p.device)?.kind ?? 'other'); + // One device: its icon; two: both; more: how many (the hover card lists them). + const badge = E('span', { class: 'dl-mk-badge' }); + badge.innerHTML = n <= 2 ? kinds.map((k) => iconSvg(k, 'dl-mk-badge-ic')).join('') : String(n); const el = E( 'button', { type: 'button', - class: `dl-mk${g.online ? ' online' : ''}${n > 1 ? ' multi' : ''}`, - 'aria-label': `${n} device${n === 1 ? '' : 's'} via ${g.org || 'unknown network'} in ${g.city || 'unknown city'}`, + class: `dl-mk${g.online ? ' online' : ''}`, + 'aria-label': `${person?.name ?? 'Someone'}: ${n} device${n === 1 ? '' : 's'} in ${g.city || 'an unknown city'}`, }, - n > 1 ? E('span', { class: 'dl-mk-count' }, String(n)) : E('span', { class: 'dl-mk-dot' }), + [ + E('span', { class: 'dl-mk-av' }, [initials(person?.name ?? '?'), badge]), + E('span', { class: 'dl-mk-label below' }, g.city || g.cc || '?'), + ], ); - const nearHome = !!home && Math.abs(at[0] - home.lon) < 0.02 && Math.abs(at[1] - home.lat) < 0.02; - const shift: [number, number] = nearHome ? [22, -16] : [0, 0]; + el.addEventListener('mouseenter', () => this.focus(g.person)); + el.addEventListener('mouseleave', () => this.focus(null)); + this.people.push({ el, person: g.person }); el.addEventListener('click', (ev) => { ev.stopPropagation(); - this.openPopup(g, at, shift); + this.openPopup(g, at, el); }); - this.markers.push(new this.gl.Marker({ element: el, offset: shift }).setLngLat(at).addTo(this.map)); + this.add(el, at, false, person?.name ?? 'Someone', `${g.city || g.cc || '?'} · ${g.online ? 'now' : ago(g.ts, data.now)}`, g.key); } + this.declutter(); - if (!this.fitted) { - const coords: [number, number][] = placed.map((x) => x.at); - if (home && (coords.length === 0 || this.range !== 'online' || placed.some((x) => x.g.online))) coords.push([home.lon, home.lat]); - this.fit(coords); + // The view follows the places shown: the first one is set at once, later ones glide there. + // Not while a popup is open (it would leave its marker); the next update catches up. + const key = placed + .map((x) => x.g.key) + .sort() + .join(';'); + if (key !== this.fitKey && !this.popup) { + const animate = this.fitted && !this.fitBlind; + this.fitBlind = !this.el.clientWidth || !this.el.clientHeight; + this.fitKey = key; this.fitted = true; + if (home && !placed.length) { + // Nobody to show: the router up close, at the same zoom as the closest fit. + const view = { center: [home.lon, home.lat], zoom: 12 }; + if (animate) this.glide(12, () => this.map.flyTo({ ...view, duration: 1200 })); + else this.map.jumpTo(view); + } else { + const coords: [number, number][] = placed.map((x) => x.at); + if (home && (coords.length === 0 || this.range !== 'online' || placed.some((x) => x.g.online))) coords.push([home.lon, home.lat]); + this.fit(coords, animate); + } } this.status.textContent = placed.length || home ? '' : 'No locations yet'; this.status.style.display = this.status.textContent ? '' : 'none'; + this.focus(this.focused && this.people.some((x) => x.person === this.focused) ? this.focused : null); + } + + private add(el: HTMLElement, at: [number, number], fixed = false, who?: string, where?: string, key?: string) { + // A redrawn marker keeps how it was (folded or not), with no fade in its first frame. + if (key && this.foldedKeys.has(key)) el.classList.add('merged'); + el.dataset.key = key ?? ''; + el.classList.add('dl-mk-new'); + requestAnimationFrame(() => requestAnimationFrame(() => el.classList.remove('dl-mk-new'))); + const marker = new this.gl.Marker({ element: el }).setLngLat(at).addTo(this.map); + this.markers.push(marker); + this.slots.push({ marker, el, at, fixed, who, where }); } /** - * Zoom to what matters: a single city fills the map at city level, a few - * places get just enough room, and lone outliers never shrink everything to - * a continent (the farthest 10% are left out when the rest are clustered). + * Markers that would cover each other: someone on top of the server folds into a count on + * its plate (moved aside they would look like another region, a dot would hide under it) and + * comes back once there is room; markers crowding each other are pushed just clear, a thin + * line pointing back to the real spot. The push grows with the overlap and fades to nothing + * as the map zooms in, so markers glide back to their places instead of jumping. */ - private fit(coords: [number, number][]) { + private declutter() { + if (!this.map) return; + const items = this.slots.map((m) => { + const p = this.map.project(m.at); + const body = m.el.querySelector(':scope > .dl-mk-host, :scope > .dl-mk-av, :scope > .dl-mk-tile') as HTMLElement | null; + return { x: p.x as number, y: p.y as number, r: (body?.offsetWidth || 24) / 2 + 3, fixed: m.fixed }; + }); + const fixed = items.filter((i) => i.fixed); + this.merged = []; + this.foldedKeys.clear(); + // Zooming out on its own (a new fit): distances as they will be, so folding happens at once. + const ahead = this.targetZoom == null ? 1 : Math.min(1, 2 ** (this.targetZoom - this.map.getZoom())); + items.forEach((it, i) => { + if (it.fixed) return; + const slot = this.slots[i]; + // A little more room to come back than to fold, so it doesn't flicker at the edge. + const room = slot.el.classList.contains('merged') ? 12 : 6; + const near = fixed.find((f) => Math.hypot(f.x - it.x, f.y - it.y) * ahead < f.r + it.r + room); + slot.el.classList.toggle('merged', !!near); + if (!near) return; + if (slot.el.dataset.key) this.foldedKeys.add(slot.el.dataset.key); + // How much closer the map has to come for them to stand apart. + const need = (near.r + it.r + 14) / Math.max(1, Math.hypot(near.x - it.x, near.y - it.y)); + this.merged.push({ at: slot.at, who: slot.who ?? 'Someone', where: slot.where ?? '', need }); + Object.assign(it, { r: 0, fixed: true }); + }); + // A folded person leaves no trace either: their accuracy zone and arc go with their marker. + const hidden = [...this.foldedKeys].sort().join('|'); + if (hidden !== this.hiddenKey) { + this.hiddenKey = hidden; + const shown = ['!', ['in', ['get', 'key'], ['literal', [...this.foldedKeys]]]]; + if (this.map.getLayer('dl-area')) this.map.setFilter('dl-area', shown); + for (const live of [false, true]) { + const id = live ? 'dl-arc-live' : 'dl-arc-recent'; + if (this.map.getLayer(id)) this.map.setFilter(id, ['all', ['==', ['get', 'online'], live], shown]); + } + } + const count = this.slots.find((m) => m.fixed)?.el.querySelector('.dl-mk-host-n') as HTMLElement | null; + if (count) { + count.textContent = this.merged.length ? String(this.merged.length) : ''; + count.classList.toggle('on', this.merged.length > 0); + } + separate(items).forEach(([dx, dy], i) => { + const m = this.slots[i]; + if (m.fixed) return; + if (items[i].fixed) [dx, dy] = [0, 0]; + m.marker.setOffset([dx, dy]); + pointer(m.el, dx, dy); + }); + } + + /** + * The card fades out and goes; the map goes back to the view before a click zoomed in. Closed + * by a press, that waits for the release: MapLibre stops a camera move when a press begins. + */ + private closePopup(pressed = false) { + const open = this.popup; + if (!open || open.card.classList.contains('leaving')) return; + open.card.classList.add('leaving'); + setTimeout(() => { + if (this.popup === open) this.dropCard(); + }, 140); + const back = this.before; + this.before = null; + if (!back) return; + const go = () => this.map?.flyTo({ ...back, duration: 800 }); + if (!pressed) return go(); + let done = false; + const once = () => { + if (done) return; + done = true; + window.removeEventListener('pointerup', once, true); + window.removeEventListener('pointercancel', once, true); + // After MapLibre has taken the release too. + setTimeout(go, 0); + }; + window.addEventListener('pointerup', once, true); + window.addEventListener('pointercancel', once, true); + setTimeout(once, 1500); + } + + /** The card gone at once (another one replaces it, or the map goes away). */ + private dropCard() { + this.popup?.off(); + this.popup?.card.remove(); + this.popup = null; + } + + /** The people folded into the server, in the corner card. */ + private showMerged(place: string) { + if (!this.merged.length) return; + dom.content(this.card, [ + E('div', { class: 'dl-map-card-head' }, [E('b', {}, `Near ${place}`), ' · zoom in to see them']), + ...this.merged.map((m) => E('div', { class: 'dl-map-card-row' }, [E('span', {}, m.who), E('span', { class: 'dl-faint' }, m.where)])), + ]); + this.card.classList.add('on'); + } + + /** Close enough for everyone folded into the server to stand apart (never past zoom 12). */ + private zoomToMerged() { + if (!this.map || !this.merged.length) return; + const step = Math.log2(Math.max(...this.merged.map((m) => m.need))) + 0.3; + const pts = [this.slots.find((m) => m.fixed)!.at, ...this.merged.map((m) => m.at)]; + const center: [number, number] = [pts.reduce((s, p) => s + p[0], 0) / pts.length, pts.reduce((s, p) => s + p[1], 0) / pts.length]; + this.map.flyTo({ center, zoom: Math.min(12, this.map.getZoom() + step), duration: 900 }); + } + + /** + * A place on a person's page: a rounded tile with the latest device's icon (and how many + * devices, when several), blue while one is live, gray and fainter the longer ago it was + * (down to 40% at 30 days); the city and when below. + */ + private placeMarker(g: Group, at: [number, number], person: Person | undefined): HTMLElement { + const now = this.data!.now; + const latest = [...g.points].sort((a, b) => Number(b.online) - Number(a.online) || b.ts - a.ts)[0]; + const kind = person?.devices.find((d) => d.id === latest.device)?.kind ?? 'other'; + const n = g.points.length; + const tile = E('span', { class: 'dl-mk-tile' }); + tile.innerHTML = iconSvg(kind, 'dl-mk-tile-ic') + (n > 1 ? `${n}` : ''); + const when = g.online ? 'now' : ago(g.ts, now); + const el = E( + 'button', + { + type: 'button', + class: `dl-mk place${g.online ? ' online' : ''}`, + style: g.online ? null : `--dl-mk-fade:${Math.max(0.4, 1 - (0.6 * (now - g.ts)) / (30 * 86400)).toFixed(2)}`, + 'aria-label': `${n} device${n === 1 ? '' : 's'} in ${g.city || 'an unknown city'}, ${when}`, + }, + [tile, E('span', { class: 'dl-mk-label below' }, [g.city || g.cc || '?', E('span', { class: 'dl-mk-when' }, when)])], + ); + el.addEventListener('click', (ev) => { + ev.stopPropagation(); + this.openPopup(g, at, el); + }); + return el; + } + + /** + * A place in a device's window: the live one as a blue tile with the device's icon and + * "now", the earlier ones as small gray tiles numbered by recency (1 = most recent). + */ + private stepMarker(g: Group, at: [number, number], person: Person | undefined, n: number): HTMLElement { + if (g.online) return this.placeMarker(g, at, person); + const when = ago(g.ts, this.data!.now); + const el = E('button', { type: 'button', class: 'dl-mk place step', 'aria-label': `${n}: ${g.city || 'an unknown city'}, ${when}` }, [ + E('span', { class: 'dl-mk-tile sm' }, String(n)), + E('span', { class: 'dl-mk-label below' }, [g.city || g.cc || '?', ` · ${when}`]), + ]); + el.addEventListener('click', (ev) => { + ev.stopPropagation(); + this.openPopup(g, at, el); + }); + return el; + } + + /** + * One person in focus (hovering any of their markers): all their places and arcs stay, + * everyone else fades, and a card lists their devices with where and when. + */ + private focus(person: string | null) { + this.focused = person; + for (const x of this.people) { + x.el.classList.toggle('dim', !!person && x.person !== person); + x.el.classList.toggle('hl', x.person === person); + } + const opacity = person ? ['case', ['==', ['get', 'person'], person], 0.85, 0.15] : 0.85; + for (const id of ['dl-arc-live', 'dl-arc-recent']) if (this.map?.getLayer(id)) this.map.setPaintProperty(id, 'line-opacity', opacity); + this.card.classList.toggle('on', !!person); + if (!person || !this.data) return; + const data = this.data; + const who = data.people.find((x) => x.id === person); + const pts = visiblePoints(data, this.range) + .filter((p) => p.person === person) + .sort((a, b) => Number(b.online) - Number(a.online) || b.ts - a.ts); + dom.content(this.card, [ + E('div', { class: 'dl-map-card-head' }, [E('b', {}, who?.name ?? person), ` · ${pts.length} device${pts.length === 1 ? '' : 's'}`]), + ...pts.map((p) => + E('div', { class: 'dl-map-card-row' }, [ + E('span', {}, who?.devices.find((d) => d.id === p.device)?.name ?? 'Device'), + E('span', { class: 'dl-faint' }, `${p.city || p.cc || '?'} · ${p.online ? 'now' : ago(p.ts, data.now)}`), + ]), + ), + ]); + } + + /** + * Zoom to what matters: the points fill the map, never closer than zoom 12 (11 on a person's page) + * (one place, or a few in one city, shows the neighbourhood), and lone + * outliers never shrink everything to a continent (the farthest 10% are + * left out when the rest are clustered). + */ + private fit(coords: [number, number][], animate = false) { if (!coords.length) return; const km = (a: [number, number], b: [number, number]) => { const r = Math.PI / 180; @@ -362,25 +676,32 @@ export class ConnectionMap { const sorted = [...coords].sort((a, b) => km(center, a) - km(center, b)); pts = sorted.slice(0, Math.ceil(sorted.length * 0.9)); } - const spread = Math.max(...pts.map((c) => km(center, c))); - if (spread < 25) { - // Everyone in one city: show the city, accuracy zones included. - this.map.jumpTo({ center, zoom: 9.5 }); - return; - } const b = new this.gl.LngLatBounds(pts[0], pts[0]); pts.forEach((c) => b.extend(c)); const h = this.el.clientHeight || 380; - this.map.fitBounds(b, { - padding: { top: Math.min(90, h / 4), bottom: Math.min(70, h / 5), left: 60, right: 60 }, - maxZoom: 9, - duration: 0, - }); + const opts = { + // Just enough room for the labels: the server's chip above its plate, a place's name above its dot. + padding: { top: Math.min(60, h / 5), bottom: Math.min(40, h / 8), left: 48, right: 48 }, + // A person's page shows a little more around a single place. + maxZoom: this.data?.person ? 11 : 12, + }; + if (!animate) this.map.fitBounds(b, { ...opts, duration: 0 }); + else this.glide(this.map.cameraForBounds(b, opts)?.zoom ?? null, () => this.map.fitBounds(b, { ...opts, duration: 1200 })); } - private openPopup(g: Group, at: [number, number], shift: [number, number] = [0, 0]) { + /** A programmatic move to `zoom`: markers are decluttered for where it ends, then follow it. */ + private glide(zoom: number | null, move: () => void) { + this.targetZoom = zoom; + this.declutter(); + this.map.once('moveend', () => { + this.targetZoom = null; + this.declutter(); + }); + move(); + } + + private openPopup(g: Group, at: [number, number], el?: HTMLElement) { const data = this.data!; - this.popup?.remove(); const where = [g.city, g.cc || g.country].filter(Boolean).join(', '); const people = [...new Set(g.points.map((p) => p.person))]; const rows = g.points @@ -413,25 +734,135 @@ export class ConnectionMap { ]) : '', ]); - // Make room above the marker so the popup is never cut by the map edge. - const h = this.el.clientHeight || 380; - this.map.easeTo({ center: at, offset: [0, Math.min(140, h * 0.32)], duration: 300 }); - this.popup = new this.gl.Popup({ - offset: [shift[0], shift[1] - 18], - anchor: 'bottom', - closeButton: false, - focusAfterOpen: false, - maxWidth: '300px', - className: 'dl-popup', - }) - .setLngLat(at) - .setDOMContent(body) - .addTo(this.map); + // Closer to a marker clicked from afar (city level); the card itself never moves the map. + const zoom = this.map.getZoom(); + if (zoom < CLICK_ZOOM) { + if (!this.before) this.before = { center: this.map.getCenter().toArray(), zoom }; + this.map.flyTo({ center: at, zoom: CLICK_ZOOM, duration: 800 }); + } + this.dropCard(); + const card = E('div', { class: 'dl-root dl-popcard', role: 'dialog' }, [E('span', { class: 'dl-popcard-tip' }), body]); + document.body.appendChild(card); + const mapEl = this.el; + const marker = (el?.querySelector('.dl-mk-av, .dl-mk-tile') as HTMLElement | null) ?? el ?? null; + // Above the marker when the window has room there, else below; inside the window sideways; + // hidden while the marker is outside the map. + const place = () => { + if (!marker) return; + const r = marker.getBoundingClientRect(); + const m = mapEl.getBoundingClientRect(); + const cx = r.left + r.width / 2; + const cy = r.top + r.height / 2; + card.classList.toggle('away', cx < m.left || cx > m.right || cy < m.top || cy > m.bottom); + const w = card.offsetWidth; + const h = card.offsetHeight; + const above = r.top - h - 12 >= 8 || r.top > window.innerHeight - r.bottom; + const left = Math.min(Math.max(8, cx - w / 2), window.innerWidth - w - 8); + card.classList.toggle('above', above); + card.classList.toggle('below', !above); + card.style.left = `${left}px`; + card.style.top = `${above ? r.top - h - 12 : r.bottom + 12}px`; + card.style.setProperty('--tip-x', `${cx - left}px`); + }; + // A press anywhere but the card or a marker (a marker opens its own) closes it, as do Esc, + // scrolling the page (not the card's own list) and going to another page. + const outside = (ev: Event) => { + if (!(ev.target as HTMLElement | null)?.closest('.dl-popcard, .maplibregl-marker')) this.closePopup(true); + }; + const esc = (ev: KeyboardEvent) => { + if (ev.key === 'Escape') this.closePopup(); + }; + const scrolled = (ev: Event) => { + if (!(ev.target instanceof Element && ev.target.closest('.dl-popcard'))) this.closePopup(); + }; + const close = () => this.closePopup(); + this.map.on('move', place); + window.addEventListener('scroll', scrolled, { capture: true, passive: true }); + window.addEventListener('resize', place); + document.addEventListener('pointerdown', outside, true); + document.addEventListener('keydown', esc); + const offNav = onNavigate(close); + window.addEventListener('pagehide', close); + this.popup = { + card, + off: () => { + this.map?.off('move', place); + window.removeEventListener('scroll', scrolled, true); + window.removeEventListener('resize', place); + document.removeEventListener('pointerdown', outside, true); + document.removeEventListener('keydown', esc); + offNav(); + window.removeEventListener('pagehide', close); + }, + }; + // Hidden with its page section (another one shown): gone too. + const watch = window.setInterval(() => { + if (this.popup?.card !== card) return clearInterval(watch); + if (!mapEl.isConnected || !mapEl.getClientRects().length) this.dropCard(); + }, 400); + place(); } } +/** + * How far each circle has to move (screen px) so none overlap by more than nothing, with `gap` + * between them: overlapping pairs are pushed apart by the overlap, half each, all of it on the + * one that isn't `fixed`. A few rounds settle a crowd; the result follows the input smoothly. + */ +export function separate(items: { x: number; y: number; r: number; fixed?: boolean }[], gap = 6): [number, number][] { + const p = items.map((i) => ({ x: i.x, y: i.y })); + for (let round = 0; round < 16; round++) { + let moved = false; + for (let i = 0; i < items.length; i++) + for (let j = i + 1; j < items.length; j++) { + const a = items[i], + b = items[j]; + if (a.fixed && b.fixed) continue; + let dx = p[j].x - p[i].x, + dy = p[j].y - p[i].y, + d = Math.hypot(dx, dy); + const push = a.r + b.r + gap - d; + if (push <= 0) continue; + if (d < 0.01) { + // On the very same spot: a fixed direction per pair, so they part the same way every time. + const t = (i + 1) * 2.399 + j; + [dx, dy, d] = [Math.cos(t), Math.sin(t), 1]; + } + const wa = a.fixed ? 0 : b.fixed ? 1 : 0.5; + const wb = 1 - wa; + p[i].x -= (dx / d) * push * wa; + p[i].y -= (dy / d) * push * wa; + p[j].x += (dx / d) * push * wb; + p[j].y += (dy / d) * push * wb; + moved = true; + } + if (!moved) break; + } + return p.map((q, i) => [q.x - items[i].x, q.y - items[i].y]); +} + +/** The line from a moved marker back to its real spot, with a dot there (hidden when in place). */ +function pointer(el: HTMLElement, dx: number, dy: number) { + let ptr = el.querySelector(':scope > .dl-mk-ptr') as HTMLElement | null; + const len = Math.hypot(dx, dy); + if (len < 1) { + ptr?.remove(); + return; + } + if (!ptr) { + ptr = E('span', { class: 'dl-mk-ptr' }, [E('i', { class: 'line' }), E('i', { class: 'spot' })]); + el.prepend(ptr); + } + const line = ptr.firstElementChild as HTMLElement; + const spot = ptr.lastElementChild as HTMLElement; + line.style.width = `${len}px`; + line.style.transform = `rotate(${Math.atan2(-dy, -dx)}rad)`; + spot.style.transform = `translate(${-dx}px, ${-dy}px)`; +} + interface Group { key: string; + person: string; lat: number; lon: number; city: string; diff --git a/web/src/admin/netcheck.ts b/web/src/admin/netcheck.ts new file mode 100644 index 0000000..9bf873a --- /dev/null +++ b/web/src/admin/netcheck.ts @@ -0,0 +1,93 @@ +// A new server's UDP port and device addresses, checked as the router checks +// them (rpc/servers.uc) and said in plain words for the setup wizard. The +// addresses are three numbers ("10.77.0"): the tunnel is that /24. + +/** A network on the router, by name: an interface ("lan") or a server ("Home"). */ +export interface Network { + name: string; + cidr: string; +} + +/** UDP ports someone holds: a single port has from == to. */ +export interface PortHold { + from: number; + to: number; + who: string; +} + +/** A help line under a field: what it means, or what is wrong (`bad`). */ +export interface Help { + text: string; + bad: boolean; +} + +interface Cidr { + net: number; + size: number; +} + +/** "10.77.0.0/24" as its network and size, prefix 8-30 like util.uc's parse_cidr; null if not one. */ +export function parseCidr(s: string): Cidr | null { + const m = /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\/(\d{1,2})$/.exec(s.trim()); + if (!m) return null; + const [a, b, c, d] = m.slice(1, 5).map(Number); + const prefix = Number(m[5]); + if ([a, b, c, d].some((x) => x > 255) || prefix < 8 || prefix > 30) return null; + const ip = a * 2 ** 24 + b * 2 ** 16 + c * 2 ** 8 + d; + const size = 2 ** (32 - prefix); + return { net: ip - (ip % size), size }; +} + +const overlaps = (x: Cidr, y: Cidr): boolean => x.net < y.net + y.size && y.net < x.net + x.size; + +const PRIVATE = ['10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16'].map((c) => parseCidr(c) as Cidr); + +/** The first three numbers of a subnet ("10.77.0.0/24" → "10.77.0"). */ +export function rangeOf(subnet: string): string { + return subnet.split('/')[0].split('.').slice(0, 3).join('.'); +} + +/** The tunnel subnet of a range ("10.77.0" → "10.77.0.0/24"). */ +export function subnetOf(range: string): string { + return `${range.trim()}.0/24`; +} + +/** The device addresses: what they give, or why not (`suggest` is a free range to offer). */ +export function rangeHelp(range: string, nets: Network[], suggest: string): Help { + const r = range.trim(); + const c = /^\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(r) ? parseCidr(subnetOf(r)) : null; + if (!c) return { text: 'Three numbers, like 10.77.0.', bad: true }; + if (!PRIVATE.some((p) => c.net >= p.net && c.net + c.size <= p.net + p.size)) + return { text: 'Use a private range: 10.x.x, 172.16–31.x or 192.168.x.', bad: true }; + const hit = nets.find((n) => { + const o = parseCidr(n.cidr); + return o != null && overlaps(c, o); + }); + if (hit) { + const used = hit.cidr.endsWith('/24') ? `${rangeOf(hit.cidr)}.x` : hit.cidr; + const other = suggest && suggest !== r ? ` Try ${suggest}.` : ''; + return { text: `${hit.name} already uses ${used}.${other}`, bad: true }; + } + return { text: `Devices get ${r}.2 – ${r}.254, the router ${r}.1.`, bad: false }; +} + +const holder = (port: number, taken: PortHold[]): string | null => taken.find((t) => t.from <= port && port <= t.to)?.who ?? null; + +const validPort = (port: number): boolean => Number.isInteger(port) && port >= 1 && port <= 65535; + +/** A port: `free` when nobody holds it, or who does. */ +export function portHelp(port: number, taken: PortHold[], free: string): Help { + if (!validPort(port)) return { text: 'Use a port from 1 to 65535.', bad: true }; + const who = holder(port, taken); + return who ? { text: `Used by ${who}. Choose another port.`, bad: true } : { text: free, bad: false }; +} + +/** The portal's TCP port; links on IP addresses (`ipLinks`) use plain HTTP on the next one too. */ +export function portalPortHelp(port: number, taken: PortHold[], ipLinks: boolean): Help { + const free = ipLinks ? `HTTPS here, plain HTTP for links on IP addresses on ${port + 1}.` : 'HTTPS on this port, opened on WAN.'; + const h = portHelp(port, taken, free); + if (h.bad || !ipLinks) return h; + if (port === 65535) return { text: 'Links on IP addresses also need the next port: choose a lower one.', bad: true }; + const who = holder(port + 1, taken); + return who ? { text: `Links on IP addresses also need ${port + 1}, used by ${who}. Choose another port.`, bad: true } : h; +} diff --git a/web/src/admin/pages/overview.ts b/web/src/admin/pages/overview.ts index 7d11e3a..33af9ca 100644 --- a/web/src/admin/pages/overview.ts +++ b/web/src/admin/pages/overview.ts @@ -41,7 +41,6 @@ function attention(st: Status): Attention[] { tone: 'bad', text: [`Tunnel ${s.ifname} is down. `, link(L.url('admin/network/dawnline/diagnostics'), 'Open Diagnostics')], }); - if (st.settings.paused_all) out.push({ tone: 'warn', text: ['Everyone is paused.'] }); for (const p of st.people) { if (p.state === 'quota') out.push({ tone: 'warn', text: [link(personUrl(p.id), p.name), ' reached the data limit.'] }); else if (p.state === 'expired') out.push({ tone: 'warn', text: [link(personUrl(p.id), p.name), '’s access has ended.'] }); @@ -166,9 +165,8 @@ export class ServerOverview { this.range, ); const legend = E('div', { class: 'dl-map-legend' }, [ - E('span', {}, [E('i', { class: 'dot ok' }), 'Online']), - E('span', {}, [E('i', { class: 'dot' }), 'Seen recently']), - E('span', {}, [E('i', { class: 'line' }), 'Live tunnel']), + E('span', {}, [E('i', { class: 'line live' }), 'Live tunnel']), + E('span', {}, [E('i', { class: 'line' }), 'Seen recently']), ]); const wrap = E('div', { class: 'dl-map-wrap' }, [this.map.el, legend]); requestAnimationFrame(() => this.map!.mount(this.mapData())); @@ -178,11 +176,10 @@ export class ServerOverview { paint(quiet = false) { const st = this.st; const srv = st.servers[0]; - const slots = st.people.reduce((a, p) => a + Math.max(0, p.device_limit - p.devices.length), 0); repaint( this.parts.bento, - E('div', { class: 'dl-bento' }, [this.onlineTile(), this.speedTile(), coreOf(srv).overviewTile(srv), this.monthTile(slots)]), + E('div', { class: 'dl-bento' }, [this.onlineTile(), this.speedTile(), coreOf(srv).overviewTile(srv), this.monthTile()]), quiet, ); @@ -235,11 +232,14 @@ export class ServerOverview { */ onlineTile(): HTMLElement { const st = this.st; + const off = st.servers[0] ? !st.servers[0].enabled : false; const CAP = 12; const today = (d: Device) => d.spark[d.spark.length - 1] ?? 0; const cityOf = (d: Device) => st.geo.points.find((g) => g.device === d.id && g.city)?.city; const home = (d: Device) => /^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(d.endpoint ?? ''); - const where = (d: Device) => (home(d) ? 'home' : cityOf(d)) ?? ''; + // Where a device is: its city, or "LAN" when it connects from the home network (the hover + // card adds its address there). + const where = (d: Device, ip = false): string => (home(d) ? (ip && d.endpoint ? `LAN · ${d.endpoint}` : 'LAN') : (cityOf(d) ?? '')); const connectedAt = (d: Device) => [...st.events].reverse().find((e) => e.type === 'connect' && e.device === d.id)?.ts ?? 0; const on = st.people .map((p) => ({ p, devs: p.devices.filter((d) => d.online).sort((a, b) => today(b) - today(a)) })) @@ -298,7 +298,7 @@ export class ServerOverview { E( 'div', { class: 'dl-hc-devs' }, - devs.map((d) => E('span', { class: 'dl-hc-dev' }, [icon(d.kind), [d.name, where(d)].filter(Boolean).join(' · ')])), + devs.map((d) => E('span', { class: 'dl-hc-dev' }, [icon(d.kind), d.name, where(d) ? [' · ', where(d, true)] : ''])), ), E('div', { class: 'dl-hc-foot' }, [ E( @@ -321,7 +321,7 @@ export class ServerOverview { ? E('span', { class: 'dl-onl-meta' }, [ ...devs.slice(0, 3).map((d) => icon(d.kind)), devs.length > 3 ? `+${devs.length - 3}` : '', - where(devs[0]) ? E('span', {}, ` · ${where(devs[0])}`) : '', + where(devs[0]) ? E('span', {}, [' · ', where(devs[0])]) : '', ]) : '', ]); @@ -362,10 +362,11 @@ export class ServerOverview { : '', ]) : E('div', { class: 'dl-onl-empty' }, [ - E('span', {}, 'Nobody is connected'), + // A server that is off takes no connections: say so rather than "nobody". + E('span', {}, off ? 'The server is turned off' : 'Nobody is connected'), last ? E('span', { class: 'dl-sub' }, `Last: ${last.p.name}, ${ago(last.d.handshake, st.now)}`) - : E('span', { class: 'dl-sub' }, 'No device has connected yet'), + : E('span', { class: 'dl-sub' }, off ? 'Devices connect once it is on' : 'No device has connected yet'), ]), ]); } @@ -375,16 +376,12 @@ export class ServerOverview { * upload side by side, the last 15 minutes as a small chart, today's total. */ speedTile(): HTMLElement { - return speedTile(this.st.servers[0]?.rate ?? [], this.st.now, this.st.totals.today); + const srv = this.st.servers[0]; + return speedTile(srv?.rate ?? [], this.st.now, this.st.totals.today, srv ? !srv.enabled : false); } - /** The last 30 days, today on the right, with the peak; plus the people summary. */ - monthTile(slots: number): HTMLElement { - const t = this.st.totals; - const paused = this.st.people.filter((p) => p.state !== 'active').length; - return daysTile( - this.st.series, - `${t.people} ${t.people === 1 ? 'person' : 'people'}${paused ? ` · ${paused} paused` : ''} · ${slots} device slot${slots === 1 ? '' : 's'} free`, - ); + /** The last 30 days, today on the right, with the peak. */ + monthTile(): HTMLElement { + return daysTile(this.st.series, ''); } } diff --git a/web/src/admin/pages/people.ts b/web/src/admin/pages/people.ts index 073b62f..73e0bce 100644 --- a/web/src/admin/pages/people.ts +++ b/web/src/admin/pages/people.ts @@ -11,7 +11,7 @@ import { copyText } from '../ui/files'; import { dropdown, type MenuItem } from '../ui/menu'; import { attempt, notify } from '../ui/toast'; import { attachTip } from '../ui/tooltip'; -import { accessBadge, stateBadge } from '../ui/badges'; +import { accessBadge } from '../ui/badges'; import { addDevice, openDevice, type DeviceOpts } from '../device'; import { copyPersonLink, inviteCard } from '../invite'; import { personUrl } from '../urls'; @@ -56,6 +56,14 @@ function slotBar(p: Person): HTMLElement { type Filter = 'all' | 'online' | 'attention' | 'paused'; type SortBy = 'seen' | 'name' | 'usage'; +/** Paused by someone or something about the person; not over a limit (Needs attention), and not their server being off (the admin's pause still counts then). */ +const paused = (p: Person): boolean => (p.state === 'server_off' ? p.paused : !['active', 'quota', 'expired'].includes(p.state)); +/** Can't connect for a reason of their own (not just their server being off). */ +const stopped = (p: Person): boolean => (p.state === 'server_off' ? p.paused : p.state !== 'active'); +/** Why they can't connect, their own reason (the admin's pause shows through a turned-off server), or null. */ +const stopReason = (p: Person): Exclude | null => + !stopped(p) ? null : p.state === 'server_off' ? 'paused' : (p.state as Exclude); + function needsAttention(p: Person, today: string): boolean { const left = daysLeft(p.expires, today); return ( @@ -269,7 +277,7 @@ export class PeoplePage { all: people.length, online: people.filter((p) => p.online > 0).length, attention: people.filter(attn).length, - paused: people.filter((p) => p.state !== 'active' && p.state !== 'quota' && p.state !== 'expired').length, + paused: people.filter((p) => paused(p)).length, }; const tabs = this.el?.querySelector('.dl-people-tabs'); if (tabs && !(quiet && focusInside(tabs))) { @@ -296,23 +304,27 @@ export class PeoplePage { const match = (p: Person) => { if (this.filter === 'online' && !p.online) return false; if (this.filter === 'attention' && !attn(p)) return false; - if (this.filter === 'paused' && !(p.state !== 'active' && p.state !== 'quota' && p.state !== 'expired')) return false; + if (this.filter === 'paused' && !paused(p)) return false; return true; }; - const order = [...people].sort((a, b) => - this.sort === 'name' - ? a.name.localeCompare(b.name) - : this.sort === 'usage' - ? b.month[0] + b.month[1] - (a.month[0] + a.month[1]) - : b.online - a.online || b.last_seen - a.last_seen, + // Whatever the sort: people who can connect, then those held by a limit or an end + // date (often something to fix), then the ones the admin paused, last. + const rank = (p: Person) => (stopReason(p) === 'paused' ? 2 : stopped(p) ? 1 : 0); + const order = [...people].sort( + (a, b) => + rank(a) - rank(b) || + (this.sort === 'name' + ? a.name.localeCompare(b.name) + : this.sort === 'usage' + ? b.month[0] + b.month[1] - (a.month[0] + a.month[1]) + : b.online - a.online || b.last_seen - a.last_seen), ); let shown = 0; for (const p of order) { const card = this.card(p.id); if (!card) continue; this.list.appendChild(card); - card.classList.toggle('dl-off', p.state !== 'active'); - card.classList.toggle('dl-attn-row', p.state === 'quota' || p.state === 'expired'); + card.classList.toggle('dl-off', stopped(p)); const hit = match(p); card.classList.toggle('dl-filtered', !hit); if (hit) shown++; @@ -343,7 +355,8 @@ export class PeoplePage { // Term and hours sit by the name; online/last seen lives in the strip below. const pills: Node[] = []; - if (p.expires) { + const why = stopReason(p); + if (p.expires && why !== 'expired') { const soon = left != null && left >= 0 && left <= Math.max(p.expire_warn, 3); const over = left != null && left < 0; pills.push( @@ -353,7 +366,8 @@ export class PeoplePage { ]), ); } - if (p.hours) pills.push(E('span', { class: 'dl-pill-ic', title: 'Allowed hours' }, [icon('clock'), p.hours.replace('-', '–')])); + if (p.hours && why !== 'hours') + pills.push(E('span', { class: 'dl-pill-ic', title: 'Allowed hours' }, [icon('clock'), p.hours.replace('-', '–')])); const chips = byDeviceState(p.devices).map((d) => { return E( @@ -394,20 +408,9 @@ export class PeoplePage { ), ); + // Ending soon (the strip below handles an end that has passed). const fixes: Node[] = []; - if (p.state === 'quota' && p.quota_period === 'month') - fixes.push( - E( - 'button', - { - type: 'button', - class: 'dl-fix', - click: () => this.quick(p, { bonus_gb: String((p.bonus_gb || 0) + 10) }, '+10 GB this month'), - }, - '+10 GB this month', - ), - ); - if (p.expires && left != null && left <= Math.max(p.expire_warn, 3)) + if (p.expires && left != null && left <= Math.max(p.expire_warn, 3) && why !== 'expired') fixes.push( E( 'button', @@ -466,7 +469,6 @@ export class PeoplePage { E('div', { class: 'dl-pcard-who' }, [ E('div', { class: 'dl-card-head' }, [ E('a', { class: 'dl-card-name', href: personUrl(p.id) }, p.name), - stateBadge(p), accessBadge(p), ...pills, ]), @@ -477,11 +479,48 @@ export class PeoplePage { fixes.length ? E('div', { class: 'dl-fixes' }, fixes) : '', ]), this.usageSide(p, actions), + why ? this.stopStrip(p, why) : '', ]), ); return node; } + /** Across the bottom of a stopped person's card: why, since when or until when, and the one action that lifts it. */ + stopStrip(p: Person, why: NonNullable>): HTMLElement { + const today = this.today; + // The month's data resets on the 1st (router time). + const reset = addMonthsClamped(`${today.slice(0, 8)}01`, 1); + const extra = () => this.quick(p, { bonus_gb: String((p.bonus_gb || 0) + 10) }, '+10 GB this month'); + const what: Record unknown] | null]> = { + paused: ['pause', 'warn', 'Paused', 'Devices can’t connect until you resume', ['play', 'Resume', () => this.togglePause(p)]], + quota: + p.quota_period === 'month' + ? ['chart', 'bad', 'Data limit reached', `Paused until it resets on ${date(reset)}`, ['plus', '+10 GB this month', extra]] + : [ + 'chart', + 'bad', + 'Data limit reached', + 'Paused until the limit is raised', + ['edit', 'Change limit', () => (location.href = personUrl(p.id))], + ], + expired: [ + 'calendar', + 'bad', + `Access ended ${date(p.expires)}`, + 'Devices can’t connect', + ['calendar', 'Extend 1 month', () => this.quick(p, { expires: addMonth(p.expires, today) }, 'Extended by 1 month')], + ], + hours: ['clock', 'warn', 'Outside allowed hours', `Access ${p.hours.replace('-', '–')} (router time)`, null], + no_server: ['alert', 'warn', 'No server', 'Choose a server on their page', null], + }; + const [ic, tone, title, sub, act] = what[why]; + return E('div', { class: `dl-pstrip ${tone}` }, [ + E('span', { class: `dl-need-ic ${tone}` }, icon(ic)), + E('span', { class: 'dl-pstrip-text' }, [E('b', {}, title), E('span', { class: 'dl-faint' }, sub)]), + act ? button([icon(act[0]), ` ${act[1]}`], act[2]) : '', + ]); + } + /** Status and actions, this month's usage, a bar split by device (or filled toward the limit), today or live speed. */ usageSide(p: Person, actions: HTMLElement): HTMLElement { const used = p.quota_used || p.month[0] + p.month[1]; diff --git a/web/src/admin/pages/person/header.ts b/web/src/admin/pages/person/header.ts index beab185..bb19f17 100644 --- a/web/src/admin/pages/person/header.ts +++ b/web/src/admin/pages/person/header.ts @@ -1,9 +1,9 @@ // Person page: the name block with its actions, and the traffic tiles. import { E } from '../../e'; -import { iconButton } from '../../ui/button'; +import { button, iconButton } from '../../ui/button'; import { dropdown, type MenuItem } from '../../ui/menu'; -import { stateBadge } from '../../ui/badges'; +import { statePill } from '../../ui/badges'; import { icon } from '../../../shared/icons'; import { ago, bytes, date, initials, isoDay } from '../../../shared/format'; import { copyPersonLink } from '../../invite'; @@ -29,12 +29,8 @@ export function headPart(page: PersonPage): HTMLElement { ] : []), null, - { - label: p.paused ? 'Resume' : 'Pause', - icon: icon(p.paused ? 'play' : 'pause'), - warn: !p.paused, - run: () => page.patch({ paused: !p.paused }, p.paused ? 'Resumed' : 'Paused'), - }, + // While paused, Resume is the page's own button (as the server's Turn on). + ...(p.paused ? [] : [{ label: 'Pause', icon: icon('pause'), warn: true, run: () => page.patch({ paused: true }, 'Paused') }]), { label: 'Delete', icon: icon('trash'), danger: true, run: () => remove(page) }, ]; return E('div', { class: 'dl-person-head' }, [ @@ -42,11 +38,13 @@ export function headPart(page: PersonPage): HTMLElement { E('div', { class: 'dl-person-id' }, [ E('span', { class: `dl-avatar lg${p.online ? ' online' : ''}` }, initials(p.name)), E('div', { class: 'dl-stack' }, [ - E('div', { class: 'dl-title-row' }, [E('h2', { class: 'dl-h1' }, p.name), stateBadge(p)]), + E('div', { class: 'dl-title-row' }, [E('h2', { class: 'dl-h1' }, p.name), statePill(p)]), E('span', { class: 'dl-faint', title: added }, `${p.devices.length} of ${p.device_limit} devices · ${lastSeen}`), ]), ]), E('div', { class: 'dl-pcard-actions' }, [ + // White, as the server's Turn on. + p.paused ? button([icon('play'), ' Resume'], () => page.patch({ paused: false }, 'Resumed'), 'add') : '', portal ? iconButton('link', 'Copy link', () => copyPersonLink(p.id), 'neutral', 'dl-icon-only') : '', iconButton('more', 'More', (ev: MouseEvent) => dropdown(ev.currentTarget as HTMLElement, menu), 'neutral', 'dl-icon-only'), ]), diff --git a/web/src/admin/pages/server.ts b/web/src/admin/pages/server.ts index 0da5945..cfa1d01 100644 --- a/web/src/admin/pages/server.ts +++ b/web/src/admin/pages/server.ts @@ -12,7 +12,8 @@ import { cancelButton, closeModal, confirmDialog, modal } from '../ui/modal'; import { copyText } from '../ui/files'; import { attempt, errorText, notify } from '../ui/toast'; import { input, seg, sw } from '../ui/controls'; -import { card, group, needRow, row } from '../ui/layout'; +import { card, group, liveRow, needRow, row } from '../ui/layout'; +import { portalPortHelp, portHelp, rangeHelp, rangeOf, subnetOf } from '../netcheck'; import { icon } from '../../shared/icons'; import { duration } from '../../shared/format'; import { accessCards } from '../interfaces'; @@ -158,7 +159,7 @@ export class ServerPage { this.paint(); }, }, - [E('i', { class: `dot ${x.up ? 'ok' : 'bad'}` }), E('b', {}, x.name)], + [E('i', { class: `dot ${!x.enabled ? 'warn' : x.up ? 'ok' : 'bad'}` }), E('b', {}, x.name)], ), ), E('button', { type: 'button', class: 'dl-srvtab add', click: () => this.addServer() }, [icon('plus'), 'Add server']), @@ -264,22 +265,16 @@ export class ServerPage { /** Name and state, the address bar, and the page actions. */ head(srv: Server): HTMLElement { - const st = this.st; const part = (ic: string, body: (Node | string)[]) => E('span', { class: 'dl-addrbar-seg' }, [icon(ic), ...body]); const addr = srv.endpoint || '—'; - // "Turn on" while the server is off (turning off lives in Connection; the same - // button also lifts an old router-wide pause). - const off = !srv.enabled || st.settings.paused_all; + // "Turn on" while the server is off (turning off lives in Connection). const actions = E('div', { class: 'dl-actions' }, [ - off + !srv.enabled ? button( [icon('play'), ' Turn on'], - async () => { - if (st.settings.paused_all && !(await attempt(() => api.pauseAll(false)))) return; - if (!srv.enabled) await this.save(srv, { enabled: '1' }, 'Server turned on'); - else await this.refresh(); - }, - 'positive', + () => this.save(srv, { enabled: '1' }, 'Server turned on'), + // White, as the other main actions (Add person). + 'add', ) : '', ]); @@ -289,10 +284,10 @@ export class ServerPage { E('h2', { class: 'dl-h1' }, srv.name), E( 'span', - { class: `dl-pill ${!srv.enabled ? 'off' : srv.up ? 'ok' : 'bad'}` }, + // Off on purpose is a warning (yellow), not a failure (red). + { class: `dl-pill ${!srv.enabled ? 'warn' : srv.up ? 'ok' : 'bad'}` }, !srv.enabled ? 'Turned off' : srv.up ? 'Running' : srv.blocked ? 'Can’t start' : 'Not running', ), - st.settings.paused_all && srv.enabled ? E('span', { class: 'dl-pill warn' }, 'Off') : '', E('span', { class: 'dl-spacer' }), actions, ]), @@ -478,7 +473,8 @@ export class ServerPage { name: d.name, endpoint: d.endpoint, port: d.port, - subnet: d.subnet, + // The tunnel's first three numbers ("10.77.0"): it is that /24. + range: rangeOf(d.subnet), preset: 'standard' as Method, // Off by default: the portal opens a port on WAN, so it is a choice. portal: false, @@ -488,11 +484,20 @@ export class ServerPage { wan_zone: d.wan_zone, }; let step = 0; + // The portal takes the server's port number (TCP beside UDP) until it is changed by hand. + let portalSame = !extra && state.portal_port === state.port; + const ipLinks = () => /^\d{1,3}(\.\d{1,3}){3}$/.test(state.endpoint); + const portHelpNow = () => portHelp(state.port, d.udp_taken ?? [], 'Opened on the WAN firewall automatically.'); + const rangeHelpNow = () => rangeHelp(state.range, d.networks ?? [], rangeOf(d.subnet)); + const portalHelpNow = () => portalPortHelp(state.portal_port, d.tcp_taken ?? [], ipLinks()); const root = E('div', { class: 'dl-wizard' }); - const field = (key: 'id' | 'name' | 'endpoint' | 'port' | 'subnet' | 'portal_port', attrs: Record = {}) => { + const field = (key: 'id' | 'name' | 'endpoint' | 'port' | 'range' | 'portal_port', attrs: Record = {}) => { const el = input(String(state[key]), attrs); el.addEventListener('input', () => { - (state as any)[key] = key === 'port' || key === 'portal_port' ? Number(el.value) : el.value.trim(); + if (key === 'port' || key === 'portal_port') (state as any)[key] = el.value.trim() === '' ? 0 : Number(el.value); + else (state as any)[key] = el.value.trim(); + if (key === 'port' && portalSame) state.portal_port = state.port; + if (key === 'portal_port') portalSame = state.portal_port === state.port; }); return el; }; @@ -525,31 +530,39 @@ export class ServerPage { render: () => E('div', { class: 'dl-wizard-groups' }, [ group('globe', 'Listening', 'Where devices reach AmneziaWG from the internet', [ - row( - 'UDP port', - field('port', { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' }), - 'Opened on the WAN firewall automatically. A random high port is fine.', - ), + liveRow('UDP port', field('port', { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' }), portHelpNow), ]), group('network', 'Tunnel network', 'Addresses devices get inside the tunnel', [ - row( - 'Tunnel subnet', - field('subnet', { class: 'cbi-input-text dl-mono' }), - `Must not overlap your networks (${d.taken.join(', ') || 'none found'}).`, - ), + (() => { + const el = field('range', { + class: 'cbi-input-text dl-w-range dl-mono', + 'aria-label': 'First three numbers of the device addresses', + }); + return liveRow( + 'Device addresses', + el, + rangeHelpNow, + E('span', { class: 'dl-suffixed' }, [el, E('span', { class: 'dl-mono' }, '.x')]), + ); + })(), ]), group('shield', 'Disguise', 'So networks that block VPNs do not recognise the tunnel. Off = plain WireGuard', [ methodPicker(d.awg, state.preset, (m) => (state.preset = m), undefined, d.awg_state?.tools !== false), ]), ]), - check: () => (!state.port || !state.subnet ? 'Fill in the UDP port and subnet.' : null), + check: () => { + const p = portHelpNow(); + if (p.bad) return `UDP port: ${p.text}`; + const r = rangeHelpNow(); + return r.bad ? `Device addresses: ${r.text}` : null; + }, }; const portalPage: Page = { id: 'portal', title: 'Portal', render: () => { const portalPort = field('portal_port', { inputmode: 'numeric', class: 'cbi-input-text dl-w-port dl-mono' }); - const portRow = row('Listening port', portalPort, 'TCP port on WAN for the portal; the whole port belongs to it.'); + const portRow = liveRow('Listening port', portalPort, portalHelpNow); portRow.hidden = !state.portal; // Off | On, Off first: the same segmented control as in Settings. const onOff = seg( @@ -580,6 +593,11 @@ export class ServerPage { ]), ]); }, + check: () => { + if (!state.portal) return null; + const h = portalHelpNow(); + return h.bad ? `Portal port: ${h.text}` : null; + }, }; const pages = (): Page[] => [serverPage, awgPage, extra ? null : portalPage].filter((x): x is Page => x != null); const aw = d.awg_state; @@ -666,7 +684,7 @@ export class ServerPage { state.name, d.ifname, state.port, - state.subnet, + subnetOf(state.range), state.endpoint, d.mtu, state.preset, @@ -678,10 +696,15 @@ export class ServerPage { ), 'Server created', ); - if (r) - setTimeout(() => { + if (!r) return; + // A network restart drops the connection to LuCI for a few seconds. + if (r.network_restart) notify('Restarting the network so it knows AmneziaWG: back in a few seconds'); + setTimeout( + () => { location.href = url(r.id); - }, 1500); + }, + r.network_restart ? 10000 : 1500, + ); }, 'positive', { disabled: missing.length > 0, title: missing.length ? 'Install AmneziaWG first' : null }, diff --git a/web/src/admin/pages/settings/portal.ts b/web/src/admin/pages/settings/portal.ts index 57cfcc2..757648a 100644 --- a/web/src/admin/pages/settings/portal.ts +++ b/web/src/admin/pages/settings/portal.ts @@ -6,7 +6,8 @@ import { E } from '../../e'; import { button } from '../../ui/button'; import { cancelButton, closeModal, modal } from '../../ui/modal'; import { input, isOn, sw } from '../../ui/controls'; -import { group, needRow, row } from '../../ui/layout'; +import { group, liveRow, needRow, row } from '../../ui/layout'; +import { portalPortHelp } from '../../netcheck'; import { icon } from '../../../shared/icons'; import { fmtDay } from '../../../shared/format'; import { installMissing } from '../../pkgs'; @@ -147,7 +148,10 @@ export function portalCard(host: SettingsHost): HTMLElement { // One row per link, as people will see it (example code). const links = E('div', { class: 'dl-links' }); + // The port's help depends on the links too (IP addresses use the next port); set below. + let refreshPort = () => {}; const paintLinks = () => { + refreshPort(); const lport = Number(port.value) || eff.portal_port; dom.content( links, @@ -263,13 +267,11 @@ export function portalCard(host: SettingsHost): HTMLElement { }; const until = c && !c.self_signed && c.expires ? fmtDay(c.expires) : ''; - const listenRow = row( - 'Listening port', - port, - host.d.port_owners.length - ? `Port ${eff.portal_port} is used by ${host.d.port_owners.join(', ')}.` - : `Where the portal runs on the router: HTTPS here, plain HTTP for IP addresses on ${eff.portal_port + 1}.`, + // Who holds the port (our own portal doesn't count), and the next one while links use an IP address. + const listenRow = liveRow('Listening port', port, () => + portalPortHelp(port.value.trim() === '' ? eff.portal_port : Number(port.value), host.d.tcp_taken ?? [], picked.some(isIp)), ); + refreshPort = listenRow.refresh; const custom = !!(s.portal_cert && s.portal_key); const kind = !c ? 'Portal is off' : custom ? 'Your files' : c.self_signed ? 'Self-signed' : 'Let’s Encrypt'; const certFiles = () => { diff --git a/web/src/admin/styles/base.css b/web/src/admin/styles/base.css index cb73cd2..9f3de1d 100644 --- a/web/src/admin/styles/base.css +++ b/web/src/admin/styles/base.css @@ -29,6 +29,10 @@ --dl-radius: 16px; } +/* Text is read, not edited: the arrow over it, the I-beam only where you type. */ +.dl-root, .dl-modal { cursor: default; } +:is(.dl-root, .dl-modal) :is(input:not([type=checkbox], [type=radio], [type=range], [type=button], [type=submit]), textarea, [contenteditable=true]) { cursor: text; } + .dl-icon-wrap { display: inline-flex; align-items: center; justify-content: center; line-height: 0; } .dl-icon { width: 16px; height: 16px; } .dl-icon-btn { display: inline-flex !important; align-items: center; gap: 6px; } diff --git a/web/src/admin/styles/controls.css b/web/src/admin/styles/controls.css index 4081a4b..1793b3f 100644 --- a/web/src/admin/styles/controls.css +++ b/web/src/admin/styles/controls.css @@ -72,7 +72,7 @@ font-size: 13px; color: var(--dl-fg-muted); text-decoration: none !important; white-space: nowrap; } .dl-srvtab b { font-weight: 500; } .dl-srvtab i.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dl-fg-faint); flex: 0 0 auto; } -.dl-srvtab i.dot.ok { background: var(--dl-ok); animation: dl-srv-pulse 2s ease-out infinite; } .dl-srvtab i.dot.bad { background: var(--dl-bad); } +.dl-srvtab i.dot.ok { background: var(--dl-ok); animation: dl-srv-pulse 2s ease-out infinite; } .dl-srvtab i.dot.bad { background: var(--dl-bad); } .dl-srvtab i.dot.warn { background: var(--dl-warn); } /* The one status dot left: a server that is running pulses. */ @keyframes dl-srv-pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--dl-ok) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 6px transparent; } } @media (prefers-reduced-motion: reduce) { .dl-srvtab i.dot.ok { animation: none; } } diff --git a/web/src/admin/styles/map.css b/web/src/admin/styles/map.css index c7ddfad..b68bbfe 100644 --- a/web/src/admin/styles/map.css +++ b/web/src/admin/styles/map.css @@ -1,37 +1,124 @@ /* Connection map and charts. */ /* map */ -.dl-geomap { position: relative; border-top: 1px solid var(--dl-line); background: var(--dl-soft); } +/* As mapcn: no backdrop of its own, the globe sits on the card. */ +.dl-geomap { position: relative; border-top: 1px solid var(--dl-line); background: transparent; } .dl-map-status { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--dl-fg-muted); font-size: 13px; z-index: 1; pointer-events: none; } .dl-map-wrap { position: relative; } .dl-map-legend { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 12px; align-items: center; padding: 6px 12px; border-radius: 999px; font-size: 12px; background: color-mix(in srgb, var(--dl-card) 88%, transparent); border: 1px solid var(--dl-line); backdrop-filter: blur(6px); z-index: 2; } .dl-map-legend span { display: inline-flex; align-items: center; gap: 6px; color: var(--dl-fg-muted); } -.dl-map-legend i.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dl-fg-faint); } -.dl-map-legend i.dot.ok { background: var(--dl-ok); } -.dl-map-legend i.line { width: 14px; height: 2px; border-radius: 2px; background: var(--dl-ok); } +.dl-map-legend i.line { width: 14px; height: 0; border-top: 2px dashed #8a8a8a; } +.dl-map-legend i.line.live { border-top-color: #3b82f6; } .dl-map-off { padding: 32px 16px; text-align: center; color: var(--dl-fg-muted); border-top: 1px solid var(--dl-line); } -.dl-mk { all: unset; cursor: pointer; width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; position: relative; } -.dl-mk-dot { width: 12px; height: 12px; border-radius: 50%; background: #8f8f8f; box-shadow: 0 0 0 3px rgba(0,0,0,.55); } -.dl-mk.online .dl-mk-dot { width: 14px; height: 14px; background: #40c977; } -.dl-mk.online::before { content: ''; position: absolute; inset: -9px; border-radius: 50%; background: rgba(64, 201, 119, .28); animation: dl-pulse 2s ease-out infinite; } -@keyframes dl-pulse { 0% { transform: scale(.5); opacity: 1; } 100% { transform: scale(1.4); opacity: 0; } } -@media (prefers-reduced-motion: reduce) { .dl-mk.online::before { animation: none; } } -.dl-mk-home { width: 22px; height: 22px; border-radius: 7px; background: #ededed; display: flex; align-items: center; justify-content: center; - box-shadow: 0 0 0 4px rgba(237, 237, 237, .18), 0 2px 6px rgba(0,0,0,.5); color: #131313; } -.dl-mk-home-ic { width: 13px; height: 13px; } -.dl-popup { z-index: 4; } -.dl-popup .maplibregl-popup-content { background: var(--dl-elevated); color: var(--dl-fg); border: 1px solid var(--dl-line); border-radius: 12px; padding: 12px; - box-shadow: var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4)); font: inherit; } -.dl-popup .maplibregl-popup-tip { border-top-color: var(--dl-elevated) !important; border-bottom-color: var(--dl-elevated) !important; } +.dl-mk { all: unset; cursor: pointer; position: relative; display: flex; align-items: center; justify-content: center; transition: opacity .2s; } +.dl-mk-hub { position: relative; display: flex; align-items: center; justify-content: center; } +/* The server: an inverse tile (white on dark, black on light) on a frosted plate. */ +.dl-mk-host { box-sizing: border-box; width: 40px; height: 40px; border-radius: 11px; display: flex; align-items: center; justify-content: center; + background: color-mix(in srgb, var(--dl-elevated) 60%, transparent); border: 1px solid var(--dl-line); backdrop-filter: blur(6px); + box-shadow: 0 6px 16px rgba(0,0,0,.35); } +.dl-mk-host-tile { width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; + background: var(--dl-fg); color: var(--background, var(--dl-elevated)); } +.dl-mk-host-ic { width: 14px; height: 14px; } +/* People: initials (who) with a device badge (what), blue while live, gray when seen recently. */ +.dl-mk-av { position: relative; box-sizing: border-box; width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; + font-size: 10px; font-weight: 500; line-height: 1; border: 2px solid #8a8a8a; background: var(--dl-elevated); color: var(--dl-fg-muted); transition: box-shadow .2s; } +.dl-mk.online .dl-mk-av { border-color: #3b82f6; background: color-mix(in srgb, #3b82f6 22%, var(--dl-elevated)); color: var(--dl-fg); } +.dl-mk-badge { position: absolute; left: 16px; bottom: -6px; height: 16px; min-width: 16px; padding: 0 3px; border-radius: 8px; + border: 2px solid var(--dl-elevated); background: #6b6b6b; color: #fff; display: flex; align-items: center; justify-content: center; gap: 1px; + font-size: 9px; font-weight: 600; white-space: nowrap; box-sizing: content-box; } +.dl-mk.online .dl-mk-badge { background: #3b82f6; } +.dl-mk-badge-ic { width: 10px; height: 10px; stroke-width: 2.2; } +/* A person's places (their page): rounded tiles without outlines, the live one blue. */ +.dl-mk-tile { position: relative; width: 26px; height: 26px; border-radius: 7px; display: flex; align-items: center; justify-content: center; + background: color-mix(in srgb, var(--dl-fg) 18%, var(--dl-elevated)); color: var(--dl-fg); } +.dl-mk.place.online .dl-mk-tile { background: #3b82f6; color: #fff; box-shadow: 0 2px 8px rgba(59, 130, 246, .35); } +.dl-mk-tile-ic { width: 14px; height: 14px; } +.dl-mk-tile-n { position: absolute; right: -5px; top: -5px; min-width: 14px; height: 14px; padding: 0 3px; box-sizing: border-box; border-radius: 7px; + background: var(--dl-fg); color: var(--dl-elevated); font-size: 9px; font-weight: 600; line-height: 14px; text-align: center; } +.dl-mk-when { display: block; text-align: center; color: var(--dl-fg-faint); font-weight: 400; } +.dl-mk.place.online .dl-mk-when { color: #3b82f6; } +.dl-mk-tile.sm { width: 18px; height: 18px; border-radius: 5px; font-size: 9px; font-weight: 600; } +/* A device's places under its map: the same numbers as the tiles, the live one blue. */ +.dl-dmap { border: 1px solid var(--dl-line); border-radius: 12px; overflow: hidden; } +.dl-dmap .dl-geomap { border-top: 0; } +.dl-dplaces { display: flex; flex-direction: column; margin-top: 4px; } +.dl-dplace-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-top: 1px solid var(--dl-line); font-size: 13px; } +.dl-dplace-row:first-child { border-top: 0; } +.dl-dplace-n { flex: 0 0 auto; width: 20px; height: 20px; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 600; + background: color-mix(in srgb, var(--dl-fg) 18%, var(--dl-elevated)); color: var(--dl-fg); } +.dl-dplace-n.live { background: #3b82f6; color: #fff; } +.dl-dplace-n .dl-icon { width: 12px; height: 12px; } +.dl-dplace-now { color: #3b82f6; } +/* Someone on top of the server: folded into a count on its plate until there is room. */ +/* MapLibre writes the marker's own opacity (fading what is behind the globe): ours goes on its parts. */ +.dl-mk > * { transition: opacity .15s; opacity: var(--dl-mk-fade, 1); } +.dl-mk.merged { pointer-events: none; } +.dl-mk.dl-mk-new > * { transition: none; } +.dl-mk.merged > * { opacity: 0; } +.dl-mk-hub { cursor: default; } +.dl-mk-host { position: relative; } +.dl-mk-host-n { position: absolute; right: -7px; top: -7px; min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box; border-radius: 9px; + border: 2px solid var(--dl-elevated); background: #3b82f6; color: #fff; font-size: 10px; font-weight: 600; line-height: 14px; text-align: center; + opacity: 0; transform: scale(.5); transition: opacity .15s, transform .15s; pointer-events: none; } +.dl-mk-host-n.on { opacity: 1; transform: none; } +.dl-mk-hub:has(.dl-mk-host-n.on) { cursor: zoom-in; } +/* A marker moved clear of a crowd: a line back to its real spot, and a dot there. */ +.dl-mk-ptr { position: absolute; left: 50%; top: 50%; width: 0; height: 0; z-index: -1; pointer-events: none; } +.dl-mk-ptr .line { position: absolute; left: 0; top: -0.5px; height: 1px; background: var(--dl-fg-faint); transform-origin: 0 50%; } +.dl-mk-ptr .spot { position: absolute; left: -3.5px; top: -3.5px; width: 7px; height: 7px; border-radius: 50%; box-sizing: border-box; border: 1.5px solid #fff; background: #8a8a8a; } +.dl-mk.online .dl-mk-ptr .spot, .dl-mk.place.online .dl-mk-ptr .spot { background: #3b82f6; } +/* Hovering a person: their places stay, everyone else fades. */ +.dl-mk.dim > * { opacity: .18; } +.dl-mk.hl .dl-mk-av { box-shadow: 0 0 0 4px rgba(59, 130, 246, .25); } +/* MarkerLabel: absolute above the dot, text-[10px] font-medium text-foreground. */ +.dl-mk-label { position: absolute; left: 50%; bottom: 100%; margin-bottom: 4px; transform: translateX(-50%); white-space: nowrap; pointer-events: none; + font-size: 10px; line-height: 14px; font-weight: 500; color: var(--dl-fg); } +.dl-mk-label.below { bottom: auto; top: 100%; margin: 4px 0 0; } +/* The hub's label: bg-background/80 rounded-sm px-1.5 py-0.5 text-[11px] font-semibold backdrop-blur. */ +.dl-mk-label.chip { padding: 2px 6px; border-radius: 4px; font-size: 11px; line-height: 16px; font-weight: 600; + background: color-mix(in srgb, var(--background, var(--dl-card)) 80%, transparent); backdrop-filter: blur(8px); } +/* The attribution as on mapcn's site: a quiet tile with a filled "i"; opened, the credits beside it. */ +.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact { margin: 0 10px 10px 0; min-height: 28px; padding: 0; border-radius: 8px; + background: var(--dl-elevated); border: 1px solid var(--dl-line); color: var(--dl-fg-muted); box-shadow: none; font-size: 11px; line-height: 26px; } +.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact:not(.maplibregl-compact-show) { width: 28px; height: 28px; box-sizing: border-box; } +.dl-geomap .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib.maplibregl-compact.maplibregl-compact-show { padding: 0 32px 0 10px; } +.dl-geomap .maplibregl-ctrl-attrib a { color: var(--dl-fg-muted); } +.dl-geomap .maplibregl-ctrl-attrib-button { top: 0; right: 0; width: 26px; height: 26px; margin: 0; border-radius: 8px; background: none; } +.dl-geomap .maplibregl-ctrl-attrib-button::after { content: ''; position: absolute; inset: 5px; background: var(--dl-fg); + -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat; + mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill-rule='evenodd' d='M12 2a10 10 0 1 1 0 20 10 10 0 0 1 0-20Zm-1.2 8.2h2.4V17h-2.4v-6.8ZM12 6a1.4 1.4 0 1 0 0 2.8A1.4 1.4 0 0 0 12 6Z'/%3E%3C/svg%3E") center / contain no-repeat; } +.dl-geomap .maplibregl-ctrl-attrib-button:focus { outline: none; box-shadow: none; } +.dl-geomap .maplibregl-ctrl-attrib-button:focus-visible { outline: 2px solid var(--dl-ring); } +/* The hovered person's devices, in the map's corner. */ +.dl-map-card { position: absolute; right: 12px; top: 12px; z-index: 3; min-width: 200px; max-width: 260px; padding: 10px 12px; border-radius: 10px; font-size: 12px; line-height: 20px; + background: var(--dl-elevated); color: var(--dl-fg); border: 1px solid var(--dl-line); box-shadow: var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4)); + opacity: 0; transition: opacity .2s; pointer-events: none; } +.dl-map-card.on { opacity: 1; } +.dl-map-card-head b { font-weight: 500; } +.dl-map-card-row { display: flex; justify-content: space-between; gap: 12px; white-space: nowrap; } +/* A marker's card: floats over the page (never clipped by the map), pinned above or below the marker. */ +.dl-popcard { position: fixed; z-index: 2100; width: max-content; max-width: 300px; padding: 12px; border-radius: 12px; box-sizing: border-box; + background: var(--dl-elevated); color: var(--dl-fg); border: 1px solid var(--dl-line); box-shadow: var(--shadow-xl, 0 8px 16px -4px rgba(0,0,0,.4)); } +.dl-popcard.away { visibility: hidden; } +.dl-popcard.leaving { pointer-events: none; } +.dl-popcard-tip { position: absolute; left: var(--tip-x, 50%); width: 10px; height: 10px; margin-left: -6px; box-sizing: border-box; + background: var(--dl-elevated); border: solid var(--dl-line); transform: rotate(45deg); } +.dl-popcard.above .dl-popcard-tip { bottom: -6px; border-width: 0 1px 1px 0; } +.dl-popcard.below .dl-popcard-tip { top: -6px; border-width: 1px 0 0 1px; } +.dl-popcard.above { transform-origin: var(--tip-x, 50%) 100%; } +.dl-popcard.below { transform-origin: var(--tip-x, 50%) 0; } +@media (prefers-reduced-motion: no-preference) { + .dl-popcard { animation: dl-pop-in .16s ease-out; } + .dl-popcard.leaving { animation: dl-pop-out .14s ease-in forwards; } +} +@keyframes dl-pop-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } } +@keyframes dl-pop-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: scale(.94); } } .dl-pop { display: flex; flex-direction: column; gap: 4px; font-size: 12px; line-height: 18px; min-width: 210px; } .dl-pop-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 2px; } -.dl-mk.multi { width: 26px; height: 26px; } -.dl-mk-count { min-width: 22px; height: 22px; padding: 0 6px; border-radius: 999px; background: #8f8f8f; color: #0a0a0a; font: 600 11px/22px var(--dl-mono); - text-align: center; box-shadow: 0 0 0 3px rgba(0,0,0,.55); box-sizing: border-box; } -.dl-mk.online .dl-mk-count { background: #40c977; } .dl-pop-net { width: 30px; height: 30px; border-radius: 9px; background: var(--dl-soft); display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; color: var(--dl-fg-muted); } -.dl-pop-list { display: flex; flex-direction: column; margin: 6px -4px 0; } -.dl-pop-row { all: unset; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 5px 4px; border-radius: 6px; } +/* The row's highlight lines up with the head's icon above it. */ +.dl-pop-list { display: flex; flex-direction: column; margin: 6px 0 0; max-height: 116px; overflow-y: auto; } +.dl-pop-row { all: unset; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 8px; } .dl-pop-row:hover { background: var(--dl-soft); } .dl-pop-row:focus { outline: none; } .dl-pop-row:focus-visible { outline: 2px solid var(--dl-ring); } @@ -41,7 +128,6 @@ .dl-pop-dot.on { background: var(--dl-ok); box-shadow: 0 0 0 3px var(--dl-ok-wash); } .dl-pop-actions { display: flex; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--dl-line); } .dl-pop-actions .cbi-button { flex: 1; height: 28px !important; font-size: 12px !important; justify-content: center; } -.maplibregl-ctrl-attrib { font-size: 10px; } /* charts */ .dl-chartbox { position: relative; } diff --git a/web/src/admin/styles/overview.css b/web/src/admin/styles/overview.css index 65acb30..557a905 100644 --- a/web/src/admin/styles/overview.css +++ b/web/src/admin/styles/overview.css @@ -165,6 +165,7 @@ .dl-speed-chart .line.up { stroke: var(--dl-ok); stroke-width: 1.2; opacity: .85; } .dl-speed-wait { height: 44px; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; font-size: 11px; color: var(--dl-fg-faint); } .dl-speed-wait i { display: block; height: 1px; background: var(--dl-line); order: 2; } +.dl-speed-val.off { color: var(--dl-fg-faint); } .dl-fld { display: flex; flex-direction: column; gap: 8px; margin: 0 0 16px; } .dl-fld-label { font-size: 13px; font-weight: 500; color: var(--dl-fg); } .dl-fld .cbi-input-text { width: 100%; box-sizing: border-box; } diff --git a/web/src/admin/styles/people.css b/web/src/admin/styles/people.css index 5f5d808..848e901 100644 --- a/web/src/admin/styles/people.css +++ b/web/src/admin/styles/people.css @@ -3,7 +3,19 @@ .dl-plist > .dl-card { display: block; margin: 0 0 12px; padding: 16px; min-width: 0; background: var(--dl-card); border: 1px solid var(--dl-line); border-radius: var(--dl-radius); box-shadow: var(--dl-shadow); } .dl-plist > .dl-card.dl-filtered { display: none; } -.dl-plist > .dl-card.dl-off .dl-card-name, .dl-plist > .dl-card.dl-off .dl-avatar { opacity: .6; } +/* Stopped (paused, ended, over a limit): the card fades, its strip and actions stay bright. */ +.dl-plist > .dl-card.dl-off :is(.dl-card-name, .dl-avatar, .dl-access, .dl-slotbar, .dl-chips, .dl-pill-ic, .dl-use-num, .dl-pside-foot, .dl-pside-state) { opacity: .45; } +.dl-plist > .dl-card.dl-off .dl-usebar i { background: var(--dl-fg-faint); } +.dl-plist > .dl-card.dl-off .dl-chip-tag { background: var(--dl-soft); color: var(--dl-fg-muted); } +/* Why, across the card's bottom edge, with the action that lifts it */ +.dl-pcard:has(> .dl-pstrip) { row-gap: 14px; } +.dl-pstrip { grid-column: 1 / -1; display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; margin: 0 -16px -16px; padding: 10px 16px; + border-top: 1px solid var(--dl-line); border-radius: 0 0 var(--dl-radius) var(--dl-radius); font-size: 14px; line-height: 20px; } +.dl-pstrip.warn { background: color-mix(in srgb, var(--dl-warn) 7%, transparent); } +.dl-pstrip.bad { background: color-mix(in srgb, var(--dl-bad) 7%, transparent); } +.dl-pstrip-text { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 8px; } +.dl-pstrip-text b { font-weight: 500; } +.dl-pstrip > .cbi-button { flex: none; height: 32px !important; } .dl-plist-none { color: var(--dl-fg-muted); text-align: center; padding: 28px 16px; background: var(--dl-card); border: 1px solid var(--dl-line); border-radius: var(--dl-radius); } .dl-card-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; } diff --git a/web/src/admin/styles/person.css b/web/src/admin/styles/person.css index 5afcd82..f1e0668 100644 --- a/web/src/admin/styles/person.css +++ b/web/src/admin/styles/person.css @@ -134,7 +134,6 @@ .dl-fix { all: unset; cursor: pointer; height: 26px; padding: 0 10px; border-radius: 999px; background: var(--dl-info-wash); color: var(--dl-info); font-size: 12px; font-weight: 500; display: inline-flex; align-items: center; } .dl-fix:hover { filter: brightness(1.15); } -.dl-plist > .dl-card.dl-attn-row { border-color: color-mix(in srgb, var(--dl-warn) 35%, transparent); } @media (max-width: 760px) { .dl-pcard { grid-template-columns: 1fr; } .dl-pside { padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--dl-line); } .dl-fixes { margin-left: 0; } } .dl-select { height: 34px !important; border-radius: 999px !important; min-width: 136px !important; width: auto !important; padding: 0 34px 0 14px !important; appearance: none !important; -webkit-appearance: none !important; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8f98' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") !important; background-repeat: no-repeat !important; background-position: right 12px center !important; background-size: 14px !important; } diff --git a/web/src/admin/styles/settings.css b/web/src/admin/styles/settings.css index 035ca58..e1cfebe 100644 --- a/web/src/admin/styles/settings.css +++ b/web/src/admin/styles/settings.css @@ -33,6 +33,11 @@ .dl-hostport { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; justify-content: flex-end; } .dl-hostport input { flex: 1; min-width: 0; } .dl-root input.dl-w-port, .dl-hostport input.dl-w-port { flex: 0 0 90px; width: 90px; } +.dl-root input.dl-w-range { flex: 0 0 130px; width: 130px; } +.dl-setrow .dl-sub.bad { color: var(--dl-bad); } +/* An input with a fixed ending ("10.77.0" .x). */ +.dl-suffixed { display: inline-flex; align-items: center; gap: 6px; } +.dl-suffixed > span { color: var(--dl-fg-muted); } .dl-more summary { cursor: pointer; color: var(--dl-fg-muted); font-size: 13px; margin-bottom: 10px; } .dl-more .dl-setrow + .dl-setrow { margin-top: 10px; } @media (max-width: 760px) { .dl-setrow:not(.head) { grid-template-columns: minmax(0, 1fr); } .dl-setrow-ctl, .dl-setrow-ctl .dl-chips-row { justify-content: flex-start; } } diff --git a/web/src/admin/ui/badges.ts b/web/src/admin/ui/badges.ts index 219f7fa..c8239f0 100644 --- a/web/src/admin/ui/badges.ts +++ b/web/src/admin/ui/badges.ts @@ -10,28 +10,26 @@ export function pill(tone: string, text: string, title?: string): HTMLElement { return E('span', { class: `dl-pill ${tone}`, title: title ?? null }, text); } -const STATE_ICON: Record = { - active: '', - paused: 'pause', - paused_all: 'pause', - expired: 'calendar', - quota: 'chart', - hours: 'clock', - no_server: 'alert', -}; - export function stateTone(p: Person): string { if (p.state === 'active') return 'ok'; if (p.state === 'quota' || p.state === 'expired') return 'bad'; return 'warn'; } -/** Nothing while active; otherwise a small icon with the state as tooltip. */ -export function stateBadge(p: Person): HTMLElement | '' { - if (p.state === 'active') return ''; - const el = E('span', { class: `dl-ibadge ${stateTone(p)}`, 'aria-label': STATE_LABEL[p.state] }, icon(STATE_ICON[p.state] || 'alert')); - attachTip(el, () => [E('div', { class: 'dl-tip-title' }, STATE_LABEL[p.state])]); - return el; +/** + * The person's own state: a turned-off server hides why they would be off + * anyway, but the admin's pause still shows ('server_off' itself is the server + * page's to say). + */ +function ownState(p: Person): Person['state'] { + return p.state === 'server_off' && p.paused ? 'paused' : p.state; +} + +/** Nothing while active (or while only their server is off); otherwise the state as text, as the server page's "Turned off". */ +export function statePill(p: Person): HTMLElement | '' { + const s = ownState(p); + if (s === 'active' || s === 'server_off') return ''; + return pill(stateTone({ ...p, state: s }), STATE_LABEL[s]); } /** What the person can reach, as icons: home network, internet, or both. */ diff --git a/web/src/admin/ui/layout.ts b/web/src/admin/ui/layout.ts index 6ee6fd6..f9e75a7 100644 --- a/web/src/admin/ui/layout.ts +++ b/web/src/admin/ui/layout.ts @@ -13,6 +13,31 @@ export function row(label: string, control: Node, help?: string): HTMLElement { ]); } +/** + * A row whose help line follows its input: `help` says what the value gives, + * or what is wrong (red, the input marked too). Callers that change what the + * help depends on call `refresh()`. + */ +export function liveRow( + label: string, + el: HTMLInputElement, + help: () => { text: string; bad: boolean }, + control: Node = el, +): HTMLElement & { refresh: () => void } { + const r = row(label, control, ' ') as HTMLElement & { refresh: () => void }; + const sub = r.querySelector('.dl-sub') as HTMLElement; + const paint = () => { + const h = help(); + sub.textContent = h.text; + sub.classList.toggle('bad', h.bad); + el.classList.toggle('cbi-input-invalid', h.bad); + }; + el.addEventListener('input', paint); + r.refresh = paint; + paint(); + return r; +} + /** A section card with its own footer (Save etc.). */ export function card(title: string, body: (Node | string)[], foot: (Node | string)[], extra = ''): HTMLElement { return E('section', { class: `dl-setsec ${extra}` }, [ diff --git a/web/src/admin/ui/tooltip.ts b/web/src/admin/ui/tooltip.ts index 901a3e5..29289e4 100644 --- a/web/src/admin/ui/tooltip.ts +++ b/web/src/admin/ui/tooltip.ts @@ -1,6 +1,8 @@ // One floating tooltip that follows the pointer (small charts, meters, round -// buttons). It hides when its anchor leaves the page (a repaint replaced it) -// or the page navigates away, so it never lingers on . +// buttons). It hides when its anchor leaves the page or is hidden (a repaint +// replaced it, another section is shown), on scrolling, on a tap or click +// elsewhere (touch screens have no mouseleave) and when the page navigates +// away, so it never lingers on . import { E } from '../e'; import { onNavigate } from './nav'; @@ -24,9 +26,9 @@ export function attachTip(el: HTMLElement, content: () => (Node | string)[]) { floating.style.left = `${ev.clientX}px`; floating.style.top = `${ev.clientY - 10}px`; anchor = el; - // No mouseleave comes from an element that was removed under the pointer. + // No mouseleave comes from an element that was removed or hidden under the pointer. watch ||= window.setInterval(() => { - if (!anchor?.isConnected) hideTip(); + if (!anchor?.isConnected || !anchor.getClientRects().length) hideTip(); }, 400); }; el.addEventListener('mouseenter', show); @@ -35,3 +37,11 @@ export function attachTip(el: HTMLElement, content: () => (Node | string)[]) { } onNavigate(hideTip); +window.addEventListener('scroll', () => anchor && hideTip(), { capture: true, passive: true }); +document.addEventListener( + 'pointerdown', + (ev) => { + if (anchor && !anchor.contains(ev.target as Node)) hideTip(); + }, + true, +); diff --git a/web/src/admin/widgets/tiles.ts b/web/src/admin/widgets/tiles.ts index eda7de7..6d08162 100644 --- a/web/src/admin/widgets/tiles.ts +++ b/web/src/admin/widgets/tiles.ts @@ -9,8 +9,11 @@ import { svg } from '../ui/layout'; const dayLabel = (day: string) => parseDay(day).toLocaleDateString('en-GB', { day: 'numeric', month: 'short' }); -/** Throughput over the last 15 minutes plus today's total. */ -export function speedTile(rate: [number, number, number][], now: number, today: [number, number]): HTMLElement { +/** + * Throughput over the last 15 minutes plus today's total. `off`: the server is + * turned off, so there is no speed to show (dashes, not zeros) and no chart. + */ +export function speedTile(rate: [number, number, number][], now: number, today: [number, number], off = false): HTMLElement { const pts = rate.slice(-15); const last = pts[pts.length - 1]; const fresh = last && now - last[0] < 180; @@ -24,19 +27,19 @@ export function speedTile(rate: [number, number, number][], now: number, today: const dl = line(2), ul = line(1); const chart = - pts.length > 1 + pts.length > 1 && !off ? svg( ``, ) - : E('div', { class: 'dl-speed-wait' }, [E('i'), E('span', {}, 'Collecting… 1 point a minute')]); + : E('div', { class: 'dl-speed-wait' }, [E('i'), off ? '' : E('span', {}, 'Collecting… 1 point a minute')]); const col = (label: string, ic: string, cls: string, v: number) => E('div', { class: 'dl-speed-col' }, [ E('span', { class: 'dl-sub' }, [E('span', { class: cls }, ic), ` ${label}`]), - E('span', { class: 'dl-speed-val' }, bits(v)), + off ? E('span', { class: 'dl-speed-val off' }, '—') : E('span', { class: 'dl-speed-val' }, bits(v)), ]); - if (pts.length > 1) + if (pts.length > 1 && !off) attachTip(chart, () => { const p = pts[pts.length - 1]; return [ @@ -47,7 +50,7 @@ export function speedTile(rate: [number, number, number][], now: number, today: return E('div', { class: 'dl-bento-tile' }, [ E('div', { class: 'dl-bento-head' }, [ E('span', { class: 'dl-metric-label' }, 'Speed now'), - E('span', { class: 'dl-sub' }, 'last 15 min'), + off ? '' : E('span', { class: 'dl-sub' }, 'last 15 min'), ]), E('div', { class: 'dl-speed-cols' }, [col('Download', '↓', 'dl-dn', down), col('Upload', '↑', 'dl-up', up)]), chart, diff --git a/web/src/portal/main.ts b/web/src/portal/main.ts index dd24a2b..c5702a9 100644 --- a/web/src/portal/main.ts +++ b/web/src/portal/main.ts @@ -5,20 +5,7 @@ // devices on the left, access on the right. import type { ClientConfig, Device, Kind, Person } from '../shared/types'; -import { - ACCESS_LABEL, - KIND_LABEL, - STATE_LABEL, - addDays, - ago, - byDeviceState, - bytes, - date, - daysLeft, - initials, - isoDay, - parseDay, -} from '../shared/format'; +import { ACCESS_LABEL, KIND_LABEL, addDays, ago, byDeviceState, bytes, date, daysLeft, initials, isoDay, parseDay } from '../shared/format'; import { iconSvg } from '../shared/icons'; import { qrSvg } from '../shared/qr'; import { vpnKey } from '../shared/vpnkey'; @@ -31,6 +18,8 @@ interface State { /** The device this page was opened from (through the tunnel), if any. */ here?: string | null; can_add: boolean; + /** The admin stopped the person (paused, access ended): the page only shows. */ + locked?: boolean; kinds: Kind[]; version: string; /** The router's day (YYYY-MM-DD) when it sends one; the browser's otherwise. */ @@ -331,6 +320,34 @@ function linkGone() { ); } +/** Why the person's devices can't connect: icon, title and what happens next. */ +function stateNotice(p: Person): [string, string, string] { + switch (p.state) { + case 'server_off': + return ['server', 'The server is turned off', 'Your devices can’t connect until the admin turns it on again.']; + case 'no_server': + return ['server', 'No server yet', 'Ask the admin to add you to a server.']; + case 'quota': + return ['chart', 'You have used all your data', 'Your devices are paused until it resets.']; + case 'expired': + return ['calendar', 'Your access has ended', 'Ask the admin to extend it.']; + case 'hours': + return ['clock', 'Outside your hours', `Access is available ${p.hours.replace('-', '–')} (router time).`]; + default: + return ['pause', 'Your access is paused by the admin', 'Your devices can’t connect until the admin resumes it.']; + } +} + +/** A notice in the admin's Overview style: a tinted icon tile, a title and a line under it. */ +function alertRow(tone: string, icon: string, title: string, sub: string): HTMLElement { + return h( + 'div', + { class: 'alert' }, + h('span', { class: `alert-ic ${tone}` }, ic(icon)), + h('div', { class: 'stack' }, h('span', { class: 'strong' }, title), h('span', { class: 'muted s' }, sub)), + ); +} + function stateTone(p: Person) { return p.state === 'active' ? 'ok' : p.state === 'quota' || p.state === 'expired' ? 'bad' : 'warn'; } @@ -527,6 +544,8 @@ function deviceCard(d: Device, st: State): HTMLElement { }); const week = d.spark.reduce((a, b) => a + b, 0); const setUp = !d.handshake && !d.disabled; + // Stopped by the admin: no actions, and a device never set up has nothing to show. + const locked = !!st.locked; // The device this page was opened from (through the tunnel): blue, and says so. const here = st.here === d.id; return h( @@ -543,24 +562,26 @@ function deviceCard(d: Device, st: State): HTMLElement { // Opened through the tunnel, so it is connected: say which one it is instead. here ? h('span', { class: 'dstat here' }, 'This device') : deviceStatus(d), ), - more, + locked ? null : more, ), - setUp - ? [ - h( - 'button', - { type: 'button', class: 'btn primary block', onclick: () => connect(d) }, - ic(isMobile() ? 'open' : 'qr'), - h('span', {}, isMobile() ? 'Open in AmneziaVPN' : 'Connect this device'), + setUp && locked + ? null + : setUp + ? [ + h( + 'button', + { type: 'button', class: 'btn primary block', onclick: () => connect(d) }, + ic(isMobile() ? 'open' : 'qr'), + h('span', {}, isMobile() ? 'Open in AmneziaVPN' : 'Connect this device'), + ), + ] + : h( + 'div', + { class: 'duse' }, + h('div', { class: 'stack' }, h('span', { class: 'faint s' }, 'Last 7 days'), h('span', { class: 'mono' }, bytes(week))), + spark(d.spark), ), - ] - : h( - 'div', - { class: 'duse' }, - h('div', { class: 'stack' }, h('span', { class: 'faint s' }, 'Last 7 days'), h('span', { class: 'mono' }, bytes(week))), - spark(d.spark), - ), - d.config_stale && !setUp + d.config_stale && !setUp && !locked ? h( 'div', { class: 'notice' }, @@ -577,35 +598,20 @@ function main(st: State) { const left = daysLeft(p.expires, today()); const notice = p.state !== 'active' - ? h( - 'div', - { class: 'notice bad' }, - ic('alert'), - h( - 'span', - {}, - p.state === 'quota' - ? 'You have used all your data for this period. Your devices are paused until it resets.' - : p.state === 'expired' - ? 'Your access has ended. Ask the admin to extend it.' - : p.state === 'hours' - ? `Access is available ${p.hours.replace('-', '–')} (router time).` - : 'Your access is paused by the admin.', - ), - ) + ? alertRow(stateTone(p), ...stateNotice(p)) : left != null && left >= 0 && left <= Math.max(p.expire_warn, 1) - ? h( - 'div', - { class: 'notice' }, - ic('alert'), - h('span', {}, `Your access ends ${left === 0 ? 'today' : `in ${left} day${left === 1 ? '' : 's'}`} (${date(p.expires)}).`), + ? alertRow( + 'warn', + 'calendar', + `Your access ends ${left === 0 ? 'today' : `in ${left} day${left === 1 ? '' : 's'}`}`, + `On ${date(p.expires)}. Ask the admin to extend it.`, ) : null; // The device this page was opened from comes first. const order = byDeviceState(p.devices).sort((a, b) => Number(b.id === st.here) - Number(a.id === st.here)); const cards: HTMLElement[] = order.map((d) => deviceCard(d, st)); - const free = Math.max(0, p.device_limit - p.devices.length); + const free = st.locked ? 0 : Math.max(0, p.device_limit - p.devices.length); if (free) cards.push( h( @@ -631,36 +637,36 @@ function main(st: State) { ), ), h('div', { class: 'dgrid' }, cards), - !st.can_add - ? h('span', { class: 'faint s' }, `You have reached your limit of ${p.device_limit} devices. Remove one or ask the admin for more.`) - : null, - h( - 'span', - { class: 'faint s' }, - 'New device? Install ', - h('a', { href: 'https://amnezia.org/downloads', target: '_blank', rel: 'noopener noreferrer' }, 'AmneziaVPN'), - ' on it first.', - ), + st.locked + ? null + : [ + !st.can_add + ? h( + 'span', + { class: 'faint s' }, + `You have reached your limit of ${p.device_limit} devices. Remove one or ask the admin for more.`, + ) + : null, + h( + 'span', + { class: 'faint s' }, + 'New device? Install ', + h('a', { href: 'https://amnezia.org/downloads', target: '_blank', rel: 'noopener noreferrer' }, 'AmneziaVPN'), + ' on it first.', + ), + ], ); + // What stops the devices comes before the greeting. shell( + notice, h( 'div', { class: 'hello' }, h('span', { class: `avatar${p.online ? ' online' : ''}` }, initials(p.name)), - h( - 'div', - { class: 'stack' }, - // Only when something is wrong: an "Active" pill says nothing. - h( - 'div', - { class: 'row' }, - h('h1', {}, `Hi, ${p.name}`), - p.state === 'active' ? null : h('span', { class: `pill ${stateTone(p)}` }, STATE_LABEL[p.state]), - ), - ), + // What is wrong is in the notice above, not a pill here. + h('h1', {}, `Hi, ${p.name}`), ), - notice, h('div', { class: 'layout' }, accessCard(st), devices), ); } diff --git a/web/src/portal/portal.css b/web/src/portal/portal.css index 826f51c..098f4c2 100644 --- a/web/src/portal/portal.css +++ b/web/src/portal/portal.css @@ -258,29 +258,6 @@ h2 { background: var(--ok); box-shadow: 0 0 0 3px var(--bg); } -.pill { - display: inline-flex; - align-items: center; - height: 22px; - padding: 0 9px; - border-radius: 999px; - font-size: 12px; - font-weight: 500; - background: var(--soft); - color: var(--muted); -} -.pill.ok { - background: var(--ok-wash); - color: var(--ok); -} -.pill.warn { - background: var(--warn-wash); - color: var(--warn); -} -.pill.bad { - background: var(--bad-wash); - color: var(--bad); -} .notice { display: flex; gap: 10px; @@ -300,6 +277,38 @@ h2 { color: var(--bad); } +/* The page's notice, as in the admin's Overview: a row in a bordered list. */ +.alert { + display: flex; + gap: 12px; + align-items: center; + padding: 12px 16px; + border: 1px solid var(--line); + border-radius: 12px; + background: var(--card); + font-size: 14px; + line-height: 20px; +} +.alert-ic { + width: 30px; + height: 30px; + border-radius: 9px; + display: inline-flex; + align-items: center; + justify-content: center; + flex: none; + background: var(--warn-wash); + color: var(--warn); +} +.alert-ic.bad { + background: var(--bad-wash); + color: var(--bad); +} +.alert-ic .ic-svg { + width: 15px; + height: 15px; +} + /* layout: phone = access then devices; desktop = devices | access */ .layout { display: grid; diff --git a/web/src/shared/format.ts b/web/src/shared/format.ts index e31954c..e3bf128 100644 --- a/web/src/shared/format.ts +++ b/web/src/shared/format.ts @@ -159,11 +159,11 @@ export const KIND_LABEL: Record = { export const STATE_LABEL: Record = { active: 'Active', paused: 'Paused', - paused_all: 'Paused (everyone)', expired: 'Expired', quota: 'Data limit reached', hours: 'Outside allowed hours', no_server: 'No server', + server_off: 'Server is turned off', }; export function initials(name: string): string { diff --git a/web/src/shared/icons.ts b/web/src/shared/icons.ts index e9ffbc5..605e98c 100644 --- a/web/src/shared/icons.ts +++ b/web/src/shared/icons.ts @@ -5,6 +5,8 @@ const P: Record = { computer: '', tablet: '', router: '', + server: + '', other: '', ethernet: '', diff --git a/web/src/shared/types.ts b/web/src/shared/types.ts index 6c1bf1e..af10477 100644 --- a/web/src/shared/types.ts +++ b/web/src/shared/types.ts @@ -2,7 +2,7 @@ export type Access = 'lan' | 'internet' | 'both'; export type Kind = 'computer' | 'phone' | 'tablet' | 'router' | 'other'; -export type PersonState = 'active' | 'paused' | 'paused_all' | 'expired' | 'quota' | 'hours' | 'no_server'; +export type PersonState = 'active' | 'paused' | 'expired' | 'quota' | 'hours' | 'no_server' | 'server_off'; export type Pair = [number, number]; // [rx, tx] from the router's point of view export interface Device { @@ -99,7 +99,10 @@ export interface Server { /** Home networks by interface, for the per-person picker. */ home: { dev: string; nets: string[] }[]; preset: string; + /** The MTU set; 0 = automatic, by device type and disguise. */ mtu: number; + /** The MTU devices get now: computers and routers, phones and tablets. */ + mtus: { computer: number; phone: number }; keepalive: number; /** DNS servers given to devices; empty = this router. */ dns: string[]; @@ -191,7 +194,6 @@ export interface Status { /** The port in personal links (the portal's own). */ portal_public_port?: number; portal_host: string; - paused_all: boolean; default_device_limit: number; domain: string; hostnames: boolean; diff --git a/web/tests/map.test.ts b/web/tests/map.test.ts new file mode 100644 index 0000000..e2df19f --- /dev/null +++ b/web/tests/map.test.ts @@ -0,0 +1,135 @@ +import { describe, expect, it } from 'vitest'; +import { arc, devicePlaces, separate, type MapData } from '../src/admin/map'; + +describe('arc (mapcn buildArcCoordinates)', () => { + it('runs from one point to the other in 64 steps', () => { + const pts = arc([-0.1276, 51.5074], [-74.006, 40.7128]); + expect(pts).toHaveLength(65); + expect(pts[0]).toEqual([-0.1276, 51.5074]); + expect(pts[64][0]).toBeCloseTo(-74.006); + expect(pts[64][1]).toBeCloseTo(40.7128); + }); + + it('bends to the left of travel by a fifth of the distance', () => { + // Due east 10°: the control point sits 2° north of the middle, the curve's peak half of that. + const mid = arc([0, 0], [10, 0])[32]; + expect(mid[0]).toBeCloseTo(5); + expect(mid[1]).toBeCloseTo(1); + }); + + it('takes the short way across the antimeridian', () => { + const pts = arc([139.69, 35.69], [-122.42, 37.77]); + expect(pts[pts.length - 1][0]).toBeCloseTo(237.58); + expect(Math.max(...pts.map((p) => Math.abs(p[0] - 139.69)))).toBeLessThan(100); + }); + + it('is a single point pair when both ends meet', () => { + expect(arc([10, 10], [10, 10])).toEqual([ + [10, 10], + [10, 10], + ]); + }); +}); + +describe('devicePlaces', () => { + const pt = (city: string, ts: number, online = false, device = 'lap') => ({ + person: 'my', + device, + ip: `ip-${city}-${ts}`, + ts, + online, + lat: 0, + lon: 0, + city, + country: '', + cc: 'RU', + asn: 0, + org: '', + }); + const now = 100 * 86400; + const data = (points: ReturnType[]): MapData => ({ + geo: { enabled: true, home: null, points } as unknown as MapData['geo'], + people: [], + now, + person: 'my', + device: 'lap', + }); + + it('puts the live place first and numbers the rest newest first, one per city', () => { + const list = devicePlaces( + data([ + pt('Kazan', now - 25 * 86400), + pt('Moscow', now - 7 * 86400), + pt('Moscow', now - 9 * 86400), + pt('Sochi', now - 86400), + pt('Krasnodar', now, true), + pt('Berlin', now - 86400, false, 'phone'), + ]), + '30d', + ); + expect(list.map((x) => [x.city, x.n])).toEqual([ + ['Krasnodar', 0], + ['Sochi', 1], + ['Moscow', 2], + ['Kazan', 3], + ]); + }); + + it('keeps to the period', () => { + expect(devicePlaces(data([pt('Kazan', now - 25 * 86400), pt('Sochi', now - 86400)]), '7d').map((x) => x.city)).toEqual(['Sochi']); + }); +}); + +describe('separate', () => { + it('leaves markers that do not touch alone', () => { + expect( + separate([ + { x: 0, y: 0, r: 10 }, + { x: 100, y: 0, r: 10 }, + ]), + ).toEqual([ + [0, 0], + [0, 0], + ]); + }); + it('moves only the free one away from a fixed one, just clear', () => { + const [s, p] = separate([ + { x: 0, y: 0, r: 20, fixed: true }, + { x: 30, y: 0, r: 14 }, + ]); + expect(s).toEqual([0, 0]); + expect(p[0]).toBeCloseTo(20 + 14 + 6 - 30); + expect(p[1]).toBeCloseTo(0); + }); + it('fades to nothing as markers part (no jump)', () => { + const at = (x: number) => + separate([ + { x: 0, y: 0, r: 20, fixed: true }, + { x, y: 0, r: 14 }, + ])[1][0]; + expect(at(39)).toBeCloseTo(1); + expect(at(39.9)).toBeCloseTo(0.1); + expect(at(40)).toBe(0); + }); + it('splits two free markers half each and parts ones on the same spot', () => { + const [a, b] = separate( + [ + { x: 0, y: 0, r: 10 }, + { x: 10, y: 0, r: 10 }, + ], + 0, + ); + expect(a[0]).toBeCloseTo(-5); + expect(b[0]).toBeCloseTo(5); + const same = separate( + [ + { x: 0, y: 0, r: 10 }, + { x: 0, y: 0, r: 10 }, + { x: 0, y: 0, r: 10 }, + ], + 0, + ); + for (let i = 0; i < 3; i++) + for (let j = i + 1; j < 3; j++) expect(Math.hypot(same[i][0] - same[j][0], same[i][1] - same[j][1])).toBeGreaterThan(19); + }); +}); diff --git a/web/tests/netcheck.test.ts b/web/tests/netcheck.test.ts new file mode 100644 index 0000000..a81cf0e --- /dev/null +++ b/web/tests/netcheck.test.ts @@ -0,0 +1,64 @@ +import { describe, expect, it } from 'vitest'; +import { parseCidr, portalPortHelp, portHelp, rangeHelp, rangeOf, subnetOf } from '../src/admin/netcheck'; + +const nets = [ + { name: 'lan', cidr: '10.0.1.0/24' }, + { name: 'loopback', cidr: '127.0.0.0/8' }, + { name: 'wan', cidr: '109.173.124.0/23' }, + { name: 'guest', cidr: '192.168.0.0/16' }, +]; + +describe('netcheck', () => { + it('parses subnets like the router', () => { + expect(parseCidr('10.10.10.5/24')).toEqual({ net: 0x0a0a0a00, size: 256 }); + expect(parseCidr('10.10.10.0/31')).toBeNull(); + expect(parseCidr('10.10.300.0/24')).toBeNull(); + expect(parseCidr('10.10.10.0')).toBeNull(); + }); + + it('converts between a range and its subnet', () => { + expect(rangeOf('10.77.0.0/24')).toBe('10.77.0'); + expect(subnetOf(' 10.77.0 ')).toBe('10.77.0.0/24'); + }); + + it('explains the device addresses', () => { + expect(rangeHelp('10.10.10', nets, '10.77.0')).toEqual({ + text: 'Devices get 10.10.10.2 – 10.10.10.254, the router 10.10.10.1.', + bad: false, + }); + expect(rangeHelp('10.0.1', nets, '10.77.0')).toEqual({ text: 'lan already uses 10.0.1.x. Try 10.77.0.', bad: true }); + expect(rangeHelp('192.168.5', nets, '10.77.0').text).toBe('guest already uses 192.168.0.0/16. Try 10.77.0.'); + expect(rangeHelp('10.77.0', [{ name: 'Home', cidr: '10.77.0.0/24' }], '10.77.0').text).toBe('Home already uses 10.77.0.x.'); + }); + + it('wants a private range of three numbers', () => { + expect(rangeHelp('8.8.8', nets, '').text).toBe('Use a private range: 10.x.x, 172.16–31.x or 192.168.x.'); + expect(rangeHelp('172.32.0', nets, '').bad).toBe(true); + expect(rangeHelp('172.31.0', nets, '').bad).toBe(false); + expect(rangeHelp('10.10', nets, '').text).toBe('Three numbers, like 10.77.0.'); + expect(rangeHelp('10.10.10.0', nets, '').bad).toBe(true); + expect(rangeHelp('10.10.256', nets, '').bad).toBe(true); + }); + + it('says who holds a port', () => { + const taken = [ + { from: 53, to: 53, who: 'dnsmasq on this router' }, + { from: 4000, to: 4100, who: 'port forward “Game”' }, + ]; + expect(portHelp(4500, taken, 'Free.')).toEqual({ text: 'Free.', bad: false }); + expect(portHelp(53, taken, '').text).toBe('Used by dnsmasq on this router. Choose another port.'); + expect(portHelp(4050, taken, '').text).toBe('Used by port forward “Game”. Choose another port.'); + expect(portHelp(0, taken, '').text).toBe('Use a port from 1 to 65535.'); + expect(portHelp(Number.NaN, taken, '').bad).toBe(true); + }); + + it('checks the portal port and the next one for IP links', () => { + const taken = [{ from: 8444, to: 8444, who: 'nginx on this router' }]; + expect(portalPortHelp(8443, taken, false)).toEqual({ text: 'HTTPS on this port, opened on WAN.', bad: false }); + expect(portalPortHelp(8443, taken, true).text).toBe( + 'Links on IP addresses also need 8444, used by nginx on this router. Choose another port.', + ); + expect(portalPortHelp(9443, taken, true)).toEqual({ text: 'HTTPS here, plain HTTP for links on IP addresses on 9444.', bad: false }); + expect(portalPortHelp(8444, taken, false).bad).toBe(true); + }); +});