diff --git a/README.md b/README.md index 94126ba..3cd64ef 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,14 @@ limits, live traffic and a LuCI admin that follows a modern design. same link at home, and wrong links can redirect to your website. - **Access per person**, enforced in an `inet dawnline` nftables table on the tunnel interface: home network only, internet only, or both, and optionally - only some home services. + only some home networks or home services (picked from the devices the router + sees over DHCP). Devices of different people reach each other never, always, + or within circles (family sees family, guests see guests). "Who reaches what" + sums up the rules and "Check access" walks them step by step for a device + and an address. +- **Find home devices** (optional, needs `umdns`): AirPlay, printers and shared + Macs at home show up on iPhone, iPad and Mac over the tunnel, published as + DNS-SD records in dnsmasq. - **Limits.** End dates (pause, keep, or remove devices when they pass), monthly or total data limits, allowed hours, pause one person or everyone. Devices drop off the tunnel at once (`awg syncconf`, no interface restart). diff --git a/package/luci-app-dawnline/Makefile b/package/luci-app-dawnline/Makefile index e853196..1eb3f27 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.2.0 +PKG_VERSION:=0.3.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 7bea7c6..da7a047 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 @@ -7,14 +7,14 @@ 'require rpc'; 'require uci'; 'require ui'; -var $n=Object.create;var Kt=Object.defineProperty;var _n=Object.getOwnPropertyDescriptor;var Ln=Object.getOwnPropertyNames;var Sn=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty;var En=(s,t)=>()=>(t||s((t={exports:{}}).exports,t),t.exports);var Tn=(s,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of Ln(t))!Mn.call(s,i)&&i!==n&&Kt(s,i,{get:()=>t[i],enumerable:!(a=_n(t,i))||a.enumerable});return s};var Cn=(s,t,n)=>(n=s!=null?$n(Sn(s)):{},Tn(t||!s||!s.__esModule?Kt(n,"default",{value:s,enumerable:!0}):n,s));var Zt=En((Jt,Qt)=>{"use strict";var Yt=(function(){var s=function(w,D){var E=236,M=17,u=w,$=n[D],h=null,p=0,T=null,m=[],y={},P=function(_,S){p=u*4+17,h=(function(x){for(var C=new Array(x),A=0;A=7&&ie(_),T==null&&(T=$t(u,$,m)),ue(T,S)},O=function(_,S){for(var x=-1;x<=7;x+=1)if(!(_+x<=-1||p<=_+x))for(var C=-1;C<=7;C+=1)S+C<=-1||p<=S+C||(0<=x&&x<=6&&(C==0||C==6)||0<=C&&C<=6&&(x==0||x==6)||2<=x&&x<=4&&2<=C&&C<=4?h[_+x][S+C]=!0:h[_+x][S+C]=!1)},H=function(){for(var _=0,S=0,x=0;x<8;x+=1){P(!0,x);var C=i.getLostPoint(y);(x==0||_>C)&&(_=C,S=x)}return S},Z=function(){for(var _=8;_>x&1)==1;h[Math.floor(x/3)][x%3+p-8-3]=C}for(var x=0;x<18;x+=1){var C=!_&&(S>>x&1)==1;h[x%3+p-8-3][Math.floor(x/3)]=C}},he=function(_,S){for(var x=$<<3|S,C=i.getBCHTypeInfo(x),A=0;A<15;A+=1){var j=!_&&(C>>A&1)==1;A<6?h[A][8]=j:A<8?h[A+1][8]=j:h[p-15+A][8]=j}for(var A=0;A<15;A+=1){var j=!_&&(C>>A&1)==1;A<8?h[8][p-A-1]=j:A<9?h[8][15-A-1+1]=j:h[8][15-A-1]=j}h[p-8][8]=!_},ue=function(_,S){for(var x=-1,C=p-1,A=7,j=0,G=i.getMaskFunction(S),q=p-1;q>0;q-=2)for(q==6&&(q-=1);;){for(var te=0;te<2;te+=1)if(h[C][q-te]==null){var re=!1;j<_.length&&(re=(_[j]>>>A&1)==1);var W=G(C,q-te);W&&(re=!re),h[C][q-te]=re,A-=1,A==-1&&(j+=1,A=7)}if(C+=x,C<0||p<=C){C-=x,x=-x;break}}},Ee=function(_,S){for(var x=0,C=0,A=0,j=new Array(S.length),G=new Array(S.length),q=0;q=0?Gt.getAt(Wt):0}}for(var Ft=0,W=0;Wq*8)throw"code length overflow. ("+A.getLengthInBits()+">"+q*8+")";for(A.getLengthInBits()+4<=q*8&&A.put(0,4);A.getLengthInBits()%8!=0;)A.putBit(!1);for(;!(A.getLengthInBits()>=q*8||(A.put(E,8),A.getLengthInBits()>=q*8));)A.put(M,8);return Ee(A,C)};y.addData=function(_,S){S=S||"Byte";var x=null;switch(S){case"Numeric":x=g(_);break;case"Alphanumeric":x=f(_);break;case"Byte":x=c(_);break;case"Kanji":x=k(_);break;default:throw"mode:"+S}m.push(x),T=null},y.isDark=function(_,S){if(_<0||p<=_||S<0||p<=S)throw _+","+S;return h[_][S]},y.getModuleCount=function(){return p},y.make=function(){if(u<1){for(var _=1;_<40;_++){for(var S=l.getRSBlocks(_,$),x=d(),C=0;C"u"?_*4:S;var x="";x+='";for(var A=0;A';x+=""}return x+="",x+="
",x},y.createSvgTag=function(_,S,x,C){var A={};typeof arguments[0]=="object"&&(A=arguments[0],_=A.cellSize,S=A.margin,x=A.alt,C=A.title),_=_||2,S=typeof S>"u"?_*4:S,x=typeof x=="string"?{text:x}:x||{},x.text=x.text||null,x.id=x.text?x.id||"qrcode-description":null,C=typeof C=="string"?{text:C}:C||{},C.text=C.text||null,C.id=C.text?C.id||"qrcode-title":null;var j=y.getModuleCount()*_+S*2,G,q,te,re,W="",ge;for(ge="l"+_+",0 0,"+_+" -"+_+",0 0,-"+_+"z ",W+=''+I(C.text)+"":"",W+=x.text?''+I(x.text)+"":"",W+='',W+='"u"?_*4:S;var x=y.getModuleCount()*_+S*2,C=S,A=x-S;return B(x,x,function(j,G){if(C<=j&&j"u"?_*4:S;var C=y.getModuleCount()*_+S*2,A="";return A+="",A};var I=function(_){for(var S="",x=0;x<_.length;x+=1){var C=_.charAt(x);switch(C){case"<":S+="<";break;case">":S+=">";break;case"&":S+="&";break;case'"':S+=""";break;default:S+=C;break}}return S},oe=function(_){var S=1;_=typeof _>"u"?S*2:_;var x=y.getModuleCount()*S+_*2,C=_,A=x-_,j,G,q,te,re,W={"██":"█","█ ":"▀"," █":"▄"," ":" "},ge={"██":"▀","█ ":"▀"," █":" "," ":" "},me="";for(j=0;j=A?ge[re]:W[re];me+=` -`}return x%2&&_>0?me.substring(0,me.length-x-1)+Array(x+1).join("▀"):me.substring(0,me.length-1)};return y.createASCII=function(_,S){if(_=_||1,_<2)return oe(S);_-=1,S=typeof S>"u"?_*2:S;var x=y.getModuleCount()*_+S*2,C=S,A=x-S,j,G,q,te,re=Array(_+1).join("██"),W=Array(_+1).join(" "),ge="",me="";for(j=0;j>>8),$.push(T&255)):$.push(M)}}return $}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={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},i=(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]],D=1335,E=7973,M=21522,u={},$=function(h){for(var p=0;h!=0;)p+=1,h>>>=1;return p};return u.getBCHTypeInfo=function(h){for(var p=h<<10;$(p)-$(D)>=0;)p^=D<<$(p)-$(D);return(h<<10|p)^M},u.getBCHTypeNumber=function(h){for(var p=h<<12;$(p)-$(E)>=0;)p^=E<<$(p)-$(E);return h<<12|p},u.getPatternPosition=function(h){return w[h-1]},u.getMaskFunction=function(h){switch(h){case a.PATTERN000:return function(p,T){return(p+T)%2==0};case a.PATTERN001:return function(p,T){return p%2==0};case a.PATTERN010:return function(p,T){return T%3==0};case a.PATTERN011:return function(p,T){return(p+T)%3==0};case a.PATTERN100:return function(p,T){return(Math.floor(p/2)+Math.floor(T/3))%2==0};case a.PATTERN101:return function(p,T){return p*T%2+p*T%3==0};case a.PATTERN110:return function(p,T){return(p*T%2+p*T%3)%2==0};case a.PATTERN111:return function(p,T){return(p*T%3+(p+T)%2)%2==0};default:throw"bad maskPattern:"+h}},u.getErrorCorrectPolynomial=function(h){for(var p=r([1],0),T=0;T5&&(T+=3+P-5)}for(var m=0;m=256;)u-=255;return w[u]},M})();function r(w,D){if(typeof w.length>"u")throw w.length+"/"+D;var E=(function(){for(var u=0;u"u")throw"bad rs block @ typeNumber:"+u+"/errorCorrectionLevel:"+$;for(var p=h.length/3,T=[],m=0;m>>7-M%8&1)==1},E.put=function(M,u){for(var $=0;$>>u-$-1&1)==1)},E.getLengthInBits=function(){return D},E.putBit=function(M){var u=Math.floor(D/8);w.length<=u&&w.push(0),M&&(w[u]|=128>>>D%8),D+=1},E},g=function(w){var D=t.MODE_NUMBER,E=w,M={};M.getMode=function(){return D},M.getLength=function(h){return E.length},M.write=function(h){for(var p=E,T=0;T+2>>8&255)*192+(m&255),h.put(m,13),T+=2}if(T>>8)},D.writeBytes=function(E,M,u){M=M||0,u=u||E.length;for(var $=0;$0&&(E+=","),E+=w[M];return E+="]",E},D},R=function(){var w=0,D=0,E=0,M="",u={},$=function(p){M+=String.fromCharCode(h(p&63))},h=function(p){if(!(p<0)){if(p<26)return 65+p;if(p<52)return 97+(p-26);if(p<62)return 48+(p-52);if(p==62)return 43;if(p==63)return 47}throw"n:"+p};return u.writeByte=function(p){for(w=w<<8|p&255,D+=8,E+=1;D>=6;)$(w>>>D-6),D-=6},u.flush=function(){if(D>0&&($(w<<6-D),w=0,D=0),E%3!=0)for(var p=3-E%3,T=0;T=D.length){if(u==0)return-1;throw"unexpected end of file./"+u}var p=D.charAt(E);if(E+=1,p=="=")return u=0,-1;if(p.match(/^\s$/))continue;M=M<<6|h(p.charCodeAt(0)),u+=6}var T=M>>>u-8&255;return u-=8,T};var h=function(p){if(65<=p&&p<=90)return p-65;if(97<=p&&p<=122)return p-97+26;if(48<=p&&p<=57)return p-48+52;if(p==43)return 62;if(p==47)return 63;throw"c:"+p};return $},V=function(w,D){var E=w,M=D,u=new Array(w*D),$={};$.setPixel=function(m,y,P){u[y*E+m]=P},$.write=function(m){m.writeString("GIF87a"),m.writeShort(E),m.writeShort(M),m.writeByte(128),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(0),m.writeByte(255),m.writeByte(255),m.writeByte(255),m.writeString(","),m.writeShort(0),m.writeShort(0),m.writeShort(E),m.writeShort(M),m.writeByte(0);var y=2,P=p(y);m.writeByte(y);for(var O=0;P.length-O>255;)m.writeByte(255),m.writeBytes(P,O,255),O+=255;m.writeByte(P.length-O),m.writeBytes(P,O,P.length-O),m.writeByte(0),m.writeString(";")};var h=function(m){var y=m,P=0,O=0,H={};return H.write=function(Z,ee){if(Z>>>ee)throw"length over";for(;P+ee>=8;)y.writeByte(255&(Z<>>=8-P,O=0,P=0;O=Z<0&&y.writeByte(O)},H},p=function(m){for(var y=1<>6,128|o&63):o<55296||o>=57344?a.push(224|o>>12,128|o>>6&63,128|o&63):(i++,o=65536+((o&1023)<<10|n.charCodeAt(i)&1023),a.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|o&63))}return a}return t(s)}})();(function(s){typeof define=="function"&&define.amd?define([],s):typeof Jt=="object"&&(Qt.exports=s())})(function(){return Yt})});function Lt(s,t){return s==null||s===!1||s===""||(Array.isArray(s)?s.forEach(n=>Lt(n,t)):t.push(s instanceof Node?s:String(s))),t}function e(s,t,n){let a=window.E,i=t!=null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof Node);return!i&&n===void 0?a(s,{},Lt(t,[])):a(s,i?t:{},Lt(n,[]))}function F(s,t=[]){let n=rpc.declare({object:"luci.dawnline",method:s,params:t});return async(...a)=>{let i=await n(...a);if(i&&typeof i=="object"&&typeof i.error=="string")throw new Error(i.error);return i}}var Dn=F("logs_clear",["person","device","category","older_days"]),An=(s={})=>Dn(s.person??"",s.device??"",s.category??"",s.older_days??""),Pn=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"]});async function Nn(s,t){let a=[s,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(o=>t[o]),t.paused,t.services],i=await Pn(...a);if(i&&typeof i.error=="string")throw new Error(i.error);return i}var zn=F("status",["days"]),Rn=0;async function Hn(s){let t=await zn(s);return Rn=Date.now(),t}var N={personUpdate:Nn,settingsGet:F("settings_get"),settingsUpdate:F("settings_update",["values"]),serviceSet:F("service_set",["id","name","address","ports"]),serviceDelete:F("service_delete",["id"]),geoClear:F("geo_clear"),events:F("events",["limit"]),logsClear:An,interfaces:F("interfaces",["id"]),serverInterfaces:F("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh"]),usageClear:F("usage_clear",["scope","id"]),uninstall:F("uninstall",["confirm"]),status:Hn,setupDefaults:F("setup_defaults"),serverCreate:F("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:F("server_obfuscation",["id","preset"]),serverUpdate:F("server_update",["id","values"]),serverDelete:F("server_delete",["id"]),personCreate:F("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:F("person_pause",["id","paused"]),personRegen:F("person_regen",["id"]),personDelete:F("person_delete",["id"]),personUsage:F("person_usage",["id","days"]),pauseAll:F("pause_all",["paused"]),deviceCreate:F("device_create",["person","name","kind"]),deviceConfig:F("device_config",["id"]),deviceUpdate:F("device_update",["id","name","disabled"]),deviceDelete:F("device_delete",["id"]),deviceRotate:F("device_rotate",["id"]),apply:F("apply"),health:F("health"),healthFix:F("health_fix",["id"]),serviceLog:F("service_log"),serviceLogClear:F("service_log_clear",["older_days"]),backupList:F("backup_list"),backupCreate:F("backup_create"),backupRestore:F("backup_restore",["name"]),backupDelete:F("backup_delete",["name"]),backupRead:F("backup_read",["name"]),backupUpload:F("backup_upload",["data"]),exportJson:F("export"),importJson:F("import",["data"]),updatesStatus:F("updates_status"),updatesRun:F("updates_run",["what"])};var Vt={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 St(s,t="dl-icon"){let n=Vt[s]??Vt.phone;return``}function v(s,t="dl-icon"){let n=document.createElement("span");return n.className="dl-icon-wrap",n.innerHTML=St(s,t),n}function z(s,t,n="neutral",a={}){let{disabled:i,...o}=a,r=e("button",{class:`cbi-button cbi-button-${n}`,type:"button",...o,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!r.disabled){r.disabled=!0,r.classList.add("spinning");try{await t(l)}catch(d){X(Mt(d),"error")}finally{r.disabled=!1,r.classList.remove("spinning")}}}},s);return r.disabled=!!i,r}function we(s,t,n,a="neutral",i=""){return z([v(s),e("span",{class:"dl-btn-label"},t)],n,a,{title:t,class:`cbi-button cbi-button-${a} dl-icon-btn ${i}`.trim()})}function X(s,t="info",n=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 i=t==="error"?"x":t==="warning"?"alert":t==="success"?"check":null,o=()=>{r.classList.remove("show"),setTimeout(()=>r.remove(),200)},r=e("div",{class:`dl-toast ${t}`},[i?v(i):"",e("span",{},s),t==="error"?e("button",{type:"button","aria-label":"Close",click:o},v("x")):""]);a.appendChild(r),requestAnimationFrame(()=>r.classList.add("show")),setTimeout(o,n||(t==="error"?8e3:t==="warning"?5e3:2600))}function Mt(s){return s instanceof Error?s.message:String(s)}async function U(s,t){try{let n=await s();return t&&X(t,"success",3500),n}catch(n){X(Mt(n),"error",1e4);return}}function ne(s,t,n,a=""){ui.showModal(s,[e("div",{class:`dl-modal ${a}`},t),e("div",{class:"button-row"},n)])}function J(){ui.hideModal()}function ae(s,t,n="Confirm",a=!1){return new Promise(i=>{ne(s,t,[e("button",{class:"cbi-button cbi-button-neutral",type:"button",click:()=>{J(),i(!1)}},"Cancel")," ",e("button",{class:`cbi-button ${a?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{J(),i(!0)}},n)])})}async function de(s,t="Copied to clipboard"){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(s);else{let n=e("textarea",{style:"position:fixed;opacity:0"},s);document.body.appendChild(n),n.select(),document.execCommand("copy"),n.remove()}X(t,"success",2500)}catch(n){X(Mt(n),"error")}}function fe(s,t,n="text/plain"){let a=globalThis,i=typeof t=="string"?new a.Blob([t],{type:n}):t,o=URL.createObjectURL(i),r=e("a",{href:o,download:s,style:"display:none"});document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(o),r.remove()},1e3)}function De(s,t){let n={ok:"success",warn:"warning",error:"error",info:"notice"}[s];return e("div",{class:`alert-message ${n}`},t)}function Ae(s,t=""){let n=e("div",{class:t});return n.innerHTML=s,n}function Et(s,t){return new Promise(n=>{let a=e("input",{type:"file",accept:s,style:"display:none"});a.addEventListener("cancel",()=>{a.remove(),n(null)}),a.addEventListener("change",()=>{let i=a.files?.[0];if(a.remove(),!i)return n(null);let o=new FileReader;o.onload=()=>{let r=String(o.result??"");n({name:i.name,data:t==="base64"?r.replace(/^data:[^,]*,/,""):r})},o.onerror=()=>n(null),t==="base64"?o.readAsDataURL(i):o.readAsText(i)}),document.body.appendChild(a),a.click()})}function ye(s,t){let n=document.querySelector(".dl-dd");if(n&&(n.dlClose?n.dlClose():n.remove(),n.dlAnchor===s))return;let a=e("div",{class:"dl-dd dl-root",role:"menu"},t.map(f=>f?e("button",{type:"button",role:"menuitem",class:f.danger?"danger":f.warn?"warn":"",click:()=>{g(),f.run()}},[f.icon??"",e("span",{},f.label)]):e("hr")));document.body.appendChild(a);let i=s.getBoundingClientRect(),o=a.offsetWidth,r=a.offsetHeight;a.style.top=`${i.bottom+6+r>window.innerHeight-8&&i.top-6-r>8?i.top-6-r:i.bottom+6}px`,a.style.left=`${Math.max(8,Math.min(i.right-o,window.innerWidth-o-8))}px`;let l=f=>{!a.contains(f.target)&&!s.contains(f.target)&&g()},d=f=>{f.key==="Escape"&&g()};a.dlAnchor=s,a.dlClose=g;function g(){a.remove(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",g,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",g,!0)}),a.querySelector("button")?.focus({preventScroll:!0})}var Xt=Cn(Zt(),1),In='';function je(s,t=3,n=!0){let a=(0,Xt.default)(0,s.length>300?"Q":"H");a.addData(s,"Byte"),a.make();let i=a.getModuleCount(),o=i+t*2,r=n?Math.round(i*.22):0;r&&(i-r)%2&&r++;let l=(i-r)/2,d=l+r,g=(k,b)=>r>0&&k>=l&&k=l&&b${In}`}return`${c}`}var Bn={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:""},jn={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 On(s){let t={};for(let[n,a]of Object.entries(jn))s[n]!=null&&s[n]!==""&&(t[a]=String(s[n]));return t}function Un(s,t){let n=s.amnezia,a=n.obfuscation??{},i=d=>a[d]!=null&&a[d]!==""?String(a[d]):Bn[d],o=n.host.replace(/^\[(.*)\]$/,"$1"),r={H1:i("h1"),H2:i("h2"),H3:i("h3"),H4:i("h4"),I1:i("i1"),I2:i("i2"),I3:i("i3"),I4:i("i4"),I5:i("i5"),Jc:i("jc"),Jmin:i("jmin"),Jmax:i("jmax"),S1:i("s1"),S2:i("s2"),S3:i("s3"),S4:i("s4"),...On(a),allowed_ips:n.allowed_ips,client_ip:n.client_ip,client_priv_key:n.client_priv_key,client_pub_key:n.client_pub_key,config:s.conf.replace(/\r?\n/g,`\r -`),hostName:o,mtu:n.mtu,persistent_keep_alive:n.persistent_keep_alive,port:Number(n.port),psk_key:n.psk_key,server_pub_key:n.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(r),port:String(n.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:o};return n.dns[0]&&(l.dns1=n.dns[0]),n.dns[1]&&(l.dns2=n.dns[1]),l}function qn(s){let t="";for(let n=0;n"u")return null;try{let n=new t.Blob([s]).stream().pipeThrough(new t.CompressionStream("deflate")),a=new Uint8Array(await new t.Response(n).arrayBuffer()),i=new Uint8Array(4+a.length);return new DataView(i.buffer).setUint32(0,s.length,!1),i.set(a,4),i}catch{return null}}async function en(s,t,n=!0){let a=new TextEncoder().encode(JSON.stringify(Un(s,t))),i=n?await Gn(a):null;return`vpn://${qn(i??a)}`}function K(s){if(!s||s<0)return"0 B";let t=["B","KB","MB","GB","TB"],n=0,a=s;for(;a>=1024&&n=100||n===0?Math.round(a):a.toFixed(1)} ${t[n]}`}function ke(s){let t=s*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 ce(s,t=Date.now()/1e3){if(!s)return"never";let n=Math.max(0,Math.round(t-s));return n<60?"just now":n<3600?`${Math.floor(n/60)} min ago`:n<86400?`${Math.floor(n/3600)} h ago`:n<86400*30?`${Math.floor(n/86400)} d ago`:new Date(s*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function tn(s){if(!s||s<0)return"—";let t=Math.floor(s/86400),n=Math.floor(s%86400/3600),a=Math.floor(s%3600/60);return t?`${t}d ${n}h`:n?`${n}h ${a}m`:`${a}m`}function Pe(s){let t=new Date(s*1e3),n=new Date,a=t.toDateString()===n.toDateString(),i=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return a?i:`${t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${i}`}function $e(s){if(!s)return"";let[t,n,a]=s.split("-").map(Number);return new Date(t,n-1,a).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function Ne(s,t=Date.now()){if(!s)return null;let[n,a,i]=s.split("-").map(Number),o=new Date(n,a-1,i,23,59,59).getTime();return Math.ceil((o-t)/864e5)}var Oe={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var nn=["computer","phone","tablet","router","other"],_e={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Tt={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function ze(s){let t=s.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let n=t[0][0]??"",a=t.length>1?t[t.length-1][0]??"":t[0][1]??"";return(n+a).toUpperCase()}function st(s){let t=n=>n.disabled?3:n.online?0:n.handshake?1:2;return s.map((n,a)=>[n,a]).sort((n,a)=>t(n[0])-t(a[0])||n[1]-a[1]).map(([n])=>n)}var an="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl",Wn="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",Fn="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",Kn={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Ye=null;function Vn(s){let t=window;return s.appendChild(e("link",{rel:"stylesheet",href:`${an}.css`})),t.maplibregl?Promise.resolve(t.maplibregl):Ye||(Ye=new Promise((n,a)=>{let i=e("script",{src:`${an}.js`});i.onload=()=>t.maplibregl?n(t.maplibregl):a(new Error("MapLibre failed to load")),i.onerror=()=>{Ye=null,a(new Error("Could not load the map library (no internet access from this browser?)"))},s.appendChild(i)}),Ye)}function ot(){let s=document.documentElement.getAttribute("data-darkmode");return s!=null?s==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}function Yn(s,t,n=48){let a=(s[0]+t[0])/2,i=(s[1]+t[1])/2,o=t[0]-s[0],r=t[1]-s[1],l=Math.hypot(o,r)||1,d=Math.min(.25*l,12),g=a-r/l*d,f=i+o/l*d,c=[];for(let k=0;k<=n;k++){let b=k/n,R=1-b;c.push([R*R*s[0]+2*R*b*g+b*b*t[0],R*R*s[1]+2*R*b*f+b*b*t[1]])}return c}function Jn(s,t){let n=new Map;for(let a of s.geo.points){if(s.person&&a.person!==s.person||(t==="online"?!a.online:s.now-a.ts>Kn[t]))continue;let i=n.get(a.device);(!i||a.online&&!i.online||a.online===i.online&&a.ts>i.ts)&&n.set(a.device,a)}return[...n.values()]}var Ue=class{constructor(t,n="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=n,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 Vn(this.el)}catch(n){this.status.textContent=n.message;return}this.map=new this.gl.Map({container:this.el,style:ot()?Wn:Fn,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",ot()?"#ededed":"#0d0d0d"],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],"#40c977",ot()?"#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":ot()?"#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]],n=-1,a=0,i=o=>{this.map&&(o-a>70&&(a=o,n=(n+1)%t.length,this.map.getLayer("dl-arc-flow")&&this.map.setPaintProperty("dl-arc-flow","line-dasharray",t[n])),this.anim=requestAnimationFrame(i))};this.anim=requestAnimationFrame(i)}groups(t){let n=new Map;for(let a of t){let i=`${a.asn||a.org||a.ip}|${a.city}|${a.cc}`,o=n.get(i);o||(o={key:i,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:[]},n.set(i,o)),o.points.push(a),o.online||(o.online=a.online),o.ts=Math.max(o.ts,a.ts)}return[...n.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let t=this.data,n=this.groups(Jn(t,this.range)),a=t.geo.home;for(let r of this.markers)r.remove();this.markers=[];let i=new Map,o=n.map(r=>{let l=`${r.lat.toFixed(2)},${r.lon.toFixed(2)}`,d=i.get(l)??0;return i.set(l,d+1),{g:r,at:[r.lon+d*.25,r.lat]}});if(this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:o.map(({g:r,at:l})=>({type:"Feature",properties:{online:r.online},geometry:{type:"Point",coordinates:l}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:a?o.map(({g:r,at:l})=>({type:"Feature",properties:{online:r.online},geometry:{type:"LineString",coordinates:Yn([a.lon,a.lat],l)}})):[]}),a){let r=e("div",{class:"dl-mk-home",title:`Home router${a.city?` · ${a.city}`:""}${a.org?` · ${a.org}`:""}`});r.innerHTML=St("home","dl-mk-home-ic"),this.markers.push(new this.gl.Marker({element:r}).setLngLat([a.lon,a.lat]).addTo(this.map))}for(let{g:r,at:l}of o){let d=r.points.length,g=e("button",{type:"button",class:`dl-mk${r.online?" online":""}${d>1?" multi":""}`,"aria-label":`${d} device${d===1?"":"s"} via ${r.org||"unknown network"} in ${r.city||"unknown city"}`},d>1?e("span",{class:"dl-mk-count"},String(d)):e("span",{class:"dl-mk-dot"})),c=!!a&&Math.abs(l[0]-a.lon)<.02&&Math.abs(l[1]-a.lat)<.02?[22,-16]:[0,0];g.addEventListener("click",k=>{k.stopPropagation(),this.openPopup(r,l,c)}),this.markers.push(new this.gl.Marker({element:g,offset:c}).setLngLat(l).addTo(this.map))}if(!this.fitted){let r=o.map(l=>l.at);a&&(r.length===0||this.range!=="online"||o.some(l=>l.g.online))&&r.push([a.lon,a.lat]),this.fit(r),this.fitted=!0}this.status.textContent=o.length||a?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none"}fit(t){if(!t.length)return;let n=(d,g)=>{let f=Math.PI/180,c=(g[1]-d[1])*f,k=(g[0]-d[0])*f,b=Math.sin(c/2)**2+Math.cos(d[1]*f)*Math.cos(g[1]*f)*Math.sin(k/2)**2;return 12742*Math.asin(Math.sqrt(b))},a=[t.reduce((d,g)=>d+g[0],0)/t.length,t.reduce((d,g)=>d+g[1],0)/t.length],i=t;if(t.length>=5){let d=[...t].sort((g,f)=>n(a,g)-n(a,f));i=d.slice(0,Math.ceil(d.length*.9))}if(Math.max(...i.map(d=>n(a,d)))<25){this.map.jumpTo({center:a,zoom:9.5});return}let r=new this.gl.LngLatBounds(i[0],i[0]);i.forEach(d=>r.extend(d));let l=this.el.clientHeight||380;this.map.fitBounds(r,{padding:{top:Math.min(90,l/4),bottom:Math.min(70,l/5),left:60,right:60},maxZoom:9,duration:0})}openPopup(t,n,a=[0,0]){let i=this.data;this.popup?.remove();let o=[t.city,t.cc||t.country].filter(Boolean).join(", "),r=[...new Set(t.points.map(f=>f.person))],l=t.points.sort((f,c)=>Number(c.online)-Number(f.online)||c.ts-f.ts).map(f=>{let c=i.people.find(b=>b.id===f.person),k=c?.devices.find(b=>b.id===f.device);return e("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(f.person,f.device)},[e("span",{class:`dl-pop-dot${f.online?" on":""}`}),e("span",{class:"dl-pop-name"},[e("b",{},c?.name??f.person),` · ${k?.name??"device"}`]),e("span",{class:"dl-faint dl-nowrap"},f.online?"now":ce(f.ts,i.now))])}),d=e("div",{class:"dl-pop"},[e("div",{class:"dl-pop-head"},[e("span",{class:"dl-pop-net"},v("globe")),e("div",{class:"dl-stack"},[e("strong",{},t.org||"Unknown network"),e("span",{class:"dl-faint"},[t.asn?`AS${t.asn} · `:"",o?`${o} · approximate`:"approximate location"])])]),e("div",{class:"dl-pop-list"},l),r.length===1?e("div",{class:"dl-pop-actions"},[e("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(r[0])},`Open ${i.people.find(f=>f.id===r[0])?.name??"person"}`)]):""]),g=this.el.clientHeight||380;this.map.easeTo({center:n,offset:[0,Math.min(140,g*.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(n).setDOMContent(d).addTo(this.map)}};function rt(s,t,n=!0){let a=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],i=e("div",{class:"dl-seg",role:"tablist"});for(let[o,r]of a)o==="online"&&!n||i.appendChild(e("button",{type:"button",role:"tab",class:o===s?"on":"","data-v":o,click:()=>{i.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===o)),t(o)}},r));return i}var Re=null;function le(s,t){let n=a=>{Re??(Re=document.body.appendChild(e("div",{class:"dl-tip dl-tip-float dl-root"}))),Re.replaceChildren(...t().map(i=>typeof i=="string"?document.createTextNode(i):i)),Re.style.display="",Re.style.left=`${a.clientX}px`,Re.style.top=`${a.clientY-10}px`};s.addEventListener("mouseenter",n),s.addEventListener("mousemove",n),s.addEventListener("mouseleave",()=>Re&&(Re.style.display="none"))}function sn(s,t=120,n=26){let a=Math.max(1,...s),i=e("div",{class:"dl-spark"});i.style.width=`${t}px`,i.style.height=`${n}px`;let o=Date.now();return s.forEach((r,l)=>{let d=e("i");d.style.height=`${Math.max(6,r/a*100)}%`,r||d.classList.add("zero");let g=s.length-1-l,f=new Date(o-g*864e5);le(d,()=>[e("div",{class:"dl-tip-title"},g===0?"Today":g===1?"Yesterday":f.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),e("div",{class:"dl-muted"},K(r))]),i.appendChild(d)}),i}var rn=[{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"}],qe=s=>rn.find(t=>t.id===s),Qn={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)."};function on(s,t){return e("span",{class:"dl-dots",title:`${t}: ${s} of 4`},[e("span",{class:"dl-dots-label"},t),e("span",{class:"dl-dots-row"},[0,1,2,3].map(n=>e("i",{class:ndom.content(i,rn.map(r=>{let l=!r.needs||s[r.needs],d=r.id===t;return e("button",{type:"button",role:"radio","aria-checked":d?"true":"false","aria-disabled":l?null:"true",class:`dl-method${d?" on":""}${l?"":" off"}`,click:()=>{!l||d||(t=r.id,o(),n(r.id))}},[e("div",{class:"dl-method-head"},[e("span",{class:"dl-method-ic"},v(r.ic)),e("b",{},r.title),r.id===a?e("span",{class:"dl-pill ok"},"Current"):""]),e("p",{},r.text),e("div",{class:"dl-method-meters"},[on(r.stealth,"Stealth"),on(r.speed,"Speed")]),e("div",{class:"dl-method-foot"},l?[v("phone"),e("span",{},r.apps)]:[v("alert"),e("span",{},Qn[r.needs])])])}));return o(),i}function Je(s){return`${L.url("admin/network/dawnline/server")}?${s?`server=${encodeURIComponent(s)}&`:""}section=people`}function ve(s,t){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(s)}${t?`&device=${encodeURIComponent(t)}`:""}`}var Zn={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"},Xn={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 ea(s,t){return t.device?s.people.flatMap(a=>a.devices).find(a=>a.id===t.device)?.kind??t.dkind??"other":Xn[t.type]??"activity"}var ta=["person_added","person_removed","person_changed","paused_all","resumed_all"];function be(s){return s.by?s.by:ta.includes(s.type)||s.detail==="by admin"||s.detail?.endsWith(" (admin)")?"admin":s.detail?.endsWith(" (portal)")?"portal":null}function na(s){return(s.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}function Dt(s,t){let n=s.people.find(b=>b.id===t.person),a=n?.name??t.pname??t.person??"",i=n?.devices.find(b=>b.id===t.device)?.name??t.dname??"",o=b=>e("b",{},b),r=b=>e("span",{class:"dl-muted"},b),l=b=>e("span",{class:"dl-mono"},b),d=b=>e("span",{class:"dl-ev-kind"},`${b} `),g=i?`${a} · ${i}`:a,f=na(t),c=f||i||"a device",k=b=>[e("span",{class:"dl-you"},"You"),r(` ${b} `)];if(be(t)==="admin")switch(t.type){case"device_added":return[...k("added"),d("device"),o(c),r(" for "),o(a)];case"device_removed":return[...k("removed"),d("device"),o(c),r(" from "),o(a)];case"paused":return[...k("paused"),d("person"),o(a)];case"resumed":return[...k("resumed"),d("person"),o(a)];case"device_changed":{let b=f.startsWith("renamed from ");return[...k(b?"renamed":f),d("device"),o(i||"a device"),r(" of "),o(a),...b?[r(` · was ${f.slice(13)}`)]:[]]}case"device_keys":return[...k("issued new keys for"),d("device"),o(c),r(" of "),o(a),r(" · it needs its new configuration")];case"link_changed":return[...k("issued a new link for"),d("person"),o(a),r(" · the old link stopped working")];case"paused_all":return[e("span",{class:"dl-you"},"You"),r(" paused everyone")];case"resumed_all":return[e("span",{class:"dl-you"},"You"),r(" resumed everyone")]}switch(t.type){case"connect":return[d("Device"),o(g),r(" connected"),...t.detail?[r(" from "),l(t.detail)]:[],...t.where?[r(` · ${t.where}`)]:[]];case"disconnect":return[d("Device"),o(g),r(" went offline")];case"roam":return[d("Device"),o(g),r(" changed network "),l(t.detail??"")];case"device_added":return[d("Person"),o(a),r(" added "),d("device"),o(c),...be(t)==="portal"?[r(" on their portal")]:[]];case"device_removed":return[d("Person"),o(a),r(" removed "),d("device"),o(c),...be(t)==="portal"?[r(" on their portal")]:[]];case"device_keys":return[d("Person"),o(a),r(" issued new keys for "),d("device"),o(c),r(" on their portal")];case"person_added":return[...k("added"),d("person"),o(t.detail??a)];case"person_removed":return[...k("removed"),d("person"),o(t.detail??a)];case"person_changed":return[...k("changed"),d("person"),o(a),...f?[r(` · ${f.replace(/_/g," ")}`)]:[]];case"paused":return[d("Person"),o(a),r(` paused — ${t.detail??""}`)];case"resumed":return[d("Person"),o(a),r(" resumed"),...t.detail&&t.detail!=="active"?[r(` — ${t.detail}`)]:[]];case"paused_all":return[r("Everyone paused")];case"resumed_all":return[r("Everyone resumed")];case"portal_blocked":return[e("b",{class:"dl-sys-src"},"Personal portal"),r(" blocked "),l(t.detail??""),r(" for 15 min after too many wrong codes")];case"devices_removed":return[d("Person"),o(a),r(" — all devices removed, end date reached")];default:return[r(`${t.type}${t.detail?`: ${t.detail}`:""}`)]}}var aa={portal_blocked:["globe","bad"]};function ia(s,t){if(s.servers.length<2||!t.person)return"";let n=s.people.find(i=>i.id===t.person),a=n&&s.servers.find(i=>i.id===n.server);return a?e("span",{class:"dl-ev-srv",title:"Server"},a.name):""}function He(s,t,n={}){let a=aa[t.type],i=be(t);return e("div",{class:`dl-row${i==="admin"?" dl-ev-by-admin":a?` dl-ev-by-system ${a[1]}`:""}`},[i==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):a?e("span",{class:"dl-ev-tile sys"},v(a[0])):e("span",{class:`dl-ev-tile ev ${Zn[t.type]??""}`},v(ea(s,t))),e("span",{class:"dl-row-main"},Dt(s,t)),n.server===!1?"":ia(s,t),e("span",{class:"dl-faint dl-nowrap",title:new Date(t.ts*1e3).toLocaleString()},ce(t.ts,s.now))])}function sa(s){let t=[],n=(i,o)=>e("a",{href:i},o);for(let i of s.servers)i.enabled&&!i.up&&t.push({tone:"bad",text:[`Tunnel ${i.ifname} is down. `,n(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});s.settings.paused_all&&t.push({tone:"warn",text:["Everyone is paused."]});for(let i of s.people)if(i.state==="quota")t.push({tone:"warn",text:[n(ve(i.id),i.name)," reached the data limit."]});else if(i.state==="expired")t.push({tone:"warn",text:[n(ve(i.id),i.name),"’s access has ended."]});else{let o=Ne(i.expires);o!=null&&o>=0&&o<=Math.max(i.expire_warn,3)&&t.push({tone:"",text:[n(ve(i.id),i.name),`’s access ends in ${o} day${o===1?"":"s"}.`]}),i.quota_limit&&i.quota_used>=i.quota_limit*.9&&t.push({tone:"",text:[n(ve(i.id),i.name)," has used 90% of the data limit."]})}let a=s.people.flatMap(i=>i.devices.filter(o=>o.config_stale).map(o=>[i,o]));return a.length&&t.push({tone:"warn",text:a.length===1?[n(ve(a[0][0].id,a[0][1].id),`${a[0][0].name} · ${a[0][1].name}`)," needs its configuration again."]:[`${a.length} devices need their configuration again (networks or DNS changed).`]}),s.servers.some(i=>i.lan_like)&&s.like_home.error&&t.push({tone:"warn",text:[`Internet through the LAN is off: ${s.like_home.error} `,n(L.url("admin/network/dawnline/diagnostics"),"Details")]}),s.settings.portal_enabled||t.push({tone:"",text:["The personal portal is off. ",n(L.url("admin/network/dawnline/settings"),"Turn on")]}),t}function lt(s,t){let n=s.servers.find(d=>d.id===t)??s.servers[0],a=s.people.filter(d=>d.server===n.id),i=new Set(a.map(d=>d.id)),o=a.flatMap(d=>d.devices),r=d=>a.reduce((g,f)=>{let c=d(f);return[g[0]+c[0],g[1]+c[1]]},[0,0]),l=n.series?.[n.series.length-1];return{...s,servers:[n],people:a,series:n.series??s.series,events:s.events.filter(d=>d.person?i.has(d.person):!0),geo:{...s.geo,points:s.geo.points.filter(d=>i.has(d.person))},totals:{people:a.length,devices:o.length,online:o.filter(d=>d.online).length,active:a.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:r(d=>d.month)}}}var dt=class{constructor(t,n){this.srvId=t;this.go=n;this.el=e("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(t){this.st=lt(t,this.srvId);for(let n of["health","bento","side","activity"])this.parts[n]=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){this.st=lt(t,this.srvId),this.paint(),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let t=await N.health().catch(()=>null);if(!t)return;let n=t.checks.filter(o=>o.status==="warn"||o.status==="error");if(!n.length){dom.content(this.parts.health,"");return}let a=n.filter(o=>o.status==="error").length,i=`${n.length} ${a?n.length===1?"problem":"problems":n.length===1?"warning":"warnings"}`;dom.content(this.parts.health,e("div",{class:`dl-healthstrip ${a?"bad":"warn"}`},[e("span",{class:"dl-healthstrip-title"},[v("alert"),i]),...n.slice(0,3).map(o=>{let r=e("span",{class:"dl-healthstrip-item"},o.title);return le(r,()=>[e("div",{class:"dl-tip-title"},o.title),e("div",{class:"dl-muted"},o.detail)]),r}),n.length>3?e("span",{class:"dl-sub"},`+${n.length-3} more`):"",e("a",{href:L.url("admin/network/dawnline/diagnostics")},n.some(o=>o.fix)?"Fix in Diagnostics →":"Open Diagnostics →")]))}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let t=this.st,n=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"}),rt(this.range,o=>{this.range=o,this.map?.setRange(o)})]);if(!t.geo.enabled)return e("div",{class:"dl-panel flush"},[n,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 Ue({openPerson:o=>location.href=ve(o),openDevice:(o,r)=>location.href=ve(o,r)},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"])]),i=e("div",{class:"dl-map-wrap"},[this.map.el,a]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[n,i])}paint(){let t=this.st,n=t.servers[0],a=t.people.reduce((l,d)=>l+Math.max(0,d.device_limit-d.devices.length),0),i=t.people.flatMap(l=>l.devices.filter(d=>d.online));dom.content(this.parts.bento,e("div",{class:"dl-bento"},[this.onlineTile(i),this.speedTile(),this.disguiseTile(n),this.monthTile(a)]));let o=sa(t);dom.content(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")]),o.length?o.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)])):e("div",{class:"dl-row dl-muted"},[v("check"),"All good. Nothing needs you right now."])]));let r=[...t.events].reverse().slice(0,8);dom.content(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")]),r.length?r.map(l=>He(t,l)):e("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]))}onlineTile(t){let n=this.st,a=12,i=B=>B.spark[B.spark.length-1]??0,o=B=>n.geo.points.find(w=>w.device===B.id&&w.city)?.city,r=B=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(B.endpoint??""),l=B=>(r(B)?"home":o(B))??"",d=B=>[...n.events].reverse().find(w=>w.type==="connect"&&w.device===B.id)?.ts??0,g=n.people.map(B=>({p:B,devs:B.devices.filter(w=>w.online).sort((w,D)=>i(D)-i(w))})).filter(B=>B.devs.length).sort((B,w)=>w.devs.reduce((D,E)=>D+i(E),0)-B.devs.reduce((D,E)=>D+i(E),0)),f=g.length<=2,c=({p:B,devs:w})=>{let D=w.map(d).filter(Boolean),E=D.length?Math.min(...D):0,M=(B.rate??[]).slice(-15),u=M[M.length-1],$=u&&n.now-u[0]<180?u:null,h=200,p=30,T=Math.max(1,...M.map(H=>Math.max(H[1],H[2]))),m=H=>M.map((Z,ee)=>`${M.length>1?ee/(M.length-1)*h:h},${p-2-Z[H]/T*(p-6)}`),y=M.length>1?Ae(``):"",P=!$||$[1]<64&&$[2]<64,O=B.access==="both"?["home","globe"]:B.access==="lan"?["home"]:["globe"];return[e("div",{class:"dl-hc"},[e("div",{class:"dl-hc-head"},[e("span",{class:"dl-onl-av sm"},ze(B.name)),e("span",{class:"dl-stack"},[e("b",{},B.name),e("span",{class:"dl-hc-since"},E?`online for ${ce(E,n.now).replace(" ago","")}`:"online")]),e("span",{class:"dl-hc-reach"},O.map(H=>e("span",{class:`dl-ibadge ${H==="home"?"lan":"inet"}`},v(H))))]),e("div",{class:"dl-hc-speed"},[e("div",{class:"dl-hc-speed-row"},P?[e("span",{class:"dl-faint"},"Idle right now")]:[e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${ke($[2])}`]),e("span",{},[e("span",{class:"dl-up"},"↑"),` ${ke($[1])}`]),e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint"},"15 min")]),y]),e("div",{class:"dl-hc-devs"},w.map(H=>e("span",{class:"dl-hc-dev"},[v(H.kind),[H.name,l(H)].filter(Boolean).join(" · ")]))),e("div",{class:"dl-hc-foot"},[e("span",{class:"dl-faint"},`${K(w.reduce((H,Z)=>H+i(Z),0))} today · ${K(B.month[0]+B.month[1])} this month`)])])]},k=B=>{let{p:w,devs:D}=B,E=e("span",{class:"dl-onl-dev"},D.length>1?String(D.length):v(D[0].kind)),M=e("a",{class:`dl-onl-p${f?"":" sm"}`,href:ve(w.id),"aria-label":`${w.name}, online`},[e("span",{class:"dl-onl-av"},[ze(w.name),E]),f?e("span",{class:"dl-onl-name"},w.name):"",f?e("span",{class:"dl-onl-meta"},[...D.slice(0,3).map(u=>v(u.kind)),D.length>3?`+${D.length-3}`:"",l(D[0])?e("span",{},` · ${l(D[0])}`):""]):""]);return le(M,()=>c(B)),M},b=e("b",{class:`dl-onl-count${g.length?"":" none"}`},String(g.length)),R=g.reduce((B,w)=>B+w.devs.length,0);g.length&&le(b,()=>[`${g.length} ${g.length===1?"person":"people"} · ${R} device${R===1?"":"s"}`]);let Y=g.length>a?g.slice(0,a-1):g,V=n.people.flatMap(B=>B.devices.map(w=>({p:B,d:w}))).filter(B=>B.d.handshake).sort((B,w)=>w.d.handshake-B.d.handshake)[0];return e("div",{class:"dl-bento-tile online"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Online"),b]),g.length?e("div",{class:`dl-onl-row${f?"":" grid"}`},[...Y.map(k),g.length>a?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:B=>{this.go&&(B.preventDefault(),this.go("people","online"))}},[e("span",{class:"dl-onl-av"},`+${g.length-Y.length}`)]):""]):e("div",{class:"dl-onl-empty"},[e("span",{},"Nobody is connected"),V?e("span",{class:"dl-sub"},`Last: ${V.p.name}, ${ce(V.d.handshake,n.now)}`):e("span",{class:"dl-sub"},"No device has connected yet")])])}speedTile(){return At(this.st.servers[0]?.rate??[],this.st.now,this.st.totals.today)}disguiseTile(t){let n=qe(t.preset),a=t.obf??{},i=(l,d)=>e("span",{class:`dl-segs ${d}`},[0,1,2,3].map(g=>e("i",{class:g+a[l]).map(l=>`${l.toUpperCase()} ${a[l]}`);return r.length&&o.push(r.slice(0,2).join(" · ")+(r.length>2?` +${r.length-2}`:"")),["h1","h2","h3","h4"].some(l=>a[l]&&a[l]!==String(["h1","h2","h3","h4"].indexOf(l)+1))&&o.push("H1–H4 random"),a.i1&&o.push(a.i1.includes("0x8580")?"DNS-like first packet":"Signature packets"),a.header_protection_key&&o.push("Encrypted headers"),o.length||o.push(n?.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(t.id)}§ion=disguise`},"Change")]),e("div",{class:"dl-disg-id"},[e("span",{class:"dl-disg-ic"},v(n?.ic??"shield")),e("span",{class:"dl-stack"},[e("b",{},n?n.title:"Custom"),e("span",{class:"dl-sub"},n?n.short:"Set by hand")])]),n?e("div",{class:"dl-disg-meters"},[e("span",{},"Stealth"),i(n.stealth,"acc"),e("span",{},"Speed"),i(n.speed,"ok")]):"",e("div",{class:"dl-disg-chips"},o.map(l=>e("span",{},l)))])}monthTile(t){let n=this.st.totals,a=this.st.people.filter(i=>i.state!=="active").length;return Pt(this.st.series,`${n.people} ${n.people===1?"person":"people"}${a?` · ${a} paused`:""} · ${t} device slot${t===1?"":"s"} free`)}};function At(s,t,n){let a=s.slice(-15),i=a[a.length-1],o=i&&t-i[0]<180,r=o?i[2]:0,l=o?i[1]:0,[d,g]=n,f=200,c=40,k=Math.max(1,...a.map(w=>Math.max(w[1],w[2]))),b=w=>a.map((D,E)=>`${a.length>1?E/(a.length-1)*f:f},${c-2-D[w]/k*(c-6)}`),R=b(2),Y=b(1),V=a.length>1?Ae(``):e("div",{class:"dl-speed-wait"},[e("i"),e("span",{},"Collecting… 1 point a minute")]),B=(w,D,E,M)=>e("div",{class:"dl-speed-col"},[e("span",{class:"dl-sub"},[e("span",{class:E},D),` ${w}`]),e("span",{class:"dl-speed-val"},ke(M))]);return a.length>1&&le(V,()=>{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",{},`↓ ${ke(w[2])} · ↑ ${ke(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"},[B("Download","↓","dl-dn",r),B("Upload","↑","dl-up",l)]),V,e("div",{class:"dl-speed-today"},[e("span",{},["Today ",e("b",{},K(d+g))]),e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${K(g)} `,e("span",{class:"dl-up"},"↑"),` ${K(d)}`])])])}function Pt(s,t){let n=s.slice(-30),a=n.map(g=>g.rx+g.tx),i=Math.max(1,...a),o=a.reduce((g,f)=>g+f,0),r=a.reduce((g,f,c)=>f>a[g]?c:g,0),l=g=>new Date(`${g}T12:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"}),d=e("div",{class:"dl-bento-bars"},n.map((g,f)=>{let c=a[f],k=e("i",{class:f===n.length-1?"hi":"",style:`height:${Math.max(4,c/i*100)}%`});return le(k,()=>[e("div",{class:"dl-tip-title"},f===n.length-1?`Today · ${l(g.day)}`:l(g.day)),e("div",{},K(c)),e("div",{class:"dl-muted dl-mono"},`↓ ${K(g.tx)} ↑ ${K(g.rx)}`)]),k}));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"},K(o))]),a[r]>0?e("span",{class:"dl-sub"},`peak ${K(a[r])} · ${l(n[r].day)}`):""]),n.length?d:e("p",{class:"dl-muted"},"No traffic yet."),e("div",{class:"dl-bento-head"},[e("span",{class:"dl-sub"},n.length?l(n[0].day):""),e("span",{class:"dl-sub"},t),e("span",{class:"dl-sub"},"today")])])}var oa={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"},Qe=["connections","people","problems"],Ge={connections:"Connections",people:"People",problems:"Problems"},ln={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)"},ct=s=>oa[s]??"problems";function ra(s){let t=new Map(s.people.map(a=>[a.id,a.name])),n=new Map(s.people.flatMap(a=>a.devices.map(i=>[i.id,i.name])));return{people:t,devices:n}}function la(s){let t=s==null?"":String(s);return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}var pt={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"};function Le(s,t,n,a="",i=[]){let o=ra(s),r=[...t.map(c=>({ts:c.ts,category:ct(c.type),type:c.type,person:c.person?o.people.get(c.person)??c.pname??c.person:"",device:c.device?o.devices.get(c.device)??c.dname??c.device:"",detail:c.detail??"",where:c.where??"",by:be(c)??""})),...i.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:pt[c.src]??c.src,by:""}))].sort((c,k)=>c.ts-k.ts).map(({ts:c,...k})=>({time:new Date(c*1e3).toISOString(),...k})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${a?`-${a}`:""}-${l}.${n}`;if(n==="json"){fe(d,JSON.stringify(r,null,2),"application/json");return}let g=["time","category","type","person","device","detail","where","by"],f=[g.join(","),...r.map(c=>g.map(k=>la(c[k])).join(","))].join(` -`);fe(d,f,"text/csv")}var da=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]];function Te(s,t,n,a,i,o=!1){let r=e("select",{class:"cbi-input-select"},[e("option",{value:""},"All categories"),...Qe.map(d=>e("option",{value:d,selected:d===i?"selected":null},Ge[d])),o?e("option",{value:"system",selected:i==="system"?"selected":null},"System"):""]),l=e("select",{class:"cbi-input-select"},da.map(([d,g])=>e("option",{value:d},g)));ne(s,[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"),r]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Which events"),l])],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Clear",async()=>{let d=await U(async()=>{let g=o&&(r.value==="system"||r.value==="")?await N.serviceLogClear(l.value):{removed:0},f=r.value==="system"?{removed:0}:await N.logsClear({...n,category:r.value,older_days:l.value});return{removed:g.removed+f.removed}});d&&(J(),X(d.removed?`${d.removed} event${d.removed===1?"":"s"} removed`:"Nothing matched","success",3e3),a())},"negative")])}function We(s,t,n,a){let i=s==="device"?`Clears ${n}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:s==="person"?`Clears ${n}'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.";ne(s==="all"?"Reset all traffic history?":`Reset traffic history for ${n}?`,[e("p",{class:"dl-muted"},i)],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Reset",async()=>{await U(()=>N.usageClear(s,t),"Traffic history reset")&&(J(),a())},"negative")])}var ht=null;function ca(s){return s?new Date(s*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function dn(s,t,n=!1){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},s),e("button",{type:"button",class:`dl-kvrow-v copy${n?" dl-mono":""}`,title:"Copy",click:()=>de(t,`${s} copied`)},[e("span",{},t),v("copy")])])}function ut(s,t){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},s),e("span",{class:"dl-kvrow-v"},t)])}function cn(s,t){if(/^\s*\[.+\]\s*$/.test(s))return e("span",{class:"dl-conf-sec"},s);let n=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(s);if(!n)return document.createTextNode(s);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(s);return e("span",{},[e("span",{class:"dl-conf-k"},n[1])," ",a&&!t?e("span",{class:"dl-conf-mask"},"••••••••••••••••"):n[2]])}function pa(s){let t=!1,n=e("pre",{class:"dl-conf"}),a=()=>dom.content(n,s.conf.split(` +var An=Object.create;var Qt=Object.defineProperty;var Pn=Object.getOwnPropertyDescriptor;var Nn=Object.getOwnPropertyNames;var zn=Object.getPrototypeOf,Rn=Object.prototype.hasOwnProperty;var Hn=(i,t)=>()=>(t||i((t={exports:{}}).exports,t),t.exports);var In=(i,t,n,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Nn(t))!Rn.call(i,s)&&s!==n&&Qt(i,s,{get:()=>t[s],enumerable:!(a=Pn(t,s))||a.enumerable});return i};var Bn=(i,t,n)=>(n=i!=null?An(zn(i)):{},In(t||!i||!i.__esModule?Qt(n,"default",{value:i,enumerable:!0}):n,i));var nn=Hn((en,tn)=>{"use strict";var Xt=(function(){var i=function($,N){var C=236,T=17,y=$,A=n[N],m=null,h=0,P=null,f=[],_={},O=function(M,E){h=y*4+17,m=(function(x){for(var D=new Array(x),k=0;k=7&&W(M),P==null&&(P=Te(y,A,f)),le(P,E)},G=function(M,E){for(var x=-1;x<=7;x+=1)if(!(M+x<=-1||h<=M+x))for(var D=-1;D<=7;D+=1)E+D<=-1||h<=E+D||(0<=x&&x<=6&&(D==0||D==6)||0<=D&&D<=6&&(x==0||x==6)||2<=x&&x<=4&&2<=D&&D<=4?m[M+x][E+D]=!0:m[M+x][E+D]=!1)},B=function(){for(var M=0,E=0,x=0;x<8;x+=1){O(!0,x);var D=s.getLostPoint(_);(x==0||M>D)&&(M=D,E=x)}return E},S=function(){for(var M=8;M>x&1)==1;m[Math.floor(x/3)][x%3+h-8-3]=D}for(var x=0;x<18;x+=1){var D=!M&&(E>>x&1)==1;m[x%3+h-8-3][Math.floor(x/3)]=D}},te=function(M,E){for(var x=A<<3|E,D=s.getBCHTypeInfo(x),k=0;k<15;k+=1){var H=!M&&(D>>k&1)==1;k<6?m[k][8]=H:k<8?m[k+1][8]=H:m[h-15+k][8]=H}for(var k=0;k<15;k+=1){var H=!M&&(D>>k&1)==1;k<8?m[8][h-k-1]=H:k<9?m[8][15-k-1+1]=H:m[8][15-k-1]=H}m[h-8][8]=!M},le=function(M,E){for(var x=-1,D=h-1,k=7,H=0,V=s.getMaskFunction(E),K=h-1;K>0;K-=2)for(K==6&&(K-=1);;){for(var ie=0;ie<2;ie+=1)if(m[D][K-ie]==null){var ce=!1;H>>k&1)==1);var Q=V(D,K-ie);Q&&(ce=!ce),m[D][K-ie]=ce,k-=1,k==-1&&(H+=1,k=7)}if(D+=x,D<0||h<=D){D-=x,x=-x;break}}},de=function(M,E){for(var x=0,D=0,k=0,H=new Array(E.length),V=new Array(E.length),K=0;K=0?Vt.getAt(Yt):0}}for(var Jt=0,Q=0;QK*8)throw"code length overflow. ("+k.getLengthInBits()+">"+K*8+")";for(k.getLengthInBits()+4<=K*8&&k.put(0,4);k.getLengthInBits()%8!=0;)k.putBit(!1);for(;!(k.getLengthInBits()>=K*8||(k.put(C,8),k.getLengthInBits()>=K*8));)k.put(T,8);return de(k,D)};_.addData=function(M,E){E=E||"Byte";var x=null;switch(E){case"Numeric":x=p(M);break;case"Alphanumeric":x=u(M);break;case"Byte":x=c(M);break;case"Kanji":x=b(M);break;default:throw"mode:"+E}f.push(x),P=null},_.isDark=function(M,E){if(M<0||h<=M||E<0||h<=E)throw M+","+E;return m[M][E]},_.getModuleCount=function(){return h},_.make=function(){if(y<1){for(var M=1;M<40;M++){for(var E=l.getRSBlocks(M,A),x=d(),D=0;D"u"?M*4:E;var x="";x+='";for(var k=0;k<_.getModuleCount();k+=1)x+='"}return x+="",x+="
';x+="
",x},_.createSvgTag=function(M,E,x,D){var k={};typeof arguments[0]=="object"&&(k=arguments[0],M=k.cellSize,E=k.margin,x=k.alt,D=k.title),M=M||2,E=typeof E>"u"?M*4:E,x=typeof x=="string"?{text:x}:x||{},x.text=x.text||null,x.id=x.text?x.id||"qrcode-description":null,D=typeof D=="string"?{text:D}:D||{},D.text=D.text||null,D.id=D.text?D.id||"qrcode-title":null;var H=_.getModuleCount()*M+E*2,V,K,ie,ce,Q="",ge;for(ge="l"+M+",0 0,"+M+" -"+M+",0 0,-"+M+"z ",Q+=''+I(D.text)+"":"",Q+=x.text?''+I(x.text)+"":"",Q+='',Q+='"u"?M*4:E;var x=_.getModuleCount()*M+E*2,D=E,k=x-E;return j(x,x,function(H,V){if(D<=H&&H"u"?M*4:E;var D=_.getModuleCount()*M+E*2,k="";return k+="",k};var I=function(M){for(var E="",x=0;x":E+=">";break;case"&":E+="&";break;case'"':E+=""";break;default:E+=D;break}}return E},ae=function(M){var E=1;M=typeof M>"u"?E*2:M;var x=_.getModuleCount()*E+M*2,D=M,k=x-M,H,V,K,ie,ce,Q={"██":"█","█ ":"▀"," █":"▄"," ":" "},ge={"██":"▀","█ ":"▀"," █":" "," ":" "},fe="";for(H=0;H=k?ge[ce]:Q[ce];fe+=` +`}return x%2&&M>0?fe.substring(0,fe.length-x-1)+Array(x+1).join("▀"):fe.substring(0,fe.length-1)};return _.createASCII=function(M,E){if(M=M||1,M<2)return ae(E);M-=1,E=typeof E>"u"?M*2:E;var x=_.getModuleCount()*M+E*2,D=E,k=x-E,H,V,K,ie,ce=Array(M+1).join("██"),Q=Array(M+1).join(" "),ge="",fe="";for(H=0;H>>8),A.push(P&255)):A.push(T)}}return A}};var t={MODE_NUMBER:1,MODE_ALPHA_NUM:2,MODE_8BIT_BYTE:4,MODE_KANJI:8},n={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},s=(function(){var $=[[],[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]],N=1335,C=7973,T=21522,y={},A=function(m){for(var h=0;m!=0;)h+=1,m>>>=1;return h};return y.getBCHTypeInfo=function(m){for(var h=m<<10;A(h)-A(N)>=0;)h^=N<=0;)h^=C<5&&(P+=3+O-5)}for(var f=0;f=256;)y-=255;return $[y]},T})();function r($,N){if(typeof $.length>"u")throw $.length+"/"+N;var C=(function(){for(var y=0;y<$.length&&$[y]==0;)y+=1;for(var A=new Array($.length-y+N),m=0;m<$.length-y;m+=1)A[m]=$[m+y];return A})(),T={};return T.getAt=function(y){return C[y]},T.getLength=function(){return C.length},T.multiply=function(y){for(var A=new Array(T.getLength()+y.getLength()-1),m=0;m"u")throw"bad rs block @ typeNumber:"+y+"/errorCorrectionLevel:"+A;for(var h=m.length/3,P=[],f=0;f>>7-T%8&1)==1},C.put=function(T,y){for(var A=0;A>>y-A-1&1)==1)},C.getLengthInBits=function(){return N},C.putBit=function(T){var y=Math.floor(N/8);$.length<=y&&$.push(0),T&&($[y]|=128>>>N%8),N+=1},C},p=function($){var N=t.MODE_NUMBER,C=$,T={};T.getMode=function(){return N},T.getLength=function(m){return C.length},T.write=function(m){for(var h=C,P=0;P+2>>8&255)*192+(f&255),m.put(f,13),P+=2}if(P>>8)},N.writeBytes=function(C,T,y){T=T||0,y=y||C.length;for(var A=0;A0&&(C+=","),C+=$[T];return C+="]",C},N},w=function(){var $=0,N=0,C=0,T="",y={},A=function(h){T+=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 y.writeByte=function(h){for($=$<<8|h&255,N+=8,C+=1;N>=6;)A($>>>N-6),N-=6},y.flush=function(){if(N>0&&(A($<<6-N),$=0,N=0),C%3!=0)for(var h=3-C%3,P=0;P=N.length){if(y==0)return-1;throw"unexpected end of file./"+y}var h=N.charAt(C);if(C+=1,h=="=")return y=0,-1;if(h.match(/^\s$/))continue;T=T<<6|m(h.charCodeAt(0)),y+=6}var P=T>>>y-8&255;return y-=8,P};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 A},Y=function($,N){var C=$,T=N,y=new Array($*N),A={};A.setPixel=function(f,_,O){y[_*C+f]=O},A.write=function(f){f.writeString("GIF87a"),f.writeShort(C),f.writeShort(T),f.writeByte(128),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(0),f.writeByte(255),f.writeByte(255),f.writeByte(255),f.writeString(","),f.writeShort(0),f.writeShort(0),f.writeShort(C),f.writeShort(T),f.writeByte(0);var _=2,O=h(_);f.writeByte(_);for(var G=0;O.length-G>255;)f.writeByte(255),f.writeBytes(O,G,255),G+=255;f.writeByte(O.length-G),f.writeBytes(O,G,O.length-G),f.writeByte(0),f.writeString(";")};var m=function(f){var _=f,O=0,G=0,B={};return B.write=function(S,q){if(S>>>q)throw"length over";for(;O+q>=8;)_.writeByte(255&(S<>>=8-O,G=0,O=0;G=S<0&&_.writeByte(G)},B},h=function(f){for(var _=1<>6,128|o&63):o<55296||o>=57344?a.push(224|o>>12,128|o>>6&63,128|o&63):(s++,o=65536+((o&1023)<<10|n.charCodeAt(s)&1023),a.push(240|o>>18,128|o>>12&63,128|o>>6&63,128|o&63))}return a}return t(i)}})();(function(i){typeof define=="function"&&define.amd?define([],i):typeof en=="object"&&(tn.exports=i())})(function(){return Xt})});function Tt(i,t){return i==null||i===!1||i===""||(Array.isArray(i)?i.forEach(n=>Tt(n,t)):t.push(i instanceof Node?i:String(i))),t}function e(i,t,n){let a=window.E,s=t!=null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof Node);return!s&&n===void 0?a(i,{},Tt(t,[])):a(i,s?t:{},Tt(n,[]))}function J(i,t=[]){let n=rpc.declare({object:"luci.dawnline",method:i,params:t});return async(...a)=>{let s=await n(...a);if(s&&typeof s=="object"&&typeof s.error=="string")throw new Error(s.error);return s}}var jn=J("logs_clear",["person","device","category","older_days"]),On=(i={})=>jn(i.person??"",i.device??"",i.category??"",i.older_days??""),Un=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 qn(i,t){let a=[i,...["name","access","device_limit","expires","expire_action","expire_warn","quota_gb","quota_period","bonus_gb","hours","note","dns_mode"].map(o=>t[o]),t.paused,t.services,t.circle,t.home_nets],s=await Un(...a);if(s&&typeof s.error=="string")throw new Error(s.error);return s}var Wn=J("status",["days"]),Gn=0;async function Fn(i){let t=await Wn(i);return Gn=Date.now(),t}var z={personUpdate:qn,settingsGet:J("settings_get"),settingsUpdate:J("settings_update",["values"]),serviceSet:J("service_set",["id","name","address","ports"]),serviceDelete:J("service_delete",["id"]),geoClear:J("geo_clear"),events:J("events",["limit"]),logsClear:On,interfaces:J("interfaces",["id"]),serverInterfaces:J("server_interfaces",["id","auto_wan","wan_device","auto_lan","lan_devices","lan_like","device_mesh","mesh"]),circleSet:J("circle_set",["id","server","name","color","members"]),circleDelete:J("circle_delete",["id"]),accessCheck:J("access_check",["from","to"]),homeHosts:J("home_hosts",["id"]),usageClear:J("usage_clear",["scope","id"]),uninstall:J("uninstall",["confirm"]),status:Fn,setupDefaults:J("setup_defaults"),serverCreate:J("server_create",["id","name","ifname","port","subnet","endpoint","mtu","preset","lan_zone","wan_zone","lan_like","portal_enabled","portal_port"]),serverObfuscation:J("server_obfuscation",["id","preset"]),serverUpdate:J("server_update",["id","values"]),serverDelete:J("server_delete",["id"]),personCreate:J("person_create",["name","slug","server","access","device_limit","expires","quota_gb","quota_period"]),personPause:J("person_pause",["id","paused"]),personRegen:J("person_regen",["id"]),personDelete:J("person_delete",["id"]),personUsage:J("person_usage",["id","days"]),pauseAll:J("pause_all",["paused"]),deviceCreate:J("device_create",["person","name","kind"]),deviceConfig:J("device_config",["id"]),deviceUpdate:J("device_update",["id","name","disabled"]),deviceDelete:J("device_delete",["id"]),deviceRotate:J("device_rotate",["id"]),apply:J("apply"),health:J("health"),healthFix:J("health_fix",["id"]),serviceLog:J("service_log"),serviceLogClear:J("service_log_clear",["older_days"]),backupList:J("backup_list"),backupCreate:J("backup_create"),backupRestore:J("backup_restore",["name"]),backupDelete:J("backup_delete",["name"]),backupRead:J("backup_read",["name"]),backupUpload:J("backup_upload",["data"]),exportJson:J("export"),importJson:J("import",["data"]),updatesStatus:J("updates_status"),updatesRun:J("updates_run",["what"])};var Zt={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 Ct(i,t="dl-icon"){let n=Zt[i]??Zt.phone;return``}function v(i,t="dl-icon"){let n=document.createElement("span");return n.className="dl-icon-wrap",n.innerHTML=Ct(i,t),n}function R(i,t,n="neutral",a={}){let{disabled:s,...o}=a,r=e("button",{class:`cbi-button cbi-button-${n}`,type:"button",...o,click:async l=>{if(l.preventDefault(),l.stopPropagation(),!r.disabled){r.disabled=!0,r.classList.add("spinning");try{await t(l)}catch(d){ne(Dt(d),"error")}finally{r.disabled=!1,r.classList.remove("spinning")}}}},i);return r.disabled=!!s,r}function ke(i,t,n,a="neutral",s=""){return R([v(i),e("span",{class:"dl-btn-label"},t)],n,a,{title:t,class:`cbi-button cbi-button-${a} dl-icon-btn ${s}`.trim()})}function ne(i,t="info",n=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 s=t==="error"?"x":t==="warning"?"alert":t==="success"?"check":null,o=()=>{r.classList.remove("show"),setTimeout(()=>r.remove(),200)},r=e("div",{class:`dl-toast ${t}`},[s?v(s):"",e("span",{},i),t==="error"?e("button",{type:"button","aria-label":"Close",click:o},v("x")):""]);a.appendChild(r),requestAnimationFrame(()=>r.classList.add("show")),setTimeout(o,n||(t==="error"?8e3:t==="warning"?5e3:2600))}function Dt(i){return i instanceof Error?i.message:String(i)}async function U(i,t){try{let n=await i();return t&&ne(t,"success",3500),n}catch(n){ne(Dt(n),"error",1e4);return}}function se(i,t,n,a=""){ui.showModal(i,[e("div",{class:`dl-modal ${a}`},t),e("div",{class:"button-row"},n)])}function X(){ui.hideModal()}function re(i,t,n="Confirm",a=!1){return new Promise(s=>{se(i,t,[e("button",{class:"cbi-button cbi-button-neutral",type:"button",click:()=>{X(),s(!1)}},"Cancel")," ",e("button",{class:`cbi-button ${a?"cbi-button-negative":"cbi-button-positive"}`,type:"button",click:()=>{X(),s(!0)}},n)])})}async function he(i,t="Copied to clipboard"){try{if(navigator.clipboard&&window.isSecureContext)await navigator.clipboard.writeText(i);else{let n=e("textarea",{style:"position:fixed;opacity:0"},i);document.body.appendChild(n),n.select(),document.execCommand("copy"),n.remove()}ne(t,"success",2500)}catch(n){ne(Dt(n),"error")}}function ve(i,t,n="text/plain"){let a=globalThis,s=typeof t=="string"?new a.Blob([t],{type:n}):t,o=URL.createObjectURL(s),r=e("a",{href:o,download:i,style:"display:none"});document.body.appendChild(r),r.click(),setTimeout(()=>{URL.revokeObjectURL(o),r.remove()},1e3)}function Ae(i,t){let n={ok:"success",warn:"warning",error:"error",info:"notice"}[i];return e("div",{class:`alert-message ${n}`},t)}function Pe(i,t=""){let n=e("div",{class:t});return n.innerHTML=i,n}function At(i,t){return new Promise(n=>{let a=e("input",{type:"file",accept:i,style:"display:none"});a.addEventListener("cancel",()=>{a.remove(),n(null)}),a.addEventListener("change",()=>{let s=a.files?.[0];if(a.remove(),!s)return n(null);let o=new FileReader;o.onload=()=>{let r=String(o.result??"");n({name:s.name,data:t==="base64"?r.replace(/^data:[^,]*,/,""):r})},o.onerror=()=>n(null),t==="base64"?o.readAsDataURL(s):o.readAsText(s)}),document.body.appendChild(a),a.click()})}function we(i,t){let n=document.querySelector(".dl-dd");if(n&&(n.dlClose?n.dlClose():n.remove(),n.dlAnchor===i))return;let a=e("div",{class:"dl-dd dl-root",role:"menu"},t.map(u=>u?e("button",{type:"button",role:"menuitem",class:u.danger?"danger":u.warn?"warn":"",click:()=>{p(),u.run()}},[u.icon??"",e("span",{},u.label)]):e("hr")));document.body.appendChild(a);let s=i.getBoundingClientRect(),o=a.offsetWidth,r=a.offsetHeight;a.style.top=`${s.bottom+6+r>window.innerHeight-8&&s.top-6-r>8?s.top-6-r:s.bottom+6}px`,a.style.left=`${Math.max(8,Math.min(s.right-o,window.innerWidth-o-8))}px`;let l=u=>{!a.contains(u.target)&&!i.contains(u.target)&&p()},d=u=>{u.key==="Escape"&&p()};a.dlAnchor=i,a.dlClose=p;function p(){a.remove(),document.removeEventListener("mousedown",l,!0),document.removeEventListener("keydown",d,!0),window.removeEventListener("scroll",p,!0)}setTimeout(()=>{document.addEventListener("mousedown",l,!0),document.addEventListener("keydown",d,!0),window.addEventListener("scroll",p,!0)}),a.querySelector("button")?.focus({preventScroll:!0})}var an=Bn(nn(),1),Kn='';function Oe(i,t=3,n=!0){let a=(0,an.default)(0,i.length>300?"Q":"H");a.addData(i,"Byte"),a.make();let s=a.getModuleCount(),o=s+t*2,r=n?Math.round(s*.22):0;r&&(s-r)%2&&r++;let l=(s-r)/2,d=l+r,p=(b,g)=>r>0&&b>=l&&b=l&&g${Kn}`}return`${c}`}var Vn={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:""},Yn={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 Jn(i){let t={};for(let[n,a]of Object.entries(Yn))i[n]!=null&&i[n]!==""&&(t[a]=String(i[n]));return t}function Qn(i,t){let n=i.amnezia,a=n.obfuscation??{},s=d=>a[d]!=null&&a[d]!==""?String(a[d]):Vn[d],o=n.host.replace(/^\[(.*)\]$/,"$1"),r={H1:s("h1"),H2:s("h2"),H3:s("h3"),H4:s("h4"),I1:s("i1"),I2:s("i2"),I3:s("i3"),I4:s("i4"),I5:s("i5"),Jc:s("jc"),Jmin:s("jmin"),Jmax:s("jmax"),S1:s("s1"),S2:s("s2"),S3:s("s3"),S4:s("s4"),...Jn(a),allowed_ips:n.allowed_ips,client_ip:n.client_ip,client_priv_key:n.client_priv_key,client_pub_key:n.client_pub_key,config:i.conf.replace(/\r?\n/g,`\r +`),hostName:o,mtu:n.mtu,persistent_keep_alive:n.persistent_keep_alive,port:Number(n.port),psk_key:n.psk_key,server_pub_key:n.server_pub_key},l={containers:[{container:"amnezia-awg",awg:{isThirdPartyConfig:!0,last_config:JSON.stringify(r),port:String(n.port),protocol_version:a.header_protection_key?"3.1":"2",transport_proto:"udp"}}],defaultContainer:"amnezia-awg",description:t,hostName:o};return n.dns[0]&&(l.dns1=n.dns[0]),n.dns[1]&&(l.dns2=n.dns[1]),l}function Zn(i){let t="";for(let n=0;n"u")return null;try{let n=new t.Blob([i]).stream().pipeThrough(new t.CompressionStream("deflate")),a=new Uint8Array(await new t.Response(n).arrayBuffer()),s=new Uint8Array(4+a.length);return new DataView(s.buffer).setUint32(0,i.length,!1),s.set(a,4),s}catch{return null}}async function sn(i,t,n=!0){let a=new TextEncoder().encode(JSON.stringify(Qn(i,t))),s=n?await Xn(a):null;return`vpn://${Zn(s??a)}`}function Z(i){if(!i||i<0)return"0 B";let t=["B","KB","MB","GB","TB"],n=0,a=i;for(;a>=1024&&n=100||n===0?Math.round(a):a.toFixed(1)} ${t[n]}`}function $e(i){let t=i*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 ue(i,t=Date.now()/1e3){if(!i)return"never";let n=Math.max(0,Math.round(t-i));return n<60?"just now":n<3600?`${Math.floor(n/60)} min ago`:n<86400?`${Math.floor(n/3600)} h ago`:n<86400*30?`${Math.floor(n/86400)} d ago`:new Date(i*1e3).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function on(i){if(!i||i<0)return"—";let t=Math.floor(i/86400),n=Math.floor(i%86400/3600),a=Math.floor(i%3600/60);return t?`${t}d ${n}h`:n?`${n}h ${a}m`:`${a}m`}function Ne(i){let t=new Date(i*1e3),n=new Date,a=t.toDateString()===n.toDateString(),s=t.toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});return a?s:`${t.toLocaleDateString("en-GB",{day:"numeric",month:"short"})} ${s}`}function _e(i){if(!i)return"";let[t,n,a]=i.split("-").map(Number);return new Date(t,n-1,a).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"})}function ze(i,t=Date.now()){if(!i)return null;let[n,a,s]=i.split("-").map(Number),o=new Date(n,a-1,s,23,59,59).getTime();return Math.ceil((o-t)/864e5)}var Ue={lan:"Home network",internet:"Internet",both:"Home network + Internet"};var rn=["computer","phone","tablet","router","other"],Se={computer:"PC",phone:"Phone",tablet:"Tablet",router:"Router",other:"Other"},Pt={active:"Active",paused:"Paused",paused_all:"Paused (everyone)",expired:"Expired",quota:"Data limit reached",hours:"Outside allowed hours",no_server:"No server"};function Re(i){let t=i.trim().split(/\s+/).filter(Boolean);if(!t.length)return"?";let n=t[0][0]??"",a=t.length>1?t[t.length-1][0]??"":t[0][1]??"";return(n+a).toUpperCase()}function rt(i){let t=n=>n.disabled?3:n.online?0:n.handshake?1:2;return i.map((n,a)=>[n,a]).sort((n,a)=>t(n[0])-t(a[0])||n[1]-a[1]).map(([n])=>n)}var ln="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl",ea="https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",ta="https://basemaps.cartocdn.com/gl/positron-gl-style/style.json",na={online:0,"24h":86400,"7d":7*86400,"30d":30*86400},Qe=null;function aa(i){let t=window;return i.appendChild(e("link",{rel:"stylesheet",href:`${ln}.css`})),t.maplibregl?Promise.resolve(t.maplibregl):Qe||(Qe=new Promise((n,a)=>{let s=e("script",{src:`${ln}.js`});s.onload=()=>t.maplibregl?n(t.maplibregl):a(new Error("MapLibre failed to load")),s.onerror=()=>{Qe=null,a(new Error("Could not load the map library (no internet access from this browser?)"))},i.appendChild(s)}),Qe)}function lt(){let i=document.documentElement.getAttribute("data-darkmode");return i!=null?i==="true":window.matchMedia?.("(prefers-color-scheme: dark)").matches??!1}function sa(i,t,n=48){let a=(i[0]+t[0])/2,s=(i[1]+t[1])/2,o=t[0]-i[0],r=t[1]-i[1],l=Math.hypot(o,r)||1,d=Math.min(.25*l,12),p=a-r/l*d,u=s+o/l*d,c=[];for(let b=0;b<=n;b++){let g=b/n,w=1-g;c.push([w*w*i[0]+2*w*g*p+g*g*t[0],w*w*i[1]+2*w*g*u+g*g*t[1]])}return c}function ia(i,t){let n=new Map;for(let a of i.geo.points){if(i.person&&a.person!==i.person||(t==="online"?!a.online:i.now-a.ts>na[t]))continue;let s=n.get(a.device);(!s||a.online&&!s.online||a.online===s.online&&a.ts>s.ts)&&n.set(a.device,a)}return[...n.values()]}var qe=class{constructor(t,n="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=n,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 aa(this.el)}catch(n){this.status.textContent=n.message;return}this.map=new this.gl.Map({container:this.el,style:lt()?ea:ta,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",lt()?"#ededed":"#0d0d0d"],"circle-opacity":["case",["get","online"],.12,.06],"circle-stroke-width":1,"circle-stroke-color":["case",["get","online"],"#40c977",lt()?"#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":lt()?"#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]],n=-1,a=0,s=o=>{this.map&&(o-a>70&&(a=o,n=(n+1)%t.length,this.map.getLayer("dl-arc-flow")&&this.map.setPaintProperty("dl-arc-flow","line-dasharray",t[n])),this.anim=requestAnimationFrame(s))};this.anim=requestAnimationFrame(s)}groups(t){let n=new Map;for(let a of t){let s=`${a.asn||a.org||a.ip}|${a.city}|${a.cc}`,o=n.get(s);o||(o={key:s,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:[]},n.set(s,o)),o.points.push(a),o.online||(o.online=a.online),o.ts=Math.max(o.ts,a.ts)}return[...n.values()]}draw(){if(!this.map||!this.data||!this.map.getSource("dl-arcs"))return;let t=this.data,n=this.groups(ia(t,this.range)),a=t.geo.home;for(let r of this.markers)r.remove();this.markers=[];let s=new Map,o=n.map(r=>{let l=`${r.lat.toFixed(2)},${r.lon.toFixed(2)}`,d=s.get(l)??0;return s.set(l,d+1),{g:r,at:[r.lon+d*.25,r.lat]}});if(this.map.getSource("dl-areas").setData({type:"FeatureCollection",features:o.map(({g:r,at:l})=>({type:"Feature",properties:{online:r.online},geometry:{type:"Point",coordinates:l}}))}),this.map.getSource("dl-arcs").setData({type:"FeatureCollection",features:a?o.map(({g:r,at:l})=>({type:"Feature",properties:{online:r.online},geometry:{type:"LineString",coordinates:sa([a.lon,a.lat],l)}})):[]}),a){let r=e("div",{class:"dl-mk-home",title:`Home router${a.city?` · ${a.city}`:""}${a.org?` · ${a.org}`:""}`});r.innerHTML=Ct("home","dl-mk-home-ic"),this.markers.push(new this.gl.Marker({element:r}).setLngLat([a.lon,a.lat]).addTo(this.map))}for(let{g:r,at:l}of o){let d=r.points.length,p=e("button",{type:"button",class:`dl-mk${r.online?" online":""}${d>1?" multi":""}`,"aria-label":`${d} device${d===1?"":"s"} via ${r.org||"unknown network"} in ${r.city||"unknown city"}`},d>1?e("span",{class:"dl-mk-count"},String(d)):e("span",{class:"dl-mk-dot"})),c=!!a&&Math.abs(l[0]-a.lon)<.02&&Math.abs(l[1]-a.lat)<.02?[22,-16]:[0,0];p.addEventListener("click",b=>{b.stopPropagation(),this.openPopup(r,l,c)}),this.markers.push(new this.gl.Marker({element:p,offset:c}).setLngLat(l).addTo(this.map))}if(!this.fitted){let r=o.map(l=>l.at);a&&(r.length===0||this.range!=="online"||o.some(l=>l.g.online))&&r.push([a.lon,a.lat]),this.fit(r),this.fitted=!0}this.status.textContent=o.length||a?"":"No locations yet",this.status.style.display=this.status.textContent?"":"none"}fit(t){if(!t.length)return;let n=(d,p)=>{let u=Math.PI/180,c=(p[1]-d[1])*u,b=(p[0]-d[0])*u,g=Math.sin(c/2)**2+Math.cos(d[1]*u)*Math.cos(p[1]*u)*Math.sin(b/2)**2;return 12742*Math.asin(Math.sqrt(g))},a=[t.reduce((d,p)=>d+p[0],0)/t.length,t.reduce((d,p)=>d+p[1],0)/t.length],s=t;if(t.length>=5){let d=[...t].sort((p,u)=>n(a,p)-n(a,u));s=d.slice(0,Math.ceil(d.length*.9))}if(Math.max(...s.map(d=>n(a,d)))<25){this.map.jumpTo({center:a,zoom:9.5});return}let r=new this.gl.LngLatBounds(s[0],s[0]);s.forEach(d=>r.extend(d));let l=this.el.clientHeight||380;this.map.fitBounds(r,{padding:{top:Math.min(90,l/4),bottom:Math.min(70,l/5),left:60,right:60},maxZoom:9,duration:0})}openPopup(t,n,a=[0,0]){let s=this.data;this.popup?.remove();let o=[t.city,t.cc||t.country].filter(Boolean).join(", "),r=[...new Set(t.points.map(u=>u.person))],l=t.points.sort((u,c)=>Number(c.online)-Number(u.online)||c.ts-u.ts).map(u=>{let c=s.people.find(g=>g.id===u.person),b=c?.devices.find(g=>g.id===u.device);return e("button",{type:"button",class:"dl-pop-row",click:()=>this.cb.openDevice(u.person,u.device)},[e("span",{class:`dl-pop-dot${u.online?" on":""}`}),e("span",{class:"dl-pop-name"},[e("b",{},c?.name??u.person),` · ${b?.name??"device"}`]),e("span",{class:"dl-faint dl-nowrap"},u.online?"now":ue(u.ts,s.now))])}),d=e("div",{class:"dl-pop"},[e("div",{class:"dl-pop-head"},[e("span",{class:"dl-pop-net"},v("globe")),e("div",{class:"dl-stack"},[e("strong",{},t.org||"Unknown network"),e("span",{class:"dl-faint"},[t.asn?`AS${t.asn} · `:"",o?`${o} · approximate`:"approximate location"])])]),e("div",{class:"dl-pop-list"},l),r.length===1?e("div",{class:"dl-pop-actions"},[e("button",{type:"button",class:"cbi-button cbi-button-positive important",click:()=>this.cb.openPerson(r[0])},`Open ${s.people.find(u=>u.id===r[0])?.name??"person"}`)]):""]),p=this.el.clientHeight||380;this.map.easeTo({center:n,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(n).setDOMContent(d).addTo(this.map)}};function dt(i,t,n=!0){let a=[["online","Online now"],["24h","24h"],["7d","7 days"],["30d","30 days"]],s=e("div",{class:"dl-seg",role:"tablist"});for(let[o,r]of a)o==="online"&&!n||s.appendChild(e("button",{type:"button",role:"tab",class:o===i?"on":"","data-v":o,click:()=>{s.querySelectorAll("button").forEach(l=>l.classList.toggle("on",l.dataset.v===o)),t(o)}},r));return s}var He=null;function pe(i,t){let n=a=>{He??(He=document.body.appendChild(e("div",{class:"dl-tip dl-tip-float dl-root"}))),He.replaceChildren(...t().map(s=>typeof s=="string"?document.createTextNode(s):s)),He.style.display="",He.style.left=`${a.clientX}px`,He.style.top=`${a.clientY-10}px`};i.addEventListener("mouseenter",n),i.addEventListener("mousemove",n),i.addEventListener("mouseleave",()=>He&&(He.style.display="none"))}function dn(i,t=120,n=26){let a=Math.max(1,...i),s=e("div",{class:"dl-spark"});s.style.width=`${t}px`,s.style.height=`${n}px`;let o=Date.now();return i.forEach((r,l)=>{let d=e("i");d.style.height=`${Math.max(6,r/a*100)}%`,r||d.classList.add("zero");let p=i.length-1-l,u=new Date(o-p*864e5);pe(d,()=>[e("div",{class:"dl-tip-title"},p===0?"Today":p===1?"Yesterday":u.toLocaleDateString("en-GB",{weekday:"short",day:"numeric",month:"short"})),e("div",{class:"dl-muted"},Z(r))]),s.appendChild(d)}),s}var pn=[{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"}],We=i=>pn.find(t=>t.id===i),oa={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)."};function cn(i,t){return e("span",{class:"dl-dots",title:`${t}: ${i} of 4`},[e("span",{class:"dl-dots-label"},t),e("span",{class:"dl-dots-row"},[0,1,2,3].map(n=>e("i",{class:ndom.content(s,pn.map(r=>{let l=!r.needs||i[r.needs],d=r.id===t;return e("button",{type:"button",role:"radio","aria-checked":d?"true":"false","aria-disabled":l?null:"true",class:`dl-method${d?" on":""}${l?"":" off"}`,click:()=>{!l||d||(t=r.id,o(),n(r.id))}},[e("div",{class:"dl-method-head"},[e("span",{class:"dl-method-ic"},v(r.ic)),e("b",{},r.title),r.id===a?e("span",{class:"dl-pill ok"},"Current"):""]),e("p",{},r.text),e("div",{class:"dl-method-meters"},[cn(r.stealth,"Stealth"),cn(r.speed,"Speed")]),e("div",{class:"dl-method-foot"},l?[v("phone"),e("span",{},r.apps)]:[v("alert"),e("span",{},oa[r.needs])])])}));return o(),s}function Ze(i){return`${L.url("admin/network/dawnline/server")}?${i?`server=${encodeURIComponent(i)}&`:""}section=people`}function be(i,t){return`${L.url("admin/network/dawnline/person")}?id=${encodeURIComponent(i)}${t?`&device=${encodeURIComponent(t)}`:""}`}var ra={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"},la={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 da(i,t){return t.device?i.people.flatMap(a=>a.devices).find(a=>a.id===t.device)?.kind??t.dkind??"other":la[t.type]??"activity"}var ca=["person_added","person_removed","person_changed","paused_all","resumed_all"];function xe(i){return i.by?i.by:ca.includes(i.type)||i.detail==="by admin"||i.detail?.endsWith(" (admin)")?"admin":i.detail?.endsWith(" (portal)")?"portal":null}function pa(i){return(i.detail??"").replace(/ \((admin|portal)\)$/,"").replace(/^by admin$/,"")}function zt(i,t){let n=i.people.find(w=>w.id===t.person),a=n?.name??t.pname??t.person??"",s=n?.devices.find(w=>w.id===t.device)?.name??t.dname??"",o=w=>e("b",{},w),r=w=>e("span",{class:"dl-muted"},w),l=w=>e("span",{class:"dl-mono"},w),d=w=>t.hosts?.[w]?[e("span",{class:"dl-ev-host"},[e("b",{},t.hosts[w]),e("span",{class:"dl-faint"},` (${w})`)])]:[l(w)],p=w=>e("span",{class:"dl-ev-kind"},`${w} `),u=s?`${a} · ${s}`:a,c=pa(t),b=c||s||"a device",g=w=>[e("span",{class:"dl-you"},"You"),r(` ${w} `)];if(xe(t)==="admin")switch(t.type){case"device_added":return[...g("added"),p("device"),o(b),r(" for "),o(a)];case"device_removed":return[...g("removed"),p("device"),o(b),r(" from "),o(a)];case"paused":return[...g("paused"),p("person"),o(a)];case"resumed":return[...g("resumed"),p("person"),o(a)];case"device_changed":{let w=c.startsWith("renamed from ");return[...g(w?"renamed":c),p("device"),o(s||"a device"),r(" of "),o(a),...w?[r(` · was ${c.slice(13)}`)]:[]]}case"device_keys":return[...g("issued new keys for"),p("device"),o(b),r(" of "),o(a),r(" · it needs its new configuration")];case"link_changed":return[...g("issued a new link for"),p("person"),o(a),r(" · the old link stopped working")];case"paused_all":return[e("span",{class:"dl-you"},"You"),r(" paused everyone")];case"resumed_all":return[e("span",{class:"dl-you"},"You"),r(" resumed everyone")]}switch(t.type){case"connect":return[p("Device"),o(u),r(" connected"),...t.detail?[r(" from "),...d(t.detail)]:[],...t.where?[r(` · ${t.where}`)]:[]];case"disconnect":return[p("Device"),o(u),r(" went offline")];case"roam":return[p("Device"),o(u),r(" changed network "),...(t.detail??"").split(" → ").flatMap((w,F)=>F?[r(" → "),...d(w)]:d(w))];case"device_added":return[p("Person"),o(a),r(" added "),p("device"),o(b),...xe(t)==="portal"?[r(" on their portal")]:[]];case"device_removed":return[p("Person"),o(a),r(" removed "),p("device"),o(b),...xe(t)==="portal"?[r(" on their portal")]:[]];case"device_keys":return[p("Person"),o(a),r(" issued new keys for "),p("device"),o(b),r(" on their portal")];case"person_added":return[...g("added"),p("person"),o(t.detail??a)];case"person_removed":return[...g("removed"),p("person"),o(t.detail??a)];case"person_changed":return[...g("changed"),p("person"),o(a),...c?[r(` · ${c.replace(/_/g," ")}`)]:[]];case"paused":return[p("Person"),o(a),r(` paused — ${t.detail??""}`)];case"resumed":return[p("Person"),o(a),r(" resumed"),...t.detail&&t.detail!=="active"?[r(` — ${t.detail}`)]:[]];case"paused_all":return[r("Everyone paused")];case"resumed_all":return[r("Everyone resumed")];case"portal_blocked":return[e("b",{class:"dl-sys-src"},"Personal portal"),r(" blocked "),l(t.detail??""),r(" for 15 min after too many wrong codes")];case"devices_removed":return[p("Person"),o(a),r(" — all devices removed, end date reached")];default:return[r(`${t.type}${t.detail?`: ${t.detail}`:""}`)]}}var ha={portal_blocked:["globe","bad"]};function ua(i,t){if(i.servers.length<2||!t.person)return"";let n=i.people.find(s=>s.id===t.person),a=n&&i.servers.find(s=>s.id===n.server);return a?e("span",{class:"dl-ev-srv",title:"Server"},a.name):""}function Ie(i,t,n={}){let a=ha[t.type],s=xe(t);return e("div",{class:`dl-row${s==="admin"?" dl-ev-by-admin":a?` dl-ev-by-system ${a[1]}`:""}`},[s==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):a?e("span",{class:"dl-ev-tile sys"},v(a[0])):e("span",{class:`dl-ev-tile ev ${ra[t.type]??""}`},v(da(i,t))),e("span",{class:"dl-row-main"},zt(i,t)),n.server===!1?"":ua(i,t),e("span",{class:"dl-faint dl-nowrap",title:new Date(t.ts*1e3).toLocaleString()},ue(t.ts,i.now))])}function ma(i){let t=[],n=(s,o)=>e("a",{href:s},o);for(let s of i.servers)s.enabled&&!s.up&&t.push({tone:"bad",text:[`Tunnel ${s.ifname} is down. `,n(L.url("admin/network/dawnline/diagnostics"),"Open Diagnostics")]});i.settings.paused_all&&t.push({tone:"warn",text:["Everyone is paused."]});for(let s of i.people)if(s.state==="quota")t.push({tone:"warn",text:[n(be(s.id),s.name)," reached the data limit."]});else if(s.state==="expired")t.push({tone:"warn",text:[n(be(s.id),s.name),"’s access has ended."]});else{let o=ze(s.expires);o!=null&&o>=0&&o<=Math.max(s.expire_warn,3)&&t.push({tone:"",text:[n(be(s.id),s.name),`’s access ends in ${o} day${o===1?"":"s"}.`]}),s.quota_limit&&s.quota_used>=s.quota_limit*.9&&t.push({tone:"",text:[n(be(s.id),s.name)," has used 90% of the data limit."]})}let a=i.people.flatMap(s=>s.devices.filter(o=>o.config_stale).map(o=>[s,o]));return a.length&&t.push({tone:"warn",text:a.length===1?[n(be(a[0][0].id,a[0][1].id),`${a[0][0].name} · ${a[0][1].name}`)," needs its configuration again."]:[`${a.length} devices need their configuration again (networks or DNS changed).`]}),i.servers.some(s=>s.lan_like)&&i.like_home.error&&t.push({tone:"warn",text:[`Internet through the LAN is off: ${i.like_home.error} `,n(L.url("admin/network/dawnline/diagnostics"),"Details")]}),i.settings.portal_enabled||t.push({tone:"",text:["The personal portal is off. ",n(L.url("admin/network/dawnline/settings"),"Turn on")]}),t}function ct(i,t){let n=i.servers.find(d=>d.id===t)??i.servers[0],a=i.people.filter(d=>d.server===n.id),s=new Set(a.map(d=>d.id)),o=a.flatMap(d=>d.devices),r=d=>a.reduce((p,u)=>{let c=d(u);return[p[0]+c[0],p[1]+c[1]]},[0,0]),l=n.series?.[n.series.length-1];return{...i,servers:[n],people:a,series:n.series??i.series,events:i.events.filter(d=>d.person?s.has(d.person):!0),geo:{...i.geo,points:i.geo.points.filter(d=>s.has(d.person))},totals:{people:a.length,devices:o.length,online:o.filter(d=>d.online).length,active:a.filter(d=>d.state==="active").length,today:l?[l.rx,l.tx]:[0,0],month:r(d=>d.month)}}}var pt=class{constructor(t,n){this.srvId=t;this.go=n;this.el=e("div",{class:"dl-srvov"});this.map=null;this.range="online";this.parts={};this.healthAt=0}mount(t){this.st=ct(t,this.srvId);for(let n of["health","bento","side","activity"])this.parts[n]=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){this.st=ct(t,this.srvId),this.paint(),this.map?.update(this.mapData()),Date.now()-this.healthAt>6e4&&this.loadHealth()}async loadHealth(){this.healthAt=Date.now();let t=await z.health().catch(()=>null);if(!t)return;let n=t.checks.filter(o=>o.status==="warn"||o.status==="error");if(!n.length){dom.content(this.parts.health,"");return}let a=n.filter(o=>o.status==="error").length,s=`${n.length} ${a?n.length===1?"problem":"problems":n.length===1?"warning":"warnings"}`;dom.content(this.parts.health,e("div",{class:`dl-healthstrip ${a?"bad":"warn"}`},[e("span",{class:"dl-healthstrip-title"},[v("alert"),s]),...n.slice(0,3).map(o=>{let r=e("span",{class:"dl-healthstrip-item"},o.title);return pe(r,()=>[e("div",{class:"dl-tip-title"},o.title),e("div",{class:"dl-muted"},o.detail)]),r}),n.length>3?e("span",{class:"dl-sub"},`+${n.length-3} more`):"",e("a",{href:L.url("admin/network/dawnline/diagnostics")},n.some(o=>o.fix)?"Fix in Diagnostics →":"Open Diagnostics →")]))}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now}}mapCard(){let t=this.st,n=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"}),dt(this.range,o=>{this.range=o,this.map?.setRange(o)})]);if(!t.geo.enabled)return e("div",{class:"dl-panel flush"},[n,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 qe({openPerson:o=>location.href=be(o),openDevice:(o,r)=>location.href=be(o,r)},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"])]),s=e("div",{class:"dl-map-wrap"},[this.map.el,a]);return requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[n,s])}paint(){let t=this.st,n=t.servers[0],a=t.people.reduce((l,d)=>l+Math.max(0,d.device_limit-d.devices.length),0),s=t.people.flatMap(l=>l.devices.filter(d=>d.online));dom.content(this.parts.bento,e("div",{class:"dl-bento"},[this.onlineTile(s),this.speedTile(),this.disguiseTile(n),this.monthTile(a)]));let o=ma(t);dom.content(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")]),o.length?o.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)])):e("div",{class:"dl-row dl-muted"},[v("check"),"All good. Nothing needs you right now."])]));let r=[...t.events].reverse().slice(0,8);dom.content(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")]),r.length?r.map(l=>Ie(t,l)):e("div",{class:"dl-row dl-muted"},"Nothing yet. Connections, new devices and pauses appear here.")]))}onlineTile(t){let n=this.st,a=12,s=j=>j.spark[j.spark.length-1]??0,o=j=>n.geo.points.find($=>$.device===j.id&&$.city)?.city,r=j=>/^(10\.|192\.168\.|172\.(1[6-9]|2\d|3[01])\.)/.test(j.endpoint??""),l=j=>(r(j)?"home":o(j))??"",d=j=>[...n.events].reverse().find($=>$.type==="connect"&&$.device===j.id)?.ts??0,p=n.people.map(j=>({p:j,devs:j.devices.filter($=>$.online).sort(($,N)=>s(N)-s($))})).filter(j=>j.devs.length).sort((j,$)=>$.devs.reduce((N,C)=>N+s(C),0)-j.devs.reduce((N,C)=>N+s(C),0)),u=p.length<=2,c=({p:j,devs:$})=>{let N=$.map(d).filter(Boolean),C=N.length?Math.min(...N):0,T=(j.rate??[]).slice(-15),y=T[T.length-1],A=y&&n.now-y[0]<180?y:null,m=200,h=30,P=Math.max(1,...T.map(B=>Math.max(B[1],B[2]))),f=B=>T.map((S,q)=>`${T.length>1?q/(T.length-1)*m:m},${h-2-S[B]/P*(h-6)}`),_=T.length>1?Pe(``):"",O=!A||A[1]<64&&A[2]<64,G=j.access==="both"?["home","globe"]:j.access==="lan"?["home"]:["globe"];return[e("div",{class:"dl-hc"},[e("div",{class:"dl-hc-head"},[e("span",{class:"dl-onl-av sm"},Re(j.name)),e("span",{class:"dl-stack"},[e("b",{},j.name),e("span",{class:"dl-hc-since"},C?`online for ${ue(C,n.now).replace(" ago","")}`:"online")]),e("span",{class:"dl-hc-reach"},G.map(B=>e("span",{class:`dl-ibadge ${B==="home"?"lan":"inet"}`},v(B))))]),e("div",{class:"dl-hc-speed"},[e("div",{class:"dl-hc-speed-row"},O?[e("span",{class:"dl-faint"},"Idle right now")]:[e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${$e(A[2])}`]),e("span",{},[e("span",{class:"dl-up"},"↑"),` ${$e(A[1])}`]),e("span",{class:"dl-spacer"}),e("span",{class:"dl-faint"},"15 min")]),_]),e("div",{class:"dl-hc-devs"},$.map(B=>e("span",{class:"dl-hc-dev"},[v(B.kind),[B.name,l(B)].filter(Boolean).join(" · ")]))),e("div",{class:"dl-hc-foot"},[e("span",{class:"dl-faint"},`${Z($.reduce((B,S)=>B+s(S),0))} today · ${Z(j.month[0]+j.month[1])} this month`)])])]},b=j=>{let{p:$,devs:N}=j,C=e("span",{class:"dl-onl-dev"},N.length>1?String(N.length):v(N[0].kind)),T=e("a",{class:`dl-onl-p${u?"":" sm"}`,href:be($.id),"aria-label":`${$.name}, online`},[e("span",{class:"dl-onl-av"},[Re($.name),C]),u?e("span",{class:"dl-onl-name"},$.name):"",u?e("span",{class:"dl-onl-meta"},[...N.slice(0,3).map(y=>v(y.kind)),N.length>3?`+${N.length-3}`:"",l(N[0])?e("span",{},` · ${l(N[0])}`):""]):""]);return pe(T,()=>c(j)),T},g=e("b",{class:`dl-onl-count${p.length?"":" none"}`},String(p.length)),w=p.reduce((j,$)=>j+$.devs.length,0);p.length&&pe(g,()=>[`${p.length} ${p.length===1?"person":"people"} · ${w} device${w===1?"":"s"}`]);let F=p.length>a?p.slice(0,a-1):p,Y=n.people.flatMap(j=>j.devices.map($=>({p:j,d:$}))).filter(j=>j.d.handshake).sort((j,$)=>$.d.handshake-j.d.handshake)[0];return e("div",{class:"dl-bento-tile online"},[e("div",{class:"dl-bento-head"},[e("span",{class:"dl-metric-label"},"Online"),g]),p.length?e("div",{class:`dl-onl-row${u?"":" grid"}`},[...F.map(b),p.length>a?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:j=>{this.go&&(j.preventDefault(),this.go("people","online"))}},[e("span",{class:"dl-onl-av"},`+${p.length-F.length}`)]):""]):e("div",{class:"dl-onl-empty"},[e("span",{},"Nobody is connected"),Y?e("span",{class:"dl-sub"},`Last: ${Y.p.name}, ${ue(Y.d.handshake,n.now)}`):e("span",{class:"dl-sub"},"No device has connected yet")])])}speedTile(){return Rt(this.st.servers[0]?.rate??[],this.st.now,this.st.totals.today)}disguiseTile(t){let n=We(t.preset),a=t.obf??{},s=(l,d)=>e("span",{class:`dl-segs ${d}`},[0,1,2,3].map(p=>e("i",{class:p+a[l]).map(l=>`${l.toUpperCase()} ${a[l]}`);return r.length&&o.push(r.slice(0,2).join(" · ")+(r.length>2?` +${r.length-2}`:"")),["h1","h2","h3","h4"].some(l=>a[l]&&a[l]!==String(["h1","h2","h3","h4"].indexOf(l)+1))&&o.push("H1–H4 random"),a.i1&&o.push(a.i1.includes("0x8580")?"DNS-like first packet":"Signature packets"),a.header_protection_key&&o.push("Encrypted headers"),o.length||o.push(n?.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(t.id)}§ion=disguise`},"Change")]),e("div",{class:"dl-disg-id"},[e("span",{class:"dl-disg-ic"},v(n?.ic??"shield")),e("span",{class:"dl-stack"},[e("b",{},n?n.title:"Custom"),e("span",{class:"dl-sub"},n?n.short:"Set by hand")])]),n?e("div",{class:"dl-disg-meters"},[e("span",{},"Stealth"),s(n.stealth,"acc"),e("span",{},"Speed"),s(n.speed,"ok")]):"",e("div",{class:"dl-disg-chips"},o.map(l=>e("span",{},l)))])}monthTile(t){let n=this.st.totals,a=this.st.people.filter(s=>s.state!=="active").length;return Ht(this.st.series,`${n.people} ${n.people===1?"person":"people"}${a?` · ${a} paused`:""} · ${t} device slot${t===1?"":"s"} free`)}};function Rt(i,t,n){let a=i.slice(-15),s=a[a.length-1],o=s&&t-s[0]<180,r=o?s[2]:0,l=o?s[1]:0,[d,p]=n,u=200,c=40,b=Math.max(1,...a.map($=>Math.max($[1],$[2]))),g=$=>a.map((N,C)=>`${a.length>1?C/(a.length-1)*u:u},${c-2-N[$]/b*(c-6)}`),w=g(2),F=g(1),Y=a.length>1?Pe(``):e("div",{class:"dl-speed-wait"},[e("i"),e("span",{},"Collecting… 1 point a minute")]),j=($,N,C,T)=>e("div",{class:"dl-speed-col"},[e("span",{class:"dl-sub"},[e("span",{class:C},N),` ${$}`]),e("span",{class:"dl-speed-val"},$e(T))]);return a.length>1&&pe(Y,()=>{let $=a[a.length-1];return[e("div",{class:"dl-tip-title"},new Date($[0]*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"})),e("div",{},`↓ ${$e($[2])} · ↑ ${$e($[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",r),j("Upload","↑","dl-up",l)]),Y,e("div",{class:"dl-speed-today"},[e("span",{},["Today ",e("b",{},Z(d+p))]),e("span",{},[e("span",{class:"dl-dn"},"↓"),` ${Z(p)} `,e("span",{class:"dl-up"},"↑"),` ${Z(d)}`])])])}function Ht(i,t){let n=i.slice(-30),a=n.map(p=>p.rx+p.tx),s=Math.max(1,...a),o=a.reduce((p,u)=>p+u,0),r=a.reduce((p,u,c)=>u>a[p]?c:p,0),l=p=>new Date(`${p}T12:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"}),d=e("div",{class:"dl-bento-bars"},n.map((p,u)=>{let c=a[u],b=e("i",{class:u===n.length-1?"hi":"",style:`height:${Math.max(4,c/s*100)}%`});return pe(b,()=>[e("div",{class:"dl-tip-title"},u===n.length-1?`Today · ${l(p.day)}`:l(p.day)),e("div",{},Z(c)),e("div",{class:"dl-muted dl-mono"},`↓ ${Z(p.tx)} ↑ ${Z(p.rx)}`)]),b}));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"},Z(o))]),a[r]>0?e("span",{class:"dl-sub"},`peak ${Z(a[r])} · ${l(n[r].day)}`):""]),n.length?d:e("p",{class:"dl-muted"},"No traffic yet."),e("div",{class:"dl-bento-head"},[e("span",{class:"dl-sub"},n.length?l(n[0].day):""),e("span",{class:"dl-sub"},t),e("span",{class:"dl-sub"},"today")])])}var ga={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"},Xe=["connections","people","problems"],Ge={connections:"Connections",people:"People",problems:"Problems"},hn={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)"},ht=i=>ga[i]??"problems";function fa(i){let t=new Map(i.people.map(a=>[a.id,a.name])),n=new Map(i.people.flatMap(a=>a.devices.map(s=>[s.id,s.name])));return{people:t,devices:n}}function va(i){let t=i==null?"":String(i);return/[",\n]/.test(t)?`"${t.replace(/"/g,'""')}"`:t}var ut={awg:"AmneziaWG",dawnline:"Dawnline",portal:"Portal"};function Le(i,t,n,a="",s=[]){let o=fa(i),r=[...t.map(c=>({ts:c.ts,category:ht(c.type),type:c.type,person:c.person?o.people.get(c.person)??c.pname??c.person:"",device:c.device?o.devices.get(c.device)??c.dname??c.device:"",detail:c.detail??"",where:c.where??"",by:xe(c)??""})),...s.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:ut[c.src]??c.src,by:""}))].sort((c,b)=>c.ts-b.ts).map(({ts:c,...b})=>({time:new Date(c*1e3).toISOString(),...b})),l=new Date().toISOString().slice(0,10),d=`dawnline-activity${a?`-${a}`:""}-${l}.${n}`;if(n==="json"){ve(d,JSON.stringify(r,null,2),"application/json");return}let p=["time","category","type","person","device","detail","where","by"],u=[p.join(","),...r.map(c=>p.map(b=>va(c[b])).join(","))].join(` +`);ve(d,u,"text/csv")}var ba=[["","Everything"],["7","Older than 7 days"],["30","Older than 30 days"],["90","Older than 90 days"]];function Ce(i,t,n,a,s,o=!1){let r=e("select",{class:"cbi-input-select"},[e("option",{value:""},"All categories"),...Xe.map(d=>e("option",{value:d,selected:d===s?"selected":null},Ge[d])),o?e("option",{value:"system",selected:s==="system"?"selected":null},"System"):""]),l=e("select",{class:"cbi-input-select"},ba.map(([d,p])=>e("option",{value:d},p)));se(i,[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"),r]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Which events"),l])],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Clear",async()=>{let d=await U(async()=>{let p=o&&(r.value==="system"||r.value==="")?await z.serviceLogClear(l.value):{removed:0},u=r.value==="system"?{removed:0}:await z.logsClear({...n,category:r.value,older_days:l.value});return{removed:p.removed+u.removed}});d&&(X(),ne(d.removed?`${d.removed} event${d.removed===1?"":"s"} removed`:"Nothing matched","success",3e3),a())},"negative")])}function Fe(i,t,n,a){let s=i==="device"?`Clears ${n}'s daily and monthly traffic history. Their person's totals and data limit are not changed.`:i==="person"?`Clears ${n}'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.";se(i==="all"?"Reset all traffic history?":`Reset traffic history for ${n}?`,[e("p",{class:"dl-muted"},s)],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Reset",async()=>{await U(()=>z.usageClear(i,t),"Traffic history reset")&&(X(),a())},"negative")])}var mt=null;function xa(i){return i?new Date(i*1e3).toLocaleString("en-GB",{day:"numeric",month:"short",year:"numeric",hour:"2-digit",minute:"2-digit"}):"—"}function un(i,t,n=!1){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},i),e("button",{type:"button",class:`dl-kvrow-v copy${n?" dl-mono":""}`,title:"Copy",click:()=>he(t,`${i} copied`)},[e("span",{},t),v("copy")])])}function gt(i,t){return e("div",{class:"dl-kvrow"},[e("span",{class:"dl-kvrow-k"},i),e("span",{class:"dl-kvrow-v"},t)])}function mn(i,t){if(/^\s*\[.+\]\s*$/.test(i))return e("span",{class:"dl-conf-sec"},i);let n=/^(\s*[A-Za-z0-9]+\s*=)\s*(.*)$/.exec(i);if(!n)return document.createTextNode(i);let a=/^(\s*)(PrivateKey|PresharedKey)\b/.test(i);return e("span",{},[e("span",{class:"dl-conf-k"},n[1])," ",a&&!t?e("span",{class:"dl-conf-mask"},"••••••••••••••••"):n[2]])}function wa(i){let t=!1,n=e("pre",{class:"dl-conf"}),a=()=>dom.content(n,i.conf.split(` `).flatMap((r,l)=>l?[` -`,cn(r,t)]:[cn(r,t)])),i=e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),t=!t,dom.content(i,[v(t?"x":"key"),t?"Hide key":"Show key"]),a()}},[v("key"),"Show key"]);a();let o=new Blob([s.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"},s.filename),e("span",{class:"dl-sub"},`AmneziaWG · ${o} bytes · import it in the app`)]),z([v("download")," Download"],()=>fe(s.filename,s.conf,"application/octet-stream"),"positive")]),e("details",{class:"dl-params"},[e("summary",{},[v("chevron"),e("span",{},"Configuration"),e("span",{class:"dl-spacer"}),i,e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),de(s.conf,"Configuration copied")}},[v("copy"),"Copy"])]),n])])}async function Nt(s,t="file"){if(!s.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 n=await en(s,`${s.server} · ${s.person} · ${s.name}`),a={qr:()=>e("div",{class:"dl-qr-pane"},[Ae(je(s.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"},n),z("Copy",()=>de(n,"Key copied"))]),e("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>pa(s)},i=e("div",{class:"dl-connect-body"}),o=e("div",{class:"dl-seg"}),r=l=>{o.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(i,a[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])o.appendChild(e("button",{type:"button","data-id":l,click:()=>r(l)},d));return r(t),e("div",{class:"dl-stack gap12"},[o,i])}function ha(s,t,n,a){ht?.close();let i=e("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[e("div",{class:"dl-drawer-head"},[s,e("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>l()},v("x"))]),e("div",{class:"dl-drawer-body"},t),n?e("div",{class:"dl-drawer-foot"},n):""]),o=e("div",{class:"dl-drawer-overlay dl-root",click:g=>{g.target===o&&l()}},i),r=g=>{g.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&l()};function l(){document.removeEventListener("keydown",r),o.classList.remove("open"),setTimeout(()=>o.remove(),220),ht===d&&(ht=null),a()}let d={close:l,panel:i};return document.addEventListener("keydown",r),document.body.appendChild(o),requestAnimationFrame(()=>o.classList.add("open")),ht=d,d}var pn={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 ua(s,t){let n=s.filter(a=>a.device===t&&pn[a.type]).reverse().slice(0,12);return n.length?e("div",{class:"dl-dev-log"},n.map(a=>{let[i,o,r]=pn[a.type],l=a.type==="connect"?[a.detail?e("span",{class:"dl-muted"},` from ${a.detail}`):"",a.where?e("span",{class:"dl-muted"},` · ${a.where}`):""]:a.type==="roam"?[e("span",{class:"dl-muted"},` · ${a.detail??""}`)]:a.type==="device_added"||a.type==="device_removed"||a.type==="device_keys"?[e("span",{class:"dl-muted"},be(a)==="portal"?" on the portal":be(a)==="admin"?" by you":"")]:[],d=new Date(a.ts*1e3);return e("div",{class:`dl-dev-log-row${be(a)==="admin"?" dl-ev-by-admin":""}`},[be(a)==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):e("span",{class:`dl-ev-tile ev ${i}`},v(r)),e("span",{class:"dl-row-main"},[e("span",{},o),...l]),e("span",{class:"dl-faint dl-nowrap",title:d.toLocaleString()},ce(a.ts))])})):e("div",{class:"dl-sub"},"No activity yet.")}function ga(s){return s.disabled?e("span",{class:"dl-dstat"},"Disabled"):s.online?e("span",{class:"dl-dstat ok"},"Connected"):s.handshake?e("span",{class:"dl-dstat"},`Last seen ${ce(s.handshake)}`):e("span",{class:"dl-dstat warn"},"Waiting for the first connection")}async function Ce(s,t,n,a){let i=await U(()=>N.deviceConfig(t.id));if(!i)return;let o=t,r=s,l=await Nt(i),d=e("div",{class:"dl-drawer-title"}),g=e("div",{}),f=e("div",{}),c=e("div",{},e("div",{class:"dl-sub"},"Loading…")),k=[],b=async()=>{let p=await N.events(5e3).catch(()=>null);p&&(k=p.events.filter(T=>T.device===o.id),dom.content(c,ua(p.events,o.id)))},R=()=>{let p=a?.points.find(m=>m.device===o.id&&m.ip===o.endpoint);dom.content(d,[e("span",{class:`dl-dcard-ic${o.online?" on":""}`},v(o.kind)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h3",{},o.name),z([v("edit")],()=>V(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),e("span",{class:"dl-sub"},[`${r.name} · ${_e[o.kind]}`])])]);let T=o.spark.reduce((m,y)=>m+y,0);dom.content(g,e("div",{class:"dl-dstats"},[e("div",{class:"dl-dstats-cell wide"},[e("span",{class:"dl-metric-label"},"Status"),ga(o)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"This month"),e("b",{},K(o.month[0]+o.month[1])),e("span",{class:"dl-sub dl-mono"},`↓ ${K(o.month[1])} ↑ ${K(o.month[0])}`)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"Last 7 days"),e("b",{},K(T)),sn(o.spark,120,22)])])),dom.content(f,e("div",{class:"dl-kv2"},[dn("Tunnel address",o.address),o.hostname&&r.access!=="internet"?dn("Local address",o.hostname):"",o.endpoint?ut("Client IP",e("span",{},[o.endpoint,p?e("span",{class:"dl-muted"},` · ${[p.city,p.org].filter(Boolean).join(" · ")}`):""])):"",ut("Total",e("span",{class:"dl-kv-act"},[`↓ ${K(o.total[1])} · ↑ ${K(o.total[0])}`,e("button",{type:"button",class:"dl-linkbtn danger",click:()=>We("device",o.id,o.name,()=>setTimeout(Y,300))},"Reset")])),ut("Added",`${ca(o.created)} · ${o.created_by==="portal"?"from the portal":"by you"}`),ut("Public key",e("span",{class:"dl-mono dl-faint"},i.amnezia.client_pub_key?`${i.amnezia.client_pub_key.slice(0,16)}…`:"—"))])),dom.content(B,[z([v(o.disabled?"play":"pause"),o.disabled?" Enable":" Disable"],async()=>{await U(()=>N.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&await Y()},"neutral",o.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),z([v("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;if(await U(()=>N.deviceRotate(o.id),"New keys generated")){n(),h.close();let y=await N.status(1),P=y.people.find(H=>H.id===r.id),O=P?.devices.find(H=>H.id===o.id);P&&O&&Ce(P,O,n,y.geo)}}),e("span",{class:"dl-spacer"}),z([v("trash")," Remove"],async()=>{await ae(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await U(()=>N.deviceDelete(o.id),"Device removed")&&(h.close(),n())},"negative")])},Y=async()=>{let p=await N.status(1).catch(()=>null),T=p?.people.find(y=>y.id===r.id),m=T?.devices.find(y=>y.id===o.id);!p||!T||!m||(r=T,o=m,a=p.geo,R(),n())},V=()=>{let p=e("input",{type:"text",class:"cbi-input-text",value:o.name,maxlength:48});ne(`Rename ${o.name}`,[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},p)])],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Save",async()=>{await U(()=>N.deviceUpdate(o.id,p.value,void 0),"Renamed")&&(J(),await Y())},"positive")]),setTimeout(()=>p.select(),50)},B=e("div",{class:"dl-drawer-actions"}),w=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Connect")]),o.config_stale?e("div",{class:"dl-note warn"},[v("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.")]):"",l]),D=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:()=>Le({people:[r]},k,"csv",o.id)},"Export"),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Te(`Clear ${o.name}'s activity`,`Removes events about ${o.name}.`,{device:o.id},b)},"Clear"),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),c]),E=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},e("h4",{},"Details")),f]),M=!o.handshake||o.config_stale,u=e("div",{class:"dl-stack gap16"},M?[g,w,E,D]:[g,E,D,w]);b();let $=window.setInterval(()=>{Y(),b()},8e3),h=ha(d,u,B,()=>clearInterval($));R()}function Fe(s,t){let n=e("input",{type:"text",class:"cbi-input-text",placeholder:_e.phone,maxlength:48}),a="phone",i=e("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},nn.map(r=>e("button",{type:"button",role:"radio",class:r===a?"on":"","aria-checked":r===a?"true":"false","data-kind":r,click:()=>{a=r,i.querySelectorAll("button").forEach(l=>{let d=l.dataset.kind===r;l.classList.toggle("on",d),l.setAttribute("aria-checked",d?"true":"false")}),n.placeholder=_e[r]}},[v(r),e("span",{},_e[r])]))),o=s.devices.length>=s.device_limit;ne(`Add a device for ${s.name}`,[o?e("p",{class:"dl-hint"},`${s.name} already has ${s.devices.length} of ${s.device_limit} devices. As admin you can still add one.`):"",e("div",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Type"),i]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Name"),n])],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Add device",async()=>{let r=n.value.trim()||n.placeholder.replace(/^e\.g\. /,""),l=await U(()=>N.deviceCreate(s.id,r,a));if(!l)return;J(),X(`${r} added`,"success",3e3),t();let d=await N.status(1),g=d.people.find(c=>c.id===s.id),f=g?.devices.find(c=>c.id===l.id);g&&f&&Ce(g,f,t,d.geo)},"positive")]),setTimeout(()=>n.focus(),50)}var Se=1080,Xe=1512,xe=96,ma="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",fa="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",Ze=s=>s.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function va(s,t,n){let a=new URL(n),i=a.pathname.slice(1),o=Math.min(92,Math.floor((Se-2*xe)/(.58*(4+s.name.length)))),r=Se-2*xe,l=392,d=40,g=je(n,2).replace("`${Y}`;return``+f(xe+82,xe+42,36,"#a3a3a3",Ze(t))+f(xe,276,o,"#ffffff",`Hi, ${Ze(s.name)}`,'font-weight="600"')+f(xe,340,40,"#8a8a8a",`Scan to connect to ${Ze(t)}`)+``+g+`${Ze(i)}`+f(Se/2,l+r+156,34,"#737373",Ze(a.host),'text-anchor="middle"')+""}async function ba(s){let t=new Image;t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(s)}`,await t.decode();let n=document.createElement("canvas");return n.width=Se,n.height=Xe,n.getContext("2d").drawImage(t,0,0,Se,Xe),new Promise((a,i)=>n.toBlob(o=>o?a(o):i(new Error("Could not draw the card")),"image/png"))}async function et(s,t,n={}){if(!s.link){X("The personal portal is off. Turn it on in Settings.","warning");return}let a=s.link,i=await U(()=>ba(va(s,t,a)));if(!i)return;let o=new File([i],`${s.id}-invite.png`,{type:"image/png"}),r=URL.createObjectURL(i),l=navigator,d=!!l.canShare?.({files:[o]}),g=()=>{URL.revokeObjectURL(r),J()},f=d?z([v("link")," Share card"],async()=>{try{await l.share({files:[o],title:`Invite ${s.name}`})}catch{}},"positive"):z([v("download")," Download card"],()=>fe(o.name,i),"positive");ne(n.title??`Invite ${s.name}`,e("div",{class:"dl-invite"},[e("img",{src:r,alt:`Invite card for ${s.name}`}),e("div",{class:"dl-invite-side"},[e("p",{class:"dl-muted"},n.lead??`Send ${s.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:()=>de(a,"Personal link copied")},[e("span",{},a.replace(/^https:\/\//,"")),v("copy")]),...(s.links??[]).filter(c=>c!==a).map(c=>e("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>de(c,"Link copied")},[e("span",{},c.replace(/^https?:\/\//,"")),e("span",{class:`dl-pill ${c.startsWith("http:")?"warn":""}`},c.startsWith("http:")?"HTTP":"Also"),v("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"},[f,z([v("copy")," Copy link"],()=>de(a,"Personal link copied"))])])]),[e("button",{class:"cbi-button cbi-button-neutral",click:g},"Done")],"wide")}var xa={active:"",paused:"pause",paused_all:"pause",expired:"calendar",quota:"chart",hours:"clock",no_server:"alert"};function zt(s){if(s.state==="active")return"";let t=e("span",{class:`dl-ibadge ${ka(s)}`,"aria-label":Tt[s.state]},v(xa[s.state]||"alert"));return le(t,()=>[e("div",{class:"dl-tip-title"},Tt[s.state])]),t}function wa(s){let t=s.devices.length,n=Math.max(1,s.device_limit,t),a=Math.min(160,n*22+(n-1)*3);return e("div",{class:"dl-slotbar",title:`${t} of ${s.device_limit} devices`},[e("span",{class:"dl-slotbar-segs",style:`width: ${a}px`},Array.from({length:n},(i,o)=>e("i",{class:o>=s.device_limit?"over":oe("span",{class:`dl-ibadge ${a}`},v(a==="lan"?"home":"globe"))));return le(n,()=>[e("div",{class:"dl-tip-title"},Oe[s.access]),s.access==="lan"&&s.services?.length?e("div",{class:"dl-muted"},`${s.services.length} home service${s.services.length===1?"":"s"} only`):""]),n}function ka(s){return s.state==="active"?"ok":s.state==="quota"||s.state==="expired"?"bad":"warn"}function $a(s,t){let n=s,i=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(o=>e("button",{type:"button",class:`dl-choice${o.v===n?" selected":""}`,"data-v":o.v,click:()=>{n=o.v,i.querySelectorAll(".dl-choice").forEach(r=>r.classList.toggle("selected",r.dataset.v===o.v)),t?.(o.v)}},[e("span",{class:"dl-choice-title"},[v(o.ic),Oe[o.v]]),e("span",{class:"dl-choice-text"},o.text)])));return{el:i,get:()=>n}}function _a(s){return`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`}function hn(s){let t=Ne(s.expires);return s.state==="quota"||s.state==="expired"||t!=null&&t<=Math.max(s.expire_warn,3)||!!s.quota_limit&&s.quota_used>=s.quota_limit*.9}function La(s){let t=s?new Date(`${s}T12:00:00`):new Date,n=t.getTime()t===new URLSearchParams(location.search).get("filter"))??"all";this.sort="seen";this.noFooter=!0;this.serverId=null;this.polling=!1;this.el=null;this.statusSeq=0;this.statusShown=0}async load(){return N.status(30)}scope(t){return this.serverId?lt(t,this.serverId):t}embed(t,n){return this.serverId=n,this.render(t)}person(t){return this.st.people.find(n=>n.id===t)}async latestStatus(){let t=++this.statusSeq,n=await N.status(30).catch(()=>null);return!n||te("em",{},n.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people."),a.serverId&&(r.filter=l=>a.st.people.some(d=>d.id===l)),r.handleAdd=()=>a.openCreate(),r.handleRemove=l=>a.remove(l),r.renderRowActions=()=>e("div",{class:"dl-none"}),i=r.option(form.DummyValue,"_card"),i.modalonly=!1,i.textvalue=l=>a.renderCard(e("div",{class:"dl-card",id:`dl-card-${l}`}),l),o.render().then(l=>{l.classList.add("dl-map","dl-root");let d=e("select",{class:"dl-select","aria-label":"Sort",change:f=>{a.sort=f.target.value,a.decorate()}},[e("option",{value:"seen"},"Last seen"),e("option",{value:"name"},"Name"),e("option",{value:"usage"},"Usage")]),g=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",id:"dl-people-count"},this.countText())]),n.servers.length?z([v("plus")," Add person"],()=>a.openCreate(),"add"):""]),n.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",id:"dl-people-tabs",role:"tablist"}),e("div",{class:"dl-toolbar-end"},[d,a.serverId?z([v("plus")," Add person"],()=>a.openCreate(),"add"):""])]),l]);return this.el=g,requestAnimationFrame(()=>this.decorate()),this.polling||(this.polling=!0,poll.add(()=>a.el?.isConnected?a.poll():Promise.resolve(),10)),!un&&new URLSearchParams(location.search).get("add")&&(un=!0,setTimeout(()=>a.openCreate(),100)),g})}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(){let t=document.getElementById("dl-people-count");t&&(t.textContent=this.countText());let n=this.st.people,a={all:n.length,online:n.filter(c=>c.online>0).length,attention:n.filter(hn).length,paused:n.filter(c=>c.state!=="active"&&c.state!=="quota"&&c.state!=="expired").length},i=document.getElementById("dl-people-tabs");if(i){let c={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(i,Object.keys(c).map(k=>e("button",{type:"button",role:"tab",class:k===this.filter?"on":"",click:()=>{this.filter=k,this.decorate()}},[c[k],e("b",{class:k==="attention"&&a[k]?"warn":""},String(a[k]))])))}let o=c=>!(this.filter==="online"&&!c.online||this.filter==="attention"&&!hn(c)||this.filter==="paused"&&!(c.state!=="active"&&c.state!=="quota"&&c.state!=="expired")),r=[...n].sort((c,k)=>this.sort==="name"?c.name.localeCompare(k.name):this.sort==="usage"?k.month[0]+k.month[1]-(c.month[0]+c.month[1]):k.online-c.online||k.last_seen-c.last_seen),l=null,d=0;for(let c of r){let b=document.getElementById(`dl-card-${c.id}`)?.closest(".cbi-section-table-row");if(!b)continue;l??(l=b.parentElement),l?.appendChild(b),b.classList.toggle("dl-off",c.state!=="active"),b.classList.toggle("dl-attn-row",c.state==="quota"||c.state==="expired");let R=o(c);b.classList.toggle("dl-filtered",!R),R&&d++}let g=l?.closest(".cbi-section-table")??l,f=document.getElementById("dl-people-none");g&&n.length&&!d?(f??(f=e("div",{id:"dl-people-none",class:"dl-empty"})),dom.content(f,e("p",{},"No one here right now.")),f.parentElement!==g.parentElement&&g.after(f)):f?.remove()}async poll(){let t=await this.latestStatus();if(!t)return;let n=this.scope(t);this.st=n,this.paintCards(),this.decorate()}async quick(t,n,a){await U(()=>N.personUpdate(t.id,n),a)&&await this.poll()}renderCard(t,n){let a=this.person(n);if(!a)return dom.content(t,e("em",{},"Not saved yet — use “Save & Apply”.")),t;let i=Ne(a.expires),o=Math.max(0,a.device_limit-a.devices.length),r=[];if(a.expires){let c=i!=null&&i>=0&&i<=Math.max(a.expire_warn,3),k=i!=null&&i<0;r.push(e("span",{class:`dl-pill-ic${k?" bad":c?" warn":""}`,title:`Access ends ${$e(a.expires)}`},[v("calendar"),k?`ended ${$e(a.expires)}`:c?`ends in ${i} day${i===1?"":"s"}`:`until ${$e(a.expires)}`]))}a.hours&&r.push(e("span",{class:"dl-pill-ic",title:"Allowed hours"},[v("clock"),a.hours.replace("-","–")]));let l=st(a.devices).map(c=>e("button",{type:"button",class:`dl-chip${c.disabled?" disabled":""}${c.online?" live":""}`,title:`${_e[c.kind]} · ${c.address}${c.online?` · online from ${c.endpoint}`:c.handshake?` · seen ${ce(c.handshake,this.st.now)}`:""}`,click:k=>{k.preventDefault(),Ce(a,c,()=>this.refresh(),this.st.geo)}},[v(c.kind),e("span",{class:"dl-chip-name"},c.name),!c.handshake&&!c.disabled?e("span",{class:"dl-chip-tag"},"not set up"):""]));l.push(e("button",{type:"button",class:"dl-chip add","aria-label":"Add device",title:o>0?"Add device":"Add device · over the limit, admins can still add",click:c=>{c.preventDefault(),Fe(a,()=>this.refresh())}},v("plus")));let d=[];a.state==="quota"&&a.quota_period==="month"&&d.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)&&d.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{expires:La(a.expires)},"Extended by 1 month")},"Extend 1 month"));let g=we("more","More",c=>ye(c.currentTarget,[{label:"Open",icon:v("open"),run:()=>{location.href=ve(a.id)}},a.link?{label:"Invite card",icon:v("qr"),run:()=>et(a,this.st.servers.find(k=>k.id===a.server)?.name??"Home")}:null,o>0?{label:"Add device",icon:v("plus"),run:()=>Fe(a,()=>this.refresh())}:null,null,{label:a.paused?"Resume":"Pause",icon:v(a.paused?"play":"pause"),warn:!a.paused,run:()=>this.togglePause(a)},{label:"Delete",icon:v("trash"),danger:!0,run:()=>this.remove(a.id)}].filter((k,b,R)=>k||b>0&&R[b-1])),"neutral","dl-icon-only"),f=e("div",{class:"dl-pcard-actions"},[a.link?we("link","Copy link",()=>de(a.link,"Personal link copied"),"neutral","dl-icon-only"):"",g]);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":""}`},ze(a.name)),e("div",{class:"dl-pcard-who"},[e("div",{class:"dl-card-head"},[e("a",{class:"dl-card-name",href:ve(a.id)},a.name),zt(a),ya(a),...r]),wa(a)])]),e("div",{class:"dl-chips"},l),d.length?e("div",{class:"dl-fixes"},d):""]),this.usageSide(a,f)])),t}usageSide(t,n){let a=t.quota_used||t.month[0]+t.month[1],i=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,o=t.devices.reduce((f,c)=>f+(c.spark[c.spark.length-1]??0),0),r=t.rate?.[t.rate.length-1],l=t.online&&r&&this.st.now-r[0]<180,d=e("div",{class:`dl-usebar${i>=100?" bad":i>=90?" warn":""}`});if(t.quota_limit){let f=e("i",{class:"fill"});f.style.width=`${i}%`,d.appendChild(f),le(d,()=>[e("div",{class:"dl-tip-title"},`${i.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${K(t.quota_used)} of ${K(t.quota_limit)} · ${K(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 f=t.devices.map(c=>({d:c,v:c.month[0]+c.month[1]})).filter(c=>c.v>0).sort((c,k)=>k.v-c.v);f.forEach((c,k)=>{let b=e("i",{class:`c${Math.min(k,4)}`});b.style.flexGrow=String(c.v),d.appendChild(b)}),f.length&&le(d,()=>[e("div",{class:"dl-tip-title"},"This month by device"),...f.map((c,k)=>e("div",{class:"dl-tip-row"},[e("span",{class:`dl-swatch c${Math.min(k,4)}`}),e("span",{},c.d.name),e("b",{},K(c.v))]))])}let g=t.quota_limit?`${K(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"),n]),e("div",{class:"dl-use-num"},[e("b",{class:a?"":"dl-faint"},K(a)),e("span",{class:"dl-faint"},t.quota_limit?`of ${K(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"},[`↓ ${ke(r[2])}`,e("span",{class:"dl-faint"},`↑ ${ke(r[1])}`)]):e("div",{class:"dl-faint dl-pside-foot"},o?`today ${K(o)} · ${g}`:g)])}async togglePause(t){await U(()=>N.personPause(t.id,!t.paused),t.paused?`${t.name} resumed`:`${t.name} paused`)&&await this.refresh()}async remove(t){let n=this.person(t);await ae(`Remove ${n?.name??t}?`,`All ${n?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await U(()=>N.personDelete(t),"Person removed")&&await this.refresh()}openCreate(){let t=this.st;if(!t.servers.length){X("Set up the server first.","warning");return}let n=e("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),a=$a("internet"),i=e("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:t.settings.default_device_limit}),o=e("input",{type:"date",class:"cbi-input-text"}),r=e("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited"}),l=(c,k)=>e("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{if(!k)o.value="";else{let b=new Date;b.setMonth(b.getMonth()+k),o.value=_a(b)}}},c),d=t.servers[0],g=!this.serverId&&t.servers.length>1?e("select",{class:"cbi-input-select"},t.servers.map(c=>e("option",{value:c.id},c.name))):null,f=(c,k,b)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},c),e("div",{class:"cbi-value-field"},[k,b?e("div",{class:"cbi-value-description"},b):""])]);ne("Add person",[f("Name",n),g?f("Server",g):"",e("div",{class:"cbi-value dl-block"},[e("label",{class:"cbi-value-title"},"Access"),e("div",{class:"cbi-value-field"},a.el)]),f("Devices",i,"How many devices they can add themselves."),f("End date",e("div",{class:"dl-actions"},[o,l("1 month",1),l("3 months",3),l("1 year",12),l("None",0)]),"Optional."),f("Monthly data (GB)",r,"Optional. They are paused when it runs out and resumed next month.")],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Create and copy link",async()=>{let c=await U(()=>N.personCreate(n.value.trim(),"",g?.value??d.id,a.get(),Number(i.value)||t.settings.default_device_limit,o.value,Number(r.value)||0,"month"));c&&(c.link&&await de(c.link,"Personal link copied"),this.showCreated(c.id,n.value.trim(),c.link,t.servers.find(k=>k.id===(g?.value??d.id))?.name??d.name),await this.refresh())},"positive")]),setTimeout(()=>n.focus(),50)}showCreated(t,n,a,i){if(a){et({id:t,name:n,link:a},i,{title:`${n} is ready`,lead:`Send ${n} the card or the link. They open it, add their devices and connect — no account needed.`});return}ne(`${n} 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:J},"Done")])}};var Sa={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link"},Ma=300*1e3;async function tt(s,t,n){if(!t.length)return!0;if(!await ae(`Install ${Sa[s]}?`,`${t.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,"Install"))return!1;let i=(await N.updatesStatus().catch(()=>null))?.job?.started??0;if(!await U(()=>N.updatesRun(`pkgs:${t.join(",")}`)))return!1;X(`Installing ${t.join(", ")}…`,"info",4e3);let o=Date.now()+Ma;for(;Date.now()setTimeout(d,2e3));let l=(await N.updatesStatus().catch(()=>null))?.job;if(!(!l||l.started===i||l.state==="running"))return l.state==="done"?(X(`${t.join(", ")} installed`,"success"),setTimeout(()=>n?.(),4e3),!0):(X(l.error??"Installation failed","error"),!1)}return X("Still installing: see Updates for the log.","warning"),!1}async function gn(s,t){let n=await U(()=>N.updatesStatus());return n?tt(s,n.needs?.[s]??[],t):!1}var Ea=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],Ta={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function gt(s,t,n){let a=e("button",{type:"button",role:"switch",class:`dl-switch${s?" on":""}`,"aria-checked":s?"true":"false","aria-label":t,click:()=>{let i=!a.classList.contains("on");a.classList.toggle("on",i),a.setAttribute("aria-checked",i?"true":"false"),n(i)}},e("i"));return a}function mn(s,t="Interfaces"){let n=e("section",{class:"dl-setsec dl-ifcard"},e("div",{class:"dl-setsec-body"},e("p",{class:"dl-muted"},"Loading interfaces…"))),a,i=!0,o="",r=!0,l=!0,d=!0,g=new Set,f="",c=()=>JSON.stringify([l,d,i,i?"":o,r,[...g].sort()]),k=()=>a.detected.lan||a.saved.lan||"",b=()=>(i?a.detected.wan||a.saved.wan:o)||"",R=()=>new Map(a.devices.map(u=>[u.name,u])),Y=()=>{let u=R();return[...r&&k()?[k()]:[],...[...g].filter(h=>h!==k())].filter(h=>h!==b()).map(h=>u.get(h)??{name:h,nets:[],missing:!0})},V=(u,$)=>{a=u,$&&(i=u.config.auto_wan,o=u.config.wan_device||u.detected.wan||u.saved.wan||"",r=u.config.auto_lan,l=u.config.lan_like,d=u.config.device_mesh,g=new Set(u.config.lan_devices),f=c()),M()},B=async u=>{let $=await N.interfaces(s).catch(h=>(X(h.message,"error"),null));$&&V($,u)};function w(u){let $=r&&u.name===k(),h=u.name===b(),p=!$&&g.has(u.name),m=!(!!u.own||!!u.master||h||$)&&(u.nets.length>0||p||!!u.missing),y=(p||$)&&!u.zone&&!u.missing,P=u.missing?"Not present right now":u.own?"This server":u.master?`Port of ${u.master}`:h?`Internet${u.zone?` · zone ${u.zone}`:""}`:u.nets.length?u.nets.join(", "):"No IPv4 network",O=e("button",{type:"button",class:`dl-if${p?" sel":""}${$?" auto":""}${!m&&!p&&!$?" off":""}${y?" warn":""}`,"aria-pressed":p||$?"true":"false","aria-disabled":m?null:"true",click:()=>{m&&(g.has(u.name)?g.delete(u.name):g.add(u.name),M())}},[e("span",{class:"dl-if-ic"},v(Ta[u.kind]??"link")),e("span",{class:"dl-if-main"},[e("span",{class:"dl-if-name"},u.name),e("span",{class:"dl-if-sub"},P)]),$?e("span",{class:"dl-if-badge ok"},"Auto"):p?e("span",{class:"dl-if-check"},v("check")):""]);return le(O,()=>[e("div",{class:"dl-tip-title"},u.name),e("div",{class:"dl-muted"},[u.logical?`Interface ${u.logical}`:"No netifd interface",u.zone?` · zone ${u.zone}`:" · no firewall zone"]),u.members.length?e("div",{class:"dl-muted"},`Ports: ${u.members.join(", ")}`):"",u.nets.length?e("div",{class:"dl-mono"},u.nets.join(", ")):"",y?e("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",u.master?e("div",{class:"dl-muted"},`Choose ${u.master} to include it.`):""]),O}function D(){let u=a.like_home;return!l||!a.config.lan_like?"":!a.needs?.length&&u.active&&u.bridged?"ok":"warn"}function E(){let u=a.like_home;return l?a.needs?.length?[e("span",{class:"dl-warn"},`Needs ${a.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:a.config.lan_like?u.active&&u.bridged?["Internet traffic enters ",e("span",{class:"dl-mono"},u.dev??"")," as ",e("span",{class:"dl-mono"},u.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[e("span",{class:"dl-warn"},`Not working: ${u.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."]}function M(){let u=e("select",{class:"cbi-input-select","aria-label":"Internet interface",change:P=>{o=P.target.value,M()}},a.devices.filter(P=>!P.own&&!P.master&&P.zone&&!P.missing).map(P=>e("option",{value:P.name,selected:P.name===o?"selected":null},`${P.name} · zone ${P.zone}`))),$=(P,O)=>{let H=Z=>e("span",{class:"dl-mono"},Z);return P?e("span",{},[" Now: ",H(P),...O&&O!==P?[", was ",H(O)]:[],"."]):e("span",{},O?[" Not found now: using ",H(O),"."]:[" Not found."])},h=Ea.map(([P,O])=>{let H=a.devices.filter(Z=>Z.category===P);return H.length?e("div",{class:"dl-ifgroup"},[e("h4",{},O),e("div",{class:"dl-ifgrid"},H.map(w))]):""}),T=Y().flatMap(P=>P.nets.map(O=>[O,P.name])),m=c()!==f,y=z("Save",async()=>{let P=await U(()=>N.serverInterfaces(s,i,i?"":o,r,[...g],l,d),"Interfaces saved");P&&(V(P,!0),P.nets_changed&&P.lan_only&&X(`${P.lan_only} ${P.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:!m});dom.content(n,[e("div",{class:"dl-setsec-body"},[e("div",{class:"dl-panel-head"},[e("h3",{},t),e("span",{class:"dl-spacer"}),z([v("reset")," Rescan"],()=>B(!1),"neutral",{title:"Read the interfaces again"})]),e("div",{class:"dl-setrow"},[e("div",{class:"dl-lh-main"},[e("span",{class:`dl-need-ic ${D()}`},v("home")),e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},"Internet like a home device"),e("span",{class:"dl-sub"},E())])]),e("div",{class:"dl-setrow-ctl dl-if-wanctl"},[l&&a.needs?.length?z("Install",()=>tt("home",a.needs,()=>B(!1)),"positive"):"",gt(l,"Internet like a home device",P=>{l=P,M()})])]),e("div",{class:"dl-setrow"},[e("div",{class:"dl-lh-main"},[e("span",{class:"dl-need-ic"},v("link")),e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},"Devices reach each other"),e("span",{class:"dl-sub"},"Devices of people with Home access can open connections to each other on this server, like home devices do. Internet-only people never.")])]),e("div",{class:"dl-setrow-ctl"},gt(d,"Devices reach each other",P=>{d=P,M()}))]),e("div",{class:"dl-setrow"},[e("div",{class:"dl-lh-main"},[e("span",{class:"dl-need-ic"},v("globe")),e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},"Auto-detect WAN"),e("span",{class:"dl-sub"},["The interface with the default route: the server port opens there and Internet access leaves through it.",$(a.detected.wan,a.saved.wan)])])]),e("div",{class:"dl-setrow-ctl dl-if-wanctl"},[i?"":u,gt(i,"Auto-detect WAN",P=>{i=P,M()})])]),e("div",{class:"dl-setrow"},[e("div",{class:"dl-lh-main"},[e("span",{class:"dl-need-ic"},v("network")),e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},"Auto-detect LAN"),e("span",{class:"dl-sub"},["Adds the detected LAN to the home network.",$(a.detected.lan,a.saved.lan)])])]),e("div",{class:"dl-setrow-ctl"},gt(r,"Auto-detect LAN",P=>{r=P,M()}))]),e("div",{class:"dl-iflead"},[e("b",{},"Home network"),e("span",{class:"dl-sub"},"What people with Home access can reach, and where their devices can be reached from. Click to add an interface; bridge ports and Wi-Fi in a bridge come with the bridge.")]),...h]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub dl-if-summary"},T.length?["Home access reaches ",...T.flatMap(([P,O],H)=>[H?", ":"",e("span",{class:"dl-mono"},P),` (${O})`]),l?" · Internet like a home device":b()?` · Internet via ${b()}`:""]:["No home network: Home access reaches nothing but this router.",b()?` Internet via ${b()}.`:""]),y])])}return B(!0),n}function Me(s,t,n){let a=e("button",{type:"button",role:"switch",class:`dl-switch${s?" on":""}`,"aria-checked":s?"true":"false","aria-label":t,click:()=>{let i=!a.classList.contains("on");a.classList.toggle("on",i),a.setAttribute("aria-checked",i?"true":"false"),n?.(i)}},e("i"));return a}var Ke=s=>s.classList.contains("on");function se(s,t={}){return e("input",{type:"text",class:"cbi-input-text",value:s,...t})}function Q(s,t,n){return e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},s),n?e("span",{class:"dl-sub"},n):""]),e("div",{class:"dl-setrow-ctl"},t)])}function Ve(s,t,n,a=""){return e("section",{class:`dl-setsec ${a}`},[e("div",{class:"dl-setsec-body"},[s?e("h3",{},s):"",...t]),n.length?e("div",{class:"dl-setsec-foot"},n):""])}function pe(s,t,n,a){return e("div",{class:"dl-group"},[e("div",{class:"dl-group-head"},[e("span",{class:"dl-group-ic"},v(s)),e("span",{class:"dl-stack"},[e("b",{},t),n?e("span",{class:"dl-sub"},n):""])]),e("div",{class:"dl-group-body"},a.filter(i=>i!==""))])}var fn=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["disguise","Disguise"],["tunnel","Tunnel"]],Ca={general:"connection",network:"connection",interfaces:"access",advanced:"tunnel"},vn=[["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 Da(s){let t=g=>s[g]!=null&&s[g]!=="",n=vn.filter(([g])=>t(g));if(!n.length)return null;let a=(g,f)=>e("span",{class:"dl-pv"},[e("i",{},f),e("b",{},g==="header_protection_key"?`${s[g].slice(0,6)}••••`:s[g])]),i=(g,f,c,k)=>{let b=vn.filter(([R])=>k.includes(R)&&t(R));return b.length?e("div",{class:"dl-pgroup"},[e("div",{class:"dl-pgroup-head"},[v(f),e("b",{},g)]),e("p",{},c),e("div",{class:"dl-pvals"},b.map(([R,Y])=>a(R,Y)))]):""},o=Number(s.jc||0),r=(s.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=n.map(([g,f])=>`${f} = ${s[g]}`).join(` -`),d=e("div",{class:"dl-pgrid"},[i("Junk packets","zap",o?`${o} random packet${o===1?"":"s"} of ${s.jmin}–${s.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),i("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),i("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),i("Signatures","globe",r,["i1","i2","i3","i4","i5"]),i("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"]),i("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",{},[v("chevron"),e("span",{},"Current parameters"),e("span",{class:"dl-pcount"},String(n.length)),e("span",{class:"dl-spacer"}),e("button",{type:"button",class:"dl-linkbtn",click:g=>{g.preventDefault(),de(l,"Parameters copied")}},"Copy as config")]),d])}var Rt=(s,t)=>{let n=new URLSearchParams;s&&n.set("server",s),t&&t!=="overview"&&n.set("section",t);let a=n.toString();return`${L.url("admin/network/dawnline/server")}${a?`?${a}`:""}`},nt=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 N.status(31),n=t.servers.length?null:await N.setupDefaults();return[t,n]}render([t,n]){if(this.st=t,!t.servers.length&&n)return this.wizard(n);let a=new URLSearchParams(location.search),i=a.get("section")??"",o=Ca[i]??i;return fn.some(([r])=>r===o)&&(this.section=o),this.srvId=(t.servers.find(r=>r.id===a.get("server"))??t.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),poll.add(async()=>{if(this.section!=="overview")return;let r=await N.status(31).catch(()=>null);if(!r||!r.servers.length)return;this.st=r;let l=this.current();dom.content(this.headEl,this.head(l)),this.paintTabs(),this.ov[l.id]?.update(r)},10),this.root}current(){return this.st.servers.find(t=>t.id===this.srvId)??this.st.servers[0]}async refresh(){let t=await N.status(31).catch(()=>null);t&&(this.st=t,t.servers.length?this.paint():location.href=Rt())}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(n=>e("button",{type:"button",role:"tab",class:`dl-srvtab${n.id===t.id?" on":""}`,"aria-selected":n.id===t.id?"true":"false",click:()=>{n.id!==this.srvId&&(this.srvId=n.id,this.paint())}},[e("i",{class:`dot ${n.up?"ok":"bad"}`}),e("b",{},n.name),e("span",{class:"dl-mono dl-faint"},`:${n.port}`)])),e("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[v("plus"),"Add server"])]))}paintSections(){dom.content(this.secEl,e("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},fn.map(([t,n])=>e("button",{type:"button",role:"tab","data-section":t,class:t===this.section?"on":"","aria-selected":t===this.section?"true":"false",click:()=>this.showSection(t)},n))))}go(t,n){let a=this.pp[this.current().id];if(n&&a)a.filter=n,a.el&&a.decorate();else if(n){let i=this.pp[this.current().id]=new Ie;i.filter=n}this.showSection(t),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let t=[...Object.values(this.ov).map(n=>n.el),...Object.values(this.pp).map(n=>n.el)];for(let n of t)n&&this.bodyEl.contains(n)&&n.remove()}showSection(t){this.section=t,this.secEl.querySelectorAll("[data-section]").forEach(r=>{let l=r.dataset.section===t;r.classList.toggle("on",l),r.setAttribute("aria-selected",l?"true":"false")});let n=this.st,a=this.current(),o={overview:()=>{let r=this.ov[a.id];return r?(r.update(n),r.el):(this.ov[a.id]=new dt(a.id,(l,d)=>this.go(l,d))).mount(n)},people:()=>{var g,f;let r=this.pp[a.id];if(r?.el)return r.poll(),r.el;let l=e("div",{},e("p",{class:"dl-muted"},"Loading people…"));return((g=this.pp)[f=a.id]??(g[f]=new Ie)).embed(n,a.id).then(c=>{l.isConnected?dom.content(l,c):l.replaceChildren(c)}),l},connection:()=>this.connection(a),access:()=>this.access(a),disguise:()=>this.disguise(a),tunnel:()=>this.tunnel(a)}[t]();this.detachKept(),dom.content(this.bodyEl,o)}head(t){let n=this.st,a=(l,d)=>e("span",{class:"dl-addrbar-seg"},[v(l),...d]),i=`${t.endpoint||"—"}:${t.port}`,o=!t.enabled||n.settings.paused_all,r=e("div",{class:"dl-actions"},[o?z([v("play")," Turn on"],async()=>{n.settings.paused_all&&!await U(()=>N.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":"Not running":"Turned off"),n.settings.paused_all&&t.enabled?e("span",{class:"dl-pill warn"},"Off"):"",e("span",{class:"dl-spacer"}),r]),e("div",{class:"dl-addrbar"},[e("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address and port",click:()=>de(i,"Address copied")},[v("globe"),e("span",{class:"dl-mono"},i),v("copy")]),a("tunnel",[e("span",{class:"dl-mono"},t.ifname)]),a("network",[e("span",{class:"dl-mono"},t.subnet)]),t.up?a("clock",[`up ${tn(t.uptime)}`]):""])])}async save(t,n,a="Saved"){await U(()=>N.serverUpdate(t.id,n),a)&&await this.refresh()}connection(t){let n=se(t.name,{placeholder:"Home"}),a=se(t.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),i=se(String(t.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),o=se(t.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),r=se(String(t.mtu??""),{placeholder:"1380",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),l=se(String(t.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"});return Ve("Connection",[e("p",{class:"dl-muted"},"How devices find this server, and what goes into their configuration."),pe("router","Server","What people see",[Q("Name",n,"Shown to people in their portal.")]),pe("globe","Devices connect to","Where the tunnel answers from the internet",[Q("Public address",a,"Hostname or IP of the router on the internet. A DDNS name keeps links working when your IP changes."),Q("UDP port",i,"Opened on the WAN firewall automatically.")]),pe("file","In every device configuration","Changing these marks devices “Update config” until they import again",[Q("DNS for devices",o,"Empty = this router, which sends each query where your home network would."),Q("MTU",r,"Lower it if some sites hang on mobile networks."),Q("Keep-alive",l,"Seconds between packets devices send to keep NAT open. 0 = off.")])],[e("span"),z("Save",()=>this.save(t,{name:n.value,endpoint:a.value,port:i.value,dns:o.value,mtu:r.value,keepalive:l.value}),"positive")])}access(t){let n=this.st.services;return e("div",{class:"dl-stack gap16"},[mn(t.id,"Access"),Ve("Home services",[e("p",{class:"dl-muted"},"People with Home-only access can be limited to these services instead of the whole home network (chosen per person). The list is shared by all servers."),e("div",{class:"dl-list"},n.length?n.map(a=>e("div",{class:"dl-row"},[v("home"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},a.name),e("span",{class:"dl-mono dl-faint"},`${a.address}${a.ports.length?` · ports ${a.ports.join(", ")}`:" · all ports"}`)])])):[e("div",{class:"dl-row dl-muted"},"No services yet.")])],[e("span"),e("a",{class:"cbi-button cbi-button-neutral",href:`${L.url("admin/network/dawnline/settings")}#dl-set-services`},"Edit in Settings")])])}disguise(t){let n=qe(t.preset)?t.preset:void 0,a=n??"standard",i=z("",()=>this.applyDisguise(t,a,a===n),"positive"),o=()=>{dom.content(i,a===n?[v("reset")," Generate new values"]:`Switch to ${qe(a).title}`)};o();let r=Da(t.obf??{});return Ve("Disguise",[e("p",{class:"dl-muted"},"AmneziaWG reshapes the tunnel so networks that block VPNs do not recognise it. Every device gets these settings in its configuration."),Ct(this.st.awg,a,l=>{a=l,o()},n),this.st.awg.v3?"":De("info",["This router runs an older AmneziaWG. ",e("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]),r??""],[e("span",{class:"dl-sub"},"Applies at once. Every device on this server must import its configuration again."),i])}async applyDisguise(t,n,a){let i=qe(n),r=this.st.people.filter(d=>d.server===t.id).reduce((d,g)=>d+g.devices.length,0);await ae(a?"Generate new disguise values?":`Switch to ${i.title}?`,`${r} device${r===1?"":"s"} stop connecting until they import their configuration again (from their personal link or from you).${n==="max"?" They need an app with AmneziaWG 3.1.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await U(()=>N.serverObfuscation(t.id,n),a?"New values applied":`${i.title} applied`)&&(X("Devices are marked “Update config” until they import again.","info",6e3),await this.refresh())}tunnel(t){let n=this.st.people.filter(i=>i.server===t.id).length,a=z(t.enabled?"Turn off":"Turn on",async()=>{t.enabled&&!await ae(`Turn off ${t.name}?`,`The tunnel stops and ${n} ${n===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"},[Ve("Tunnel",[e("p",{class:"dl-muted"},"Technical details. They are set when the server is created and rarely change."),Q("Interface",e("span",{class:"dl-mono"},`${t.ifname} · router ${t.address}`)),Q("Tunnel subnet",e("span",{class:"dl-mono"},t.subnet),"Device addresses come from it."),Q("Server public key",e("span",{class:"dl-keyrow"},[e("code",{class:"dl-mono"},t.public_key),z([v("copy")],()=>de(t.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))],[]),Ve("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"},a)]),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 ${n} ${n===1?"person":"people"} with all their devices. A backup is made first.`)]),e("div",{class:"dl-setrow-ctl"},z([v("trash")," Remove"],()=>this.remove(t),"negative"))])],[],"danger")])}async addServer(){let t=await U(()=>N.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 n=this.st.people.filter(a=>a.server===t.id);ne(`Remove ${t.name}?`,[e("p",{},`This removes the tunnel, its firewall rules and ${n.length} ${n.length===1?"person":"people"} with all their devices. A backup is made first.`)],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Remove",async()=>{J(),await U(()=>N.serverDelete(t.id),"Server removed")&&setTimeout(()=>{location.href=Rt()},800)},"negative")])}wizard(t,n=!1,a){let i={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},o=0,r=e("div",{class:"dl-wizard"}),l=(c,k={})=>{let b=se(String(i[c]),k);return b.addEventListener("input",()=>{i[c]=c==="port"||c==="portal_port"?Number(b.value):b.value.trim()}),b},d=n?["Connection","Disguise"]:["Connection","Disguise","Portal"],g=[()=>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."),pe("router","Server","What people see",[Q("Name",l("name"),"Shown to people in their portal.")]),pe("globe","Devices connect to","Where the tunnel answers from the internet",[Q("Public address",l("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),"Hostname or IP address of your router on the internet."),Q("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.")]),pe("network","Tunnel network","Addresses devices get inside the tunnel",[Q("Tunnel subnet",l("subnet",{class:"cbi-input-text dl-mono"}),`Must not overlap your networks (${t.taken.join(", ")||"none found"}).`)])]),()=>e("div",{},[e("p",{},"AmneziaWG reshapes the tunnel so networks that block VPNs do not recognise it. Every device gets these settings automatically; you can change the method later."),Ct(t.awg,i.preset,c=>i.preset=c)]),()=>{let c=l("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),k=Q("Listening port",c,"TCP port on WAN for the portal; the whole port belongs to it.");k.hidden=!i.portal;let b=e("div",{class:"dl-seg",role:"radiogroup","aria-label":"Personal portal"},["off","on"].map(R=>e("button",{type:"button",role:"radio",class:R==="on"===i.portal?"on":"","aria-checked":R==="on"===i.portal?"true":"false",click:Y=>{i.portal=R==="on",k.hidden=!i.portal,b.querySelectorAll("button").forEach(V=>{let B=V===Y.currentTarget;V.classList.toggle("on",B),V.setAttribute("aria-checked",B?"true":"false")})}},R==="on"?"On":"Off")));return e("div",{class:"dl-wizard-groups"},[pe("home","Internet like a home device","How devices reach the internet",[Q("Through the home network",Me(i.lan_like,"Internet like a home device",R=>i.lan_like=R),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),pe("link","Personal portal","A page where each person adds their own devices with their personal link",[Q("Portal",b,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),k])])}],f=()=>{dom.content(r,[e("h2",{},n?"Add a server":"Set up Dawnline"),e("div",{class:"dl-steps"},d.map((c,k)=>e("span",{class:`dl-step${k===o?" current":k0?z("Back",()=>{o--,f()}):a?z("Cancel",a):"",e("span",{class:"dl-spacer"}),o{if(o===0&&(!i.endpoint||!i.port||!i.subnet)){X("Fill in the public address, port and subnet.","warning");return}o++,f()},"positive"):z("Create server",async()=>{let c=await U(()=>N.serverCreate(i.id,i.name,t.ifname,i.port,i.subnet,i.endpoint,t.mtu,i.preset,i.lan_zone,i.wan_zone,i.lan_like,n?void 0:i.portal,n?void 0:i.portal_port),"Server created");c&&setTimeout(()=>{location.href=Rt(c.id)},1500)},"positive")])])};return f(),r}};var mt=300,Aa=["all","connections","people","system","problems"],Pa={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},Na={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function za(s){let t=new Date(s*1e3),n=new Date,a=new Date;return a.setDate(n.getDate()-1),t.toDateString()===n.toDateString()?"Today":t.toDateString()===a.toDateString()?"Yesterday":t.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}function Ht(s){let t=s.keep_days>0?`${s.keep_days} day${s.keep_days===1?"":"s"}`:"no age limit",n=s.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${s.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${t}, up to ${s.max.toLocaleString("en-GB")} events, ${n}.`}var It=s=>s.sys?["error","repair","down"].includes(s.sys.level):ct(s.ev.type)==="problems";function Bt(s,t,n,a){let i=s.by==="admin",o=e("div",{class:`dl-row dl-slog-row ${i?"dl-ev-by-admin":`dl-ev-by-system ${Pa[s.level]??""}`}${s.detail?" has-detail":""}`},[i?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):e("span",{class:"dl-ev-tile sys",title:s.level},v(Na[s.src]??"zap")),e("span",{class:"dl-row-main"},i?[e("span",{class:"dl-you"},"You"),e("span",{class:"dl-muted"},` ${s.msg} `),s.kind?e("span",{class:"dl-ev-kind"},`${s.kind} `):"",s.who?e("b",{},s.who):"",s.note?e("span",{class:"dl-muted"},` · ${s.note}`):"",s.detail?e("span",{class:`dl-slog-more${t?" open":""}`},v("chevron")):"",s.detail&&t?e("pre",{class:"dl-slog-detail"},s.detail):""]:[s.src==="awg"&&s.who&&s.who!=="AmneziaWG"?e("span",{class:"dl-ev-kind"},"Server "):"",e("b",{class:"dl-sys-src",title:pt[s.src]??s.src},s.who??pt[s.src]??s.src)," ",e("span",{class:"dl-muted"},s.msg),s.detail?e("span",{class:`dl-slog-more${t?" open":""}`},v("chevron")):"",s.detail&&t?e("pre",{class:"dl-slog-detail"},s.detail):""]),e("span",{class:"dl-faint dl-nowrap",title:new Date(s.ts*1e3).toLocaleString()},a)]);return s.detail&&o.addEventListener("click",r=>{r.target.closest("pre")||n()}),o}var ft=class{constructor(t,n,a){this.events=[];this.system=[];this.kind="all";this.shown=mt;this.open=new Set;this.list=e("div",{});this.sub="";this.tabs=e("div",{class:"dl-seg",role:"tablist"});this.st=t,this.take(n),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,n=o=>()=>{let r=this.filtered().reverse();Le(this.st,r.filter(l=>l.ev).map(l=>l.ev),o,t(),r.filter(l=>l.sys).map(l=>l.sys))},a=z([v("download")," Export"],()=>ye(a,[{label:"CSV (spreadsheet)",icon:v("download"),run:n("csv")},{label:"JSON",icon:v("download"),run:n("json")}])),i=z([v("trash")," Clear"],()=>Te("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[a,i]}take(t){this.events=t.events,this.policy=t.policy;let n=Qe.filter(a=>!t.policy.categories.includes(a));this.sub=`${Ht(t.policy)}${n.length?` Not recorded: ${n.map(a=>Ge[a].toLowerCase()).join(", ")}.`:""}`}async reload(){let[t,n]=await Promise.all([N.events(2e4).catch(()=>null),N.serviceLog().catch(()=>null)]);t&&this.take(t),n&&(this.system=n.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,n)=>n.ts-t.ts)}matches(t,n){return n==="all"?!0:n==="problems"?It(t):n==="system"?!!t.sys:!!t.ev&&ct(t.ev.type)===n}filtered(){return this.items().filter(t=>this.matches(t,this.kind))}paintTabs(t){dom.content(this.tabs,Aa.map(n=>e("button",{type:"button",role:"tab",class:n===this.kind?"on":"","aria-selected":n===this.kind?"true":"false",click:()=>this.show(n)},[n==="all"?"All":n==="system"?"System":Ge[n],e("b",{},String(t.filter(a=>this.matches(a,n)).length))])))}show(t){this.kind=t,this.shown=mt,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 n=[],a="",i=null;for(let o of t.slice(0,this.shown)){let r=za(o.ts);r!==a&&(a=r,i=e("div",{class:"dl-panel flush"},e("div",{class:"dl-panel-head pad"},e("h3",{},r))),n.push(i));let l=new Date(o.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(o.sys){let d=`${o.sys.ts}|${o.sys.msg}`;i.appendChild(Bt(o.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else{let d=He(this.st,o.ev);d.lastElementChild.textContent=l,i.appendChild(d)}}t.length>this.shown&&n.push(e("div",{class:"dl-more-row"},z(`Show ${Math.min(mt,t.length-this.shown)} more of ${t.length-this.shown}`,()=>{this.shown+=mt,this.paint()}))),dom.content(this.list,n)}};var Ra={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},bn=3;function jt(s){let t=new Date(s*1e3),n=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"})}, ${n}`}async function Ha(s){let t=await U(()=>N.backupRead(s.name));if(!t)return;let n=atob(t.data),a=new Uint8Array(n.length);for(let o=0;oHa(s),"neutral","dl-icon-only"),we("more","More",n=>ye(n.currentTarget,[{label:"Restore",icon:v("reset"),run:async()=>{await ae("Restore this backup?",`Everything returns to ${jt(s.created)}. The current state is backed up first.`,"Restore",!0)&&await U(()=>N.backupRestore(s.name),"Restored")&&t()}},{label:"Delete",icon:v("trash"),danger:!0,run:async()=>{await ae("Delete this backup?",`The backup from ${jt(s.created)} is removed from the router.`,"Delete",!0)&&await U(()=>N.backupDelete(s.name),"Backup deleted")&&t()}}]),"neutral","dl-icon-only")])])}function Ot(s,t){let n=s.slice(0,bn).map(d=>xn(d,t)),a=s.slice(bn),i=s.length?e("div",{class:"dl-list"},[...n,a.length?e("details",{class:"dl-bk-older"},[e("summary",{},[v("chevron"),`${a.length} older backup${a.length===1?"":"s"}`]),...a.map(d=>xn(d,t))]):""]):e("div",{class:"dl-list"},[e("div",{class:"dl-row dl-muted"},"No backups yet.")]),o=z("Restore from file",async()=>{let d=await Et(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await ae("Restore from file?",`Replace the current Dawnline configuration with ${d.name}? The current state is backed up first.`,"Restore",!0)&&await U(()=>N.backupUpload(d.data),"Restored")&&t()}),r=z("Export JSON",async()=>{let d=await U(()=>N.exportJson());d&&fe(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=z("Import JSON",async()=>{let d=await Et(".json,application/json","text");if(!d)return;let g;try{g=JSON.parse(d.data)}catch{X("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 U(()=>N.importJson(g),"Imported")&&t()});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"}),z([v("plus")," Back up now"],async()=>{await U(()=>N.backupCreate(),"Backup created")&&t()},"positive")]),i]),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"},[o,r,l])])])}function at(s,t,n){s.some(([o])=>o===t)||(s=[...s,[t,t]]);let a=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":n,"data-value":t}),i=()=>dom.content(a,s.map(([o,r])=>e("button",{type:"button",role:"radio",class:o===a.dataset.value?"on":"","aria-checked":o===a.dataset.value?"true":"false",click:()=>{a.dataset.value=o,i()}},r)));return i(),a}function Ut(s,t,n=`${t}s`){return`${s.toLocaleString("en-GB")} ${s===1?t:n}`}function vt(s){return s<1024?`${s} B`:s<1048576?`${(s/1024).toFixed(s<10240?1:0)} KB`:`${(s/1048576).toFixed(1)} MB`}var bt=class{constructor(){this.root=e("div",{class:"dl-settings-main"});this.backups=[]}load(){return N.settingsGet()}render(t){return this.d=t,this.paint(),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),e("div",{},[e("div",{class:"dl-pagehead"},[e("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(t,n="Saved"){let a=await U(()=>N.settingsUpdate(t),n);a&&(this.d=a,this.paint())}section(t,n,a,i,o="",r=[]){return e("section",{class:`dl-setsec ${o}`,id:`dl-set-${t}`},[e("div",{class:"dl-setsec-body"},[r.length?e("div",{class:"dl-setsec-head"},[e("h3",{},n),e("span",{class:"dl-spacer"}),...r]):e("h3",{},n),...a]),i.length?e("div",{class:"dl-setsec-foot"},i):""])}portalSection(){let t=this.d.settings,n=this.d.effective,a=this.d.cert,i=this.d.portal_candidates??[],o=this.d.portal_checks??[],r=Me(n.portal_enabled,"Enable portal"),l=se(t.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),d=Me(n.portal_443,"Standard ports",()=>M()),g=se(t.portal_title,{placeholder:"Dawnline"}),f=se(t.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),c=se("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),k=I=>/^\d{1,3}(\.\d{1,3}){3}$/.test(I),b=[n.portal_host,...n.portal_alt??[]].filter((I,oe,_)=>I&&_.indexOf(I)===oe);!b.length&&i[0]&&(b=[i[0].host]);let R=[...i],Y=I=>{I&&!R.some(oe=>oe.host===I)&&R.push({host:I,kind:k(I)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})};b.forEach(Y);let V=I=>I.kind==="ip"?e("span",{class:"dl-addr-warn"},[v("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):e("span",{class:"dl-sub"},I.cloudflare?"Behind Cloudflare · often stalls in Russia":I.ips.length?I.here?`Points at this router${I.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${I.ips.join(", ")}, not this router`:"Your address"),B=e("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),w=I=>{b.includes(I)?b.length>1&&(b=b.filter(oe=>oe!==I)):b=[...b,I],D(),M()},D=()=>dom.content(B,[...R.map(I=>{let oe=b.includes(I.host),_=b[0]===I.host;return e("div",{class:`dl-addr-opt${oe?" on":""}`,role:"checkbox","aria-checked":oe?"true":"false",tabindex:"0",click:()=>w(I.host),keydown:S=>{(S.key===" "||S.key==="Enter")&&(S.preventDefault(),w(I.host))}},[e("i",{class:"dl-addr-check"},oe?v("check"):""),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono"},I.host),V(I)]),_?e("span",{class:"dl-pill info"},"Main"):oe?e("button",{type:"button",class:"dl-linkbtn",click:S=>{S.stopPropagation(),b=[I.host,...b.filter(x=>x!==I.host)],D(),M()}},"Make main"):I.cloudflare?e("span",{class:"dl-pill warn"},"Cloudflare"):I.kind==="ip"?e("span",{class:"dl-pill"},"IP"):I.here&&I.cert?e("span",{class:"dl-pill ok"},"Recommended"):""])}),e("div",{class:"dl-addr-opt other"},[e("i",{class:"dl-addr-check"},v("plus")),c,z("Add",()=>{let I=c.value.trim().toLowerCase();I&&(Y(I),b.includes(I)||(b=[...b,I]),c.value="",D(),M())})])]);c.addEventListener("keydown",I=>{I.key==="Enter"&&(I.preventDefault(),c.nextElementSibling?.click())});let E=e("div",{class:"dl-links"}),M=()=>{let I=Ke(d),oe=Number(l.value)||n.portal_port;dom.content(E,b.map((_,S)=>{let x=k(_),C=x?I?80:oe+1:I&&!this.d.wan443_taken?443:oe,A=`${x?"http":"https"}://${_}${C===(x?80:443)?"":`:${C}`}/`;return e("div",{class:"dl-link-row"},[e("span",{class:`dl-link-ic ${x?"warn":"ok"}`},v(x?"alert":"lock")),e("span",{class:"dl-mono dl-link-url"},[A,e("b",{},"kamiro-telosu-bavine")]),S===0?e("span",{class:"dl-pill info"},"Main"):x?e("span",{class:"dl-pill warn"},"HTTP"):""])}))};D(),M(),l.addEventListener("input",()=>M());let u={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_443:"Port 443",portal_lan:"Works at home",portal_http:"Plain HTTP",cert:"Certificate"},$=o.filter(I=>I.status!=="skip"),h=$.filter(I=>I.status==="error"||I.status==="warn"),p=$.some(I=>I.status==="error")?"error":h.length?"warn":"ok",T=e("div",{class:"dl-ready-details",hidden:!0},$.map(I=>e("div",{class:`dl-ready-item ${I.status}`},[v(I.status==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("span",{},I.title),e("span",{class:"dl-sub"},I.detail)])]))),m=e("div",{class:"dl-stack gap8"},[e("div",{class:`dl-ready-sum ${p}`},[v(p==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("b",{},p==="ok"?`All ${$.length} checks passed`:`${$.length-h.length} of ${$.length} checks passed`),h.length?e("span",{class:"dl-sub"},h.map(I=>I.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:I=>{T.hidden=!T.hidden,I.currentTarget.textContent=T.hidden?"Details":"Hide"}},"Details")]),e("div",{class:"dl-chips-row"},$.map(I=>e("span",{class:`dl-check-chip ${I.status}`,title:I.detail},[v(I.status==="ok"?"check":"alert"),u[I.id]??I.title]))),T]),y=a&&!a.self_signed&&a.expires?new Date(a.expires).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"",P=Q("Standard ports",d,this.d.wan443_taken?"Port 443 is already forwarded to another device, so HTTPS links keep the listening port.":"Links without a port: 443 for names, 80 for IP addresses. Mobile networks often drop other ports. From the internet these reach only the portal; LuCI stays closed."),O=Q("Listening port",l,this.d.port_owners.length?`Port ${n.portal_port} is used by ${this.d.port_owners.join(", ")}.`:`Where the portal runs on the router: HTTPS here, plain HTTP for IP addresses on ${n.portal_port+1}.`),H=!!(t.portal_cert&&t.portal_key),Z=a?H?"Your files":a.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",ee=()=>{let I=se(t.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),oe=se(t.portal_key,{placeholder:"/etc/ssl/…/key"});ne("Use your own certificate",[e("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),Q("Certificate file",I),Q("Key file",oe)],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Save",()=>{J(),this.save({portal_cert:I.value.trim(),portal_key:oe.value.trim()},"Certificate saved")},"positive")])},ie=this.d.needs??{https:[],acme:[],home:[]},he=(I,oe,_,S,x,C)=>e("div",{class:`dl-row dl-need-row ${oe}`},[oe?e("span",{class:"dl-need-ic"},v(I)):v(I),e("span",{class:"dl-row-main dl-stack"},[e("b",{},_),e("span",{class:"dl-sub"},S)]),z(C,()=>tt(x,ie[x],()=>this.reload()),"positive")]),ue=ie.https.length?he("lock","bad","HTTPS isn’t available on this router",`The portal needs ${ie.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",Ee=ie.acme.length&&(!a||a.self_signed)?he("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"):"",$t=[e("div",{class:"dl-row"},[v("lock"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},[Z,y?e("span",{class:"dl-faint"},` · until ${y}`):""]),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.":`${H?"Your files":"Found automatically"} · ${a.path}`:"Turn the portal on to see its certificate.")])]),e("div",{class:"dl-row"},[v("file"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},"Your own files"),e("span",{class:"dl-sub"},H?`${t.portal_cert} · ${t.portal_key}`:"Not set: the certificate is picked automatically.")]),H?z("Reset",()=>this.save({portal_cert:"",portal_key:""},"Automatic certificate"),"negative"):"",z(H?"Change":"Use files",ee)]),Ee];return this.section("portal","Personal portal",[e("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),ue?e("div",{class:"dl-list"},[ue]):"",pe("network","Ports","How the portal listens",[P,O]),pe("edit","Appearance","What people see",[Q("Title",g,"Shown at the top of the portal."),Q("Unknown links",f,"Where a wrong or old link goes, for example your website. Empty shows a plain “Not found”.")]),pe("link","Addresses","Pick one or more; the first is the main link",[B,e("div",{class:"dl-stack gap8"},[E,e("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),pe("lock","Certificate","Used for HTTPS links",$t),n.portal_enabled&&$.length?pe("check","Ready to share","The portal’s checks from Health",[m]):""],[e("span"),z("Save",()=>this.save({portal_enabled:Ke(r)?"1":"0",portal_443:Ke(d)?"1":"0",portal_host:b[0]??"",portal_alt:b.slice(1),portal_port:l.value,portal_title:g.value,portal_redirect:f.value.trim()}),"positive")],"",[n.portal_enabled?ie.https.length?e("span",{class:"dl-pill bad"},"Can’t start"):e("span",{class:`dl-pill ${p==="ok"?"ok":p==="error"?"bad":"warn"}`},p==="error"?"Needs attention":"Ready"):"",r])}paint(){let t=this.d.settings,n=this.d.effective,a=this.portalSection(),i=se(t.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),o=Me(n.hostnames,"Device hostnames"),r=se(t.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),l=se(t.home_dns_fallback==="none"?"":t.home_dns_fallback||n.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),d=this.section("defaults","Defaults",[Q("Devices per person",i,"Pre-filled when you add someone."),Q("Device hostnames",e("div",{class:"dl-hostport"},[o,e("span",{class:"dl-faint dl-mono"},"phone.myata."),r]),"Name devices in your home DNS."),Q("Fallback DNS",l,"For Home-only devices using home names: the second DNS server, used by the device when the tunnel is down. Empty = none.")],[e("span"),z("Save",()=>this.save({default_device_limit:i.value,hostnames:Ke(o)?"1":"0",domain:r.value,home_dns_fallback:l.value}),"positive")]),g=Me(n.geo_enabled,"Locations"),f=e("select",{class:"cbi-input-select"},[e("option",{value:"ipwho.is",selected:n.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),e("option",{value:"ipapi.co",selected:n.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]),c=this.section("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."),g]),Q("Provider",f)],[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."),z("Save",()=>this.save({geo_enabled:Ke(g)?"1":"0",geo_provider:f.value}),"positive")]),k=this.logsSection(),b=this.d.services.map(B=>e("div",{class:"dl-row"},[v("home"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},B.name),e("span",{class:"dl-mono dl-faint"},`${B.address}${B.ports.length?` · ports ${B.ports.join(", ")}`:" · all ports"}`)]),z("Edit",()=>this.editService(B)),z([v("trash")],async()=>{await ae(`Remove ${B.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await U(()=>N.serviceDelete(B.id),"Removed")&&this.reload()},"negative",{title:"Remove"})])),R=this.section("services","Home services",[e("p",{class:"dl-muted"},"Give people with home-network access only specific services instead of the whole network (choose them per person)."),e("div",{class:"dl-list"},b.length?b:[e("div",{class:"dl-row dl-muted"},"No services yet.")])],[e("span"),z([v("plus")," Add service"],()=>this.editService(null),"add")]),Y=this.section("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"),z("Remove",()=>this.uninstall(),"negative")],"danger"),V=Ot(this.backups,()=>{this.reload(),this.loadBackups()});dom.content(this.root,[a,d,c,k,R,V,Y])}logsSection(){let t=this.d.logs,n=t.policy,a=at([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(n.keep_days),"Keep activity"),i=at([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(n.max),"Maximum events"),o=at([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],n.persist,"Save to flash"),r=at([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(n.usage_days),"Daily traffic"),l=at([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(n.usage_months),"Monthly traffic"),d=new Set(n.categories),g=e("div",{class:"dl-chips-row"},Qe.map(R=>{let Y=e("button",{type:"button",class:`dl-chipbtn${d.has(R)?" on":""}`,title:ln[R],click:()=>{d.has(R)?d.delete(R):d.add(R),Y.classList.toggle("on",d.has(R))}},[Ge[R],e("b",{},String(t.by_category[R]??0))]);return Y})),f=R=>new Date(R).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),c=t.oldest?f(new Date(t.oldest*1e3)):"",k=(R,Y,V,B)=>e("div",{class:"dl-row"},[v(R),e("span",{class:"dl-row-main dl-stack"},[e("b",{},Y),e("span",{class:"dl-sub"},V)]),...B]),b=R=>z(R.toUpperCase(),async()=>{let[Y,V]=await Promise.all([N.status(1),N.events(2e4)]);Le(Y,V.events,R)},"neutral",{title:`Download the log as ${R.toUpperCase()}`});return this.section("logs","Logs & history",[e("p",{class:"dl-muted"},Ht(n)),Q("Keep activity",a,"Older events are removed automatically."),Q("Maximum size",i,"Newest events are kept when the log is full."),Q("Record",g,"Switched-off categories are not logged from now on."),Q("Save to flash",o,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),Q("Daily traffic",r,"Per-day history behind the charts."),Q("Monthly traffic",l,"Per-month totals; data limits use the current month."),e("h4",{class:"dl-setsub"},"Stored data"),e("div",{class:"dl-list"},[k("activity","Activity log",t.events?`${Ut(t.events,"event")} since ${c} · ${vt(t.log_ram)} in memory${n.persist==="off"?"":`, ${vt(t.log_flash)} on flash`}`:"Empty",[b("csv"),b("json"),z("Clear",()=>Te("Clear activity","Removes events from the log on the router.",{},()=>this.reload()),"negative")]),k("chart","Traffic history",t.usage_days?`${Ut(t.usage_days,"day")} since ${f(t.usage_since)} · ${vt(t.usage_flash)} on flash`:"Empty",[z("Reset",()=>We("all","","",()=>setTimeout(()=>this.reload(),300)),"negative")]),k("pin","Location cache",`${Ut(this.d.geo_cached,"address","addresses")} · ${vt(t.geo_flash)} on flash`,[z("Clear",async()=>{await U(()=>N.geoClear(),"Location cache cleared")&&this.reload()},"negative")])])],[e("span",{class:"dl-sub"},"Clear one person or device from their own page."),z("Save",()=>this.save({log_keep_days:a.dataset.value,log_max:i.dataset.value,log_persist:o.dataset.value,usage_keep_days:r.dataset.value,usage_keep_months:l.dataset.value,log_category:[...d]}),"positive")])}async loadBackups(){let t=await N.backupList().catch(()=>null);if(t){this.backups=t.backups;let n=document.getElementById("dl-set-backups");n&&n.replaceWith(Ot(this.backups,()=>{this.reload(),this.loadBackups()}))}}async reload(){let t=await N.settingsGet().catch(()=>null);t&&(this.d=t,this.paint())}editService(t){let n=se(t?.name??"",{placeholder:"NAS"}),a=se(t?.address??"",{placeholder:"192.168.1.10"}),i=se(t?.ports.join(", ")??"",{placeholder:"All ports, or e.g. 445, 5000"});ne(t?`Edit ${t.name}`:"Add service",[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},n)]),e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Address"),e("div",{class:"cbi-value-field"},a)]),e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Ports"),e("div",{class:"cbi-value-field"},i)])],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Save",async()=>{let o=i.value.split(/[ ,]+/).filter(Boolean);await U(()=>N.serviceSet(t?.id??"",n.value,a.value,o),"Saved")&&(J(),this.reload())},"positive")])}uninstall(){let t=se("",{placeholder:"remove"});ne("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."),t],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Remove Dawnline",async()=>{await U(()=>N.uninstall(t.value.trim()),"Dawnline removed")&&(J(),setTimeout(()=>location.reload(),800))},"negative")])}};var Ia={ok:"check",warn:"alert",error:"x",skip:"pause"},wn={apply:"Repair",sync:"Reload devices",restart:"Restart service",updates:"Open updates"},xt=class{constructor(t,n,a,i){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=n,this.events=a,this.toLog=i,dom.content(this.el,[this.summary,this.wdEl,e("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(n,a)}async run(t){let n=t?await U(()=>N.healthFix(t),"Done"):await N.health().catch(()=>null);n&&this.take(n)}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 n=t.filter(r=>r.status==="error").length,a=t.filter(r=>r.status==="warn").length;dom.content(this.summary,n?De("error",`${n} problem${n>1?"s":""} need attention.`):a?De("warn",`${a} warning${a>1?"s":""}.`):De("ok","All checks passed."));let i=new Map;for(let r of this.sl.watchdog.repairs)i.set(r.id,Math.max(i.get(r.id)??0,r.ts));let o=()=>this.run();dom.content(this.checksEl,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks"),e("span",{class:"dl-spacer"}),z("Run again",o)]),e("ul",{class:"dl-checks"},t.map(r=>e("li",{},[e("span",{class:`dl-check-icon ${r.status}`},v(Ia[r.status])),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},r.title),e("div",{class:"dl-check-detail"},r.detail),i.has(r.id)?e("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${Pe(i.get(r.id))}`):""]),r.fix?r.fix.startsWith("install:")?z("Install",()=>gn(r.fix.slice(8),o),"action"):r.fix==="updates"?e("a",{class:"cbi-button cbi-button-action",href:L.url("admin/network/dawnline/updates")},wn.updates):z(wn[r.fix]??"Fix",()=>this.run(r.fix),"action"):""])))])}paintLive(t,n){this.sl=t,this.events=n;let a=t.watchdog,i=a.beat!=null&&a.now-a.beat>180,o=a.repairs.filter(d=>a.now-d.ts<86400),r=o[o.length-1],l=Me(a.enabled,"Watchdog repairs",async d=>{await U(()=>N.settingsUpdate({watchdog:d?"1":"0"}),d?"Watchdog on":"Watchdog off")||l.classList.toggle("on",!d);let f=await N.serviceLog().catch(()=>null);f&&this.paintLive(f,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"}`},v("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":""}`:""}`},[v(d.ok?"check":"x"),d.name]))),e("span",{class:`dl-sub${i?" dl-warn-text":""}`},i?`The agent has not checked in for ${Math.round((a.now-a.beat)/60)} min; cron restarts it after 5.`:[a.last?`Looked ${ce(a.last,a.now)}`:"Starts within a minute"," · ",o.length?`${o.length} repair${o.length>1?"s":""} today, last ${r.name} at ${Pe(r.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let t=Date.now()/1e3-604800,n=[...this.events.map(i=>({ts:i.ts,ev:i})),...this.sl.log.map(i=>({ts:i.ts,sys:i}))].filter(i=>i.ts>=t&&It(i)).sort((i,o)=>o.ts-i.ts),a=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Recent problems"),e("span",{class:"dl-spacer"}),n.length?e("a",{href:"#",click:i=>(i.preventDefault(),this.toLog())},"All in Log →"):""]);if(!n.length){dom.content(this.recentEl,[a,e("div",{class:"dl-recent-empty"},[e("span",{class:"dl-check-icon ok"},v("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[a,...n.slice(0,8).map(i=>{if(i.sys){let r=i.sys,l=`${r.ts}|${r.msg}`;return Bt(r,this.open.has(l),()=>{this.open.delete(l)||this.open.add(l),this.paintRecent()},Pe(r.ts))}let o=He(this.st,i.ev);return o.lastElementChild.textContent=Pe(i.ts),o})])}},Ba=[{title:"ip-full · veth",sub:"Policy routing and the home-like link",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"OpenSSL",sub:"HTTPS for the personal portal",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"ACME",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],wt=class{constructor(){this.running=!1}load(){return N.updatesStatus()}render(t){return this.root=e("div",{class:"dl-root dl-upd"}),this.paint(t),poll.add(async()=>{let n=await N.updatesStatus().catch(()=>null);n&&n.job?.state==="running"?this.paint(n):n&&this.running&&(this.running=!1,this.paint(n),n.job?.component==="app"&&n.job.state==="done"&&(ui.menu?.flushCache(),setTimeout(()=>location.reload(),1500)))},3),this.root}paint(t){let n=t.job;this.running=n?.state==="running";let a=t.check?.components??{},i=t.firmware,o=a.app,r=a.amneziawg,l=a.packages,d={disabled:this.running},g=(m,y)=>e("span",{class:`dl-pill ${m}`},y),f=(m,y,P)=>e("div",{class:"dl-upd-row"},[e("span",{class:"dl-stack"},[e("span",{class:"dl-upd-name"},m),e("span",{class:"dl-sub"},y)]),P]),c=(m,y,P,O,H=[])=>e("section",{class:"dl-setsec dl-upd-sec"},[e("div",{class:"dl-upd-head"},[e("span",{class:"dl-group-ic"},v(m)),e("span",{class:"dl-stack"},[e("b",{},y),e("span",{class:"dl-sub"},P)]),O]),...H]),k=m=>m?new Date(m).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"",b=c("sunrise","Dawnline",o?.repo?`${t.version} · ${o.repo}`:t.version,o?o.update?z(`Update to ${o.latest}`,()=>this.run("app"),"positive",d):o.latest?g("ok","Up to date"):g("","No releases yet"):g("","Not checked")),R=r?.sources??{},V=Object.keys(R).map(m=>{let y=R[m],P=r?.current===m,O=[y.version?`${y.tag} build${y.date?` · ${k(y.date)}`:""} · ${y.gen==="3.1"?"devices need AmneziaVPN with 3.1":"works with every AmneziaWG app"}`:`No build for OpenWrt ${i?.version??""}`],H=y.version?P?r?.update?z("Update",()=>this.runAwg(m,!!r.ru,y.gen),"positive",d):g("ok","Installed"):z("Switch",()=>this.runAwg(m,!!r?.ru,y.gen),"neutral",d):g("","No build");return f([y.gen?`AmneziaWG ${y.gen}`:"AmneziaWG",e("span",{class:"dl-faint"},` · ${y.label}`)],O,H)});r?.current&&R[r.current]?.version&&V.push(f("Russian translation","LuCI pages for AmneziaWG in Russian",z(r.ru?"Remove":"Add",()=>this.runAwg(r.current,!r.ru,r.gen),"neutral",d)));let B=c("shield","AmneziaWG",r?.installed?`${r.gen?`${r.gen} · `:""}${r.installed} · changing it restarts every tunnel`:"Not installed",r?"":g("","Not checked"),V.length?V:[f("Builds for this router","Check for updates to see them.","")]),w=l?.pkgs??{},D=[],E=Ba.filter(m=>m.feature==="home"?t.home:t.portal);for(let m of E){let y=m.pkgs.filter(H=>w[H]?.installed),P=[...new Set(y.flatMap(H=>[...w[H]?.latest?[H]:[],...w[H]?.with??[]]))],O=t.needs?.[m.feature]??m.pkgs.filter(H=>!w[H]?.installed);if(O.length)D.push(f(m.title,m.optional?`Not installed · ${m.sub}`:e("span",{class:"dl-upd-bad"},`Missing ${O.join(", ")} · ${m.sub}`),z("Install",()=>this.runPkgs(O,m.title),"neutral",d)));else if(P.length){let H=y.find(ie=>w[ie]?.latest),Z=H?[e("span",{class:"dl-mono"},[`${w[H].installed} → `,e("b",{},w[H].latest)])]:[],ee=P.filter(ie=>ie!==H);ee.length&&Z.push(`${H?" · ":""}${ee.length<=2?`${H?"with ":""}${ee.join(", ")}`:`${H?"+":""}${ee.length} related packages`}`),D.push(f(m.title,Z,z("Update",()=>this.runPkgs(y.filter(ie=>w[ie]?.latest||w[ie]?.with?.length),m.title,P),"neutral",d)))}else D.push(f(m.title,m.sub,g("ok","Up to date")))}let M=E.flatMap(m=>m.pkgs).filter(m=>w[m]?.installed),u=[...new Set(M.flatMap(m=>[...w[m].latest?[m]:[],...w[m].with??[]]))],$=c("package","System packages",l?u.length?`${u.length} update${u.length===1?"":"s"} from the OpenWrt ${i?.version?.replace(/\.\d+$/,"")??""} feeds`:"What Dawnline adds to OpenWrt is current":"What Dawnline adds to OpenWrt",l?u.length?z("Update all",()=>this.runPkgs(M.filter(m=>w[m].latest||w[m].with?.length),"all packages",u),"positive",d):"":g("","Not checked"),l?D:[]),h=n?e("details",{class:"dl-params dl-upd-job",open:this.running?"open":null},[e("summary",{},[v("chevron"),e("span",{},"Last job"),g(n.state==="done"?"ok":n.state==="failed"?"bad":"warn",n.state==="running"?n.phase||"Running":n.state==="done"?"Finished":"Failed"),e("span",{class:"dl-sub"},`${n.action==="check"?"check":n.component??""} · ${Pe(n.started)}${n.finished?` · ${n.finished-n.started} s`:""}`)]),n.error?De("error",n.error):"",e("pre",{class:"dl-log"},n.log.join(` -`))]):"",p=u.length+(o?.update?1:0)+(r?.update?1:0),T=[i?.version?`OpenWrt ${i.version} · ${i.target}`:"",t.check?p?`${p} update${p===1?"":"s"} ready`:"everything is current":"not checked yet",t.check?`checked ${Pe(t.check.time)}`:""].filter(Boolean).join(" · ");dom.content(this.root,[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Updates"),e("span",{class:"dl-faint"},T)]),z([v("refresh")," Check now"],()=>this.run("check"),"neutral",d)]),b,B,$,h])}async runAwg(t,n,a){await ae(a?`Install AmneziaWG ${a}?`:"Install AmneziaWG?","Every AmneziaWG tunnel on the router restarts for a few seconds, HomeTunnel too. Devices stay configured.","Install")&&this.start(`amneziawg:${t}${n?":ru":""}`)}async runPkgs(t,n,a=t){await ae(`Update ${n}?`,`${a.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&this.start(`pkgs:${t.join(",")}`)}async run(t){t!=="check"&&!await ae(`Update ${t==="app"?"Dawnline":t}?`,"A backup is made first. The page reloads when it finishes.","Update")||this.start(t)}async start(t){if(await U(()=>N.updatesRun(t))){this.running=!0;let n=await N.updatesStatus().catch(()=>null);n&&this.paint(n)}}};function qt(s){return`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`}function ja(s,t,n,a=30){let i=s?new Date(`${s}T12:00:00`):new Date;return t==="day"?i.setDate(i.getDate()+n):t==="week"?i.setDate(i.getDate()+7*n):t==="month"?i.setMonth(i.getMonth()+n):t==="year"?i.setFullYear(i.getFullYear()+n):i.setDate(i.getDate()+a*n),qt(i)}var Oa={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."},yt=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.refreshSeq=0;this.refreshShown=0}async load(){this.id=new URLSearchParams(location.search).get("id")??"";let[t,n,a]=await Promise.all([N.status(30),N.events(5e3).catch(()=>({events:[]})),N.personUsage(this.id,30).catch(()=>null)]);return this.series=a?.person??[],this.devSeries=a?.devices??{},[t,n.events]}render([t,n]){this.st=t,this.events=n;let a=t.people.find(l=>l.id===this.id);if(!a)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=a;for(let l of["head","devices","traffic","places","activity","limits"])this.parts[l]=e("div",{});this.parts.devices.className="dl-person-devices";let i=e("div",{},[e("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[e("a",{href:Je(a.server)},t.servers.find(l=>l.id===a.server)?.name??"Servers"),e("span",{},"/"),e("a",{href:Je(a.server)},"People"),e("span",{},"/"),e("span",{},a.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 o=new URLSearchParams(location.search),r=o.get("device")&&a.devices.find(l=>l.id===o.get("device"));return r?setTimeout(()=>Ce(this.p,r,()=>this.refresh(),this.st.geo),50):o.get("add")&&setTimeout(()=>Fe(this.p,()=>this.refresh()),50),poll.add(()=>this.refresh(!0),15),i}async refresh(t=!1){let n=++this.refreshSeq,[a,i,o]=await Promise.all([N.status(30).catch(()=>null),N.events(5e3).catch(()=>null),N.personUsage(this.id,30).catch(()=>null)]);if(!a||nl.id===this.id);if(!r){t||(location.href=Je(this.p?.server));return}this.p=r,this.paint(),this.map?.update(this.mapData())}async patch(t,n){var o;let a=await U(()=>N.personUpdate(this.p.id,t),n);if(!a)return;let i=this.st.people.findIndex(r=>r.id===this.p.id);(o=a.person).rate??(o.rate=this.p.rate),i>=0&&(this.st.people[i]=a.person),this.p=a.person,this.paint()}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}mapCard(){let t=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Locations"),e("span",{class:"dl-spacer"}),this.st.geo.enabled?rt("30d",n=>this.map?.setRange(n),!1):"",z("Hide",()=>{this.mapOpen=!1,this.map?.destroy(),this.map=null,this.paintPlaces()},"neutral")]);return this.st.geo.enabled?(this.map=new Ue({openPerson:()=>{},openDevice:(n,a)=>{let i=this.p.devices.find(o=>o.id===a);i&&Ce(this.p,i,()=>this.refresh(),this.st.geo)}},"30d",280),requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[t,this.map.el])):e("div",{class:"dl-panel flush"},[t,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])])}paint(){let t=this.p,n=this.st,a=t.online?"online now":t.last_seen?`last seen ${ce(t.last_seen,n.now)}`:"never connected",i=this.series.find(c=>c.day===qt(new Date));dom.content(this.parts.traffic,e("div",{class:`dl-person-live${t.online?"":" solo"}`},[t.online?At(t.rate??[],n.now,i?[i.rx,i.tx]:[0,0]):"",Pt(this.series,`${K(t.month[0]+t.month[1])} this month`)]));let o=t.created?`Added ${$e(qt(new Date(t.created*1e3)))}`:"",r=[{label:"Rename",icon:v("edit"),run:()=>this.rename()},{label:t.note?"Edit note":"Add note",icon:v("file"),run:()=>this.editNote()},...t.link?[null,{label:"Invite card",icon:v("qr"),run:()=>this.invite()},{label:"New link",icon:v("key"),run:()=>this.newLink()}]:[],null,{label:t.paused?"Resume":"Pause",icon:v(t.paused?"play":"pause"),warn:!t.paused,run:()=>this.patch({paused:!t.paused},t.paused?"Resumed":"Paused")},{label:"Delete",icon:v("trash"),danger:!0,run:()=>this.remove()}];dom.content(this.parts.head,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":""}`},ze(t.name)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),zt(t)]),e("span",{class:"dl-faint",title:o},`${t.devices.length} of ${t.device_limit} devices · ${a}`)])]),e("div",{class:"dl-pcard-actions"},[t.link?we("link","Copy link",()=>de(t.link,"Personal link copied"),"neutral","dl-icon-only"):"",we("more","More",c=>ye(c.currentTarget,r),"neutral","dl-icon-only")])]),t.note?e("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>this.editNote()},[v("file"),e("span",{},t.note)]):""])),this.paintDevices(),this.paintLimits(),this.paintPlaces();let l=this.events.filter(c=>c.person===t.id),d=[],g=[...l].reverse();for(let c=0;c1){let Y=R.querySelector(".dl-row-main");dom.content(Y,[...Dt(n,k).slice(0,3),e("span",{class:"dl-muted"},`${b} times`)]),Y.title=g.slice(c,c+b).map(V=>V.detail??"").join(` -`)}d.push(R),c+=b-1}let f=z([v("more")],()=>ye(f,[{label:"Export CSV",icon:v("download"),run:()=>Le(this.st,l,"csv",t.id)},{label:"Export JSON",icon:v("download"),run:()=>Le(this.st,l,"json",t.id)},null,{label:`Clear ${t.name}'s activity`,icon:v("trash"),danger:!0,run:()=>Te(`Clear ${t.name}'s activity`,`Removes events about ${t.name} and their devices.`,{person:t.id},()=>this.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});dom.content(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-sub"},l.length>10?`latest 10 of ${l.length}`:""),e("span",{class:"dl-spacer"}),f]),d.length?d:e("div",{class:"dl-row dl-muted"},"Nothing yet.")]))}deviceStatus(t){return t.disabled?e("span",{class:"dl-dstat"},"Disabled"):t.online?e("span",{class:"dl-dstat ok"},"Connected"):t.handshake?e("span",{class:"dl-dstat"},`Last seen ${ce(t.handshake,this.st.now)}`):e("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},"Not set up yet")}deviceBars(t){let n=(this.devSeries[t]??[]).slice(-30),a=n.map(r=>r.rx+r.tx),i=Math.max(1,...a),o=r=>new Date(`${r}T12:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"});return e("div",{class:"dl-dbars"},n.map((r,l)=>{let d=e("i",{class:`${a[l]?"":"zero"}${l===n.length-1?" hi":""}`});return d.style.height=`${Math.max(8,a[l]/i*100)}%`,le(d,()=>[e("div",{class:"dl-tip-title"},l===n.length-1?`Today · ${o(r.day)}`:o(r.day)),e("div",{},K(a[l]))]),d}))}paintDevices(){let t=this.p,n=()=>this.refresh(),a=st(t.devices).map(o=>{let r=()=>Ce(t,o,n,this.st.geo);return e("article",{class:`dl-dcard${o.online?" online":""}${o.disabled?" off":""}`},[e("div",{class:"dl-dcard-head"},[e("span",{class:"dl-dcard-ic"},v(o.kind)),e("button",{type:"button",class:"dl-dcard-title",click:r},[e("b",{},o.name),this.deviceStatus(o),o.config_stale?e("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),z([v("more")],r,"neutral",{title:`${o.name}: connect, rename, keys, remove`,class:"cbi-button cbi-button-neutral dl-icon-only"})]),o.handshake?e("div",{class:"dl-dcard-trend"},[e("div",{class:"dl-stack"},[e("b",{},K(o.month[0]+o.month[1])),e("span",{class:"dl-sub"},"this month")]),this.deviceBars(o.id)]):o.disabled?e("div",{class:"dl-sub"},`${_e[o.kind]} · created ${ce(o.created,this.st.now)} ${o.created_by==="portal"?"in the portal":"by you"}.`):e("div",{class:"dl-chips-row"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>this.showDeviceQr(o)},[v("qr"),"Show QR"]),e("button",{type:"button",class:"dl-chipbtn",click:()=>this.downloadConfig(o)},[v("download"),"Config"])])])}),i=t.devices.length>=t.device_limit;a.push(e("button",{type:"button",class:"dl-dslot add",click:()=>Fe(t,n)},[e("span",{class:"dl-dslot-ic"},v("plus")),e("span",{class:"dl-stack"},[e("b",{},"Add device"),i?e("span",{class:"dl-sub"},`Over the limit · ${t.devices.length} of ${t.device_limit}`):""])])),dom.content(this.parts.devices,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"},a)]))}paintLimits(){let t=this.p,n=e("div",{class:"dl-seg wide",role:"radiogroup","aria-label":"Access"},["internet","lan","both"].map(h=>e("button",{type:"button",role:"radio",class:t.access===h?"on":"","aria-checked":t.access===h?"true":"false",click:()=>t.access!==h&&this.patch({access:h},`Access: ${Oe[h]}`)},[v(h==="internet"?"globe":h==="lan"?"home":"shield"),h==="internet"?"Internet":h==="lan"?"Home":"Both"]))),a=Ne(t.expires),i=e("input",{type:"date",class:"dl-date-hidden",value:t.expires,tabindex:"-1","aria-hidden":"true"});i.addEventListener("change",()=>i.value&&this.patch({expires:i.value},`Access until ${$e(i.value)}`));let o=(h,p,T)=>{let m=ja(t.expires&&(a??-1)>=0?t.expires:"",h,p);return this.patch({expires:m},`Access until ${$e(m)}`),T},r=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([h,p,T])=>e("button",{type:"button",class:"dl-chipbtn",click:()=>o(h,p,T)},T)),l=e("span",{class:"dl-datechip"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>{try{i.showPicker()}catch{i.focus()}}},[v("calendar"),t.expires?$e(t.expires):"Date"]),i]),d={pause:"pause access",notify:"keep access",remove:"remove their devices"}[t.expire_action],g=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"},[...r,l,t.expires?e("button",{type:"button",class:"dl-chipbtn",click:()=>this.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:h=>{h.preventDefault(),this.endSettings()}},"Change")])]),f=t.quota_used||t.month[0]+t.month[1],c=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,k=e("div",{class:`dl-meter${c>=100?" bad":c>=90?" warn":""}`},[e("i"),t.quota_limit?e("span",{class:"mark",title:"Alert at 90%"}):""]);k.firstChild.style.width=`${c}%`,t.quota_limit&&le(k,()=>[e("div",{class:"dl-tip-title"},`${c.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${K(t.quota_used)} of ${K(t.quota_limit)} · ${K(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},"Alert at 90%")]);let b=e("div",{class:"dl-seg sm"},["month","total"].map(h=>e("button",{type:"button",class:t.quota_period===h?"on":"",click:()=>t.quota_period!==h&&this.patch({quota_period:h})},h==="month"?"Monthly":"Total"))),R=[10,50,100].map(h=>e("button",{type:"button",class:`dl-chipbtn${t.quota_gb===h?" on":""}`,click:()=>this.patch({quota_gb:String(h)},`Data limit ${h} GB`)},`${h} GB`));R.push(e("button",{type:"button",class:`dl-chipbtn${t.quota_gb?"":" on"}`,click:()=>this.patch({quota_gb:""},"No data limit")},"Unlimited")),R.push(e("button",{type:"button",class:"dl-chipbtn",click:()=>{let h=prompt("Data limit in GB",t.quota_gb?String(t.quota_gb):"");h!=null&&h.trim()!==""&&Number(h)>0&&this.patch({quota_gb:h.trim()},`Data limit ${h.trim()} GB`)}},"Custom"));let Y=e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Data"),b]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[K(f),t.quota_limit?e("span",{class:"dl-faint"},` of ${K(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?k:"",e("div",{class:"dl-chips-row"},R),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:h=>{h.preventDefault(),this.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"},`${K(t.total[0]+t.total[1])} in total`),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>We("person",t.id,t.name,()=>setTimeout(()=>this.refresh(),300))},"Reset usage")])]),V=!!t.hours,[B,w]=(t.hours||"07:00-23:00").split("-"),D=e("input",{type:"time",class:"cbi-input-text",value:B}),E=e("input",{type:"time",class:"cbi-input-text",value:w}),M=()=>this.patch({hours:`${D.value}-${E.value}`},`Allowed ${D.value}–${E.value}`);D.addEventListener("change",M),E.addEventListener("change",M);let u=e("button",{type:"button",role:"switch","aria-checked":V?"true":"false",class:`dl-switch${V?" on":""}`,"aria-label":"Limit hours",click:()=>this.patch({hours:V?"":"07:00-23:00"},V?"Any time":"Allowed 07:00–23:00")},e("i")),$=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",{},V?`${B} – ${w} (router time)`:"Any time")]),u]),V?e("div",{class:"dl-tile2-row"},[D,e("span",{class:"dl-faint"},"to"),E]):""]);dom.content(this.parts.limits,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"),n,e("span",{class:"dl-sub"},Oa[t.access]),t.access==="lan"&&this.st.services.length?this.servicesPicker():"",t.access==="lan"?this.dnsPicker():""]),e("div",{class:"dl-tiles2"},[this.devTile(),g,Y,$])])]))}dnsPicker(){let t=this.p,n=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":"DNS"},[["device","Device’s own DNS"],["home","Home names"]].map(([i,o])=>e("button",{type:"button",role:"radio",class:t.dns_mode===i?"on":"","aria-checked":t.dns_mode===i?"true":"false",click:()=>t.dns_mode!==i&&this.patch({dns_mode:i},i==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")},o))),a=this.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"),n]),e("span",{class:"dl-sub"},t.dns_mode==="home"?["Names like ",e("span",{class:"dl-mono"},`nas.${this.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.")])}servicesPicker(){let t=new Set(this.p.services??[]);return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},this.st.services.map(n=>e("button",{type:"button",class:`dl-chipbtn${t.has(n.id)?" on":""}`,title:`${n.address}${n.ports.length?` · ${n.ports.join(", ")}`:""}`,click:()=>{t.has(n.id)?t.delete(n.id):t.add(n.id),this.patch({services:[...t]},t.size?"Home services updated":"Whole home network")}},n.name))),e("span",{class:"dl-sub"},t.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}devTile(){let t=this.p,n=e("div",{class:"dl-slots"});for(let o=0;o=t.device_limit,d=e("i",{class:l?"over":r?"used":""});le(d,()=>[e("div",{class:"dl-tip-title"},r?`${r.name}${l?" · over the limit":""}`:"Free slot"),e("div",{class:"dl-muted"},r?r.online?"Connected":r.handshake?`Last seen ${ce(r.handshake,this.st.now)}`:"Not set up yet":"They can add a device here")]),n.appendChild(d)}let a=Math.max(1,t.devices.length),i=e("button",{type:"button","aria-label":"Allow fewer devices",disabled:t.device_limit<=a?"disabled":null,click:()=>this.patch({device_limit:String(t.device_limit-1)})},"−");return t.device_limit<=a&&t.devices.length>1&&le(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:()=>this.patch({device_limit:String(t.device_limit+1)})},"+")])]),n])}paintPlaces(){let t=this.st;if(!t.geo.enabled){dom.content(this.parts.places,e("div",{class:"dl-places"},[v("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")]));return}if(this.mapOpen){(!this.map||!this.parts.places.contains(this.map.el))&&dom.content(this.parts.places,this.mapCard());return}let n=t.now-30*86400,a=t.geo.points.filter(r=>r.person===this.p.id&&r.ts>=n).sort((r,l)=>l.ts-r.ts),i=[...new Set(a.map(r=>r.city||r.country).filter(Boolean))],o=a[0];dom.content(this.parts.places,e("div",{class:"dl-places"},[v("pin"),e("div",{class:"dl-stack"},[e("span",{},o?o.city||o.country:"No locations yet"),e("span",{class:"dl-sub"},o?`${i.length} place${i.length===1?"":"s"} in 30 days${o.org?` · ${o.org}`:""}`:"Shown after a device connects")]),e("span",{class:"dl-spacer"}),a.length?z("Show map",()=>{this.mapOpen=!0,this.paintPlaces()},"neutral"):""]))}invite(){let t=this.st.servers.find(n=>n.id===this.p.server)?.name??"Home";et(this.p,t)}showQr(){let t=this.p;t.link&&ne(`${t.name}’s link`,[e("div",{class:"dl-qr-pane"},[Ae(je(t.link),"dl-qr"),e("div",{class:"dl-hint"},"Scan with the phone camera to open the portal.")])],[e("button",{class:"cbi-button",click:J},"Close")])}async newLink(){let t=this.p;if(!await ae("Create a new link?","The old link stops working right away.","Create new link",!0))return;let n=await U(()=>N.personRegen(t.id),"New link created");n?.link&&(t.link=n.link,de(n.link,"New link copied"),this.paint())}async showDeviceQr(t){let n=await U(()=>N.deviceConfig(t.id));n&&ne(`Set up ${t.name}`,[await Nt(n,"qr")],[e("button",{class:"cbi-button",click:J},"Close")])}async downloadConfig(t){let n=await U(()=>N.deviceConfig(t.id));if(n){if(!n.has_private_key){X("This device made its own keys in the browser; its configuration only exists there.","warning");return}fe(n.filename,n.conf,"application/octet-stream")}}editNote(){let t=e("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},this.p.note??"");ne("Note",[t],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Save",async()=>{J(),await this.patch({note:t.value.trim()},t.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>t.focus(),50)}endSettings(){let t=this.p,n=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(i=>e("option",{value:i,selected:t.expire_warn===i?"selected":null},i?`${i} day${i===1?"":"s"} before`:"Don’t warn")));ne("When access ends",[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Then"),e("div",{class:"cbi-value-field"},n)]),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.")])])],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Save",async()=>{J(),await this.patch({expire_action:n.value,expire_warn:a.value},"Saved")},"positive")])}rename(){let t=e("input",{type:"text",class:"cbi-input-text",value:this.p.name,maxlength:48});ne("Rename",[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},t)])],[e("button",{class:"cbi-button cbi-button-neutral",click:J},"Cancel")," ",z("Save",async()=>{J(),await this.patch({name:t.value},"Renamed")},"positive")]),setTimeout(()=>t.select(),50)}async remove(){let t=this.p;await ae(`Delete ${t.name}?`,`All ${t.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await U(()=>N.personDelete(t.id),"Deleted")&&(location.href=Je(t.server))}};var Ua=[["health","Health"],["log","Log"]],kt=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",{})}load(){return Promise.all([N.status(1),N.events(2e4),N.serviceLog(),this.tab==="health"?N.health().catch(()=>null):Promise.resolve(null)])}render([t,n,a,i]){return this.log=new ft(t,n,a.log),this.health=new xt(t,a,n.events,()=>{this.show("log"),this.log.show("problems")}),i&&this.health.take(i),this.show(this.tab),poll.add(async()=>{if(!this.bodyEl.isConnected)return;let[o,r]=await Promise.all([N.serviceLog().catch(()=>null),N.events(2e4).catch(()=>null)]);r&&this.log.take(r),o&&(this.log.system=o.log),o&&this.health.paintLive(o,r?.events??this.health.events),this.tab==="log"&&(o||r)&&this.log.paint()},10),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])}show(t){this.tab=t;let n=new URL(location.href);t==="log"?n.searchParams.set("tab","log"):n.searchParams.delete("tab"),history.replaceState(null,"",n),dom.content(this.segEl,Ua.map(([a,i])=>e("button",{type:"button",role:"tab",class:a===t?"on":"","aria-selected":a===t?"true":"false",click:()=>a!==this.tab&&this.show(a)},i))),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():this.health.checks||this.health.run()}};var qa=`: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}.dl-map .cbi-section,.dl-map .cbi-section-node{border:0!important;background:none!important;box-shadow:none!important;padding:0!important}.dl-map .table.cbi-section-table,.dl-map .cbi-section-table>.tbody,.dl-map .cbi-section-table>tbody{display:block!important;width:100%;border:0!important;background:none!important;box-shadow:none!important;border-radius:0!important}.dl-map .cbi-section-table-titles,.dl-map .cbi-section-table-descr,.dl-map .thead{display:none!important}.dl-map .cbi-section-table-row{display:flex!important;flex-wrap:wrap;align-items:flex-start;gap:12px 16px;margin:0 0 12px;padding:16px!important;background:var(--dl-card)!important;border:1px solid var(--dl-line)!important;border-radius:var(--dl-radius)!important;box-shadow:var(--dl-shadow)}.dl-map .cbi-section-table-row.dl-filtered{display:none!important}.dl-map .cbi-section-table-row:hover{background:var(--dl-card)!important}.dl-map .cbi-section-table-row>.td{display:block!important;border:0!important;padding:0!important;background:none!important;width:auto!important}.dl-map .cbi-section-table-row>.td:first-child{flex:1 1 26em;min-width:0}.dl-map .cbi-section-table-row>.td.cbi-section-actions{flex:0 0 auto;margin-left:auto}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div{display:flex;flex-wrap:nowrap;gap:6px;justify-content:flex-end}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div>*{margin:0!important;flex:0 0 auto}.dl-map .cbi-section-table-row>.td:before{display:none!important}.dl-map .cbi-section-table-row.placeholder{color:var(--dl-fg-muted);display:flex!important;justify-content:center;align-items:center;min-height:0!important;height:auto!important;padding:28px 16px!important;text-align:center}.dl-map .cbi-section-table-row.placeholder>*{position:static!important;padding:0!important;margin:0!important;border:0!important;flex:0 1 auto!important}.dl-map .cbi-section-table-row.dl-off .dl-card-name,.dl-map .cbi-section-table-row.dl-off .dl-avatar{opacity:.6}.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-map .cbi-section-table-row>.td.cbi-section-actions{margin-left:0;width:100%!important}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div{justify-content:flex-start;flex-wrap:wrap}.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}#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-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}.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)}.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-healthstrip{display:flex;align-items:center;gap:8px 16px;flex-wrap:wrap;padding:9px 14px;margin:0 0 12px;border-radius:12px;border:1px solid color-mix(in srgb,var(--dl-warn) 45%,transparent);background:var(--dl-warn-wash);font-size:13px;color:var(--dl-fg-muted)}.dl-healthstrip.bad{border-color:color-mix(in srgb,var(--dl-bad) 45%,transparent);background:var(--dl-bad-wash)}.dl-healthstrip-title{display:inline-flex;align-items:center;gap:6px;font-weight:500;color:var(--dl-warn)}.dl-healthstrip.bad .dl-healthstrip-title{color:var(--dl-bad)}.dl-healthstrip-title .dl-icon{width:15px;height:15px}.dl-healthstrip-item{cursor:default}.dl-healthstrip a{margin-left:auto;font-size:12px;font-weight:500;color:var(--dl-fg);text-decoration:none;padding:3px 9px;border-radius:8px}.dl-healthstrip a:hover{background:var(--dl-soft)}.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-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}.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}.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)}.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)}.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}.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-map .cbi-section-create,.dl-map>.cbi-section>.cbi-button-add{display:none!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-map .cbi-section-table-row>.td:has(.dl-pcard){flex:1 1 100%;max-width:none!important;width:100%!important;margin:0!important}.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-map .cbi-section-table-row.dl-attn-row{border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}@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}.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}.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>*+*{border-top:1px solid var(--dl-line)}.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-head{display:flex;align-items:center;gap:12px;padding:16px 20px}.dl-upd-head>.dl-stack{flex:1;min-width:0}.dl-upd-head>.dl-stack>b{font-size:15px;font-weight:500}.dl-upd-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 20px;border-top:1px solid var(--dl-line);min-height:40px}.dl-upd-row>.dl-stack{min-width:0}.dl-upd-name{font-size:14px}.dl-upd-row .dl-mono{font-size:11px}.dl-upd-row .dl-mono b{color:var(--dl-fg);font-weight:500}.dl-upd-row>.dl-pill,.dl-upd-row>button,.dl-upd-head>.dl-pill,.dl-upd-head>button{flex:none}.dl-upd-bad{color:var(--dl-bad)}.dl-upd-job>.dl-log,.dl-upd-job>.alert-message{margin:0 14px 14px}`;function yn(){let s=document.createElement("style");return s.dataset.dawnline="1",s.textContent=qa,s}function Be(s,t){return()=>{let n=new s,a={load:()=>n.load(),render:async i=>{let o=await n.render(i),r=document.createElement("div");return r.className="dl-root",r.append(yn(),o),r},addFooter(){return n.noFooter?document.createElement("div"):this.super("addFooter",[])}};return t||Object.assign(a,{handleSave:null,handleSaveApply:null,handleReset:null}),a}}var Ao=Be(nt,!1),Po=Be(Ie,!0),No=Be(nt,!1),zo=Be(bt,!1),Ro=Be(yt,!1),Ho=Be(kt,!1),Io=Be(wt,!1);function kn(s){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${s?`?tab=${s}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var Bo=kn(""),jo=kn("log");return baseclass.extend({ activity: jo, diagnostics: Ho, health: Bo, overview: Ao, people: Po, person: Ro, server: No, settings: zo, updates: Io }); +`,mn(r,t)]:[mn(r,t)])),s=e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),t=!t,dom.content(s,[v(t?"x":"key"),t?"Hide key":"Show key"]),a()}},[v("key"),"Show key"]);a();let o=new Blob([i.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"},i.filename),e("span",{class:"dl-sub"},`AmneziaWG · ${o} bytes · import it in the app`)]),R([v("download")," Download"],()=>ve(i.filename,i.conf,"application/octet-stream"),"positive")]),e("details",{class:"dl-params"},[e("summary",{},[v("chevron"),e("span",{},"Configuration"),e("span",{class:"dl-spacer"}),s,e("button",{type:"button",class:"dl-chipbtn",click:r=>{r.preventDefault(),he(i.conf,"Configuration copied")}},[v("copy"),"Copy"])]),n])])}async function It(i,t="file"){if(!i.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 n=await sn(i,`${i.server} · ${i.person} · ${i.name}`),a={qr:()=>e("div",{class:"dl-qr-pane"},[Pe(Oe(i.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"},n),R("Copy",()=>he(n,"Key copied"))]),e("span",{class:"dl-sub"},"AmneziaVPN → Add server → Insert key. Keep it private.")]),file:()=>wa(i)},s=e("div",{class:"dl-connect-body"}),o=e("div",{class:"dl-seg"}),r=l=>{o.querySelectorAll("button").forEach(d=>d.classList.toggle("on",d.dataset.id===l)),dom.content(s,a[l]())};for(let[l,d]of[["file","File"],["key","Key"],["qr","QR code"]])o.appendChild(e("button",{type:"button","data-id":l,click:()=>r(l)},d));return r(t),e("div",{class:"dl-stack gap12"},[o,s])}function ya(i,t,n,a){mt?.close();let s=e("aside",{class:"dl-drawer",role:"dialog","aria-modal":"true"},[e("div",{class:"dl-drawer-head"},[i,e("button",{type:"button",class:"dl-drawer-x","aria-label":"Close",click:()=>l()},v("x"))]),e("div",{class:"dl-drawer-body"},t),n?e("div",{class:"dl-drawer-foot"},n):""]),o=e("div",{class:"dl-drawer-overlay dl-root",click:p=>{p.target===o&&l()}},s),r=p=>{p.key==="Escape"&&!document.body.classList.contains("modal-overlay-active")&&l()};function l(){document.removeEventListener("keydown",r),o.classList.remove("open"),setTimeout(()=>o.remove(),220),mt===d&&(mt=null),a()}let d={close:l,panel:s};return document.addEventListener("keydown",r),document.body.appendChild(o),requestAnimationFrame(()=>o.classList.add("open")),mt=d,d}var gn={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 ka(i,t){let n=i.filter(a=>a.device===t&&gn[a.type]).reverse().slice(0,12);return n.length?e("div",{class:"dl-dev-log"},n.map(a=>{let[s,o,r]=gn[a.type],l=a.type==="connect"?[a.detail?e("span",{class:"dl-muted"},` from ${a.detail}`):"",a.where?e("span",{class:"dl-muted"},` · ${a.where}`):""]:a.type==="roam"?[e("span",{class:"dl-muted"},` · ${a.detail??""}`)]:a.type==="device_added"||a.type==="device_removed"||a.type==="device_keys"?[e("span",{class:"dl-muted"},xe(a)==="portal"?" on the portal":xe(a)==="admin"?" by you":"")]:[],d=new Date(a.ts*1e3);return e("div",{class:`dl-dev-log-row${xe(a)==="admin"?" dl-ev-by-admin":""}`},[xe(a)==="admin"?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):e("span",{class:`dl-ev-tile ev ${s}`},v(r)),e("span",{class:"dl-row-main"},[e("span",{},o),...l]),e("span",{class:"dl-faint dl-nowrap",title:d.toLocaleString()},ue(a.ts))])})):e("div",{class:"dl-sub"},"No activity yet.")}function $a(i){return i.disabled?e("span",{class:"dl-dstat"},"Disabled"):i.online?e("span",{class:"dl-dstat ok"},"Connected"):i.handshake?e("span",{class:"dl-dstat"},`Last seen ${ue(i.handshake)}`):e("span",{class:"dl-dstat warn"},"Waiting for the first connection")}async function De(i,t,n,a){let s=await U(()=>z.deviceConfig(t.id));if(!s)return;let o=t,r=i,l=await It(s),d=e("div",{class:"dl-drawer-title"}),p=e("div",{}),u=e("div",{}),c=e("div",{},e("div",{class:"dl-sub"},"Loading…")),b=[],g=async()=>{let h=await z.events(5e3).catch(()=>null);h&&(b=h.events.filter(P=>P.device===o.id),dom.content(c,ka(h.events,o.id)))},w=()=>{let h=a?.points.find(f=>f.device===o.id&&f.ip===o.endpoint);dom.content(d,[e("span",{class:`dl-dcard-ic${o.online?" on":""}`},v(o.kind)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h3",{},o.name),R([v("edit")],()=>Y(),"neutral",{title:"Rename",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]),e("span",{class:"dl-sub"},[`${r.name} · ${Se[o.kind]}`])])]);let P=o.spark.reduce((f,_)=>f+_,0);dom.content(p,e("div",{class:"dl-dstats"},[e("div",{class:"dl-dstats-cell wide"},[e("span",{class:"dl-metric-label"},"Status"),$a(o)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"This month"),e("b",{},Z(o.month[0]+o.month[1])),e("span",{class:"dl-sub dl-mono"},`↓ ${Z(o.month[1])} ↑ ${Z(o.month[0])}`)]),e("div",{class:"dl-dstats-cell"},[e("span",{class:"dl-metric-label"},"Last 7 days"),e("b",{},Z(P)),dn(o.spark,120,22)])])),dom.content(u,e("div",{class:"dl-kv2"},[un("Tunnel address",o.address),o.hostname&&r.access!=="internet"?un("Local address",o.hostname):"",o.endpoint?gt("Client IP",e("span",{},[o.endpoint,h?e("span",{class:"dl-muted"},` · ${[h.city,h.org].filter(Boolean).join(" · ")}`):""])):"",gt("Total",e("span",{class:"dl-kv-act"},[`↓ ${Z(o.total[1])} · ↑ ${Z(o.total[0])}`,e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Fe("device",o.id,o.name,()=>setTimeout(F,300))},"Reset")])),gt("Added",`${xa(o.created)} · ${o.created_by==="portal"?"from the portal":"by you"}`),gt("Public key",e("span",{class:"dl-mono dl-faint"},s.amnezia.client_pub_key?`${s.amnezia.client_pub_key.slice(0,16)}…`:"—"))])),dom.content(j,[R([v(o.disabled?"play":"pause"),o.disabled?" Enable":" Disable"],async()=>{await U(()=>z.deviceUpdate(o.id,void 0,!o.disabled),o.disabled?"Device enabled":"Device disabled")&&await F()},"neutral",o.disabled?{}:{class:"cbi-button cbi-button-neutral dl-btn-warn"}),R([v("key")," New keys"],async()=>{if(!await re("Generate new keys?","The current configuration on this device stops working until it is imported again.","Generate",!0))return;if(await U(()=>z.deviceRotate(o.id),"New keys generated")){n(),m.close();let _=await z.status(1),O=_.people.find(B=>B.id===r.id),G=O?.devices.find(B=>B.id===o.id);O&&G&&De(O,G,n,_.geo)}}),e("span",{class:"dl-spacer"}),R([v("trash")," Remove"],async()=>{await re(`Remove ${o.name}?`,"The device is disconnected immediately and its configuration stops working.","Remove",!0)&&await U(()=>z.deviceDelete(o.id),"Device removed")&&(m.close(),n())},"negative")])},F=async()=>{let h=await z.status(1).catch(()=>null),P=h?.people.find(_=>_.id===r.id),f=P?.devices.find(_=>_.id===o.id);!h||!P||!f||(r=P,o=f,a=h.geo,w(),n())},Y=()=>{let h=e("input",{type:"text",class:"cbi-input-text",value:o.name,maxlength:48});se(`Rename ${o.name}`,[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},h)])],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{await U(()=>z.deviceUpdate(o.id,h.value,void 0),"Renamed")&&(X(),await F())},"positive")]),setTimeout(()=>h.select(),50)},j=e("div",{class:"dl-drawer-actions"}),$=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},[e("h4",{},"Connect")]),o.config_stale?e("div",{class:"dl-note warn"},[v("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.")]):"",l]),N=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:()=>Le({people:[r]},b,"csv",o.id)},"Export"),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Ce(`Clear ${o.name}'s activity`,`Removes events about ${o.name}.`,{device:o.id},g)},"Clear"),e("a",{href:`${L.url("admin/network/dawnline/diagnostics")}?tab=log`},"All activity")])]),c]),C=e("section",{class:"dl-dsec"},[e("div",{class:"dl-dsec-head"},e("h4",{},"Details")),u]),T=!o.handshake||o.config_stale,y=e("div",{class:"dl-stack gap16"},T?[p,$,C,N]:[p,C,N,$]);g();let A=window.setInterval(()=>{F(),g()},8e3),m=ya(d,y,j,()=>clearInterval(A));w()}function Ke(i,t){let n=e("input",{type:"text",class:"cbi-input-text",placeholder:Se.phone,maxlength:48}),a="phone",s=e("div",{class:"dl-kinds",role:"radiogroup","aria-label":"Type"},rn.map(r=>e("button",{type:"button",role:"radio",class:r===a?"on":"","aria-checked":r===a?"true":"false","data-kind":r,click:()=>{a=r,s.querySelectorAll("button").forEach(l=>{let d=l.dataset.kind===r;l.classList.toggle("on",d),l.setAttribute("aria-checked",d?"true":"false")}),n.placeholder=Se[r]}},[v(r),e("span",{},Se[r])]))),o=i.devices.length>=i.device_limit;se(`Add a device for ${i.name}`,[o?e("p",{class:"dl-hint"},`${i.name} already has ${i.devices.length} of ${i.device_limit} devices. As admin you can still add one.`):"",e("div",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Type"),s]),e("label",{class:"dl-fld"},[e("span",{class:"dl-fld-label"},"Name"),n])],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Add device",async()=>{let r=n.value.trim()||n.placeholder.replace(/^e\.g\. /,""),l=await U(()=>z.deviceCreate(i.id,r,a));if(!l)return;X(),ne(`${r} added`,"success",3e3),t();let d=await z.status(1),p=d.people.find(c=>c.id===i.id),u=p?.devices.find(c=>c.id===l.id);p&&u&&De(p,u,t,d.geo)},"positive")]),setTimeout(()=>n.focus(),50)}var Me=1080,tt=1512,ye=96,_a="-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif",Sa="ui-monospace, SFMono-Regular, Menlo, Consolas, monospace",et=i=>i.replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);function La(i,t,n){let a=new URL(n),s=a.pathname.slice(1),o=Math.min(92,Math.floor((Me-2*ye)/(.58*(4+i.name.length)))),r=Me-2*ye,l=392,d=40,p=Oe(n,2).replace("`${F}`;return``+u(ye+82,ye+42,36,"#a3a3a3",et(t))+u(ye,276,o,"#ffffff",`Hi, ${et(i.name)}`,'font-weight="600"')+u(ye,340,40,"#8a8a8a",`Scan to connect to ${et(t)}`)+``+p+`${et(s)}`+u(Me/2,l+r+156,34,"#737373",et(a.host),'text-anchor="middle"')+""}async function Ma(i){let t=new Image;t.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(i)}`,await t.decode();let n=document.createElement("canvas");return n.width=Me,n.height=tt,n.getContext("2d").drawImage(t,0,0,Me,tt),new Promise((a,s)=>n.toBlob(o=>o?a(o):s(new Error("Could not draw the card")),"image/png"))}async function nt(i,t,n={}){if(!i.link){ne("The personal portal is off. Turn it on in Settings.","warning");return}let a=i.link,s=await U(()=>Ma(La(i,t,a)));if(!s)return;let o=new File([s],`${i.id}-invite.png`,{type:"image/png"}),r=URL.createObjectURL(s),l=navigator,d=!!l.canShare?.({files:[o]}),p=()=>{URL.revokeObjectURL(r),X()},u=d?R([v("link")," Share card"],async()=>{try{await l.share({files:[o],title:`Invite ${i.name}`})}catch{}},"positive"):R([v("download")," Download card"],()=>ve(o.name,s),"positive");se(n.title??`Invite ${i.name}`,e("div",{class:"dl-invite"},[e("img",{src:r,alt:`Invite card for ${i.name}`}),e("div",{class:"dl-invite-side"},[e("p",{class:"dl-muted"},n.lead??`Send ${i.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:()=>he(a,"Personal link copied")},[e("span",{},a.replace(/^https:\/\//,"")),v("copy")]),...(i.links??[]).filter(c=>c!==a).map(c=>e("button",{type:"button",class:"dl-invite-link alt",title:"Copy this link",click:()=>he(c,"Link copied")},[e("span",{},c.replace(/^https?:\/\//,"")),e("span",{class:`dl-pill ${c.startsWith("http:")?"warn":""}`},c.startsWith("http:")?"HTTP":"Also"),v("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"},[u,R([v("copy")," Copy link"],()=>he(a,"Personal link copied"))])])]),[e("button",{class:"cbi-button cbi-button-neutral",click:p},"Done")],"wide")}var Ea={active:"",paused:"pause",paused_all:"pause",expired:"calendar",quota:"chart",hours:"clock",no_server:"alert"};function Bt(i){if(i.state==="active")return"";let t=e("span",{class:`dl-ibadge ${Da(i)}`,"aria-label":Pt[i.state]},v(Ea[i.state]||"alert"));return pe(t,()=>[e("div",{class:"dl-tip-title"},Pt[i.state])]),t}function Ta(i){let t=i.devices.length,n=Math.max(1,i.device_limit,t),a=Math.min(160,n*22+(n-1)*3);return e("div",{class:"dl-slotbar",title:`${t} of ${i.device_limit} devices`},[e("span",{class:"dl-slotbar-segs",style:`width: ${a}px`},Array.from({length:n},(s,o)=>e("i",{class:o>=i.device_limit?"over":oe("span",{class:`dl-ibadge ${a}`},v(a==="lan"?"home":"globe"))));return pe(n,()=>[e("div",{class:"dl-tip-title"},Ue[i.access]),i.access==="lan"&&i.services?.length?e("div",{class:"dl-muted"},`${i.services.length} home service${i.services.length===1?"":"s"} only`):""]),n}function Da(i){return i.state==="active"?"ok":i.state==="quota"||i.state==="expired"?"bad":"warn"}function Aa(i,t){let n=i,s=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(o=>e("button",{type:"button",class:`dl-choice${o.v===n?" selected":""}`,"data-v":o.v,click:()=>{n=o.v,s.querySelectorAll(".dl-choice").forEach(r=>r.classList.toggle("selected",r.dataset.v===o.v)),t?.(o.v)}},[e("span",{class:"dl-choice-title"},[v(o.ic),Ue[o.v]]),e("span",{class:"dl-choice-text"},o.text)])));return{el:s,get:()=>n}}function Pa(i){return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`}function fn(i){let t=ze(i.expires);return i.state==="quota"||i.state==="expired"||t!=null&&t<=Math.max(i.expire_warn,3)||!!i.quota_limit&&i.quota_used>=i.quota_limit*.9}function Na(i){let t=i?new Date(`${i}T12:00:00`):new Date,n=t.getTime()t===new URLSearchParams(location.search).get("filter"))??"all";this.sort="seen";this.noFooter=!0;this.serverId=null;this.polling=!1;this.el=null;this.statusSeq=0;this.statusShown=0}async load(){return z.status(30)}scope(t){return this.serverId?ct(t,this.serverId):t}embed(t,n){return this.serverId=n,this.render(t)}person(t){return this.st.people.find(n=>n.id===t)}async latestStatus(){let t=++this.statusSeq,n=await z.status(30).catch(()=>null);return!n||te("em",{},n.servers.length?"No people yet. Add someone and send them their personal link.":"Set up the server first, then add people."),a.serverId&&(r.filter=l=>a.st.people.some(d=>d.id===l)),r.handleAdd=()=>a.openCreate(),r.handleRemove=l=>a.remove(l),r.renderRowActions=()=>e("div",{class:"dl-none"}),s=r.option(form.DummyValue,"_card"),s.modalonly=!1,s.textvalue=l=>a.renderCard(e("div",{class:"dl-card",id:`dl-card-${l}`}),l),o.render().then(l=>{l.classList.add("dl-map","dl-root");let d=e("select",{class:"dl-select","aria-label":"Sort",change:u=>{a.sort=u.target.value,a.decorate()}},[e("option",{value:"seen"},"Last seen"),e("option",{value:"name"},"Name"),e("option",{value:"usage"},"Usage")]),p=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",id:"dl-people-count"},this.countText())]),n.servers.length?R([v("plus")," Add person"],()=>a.openCreate(),"add"):""]),n.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",id:"dl-people-tabs",role:"tablist"}),e("div",{class:"dl-toolbar-end"},[d,a.serverId?R([v("plus")," Add person"],()=>a.openCreate(),"add"):""])]),l]);return this.el=p,requestAnimationFrame(()=>this.decorate()),this.polling||(this.polling=!0,poll.add(()=>a.el?.isConnected?a.poll():Promise.resolve(),10)),!vn&&new URLSearchParams(location.search).get("add")&&(vn=!0,setTimeout(()=>a.openCreate(),100)),p})}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(){let t=document.getElementById("dl-people-count");t&&(t.textContent=this.countText());let n=this.st.people,a={all:n.length,online:n.filter(c=>c.online>0).length,attention:n.filter(fn).length,paused:n.filter(c=>c.state!=="active"&&c.state!=="quota"&&c.state!=="expired").length},s=document.getElementById("dl-people-tabs");if(s){let c={all:"All",online:"Online",attention:"Needs attention",paused:"Paused"};dom.content(s,Object.keys(c).map(b=>e("button",{type:"button",role:"tab",class:b===this.filter?"on":"",click:()=>{this.filter=b,this.decorate()}},[c[b],e("b",{class:b==="attention"&&a[b]?"warn":""},String(a[b]))])))}let o=c=>!(this.filter==="online"&&!c.online||this.filter==="attention"&&!fn(c)||this.filter==="paused"&&!(c.state!=="active"&&c.state!=="quota"&&c.state!=="expired")),r=[...n].sort((c,b)=>this.sort==="name"?c.name.localeCompare(b.name):this.sort==="usage"?b.month[0]+b.month[1]-(c.month[0]+c.month[1]):b.online-c.online||b.last_seen-c.last_seen),l=null,d=0;for(let c of r){let g=document.getElementById(`dl-card-${c.id}`)?.closest(".cbi-section-table-row");if(!g)continue;l??(l=g.parentElement),l?.appendChild(g),g.classList.toggle("dl-off",c.state!=="active"),g.classList.toggle("dl-attn-row",c.state==="quota"||c.state==="expired");let w=o(c);g.classList.toggle("dl-filtered",!w),w&&d++}let p=l?.closest(".cbi-section-table")??l,u=document.getElementById("dl-people-none");p&&n.length&&!d?(u??(u=e("div",{id:"dl-people-none",class:"dl-empty"})),dom.content(u,e("p",{},"No one here right now.")),u.parentElement!==p.parentElement&&p.after(u)):u?.remove()}async poll(){let t=await this.latestStatus();if(!t)return;let n=this.scope(t);this.st=n,this.paintCards(),this.decorate()}async quick(t,n,a){await U(()=>z.personUpdate(t.id,n),a)&&await this.poll()}renderCard(t,n){let a=this.person(n);if(!a)return dom.content(t,e("em",{},"Not saved yet — use “Save & Apply”.")),t;let s=ze(a.expires),o=Math.max(0,a.device_limit-a.devices.length),r=[];if(a.expires){let c=s!=null&&s>=0&&s<=Math.max(a.expire_warn,3),b=s!=null&&s<0;r.push(e("span",{class:`dl-pill-ic${b?" bad":c?" warn":""}`,title:`Access ends ${_e(a.expires)}`},[v("calendar"),b?`ended ${_e(a.expires)}`:c?`ends in ${s} day${s===1?"":"s"}`:`until ${_e(a.expires)}`]))}a.hours&&r.push(e("span",{class:"dl-pill-ic",title:"Allowed hours"},[v("clock"),a.hours.replace("-","–")]));let l=rt(a.devices).map(c=>e("button",{type:"button",class:`dl-chip${c.disabled?" disabled":""}${c.online?" live":""}`,title:`${Se[c.kind]} · ${c.address}${c.online?` · online from ${c.endpoint}`:c.handshake?` · seen ${ue(c.handshake,this.st.now)}`:""}`,click:b=>{b.preventDefault(),De(a,c,()=>this.refresh(),this.st.geo)}},[v(c.kind),e("span",{class:"dl-chip-name"},c.name),!c.handshake&&!c.disabled?e("span",{class:"dl-chip-tag"},"not set up"):""]));l.push(e("button",{type:"button",class:"dl-chip add","aria-label":"Add device",title:o>0?"Add device":"Add device · over the limit, admins can still add",click:c=>{c.preventDefault(),Ke(a,()=>this.refresh())}},v("plus")));let d=[];a.state==="quota"&&a.quota_period==="month"&&d.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&&s!=null&&s<=Math.max(a.expire_warn,3)&&d.push(e("button",{type:"button",class:"dl-fix",click:()=>this.quick(a,{expires:Na(a.expires)},"Extended by 1 month")},"Extend 1 month"));let p=ke("more","More",c=>we(c.currentTarget,[{label:"Open",icon:v("open"),run:()=>{location.href=be(a.id)}},a.link?{label:"Invite card",icon:v("qr"),run:()=>nt(a,this.st.servers.find(b=>b.id===a.server)?.name??"Home")}:null,o>0?{label:"Add device",icon:v("plus"),run:()=>Ke(a,()=>this.refresh())}:null,null,{label:a.paused?"Resume":"Pause",icon:v(a.paused?"play":"pause"),warn:!a.paused,run:()=>this.togglePause(a)},{label:"Delete",icon:v("trash"),danger:!0,run:()=>this.remove(a.id)}].filter((b,g,w)=>b||g>0&&w[g-1])),"neutral","dl-icon-only"),u=e("div",{class:"dl-pcard-actions"},[a.link?ke("link","Copy link",()=>he(a.link,"Personal link copied"),"neutral","dl-icon-only"):"",p]);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":""}`},Re(a.name)),e("div",{class:"dl-pcard-who"},[e("div",{class:"dl-card-head"},[e("a",{class:"dl-card-name",href:be(a.id)},a.name),Bt(a),Ca(a),...r]),Ta(a)])]),e("div",{class:"dl-chips"},l),d.length?e("div",{class:"dl-fixes"},d):""]),this.usageSide(a,u)])),t}usageSide(t,n){let a=t.quota_used||t.month[0]+t.month[1],s=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,o=t.devices.reduce((u,c)=>u+(c.spark[c.spark.length-1]??0),0),r=t.rate?.[t.rate.length-1],l=t.online&&r&&this.st.now-r[0]<180,d=e("div",{class:`dl-usebar${s>=100?" bad":s>=90?" warn":""}`});if(t.quota_limit){let u=e("i",{class:"fill"});u.style.width=`${s}%`,d.appendChild(u),pe(d,()=>[e("div",{class:"dl-tip-title"},`${s.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${Z(t.quota_used)} of ${Z(t.quota_limit)} · ${Z(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 u=t.devices.map(c=>({d:c,v:c.month[0]+c.month[1]})).filter(c=>c.v>0).sort((c,b)=>b.v-c.v);u.forEach((c,b)=>{let g=e("i",{class:`c${Math.min(b,4)}`});g.style.flexGrow=String(c.v),d.appendChild(g)}),u.length&&pe(d,()=>[e("div",{class:"dl-tip-title"},"This month by device"),...u.map((c,b)=>e("div",{class:"dl-tip-row"},[e("span",{class:`dl-swatch c${Math.min(b,4)}`}),e("span",{},c.d.name),e("b",{},Z(c.v))]))])}let p=t.quota_limit?`${Z(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"),n]),e("div",{class:"dl-use-num"},[e("b",{class:a?"":"dl-faint"},Z(a)),e("span",{class:"dl-faint"},t.quota_limit?`of ${Z(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"},[`↓ ${$e(r[2])}`,e("span",{class:"dl-faint"},`↑ ${$e(r[1])}`)]):e("div",{class:"dl-faint dl-pside-foot"},o?`today ${Z(o)} · ${p}`:p)])}async togglePause(t){await U(()=>z.personPause(t.id,!t.paused),t.paused?`${t.name} resumed`:`${t.name} paused`)&&await this.refresh()}async remove(t){let n=this.person(t);await re(`Remove ${n?.name??t}?`,`All ${n?.devices.length??0} devices are disconnected immediately and the personal link stops working. Usage history is kept in backups.`,"Remove",!0)&&await U(()=>z.personDelete(t),"Person removed")&&await this.refresh()}openCreate(){let t=this.st;if(!t.servers.length){ne("Set up the server first.","warning");return}let n=e("input",{type:"text",class:"cbi-input-text",placeholder:"e.g. Myata",maxlength:48}),a=Aa("internet"),s=e("input",{type:"number",class:"cbi-input-text",min:1,max:32,value:t.settings.default_device_limit}),o=e("input",{type:"date",class:"cbi-input-text"}),r=e("input",{type:"number",class:"cbi-input-text",min:0,step:"any",placeholder:"Unlimited"}),l=(c,b)=>e("button",{type:"button",class:"cbi-button cbi-button-neutral",click:()=>{if(!b)o.value="";else{let g=new Date;g.setMonth(g.getMonth()+b),o.value=Pa(g)}}},c),d=t.servers[0],p=!this.serverId&&t.servers.length>1?e("select",{class:"cbi-input-select"},t.servers.map(c=>e("option",{value:c.id},c.name))):null,u=(c,b,g)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},c),e("div",{class:"cbi-value-field"},[b,g?e("div",{class:"cbi-value-description"},g):""])]);se("Add person",[u("Name",n),p?u("Server",p):"",e("div",{class:"cbi-value dl-block"},[e("label",{class:"cbi-value-title"},"Access"),e("div",{class:"cbi-value-field"},a.el)]),u("Devices",s,"How many devices they can add themselves."),u("End date",e("div",{class:"dl-actions"},[o,l("1 month",1),l("3 months",3),l("1 year",12),l("None",0)]),"Optional."),u("Monthly data (GB)",r,"Optional. They are paused when it runs out and resumed next month.")],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Create and copy link",async()=>{let c=await U(()=>z.personCreate(n.value.trim(),"",p?.value??d.id,a.get(),Number(s.value)||t.settings.default_device_limit,o.value,Number(r.value)||0,"month"));c&&(c.link&&await he(c.link,"Personal link copied"),this.showCreated(c.id,n.value.trim(),c.link,t.servers.find(b=>b.id===(p?.value??d.id))?.name??d.name),await this.refresh())},"positive")]),setTimeout(()=>n.focus(),50)}showCreated(t,n,a,s){if(a){nt({id:t,name:n,link:a},s,{title:`${n} is ready`,lead:`Send ${n} the card or the link. They open it, add their devices and connect — no account needed.`});return}se(`${n} 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:X},"Done")])}};function Ee(i,t,n){let a=e("button",{type:"button",role:"switch",class:`dl-switch${i?" on":""}`,"aria-checked":i?"true":"false","aria-label":t,click:()=>{let s=!a.classList.contains("on");a.classList.toggle("on",s),a.setAttribute("aria-checked",s?"true":"false"),n?.(s)}},e("i"));return a}var Ve=i=>i.classList.contains("on");function oe(i,t={}){return e("input",{type:"text",class:"cbi-input-text",value:i,...t})}function ee(i,t,n){return e("div",{class:"dl-setrow"},[e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},i),n?e("span",{class:"dl-sub"},n):""]),e("div",{class:"dl-setrow-ctl"},t)])}function at(i,t,n,a=""){return e("section",{class:`dl-setsec ${a}`},[e("div",{class:"dl-setsec-body"},[i?e("h3",{},i):"",...t]),n.length?e("div",{class:"dl-setsec-foot"},n):""])}function me(i,t,n,a){return e("div",{class:"dl-group"},[e("div",{class:"dl-group-head"},[e("span",{class:"dl-group-ic"},v(i)),e("span",{class:"dl-stack"},[e("b",{},t),n?e("span",{class:"dl-sub"},n):""])]),e("div",{class:"dl-group-body"},a.filter(s=>s!==""))])}var ft=["#3a83f7","#a78bfa","#f472b6","#f59e0b","#10b981","#22d3ee","#ef4444","#84cc16"],bt=i=>e("i",{class:"dl-circle-dot",style:`background:${ft[i?.color??0]??ft[0]}`}),Ye=i=>i.access==="both"||i.access==="lan"&&!i.services?.length;function bn(i,t,n){let a=oe(i?.name??t.name??"",{placeholder:"NAS"}),s=oe(i?.address??t.address??"",{placeholder:"192.168.1.10",class:"cbi-input-text dl-mono"}),o=oe((i?.ports??t.ports??[]).join(", "),{placeholder:"All ports, or e.g. 445, 5000",class:"cbi-input-text dl-mono"}),r=(l,d)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},l),e("div",{class:"cbi-value-field"},d)]);se(i?`Edit ${i.name}`:"Add service",[r("Name",a),r("Address",s),r("Ports",o)],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{let l=o.value.split(/[ ,]+/).filter(Boolean);await U(()=>z.serviceSet(i?.id??"",a.value,s.value,l),"Saved")&&(X(),n())},"positive")])}var za={_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"},Ra=[["Web",["80","443"]],["SMB",["445"]],["SSH",["22"]]];function Ha(i){let t=new Map;for(let n of i.services){let a=za[n.type.split(".")[0]];!a||!n.port||(t.get(a)??t.set(a,new Set).get(a)).add(String(n.port))}return t.size?[...t].map(([n,a])=>[n,[...a].sort((s,o)=>+s-+o)]):Ra}function xn(i,t,n){let a=i.services,s=e("div",{class:"dl-stack gap8"},e("span",{class:"dl-sub"},"Looking for devices at home…")),o=a.length?a.map(d=>e("div",{class:"dl-row"},[v("home"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},d.name),e("span",{class:"dl-mono dl-faint"},`${d.address}${d.ports.length?` · ports ${d.ports.join(", ")}`:" · all ports"}`)]),R("Edit",()=>bn(d,{},n)),R([v("trash")],async()=>{await re(`Remove ${d.name}?`,"People limited to this service lose access to it.","Remove",!0)&&await U(()=>z.serviceDelete(d.id),"Removed")&&n()},"neutral",{title:"Remove","aria-label":`Remove ${d.name}`})])):[e("div",{class:"dl-row dl-muted"},"No services yet: pick ports of a device below.")];async function r(d,p){let u=a.find(b=>b.address===d.address);(p===null?u&&await U(()=>z.serviceDelete(u.id),`${u.name} removed`):await U(()=>z.serviceSet(u?.id??"",u?.name??(d.name||d.address),d.address,p),u?`${u.name} updated`:`${d.name||d.address} added`))&&n()}function l(d){let p=a.find(g=>g.address===d.address),u=!!p&&!p.ports.length,c=new Set(p?.ports??[]),b=(g,w,F)=>e("button",{type:"button",class:`dl-chipbtn${w?" on":""}`,"aria-pressed":w?"true":"false",click:F},g);return e("div",{class:"dl-row"},[v(d.services.some(g=>g.type.startsWith("_ipp")||g.type.startsWith("_printer"))?"file":"computer"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},d.name||d.address),e("span",{class:"dl-mono dl-faint"},d.address)]),e("div",{class:"dl-chips-row dl-host-ports"},[b("All ports",u,()=>r(d,u?null:[])),...Ha(d).map(([g,w])=>{let F=!u&&w.every(Y=>c.has(Y));return b(`${g} ${w.join(", ")}`,F,()=>{let Y=new Set(u?[]:c);for(let j of w)F?Y.delete(j):Y.add(j);r(d,Y.size?[...Y]:null)})})])])}return z.homeHosts(t).then(d=>{let p=d.hosts.some(u=>a.some(c=>c.address===u.address))&&!a.length;dom.content(s,d.hosts.length?e("details",{class:"dl-params",open:p?"":null},[e("summary",{},[v("chevron"),e("span",{},"Add from devices at home"),e("span",{class:"dl-pcount"},String(d.hosts.length))]),e("div",{class:"dl-params-body"},[e("span",{class:"dl-sub"},d.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"},d.hosts.map(l))])]):e("span",{class:"dl-sub"},"No devices found in the home network right now."))}).catch(()=>dom.content(s,e("span",{class:"dl-sub"},"Couldn't read the devices at home."))),e("div",{class:"dl-stack gap8"},[e("div",{class:"dl-iflead"},[e("div",{class:"dl-iflead-row"},[e("b",{},"Home services"),R([v("plus")," Add service"],()=>bn(null,{},n))]),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.")]),e("div",{class:"dl-list"},o),s])}function vt(i,t,n,a){let s=new Set(i.circles.filter(g=>g.server===t).map(g=>g.color)),o=n?.color??ft.findIndex((g,w)=>!s.has(w));o<0&&(o=0);let r=oe(n?.name??"",{placeholder:"Family"}),l=i.people.filter(g=>g.server===t).sort((g,w)=>g.name.localeCompare(w.name)),d=new Set(l.filter(g=>n&&g.circle===n.id).map(g=>g.id)),p=e("div",{class:"dl-swatches",role:"radiogroup","aria-label":"Colour"}),u=()=>dom.content(p,ft.map((g,w)=>e("button",{type:"button",role:"radio",class:`dl-swatch${w===o?" on":""}`,style:`--sw:${g}`,"aria-checked":w===o?"true":"false","aria-label":`Colour ${w+1}`,click:()=>{o=w,u()}})));u();let c=e("div",{class:"dl-chips-row"},l.map(g=>{let w=g.circle&&g.circle!==n?.id?i.circles.find(F=>F.id===g.circle):void 0;return e("button",{type:"button",class:`dl-chipbtn${d.has(g.id)?" on":""}`,title:Ye(g)?w?`Now in ${w.name}`:"":`${g.name} has no home access: their devices aren't reachable anyway`,click:F=>{d.delete(g.id)||d.add(g.id),F.currentTarget.classList.toggle("on",d.has(g.id))}},[g.name,Ye(g)?w?e("b",{},w.name):"":e("b",{},"internet")])})),b=(g,w)=>e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},g),e("div",{class:"cbi-value-field"},w)]);se(n?`Edit ${n.name}`:"New circle",[b("Name",r),b("Colour",p),b("People",c),e("p",{class:"dl-sub"},"Devices of people in one circle reach each other. A person is in one circle at a time.")],[n?R("Delete",async()=>{await U(()=>z.circleDelete(n.id),`${n.name} deleted`)&&(X(),a())},"negative"):"",e("span",{class:"dl-spacer"}),e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{await U(()=>z.circleSet(n?.id??"",t,r.value,o,[...d]),"Saved")&&(X(),a())},"positive")],"dl-circle-modal")}function wn(i,t,n){let a=i.circles.filter(s=>s.server===t);return e("div",{class:"dl-chips-row dl-circles"},[...a.map(s=>{let o=i.people.filter(r=>r.circle===s.id).map(r=>r.name);return e("button",{type:"button",class:"dl-chip",title:`Edit ${s.name}`,click:()=>vt(i,t,s,n)},[bt(s),e("b",{},s.name),e("span",{class:"dl-faint"},o.length?o.join(", "):"nobody yet")])}),e("button",{type:"button",class:"dl-chip add",title:"New circle","aria-label":"New circle",click:()=>vt(i,t,null,n)},v("plus"))])}function yn(i,t){let n=i.people.filter(u=>u.server===t.id),a=(u="")=>e("span",{class:"dl-yes"},[v("check"),u]),s=()=>e("span",{class:"dl-faint"},"—"),o=u=>{let c=new Set(u.map(b=>b.access==="lan"&&b.services?.length?"services":b.home_nets?.length?"some":"all"));return c.size||c.add("all"),a([...c].map(b=>({all:"all networks",some:"their networks",services:"services"})[b]).join(" / "))},r=()=>t.mesh==="off"?s():t.mesh==="circles"?a("circle"):a(),l=t.lan_like?"like home":"direct",d=(u,c,b)=>e("tr",{},[e("td",{},[e("b",{},u),e("div",{class:"dl-sub"},`${c.length} ${c.length===1?"person":"people"}`)]),...b.map(g=>e("td",{},g))]),p=u=>n.filter(c=>c.access===u);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(u=>e("th",{},u))),d("Internet",p("internet"),[a(l),s(),e("span",{class:"dl-faint"},"DNS"),s()]),d("Home",p("lan"),[e("span",{class:"dl-faint"},"their own"),o(p("lan")),a(),r()]),d("Both",p("both"),[a(l),o(p("both")),a(),r()])])),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 kn(i,t){let n=i.people.filter(p=>p.server===t.id).flatMap(p=>p.devices.map(u=>({id:u.id,label:`${p.name} · ${u.name}`}))).sort((p,u)=>p.label.localeCompare(u.label)),a="@addr",s=(p,u)=>{let c=e("select",{class:"cbi-input-select","aria-label":p},[...n.map(F=>e("option",{value:F.id,selected:F.id===u?"selected":null},F.label)),e("option",{value:a,selected:u===a?"selected":null},"Address")]),b=oe("",{placeholder:p,class:"cbi-input-text dl-mono"}),g=e("div",{class:"dl-check-end"},[c,b]),w=()=>b.hidden=c.value!==a;return c.addEventListener("change",w),w(),{el:g,value:()=>c.value===a?b.value.trim():c.value}},o=s("10.0.1.11",n[0]?.id??a),r=s("10.0.1.20:445",a),l=e("div",{class:"dl-stack gap8"}),d=async()=>{let p=await U(()=>z.accessCheck(o.value(),r.value()));if(!p)return;let u=p.steps.findIndex(c=>!c.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 ${u+1} of ${p.steps.length}`)]),e("ul",{class:"dl-checks"},p.steps.map(c=>e("li",{},[e("span",{class:`dl-check-icon ${c.ok?"ok":"error"}`},v(c.ok?"check":"x")),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},c.title),c.detail?e("div",{class:"dl-check-detail"},c.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"},[o.el,e("span",{class:"dl-faint"},"→"),r.el,R("Check",d)]),l])])}var Ia={https:"HTTPS for the portal",acme:"ACME certificates",home:"the home-like link",bonjour:"Bonjour for home devices"},Ba=300*1e3;async function Je(i,t,n){if(!t.length)return!0;if(!await re(`Install ${Ia[i]}?`,`${t.join(", ")} from the OpenWrt feeds. Dawnline sets the rest up when they arrive.`,"Install"))return!1;let s=(await z.updatesStatus().catch(()=>null))?.job?.started??0;if(!await U(()=>z.updatesRun(`pkgs:${t.join(",")}`)))return!1;ne(`Installing ${t.join(", ")}…`,"info",4e3);let o=Date.now()+Ba;for(;Date.now()setTimeout(d,2e3));let l=(await z.updatesStatus().catch(()=>null))?.job;if(!(!l||l.started===s||l.state==="running"))return l.state==="done"?(ne(`${t.join(", ")} installed`,"success"),setTimeout(()=>n?.(),4e3),!0):(ne(l.error??"Installation failed","error"),!1)}return ne("Still installing: see Updates for the log.","warning"),!1}async function $n(i,t){let n=await U(()=>z.updatesStatus());return n?Je(i,n.needs?.[i]??[],t):!1}var ja=[["wan","WAN"],["ethernet","Ethernet"],["wifi","Wi-Fi"],["vpn","VPN & tunnels"],["other","Other"]],Oa={wan:"globe",ethernet:"ethernet",bridge:"bridge",wifi:"wifi",vpn:"tunnel",other:"link"};function xt(i,t,n){let a=e("button",{type:"button",role:"switch",class:`dl-switch${i?" on":""}`,"aria-checked":i?"true":"false","aria-label":t,click:()=>{let s=!a.classList.contains("on");a.classList.toggle("on",s),a.setAttribute("aria-checked",s?"true":"false"),n(s)}},e("i"));return a}function _n(i,t,n){let a=i.id,s=e("div",{class:"dl-stack gap16"},e("section",{class:"dl-setsec"},e("div",{class:"dl-setsec-body"},e("p",{class:"dl-muted"},"Loading interfaces…")))),o,r=!0,l="",d=!0,p=!0,u="all",c=!1,b=xn(t,a,n),g=new Set,w="",F=()=>JSON.stringify([p,r,r?"":l,d,[...g].sort()]),Y=()=>o.detected.lan||o.saved.lan||"",j=()=>(r?o.detected.wan||o.saved.wan:l)||"",$=()=>new Map(o.devices.map(S=>[S.name,S])),N=()=>{let S=$();return[...d&&Y()?[Y()]:[],...[...g].filter(W=>W!==Y())].filter(W=>W!==j()).map(W=>S.get(W)??{name:W,nets:[],missing:!0})},C=(S,q)=>{o=S,q&&(r=S.config.auto_wan,l=S.config.wan_device||S.detected.wan||S.saved.wan||"",d=S.config.auto_lan,p=S.config.lan_like,u=S.config.mesh??(S.config.device_mesh?"all":"off"),g=new Set(S.config.lan_devices),w=F()),O()},T=async S=>{let q=await z.interfaces(a).catch(W=>(ne(W.message,"error"),null));q&&C(q,S)};function y(S){let q=d&&S.name===Y(),W=!!S.own||!!S.master||S.name===j()||q;return q||g.has(S.name)||!W&&(S.nets.length>0||!!S.missing)}function A(S){let q=d&&S.name===Y(),W=S.name===j(),te=!q&&g.has(S.name),de=!(!!S.own||!!S.master||W||q)&&(S.nets.length>0||te||!!S.missing),Te=(te||q)&&!S.zone&&!S.missing,I=S.missing?"Not present right now":S.own?"This server":S.master?`Port of ${S.master}`:W?`Internet${S.zone?` · zone ${S.zone}`:""}`:S.nets.length?S.nets.join(", "):"No IPv4 network",ae=e("button",{type:"button",class:`dl-if${te?" sel":""}${q?" auto":""}${!de&&!te&&!q?" off":""}${Te?" warn":""}`,"aria-pressed":te||q?"true":"false","aria-disabled":de?null:"true",click:()=>{de&&(g.has(S.name)?g.delete(S.name):g.add(S.name),O())}},[e("span",{class:"dl-if-ic"},v(Oa[S.kind]??"link")),e("span",{class:"dl-if-main"},[e("span",{class:"dl-if-name"},S.name),e("span",{class:"dl-if-sub"},I)]),q?e("span",{class:"dl-if-badge ok"},"Auto"):te?e("span",{class:"dl-if-check"},v("check")):""]);return pe(ae,()=>[e("div",{class:"dl-tip-title"},S.name),e("div",{class:"dl-muted"},[S.logical?`Interface ${S.logical}`:"No netifd interface",S.zone?` · zone ${S.zone}`:" · no firewall zone"]),S.members.length?e("div",{class:"dl-muted"},`Ports: ${S.members.join(", ")}`):"",S.nets.length?e("div",{class:"dl-mono"},S.nets.join(", ")):"",Te?e("div",{class:"dl-warn"},"Not in a firewall zone: the firewall rejects this traffic."):"",S.master?e("div",{class:"dl-muted"},`Choose ${S.master} to include it.`):""]),ae}function m(){let S=o.like_home;return!p||!o.config.lan_like?"":!o.needs?.length&&S.active&&S.bridged?"ok":"warn"}function h(){let S=o.like_home;return p?o.needs?.length?[e("span",{class:"dl-warn"},`Needs ${o.needs.join(" and ")}.`)," Until they are installed, internet traffic goes straight to the WAN."]:o.config.lan_like?S.active&&S.bridged?["Internet traffic enters ",e("span",{class:"dl-mono"},S.dev??"")," as ",e("span",{class:"dl-mono"},S.address??""),", so whatever handles home traffic (proxies, filters, DNS) handles it too."]:[e("span",{class:"dl-warn"},`Not working: ${S.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 f(S,q,W,te,le="",de){return e("div",{class:de?"dl-setrow head":"dl-setrow"},[e("div",{class:"dl-lh-main"},[e("span",{class:`dl-need-ic ${le}`},v(S)),e("div",{class:"dl-stack"},[e("span",{class:"dl-setrow-label"},q),e("span",{class:"dl-sub"},W),de??""])]),e("div",{class:"dl-setrow-ctl"},te)])}let _=(S,q)=>{let W=te=>e("span",{class:"dl-mono"},te);return S?e("span",{},[" Now: ",W(S),...q&&q!==S?[", was ",W(q)]:[],"."]):e("span",{},q?[" Not found now: using ",W(q),"."]:[" Not found."])};function O(){let S=e("select",{class:"cbi-input-select","aria-label":"Internet interface",change:k=>{l=k.target.value,O()}},o.devices.filter(k=>!k.own&&!k.master&&k.zone&&!k.missing).map(k=>e("option",{value:k.name,selected:k.name===l?"selected":null},`${k.name} · zone ${k.zone}`))),W=N().flatMap(k=>k.nets.map(H=>[H,k.name])),te=JSON.parse(F()),le=JSON.parse(w),de=(...k)=>k.some(H=>JSON.stringify(te[H])!==JSON.stringify(le[H])),Te=de(0,1,2),I=de(3,4),ae=k=>R("Save",async()=>{let H=await U(()=>z.serverInterfaces(a,r,r?"":l,d,[...g],p,u!=="off",u),"Access saved");H&&(C(H,!0),H.nets_changed&&H.lan_only&&ne(`${H.lan_only} ${H.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:!k}),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")]),f("home","Internet like a home device",h(),[p&&o.needs?.length?R("Install",()=>Je("home",o.needs,()=>T(!1)),"positive"):"",xt(p,"Internet like a home device",k=>{p=k,O()})],m()),f("globe","Auto-detect WAN",["The interface with the default route: the server port opens there and Internet access leaves through it.",_(o.detected.wan,o.saved.wan)],[r?"":S,xt(r,"Auto-detect WAN",k=>{r=k,O()})])]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub"},p?["Internet like a home device",j()?[" · leaves through ",e("span",{class:"dl-mono"},j())]:""]:j()?["Internet straight to ",e("span",{class:"dl-mono"},j())]:"No WAN found"),ae(Te)])]),E=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":"Devices reach each other"},[["off","Off"],["all","Everyone"],["circles","Circles"]].map(([k,H])=>e("button",{type:"button",role:"radio",class:u===k?"on":"","aria-checked":u===k?"true":"false",click:async()=>{u!==k&&await U(()=>z.serverUpdate(a,{mesh:k}),`Devices reach each other: ${H}`)&&n()}},H))),x=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"),R([v("reset")," Rescan"],()=>T(!1),"neutral",{title:"Read the interfaces again"})]),f("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.","","",B()),f("link","Devices reach each other",P[u],E,"",u==="circles"?wn(t,a,n):void 0),G(),b]),e("div",{class:"dl-setsec-foot"},[e("span",{class:"dl-sub dl-if-summary"},W.length?["Home access reaches ",...W.flatMap(([k,H],V)=>[V?", ":"",e("span",{class:"dl-mono"},k),` (${H})`])]:"No home network: Home access reaches nothing but this router."),ae(I)])]),D=window.scrollY;s.style.minHeight=`${s.offsetHeight}px`,dom.content(s,[M,x]),s.style.minHeight="",window.scrollTo({top:D})}function G(){let S=o.bonjour,q=async te=>{await U(()=>z.serverUpdate(a,{bonjour:te}),te?"Finding home devices":"Home devices no longer listed")&&T(!1)},W=S.needs.length?e("span",{class:"dl-warn"},` Needs ${S.needs.join(", ")}.`):S.on&&!S.running?e("span",{class:"dl-warn"}," umdns is not running."):S.on?` Listing ${S.services} service${S.services===1?"":"s"} from home now.`:"";return f("wifi",["Find home devices ",e("span",{class:"dl-faint dl-w400"},"· Bonjour")],["iPhone, iPad and Mac on the VPN see AirPlay, printers and shared Macs at home, as on Wi-Fi. Android and Chromecast look only on the local network.",W],S.needs.length?R("Install",()=>Je("bonjour",S.needs,()=>T(!1)),"positive"):xt(S.on,"Find home devices",te=>q(te)),S.on&&S.running?"ok":"")}function B(){let S=o.devices.filter(y),q=o.devices.filter(W=>!y(W));return e("div",{class:"dl-stack gap8 dl-netpick"},[S.length?e("div",{class:"dl-ifgrid"},S.map(A)):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.",_(o.detected.lan,o.saved.lan)])]),xt(d,"Auto-detect LAN",W=>{d=W,O()})]),q.length?e("details",{class:"dl-params",open:c?"":null,toggle:W=>c=W.currentTarget.open},[e("summary",{},[v("chevron"),e("span",{},"Other interfaces"),e("span",{class:"dl-pcount"},String(q.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."),...ja.map(([W,te])=>{let le=q.filter(de=>de.category===W);return le.length?e("div",{class:"dl-ifgroup"},[e("h4",{},te),e("div",{class:"dl-ifgrid"},le.map(A))]):""})])]):""])}return T(!0),s}var Sn=[["overview","Overview"],["people","People"],["connection","Connection"],["access","Access"],["disguise","Disguise"],["tunnel","Tunnel"]],Ua={general:"connection",network:"connection",interfaces:"access",advanced:"tunnel"},Ln=[["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 qa(i){let t=p=>i[p]!=null&&i[p]!=="",n=Ln.filter(([p])=>t(p));if(!n.length)return null;let a=(p,u)=>e("span",{class:"dl-pv"},[e("i",{},u),e("b",{},p==="header_protection_key"?`${i[p].slice(0,6)}••••`:i[p])]),s=(p,u,c,b)=>{let g=Ln.filter(([w])=>b.includes(w)&&t(w));return g.length?e("div",{class:"dl-pgroup"},[e("div",{class:"dl-pgroup-head"},[v(u),e("b",{},p)]),e("p",{},c),e("div",{class:"dl-pvals"},g.map(([w,F])=>a(w,F)))]):""},o=Number(i.jc||0),r=(i.i1??"").includes("0x8580")?"A first packet shaped like a DNS answer.":"Extra packets sent before the handshake.",l=n.map(([p,u])=>`${u} = ${i[p]}`).join(` +`),d=e("div",{class:"dl-pgrid"},[s("Junk packets","zap",o?`${o} random packet${o===1?"":"s"} of ${i.jmin}–${i.jmax} bytes before each handshake.`:"No junk packets.",["jc","jmin","jmax"]),s("Padding","archive","Random bytes in front of handshake, cookie and data packets, so their sizes do not match WireGuard.",["s1","s2","s3","s4"]),s("Packet types","key","The values that replace WireGuard’s recognisable message types.",["h1","h2","h3","h4"]),s("Signatures","globe",r,["i1","i2","i3","i4","i5"]),s("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"]),s("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",{},[v("chevron"),e("span",{},"Current parameters"),e("span",{class:"dl-pcount"},String(n.length)),e("span",{class:"dl-spacer"}),e("button",{type:"button",class:"dl-linkbtn",click:p=>{p.preventDefault(),he(l,"Parameters copied")}},"Copy as config")]),d])}var jt=(i,t)=>{let n=new URLSearchParams;i&&n.set("server",i),t&&t!=="overview"&&n.set("section",t);let a=n.toString();return`${L.url("admin/network/dawnline/server")}${a?`?${a}`:""}`},st=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 z.status(31),n=t.servers.length?null:await z.setupDefaults();return[t,n]}render([t,n]){if(this.st=t,!t.servers.length&&n)return this.wizard(n);let a=new URLSearchParams(location.search),s=a.get("section")??"",o=Ua[s]??s;return Sn.some(([r])=>r===o)&&(this.section=o),this.srvId=(t.servers.find(r=>r.id===a.get("server"))??t.servers[0]).id,dom.content(this.root,[this.tabsEl,this.headEl,this.secEl,this.bodyEl]),this.paint(),poll.add(async()=>{if(this.section!=="overview")return;let r=await z.status(31).catch(()=>null);if(!r||!r.servers.length)return;this.st=r;let l=this.current();dom.content(this.headEl,this.head(l)),this.paintTabs(),this.ov[l.id]?.update(r)},10),this.root}current(){return this.st.servers.find(t=>t.id===this.srvId)??this.st.servers[0]}async refresh(){let t=await z.status(31).catch(()=>null);t&&(this.st=t,t.servers.length?this.paint():location.href=jt())}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(n=>e("button",{type:"button",role:"tab",class:`dl-srvtab${n.id===t.id?" on":""}`,"aria-selected":n.id===t.id?"true":"false",click:()=>{n.id!==this.srvId&&(this.srvId=n.id,this.paint())}},[e("i",{class:`dot ${n.up?"ok":"bad"}`}),e("b",{},n.name),e("span",{class:"dl-mono dl-faint"},`:${n.port}`)])),e("button",{type:"button",class:"dl-srvtab add",click:()=>this.addServer()},[v("plus"),"Add server"])]))}paintSections(){dom.content(this.secEl,e("div",{class:"dl-seg dl-srvsections",role:"tablist","aria-label":"Server"},Sn.map(([t,n])=>e("button",{type:"button",role:"tab","data-section":t,class:t===this.section?"on":"","aria-selected":t===this.section?"true":"false",click:()=>this.showSection(t)},n))))}go(t,n){let a=this.pp[this.current().id];if(n&&a)a.filter=n,a.el&&a.decorate();else if(n){let s=this.pp[this.current().id]=new Be;s.filter=n}this.showSection(t),window.scrollTo({top:0,behavior:"smooth"})}detachKept(){let t=[...Object.values(this.ov).map(n=>n.el),...Object.values(this.pp).map(n=>n.el)];for(let n of t)n&&this.bodyEl.contains(n)&&n.remove()}showSection(t){this.section=t,this.secEl.querySelectorAll("[data-section]").forEach(r=>{let l=r.dataset.section===t;r.classList.toggle("on",l),r.setAttribute("aria-selected",l?"true":"false")});let n=this.st,a=this.current(),o={overview:()=>{let r=this.ov[a.id];return r?(r.update(n),r.el):(this.ov[a.id]=new pt(a.id,(l,d)=>this.go(l,d))).mount(n)},people:()=>{var p,u;let r=this.pp[a.id];if(r?.el)return r.poll(),r.el;let l=e("div",{},e("p",{class:"dl-muted"},"Loading people…"));return((p=this.pp)[u=a.id]??(p[u]=new Be)).embed(n,a.id).then(c=>{l.isConnected?dom.content(l,c):l.replaceChildren(c)}),l},connection:()=>this.connection(a),access:()=>this.access(a),disguise:()=>this.disguise(a),tunnel:()=>this.tunnel(a)}[t]();this.detachKept(),dom.content(this.bodyEl,o)}head(t){let n=this.st,a=(l,d)=>e("span",{class:"dl-addrbar-seg"},[v(l),...d]),s=`${t.endpoint||"—"}:${t.port}`,o=!t.enabled||n.settings.paused_all,r=e("div",{class:"dl-actions"},[o?R([v("play")," Turn on"],async()=>{n.settings.paused_all&&!await U(()=>z.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":"Not running":"Turned off"),n.settings.paused_all&&t.enabled?e("span",{class:"dl-pill warn"},"Off"):"",e("span",{class:"dl-spacer"}),r]),e("div",{class:"dl-addrbar"},[e("button",{type:"button",class:"dl-addrbar-seg main",title:"Copy address and port",click:()=>he(s,"Address copied")},[v("globe"),e("span",{class:"dl-mono"},s),v("copy")]),a("tunnel",[e("span",{class:"dl-mono"},t.ifname)]),a("network",[e("span",{class:"dl-mono"},t.subnet)]),t.up?a("clock",[`up ${on(t.uptime)}`]):""])])}async save(t,n,a="Saved"){await U(()=>z.serverUpdate(t.id,n),a)&&await this.refresh()}connection(t){let n=oe(t.name,{placeholder:"Home"}),a=oe(t.endpoint,{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),s=oe(String(t.port),{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),o=oe(t.dns.join(", "),{placeholder:"This router (recommended)",class:"cbi-input-text dl-mono"}),r=oe(String(t.mtu??""),{placeholder:"1380",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),l=oe(String(t.keepalive??""),{placeholder:"25",inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"});return at("Connection",[e("p",{class:"dl-muted"},"How devices find this server, and what goes into their configuration."),me("router","Server","What people see",[ee("Name",n,"Shown to people in their portal.")]),me("globe","Devices connect to","Where the tunnel answers from the internet",[ee("Public address",a,"Hostname or IP of the router on the internet. A DDNS name keeps links working when your IP changes."),ee("UDP port",s,"Opened on the WAN firewall automatically.")]),me("file","In every device configuration","Changing these marks devices “Update config” until they import again",[ee("DNS for devices",o,"Empty = this router, which sends each query where your home network would."),ee("MTU",r,"Lower it if some sites hang on mobile networks."),ee("Keep-alive",l,"Seconds between packets devices send to keep NAT open. 0 = off.")])],[e("span"),R("Save",()=>this.save(t,{name:n.value,endpoint:a.value,port:s.value,dns:o.value,mtu:r.value,keepalive:l.value}),"positive")])}access(t){let n=()=>this.refresh();return e("div",{class:"dl-stack gap16"},[_n(t,this.st,n),e("div",{class:"dl-health-cols"},[yn(this.st,t),kn(this.st,t)])])}disguise(t){let n=We(t.preset)?t.preset:void 0,a=n??"standard",s=R("",()=>this.applyDisguise(t,a,a===n),"positive"),o=()=>{dom.content(s,a===n?[v("reset")," Generate new values"]:`Switch to ${We(a).title}`)};o();let r=qa(t.obf??{});return at("Disguise",[e("p",{class:"dl-muted"},"AmneziaWG reshapes the tunnel so networks that block VPNs do not recognise it. Every device gets these settings in its configuration."),Nt(this.st.awg,a,l=>{a=l,o()},n),this.st.awg.v3?"":Ae("info",["This router runs an older AmneziaWG. ",e("b",{},"Maximum")," becomes available with kmod-amneziawg and amneziawg-tools 3.1."]),r??""],[e("span",{class:"dl-sub"},"Applies at once. Every device on this server must import its configuration again."),s])}async applyDisguise(t,n,a){let s=We(n),r=this.st.people.filter(d=>d.server===t.id).reduce((d,p)=>d+p.devices.length,0);await re(a?"Generate new disguise values?":`Switch to ${s.title}?`,`${r} device${r===1?"":"s"} stop connecting until they import their configuration again (from their personal link or from you).${n==="max"?" They need an app with AmneziaWG 3.1.":""}`,a?"Generate and apply":"Switch and apply",!0)&&await U(()=>z.serverObfuscation(t.id,n),a?"New values applied":`${s.title} applied`)&&(ne("Devices are marked “Update config” until they import again.","info",6e3),await this.refresh())}tunnel(t){let n=this.st.people.filter(s=>s.server===t.id).length,a=R(t.enabled?"Turn off":"Turn on",async()=>{t.enabled&&!await re(`Turn off ${t.name}?`,`The tunnel stops and ${n} ${n===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"},[at("Tunnel",[e("p",{class:"dl-muted"},"Technical details. They are set when the server is created and rarely change."),ee("Interface",e("span",{class:"dl-mono"},`${t.ifname} · router ${t.address}`)),ee("Tunnel subnet",e("span",{class:"dl-mono"},t.subnet),"Device addresses come from it."),ee("Server public key",e("span",{class:"dl-keyrow"},[e("code",{class:"dl-mono"},t.public_key),R([v("copy")],()=>he(t.public_key,"Public key copied"),"neutral",{title:"Copy",class:"cbi-button cbi-button-neutral dl-icon-only sm"})]))],[]),at("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"},a)]),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 ${n} ${n===1?"person":"people"} with all their devices. A backup is made first.`)]),e("div",{class:"dl-setrow-ctl"},R([v("trash")," Remove"],()=>this.remove(t),"negative"))])],[],"danger")])}async addServer(){let t=await U(()=>z.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 n=this.st.people.filter(a=>a.server===t.id);se(`Remove ${t.name}?`,[e("p",{},`This removes the tunnel, its firewall rules and ${n.length} ${n.length===1?"person":"people"} with all their devices. A backup is made first.`)],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Remove",async()=>{X(),await U(()=>z.serverDelete(t.id),"Server removed")&&setTimeout(()=>{location.href=jt()},800)},"negative")])}wizard(t,n=!1,a){let s={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},o=0,r=e("div",{class:"dl-wizard"}),l=(c,b={})=>{let g=oe(String(s[c]),b);return g.addEventListener("input",()=>{s[c]=c==="port"||c==="portal_port"?Number(g.value):g.value.trim()}),g},d=n?["Connection","Disguise"]:["Connection","Disguise","Portal"],p=[()=>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."),me("router","Server","What people see",[ee("Name",l("name"),"Shown to people in their portal.")]),me("globe","Devices connect to","Where the tunnel answers from the internet",[ee("Public address",l("endpoint",{placeholder:"vpn.example.com",class:"cbi-input-text dl-mono"}),"Hostname or IP address of your router on the internet."),ee("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.")]),me("network","Tunnel network","Addresses devices get inside the tunnel",[ee("Tunnel subnet",l("subnet",{class:"cbi-input-text dl-mono"}),`Must not overlap your networks (${t.taken.join(", ")||"none found"}).`)])]),()=>e("div",{},[e("p",{},"AmneziaWG reshapes the tunnel so networks that block VPNs do not recognise it. Every device gets these settings automatically; you can change the method later."),Nt(t.awg,s.preset,c=>s.preset=c)]),()=>{let c=l("portal_port",{inputmode:"numeric",class:"cbi-input-text dl-w-port dl-mono"}),b=ee("Listening port",c,"TCP port on WAN for the portal; the whole port belongs to it.");b.hidden=!s.portal;let g=e("div",{class:"dl-seg",role:"radiogroup","aria-label":"Personal portal"},["off","on"].map(w=>e("button",{type:"button",role:"radio",class:w==="on"===s.portal?"on":"","aria-checked":w==="on"===s.portal?"true":"false",click:F=>{s.portal=w==="on",b.hidden=!s.portal,g.querySelectorAll("button").forEach(Y=>{let j=Y===F.currentTarget;Y.classList.toggle("on",j),Y.setAttribute("aria-checked",j?"true":"false")})}},w==="on"?"On":"Off")));return e("div",{class:"dl-wizard-groups"},[me("home","Internet like a home device","How devices reach the internet",[ee("Through the home network",Ee(s.lan_like,"Internet like a home device",w=>s.lan_like=w),"Whatever handles home traffic on this router (proxies, filters, DNS) handles theirs too. Change it later under Servers → Access.")]),me("link","Personal portal","A page where each person adds their own devices with their personal link",[ee("Portal",g,"Off: only you add devices, from LuCI. On: people manage their devices within the limits you set."),b])])}],u=()=>{dom.content(r,[e("h2",{},n?"Add a server":"Set up Dawnline"),e("div",{class:"dl-steps"},d.map((c,b)=>e("span",{class:`dl-step${b===o?" current":b0?R("Back",()=>{o--,u()}):a?R("Cancel",a):"",e("span",{class:"dl-spacer"}),o{if(o===0&&(!s.endpoint||!s.port||!s.subnet)){ne("Fill in the public address, port and subnet.","warning");return}o++,u()},"positive"):R("Create server",async()=>{let c=await U(()=>z.serverCreate(s.id,s.name,t.ifname,s.port,s.subnet,s.endpoint,t.mtu,s.preset,s.lan_zone,s.wan_zone,s.lan_like,n?void 0:s.portal,n?void 0:s.portal_port),"Server created");c&&setTimeout(()=>{location.href=jt(c.id)},1500)},"positive")])])};return u(),r}};var wt=300,Wa=["all","connections","people","system","problems"],Ga={info:"",up:"ok",down:"warn",repair:"warn",error:"bad"},Fa={awg:"tunnel",dawnline:"sunrise",portal:"globe"};function Ka(i){let t=new Date(i*1e3),n=new Date,a=new Date;return a.setDate(n.getDate()-1),t.toDateString()===n.toDateString()?"Today":t.toDateString()===a.toDateString()?"Yesterday":t.toLocaleDateString("en-GB",{weekday:"long",day:"numeric",month:"long"})}function Ot(i){let t=i.keep_days>0?`${i.keep_days} day${i.keep_days===1?"":"s"}`:"no age limit",n=i.persist==="off"?"kept in memory only (lost on reboot)":`saved to flash ${i.persist==="10min"?"every 10 minutes":"hourly"}`;return`Kept for ${t}, up to ${i.max.toLocaleString("en-GB")} events, ${n}.`}var Ut=i=>i.sys?["error","repair","down"].includes(i.sys.level):ht(i.ev.type)==="problems";function qt(i,t,n,a){let s=i.by==="admin",o=e("div",{class:`dl-row dl-slog-row ${s?"dl-ev-by-admin":`dl-ev-by-system ${Ga[i.level]??""}`}${i.detail?" has-detail":""}`},[s?e("span",{class:"dl-ev-tile",title:"Done by you in LuCI"},v("admin")):e("span",{class:"dl-ev-tile sys",title:i.level},v(Fa[i.src]??"zap")),e("span",{class:"dl-row-main"},s?[e("span",{class:"dl-you"},"You"),e("span",{class:"dl-muted"},` ${i.msg} `),i.kind?e("span",{class:"dl-ev-kind"},`${i.kind} `):"",i.who?e("b",{},i.who):"",i.note?e("span",{class:"dl-muted"},` · ${i.note}`):"",i.detail?e("span",{class:`dl-slog-more${t?" open":""}`},v("chevron")):"",i.detail&&t?e("pre",{class:"dl-slog-detail"},i.detail):""]:[i.src==="awg"&&i.who&&i.who!=="AmneziaWG"?e("span",{class:"dl-ev-kind"},"Server "):"",e("b",{class:"dl-sys-src",title:ut[i.src]??i.src},i.who??ut[i.src]??i.src)," ",e("span",{class:"dl-muted"},i.msg),i.detail?e("span",{class:`dl-slog-more${t?" open":""}`},v("chevron")):"",i.detail&&t?e("pre",{class:"dl-slog-detail"},i.detail):""]),e("span",{class:"dl-faint dl-nowrap",title:new Date(i.ts*1e3).toLocaleString()},a)]);return i.detail&&o.addEventListener("click",r=>{r.target.closest("pre")||n()}),o}var yt=class{constructor(t,n,a){this.events=[];this.system=[];this.kind="all";this.shown=wt;this.open=new Set;this.list=e("div",{});this.sub="";this.tabs=e("div",{class:"dl-seg",role:"tablist"});this.st=t,this.take(n),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,n=o=>()=>{let r=this.filtered().reverse();Le(this.st,r.filter(l=>l.ev).map(l=>l.ev),o,t(),r.filter(l=>l.sys).map(l=>l.sys))},a=R([v("download")," Export"],()=>we(a,[{label:"CSV (spreadsheet)",icon:v("download"),run:n("csv")},{label:"JSON",icon:v("download"),run:n("json")}])),s=R([v("trash")," Clear"],()=>Ce("Clear the log","Removes events from the log on the router.",{},()=>this.reload(),this.kind==="all"?void 0:this.kind,!0));return[a,s]}take(t){this.events=t.events,this.policy=t.policy;let n=Xe.filter(a=>!t.policy.categories.includes(a));this.sub=`${Ot(t.policy)}${n.length?` Not recorded: ${n.map(a=>Ge[a].toLowerCase()).join(", ")}.`:""}`}async reload(){let[t,n]=await Promise.all([z.events(2e4).catch(()=>null),z.serviceLog().catch(()=>null)]);t&&this.take(t),n&&(this.system=n.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,n)=>n.ts-t.ts)}matches(t,n){return n==="all"?!0:n==="problems"?Ut(t):n==="system"?!!t.sys:!!t.ev&&ht(t.ev.type)===n}filtered(){return this.items().filter(t=>this.matches(t,this.kind))}paintTabs(t){dom.content(this.tabs,Wa.map(n=>e("button",{type:"button",role:"tab",class:n===this.kind?"on":"","aria-selected":n===this.kind?"true":"false",click:()=>this.show(n)},[n==="all"?"All":n==="system"?"System":Ge[n],e("b",{},String(t.filter(a=>this.matches(a,n)).length))])))}show(t){this.kind=t,this.shown=wt,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 n=[],a="",s=null;for(let o of t.slice(0,this.shown)){let r=Ka(o.ts);r!==a&&(a=r,s=e("div",{class:"dl-panel flush"},e("div",{class:"dl-panel-head pad"},e("h3",{},r))),n.push(s));let l=new Date(o.ts*1e3).toLocaleTimeString("en-GB",{hour:"2-digit",minute:"2-digit"});if(o.sys){let d=`${o.sys.ts}|${o.sys.msg}`;s.appendChild(qt(o.sys,this.open.has(d),()=>{this.open.delete(d)||this.open.add(d),this.paint()},l))}else{let d=Ie(this.st,o.ev);d.lastElementChild.textContent=l,s.appendChild(d)}}t.length>this.shown&&n.push(e("div",{class:"dl-more-row"},R(`Show ${Math.min(wt,t.length-this.shown)} more of ${t.length-this.shown}`,()=>{this.shown+=wt,this.paint()}))),dom.content(this.list,n)}};var Va={manual:"Manual",auto:"Nightly","pre-restore":"Before restore","pre-import":"Before import","pre-delete":"Before removing a server","pre-update":"Before update"},Mn=3;function Wt(i){let t=new Date(i*1e3),n=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"})}, ${n}`}async function Ya(i){let t=await U(()=>z.backupRead(i.name));if(!t)return;let n=atob(t.data),a=new Uint8Array(n.length);for(let o=0;oYa(i),"neutral","dl-icon-only"),ke("more","More",n=>we(n.currentTarget,[{label:"Restore",icon:v("reset"),run:async()=>{await re("Restore this backup?",`Everything returns to ${Wt(i.created)}. The current state is backed up first.`,"Restore",!0)&&await U(()=>z.backupRestore(i.name),"Restored")&&t()}},{label:"Delete",icon:v("trash"),danger:!0,run:async()=>{await re("Delete this backup?",`The backup from ${Wt(i.created)} is removed from the router.`,"Delete",!0)&&await U(()=>z.backupDelete(i.name),"Backup deleted")&&t()}}]),"neutral","dl-icon-only")])])}function Gt(i,t){let n=i.slice(0,Mn).map(d=>En(d,t)),a=i.slice(Mn),s=i.length?e("div",{class:"dl-list"},[...n,a.length?e("details",{class:"dl-bk-older"},[e("summary",{},[v("chevron"),`${a.length} older backup${a.length===1?"":"s"}`]),...a.map(d=>En(d,t))]):""]):e("div",{class:"dl-list"},[e("div",{class:"dl-row dl-muted"},"No backups yet.")]),o=R("Restore from file",async()=>{let d=await At(".tar.gz,.tgz,application/gzip","base64");if(!d)return;await re("Restore from file?",`Replace the current Dawnline configuration with ${d.name}? The current state is backed up first.`,"Restore",!0)&&await U(()=>z.backupUpload(d.data),"Restored")&&t()}),r=R("Export JSON",async()=>{let d=await U(()=>z.exportJson());d&&ve(`dawnline-export-${new Date().toISOString().slice(0,10)}.json`,JSON.stringify(d,null,2),"application/json")}),l=R("Import JSON",async()=>{let d=await At(".json,application/json","text");if(!d)return;let p;try{p=JSON.parse(d.data)}catch{ne("Not a JSON file.","error");return}await re("Import?","This replaces the whole Dawnline configuration on this router. The current state is backed up first.","Import",!0)&&await U(()=>z.importJson(p),"Imported")&&t()});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"}),R([v("plus")," Back up now"],async()=>{await U(()=>z.backupCreate(),"Backup created")&&t()},"positive")]),s]),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"},[o,r,l])])])}function it(i,t,n){i.some(([o])=>o===t)||(i=[...i,[t,t]]);let a=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":n,"data-value":t}),s=()=>dom.content(a,i.map(([o,r])=>e("button",{type:"button",role:"radio",class:o===a.dataset.value?"on":"","aria-checked":o===a.dataset.value?"true":"false",click:()=>{a.dataset.value=o,s()}},r)));return s(),a}function Ft(i,t,n=`${t}s`){return`${i.toLocaleString("en-GB")} ${i===1?t:n}`}function kt(i){return i<1024?`${i} B`:i<1048576?`${(i/1024).toFixed(i<10240?1:0)} KB`:`${(i/1048576).toFixed(1)} MB`}var $t=class{constructor(){this.root=e("div",{class:"dl-settings-main"});this.backups=[]}load(){return z.settingsGet()}render(t){return this.d=t,this.paint(),this.loadBackups().then(()=>{new URLSearchParams(location.search).get("section")==="backups"&&document.getElementById("dl-set-backups")?.scrollIntoView({block:"start"})}),e("div",{},[e("div",{class:"dl-pagehead"},[e("h2",{class:"dl-h1"},"Settings")]),this.root])}async save(t,n="Saved"){let a=await U(()=>z.settingsUpdate(t),n);a&&(this.d=a,this.paint())}section(t,n,a,s,o="",r=[]){return e("section",{class:`dl-setsec ${o}`,id:`dl-set-${t}`},[e("div",{class:"dl-setsec-body"},[r.length?e("div",{class:"dl-setsec-head"},[e("h3",{},n),e("span",{class:"dl-spacer"}),...r]):e("h3",{},n),...a]),s.length?e("div",{class:"dl-setsec-foot"},s):""])}portalSection(){let t=this.d.settings,n=this.d.effective,a=this.d.cert,s=this.d.portal_candidates??[],o=this.d.portal_checks??[],r=Ee(n.portal_enabled,"Enable portal"),l=oe(t.portal_port,{placeholder:"8443",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),d=Ee(n.portal_443,"Standard ports",()=>T()),p=oe(t.portal_title,{placeholder:"Dawnline"}),u=oe(t.portal_redirect,{placeholder:"Show “Not found”",class:"cbi-input-text dl-mono"}),c=oe("",{placeholder:"vpn.example.com or an IP","aria-label":"Other address"}),b=I=>/^\d{1,3}(\.\d{1,3}){3}$/.test(I),g=[n.portal_host,...n.portal_alt??[]].filter((I,ae,M)=>I&&M.indexOf(I)===ae);!g.length&&s[0]&&(g=[s[0].host]);let w=[...s],F=I=>{I&&!w.some(ae=>ae.host===I)&&w.push({host:I,kind:b(I)?"ip":"name",ips:[],here:!1,cloudflare:!1,cert:!1})};g.forEach(F);let Y=I=>I.kind==="ip"?e("span",{class:"dl-addr-warn"},[v("alert"),"Plain HTTP: the link and VPN keys travel unencrypted"]):e("span",{class:"dl-sub"},I.cloudflare?"Behind Cloudflare · often stalls in Russia":I.ips.length?I.here?`Points at this router${I.cert?" · Let’s Encrypt certificate":" · no certificate yet"}`:`Points at ${I.ips.join(", ")}, not this router`:"Your address"),j=e("div",{class:"dl-addr-opts",role:"group","aria-label":"Portal addresses"}),$=I=>{g.includes(I)?g.length>1&&(g=g.filter(ae=>ae!==I)):g=[...g,I],N(),T()},N=()=>dom.content(j,[...w.map(I=>{let ae=g.includes(I.host),M=g[0]===I.host;return e("div",{class:`dl-addr-opt${ae?" on":""}`,role:"checkbox","aria-checked":ae?"true":"false",tabindex:"0",click:()=>$(I.host),keydown:E=>{(E.key===" "||E.key==="Enter")&&(E.preventDefault(),$(I.host))}},[e("i",{class:"dl-addr-check"},ae?v("check"):""),e("span",{class:"dl-stack"},[e("span",{class:"dl-mono"},I.host),Y(I)]),M?e("span",{class:"dl-pill info"},"Main"):ae?e("button",{type:"button",class:"dl-linkbtn",click:E=>{E.stopPropagation(),g=[I.host,...g.filter(x=>x!==I.host)],N(),T()}},"Make main"):I.cloudflare?e("span",{class:"dl-pill warn"},"Cloudflare"):I.kind==="ip"?e("span",{class:"dl-pill"},"IP"):I.here&&I.cert?e("span",{class:"dl-pill ok"},"Recommended"):""])}),e("div",{class:"dl-addr-opt other"},[e("i",{class:"dl-addr-check"},v("plus")),c,R("Add",()=>{let I=c.value.trim().toLowerCase();I&&(F(I),g.includes(I)||(g=[...g,I]),c.value="",N(),T())})])]);c.addEventListener("keydown",I=>{I.key==="Enter"&&(I.preventDefault(),c.nextElementSibling?.click())});let C=e("div",{class:"dl-links"}),T=()=>{let I=Ve(d),ae=Number(l.value)||n.portal_port;dom.content(C,g.map((M,E)=>{let x=b(M),D=x?I?80:ae+1:I&&!this.d.wan443_taken?443:ae,k=`${x?"http":"https"}://${M}${D===(x?80:443)?"":`:${D}`}/`;return e("div",{class:"dl-link-row"},[e("span",{class:`dl-link-ic ${x?"warn":"ok"}`},v(x?"alert":"lock")),e("span",{class:"dl-mono dl-link-url"},[k,e("b",{},"kamiro-telosu-bavine")]),E===0?e("span",{class:"dl-pill info"},"Main"):x?e("span",{class:"dl-pill warn"},"HTTP"):""])}))};N(),T(),l.addEventListener("input",()=>T());let y={portal:"Portal running",portal_dns:"Points here",portal_reply:"Answers reach visitors",portal_443:"Port 443",portal_lan:"Works at home",portal_http:"Plain HTTP",cert:"Certificate"},A=o.filter(I=>I.status!=="skip"),m=A.filter(I=>I.status==="error"||I.status==="warn"),h=A.some(I=>I.status==="error")?"error":m.length?"warn":"ok",P=e("div",{class:"dl-ready-details",hidden:!0},A.map(I=>e("div",{class:`dl-ready-item ${I.status}`},[v(I.status==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("span",{},I.title),e("span",{class:"dl-sub"},I.detail)])]))),f=e("div",{class:"dl-stack gap8"},[e("div",{class:`dl-ready-sum ${h}`},[v(h==="ok"?"check":"alert"),e("span",{class:"dl-stack"},[e("b",{},h==="ok"?`All ${A.length} checks passed`:`${A.length-m.length} of ${A.length} checks passed`),m.length?e("span",{class:"dl-sub"},m.map(I=>I.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:I=>{P.hidden=!P.hidden,I.currentTarget.textContent=P.hidden?"Details":"Hide"}},"Details")]),e("div",{class:"dl-chips-row"},A.map(I=>e("span",{class:`dl-check-chip ${I.status}`,title:I.detail},[v(I.status==="ok"?"check":"alert"),y[I.id]??I.title]))),P]),_=a&&!a.self_signed&&a.expires?new Date(a.expires).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"",O=ee("Standard ports",d,this.d.wan443_taken?"Port 443 is already forwarded to another device, so HTTPS links keep the listening port.":"Links without a port: 443 for names, 80 for IP addresses. Mobile networks often drop other ports. From the internet these reach only the portal; LuCI stays closed."),G=ee("Listening port",l,this.d.port_owners.length?`Port ${n.portal_port} is used by ${this.d.port_owners.join(", ")}.`:`Where the portal runs on the router: HTTPS here, plain HTTP for IP addresses on ${n.portal_port+1}.`),B=!!(t.portal_cert&&t.portal_key),S=a?B?"Your files":a.self_signed?"Self-signed":"Let’s Encrypt":"Portal is off",q=()=>{let I=oe(t.portal_cert,{placeholder:"/etc/ssl/…/fullchain.crt"}),ae=oe(t.portal_key,{placeholder:"/etc/ssl/…/key"});se("Use your own certificate",[e("p",{class:"dl-muted"},"Paths on the router. Leave both empty to pick a certificate automatically."),ee("Certificate file",I),ee("Key file",ae)],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",()=>{X(),this.save({portal_cert:I.value.trim(),portal_key:ae.value.trim()},"Certificate saved")},"positive")])},W=this.d.needs??{https:[],acme:[],home:[]},te=(I,ae,M,E,x,D)=>e("div",{class:`dl-row dl-need-row ${ae}`},[ae?e("span",{class:"dl-need-ic"},v(I)):v(I),e("span",{class:"dl-row-main dl-stack"},[e("b",{},M),e("span",{class:"dl-sub"},E)]),R(D,()=>Je(x,W[x],()=>this.reload()),"positive")]),le=W.https.length?te("lock","bad","HTTPS isn’t available on this router",`The portal needs ${W.https.join(" and ")}. It can’t start without them.`,"https","Install"):"",de=W.acme.length&&(!a||a.self_signed)?te("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"):"",Te=[e("div",{class:"dl-row"},[v("lock"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},[S,_?e("span",{class:"dl-faint"},` · until ${_}`):""]),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.":`${B?"Your files":"Found automatically"} · ${a.path}`:"Turn the portal on to see its certificate.")])]),e("div",{class:"dl-row"},[v("file"),e("span",{class:"dl-row-main dl-stack"},[e("b",{},"Your own files"),e("span",{class:"dl-sub"},B?`${t.portal_cert} · ${t.portal_key}`:"Not set: the certificate is picked automatically.")]),B?R("Reset",()=>this.save({portal_cert:"",portal_key:""},"Automatic certificate"),"negative"):"",R(B?"Change":"Use files",q)]),de];return this.section("portal","Personal portal",[e("span",{class:"dl-muted"},"A page where each person adds and manages their devices with their personal link."),le?e("div",{class:"dl-list"},[le]):"",me("network","Ports","How the portal listens",[O,G]),me("edit","Appearance","What people see",[ee("Title",p,"Shown at the top of the portal."),ee("Unknown links",u,"Where a wrong or old link goes, for example your website. Empty shows a plain “Not found”.")]),me("link","Addresses","Pick one or more; the first is the main link",[j,e("div",{class:"dl-stack gap8"},[C,e("span",{class:"dl-sub"},"Example code; each person gets their own three words.")])]),me("lock","Certificate","Used for HTTPS links",Te),n.portal_enabled&&A.length?me("check","Ready to share","The portal’s checks from Health",[f]):""],[e("span"),R("Save",()=>this.save({portal_enabled:Ve(r)?"1":"0",portal_443:Ve(d)?"1":"0",portal_host:g[0]??"",portal_alt:g.slice(1),portal_port:l.value,portal_title:p.value,portal_redirect:u.value.trim()}),"positive")],"",[n.portal_enabled?W.https.length?e("span",{class:"dl-pill bad"},"Can’t start"):e("span",{class:`dl-pill ${h==="ok"?"ok":h==="error"?"bad":"warn"}`},h==="error"?"Needs attention":"Ready"):"",r])}paint(){let t=this.d.settings,n=this.d.effective,a=this.portalSection(),s=oe(t.default_device_limit,{placeholder:"3",inputmode:"numeric",class:"cbi-input-text dl-w-port"}),o=Ee(n.hostnames,"Device hostnames"),r=oe(t.domain,{placeholder:"lan",class:"cbi-input-text dl-w-port"}),l=oe(t.home_dns_fallback==="none"?"":t.home_dns_fallback||n.home_dns_fallback||"",{placeholder:"None",inputmode:"decimal",class:"cbi-input-text dl-w-ip dl-mono"}),d=this.section("defaults","Defaults",[ee("Devices per person",s,"Pre-filled when you add someone."),ee("Device hostnames",e("div",{class:"dl-hostport"},[o,e("span",{class:"dl-faint dl-mono"},"phone.myata."),r]),"Name devices in your home DNS."),ee("Fallback DNS",l,"For Home-only devices using home names: the second DNS server, used by the device when the tunnel is down. Empty = none.")],[e("span"),R("Save",()=>this.save({default_device_limit:s.value,hostnames:Ve(o)?"1":"0",domain:r.value,home_dns_fallback:l.value}),"positive")]),p=Ee(n.geo_enabled,"Locations"),u=e("select",{class:"cbi-input-select"},[e("option",{value:"ipwho.is",selected:n.geo_provider!=="ipapi.co"?"selected":null},"ipwho.is (fallback: ipapi.co)"),e("option",{value:"ipapi.co",selected:n.geo_provider==="ipapi.co"?"selected":null},"ipapi.co (fallback: ipwho.is)")]),c=this.section("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."),p]),ee("Provider",u)],[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."),R("Save",()=>this.save({geo_enabled:Ve(p)?"1":"0",geo_provider:u.value}),"positive")]),b=this.logsSection(),g=this.section("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"),R("Remove",()=>this.uninstall(),"negative")],"danger"),w=Gt(this.backups,()=>{this.reload(),this.loadBackups()});dom.content(this.root,[a,d,c,b,w,g])}logsSection(){let t=this.d.logs,n=t.policy,a=it([["7","7 days"],["30","30 days"],["90","90 days"],["365","1 year"],["0","No limit"]],String(n.keep_days),"Keep activity"),s=it([["500","500"],["2000","2,000"],["5000","5,000"],["20000","20,000"]],String(n.max),"Maximum events"),o=it([["10min","Every 10 min"],["hourly","Hourly"],["off","Memory only"]],n.persist,"Save to flash"),r=it([["31","1 month"],["62","2 months"],["180","6 months"],["365","1 year"],["730","2 years"]],String(n.usage_days),"Daily traffic"),l=it([["12","1 year"],["24","2 years"],["60","5 years"],["120","10 years"]],String(n.usage_months),"Monthly traffic"),d=new Set(n.categories),p=e("div",{class:"dl-chips-row"},Xe.map(w=>{let F=e("button",{type:"button",class:`dl-chipbtn${d.has(w)?" on":""}`,title:hn[w],click:()=>{d.has(w)?d.delete(w):d.add(w),F.classList.toggle("on",d.has(w))}},[Ge[w],e("b",{},String(t.by_category[w]??0))]);return F})),u=w=>new Date(w).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),c=t.oldest?u(new Date(t.oldest*1e3)):"",b=(w,F,Y,j)=>e("div",{class:"dl-row"},[v(w),e("span",{class:"dl-row-main dl-stack"},[e("b",{},F),e("span",{class:"dl-sub"},Y)]),...j]),g=w=>R(w.toUpperCase(),async()=>{let[F,Y]=await Promise.all([z.status(1),z.events(2e4)]);Le(F,Y.events,w)},"neutral",{title:`Download the log as ${w.toUpperCase()}`});return this.section("logs","Logs & history",[e("p",{class:"dl-muted"},Ot(n)),ee("Keep activity",a,"Older events are removed automatically."),ee("Maximum size",s,"Newest events are kept when the log is full."),ee("Record",p,"Switched-off categories are not logged from now on."),ee("Save to flash",o,"The log lives in memory and is copied to flash. Memory only saves flash writes but is lost on reboot."),ee("Daily traffic",r,"Per-day history behind the charts."),ee("Monthly traffic",l,"Per-month totals; data limits use the current month."),e("h4",{class:"dl-setsub"},"Stored data"),e("div",{class:"dl-list"},[b("activity","Activity log",t.events?`${Ft(t.events,"event")} since ${c} · ${kt(t.log_ram)} in memory${n.persist==="off"?"":`, ${kt(t.log_flash)} on flash`}`:"Empty",[g("csv"),g("json"),R("Clear",()=>Ce("Clear activity","Removes events from the log on the router.",{},()=>this.reload()),"negative")]),b("chart","Traffic history",t.usage_days?`${Ft(t.usage_days,"day")} since ${u(t.usage_since)} · ${kt(t.usage_flash)} on flash`:"Empty",[R("Reset",()=>Fe("all","","",()=>setTimeout(()=>this.reload(),300)),"negative")]),b("pin","Location cache",`${Ft(this.d.geo_cached,"address","addresses")} · ${kt(t.geo_flash)} on flash`,[R("Clear",async()=>{await U(()=>z.geoClear(),"Location cache cleared")&&this.reload()},"negative")])])],[e("span",{class:"dl-sub"},"Clear one person or device from their own page."),R("Save",()=>this.save({log_keep_days:a.dataset.value,log_max:s.dataset.value,log_persist:o.dataset.value,usage_keep_days:r.dataset.value,usage_keep_months:l.dataset.value,log_category:[...d]}),"positive")])}async loadBackups(){let t=await z.backupList().catch(()=>null);if(t){this.backups=t.backups;let n=document.getElementById("dl-set-backups");n&&n.replaceWith(Gt(this.backups,()=>{this.reload(),this.loadBackups()}))}}async reload(){let t=await z.settingsGet().catch(()=>null);t&&(this.d=t,this.paint())}uninstall(){let t=oe("",{placeholder:"remove"});se("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."),t],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Remove Dawnline",async()=>{await U(()=>z.uninstall(t.value.trim()),"Dawnline removed")&&(X(),setTimeout(()=>location.reload(),800))},"negative")])}};var Ja={ok:"check",warn:"alert",error:"x",skip:"pause"},Tn={apply:"Repair",sync:"Reload devices",restart:"Restart service",updates:"Open updates"},_t=class{constructor(t,n,a,s){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=n,this.events=a,this.toLog=s,dom.content(this.el,[this.summary,this.wdEl,e("div",{class:"dl-health-cols"},[this.checksEl,this.recentEl])]),this.paintChecks(),this.paintLive(n,a)}async run(t){let n=t?await U(()=>z.healthFix(t),"Done"):await z.health().catch(()=>null);n&&this.take(n)}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 n=t.filter(r=>r.status==="error").length,a=t.filter(r=>r.status==="warn").length;dom.content(this.summary,n?Ae("error",`${n} problem${n>1?"s":""} need attention.`):a?Ae("warn",`${a} warning${a>1?"s":""}.`):Ae("ok","All checks passed."));let s=new Map;for(let r of this.sl.watchdog.repairs)s.set(r.id,Math.max(s.get(r.id)??0,r.ts));let o=()=>this.run();dom.content(this.checksEl,[e("div",{class:"dl-panel-head"},[e("h3",{},"Checks"),e("span",{class:"dl-spacer"}),R("Run again",o)]),e("ul",{class:"dl-checks"},t.map(r=>e("li",{},[e("span",{class:`dl-check-icon ${r.status}`},v(Ja[r.status])),e("div",{class:"dl-check-body"},[e("div",{class:"dl-check-title"},r.title),e("div",{class:"dl-check-detail"},r.detail),s.has(r.id)?e("div",{class:"dl-check-repaired"},`Repaired by the watchdog at ${Ne(s.get(r.id))}`):""]),r.fix?r.fix.startsWith("install:")?R("Install",()=>$n(r.fix.slice(8),o),"action"):r.fix==="updates"?e("a",{class:"cbi-button cbi-button-action",href:L.url("admin/network/dawnline/updates")},Tn.updates):R(Tn[r.fix]??"Fix",()=>this.run(r.fix),"action"):""])))])}paintLive(t,n){this.sl=t,this.events=n;let a=t.watchdog,s=a.beat!=null&&a.now-a.beat>180,o=a.repairs.filter(d=>a.now-d.ts<86400),r=o[o.length-1],l=Ee(a.enabled,"Watchdog repairs",async d=>{await U(()=>z.settingsUpdate({watchdog:d?"1":"0"}),d?"Watchdog on":"Watchdog off")||l.classList.toggle("on",!d);let u=await z.serviceLog().catch(()=>null);u&&this.paintLive(u,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"}`},v("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":""}`:""}`},[v(d.ok?"check":"x"),d.name]))),e("span",{class:`dl-sub${s?" dl-warn-text":""}`},s?`The agent has not checked in for ${Math.round((a.now-a.beat)/60)} min; cron restarts it after 5.`:[a.last?`Looked ${ue(a.last,a.now)}`:"Starts within a minute"," · ",o.length?`${o.length} repair${o.length>1?"s":""} today, last ${r.name} at ${Ne(r.ts)}`:"no repairs today"])])])),this.paintRecent()}paintRecent(){let t=Date.now()/1e3-604800,n=[...this.events.map(s=>({ts:s.ts,ev:s})),...this.sl.log.map(s=>({ts:s.ts,sys:s}))].filter(s=>s.ts>=t&&Ut(s)).sort((s,o)=>o.ts-s.ts),a=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Recent problems"),e("span",{class:"dl-spacer"}),n.length?e("a",{href:"#",click:s=>(s.preventDefault(),this.toLog())},"All in Log →"):""]);if(!n.length){dom.content(this.recentEl,[a,e("div",{class:"dl-recent-empty"},[e("span",{class:"dl-check-icon ok"},v("check")),"No problems in the last 7 days."])]);return}dom.content(this.recentEl,[a,...n.slice(0,8).map(s=>{if(s.sys){let r=s.sys,l=`${r.ts}|${r.msg}`;return qt(r,this.open.has(l),()=>{this.open.delete(l)||this.open.add(l),this.paintRecent()},Ne(r.ts))}let o=Ie(this.st,s.ev);return o.lastElementChild.textContent=Ne(s.ts),o})])}},Qa=[{title:"ip-full · veth",sub:"Policy routing and the home-like link",pkgs:["ip-full","kmod-veth"],feature:"home"},{title:"OpenSSL",sub:"HTTPS for the personal portal",pkgs:["libustream-openssl","openssl-util"],feature:"https"},{title:"ACME",sub:"Let’s Encrypt certificate for the portal",pkgs:["acme","acme-acmesh-dnsapi"],feature:"acme",optional:!0}],St=class{constructor(){this.running=!1}load(){return z.updatesStatus()}render(t){return this.root=e("div",{class:"dl-root dl-upd"}),this.paint(t),poll.add(async()=>{let n=await z.updatesStatus().catch(()=>null);n&&n.job?.state==="running"?this.paint(n):n&&this.running&&(this.running=!1,this.paint(n),n.job?.component==="app"&&n.job.state==="done"&&(ui.menu?.flushCache(),setTimeout(()=>location.reload(),1500)))},3),this.root}paint(t){let n=t.job;this.running=n?.state==="running";let a=t.check?.components??{},s=t.firmware,o=a.app,r=a.amneziawg,l=a.packages,d={disabled:this.running},p=(f,_)=>e("span",{class:`dl-pill ${f}`},_),u=(f,_,O)=>e("div",{class:"dl-upd-row"},[e("span",{class:"dl-stack"},[e("span",{class:"dl-upd-name"},f),e("span",{class:"dl-sub"},_)]),O]),c=(f,_,O,G,B=[])=>e("section",{class:"dl-setsec dl-upd-sec"},[e("div",{class:"dl-upd-head"},[e("span",{class:"dl-group-ic"},v(f)),e("span",{class:"dl-stack"},[e("b",{},_),e("span",{class:"dl-sub"},O)]),G]),...B]),b=f=>f?new Date(f).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"",g=c("sunrise","Dawnline",o?.repo?`${t.version} · ${o.repo}`:t.version,o?o.update?R(`Update to ${o.latest}`,()=>this.run("app"),"positive",d):o.latest?p("ok","Up to date"):p("","No releases yet"):p("","Not checked")),w=r?.sources??{},Y=Object.keys(w).map(f=>{let _=w[f],O=r?.current===f,G=[_.version?`${_.tag} build${_.date?` · ${b(_.date)}`:""} · ${_.gen==="3.1"?"devices need AmneziaVPN with 3.1":"works with every AmneziaWG app"}`:`No build for OpenWrt ${s?.version??""}`],B=_.version?O?r?.update?R("Update",()=>this.runAwg(f,!!r.ru,_.gen),"positive",d):p("ok","Installed"):R("Switch",()=>this.runAwg(f,!!r?.ru,_.gen),"neutral",d):p("","No build");return u([_.gen?`AmneziaWG ${_.gen}`:"AmneziaWG",e("span",{class:"dl-faint"},` · ${_.label}`)],G,B)});r?.current&&w[r.current]?.version&&Y.push(u("Russian translation","LuCI pages for AmneziaWG in Russian",R(r.ru?"Remove":"Add",()=>this.runAwg(r.current,!r.ru,r.gen),"neutral",d)));let j=c("shield","AmneziaWG",r?.installed?`${r.gen?`${r.gen} · `:""}${r.installed} · changing it restarts every tunnel`:"Not installed",r?"":p("","Not checked"),Y.length?Y:[u("Builds for this router","Check for updates to see them.","")]),$=l?.pkgs??{},N=[],C=Qa.filter(f=>f.feature==="home"?t.home:t.portal);for(let f of C){let _=f.pkgs.filter(B=>$[B]?.installed),O=[...new Set(_.flatMap(B=>[...$[B]?.latest?[B]:[],...$[B]?.with??[]]))],G=t.needs?.[f.feature]??f.pkgs.filter(B=>!$[B]?.installed);if(G.length)N.push(u(f.title,f.optional?`Not installed · ${f.sub}`:e("span",{class:"dl-upd-bad"},`Missing ${G.join(", ")} · ${f.sub}`),R("Install",()=>this.runPkgs(G,f.title),"neutral",d)));else if(O.length){let B=_.find(W=>$[W]?.latest),S=B?[e("span",{class:"dl-mono"},[`${$[B].installed} → `,e("b",{},$[B].latest)])]:[],q=O.filter(W=>W!==B);q.length&&S.push(`${B?" · ":""}${q.length<=2?`${B?"with ":""}${q.join(", ")}`:`${B?"+":""}${q.length} related packages`}`),N.push(u(f.title,S,R("Update",()=>this.runPkgs(_.filter(W=>$[W]?.latest||$[W]?.with?.length),f.title,O),"neutral",d)))}else N.push(u(f.title,f.sub,p("ok","Up to date")))}let T=C.flatMap(f=>f.pkgs).filter(f=>$[f]?.installed),y=[...new Set(T.flatMap(f=>[...$[f].latest?[f]:[],...$[f].with??[]]))],A=c("package","System packages",l?y.length?`${y.length} update${y.length===1?"":"s"} from the OpenWrt ${s?.version?.replace(/\.\d+$/,"")??""} feeds`:"What Dawnline adds to OpenWrt is current":"What Dawnline adds to OpenWrt",l?y.length?R("Update all",()=>this.runPkgs(T.filter(f=>$[f].latest||$[f].with?.length),"all packages",y),"positive",d):"":p("","Not checked"),l?N:[]),m=n?e("details",{class:"dl-params dl-upd-job",open:this.running?"open":null},[e("summary",{},[v("chevron"),e("span",{},"Last job"),p(n.state==="done"?"ok":n.state==="failed"?"bad":"warn",n.state==="running"?n.phase||"Running":n.state==="done"?"Finished":"Failed"),e("span",{class:"dl-sub"},`${n.action==="check"?"check":n.component??""} · ${Ne(n.started)}${n.finished?` · ${n.finished-n.started} s`:""}`)]),n.error?Ae("error",n.error):"",e("pre",{class:"dl-log"},n.log.join(` +`))]):"",h=y.length+(o?.update?1:0)+(r?.update?1:0),P=[s?.version?`OpenWrt ${s.version} · ${s.target}`:"",t.check?h?`${h} update${h===1?"":"s"} ready`:"everything is current":"not checked yet",t.check?`checked ${Ne(t.check.time)}`:""].filter(Boolean).join(" · ");dom.content(this.root,[e("div",{class:"dl-pagehead"},[e("div",{class:"dl-stack"},[e("h2",{class:"dl-h1"},"Updates"),e("span",{class:"dl-faint"},P)]),R([v("refresh")," Check now"],()=>this.run("check"),"neutral",d)]),g,j,A,m])}async runAwg(t,n,a){await re(a?`Install AmneziaWG ${a}?`:"Install AmneziaWG?","Every AmneziaWG tunnel on the router restarts for a few seconds, HomeTunnel too. Devices stay configured.","Install")&&this.start(`amneziawg:${t}${n?":ru":""}`)}async runPkgs(t,n,a=t){await re(`Update ${n}?`,`${a.join(", ")} from the OpenWrt feeds. Services that use them restart for a moment.`,"Update")&&this.start(`pkgs:${t.join(",")}`)}async run(t){t!=="check"&&!await re(`Update ${t==="app"?"Dawnline":t}?`,"A backup is made first. The page reloads when it finishes.","Update")||this.start(t)}async start(t){if(await U(()=>z.updatesRun(t))){this.running=!0;let n=await z.updatesStatus().catch(()=>null);n&&this.paint(n)}}};function Kt(i){return`${i.getFullYear()}-${String(i.getMonth()+1).padStart(2,"0")}-${String(i.getDate()).padStart(2,"0")}`}function Za(i,t,n,a=30){let s=i?new Date(`${i}T12:00:00`):new Date;return t==="day"?s.setDate(s.getDate()+n):t==="week"?s.setDate(s.getDate()+7*n):t==="month"?s.setMonth(s.getMonth()+n):t==="year"?s.setFullYear(s.getFullYear()+n):s.setDate(s.getDate()+a*n),Kt(s)}var Xa={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."},Lt=class{constructor(){this.id="";this.events=[];this.mapOpen=!1;this.map=null;this.parts={};this.series=[];this.devSeries={};this.refreshSeq=0;this.refreshShown=0}async load(){this.id=new URLSearchParams(location.search).get("id")??"";let[t,n,a]=await Promise.all([z.status(30),z.events(5e3).catch(()=>({events:[]})),z.personUsage(this.id,30).catch(()=>null)]);return this.series=a?.person??[],this.devSeries=a?.devices??{},[t,n.events]}render([t,n]){this.st=t,this.events=n;let a=t.people.find(l=>l.id===this.id);if(!a)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=a;for(let l of["head","devices","traffic","places","activity","limits"])this.parts[l]=e("div",{});this.parts.devices.className="dl-person-devices";let s=e("div",{},[e("nav",{class:"dl-crumbs","aria-label":"Breadcrumb"},[e("a",{href:Ze(a.server)},t.servers.find(l=>l.id===a.server)?.name??"Servers"),e("span",{},"/"),e("a",{href:Ze(a.server)},"People"),e("span",{},"/"),e("span",{},a.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 o=new URLSearchParams(location.search),r=o.get("device")&&a.devices.find(l=>l.id===o.get("device"));return r?setTimeout(()=>De(this.p,r,()=>this.refresh(),this.st.geo),50):o.get("add")&&setTimeout(()=>Ke(this.p,()=>this.refresh()),50),poll.add(()=>this.refresh(!0),15),s}async refresh(t=!1){let n=++this.refreshSeq,[a,s,o]=await Promise.all([z.status(30).catch(()=>null),z.events(5e3).catch(()=>null),z.personUsage(this.id,30).catch(()=>null)]);if(!a||nl.id===this.id);if(!r){t||(location.href=Ze(this.p?.server));return}this.p=r,this.paint(),this.map?.update(this.mapData())}async patch(t,n){var o;let a=await U(()=>z.personUpdate(this.p.id,t),n);if(!a)return;let s=this.st.people.findIndex(r=>r.id===this.p.id);(o=a.person).rate??(o.rate=this.p.rate),s>=0&&(this.st.people[s]=a.person),this.p=a.person,this.paint()}mapData(){return{geo:this.st.geo,people:this.st.people,now:this.st.now,person:this.p.id}}mapCard(){let t=e("div",{class:"dl-panel-head pad"},[e("h3",{},"Locations"),e("span",{class:"dl-spacer"}),this.st.geo.enabled?dt("30d",n=>this.map?.setRange(n),!1):"",R("Hide",()=>{this.mapOpen=!1,this.map?.destroy(),this.map=null,this.paintPlaces()},"neutral")]);return this.st.geo.enabled?(this.map=new qe({openPerson:()=>{},openDevice:(n,a)=>{let s=this.p.devices.find(o=>o.id===a);s&&De(this.p,s,()=>this.refresh(),this.st.geo)}},"30d",280),requestAnimationFrame(()=>this.map.mount(this.mapData())),e("div",{class:"dl-panel flush"},[t,this.map.el])):e("div",{class:"dl-panel flush"},[t,e("div",{class:"dl-map-off"},["Locations are off. ",e("a",{href:L.url("admin/network/dawnline/settings")},"Turn them on in Settings"),"."])])}paint(){let t=this.p,n=this.st,a=t.online?"online now":t.last_seen?`last seen ${ue(t.last_seen,n.now)}`:"never connected",s=this.series.find(c=>c.day===Kt(new Date));dom.content(this.parts.traffic,e("div",{class:`dl-person-live${t.online?"":" solo"}`},[t.online?Rt(t.rate??[],n.now,s?[s.rx,s.tx]:[0,0]):"",Ht(this.series,`${Z(t.month[0]+t.month[1])} this month`)]));let o=t.created?`Added ${_e(Kt(new Date(t.created*1e3)))}`:"",r=[{label:"Rename",icon:v("edit"),run:()=>this.rename()},{label:t.note?"Edit note":"Add note",icon:v("file"),run:()=>this.editNote()},...t.link?[null,{label:"Invite card",icon:v("qr"),run:()=>this.invite()},{label:"New link",icon:v("key"),run:()=>this.newLink()}]:[],null,{label:t.paused?"Resume":"Pause",icon:v(t.paused?"play":"pause"),warn:!t.paused,run:()=>this.patch({paused:!t.paused},t.paused?"Resumed":"Paused")},{label:"Delete",icon:v("trash"),danger:!0,run:()=>this.remove()}];dom.content(this.parts.head,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":""}`},Re(t.name)),e("div",{class:"dl-stack"},[e("div",{class:"dl-title-row"},[e("h2",{class:"dl-h1"},t.name),Bt(t)]),e("span",{class:"dl-faint",title:o},`${t.devices.length} of ${t.device_limit} devices · ${a}`)])]),e("div",{class:"dl-pcard-actions"},[t.link?ke("link","Copy link",()=>he(t.link,"Personal link copied"),"neutral","dl-icon-only"):"",ke("more","More",c=>we(c.currentTarget,r),"neutral","dl-icon-only")])]),t.note?e("button",{type:"button",class:"dl-pnote",title:"Edit note",click:()=>this.editNote()},[v("file"),e("span",{},t.note)]):""])),this.paintDevices(),this.paintLimits(),this.paintPlaces();let l=this.events.filter(c=>c.person===t.id),d=[],p=[...l].reverse();for(let c=0;c1){let F=w.querySelector(".dl-row-main");dom.content(F,[...zt(n,b).slice(0,3),e("span",{class:"dl-muted"},`${g} times`)]),F.title=p.slice(c,c+g).map(Y=>Y.detail??"").join(` +`)}d.push(w),c+=g-1}let u=R([v("more")],()=>we(u,[{label:"Export CSV",icon:v("download"),run:()=>Le(this.st,l,"csv",t.id)},{label:"Export JSON",icon:v("download"),run:()=>Le(this.st,l,"json",t.id)},null,{label:`Clear ${t.name}'s activity`,icon:v("trash"),danger:!0,run:()=>Ce(`Clear ${t.name}'s activity`,`Removes events about ${t.name} and their devices.`,{person:t.id},()=>this.refresh())}]),"neutral",{title:"Export or clear",class:"cbi-button cbi-button-neutral dl-icon-only"});dom.content(this.parts.activity,e("div",{class:"dl-panel flush"},[e("div",{class:"dl-panel-head pad"},[e("h3",{},"Activity"),e("span",{class:"dl-sub"},l.length>10?`latest 10 of ${l.length}`:""),e("span",{class:"dl-spacer"}),u]),d.length?d:e("div",{class:"dl-row dl-muted"},"Nothing yet.")]))}deviceStatus(t){return t.disabled?e("span",{class:"dl-dstat"},"Disabled"):t.online?e("span",{class:"dl-dstat ok"},"Connected"):t.handshake?e("span",{class:"dl-dstat"},`Last seen ${ue(t.handshake,this.st.now)}`):e("span",{class:"dl-dstat warn",title:"Waiting for the first connection"},"Not set up yet")}deviceBars(t){let n=(this.devSeries[t]??[]).slice(-30),a=n.map(r=>r.rx+r.tx),s=Math.max(1,...a),o=r=>new Date(`${r}T12:00:00`).toLocaleDateString("en-GB",{day:"numeric",month:"short"});return e("div",{class:"dl-dbars"},n.map((r,l)=>{let d=e("i",{class:`${a[l]?"":"zero"}${l===n.length-1?" hi":""}`});return d.style.height=`${Math.max(8,a[l]/s*100)}%`,pe(d,()=>[e("div",{class:"dl-tip-title"},l===n.length-1?`Today · ${o(r.day)}`:o(r.day)),e("div",{},Z(a[l]))]),d}))}paintDevices(){let t=this.p,n=()=>this.refresh(),a=rt(t.devices).map(o=>{let r=()=>De(t,o,n,this.st.geo);return e("article",{class:`dl-dcard${o.online?" online":""}${o.disabled?" off":""}`},[e("div",{class:"dl-dcard-head"},[e("span",{class:"dl-dcard-ic"},v(o.kind)),e("button",{type:"button",class:"dl-dcard-title",click:r},[e("b",{},o.name),this.deviceStatus(o),o.config_stale?e("span",{class:"dl-pill warn dl-stale"},"Update config"):""]),R([v("more")],r,"neutral",{title:`${o.name}: connect, rename, keys, remove`,class:"cbi-button cbi-button-neutral dl-icon-only"})]),o.handshake?e("div",{class:"dl-dcard-trend"},[e("div",{class:"dl-stack"},[e("b",{},Z(o.month[0]+o.month[1])),e("span",{class:"dl-sub"},"this month")]),this.deviceBars(o.id)]):o.disabled?e("div",{class:"dl-sub"},`${Se[o.kind]} · created ${ue(o.created,this.st.now)} ${o.created_by==="portal"?"in the portal":"by you"}.`):e("div",{class:"dl-chips-row"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>this.showDeviceQr(o)},[v("qr"),"Show QR"]),e("button",{type:"button",class:"dl-chipbtn",click:()=>this.downloadConfig(o)},[v("download"),"Config"])])])}),s=t.devices.length>=t.device_limit;a.push(e("button",{type:"button",class:"dl-dslot add",click:()=>Ke(t,n)},[e("span",{class:"dl-dslot-ic"},v("plus")),e("span",{class:"dl-stack"},[e("b",{},"Add device"),s?e("span",{class:"dl-sub"},`Over the limit · ${t.devices.length} of ${t.device_limit}`):""])])),dom.content(this.parts.devices,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"},a)]))}paintLimits(){let t=this.p,n=e("div",{class:"dl-seg wide",role:"radiogroup","aria-label":"Access"},["internet","lan","both"].map(m=>e("button",{type:"button",role:"radio",class:t.access===m?"on":"","aria-checked":t.access===m?"true":"false",click:()=>t.access!==m&&this.patch({access:m},`Access: ${Ue[m]}`)},[v(m==="internet"?"globe":m==="lan"?"home":"shield"),m==="internet"?"Internet":m==="lan"?"Home":"Both"]))),a=ze(t.expires),s=e("input",{type:"date",class:"dl-date-hidden",value:t.expires,tabindex:"-1","aria-hidden":"true"});s.addEventListener("change",()=>s.value&&this.patch({expires:s.value},`Access until ${_e(s.value)}`));let o=(m,h,P)=>{let f=Za(t.expires&&(a??-1)>=0?t.expires:"",m,h);return this.patch({expires:f},`Access until ${_e(f)}`),P},r=[["week",1,"+1 week"],["month",1,"+1 month"],["month",3,"+3 months"],["year",1,"+1 year"]].map(([m,h,P])=>e("button",{type:"button",class:"dl-chipbtn",click:()=>o(m,h,P)},P)),l=e("span",{class:"dl-datechip"},[e("button",{type:"button",class:"dl-chipbtn",click:()=>{try{s.showPicker()}catch{s.focus()}}},[v("calendar"),t.expires?_e(t.expires):"Date"]),s]),d={pause:"pause access",notify:"keep access",remove:"remove their devices"}[t.expire_action],p=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"},[...r,l,t.expires?e("button",{type:"button",class:"dl-chipbtn",click:()=>this.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:m=>{m.preventDefault(),this.endSettings()}},"Change")])]),u=t.quota_used||t.month[0]+t.month[1],c=t.quota_limit?Math.min(100,t.quota_used/t.quota_limit*100):0,b=e("div",{class:`dl-meter${c>=100?" bad":c>=90?" warn":""}`},[e("i"),t.quota_limit?e("span",{class:"mark",title:"Alert at 90%"}):""]);b.firstChild.style.width=`${c}%`,t.quota_limit&&pe(b,()=>[e("div",{class:"dl-tip-title"},`${c.toFixed(1)}% used`),e("div",{class:"dl-muted"},`${Z(t.quota_used)} of ${Z(t.quota_limit)} · ${Z(Math.max(0,t.quota_limit-t.quota_used))} left`),e("div",{class:"dl-faint"},"Alert at 90%")]);let g=e("div",{class:"dl-seg sm"},["month","total"].map(m=>e("button",{type:"button",class:t.quota_period===m?"on":"",click:()=>t.quota_period!==m&&this.patch({quota_period:m})},m==="month"?"Monthly":"Total"))),w=[10,50,100].map(m=>e("button",{type:"button",class:`dl-chipbtn${t.quota_gb===m?" on":""}`,click:()=>this.patch({quota_gb:String(m)},`Data limit ${m} GB`)},`${m} GB`));w.push(e("button",{type:"button",class:`dl-chipbtn${t.quota_gb?"":" on"}`,click:()=>this.patch({quota_gb:""},"No data limit")},"Unlimited")),w.push(e("button",{type:"button",class:"dl-chipbtn",click:()=>{let m=prompt("Data limit in GB",t.quota_gb?String(t.quota_gb):"");m!=null&&m.trim()!==""&&Number(m)>0&&this.patch({quota_gb:m.trim()},`Data limit ${m.trim()} GB`)}},"Custom"));let F=e("div",{class:"dl-tile2"},[e("div",{class:"dl-tile2-label"},[e("span",{},"Data"),g]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-tile2-value"},[Z(u),t.quota_limit?e("span",{class:"dl-faint"},` of ${Z(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?b:"",e("div",{class:"dl-chips-row"},w),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:m=>{m.preventDefault(),this.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"},`${Z(t.total[0]+t.total[1])} in total`),e("button",{type:"button",class:"dl-linkbtn danger",click:()=>Fe("person",t.id,t.name,()=>setTimeout(()=>this.refresh(),300))},"Reset usage")])]),Y=!!t.hours,[j,$]=(t.hours||"07:00-23:00").split("-"),N=e("input",{type:"time",class:"cbi-input-text",value:j}),C=e("input",{type:"time",class:"cbi-input-text",value:$}),T=()=>this.patch({hours:`${N.value}-${C.value}`},`Allowed ${N.value}–${C.value}`);N.addEventListener("change",T),C.addEventListener("change",T);let y=e("button",{type:"button",role:"switch","aria-checked":Y?"true":"false",class:`dl-switch${Y?" on":""}`,"aria-label":"Limit hours",click:()=>this.patch({hours:Y?"":"07:00-23:00"},Y?"Any time":"Allowed 07:00–23:00")},e("i")),A=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",{},Y?`${j} – ${$} (router time)`:"Any time")]),y]),Y?e("div",{class:"dl-tile2-row"},[N,e("span",{class:"dl-faint"},"to"),C]):""]);dom.content(this.parts.limits,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"),n,e("span",{class:"dl-sub"},Xa[t.access]),t.access==="lan"&&this.st.services.length?this.servicesPicker():"",Ye(t)?this.netsPicker():"",t.access==="lan"?this.dnsPicker():""]),e("div",{class:"dl-tiles2"},[this.devTile(),this.circleTile(),p,F,A])])]))}dnsPicker(){let t=this.p,n=e("div",{class:"dl-seg sm",role:"radiogroup","aria-label":"DNS"},[["device","Device’s own DNS"],["home","Home names"]].map(([s,o])=>e("button",{type:"button",role:"radio",class:t.dns_mode===s?"on":"","aria-checked":t.dns_mode===s?"true":"false",click:()=>t.dns_mode!==s&&this.patch({dns_mode:s},s==="home"?"Home names on — devices need their configuration again":"Device DNS — devices need their configuration again")},o))),a=this.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"),n]),e("span",{class:"dl-sub"},t.dns_mode==="home"?["Names like ",e("span",{class:"dl-mono"},`nas.${this.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.")])}netsPicker(){let t=this.p,a=this.st.servers.find(o=>o.id===t.server)?.home??[];if(a.length<2)return"";let s=new Set(t.home_nets?.length?t.home_nets:a.map(o=>o.dev));return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},a.map(o=>e("button",{type:"button",class:`dl-chipbtn${s.has(o.dev)?" on":""}`,"aria-pressed":s.has(o.dev)?"true":"false",title:o.nets.join(", "),click:()=>{let r=new Set(s);if(r.delete(o.dev)||r.add(o.dev),!r.size)return ne("Keep at least one network, or choose Internet only.","warning",5e3);let l=r.size===a.length?[]:[...r];this.patch({home_nets:l},l.length?`${t.name} reaches ${l.join(", ")}`:`${t.name} reaches every home network`)}},o.dev))),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.`)])}circleTile(){let t=this.p;if(this.st.servers.find(l=>l.id===t.server)?.mesh!=="circles"||!Ye(t))return"";let a=this.st.circles.filter(l=>l.server===t.server),s=a.find(l=>l.id===t.circle),o=s?this.st.people.filter(l=>l.id!==t.id&&l.circle===s.id&&Ye(l)).map(l=>l.name):[],r=R("Change",()=>we(r,[...a.map(l=>({label:l.name,icon:bt(l),run:()=>l.id!==t.circle&&this.patch({circle:l.id},`${t.name} is in ${l.name}`)})),t.circle?{label:"No circle",icon:v("x"),run:()=>this.patch({circle:""},`${t.name} is in no circle`)}:null,{label:"New circle",icon:v("plus"),run:()=>vt(this.st,t.server,null,()=>this.refresh())}]));return e("div",{class:"dl-tile2"},[e("span",{class:"dl-tile2-label"},["Devices see each other",e("span",{class:"dl-faint dl-w400"},"circle")]),e("div",{class:"dl-tile2-row"},[e("span",{class:"dl-circle-name"},s?[bt(s),s.name]:e("span",{class:"dl-muted"},"No circle")),r]),e("span",{class:"dl-sub"},s?o.length?`${t.name}'s devices and ${o.join(", ")}'s see each other. Others don't.`:`Nobody else in ${s.name} yet: only ${t.name}'s own devices see each other.`:`Only ${t.name}'s own devices see each other.`)])}servicesPicker(){let t=new Set(this.p.services??[]);return e("div",{class:"dl-stack gap4"},[e("div",{class:"dl-chips-row"},this.st.services.map(n=>e("button",{type:"button",class:`dl-chipbtn${t.has(n.id)?" on":""}`,title:`${n.address}${n.ports.length?` · ${n.ports.join(", ")}`:""}`,click:()=>{t.has(n.id)?t.delete(n.id):t.add(n.id),this.patch({services:[...t]},t.size?"Home services updated":"Whole home network")}},n.name))),e("span",{class:"dl-sub"},t.size?"Only the selected services at home.":"Whole home network. Pick services to narrow it down.")])}devTile(){let t=this.p,n=e("div",{class:"dl-slots"});for(let o=0;o=t.device_limit,d=e("i",{class:l?"over":r?"used":""});pe(d,()=>[e("div",{class:"dl-tip-title"},r?`${r.name}${l?" · over the limit":""}`:"Free slot"),e("div",{class:"dl-muted"},r?r.online?"Connected":r.handshake?`Last seen ${ue(r.handshake,this.st.now)}`:"Not set up yet":"They can add a device here")]),n.appendChild(d)}let a=Math.max(1,t.devices.length),s=e("button",{type:"button","aria-label":"Allow fewer devices",disabled:t.device_limit<=a?"disabled":null,click:()=>this.patch({device_limit:String(t.device_limit-1)})},"−");return t.device_limit<=a&&t.devices.length>1&&pe(s,()=>[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"},[s,e("button",{type:"button","aria-label":"Allow more devices",disabled:t.device_limit>=32?"disabled":null,click:()=>this.patch({device_limit:String(t.device_limit+1)})},"+")])]),n])}paintPlaces(){let t=this.st;if(!t.geo.enabled){dom.content(this.parts.places,e("div",{class:"dl-places"},[v("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")]));return}if(this.mapOpen){(!this.map||!this.parts.places.contains(this.map.el))&&dom.content(this.parts.places,this.mapCard());return}let n=t.now-30*86400,a=t.geo.points.filter(r=>r.person===this.p.id&&r.ts>=n).sort((r,l)=>l.ts-r.ts),s=[...new Set(a.map(r=>r.city||r.country).filter(Boolean))],o=a[0];dom.content(this.parts.places,e("div",{class:"dl-places"},[v("pin"),e("div",{class:"dl-stack"},[e("span",{},o?o.city||o.country:"No locations yet"),e("span",{class:"dl-sub"},o?`${s.length} place${s.length===1?"":"s"} in 30 days${o.org?` · ${o.org}`:""}`:"Shown after a device connects")]),e("span",{class:"dl-spacer"}),a.length?R("Show map",()=>{this.mapOpen=!0,this.paintPlaces()},"neutral"):""]))}invite(){let t=this.st.servers.find(n=>n.id===this.p.server)?.name??"Home";nt(this.p,t)}showQr(){let t=this.p;t.link&&se(`${t.name}’s link`,[e("div",{class:"dl-qr-pane"},[Pe(Oe(t.link),"dl-qr"),e("div",{class:"dl-hint"},"Scan with the phone camera to open the portal.")])],[e("button",{class:"cbi-button",click:X},"Close")])}async newLink(){let t=this.p;if(!await re("Create a new link?","The old link stops working right away.","Create new link",!0))return;let n=await U(()=>z.personRegen(t.id),"New link created");n?.link&&(t.link=n.link,he(n.link,"New link copied"),this.paint())}async showDeviceQr(t){let n=await U(()=>z.deviceConfig(t.id));n&&se(`Set up ${t.name}`,[await It(n,"qr")],[e("button",{class:"cbi-button",click:X},"Close")])}async downloadConfig(t){let n=await U(()=>z.deviceConfig(t.id));if(n){if(!n.has_private_key){ne("This device made its own keys in the browser; its configuration only exists there.","warning");return}ve(n.filename,n.conf,"application/octet-stream")}}editNote(){let t=e("textarea",{class:"cbi-input-textarea dl-note-input",rows:3,maxlength:500,placeholder:"Only you see this"},this.p.note??"");se("Note",[t],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{X(),await this.patch({note:t.value.trim()},t.value.trim()?"Note saved":"Note removed")},"positive")]),setTimeout(()=>t.focus(),50)}endSettings(){let t=this.p,n=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(s=>e("option",{value:s,selected:t.expire_warn===s?"selected":null},s?`${s} day${s===1?"":"s"} before`:"Don’t warn")));se("When access ends",[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Then"),e("div",{class:"cbi-value-field"},n)]),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.")])])],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{X(),await this.patch({expire_action:n.value,expire_warn:a.value},"Saved")},"positive")])}rename(){let t=e("input",{type:"text",class:"cbi-input-text",value:this.p.name,maxlength:48});se("Rename",[e("div",{class:"cbi-value"},[e("label",{class:"cbi-value-title"},"Name"),e("div",{class:"cbi-value-field"},t)])],[e("button",{class:"cbi-button cbi-button-neutral",click:X},"Cancel")," ",R("Save",async()=>{X(),await this.patch({name:t.value},"Renamed")},"positive")]),setTimeout(()=>t.select(),50)}async remove(){let t=this.p;await re(`Delete ${t.name}?`,`All ${t.devices.length} devices are disconnected immediately and the personal link stops working.`,"Delete",!0)&&await U(()=>z.personDelete(t.id),"Deleted")&&(location.href=Ze(t.server))}};var es=[["health","Health"],["log","Log"]],Mt=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",{})}load(){return Promise.all([z.status(1),z.events(2e4),z.serviceLog(),this.tab==="health"?z.health().catch(()=>null):Promise.resolve(null)])}render([t,n,a,s]){return this.log=new yt(t,n,a.log),this.health=new _t(t,a,n.events,()=>{this.show("log"),this.log.show("problems")}),s&&this.health.take(s),this.show(this.tab),poll.add(async()=>{if(!this.bodyEl.isConnected)return;let[o,r]=await Promise.all([z.serviceLog().catch(()=>null),z.events(2e4).catch(()=>null)]);r&&this.log.take(r),o&&(this.log.system=o.log),o&&this.health.paintLive(o,r?.events??this.health.events),this.tab==="log"&&(o||r)&&this.log.paint()},10),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])}show(t){this.tab=t;let n=new URL(location.href);t==="log"?n.searchParams.set("tab","log"):n.searchParams.delete("tab"),history.replaceState(null,"",n),dom.content(this.segEl,es.map(([a,s])=>e("button",{type:"button",role:"tab",class:a===t?"on":"","aria-selected":a===t?"true":"false",click:()=>a!==this.tab&&this.show(a)},s))),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():this.health.checks||this.health.run()}};var ts=`: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}.dl-map .cbi-section,.dl-map .cbi-section-node{border:0!important;background:none!important;box-shadow:none!important;padding:0!important}.dl-map .table.cbi-section-table,.dl-map .cbi-section-table>.tbody,.dl-map .cbi-section-table>tbody{display:block!important;width:100%;border:0!important;background:none!important;box-shadow:none!important;border-radius:0!important}.dl-map .cbi-section-table-titles,.dl-map .cbi-section-table-descr,.dl-map .thead{display:none!important}.dl-map .cbi-section-table-row{display:flex!important;flex-wrap:wrap;align-items:flex-start;gap:12px 16px;margin:0 0 12px;padding:16px!important;background:var(--dl-card)!important;border:1px solid var(--dl-line)!important;border-radius:var(--dl-radius)!important;box-shadow:var(--dl-shadow)}.dl-map .cbi-section-table-row.dl-filtered{display:none!important}.dl-map .cbi-section-table-row:hover{background:var(--dl-card)!important}.dl-map .cbi-section-table-row>.td{display:block!important;border:0!important;padding:0!important;background:none!important;width:auto!important}.dl-map .cbi-section-table-row>.td:first-child{flex:1 1 26em;min-width:0}.dl-map .cbi-section-table-row>.td.cbi-section-actions{flex:0 0 auto;margin-left:auto}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div{display:flex;flex-wrap:nowrap;gap:6px;justify-content:flex-end}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div>*{margin:0!important;flex:0 0 auto}.dl-map .cbi-section-table-row>.td:before{display:none!important}.dl-map .cbi-section-table-row.placeholder{color:var(--dl-fg-muted);display:flex!important;justify-content:center;align-items:center;min-height:0!important;height:auto!important;padding:28px 16px!important;text-align:center}.dl-map .cbi-section-table-row.placeholder>*{position:static!important;padding:0!important;margin:0!important;border:0!important;flex:0 1 auto!important}.dl-map .cbi-section-table-row.dl-off .dl-card-name,.dl-map .cbi-section-table-row.dl-off .dl-avatar{opacity:.6}.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-map .cbi-section-table-row>.td.cbi-section-actions{margin-left:0;width:100%!important}.dl-map .cbi-section-table-row>.td.cbi-section-actions>div{justify-content:flex-start;flex-wrap:wrap}.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}#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-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}.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)}.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-healthstrip{display:flex;align-items:center;gap:8px 16px;flex-wrap:wrap;padding:9px 14px;margin:0 0 12px;border-radius:12px;border:1px solid color-mix(in srgb,var(--dl-warn) 45%,transparent);background:var(--dl-warn-wash);font-size:13px;color:var(--dl-fg-muted)}.dl-healthstrip.bad{border-color:color-mix(in srgb,var(--dl-bad) 45%,transparent);background:var(--dl-bad-wash)}.dl-healthstrip-title{display:inline-flex;align-items:center;gap:6px;font-weight:500;color:var(--dl-warn)}.dl-healthstrip.bad .dl-healthstrip-title{color:var(--dl-bad)}.dl-healthstrip-title .dl-icon{width:15px;height:15px}.dl-healthstrip-item{cursor:default}.dl-healthstrip a{margin-left:auto;font-size:12px;font-weight:500;color:var(--dl-fg);text-decoration:none;padding:3px 9px;border-radius:8px}.dl-healthstrip a:hover{background:var(--dl-soft)}.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-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}.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}.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)}.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)}.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}.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-map .cbi-section-create,.dl-map>.cbi-section>.cbi-button-add{display:none!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-map .cbi-section-table-row>.td:has(.dl-pcard){flex:1 1 100%;max-width:none!important;width:100%!important;margin:0!important}.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-map .cbi-section-table-row.dl-attn-row{border-color:color-mix(in srgb,var(--dl-warn) 35%,transparent)!important}@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}.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}.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>*+*{border-top:1px solid var(--dl-line)}.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-head{display:flex;align-items:center;gap:12px;padding:16px 20px}.dl-upd-head>.dl-stack{flex:1;min-width:0}.dl-upd-head>.dl-stack>b{font-size:15px;font-weight:500}.dl-upd-row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 20px;border-top:1px solid var(--dl-line);min-height:40px}.dl-upd-row>.dl-stack{min-width:0}.dl-upd-name{font-size:14px}.dl-upd-row .dl-mono{font-size:11px}.dl-upd-row .dl-mono b{color:var(--dl-fg);font-weight:500}.dl-upd-row>.dl-pill,.dl-upd-row>button,.dl-upd-head>.dl-pill,.dl-upd-head>button{flex:none}.dl-upd-bad{color:var(--dl-bad)}.dl-upd-job>.dl-log,.dl-upd-job>.alert-message{margin:0 14px 14px}.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)}`;function Cn(){let i=document.createElement("style");return i.dataset.dawnline="1",i.textContent=ts,i}function je(i,t){return()=>{let n=new i,a={load:()=>n.load(),render:async s=>{let o=await n.render(s),r=document.createElement("div");return r.className="dl-root",r.append(Cn(),o),r},addFooter(){return n.noFooter?document.createElement("div"):this.super("addFooter",[])}};return t||Object.assign(a,{handleSave:null,handleSaveApply:null,handleReset:null}),a}}var Xo=je(st,!1),er=je(Be,!0),tr=je(st,!1),nr=je($t,!1),ar=je(Lt,!1),sr=je(Mt,!1),ir=je(St,!1);function Dn(i){return()=>({load:()=>(ui.menu?.flushCache(),location.replace(`${L.url("admin/network/dawnline/diagnostics")}${i?`?tab=${i}`:""}`),new Promise(()=>{})),render:()=>document.createElement("div"),handleSave:null,handleSaveApply:null,handleReset:null})}var or=Dn(""),rr=Dn("log");return baseclass.extend({ activity: rr, diagnostics: sr, health: or, overview: Xo, people: er, person: ar, server: tr, settings: nr, updates: ir }); diff --git a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent index baa0eee..c6702ac 100755 --- a/package/luci-app-dawnline/root/usr/libexec/dawnline/agent +++ b/package/luci-app-dawnline/root/usr/libexec/dawnline/agent @@ -20,6 +20,7 @@ import * as ops from 'dawnline.ops'; import * as geo from 'dawnline.geo'; import * as watchdog from 'dawnline.watchdog'; import * as net from 'dawnline.net'; +import * as bonjour from 'dawnline.bonjour'; const TICK = 60 * 1000; const FLUSH_EVERY = 3600; @@ -151,6 +152,14 @@ function place_of(ip) { return pl ? join(' · ', filter([ pl.city, pl.org ], (x) => x)) : null; } +/** Connections from home: the DHCP name of the address, as it is now. */ +function named(e) { + let h = net.event_hosts(e, net.lan_names()); + if (h) + e.hosts = h; + return e; +} + function check_devices(m, lv, events) { for (let id, d in lv) { let dev = m.devices[id]; @@ -169,12 +178,12 @@ function check_devices(m, lv, events) { delete offline_ticks[id]; if (was != null && was != d.online) { if (d.online) - push(events, { type: 'connect', person: dev.person, device: id, detail: d.endpoint, where: place_of(d.endpoint) }); + push(events, named({ type: 'connect', person: dev.person, device: id, detail: d.endpoint, where: place_of(d.endpoint) })); else push(events, { type: 'disconnect', person: dev.person, device: id }); } else if (d.online && last_endpoint[id] && d.endpoint && last_endpoint[id] != d.endpoint) - push(events, { type: 'roam', person: dev.person, device: id, detail: `${last_endpoint[id]} → ${d.endpoint}` }); + push(events, named({ type: 'roam', person: dev.person, device: id, detail: `${last_endpoint[id]} → ${d.endpoint}` })); last_online[id] = d.online; if (d.endpoint) last_endpoint[id] = d.endpoint; @@ -348,6 +357,12 @@ function tick() { check_wan(m); } catch (e) {} + try { + bonjour.sync(m); + } + catch (e) { + slog('dawnline', 'error', `failed: ${e.message}`, null, 'Find home devices'); + } nightly_backup(); try { check_geo(m); diff --git a/package/luci-app-dawnline/root/usr/libexec/dawnline/updater b/package/luci-app-dawnline/root/usr/libexec/dawnline/updater index 5054528..a95a949 100755 --- a/package/luci-app-dawnline/root/usr/libexec/dawnline/updater +++ b/package/luci-app-dawnline/root/usr/libexec/dawnline/updater @@ -28,7 +28,7 @@ const AWG_RU = 'luci-i18n-amneziawg-ru'; // OpenWrt packages Dawnline runs on (the Updates tab groups and names them). // What Dawnline itself adds to OpenWrt (the rest of LuCI, ucode, rpcd and uhttpd is the // stock system): the home-like link, and HTTPS plus certificates for the personal portal. -const SYS_PKGS = [ 'ip-full', 'kmod-veth', 'libustream-openssl', 'openssl-util', 'acme', 'acme-acmesh-dnsapi', 'luci-app-acme' ]; +const SYS_PKGS = [ 'ip-full', 'kmod-veth', 'libustream-openssl', 'openssl-util', 'acme', 'acme-acmesh-dnsapi', 'luci-app-acme', 'umdns' ]; // Packages released together with each of the above, updated as a set so OpenSSL never ends up // half old and half new. const PKG_FAMILY = [ @@ -463,6 +463,9 @@ function install_pkgs(arg) { // The portal's HTTPS runs in uhttpd. Restart after this job saved its state. let touched = [ ...names, ...have ]; // A missing piece arrived: set up what waited for it (the portal, the home-like link). + // Bonjour: OpenWrt's mDNS daemon starts at once; the agent publishes what it finds. + if (index(missing, 'umdns') >= 0) + run('/etc/init.d/umdns enable; /etc/init.d/umdns start'); if (length(missing) && length(filter(missing, (n) => match(n, /^(openssl-util|libustream|ip-full|kmod-veth)/)))) run('( sleep 3; /usr/bin/dawnline apply; /etc/init.d/uhttpd restart; /etc/init.d/dawnline restart ) /dev/null 2>&1 &'); else if (length(filter(touched, (n) => match(n, /^(libustream|libopenssl)/)))) diff --git a/package/luci-app-dawnline/root/usr/share/rpcd/ucode/luci.dawnline b/package/luci-app-dawnline/root/usr/share/rpcd/ucode/luci.dawnline index 62d6b74..e2fae48 100644 --- a/package/luci-app-dawnline/root/usr/share/rpcd/ucode/luci.dawnline +++ b/package/luci-app-dawnline/root/usr/share/rpcd/ucode/luci.dawnline @@ -5,7 +5,7 @@ import { cursor } from 'uci'; import { readfile, stat } from 'fs'; import { q, sh, sh_out, sh_bg, ensure_dir, read_json, write_json, parse_cidr, cidr_str, cidr_overlaps, int2ip, - ip2int, valid_host, rand_int, lock, unlock, uniq, slog_clear, admin_log, VERSION, RUN_DIR, DATA_DIR + ip2int, valid_host, rand_int, rand_hex, lock, unlock, uniq, slog_clear, admin_log, VERSION, RUN_DIR, DATA_DIR } from 'dawnline.util'; import * as core from 'dawnline.core'; import * as live from 'dawnline.live'; @@ -16,6 +16,8 @@ import * as geo from 'dawnline.geo'; import * as net from 'dawnline.net'; import * as loop from 'dawnline.loop'; import * as watchdog from 'dawnline.watchdog'; +import * as access from 'dawnline.access'; +import * as bonjour from 'dawnline.bonjour'; function wrap(fn) { return function(req) { @@ -96,6 +98,18 @@ function geo_view(m, usage, dmp) { /* ---------- status ---------- */ +/** Older connections from home get the DHCP name their address has now. */ +function with_hosts(ev) { + let names = null; + for (let e in ev) + if ((e.type == 'connect' || e.type == 'roam') && !e.hosts) { + let h = net.event_hosts(e, names ??= net.lan_names()); + if (h) + e.hosts = h; + } + return ev; +} + function status(a) { let m = core.load(); let usage = core.load_usage(); @@ -117,8 +131,10 @@ function status(a) { push(servers, { 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, preset: srv.preset, mtu: srv.mtu, keepalive: srv.keepalive, dns: srv.dns, + 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, address: core.server_address(srv), up: !!st?.up, uptime: st?.uptime ?? 0, + // Home networks (interfaces) for the per-person picker. + home: map(net.server_net(srv).home, (h) => ({ dev: h.dev, nets: h.nets })), peers, online, obf: srv.obf, // Bytes per second, one point a minute: [ts, rx, tx] (rx = from devices). rate: rates[id] ?? [], @@ -169,9 +185,10 @@ function status(a) { servers, people, services: values(m.services), + circles: values(m.circles), totals, series: live.series(recs, clamp_days(a.days)), - events: slice(events, length(events) > 60 ? length(events) - 60 : 0), + events: with_hosts(slice(events, length(events) > 60 ? length(events) - 60 : 0)), like_home: loop.status(), awg: core.awg_caps(), }; @@ -406,9 +423,10 @@ function interfaces_view(srv, snap) { detected: { wan: snap.wan, lan: snap.lan }, saved: { wan: srv.detected_wan, lan: srv.detected_lan }, config: { auto_wan: srv.auto_wan, wan_device: srv.wan_device, auto_lan: srv.auto_lan, lan_devices: srv.lan_devices, lan_like: srv.lan_like, - device_mesh: srv.device_mesh }, + device_mesh: srv.device_mesh, mesh: srv.mesh }, like_home: loop.status(), needs: ops.needs().home, + bonjour: { on: srv.bonjour, needs: ops.needs().bonjour, ...bonjour.view(core.load()) }, effective: sn, zones: snap.zones, devices, @@ -455,8 +473,10 @@ function server_interfaces(a) { lans = uniq(lans); if (a.lan_like != null) c.set('dawnline', srv.id, 'lan_like', a.lan_like === false || a.lan_like === '0' ? '0' : '1'); - if (a.device_mesh != null) - c.set('dawnline', srv.id, 'device_mesh', a.device_mesh === false || a.device_mesh === '0' ? '0' : '1'); + let mesh = index(core.MESH, a.mesh) >= 0 ? a.mesh + : a.device_mesh == null ? srv.mesh : (a.device_mesh === false || a.device_mesh === '0' ? 'off' : 'all'); + c.set('dawnline', srv.id, 'mesh', mesh); + c.delete('dawnline', srv.id, 'device_mesh'); c.set('dawnline', srv.id, 'auto_wan', auto_wan ? '1' : '0'); c.set('dawnline', srv.id, 'auto_lan', auto_lan ? '1' : '0'); if (auto_wan || wan_dev == '') @@ -483,7 +503,6 @@ function server_interfaces(a) { system('chmod 600 /etc/config/dawnline'); let before = join(',', net.server_net(srv, snap).nets); // What the admin changed here: the networks, and/or whether devices reach each other. - let mesh = a.device_mesh == null ? srv.device_mesh : !(a.device_mesh === false || a.device_mesh === '0'); let sig = (x) => { let sn = net.server_net(x, snap); return `${join(',', sn.nets)}|${sn.wan.dev}|${x.lan_like}`; @@ -491,8 +510,8 @@ function server_interfaces(a) { let what = []; if (sig(core.load(c).servers[srv.id]) != sig(srv)) push(what, 'home network and internet path'); - if (mesh != srv.device_mesh) - push(what, mesh ? 'devices reach each other' : 'devices kept apart'); + if (mesh != srv.mesh) + push(what, { off: 'devices kept apart', all: 'devices reach each other', circles: 'devices reach each other in circles' }[mesh]); if (length(what)) admin_log('awg', 'changed', 'server', srv.name, join(', ', what)); apply.apply(); @@ -532,8 +551,20 @@ function server_update(a) { } if (v.enabled != null) set('enabled', v.enabled === true || v.enabled == '1' ? '1' : '0'); - if (v.device_mesh != null) - set('device_mesh', v.device_mesh === true || v.device_mesh == '1' ? '1' : '0'); + let bj = v.bonjour == null ? null : (v.bonjour === true || v.bonjour == '1'); + if (bj != null) { + if (bj && length(ops.needs().bonjour)) + die('Install umdns first.'); + set('bonjour', bj ? '1' : null); + } + if (v.device_mesh != null && v.mesh == null) + v.mesh = v.device_mesh === true || v.device_mesh == '1' ? 'all' : 'off'; + if (v.mesh != null) { + if (index(core.MESH, v.mesh) < 0) + die('Unknown choice for devices reaching each other.'); + set('mesh', v.mesh); + set('device_mesh', null); + } if (v.mtu != null) { if (str(v.mtu) != '' && (!match(str(v.mtu), /^[0-9]+$/) || +v.mtu < 1280 || +v.mtu > 1500)) die('MTU must be 1280-1500.'); @@ -566,15 +597,22 @@ function server_update(a) { push(what, label); } let on = v.enabled == null ? null : (v.enabled === true || v.enabled == '1'); - let mesh = v.device_mesh == null ? null : (v.device_mesh === true || v.device_mesh == '1'); + let mesh = v.mesh; let name = v.name != null ? str(v.name) : srv.name; let r = commit(c, true); if (on != null && on != srv.enabled) admin_log('awg', on ? 'turned on' : 'turned off', 'server', name); if (length(what)) admin_log('awg', 'changed', 'server', name, join(', ', what)); - if (mesh != null && mesh != srv.device_mesh) - admin_log('awg', 'changed', 'server', name, mesh ? 'devices reach each other' : 'devices kept apart'); + if (bj != null && bj != srv.bonjour) { + admin_log('awg', bj ? 'turned on' : 'turned off', 'server', name, 'finding home devices (Bonjour)'); + if (bj) + bonjour.start_mdns(); + bonjour.sync(core.load(), true); + } + if (mesh != null && mesh != srv.mesh) + admin_log('awg', 'changed', 'server', name, + { off: 'devices kept apart', all: 'devices reach each other', circles: 'devices reach each other in circles' }[mesh]); return r; } @@ -823,6 +861,10 @@ function person_update(a) { fields.paused = a.paused; if (type(a.services) == 'array') fields.services = a.services; + if (a.circle != null) + fields.circle = a.circle; + if (type(a.home_nets) == 'array') + fields.home_nets = a.home_nets; let before = m.people[a.id]; core.update_person(c, m, a.id, fields); c.commit('dawnline'); @@ -1038,6 +1080,99 @@ function service_set(a) { return { id }; } +/** Create or edit a circle; `members` (person ids) replaces who is in it. */ +function circle_set(a) { + let c = core.open_cursor(); + let m = core.load(c); + let ci = a.id ? m.circles[a.id] : null; + if (a.id && !ci) + die('Unknown circle.'); + let server = ci?.server ?? a.server; + if (!m.servers[server]) + die('Unknown server.'); + let name = trim(`${a.name ?? ''}`); + if (name == '' || length(name) > 32) + die('Enter a circle name (up to 32 characters).'); + for (let id, o in m.circles) + if (id != a.id && o.server == server && lc(o.name) == lc(name)) + die(`${name} already exists.`); + let id = ci?.id ?? `c_${rand_hex(4)}`; + c.set('dawnline', id, 'circle'); + c.set('dawnline', id, 'server', server); + c.set('dawnline', id, 'name', name); + c.set('dawnline', id, 'color', `${(int(a.color) || 0) % core.CIRCLE_COLORS}`); + if (type(a.members) == 'array') { + let want = {}; + for (let pid in a.members) + if (m.people[pid]?.server == server) + want[pid] = true; + for (let pid, p in m.people) + if (want[pid]) + c.set('dawnline', pid, 'circle', id); + else if (p.circle == id) + c.delete('dawnline', pid, 'circle'); + } + commit(c); + admin_log('awg', ci ? 'changed' : 'added', 'circle', name, m.servers[server].name); + return { id, circles: values(core.load().circles) }; +} + +function circle_delete(a) { + let c = core.open_cursor(); + let m = core.load(c); + let ci = m.circles[a.id]; + if (!ci) + die('Unknown circle.'); + c.delete('dawnline', a.id); + for (let pid, p in m.people) + if (p.circle == a.id) + c.delete('dawnline', pid, 'circle'); + commit(c); + admin_log('awg', 'removed', 'circle', ci.name, m.servers[ci.server]?.name); + return { circles: values(core.load().circles) }; +} + +/** + * Devices at home for the Home services picker: DHCP leases and static hosts + * in the server's home networks, with the services they announce (Bonjour, + * when umdns runs). + */ +function home_hosts(a) { + let m = core.load(); + let srv = m.servers[a.id] ?? values(m.servers)[0]; + if (!srv) + die('No server yet.'); + let nets = net.server_net(srv).nets; + let inside = (ip) => { + let n = ip2int(ip); + for (let cidr in nets) { + let x = match(cidr, /^([0-9.]+)\/([0-9]+)$/); + let size = 1 << (32 - +x[2]), base = ip2int(x[1]); + if (n != null && n >= base && n < base + size) + return true; + } + return false; + }; + let hosts = {}; + for (let line in split(readfile('/tmp/dhcp.leases') ?? '', '\n')) { + let f = split(line, ' '); + if (length(f) >= 4 && inside(f[2])) + hosts[f[2]] = { address: f[2], name: f[3] == '*' ? '' : f[3], mac: f[1], services: [] }; + } + let c = cursor(); + c.foreach('dhcp', 'host', (h) => { + if (h.ip && inside(h.ip)) + hosts[h.ip] ??= { address: h.ip, name: h.name ?? '', mac: type(h.mac) == 'array' ? h.mac[0] : h.mac ?? '', services: [] }; + }); + for (let s in ops.mdns_services()) + if (hosts[s.address]) + push(hosts[s.address].services, { type: s.type, name: s.name, port: s.port }); + else if (inside(s.address)) + hosts[s.address] = { address: s.address, name: s.host ?? '', mac: '', services: [ { type: s.type, name: s.name, port: s.port } ] }; + let out = values(hosts); + return { hosts: sort(out, (x, y) => ip2int(x.address) - ip2int(y.address)), mdns: ops.mdns_running() }; +} + function service_delete(a) { let c = core.open_cursor(); if (c.get('dawnline', a.id) != 'service') @@ -1060,7 +1195,7 @@ function events_list(a) { // Tunnel down/up events of older versions: the service log tells it better (names, reasons). let ev = filter(live.load_events(), (e) => e.type != 'server_down' && e.type != 'server_up'); let n = +a.limit || 300; - return { events: slice(ev, length(ev) > n ? length(ev) - n : 0), total: length(ev), policy: live.policy() }; + return { events: with_hosts(slice(ev, length(ev) > n ? length(ev) - n : 0)), total: length(ev), policy: live.policy() }; } /** Remove activity by person, device, category and/or age; nothing given clears it all. */ @@ -1206,13 +1341,17 @@ const methods = { updates_run: { args: { what: '' }, call: wrap(updates_run) }, person_update: { args: { id: '', name: '', access: '', device_limit: '', expires: '', expire_action: '', expire_warn: '', quota_gb: '', - quota_period: '', bonus_gb: '', hours: '', note: '', dns_mode: '', paused: false, services: [] }, + quota_period: '', bonus_gb: '', hours: '', note: '', dns_mode: '', paused: false, services: [], circle: '', home_nets: [] }, call: wrap(person_update), }, settings_get: { call: wrap(settings_get) }, settings_update: { args: { values: {} }, call: wrap(settings_update) }, service_set: { args: { id: '', name: '', address: '', ports: [] }, call: wrap(service_set) }, service_delete: { args: { id: '' }, call: wrap(service_delete) }, + circle_set: { args: { id: '', server: '', name: '', color: 0, members: [] }, call: wrap(circle_set) }, + circle_delete: { args: { id: '' }, call: wrap(circle_delete) }, + access_check: { args: { from: '', to: '' }, call: wrap((a) => access.check(core.load(), a.from, a.to)) }, + home_hosts: { args: { id: '' }, call: wrap(home_hosts) }, geo_clear: { call: wrap((a) => { geo.clear(); return { ok: true }; }) }, events: { args: { limit: 300 }, call: wrap(events_list) }, logs_clear: { args: { person: '', device: '', category: '', older_days: '' }, call: wrap(logs_clear) }, 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 new file mode 100644 index 0000000..e1c2ff1 --- /dev/null +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/access.uc @@ -0,0 +1,252 @@ +// Dawnline: "Check access" — walks the same rules the nft table and the +// client configuration apply, and says in words where a connection stops. + +'use strict'; + +import { ip2int } from 'dawnline.util'; +import * as core from 'dawnline.core'; +import * as net from 'dawnline.net'; +import * as live from 'dawnline.live'; +import * as view from 'dawnline.view'; + +const STATE_TEXT = { + no_server: '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', +}; + +const ACCESS_TEXT = { lan: 'Home only', internet: 'Internet only', both: 'Home and Internet' }; + +function step(ok, title, detail) { + return { ok: !!ok, title, detail: detail ?? '' }; +} + +/** Add the step where it stops and end the walk. */ +function stop(steps, s) { + push(steps, s); + return steps; +} + +/** The first of `nets` (IPv4 CIDRs, any prefix) that holds `ip`. */ +function in_any(ip, nets) { + let n = ip2int(ip); + if (n == null) + return null; + for (let c in nets) { + let mm = match(c, /^([0-9.]+)\/([0-9]+)$/); + let base = mm ? ip2int(mm[1]) : null; + if (base == null) + continue; + let size = 1 << (32 - +mm[2]); + if (+mm[2] == 0 || (n >= base - base % size && n < base - base % size + size)) + return c; + } + return null; +} + +/** "10.0.1.20:445" → [ip, port]; a device id → its address. */ +function parse_target(m, s) { + s = trim(`${s ?? ''}`); + if (m.devices[s]) + return { dev: m.devices[s], ip: m.devices[s].address, port: null }; + let mm = match(s, /^([0-9.]+)(:([0-9]{1,5}))?$/); + if (!mm || ip2int(mm[1]) == null) + return null; + let ip = mm[1]; + for (let id, d in m.devices) + if (d.address == ip) + return { dev: d, ip, port: mm[3] ? +mm[3] : null }; + return { ip, port: mm[3] ? +mm[3] : null }; +} + +function home_access(p) { + return p.access == 'both' || (p.access == 'lan' && !length(p.services)); +} + +function peer_of(dmp, d) { + return dmp.peers[d.public_key]; +} + +/** The home network (interface) of a server that holds an address. */ +function home_dev_of(srv, ip, snap) { + for (let h in net.server_net(srv, snap).home) + if (in_any(ip, h.nets)) + return h.dev; + return null; +} + +function router_addrs(snap) { + let out = []; + for (let dev, d in snap.devices) + for (let a in d.addrs ?? []) + push(out, split(a, '/')[0]); + return out; +} + +function person_ok(m, p, d, states) { + let st = states[p.id] ?? 'active'; + if (d.disabled) + return step(false, `${d.name} is turned off`, 'Turn the device on again on its page.'); + if (st != 'active') + return step(false, `${p.name} can't connect: ${STATE_TEXT[st] ?? st}`, ''); + return step(true, `${p.name} is active`, ACCESS_TEXT[p.access]); +} + +function connected(dmp, d, who) { + let peer = peer_of(dmp, d); + if (!peer || !(peer.handshake > 0)) + return step(false, `${who} has never connected`, 'There is no session the router could reach.'); + if (time() - peer.handshake >= live.ONLINE_WINDOW) + return step(false, `${who} isn't connected right now`, 'The router reaches it only while its VPN is on.'); + return step(true, `${who} is connected`, ''); +} + +/** A device → somewhere: the router, home, another device or the internet. */ +function from_device(m, d, t, states, dmp, snap) { + let p = m.people[d.person]; + let srv = p ? m.servers[p.server] : null; + if (!p || !srv) + return [ step(false, `${d.name} has no server`, '') ]; + let steps = [ person_ok(m, p, d, states) ]; + if (!steps[0].ok) + return steps; + let allowed = core.allowed_ips(m, srv, p); + let via = (ip) => { + let hit = in_any(ip, allowed); + return hit + ? step(true, 'Its configuration sends it through the tunnel', `AllowedIPs ${join(', ', filter(allowed, (x) => index(x, ':') < 0))}`) + : step(false, "Its configuration doesn't send it through the tunnel", `AllowedIPs ${join(', ', allowed)}: the device's own network handles it.`); + }; + + // Another device. + if (t.dev) { + let q = m.people[t.dev.person]; + let who = `${q?.name ?? '?'} · ${t.dev.name}`; + if (t.dev.id == d.id) + return [ step(false, 'That is the same device', '') ]; + if (!q || q.server != p.server) + return stop(steps, step(false, `${who} is on another server`, 'Devices of different servers never reach each other.')); + if (!home_access(p)) + return stop(steps, step(false, `${p.name} has ${ACCESS_TEXT[p.access]}`, 'Only people with home access reach other devices.')); + if (!home_access(q)) + return stop(steps, step(false, `${q.name} has ${ACCESS_TEXT[q.access]}`, 'Only devices of people with home access can be reached.')); + if (srv.mesh == 'off') + return stop(steps, step(false, `"Devices reach each other" is off on ${srv.name}`, 'Server → Access → Home network.')); + if (srv.mesh == 'circles' && q.id != p.id) { + let a = core.person_circle(m, p), b = core.person_circle(m, q); + if (!a || !b || a.id != b.id) + return stop(steps, step(false, `${p.name} and ${q.name} are not in one circle`, + `${p.name}: ${a?.name ?? 'no circle'} · ${q.name}: ${b?.name ?? 'no circle'}`)); + push(steps, step(true, `Both are in ${a.name}`, 'Devices in one circle reach each other.')); + } + else + push(steps, step(true, q.id == p.id ? `Both are ${p.name}'s devices` : 'Devices reach each other on this server', '')); + let st = states[q.id] ?? 'active'; + if (st != 'active' || t.dev.disabled) + return stop(steps, step(false, `${who} can't be reached: ${t.dev.disabled ? 'it is turned off' : STATE_TEXT[st] ?? st}`, '')); + push(steps, via(t.ip)); + push(steps, connected(dmp, t.dev, who)); + return steps; + } + + // The router itself. + if (index(router_addrs(snap), t.ip) >= 0) { + if (home_access(p)) + push(steps, step(true, `${t.ip} is this router`, 'Home access includes the router.')); + else if (t.port == 53) + push(steps, step(true, `${t.ip} is this router: DNS is open to everyone`, '')); + else + return stop(steps, step(false, `${t.ip} is this router`, `${p.name} has ${ACCESS_TEXT[p.access]}: only DNS on the router.`)); + push(steps, via(t.ip)); + return steps; + } + + // Home. + let sn = net.server_net(srv, snap); + let hdev = home_dev_of(srv, t.ip, snap); + if (hdev) { + if (p.access == 'internet') + return stop(steps, step(false, `${t.ip} is at home (${hdev})`, `${p.name} has Internet only.`)); + if (p.access == 'lan' && length(p.services)) { + let hit = null; + for (let sid in p.services) { + let s = m.services[sid]; + if (s?.address == t.ip && (!length(s.ports) || t.port == null || index(s.ports, `${t.port}`) >= 0)) + hit = s; + } + let names = join(', ', map(filter(map(p.services, (x) => m.services[x]), (x) => x), (x) => x.name)); + if (!hit) + return stop(steps, step(false, `${t.ip}${t.port ? `:${t.port}` : ''} is not one of ${p.name}'s home services`, `Allowed: ${names}`)); + push(steps, step(true, `${t.ip} is ${hit.name}, one of ${p.name}'s home services`, + length(hit.ports) ? `Ports ${join(', ', hit.ports)}` : 'All ports')); + } + else { + let h = core.person_home(srv, p, snap); + if (!in_any(t.ip, h.nets)) + return stop(steps, step(false, `${t.ip} is in ${hdev}, which ${p.name} doesn't reach`, `${p.name} reaches ${join(', ', h.devs) || 'no home network'}.`)); + push(steps, step(true, `${t.ip} is in ${hdev}`, h.all ? 'Home access reaches every home network.' : `One of the networks ${p.name} reaches.`)); + } + push(steps, via(t.ip)); + push(steps, step(true, 'The firewall lets it through', `${srv.ifname} → ${join(', ', sn.zones) || 'home'}`)); + return steps; + } + + // Another private address, or the internet. + if (in_any(t.ip, [ '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '100.64.0.0/10', '169.254.0.0/16' ])) + return stop(steps, step(false, `${t.ip} isn't in ${srv.name}'s home network`, 'Private addresses outside the home network are blocked.')); + if (p.access == 'lan') + return stop(steps, step(true, `${t.ip} is on the internet`, `${p.name} has Home only: their device's own internet reaches it, not the tunnel.`)); + push(steps, via(t.ip)); + push(steps, step(true, `${t.ip} is on the internet`, srv.lan_like ? 'It leaves like a home device would.' : `It leaves through ${sn.wan.dev ?? 'the WAN'}.`)); + return steps; +} + +/** A home address → a device. */ +function to_device(m, ip, d, states, dmp, snap) { + let p = m.people[d.person]; + let srv = p ? m.servers[p.server] : null; + if (!p || !srv) + return [ step(false, `${d.name} has no server`, '') ]; + let who = `${p.name} · ${d.name}`; + let hdev = home_dev_of(srv, ip, snap); + if (!hdev) + return [ step(false, `${ip} isn't in ${srv.name}'s home network`, 'Only home devices reach people\'s devices.') ]; + let steps = [ step(true, `${ip} is at home (${hdev})`, '') ]; + if (!home_access(p)) + return stop(steps, step(false, `${p.name} has ${p.access == 'lan' ? 'only some home services' : ACCESS_TEXT[p.access]}`, + 'Home devices reach only people with home access.')); + let h = core.person_home(srv, p, snap); + if (!in_any(ip, h.nets)) + return stop(steps, step(false, `${p.name} doesn't reach ${hdev}`, 'Networks a person does not reach cannot reach them either.')); + push(steps, person_ok(m, p, d, states)); + if (!steps[length(steps) - 1].ok) + return steps; + push(steps, step(true, 'The firewall lets it through', `${join(', ', net.server_net(srv, snap).zones) || 'home'} → ${srv.ifname}`)); + push(steps, connected(dmp, d, who)); + return steps; +} + +/** `from` and `to`: a device id, or an IPv4 address (optionally :port). */ +export function check(m, from, to) { + let a = parse_target(m, from), b = parse_target(m, to); + if (!a) + die(`"${from}" is not a device or an IPv4 address.`); + if (!b) + die(`"${to}" is not a device or an IPv4 address.`); + let usage = core.load_usage(); + let states = view.states(m, usage); + let dmp = live.dump(); + let snap = net.snapshot(true); + let steps; + if (a.dev) + steps = from_device(m, a.dev, b, states, dmp, snap); + else if (b.dev) + steps = to_device(m, a.ip, b.dev, states, dmp, snap); + else + die('Choose a device on at least one side.'); + let ok = length(filter(steps, (s) => !s.ok)) == 0; + return { ok, steps }; +}; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc index 2b2b376..74aa8c9 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/apply.uc @@ -269,7 +269,12 @@ const PRIVATE4 = [ '10.0.0.0/8', '172.16.0.0/12', '192.168.0.0/16', '100.64.0.0/ /** Per-person runtime membership: which tunnel addresses may reach what. */ export function access_sets(m, usage, states) { - let sets = { lan_ok: [], inet_ok: [], svc_ok: [], dns_real: [] }; + // lan_ok: home access (the router itself, the mesh); lan_all: every home + // network; lan_part: device . network for people limited to some networks; + // mesh_pairs: device . device within a circle (or one person's own devices). + let sets = { lan_ok: [], lan_all: [], lan_part: [], mesh_pairs: [], inet_ok: [], svc_ok: [], dns_real: [] }; + let snap = net.snapshot(); + let homes = {}, groups = {}; for (let id, d in m.devices) { let p = m.people[d.person]; if (!p || d.disabled || !d.address || states[p.id] != 'active') @@ -280,8 +285,21 @@ export function access_sets(m, usage, states) { push(sets.dns_real, d.address); if (p.access == 'internet' || p.access == 'both') push(sets.inet_ok, d.address); - if (p.access == 'both' || (p.access == 'lan' && !length(p.services))) + if (p.access == 'both' || (p.access == 'lan' && !length(p.services))) { push(sets.lan_ok, d.address); + let srv = m.servers[p.server]; + let h = homes[p.id] ??= srv ? core.person_home(srv, p, snap) : { all: true, nets: [] }; + if (h.all) + push(sets.lan_all, d.address); + else + for (let n in h.nets) + push(sets.lan_part, `${d.address} . ${n}`); + // Who this device may reach directly: its circle, or at least its owner's devices. + if (srv?.mesh == 'circles') { + let ci = core.person_circle(m, p); + push(groups[ci ? `c:${ci.id}` : `p:${p.id}`] ??= [], d.address); + } + } else if (p.access == 'lan') for (let sid in p.services) { let s = m.services[sid]; @@ -292,6 +310,11 @@ export function access_sets(m, usage, states) { push(sets.svc_ok, `${d.address} . ${s.address} . ${port}`); } } + for (let g, addrs in groups) + for (let a in addrs) + for (let b in addrs) + if (a != b) + push(sets.mesh_pairs, `${a} . ${b}`); return sets; }; @@ -314,6 +337,9 @@ function nft_table(m, sets) { push(t, 'table inet dawnline {'); push(t, ` set lan_nets { type ipv4_addr; flags interval; auto-merge; ${set_elems(lan)} }`); push(t, ` set lan_ok { type ipv4_addr; ${set_elems(sets.lan_ok)} }`); + push(t, ` set lan_all { type ipv4_addr; ${set_elems(sets.lan_all)} }`); + push(t, ` set lan_part { type ipv4_addr . ipv4_addr; flags interval; ${set_elems(sets.lan_part)} }`); + push(t, ` set mesh_pairs { type ipv4_addr . ipv4_addr; ${set_elems(sets.mesh_pairs)} }`); push(t, ` set inet_ok { type ipv4_addr; ${set_elems(sets.inet_ok)} }`); push(t, ` set svc_ok { type ipv4_addr . ipv4_addr . inet_service; ${set_elems(sets.svc_ok)} }`); push(t, ` set dns_real { type ipv4_addr; ${set_elems(sets.dns_real)} }`); @@ -333,13 +359,16 @@ function nft_table(m, sets) { if (dns_addr) // DNS through the netns (it forwards to the LAN's DNS), for everyone. push(t, ` ip daddr ${dns_addr} meta l4proto { tcp, udp } th dport 53 accept`); - push(t, ' ip daddr @lan_nets ip saddr @lan_ok accept'); + push(t, ' ip daddr @lan_nets ip saddr @lan_all accept'); + push(t, ' ip saddr . ip daddr @lan_part accept'); // Devices with home access are part of home: they reach each other, where the - // server allows it. Within one server: the firewall has no forwarding between - // different servers' zones. + // server allows it (everyone, or within circles). Within one server: the + // firewall has no forwarding between different servers' zones. for (let id, srv in m.servers) - if (srv.private_key && srv.device_mesh) + if (srv.private_key && srv.mesh == 'all') push(t, ` iifname "${srv.ifname}" ip saddr @lan_ok ip daddr @lan_ok accept`); + else if (srv.private_key && srv.mesh == 'circles') + push(t, ` iifname "${srv.ifname}" ip saddr . ip daddr @mesh_pairs accept`); push(t, ' meta l4proto { tcp, udp } ip saddr . ip daddr . th dport @svc_ok accept'); push(t, ` ip daddr { ${join(', ', PRIVATE4)} } counter drop`); push(t, ' ip saddr @inet_ok accept'); @@ -357,7 +386,8 @@ function nft_table(m, sets) { push(t, ' chain to_device {'); push(t, ' meta nfproto ipv6 drop'); push(t, ' ct status dnat accept'); - push(t, ' ip saddr @lan_nets ip daddr @lan_ok accept'); + push(t, ' ip saddr @lan_nets ip daddr @lan_all accept'); + push(t, ' ip daddr . ip saddr @lan_part accept'); push(t, ' counter reject with icmpx admin-prohibited'); push(t, ' }'); // Devices ask the tunnel address; send each query where it belongs. @@ -400,7 +430,7 @@ export function rebuild_nft(m, sets) { /** Atomically replace set contents only. */ export function update_sets(sets) { let s = ''; - for (let name in [ 'lan_ok', 'inet_ok', 'svc_ok', 'dns_real' ]) { + for (let name in [ 'lan_ok', 'lan_all', 'lan_part', 'mesh_pairs', 'inet_ok', 'svc_ok', 'dns_real' ]) { s += `flush set inet dawnline ${name}\n`; if (length(sets[name])) s += `add element inet dawnline ${name} { ${join(', ', sets[name])} }\n`; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/bonjour.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/bonjour.uc new file mode 100644 index 0000000..7b30f93 --- /dev/null +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/bonjour.uc @@ -0,0 +1,149 @@ +// Dawnline: "Find home devices" (Bonjour over the tunnel). Multicast DNS does +// not cross WireGuard, so what umdns sees on the home networks is published +// as unicast DNS-SD records in dnsmasq: iPhone, iPad and Mac look there +// (browse domains under the home domain and the reverse zone of their own +// tunnel address) and list AirPlay, printers and shared Macs as at home. + +'use strict'; + +import { readfile, writefile, unlink, lsdir, stat } from 'fs'; +import { read_json, write_json, ensure_dir, RUN_DIR } from 'dawnline.util'; +import * as ops from 'dawnline.ops'; + +const FILE = 'dawnline-bonjour.conf'; +const STATE = `${RUN_DIR}/bonjour.json`; +/** dnsmasq restarts to read the records: at most this often when only TXT data changed. */ +const QUIET = 600; +/** Not useful from a phone, or not a service at all. */ +const SKIP = [ '_device-info._tcp', '_companion-link._tcp', '_sleep-proxy._udp', '_workstation._tcp', '_rdlink._tcp', '_hap._udp' ]; + +export function enabled(m) { + for (let id, srv in m.servers) + if (srv.bonjour && srv.private_key) + return true; + return false; +}; + +/** dnsmasq's conf-dirs (one per instance), from its generated configs. */ +function conf_dirs() { + let out = []; + for (let f in lsdir('/var/etc') ?? []) { + if (!match(f, /^dnsmasq\.conf\./)) + continue; + for (let line in split(readfile(`/var/etc/${f}`) ?? '', '\n')) { + let mm = match(line, /^conf-dir=([^,]+)/); + if (mm && index(out, mm[1]) < 0) + push(out, mm[1]); + } + } + return out; +} + +/** An instance name as dnsmasq takes it: printable ASCII, no dots or commas. */ +function instance(s) { + s = replace(s ?? '', /[\u2018\u2019]/g, "'"); + s = replace(s, /[\u201c\u201d]/g, ''); + s = replace(s, /[^\x20-\x7e]/g, ''); + s = replace(s, /[.,"\\]/g, ' '); + s = trim(replace(s, / +/g, ' ')); + return substr(s, 0, 63); +} + +function label(s) { + return substr(trim(replace(replace(s ?? '', /[^A-Za-z0-9-]+/g, '-'), /^-+|-+$/g, '')), 0, 63); +} + +/** Reverse zone of a server's tunnel network (its /24), where devices look for browse domains. */ +function reverse24(subnet) { + let mm = match(subnet ?? '', /^([0-9]+)\.([0-9]+)\.([0-9]+)\.[0-9]+\//); + return mm ? `0.${mm[3]}.${mm[2]}.${mm[1]}.in-addr.arpa` : null; +} + +/** The records, and a signature of what matters without TXT data. */ +export function records(m, services) { + let dom = m.settings.domain || 'lan'; + let lines = [], sig = []; + let zones = [ dom ]; + for (let id, srv in m.servers) + if (srv.bonjour && reverse24(srv.subnet)) + push(zones, reverse24(srv.subnet)); + for (let z in zones) + for (let b in [ 'b', 'db', 'lb' ]) + push(lines, `ptr-record=${b}._dns-sd._udp.${z},${dom}`); + let types = {}, hosts = {}; + for (let s in services) { + if (!s.port || index(SKIP, s.type) >= 0 || !match(s.type, /^_[A-Za-z0-9-]+\._(tcp|udp)$/)) + continue; + let name = instance(s.name), host = label(s.host) || label(replace(s.address, /\./g, '-')); + if (name == '') + continue; + let full = `${name}.${s.type}.${dom}`; + types[s.type] = true; + hosts[host] = s.address; + push(lines, `ptr-record=${s.type}.${dom},${full}`); + push(lines, `srv-host=${full},${host}.${dom},${s.port}`); + let txt = filter(s.txt ?? [], (t) => type(t) == 'string' && length(t) <= 255 && !match(t, /["\\\n]/)); + push(lines, length(txt) ? `txt-record=${full},${join(',', map(txt, (t) => `"${t}"`))}` : `txt-record=${full}`); + push(sig, `${full}|${host}|${s.port}`); + } + for (let t in sort(keys(types))) + push(lines, `ptr-record=_services._dns-sd._udp.${dom},${t}.${dom}`); + for (let h in sort(keys(hosts))) { + push(lines, `host-record=${h}.${dom},${hosts[h]}`); + push(sig, `${h}=${hosts[h]}`); + } + return { conf: '# Written by Dawnline: home devices for Bonjour over the tunnel.\n' + join('\n', lines) + '\n', sig: join('\n', sort(sig)) }; +}; + +function restart_dnsmasq() { + system('/etc/init.d/dnsmasq restart >/dev/null 2>&1'); +} + +/** + * Keep the records in step with what umdns sees (agent tick and apply). + * Turned off: the records go away. + */ +export function sync(m, force) { + let dirs = conf_dirs(); + if (!enabled(m) || !ops.mdns_running()) { + let removed = false; + for (let d in dirs) + if (stat(`${d}/${FILE}`)) { + unlink(`${d}/${FILE}`); + removed = true; + } + if (removed) + restart_dnsmasq(); + unlink(STATE); + return false; + } + let r = records(m, ops.mdns_services()); + let st = read_json(STATE, {}); + let now = time(); + let same = st.conf == r.conf; + let quiet = !force && st.sig == r.sig && now - (st.ts ?? 0) < QUIET; + let missing = length(filter(dirs, (d) => !stat(`${d}/${FILE}`))); + if ((same || quiet) && !missing) + return false; + for (let d in dirs) { + ensure_dir(d); + writefile(`${d}/${FILE}`, r.conf); + system(`chmod 644 ${d}/${FILE}`); + } + write_json(STATE, { conf: r.conf, sig: r.sig, ts: now }, 0o644); + restart_dnsmasq(); + return true; +}; + +/** Turning it on: umdns must run and look at the home networks. */ +export function start_mdns() { + system('/etc/init.d/umdns enable >/dev/null 2>&1; /etc/init.d/umdns start >/dev/null 2>&1'); +}; + +export function view(m) { + let s = ops.mdns_running() ? ops.mdns_services() : []; + return { + running: ops.mdns_running(), + services: length(filter(s, (x) => x.port && index(SKIP, x.type) < 0)), + }; +}; 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 1d2dc84..1b29131 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 @@ -14,6 +14,10 @@ import * as loop from 'dawnline.loop'; export const CONFIG = 'dawnline'; export const ACCESS = [ 'lan', 'internet', 'both' ]; export const KINDS = [ 'computer', 'phone', 'tablet', 'router', 'other' ]; +/** 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). */ +export const CIRCLE_COLORS = 8; export const OBF_KEYS = [ 'jc', 'jmin', 'jmax', 's1', 's2', 's3', 's4', 'h1', 'h2', 'h3', 'h4', 'i1', 'i2', 'i3', 'i4', 'i5', // AmneziaWG 3.x 'header_protection_key', 'content_padding_addition', 'rekey_after_time', 'rekey_timeout', 'reject_after_time', @@ -102,6 +106,7 @@ export function load(c) { people: {}, devices: {}, services: {}, + circles: {}, }; c.foreach(CONFIG, 'server', (r) => { @@ -128,11 +133,16 @@ export function load(c) { detected_wan: r.detected_wan ?? '', detected_lan: r.detected_lan ?? '', lan_like: bool(r.lan_like, true), - // Devices of people with home access reach each other through the tunnel. - device_mesh: bool(r.device_mesh, true), + // Devices of people with home access reach each other: off, all, or within circles. + // (Older configs: device_mesh 0/1.) + mesh: index(MESH, r.mesh) >= 0 ? r.mesh : (bool(r.device_mesh, true) ? 'all' : 'off'), enabled: bool(r.enabled, true), + // Home devices found over Bonjour are published as DNS-SD records (needs umdns). + bonjour: bool(r.bonjour, false), obf: {}, }; + // A person's own devices reach each other whenever the mesh is not off. + srv.device_mesh = srv.mesh != 'off'; for (let k in OBF_KEYS) if (r[k] != null && r[k] != '') srv.obf[k] = `${r[k]}`; @@ -160,6 +170,9 @@ export function load(c) { bonus_gb: num(r.bonus_gb, 0), bonus_month: r.bonus_month ?? '', services: list(r.service), + // Home networks (interfaces) this person reaches; empty = all of the server's. + home_nets: list(r.home_net), + circle: r.circle ?? '', note: r.note ?? '', created: toint(r.created, 0), devices: [], @@ -186,6 +199,11 @@ export function load(c) { push(m.people[d.person].devices, id); }); + c.foreach(CONFIG, 'circle', (r) => { + let id = r['.name']; + m.circles[id] = { id, server: r.server ?? '', name: r.name ?? id, color: toint(r.color, 0) % CIRCLE_COLORS }; + }); + c.foreach(CONFIG, 'service', (r) => { let id = r['.name']; m.services[id] = { @@ -460,9 +478,33 @@ export function client_dns(m, srv, p) { return out; }; +/** + * The home networks a person reaches: all of the server's, or only the + * interfaces ticked on their page (networks added later are not included). + */ +export function person_home(srv, p, snap) { + let sn = net.server_net(srv, snap); + let pick = p?.home_nets ?? []; + if (!length(pick)) + return { all: true, nets: sn.nets, devs: map(sn.home, (h) => h.dev) }; + let nets = [], devs = []; + for (let h in sn.home) + if (index(pick, h.dev) >= 0) { + push(nets, ...h.nets); + push(devs, h.dev); + } + return { all: false, nets: net.collapse(nets), devs }; +}; + +/** The circle a person is in on their server (circles mode only), or null. */ +export function person_circle(m, p) { + let c = m.circles[p?.circle]; + return c && c.server == p.server ? c : null; +}; + export function allowed_ips(m, srv, p) { if (p.access == 'lan') { - let nets = net.server_net(srv).nets; + let nets = person_home(srv, p).nets; // With devices reaching each other, the whole tunnel network (the router's // address is in it); otherwise only the router's own address. let a = server_address(srv); @@ -750,6 +792,19 @@ export function update_person(c, m, id, a) { else c.delete(CONFIG, id, 'service'); } + if (a.circle != null) { + let ci = m.circles[a.circle]; + if (a.circle != '' && (!ci || ci.server != p.server)) + fail('Unknown circle.'); + set('circle', a.circle); + } + if (type(a.home_nets) == 'array') { + let nets = uniq(filter(map(a.home_nets, (x) => trim(`${x}`)), (x) => match(x, /^[A-Za-z0-9_.@-]{1,32}$/))); + if (length(nets)) + c.set(CONFIG, id, 'home_net', nets); + else + c.delete(CONFIG, id, 'home_net'); + } if (a.paused != null) set('paused', a.paused ? '1' : ''); }; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/net.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/net.uc index bcd3e93..509504d 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/net.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/net.uc @@ -266,3 +266,28 @@ export function wan_address(srv, snap) { let a = snap.devices[server_net(srv, snap).wan.dev]?.addrs?.[0]; return a ? split(a, '/')[0] : null; }; + +/** Names of devices at home by address: DHCP leases, then static hosts. */ +export function lan_names() { + let out = {}; + for (let line in split(readfile('/tmp/dhcp.leases') ?? '', '\n')) { + let f = split(line, ' '); + if (length(f) >= 4 && f[3] != '*') + out[f[2]] = f[3]; + } + let c = cursor(); + c.foreach('dhcp', 'host', (h) => { + if (h.ip && h.name) + out[h.ip] ??= h.name; + }); + return out; +}; + +/** Event addresses that belong to devices at home, with their names ({ ip: name }). */ +export function event_hosts(e, names) { + let out = null; + for (let ip in match(e.detail ?? '', /[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+/g) ?? []) + if (names[ip[0]]) + (out ??= {})[ip[0]] = names[ip[0]]; + return out; +}; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/ops.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/ops.uc index d45a7b5..cd2769e 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/ops.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/ops.uc @@ -34,9 +34,39 @@ export function needs() { acme: miss([ [ file_exists('/usr/lib/acme/client/acme.sh'), 'acme' ], [ file_exists('/usr/lib/acme/client/dnsapi/dns_cf.sh'), 'acme-acmesh-dnsapi' ], [ file_exists('/www/luci-static/resources/view/acme.js'), 'luci-app-acme' ] ]), home: miss([ [ file_exists('/usr/libexec/ip-full'), 'ip-full' ], [ veth, 'kmod-veth' ] ]), + bonjour: miss([ [ file_exists('/usr/sbin/umdns'), 'umdns' ] ]), }; }; +/** True while OpenWrt's mDNS daemon answers on ubus. */ +export function mdns_running() { + return index(split(sh_out('ubus list umdns 2>/dev/null') ?? '', '\n'), 'umdns') >= 0; +}; + +/** + * Services announced on the home networks (Bonjour), from umdns: + * [{ type: '_airplay._tcp', name, host, address, port, txt }]. + */ +export function mdns_services() { + if (!mdns_running()) + return []; + let r = {}; + try { + r = json(sh_out(`ubus call umdns browse '{"address":true}' 2>/dev/null`) || '{}') ?? {}; + } + catch (e) { + r = {}; + } + let out = []; + for (let t, insts in r) + for (let name, i in insts) { + let addr = type(i.ipv4) == 'array' ? i.ipv4[0] : i.ipv4; + if (addr) + push(out, { type: t, name, host: replace(i.host ?? '', /\.local\.?$/, ''), address: addr, port: i.port ?? 0, txt: i.txt ?? [] }); + } + return out; +}; + /** ACME certificates on the router and the names each covers. */ function acme_certs() { let out = []; 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 e1d49dd..f7b1b27 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 @@ -3,7 +3,7 @@ import { open, readfile, writefile, rename, mkdir, stat, unlink, popen, lsdir } from 'fs'; -export const VERSION = '0.2.0'; +export const VERSION = '0.3.0'; /** GitHub repository with Dawnline releases (updates and the installer). */ export const REPO = 'tickcount/luci-app-dawnline'; export const RUN_DIR = '/var/run/dawnline'; diff --git a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc index 16bdf5d..756c705 100644 --- a/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc +++ b/package/luci-app-dawnline/root/usr/share/ucode/dawnline/view.uc @@ -90,6 +90,8 @@ export function person_view(m, p, usage, dmp, states, opts) { v.links = core.portal_urls(m, p); v.note = p.note; v.services = p.services; + v.home_nets = p.home_nets; + v.circle = p.circle; v.created = p.created; } return v; diff --git a/web/package-lock.json b/web/package-lock.json index f14a340..11076c7 100644 --- a/web/package-lock.json +++ b/web/package-lock.json @@ -1,12 +1,12 @@ { "name": "dawnline-web", - "version": "0.2.0", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "dawnline-web", - "version": "0.2.0", + "version": "0.3.0", "license": "MIT", "dependencies": { "qrcode-generator": "1.4.4" diff --git a/web/package.json b/web/package.json index fb31fec..e002fd5 100644 --- a/web/package.json +++ b/web/package.json @@ -1,6 +1,6 @@ { "name": "dawnline-web", - "version": "0.2.0", + "version": "0.3.0", "private": true, "license": "MIT", "type": "module", diff --git a/web/src/admin/access.ts b/web/src/admin/access.ts new file mode 100644 index 0000000..cfd048a --- /dev/null +++ b/web/src/admin/access.ts @@ -0,0 +1,441 @@ +// Server → Access pieces: home services (picked from devices at home), circles, +// "Who reaches what" and "Check access". + +import type { Circle, Person, Server, Status } from '../shared/types'; +import { E } from './e'; +import { api, type HomeHost } from './api'; +import { attempt, button, closeModal, confirmDialog, modal } from './ui'; +import { input } from './kit'; +import { icon } from '../shared/icons'; + +type Service = Status['services'][number]; + +/** Circle colours; the circle stores an index. */ +export const CIRCLE_COLORS = ['#3a83f7', '#a78bfa', '#f472b6', '#f59e0b', '#10b981', '#22d3ee', '#ef4444', '#84cc16']; + +export const circleDot = (c: Circle | undefined) => + E('i', { class: 'dl-circle-dot', style: `background:${CIRCLE_COLORS[c?.color ?? 0] ?? CIRCLE_COLORS[0]}` }); + +/** People whose devices can be reached at home (the mesh and home devices). */ +export const homeAccess = (p: Person) => p.access === 'both' || (p.access === 'lan' && !p.services?.length); + +/* ---------- Home services ---------- */ + +export function serviceDialog(sv: Service | null, prefill: Partial, onSaved: () => void) { + const name = input(sv?.name ?? prefill.name ?? '', { placeholder: 'NAS' }); + const addr = input(sv?.address ?? prefill.address ?? '', { placeholder: '192.168.1.10', class: 'cbi-input-text dl-mono' }); + const ports = input((sv?.ports ?? prefill.ports ?? []).join(', '), { + placeholder: 'All ports, or e.g. 445, 5000', + class: 'cbi-input-text dl-mono', + }); + const field = (label: string, el: Node) => + E('div', { class: 'cbi-value' }, [E('label', { class: 'cbi-value-title' }, label), E('div', { class: 'cbi-value-field' }, el)]); + modal( + sv ? `Edit ${sv.name}` : 'Add service', + [field('Name', name), field('Address', addr), field('Ports', ports)], + [ + E('button', { class: 'cbi-button cbi-button-neutral', click: closeModal }, 'Cancel'), + ' ', + button( + 'Save', + async () => { + const list = ports.value.split(/[ ,]+/).filter(Boolean); + if (await attempt(() => api.serviceSet(sv?.id ?? '', name.value, addr.value, list), 'Saved')) { + closeModal(); + onSaved(); + } + }, + 'positive', + ), + ], + ); +} + +/** Port groups a device at home offers: what it announces over Bonjour, or the usual ones. */ +const MDNS_LABEL: Record = { + _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', +}; +const DEFAULT_PORTS: [string, string[]][] = [ + ['Web', ['80', '443']], + ['SMB', ['445']], + ['SSH', ['22']], +]; + +function portGroups(h: HomeHost): [string, string[]][] { + const by = new Map>(); + for (const s of h.services) { + const label = MDNS_LABEL[s.type.split('.')[0]]; + if (!label || !s.port) continue; + (by.get(label) ?? by.set(label, new Set()).get(label)!).add(String(s.port)); + } + return by.size ? [...by].map(([l, p]) => [l, [...p].sort((a, b) => +a - +b)]) : DEFAULT_PORTS; +} + +/** Services shared by all servers, and the devices at home to add them from. */ +export function homeServices(st: Status, serverId: string, reload: () => void): HTMLElement { + const services = st.services; + const picker = E('div', { class: 'dl-stack gap8' }, E('span', { class: 'dl-sub' }, 'Looking for devices at home…')); + + const rows = services.length + ? services.map((sv) => + E('div', { class: 'dl-row' }, [ + icon('home'), + E('span', { class: 'dl-row-main dl-stack' }, [ + E('b', {}, sv.name), + E( + 'span', + { class: 'dl-mono dl-faint' }, + `${sv.address}${sv.ports.length ? ` · ports ${sv.ports.join(', ')}` : ' · all ports'}`, + ), + ]), + button('Edit', () => serviceDialog(sv, {}, reload)), + button( + [icon('trash')], + async () => { + if ( + (await confirmDialog(`Remove ${sv.name}?`, 'People limited to this service lose access to it.', 'Remove', true)) && + (await attempt(() => api.serviceDelete(sv.id), 'Removed')) + ) + reload(); + }, + 'neutral', + { title: 'Remove', 'aria-label': `Remove ${sv.name}` }, + ), + ]), + ) + : [E('div', { class: 'dl-row dl-muted' }, 'No services yet: pick ports of a device below.')]; + + /** Ports chosen for a device: add, change or remove its service at once. */ + async function choose(h: HomeHost, ports: string[] | null) { + const sv = services.find((s) => s.address === h.address); + const ok = + ports === null + ? sv && (await attempt(() => api.serviceDelete(sv.id), `${sv.name} removed`)) + : await attempt( + () => api.serviceSet(sv?.id ?? '', sv?.name ?? (h.name || h.address), h.address, ports), + sv ? `${sv.name} updated` : `${h.name || h.address} added`, + ); + if (ok) reload(); + } + + function hostRow(h: HomeHost): HTMLElement { + const sv = services.find((s) => s.address === h.address); + const all = !!sv && !sv.ports.length; + const chosen = new Set(sv?.ports ?? []); + const chip = (label: string, on: boolean, click: () => void) => + E('button', { type: 'button', class: `dl-chipbtn${on ? ' on' : ''}`, 'aria-pressed': on ? 'true' : 'false', click }, label); + return E('div', { class: 'dl-row' }, [ + icon(h.services.some((s) => s.type.startsWith('_ipp') || s.type.startsWith('_printer')) ? 'file' : 'computer'), + E('span', { class: 'dl-row-main dl-stack' }, [E('b', {}, h.name || h.address), E('span', { class: 'dl-mono dl-faint' }, h.address)]), + E('div', { class: 'dl-chips-row dl-host-ports' }, [ + chip('All ports', all, () => choose(h, all ? null : [])), + ...portGroups(h).map(([label, ports]) => { + const on = !all && ports.every((p) => chosen.has(p)); + return chip(`${label} ${ports.join(', ')}`, on, () => { + const next = new Set(all ? [] : chosen); + for (const p of ports) { + if (on) next.delete(p); + else next.add(p); + } + choose(h, next.size ? [...next] : null); + }); + }), + ]), + ]); + } + + api + .homeHosts(serverId) + .then((r) => { + const open = r.hosts.some((h) => services.some((s) => s.address === h.address)) && !services.length; + dom.content( + picker, + r.hosts.length + ? E('details', { class: 'dl-params', open: open ? '' : null }, [ + E('summary', {}, [ + icon('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(hostRow)), + ]), + ]) + : E('span', { class: 'dl-sub' }, 'No devices found in the home network right now.'), + ); + }) + .catch(() => dom.content(picker, E('span', { class: 'dl-sub' }, "Couldn't read the devices at home."))); + + return E('div', { class: 'dl-stack gap8' }, [ + E('div', { class: 'dl-iflead' }, [ + E('div', { class: 'dl-iflead-row' }, [ + E('b', {}, 'Home services'), + button([icon('plus'), ' Add service'], () => serviceDialog(null, {}, reload)), + ]), + 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.', + ), + ]), + E('div', { class: 'dl-list' }, rows), + picker, + ]); +} + +/* ---------- Circles ---------- */ + +export function circleDialog(st: Status, serverId: string, ci: Circle | null, onDone: () => void) { + const used = new Set(st.circles.filter((c) => c.server === serverId).map((c) => c.color)); + let color = ci?.color ?? CIRCLE_COLORS.findIndex((_, i) => !used.has(i)); + if (color < 0) color = 0; + const name = input(ci?.name ?? '', { placeholder: 'Family' }); + const people = st.people.filter((p) => p.server === serverId).sort((a, b) => a.name.localeCompare(b.name)); + const members = new Set(people.filter((p) => ci && p.circle === ci.id).map((p) => p.id)); + + const swatches = E('div', { class: 'dl-swatches', role: 'radiogroup', 'aria-label': 'Colour' }); + const paintSwatches = () => + dom.content( + swatches, + CIRCLE_COLORS.map((c, i) => + E('button', { + type: 'button', + role: 'radio', + class: `dl-swatch${i === color ? ' on' : ''}`, + style: `--sw:${c}`, + 'aria-checked': i === color ? 'true' : 'false', + 'aria-label': `Colour ${i + 1}`, + click: () => { + color = i; + paintSwatches(); + }, + }), + ), + ); + paintSwatches(); + + const chips = E( + 'div', + { class: 'dl-chips-row' }, + people.map((p) => { + const other = p.circle && p.circle !== ci?.id ? st.circles.find((c) => c.id === p.circle) : undefined; + return E( + 'button', + { + type: 'button', + class: `dl-chipbtn${members.has(p.id) ? ' on' : ''}`, + title: !homeAccess(p) + ? `${p.name} has no home access: their devices aren't reachable anyway` + : other + ? `Now in ${other.name}` + : '', + click: (ev: Event) => { + if (!members.delete(p.id)) members.add(p.id); + (ev.currentTarget as HTMLElement).classList.toggle('on', members.has(p.id)); + }, + }, + [p.name, !homeAccess(p) ? E('b', {}, 'internet') : other ? E('b', {}, other.name) : ''], + ); + }), + ); + const field = (label: string, el: Node) => + E('div', { class: 'cbi-value' }, [E('label', { class: 'cbi-value-title' }, label), E('div', { class: 'cbi-value-field' }, el)]); + + modal( + ci ? `Edit ${ci.name}` : 'New circle', + [ + field('Name', name), + field('Colour', swatches), + field('People', chips), + E('p', { class: 'dl-sub' }, 'Devices of people in one circle reach each other. A person is in one circle at a time.'), + ], + [ + ci + ? button( + 'Delete', + async () => { + if (await attempt(() => api.circleDelete(ci.id), `${ci.name} deleted`)) { + closeModal(); + onDone(); + } + }, + 'negative', + ) + : '', + E('span', { class: 'dl-spacer' }), + E('button', { class: 'cbi-button cbi-button-neutral', click: closeModal }, 'Cancel'), + ' ', + button( + 'Save', + async () => { + if (await attempt(() => api.circleSet(ci?.id ?? '', serverId, name.value, color, [...members]), 'Saved')) { + closeModal(); + onDone(); + } + }, + 'positive', + ), + ], + 'dl-circle-modal', + ); +} + +/** The server's circles as chips (click to edit) and a round "+" to add one. */ +export function circleChips(st: Status, serverId: string, onDone: () => void): HTMLElement { + const list = st.circles.filter((c) => c.server === serverId); + return E('div', { class: 'dl-chips-row dl-circles' }, [ + ...list.map((c) => { + const who = st.people.filter((p) => p.circle === c.id).map((p) => p.name); + return E( + 'button', + { type: 'button', class: 'dl-chip', title: `Edit ${c.name}`, click: () => circleDialog(st, serverId, c, onDone) }, + [circleDot(c), E('b', {}, c.name), E('span', { class: 'dl-faint' }, who.length ? who.join(', ') : 'nobody yet')], + ); + }), + E( + 'button', + { + type: 'button', + class: 'dl-chip add', + title: 'New circle', + 'aria-label': 'New circle', + click: () => circleDialog(st, serverId, null, onDone), + }, + icon('plus'), + ), + ]); +} + +/* ---------- Who reaches what ---------- */ + +export function whoReaches(st: Status, srv: Server): HTMLElement { + const people = st.people.filter((p) => p.server === srv.id); + const yes = (t = '') => E('span', { class: 'dl-yes' }, [icon('check'), t]); + const no = () => E('span', { class: 'dl-faint' }, '—'); + const home = (list: Person[]) => { + const kinds = new Set(list.map((p) => (p.access === 'lan' && p.services?.length ? 'services' : p.home_nets?.length ? 'some' : 'all'))); + if (!kinds.size) kinds.add('all'); + return yes([...kinds].map((k) => ({ all: 'all networks', some: 'their networks', services: 'services' })[k]).join(' / ')); + }; + const each = () => (srv.mesh === 'off' ? no() : srv.mesh === 'circles' ? yes('circle') : yes()); + const net = srv.lan_like ? 'like home' : 'direct'; + const row = (label: string, list: Person[], cells: Node[]) => + E('tr', {}, [ + E('td', {}, [E('b', {}, label), E('div', { class: 'dl-sub' }, `${list.length} ${list.length === 1 ? 'person' : 'people'}`)]), + ...cells.map((c) => E('td', {}, c)), + ]); + const by = (a: string) => people.filter((p) => p.access === a); + 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((t) => E('th', {}, t)), + ), + row('Internet', by('internet'), [yes(net), no(), E('span', { class: 'dl-faint' }, 'DNS'), no()]), + row('Home', by('lan'), [E('span', { class: 'dl-faint' }, 'their own'), home(by('lan')), yes(), each()]), + row('Both', by('both'), [yes(net), home(by('both')), yes(), each()]), + ]), + ), + 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.', + ), + ]), + ]); +} + +/* ---------- Check access ---------- */ + +export function checkAccess(st: Status, srv: Server): HTMLElement { + const devs = st.people + .filter((p) => p.server === srv.id) + .flatMap((p) => p.devices.map((d) => ({ id: d.id, label: `${p.name} · ${d.name}` }))) + .sort((a, b) => a.label.localeCompare(b.label)); + const ADDR = '@addr'; + /** A device, or an address typed in. */ + const end = (placeholder: string, initial: string) => { + const sel = E('select', { class: 'cbi-input-select', 'aria-label': placeholder }, [ + ...devs.map((d) => E('option', { value: d.id, selected: d.id === initial ? 'selected' : null }, d.label)), + E('option', { value: ADDR, selected: initial === ADDR ? 'selected' : null }, 'Address'), + ]) as HTMLSelectElement; + const addr = input('', { placeholder, class: 'cbi-input-text dl-mono' }); + const wrap = E('div', { class: 'dl-check-end' }, [sel, addr]); + const sync = () => (addr.hidden = sel.value !== ADDR); + sel.addEventListener('change', sync); + sync(); + return { el: wrap, value: () => (sel.value === ADDR ? addr.value.trim() : sel.value) }; + }; + const from = end('10.0.1.11', devs[0]?.id ?? ADDR); + const to = end('10.0.1.20:445', ADDR); + const out = E('div', { class: 'dl-stack gap8' }); + const run = async () => { + const r = await attempt(() => api.accessCheck(from.value(), to.value())); + if (!r) return; + const stop = r.steps.findIndex((s) => !s.ok); + dom.content(out, [ + E('div', { class: `dl-verdict ${r.ok ? 'ok' : 'bad'}` }, [ + E('b', {}, r.ok ? 'Allowed' : 'Blocked'), + E('span', { class: 'dl-sub' }, r.ok ? 'Every step lets it through' : `Stops at step ${stop + 1} of ${r.steps.length}`), + ]), + E( + 'ul', + { class: 'dl-checks' }, + r.steps.map((s) => + E('li', {}, [ + E('span', { class: `dl-check-icon ${s.ok ? 'ok' : 'error'}` }, icon(s.ok ? 'check' : 'x')), + E('div', { class: 'dl-check-body' }, [ + E('div', { class: 'dl-check-title' }, s.title), + s.detail ? E('div', { class: 'dl-check-detail' }, s.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' }, [from.el, E('span', { class: 'dl-faint' }, '→'), to.el, button('Check', run)]), + out, + ]), + ]); +} diff --git a/web/src/admin/api.ts b/web/src/admin/api.ts index fcfff72..2e60639 100644 --- a/web/src/admin/api.ts +++ b/web/src/admin/api.ts @@ -1,6 +1,6 @@ // luci.dawnline RPC bindings. The backend reports failures as { error }. -import type { AwgCaps, ClientConfig, DayUsage, HealthCheck, LogEvent, Person, Status } from '../shared/types'; +import type { AwgCaps, Circle, ClientConfig, DayUsage, HealthCheck, LogEvent, MeshMode, Person, Status } from '../shared/types'; function call(method: string, params: string[] = []) { const fn = rpc.declare({ object: 'luci.dawnline', method, params }); @@ -95,6 +95,7 @@ export interface Needs { https: string[]; acme: string[]; home: string[]; + bonjour: string[]; } export interface SettingsData { @@ -178,8 +179,18 @@ export interface InterfacesData { ifname: string; detected: { wan: string | null; lan: string | null }; saved: { wan: string; lan: string }; - config: { auto_wan: boolean; wan_device: string; auto_lan: boolean; lan_devices: string[]; lan_like: boolean; device_mesh: boolean }; + config: { + auto_wan: boolean; + wan_device: string; + auto_lan: boolean; + lan_devices: string[]; + lan_like: boolean; + device_mesh: boolean; + mesh: MeshMode; + }; like_home: LikeHome; + /** Find home devices: published from umdns as DNS-SD records. */ + bonjour: { on: boolean; needs: string[]; running: boolean; services: number }; effective: { wan: { dev: string | null; zone: string; auto: boolean; missing: boolean }; home: { dev: string; auto: boolean; nets: string[]; zone: string | null; missing: boolean }[]; @@ -193,6 +204,20 @@ export interface InterfacesData { nets_changed?: boolean; } +/** "Check access": each rule on the way, in order; it stops at the first that fails. */ +export interface AccessCheck { + ok: boolean; + steps: { ok: boolean; title: string; detail: string }[]; +} + +/** A device at home (DHCP lease or static host) and the services it announces over Bonjour. */ +export interface HomeHost { + address: string; + name: string; + mac: string; + services: { type: string; name: string; port: number }[]; +} + /** Filters for logs_clear; all empty clears the whole log. */ export interface LogFilter { person?: string; @@ -221,7 +246,7 @@ export type PersonPatch = Partial< | 'dns_mode', string > -> & { paused?: boolean; services?: string[] }; +> & { paused?: boolean; services?: string[]; circle?: string; home_nets?: string[] }; const personUpdateRaw = rpc.declare({ object: 'luci.dawnline', @@ -242,6 +267,8 @@ const personUpdateRaw = rpc.declare({ 'dns_mode', 'paused', 'services', + 'circle', + 'home_nets', ], }); @@ -260,7 +287,7 @@ async function personUpdate(id: string, patch: PersonPatch): Promise<{ person: P 'note', 'dns_mode', ] as const; - const args: unknown[] = [id, ...keys.map((k) => patch[k]), patch.paused, patch.services]; + const args: unknown[] = [id, ...keys.map((k) => patch[k]), patch.paused, patch.services, patch.circle, patch.home_nets]; const r = await personUpdateRaw(...args); if (r && typeof r.error === 'string') throw new Error(r.error); return r; @@ -324,7 +351,12 @@ export const api = { 'lan_devices', 'lan_like', 'device_mesh', + 'mesh', ]), + circleSet: call<{ id: string; circles: Circle[] }>('circle_set', ['id', 'server', 'name', 'color', 'members']), + circleDelete: call<{ circles: Circle[] }>('circle_delete', ['id']), + accessCheck: call('access_check', ['from', 'to']), + homeHosts: call<{ hosts: HomeHost[]; mdns: boolean }>('home_hosts', ['id']), usageClear: call('usage_clear', ['scope', 'id']), uninstall: call('uninstall', ['confirm']), status, diff --git a/web/src/admin/interfaces.ts b/web/src/admin/interfaces.ts index 313c062..e83e651 100644 --- a/web/src/admin/interfaces.ts +++ b/web/src/admin/interfaces.ts @@ -1,8 +1,10 @@ // Interfaces card (Server page): auto-detected WAN and LAN, plus a picker for // the interfaces that make up a server's home network. +import type { MeshMode, Server, Status } from '../shared/types'; import { E } from './e'; import { api, type IfaceCategory, type InterfacesData, type NetDevice } from './api'; +import { circleChips, homeServices } from './access'; import { attempt, button, notify } from './ui'; import { installMissing } from './pkgs'; import { attachTip } from './charts'; @@ -46,22 +48,32 @@ function sw(on: boolean, label: string, onChange: (v: boolean) => void): HTMLBut return b; } -export function interfacesCard(serverId: string, title = 'Interfaces'): HTMLElement { +/** + * Server → Access: how internet traffic leaves (Internet) and what home access + * reaches (Home network: networks, devices reaching each other, services). + * Both cards share one draft; either Save stores it. + */ +export function accessCards(srv: Server, st: Status, reload: () => void): HTMLElement { + const serverId = srv.id; const root = E( - 'section', - { class: 'dl-setsec dl-ifcard' }, - E('div', { class: 'dl-setsec-body' }, E('p', { class: 'dl-muted' }, 'Loading interfaces…')), + 'div', + { class: 'dl-stack gap16' }, + E('section', { class: 'dl-setsec' }, E('div', { class: 'dl-setsec-body' }, E('p', { class: 'dl-muted' }, 'Loading interfaces…'))), ); let d: InterfacesData; let autoWan = true, wanDev = '', autoLan = true, lanLike = true, - mesh = true; + mesh: MeshMode = 'all'; + // "Other interfaces" stays open or folded across repaints. + let otherOpen = false; + // Built once: it reads the devices at home, which should not happen on every repaint. + const services = homeServices(st, serverId, reload); let lans = new Set(); let initial = ''; - const snapshot = () => JSON.stringify([lanLike, mesh, autoWan, autoWan ? '' : wanDev, autoLan, [...lans].sort()]); + const snapshot = () => JSON.stringify([lanLike, autoWan, autoWan ? '' : wanDev, autoLan, [...lans].sort()]); const liveLan = () => d.detected.lan || d.saved.lan || ''; const currentWan = () => (autoWan ? d.detected.wan || d.saved.wan : wanDev) || ''; const byName = () => new Map(d.devices.map((x) => [x.name, x])); @@ -80,7 +92,7 @@ export function interfacesCard(serverId: string, title = 'Interfaces'): HTMLElem wanDev = r.config.wan_device || r.detected.wan || r.saved.wan || ''; autoLan = r.config.auto_lan; lanLike = r.config.lan_like; - mesh = r.config.device_mesh; + mesh = r.config.mesh ?? (r.config.device_mesh ? 'all' : 'off'); lans = new Set(r.config.lan_devices); initial = snapshot(); } @@ -95,6 +107,13 @@ export function interfacesCard(serverId: string, title = 'Interfaces'): HTMLElem if (r) take(r, reset); }; + /** Can be part of the home network (or already is). */ + function pickable(x: NetDevice): boolean { + const isAuto = autoLan && x.name === liveLan(); + const blocked = !!x.own || !!x.master || x.name === currentWan() || isAuto; + return isAuto || lans.has(x.name) || (!blocked && (x.nets.length > 0 || !!x.missing)); + } + function tile(x: NetDevice): HTMLElement { const isAuto = autoLan && x.name === liveLan(); const isWan = x.name === currentWan(); @@ -179,6 +198,35 @@ export function interfacesCard(serverId: string, title = 'Interfaces'): HTMLElem ]; } + const MESH_TEXT: Record = { + 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 setrow( + ic: string, + label: (Node | string)[] | string, + sub: (Node | string)[] | string, + ctl: Node | (Node | string)[] | '', + tone = '', + below?: Node, + ) { + return E('div', { class: below ? 'dl-setrow head' : 'dl-setrow' }, [ + E('div', { class: 'dl-lh-main' }, [ + E('span', { class: `dl-need-ic ${tone}` }, icon(ic)), + E('div', { class: 'dl-stack' }, [E('span', { class: 'dl-setrow-label' }, label), E('span', { class: 'dl-sub' }, sub), below ?? '']), + ]), + E('div', { class: 'dl-setrow-ctl' }, ctl), + ]); + } + + const hint = (live: string | null, saved: string) => { + const mono = (t: string) => E('span', { class: 'dl-mono' }, t); + if (live) return E('span', {}, [' Now: ', mono(live), ...(saved && saved !== live ? [', was ', mono(saved)] : []), '.']); + return E('span', {}, saved ? [' Not found now: using ', mono(saved), '.'] : [' Not found.']); + }; + function paint() { const wanSel = E( 'select', @@ -195,146 +243,237 @@ export function interfacesCard(serverId: string, title = 'Interfaces'): HTMLElem .map((x) => E('option', { value: x.name, selected: x.name === wanDev ? 'selected' : null }, `${x.name} · zone ${x.zone}`)), ) as HTMLSelectElement; - // What auto-detection finds now; the remembered one (used when nothing is found) only when it differs. - const hint = (live: string | null, saved: string) => { - const mono = (t: string) => E('span', { class: 'dl-mono' }, t); - if (live) return E('span', {}, [' Now: ', mono(live), ...(saved && saved !== live ? [', was ', mono(saved)] : []), '.']); - return E('span', {}, saved ? [' Not found now: using ', mono(saved), '.'] : [' Not found.']); - }; - - const groups = GROUPS.map(([cat, label]) => { - const list = d.devices.filter((x) => x.category === cat); - return list.length ? E('div', { class: 'dl-ifgroup' }, [E('h4', {}, label), E('div', { class: 'dl-ifgrid' }, list.map(tile))]) : ''; - }); - const home = homeDevs(); const nets = home.flatMap((x) => x.nets.map((n) => [n, x.name] as const)); - const dirty = snapshot() !== initial; - const save = button( - 'Save', - async () => { - const r = await attempt( - () => api.serverInterfaces(serverId, autoWan, autoWan ? '' : wanDev, autoLan, [...lans], lanLike, mesh), - 'Interfaces saved', - ); - if (!r) return; - take(r, true); - if (r.nets_changed && r.lan_only) - notify( - `${r.lan_only} ${r.lan_only === 1 ? 'person has' : 'people have'} Home-only access: their devices need the configuration again to reach the new networks.`, - 'warning', - 10000, + // Draft vs saved, per card: [lanLike, autoWan, wan, autoLan, lans]. + const now = JSON.parse(snapshot()) as unknown[]; + const was = JSON.parse(initial) as unknown[]; + const changed = (...i: number[]) => i.some((k) => JSON.stringify(now[k]) !== JSON.stringify(was[k])); + const netDirty = changed(0, 1, 2); + const homeDirty = changed(3, 4); + const save = (on: boolean) => + button( + 'Save', + async () => { + const r = await attempt( + () => api.serverInterfaces(serverId, autoWan, autoWan ? '' : wanDev, autoLan, [...lans], lanLike, mesh !== 'off', mesh), + 'Access saved', ); - }, - 'positive', - { disabled: !dirty }, - ); + if (!r) return; + take(r, true); + if (r.nets_changed && r.lan_only) + notify( + `${r.lan_only} ${r.lan_only === 1 ? 'person has' : 'people have'} Home-only access: their devices need the configuration again to reach the new networks.`, + 'warning', + 10000, + ); + }, + 'positive', + { disabled: !on }, + ); - dom.content(root, [ + const internet = E('section', { class: 'dl-setsec dl-ifcard' }, [ E('div', { class: 'dl-setsec-body' }, [ E('div', { class: 'dl-panel-head' }, [ - E('h3', {}, title), + E('h3', {}, 'Internet'), E('span', { class: 'dl-spacer' }), - button([icon('reset'), ' Rescan'], () => load(false), 'neutral', { title: 'Read the interfaces again' }), + E('span', { class: 'dl-sub' }, 'People with Internet or Both'), ]), - E('div', { class: 'dl-setrow' }, [ - E('div', { class: 'dl-lh-main' }, [ - E('span', { class: `dl-need-ic ${likeHomeTone()}` }, icon('home')), - E('div', { class: 'dl-stack' }, [ - E('span', { class: 'dl-setrow-label' }, 'Internet like a home device'), - E('span', { class: 'dl-sub' }, likeHomeText()), - ]), - ]), - E('div', { class: 'dl-setrow-ctl dl-if-wanctl' }, [ + setrow( + 'home', + 'Internet like a home device', + likeHomeText(), + [ lanLike && d.needs?.length ? button('Install', () => installMissing('home', d.needs!, () => load(false)), 'positive') : '', sw(lanLike, 'Internet like a home device', (v) => { lanLike = v; paint(); }), - ]), - ]), - E('div', { class: 'dl-setrow' }, [ - E('div', { class: 'dl-lh-main' }, [ - E('span', { class: 'dl-need-ic' }, icon('link')), - E('div', { class: 'dl-stack' }, [ - E('span', { class: 'dl-setrow-label' }, 'Devices reach each other'), - E( - 'span', - { class: 'dl-sub' }, - 'Devices of people with Home access can open connections to each other on this server, like home devices do. Internet-only people never.', - ), - ]), - ]), - E( - 'div', - { class: 'dl-setrow-ctl' }, - sw(mesh, 'Devices reach each other', (v) => { - mesh = v; - paint(); - }), - ), - ]), - E('div', { class: 'dl-setrow' }, [ - E('div', { class: 'dl-lh-main' }, [ - E('span', { class: 'dl-need-ic' }, icon('globe')), - E('div', { class: 'dl-stack' }, [ - E('span', { class: 'dl-setrow-label' }, 'Auto-detect WAN'), - E('span', { class: 'dl-sub' }, [ - 'The interface with the default route: the server port opens there and Internet access leaves through it.', - hint(d.detected.wan, d.saved.wan), - ]), - ]), - ]), - E('div', { class: 'dl-setrow-ctl dl-if-wanctl' }, [ + ], + likeHomeTone(), + ), + setrow( + 'globe', + 'Auto-detect WAN', + [ + 'The interface with the default route: the server port opens there and Internet access leaves through it.', + hint(d.detected.wan, d.saved.wan), + ], + [ autoWan ? '' : wanSel, sw(autoWan, 'Auto-detect WAN', (v) => { autoWan = v; paint(); }), - ]), + ], + ), + ]), + E('div', { class: 'dl-setsec-foot' }, [ + E( + 'span', + { class: 'dl-sub' }, + lanLike + ? ['Internet like a home device', currentWan() ? [' · leaves through ', E('span', { class: 'dl-mono' }, currentWan())] : ''] + : currentWan() + ? ['Internet straight to ', E('span', { class: 'dl-mono' }, currentWan())] + : 'No WAN found', + ), + save(netDirty), + ]), + ]); + + const meshSeg = E( + 'div', + { class: 'dl-seg sm', role: 'radiogroup', 'aria-label': 'Devices reach each other' }, + ( + [ + ['off', 'Off'], + ['all', 'Everyone'], + ['circles', 'Circles'], + ] as const + ).map(([v, t]) => + E( + 'button', + { + type: 'button', + role: 'radio', + class: mesh === v ? 'on' : '', + 'aria-checked': mesh === v ? 'true' : 'false', + // Applies at once, like the choices on a person's page. + click: async () => { + if (mesh === v) return; + if (await attempt(() => api.serverUpdate(serverId, { mesh: v }), `Devices reach each other: ${t}`)) reload(); + }, + }, + t, + ), + ), + ); + + const homeCard = 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'), + button([icon('reset'), ' Rescan'], () => load(false), 'neutral', { title: 'Read the interfaces again' }), ]), - E('div', { class: 'dl-setrow' }, [ - E('div', { class: 'dl-lh-main' }, [ - E('span', { class: 'dl-need-ic' }, icon('network')), - E('div', { class: 'dl-stack' }, [ - E('span', { class: 'dl-setrow-label' }, 'Auto-detect LAN'), - E('span', { class: 'dl-sub' }, ['Adds the detected LAN to the home network.', hint(d.detected.lan, d.saved.lan)]), - ]), - ]), - E( - 'div', - { class: 'dl-setrow-ctl' }, - sw(autoLan, 'Auto-detect LAN', (v) => { - autoLan = v; - paint(); - }), - ), - ]), - E('div', { class: 'dl-iflead' }, [ - E('b', {}, 'Home network'), - E( - 'span', - { class: 'dl-sub' }, - 'What people with Home access can reach, and where their devices can be reached from. Click to add an interface; bridge ports and Wi-Fi in a bridge come with the bridge.', - ), - ]), - ...groups, + setrow( + '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.', + '', + '', + netPicker(), + ), + setrow( + 'link', + 'Devices reach each other', + MESH_TEXT[mesh], + meshSeg, + '', + mesh === 'circles' ? circleChips(st, serverId, reload) : undefined, + ), + bonjourRow(), + services, ]), E('div', { class: 'dl-setsec-foot' }, [ E( 'span', { class: 'dl-sub dl-if-summary' }, nets.length - ? [ - 'Home access reaches ', - ...nets.flatMap(([n, dev], i) => [i ? ', ' : '', E('span', { class: 'dl-mono' }, n), ` (${dev})`]), - lanLike ? ' · Internet like a home device' : currentWan() ? ` · Internet via ${currentWan()}` : '', - ] - : ['No home network: Home access reaches nothing but this router.', currentWan() ? ` Internet via ${currentWan()}.` : ''], + ? ['Home access reaches ', ...nets.flatMap(([n, dev], i) => [i ? ', ' : '', E('span', { class: 'dl-mono' }, n), ` (${dev})`])] + : 'No home network: Home access reaches nothing but this router.', ), - save, + save(homeDirty), ]), ]); + + // Keep the page where it is: replacing the cards would otherwise jump to the top. + const y = window.scrollY; + root.style.minHeight = `${root.offsetHeight}px`; + dom.content(root, [internet, homeCard]); + root.style.minHeight = ''; + window.scrollTo({ top: y }); + } + + /** Find home devices: AirPlay, printers and shared Macs listed on Apple devices over the tunnel. */ + function bonjourRow(): HTMLElement { + const b = d.bonjour; + const set = async (on: boolean) => { + if (await attempt(() => api.serverUpdate(serverId, { bonjour: on }), on ? 'Finding home devices' : 'Home devices no longer listed')) + load(false); + }; + const state = b.needs.length + ? E('span', { class: 'dl-warn' }, ` Needs ${b.needs.join(', ')}.`) + : b.on && !b.running + ? E('span', { class: 'dl-warn' }, ' umdns is not running.') + : b.on + ? ` Listing ${b.services} service${b.services === 1 ? '' : 's'} from home now.` + : ''; + return setrow( + 'wifi', + ['Find home devices ', E('span', { class: 'dl-faint dl-w400' }, '· Bonjour')], + [ + 'iPhone, iPad and Mac on the VPN see AirPlay, printers and shared Macs at home, as on Wi-Fi. Android and Chromecast look only on the local network.', + state, + ], + b.needs.length + ? button('Install', () => installMissing('bonjour', b.needs, () => load(false)), 'positive') + : sw(b.on, 'Find home devices', (v) => set(v)), + b.on && b.running ? 'ok' : '', + ); + } + + /** Interfaces that can be home networks as tiles; the rest folded, by kind. */ + function netPicker(): HTMLElement { + const avail = d.devices.filter(pickable); + const rest = d.devices.filter((x) => !pickable(x)); + return E('div', { class: 'dl-stack gap8 dl-netpick' }, [ + avail.length + ? E('div', { class: 'dl-ifgrid' }, avail.map(tile)) + : 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.', hint(d.detected.lan, d.saved.lan)]), + ]), + sw(autoLan, 'Auto-detect LAN', (v) => { + autoLan = v; + paint(); + }), + ]), + rest.length + ? E( + 'details', + { + class: 'dl-params', + open: otherOpen ? '' : null, + toggle: (ev: Event) => (otherOpen = (ev.currentTarget as HTMLDetailsElement).open), + }, + [ + E('summary', {}, [ + icon('chevron'), + E('span', {}, 'Other interfaces'), + E('span', { class: 'dl-pcount' }, String(rest.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.', + ), + ...GROUPS.map(([cat, label]) => { + const list = rest.filter((x) => x.category === cat); + return list.length + ? E('div', { class: 'dl-ifgroup' }, [E('h4', {}, label), E('div', { class: 'dl-ifgrid' }, list.map(tile))]) + : ''; + }), + ]), + ], + ) + : '', + ]); } load(true); diff --git a/web/src/admin/pages/overview.ts b/web/src/admin/pages/overview.ts index dffb094..2efacca 100644 --- a/web/src/admin/pages/overview.ts +++ b/web/src/admin/pages/overview.ts @@ -73,6 +73,11 @@ export function eventText(st: Status, e: LogEvent): Node[] { const b = (t: string) => E('b', {}, t); const m = (t: string) => E('span', { class: 'dl-muted' }, t); const mono = (t: string) => E('span', { class: 'dl-mono' }, t); + /** An address; at home, the name of the device that has it, with the address in brackets. */ + const addr = (ip: string) => + e.hosts?.[ip] + ? [E('span', { class: 'dl-ev-host' }, [E('b', {}, e.hosts[ip]), E('span', { class: 'dl-faint' }, ` (${ip})`)])] + : [mono(ip)]; // What the bold name is (a person, a device), said before it in grey. const kind = (t: string) => E('span', { class: 'dl-ev-kind' }, `${t} `); const wd = dev ? `${who} · ${dev}` : who; @@ -116,13 +121,18 @@ export function eventText(st: Status, e: LogEvent): Node[] { kind('Device'), b(wd), m(' connected'), - ...(e.detail ? [m(' from '), mono(e.detail)] : []), + ...(e.detail ? [m(' from '), ...addr(e.detail)] : []), ...(e.where ? [m(` · ${e.where}`)] : []), ]; case 'disconnect': return [kind('Device'), b(wd), m(' went offline')]; case 'roam': - return [kind('Device'), b(wd), m(' changed network '), mono(e.detail ?? '')]; + return [ + kind('Device'), + b(wd), + m(' changed network '), + ...(e.detail ?? '').split(' → ').flatMap((ip, i) => (i ? [m(' → '), ...addr(ip)] : addr(ip))), + ]; case 'device_added': return [ kind('Person'), diff --git a/web/src/admin/pages/person.ts b/web/src/admin/pages/person.ts index e958c6a..e77049c 100644 --- a/web/src/admin/pages/person.ts +++ b/web/src/admin/pages/person.ts @@ -29,6 +29,7 @@ import { attachTip } from '../charts'; import { peopleUrl } from '../urls'; import { daysTile, eventRow, eventText, speedTile } from './overview'; import { stateBadge } from './people'; +import { circleDialog, circleDot, homeAccess } from '../access'; type Step = 'day' | 'week' | 'month' | 'year' | 'custom'; @@ -657,9 +658,10 @@ export class PersonPage { seg, E('span', { class: 'dl-sub' }, ACCESS_TEXT[p.access]), p.access === 'lan' && this.st.services.length ? this.servicesPicker() : '', + homeAccess(p) ? this.netsPicker() : '', p.access === 'lan' ? this.dnsPicker() : '', ]), - E('div', { class: 'dl-tiles2' }, [this.devTile(), endTile, dataTile, hoursTile]), + E('div', { class: 'dl-tiles2' }, [this.devTile(), this.circleTile(), endTile, dataTile, hoursTile]), ]), ]), ); @@ -720,6 +722,87 @@ export class PersonPage { ]); } + /** Home networks this person reaches, when the server has more than one. */ + netsPicker(): HTMLElement | '' { + const p = this.p; + const srv = this.st.servers.find((x) => x.id === p.server); + const all = srv?.home ?? []; + if (all.length < 2) return ''; + const picked = new Set(p.home_nets?.length ? p.home_nets : all.map((h) => h.dev)); + return E('div', { class: 'dl-stack gap4' }, [ + E( + 'div', + { class: 'dl-chips-row' }, + all.map((h) => + E( + 'button', + { + type: 'button', + class: `dl-chipbtn${picked.has(h.dev) ? ' on' : ''}`, + 'aria-pressed': picked.has(h.dev) ? 'true' : 'false', + title: h.nets.join(', '), + click: () => { + const next = new Set(picked); + if (!next.delete(h.dev)) next.add(h.dev); + if (!next.size) return notify('Keep at least one network, or choose Internet only.', 'warning', 5000); + const list = next.size === all.length ? [] : [...next]; + this.patch( + { home_nets: list }, + list.length ? `${p.name} reaches ${list.join(', ')}` : `${p.name} reaches every home network`, + ); + }, + }, + h.dev, + ), + ), + ), + E( + 'span', + { class: 'dl-sub' }, + p.home_nets?.length + ? `Home networks ${p.name} reaches. Networks added to the server later stay out.` + : `Home networks ${p.name} reaches: all of them. Untick one to keep ${p.name} out of it.`, + ), + ]); + } + + /** The circle this person's devices share (servers where devices reach each other in circles). */ + circleTile(): HTMLElement | '' { + const p = this.p; + const srv = this.st.servers.find((x) => x.id === p.server); + if (srv?.mesh !== 'circles' || !homeAccess(p)) return ''; + const circles = this.st.circles.filter((c) => c.server === p.server); + const ci = circles.find((c) => c.id === p.circle); + const mates = ci ? this.st.people.filter((x) => x.id !== p.id && x.circle === ci.id && homeAccess(x)).map((x) => x.name) : []; + const change: HTMLElement = button('Change', () => + dropdown(change, [ + ...circles.map((c) => ({ + label: c.name, + icon: circleDot(c), + run: () => c.id !== p.circle && this.patch({ circle: c.id }, `${p.name} is in ${c.name}`), + })), + p.circle ? { label: 'No circle', icon: icon('x'), run: () => this.patch({ circle: '' }, `${p.name} is in no circle`) } : null, + { label: 'New circle', icon: icon('plus'), run: () => circleDialog(this.st, p.server, null, () => this.refresh()) }, + ]), + ); + return E('div', { class: 'dl-tile2' }, [ + E('span', { class: 'dl-tile2-label' }, ['Devices see each other', E('span', { class: 'dl-faint dl-w400' }, 'circle')]), + E('div', { class: 'dl-tile2-row' }, [ + E('span', { class: 'dl-circle-name' }, ci ? [circleDot(ci), ci.name] : E('span', { class: 'dl-muted' }, 'No circle')), + change, + ]), + E( + 'span', + { class: 'dl-sub' }, + !ci + ? `Only ${p.name}'s own devices see each other.` + : mates.length + ? `${p.name}'s devices and ${mates.join(', ')}'s see each other. Others don't.` + : `Nobody else in ${ci.name} yet: only ${p.name}'s own devices see each other.`, + ), + ]); + } + /** Optional narrowing of home-network access to selected services. */ servicesPicker(): HTMLElement { const chosen = new Set(this.p.services ?? []); diff --git a/web/src/admin/pages/server.ts b/web/src/admin/pages/server.ts index 9394cd0..47b3574 100644 --- a/web/src/admin/pages/server.ts +++ b/web/src/admin/pages/server.ts @@ -9,7 +9,8 @@ import { api, type SetupDefaults } from '../api'; import { attempt, button, callout, closeModal, confirmDialog, copyText, modal, notify } from '../ui'; import { icon } from '../../shared/icons'; import { duration } from '../../shared/format'; -import { interfacesCard } from '../interfaces'; +import { accessCards } from '../interfaces'; +import { checkAccess, whoReaches } from '../access'; import { card, group, input, row, sw } from '../kit'; import { methodInfo, methodPicker, type Method } from '../disguise'; import { ServerOverview } from './overview'; @@ -426,48 +427,12 @@ export class ServerPage { ); } - /** Where devices may go and how their traffic leaves: internet path, WAN, home network, services. */ + /** Where devices may go and how their traffic leaves: internet path, home network, services, circles. */ access(srv: Server): HTMLElement { - const svcs = this.st.services; + const reload = () => this.refresh(); return E('div', { class: 'dl-stack gap16' }, [ - interfacesCard(srv.id, 'Access'), - card( - 'Home services', - [ - E( - 'p', - { class: 'dl-muted' }, - 'People with Home-only access can be limited to these services instead of the whole home network (chosen per person). The list is shared by all servers.', - ), - E( - 'div', - { class: 'dl-list' }, - svcs.length - ? svcs.map((sv) => - E('div', { class: 'dl-row' }, [ - icon('home'), - E('span', { class: 'dl-row-main dl-stack' }, [ - E('b', {}, sv.name), - E( - 'span', - { class: 'dl-mono dl-faint' }, - `${sv.address}${sv.ports.length ? ` · ports ${sv.ports.join(', ')}` : ' · all ports'}`, - ), - ]), - ]), - ) - : [E('div', { class: 'dl-row dl-muted' }, 'No services yet.')], - ), - ], - [ - E('span'), - E( - 'a', - { class: 'cbi-button cbi-button-neutral', href: `${L.url('admin/network/dawnline/settings')}#dl-set-services` }, - 'Edit in Settings', - ), - ], - ), + accessCards(srv, this.st, reload), + E('div', { class: 'dl-health-cols' }, [whoReaches(this.st, srv), checkAccess(this.st, srv)]), ]); } diff --git a/web/src/admin/pages/settings.ts b/web/src/admin/pages/settings.ts index f0f5ef6..e7a4816 100644 --- a/web/src/admin/pages/settings.ts +++ b/web/src/admin/pages/settings.ts @@ -2,7 +2,7 @@ import { E } from '../e'; import { api, type Backup, type SettingsData } from '../api'; -import { attempt, button, closeModal, confirmDialog, modal } from '../ui'; +import { attempt, button, closeModal, modal } from '../ui'; import { icon } from '../../shared/icons'; import { group, input, isOn, row, sw } from '../kit'; import { CATEGORIES, CATEGORY_HELP, CATEGORY_LABEL, clearLogDialog, exportEvents, resetUsageDialog } from '../logs'; @@ -525,43 +525,6 @@ export class SettingsPage { const logs = this.logsSection(); - // Home services - const svcRows = this.d.services.map((sv) => - E('div', { class: 'dl-row' }, [ - icon('home'), - E('span', { class: 'dl-row-main dl-stack' }, [ - E('b', {}, sv.name), - E('span', { class: 'dl-mono dl-faint' }, `${sv.address}${sv.ports.length ? ` · ports ${sv.ports.join(', ')}` : ' · all ports'}`), - ]), - button('Edit', () => this.editService(sv)), - button( - [icon('trash')], - async () => { - if ( - (await confirmDialog(`Remove ${sv.name}?`, 'People limited to this service lose access to it.', 'Remove', true)) && - (await attempt(() => api.serviceDelete(sv.id), 'Removed')) - ) - this.reload(); - }, - 'negative', - { title: 'Remove' }, - ), - ]), - ); - const services = this.section( - 'services', - 'Home services', - [ - E( - 'p', - { class: 'dl-muted' }, - 'Give people with home-network access only specific services instead of the whole network (choose them per person).', - ), - E('div', { class: 'dl-list' }, svcRows.length ? svcRows : [E('div', { class: 'dl-row dl-muted' }, 'No services yet.')]), - ], - [E('span'), button([icon('plus'), ' Add service'], () => this.editService(null), 'add')], - ); - const danger = this.section( 'danger', 'Remove Dawnline from this router', @@ -580,7 +543,7 @@ export class SettingsPage { this.reload(); this.loadBackups(); }); - dom.content(this.root, [portal, defaults, map, logs, services, backups, danger]); + dom.content(this.root, [portal, defaults, map, logs, backups, danger]); } logsSection(): HTMLElement { @@ -771,41 +734,6 @@ export class SettingsPage { } } - editService(sv: SettingsData['services'][number] | null) { - const name = input(sv?.name ?? '', { placeholder: 'NAS' }); - const addr = input(sv?.address ?? '', { placeholder: '192.168.1.10' }); - const ports = input(sv?.ports.join(', ') ?? '', { placeholder: 'All ports, or e.g. 445, 5000' }); - modal( - sv ? `Edit ${sv.name}` : 'Add service', - [ - E('div', { class: 'cbi-value' }, [E('label', { class: 'cbi-value-title' }, 'Name'), E('div', { class: 'cbi-value-field' }, name)]), - E('div', { class: 'cbi-value' }, [ - E('label', { class: 'cbi-value-title' }, 'Address'), - E('div', { class: 'cbi-value-field' }, addr), - ]), - E('div', { class: 'cbi-value' }, [ - E('label', { class: 'cbi-value-title' }, 'Ports'), - E('div', { class: 'cbi-value-field' }, ports), - ]), - ], - [ - E('button', { class: 'cbi-button cbi-button-neutral', click: closeModal }, 'Cancel'), - ' ', - button( - 'Save', - async () => { - const list = ports.value.split(/[ ,]+/).filter(Boolean); - if (await attempt(() => api.serviceSet(sv?.id ?? '', name.value, addr.value, list), 'Saved')) { - closeModal(); - this.reload(); - } - }, - 'positive', - ), - ], - ); - } - uninstall() { const confirmInput = input('', { placeholder: 'remove' }); modal( diff --git a/web/src/admin/pkgs.ts b/web/src/admin/pkgs.ts index aeebea9..9891edb 100644 --- a/web/src/admin/pkgs.ts +++ b/web/src/admin/pkgs.ts @@ -4,7 +4,12 @@ import { api, type Needs } from './api'; import { attempt, confirmDialog, notify } from './ui'; -const WHAT: Record = { https: 'HTTPS for the portal', acme: 'ACME certificates', home: 'the home-like link' }; +const WHAT: Record = { + https: 'HTTPS for the portal', + acme: 'ACME certificates', + home: 'the home-like link', + bonjour: 'Bonjour for home devices', +}; const WAIT_MS = 5 * 60 * 1000; /** Install `names` for `feature`; resolves true when the job finished, then calls `done`. */ diff --git a/web/src/admin/styles.ts b/web/src/admin/styles.ts index 81a799d..1a72fe7 100644 --- a/web/src/admin/styles.ts +++ b/web/src/admin/styles.ts @@ -1072,6 +1072,46 @@ const CSS = ` .dl-upd-row > .dl-pill, .dl-upd-row > button, .dl-upd-head > .dl-pill, .dl-upd-head > button { flex: none; } .dl-upd-bad { color: var(--dl-bad); } .dl-upd-job > .dl-log, .dl-upd-job > .alert-message { margin: 0 14px 14px; } + +/* Server → Access: networks as chips, circles, services from home, who reaches what, check access. */ +.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); } `; /** A