!function(){"use strict";var e,t,n,o;o={_whatToTrace:[function(e,t){return`groupBy=substr(${e},1)`},function(e,t){return`${e}=${t}*&groupBy=${e}`},function(e,t){return`${e}=${t}`}],ipAddr:[function(e,t){return`groupBy=net(${e},16,1)`},function(e,t){return t.match(/:/)||(t+="."),`${e}=${t}*&groupBy=net(${e},32,2)`},function(e,t){return t.match(/:/)||(t+="."),`${e}=${t}*&groupBy=net(${e},48,3)`},function(e,t){return t.match(/:/)||(t+="."),`${e}=${t}*&groupBy=net(${e},128,4)`},function(e,t){return`${e}=${t}&groupBy=_whatToTrace`},function(e,t,n){return n.replace(/\&groupBy.*$/,"")+`&_whatToTrace=${t}`}],_startTime:[function(e,t){return`groupBy=substr(${e},8)`},function(e,t){return`${e}=${t}*&groupBy=substr(${e},10)`},function(e,t){return`${e}=${t}*&groupBy=substr(${e},11)`},function(e,t){return`${e}=${t}*&groupBy=substr(${e},12)`},function(e,t){return`${e}=${t}*&groupBy=_whatToTrace`},function(e,t,n){return n.replace(/\&groupBy.*$/,"")+`&_whatToTrace=${t}`}],doubleIp:[function(e,t){return e},function(e,t){return`_whatToTrace=${t}&groupBy=ipAddr`},function(e,t,n){return n.replace(/\&groupBy.*$/,"")+`&ipAddr=${t}`}],_session_uid:[function(e,t){return`groupBy=substr(${e},1)`},function(e,t){return`${e}=${t}*&groupBy=${e}`},function(e,t){return`${e}=${t}`}]},n={_whatToTrace:function(e,t,n,o){return console.debug("overScheme => level",n,"over",o),t.length>=n+o?null:1===n&&t.length>o?`${e}=${t}*&groupBy=substr(${e},${n+o+1})`:null},ipAddr:function(e,t,n,o){return console.debug("overScheme => level",n,"over",o),n>0&&n<4&&!t.match(/^\d+\.\d/)&&o<2?`${e}=${t}*&groupBy=net(${e},${16*n+4*(o+1)},${1+n+o})`:null},_startTime:function(e,t,n,o){return console.debug("overScheme => level",n,"over",o),n>3?`${e}=${t}*&groupBy=substr(${e},${10+n+o})`:null},_session_uid:function(e,t,n,o){return console.debug("overScheme => level",n,"over",o),1===n&&t.length>o?`${e}=${t}*&groupBy=substr(${e},${n+o+1})`:null}},e={dateTitle:["_utime","_startTime","_updateTime","_lastAuthnUTime","_lastSeen"],connectionTitle:["ipAddr","_timezone","_url"],authenticationTitle:["_session_id","_user","_password","authenticationLevel"],modulesTitle:["_auth","_userDB","_passwordDB","_issuerDB","_authChoice","_authMulti","_userDBMulti","_2f"],saml:["_idp","_idpConfKey","_samlToken","_lassoSessionDump","_lassoIdentityDump"],groups:["groups","hGroups"],ldap:["dn"],OpenIDConnect:["_oidc_id_token","_oidc_OP","_oidc_access_token","_oidc_refresh_token","_oidc_access_token_eol","_oidcConnectedRP","_oidcConnectedRPIDs"],sfaTitle:["_2fDevices"],oidcConsents:["_oidcConsents"]},t={session:[{title:"deleteSession",icon:"trash"},{title:"globalLogout",icon:"trash"}],home:[]},angular.module("llngSessionsExplorer",["ui.tree","ui.bootstrap","llApp"]).controller("SessionsExplorerCtrl",["$scope","$translator","$location","$q","$http",function(r,i,s,u,l){var a,c,p,d;return r.links=links,r.menulinks=menulinks,r.staticPrefix=staticPrefix,r.scriptname=scriptname,r.formPrefix=formPrefix,r.impPrefix=impPrefix,r.sessionTTL=sessionTTL,r.availableLanguages=availableLanguages,r.waiting=!0,r.showM=!1,r.showT=!0,r.data=[],r.currentScope=null,r.currentSession=null,r.menu=t,r.translateP=i.translateP,r.translate=i.translate,r.translateTitle=function(e){return i.translateField(e,"title")},d="global",r.menuClick=function(e){if(e.popup)window.open(e.popup);else switch(e.action||(e.action=e.title),typeof e.action){case"function":e.action(r.currentNode,r);break;case"string":r[e.action]();break;default:console.warn("Unknown action type",typeof e.action)}return r.showM=!1},r.deleteOIDCConsent=function(e,t){var n;return n=document.querySelectorAll(`.data-${t}`),r.waiting=!0,l.delete(`${scriptname}sessions/OIDCConsent/${d}/${r.currentSession.id}?rp=${e}&epoch=${t}`).then(function(e){var t,o,i,s;for(r.waiting=!1,s=[],o=0,i=n.length;o<i;o++)t=n[o],s.push(t.remove());return s},function(e){return r.waiting=!1}),r.showT=!1},r.deleteSession=function(){return r.waiting=!0,l.delete(`${scriptname}sessions/${d}/${r.currentSession.id}`).then(function(e){return r.currentSession=null,r.currentScope.remove(),r.waiting=!1},function(e){return r.waiting=!1})},r.globalLogout=function(){return r.waiting=!0,l.post(`${scriptname}sessions/glogout/${d}/${r.currentSession.id}`).then(function(e){return r.currentSession=null,r.currentScope.remove(),r.waiting=!1},function(e){return r.waiting=!1})},r.stoggle=function(e){var t;return 0===(t=e.$modelValue).nodes.length&&r.updateTree(t.value,t.nodes,t.level,t.over,t.query,t.count),e.toggle()},r.displaySession=function(t){var n,o;return o=function(t){var n,o,i,s,u,l,a,c,p,d,$,f,g,h,_,m,y,T,v,w,S,b,B,D,L,P,C,A,k,x,R,I,E,H,M,O;for(f in n=function(e,n){var o,i,s,u,l,a,c,p,d;for(s in c=[],l=new RegExp(e),o="",t)p=t[s],s.match(l)&&p&&(o+=`${p}:${s},`,delete t[s]);if(o){for((a=(o=o.replace(/,$/,"")).split(",")).sort(),a.reverse(),i=0,u=a.length;i<u;i++)d=a[i].split(":"),c.push({title:d[1],value:r.localeDate(d[0])});return A.push({title:n,nodes:c})}},E=t._utime,t)(O=t[f])?("string"==typeof t&&O.match(/; /)&&(t[f]=O.split("; ")),"object"!=typeof t[f]&&("_password".match(new RegExp("\b"+f+"\b"))?t[f]="********":f.match(/^(_utime|_lastAuthnUTime|_lastSeen|notification)$/)?t[f]=r.localeDate(O):f.match(/^(_startTime|_updateTime)$/)&&(t[f]=r.strToLocaleDate(O)))):delete t[f];for(u in A=[],e){for(R=[],p=0,h=(s=e[u]).length;p<h;p++)if(i=s[p],t[i])if("_2fDevices"===i&&t[i]){if((o=JSON.parse(t[i])).length>0)for(R.push({title:"type",value:"name",epoch:"date",td:"0"}),d=0,_=o.length;d<_;d++){for(f in k=o[d])O=k[f],"type"===f&&(H=O),"name"===f&&(S=O),"epoch"===f&&(c=O);R.push({title:H,value:S,epoch:c,td:"1"})}delete t[i]}else if(t[i].toString().match(/"rp":\s*"[\w-]+"/)){for(R.push({title:"RP",value:"scope",epoch:"date",td:"0"}),$=0,m=(o=JSON.parse(t[i])).length;$<m;$++){for(f in B=o[$])O=B[f],"rp"===f&&(H=O),"scope"===f&&(S=O),"epoch"===f&&(c=O);R.push({title:H,value:S,epoch:c,td:"2"})}delete t[i]}else t[i].toString().match(/\w+/)?(R.push({title:i,value:t[i],epoch:""}),delete t[i]):delete t[i];else delete t[i];R.length>0&&A.push({title:`__${u}__`,nodes:R})}if(n("^openid","OpenID"),n("^notification_(.+)","__notificationsDone__"),t._loginHistory){if(M=[],t._loginHistory.successLogin)for(w=0,y=(P=t._loginHistory.successLogin).length;w<y;w++){for(f in l="",g=P[w])O=g[f],f.match(/^(_utime|ipAddr|error)$/)||(l+=`, ${f} : ${O}`);(I=l.split(", ")).sort(),l=I.join(", "),M.push({t:g._utime,title:r.localeDate(g._utime),value:`Success (IP ${g.ipAddr})`+l})}if(t._loginHistory.failedLogin)for(b=0,T=(C=t._loginHistory.failedLogin).length;b<T;b++){for(f in l="",g=C[b])O=g[f],f.match(/^(_utime|ipAddr|error)$/)||(l+=`, ${f} : ${O}`);(I=l.split(", ")).sort(),l=I.join(", "),M.push({t:g._utime,title:r.localeDate(g._utime),value:`Error ${g.error} (IP ${g.ipAddr})`+l})}delete t._loginHistory,M.sort(function(e,t){return t.t-e.t}),A.push({title:"__loginHistory__",nodes:M})}for(f in M=[],t)O=t[f],M.push({title:f,value:O});for(M.sort(function(e,t){return e.title>t.title?1:e.title<t.title?-1:0}),L=[],x=[],D=0,v=M.length;D<v;D++)(a=M[D]).title.match(new RegExp("^"+r.impPrefix+".+$"))?(console.debug(a,"-> real attribute"),L.push(a)):x.push(a);return M=x.concat(L),A.push({title:"__attributesAndMacros__",nodes:M}),{_utime:E,nodes:A}},r.currentScope=t,n=t.$modelValue.session,l.get(`${scriptname}sessions/${d}/${n}`).then(function(e){return r.currentSession=o(e.data),r.currentSession.id=n}),r.showT=!1},r.localeDate=function(e){return new Date(1e3*e).toLocaleString()},r.isValid=function(e,t){var n,o,r;return r=s.path(),o=Date.now()/1e3,console.debug("Path",r),console.debug("Session epoch",e),console.debug("Current date",o),console.debug("Session TTL",sessionTTL),n=o-e<sessionTTL||s.path().match(/^\/persistent/),"msg"===t?(console.debug("Return msg"),n?"info":"warning"):"style"===t?(console.debug("Return style"),n?{}:{color:"#627990","font-style":"italic"}):(console.debug("Return isValid"),n)},r.strToLocaleDate=function(e){var t;return(t=e.match(/^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})$/)).length?new Date(`${t[1]}-${t[2]}-${t[3]}T${t[4]}:${t[5]}:${t[6]}`).toLocaleString():e},r.getLanguage=function(e){return r.lang=e,r.form="white",r.init(),r.showM=!1},p=function(e,t,n){var o;return o=t.match(/#!?\/(\w+)/),d="global",null===o?r.type="_whatToTrace":o[1].match(/^(persistent|offline)$/)?(d=RegExp.$1,r.type="_session_uid"):r.type=o[1],r.init()},r.$on("$locationChangeSuccess",p),a=0,r.updateTree=function(e,t,i,s,u,c){var p,$,f;if(r.waiting=!0,$=o[r.type]?o[r.type]:"_updateTime"===r.type?o._startTime:o._whatToTrace,p=$[i](r.type,e,u),c>25&&n[r.type]&&(f=n[r.type](r.type,e,i,s,u))?(s++,p=f,i-=1):s=0,l.get(`${scriptname}sessions/${d}?${p}`).then(function(n){var o,u,l;if((o=n.data).result){for(u=0;u<o.values.length;u++)l=o.values[u],a++,l.id=`node${a}`,i<$.length-1&&(l.nodes=[],l.level=i+1,l.query=p,l.over=s,r.type.match(/^(?:start|update)Time$/)&&(l.title=l.value.replace(/^(\d{8})(\d{2})(\d{2})$/,"$2:$3").replace(/^(\d{8})(\d{2})(\d)$/,"$2:$30").replace(/^(\d{8})(\d{2})$/,"$2h").replace(/^(\d{4})(\d{2})(\d{2})/,"$1-$2-$3"))),t.push(l);""===e&&(r.total=o.total)}return r.waiting=!1},function(e){return r.waiting=!1}),console.debug("Selection",d),r.navssoStyle={color:"#777"},r.offlineStyle={color:"#777"},r.persistentStyle={color:"#777"},"global"===d&&(r.navssoStyle={color:"#333"}),"offline"===d&&(r.offlineStyle={color:"#333"}),"persistent"===d)return r.persistentStyle={color:"#333"}},r.init=function(){return r.waiting=!0,r.data=[],r.currentScope=null,r.currentSession=null,u.all([i.init(r.lang),r.updateTree("",r.data,0,0)]).then(function(){return r.waiting=!1},function(e){return r.waiting=!1}),r.activeModule="sessions",r.myStyle={color:"#ffb84d"}},c=s.path().match(/^\/(\w+)/),r.type=c?c[1]:"_whatToTrace"}])}();